@tutti-os/agent-gui 0.0.132 → 0.0.134

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 (96) hide show
  1. package/README.md +21 -4
  2. package/dist/{AgentRichTextReadonly-PEKCMRPE.js → AgentRichTextReadonly-HCKTNAYO.js} +7 -6
  3. package/dist/agent-conversation/index.d.ts +4 -6
  4. package/dist/agent-conversation/index.js +10 -10
  5. package/dist/agent-env/index.d.ts +10 -27
  6. package/dist/agent-env/index.js +14 -290
  7. package/dist/agent-env/index.js.map +1 -1
  8. package/dist/agent-gui.d.ts +1118 -20
  9. package/dist/agent-gui.js +18 -18
  10. package/dist/agent-message-center/index.d.ts +42 -7
  11. package/dist/agent-message-center/index.js +7 -7
  12. package/dist/{agentConversationVM-BD0-gg6C.d.ts → agentConversationVM-DWEy7jzx.d.ts} +41 -2
  13. package/dist/{agentFileMentionContracts-CWAeuL7S.d.ts → agentFileMentionContracts-B0yQizXB.d.ts} +5 -0
  14. package/dist/{agentGuiNodeTypes-5TL1hyCN.d.ts → agentGuiNodeTypes-DV7KvZRe.d.ts} +10 -26
  15. package/dist/agents.d.ts +1 -1
  16. package/dist/agents.js +1 -1
  17. package/dist/app/renderer/agentactivity.css +7 -0
  18. package/dist/app/renderer/assets/icons/@-lined.svg +1 -8
  19. package/dist/{chunk-PQJXWXTS.js → chunk-25VMCMAQ.js} +4 -4
  20. package/dist/{chunk-T2NICA5D.js → chunk-5WOCGIXJ.js} +7 -1
  21. package/dist/chunk-5WOCGIXJ.js.map +1 -0
  22. package/dist/chunk-DLCZJKCA.js +1 -0
  23. package/dist/chunk-DLCZJKCA.js.map +1 -0
  24. package/dist/{chunk-QQRTUHCH.js → chunk-EU7DCT4F.js} +2 -2
  25. package/dist/chunk-FM42UN2J.js +462 -0
  26. package/dist/chunk-FM42UN2J.js.map +1 -0
  27. package/dist/{chunk-SZOTLVH6.js → chunk-GIYGO2PB.js} +2 -2
  28. package/dist/{chunk-GCQYN7BR.js → chunk-IN3HXYOO.js} +4 -4
  29. package/dist/{chunk-YWHGCKMT.js → chunk-IYZ4GOSN.js} +10 -10
  30. package/dist/chunk-IYZ4GOSN.js.map +1 -0
  31. package/dist/{chunk-JZS4SWFJ.js → chunk-JI5KND3K.js} +60 -56
  32. package/dist/chunk-JI5KND3K.js.map +1 -0
  33. package/dist/{chunk-J4TTEMRW.js → chunk-KWGMK4IZ.js} +4 -4
  34. package/dist/{chunk-NE6H7S5Z.js → chunk-OFJNIQWR.js} +2 -2
  35. package/dist/{chunk-NE6H7S5Z.js.map → chunk-OFJNIQWR.js.map} +1 -1
  36. package/dist/{chunk-UARZZJJB.js → chunk-OI6BYC7P.js} +4 -4
  37. package/dist/{chunk-OBWM2RFE.js → chunk-QPEO4OQS.js} +308 -8
  38. package/dist/chunk-QPEO4OQS.js.map +1 -0
  39. package/dist/{chunk-XNE2ROCP.js → chunk-UA75CGAG.js} +3 -3
  40. package/dist/{chunk-PVTAFUDS.js → chunk-VGS7S7YT.js} +2 -2
  41. package/dist/{chunk-OQR3HXPF.js → chunk-VUNVGEQG.js} +7 -1
  42. package/dist/chunk-VUNVGEQG.js.map +1 -0
  43. package/dist/{chunk-G75CPIVV.js → chunk-Y5HD6XHP.js} +1040 -797
  44. package/dist/chunk-Y5HD6XHP.js.map +1 -0
  45. package/dist/{chunk-KPMQGPYU.js → chunk-ZVYUTXQJ.js} +1 -1
  46. package/dist/chunk-ZVYUTXQJ.js.map +1 -0
  47. package/dist/context-mention-palette/index.d.ts +1 -1
  48. package/dist/context-mention-palette/index.js +8 -7
  49. package/dist/{contribution-yc4CGJmy.d.ts → contribution-CDdwTppn.d.ts} +54 -1
  50. package/dist/custom-mention.d.ts +4 -2
  51. package/dist/custom-mention.js +1 -0
  52. package/dist/i18n/index.d.ts +17 -6
  53. package/dist/i18n/index.js +2 -2
  54. package/dist/index.d.ts +8026 -33
  55. package/dist/index.js +21 -21
  56. package/dist/index.js.map +1 -1
  57. package/dist/mention-search.d.ts +1 -1
  58. package/dist/mention-search.js +6 -5
  59. package/dist/runtime-Dwf44VKc.d.ts +7 -0
  60. package/dist/{types-BicfRVrV.d.ts → types-ee3zJ6Cc.d.ts} +6 -5
  61. package/dist/workbench/browser-element-context/index.d.ts +37 -0
  62. package/dist/workbench/browser-element-context/index.js +750 -0
  63. package/dist/workbench/browser-element-context/index.js.map +1 -0
  64. package/dist/workbench/contribution.d.ts +1 -2
  65. package/dist/workbench/contribution.js +4 -4
  66. package/dist/workbench/index.d.ts +1 -2
  67. package/dist/workbench/index.js +4 -4
  68. package/dist/workbench/sessionTitle.js +2 -2
  69. package/dist/workbench/tool-sidebar/index.d.ts +189 -0
  70. package/dist/workbench/tool-sidebar/index.js +1492 -0
  71. package/dist/workbench/tool-sidebar/index.js.map +1 -0
  72. package/dist/workspace-agent-generated-files.d.ts +12 -1
  73. package/package.json +28 -13
  74. package/dist/AgentGUI-DxypmD7b.d.ts +0 -1080
  75. package/dist/agentPlanPromptDispatch-C7cCMjve.d.ts +0 -37
  76. package/dist/chunk-G75CPIVV.js.map +0 -1
  77. package/dist/chunk-JZS4SWFJ.js.map +0 -1
  78. package/dist/chunk-KPMQGPYU.js.map +0 -1
  79. package/dist/chunk-OBWM2RFE.js.map +0 -1
  80. package/dist/chunk-OQR3HXPF.js.map +0 -1
  81. package/dist/chunk-T2NICA5D.js.map +0 -1
  82. package/dist/chunk-VMQNG2KI.js +0 -178
  83. package/dist/chunk-VMQNG2KI.js.map +0 -1
  84. package/dist/chunk-YWHGCKMT.js.map +0 -1
  85. package/dist/pastedTextKinds-D-XuInaS.d.ts +0 -4
  86. package/dist/runtime-BBNdWgDU.d.ts +0 -10
  87. package/dist/workspaceAgentActivityListTypes-DZfS_HgG.d.ts +0 -48
  88. /package/dist/{AgentRichTextReadonly-PEKCMRPE.js.map → AgentRichTextReadonly-HCKTNAYO.js.map} +0 -0
  89. /package/dist/{chunk-PQJXWXTS.js.map → chunk-25VMCMAQ.js.map} +0 -0
  90. /package/dist/{chunk-QQRTUHCH.js.map → chunk-EU7DCT4F.js.map} +0 -0
  91. /package/dist/{chunk-SZOTLVH6.js.map → chunk-GIYGO2PB.js.map} +0 -0
  92. /package/dist/{chunk-GCQYN7BR.js.map → chunk-IN3HXYOO.js.map} +0 -0
  93. /package/dist/{chunk-J4TTEMRW.js.map → chunk-KWGMK4IZ.js.map} +0 -0
  94. /package/dist/{chunk-UARZZJJB.js.map → chunk-OI6BYC7P.js.map} +0 -0
  95. /package/dist/{chunk-XNE2ROCP.js.map → chunk-UA75CGAG.js.map} +0 -0
  96. /package/dist/{chunk-PVTAFUDS.js.map → chunk-VGS7S7YT.js.map} +0 -0
package/README.md CHANGED
@@ -44,8 +44,20 @@ local persistence and returns `{ path, name, sizeBytes }`.
44
44
  If the method is absent or staging fails, the attachment remains in an explicit
45
45
  failed state and retains its in-memory text. AgentGUI must not silently put the
46
46
  payload back into the input. The user can explicitly choose “Show in text
47
- field” to do that. Generic `uploadPromptContent` remains the contract for
48
- images and host-local files; it is not a pasted-text capability signal.
47
+ field” to do that. Generic `uploadPromptContent` remains the image-upload
48
+ contract; it is not a pasted-text or external-file capability signal.
49
+
50
+ ## External File Preparation
51
+
52
+ OS clipboard and drop files use the required workspace
53
+ `prepareExternalPromptFiles` host port. AgentGUI owns classification, pending
54
+ mentions, and draft reconciliation. The host owns native-path lookup, size
55
+ enforcement, persistence, and remote transport.
56
+
57
+ The preparer returns one result per input `sourceIndex`. Prepared files require
58
+ a provider-readable `path` or `url`; failures require a typed `errorCode`.
59
+ Hosts must isolate per-file failures and reject oversized inputs before reading
60
+ or persisting their bytes.
49
61
 
50
62
  Slash commands come from the runtime session command snapshot. AgentGUI keeps
51
63
  legacy provider-default slash entries unless the host passes
@@ -154,6 +166,7 @@ export interface AgentGUIAgent {
154
166
  agentTargetId: string;
155
167
  name: string;
156
168
  iconUrl: string;
169
+ sidebarIconUrl?: string | null;
157
170
  heroImageUrl?: string | null;
158
171
  description?: string | null;
159
172
  owner?: {
@@ -186,8 +199,12 @@ Runnable provider targets are host-supplied. If the target catalog is absent,
186
199
  AgentGUI presents an explicit unavailable state; it does not synthesize local
187
200
  targets from presentation metadata.
188
201
 
189
- Agent names, primary icons, and optional home-carousel artwork come from
190
- `agents[].name`, `agents[].iconUrl`, and `agents[].heroImageUrl`.
202
+ Agent names, primary icons, optional conversation-mask icons, optional
203
+ rail-specific icons, and optional home-carousel artwork come from
204
+ `agents[].name`, `agents[].iconUrl`, `agents[].maskIconUrl`,
205
+ `agents[].sidebarIconUrl`, and `agents[].heroImageUrl`. Provider rail surfaces
206
+ prefer `sidebarIconUrl`; conversation rows use `maskIconUrl` where present;
207
+ other identity surfaces retain `iconUrl`.
191
208
  `owner.avatarUrl` is rendered separately as an ownership badge. Invalid entries
192
209
  and duplicate `agentTargetId` values are discarded by
193
210
  `normalizeAgentGUIAgents`, with the first occurrence preserving host order.
@@ -1,18 +1,19 @@
1
1
  import {
2
2
  AgentRichTextReadonly
3
- } from "./chunk-XNE2ROCP.js";
4
- import "./chunk-OBWM2RFE.js";
3
+ } from "./chunk-UA75CGAG.js";
4
+ import "./chunk-QPEO4OQS.js";
5
5
  import "./chunk-5QPOMKMQ.js";
6
- import "./chunk-KPMQGPYU.js";
6
+ import "./chunk-FGLQZ6I4.js";
7
+ import "./chunk-ZVYUTXQJ.js";
7
8
  import "./chunk-EDNJMG5T.js";
8
- import "./chunk-SZOTLVH6.js";
9
+ import "./chunk-GIYGO2PB.js";
9
10
  import "./chunk-PJP5BUU6.js";
10
11
  import "./chunk-7KVZPJ3O.js";
11
- import "./chunk-OQR3HXPF.js";
12
+ import "./chunk-VUNVGEQG.js";
12
13
  import "./chunk-D2JUDUYY.js";
13
14
  import "./chunk-6CUELYIF.js";
14
15
  import "./chunk-QMMWKQOT.js";
15
16
  export {
16
17
  AgentRichTextReadonly
17
18
  };
18
- //# sourceMappingURL=AgentRichTextReadonly-PEKCMRPE.js.map
19
+ //# sourceMappingURL=AgentRichTextReadonly-HCKTNAYO.js.map
@@ -1,14 +1,12 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, JSX } from 'react';
3
- import { c as AgentConversationVM, e as WorkspaceLinkAction, d as WorkspaceAgentSessionDetailViewModel } from '../agentConversationVM-BD0-gg6C.js';
4
- export { B as BuildWorkspaceAgentSessionDetailInput, W as WorkspaceAgentActivityTimelineItem, f as buildWorkspaceAgentSessionDetailViewModel } from '../agentConversationVM-BD0-gg6C.js';
5
- import { d as AgentGUIProviderSkillOption, q as AgentMessageMarkdownWorkspaceAppIcon } from '../agentGuiNodeTypes-5TL1hyCN.js';
6
- export { W as WorkspaceAgentActivityCard } from '../workspaceAgentActivityListTypes-DZfS_HgG.js';
3
+ import { c as AgentConversationVM, g as WorkspaceLinkAction, f as WorkspaceAgentSessionDetailViewModel } from '../agentConversationVM-DWEy7jzx.js';
4
+ export { B as BuildWorkspaceAgentSessionDetailInput, W as WorkspaceAgentActivityCard, e as WorkspaceAgentActivityTimelineItem, h as buildWorkspaceAgentSessionDetailViewModel } from '../agentConversationVM-DWEy7jzx.js';
5
+ import { d as AgentGUIProviderSkillOption, h as AgentMessageMarkdownWorkspaceAppIcon } from '../agentGuiNodeTypes-DV7KvZRe.js';
7
6
  import '@tutti-os/workspace-issue-manager/core';
8
7
  import '@tutti-os/agent-activity-core';
9
- import '../types-BicfRVrV.js';
8
+ import '../types-ee3zJ6Cc.js';
10
9
  import '@tutti-os/workspace-user-project/contracts';
11
- import '../pastedTextKinds-D-XuInaS.js';
12
10
 
13
11
  interface AgentConversationFlowProps {
14
12
  conversation: AgentConversationVM | null;
@@ -6,25 +6,25 @@ import {
6
6
  projectAgentConversationVM,
7
7
  reconcileProjectedAgentConversationVM,
8
8
  useProjectedAgentConversation
9
- } from "../chunk-JZS4SWFJ.js";
10
- import "../chunk-XNE2ROCP.js";
11
- import "../chunk-VMQNG2KI.js";
12
- import "../chunk-FGLQZ6I4.js";
9
+ } from "../chunk-JI5KND3K.js";
10
+ import "../chunk-UA75CGAG.js";
11
+ import "../chunk-FM42UN2J.js";
13
12
  import "../chunk-XJ34OIEQ.js";
14
13
  import "../chunk-R7AXDQCA.js";
15
- import "../chunk-OBWM2RFE.js";
14
+ import "../chunk-QPEO4OQS.js";
16
15
  import "../chunk-5QPOMKMQ.js";
17
- import "../chunk-YWHGCKMT.js";
18
- import "../chunk-KPMQGPYU.js";
19
- import "../chunk-NE6H7S5Z.js";
16
+ import "../chunk-FGLQZ6I4.js";
17
+ import "../chunk-IYZ4GOSN.js";
18
+ import "../chunk-ZVYUTXQJ.js";
19
+ import "../chunk-OFJNIQWR.js";
20
20
  import "../chunk-F5UR6EJG.js";
21
21
  import "../chunk-EDNJMG5T.js";
22
22
  import {
23
23
  translate
24
- } from "../chunk-SZOTLVH6.js";
24
+ } from "../chunk-GIYGO2PB.js";
25
25
  import "../chunk-PJP5BUU6.js";
26
26
  import "../chunk-7KVZPJ3O.js";
27
- import "../chunk-OQR3HXPF.js";
27
+ import "../chunk-VUNVGEQG.js";
28
28
  import "../chunk-MIJXEELH.js";
29
29
  import "../chunk-D2JUDUYY.js";
30
30
  import "../chunk-6CUELYIF.js";
@@ -1,36 +1,19 @@
1
+ import { ReactNode, ReactElement } from 'react';
1
2
  import { AgentProviderActiveActionStepStatus, AgentProviderActiveActionPhase, AgentProviderActiveActionError, AgentProviderActiveAction, AgentProviderActiveActionStep, AgentProviderStatus, WorkspaceAgentProvider } from '@tutti-os/client-tuttid-ts';
2
3
 
3
- /**
4
- * Section the Agent Env panel (the片6 Setup Wizard / config panel) should scroll
5
- * to / emphasise when opened via a deep-link. The error card (片5) maps a domain
6
- * error code to one of these so the user lands on the relevant remediation.
7
- */
4
+ /** Setup section requested by an AgentGUI remediation action. */
8
5
  type AgentEnvPanelFocus = "detect" | "install" | "repair" | "upgrade" | "auth" | "network" | "registry";
9
- interface AgentEnvPanelRequest {
10
- open: boolean;
11
- provider: string | null;
12
- focus: AgentEnvPanelFocus | null;
13
- /**
14
- * Bumped on every openAgentEnvPanel() call. The host panel watches this to
15
- * re-run detection even when it is already open (e.g. a second deep-link).
16
- */
17
- requestSequence: number;
18
- }
19
6
  interface OpenAgentEnvPanelInput {
20
7
  provider?: string | null;
21
8
  focus?: AgentEnvPanelFocus | null;
22
9
  }
23
- /**
24
- * Open the agent environment panel. Safe to call from anywhere in the agent-gui
25
- * tree (rail footer entry, error-card deep-link). The host renders the actual
26
- * panel and reacts to this singleton store.
27
- */
28
- declare function openAgentEnvPanel(input?: OpenAgentEnvPanelInput): void;
29
- declare function closeAgentEnvPanel(): void;
30
- /** Imperative read, mainly for tests. Components should use the hook. */
31
- declare function getAgentEnvPanelStore(): AgentEnvPanelRequest;
32
- /** Reactive snapshot of the panel request for the host renderer. */
33
- declare function useAgentEnvPanelRequest(): AgentEnvPanelRequest;
10
+ type OpenAgentEnvPanelAction = (input?: OpenAgentEnvPanelInput) => void;
11
+ declare function AgentEnvPanelActionProvider({ children, openPanel }: {
12
+ children: ReactNode;
13
+ openPanel?: OpenAgentEnvPanelAction;
14
+ }): ReactElement;
15
+ /** Host-injected command; AgentGUI never owns the panel workflow state. */
16
+ declare function useOpenAgentEnvPanel(): OpenAgentEnvPanelAction | null;
34
17
 
35
18
  /**
36
19
  * Run-failure codes actually emitted by the daemon runtime classifier
@@ -258,4 +241,4 @@ interface AgentEnvWizardViewModel {
258
241
  }
259
242
  declare function buildAgentEnvWizardViewModel(input: AgentEnvWizardViewModelInput): AgentEnvWizardViewModel;
260
243
 
261
- export { type AgentEnvPanelFocus, type AgentEnvPanelRequest, type AgentEnvWizardViewModel, type AgentEnvWizardViewModelInput, type AgentErrorPresentation, type AgentRunErrorCode, type AgentSetupStage, type AgentSetupStageId, type AgentSetupStageLabels, type CodexSetupActiveAction, type CodexSetupActiveActionError, type CodexSetupPhase, type CodexSetupStep, type CodexSetupStepStatus, type DeriveAgentSetupStagesInput, type NetworkCheck, type OpenAgentEnvPanelInput, type ResolveWizardAutoStartInput, type StageActionId, type StageDetailToken, type StageProblem, type StageRemediation, buildAgentEnvWizardViewModel, classifyFailedAgentMessage, closeAgentEnvPanel, deriveAgentSetupStages, deriveHasAnomaly, getAgentEnvPanelStore, openAgentEnvPanel, projectRevealedStages, readCodexSetupActiveAction, reasonCodeIndicatesCliVersionUnsupported, resolveAgentErrorPresentation, resolveWizardAutoStartAction, shouldAdvanceReveal, stageRemediation, useAgentEnvPanelRequest };
244
+ export { AgentEnvPanelActionProvider, type AgentEnvPanelFocus, type AgentEnvWizardViewModel, type AgentEnvWizardViewModelInput, type AgentErrorPresentation, type AgentRunErrorCode, type AgentSetupStage, type AgentSetupStageId, type AgentSetupStageLabels, type CodexSetupActiveAction, type CodexSetupActiveActionError, type CodexSetupPhase, type CodexSetupStep, type CodexSetupStepStatus, type DeriveAgentSetupStagesInput, type NetworkCheck, type OpenAgentEnvPanelAction, type OpenAgentEnvPanelInput, type ResolveWizardAutoStartInput, type StageActionId, type StageDetailToken, type StageProblem, type StageRemediation, buildAgentEnvWizardViewModel, classifyFailedAgentMessage, deriveAgentSetupStages, deriveHasAnomaly, projectRevealedStages, readCodexSetupActiveAction, reasonCodeIndicatesCliVersionUnsupported, resolveAgentErrorPresentation, resolveWizardAutoStartAction, shouldAdvanceReveal, stageRemediation, useOpenAgentEnvPanel };
@@ -1,300 +1,24 @@
1
1
  import {
2
+ AgentEnvPanelActionProvider,
3
+ buildAgentEnvWizardViewModel,
2
4
  classifyFailedAgentMessage,
3
- closeAgentEnvPanel,
4
- getAgentEnvPanelStore,
5
- openAgentEnvPanel,
5
+ deriveAgentSetupStages,
6
+ deriveHasAnomaly,
7
+ projectRevealedStages,
8
+ readCodexSetupActiveAction,
9
+ reasonCodeIndicatesCliVersionUnsupported,
6
10
  resolveAgentErrorPresentation,
7
- useAgentEnvPanelRequest
8
- } from "../chunk-VMQNG2KI.js";
9
-
10
- // shared/agentEnv/codexSetupContract.ts
11
- function readCodexSetupActiveAction(status) {
12
- return status?.activeAction ?? null;
13
- }
14
-
15
- // shared/agentEnv/agentEnvWizardFlow.ts
16
- function reasonCodeIndicatesCliVersionUnsupported(reasonCode) {
17
- const lower = (reasonCode ?? "").toLowerCase();
18
- return lower.includes("version") && !lower.includes("adapter");
19
- }
20
- var INSTALLING_PHASES = /* @__PURE__ */ new Set([
21
- "install",
22
- "repair",
23
- "verify"
24
- ]);
25
- function deriveAgentSetupStages(input) {
26
- const installing = input.installActionPending || (input.activePhase ? INSTALLING_PHASES.has(input.activePhase) : false);
27
- const detectStatus = input.detected ? "ok" : "running";
28
- const networkStatus = !input.detected ? "pending" : input.networkReachable === false ? "error" : "ok";
29
- const cliOk = input.ready || input.cliInstalled && !input.versionTooOld && !input.platformPackageIncomplete;
30
- const installStatus = cliOk ? "ok" : installing ? "running" : input.versionTooOld ? "error" : "pending";
31
- const installProblem = input.platformPackageIncomplete && !cliOk ? "install-platform-incomplete" : void 0;
32
- const adapterOk = input.ready || input.adapterInstalled && !input.adapterVersionMismatch;
33
- const adapterStatus = adapterOk ? "ok" : installing ? "running" : input.adapterVersionMismatch ? "error" : "pending";
34
- const loginStatus = input.authenticated ? "ok" : input.loginPending ? "running" : "pending";
35
- const readyStatus = input.ready ? "ok" : "pending";
36
- return [
37
- {
38
- id: "detect",
39
- label: input.labels.detect,
40
- status: detectStatus,
41
- detail: null
42
- },
43
- {
44
- id: "network",
45
- label: input.labels.network,
46
- status: networkStatus,
47
- detail: input.networkDetail
48
- },
49
- {
50
- id: "install",
51
- label: input.labels.install,
52
- status: installStatus,
53
- detail: input.cliVersionDetail,
54
- ...installProblem ? { problem: installProblem } : {}
55
- },
56
- {
57
- id: "adapter",
58
- label: input.labels.adapter,
59
- status: adapterStatus,
60
- detail: input.adapterDetail
61
- },
62
- {
63
- id: "login",
64
- label: input.labels.login,
65
- status: loginStatus,
66
- detail: input.accountDetail,
67
- authMethod: input.authMethod
68
- },
69
- {
70
- id: "ready",
71
- label: input.labels.ready,
72
- status: readyStatus,
73
- detail: null
74
- }
75
- ];
76
- }
77
- function projectRevealedStages(realStages, revealIndex) {
78
- return realStages.map((stage, index) => {
79
- if (index < revealIndex) {
80
- return stage;
81
- }
82
- if (index === revealIndex) {
83
- if (stage.status === "ok" || stage.status === "skipped") {
84
- return { ...stage, status: "running" };
85
- }
86
- return stage;
87
- }
88
- return { ...stage, status: "pending" };
89
- });
90
- }
91
- function shouldAdvanceReveal(realStages, revealIndex) {
92
- const cursor = realStages[revealIndex];
93
- if (!cursor) {
94
- return false;
95
- }
96
- return cursor.status === "ok" || cursor.status === "skipped";
97
- }
98
- function stageRemediation(stage) {
99
- if (stage.status !== "pending" && stage.status !== "error") {
100
- return null;
101
- }
102
- switch (stage.id) {
103
- case "network":
104
- return { actionId: "redetect", problem: "network-unreachable" };
105
- case "install":
106
- if (stage.problem) {
107
- return { actionId: "install", problem: stage.problem };
108
- }
109
- return stage.status === "error" ? { actionId: "redetect", problem: "install-outdated" } : { actionId: "install", problem: "install-missing" };
110
- case "adapter":
111
- return {
112
- actionId: "install",
113
- problem: stage.status === "error" ? "adapter-mismatch" : "adapter-missing"
114
- };
115
- case "login":
116
- return { actionId: "login", problem: "login-missing" };
117
- default:
118
- return null;
119
- }
120
- }
121
- function resolveWizardAutoStartAction(input) {
122
- const candidate = autoStartCandidate(input.focus);
123
- if (!candidate) {
124
- return null;
125
- }
126
- if (!input.detected || input.ready) {
127
- return null;
128
- }
129
- if (candidate === "install" && input.installPending) {
130
- return null;
131
- }
132
- if (candidate === "login" && input.loginPending) {
133
- return null;
134
- }
135
- return candidate;
136
- }
137
- function autoStartCandidate(focus) {
138
- switch (focus) {
139
- case "install":
140
- case "repair":
141
- return "install";
142
- case "upgrade":
143
- return null;
144
- case "auth":
145
- return "login";
146
- default:
147
- return null;
148
- }
149
- }
150
-
151
- // shared/agentEnv/agentEnvViewModel.ts
152
- var MANUAL_INSTALL_COMMANDS = {
153
- codex: "npm install -g @openai/codex --include=optional",
154
- "claude-code": "curl -fsSL https://claude.ai/install.sh | bash",
155
- cursor: "curl https://cursor.com/install -fsS | bash",
156
- opencode: "curl -fsSL https://opencode.ai/install | bash"
157
- };
158
- function endpointHost(endpoint) {
159
- if (!endpoint) {
160
- return null;
161
- }
162
- return endpoint.replace(/^https?:\/\//, "").replace(/\/.*$/, "") || null;
163
- }
164
- function scrubProxyUrl(url) {
165
- if (!url) {
166
- return null;
167
- }
168
- try {
169
- const parsed = new URL(url);
170
- parsed.username = "";
171
- parsed.password = "";
172
- return `${parsed.protocol}//${parsed.host}`;
173
- } catch {
174
- return url.replace(/\/\/[^/@]*@/, "//") || null;
175
- }
176
- }
177
- function textToken(text) {
178
- return text ? { kind: "text", text } : null;
179
- }
180
- function joinDetail(parts) {
181
- const joined = parts.filter((p) => Boolean(p)).join(" \xB7 ");
182
- return joined || null;
183
- }
184
- function deriveHasAnomaly(stages, activeActionError) {
185
- return stages.some((s) => s.status === "error") || Boolean(activeActionError);
186
- }
187
- function buildAgentEnvWizardViewModel(input) {
188
- const { status, activeAction, provider } = input;
189
- const ready = status?.availability.status === "ready";
190
- const installPending = input.installActionPending;
191
- const loginPending = input.loginPending;
192
- const busy = installPending || activeAction?.phase === "install" || activeAction?.phase === "repair" || activeAction?.phase === "verify";
193
- const reasonCode = (status?.availability.reasonCode ?? "").toLowerCase();
194
- const versionTooOld = reasonCodeIndicatesCliVersionUnsupported(reasonCode);
195
- const cliBelowFloor = reasonCode.includes("codex_version_too_old");
196
- const platformPackageIncomplete = reasonCode.includes(
197
- "codex_platform_pkg_incomplete"
198
- );
199
- const adapterVersionMismatch = reasonCode.includes(
200
- "acp_adapter_version_mismatch"
201
- );
202
- const cliDetail = cliBelowFloor && status?.cli.version && status.cli.minVersion ? {
203
- kind: "version-floor",
204
- current: status.cli.version,
205
- required: status.cli.minVersion
206
- } : status?.cli.installed ? textToken(joinDetail([status?.cli.version, status?.cli.binaryPath])) : textToken(status?.cli.version ?? null);
207
- const adapterDetail = adapterVersionMismatch && status?.adapter.version && status?.adapter.requiredVersion ? {
208
- kind: "version-mismatch",
209
- current: status.adapter.version,
210
- required: status.adapter.requiredVersion
211
- } : status?.adapter.installed ? textToken(
212
- joinDetail([status?.adapter.version, status?.adapter.binaryPath])
213
- ) : textToken(
214
- status?.adapter.binaryPath ?? (status?.adapter.command?.length ? status.adapter.command.join(" ") : null)
215
- );
216
- const networkChecks = status?.network ? [
217
- {
218
- kind: "registry",
219
- reachable: status.network.registry.reachable,
220
- host: endpointHost(status.network.registry.endpoint)
221
- },
222
- ...status.network.providerApi ? [
223
- {
224
- kind: "api",
225
- reachable: status.network.providerApi.reachable,
226
- host: endpointHost(status.network.providerApi.endpoint)
227
- }
228
- ] : [],
229
- ...status.network.proxy ? [
230
- {
231
- kind: "proxy",
232
- reachable: !status.network.proxy.configured || status.network.proxy.reachable,
233
- host: scrubProxyUrl(status.network.proxy.url),
234
- configured: status.network.proxy.configured
235
- }
236
- ] : []
237
- ] : [];
238
- const networkReachable = networkChecks.length === 0 ? null : networkChecks.every((c) => c.reachable);
239
- const accountDetail = status?.auth.accountLabel ? { kind: "text", text: status.auth.accountLabel } : status?.auth.status === "authenticated" ? { kind: "text", text: "__SIGNED_IN__" } : null;
240
- const authMethod = status?.auth.authMethod ?? null;
241
- const stages = deriveAgentSetupStages({
242
- detected: status !== null,
243
- cliInstalled: status?.cli.installed ?? false,
244
- versionTooOld,
245
- platformPackageIncomplete,
246
- adapterInstalled: status?.adapter.installed ?? false,
247
- adapterVersionMismatch,
248
- authenticated: status?.auth.status === "authenticated",
249
- authRequired: status?.auth.status === "required",
250
- ready: Boolean(ready),
251
- activePhase: activeAction?.phase ?? null,
252
- installActionPending: installPending,
253
- loginPending,
254
- networkReachable,
255
- cliVersionDetail: cliDetail,
256
- adapterDetail,
257
- accountDetail,
258
- authMethod,
259
- networkDetail: null,
260
- labels: input.stageLabels
261
- });
262
- const registry = activeAction?.registry ?? null;
263
- const stagesWithDetail = registry ? stages.map(
264
- (s) => s.id === "ready" ? { ...s, detail: { kind: "text", text: registry } } : s
265
- ) : stages;
266
- const displayStages = projectRevealedStages(
267
- stagesWithDetail,
268
- input.revealIndex
269
- );
270
- const blockingIndex = stages.findIndex((s) => s.status !== "ok");
271
- const blockingStage = blockingIndex >= 0 ? stages[blockingIndex] : void 0;
272
- const blockingStageId = blockingStage && input.revealIndex >= blockingIndex ? blockingStage.id : null;
273
- return {
274
- ready: Boolean(ready),
275
- busy: Boolean(busy),
276
- redetecting: input.isLoading,
277
- displayStages,
278
- blockingStageId,
279
- networkChecks,
280
- hasAnomaly: deriveHasAnomaly(stages, activeAction?.error ?? null),
281
- activePhase: activeAction?.phase ?? null,
282
- log: activeAction?.log ?? [],
283
- registry,
284
- error: activeAction?.error ?? null,
285
- manualCommand: MANUAL_INSTALL_COMMANDS[provider] ?? null,
286
- installPending,
287
- loginPending
288
- };
289
- }
11
+ resolveWizardAutoStartAction,
12
+ shouldAdvanceReveal,
13
+ stageRemediation,
14
+ useOpenAgentEnvPanel
15
+ } from "../chunk-FM42UN2J.js";
290
16
  export {
17
+ AgentEnvPanelActionProvider,
291
18
  buildAgentEnvWizardViewModel,
292
19
  classifyFailedAgentMessage,
293
- closeAgentEnvPanel,
294
20
  deriveAgentSetupStages,
295
21
  deriveHasAnomaly,
296
- getAgentEnvPanelStore,
297
- openAgentEnvPanel,
298
22
  projectRevealedStages,
299
23
  readCodexSetupActiveAction,
300
24
  reasonCodeIndicatesCliVersionUnsupported,
@@ -302,6 +26,6 @@ export {
302
26
  resolveWizardAutoStartAction,
303
27
  shouldAdvanceReveal,
304
28
  stageRemediation,
305
- useAgentEnvPanelRequest
29
+ useOpenAgentEnvPanel
306
30
  };
307
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../shared/agentEnv/codexSetupContract.ts","../../shared/agentEnv/agentEnvWizardFlow.ts","../../shared/agentEnv/agentEnvViewModel.ts"],"sourcesContent":["import type {\n AgentProviderActiveAction,\n AgentProviderActiveActionError,\n AgentProviderActiveActionPhase,\n AgentProviderActiveActionStep,\n AgentProviderActiveActionStepStatus,\n AgentProviderStatus\n} from \"@tutti-os/client-tuttid-ts\";\n\n// Compatibility aliases for the existing Agent Environment UI. The wire\n// contract is generated from OpenAPI; this module must not maintain a second\n// parser or enum vocabulary.\nexport type CodexSetupStepStatus = AgentProviderActiveActionStepStatus;\nexport type CodexSetupStep = AgentProviderActiveActionStep;\nexport type CodexSetupPhase = AgentProviderActiveActionPhase;\nexport type CodexSetupActiveActionError = AgentProviderActiveActionError;\nexport type CodexSetupActiveAction = AgentProviderActiveAction;\n\nexport function readCodexSetupActiveAction(\n status: Pick<AgentProviderStatus, \"activeAction\"> | null | undefined\n): AgentProviderActiveAction | null {\n return status?.activeAction ?? null;\n}\n","import type { AgentEnvPanelFocus } from \"./agentEnvPanelStore\";\nimport type {\n CodexSetupPhase,\n CodexSetupStepStatus\n} from \"./codexSetupContract\";\n\nexport type AgentSetupStageId =\n | \"detect\"\n | \"network\"\n | \"install\"\n | \"adapter\"\n | \"login\"\n | \"ready\";\n\nexport type StageDetailToken =\n | { kind: \"text\"; text: string }\n | { kind: \"version-floor\"; current: string; required: string }\n | { kind: \"version-mismatch\"; current: string; required: string };\n\n// Whether an availability reason code means the CLI itself is on an unsupported\n// version — as opposed to an ADAPTER version mismatch. The adapter reason code\n// `acp_adapter_version_mismatch` also contains the substring \"version\", so a\n// plain `includes(\"version\")` test wrongly paints the CLI step red (\"版本不受支持\")\n// when only the adapter is mismatched. Require \"version\" but exclude any adapter\n// reason so the CLI and adapter stages stay independent.\nexport function reasonCodeIndicatesCliVersionUnsupported(\n reasonCode: string | null | undefined\n): boolean {\n const lower = (reasonCode ?? \"\").toLowerCase();\n return lower.includes(\"version\") && !lower.includes(\"adapter\");\n}\n\nexport interface AgentSetupStage {\n id: AgentSetupStageId;\n label: string;\n status: CodexSetupStepStatus;\n detail: StageDetailToken | null;\n /**\n * Optional explicit problem token for a blocked stage that can't be inferred\n * from `status` alone. Today only the install stage sets it — when the codex\n * launcher is present but its platform subpackage is missing, the stage is\n * `pending` (the daemon repairs it via the install action) yet needs a distinct\n * \"platform package missing\" problem rather than the generic \"install-missing\".\n */\n problem?: StageProblem;\n authMethod?: string | null;\n}\n\nexport interface AgentSetupStageLabels {\n detect: string;\n network: string;\n install: string;\n adapter: string;\n login: string;\n ready: string;\n}\n\nexport interface DeriveAgentSetupStagesInput {\n detected: boolean;\n cliInstalled: boolean;\n versionTooOld: boolean;\n /**\n * The codex CLI launcher is resolved but its platform-specific optional\n * dependency subpackage (e.g. @openai/codex-darwin-arm64) is missing — the\n * binary spawns ENOENT. The daemon repairs this in place via the install\n * action, so the install stage is `pending` (not `ok`) with a distinct\n * \"platform package missing\" problem token.\n */\n platformPackageIncomplete?: boolean;\n adapterInstalled: boolean;\n adapterVersionMismatch: boolean;\n authenticated: boolean;\n authRequired: boolean;\n ready: boolean;\n activePhase: CodexSetupPhase | null;\n /**\n * Whether the daemon-driven install action is in flight. This is the\n * authoritative \"installing\" signal: the adapter (external-registry) installer\n * emits no activeAction phase, so without this an in-progress adapter install\n * would show no spinner.\n */\n installActionPending: boolean;\n loginPending: boolean;\n /**\n * Active connectivity probe verdict: true (reachable), false (offline), or\n * null when the daemon reported no network info (older daemon / not probed) —\n * null is treated as \"don't block\".\n */\n networkReachable: boolean | null;\n cliVersionDetail: StageDetailToken | null;\n adapterDetail: StageDetailToken | null;\n accountDetail: StageDetailToken | null;\n authMethod: string | null;\n networkDetail: StageDetailToken | null;\n labels: AgentSetupStageLabels;\n}\n\nconst INSTALLING_PHASES: ReadonlySet<CodexSetupPhase> = new Set([\n \"install\",\n \"repair\",\n \"verify\"\n]);\n\n/**\n * Maps primitive provider-status flags onto the fixed 5-stage track the wizard\n * renders. Version verification folds into the install (CLI) stage (an\n * unsupported version means install is `error`, not `ok`). The adapter stage\n * covers any provider runtime component installed separately from its CLI,\n * such as an SDK sidecar; where no separate component exists it simply tracks\n * the CLI. Login `running` is driven\n * by the caller's pending flag because login runs as a terminal action, not via\n * the activeAction phase stream.\n */\nexport function deriveAgentSetupStages(\n input: DeriveAgentSetupStagesInput\n): AgentSetupStage[] {\n const installing =\n input.installActionPending ||\n (input.activePhase ? INSTALLING_PHASES.has(input.activePhase) : false);\n\n const detectStatus: CodexSetupStepStatus = input.detected ? \"ok\" : \"running\";\n\n // Network is an independent live-connectivity check (registry + provider API),\n // so it is NOT folded into the `ready` short-circuit — a real outage shows even\n // when the CLI is otherwise configured. It can only be judged once detection\n // has run; `false` is the only blocking value (null = no daemon verdict).\n const networkStatus: CodexSetupStepStatus = !input.detected\n ? \"pending\"\n : input.networkReachable === false\n ? \"error\"\n : \"ok\";\n\n // A satisfied CLI stays checked even while an install runs, so the spinner\n // lands on the stage actually being worked on (e.g. the adapter during a\n // repair) rather than flipping every install-related stage back to running.\n // A present launcher with a missing platform subpackage is NOT ok — the\n // daemon repairs it via the install action, so it reads as a pending install.\n const cliOk =\n input.ready ||\n (input.cliInstalled &&\n !input.versionTooOld &&\n !input.platformPackageIncomplete);\n const installStatus: CodexSetupStepStatus = cliOk\n ? \"ok\"\n : installing\n ? \"running\"\n : input.versionTooOld\n ? \"error\"\n : \"pending\";\n const installProblem: StageProblem | undefined =\n input.platformPackageIncomplete && !cliOk\n ? \"install-platform-incomplete\"\n : undefined;\n\n const adapterOk =\n input.ready || (input.adapterInstalled && !input.adapterVersionMismatch);\n const adapterStatus: CodexSetupStepStatus = adapterOk\n ? \"ok\"\n : installing\n ? \"running\"\n : input.adapterVersionMismatch\n ? \"error\"\n : \"pending\";\n\n const loginStatus: CodexSetupStepStatus = input.authenticated\n ? \"ok\"\n : input.loginPending\n ? \"running\"\n : \"pending\";\n\n const readyStatus: CodexSetupStepStatus = input.ready ? \"ok\" : \"pending\";\n\n return [\n {\n id: \"detect\",\n label: input.labels.detect,\n status: detectStatus,\n detail: null\n },\n {\n id: \"network\",\n label: input.labels.network,\n status: networkStatus,\n detail: input.networkDetail\n },\n {\n id: \"install\",\n label: input.labels.install,\n status: installStatus,\n detail: input.cliVersionDetail,\n ...(installProblem ? { problem: installProblem } : {})\n },\n {\n id: \"adapter\",\n label: input.labels.adapter,\n status: adapterStatus,\n detail: input.adapterDetail\n },\n {\n id: \"login\",\n label: input.labels.login,\n status: loginStatus,\n detail: input.accountDetail,\n authMethod: input.authMethod\n },\n {\n id: \"ready\",\n label: input.labels.ready,\n status: readyStatus,\n detail: null\n }\n ];\n}\n\n/**\n * Step-by-step reveal: even when prerequisites are already satisfied, the wizard\n * walks a cursor down the track so each stage visibly \"checks off\" one at a time\n * instead of all flashing complete at once.\n *\n * `revealIndex` is the cursor position. Stages before it show their real status\n * (already revealed). The stage AT the cursor is shown as `running` when its\n * real status is terminal-ok (the brief \"working on it\" moment before it checks\n * off) and otherwise shows its real status (so a genuinely running install, an\n * error, or a blocked prerequisite are honest). Stages after the cursor are\n * dimmed to `pending`.\n */\nexport function projectRevealedStages(\n realStages: AgentSetupStage[],\n revealIndex: number\n): AgentSetupStage[] {\n return realStages.map((stage, index) => {\n if (index < revealIndex) {\n return stage;\n }\n if (index === revealIndex) {\n if (stage.status === \"ok\" || stage.status === \"skipped\") {\n return { ...stage, status: \"running\" };\n }\n return stage;\n }\n return { ...stage, status: \"pending\" };\n });\n}\n\n/**\n * The reveal cursor advances past a stage only once that stage is really done\n * (`ok`/`skipped`). It parks on a stage that is still `running` (a real install\n * in progress), `error`, or `pending` (a blocked prerequisite) — so the\n * animation never races ahead of reality.\n */\nexport function shouldAdvanceReveal(\n realStages: AgentSetupStage[],\n revealIndex: number\n): boolean {\n const cursor = realStages[revealIndex];\n if (!cursor) {\n return false;\n }\n return cursor.status === \"ok\" || cursor.status === \"skipped\";\n}\n\nexport type StageActionId = \"install\" | \"login\" | \"redetect\";\n\n/**\n * The problem token a blocked stage represents. The UI maps this to \"未xxx\"\n * copy; keeping it i18n-agnostic here lets the mapping stay tested without\n * pulling translation strings into the pure flow module.\n */\nexport type StageProblem =\n | \"network-unreachable\"\n | \"install-missing\"\n | \"install-outdated\"\n | \"install-platform-incomplete\"\n | \"adapter-missing\"\n | \"adapter-mismatch\"\n | \"login-missing\";\n\nexport interface StageRemediation {\n actionId: StageActionId;\n problem: StageProblem;\n}\n\n/**\n * For a stage the user must act on (idle `pending`/`error`, never `running` or\n * `ok`), returns what is wrong and which action fixes it. `detect`/`ready` never\n * carry their own remediation — they reflect prerequisites, not user actions.\n *\n * `error` means a version problem on the install/adapter stages (the only stages\n * derive marks `error`); `pending` means the step simply has not run yet.\n */\nexport function stageRemediation(\n stage: AgentSetupStage\n): StageRemediation | null {\n if (stage.status !== \"pending\" && stage.status !== \"error\") {\n return null;\n }\n switch (stage.id) {\n case \"network\":\n // Connectivity isn't fixed by an install/login action — re-running\n // detection (which re-probes the network) is the remediation.\n return { actionId: \"redetect\", problem: \"network-unreachable\" };\n case \"install\":\n // An explicit problem token (today: platform subpackage missing) takes\n // precedence — the daemon repairs it in place via the install action, so\n // route through install rather than the manual-upgrade error path.\n if (stage.problem) {\n return { actionId: \"install\", problem: stage.problem };\n }\n // A genuinely missing CLI is installed for the user; a present-but-\n // outdated CLI is NOT — we don't silently reinstall a binary the user\n // manages. Instead the panel shows the manual upgrade command and\n // re-detection confirms it once they've upgraded.\n return stage.status === \"error\"\n ? { actionId: \"redetect\", problem: \"install-outdated\" }\n : { actionId: \"install\", problem: \"install-missing\" };\n case \"adapter\":\n return {\n actionId: \"install\",\n problem:\n stage.status === \"error\" ? \"adapter-mismatch\" : \"adapter-missing\"\n };\n case \"login\":\n return { actionId: \"login\", problem: \"login-missing\" };\n default:\n return null;\n }\n}\n\nexport interface ResolveWizardAutoStartInput {\n focus: AgentEnvPanelFocus | null;\n detected: boolean;\n ready: boolean;\n installPending: boolean;\n loginPending: boolean;\n}\n\n/**\n * Decides whether opening the wizard with a remediation focus should auto-start\n * an action. Returns the action id to run, or null when nothing should run\n * (non-remediation focus, detection not settled, already ready, or already\n * pending). The caller is responsible for firing this at most once per open.\n */\nexport function resolveWizardAutoStartAction(\n input: ResolveWizardAutoStartInput\n): \"install\" | \"login\" | null {\n const candidate = autoStartCandidate(input.focus);\n if (!candidate) {\n return null;\n }\n if (!input.detected || input.ready) {\n return null;\n }\n if (candidate === \"install\" && input.installPending) {\n return null;\n }\n if (candidate === \"login\" && input.loginPending) {\n return null;\n }\n return candidate;\n}\n\nfunction autoStartCandidate(\n focus: AgentEnvPanelFocus | null\n): \"install\" | \"login\" | null {\n switch (focus) {\n case \"install\":\n case \"repair\":\n return \"install\";\n case \"upgrade\":\n // CLI upgrades are user-driven: opening the panel from a version error\n // shows the manual upgrade command rather than auto-running an install\n // (which can't upgrade an already-present binary anyway).\n return null;\n case \"auth\":\n return \"login\";\n default:\n return null;\n }\n}\n","import type {\n AgentProviderStatus,\n WorkspaceAgentProvider\n} from \"@tutti-os/client-tuttid-ts\";\nimport {\n deriveAgentSetupStages,\n projectRevealedStages,\n reasonCodeIndicatesCliVersionUnsupported,\n type AgentSetupStage,\n type AgentSetupStageId,\n type AgentSetupStageLabels,\n type StageDetailToken\n} from \"./agentEnvWizardFlow.ts\";\nimport type {\n CodexSetupActiveAction,\n CodexSetupActiveActionError,\n CodexSetupPhase\n} from \"./codexSetupContract.ts\";\n\nexport interface NetworkCheck {\n kind: \"registry\" | \"api\" | \"proxy\";\n reachable: boolean;\n host: string | null;\n configured?: boolean;\n}\n\nconst MANUAL_INSTALL_COMMANDS: Partial<Record<WorkspaceAgentProvider, string>> =\n {\n codex: \"npm install -g @openai/codex --include=optional\",\n \"claude-code\": \"curl -fsSL https://claude.ai/install.sh | bash\",\n cursor: \"curl https://cursor.com/install -fsS | bash\",\n opencode: \"curl -fsSL https://opencode.ai/install | bash\"\n };\n\nfunction endpointHost(endpoint: string | null | undefined): string | null {\n if (!endpoint) {\n return null;\n }\n return endpoint.replace(/^https?:\\/\\//, \"\").replace(/\\/.*$/, \"\") || null;\n}\n\n// A proxy URL may carry credentials (http://user:pass@host:port). Strip the\n// userinfo before it reaches the renderer/UI so proxy passwords are never\n// surfaced; the scheme + host:port are kept for display.\nfunction scrubProxyUrl(url: string | null | undefined): string | null {\n if (!url) {\n return null;\n }\n try {\n const parsed = new URL(url);\n parsed.username = \"\";\n parsed.password = \"\";\n return `${parsed.protocol}//${parsed.host}`;\n } catch {\n // Not a parseable URL — still strip a leading userinfo segment defensively.\n return url.replace(/\\/\\/[^/@]*@/, \"//\") || null;\n }\n}\n\nfunction textToken(text: string | null): StageDetailToken | null {\n return text ? { kind: \"text\", text } : null;\n}\n\nfunction joinDetail(parts: Array<string | null | undefined>): string | null {\n const joined = parts.filter((p): p is string => Boolean(p)).join(\" · \");\n return joined || null;\n}\n\nexport function deriveHasAnomaly(\n stages: AgentSetupStage[],\n activeActionError: CodexSetupActiveActionError | null\n): boolean {\n return stages.some((s) => s.status === \"error\") || Boolean(activeActionError);\n}\n\nexport interface AgentEnvWizardViewModelInput {\n provider: WorkspaceAgentProvider;\n status: AgentProviderStatus | null;\n isLoading: boolean;\n activeAction: CodexSetupActiveAction | null;\n installActionPending: boolean;\n loginPending: boolean;\n revealIndex: number;\n stageLabels: AgentSetupStageLabels;\n}\n\nexport interface AgentEnvWizardViewModel {\n ready: boolean;\n busy: boolean;\n redetecting: boolean;\n displayStages: AgentSetupStage[];\n blockingStageId: AgentSetupStageId | null;\n networkChecks: NetworkCheck[];\n hasAnomaly: boolean;\n activePhase: CodexSetupPhase | null;\n log: string[];\n registry: string | null;\n error: CodexSetupActiveActionError | null;\n manualCommand: string | null;\n installPending: boolean;\n loginPending: boolean;\n}\n\nexport function buildAgentEnvWizardViewModel(\n input: AgentEnvWizardViewModelInput\n): AgentEnvWizardViewModel {\n const { status, activeAction, provider } = input;\n const ready = status?.availability.status === \"ready\";\n const installPending = input.installActionPending;\n const loginPending = input.loginPending;\n const busy =\n installPending ||\n activeAction?.phase === \"install\" ||\n activeAction?.phase === \"repair\" ||\n activeAction?.phase === \"verify\";\n\n const reasonCode = (status?.availability.reasonCode ?? \"\").toLowerCase();\n const versionTooOld = reasonCodeIndicatesCliVersionUnsupported(reasonCode);\n const cliBelowFloor = reasonCode.includes(\"codex_version_too_old\");\n // The codex launcher is present but its platform subpackage is missing — the\n // CLI spawns ENOENT. The daemon repairs this in place via the install action;\n // the wizard must NOT mark the install stage ok just because the launcher\n // resolved.\n const platformPackageIncomplete = reasonCode.includes(\n \"codex_platform_pkg_incomplete\"\n );\n const adapterVersionMismatch = reasonCode.includes(\n \"acp_adapter_version_mismatch\"\n );\n\n const cliDetail: StageDetailToken | null =\n cliBelowFloor && status?.cli.version && status.cli.minVersion\n ? {\n kind: \"version-floor\",\n current: status.cli.version,\n required: status.cli.minVersion\n }\n : status?.cli.installed\n ? textToken(joinDetail([status?.cli.version, status?.cli.binaryPath]))\n : textToken(status?.cli.version ?? null);\n\n const adapterDetail: StageDetailToken | null =\n adapterVersionMismatch &&\n status?.adapter.version &&\n status?.adapter.requiredVersion\n ? {\n kind: \"version-mismatch\",\n current: status.adapter.version,\n required: status.adapter.requiredVersion\n }\n : status?.adapter.installed\n ? textToken(\n joinDetail([status?.adapter.version, status?.adapter.binaryPath])\n )\n : textToken(\n status?.adapter.binaryPath ??\n (status?.adapter.command?.length\n ? status.adapter.command.join(\" \")\n : null)\n );\n\n const networkChecks: NetworkCheck[] = status?.network\n ? [\n {\n kind: \"registry\",\n reachable: status.network.registry.reachable,\n host: endpointHost(status.network.registry.endpoint)\n },\n ...(status.network.providerApi\n ? [\n {\n kind: \"api\" as const,\n reachable: status.network.providerApi.reachable,\n host: endpointHost(status.network.providerApi.endpoint)\n }\n ]\n : []),\n ...(status.network.proxy\n ? [\n {\n kind: \"proxy\" as const,\n reachable:\n !status.network.proxy.configured ||\n status.network.proxy.reachable,\n host: scrubProxyUrl(status.network.proxy.url),\n configured: status.network.proxy.configured\n }\n ]\n : [])\n ]\n : [];\n const networkReachable =\n networkChecks.length === 0 ? null : networkChecks.every((c) => c.reachable);\n\n const accountDetail: StageDetailToken | null = status?.auth.accountLabel\n ? { kind: \"text\", text: status.auth.accountLabel }\n : status?.auth.status === \"authenticated\"\n ? { kind: \"text\", text: \"__SIGNED_IN__\" }\n : null;\n const authMethod: string | null = status?.auth.authMethod ?? null;\n\n const stages = deriveAgentSetupStages({\n detected: status !== null,\n cliInstalled: status?.cli.installed ?? false,\n versionTooOld,\n platformPackageIncomplete,\n adapterInstalled: status?.adapter.installed ?? false,\n adapterVersionMismatch,\n authenticated: status?.auth.status === \"authenticated\",\n authRequired: status?.auth.status === \"required\",\n ready: Boolean(ready),\n activePhase: activeAction?.phase ?? null,\n installActionPending: installPending,\n loginPending,\n networkReachable,\n cliVersionDetail: cliDetail,\n adapterDetail,\n accountDetail,\n authMethod,\n networkDetail: null,\n labels: input.stageLabels\n });\n\n const registry = activeAction?.registry ?? null;\n const stagesWithDetail = registry\n ? stages.map((s) =>\n s.id === \"ready\"\n ? { ...s, detail: { kind: \"text\" as const, text: registry } }\n : s\n )\n : stages;\n const displayStages = projectRevealedStages(\n stagesWithDetail,\n input.revealIndex\n );\n\n const blockingIndex = stages.findIndex((s) => s.status !== \"ok\");\n const blockingStage = blockingIndex >= 0 ? stages[blockingIndex] : undefined;\n const blockingStageId: AgentSetupStageId | null =\n blockingStage && input.revealIndex >= blockingIndex\n ? blockingStage.id\n : null;\n\n return {\n ready: Boolean(ready),\n busy: Boolean(busy),\n redetecting: input.isLoading,\n displayStages,\n blockingStageId,\n networkChecks,\n hasAnomaly: deriveHasAnomaly(stages, activeAction?.error ?? null),\n activePhase: activeAction?.phase ?? null,\n log: activeAction?.log ?? [],\n registry,\n error: activeAction?.error ?? null,\n manualCommand: MANUAL_INSTALL_COMMANDS[provider] ?? null,\n installPending,\n loginPending\n };\n}\n"],"mappings":";;;;;;;;;;AAkBO,SAAS,2BACd,QACkC;AAClC,SAAO,QAAQ,gBAAgB;AACjC;;;ACGO,SAAS,yCACd,YACS;AACT,QAAM,SAAS,cAAc,IAAI,YAAY;AAC7C,SAAO,MAAM,SAAS,SAAS,KAAK,CAAC,MAAM,SAAS,SAAS;AAC/D;AAmEA,IAAM,oBAAkD,oBAAI,IAAI;AAAA,EAC9D;AA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