Files
agent-radar 2ed3415fb7
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
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

85 lines
2.6 KiB
Go

package agentruntime
import (
"errors"
"fmt"
"strings"
)
func classifyACPResumeError(session Session, method string, err error) error {
if err == nil {
return nil
}
var callErr *acpCallError
if !errors.As(err, &callErr) || callErr == nil {
return err
}
if !isACPProviderSessionNotFound(method, callErr) {
return err
}
return &AppError{
Code: AppErrorProviderSessionNotFound,
Message: "Agent provider session could not be restored.",
DebugMessage: fmt.Sprintf(
"ACP restore target missing: room_id=%s provider=%s agent_session_id=%s provider_session_id=%s method=%s acp_error=%s",
strings.TrimSpace(session.RoomID),
strings.TrimSpace(session.Provider),
strings.TrimSpace(session.AgentSessionID),
strings.TrimSpace(session.ProviderSessionID),
strings.TrimSpace(method),
acpErrorSummary(&callErr.Err),
),
Cause: err,
}
}
func unsupportedACPResumeError(session Session) error {
return resumeSessionNotLocalError(session, "reason=resume/load unsupported")
}
func missingProviderSessionResumeError(session Session) error {
return resumeSessionNotLocalError(session, "reason=provider_session_id missing")
}
func resumeSessionNotLocalError(session Session, reason string) error {
return &AppError{
Code: AppErrorResumeSessionNotLocal,
Message: "Agent provider session could not be restored.",
DebugMessage: fmt.Sprintf(
"ACP restore unavailable locally: room_id=%s provider=%s agent_session_id=%s provider_session_id=%s %s",
strings.TrimSpace(session.RoomID),
strings.TrimSpace(session.Provider),
strings.TrimSpace(session.AgentSessionID),
strings.TrimSpace(session.ProviderSessionID),
strings.TrimSpace(reason),
),
}
}
func isACPProviderSessionNotFound(method string, callErr *acpCallError) bool {
if callErr == nil {
return false
}
switch strings.TrimSpace(method) {
case acpMethodLoadSession, acpMethodResume, appServerMethodThreadResume:
default:
return false
}
message := strings.TrimSpace(callErr.Err.Message)
lower := strings.ToLower(message)
// Codex app server reports a missing rollout file (conversation imported from
// another device, rollout pruned by retention, ...) as -32600 "no rollout
// found for thread id …". JSON-RPC -32600 is the generic "invalid request"
// code, so key off the distinctive message rather than the code here.
if strings.Contains(lower, "no rollout found") {
return true
}
// Standard ACP session/load and session/resume report a vanished provider
// session as -32002 "Resource not found".
if callErr.Err.Code == -32002 {
return strings.EqualFold(message, "Resource not found") ||
strings.HasPrefix(lower, "resource not found:")
}
return false
}