@gajae-code/coding-agent 0.2.5 → 0.3.1

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 (234) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/types/async/job-manager.d.ts +91 -2
  3. package/dist/types/cli/args.d.ts +1 -1
  4. package/dist/types/commands/deep-interview.d.ts +3 -0
  5. package/dist/types/commands/harness.d.ts +37 -0
  6. package/dist/types/config/keybindings.d.ts +5 -0
  7. package/dist/types/config/settings-schema.d.ts +10 -4
  8. package/dist/types/config/settings.d.ts +2 -0
  9. package/dist/types/debug/crash-diagnostics.d.ts +45 -0
  10. package/dist/types/debug/runtime-gauges.d.ts +6 -0
  11. package/dist/types/deep-interview/render-middleware.d.ts +6 -0
  12. package/dist/types/eval/py/executor.d.ts +2 -0
  13. package/dist/types/eval/py/kernel.d.ts +2 -0
  14. package/dist/types/exec/bash-executor.d.ts +10 -0
  15. package/dist/types/extensibility/custom-tools/types.d.ts +1 -0
  16. package/dist/types/extensibility/extensions/types.d.ts +6 -0
  17. package/dist/types/extensibility/shared-events.d.ts +1 -0
  18. package/dist/types/gjc-runtime/cli-write-receipt.d.ts +24 -0
  19. package/dist/types/gjc-runtime/deep-interview-runtime.d.ts +1 -0
  20. package/dist/types/gjc-runtime/state-graph.d.ts +4 -0
  21. package/dist/types/gjc-runtime/state-migrations.d.ts +33 -0
  22. package/dist/types/gjc-runtime/state-renderer.d.ts +65 -0
  23. package/dist/types/gjc-runtime/state-runtime.d.ts +2 -0
  24. package/dist/types/gjc-runtime/state-schema.d.ts +317 -0
  25. package/dist/types/gjc-runtime/state-validation.d.ts +6 -0
  26. package/dist/types/gjc-runtime/state-writer.d.ts +147 -0
  27. package/dist/types/gjc-runtime/team-runtime.d.ts +81 -7
  28. package/dist/types/gjc-runtime/workflow-command-ref.d.ts +43 -0
  29. package/dist/types/gjc-runtime/workflow-manifest.d.ts +54 -0
  30. package/dist/types/harness-control-plane/classifier.d.ts +13 -0
  31. package/dist/types/harness-control-plane/control-endpoint.d.ts +31 -0
  32. package/dist/types/harness-control-plane/finalize.d.ts +47 -0
  33. package/dist/types/harness-control-plane/frame-mapper.d.ts +29 -0
  34. package/dist/types/harness-control-plane/operate.d.ts +35 -0
  35. package/dist/types/harness-control-plane/owner.d.ts +46 -0
  36. package/dist/types/harness-control-plane/preserve.d.ts +19 -0
  37. package/dist/types/harness-control-plane/receipts.d.ts +88 -0
  38. package/dist/types/harness-control-plane/rpc-adapter.d.ts +66 -0
  39. package/dist/types/harness-control-plane/seams.d.ts +21 -0
  40. package/dist/types/harness-control-plane/session-lease.d.ts +65 -0
  41. package/dist/types/harness-control-plane/state-machine.d.ts +19 -0
  42. package/dist/types/harness-control-plane/storage.d.ts +53 -0
  43. package/dist/types/harness-control-plane/types.d.ts +162 -0
  44. package/dist/types/hooks/skill-keywords.d.ts +2 -1
  45. package/dist/types/hooks/skill-state.d.ts +23 -29
  46. package/dist/types/internal-urls/agent-protocol.d.ts +2 -2
  47. package/dist/types/internal-urls/artifact-protocol.d.ts +2 -2
  48. package/dist/types/internal-urls/registry-helpers.d.ts +8 -7
  49. package/dist/types/internal-urls/types.d.ts +4 -0
  50. package/dist/types/lsp/index.d.ts +10 -10
  51. package/dist/types/modes/bridge/auth.d.ts +12 -0
  52. package/dist/types/modes/bridge/bridge-client-bridge.d.ts +9 -0
  53. package/dist/types/modes/bridge/bridge-mode.d.ts +44 -0
  54. package/dist/types/modes/bridge/bridge-ui-context.d.ts +88 -0
  55. package/dist/types/modes/bridge/event-stream.d.ts +8 -0
  56. package/dist/types/modes/components/custom-editor.d.ts +6 -0
  57. package/dist/types/modes/components/hook-selector.d.ts +1 -0
  58. package/dist/types/modes/components/jobs-overlay-model.d.ts +31 -0
  59. package/dist/types/modes/components/jobs-overlay.d.ts +30 -0
  60. package/dist/types/modes/components/status-line/types.d.ts +2 -0
  61. package/dist/types/modes/components/status-line.d.ts +2 -0
  62. package/dist/types/modes/controllers/input-controller.d.ts +1 -0
  63. package/dist/types/modes/controllers/selector-controller.d.ts +8 -0
  64. package/dist/types/modes/index.d.ts +1 -0
  65. package/dist/types/modes/interactive-mode.d.ts +2 -0
  66. package/dist/types/modes/jobs-observer.d.ts +57 -0
  67. package/dist/types/modes/rpc/host-tools.d.ts +1 -16
  68. package/dist/types/modes/rpc/host-uris.d.ts +1 -38
  69. package/dist/types/modes/shared/agent-wire/command-dispatch.d.ts +20 -0
  70. package/dist/types/modes/shared/agent-wire/command-validation.d.ts +2 -0
  71. package/dist/types/modes/shared/agent-wire/event-envelope.d.ts +24 -0
  72. package/dist/types/modes/shared/agent-wire/handshake.d.ts +46 -0
  73. package/dist/types/modes/shared/agent-wire/host-tool-bridge.d.ts +16 -0
  74. package/dist/types/modes/shared/agent-wire/host-uri-bridge.d.ts +17 -0
  75. package/dist/types/modes/shared/agent-wire/protocol.d.ts +44 -0
  76. package/dist/types/modes/shared/agent-wire/responses.d.ts +4 -0
  77. package/dist/types/modes/shared/agent-wire/scopes.d.ts +18 -0
  78. package/dist/types/modes/shared/agent-wire/ui-request-broker.d.ts +42 -0
  79. package/dist/types/modes/shared/agent-wire/ui-result.d.ts +27 -0
  80. package/dist/types/modes/types.d.ts +2 -0
  81. package/dist/types/sdk.d.ts +4 -0
  82. package/dist/types/session/agent-session.d.ts +19 -1
  83. package/dist/types/skill-state/active-state.d.ts +2 -0
  84. package/dist/types/skill-state/deep-interview-mutation-guard.d.ts +1 -1
  85. package/dist/types/skill-state/workflow-state-contract.d.ts +25 -2
  86. package/dist/types/skill-state/workflow-state-version.d.ts +3 -0
  87. package/dist/types/task/executor.d.ts +3 -0
  88. package/dist/types/task/id.d.ts +7 -0
  89. package/dist/types/task/index.d.ts +5 -0
  90. package/dist/types/task/receipt.d.ts +85 -0
  91. package/dist/types/task/spawn-gate.d.ts +38 -0
  92. package/dist/types/task/types.d.ts +198 -14
  93. package/dist/types/tools/cron.d.ts +6 -0
  94. package/dist/types/tools/index.d.ts +2 -0
  95. package/dist/types/tools/path-utils.d.ts +1 -0
  96. package/dist/types/tools/subagent.d.ts +26 -1
  97. package/package.json +7 -7
  98. package/scripts/build-binary.ts +7 -0
  99. package/src/async/job-manager.ts +334 -6
  100. package/src/cli/args.ts +9 -2
  101. package/src/cli/auth-broker-cli.ts +1 -0
  102. package/src/cli/config-cli.ts +10 -2
  103. package/src/cli.ts +2 -0
  104. package/src/commands/deep-interview.ts +1 -0
  105. package/src/commands/harness.ts +862 -0
  106. package/src/commands/launch.ts +2 -2
  107. package/src/commands/state.ts +2 -1
  108. package/src/commands/team.ts +54 -39
  109. package/src/config/keybindings.ts +6 -0
  110. package/src/config/settings-schema.ts +13 -3
  111. package/src/config/settings.ts +5 -0
  112. package/src/dap/client.ts +17 -3
  113. package/src/debug/crash-diagnostics.ts +223 -0
  114. package/src/debug/runtime-gauges.ts +20 -0
  115. package/src/deep-interview/render-middleware.ts +372 -0
  116. package/src/defaults/gjc/skills/deep-interview/SKILL.md +1 -1
  117. package/src/defaults/gjc/skills/ralplan/SKILL.md +31 -2
  118. package/src/defaults/gjc/skills/team/SKILL.md +47 -21
  119. package/src/defaults/gjc/skills/ultragoal/SKILL.md +106 -13
  120. package/src/eval/py/executor.ts +21 -1
  121. package/src/eval/py/kernel.ts +15 -0
  122. package/src/exec/bash-executor.ts +41 -0
  123. package/src/extensibility/custom-tools/types.ts +1 -0
  124. package/src/extensibility/extensions/types.ts +6 -0
  125. package/src/extensibility/shared-events.ts +1 -0
  126. package/src/gjc-runtime/cli-write-receipt.ts +31 -0
  127. package/src/gjc-runtime/deep-interview-runtime.ts +98 -42
  128. package/src/gjc-runtime/goal-mode-request.ts +11 -3
  129. package/src/gjc-runtime/ralplan-runtime.ts +235 -43
  130. package/src/gjc-runtime/state-graph.ts +86 -0
  131. package/src/gjc-runtime/state-migrations.ts +179 -0
  132. package/src/gjc-runtime/state-renderer.ts +345 -0
  133. package/src/gjc-runtime/state-runtime.ts +1155 -46
  134. package/src/gjc-runtime/state-schema.ts +192 -0
  135. package/src/gjc-runtime/state-validation.ts +49 -0
  136. package/src/gjc-runtime/state-writer.ts +749 -0
  137. package/src/gjc-runtime/team-runtime.ts +1255 -189
  138. package/src/gjc-runtime/ultragoal-runtime.ts +460 -43
  139. package/src/gjc-runtime/workflow-command-ref.ts +239 -0
  140. package/src/gjc-runtime/workflow-manifest.generated.json +1601 -0
  141. package/src/gjc-runtime/workflow-manifest.ts +427 -0
  142. package/src/harness-control-plane/classifier.ts +128 -0
  143. package/src/harness-control-plane/control-endpoint.ts +148 -0
  144. package/src/harness-control-plane/finalize.ts +222 -0
  145. package/src/harness-control-plane/frame-mapper.ts +286 -0
  146. package/src/harness-control-plane/operate.ts +225 -0
  147. package/src/harness-control-plane/owner.ts +600 -0
  148. package/src/harness-control-plane/preserve.ts +102 -0
  149. package/src/harness-control-plane/receipts.ts +216 -0
  150. package/src/harness-control-plane/rpc-adapter.ts +276 -0
  151. package/src/harness-control-plane/seams.ts +39 -0
  152. package/src/harness-control-plane/session-lease.ts +388 -0
  153. package/src/harness-control-plane/state-machine.ts +98 -0
  154. package/src/harness-control-plane/storage.ts +257 -0
  155. package/src/harness-control-plane/types.ts +214 -0
  156. package/src/hooks/skill-keywords.ts +4 -2
  157. package/src/hooks/skill-state.ts +197 -64
  158. package/src/internal-urls/agent-protocol.ts +68 -21
  159. package/src/internal-urls/artifact-protocol.ts +12 -17
  160. package/src/internal-urls/docs-index.generated.ts +3 -2
  161. package/src/internal-urls/registry-helpers.ts +19 -16
  162. package/src/internal-urls/types.ts +4 -0
  163. package/src/lsp/client.ts +18 -2
  164. package/src/main.ts +21 -5
  165. package/src/modes/bridge/auth.ts +41 -0
  166. package/src/modes/bridge/bridge-client-bridge.ts +47 -0
  167. package/src/modes/bridge/bridge-mode.ts +520 -0
  168. package/src/modes/bridge/bridge-ui-context.ts +200 -0
  169. package/src/modes/bridge/event-stream.ts +70 -0
  170. package/src/modes/components/assistant-message.ts +5 -1
  171. package/src/modes/components/custom-editor.ts +101 -0
  172. package/src/modes/components/hook-selector.ts +133 -20
  173. package/src/modes/components/jobs-overlay-model.ts +109 -0
  174. package/src/modes/components/jobs-overlay.ts +172 -0
  175. package/src/modes/components/status-line/presets.ts +7 -5
  176. package/src/modes/components/status-line/segments.ts +25 -0
  177. package/src/modes/components/status-line/types.ts +2 -0
  178. package/src/modes/components/status-line.ts +9 -1
  179. package/src/modes/controllers/event-controller.ts +71 -6
  180. package/src/modes/controllers/extension-ui-controller.ts +43 -1
  181. package/src/modes/controllers/input-controller.ts +105 -9
  182. package/src/modes/controllers/selector-controller.ts +31 -1
  183. package/src/modes/index.ts +1 -0
  184. package/src/modes/interactive-mode.ts +28 -0
  185. package/src/modes/jobs-observer.ts +204 -0
  186. package/src/modes/rpc/host-tools.ts +1 -186
  187. package/src/modes/rpc/host-uris.ts +1 -235
  188. package/src/modes/rpc/rpc-client.ts +25 -10
  189. package/src/modes/rpc/rpc-mode.ts +12 -381
  190. package/src/modes/shared/agent-wire/command-dispatch.ts +341 -0
  191. package/src/modes/shared/agent-wire/command-validation.ts +131 -0
  192. package/src/modes/shared/agent-wire/event-envelope.ts +108 -0
  193. package/src/modes/shared/agent-wire/handshake.ts +117 -0
  194. package/src/modes/shared/agent-wire/host-tool-bridge.ts +194 -0
  195. package/src/modes/shared/agent-wire/host-uri-bridge.ts +236 -0
  196. package/src/modes/shared/agent-wire/protocol.ts +96 -0
  197. package/src/modes/shared/agent-wire/responses.ts +17 -0
  198. package/src/modes/shared/agent-wire/scopes.ts +89 -0
  199. package/src/modes/shared/agent-wire/ui-request-broker.ts +150 -0
  200. package/src/modes/shared/agent-wire/ui-result.ts +48 -0
  201. package/src/modes/types.ts +2 -0
  202. package/src/prompts/agents/executor.md +13 -0
  203. package/src/prompts/tools/subagent.md +39 -4
  204. package/src/prompts/tools/task-summary.md +3 -9
  205. package/src/prompts/tools/task.md +5 -1
  206. package/src/sdk.ts +8 -0
  207. package/src/session/agent-session.ts +445 -71
  208. package/src/session/session-manager.ts +13 -1
  209. package/src/skill-state/active-state.ts +58 -65
  210. package/src/skill-state/deep-interview-mutation-guard.ts +114 -17
  211. package/src/skill-state/initial-phase.ts +2 -0
  212. package/src/skill-state/workflow-state-contract.ts +33 -4
  213. package/src/skill-state/workflow-state-version.ts +3 -0
  214. package/src/slash-commands/builtin-registry.ts +8 -0
  215. package/src/task/executor.ts +79 -13
  216. package/src/task/id.ts +33 -0
  217. package/src/task/index.ts +376 -74
  218. package/src/task/output-manager.ts +5 -4
  219. package/src/task/receipt.ts +297 -0
  220. package/src/task/render.ts +54 -134
  221. package/src/task/spawn-gate.ts +132 -0
  222. package/src/task/types.ts +104 -10
  223. package/src/tools/ask.ts +88 -27
  224. package/src/tools/ast-edit.ts +1 -0
  225. package/src/tools/ast-grep.ts +1 -0
  226. package/src/tools/bash.ts +1 -1
  227. package/src/tools/cron.ts +48 -0
  228. package/src/tools/find.ts +4 -1
  229. package/src/tools/index.ts +2 -0
  230. package/src/tools/path-utils.ts +3 -2
  231. package/src/tools/read.ts +1 -0
  232. package/src/tools/search.ts +1 -0
  233. package/src/tools/skill.ts +6 -1
  234. package/src/tools/subagent.ts +423 -79
@@ -0,0 +1,85 @@
1
+ import type { SingleResult, TaskToolDetails } from "./types";
2
+ export interface TaskRoi {
3
+ tokens: number;
4
+ contextTokens?: number;
5
+ clonedTokens?: number;
6
+ costTotal?: number;
7
+ outputBytes?: number;
8
+ outputLines?: number;
9
+ producedChanges: boolean;
10
+ materialContribution: boolean;
11
+ lowRoi: boolean;
12
+ }
13
+ export interface TaskResultReceipt {
14
+ index: number;
15
+ id: string;
16
+ agent: string;
17
+ agentSource: SingleResult["agentSource"];
18
+ task: string;
19
+ assignment?: string;
20
+ description?: string;
21
+ status: "completed" | "failed" | "aborted" | "merge_failed" | "paused";
22
+ exitCode: number;
23
+ aborted?: boolean;
24
+ paused?: boolean;
25
+ truncated: boolean;
26
+ durationMs: number;
27
+ tokens: number;
28
+ contextTokens?: number;
29
+ contextWindow?: number;
30
+ modelOverride?: string | string[];
31
+ usage?: SingleResult["usage"];
32
+ cost?: number;
33
+ branchName?: string;
34
+ retryFailure?: {
35
+ attempt: number;
36
+ errorSummary: string;
37
+ };
38
+ errorSummary?: string;
39
+ abortSummary?: string;
40
+ preview: string;
41
+ previewTruncated: boolean;
42
+ outputRef?: {
43
+ uri: string;
44
+ sizeBytes: number;
45
+ lineCount: number;
46
+ sha256?: string;
47
+ };
48
+ outputUnavailable?: boolean;
49
+ review?: {
50
+ overallCorrectness?: string;
51
+ findingCount: number;
52
+ findings?: Array<{
53
+ severity?: string;
54
+ summary: string;
55
+ }>;
56
+ };
57
+ extractedToolCounts?: Record<string, number>;
58
+ forkContext?: SingleResult["forkContext"];
59
+ roi?: TaskRoi;
60
+ }
61
+ /**
62
+ * Heuristic task ROI signal built only from receipt-safe accounting fields.
63
+ * Advisory only: these flags never change task success/failure semantics.
64
+ */
65
+ export declare function buildTaskRoi(raw: SingleResult): TaskRoi;
66
+ export declare function buildTaskRoiSummary(receipts: readonly TaskResultReceipt[]): TaskToolDetails["roiSummary"];
67
+ export declare function buildTaskReceipt(raw: SingleResult): TaskResultReceipt;
68
+ /**
69
+ * Raw, pre-sanitization task details: the internal shape produced during task
70
+ * execution, where `results` are full `SingleResult` objects. The public
71
+ * `TaskToolDetails` exposes only receipts.
72
+ */
73
+ export interface RawTaskToolDetails {
74
+ projectAgentsDir: string | null;
75
+ results: SingleResult[];
76
+ totalDurationMs: number;
77
+ usage?: TaskToolDetails["usage"];
78
+ async?: TaskToolDetails["async"];
79
+ forkContextClonedTokens?: number;
80
+ roiSummary?: TaskToolDetails["roiSummary"];
81
+ }
82
+ /** Central converter from raw task details to receipt-only public details. */
83
+ export declare function sanitizeTaskToolDetails(raw: RawTaskToolDetails): TaskToolDetails;
84
+ export declare function findRawTaskLeakKeys(value: unknown): string[];
85
+ export declare function assertNoRawTaskFields(value: unknown, surface: string): void;
@@ -0,0 +1,38 @@
1
+ /** The hard, locked batch threshold enforced by the runtime gate. */
2
+ export declare const DEFAULT_SPAWN_THRESHOLD = 4;
3
+ /** The justification a large batch or reviewer-spawned explorer must supply to pass the hard gate. */
4
+ export interface SpawnPlanReceipt {
5
+ whyParallel: string;
6
+ whyNotLocal: string;
7
+ independence: string;
8
+ expectedReceiptShape: string;
9
+ maxInlineTokens: number;
10
+ }
11
+ export interface SpawnGateRequest {
12
+ /** Number of children the batch wants to spawn. */
13
+ childCount: number;
14
+ /** The spawn-plan receipt, when provided. */
15
+ plan?: SpawnPlanReceipt;
16
+ }
17
+ export interface ReviewerExploreGateRequest {
18
+ /** Agent type/name doing the spawning, when known. */
19
+ spawningAgentType?: string | null;
20
+ /** Target agent type/name requested by the task call. */
21
+ targetAgent: string;
22
+ /** The spawn-plan receipt, when provided. */
23
+ plan?: SpawnPlanReceipt;
24
+ }
25
+ export type SpawnGateOutcome = "allowed" | "rejected";
26
+ export interface SpawnGateDecision {
27
+ outcome: SpawnGateOutcome;
28
+ /** Human-readable reason, suitable for a blocked-result message. */
29
+ reason: string;
30
+ /** Whether a plan was required for this request. */
31
+ planRequired: boolean;
32
+ /** Missing plan field names when rejected for an incomplete plan. */
33
+ missingFields: readonly string[];
34
+ }
35
+ export declare function findMissingPlanFields(plan: SpawnPlanReceipt | undefined): string[];
36
+ export declare function decide(childCount: number, threshold: number, plan: SpawnPlanReceipt | undefined): SpawnGateDecision;
37
+ export declare function evaluateSpawnGate(request: SpawnGateRequest): SpawnGateDecision;
38
+ export declare function evaluateReviewerExploreGate(request: ReviewerExploreGateRequest): SpawnGateDecision;
@@ -1,11 +1,14 @@
1
1
  import type { ThinkingLevel } from "@gajae-code/agent-core";
2
2
  import type { Usage } from "@gajae-code/ai";
3
3
  import * as z from "zod/v4";
4
+ import type { TaskResultReceipt } from "./receipt";
4
5
  import { type TaskSimpleMode } from "./simple-mode";
6
+ import type { SpawnPlanReceipt } from "./spawn-gate";
5
7
  import type { NestedRepoPatch } from "./worktree";
6
8
  /** Source of an agent definition */
7
9
  export type AgentSource = "bundled" | "user" | "project";
8
10
  export type ForkContextPolicy = "forbidden" | "allowed";
11
+ export type ForkContextMode = "none" | "receipt" | "last-turn" | "bounded" | "full";
9
12
  /** Maximum output bytes per agent */
10
13
  export declare const MAX_OUTPUT_BYTES: number;
11
14
  /** Maximum output lines per agent */
@@ -32,7 +35,7 @@ export interface SubagentLifecyclePayload {
32
35
  agent: string;
33
36
  agentSource: AgentSource;
34
37
  description?: string;
35
- status: "started" | "completed" | "failed" | "aborted";
38
+ status: "started" | "completed" | "failed" | "aborted" | "paused";
36
39
  sessionFile?: string;
37
40
  index: number;
38
41
  }
@@ -41,7 +44,13 @@ export declare const taskItemSchema: z.ZodObject<{
41
44
  id: z.ZodString;
42
45
  description: z.ZodString;
43
46
  assignment: z.ZodString;
44
- inheritContext: z.ZodOptional<z.ZodBoolean>;
47
+ inheritContext: z.ZodOptional<z.ZodEnum<{
48
+ bounded: "bounded";
49
+ full: "full";
50
+ "last-turn": "last-turn";
51
+ none: "none";
52
+ receipt: "receipt";
53
+ }>>;
45
54
  }, z.core.$strip>;
46
55
  export type TaskItem = z.infer<typeof taskItemSchema>;
47
56
  export declare const taskSchema: z.ZodObject<{
@@ -50,7 +59,20 @@ export declare const taskSchema: z.ZodObject<{
50
59
  id: z.ZodString;
51
60
  description: z.ZodString;
52
61
  assignment: z.ZodString;
53
- inheritContext: z.ZodOptional<z.ZodBoolean>;
62
+ inheritContext: z.ZodOptional<z.ZodEnum<{
63
+ bounded: "bounded";
64
+ full: "full";
65
+ "last-turn": "last-turn";
66
+ none: "none";
67
+ receipt: "receipt";
68
+ }>>;
69
+ }, z.core.$strip>>;
70
+ spawnPlan: z.ZodOptional<z.ZodObject<{
71
+ whyParallel: z.ZodString;
72
+ whyNotLocal: z.ZodString;
73
+ independence: z.ZodString;
74
+ expectedReceiptShape: z.ZodString;
75
+ maxInlineTokens: z.ZodNumber;
54
76
  }, z.core.$strip>>;
55
77
  }, z.core.$strip>;
56
78
  export declare const taskSchemaNoIsolation: z.ZodObject<{
@@ -59,7 +81,20 @@ export declare const taskSchemaNoIsolation: z.ZodObject<{
59
81
  id: z.ZodString;
60
82
  description: z.ZodString;
61
83
  assignment: z.ZodString;
62
- inheritContext: z.ZodOptional<z.ZodBoolean>;
84
+ inheritContext: z.ZodOptional<z.ZodEnum<{
85
+ bounded: "bounded";
86
+ full: "full";
87
+ "last-turn": "last-turn";
88
+ none: "none";
89
+ receipt: "receipt";
90
+ }>>;
91
+ }, z.core.$strip>>;
92
+ spawnPlan: z.ZodOptional<z.ZodObject<{
93
+ whyParallel: z.ZodString;
94
+ whyNotLocal: z.ZodString;
95
+ independence: z.ZodString;
96
+ expectedReceiptShape: z.ZodString;
97
+ maxInlineTokens: z.ZodNumber;
63
98
  }, z.core.$strip>>;
64
99
  }, z.core.$strip>;
65
100
  declare const ALL_TASK_SCHEMAS: readonly [z.ZodObject<{
@@ -68,7 +103,20 @@ declare const ALL_TASK_SCHEMAS: readonly [z.ZodObject<{
68
103
  id: z.ZodString;
69
104
  description: z.ZodString;
70
105
  assignment: z.ZodString;
71
- inheritContext: z.ZodOptional<z.ZodBoolean>;
106
+ inheritContext: z.ZodOptional<z.ZodEnum<{
107
+ bounded: "bounded";
108
+ full: "full";
109
+ "last-turn": "last-turn";
110
+ none: "none";
111
+ receipt: "receipt";
112
+ }>>;
113
+ }, z.core.$strip>>;
114
+ spawnPlan: z.ZodOptional<z.ZodObject<{
115
+ whyParallel: z.ZodString;
116
+ whyNotLocal: z.ZodString;
117
+ independence: z.ZodString;
118
+ expectedReceiptShape: z.ZodString;
119
+ maxInlineTokens: z.ZodNumber;
72
120
  }, z.core.$strip>>;
73
121
  }, z.core.$strip>, z.ZodObject<{
74
122
  agent: z.ZodString;
@@ -76,7 +124,20 @@ declare const ALL_TASK_SCHEMAS: readonly [z.ZodObject<{
76
124
  id: z.ZodString;
77
125
  description: z.ZodString;
78
126
  assignment: z.ZodString;
79
- inheritContext: z.ZodOptional<z.ZodBoolean>;
127
+ inheritContext: z.ZodOptional<z.ZodEnum<{
128
+ bounded: "bounded";
129
+ full: "full";
130
+ "last-turn": "last-turn";
131
+ none: "none";
132
+ receipt: "receipt";
133
+ }>>;
134
+ }, z.core.$strip>>;
135
+ spawnPlan: z.ZodOptional<z.ZodObject<{
136
+ whyParallel: z.ZodString;
137
+ whyNotLocal: z.ZodString;
138
+ independence: z.ZodString;
139
+ expectedReceiptShape: z.ZodString;
140
+ maxInlineTokens: z.ZodNumber;
80
141
  }, z.core.$strip>>;
81
142
  }, z.core.$strip>, z.ZodObject<{
82
143
  agent: z.ZodString;
@@ -84,7 +145,20 @@ declare const ALL_TASK_SCHEMAS: readonly [z.ZodObject<{
84
145
  id: z.ZodString;
85
146
  description: z.ZodString;
86
147
  assignment: z.ZodString;
87
- inheritContext: z.ZodOptional<z.ZodBoolean>;
148
+ inheritContext: z.ZodOptional<z.ZodEnum<{
149
+ bounded: "bounded";
150
+ full: "full";
151
+ "last-turn": "last-turn";
152
+ none: "none";
153
+ receipt: "receipt";
154
+ }>>;
155
+ }, z.core.$strip>>;
156
+ spawnPlan: z.ZodOptional<z.ZodObject<{
157
+ whyParallel: z.ZodString;
158
+ whyNotLocal: z.ZodString;
159
+ independence: z.ZodString;
160
+ expectedReceiptShape: z.ZodString;
161
+ maxInlineTokens: z.ZodNumber;
88
162
  }, z.core.$strip>>;
89
163
  }, z.core.$strip>, z.ZodObject<{
90
164
  agent: z.ZodString;
@@ -92,7 +166,20 @@ declare const ALL_TASK_SCHEMAS: readonly [z.ZodObject<{
92
166
  id: z.ZodString;
93
167
  description: z.ZodString;
94
168
  assignment: z.ZodString;
95
- inheritContext: z.ZodOptional<z.ZodBoolean>;
169
+ inheritContext: z.ZodOptional<z.ZodEnum<{
170
+ bounded: "bounded";
171
+ full: "full";
172
+ "last-turn": "last-turn";
173
+ none: "none";
174
+ receipt: "receipt";
175
+ }>>;
176
+ }, z.core.$strip>>;
177
+ spawnPlan: z.ZodOptional<z.ZodObject<{
178
+ whyParallel: z.ZodString;
179
+ whyNotLocal: z.ZodString;
180
+ independence: z.ZodString;
181
+ expectedReceiptShape: z.ZodString;
182
+ maxInlineTokens: z.ZodNumber;
96
183
  }, z.core.$strip>>;
97
184
  }, z.core.$strip>, z.ZodObject<{
98
185
  agent: z.ZodString;
@@ -100,7 +187,20 @@ declare const ALL_TASK_SCHEMAS: readonly [z.ZodObject<{
100
187
  id: z.ZodString;
101
188
  description: z.ZodString;
102
189
  assignment: z.ZodString;
103
- inheritContext: z.ZodOptional<z.ZodBoolean>;
190
+ inheritContext: z.ZodOptional<z.ZodEnum<{
191
+ bounded: "bounded";
192
+ full: "full";
193
+ "last-turn": "last-turn";
194
+ none: "none";
195
+ receipt: "receipt";
196
+ }>>;
197
+ }, z.core.$strip>>;
198
+ spawnPlan: z.ZodOptional<z.ZodObject<{
199
+ whyParallel: z.ZodString;
200
+ whyNotLocal: z.ZodString;
201
+ independence: z.ZodString;
202
+ expectedReceiptShape: z.ZodString;
203
+ maxInlineTokens: z.ZodNumber;
104
204
  }, z.core.$strip>>;
105
205
  }, z.core.$strip>, z.ZodObject<{
106
206
  agent: z.ZodString;
@@ -108,7 +208,20 @@ declare const ALL_TASK_SCHEMAS: readonly [z.ZodObject<{
108
208
  id: z.ZodString;
109
209
  description: z.ZodString;
110
210
  assignment: z.ZodString;
111
- inheritContext: z.ZodOptional<z.ZodBoolean>;
211
+ inheritContext: z.ZodOptional<z.ZodEnum<{
212
+ bounded: "bounded";
213
+ full: "full";
214
+ "last-turn": "last-turn";
215
+ none: "none";
216
+ receipt: "receipt";
217
+ }>>;
218
+ }, z.core.$strip>>;
219
+ spawnPlan: z.ZodOptional<z.ZodObject<{
220
+ whyParallel: z.ZodString;
221
+ whyNotLocal: z.ZodString;
222
+ independence: z.ZodString;
223
+ expectedReceiptShape: z.ZodString;
224
+ maxInlineTokens: z.ZodNumber;
112
225
  }, z.core.$strip>>;
113
226
  }, z.core.$strip>];
114
227
  type DynamicTaskSchema = (typeof ALL_TASK_SCHEMAS)[number];
@@ -123,6 +236,7 @@ export interface TaskParams {
123
236
  agent: string;
124
237
  context?: string;
125
238
  schema?: string;
239
+ spawnPlan?: SpawnPlanReceipt;
126
240
  tasks: TaskItem[];
127
241
  isolated?: boolean;
128
242
  }
@@ -171,7 +285,7 @@ export interface AgentProgress {
171
285
  id: string;
172
286
  agent: string;
173
287
  agentSource: AgentSource;
174
- status: "pending" | "running" | "completed" | "failed" | "aborted";
288
+ status: "pending" | "running" | "completed" | "failed" | "aborted" | "paused";
175
289
  task: string;
176
290
  assignment?: string;
177
291
  description?: string;
@@ -213,6 +327,7 @@ export interface AgentProgress {
213
327
  retryState?: {
214
328
  attempt: number;
215
329
  maxAttempts: number;
330
+ unbounded?: boolean;
216
331
  delayMs: number;
217
332
  errorMessage: string;
218
333
  startedAtMs: number;
@@ -261,6 +376,7 @@ export interface SingleResult {
261
376
  error?: string;
262
377
  aborted?: boolean;
263
378
  abortReason?: string;
379
+ paused?: boolean;
264
380
  /** Aggregated usage from the subprocess, accumulated incrementally from message_end events. */
265
381
  usage?: Usage;
266
382
  /** Output path for the task result */
@@ -271,6 +387,8 @@ export interface SingleResult {
271
387
  branchName?: string;
272
388
  /** Nested repo patches to apply after parent merge */
273
389
  nestedPatches?: NestedRepoPatch[];
390
+ /** Whether isolated execution produced a non-empty root or nested patch. */
391
+ producedChanges?: boolean;
274
392
  /** Data extracted by registered subprocess tool handlers (keyed by tool name) */
275
393
  extractedToolData?: Record<string, unknown[]>;
276
394
  /**
@@ -287,21 +405,87 @@ export interface SingleResult {
287
405
  outputMeta?: {
288
406
  lineCount: number;
289
407
  charCount: number;
408
+ byteSize?: number;
409
+ sha256?: string;
410
+ };
411
+ /** Fork-context seed accounting for this subagent, when inherited parent context was cloned. */
412
+ forkContext?: {
413
+ mode: ForkContextMode;
414
+ clonedTokens: number;
290
415
  };
291
416
  }
292
417
  /** Tool details for TUI rendering */
293
418
  export interface TaskToolDetails {
294
419
  projectAgentsDir: string | null;
295
- results: SingleResult[];
420
+ results: TaskResultReceipt[];
296
421
  totalDurationMs: number;
297
422
  /** Aggregated usage across all subagents. */
298
423
  usage?: Usage;
299
- outputPaths?: string[];
424
+ /** Aggregate cloned tokens copied into fork-context seeds across subagents. */
425
+ forkContextClonedTokens?: number;
426
+ roiSummary?: {
427
+ childCount: number;
428
+ totalTokens: number;
429
+ totalCostTotal?: number;
430
+ totalClonedTokens?: number;
431
+ /** Advisory ids for terminal children that spent tokens without detectable output/review/changes. */
432
+ lowRoiChildIds: string[];
433
+ };
300
434
  progress?: AgentProgress[];
301
435
  async?: {
302
- state: "running" | "completed" | "failed";
436
+ state: "running" | "paused" | "queued" | "completed" | "failed";
303
437
  jobId: string;
304
438
  type: "task";
305
439
  };
306
440
  }
441
+ /**
442
+ * Persisted per-turn / per-subagent token record (Phase 0 instrumentation).
443
+ *
444
+ * Additive: this does not alter any existing task result shape. It is the
445
+ * durable, model-independent unit the deterministic orchestration-token
446
+ * benchmark (`@gajae-code/orchestration-token-benchmark`) consumes to measure
447
+ * token efficiency without any live-model calls.
448
+ */
449
+ export interface TaskTokenLog {
450
+ /** Subagent id, or "root" for the orchestrator's own turn. */
451
+ subagentId: string;
452
+ /** Agent name for attribution, when known. */
453
+ agent?: string;
454
+ /** 1-based turn index within the subagent's session. */
455
+ turn: number;
456
+ /** ISO-8601 timestamp the turn completed. */
457
+ at: string;
458
+ /** Cost-bearing input tokens (excludes cache reads), mirrors `Usage.input`. */
459
+ input: number;
460
+ /** Total output tokens for the turn, mirrors `Usage.output`. */
461
+ output: number;
462
+ /** Tokens read from the prompt cache, mirrors `Usage.cacheRead`. */
463
+ cacheRead: number;
464
+ /** Tokens written to the prompt cache, mirrors `Usage.cacheWrite`. */
465
+ cacheWrite: number;
466
+ /** input + output + cacheRead + cacheWrite. */
467
+ totalTokens: number;
468
+ /** Latest per-turn context-window occupancy, when known. */
469
+ contextTokens?: number;
470
+ /** Estimated USD cost for the turn, when known. */
471
+ cost?: number;
472
+ /** Model id used for the turn, when known. */
473
+ model?: string;
474
+ }
475
+ /**
476
+ * Deterministic aggregate token metrics computed from a set of `TaskTokenLog`
477
+ * entries. The cache-hit-rate field is the primary prompt-cache signal called
478
+ * out by the prefix-stability invariant (see the approved plan).
479
+ */
480
+ export interface TaskTokenMetrics {
481
+ /** Number of token-log entries aggregated. */
482
+ turns: number;
483
+ inputTokens: number;
484
+ outputTokens: number;
485
+ cacheReadTokens: number;
486
+ cacheWriteTokens: number;
487
+ totalTokens: number;
488
+ /** cacheRead / (input + cacheRead); 0 when there is no input-class traffic. */
489
+ cacheHitRate: number;
490
+ }
307
491
  export {};
@@ -52,6 +52,12 @@ export interface CronDeleteToolDetails {
52
52
  export declare function clearOwnerSchedules(ownerId: string | undefined): void;
53
53
  /** Reset every owner's schedule store. Test-only. */
54
54
  export declare function resetCronRegistryForTests(): void;
55
+ /** Subscribe to cron schedule-set changes. Returns an unsubscribe function. */
56
+ export declare function onCronChange(cb: () => void): () => void;
57
+ /** Snapshot the scheduled cron jobs for an owner (or all owners when omitted). */
58
+ export declare function listCronSnapshots(ownerId?: string): CronJobSnapshot[];
59
+ /** Delete a scheduled cron job by owner-scoped id. Returns true when removed. */
60
+ export declare function deleteCronJobById(ownerId: string | undefined, id: string): boolean;
55
61
  export declare function validateCronExpression(expression: string): void;
56
62
  export declare function findNextCronMatchMs(expression: string, afterMs: number, deadlineMs?: number): number | undefined;
57
63
  export declare function calculateCronFireTimeMs(params: {
@@ -102,6 +102,8 @@ export interface ToolSession {
102
102
  requireYieldTool?: boolean;
103
103
  /** Task recursion depth (0 = top-level, 1 = first child, etc.) */
104
104
  taskDepth?: number;
105
+ /** Current role-agent type/name for nested task sessions. */
106
+ currentAgentType?: string;
105
107
  /** Get session file */
106
108
  getSessionFile: () => string | null;
107
109
  /** Get eval kernel owner ID for session-scoped retained-kernel cleanup. */
@@ -116,6 +116,7 @@ export declare function resolveReadPath(filePath: string, cwd: string): string;
116
116
  export interface ToolScopeOptions {
117
117
  rawPaths: string[];
118
118
  cwd: string;
119
+ getArtifactsDir?: () => string | null;
119
120
  /** Verb used in the "Cannot {action} internal URL without a backing file: …" message. */
120
121
  internalUrlAction: string;
121
122
  /** Collect absolute paths flagged immutable by their internal-URL handler. */
@@ -8,13 +8,24 @@ declare const subagentSchema: z.ZodObject<{
8
8
  cancel: "cancel";
9
9
  inspect: "inspect";
10
10
  list: "list";
11
+ pause: "pause";
12
+ resume: "resume";
13
+ steer: "steer";
11
14
  }>;
12
15
  ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
16
+ id: z.ZodOptional<z.ZodString>;
17
+ message: z.ZodOptional<z.ZodString>;
18
+ pause: z.ZodOptional<z.ZodBoolean>;
13
19
  timeout_ms: z.ZodOptional<z.ZodNumber>;
14
20
  limit: z.ZodOptional<z.ZodNumber>;
21
+ verbosity: z.ZodOptional<z.ZodEnum<{
22
+ full: "full";
23
+ preview: "preview";
24
+ receipt: "receipt";
25
+ }>>;
15
26
  }, z.core.$strip>;
16
27
  type SubagentParams = z.infer<typeof subagentSchema>;
17
- type SubagentStatus = "running" | "completed" | "failed" | "cancelled" | "not_found" | "already_completed";
28
+ type SubagentStatus = "running" | "paused" | "queued" | "completed" | "failed" | "cancelled" | "not_found" | "already_completed";
18
29
  export interface SubagentSnapshot {
19
30
  id: string;
20
31
  jobId: string;
@@ -27,6 +38,9 @@ export interface SubagentSnapshot {
27
38
  durationMs: number;
28
39
  resultText?: string;
29
40
  errorText?: string;
41
+ resultPreview?: string;
42
+ outputRef?: string;
43
+ truncated?: boolean;
30
44
  guidance?: string;
31
45
  }
32
46
  export interface SubagentToolDetails {
@@ -45,10 +59,21 @@ export declare class SubagentTool implements AgentTool<typeof subagentSchema, Su
45
59
  cancel: "cancel";
46
60
  inspect: "inspect";
47
61
  list: "list";
62
+ pause: "pause";
63
+ resume: "resume";
64
+ steer: "steer";
48
65
  }>;
49
66
  ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
67
+ id: z.ZodOptional<z.ZodString>;
68
+ message: z.ZodOptional<z.ZodString>;
69
+ pause: z.ZodOptional<z.ZodBoolean>;
50
70
  timeout_ms: z.ZodOptional<z.ZodNumber>;
51
71
  limit: z.ZodOptional<z.ZodNumber>;
72
+ verbosity: z.ZodOptional<z.ZodEnum<{
73
+ full: "full";
74
+ preview: "preview";
75
+ receipt: "receipt";
76
+ }>>;
52
77
  }, z.core.$strip>;
53
78
  readonly strict = true;
54
79
  readonly loadMode = "discoverable";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@gajae-code/coding-agent",
4
- "version": "0.2.5",
4
+ "version": "0.3.1",
5
5
  "description": "Gajae Code CLI with read, bash, edit, write tools and session management",
6
6
  "homepage": "https://gaebal-gajae.dev",
7
7
  "author": "Yeachan-Heo",
@@ -48,12 +48,12 @@
48
48
  "@agentclientprotocol/sdk": "0.21.0",
49
49
  "@babel/parser": "^7.29.3",
50
50
  "@mozilla/readability": "^0.6.0",
51
- "@gajae-code/stats": "0.2.5",
52
- "@gajae-code/agent-core": "0.2.5",
53
- "@gajae-code/ai": "0.2.5",
54
- "@gajae-code/natives": "0.2.5",
55
- "@gajae-code/tui": "0.2.5",
56
- "@gajae-code/utils": "0.2.5",
51
+ "@gajae-code/stats": "0.3.1",
52
+ "@gajae-code/agent-core": "0.3.1",
53
+ "@gajae-code/ai": "0.3.1",
54
+ "@gajae-code/natives": "0.3.1",
55
+ "@gajae-code/tui": "0.3.1",
56
+ "@gajae-code/utils": "0.3.1",
57
57
  "@puppeteer/browsers": "^2.13.0",
58
58
  "@types/turndown": "5.0.6",
59
59
  "@xterm/headless": "^6.0.0",
@@ -4,6 +4,7 @@ import * as path from "node:path";
4
4
 
5
5
  const packageDir = path.join(import.meta.dir, "..");
6
6
  const outputPath = path.join(packageDir, "dist", "gjc");
7
+ const nativeDir = path.join(packageDir, "..", "natives", "native");
7
8
 
8
9
  function shouldAdhocSignDarwinBinary(): boolean {
9
10
  return process.platform === "darwin";
@@ -21,6 +22,11 @@ async function runCommand(command: string[], env: NodeJS.ProcessEnv = Bun.env):
21
22
  throw new Error(`Command failed with exit code ${exitCode}: ${command.join(" ")}`);
22
23
  }
23
24
  }
25
+ async function stageWorkspaceNativeAddons(): Promise<void> {
26
+ await Array.fromAsync(new Bun.Glob("pi_natives.*.node").scan({ cwd: nativeDir }), async filename => {
27
+ await Bun.write(path.join(packageDir, "dist", filename), Bun.file(path.join(nativeDir, filename)));
28
+ });
29
+ }
24
30
 
25
31
  async function main(): Promise<void> {
26
32
  await runCommand(["bun", "--cwd=../stats", "scripts/generate-client-bundle.ts", "--generate"]);
@@ -62,6 +68,7 @@ async function main(): Promise<void> {
62
68
  buildEnv,
63
69
  );
64
70
 
71
+ await stageWorkspaceNativeAddons();
65
72
  // Bun 1.3.12 emits a truncated Mach-O signature on darwin builds.
66
73
  if (shouldAdhocSignDarwinBinary()) {
67
74
  await runCommand(["codesign", "--force", "--sign", "-", outputPath]);