@ngockhoale/ckit 0.0.0-stage → 0.1.0

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 (244) hide show
  1. package/.env.example +42 -0
  2. package/README.md +116 -2
  3. package/dist/src/adapters/agent/claude/errors.d.ts +13 -0
  4. package/dist/src/adapters/agent/claude/errors.js +16 -0
  5. package/dist/src/adapters/agent/claude/normalize.d.ts +11 -0
  6. package/dist/src/adapters/agent/claude/normalize.js +83 -0
  7. package/dist/src/adapters/agent/errors.d.ts +13 -0
  8. package/dist/src/adapters/agent/errors.js +19 -0
  9. package/dist/src/adapters/agent/fixtures/claude-transcript.d.ts +70 -0
  10. package/dist/src/adapters/agent/fixtures/claude-transcript.js +15 -0
  11. package/dist/src/adapters/agent/fixtures/omp-transcript.d.ts +60 -0
  12. package/dist/src/adapters/agent/fixtures/omp-transcript.js +14 -0
  13. package/dist/src/adapters/agent/normalize.d.ts +18 -0
  14. package/dist/src/adapters/agent/normalize.js +77 -0
  15. package/dist/src/adapters/agent/transport.d.ts +35 -0
  16. package/dist/src/adapters/agent/transport.js +39 -0
  17. package/dist/src/adapters/agent/worker-service.d.ts +49 -0
  18. package/dist/src/adapters/agent/worker-service.js +77 -0
  19. package/dist/src/adapters/fake/fake-advisor.d.ts +15 -0
  20. package/dist/src/adapters/fake/fake-advisor.js +29 -0
  21. package/dist/src/adapters/fake/fake-agent.d.ts +12 -0
  22. package/dist/src/adapters/fake/fake-agent.js +21 -0
  23. package/dist/src/adapters/fake/fake-store.d.ts +13 -0
  24. package/dist/src/adapters/fake/fake-store.js +23 -0
  25. package/dist/src/adapters/fake/fake-web.d.ts +12 -0
  26. package/dist/src/adapters/fake/fake-web.js +21 -0
  27. package/dist/src/adapters/fake/fault-injector.d.ts +18 -0
  28. package/dist/src/adapters/fake/fault-injector.js +64 -0
  29. package/dist/src/adapters/fake/virtual-clock.d.ts +12 -0
  30. package/dist/src/adapters/fake/virtual-clock.js +35 -0
  31. package/dist/src/adapters/launch/discover.d.ts +18 -0
  32. package/dist/src/adapters/launch/discover.js +55 -0
  33. package/dist/src/adapters/launch/executor.d.ts +117 -0
  34. package/dist/src/adapters/launch/executor.js +383 -0
  35. package/dist/src/adapters/launch/profile.d.ts +35 -0
  36. package/dist/src/adapters/launch/profile.js +73 -0
  37. package/dist/src/adapters/launch/spawn.d.ts +29 -0
  38. package/dist/src/adapters/launch/spawn.js +18 -0
  39. package/dist/src/adapters/openai/openai-advisor.d.ts +56 -0
  40. package/dist/src/adapters/openai/openai-advisor.js +146 -0
  41. package/dist/src/cli/ckit.d.ts +5 -0
  42. package/dist/src/cli/ckit.js +472 -0
  43. package/dist/src/cli/demo.d.ts +1 -0
  44. package/dist/src/cli/demo.js +30 -0
  45. package/dist/src/cli/sessions.d.ts +10 -0
  46. package/dist/src/cli/sessions.js +381 -0
  47. package/dist/src/cli/setup.d.ts +11 -0
  48. package/dist/src/cli/setup.js +115 -0
  49. package/dist/src/committee/decision.d.ts +84 -0
  50. package/dist/src/committee/decision.js +167 -0
  51. package/dist/src/committee/handover.d.ts +115 -0
  52. package/dist/src/committee/handover.js +191 -0
  53. package/dist/src/committee/no-progress.d.ts +44 -0
  54. package/dist/src/committee/no-progress.js +64 -0
  55. package/dist/src/committee/primary-registry.d.ts +15 -0
  56. package/dist/src/committee/primary-registry.js +60 -0
  57. package/dist/src/committee/reply-parser.d.ts +28 -0
  58. package/dist/src/committee/reply-parser.js +53 -0
  59. package/dist/src/committee/reviewer-scheduler.d.ts +101 -0
  60. package/dist/src/committee/reviewer-scheduler.js +163 -0
  61. package/dist/src/committee/role-epoch.d.ts +91 -0
  62. package/dist/src/committee/role-epoch.js +154 -0
  63. package/dist/src/core/control.d.ts +18 -0
  64. package/dist/src/core/control.js +29 -0
  65. package/dist/src/core/entities.d.ts +166 -0
  66. package/dist/src/core/entities.js +119 -0
  67. package/dist/src/core/errors.d.ts +9 -0
  68. package/dist/src/core/errors.js +17 -0
  69. package/dist/src/core/events.d.ts +72 -0
  70. package/dist/src/core/events.js +125 -0
  71. package/dist/src/core/ids.d.ts +47 -0
  72. package/dist/src/core/ids.js +32 -0
  73. package/dist/src/core/machine.d.ts +55 -0
  74. package/dist/src/core/machine.js +110 -0
  75. package/dist/src/core/policy.d.ts +34 -0
  76. package/dist/src/core/policy.js +59 -0
  77. package/dist/src/core/provenance.d.ts +20 -0
  78. package/dist/src/core/provenance.js +21 -0
  79. package/dist/src/core/record.d.ts +35 -0
  80. package/dist/src/core/record.js +67 -0
  81. package/dist/src/core/replay.d.ts +10 -0
  82. package/dist/src/core/replay.js +36 -0
  83. package/dist/src/core/run-task.d.ts +20 -0
  84. package/dist/src/core/run-task.js +48 -0
  85. package/dist/src/diagnostics/doctor.d.ts +78 -0
  86. package/dist/src/diagnostics/doctor.js +365 -0
  87. package/dist/src/diagnostics/journal-lock.d.ts +38 -0
  88. package/dist/src/diagnostics/journal-lock.js +181 -0
  89. package/dist/src/evidence/linker.d.ts +44 -0
  90. package/dist/src/evidence/linker.js +75 -0
  91. package/dist/src/evidence/report-parser.d.ts +27 -0
  92. package/dist/src/evidence/report-parser.js +17 -0
  93. package/dist/src/evidence/store.d.ts +36 -0
  94. package/dist/src/evidence/store.js +57 -0
  95. package/dist/src/gui/server.d.ts +27 -0
  96. package/dist/src/gui/server.js +497 -0
  97. package/dist/src/host/checkpoint.d.ts +22 -0
  98. package/dist/src/host/checkpoint.js +74 -0
  99. package/dist/src/host/export.d.ts +52 -0
  100. package/dist/src/host/export.js +45 -0
  101. package/dist/src/host/ipc.d.ts +57 -0
  102. package/dist/src/host/ipc.js +124 -0
  103. package/dist/src/host/leases.d.ts +27 -0
  104. package/dist/src/host/leases.js +40 -0
  105. package/dist/src/host/retention.d.ts +47 -0
  106. package/dist/src/host/retention.js +130 -0
  107. package/dist/src/host/supervisor.d.ts +59 -0
  108. package/dist/src/host/supervisor.js +64 -0
  109. package/dist/src/intake/owner-intake.d.ts +31 -0
  110. package/dist/src/intake/owner-intake.js +97 -0
  111. package/dist/src/intake/types.d.ts +46 -0
  112. package/dist/src/intake/types.js +2 -0
  113. package/dist/src/intent/context-packet.d.ts +68 -0
  114. package/dist/src/intent/context-packet.js +76 -0
  115. package/dist/src/intent/idea-ledger.d.ts +50 -0
  116. package/dist/src/intent/idea-ledger.js +136 -0
  117. package/dist/src/intent/ledger.d.ts +35 -0
  118. package/dist/src/intent/ledger.js +40 -0
  119. package/dist/src/intent/registry.d.ts +51 -0
  120. package/dist/src/intent/registry.js +44 -0
  121. package/dist/src/intent/revision.d.ts +37 -0
  122. package/dist/src/intent/revision.js +48 -0
  123. package/dist/src/orchestration/dispatcher.d.ts +32 -0
  124. package/dist/src/orchestration/dispatcher.js +136 -0
  125. package/dist/src/orchestration/milestone-loop.d.ts +149 -0
  126. package/dist/src/orchestration/milestone-loop.js +132 -0
  127. package/dist/src/orchestration/recovery-coordinator.d.ts +74 -0
  128. package/dist/src/orchestration/recovery-coordinator.js +180 -0
  129. package/dist/src/orchestration/work-order-contract.d.ts +44 -0
  130. package/dist/src/orchestration/work-order-contract.js +85 -0
  131. package/dist/src/orchestration/work-queue.d.ts +56 -0
  132. package/dist/src/orchestration/work-queue.js +95 -0
  133. package/dist/src/ports/advisor.d.ts +33 -0
  134. package/dist/src/ports/advisor.js +2 -0
  135. package/dist/src/ports/agent.d.ts +31 -0
  136. package/dist/src/ports/agent.js +2 -0
  137. package/dist/src/ports/capabilities.d.ts +3 -0
  138. package/dist/src/ports/capabilities.js +5 -0
  139. package/dist/src/ports/clock.d.ts +5 -0
  140. package/dist/src/ports/clock.js +5 -0
  141. package/dist/src/ports/store.d.ts +13 -0
  142. package/dist/src/ports/store.js +2 -0
  143. package/dist/src/ports/web.d.ts +29 -0
  144. package/dist/src/ports/web.js +2 -0
  145. package/dist/src/run/api-run.d.ts +49 -0
  146. package/dist/src/run/api-run.js +173 -0
  147. package/dist/src/run/plan-run.d.ts +22 -0
  148. package/dist/src/run/plan-run.js +233 -0
  149. package/dist/src/run/plan.d.ts +36 -0
  150. package/dist/src/run/plan.js +119 -0
  151. package/dist/src/run/verify.d.ts +25 -0
  152. package/dist/src/run/verify.js +81 -0
  153. package/dist/src/security/redact.d.ts +7 -0
  154. package/dist/src/security/redact.js +21 -0
  155. package/dist/src/settings/env-config.d.ts +64 -0
  156. package/dist/src/settings/env-config.js +232 -0
  157. package/dist/src/storage/artifacts.d.ts +30 -0
  158. package/dist/src/storage/artifacts.js +105 -0
  159. package/dist/src/storage/audit.d.ts +6 -0
  160. package/dist/src/storage/audit.js +6 -0
  161. package/dist/src/storage/db.d.ts +9 -0
  162. package/dist/src/storage/db.js +43 -0
  163. package/dist/src/storage/events.d.ts +20 -0
  164. package/dist/src/storage/events.js +69 -0
  165. package/dist/src/storage/migrations.d.ts +8 -0
  166. package/dist/src/storage/migrations.js +48 -0
  167. package/dist/src/storage/outbox.d.ts +25 -0
  168. package/dist/src/storage/outbox.js +40 -0
  169. package/dist/src/storage/projections.d.ts +18 -0
  170. package/dist/src/storage/projections.js +40 -0
  171. package/dist/src/storage/reconcile.d.ts +14 -0
  172. package/dist/src/storage/reconcile.js +93 -0
  173. package/dist/src/storage/reservations.d.ts +12 -0
  174. package/dist/src/storage/reservations.js +80 -0
  175. package/dist/src/storage/store.d.ts +34 -0
  176. package/dist/src/storage/store.js +105 -0
  177. package/dist/src/team/attachments.d.ts +22 -0
  178. package/dist/src/team/attachments.js +211 -0
  179. package/dist/src/team/cli-models.d.ts +24 -0
  180. package/dist/src/team/cli-models.js +72 -0
  181. package/dist/src/team/config.d.ts +20 -0
  182. package/dist/src/team/config.js +111 -0
  183. package/dist/src/team/engine.d.ts +28 -0
  184. package/dist/src/team/engine.js +443 -0
  185. package/dist/src/team/journal.d.ts +30 -0
  186. package/dist/src/team/journal.js +70 -0
  187. package/dist/src/team/runners.d.ts +79 -0
  188. package/dist/src/team/runners.js +436 -0
  189. package/dist/src/team/secrets.d.ts +10 -0
  190. package/dist/src/team/secrets.js +68 -0
  191. package/dist/src/team/types.d.ts +155 -0
  192. package/dist/src/team/types.js +5 -0
  193. package/dist/src/tui/app.d.ts +29 -0
  194. package/dist/src/tui/app.js +96 -0
  195. package/dist/src/tui/control-model.d.ts +101 -0
  196. package/dist/src/tui/control-model.js +109 -0
  197. package/dist/src/tui/control-screens.d.ts +27 -0
  198. package/dist/src/tui/control-screens.js +85 -0
  199. package/dist/src/tui/graph-model.d.ts +34 -0
  200. package/dist/src/tui/graph-model.js +29 -0
  201. package/dist/src/tui/graph-screens.d.ts +13 -0
  202. package/dist/src/tui/graph-screens.js +4 -0
  203. package/dist/src/tui/inspector-model.d.ts +150 -0
  204. package/dist/src/tui/inspector-model.js +15 -0
  205. package/dist/src/tui/inspector-screens.d.ts +14 -0
  206. package/dist/src/tui/inspector-screens.js +61 -0
  207. package/dist/src/tui/live.d.ts +16 -0
  208. package/dist/src/tui/live.js +39 -0
  209. package/dist/src/tui/mission-action-screens.d.ts +15 -0
  210. package/dist/src/tui/mission-action-screens.js +105 -0
  211. package/dist/src/tui/mission-actions.d.ts +46 -0
  212. package/dist/src/tui/mission-actions.js +53 -0
  213. package/dist/src/tui/mission-model.d.ts +120 -0
  214. package/dist/src/tui/mission-model.js +164 -0
  215. package/dist/src/tui/mission-nav.d.ts +82 -0
  216. package/dist/src/tui/mission-nav.js +131 -0
  217. package/dist/src/tui/mission-plan-screens.d.ts +11 -0
  218. package/dist/src/tui/mission-plan-screens.js +40 -0
  219. package/dist/src/tui/mission-plan.d.ts +45 -0
  220. package/dist/src/tui/mission-plan.js +166 -0
  221. package/dist/src/tui/mission-screens.d.ts +7 -0
  222. package/dist/src/tui/mission-screens.js +263 -0
  223. package/dist/src/tui/provenance-label.d.ts +11 -0
  224. package/dist/src/tui/provenance-label.js +16 -0
  225. package/dist/src/tui/screens.d.ts +10 -0
  226. package/dist/src/tui/screens.js +34 -0
  227. package/dist/src/tui/session-outcome.d.ts +14 -0
  228. package/dist/src/tui/session-outcome.js +57 -0
  229. package/dist/src/tui/setup-model.d.ts +159 -0
  230. package/dist/src/tui/setup-model.js +234 -0
  231. package/dist/src/tui/setup-screens.d.ts +66 -0
  232. package/dist/src/tui/setup-screens.js +72 -0
  233. package/dist/src/tui/team/app.d.ts +24 -0
  234. package/dist/src/tui/team/app.js +228 -0
  235. package/dist/src/tui/team/demo-handle.d.ts +22 -0
  236. package/dist/src/tui/team/demo-handle.js +42 -0
  237. package/dist/src/tui/team/model.d.ts +81 -0
  238. package/dist/src/tui/team/model.js +133 -0
  239. package/gui/app.css +177 -0
  240. package/gui/app.js +675 -0
  241. package/gui/index.html +51 -0
  242. package/gui/network.js +413 -0
  243. package/package.json +45 -4
  244. package/src/storage/schema.sql +42 -0
@@ -0,0 +1,159 @@
1
+ import { type SessionId, type TaskId } from '../core/ids.js';
2
+ import type { AdvisorBinding, ProjectBinding, SessionEntity, TaskEntity } from '../core/entities.js';
3
+ import type { Envelope } from '../core/events.js';
4
+ import { PrimaryRegistry } from '../committee/primary-registry.js';
5
+ import { CheckpointStore, type RestoredCheckpoint } from '../host/checkpoint.js';
6
+ import { SessionSupervisor } from '../host/supervisor.js';
7
+ import { type LaunchProfile } from '../adapters/launch/profile.js';
8
+ import type { WebPort } from '../ports/web.js';
9
+ export type AdvisorProvider = 'chatgpt' | 'claude' | 'zai';
10
+ export type ReadinessStatus = 'ready' | 'needs_login' | 'login-expired' | 'quota' | 'network' | 'unknown';
11
+ export interface ReadinessResult {
12
+ readonly status: ReadinessStatus;
13
+ readonly capabilities: readonly string[];
14
+ readonly label?: string;
15
+ readonly ownerHandoff?: boolean;
16
+ readonly classification?: 'LOGIN' | 'QUOTA' | 'NETWORK' | 'READY' | 'UNKNOWN';
17
+ readonly pendingRequest?: string;
18
+ }
19
+ export interface ReadinessProbe {
20
+ readonly label: string;
21
+ check(input: {
22
+ readonly advisor: AdvisorBinding;
23
+ readonly profileRef: string;
24
+ }): Promise<ReadinessResult>;
25
+ }
26
+ export interface AdvisorInput {
27
+ readonly id: string;
28
+ readonly url: string;
29
+ readonly provider?: AdvisorProvider;
30
+ readonly profileRef: string;
31
+ readonly conversationId: string | null;
32
+ readonly capabilities: readonly string[];
33
+ readonly readOnly?: boolean;
34
+ }
35
+ export interface SetupEvent {
36
+ readonly type: 'owner-initiation';
37
+ readonly actor: string;
38
+ readonly goal: string;
39
+ readonly cwd: string;
40
+ }
41
+ export interface SetupSession {
42
+ readonly sessionId: SessionId;
43
+ readonly taskId: TaskId;
44
+ readonly project: ProjectBinding;
45
+ readonly session: SessionEntity;
46
+ readonly task: TaskEntity;
47
+ readonly ownerInitiation: string;
48
+ readonly state: 'setup' | 'recovering' | 'ready';
49
+ readonly events: readonly SetupEvent[];
50
+ readonly sourceEvents: readonly Envelope[];
51
+ }
52
+ export interface SetupModelOptions {
53
+ readonly cwd: string;
54
+ readonly ownerId: string;
55
+ readonly taskId: string;
56
+ readonly goal: string;
57
+ readonly sessionId?: string;
58
+ readonly readinessProbe?: ReadinessProbe;
59
+ readonly checkpointStore?: CheckpointStore;
60
+ readonly sessionSupervisor?: SessionSupervisor;
61
+ }
62
+ export interface ResumeRequest {
63
+ readonly sessionIdentity: string;
64
+ readonly cwd: string;
65
+ readonly profile: string;
66
+ readonly rebind?: boolean;
67
+ }
68
+ export interface SetupView {
69
+ readonly width: number;
70
+ readonly layout: 'compact' | 'wide';
71
+ readonly title: string;
72
+ readonly state: string;
73
+ readonly controls: readonly string[];
74
+ readonly advisorCount: number;
75
+ readonly primary: string | null;
76
+ readonly pendingOrders: number;
77
+ readonly labels: readonly string[];
78
+ readonly cwd: string;
79
+ readonly sessionId: string;
80
+ readonly urls: readonly string[];
81
+ readonly advisors: readonly AdvisorBinding[];
82
+ readonly fallbackOrder: readonly string[];
83
+ readonly loginRequired: boolean;
84
+ readonly resumeRequiresRebind: boolean;
85
+ }
86
+ export interface SendResult {
87
+ readonly allowed: boolean;
88
+ readonly reason?: 'unknown-binding' | 'read-only' | 'identity-mismatch' | 'send-not-capable' | 'not-ready';
89
+ }
90
+ export declare const PROVIDER_HOSTS: Readonly<Record<string, AdvisorProvider>>;
91
+ export declare function providerFor(url: string): AdvisorProvider;
92
+ /** Headless, owner-driven session setup and safe checkpoint resume model. */
93
+ export declare class SetupModel {
94
+ readonly registry: PrimaryRegistry;
95
+ readonly session: SetupSession;
96
+ readonly readinessProbe: ReadinessProbe;
97
+ readonly checkpointStore: CheckpointStore | undefined;
98
+ readonly sessionSupervisor: SessionSupervisor | undefined;
99
+ private readonly byId;
100
+ private readonly observedIdentity;
101
+ private readonly readiness;
102
+ private readonly requestPending;
103
+ private restored;
104
+ private activeCwd;
105
+ private activeProfile;
106
+ private workerProfile;
107
+ private readonly boundSessionId;
108
+ private readonly actions;
109
+ private paused;
110
+ private evidenceCount;
111
+ private readonly credentialInputsSeen;
112
+ private readonly urlQueue;
113
+ private urlSequence;
114
+ private readinessSequence;
115
+ private resumeRequest;
116
+ constructor(options: SetupModelOptions);
117
+ get pendingOrders(): readonly unknown[];
118
+ get dispatchCount(): number;
119
+ get reviewers(): readonly AdvisorBinding[];
120
+ get credentialSubmissionCount(): number;
121
+ get readinessProbeAutoSubmittedCredentials(): boolean;
122
+ isLoginRequired(): boolean;
123
+ get activeSessionId(): SessionId;
124
+ get isPaused(): boolean;
125
+ get evidenceRecords(): readonly {
126
+ readonly id: number;
127
+ readonly source: string;
128
+ readonly sessionId: SessionId;
129
+ }[];
130
+ bindAction(action: 'add-url' | 'send' | 'pause' | 'evidence' | 'resume', handler: () => void): () => void;
131
+ invokeAction(action: 'add-url' | 'send' | 'pause' | 'evidence' | 'resume'): boolean;
132
+ pause(): void;
133
+ captureEvidence(): {
134
+ readonly id: number;
135
+ readonly source: string;
136
+ readonly sessionId: SessionId;
137
+ };
138
+ resumeTask(request: ResumeRequest): RestoredCheckpoint;
139
+ addAdvisor(input: AdvisorInput): AdvisorBinding;
140
+ enqueueAdvisor(input: Omit<AdvisorInput, 'id'>): string;
141
+ addQueuedAdvisor(): AdvisorBinding | undefined;
142
+ configurePrimary(id: string): AdvisorBinding;
143
+ setFallbackOrder(ids: readonly string[]): readonly AdvisorBinding[];
144
+ setObservedConversation(id: string, conversationId: string): void;
145
+ fork(id: string): boolean;
146
+ send(id: string, content: string, port: WebPort): Promise<SendResult>;
147
+ checkReadiness(id: string, _credentials?: unknown): Promise<ReadinessResult>;
148
+ setPendingRequest(id: string, requestId: string): void;
149
+ setWorkerProfile(profile: LaunchProfile): void;
150
+ resume(request: ResumeRequest): RestoredCheckpoint;
151
+ view(width: number): SetupView;
152
+ }
153
+ export declare function classifyReadiness(input: {
154
+ readonly status: ReadinessStatus;
155
+ readonly capabilities?: readonly string[];
156
+ readonly label?: string;
157
+ readonly pendingRequest?: string;
158
+ }): ReadinessResult;
159
+ export declare function isSecretSetting(name: string): boolean;
@@ -0,0 +1,234 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { realpathSync } from 'node:fs';
3
+ import { advisorId, projectId, sessionId, taskId, authorizationRef } from '../core/ids.js';
4
+ import { PrimaryRegistry } from '../committee/primary-registry.js';
5
+ import { CheckpointStore } from '../host/checkpoint.js';
6
+ import { SessionSupervisor } from '../host/supervisor.js';
7
+ import { createLaunchProfile, secretKeyPattern } from '../adapters/launch/profile.js';
8
+ export const PROVIDER_HOSTS = Object.freeze({ 'chatgpt.com': 'chatgpt', 'www.chatgpt.com': 'chatgpt', 'claude.ai': 'claude', 'www.claude.ai': 'claude', 'chat.z.ai': 'zai' });
9
+ export function providerFor(url) { let host; try {
10
+ host = new URL(url).hostname.toLowerCase();
11
+ }
12
+ catch {
13
+ throw new TypeError('invalid advisor URL');
14
+ } const provider = PROVIDER_HOSTS[host]; if (!provider)
15
+ throw new TypeError('unsupported provider hostname'); return provider; }
16
+ const SECRET_URL = /(?:password|token|secret|api[_-]?key)=/i;
17
+ function parseBinding(input) {
18
+ let url;
19
+ try {
20
+ url = new URL(input.url);
21
+ }
22
+ catch {
23
+ throw new TypeError('invalid advisor URL');
24
+ }
25
+ if (url.protocol !== 'https:' || url.username || url.password || SECRET_URL.test(url.search))
26
+ throw new TypeError('unsafe advisor URL');
27
+ const host = url.hostname.toLowerCase(), provider = PROVIDER_HOSTS[host];
28
+ if (!provider)
29
+ throw new TypeError('unsupported provider hostname');
30
+ if (input.provider !== undefined && input.provider !== provider)
31
+ throw new TypeError('provider does not match exact hostname');
32
+ const parts = url.pathname.split('/').filter(Boolean);
33
+ let conversationId = null, readOnly = false;
34
+ if (provider === 'chatgpt') {
35
+ if (parts[0] === 'c' && parts[1])
36
+ conversationId = parts[1];
37
+ else if (parts[0] === 'share' && parts[1]) {
38
+ conversationId = `share:${parts[1]}`;
39
+ readOnly = true;
40
+ }
41
+ else
42
+ throw new TypeError('unsupported ChatGPT conversation route');
43
+ }
44
+ if (provider === 'claude') {
45
+ if (parts[0] === 'chat' && parts[1])
46
+ conversationId = parts[1];
47
+ else if (parts[0] === 'share' && parts[1]) {
48
+ conversationId = `share:${parts[1]}`;
49
+ readOnly = true;
50
+ }
51
+ else
52
+ throw new TypeError('unsupported Claude conversation route');
53
+ }
54
+ if (provider === 'zai') {
55
+ if (parts[0] === 'c' && parts[1])
56
+ conversationId = parts[1];
57
+ else if (parts[0] === 'share' && parts[1]) {
58
+ conversationId = `share:${parts[1]}`;
59
+ readOnly = true;
60
+ }
61
+ else
62
+ throw new TypeError('unsupported Z.ai conversation route');
63
+ }
64
+ if (input.readOnly === true)
65
+ readOnly = true;
66
+ return { url, provider, conversationId: input.conversationId ?? conversationId, readOnly };
67
+ }
68
+ function projectKey(cwd) { return `project-${createHash('sha256').update(cwd).digest('hex').slice(0, 12)}`; }
69
+ function resolveCwd(cwd) { try {
70
+ return realpathSync(cwd);
71
+ }
72
+ catch {
73
+ return cwd;
74
+ } }
75
+ /** Headless, owner-driven session setup and safe checkpoint resume model. */
76
+ export class SetupModel {
77
+ registry = new PrimaryRegistry();
78
+ session;
79
+ readinessProbe;
80
+ checkpointStore;
81
+ sessionSupervisor;
82
+ byId = new Map();
83
+ observedIdentity = new Map();
84
+ readiness = new Map();
85
+ requestPending = new Map();
86
+ restored = null;
87
+ activeCwd;
88
+ activeProfile = '';
89
+ workerProfile = null;
90
+ boundSessionId;
91
+ actions = new Map();
92
+ paused = false;
93
+ evidenceCount = 0;
94
+ credentialInputsSeen = [];
95
+ urlQueue = [];
96
+ urlSequence = 0;
97
+ readinessSequence = 0;
98
+ resumeRequest = null;
99
+ constructor(options) {
100
+ if (!options.ownerId || !options.goal.trim())
101
+ throw new TypeError('owner and owner-authored goal required');
102
+ const cwd = resolveCwd(options.cwd), sid = sessionId(options.sessionId ?? `session-${createHash('sha256').update(`${cwd}:${options.ownerId}:${options.taskId}`).digest('hex').slice(0, 12)}`), tid = taskId(options.taskId), pid = projectId(projectKey(cwd));
103
+ this.boundSessionId = sid;
104
+ this.activeCwd = cwd;
105
+ this.readinessProbe = options.readinessProbe ?? { label: 'SIMULATED · T01-04 fake readiness', async check() { return { status: 'unknown', capabilities: [] }; } };
106
+ this.checkpointStore = options.checkpointStore;
107
+ this.sessionSupervisor = options.sessionSupervisor;
108
+ const project = Object.freeze({ projectId: pid, requestedCwd: options.cwd, canonicalCwd: cwd, repoIdentity: null, worktreeIdentity: null, platform: process.platform, status: 'active' });
109
+ const task = Object.freeze({ taskId: tid, goal: options.goal, scope: options.goal, authorizationRef: authorizationRef(`authorization-${createHash('sha256').update(`${options.ownerId}:${tid}`).digest('hex').slice(0, 12)}`), acceptanceIds: Object.freeze([]), status: 'proposed', intentRevision: 1 });
110
+ const isResume = options.sessionId !== undefined;
111
+ const session = Object.freeze({ sessionId: sid, projectId: pid, ownerInitiation: options.ownerId, state: isResume ? 'recovering' : 'setup', configRevision: 1, primaryAdvisorId: null });
112
+ this.session = Object.freeze({ sessionId: sid, taskId: tid, project, session, task, ownerInitiation: options.ownerId, state: isResume ? 'recovering' : 'setup', events: Object.freeze([{ type: 'owner-initiation', actor: options.ownerId, goal: options.goal, cwd }]), sourceEvents: Object.freeze([]) });
113
+ }
114
+ get pendingOrders() { const state = this.restored?.state; if (!state || typeof state !== 'object' || !Array.isArray(state['pendingOrders']))
115
+ return Object.freeze([]); return structuredClone(state.pendingOrders); }
116
+ get dispatchCount() { return 0; }
117
+ get reviewers() { return Object.freeze([]); }
118
+ get credentialSubmissionCount() { return 0; }
119
+ get readinessProbeAutoSubmittedCredentials() { return Boolean(this.readinessProbe.autoSubmittedCredentials); }
120
+ isLoginRequired() { return [...this.readiness.values()].some(result => result.ownerHandoff === true); }
121
+ get activeSessionId() { return this.boundSessionId; }
122
+ get isPaused() { return this.paused; }
123
+ get evidenceRecords() { return Object.freeze(Array.from({ length: this.evidenceCount }, (_, index) => Object.freeze({ id: index + 1, source: 'setup-model', sessionId: this.boundSessionId }))); }
124
+ bindAction(action, handler) { if (this.actions.has(action))
125
+ throw new Error(`action already bound: ${action}`); this.actions.set(action, handler); return () => this.actions.delete(action); }
126
+ invokeAction(action) { const handler = this.actions.get(action); if (!handler)
127
+ return false; handler(); return true; }
128
+ pause() { this.paused = true; }
129
+ captureEvidence() { const item = Object.freeze({ id: ++this.evidenceCount, source: 'setup-model', sessionId: this.boundSessionId }); return item; }
130
+ resumeTask(request) { const restored = this.resume(request); this.paused = false; return restored; }
131
+ addAdvisor(input) {
132
+ const id = advisorId(input.id), parsed = parseBinding(input), normalized = new URL(parsed.url);
133
+ normalized.hash = '';
134
+ normalized.search = '';
135
+ const existing = this.registry.bindings.find(b => b.provider === parsed.provider && b.conversationId === parsed.conversationId && parsed.conversationId !== null);
136
+ if (existing)
137
+ throw new TypeError('duplicate conversation binding');
138
+ const binding = Object.freeze({ advisorId: id, provider: parsed.provider, url: normalized.toString(), conversationId: parsed.conversationId, profileRef: input.profileRef, role: 'fallback', capabilities: Object.freeze(parsed.readOnly ? input.capabilities.filter(cap => cap !== 'send' && cap !== 'fork') : [...input.capabilities]) });
139
+ const registered = this.registry.register(binding);
140
+ this.byId.set(id, registered);
141
+ this.observedIdentity.set(id, parsed.conversationId ?? '');
142
+ return registered;
143
+ }
144
+ enqueueAdvisor(input) { const id = `advisor-setup${String(++this.urlSequence).padStart(4, '0')}`; this.urlQueue.push({ ...input, id }); return id; }
145
+ addQueuedAdvisor() { const next = this.urlQueue.shift(); return next ? this.addAdvisor(next) : undefined; }
146
+ configurePrimary(id) { return this.registry.selectPrimary(id); }
147
+ setFallbackOrder(ids) { return this.registry.setFallbackOrder(ids); }
148
+ setObservedConversation(id, conversationId) { const parsed = advisorId(id); if (!this.byId.has(parsed))
149
+ throw new TypeError('unknown advisor binding'); this.observedIdentity.set(parsed, conversationId); }
150
+ fork(id) { const binding = this.byId.get(advisorId(id)); return Boolean(binding?.capabilities.includes('fork') && binding.capabilities.includes('send')); }
151
+ async send(id, content, port) {
152
+ const binding = this.byId.get(advisorId(id));
153
+ if (!binding)
154
+ return { allowed: false, reason: 'unknown-binding' };
155
+ if (this.paused)
156
+ return { allowed: false, reason: 'not-ready' };
157
+ if (!binding.capabilities.includes('send') || binding.conversationId?.startsWith('share:'))
158
+ return { allowed: false, reason: 'read-only' };
159
+ if (this.observedIdentity.get(binding.advisorId) !== (binding.conversationId ?? ''))
160
+ return { allowed: false, reason: 'identity-mismatch' };
161
+ if (!content.trim() || !port.isSimulated || port.capabilities['send'] !== 'supported')
162
+ return { allowed: false, reason: 'send-not-capable' };
163
+ const result = this.readiness.get(binding.advisorId);
164
+ if (result && result.status !== 'ready')
165
+ return { allowed: false, reason: 'not-ready' };
166
+ return { allowed: true };
167
+ }
168
+ async checkReadiness(id, _credentials) {
169
+ const binding = this.byId.get(advisorId(id));
170
+ if (!binding)
171
+ throw new TypeError('unknown advisor binding');
172
+ const current = ++this.readinessSequence;
173
+ const raw = await this.readinessProbe.check({ advisor: binding, profileRef: binding.profileRef });
174
+ const pending = this.requestPending.get(binding.advisorId);
175
+ const classified = classifyReadiness({ ...raw, ...(pending ? { pendingRequest: pending } : {}) });
176
+ const result = Object.freeze({ ...classified, label: raw.label || this.readinessProbe.label });
177
+ if (current === this.readinessSequence)
178
+ this.readiness.set(binding.advisorId, result);
179
+ return result;
180
+ }
181
+ setPendingRequest(id, requestId) { const binding = advisorId(id); if (!this.byId.has(binding) || !requestId)
182
+ throw new TypeError('binding and pending request required'); this.requestPending.set(binding, requestId); }
183
+ setWorkerProfile(profile) { const validated = createLaunchProfile(profile); if (realpathSync(validated.cwd) !== this.activeCwd)
184
+ throw new Error('worker profile cwd must match setup cwd'); this.workerProfile = validated; this.activeProfile = validated.profileRevision; }
185
+ resume(request) {
186
+ if (!this.checkpointStore)
187
+ throw new Error('real CheckpointStore required to resume');
188
+ if (!request.sessionIdentity || !request.cwd || !request.profile)
189
+ throw new TypeError('resume binding identity, cwd and profile required');
190
+ if (request.rebind !== true)
191
+ throw new Error('rebind required before checkpoint resume');
192
+ const cwd = resolveCwd(request.cwd);
193
+ if (cwd !== this.activeCwd)
194
+ throw new Error('rebind cwd mismatch; setup binding must be updated first');
195
+ if (this.activeProfile && request.profile !== this.activeProfile)
196
+ throw new Error('rebind profile mismatch');
197
+ const restored = this.checkpointStore.restore({ sessionId: this.boundSessionId, sessionIdentity: request.sessionIdentity });
198
+ if (this.sessionSupervisor) {
199
+ if (!this.sessionSupervisor.authorizeDispatch())
200
+ throw new Error('REAL host lease required before resume');
201
+ this.sessionSupervisor.setSessionState(restored.state);
202
+ }
203
+ this.restored = restored;
204
+ this.activeCwd = cwd;
205
+ this.activeProfile = request.profile;
206
+ this.resumeRequest = Object.freeze({ ...request });
207
+ return restored;
208
+ }
209
+ view(width) {
210
+ if (!Number.isSafeInteger(width) || width < 1)
211
+ throw new TypeError('terminal width must be a positive integer');
212
+ return Object.freeze({ width, layout: width < 60 ? 'compact' : 'wide', title: 'Session setup and resume', state: this.restored ? 'recovering' : this.isLoginRequired() ? 'needs-owner' : this.paused ? 'paused' : 'setup', controls: Object.freeze(['cwd', 'goal', 'add-url', 'remove-url', 'reorder-url', 'primary', 'fallback', 'worker-profile', 'login-readiness', 'send', 'pause', 'evidence', 'resume']), advisorCount: this.registry.bindings.length, primary: this.registry.primary?.advisorId ?? null, pendingOrders: this.pendingOrders.length, labels: Object.freeze(['SIMULATED provider readiness', 'REAL host lease', 'REAL checkpoint persistence']), cwd: this.activeCwd, sessionId: this.boundSessionId, urls: Object.freeze(this.registry.bindings.map(binding => binding.url)), advisors: this.registry.bindings, fallbackOrder: Object.freeze(this.registry.fallbackOrder.map(id => String(id))), loginRequired: this.isLoginRequired(), resumeRequiresRebind: this.restored === null });
213
+ }
214
+ }
215
+ export function classifyReadiness(input) {
216
+ const login = input.status === 'login-expired' || input.status === 'needs_login';
217
+ let classification;
218
+ let status = input.status;
219
+ if (login) {
220
+ classification = 'LOGIN';
221
+ status = 'needs_login';
222
+ }
223
+ else if (status === 'quota')
224
+ classification = 'QUOTA';
225
+ else if (status === 'network')
226
+ classification = 'NETWORK';
227
+ else if (status === 'ready')
228
+ classification = 'READY';
229
+ else
230
+ classification = 'UNKNOWN';
231
+ return Object.freeze({ status, capabilities: Object.freeze([...(input.capabilities ?? [])]), label: input.label ?? 'SIMULATED · T01-04 fake readiness', ownerHandoff: login, ...(classification ? { classification } : {}), ...(input.pendingRequest ? { pendingRequest: input.pendingRequest } : {}) });
232
+ }
233
+ export function isSecretSetting(name) { return secretKeyPattern.test(name); }
234
+ //# sourceMappingURL=setup-model.js.map
@@ -0,0 +1,66 @@
1
+ import { type SetupModel, type SetupView, type ResumeRequest, type AdvisorInput } from './setup-model.js';
2
+ import type { WebPort } from '../ports/web.js';
3
+ import type { LaunchProfile } from '../adapters/launch/profile.js';
4
+ import type { AdvisorBinding } from '../core/entities.js';
5
+ export interface SetupPickerState {
6
+ readonly cwd: string;
7
+ readonly sessionId: string | null;
8
+ readonly sessionChoices: readonly {
9
+ readonly sessionId: string;
10
+ readonly goal: string;
11
+ readonly cwd: string;
12
+ }[];
13
+ readonly urls: readonly string[];
14
+ readonly advisors: readonly AdvisorBinding[];
15
+ readonly primary: string | null;
16
+ readonly fallbackOrder: readonly string[];
17
+ readonly loginRequired: boolean;
18
+ readonly resumeRequiresRebind: boolean;
19
+ }
20
+ export interface SetupActions {
21
+ readonly addUrl: () => void;
22
+ readonly send: () => void;
23
+ readonly pause: () => void;
24
+ readonly evidence: () => void;
25
+ readonly resume: () => void;
26
+ readonly selectPrimary?: (id: string) => void;
27
+ readonly cycleFallback?: () => void;
28
+ readonly editProfile?: () => void;
29
+ }
30
+ /** Thin keyboard surface: callbacks own all model mutations; this component only routes input. */
31
+ export declare function SetupScreen({ view, actions, picker }: {
32
+ readonly view: SetupView;
33
+ readonly actions?: SetupActions;
34
+ readonly picker?: SetupPickerState;
35
+ }): import("react").JSX.Element;
36
+ export declare function BlankStatePicker({ cwd, sessionChoices }: {
37
+ readonly cwd: string;
38
+ readonly sessionChoices: SetupPickerState['sessionChoices'];
39
+ }): import("react").JSX.Element;
40
+ /** Resume shares the same model projection and never dispatches during rendering. */
41
+ export declare function ResumeScreen({ view }: {
42
+ readonly view: SetupView;
43
+ }): import("react").JSX.Element;
44
+ export interface SetupControllerOptions {
45
+ readonly model: SetupModel;
46
+ readonly input: () => Promise<{
47
+ readonly url: string;
48
+ readonly profileRef: string;
49
+ readonly capabilities: readonly string[];
50
+ }>;
51
+ readonly sendPort: WebPort;
52
+ readonly sendContent: () => string;
53
+ readonly profile: LaunchProfile;
54
+ readonly profileInput?: () => Promise<LaunchProfile>;
55
+ readonly resumeRequest: () => Promise<ResumeRequest>;
56
+ readonly report: (message: string) => void;
57
+ }
58
+ export declare function createSetupActions(options: SetupControllerOptions): SetupActions;
59
+ export declare function SetupFlow({ options, view }: {
60
+ readonly options: SetupControllerOptions;
61
+ readonly view: SetupView;
62
+ }): import("react").JSX.Element;
63
+ export declare function setupInputShape(url: string, profileRef: string, capabilities: readonly string[]): Omit<AdvisorInput, 'id'>;
64
+ export declare function validateSetupProfile(profile: LaunchProfile): LaunchProfile;
65
+ export declare function setupAdvisorId(id: string): import("../core/ids.js").AdvisorId;
66
+ export declare function setupResumeRequest(request: ResumeRequest): ResumeRequest;
@@ -0,0 +1,72 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useInput, Box, Text } from 'ink';
3
+ import { providerFor } from './setup-model.js';
4
+ import { createLaunchProfile } from '../adapters/launch/profile.js';
5
+ import { advisorId } from '../core/ids.js';
6
+ const KEYS = Object.freeze([['a', 'addUrl', 'add URL'], ['s', 'send', 'send'], ['p', 'pause', 'pause'], ['e', 'evidence', 'evidence'], ['r', 'resume', 'resume'], ['1', 'selectPrimary', 'select primary'], ['f', 'cycleFallback', 'cycle fallback order'], ['w', 'editProfile', 'worker profile']]);
7
+ const SCREEN_KEYS = KEYS.filter(([key]) => key !== '1' && key !== 'f' && key !== 'w');
8
+ const CHOICE_KEYS = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
9
+ function KeyboardActions({ actions, view }) {
10
+ useInput((input) => { const normalized = input.toLowerCase(); const selection = CHOICE_KEYS.indexOf(normalized); if (selection >= 0) {
11
+ const advisor = view.advisors[selection];
12
+ if (advisor)
13
+ actions.selectPrimary?.(String(advisor.advisorId));
14
+ return;
15
+ } const match = KEYS.find(([key]) => normalized === key && key !== '1'); if (match) {
16
+ const action = match[1];
17
+ if (action === 'selectPrimary')
18
+ return;
19
+ const handler = actions[action];
20
+ if (handler)
21
+ handler();
22
+ } });
23
+ return null;
24
+ }
25
+ /** Thin keyboard surface: callbacks own all model mutations; this component only routes input. */
26
+ export function SetupScreen({ view, actions, picker }) {
27
+ return _jsxs(Box, { flexDirection: "column", width: view.width, children: [actions ? _jsx(KeyboardActions, { actions: actions, view: view }) : null, _jsx(Text, { bold: true, color: "cyan", children: view.title }), _jsxs(Text, { children: ["State: ", view.state, " \u00B7 Advisors: ", view.advisorCount, " \u00B7 Primary: ", view.primary ?? 'not selected'] }), _jsxs(Text, { children: ["CWD: ", picker?.cwd ?? view.cwd] }), _jsxs(Text, { children: ["Session: ", picker?.sessionId ?? view.sessionId] }), _jsxs(Text, { children: ["Primary: ", picker?.primary ?? view.primary ?? 'not selected'] }), _jsx(Text, { children: "Advisor URLs:" }), view.urls.map((url, index) => _jsxs(Text, { children: [index + 1, ". ", url] }, `${index}:${url}`)), !view.urls.length ? _jsx(Text, { dimColor: true, children: "No advisor URLs added." }) : null, view.advisors.map((advisor, index) => _jsxs(Text, { children: ["[", index + 1, "] ", advisor.advisorId, " \u00B7 ", advisor.provider, " \u00B7 ", advisor.url, " \u00B7 ", advisor.capabilities.includes('send') ? 'send' : 'read-only', view.primary === advisor.advisorId ? ' · PRIMARY' : ''] }, advisor.advisorId)), _jsxs(Text, { children: ["Fallback order: ", view.fallbackOrder.join(', ') || 'none'] }), actions ? _jsx(Text, { children: "Choices: [1\u20139] select listed primary \u00B7 [f] cycle fallback order \u00B7 [w] set worker profile (owner input)." }) : null, view.loginRequired ? _jsx(Text, { color: "yellow", children: "NEEDS_LOGIN \u00B7 Please sign in yourself, then continue." }) : null, view.resumeRequiresRebind ? _jsx(Text, { color: "yellow", children: "Resume requires owner confirmation and binding re-check before restore." }) : null, picker ? _jsxs(_Fragment, { children: [_jsx(Text, { children: "Session choices:" }), picker.sessionChoices.map(session => _jsxs(Text, { children: ["[", session.sessionId, "] ", session.goal, " \u00B7 ", session.cwd] }, session.sessionId)), !picker.sessionChoices.length ? _jsx(Text, { dimColor: true, children: "No recorded sessions." }) : null] }) : null, _jsxs(Text, { children: ["Pending work: ", view.pendingOrders, "."] }), SCREEN_KEYS.map(([key, , label]) => _jsxs(Text, { children: ["[", key, "] ", label] }, key)), _jsx(Text, { dimColor: true, children: view.labels.join(' · ') })] });
28
+ }
29
+ export function BlankStatePicker({ cwd, sessionChoices }) {
30
+ return _jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: ["CWD: ", cwd] }), _jsx(Text, { children: "Sessions:" }), sessionChoices.map(session => _jsxs(Text, { children: ["[", session.sessionId, "] ", session.goal, " \u00B7 ", session.cwd] }, session.sessionId)), !sessionChoices.length ? _jsx(Text, { dimColor: true, children: "(empty)" }) : null] });
31
+ }
32
+ /** Resume shares the same model projection and never dispatches during rendering. */
33
+ export function ResumeScreen({ view }) {
34
+ return _jsxs(Box, { flexDirection: "column", width: view.width, children: [_jsxs(Text, { bold: true, children: ["Resume \u00B7 ", view.state] }), _jsxs(Text, { children: ["Pending work: ", view.pendingOrders, " \u00B7 ", view.controls.includes('resume') ? 'rebind required' : ''] }), _jsx(Text, { dimColor: true, children: view.labels.filter(label => label.startsWith('REAL')).join(' · ') })] });
35
+ }
36
+ export function createSetupActions(options) {
37
+ const advisorIds = () => options.model.registry.bindings.map(binding => String(binding.advisorId));
38
+ return {
39
+ addUrl: () => { void options.input().then(value => { const provider = providerFor(value.url); options.model.addAdvisor({ id: `advisor-${Date.now().toString(36)}`, url: value.url, provider, profileRef: value.profileRef, conversationId: null, capabilities: value.capabilities }); options.report('Advisor URL added.'); }).catch(error => options.report(error instanceof Error ? error.message : 'Unable to add advisor URL.')); },
40
+ send: () => { const id = options.model.registry.primary?.advisorId; if (!id) {
41
+ options.report('Select a primary advisor first.');
42
+ return;
43
+ } void options.model.send(id, options.sendContent(), options.sendPort).then(result => options.report(result.allowed ? 'Send authorized (SIMULATED port only).' : `Send denied: ${result.reason ?? 'unknown'}.`)); },
44
+ pause: () => { options.model.pause(); options.report('Session paused; new sends are blocked.'); },
45
+ evidence: () => { const evidence = options.model.captureEvidence(); options.report(`Evidence recorded: ${evidence.source} #${evidence.id}.`); },
46
+ resume: () => { void options.resumeRequest().then(request => { options.model.resumeTask(request); options.report('Checkpoint restored; pending work remains undispatched.'); }).catch(error => options.report(error instanceof Error ? error.message : 'Unable to resume checkpoint.')); },
47
+ selectPrimary: (id) => { if (!advisorIds().includes(id)) {
48
+ options.report('Primary selection must match a listed advisor.');
49
+ return;
50
+ } try {
51
+ options.model.configurePrimary(id);
52
+ options.report(`Primary selected: ${id}.`);
53
+ }
54
+ catch (error) {
55
+ options.report(error instanceof Error ? error.message : 'Unable to select primary.');
56
+ } },
57
+ cycleFallback: () => { const ids = advisorIds().filter(id => id !== String(options.model.registry.primary?.advisorId)); if (ids.length === 0) {
58
+ options.report('No fallback advisors are available.');
59
+ return;
60
+ } const order = [...options.model.registry.fallbackOrder].map(String); const next = order.length === ids.length ? [] : ids; options.model.setFallbackOrder(next); options.report(`Fallback order: ${next.join(', ') || 'none'}.`); },
61
+ editProfile: () => { if (!options.profileInput) {
62
+ options.report('Worker profile input is unavailable; profile unchanged.');
63
+ return;
64
+ } void options.profileInput().then(profile => { options.model.setWorkerProfile(createLaunchProfile(profile)); options.report('Worker profile updated.'); }).catch(error => options.report(error instanceof Error ? error.message : 'Worker profile unchanged.')); },
65
+ };
66
+ }
67
+ export function SetupFlow({ options, view }) { return _jsx(SetupScreen, { view: view, actions: createSetupActions(options) }); }
68
+ export function setupInputShape(url, profileRef, capabilities) { const parsed = new URL(url); return { url: parsed.toString(), provider: providerFor(url), profileRef, conversationId: null, capabilities: Object.freeze([...capabilities]) }; }
69
+ export function validateSetupProfile(profile) { return createLaunchProfile(profile); }
70
+ export function setupAdvisorId(id) { return advisorId(id); }
71
+ export function setupResumeRequest(request) { return Object.freeze({ ...request }); }
72
+ //# sourceMappingURL=setup-screens.js.map
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { type TeamRunHandle } from '../../team/types.js';
3
+ import { type FeedItem } from './model.js';
4
+ export interface TeamAppProps {
5
+ readonly handle: TeamRunHandle;
6
+ readonly goal: string;
7
+ readonly onQuit: () => void;
8
+ readonly tickMs?: number;
9
+ readonly now?: () => Date;
10
+ }
11
+ interface Part {
12
+ readonly text: string;
13
+ readonly color?: string | undefined;
14
+ readonly bold?: boolean;
15
+ readonly dim?: boolean;
16
+ readonly inverse?: boolean;
17
+ }
18
+ interface FeedLine {
19
+ readonly key: string;
20
+ readonly parts: readonly Part[];
21
+ }
22
+ export declare function buildFeedLines(feed: readonly FeedItem[], names: ReadonlyMap<string, string>, width: number, showActivity: boolean): FeedLine[];
23
+ export declare function TeamApp({ handle, goal, onQuit, tickMs, now }: TeamAppProps): React.ReactElement;
24
+ export {};