@gajae-code/coding-agent 0.2.5 → 0.3.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 (112) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/types/async/job-manager.d.ts +84 -2
  3. package/dist/types/commands/harness.d.ts +37 -0
  4. package/dist/types/config/settings-schema.d.ts +6 -0
  5. package/dist/types/config/settings.d.ts +2 -0
  6. package/dist/types/deep-interview/render-middleware.d.ts +5 -0
  7. package/dist/types/extensibility/custom-tools/types.d.ts +1 -0
  8. package/dist/types/extensibility/extensions/types.d.ts +6 -0
  9. package/dist/types/extensibility/shared-events.d.ts +1 -0
  10. package/dist/types/gjc-runtime/state-graph.d.ts +4 -0
  11. package/dist/types/gjc-runtime/state-migrations.d.ts +24 -0
  12. package/dist/types/gjc-runtime/state-renderer.d.ts +65 -0
  13. package/dist/types/gjc-runtime/state-runtime.d.ts +2 -0
  14. package/dist/types/gjc-runtime/state-validation.d.ts +6 -0
  15. package/dist/types/gjc-runtime/state-writer.d.ts +137 -0
  16. package/dist/types/gjc-runtime/team-runtime.d.ts +81 -7
  17. package/dist/types/gjc-runtime/workflow-manifest.d.ts +54 -0
  18. package/dist/types/harness-control-plane/classifier.d.ts +13 -0
  19. package/dist/types/harness-control-plane/control-endpoint.d.ts +30 -0
  20. package/dist/types/harness-control-plane/finalize.d.ts +47 -0
  21. package/dist/types/harness-control-plane/frame-mapper.d.ts +29 -0
  22. package/dist/types/harness-control-plane/operate.d.ts +35 -0
  23. package/dist/types/harness-control-plane/owner.d.ts +46 -0
  24. package/dist/types/harness-control-plane/preserve.d.ts +19 -0
  25. package/dist/types/harness-control-plane/receipts.d.ts +88 -0
  26. package/dist/types/harness-control-plane/rpc-adapter.d.ts +66 -0
  27. package/dist/types/harness-control-plane/seams.d.ts +21 -0
  28. package/dist/types/harness-control-plane/session-lease.d.ts +65 -0
  29. package/dist/types/harness-control-plane/state-machine.d.ts +19 -0
  30. package/dist/types/harness-control-plane/storage.d.ts +53 -0
  31. package/dist/types/harness-control-plane/types.d.ts +162 -0
  32. package/dist/types/hooks/skill-keywords.d.ts +2 -1
  33. package/dist/types/hooks/skill-state.d.ts +2 -29
  34. package/dist/types/modes/components/hook-selector.d.ts +1 -0
  35. package/dist/types/modes/interactive-mode.d.ts +1 -0
  36. package/dist/types/modes/types.d.ts +1 -0
  37. package/dist/types/sdk.d.ts +2 -0
  38. package/dist/types/session/agent-session.d.ts +8 -0
  39. package/dist/types/skill-state/active-state.d.ts +2 -0
  40. package/dist/types/skill-state/deep-interview-mutation-guard.d.ts +1 -1
  41. package/dist/types/skill-state/workflow-state-contract.d.ts +24 -0
  42. package/dist/types/task/executor.d.ts +3 -0
  43. package/dist/types/task/types.d.ts +55 -3
  44. package/dist/types/tools/subagent.d.ts +11 -1
  45. package/package.json +7 -7
  46. package/src/async/job-manager.ts +298 -6
  47. package/src/cli/auth-broker-cli.ts +1 -0
  48. package/src/cli/config-cli.ts +10 -2
  49. package/src/cli.ts +2 -0
  50. package/src/commands/harness.ts +592 -0
  51. package/src/commands/team.ts +36 -39
  52. package/src/config/settings-schema.ts +7 -0
  53. package/src/config/settings.ts +5 -0
  54. package/src/deep-interview/render-middleware.ts +366 -0
  55. package/src/defaults/gjc/skills/team/SKILL.md +47 -21
  56. package/src/defaults/gjc/skills/ultragoal/SKILL.md +78 -11
  57. package/src/extensibility/custom-tools/types.ts +1 -0
  58. package/src/extensibility/extensions/types.ts +6 -0
  59. package/src/extensibility/shared-events.ts +1 -0
  60. package/src/gjc-runtime/deep-interview-runtime.ts +40 -21
  61. package/src/gjc-runtime/goal-mode-request.ts +11 -3
  62. package/src/gjc-runtime/ralplan-runtime.ts +25 -10
  63. package/src/gjc-runtime/state-graph.ts +86 -0
  64. package/src/gjc-runtime/state-migrations.ts +132 -0
  65. package/src/gjc-runtime/state-renderer.ts +345 -0
  66. package/src/gjc-runtime/state-runtime.ts +733 -21
  67. package/src/gjc-runtime/state-validation.ts +49 -0
  68. package/src/gjc-runtime/state-writer.ts +718 -0
  69. package/src/gjc-runtime/team-runtime.ts +1083 -89
  70. package/src/gjc-runtime/ultragoal-runtime.ts +348 -19
  71. package/src/gjc-runtime/workflow-manifest.generated.json +1497 -0
  72. package/src/gjc-runtime/workflow-manifest.ts +425 -0
  73. package/src/harness-control-plane/classifier.ts +128 -0
  74. package/src/harness-control-plane/control-endpoint.ts +137 -0
  75. package/src/harness-control-plane/finalize.ts +222 -0
  76. package/src/harness-control-plane/frame-mapper.ts +286 -0
  77. package/src/harness-control-plane/operate.ts +225 -0
  78. package/src/harness-control-plane/owner.ts +553 -0
  79. package/src/harness-control-plane/preserve.ts +102 -0
  80. package/src/harness-control-plane/receipts.ts +216 -0
  81. package/src/harness-control-plane/rpc-adapter.ts +276 -0
  82. package/src/harness-control-plane/seams.ts +39 -0
  83. package/src/harness-control-plane/session-lease.ts +388 -0
  84. package/src/harness-control-plane/state-machine.ts +97 -0
  85. package/src/harness-control-plane/storage.ts +257 -0
  86. package/src/harness-control-plane/types.ts +214 -0
  87. package/src/hooks/skill-keywords.ts +4 -2
  88. package/src/hooks/skill-state.ts +24 -41
  89. package/src/internal-urls/docs-index.generated.ts +1 -1
  90. package/src/modes/components/assistant-message.ts +5 -1
  91. package/src/modes/components/hook-selector.ts +72 -2
  92. package/src/modes/controllers/event-controller.ts +71 -6
  93. package/src/modes/controllers/extension-ui-controller.ts +6 -0
  94. package/src/modes/controllers/input-controller.ts +9 -1
  95. package/src/modes/controllers/selector-controller.ts +2 -1
  96. package/src/modes/interactive-mode.ts +1 -0
  97. package/src/modes/types.ts +1 -0
  98. package/src/prompts/agents/executor.md +13 -0
  99. package/src/prompts/tools/subagent.md +33 -3
  100. package/src/sdk.ts +4 -0
  101. package/src/session/agent-session.ts +231 -33
  102. package/src/session/session-manager.ts +13 -1
  103. package/src/skill-state/active-state.ts +58 -65
  104. package/src/skill-state/deep-interview-mutation-guard.ts +91 -13
  105. package/src/skill-state/initial-phase.ts +2 -0
  106. package/src/skill-state/workflow-state-contract.ts +26 -0
  107. package/src/task/executor.ts +50 -8
  108. package/src/task/index.ts +120 -8
  109. package/src/task/render.ts +6 -3
  110. package/src/task/types.ts +56 -3
  111. package/src/tools/ask.ts +28 -7
  112. package/src/tools/subagent.ts +255 -64
@@ -2,6 +2,8 @@ import type { WorkflowHudSummary } from "../skill-state/active-state";
2
2
  export type GjcTeamPhase = "starting" | "running" | "awaiting_integration" | "complete" | "failed" | "cancelled";
3
3
  export type GjcTeamTaskStatus = "pending" | "blocked" | "in_progress" | "completed" | "failed";
4
4
  export type GjcWorkerStatusState = "idle" | "working" | "blocked" | "done" | "failed" | "draining" | "unknown";
5
+ export type GjcTeamWorkerLifecycleState = "starting" | "ready" | "working" | "draining" | "stopped" | "failed" | "unknown";
6
+ export type GjcTeamShutdownMode = "graceful" | "force" | "abort";
5
7
  export declare const GJC_TEAM_DEFAULT_WORKERS = 3;
6
8
  export declare const GJC_TEAM_MAX_WORKERS = 20;
7
9
  export type GjcTeamWorkerCli = "gjc";
@@ -33,6 +35,25 @@ export interface GjcTeamTaskClaim {
33
35
  token: string;
34
36
  leased_until: string;
35
37
  }
38
+ export type GjcTeamTaskCompletionEvidenceKind = "command" | "inspection" | "artifact";
39
+ export type GjcTeamTaskCompletionEvidenceStatus = "passed" | "failed" | "not_run" | "verified" | "rejected";
40
+ export interface GjcTeamTaskCompletionEvidenceItem {
41
+ kind: GjcTeamTaskCompletionEvidenceKind;
42
+ status: GjcTeamTaskCompletionEvidenceStatus;
43
+ summary: string;
44
+ command?: string;
45
+ artifact?: string;
46
+ location?: string;
47
+ output?: string;
48
+ }
49
+ export interface GjcTeamTaskCompletionEvidence {
50
+ summary: string;
51
+ items: GjcTeamTaskCompletionEvidenceItem[];
52
+ files?: string[];
53
+ notes?: string;
54
+ recorded_by: string;
55
+ recorded_at: string;
56
+ }
36
57
  export interface GjcTeamTask {
37
58
  id: string;
38
59
  subject: string;
@@ -43,9 +64,13 @@ export interface GjcTeamTask {
43
64
  assignee?: string;
44
65
  owner?: string;
45
66
  result?: string;
67
+ completion_evidence?: GjcTeamTaskCompletionEvidence;
46
68
  error?: string;
47
69
  blocked_by?: string[];
48
70
  depends_on?: string[];
71
+ lane?: string;
72
+ required_role?: string;
73
+ allowed_roles?: string[];
49
74
  version: number;
50
75
  claim?: GjcTeamTaskClaim;
51
76
  created_at: string;
@@ -102,6 +127,22 @@ export interface GjcTeamMonitorSnapshot {
102
127
  integration_by_worker: Record<string, GjcTeamWorkerIntegrationState>;
103
128
  updated_at: string;
104
129
  }
130
+ export interface GjcTeamWorkerLifecycle {
131
+ worker: string;
132
+ lifecycle_state: GjcTeamWorkerLifecycleState;
133
+ worker_status_state: GjcWorkerStatusState;
134
+ pane_id?: string;
135
+ pid?: number;
136
+ started_at?: string;
137
+ updated_at: string;
138
+ stopped_at?: string;
139
+ stop_reason?: string;
140
+ shutdown_request_id?: string;
141
+ shutdown_requested_at?: string;
142
+ shutdown_acknowledged_at?: string;
143
+ shutdown_ack_status?: string;
144
+ shutdown_mode?: GjcTeamShutdownMode;
145
+ }
105
146
  export type GjcTeamNotificationDeliveryState = "pending" | "sent" | "queued" | "deferred" | "failed" | "delivered" | "acknowledged";
106
147
  export type GjcTeamPaneAttemptResult = "sent" | "queued" | "deferred" | "failed";
107
148
  export interface GjcTeamNotification {
@@ -139,9 +180,13 @@ export interface GjcTeamSnapshot {
139
180
  task_counts: Record<GjcTeamTaskStatus, number>;
140
181
  workers: GjcTeamWorker[];
141
182
  integration_by_worker?: Record<string, GjcTeamWorkerIntegrationState>;
183
+ worker_lifecycle_by_id: Record<string, GjcTeamWorkerLifecycle>;
142
184
  notification_summary: GjcTeamNotificationSummary;
143
185
  updated_at: string;
144
186
  }
187
+ export interface GjcTeamSnapshotOptions {
188
+ reconcileNotifications?: boolean;
189
+ }
145
190
  export interface GjcTeamStartOptions {
146
191
  workerCount: number;
147
192
  agentType: string;
@@ -159,6 +204,16 @@ export interface GjcTeamApiClaimResult {
159
204
  claim_token?: string;
160
205
  reason?: string;
161
206
  }
207
+ export type GjcTeamLivenessRecoveryReason = "claim_expired" | "stale_heartbeat" | "missing_pane" | "worker_lifecycle_failed" | "worker_lifecycle_stopped";
208
+ export interface GjcTeamRecoveredClaim {
209
+ task_id: string;
210
+ worker: string;
211
+ reasons: GjcTeamLivenessRecoveryReason[];
212
+ }
213
+ export interface GjcTeamLivenessRecoveryResult {
214
+ recovered_claims: GjcTeamRecoveredClaim[];
215
+ stale_workers: Record<string, GjcTeamLivenessRecoveryReason[]>;
216
+ }
162
217
  export interface GjcTeamMailboxMessage {
163
218
  message_id: string;
164
219
  from_worker: string;
@@ -181,6 +236,19 @@ export interface GjcTeamEvent {
181
236
  message?: string;
182
237
  data?: Record<string, unknown>;
183
238
  }
239
+ export interface GjcTeamTraceEvent {
240
+ schema_version: 1;
241
+ trace_id: string;
242
+ span_id: string;
243
+ source_event_id: string;
244
+ event_type: string;
245
+ ts: string;
246
+ worker?: string;
247
+ task_id?: string;
248
+ message?: string;
249
+ evidence_refs?: string[];
250
+ data?: Record<string, unknown>;
251
+ }
184
252
  interface WorkerStatusFile {
185
253
  state: GjcWorkerStatusState;
186
254
  current_task_id?: string;
@@ -202,8 +270,11 @@ export interface GjcWorkerIntegrationAttemptRequestResult {
202
270
  head?: string | null;
203
271
  status?: GjcWorkerCheckpointClassification["kind"];
204
272
  }
205
- export declare const GJC_TEAM_API_OPERATIONS: readonly ["send-message", "broadcast", "mailbox-list", "mailbox-mark-delivered", "mailbox-mark-notified", "notification-list", "notification-read", "notification-replay", "notification-mark-pane-attempt", "worker-startup-ack", "create-task", "read-task", "list-tasks", "update-task", "claim-task", "transition-task-status", "transition-task", "release-task-claim", "read-config", "read-manifest", "read-worker-status", "read-worker-heartbeat", "update-worker-heartbeat", "write-worker-inbox", "write-worker-identity", "append-event", "read-events", "await-event", "write-shutdown-request", "read-shutdown-ack", "read-monitor-snapshot", "write-monitor-snapshot", "read-task-approval", "write-task-approval"];
273
+ export declare const GJC_TEAM_API_OPERATIONS: readonly ["send-message", "broadcast", "mailbox-list", "mailbox-mark-delivered", "mailbox-mark-notified", "notification-list", "notification-read", "notification-replay", "notification-mark-pane-attempt", "worker-startup-ack", "create-task", "read-task", "list-tasks", "update-task", "claim-task", "transition-task-status", "transition-task", "release-task-claim", "read-config", "read-manifest", "read-worker-status", "update-worker-status", "read-worker-heartbeat", "recover-stale-claims", "update-worker-heartbeat", "write-worker-inbox", "write-worker-identity", "append-event", "read-events", "read-traces", "await-event", "write-shutdown-request", "read-shutdown-ack", "read-monitor-snapshot", "write-monitor-snapshot", "read-task-approval", "write-task-approval"];
206
274
  export declare function resolveGjcTeamStateRoot(cwd?: string, env?: NodeJS.ProcessEnv): string;
275
+ export declare function persistGjcTeamModeStateSummary(snapshot: GjcTeamSnapshot, cwd?: string): Promise<void>;
276
+ export declare function recoverGjcTeamStaleClaims(teamName: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcTeamLivenessRecoveryResult>;
277
+ type GjcTeamTaskMetadataInput = Partial<Pick<GjcTeamTask, "owner" | "lane" | "required_role" | "allowed_roles" | "depends_on" | "blocked_by">>;
207
278
  export declare function resolveGjcTmuxCommand(env?: NodeJS.ProcessEnv): string;
208
279
  export declare function resolveGjcWorkerCommand(cwd?: string, env?: NodeJS.ProcessEnv): string;
209
280
  export type GjcWorkerCheckpointClassification = {
@@ -229,7 +300,8 @@ export declare function classifyGjcTeamCheckpointFiles(files: string[]): {
229
300
  };
230
301
  export declare function classifyWorkerCheckpointStatus(cwd: string): GjcWorkerCheckpointClassification;
231
302
  export declare function startGjcTeam(options: GjcTeamStartOptions): Promise<GjcTeamSnapshot>;
232
- export declare function readGjcTeamSnapshot(teamName: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcTeamSnapshot>;
303
+ export declare function readGjcTeamSnapshot(teamName: string, cwd?: string, env?: NodeJS.ProcessEnv, options?: GjcTeamSnapshotOptions): Promise<GjcTeamSnapshot>;
304
+ export declare function monitorGjcTeamSnapshot(teamName: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcTeamSnapshot>;
233
305
  export declare function requestGjcWorkerIntegrationAttempt(cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcWorkerIntegrationAttemptRequestResult>;
234
306
  export declare function buildTeamHudSummary(snapshot: GjcTeamSnapshot, latestEvent?: GjcTeamEvent, latestMessage?: GjcTeamMailboxMessage): Promise<WorkflowHudSummary>;
235
307
  export declare function monitorGjcTeam(teamName: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcTeamSnapshot>;
@@ -237,11 +309,11 @@ export declare function listGjcTeams(cwd?: string, env?: NodeJS.ProcessEnv): Pro
237
309
  export declare function shutdownGjcTeam(teamName: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcTeamSnapshot>;
238
310
  export declare function listGjcTeamTasks(teamName: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcTeamTask[]>;
239
311
  export declare function readGjcTeamTask(teamName: string, taskId: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcTeamTask>;
240
- export declare function createGjcTeamTask(teamName: string, subject: string, description: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcTeamTask>;
241
- export declare function updateGjcTeamTask(teamName: string, taskId: string, updates: Partial<Pick<GjcTeamTask, "subject" | "description" | "blocked_by" | "depends_on">>, cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcTeamTask>;
312
+ export declare function createGjcTeamTask(teamName: string, subject: string, description: string, cwd?: string, env?: NodeJS.ProcessEnv, taskOptions?: GjcTeamTaskMetadataInput): Promise<GjcTeamTask>;
313
+ export declare function updateGjcTeamTask(teamName: string, taskId: string, updates: Partial<Pick<GjcTeamTask, "subject" | "description" | "blocked_by" | "depends_on" | "lane" | "required_role" | "allowed_roles">>, cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcTeamTask>;
242
314
  export declare function claimGjcTeamTask(teamName: string, workerId: string, cwd?: string, env?: NodeJS.ProcessEnv, taskId?: string): Promise<GjcTeamApiClaimResult>;
243
- export declare function transitionGjcTeamTaskStatus(teamName: string, taskId: string, status: GjcTeamTaskStatus, cwd?: string, env?: NodeJS.ProcessEnv, claimToken?: string, workerId?: string, evidence?: string): Promise<GjcTeamTask>;
244
- export declare function transitionGjcTeamTask(teamName: string, taskId: string, status: GjcTeamTaskStatus | "complete", cwd?: string, env?: NodeJS.ProcessEnv, claimToken?: string): Promise<GjcTeamTask>;
315
+ export declare function transitionGjcTeamTaskStatus(teamName: string, taskId: string, status: GjcTeamTaskStatus, cwd?: string, env?: NodeJS.ProcessEnv, claimToken?: string, workerId?: string, completionEvidenceInput?: unknown): Promise<GjcTeamTask>;
316
+ export declare function transitionGjcTeamTask(teamName: string, taskId: string, status: GjcTeamTaskStatus | "complete", cwd?: string, env?: NodeJS.ProcessEnv, claimToken?: string, completionEvidenceInput?: unknown): Promise<GjcTeamTask>;
245
317
  export declare function releaseGjcTeamTaskClaim(teamName: string, taskId: string, claimToken: string, workerId: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcTeamTask>;
246
318
  export declare function replayGjcTeamNotifications(teamName: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<{
247
319
  notifications: GjcTeamNotification[];
@@ -252,6 +324,7 @@ export declare function broadcastGjcTeamMessage(teamName: string, fromWorker: st
252
324
  export declare function listGjcTeamMailbox(teamName: string, worker: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcTeamMailboxMessage[]>;
253
325
  export declare function markGjcTeamMailboxMessage(teamName: string, worker: string, messageId: string, field: "delivered_at" | "notified_at", cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcTeamMailboxMessage>;
254
326
  export declare function readGjcWorkerStatus(teamName: string, worker: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<WorkerStatusFile>;
327
+ export declare function updateGjcWorkerStatus(teamName: string, worker: string, status: GjcWorkerStatusState, cwd?: string, env?: NodeJS.ProcessEnv, currentTaskId?: string, reason?: string): Promise<WorkerStatusFile>;
255
328
  export declare function readGjcWorkerHeartbeat(teamName: string, worker: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<WorkerHeartbeatFile | null>;
256
329
  export declare function updateGjcWorkerHeartbeat(teamName: string, worker: string, heartbeat: WorkerHeartbeatFile, cwd?: string, env?: NodeJS.ProcessEnv): Promise<WorkerHeartbeatFile>;
257
330
  export declare function writeGjcWorkerInbox(teamName: string, worker: string, content: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<{
@@ -259,6 +332,7 @@ export declare function writeGjcWorkerInbox(teamName: string, worker: string, co
259
332
  }>;
260
333
  export declare function writeGjcWorkerIdentity(teamName: string, worker: GjcTeamWorker, cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcTeamWorker>;
261
334
  export declare function readGjcTeamEvents(teamName: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcTeamEvent[]>;
335
+ export declare function readGjcTeamTraces(teamName: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcTeamTraceEvent[]>;
262
336
  export declare function appendGjcTeamEvent(teamName: string, type: string, worker?: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<GjcTeamEvent>;
263
337
  export declare function awaitGjcTeamEvent(teamName: string, _timeoutMs?: number, cwd?: string, env?: NodeJS.ProcessEnv): Promise<{
264
338
  status: "event" | "timeout";
@@ -268,7 +342,7 @@ export declare function writeGjcMonitorSnapshot(teamName: string, snapshot: unkn
268
342
  export declare function readGjcMonitorSnapshot(teamName: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<unknown>;
269
343
  export declare function writeGjcTaskApproval(teamName: string, taskId: string, approval: Record<string, unknown>, cwd?: string, env?: NodeJS.ProcessEnv): Promise<Record<string, unknown>>;
270
344
  export declare function readGjcTaskApproval(teamName: string, taskId: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<Record<string, unknown> | null>;
271
- export declare function writeGjcShutdownRequest(teamName: string, worker: string, requestedBy: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<Record<string, unknown>>;
345
+ export declare function writeGjcShutdownRequest(teamName: string, worker: string, requestedBy: string, cwd?: string, env?: NodeJS.ProcessEnv, requestId?: string, mode?: GjcTeamShutdownMode, requestedAt?: string): Promise<Record<string, unknown>>;
272
346
  export declare function readGjcShutdownAck(teamName: string, worker: string, cwd?: string, env?: NodeJS.ProcessEnv): Promise<Record<string, unknown> | null>;
273
347
  export declare function executeGjcTeamApiOperation(operation: string, input: Record<string, unknown>, cwd?: string, env?: NodeJS.ProcessEnv): Promise<unknown>;
274
348
  export declare function parseTeamLaunchArgs(argv: string[]): GjcTeamStartOptions;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * TypeScript is the authoritative source of truth for GJC workflow manifests.
3
+ * Any JSON manifest projection is derived from this module and must never be
4
+ * hand-edited.
5
+ */
6
+ import type { CanonicalGjcWorkflowSkill } from "../skill-state/active-state";
7
+ export interface WorkflowState {
8
+ id: string;
9
+ initial?: boolean;
10
+ terminal?: boolean;
11
+ }
12
+ export interface WorkflowTransition {
13
+ from: string;
14
+ to: string;
15
+ verb: string;
16
+ }
17
+ export interface WorkflowVerb {
18
+ name: string;
19
+ planned?: boolean;
20
+ /** Invocation surface that exposes this verb in the real CLI parser. */
21
+ surface?: "state-action" | "command-positional" | "command-flag";
22
+ }
23
+ export interface TypedArgSpec {
24
+ name: string;
25
+ type: "string" | "number" | "boolean" | "enum" | "object";
26
+ enumValues?: string[];
27
+ required?: boolean;
28
+ appliesToVerbs?: string[];
29
+ planned?: boolean;
30
+ }
31
+ export interface RetentionPolicy {
32
+ category: string;
33
+ keep?: number;
34
+ maxAgeDays?: number;
35
+ }
36
+ export interface SkillManifest {
37
+ skill: CanonicalGjcWorkflowSkill;
38
+ states: WorkflowState[];
39
+ initialState: string;
40
+ terminalStates: string[];
41
+ transitions: WorkflowTransition[];
42
+ verbs: WorkflowVerb[];
43
+ typedArgs: TypedArgSpec[];
44
+ retention: RetentionPolicy[];
45
+ hudFields: string[];
46
+ graphLabel: string;
47
+ }
48
+ export declare const WORKFLOW_MANIFEST: Record<CanonicalGjcWorkflowSkill, SkillManifest>;
49
+ export declare function getSkillManifest(skill: CanonicalGjcWorkflowSkill): SkillManifest;
50
+ export declare function isKnownWorkflowState(skill: CanonicalGjcWorkflowSkill, state: string): boolean;
51
+ export declare function isValidTransition(skill: CanonicalGjcWorkflowSkill, from: string, to: string): boolean;
52
+ export declare function listVerbs(skill: CanonicalGjcWorkflowSkill): string[];
53
+ export declare function typedArgsFor(skill: CanonicalGjcWorkflowSkill, verb: string): TypedArgSpec[];
54
+ export declare function serializeManifestProjection(): string;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Deterministic recovery classifier (pure).
3
+ *
4
+ * Maps a bounded {@link Observation} + remaining retry budget to exactly one
5
+ * {@link RecoveryDecision}. Encodes the plan's hard data-loss invariants:
6
+ * - dirty deltas are NEVER `restart-clean`; they map to `restart-preserve-delta`.
7
+ * - unknown deltas are NEVER destructive; they map to `human-check`.
8
+ * - a deleted/mismatched worktree maps to `human-check` (never recreate over unknown data).
9
+ * `send-enter` is intentionally never emitted: it is unsupported for the gajae-code
10
+ * RPC adapter in v1 (no blind key injection).
11
+ */
12
+ import type { ClassifyInput, RecoveryDecision } from "./types";
13
+ export declare function classifyRecovery(input: ClassifyInput): RecoveryDecision;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Per-session control endpoint — a Unix domain socket served by the RuntimeOwner so
3
+ * stateless `gjc harness` CLI calls can route owner-routed primitives (submit, observe,
4
+ * recover, retire) to the live owner. One JSON request line in, one JSON response line out.
5
+ *
6
+ * The owner is the only listener; clients connect per call. When no socket is reachable
7
+ * the caller falls back to the no-owner behavior (read-only observe, owner-not-live submit).
8
+ *
9
+ * FIFO fallback (for platforms/paths where AF_UNIX is unavailable or path-length limited)
10
+ * is a documented seam tracked as an ADR follow-up.
11
+ */
12
+ export interface EndpointRequest {
13
+ verb: string;
14
+ input: Record<string, unknown>;
15
+ }
16
+ export type EndpointHandler = (req: EndpointRequest) => Promise<unknown>;
17
+ export declare class ControlServer {
18
+ #private;
19
+ readonly socketPath: string;
20
+ private readonly handler;
21
+ constructor(socketPath: string, handler: EndpointHandler);
22
+ listen(): Promise<void>;
23
+ close(): Promise<void>;
24
+ }
25
+ export declare class EndpointUnreachableError extends Error {
26
+ readonly socketPath: string;
27
+ constructor(socketPath: string);
28
+ }
29
+ /** Call the owner's control endpoint. Rejects with {@link EndpointUnreachableError} when no owner listens. */
30
+ export declare function callEndpoint(socketPath: string, req: EndpointRequest, timeoutMs?: number): Promise<unknown>;
@@ -0,0 +1,47 @@
1
+ export interface ValidationCommandSpec {
2
+ name: string;
3
+ command: string;
4
+ }
5
+ export interface ValidationRun {
6
+ exactCommand: string;
7
+ cwd: string;
8
+ exitStatus: number;
9
+ pass: boolean;
10
+ }
11
+ export interface FinalizeChecks {
12
+ runValidation(spec: ValidationCommandSpec): Promise<ValidationRun>;
13
+ resolveCommit(): Promise<string | null>;
14
+ commitOnBranch(commit: string, branch: string): Promise<boolean>;
15
+ prOrIssue(): Promise<{
16
+ prUrl: string | null;
17
+ issueArtifact: string | null;
18
+ }>;
19
+ }
20
+ export interface FinalizeOptions {
21
+ root: string;
22
+ sessionId: string;
23
+ workspace: string;
24
+ branch: string;
25
+ requireTests?: boolean;
26
+ requireCommit?: boolean;
27
+ requirePr?: boolean;
28
+ validationCommands?: ValidationCommandSpec[];
29
+ checks: FinalizeChecks;
30
+ clock?: () => number;
31
+ }
32
+ export interface FinalizeResult {
33
+ completed: boolean;
34
+ receiptPath: string | null;
35
+ validation: {
36
+ name: string;
37
+ valid: boolean;
38
+ exitStatus: number;
39
+ }[];
40
+ commitHash: string | null;
41
+ prUrl: string | null;
42
+ issueArtifact: string | null;
43
+ blockers: string[];
44
+ }
45
+ export declare function runFinalize(opts: FinalizeOptions): Promise<FinalizeResult>;
46
+ /** Real checks: git for commit/branch, gh for PR, Bun.spawn for validation commands. */
47
+ export declare function defaultFinalizeChecks(workspace: string): FinalizeChecks;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Pure mapping from `gjc --mode rpc` event frames (docs/rpc.md) to bounded owner event kinds
3
+ * and {@link ObservedSignal}s. The owner feeds raw frames through this mapper and emits the
4
+ * result via its single-writer #emit — the mapper itself performs NO IO and NO appends.
5
+ *
6
+ * Hard rule: evidence is BOUNDED — only ids, names, categories, statuses, cursors, timestamps,
7
+ * and short codes/messages. Never assistant text, message deltas, command output, or raw args.
8
+ */
9
+ import type { ObservedSignal } from "./types";
10
+ export interface MappedFrame {
11
+ /** Owner event kind (rpc_*). */
12
+ kind: string;
13
+ /** Bounded observed signal, or null when the frame carries no user-facing signal. */
14
+ signal: ObservedSignal | null;
15
+ /** Bounded evidence — ids/names/statuses/cursors/timestamps/short codes only. */
16
+ evidence: Record<string, unknown>;
17
+ /** Severity for the emitted event. */
18
+ severity: "info" | "warn" | "critical";
19
+ /** Never-drop frames (must be enqueued in order, never coalesced away). */
20
+ semantic: boolean;
21
+ /** Coalescing key for high-frequency non-semantic frames (message id / tool id); null otherwise. */
22
+ coalesceKey: string | null;
23
+ }
24
+ export declare function isTestRunnerTool(toolName?: unknown, command?: unknown): boolean;
25
+ /**
26
+ * Map a single RPC frame. Returns null for frames that carry no observability value
27
+ * (or that the adapter handles itself: `ready`, `response`).
28
+ */
29
+ export declare function mapRpcFrame(frame: Record<string, unknown>): MappedFrame | null;
@@ -0,0 +1,35 @@
1
+ import { type FinalizeChecks, type FinalizeResult, type ValidationCommandSpec } from "./finalize";
2
+ import { type PreserveResult } from "./preserve";
3
+ import { type HarnessRpc } from "./rpc-adapter";
4
+ import { type HarnessLifecycle, type Observation, type RecoveryClassification, type RetryBudget, type Severity } from "./types";
5
+ export interface OperateOptions {
6
+ root: string;
7
+ sessionId: string;
8
+ workspace: string;
9
+ branch: string;
10
+ rpc: HarnessRpc;
11
+ /** Factory used to (re)create the RPC subprocess on restart recovery. Defaults to reusing `rpc`. */
12
+ rpcFactory?: () => HarnessRpc;
13
+ /** Bounded observation provider (scripted in tests; real = git + rpc state). */
14
+ observe: () => Promise<Observation>;
15
+ /** Real dirty-worktree preservation; injectable for tests. Defaults to git stash/diff capture. */
16
+ preserve?: (workspace: string) => PreserveResult;
17
+ finalizeChecks: FinalizeChecks;
18
+ validationCommands?: ValidationCommandSpec[];
19
+ retryBudget?: Partial<RetryBudget>;
20
+ acceptanceTimeoutMs?: number;
21
+ maxIterations?: number;
22
+ /** Injected event emitter. Production owner calls must pass the lease-guarded single-writer #emit. */
23
+ emit: (severity: Severity, kind: string, evidence: Record<string, unknown>) => Promise<void>;
24
+ clock?: () => number;
25
+ }
26
+ export interface OperateResult {
27
+ completed: boolean;
28
+ lifecycle: HarnessLifecycle;
29
+ iterations: number;
30
+ classifications: RecoveryClassification[];
31
+ vanishReceiptIds: string[];
32
+ finalize?: FinalizeResult;
33
+ blockers: string[];
34
+ }
35
+ export declare function operate(goal: string, opts: OperateOptions): Promise<OperateResult>;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * RuntimeOwner — the detached per-session process that makes live control honest.
3
+ *
4
+ * Responsibilities:
5
+ * - hold the {@link SessionLease} (single writer),
6
+ * - own the {@link HarnessRpc} subprocess (injected; real `GajaeCodeRpc` in prod, fake in tests),
7
+ * - serve owner-routed primitives over the {@link ControlServer} endpoint,
8
+ * - be the SOLE writer of the severity event stream,
9
+ * - heartbeat the lease.
10
+ *
11
+ * Stateless `gjc harness` CLI calls reach the owner via {@link resolveOwner} + the endpoint.
12
+ */
13
+ import { type FinalizeChecks, type ValidationCommandSpec } from "./finalize";
14
+ import type { HarnessRpc } from "./rpc-adapter";
15
+ import { type SessionLease } from "./session-lease";
16
+ export interface OwnerOptions {
17
+ root: string;
18
+ sessionId: string;
19
+ rpc: HarnessRpc;
20
+ ownerId?: string;
21
+ ttlMs?: number;
22
+ heartbeatMs?: number;
23
+ acceptanceTimeoutMs?: number;
24
+ clock?: () => number;
25
+ finalizeChecks?: FinalizeChecks;
26
+ validationCommands?: ValidationCommandSpec[];
27
+ }
28
+ export interface OwnerStartInfo {
29
+ ownerId: string;
30
+ socketPath: string;
31
+ leaseEpoch: number;
32
+ }
33
+ export declare class RuntimeOwner {
34
+ #private;
35
+ readonly ownerId: string;
36
+ constructor(opts: OwnerOptions);
37
+ start(): Promise<OwnerStartInfo>;
38
+ stop(): Promise<void>;
39
+ }
40
+ export interface ResolvedOwner {
41
+ live: boolean;
42
+ socketPath: string | null;
43
+ lease: SessionLease | null;
44
+ }
45
+ /** Determine whether a live owner currently holds the session (for CLI routing). */
46
+ export declare function resolveOwner(root: string, sessionId: string): Promise<ResolvedOwner>;
@@ -0,0 +1,19 @@
1
+ import type { GitDelta } from "./types";
2
+ export interface UntrackedEntry {
3
+ path: string;
4
+ size: number;
5
+ sha256: string;
6
+ }
7
+ export interface PreserveResult {
8
+ gitDelta: GitDelta;
9
+ trackedDiff: string;
10
+ trackedDiffSha256: string;
11
+ untrackedManifest: UntrackedEntry[];
12
+ stashRef: string | null;
13
+ snapshotComplete: boolean;
14
+ }
15
+ /**
16
+ * Capture + snapshot a (possibly dirty) worktree without mutating it. Safe to call on a clean
17
+ * tree (returns empty evidence). Never deletes, resets, or cleans.
18
+ */
19
+ export declare function preserveDirtyWorktree(workspace: string): PreserveResult;
@@ -0,0 +1,88 @@
1
+ import type { GitDelta, ReceiptFamily, RecoveryClassification } from "./types";
2
+ export interface ReceiptSubject {
3
+ workspace: string;
4
+ branch: string | null;
5
+ head: string | null;
6
+ commit: string | null;
7
+ }
8
+ export interface ReceiptEnvelope<E = Record<string, unknown>> {
9
+ receiptId: string;
10
+ schemaVersion: number;
11
+ sessionId: string;
12
+ family: ReceiptFamily;
13
+ valid: boolean;
14
+ createdAt: string;
15
+ source: string;
16
+ subject: ReceiptSubject;
17
+ evidence: E;
18
+ /** Hashes of out-of-line artifacts (diff patches, validation logs) folded into the receipt hash. */
19
+ artifactHashes: Record<string, string>;
20
+ sha256: string;
21
+ }
22
+ export declare const RECEIPT_SCHEMA_VERSION: 1;
23
+ export declare function sha256Hex(input: string): string;
24
+ export interface BuildReceiptInput<E> {
25
+ receiptId: string;
26
+ sessionId: string;
27
+ family: ReceiptFamily;
28
+ source: string;
29
+ subject: ReceiptSubject;
30
+ evidence: E;
31
+ artifactHashes?: Record<string, string>;
32
+ createdAt?: string;
33
+ valid?: boolean;
34
+ }
35
+ export declare function buildReceipt<E>(input: BuildReceiptInput<E>): ReceiptEnvelope<E>;
36
+ export interface ValidationOutcome {
37
+ valid: boolean;
38
+ reasons: string[];
39
+ }
40
+ /** Recompute the hash and run structural family checks. Fail-closed. */
41
+ export declare function validateReceipt(receipt: ReceiptEnvelope<unknown>): ValidationOutcome;
42
+ export interface VanishEvidence {
43
+ classification: RecoveryClassification;
44
+ gitDelta: GitDelta;
45
+ gitStatusPorcelain: string;
46
+ untrackedManifest: {
47
+ path: string;
48
+ size: number;
49
+ sha256: string;
50
+ }[];
51
+ preservation: "snapshot" | "stash" | "block";
52
+ stashRef: string | null;
53
+ snapshotComplete: boolean;
54
+ forbiddenActions: string[];
55
+ }
56
+ export interface PromptAcceptanceEvidence {
57
+ promptSha256: string;
58
+ rpcCommandId: string;
59
+ preSubmitState: {
60
+ isStreaming: boolean;
61
+ steeringQueueDepth: number;
62
+ followupQueueDepth: number;
63
+ };
64
+ preSubmitCursor: number;
65
+ agentStartCursor: number;
66
+ acceptedAt: string;
67
+ singleFlight: true;
68
+ }
69
+ export interface ValidationEvidence {
70
+ command: string;
71
+ exactCommand: string;
72
+ cwd: string;
73
+ exitStatus: number;
74
+ pass: boolean;
75
+ commitUnderTest: string | null;
76
+ }
77
+ export interface CompletionEvidence {
78
+ finalCommit: string;
79
+ branch: string;
80
+ prUrl: string | null;
81
+ issueArtifact: string | null;
82
+ requiredValidationReceiptIds: string[];
83
+ finalLifecycle: string;
84
+ finalizedAt: string;
85
+ blockers: string[];
86
+ }
87
+ /** Classifications that MUST have a valid `vanish` receipt before the action proceeds. */
88
+ export declare function requiresVanishBeforeAction(classification: RecoveryClassification): boolean;
@@ -0,0 +1,66 @@
1
+ export interface RpcStateSnapshot {
2
+ isStreaming: boolean;
3
+ steeringQueueDepth: number;
4
+ followupQueueDepth: number;
5
+ }
6
+ /** Abstract handle to a live gajae-code RPC session. */
7
+ export interface HarnessRpc {
8
+ getState(): Promise<RpcStateSnapshot>;
9
+ /** Send a prompt; resolves with the RPC command id and whether it was acked. Does NOT await agent_start. */
10
+ sendPrompt(prompt: string): Promise<{
11
+ commandId: string;
12
+ ack: boolean;
13
+ }>;
14
+ /** Monotonic count of events observed so far (the acceptance cursor). */
15
+ eventCursor(): number;
16
+ /** Resolve when an `agent_start` event arrives strictly after `afterCursor`, else null on timeout. */
17
+ waitForAgentStart(afterCursor: number, timeoutMs: number): Promise<{
18
+ cursor: number;
19
+ } | null>;
20
+ close(): Promise<void>;
21
+ /** Subscribe to parsed event frames (non-ready, non-response), fired AFTER the cursor advances. Returns unsubscribe. */
22
+ onEventFrame?(listener: (frame: Record<string, unknown>) => void): () => void;
23
+ /** Whether the underlying RPC subprocess is still alive. */
24
+ isLive?(): boolean;
25
+ /** ISO timestamp of the last observed event frame, or null. */
26
+ lastFrameAt?(): string | null;
27
+ }
28
+ export interface AcceptanceResult {
29
+ accepted: boolean;
30
+ reason: string;
31
+ commandId: string | null;
32
+ preSubmitCursor: number;
33
+ agentStartCursor: number | null;
34
+ preSubmitState: RpcStateSnapshot;
35
+ }
36
+ /**
37
+ * Single-flight acceptance: idle + empty-queue pre-state, ack, then the NEXT
38
+ * `agent_start` after the pre-submit cursor within `timeoutMs`.
39
+ */
40
+ export declare function singleFlightAccept(rpc: HarnessRpc, prompt: string, timeoutMs: number): Promise<AcceptanceResult>;
41
+ /**
42
+ * Real adapter: spawns `gjc --mode rpc --session-dir <dir>` and speaks the JSONL
43
+ * protocol from docs/rpc.md. Verified end-to-end in the M10 suite.
44
+ */
45
+ export declare class GajaeCodeRpc implements HarnessRpc {
46
+ #private;
47
+ constructor(opts: {
48
+ sessionDir: string;
49
+ command?: string[];
50
+ cwd?: string;
51
+ env?: NodeJS.ProcessEnv;
52
+ });
53
+ onEventFrame(listener: (frame: Record<string, unknown>) => void): () => void;
54
+ isLive(): boolean;
55
+ lastFrameAt(): string | null;
56
+ getState(): Promise<RpcStateSnapshot>;
57
+ sendPrompt(prompt: string): Promise<{
58
+ commandId: string;
59
+ ack: boolean;
60
+ }>;
61
+ eventCursor(): number;
62
+ waitForAgentStart(afterCursor: number, timeoutMs: number): Promise<{
63
+ cursor: number;
64
+ } | null>;
65
+ close(): Promise<void>;
66
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * v1 seams (M11). The control plane is harness-agnostic by design, but v1 ships ONLY the
3
+ * gajae-code adapter. Other harnesses and transports are explicit, designed-not-built seams
4
+ * that fail closed with a clear `seam_unsupported_in_v1` signal rather than silently degrading.
5
+ */
6
+ import type { Harness } from "./types";
7
+ export declare const SUPPORTED_HARNESSES: readonly Harness[];
8
+ export declare const DEFERRED_SEAMS: readonly ["codex-adapter", "omx-adapter", "remote-transport", "global-daemon", "capability-token-auth", "web-viewer", "fleet-control-plane", "rich-tui-coview"];
9
+ export type DeferredSeam = (typeof DEFERRED_SEAMS)[number];
10
+ export declare function isHarnessSupported(harness: string): harness is Harness;
11
+ export interface UnsupportedSeamResult {
12
+ ok: false;
13
+ error: string;
14
+ evidence: {
15
+ seam: true;
16
+ name: string;
17
+ supported: readonly Harness[];
18
+ deferred: readonly string[];
19
+ };
20
+ }
21
+ export declare function unsupportedSeam(name: string): UnsupportedSeamResult;