Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
58 lines
1.5 KiB
Go
58 lines
1.5 KiB
Go
package agenthost
|
|
|
|
import (
|
|
"strings"
|
|
|
|
storesqlite "github.com/tutti-os/tutti/packages/agent/store-sqlite"
|
|
"github.com/tutti-os/tutti/packages/agent/store-sqlite/canonical"
|
|
)
|
|
|
|
const WorkspaceAgentSessionOriginImported = "WORKSPACE_AGENT_SESSION_ORIGIN_IMPORTED"
|
|
|
|
type ResumeMode string
|
|
|
|
const (
|
|
ResumeModeExisting ResumeMode = "existing"
|
|
ResumeModeRecreate ResumeMode = "recreate"
|
|
ResumeModeReject ResumeMode = "reject"
|
|
)
|
|
|
|
type ResumePolicy struct {
|
|
Mode ResumeMode
|
|
}
|
|
|
|
func runtimeSessionHasActiveTurn(session ProviderRuntimeSession) bool {
|
|
return session.TurnLifecycle != nil &&
|
|
session.TurnLifecycle.ActiveTurnID != nil &&
|
|
strings.TrimSpace(*session.TurnLifecycle.ActiveTurnID) != ""
|
|
}
|
|
|
|
func persistedRuntimeStatus(activeTurnID string) string {
|
|
if strings.TrimSpace(activeTurnID) != "" {
|
|
return "working"
|
|
}
|
|
return "ready"
|
|
}
|
|
|
|
func ResolveResumePolicy(session storesqlite.Session) ResumePolicy {
|
|
if strings.TrimSpace(session.Kind) == canonical.SessionKindChild {
|
|
return ResumePolicy{Mode: ResumeModeReject}
|
|
}
|
|
if strings.TrimSpace(session.Origin) != WorkspaceAgentSessionOriginImported {
|
|
return ResumePolicy{Mode: ResumeModeExisting}
|
|
}
|
|
if !ExternalImportResumeSupported(session.InternalRuntimeContext) {
|
|
return ResumePolicy{Mode: ResumeModeReject}
|
|
}
|
|
return ResumePolicy{Mode: ResumeModeRecreate}
|
|
}
|
|
|
|
func ExternalImportResumeSupported(runtimeContext map[string]any) bool {
|
|
value, exists := runtimeContext["externalImportResumeSupported"]
|
|
if !exists {
|
|
return true
|
|
}
|
|
supported, ok := value.(bool)
|
|
return ok && supported
|
|
}
|