@mclawnet/shared 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/chat-protocol.test.d.ts +2 -0
- package/dist/__tests__/chat-protocol.test.d.ts.map +1 -0
- package/dist/__tests__/chat-protocol.test.js +32 -0
- package/dist/__tests__/chat-protocol.test.js.map +1 -0
- package/dist/__tests__/model-catalog.test.d.ts +2 -0
- package/dist/__tests__/model-catalog.test.d.ts.map +1 -0
- package/dist/__tests__/model-catalog.test.js +55 -0
- package/dist/__tests__/model-catalog.test.js.map +1 -0
- package/dist/__tests__/session-protocol-schema.test.d.ts +2 -0
- package/dist/__tests__/session-protocol-schema.test.d.ts.map +1 -0
- package/dist/__tests__/session-protocol-schema.test.js +149 -0
- package/dist/__tests__/session-protocol-schema.test.js.map +1 -0
- package/dist/__tests__/swarm-protocol.test.d.ts +2 -0
- package/dist/__tests__/swarm-protocol.test.d.ts.map +1 -0
- package/dist/__tests__/swarm-protocol.test.js +35 -0
- package/dist/__tests__/swarm-protocol.test.js.map +1 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -1
- package/dist/constants.js.map +1 -1
- package/dist/encode-cwd.d.ts +15 -0
- package/dist/encode-cwd.d.ts.map +1 -0
- package/dist/encode-cwd.js +27 -0
- package/dist/encode-cwd.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/model-catalog.d.ts +53 -0
- package/dist/model-catalog.d.ts.map +1 -0
- package/dist/model-catalog.js +5 -0
- package/dist/model-catalog.js.map +1 -0
- package/dist/protocol/agent.d.ts +576 -17
- package/dist/protocol/agent.d.ts.map +1 -1
- package/dist/protocol/agent.js +7 -0
- package/dist/protocol/agent.js.map +1 -1
- package/dist/protocol/chat.d.ts +110 -5
- package/dist/protocol/chat.d.ts.map +1 -1
- package/dist/protocol/events.d.ts +5 -2
- package/dist/protocol/events.d.ts.map +1 -1
- package/dist/protocol/events.js.map +1 -1
- package/dist/protocol/index.d.ts +3 -3
- package/dist/protocol/index.d.ts.map +1 -1
- package/dist/protocol/index.js +1 -1
- package/dist/protocol/index.js.map +1 -1
- package/dist/sandbox.d.ts +27 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +7 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/schemas.d.ts +573 -11
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +151 -2
- package/dist/schemas.js.map +1 -1
- package/dist/types/session.d.ts +1 -1
- package/dist/types/session.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/brain-types.d.ts +0 -101
- package/dist/brain-types.d.ts.map +0 -1
- package/dist/brain-types.js +0 -4
- package/dist/brain-types.js.map +0 -1
package/dist/protocol/agent.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { SessionProcessState } from "../types/session.js";
|
|
2
|
+
import type { SandboxLevel } from "../sandbox.js";
|
|
3
|
+
import type { AgentManifestPayload, BackendKind } from "../model-catalog.js";
|
|
2
4
|
export interface AgentAuthRequired {
|
|
3
5
|
type: "auth_required";
|
|
4
6
|
}
|
|
@@ -10,12 +12,6 @@ export interface AgentAck {
|
|
|
10
12
|
type: "ack";
|
|
11
13
|
ts: number;
|
|
12
14
|
}
|
|
13
|
-
export interface AgentSessionCreate {
|
|
14
|
-
type: "session.create";
|
|
15
|
-
sessionId: string;
|
|
16
|
-
workDir?: string;
|
|
17
|
-
resumeId?: string;
|
|
18
|
-
}
|
|
19
15
|
export interface AgentSessionClose {
|
|
20
16
|
type: "session.close";
|
|
21
17
|
sessionId: string;
|
|
@@ -34,7 +30,7 @@ export interface AgentClaudeExecute {
|
|
|
34
30
|
sessionId: string;
|
|
35
31
|
content: string;
|
|
36
32
|
workDir?: string;
|
|
37
|
-
|
|
33
|
+
backendSessionId?: string;
|
|
38
34
|
useBrainCore?: boolean;
|
|
39
35
|
}
|
|
40
36
|
export interface AgentFsListDir {
|
|
@@ -55,7 +51,7 @@ export interface AgentLoadSessionHistory {
|
|
|
55
51
|
type: "load_session_history";
|
|
56
52
|
requestId: string;
|
|
57
53
|
workDir: string;
|
|
58
|
-
|
|
54
|
+
backendSessionId: string;
|
|
59
55
|
/** Pagination: return messages with seq < before. Omit/0 = newest tail. */
|
|
60
56
|
before?: number;
|
|
61
57
|
/** Max messages returned. Default 50, max 200. */
|
|
@@ -83,6 +79,7 @@ export interface AgentSwarmExecute {
|
|
|
83
79
|
targetInstance?: string;
|
|
84
80
|
crewConfig?: {
|
|
85
81
|
templateName?: string;
|
|
82
|
+
displayName?: string;
|
|
86
83
|
roles?: Array<{
|
|
87
84
|
roleName: string;
|
|
88
85
|
count?: number;
|
|
@@ -144,7 +141,7 @@ export interface SwarmResumeControl {
|
|
|
144
141
|
agentId?: string;
|
|
145
142
|
swarmId: string;
|
|
146
143
|
}
|
|
147
|
-
export type AgentServerMessage = AgentAuthRequired | AgentRegistered | AgentAck |
|
|
144
|
+
export type AgentServerMessage = AgentAuthRequired | AgentRegistered | AgentAck | AgentSessionClose | AgentClaudeInput | AgentClaudeExecute | SessionCreate | SessionInput | SessionUpdateSticky | HubPermissionDecision | AgentFsListDir | AgentListFolders | AgentListHistorySessions | AgentLoadSessionHistory | AgentProxyOpen | AgentProxyData | AgentProxyClose | AgentSwarmExecute | AgentListRoles | AgentListTemplates | AgentAbortExecution | AgentSessionForceRestart | AgentGenericRequest | SwarmSpawnControl | SwarmResumeControl | ProjectsListRequest | ProjectsGetRequest | ProjectsTasksRequest | ProjectsTaskRequest | ProjectsSwarmsRequest | ProjectsSwarmRequest | ProjectsInboxesRequest | ProjectsInboxRequest | ProjectsSwarmSessionIdRequest | ProjectsFilesListRequest | ProjectsFileReadRequest | ProjectsFileWriteRequest | ProjectsEnsureProjectRequest | WorkdirMkdirRequest | ProjectsSwarmAddRoleRequest | ProjectsShipmentGetRequest | ProjectsShipmentActionRequest | ProjectsShipmentDiffRequest | ProjectsShipmentsListRequest | ProjectsAlwaysOnGetRequest | ProjectsAlwaysOnSetRequest | ProjectsAlwaysOnTickNowRequest;
|
|
148
145
|
export interface AgentAuth {
|
|
149
146
|
type: "auth";
|
|
150
147
|
token: string;
|
|
@@ -159,12 +156,19 @@ export interface AgentHeartbeat {
|
|
|
159
156
|
export interface AgentSessionCreated {
|
|
160
157
|
type: "session.created";
|
|
161
158
|
sessionId: string;
|
|
162
|
-
|
|
159
|
+
backendSessionId: string;
|
|
163
160
|
}
|
|
164
161
|
export interface AgentSessionError {
|
|
165
162
|
type: "session.error";
|
|
166
163
|
sessionId: string;
|
|
167
164
|
error: string;
|
|
165
|
+
/**
|
|
166
|
+
* (N3) Optional structured error code. When the underlying error is a
|
|
167
|
+
* typed Error subclass with a `code` property (e.g. RespawnRequiredError
|
|
168
|
+
* with code: "RESPAWN_REQUIRED"), agent forwards it so hub/UI can branch
|
|
169
|
+
* without parsing the message string.
|
|
170
|
+
*/
|
|
171
|
+
code?: string;
|
|
168
172
|
}
|
|
169
173
|
export interface AgentClaudeOutput {
|
|
170
174
|
type: "claude.output";
|
|
@@ -174,7 +178,7 @@ export interface AgentClaudeOutput {
|
|
|
174
178
|
export interface AgentClaudeTurnComplete {
|
|
175
179
|
type: "claude.turn_complete";
|
|
176
180
|
sessionId: string;
|
|
177
|
-
|
|
181
|
+
backendSessionId?: string;
|
|
178
182
|
cost?: number;
|
|
179
183
|
duration?: number;
|
|
180
184
|
contextUsage?: {
|
|
@@ -184,14 +188,33 @@ export interface AgentClaudeTurnComplete {
|
|
|
184
188
|
}
|
|
185
189
|
/**
|
|
186
190
|
* Agent → Hub: Claude CLI emitted its `system/init` frame, meaning the
|
|
187
|
-
* backend session is now bound to a real
|
|
191
|
+
* backend session is now bound to a real backendSessionId. Hub uses this to
|
|
188
192
|
* persist the ID immediately (instead of waiting for turn_complete which
|
|
189
193
|
* never fires if the turn crashes mid-flight).
|
|
190
194
|
*/
|
|
191
195
|
export interface AgentClaudeSessionStarted {
|
|
192
196
|
type: "claude.session_started";
|
|
193
197
|
sessionId: string;
|
|
194
|
-
|
|
198
|
+
backendSessionId: string;
|
|
199
|
+
}
|
|
200
|
+
export interface AgentPermissionRequest {
|
|
201
|
+
type: "agent.permission_request";
|
|
202
|
+
sessionId: string;
|
|
203
|
+
requestId: string;
|
|
204
|
+
toolName: string;
|
|
205
|
+
args: Record<string, unknown>;
|
|
206
|
+
reason?: string;
|
|
207
|
+
backendType?: "claude" | "codex";
|
|
208
|
+
meta?: Record<string, unknown>;
|
|
209
|
+
turnId?: string;
|
|
210
|
+
agentId?: string;
|
|
211
|
+
}
|
|
212
|
+
export interface HubPermissionDecision {
|
|
213
|
+
type: "client.permission_decision";
|
|
214
|
+
sessionId: string;
|
|
215
|
+
requestId: string;
|
|
216
|
+
decision: "allow" | "allow_session" | "deny" | "abort";
|
|
217
|
+
reason?: string;
|
|
195
218
|
}
|
|
196
219
|
export interface AgentFsListDirResult {
|
|
197
220
|
type: "fs.list_dir_result";
|
|
@@ -270,9 +293,59 @@ export interface AgentSwarmStatus {
|
|
|
270
293
|
status: string;
|
|
271
294
|
currentTask?: string;
|
|
272
295
|
color?: string;
|
|
296
|
+
/**
|
|
297
|
+
* Per-role backend (claude | codex). Must round-trip through the hub
|
|
298
|
+
* into the DB's `crewConfig.roles` because continuation/recreation
|
|
299
|
+
* paths spawn roles from that stored value; missing it silently
|
|
300
|
+
* downgrades codex roles to claude after agent restart.
|
|
301
|
+
*/
|
|
302
|
+
backend?: "claude" | "codex";
|
|
303
|
+
/**
|
|
304
|
+
* Per-role sandbox level. Same round-trip requirement as backend —
|
|
305
|
+
* omitting from the wire payload causes recreation paths to silently
|
|
306
|
+
* downgrade to the default workspace-write sandbox.
|
|
307
|
+
*/
|
|
308
|
+
sandbox?: SandboxLevel;
|
|
273
309
|
}>;
|
|
274
310
|
plan?: unknown;
|
|
275
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* M6.2.1: shipment snapshot pushed from agent → hub for live UI display.
|
|
314
|
+
* Mirrors `ShipmentResult` from @mclawnet/swarm but duplicated here so the
|
|
315
|
+
* shared protocol package doesn't take a dep on swarm (same pattern as
|
|
316
|
+
* `ProjectSummaryWire`).
|
|
317
|
+
*/
|
|
318
|
+
export interface ShipmentSnapshot {
|
|
319
|
+
strategy: "pr" | "diff-only" | "skipped";
|
|
320
|
+
/** ISO timestamp; optional for back-compat with test fixtures. */
|
|
321
|
+
createdAt?: string;
|
|
322
|
+
title?: string;
|
|
323
|
+
summary?: string;
|
|
324
|
+
prUrl?: string;
|
|
325
|
+
branchName?: string;
|
|
326
|
+
diffPath?: string;
|
|
327
|
+
reportPath?: string;
|
|
328
|
+
prAttemptError?: string;
|
|
329
|
+
error?: string;
|
|
330
|
+
/**
|
|
331
|
+
* ISO timestamp stamped by mergeShipment() when the user marks the PR as
|
|
332
|
+
* merged in the UI. M6.3 surfaces this in the Shipments history list as the
|
|
333
|
+
* "Merged" filter and visual badge — strategy stays "pr" forever, mergedAt
|
|
334
|
+
* is the only signal that the merge actually happened on GitHub.
|
|
335
|
+
*/
|
|
336
|
+
mergedAt?: string;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* M6.2.1: agent → hub push when a swarm's shipment pipeline finishes
|
|
340
|
+
* (success or fallback). Hub caches and fans out as `swarm_shipment` to all
|
|
341
|
+
* browser watchers of `sessionId` so the M6.2 UI can render shipment status
|
|
342
|
+
* live without polling.
|
|
343
|
+
*/
|
|
344
|
+
export interface AgentSwarmShipment {
|
|
345
|
+
type: "swarm.shipment";
|
|
346
|
+
sessionId: string;
|
|
347
|
+
shipment: ShipmentSnapshot;
|
|
348
|
+
}
|
|
276
349
|
export interface AgentRolesListResult {
|
|
277
350
|
type: "roles_list_result";
|
|
278
351
|
sessionId: string;
|
|
@@ -315,7 +388,7 @@ export interface AgentSessionDied {
|
|
|
315
388
|
sessionId: string;
|
|
316
389
|
reason?: string;
|
|
317
390
|
/**
|
|
318
|
-
* (PR-C) Last-known
|
|
391
|
+
* (PR-C) Last-known backendSessionId of the dead session, when available.
|
|
319
392
|
*
|
|
320
393
|
* Hub uses this to decide what to keep in db when reconciling the
|
|
321
394
|
* session.died event: db's `claude_session_id` is preserved (so the user
|
|
@@ -323,7 +396,7 @@ export interface AgentSessionDied {
|
|
|
323
396
|
* because pre-PR-C agents don't send it and not every dead session ever
|
|
324
397
|
* reached `system/init`.
|
|
325
398
|
*/
|
|
326
|
-
|
|
399
|
+
backendSessionId?: string;
|
|
327
400
|
}
|
|
328
401
|
/** Agent → Hub: push available skill list to browsers */
|
|
329
402
|
export interface AgentSkillListUpdate {
|
|
@@ -337,7 +410,91 @@ export interface AgentSessionStateReport {
|
|
|
337
410
|
type: "session.state";
|
|
338
411
|
sessionId: string;
|
|
339
412
|
processState: SessionProcessState;
|
|
340
|
-
|
|
413
|
+
backendSessionId?: string;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Agent → Hub: report installed backends and their capabilities.
|
|
417
|
+
* Sent once right after `registered`; can be re-sent on manifest refresh.
|
|
418
|
+
*/
|
|
419
|
+
export interface AgentManifest {
|
|
420
|
+
type: "agent.manifest";
|
|
421
|
+
payload: AgentManifestPayload;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Agent → Hub: workspace prepared for a chat session (N5).
|
|
425
|
+
* Sent right after WorkspaceManager.prepare resolves. Hub forwards to
|
|
426
|
+
* browser watchers so ChatHeader can show a "worktree: <path>" badge.
|
|
427
|
+
*/
|
|
428
|
+
export interface AgentSessionWorktreeReady {
|
|
429
|
+
type: "session.worktree_ready";
|
|
430
|
+
sessionId: string;
|
|
431
|
+
/** Absolute path on the agent host. */
|
|
432
|
+
cwd: string;
|
|
433
|
+
/** "git-worktree" | "snapshot-copy" */
|
|
434
|
+
strategy: "git-worktree" | "snapshot-copy";
|
|
435
|
+
/** Populated for git-worktree only — null for snapshot fallback. */
|
|
436
|
+
branchName?: string | null;
|
|
437
|
+
/**
|
|
438
|
+
* (PR-A review fix I3) The repo HEAD branch at worktree create time —
|
|
439
|
+
* GitWorktreeProvider already computes this from `git rev-parse
|
|
440
|
+
* --abbrev-ref HEAD`. Persisted so worktree.ship can target it as the PR
|
|
441
|
+
* base instead of guessing "main". Null for snapshot-copy strategy.
|
|
442
|
+
*/
|
|
443
|
+
baseBranch?: string | null;
|
|
444
|
+
/** The original project root (== ChatCreateConversation.workDir). */
|
|
445
|
+
projectRoot: string;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Agent → Hub: workspace lifecycle ended (session closed). Sent on close,
|
|
449
|
+
* not abort — agent never auto-deletes the worktree (keep=true).
|
|
450
|
+
* Browser uses this to prompt the user: "Worktree retained at <path>;
|
|
451
|
+
* review/merge/delete manually."
|
|
452
|
+
*/
|
|
453
|
+
export interface AgentSessionWorktreeClosed {
|
|
454
|
+
type: "session.worktree_closed";
|
|
455
|
+
sessionId: string;
|
|
456
|
+
cwd: string;
|
|
457
|
+
branchName?: string | null;
|
|
458
|
+
/**
|
|
459
|
+
* (PR1 follow-up) Optional context fields so the UI's Banner reducer
|
|
460
|
+
* doesn't depend on the in-memory `session` row still being present.
|
|
461
|
+
* Hub fills these in when synthesizing the frame from a DELETE
|
|
462
|
+
* /api/sessions request (the row is about to be dropped, so the
|
|
463
|
+
* store can't read them back). Agent-emitted frames may omit them;
|
|
464
|
+
* reducer falls back to `session?.workDir` / `session?.worktreeBaseBranch`.
|
|
465
|
+
*/
|
|
466
|
+
baseBranch?: string | null;
|
|
467
|
+
projectRoot?: string | null;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* (PR-A) Agent → Hub: emitted after a successful `worktree.ship` generic RPC.
|
|
471
|
+
* Hub persists `result` to chat_sessions.shipment_result_json and fans the
|
|
472
|
+
* frame out to subscribed browser sessions so the UI can update the banner /
|
|
473
|
+
* shipment-history view immediately without re-querying.
|
|
474
|
+
*
|
|
475
|
+
* Sent in addition to the generic.response that completes the RPC — the
|
|
476
|
+
* response carries the same payload back to the originating browser, but
|
|
477
|
+
* other tabs / devices need this push to stay in sync.
|
|
478
|
+
*/
|
|
479
|
+
export interface AgentSessionShipmentUpdated {
|
|
480
|
+
type: "session.shipment_updated";
|
|
481
|
+
sessionId: string;
|
|
482
|
+
/** Free-form result shape — UI reads `strategy` ("pr"|"diff-only") and
|
|
483
|
+
* branches on it for display. Persisted as JSONB. */
|
|
484
|
+
result: Record<string, unknown>;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* (PR-A) Agent → Hub: emitted after a successful `worktree.delete` generic
|
|
488
|
+
* RPC. Hub clears chat_sessions.worktree_path / worktree_branch /
|
|
489
|
+
* worktree_strategy (since the on-disk worktree no longer exists) and fans
|
|
490
|
+
* the frame out so any open Banner / Header on other tabs dismisses /
|
|
491
|
+
* stops showing the (now stale) badge.
|
|
492
|
+
*/
|
|
493
|
+
export interface AgentSessionWorktreeDeleted {
|
|
494
|
+
type: "session.worktree_deleted";
|
|
495
|
+
sessionId: string;
|
|
496
|
+
/** Echoed so receivers can correlate; not strictly required. */
|
|
497
|
+
cwd?: string;
|
|
341
498
|
}
|
|
342
499
|
/** Hub -> Agent: generic request (browser-initiated) */
|
|
343
500
|
export interface AgentGenericRequest {
|
|
@@ -364,7 +521,7 @@ export interface AgentGenericPush {
|
|
|
364
521
|
event: string;
|
|
365
522
|
data: Record<string, unknown>;
|
|
366
523
|
}
|
|
367
|
-
export type AgentClientMessage = AgentAuth | AgentHeartbeat | AgentSessionCreated | AgentSessionError | AgentClaudeOutput | AgentClaudeTurnComplete | AgentClaudeSessionStarted | AgentFsListDirResult | AgentFoldersListResult | AgentHistorySessionsResult | AgentSessionHistoryResult | AgentProxyOpened | AgentProxyData | AgentProxyClose | AgentSwarmOutput | AgentSwarmTurnComplete | AgentSwarmStatus | AgentRolesListResult | AgentTemplatesListResult | AgentExecutionAborted | AgentSessionDied | AgentSkillListUpdate | AgentSessionStateReport | AgentGenericResponse | AgentGenericPush | ProjectsListResult | ProjectsGetResult | ProjectsTasksResult | ProjectsTaskResult | ProjectsSwarmsResult | ProjectsSwarmResult | ProjectsInboxesResult | ProjectsInboxResult | ProjectsSwarmSessionIdResult | ProjectsFilesListResult | ProjectsFileReadResult | ProjectsFileWriteResult;
|
|
524
|
+
export type AgentClientMessage = AgentAuth | AgentHeartbeat | AgentSessionCreated | AgentSessionError | AgentClaudeOutput | AgentClaudeTurnComplete | AgentClaudeSessionStarted | AgentPermissionRequest | AgentFsListDirResult | AgentFoldersListResult | AgentHistorySessionsResult | AgentSessionHistoryResult | AgentProxyOpened | AgentProxyData | AgentProxyClose | AgentSwarmOutput | AgentSwarmTurnComplete | AgentSwarmStatus | AgentSwarmShipment | AgentRolesListResult | AgentTemplatesListResult | AgentExecutionAborted | AgentSessionDied | AgentSkillListUpdate | AgentSessionStateReport | AgentManifest | AgentSessionWorktreeReady | AgentSessionWorktreeClosed | AgentSessionShipmentUpdated | AgentSessionWorktreeDeleted | AgentGenericResponse | AgentGenericPush | ProjectsListResult | ProjectsGetResult | ProjectsTasksResult | ProjectsTaskResult | ProjectsSwarmsResult | ProjectsSwarmResult | ProjectsInboxesResult | ProjectsInboxResult | ProjectsSwarmSessionIdResult | ProjectsFilesListResult | ProjectsFileReadResult | ProjectsFileWriteResult | ProjectsEnsureProjectResult | WorkdirMkdirResult | ProjectsSwarmAddRoleResult | ProjectsShipmentGetResult | ProjectsShipmentActionResult | ProjectsShipmentDiffResult | ProjectsShipmentsListResult | ProjectsAlwaysOnGetResult | ProjectsAlwaysOnSetResult | ProjectsAlwaysOnTickNowResult;
|
|
368
525
|
/**
|
|
369
526
|
* Capability string the agent advertises in its `auth` message to declare
|
|
370
527
|
* support for the `projects.*` RPC namespace. The hub fails fast with HTTP
|
|
@@ -373,6 +530,13 @@ export type AgentClientMessage = AgentAuth | AgentHeartbeat | AgentSessionCreate
|
|
|
373
530
|
* agent connecting to a new hub mid-deploy.
|
|
374
531
|
*/
|
|
375
532
|
export declare const PROJECTS_RPC_CAPABILITY = "projects.rpc.v1";
|
|
533
|
+
/**
|
|
534
|
+
* Capability string for agent-side workDir/project creation helpers. This is
|
|
535
|
+
* separate from `projects.rpc.v1` so a new hub can fail fast instead of
|
|
536
|
+
* timing out when an older agent supports project reads but not project
|
|
537
|
+
* ensure/create flows.
|
|
538
|
+
*/
|
|
539
|
+
export declare const WORKDIR_RPC_CAPABILITY = "workdir.rpc.v1";
|
|
376
540
|
export interface ProjectsListRequest {
|
|
377
541
|
type: "projects.list";
|
|
378
542
|
requestId: string;
|
|
@@ -567,4 +731,399 @@ export interface ProjectsFileWriteResult {
|
|
|
567
731
|
details?: Record<string, unknown>;
|
|
568
732
|
} | null;
|
|
569
733
|
}
|
|
734
|
+
export type ProjectWorkdirErrorCode = "invalid_path" | "root_forbidden" | "path_forbidden" | "workdir_not_found" | "not_directory" | "create_dir_unsupported" | "meta_write_failed" | "project_load_failed" | "parent_not_found" | "parent_not_directory" | "mkdir_failed" | "agent_error";
|
|
735
|
+
export interface ProjectWorkdirErrorWire {
|
|
736
|
+
status: number;
|
|
737
|
+
message: string;
|
|
738
|
+
/**
|
|
739
|
+
* `root_forbidden` is reserved for the filesystem root itself.
|
|
740
|
+
* `path_forbidden` means the normalized path is exactly, or under, a
|
|
741
|
+
* protected system prefix such as /etc or /usr.
|
|
742
|
+
*/
|
|
743
|
+
code?: ProjectWorkdirErrorCode;
|
|
744
|
+
details?: Record<string, unknown>;
|
|
745
|
+
}
|
|
746
|
+
export interface ProjectsEnsureProjectRequest {
|
|
747
|
+
type: "projects.ensure_project";
|
|
748
|
+
requestId: string;
|
|
749
|
+
workDir: string;
|
|
750
|
+
/**
|
|
751
|
+
* Reserved for the future workDir-creation flow. T3 only supports existing
|
|
752
|
+
* directories; agents may return a 400 when this is true until mkdir support
|
|
753
|
+
* lands.
|
|
754
|
+
*/
|
|
755
|
+
createDir?: boolean;
|
|
756
|
+
}
|
|
757
|
+
export interface ProjectsEnsureProjectResult {
|
|
758
|
+
type: "projects.ensure_project_result";
|
|
759
|
+
requestId: string;
|
|
760
|
+
ok: boolean;
|
|
761
|
+
project: ProjectSummaryWire | null;
|
|
762
|
+
encodedCwd?: string;
|
|
763
|
+
workDir?: string;
|
|
764
|
+
createdMeta?: boolean;
|
|
765
|
+
error: ProjectWorkdirErrorWire | null;
|
|
766
|
+
}
|
|
767
|
+
export interface WorkdirMkdirRequest {
|
|
768
|
+
type: "workdir.mkdir";
|
|
769
|
+
requestId: string;
|
|
770
|
+
workDir: string;
|
|
771
|
+
}
|
|
772
|
+
export interface WorkdirMkdirResult {
|
|
773
|
+
type: "workdir.mkdir_result";
|
|
774
|
+
requestId: string;
|
|
775
|
+
ok: boolean;
|
|
776
|
+
workDir?: string;
|
|
777
|
+
created?: boolean;
|
|
778
|
+
error: ProjectWorkdirErrorWire | null;
|
|
779
|
+
}
|
|
780
|
+
export interface ProjectsSwarmAddRoleRequest {
|
|
781
|
+
type: "projects.swarm_add_role";
|
|
782
|
+
requestId: string;
|
|
783
|
+
encodedCwd: string;
|
|
784
|
+
swarmId: string;
|
|
785
|
+
roleName: string;
|
|
786
|
+
backend?: "claude" | "codex";
|
|
787
|
+
sandbox?: string;
|
|
788
|
+
customPrompt?: string;
|
|
789
|
+
taskPrompt?: string;
|
|
790
|
+
}
|
|
791
|
+
export interface ProjectsSwarmAddRoleResult {
|
|
792
|
+
type: "projects.swarm_add_role_result";
|
|
793
|
+
requestId: string;
|
|
794
|
+
ok: boolean;
|
|
795
|
+
swarmId?: string;
|
|
796
|
+
instanceId?: string;
|
|
797
|
+
error?: string;
|
|
798
|
+
}
|
|
799
|
+
export interface ProjectsShipmentGetRequest {
|
|
800
|
+
type: "projects.shipment_get";
|
|
801
|
+
requestId: string;
|
|
802
|
+
encodedCwd: string;
|
|
803
|
+
swarmId: string;
|
|
804
|
+
}
|
|
805
|
+
export interface ProjectsShipmentGetResult {
|
|
806
|
+
type: "projects.shipment_get_result";
|
|
807
|
+
requestId: string;
|
|
808
|
+
projectFound: boolean;
|
|
809
|
+
shipment: ShipmentSnapshot | null;
|
|
810
|
+
diffContent?: string;
|
|
811
|
+
reportContent?: string;
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* M6.2 hotfix S4: full uncapped diff.patch download. Companion to
|
|
815
|
+
* `ProjectsShipmentGetRequest` — the inline `diffContent` there is capped
|
|
816
|
+
* at 1 MiB; this RPC returns the entire file as a string so the hub can
|
|
817
|
+
* stream it back to the browser as a `text/plain` download. `content: null`
|
|
818
|
+
* with `projectFound: true` means the swarm exists but never produced a
|
|
819
|
+
* diff (strategy=pr without local diff, skipped, etc).
|
|
820
|
+
*/
|
|
821
|
+
export interface ProjectsShipmentDiffRequest {
|
|
822
|
+
type: "projects.shipment_diff";
|
|
823
|
+
requestId: string;
|
|
824
|
+
encodedCwd: string;
|
|
825
|
+
swarmId: string;
|
|
826
|
+
}
|
|
827
|
+
export interface ProjectsShipmentDiffResult {
|
|
828
|
+
type: "projects.shipment_diff_result";
|
|
829
|
+
requestId: string;
|
|
830
|
+
projectFound: boolean;
|
|
831
|
+
content: string | null;
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* M6.3: cross-swarm shipment history listing. Scans
|
|
835
|
+
* `<projectsDir>/<encoded>/swarms/<id>/shipment.json` and returns every
|
|
836
|
+
* parseable entry sorted by `createdAt` desc (newest first; missing
|
|
837
|
+
* timestamps sink to the bottom). Corrupt JSON files are skipped with a
|
|
838
|
+
* warn rather than failing the whole list — the UI is best-effort historic
|
|
839
|
+
* data, not a transaction.
|
|
840
|
+
*
|
|
841
|
+
* The agent returns the full ShipmentSnapshot per swarm so the UI can
|
|
842
|
+
* filter / render without a second round-trip per row. Each entry stays
|
|
843
|
+
* bounded (no diff/report inlined here — M6.3 history view is a list, not a
|
|
844
|
+
* detail view; users click through to the per-swarm WorkspaceBlock for diff).
|
|
845
|
+
*/
|
|
846
|
+
export interface ShipmentListEntry {
|
|
847
|
+
swarmId: string;
|
|
848
|
+
shipment: ShipmentSnapshot;
|
|
849
|
+
}
|
|
850
|
+
export interface ProjectsShipmentsListRequest {
|
|
851
|
+
type: "projects.shipments_list";
|
|
852
|
+
requestId: string;
|
|
853
|
+
encodedCwd: string;
|
|
854
|
+
}
|
|
855
|
+
export interface ProjectsShipmentsListResult {
|
|
856
|
+
type: "projects.shipments_list_result";
|
|
857
|
+
requestId: string;
|
|
858
|
+
projectFound: boolean;
|
|
859
|
+
shipments: ShipmentListEntry[];
|
|
860
|
+
}
|
|
861
|
+
export type ProjectsShipmentActionKind = "merge" | "apply" | "discard";
|
|
862
|
+
export interface ProjectsShipmentActionRequest {
|
|
863
|
+
type: "projects.shipment_action";
|
|
864
|
+
requestId: string;
|
|
865
|
+
encodedCwd: string;
|
|
866
|
+
swarmId: string;
|
|
867
|
+
action: ProjectsShipmentActionKind;
|
|
868
|
+
/**
|
|
869
|
+
* Apply-only: bypass the "dirty working tree" and "branch already exists"
|
|
870
|
+
* safety guards. Plumbed end-to-end from the hub route (?force=true query
|
|
871
|
+
* or {force:true} body) → agent handler → applyShipment. UI does NOT pass
|
|
872
|
+
* this in M6.2 — wired now so M7 can add a second-confirm UX without
|
|
873
|
+
* another protocol round-trip.
|
|
874
|
+
*/
|
|
875
|
+
force?: boolean;
|
|
876
|
+
}
|
|
877
|
+
export interface ProjectsShipmentActionResult {
|
|
878
|
+
type: "projects.shipment_action_result";
|
|
879
|
+
requestId: string;
|
|
880
|
+
/** false when project/swarm not found (hub maps to 404). */
|
|
881
|
+
projectFound: boolean;
|
|
882
|
+
ok: boolean;
|
|
883
|
+
message?: string;
|
|
884
|
+
newBranchName?: string;
|
|
885
|
+
error?: string;
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Hub → Agent: create a backend session.
|
|
889
|
+
* Replaces the "first call" semantics of claude.execute. Carries backend
|
|
890
|
+
* kind + sticky model/mode + optional initial input.
|
|
891
|
+
*/
|
|
892
|
+
export interface SessionCreate {
|
|
893
|
+
type: "session.create";
|
|
894
|
+
sessionId: string;
|
|
895
|
+
workDir?: string;
|
|
896
|
+
backend: BackendKind;
|
|
897
|
+
sticky?: {
|
|
898
|
+
model?: string;
|
|
899
|
+
mode?: string;
|
|
900
|
+
};
|
|
901
|
+
systemPrompt?: string;
|
|
902
|
+
useBrainCore?: boolean;
|
|
903
|
+
/** Optional first user input — agent calls sendUserInput right after spawn. */
|
|
904
|
+
initialInput?: string;
|
|
905
|
+
/** Resume from this backendSessionId (Claude --resume). */
|
|
906
|
+
backendSessionId?: string;
|
|
907
|
+
/** (N5) Prepare an isolated workspace before spawning; see ChatCreateConversation. */
|
|
908
|
+
useWorktree?: boolean;
|
|
909
|
+
/**
|
|
910
|
+
* (PR-A) Optional user-supplied branch suffix. Agent prepends `clawnet/chat-`
|
|
911
|
+
* to keep namespace isolation. Only meaningful when useWorktree=true.
|
|
912
|
+
*/
|
|
913
|
+
worktreeBranchName?: string;
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Hub → Agent: send user input to an existing session.
|
|
917
|
+
* Replaces the "subsequent call" semantics of claude.execute. Carries
|
|
918
|
+
* optional per-turn override (model / mode) that wins over sticky.
|
|
919
|
+
*/
|
|
920
|
+
export interface SessionInput {
|
|
921
|
+
type: "session.input";
|
|
922
|
+
sessionId: string;
|
|
923
|
+
content: string;
|
|
924
|
+
messageMeta?: {
|
|
925
|
+
model?: string;
|
|
926
|
+
mode?: string;
|
|
927
|
+
};
|
|
928
|
+
/**
|
|
929
|
+
* (N3) Optional resume hint — when agent receives session.input for a
|
|
930
|
+
* session it doesn't have alive (e.g. after agent restart), it can use
|
|
931
|
+
* this to auto-recreate via `--resume <backendSessionId>` instead of
|
|
932
|
+
* surfacing session.error. Hub populates this from chat_sessions.
|
|
933
|
+
*/
|
|
934
|
+
backendSessionId?: string;
|
|
935
|
+
/**
|
|
936
|
+
* (N3) Optional working directory for restart-recovery. When agent
|
|
937
|
+
* recovers via --resume, the spawn needs cwd + memory injection +
|
|
938
|
+
* braincore mounts. Hub populates from chat_sessions.work_dir.
|
|
939
|
+
* Healthy-path sendUserInput ignores this (the existing process has
|
|
940
|
+
* its own cwd already).
|
|
941
|
+
*/
|
|
942
|
+
workDir?: string;
|
|
943
|
+
/**
|
|
944
|
+
* (N3) Optional braincore mount flag for restart-recovery. Same
|
|
945
|
+
* rationale as workDir — only consulted by the recovery branch.
|
|
946
|
+
*/
|
|
947
|
+
useBrainCore?: boolean;
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* Hub → Agent: update sticky model/mode on a running session.
|
|
951
|
+
* Partial — fields omitted keep their current value. Agent applies to
|
|
952
|
+
* next spawn; in-flight turn is not interrupted.
|
|
953
|
+
*/
|
|
954
|
+
export interface SessionUpdateSticky {
|
|
955
|
+
type: "session.update_sticky";
|
|
956
|
+
sessionId: string;
|
|
957
|
+
sticky: {
|
|
958
|
+
model?: string;
|
|
959
|
+
mode?: string;
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
export type AlwaysOnMode = "off" | "quiet" | "active" | "aggressive";
|
|
963
|
+
/**
|
|
964
|
+
* M8.2 — per-source opt-in toggles for the cascade picker. The agent applies
|
|
965
|
+
* sensible defaults (TaskStore + Idea Todo + Idea Research on; introspection
|
|
966
|
+
* off) when fields are absent. The M8.3 UI surfaces the toggles; today only
|
|
967
|
+
* an `always-on.json` edit can flip them.
|
|
968
|
+
*/
|
|
969
|
+
export interface AlwaysOnTaskSourcesConfig {
|
|
970
|
+
/** L1 — TaskStore (sprint backlog). Default true. */
|
|
971
|
+
taskStore?: boolean;
|
|
972
|
+
/** L2a — Ideas with status=todo. Default true. */
|
|
973
|
+
ideaTodo?: boolean;
|
|
974
|
+
/** L2b — Ideas with status=idea (research cycle). Default true. */
|
|
975
|
+
ideaResearch?: boolean;
|
|
976
|
+
/** L3 — Queen self-introspection (opt-in). Default false. */
|
|
977
|
+
introspection?: boolean;
|
|
978
|
+
}
|
|
979
|
+
export interface AlwaysOnConfig {
|
|
980
|
+
mode: AlwaysOnMode;
|
|
981
|
+
/** 1..20 cycles/day, integer. */
|
|
982
|
+
dailyBudget: number;
|
|
983
|
+
/** ISO timestamp; absent or in the past = not paused. */
|
|
984
|
+
pausedUntil?: string;
|
|
985
|
+
/**
|
|
986
|
+
* Template name used when AlwaysOnManager spawns a scheduler cycle swarm.
|
|
987
|
+
* Forward-compatible: the M7 UI doesn't expose this yet; agents pick a safe
|
|
988
|
+
* default ("minimal") when absent. PATCH-able once the toggle UI lands.
|
|
989
|
+
*/
|
|
990
|
+
templateName?: string;
|
|
991
|
+
/**
|
|
992
|
+
* M8.2 — per-source opt-in toggles. Omitted fields fall back to defaults
|
|
993
|
+
* (taskStore / ideaTodo / ideaResearch on; introspection off).
|
|
994
|
+
*/
|
|
995
|
+
taskSources?: AlwaysOnTaskSourcesConfig;
|
|
996
|
+
/**
|
|
997
|
+
* M8.2 — cooldown (in hours) between consecutive L3 introspection cycles.
|
|
998
|
+
* Independent of dailyBudget so the agent doesn't burn its main quota on
|
|
999
|
+
* self-introspection. Default 24.
|
|
1000
|
+
*/
|
|
1001
|
+
introspectionCooldownHours?: number;
|
|
1002
|
+
/**
|
|
1003
|
+
* M8.2 — runtime state: ISO timestamp of the most recent introspection
|
|
1004
|
+
* cycle that ran (regardless of whether it produced ideas). Persisted to
|
|
1005
|
+
* disk by AlwaysOnManager so cooldown survives an agent restart.
|
|
1006
|
+
*/
|
|
1007
|
+
lastIntrospectionAt?: string;
|
|
1008
|
+
/**
|
|
1009
|
+
* M8.2 — runtime state: when true, every idea produced by the previous
|
|
1010
|
+
* introspection cycle was archived by the user. Next introspection will
|
|
1011
|
+
* skip itself to avoid producing more noise. Cleared as soon as one prior
|
|
1012
|
+
* idea survives (status != archived).
|
|
1013
|
+
*/
|
|
1014
|
+
lastIntrospectionRejected?: boolean;
|
|
1015
|
+
/**
|
|
1016
|
+
* M8 hotfix I1/I2 — runtime state: when set, the agent has an
|
|
1017
|
+
* introspection swarm spawned in a prior tick whose output has not yet
|
|
1018
|
+
* been ingested. The next IntrospectionSource pick observes this
|
|
1019
|
+
* breadcrumb, checks the swarm's terminal status, POSTs the cohort, and
|
|
1020
|
+
* clears the field. Persisted so an agent restart mid-cycle still ingests
|
|
1021
|
+
* the result on next boot. Wire-exposed for future UI surfacing — the
|
|
1022
|
+
* current UI ignores it.
|
|
1023
|
+
*/
|
|
1024
|
+
pendingIntrospectionSwarmId?: string;
|
|
1025
|
+
/**
|
|
1026
|
+
* PR-B follow-up — workspace.cwd of the pending introspection swarm,
|
|
1027
|
+
* captured at spawn time. Persisted alongside `pendingIntrospectionSwarmId`
|
|
1028
|
+
* so the spawner can resolve the candidates output file after
|
|
1029
|
+
* `swarm_complete` deletes the swarm from the coordinator registry
|
|
1030
|
+
* (post-deletion `getSwarm()` returns undefined and the live workspace
|
|
1031
|
+
* handle is lost). Absent when introspection swarm runs without an
|
|
1032
|
+
* isolated workspace (snapshot-copy fallback skipped, or no
|
|
1033
|
+
* WorkspaceManager wired). Wire-exposed for parity with the agent-side
|
|
1034
|
+
* persisted config; current UI ignores it.
|
|
1035
|
+
*/
|
|
1036
|
+
pendingIntrospectionWorkspaceCwd?: string;
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Live runtime snapshot from a DiscoveryScheduler instance. M7.2 returns an
|
|
1040
|
+
* empty/default snapshot when no scheduler is wired (no live runner yet —
|
|
1041
|
+
* that's M7.3); the UI still renders the "Status" line correctly.
|
|
1042
|
+
*
|
|
1043
|
+
* All Date values are serialised as ISO strings here because the protocol
|
|
1044
|
+
* crosses a JSON boundary.
|
|
1045
|
+
*/
|
|
1046
|
+
export interface AlwaysOnTickRecord {
|
|
1047
|
+
at: string;
|
|
1048
|
+
decision: "fired" | "skipped" | "halted";
|
|
1049
|
+
/** Gates evaluated, in order. Last entry on a non-fire is the gate that
|
|
1050
|
+
* short-circuited the cascade. */
|
|
1051
|
+
gateBreakdown: Array<{
|
|
1052
|
+
gate: string;
|
|
1053
|
+
decision: {
|
|
1054
|
+
kind: "fire";
|
|
1055
|
+
} | {
|
|
1056
|
+
kind: "skip";
|
|
1057
|
+
reason: string;
|
|
1058
|
+
} | {
|
|
1059
|
+
kind: "halt";
|
|
1060
|
+
reason: string;
|
|
1061
|
+
};
|
|
1062
|
+
}>;
|
|
1063
|
+
durationMs: number;
|
|
1064
|
+
}
|
|
1065
|
+
export interface AlwaysOnSnapshot {
|
|
1066
|
+
mode: AlwaysOnMode;
|
|
1067
|
+
ticksToday: number;
|
|
1068
|
+
/** ISO timestamp or null when scheduler has never fired. */
|
|
1069
|
+
lastFireAt: string | null;
|
|
1070
|
+
/** ISO timestamp or null when stopped / mode=off / halted. */
|
|
1071
|
+
nextTickAt: string | null;
|
|
1072
|
+
/** Last N tick records, newest at the end. */
|
|
1073
|
+
recentTicks: AlwaysOnTickRecord[];
|
|
1074
|
+
}
|
|
1075
|
+
export interface ProjectsAlwaysOnGetRequest {
|
|
1076
|
+
type: "projects.always_on_get";
|
|
1077
|
+
requestId: string;
|
|
1078
|
+
encodedCwd: string;
|
|
1079
|
+
}
|
|
1080
|
+
export interface ProjectsAlwaysOnGetResult {
|
|
1081
|
+
type: "projects.always_on_get_result";
|
|
1082
|
+
requestId: string;
|
|
1083
|
+
projectFound: boolean;
|
|
1084
|
+
config: AlwaysOnConfig;
|
|
1085
|
+
snapshot: AlwaysOnSnapshot;
|
|
1086
|
+
}
|
|
1087
|
+
export interface ProjectsAlwaysOnSetRequest {
|
|
1088
|
+
type: "projects.always_on_set";
|
|
1089
|
+
requestId: string;
|
|
1090
|
+
encodedCwd: string;
|
|
1091
|
+
/** Partial update; omitted fields keep their persisted value. */
|
|
1092
|
+
config: Omit<Partial<AlwaysOnConfig>, "pausedUntil"> & {
|
|
1093
|
+
pausedUntil?: string | null;
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1096
|
+
export interface ProjectsAlwaysOnSetResult {
|
|
1097
|
+
type: "projects.always_on_set_result";
|
|
1098
|
+
requestId: string;
|
|
1099
|
+
projectFound: boolean;
|
|
1100
|
+
config: AlwaysOnConfig;
|
|
1101
|
+
snapshot: AlwaysOnSnapshot;
|
|
1102
|
+
error?: string;
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* B6 — dev-only force-tick. Bypasses the always-on gate cascade (userActive
|
|
1106
|
+
* in particular) by clearing `lastActivityAt` for the project before
|
|
1107
|
+
* invoking `DiscoveryScheduler.tickNow()`. Hub gates this on
|
|
1108
|
+
* `NODE_ENV !== "production"` so it never reaches the agent in prod.
|
|
1109
|
+
*
|
|
1110
|
+
* Returned snapshot reflects the state AFTER the forced tick so callers can
|
|
1111
|
+
* observe ticksToday increment / lastFireAt move in one round trip.
|
|
1112
|
+
*/
|
|
1113
|
+
export interface ProjectsAlwaysOnTickNowRequest {
|
|
1114
|
+
type: "projects.always_on_tick_now";
|
|
1115
|
+
requestId: string;
|
|
1116
|
+
encodedCwd: string;
|
|
1117
|
+
}
|
|
1118
|
+
export interface ProjectsAlwaysOnTickNowResult {
|
|
1119
|
+
type: "projects.always_on_tick_now_result";
|
|
1120
|
+
requestId: string;
|
|
1121
|
+
projectFound: boolean;
|
|
1122
|
+
/** "fired" | "skipped" | "halted" — matches TickRecord.decision. */
|
|
1123
|
+
decision?: string;
|
|
1124
|
+
/** Per-gate breakdown so dev tools can see WHY a forced tick still skipped. */
|
|
1125
|
+
gateBreakdown?: AlwaysOnTickRecord["gateBreakdown"];
|
|
1126
|
+
snapshot?: AlwaysOnSnapshot;
|
|
1127
|
+
error?: string;
|
|
1128
|
+
}
|
|
570
1129
|
//# sourceMappingURL=agent.d.ts.map
|