@tutti-os/agent-gui 0.0.131 → 0.0.133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/agent-conversation/index.d.ts +4 -6
- package/dist/agent-conversation/index.js +3 -3
- package/dist/agent-env/index.d.ts +10 -27
- package/dist/agent-env/index.js +14 -290
- package/dist/agent-env/index.js.map +1 -1
- package/dist/agent-gui.d.ts +1090 -20
- package/dist/agent-gui.js +7 -7
- package/dist/agent-message-center/index.d.ts +42 -7
- package/dist/agent-message-center/index.js +2 -2
- package/dist/{agentConversationVM-BD0-gg6C.d.ts → agentConversationVM-DWEy7jzx.d.ts} +41 -2
- package/dist/{agentGuiNodeTypes-5TL1hyCN.d.ts → agentGuiNodeTypes-B57MfwVo.d.ts} +5 -22
- package/dist/agents.d.ts +1 -1
- package/dist/agents.js +1 -1
- package/dist/app/renderer/agentactivity.css +1 -0
- package/dist/app/renderer/assets/icons/@-lined.svg +1 -8
- package/dist/{chunk-2RSNLVOX.js → chunk-A6NSHCRP.js} +204 -47
- package/dist/chunk-A6NSHCRP.js.map +1 -0
- package/dist/chunk-FM42UN2J.js +462 -0
- package/dist/chunk-FM42UN2J.js.map +1 -0
- package/dist/{chunk-PQJXWXTS.js → chunk-GBBNYGL7.js} +2 -2
- package/dist/{chunk-GCQYN7BR.js → chunk-HCRROERX.js} +2 -2
- package/dist/{chunk-WVWSFGBU.js → chunk-IZ626FDO.js} +563 -444
- package/dist/chunk-IZ626FDO.js.map +1 -0
- package/dist/{chunk-YWHGCKMT.js → chunk-N62NVPHT.js} +7 -7
- package/dist/chunk-N62NVPHT.js.map +1 -0
- package/dist/{chunk-T2NICA5D.js → chunk-VS5BRBY6.js} +4 -1
- package/dist/chunk-VS5BRBY6.js.map +1 -0
- package/dist/{contribution-yc4CGJmy.d.ts → contribution-BbW-kkpi.d.ts} +52 -1
- package/dist/custom-mention.d.ts +4 -2
- package/dist/i18n/index.d.ts +11 -6
- package/dist/index.d.ts +7982 -33
- package/dist/index.js +7 -7
- package/dist/runtime-Dwf44VKc.d.ts +7 -0
- package/dist/{types-BicfRVrV.d.ts → types-BeAVr4of.d.ts} +3 -5
- package/dist/workbench/contribution.d.ts +1 -2
- package/dist/workbench/contribution.js +2 -2
- package/dist/workbench/index.d.ts +1 -2
- package/dist/workbench/index.js +2 -2
- package/dist/workspace-agent-generated-files.d.ts +12 -1
- package/package.json +15 -15
- package/dist/AgentGUI-DxypmD7b.d.ts +0 -1080
- package/dist/agentPlanPromptDispatch-C7cCMjve.d.ts +0 -37
- package/dist/chunk-2RSNLVOX.js.map +0 -1
- package/dist/chunk-T2NICA5D.js.map +0 -1
- package/dist/chunk-VMQNG2KI.js +0 -178
- package/dist/chunk-VMQNG2KI.js.map +0 -1
- package/dist/chunk-WVWSFGBU.js.map +0 -1
- package/dist/chunk-YWHGCKMT.js.map +0 -1
- package/dist/pastedTextKinds-D-XuInaS.d.ts +0 -4
- package/dist/runtime-BBNdWgDU.d.ts +0 -10
- package/dist/workspaceAgentActivityListTypes-DZfS_HgG.d.ts +0 -48
- /package/dist/{chunk-PQJXWXTS.js.map → chunk-GBBNYGL7.js.map} +0 -0
- /package/dist/{chunk-GCQYN7BR.js.map → chunk-HCRROERX.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../agents.ts"],"sourcesContent":["import type {\n AgentGUIAgent,\n AgentGUIAgentAvailabilityStatus,\n AgentGUIAgentTarget\n} from \"./types.ts\";\n\nexport function normalizeAgentGUIAgents(\n agents: readonly AgentGUIAgent[] | null | undefined\n): AgentGUIAgent[] {\n const normalized: AgentGUIAgent[] = [];\n const seenAgentTargetIds = new Set<string>();\n for (const agent of agents ?? []) {\n const agentTargetId = agent.agentTargetId.trim();\n const name = agent.name.trim();\n const iconUrl = agent.iconUrl.trim();\n const heroImageUrl = agent.heroImageUrl?.trim() ?? \"\";\n if (\n !agentTargetId ||\n !name ||\n !iconUrl ||\n seenAgentTargetIds.has(agentTargetId)\n ) {\n continue;\n }\n seenAgentTargetIds.add(agentTargetId);\n const ownerName = agent.owner?.name?.trim() ?? \"\";\n const ownerAvatarUrl = agent.owner?.avatarUrl?.trim() ?? \"\";\n const reason = agent.availability.reason?.trim() ?? \"\";\n normalized.push({\n agentTargetId,\n name,\n iconUrl,\n ...(heroImageUrl ? { heroImageUrl } : {}),\n ...(agent.description?.trim()\n ? { description: agent.description.trim() }\n : {}),\n ...(ownerName || ownerAvatarUrl\n ? {\n owner: {\n ...(ownerName ? { name: ownerName } : {}),\n ...(ownerAvatarUrl ? { avatarUrl: ownerAvatarUrl } : {})\n }\n }\n : {}),\n ...(agent.ownership === \"self\" || agent.ownership === \"shared\"\n ? { ownership: agent.ownership }\n : {}),\n availability: {\n status: normalizeAgentGUIAgentAvailabilityStatus(\n agent.availability.status\n ),\n ...(reason ? { reason } : {}),\n ...(agent.availability.pendingAction\n ? { pendingAction: agent.availability.pendingAction }\n : {})\n },\n provider: agent.provider,\n ...(agent.setupKind === \"target_runtime\"\n ? { setupKind: \"target_runtime\" as const }\n : {})\n });\n }\n return normalized;\n}\n\nexport function agentGUIAgentIsReady(agent: AgentGUIAgent): boolean {\n return agent.availability.status === \"ready\";\n}\n\nexport function resolveAgentGUISelectedDirectoryAgent(input: {\n agents: readonly AgentGUIAgent[];\n agentTargetId?: string | null;\n defaultAgentTargetId?: string | null;\n}): AgentGUIAgent | null {\n const explicitAgentTargetId =\n input.agentTargetId?.trim() || input.defaultAgentTargetId?.trim() || \"\";\n if (explicitAgentTargetId) {\n return (\n input.agents.find(\n (agent) => agent.agentTargetId === explicitAgentTargetId\n ) ?? null\n );\n }\n return (\n input.agents.find((agent) => agentGUIAgentIsReady(agent)) ??\n input.agents[0] ??\n null\n );\n}\n\n/** Package-internal bridge while the carried node is migrated to agent names. */\nexport function projectAgentGUIAgentsToInternalTargets(\n agents: readonly AgentGUIAgent[]\n): AgentGUIAgentTarget[] {\n return agents.map((agent) => ({\n targetId: agent.agentTargetId,\n agentTargetId: agent.agentTargetId,\n provider: agent.provider,\n ref: {\n kind: \"agent-directory\",\n provider: agent.provider,\n agentTargetId: agent.agentTargetId,\n ...(agent.setupKind ? { setupKind: agent.setupKind } : {})\n },\n label: agent.name,\n availability: agent.availability,\n ...(agent.description ? { description: agent.description } : {}),\n iconUrl: agent.iconUrl,\n ...(agent.heroImageUrl ? { heroImageUrl: agent.heroImageUrl } : {}),\n ...(agent.owner?.avatarUrl\n ? {\n badge: {\n iconUrl: agent.owner.avatarUrl,\n ...(agent.owner.name ? { label: agent.owner.name } : {})\n }\n }\n : {}),\n ...(agent.owner?.name ? { ownerLabel: agent.owner.name } : {}),\n ...(agent.ownership ? { ownership: agent.ownership } : {}),\n ...(agent.availability.status !== \"ready\" && !agent.setupKind\n ? { disabled: true }\n : {}),\n ...(agent.availability.reason\n ? { unavailableReason: agent.availability.reason }\n : {})\n }));\n}\n\nfunction normalizeAgentGUIAgentAvailabilityStatus(\n status: AgentGUIAgentAvailabilityStatus\n): AgentGUIAgentAvailabilityStatus {\n switch (status) {\n case \"ready\":\n case \"checking\":\n case \"coming_soon\":\n case \"not_installed\":\n case \"auth_required\":\n case \"unavailable\":\n return status;\n }\n}\n"],"mappings":";AAMO,SAAS,wBACd,QACiB;AACjB,QAAM,aAA8B,CAAC;AACrC,QAAM,qBAAqB,oBAAI,IAAY;AAC3C,aAAW,SAAS,UAAU,CAAC,GAAG;AAChC,UAAM,gBAAgB,MAAM,cAAc,KAAK;AAC/C,UAAM,OAAO,MAAM,KAAK,KAAK;AAC7B,UAAM,UAAU,MAAM,QAAQ,KAAK;AACnC,UAAM,eAAe,MAAM,cAAc,KAAK,KAAK;AACnD,QACE,CAAC,iBACD,CAAC,QACD,CAAC,WACD,mBAAmB,IAAI,aAAa,GACpC;AACA;AAAA,IACF;AACA,uBAAmB,IAAI,aAAa;AACpC,UAAM,YAAY,MAAM,OAAO,MAAM,KAAK,KAAK;AAC/C,UAAM,iBAAi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[]}
|
package/dist/chunk-VMQNG2KI.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
// shared/agentEnv/agentEnvPanelStore.ts
|
|
2
|
-
import { useSnapshot } from "valtio";
|
|
3
|
-
import { proxy } from "valtio/vanilla";
|
|
4
|
-
var agentEnvPanelStore = proxy({
|
|
5
|
-
open: false,
|
|
6
|
-
provider: null,
|
|
7
|
-
focus: null,
|
|
8
|
-
requestSequence: 0
|
|
9
|
-
});
|
|
10
|
-
function openAgentEnvPanel(input) {
|
|
11
|
-
agentEnvPanelStore.open = true;
|
|
12
|
-
agentEnvPanelStore.provider = input?.provider ?? null;
|
|
13
|
-
agentEnvPanelStore.focus = input?.focus ?? null;
|
|
14
|
-
agentEnvPanelStore.requestSequence += 1;
|
|
15
|
-
}
|
|
16
|
-
function closeAgentEnvPanel() {
|
|
17
|
-
agentEnvPanelStore.open = false;
|
|
18
|
-
}
|
|
19
|
-
function getAgentEnvPanelStore() {
|
|
20
|
-
return agentEnvPanelStore;
|
|
21
|
-
}
|
|
22
|
-
function useAgentEnvPanelRequest() {
|
|
23
|
-
return useSnapshot(agentEnvPanelStore);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// shared/agentEnv/agentErrorPresentation.ts
|
|
27
|
-
var NO_CTA = { focus: null, actionKey: null };
|
|
28
|
-
var SELF_DETECT = {
|
|
29
|
-
messageKey: null,
|
|
30
|
-
focus: "detect",
|
|
31
|
-
actionKey: "agentHost.agentGui.visibleErrorActionDetect"
|
|
32
|
-
};
|
|
33
|
-
var PRESENTATIONS = {
|
|
34
|
-
// Environment problems the wizard can detect or repair → route to its step.
|
|
35
|
-
auth_required: {
|
|
36
|
-
messageKey: "agentHost.agentGui.visibleErrorAuthRequired",
|
|
37
|
-
focus: "auth",
|
|
38
|
-
actionKey: "agentHost.agentGui.visibleErrorActionRelogin"
|
|
39
|
-
},
|
|
40
|
-
cli_not_found: {
|
|
41
|
-
messageKey: "agentHost.agentGui.visibleErrorCliNotFound",
|
|
42
|
-
focus: "install",
|
|
43
|
-
actionKey: "agentHost.agentGui.visibleErrorActionInstall"
|
|
44
|
-
},
|
|
45
|
-
cli_version_unsupported: {
|
|
46
|
-
messageKey: "agentHost.agentGui.visibleErrorVersionUnsupported",
|
|
47
|
-
focus: "upgrade",
|
|
48
|
-
actionKey: "agentHost.agentGui.visibleErrorActionUpgrade"
|
|
49
|
-
},
|
|
50
|
-
network_error: {
|
|
51
|
-
messageKey: "agentHost.agentGui.visibleErrorNetwork",
|
|
52
|
-
focus: "network",
|
|
53
|
-
actionKey: "agentHost.agentGui.visibleErrorActionCheckNetwork"
|
|
54
|
-
},
|
|
55
|
-
runtime_unavailable: {
|
|
56
|
-
messageKey: "agentHost.agentGui.visibleErrorRuntimeUnavailable",
|
|
57
|
-
focus: "detect",
|
|
58
|
-
actionKey: "agentHost.agentGui.visibleErrorActionDetect"
|
|
59
|
-
},
|
|
60
|
-
// Transient / server-side failures: accurate copy, but no wizard CTA — it
|
|
61
|
-
// cannot fix a rate limit or a dropped stream.
|
|
62
|
-
request_timed_out: {
|
|
63
|
-
messageKey: "agentHost.agentGui.visibleErrorRequestTimedOut",
|
|
64
|
-
...NO_CTA
|
|
65
|
-
},
|
|
66
|
-
provider_config_timeout: {
|
|
67
|
-
messageKey: "agentHost.agentGui.visibleErrorConfigTimeout",
|
|
68
|
-
...NO_CTA
|
|
69
|
-
},
|
|
70
|
-
provider_stream_disconnected: {
|
|
71
|
-
messageKey: "agentHost.agentGui.visibleErrorStreamDisconnected",
|
|
72
|
-
...NO_CTA
|
|
73
|
-
},
|
|
74
|
-
provider_concurrency_limit: {
|
|
75
|
-
messageKey: "agentHost.agentGui.visibleErrorConcurrencyLimit",
|
|
76
|
-
...NO_CTA
|
|
77
|
-
},
|
|
78
|
-
insufficient_credits: {
|
|
79
|
-
messageKey: "agentHost.agentGui.visibleErrorInsufficientCredits",
|
|
80
|
-
focus: null,
|
|
81
|
-
actionKey: "agentHost.agentGui.visibleErrorActionViewPlans",
|
|
82
|
-
externalUrl: "https://tutti.sh/profile/plan"
|
|
83
|
-
},
|
|
84
|
-
quota_or_rate_limit: {
|
|
85
|
-
messageKey: "agentHost.agentGui.visibleErrorQuotaOrRateLimit",
|
|
86
|
-
...NO_CTA
|
|
87
|
-
},
|
|
88
|
-
// Ambiguous hard failures → generic message + self-detect escape hatch.
|
|
89
|
-
process_exited: SELF_DETECT,
|
|
90
|
-
provider_error: SELF_DETECT,
|
|
91
|
-
unknown: SELF_DETECT
|
|
92
|
-
};
|
|
93
|
-
function resolveAgentErrorPresentation(code) {
|
|
94
|
-
if (!code) {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
return PRESENTATIONS[code] ?? null;
|
|
98
|
-
}
|
|
99
|
-
var FAILED_MESSAGE_CODE_MARKERS = [
|
|
100
|
-
[
|
|
101
|
-
"auth_required",
|
|
102
|
-
[
|
|
103
|
-
"authentication_failed",
|
|
104
|
-
"invalid authentication credentials",
|
|
105
|
-
"401 invalid authentication",
|
|
106
|
-
"unauthorized",
|
|
107
|
-
"not logged in",
|
|
108
|
-
"please run /login",
|
|
109
|
-
"invalid api key"
|
|
110
|
-
]
|
|
111
|
-
],
|
|
112
|
-
[
|
|
113
|
-
"cli_version_unsupported",
|
|
114
|
-
["requires a newer version", "version is too old", "unsupported version"]
|
|
115
|
-
],
|
|
116
|
-
[
|
|
117
|
-
"cli_not_found",
|
|
118
|
-
[
|
|
119
|
-
"no such file or directory",
|
|
120
|
-
"command not found",
|
|
121
|
-
"enoent",
|
|
122
|
-
"executable file not found"
|
|
123
|
-
]
|
|
124
|
-
],
|
|
125
|
-
[
|
|
126
|
-
"network_error",
|
|
127
|
-
["enotfound", "econnrefused", "econnreset", "getaddrinfo", "socket hang up"]
|
|
128
|
-
],
|
|
129
|
-
[
|
|
130
|
-
"quota_or_rate_limit",
|
|
131
|
-
["upgrade your plan to continue", "add a payment method to continue"]
|
|
132
|
-
]
|
|
133
|
-
];
|
|
134
|
-
function classifyFailedAgentMessage(body) {
|
|
135
|
-
if (!body) {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
const lower = body.toLowerCase();
|
|
139
|
-
for (const [code, markers] of FAILED_MESSAGE_CODE_MARKERS) {
|
|
140
|
-
if (markers.some((marker) => lower.includes(marker))) {
|
|
141
|
-
return code;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
var COMPLETED_AUTH_MESSAGE_MAX_LENGTH = 160;
|
|
147
|
-
var COMPLETED_AUTH_MESSAGE_PATTERN = /^not logged in\s*(?:[·•:—-]|\.)?\s*please run\s+\/login[.!]?$/i;
|
|
148
|
-
function classifyRecoverableAgentMessage(input) {
|
|
149
|
-
if (input.statusKind === "failed") {
|
|
150
|
-
return classifyFailedAgentMessage(input.body);
|
|
151
|
-
}
|
|
152
|
-
if (input.statusKind !== "completed" || !input.body || input.body.length > COMPLETED_AUTH_MESSAGE_MAX_LENGTH) {
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
155
|
-
return COMPLETED_AUTH_MESSAGE_PATTERN.test(input.body.trim()) ? "auth_required" : null;
|
|
156
|
-
}
|
|
157
|
-
function isProviderPlanLimitMessage(detail) {
|
|
158
|
-
const normalized = detail?.trim().toLowerCase() ?? "";
|
|
159
|
-
if (!normalized) {
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
const markers = FAILED_MESSAGE_CODE_MARKERS.find(
|
|
163
|
-
([code]) => code === "quota_or_rate_limit"
|
|
164
|
-
)?.[1] ?? [];
|
|
165
|
-
return markers.some((marker) => normalized.includes(marker));
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export {
|
|
169
|
-
openAgentEnvPanel,
|
|
170
|
-
closeAgentEnvPanel,
|
|
171
|
-
getAgentEnvPanelStore,
|
|
172
|
-
useAgentEnvPanelRequest,
|
|
173
|
-
resolveAgentErrorPresentation,
|
|
174
|
-
classifyFailedAgentMessage,
|
|
175
|
-
classifyRecoverableAgentMessage,
|
|
176
|
-
isProviderPlanLimitMessage
|
|
177
|
-
};
|
|
178
|
-
//# sourceMappingURL=chunk-VMQNG2KI.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../shared/agentEnv/agentEnvPanelStore.ts","../shared/agentEnv/agentErrorPresentation.ts"],"sourcesContent":["import { useSnapshot } from \"valtio\";\nimport { proxy } from \"valtio/vanilla\";\n\n/**\n * Section the Agent Env panel (the片6 Setup Wizard / config panel) should scroll\n * to / emphasise when opened via a deep-link. The error card (片5) maps a domain\n * error code to one of these so the user lands on the relevant remediation.\n */\nexport type AgentEnvPanelFocus =\n | \"detect\"\n | \"install\"\n | \"repair\"\n | \"upgrade\"\n | \"auth\"\n | \"network\"\n | \"registry\";\n\nexport interface AgentEnvPanelRequest {\n open: boolean;\n provider: string | null;\n focus: AgentEnvPanelFocus | null;\n /**\n * Bumped on every openAgentEnvPanel() call. The host panel watches this to\n * re-run detection even when it is already open (e.g. a second deep-link).\n */\n requestSequence: number;\n}\n\nexport interface OpenAgentEnvPanelInput {\n provider?: string | null;\n focus?: AgentEnvPanelFocus | null;\n}\n\nconst agentEnvPanelStore = proxy<AgentEnvPanelRequest>({\n open: false,\n provider: null,\n focus: null,\n requestSequence: 0\n});\n\n/**\n * Open the agent environment panel. Safe to call from anywhere in the agent-gui\n * tree (rail footer entry, error-card deep-link). The host renders the actual\n * panel and reacts to this singleton store.\n */\nexport function openAgentEnvPanel(input?: OpenAgentEnvPanelInput): void {\n agentEnvPanelStore.open = true;\n agentEnvPanelStore.provider = input?.provider ?? null;\n agentEnvPanelStore.focus = input?.focus ?? null;\n agentEnvPanelStore.requestSequence += 1;\n}\n\nexport function closeAgentEnvPanel(): void {\n agentEnvPanelStore.open = false;\n}\n\n/** Imperative read, mainly for tests. Components should use the hook. */\nexport function getAgentEnvPanelStore(): AgentEnvPanelRequest {\n return agentEnvPanelStore;\n}\n\n/** Reactive snapshot of the panel request for the host renderer. */\nexport function useAgentEnvPanelRequest(): AgentEnvPanelRequest {\n return useSnapshot(agentEnvPanelStore);\n}\n","import type { AgentEnvPanelFocus } from \"./agentEnvPanelStore\";\n\n/**\n * Run-failure codes actually emitted by the daemon runtime classifier\n * (packages/agent/daemon/runtime/visible_error.go `visibleFailureCode`). These\n * are the codes the conversation error card really receives — unlike the\n * aspirational `CODEX_*` codes, which the run pipeline never produces.\n *\n * Keep this union aligned with the Go switch in `visibleFailureCode`.\n */\nexport type AgentRunErrorCode =\n | \"auth_required\"\n | \"cli_not_found\"\n | \"cli_version_unsupported\"\n | \"network_error\"\n | \"runtime_unavailable\"\n | \"request_timed_out\"\n | \"provider_config_timeout\"\n | \"provider_stream_disconnected\"\n | \"provider_concurrency_limit\"\n | \"insufficient_credits\"\n | \"quota_or_rate_limit\"\n | \"process_exited\"\n | \"provider_error\"\n | \"unknown\";\n\nexport interface AgentErrorPresentation {\n /**\n * i18n key for the one human sentence shown in the card, or null to let the\n * caller fall back to its phase-aware generic title.\n */\n messageKey: string | null;\n /**\n * Env-panel section the remediation button deep-links to, or null when the\n * failure is transient/server-side and the wizard cannot fix it — in which\n * case no call-to-action is shown (showing one would misrepresent reality).\n */\n focus: AgentEnvPanelFocus | null;\n /** i18n key for the remediation button. */\n actionKey: string | null;\n /** External remediation destination, when the action is account-level. */\n externalUrl?: string | null;\n}\n\nconst NO_CTA = { focus: null, actionKey: null } as const;\n\n// The escape hatch for hard failures whose cause is ambiguous from the message\n// alone (a non-zero exit, an unclassified provider error): send the user into\n// the wizard to self-detect, but keep the generic message.\nconst SELF_DETECT = {\n messageKey: null,\n focus: \"detect\" as const,\n actionKey: \"agentHost.agentGui.visibleErrorActionDetect\"\n};\n\nconst PRESENTATIONS: Record<AgentRunErrorCode, AgentErrorPresentation> = {\n // Environment problems the wizard can detect or repair → route to its step.\n auth_required: {\n messageKey: \"agentHost.agentGui.visibleErrorAuthRequired\",\n focus: \"auth\",\n actionKey: \"agentHost.agentGui.visibleErrorActionRelogin\"\n },\n cli_not_found: {\n messageKey: \"agentHost.agentGui.visibleErrorCliNotFound\",\n focus: \"install\",\n actionKey: \"agentHost.agentGui.visibleErrorActionInstall\"\n },\n cli_version_unsupported: {\n messageKey: \"agentHost.agentGui.visibleErrorVersionUnsupported\",\n focus: \"upgrade\",\n actionKey: \"agentHost.agentGui.visibleErrorActionUpgrade\"\n },\n network_error: {\n messageKey: \"agentHost.agentGui.visibleErrorNetwork\",\n focus: \"network\",\n actionKey: \"agentHost.agentGui.visibleErrorActionCheckNetwork\"\n },\n runtime_unavailable: {\n messageKey: \"agentHost.agentGui.visibleErrorRuntimeUnavailable\",\n focus: \"detect\",\n actionKey: \"agentHost.agentGui.visibleErrorActionDetect\"\n },\n // Transient / server-side failures: accurate copy, but no wizard CTA — it\n // cannot fix a rate limit or a dropped stream.\n request_timed_out: {\n messageKey: \"agentHost.agentGui.visibleErrorRequestTimedOut\",\n ...NO_CTA\n },\n provider_config_timeout: {\n messageKey: \"agentHost.agentGui.visibleErrorConfigTimeout\",\n ...NO_CTA\n },\n provider_stream_disconnected: {\n messageKey: \"agentHost.agentGui.visibleErrorStreamDisconnected\",\n ...NO_CTA\n },\n provider_concurrency_limit: {\n messageKey: \"agentHost.agentGui.visibleErrorConcurrencyLimit\",\n ...NO_CTA\n },\n insufficient_credits: {\n messageKey: \"agentHost.agentGui.visibleErrorInsufficientCredits\",\n focus: null,\n actionKey: \"agentHost.agentGui.visibleErrorActionViewPlans\",\n externalUrl: \"https://tutti.sh/profile/plan\"\n },\n quota_or_rate_limit: {\n messageKey: \"agentHost.agentGui.visibleErrorQuotaOrRateLimit\",\n ...NO_CTA\n },\n // Ambiguous hard failures → generic message + self-detect escape hatch.\n process_exited: SELF_DETECT,\n provider_error: SELF_DETECT,\n unknown: SELF_DETECT\n};\n\n/**\n * Resolves the card presentation for a run-failure code. Returns null for codes\n * outside the known vocabulary so the caller renders its plain generic card with\n * no call-to-action.\n */\nexport function resolveAgentErrorPresentation(\n code: string | null | undefined\n): AgentErrorPresentation | null {\n if (!code) {\n return null;\n }\n return PRESENTATIONS[code as AgentRunErrorCode] ?? null;\n}\n\nconst FAILED_MESSAGE_CODE_MARKERS: ReadonlyArray<\n readonly [AgentRunErrorCode, readonly string[]]\n> = [\n [\n \"auth_required\",\n [\n \"authentication_failed\",\n \"invalid authentication credentials\",\n \"401 invalid authentication\",\n \"unauthorized\",\n \"not logged in\",\n \"please run /login\",\n \"invalid api key\"\n ]\n ],\n [\n \"cli_version_unsupported\",\n [\"requires a newer version\", \"version is too old\", \"unsupported version\"]\n ],\n [\n \"cli_not_found\",\n [\n \"no such file or directory\",\n \"command not found\",\n \"enoent\",\n \"executable file not found\"\n ]\n ],\n [\n \"network_error\",\n [\"enotfound\", \"econnrefused\", \"econnreset\", \"getaddrinfo\", \"socket hang up\"]\n ],\n [\n \"quota_or_rate_limit\",\n [\"upgrade your plan to continue\", \"add a payment method to continue\"]\n ]\n];\n\n/**\n * Some providers (notably Claude Code) report an environment failure — e.g. a\n * dropped login (401) — as a plain failed assistant message rather than a\n * structured visibleError, so it never gets the remediation card. This recovers\n * the env-fixable code from that message's text so the caller can still route the\n * user to the wizard. Returns null when the text isn't a recognized env failure\n * (so transient/unknown failures stay plain).\n */\nexport function classifyFailedAgentMessage(\n body: string | null | undefined\n): AgentRunErrorCode | null {\n if (!body) {\n return null;\n }\n const lower = body.toLowerCase();\n for (const [code, markers] of FAILED_MESSAGE_CODE_MARKERS) {\n if (markers.some((marker) => lower.includes(marker))) {\n return code;\n }\n }\n return null;\n}\n\nconst COMPLETED_AUTH_MESSAGE_MAX_LENGTH = 160;\nconst COMPLETED_AUTH_MESSAGE_PATTERN =\n /^not logged in\\s*(?:[·•:—-]|\\.)?\\s*please run\\s+\\/login[.!]?$/i;\n\n/**\n * Resolves a plain assistant message that should be recovered into a visible\n * error card. Failed messages keep the provider-agnostic fallback above.\n *\n * Claude Code demonstrates why completed messages need a narrow exception: its\n * SDK can return the standalone \"Not logged in · Please run /login\" notice\n * together with a successful result. Match the provider-owned output shape,\n * rather than branching on provider identity, and keep it short and\n * whole-message anchored so normal answers are not reclassified.\n */\nexport function classifyRecoverableAgentMessage(input: {\n body: string | null | undefined;\n statusKind: string | null | undefined;\n}): AgentRunErrorCode | null {\n if (input.statusKind === \"failed\") {\n return classifyFailedAgentMessage(input.body);\n }\n if (\n input.statusKind !== \"completed\" ||\n !input.body ||\n input.body.length > COMPLETED_AUTH_MESSAGE_MAX_LENGTH\n ) {\n return null;\n }\n return COMPLETED_AUTH_MESSAGE_PATTERN.test(input.body.trim())\n ? \"auth_required\"\n : null;\n}\n\n/** True when detail text is a provider plan/payment gate (not a generic quota). */\nexport function isProviderPlanLimitMessage(\n detail: string | null | undefined\n): boolean {\n const normalized = detail?.trim().toLowerCase() ?? \"\";\n if (!normalized) {\n return false;\n }\n const markers =\n FAILED_MESSAGE_CODE_MARKERS.find(\n ([code]) => code === \"quota_or_rate_limit\"\n )?.[1] ?? [];\n return markers.some((marker) => normalized.includes(marker));\n}\n"],"mappings":";AAAA,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AAgCtB,IAAM,qBAAqB,MAA4B;AAAA,EACrD,MAAM;AAAA,EACN,UAAU;AAAA,EACV,OAAO;AAAA,EACP,iBAAiB;AACnB,CAAC;AAOM,SAAS,kBAAkB,OAAsC;AACtE,qBAAmB,OAAO;AAC1B,qBAAmB,WAAW,OAAO,YAAY;AACjD,qBAAmB,QAAQ,OAAO,SAAS;AAC3C,qBAAmB,mBAAmB;AACxC;AAEO,SAAS,qBAA2B;AACzC,qBAAmB,OAAO;AAC5B;AAGO,SAAS,wBAA8C;AAC5D,SAAO;AACT;AAGO,SAAS,0BAAgD;AAC9D,SAAO,YAAY,kBAAkB;AACvC;;;ACpBA,IAAM,SAAS,EAAE,OAAO,MAAM,WAAW,KAAK;AAK9C,IAAM,cAAc;AAAA,EAClB,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,WAAW;AACb;AAEA,IAAM,gBAAmE;AAA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