@tutti-os/agent-gui 0.0.95 → 0.0.97

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.
Files changed (111) hide show
  1. package/README.md +38 -6
  2. package/dist/{AgentGUI-CwBLYtv-.d.ts → AgentGUI-DWdvUV4x.d.ts} +64 -18
  3. package/dist/agent-conversation/index.d.ts +3 -2
  4. package/dist/agent-conversation/index.js +10 -9
  5. package/dist/agent-conversation/index.js.map +1 -1
  6. package/dist/agent-env/index.js +1 -1
  7. package/dist/agent-gui.d.ts +5 -5
  8. package/dist/agent-gui.js +26 -26
  9. package/dist/agent-message-center/index.d.ts +14 -3
  10. package/dist/agent-message-center/index.js +182 -47
  11. package/dist/agent-message-center/index.js.map +1 -1
  12. package/dist/{agentFileMentionContracts-Czvz6YMI.d.ts → agentFileMentionContracts-58IjMU-u.d.ts} +1 -0
  13. package/dist/{agentGuiNodeTypes-DppADPHW.d.ts → agentGuiNodeTypes-B9X4aWfv.d.ts} +30 -18
  14. package/dist/agents.d.ts +1 -1
  15. package/dist/agents.js +1 -1
  16. package/dist/app/renderer/agentactivity.css +150 -10
  17. package/dist/{chunk-BIHBXWK5.js → chunk-3EAANCKF.js} +2 -2
  18. package/dist/{chunk-LQVXBT65.js → chunk-3RYZYA72.js} +9 -9
  19. package/dist/{chunk-LQVXBT65.js.map → chunk-3RYZYA72.js.map} +1 -1
  20. package/dist/{chunk-BFNJKTDV.js → chunk-4VBKQY24.js} +11 -16
  21. package/dist/chunk-4VBKQY24.js.map +1 -0
  22. package/dist/{chunk-7PFDA2HQ.js → chunk-4YVGHJIE.js} +8 -116
  23. package/dist/chunk-4YVGHJIE.js.map +1 -0
  24. package/dist/{chunk-NITOD7WF.js → chunk-74CPYRWJ.js} +2 -2
  25. package/dist/{chunk-R2EWECUP.js → chunk-7BXWPI4F.js} +17 -2
  26. package/dist/{chunk-R2EWECUP.js.map → chunk-7BXWPI4F.js.map} +1 -1
  27. package/dist/{chunk-3R2D4E57.js → chunk-AAFTWZV7.js} +933 -844
  28. package/dist/chunk-AAFTWZV7.js.map +1 -0
  29. package/dist/{chunk-JX2SIXNL.js → chunk-AO2FDYAL.js} +8 -7
  30. package/dist/{chunk-JX2SIXNL.js.map → chunk-AO2FDYAL.js.map} +1 -1
  31. package/dist/{chunk-RY6GIO3K.js → chunk-BIS4QRX7.js} +5744 -4357
  32. package/dist/chunk-BIS4QRX7.js.map +1 -0
  33. package/dist/{chunk-O6W72SEP.js → chunk-C35SNDVZ.js} +4 -1
  34. package/dist/chunk-C35SNDVZ.js.map +1 -0
  35. package/dist/{chunk-WEDMAVX2.js → chunk-IYEXLOUE.js} +3 -6
  36. package/dist/chunk-IYEXLOUE.js.map +1 -0
  37. package/dist/{chunk-AOS2VWU6.js → chunk-K2NURZ7V.js} +37 -3
  38. package/dist/chunk-K2NURZ7V.js.map +1 -0
  39. package/dist/{chunk-UQJPV6HP.js → chunk-L3GMMGRS.js} +8 -6
  40. package/dist/chunk-L3GMMGRS.js.map +1 -0
  41. package/dist/{chunk-KAL4XZMA.js → chunk-MASXZENX.js} +1 -1
  42. package/dist/chunk-MASXZENX.js.map +1 -0
  43. package/dist/{chunk-YE25HN6T.js → chunk-NRJEKWLY.js} +17 -25
  44. package/dist/chunk-NRJEKWLY.js.map +1 -0
  45. package/dist/{chunk-XMO45GKA.js → chunk-P2BCMPTX.js} +14 -4
  46. package/dist/chunk-P2BCMPTX.js.map +1 -0
  47. package/dist/{chunk-7RDD3EWP.js → chunk-RE4AXS27.js} +24 -15
  48. package/dist/chunk-RE4AXS27.js.map +1 -0
  49. package/dist/{chunk-C5FV4UGI.js → chunk-SQTSLCMV.js} +22 -44
  50. package/dist/chunk-SQTSLCMV.js.map +1 -0
  51. package/dist/{chunk-NJAZ7LQM.js → chunk-TVIGLNNI.js} +3 -3
  52. package/dist/{chunk-VF22EG3F.js → chunk-UHBCM6RO.js} +1 -1
  53. package/dist/chunk-UHBCM6RO.js.map +1 -0
  54. package/dist/{chunk-CRO2MV2Y.js → chunk-XGGKHIQA.js} +21 -116
  55. package/dist/chunk-XGGKHIQA.js.map +1 -0
  56. package/dist/{chunk-NX3CZJXW.js → chunk-Y57VNTVM.js} +2 -2
  57. package/dist/chunk-YMXYBG7U.js +12 -0
  58. package/dist/chunk-YMXYBG7U.js.map +1 -0
  59. package/dist/context-mention-palette/index.d.ts +1 -1
  60. package/dist/context-mention-palette/index.js +14 -14
  61. package/dist/custom-mention.d.ts +2 -4
  62. package/dist/dock-icons.d.ts +2 -4
  63. package/dist/i18n/index.d.ts +34 -0
  64. package/dist/i18n/index.js +2 -2
  65. package/dist/index.d.ts +14 -12
  66. package/dist/index.js +34 -30
  67. package/dist/index.js.map +1 -1
  68. package/dist/mention-search.d.ts +1 -1
  69. package/dist/mention-search.js +11 -11
  70. package/dist/pastedTextKinds-D-XuInaS.d.ts +4 -0
  71. package/dist/startup-shell.d.ts +8 -0
  72. package/dist/startup-shell.js +184 -0
  73. package/dist/startup-shell.js.map +1 -0
  74. package/dist/{types-DX2bxgB8.d.ts → types-CnT8rNUI.d.ts} +16 -5
  75. package/dist/workbench/contribution.d.ts +3 -2
  76. package/dist/workbench/contribution.js +6 -6
  77. package/dist/workbench/index.d.ts +4 -4
  78. package/dist/workbench/index.js +14 -16
  79. package/dist/workbench/launch.d.ts +2 -2
  80. package/dist/workbench/launch.js +3 -3
  81. package/dist/workbench/providerCatalog.d.ts +2 -2
  82. package/dist/workbench/providerCatalog.js +1 -1
  83. package/dist/workbench/sessionTitle.d.ts +8 -12
  84. package/dist/workbench/sessionTitle.js +5 -7
  85. package/dist/workbench/state.js +2 -2
  86. package/dist/workbench/types.d.ts +2 -1
  87. package/dist/workbench/types.js +1 -1
  88. package/dist/workspace-agent-generated-files.js +6 -6
  89. package/package.json +21 -14
  90. package/dist/chunk-3R2D4E57.js.map +0 -1
  91. package/dist/chunk-7J4K6WKB.js +0 -66
  92. package/dist/chunk-7J4K6WKB.js.map +0 -1
  93. package/dist/chunk-7PFDA2HQ.js.map +0 -1
  94. package/dist/chunk-7RDD3EWP.js.map +0 -1
  95. package/dist/chunk-AOS2VWU6.js.map +0 -1
  96. package/dist/chunk-BFNJKTDV.js.map +0 -1
  97. package/dist/chunk-C5FV4UGI.js.map +0 -1
  98. package/dist/chunk-CRO2MV2Y.js.map +0 -1
  99. package/dist/chunk-KAL4XZMA.js.map +0 -1
  100. package/dist/chunk-O6W72SEP.js.map +0 -1
  101. package/dist/chunk-RY6GIO3K.js.map +0 -1
  102. package/dist/chunk-UQJPV6HP.js.map +0 -1
  103. package/dist/chunk-VF22EG3F.js.map +0 -1
  104. package/dist/chunk-WEDMAVX2.js.map +0 -1
  105. package/dist/chunk-XMO45GKA.js.map +0 -1
  106. package/dist/chunk-YE25HN6T.js.map +0 -1
  107. package/dist/uiSettings-BQS9r2eo.d.ts +0 -6
  108. /package/dist/{chunk-BIHBXWK5.js.map → chunk-3EAANCKF.js.map} +0 -0
  109. /package/dist/{chunk-NITOD7WF.js.map → chunk-74CPYRWJ.js.map} +0 -0
  110. /package/dist/{chunk-NJAZ7LQM.js.map → chunk-TVIGLNNI.js.map} +0 -0
  111. /package/dist/{chunk-NX3CZJXW.js.map → chunk-Y57VNTVM.js.map} +0 -0
@@ -125,6 +125,10 @@ var FAILED_MESSAGE_CODE_MARKERS = [
125
125
  [
126
126
  "network_error",
127
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"]
128
132
  ]
129
133
  ];
130
134
  function classifyFailedAgentMessage(body) {
@@ -139,6 +143,16 @@ function classifyFailedAgentMessage(body) {
139
143
  }
140
144
  return null;
141
145
  }
146
+ function isProviderPlanLimitMessage(detail) {
147
+ const normalized = detail?.trim().toLowerCase() ?? "";
148
+ if (!normalized) {
149
+ return false;
150
+ }
151
+ const markers = FAILED_MESSAGE_CODE_MARKERS.find(
152
+ ([code]) => code === "quota_or_rate_limit"
153
+ )?.[1] ?? [];
154
+ return markers.some((marker) => normalized.includes(marker));
155
+ }
142
156
 
143
157
  export {
144
158
  openAgentEnvPanel,
@@ -146,6 +160,7 @@ export {
146
160
  getAgentEnvPanelStore,
147
161
  useAgentEnvPanelRequest,
148
162
  resolveAgentErrorPresentation,
149
- classifyFailedAgentMessage
163
+ classifyFailedAgentMessage,
164
+ isProviderPlanLimitMessage
150
165
  };
151
- //# sourceMappingURL=chunk-R2EWECUP.js.map
166
+ //# sourceMappingURL=chunk-7BXWPI4F.js.map
@@ -1 +1 @@
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\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"],"mappings":";AAAA,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AAgCtB,IAAM,qBAAqB,MAA4B;AAAA,EACrD,MAAM;AAAA,EACN,UAAU;AAAA,E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ACP,WAAW;AAAA,IACX,aAAa;AAAA,EACf;AAAA,EACA,qBAAqB;AAAA,IACnB,YAAY;AAAA,IACZ,GAAG;AAAA,EACL;AAAA;AAAA,EAEA,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,SAAS;AACX;AAOO,SAAS,8BACd,MAC+B;AAC/B,MAAI,CAAC,MAAM;AACT,WAAO;AAAA,EACT;AACA,SAAO,cAAc,IAAyB,KAAK;AACrD;AAEA,IAAM,8BAEF;AAAA,EACF;AAAA,IACE;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE;AAAA,IACA,CAAC,4BAA4B,sBAAsB,qBAAqB;AAAA,EAC1E;AAAA,EACA;AAAA,IACE;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE;AAAA,IACA,CAAC,aAAa,gBAAgB,cAAc,eAAe,gBAAgB;AAAA,EAC7E;AACF;AAUO,SAAS,2BACd,MAC0B;AAC1B,MAAI,CAAC,MAAM;AACT,WAAO;AAAA,EACT;AACA,QAAM,QAAQ,KAAK,YAAY;AAC/B,aAAW,CAAC,MAAM,OAAO,KAAK,6BAA6B;AACzD,QAAI,QAAQ,KAAK,CAAC,WAAW,MAAM,SAAS,MAAM,CAAC,GAAG;AACpD,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
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\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,Y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