@gajae-code/coding-agent 0.3.0 → 0.3.2

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 (213) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +1 -1
  3. package/dist/types/async/job-manager.d.ts +7 -0
  4. package/dist/types/cli/args.d.ts +3 -1
  5. package/dist/types/commands/deep-interview.d.ts +3 -0
  6. package/dist/types/commands/launch.d.ts +6 -0
  7. package/dist/types/config/keybindings.d.ts +5 -0
  8. package/dist/types/config/model-profile-activation.d.ts +30 -0
  9. package/dist/types/config/model-profiles.d.ts +19 -0
  10. package/dist/types/config/model-registry.d.ts +8 -0
  11. package/dist/types/config/model-resolver.d.ts +1 -1
  12. package/dist/types/config/models-config-schema.d.ts +47 -0
  13. package/dist/types/config/settings-schema.d.ts +14 -4
  14. package/dist/types/debug/crash-diagnostics.d.ts +45 -0
  15. package/dist/types/debug/runtime-gauges.d.ts +6 -0
  16. package/dist/types/deep-interview/render-middleware.d.ts +1 -0
  17. package/dist/types/eval/py/executor.d.ts +2 -0
  18. package/dist/types/eval/py/kernel.d.ts +2 -0
  19. package/dist/types/exec/bash-executor.d.ts +10 -0
  20. package/dist/types/gjc-runtime/cli-write-receipt.d.ts +24 -0
  21. package/dist/types/gjc-runtime/deep-interview-runtime.d.ts +1 -0
  22. package/dist/types/gjc-runtime/state-migrations.d.ts +9 -0
  23. package/dist/types/gjc-runtime/state-schema.d.ts +317 -0
  24. package/dist/types/gjc-runtime/state-writer.d.ts +10 -0
  25. package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +2 -1
  26. package/dist/types/gjc-runtime/workflow-command-ref.d.ts +43 -0
  27. package/dist/types/harness-control-plane/control-endpoint.d.ts +3 -2
  28. package/dist/types/hooks/skill-state.d.ts +21 -0
  29. package/dist/types/internal-urls/agent-protocol.d.ts +2 -2
  30. package/dist/types/internal-urls/artifact-protocol.d.ts +2 -2
  31. package/dist/types/internal-urls/registry-helpers.d.ts +8 -7
  32. package/dist/types/internal-urls/types.d.ts +4 -0
  33. package/dist/types/lsp/index.d.ts +10 -10
  34. package/dist/types/main.d.ts +10 -1
  35. package/dist/types/modes/bridge/auth.d.ts +12 -0
  36. package/dist/types/modes/bridge/bridge-client-bridge.d.ts +9 -0
  37. package/dist/types/modes/bridge/bridge-mode.d.ts +44 -0
  38. package/dist/types/modes/bridge/bridge-ui-context.d.ts +88 -0
  39. package/dist/types/modes/bridge/event-stream.d.ts +8 -0
  40. package/dist/types/modes/components/custom-editor.d.ts +6 -0
  41. package/dist/types/modes/components/custom-provider-wizard.d.ts +10 -0
  42. package/dist/types/modes/components/jobs-overlay-model.d.ts +31 -0
  43. package/dist/types/modes/components/jobs-overlay.d.ts +30 -0
  44. package/dist/types/modes/components/model-selector.d.ts +6 -1
  45. package/dist/types/modes/components/provider-onboarding-selector.d.ts +1 -1
  46. package/dist/types/modes/components/status-line/types.d.ts +2 -0
  47. package/dist/types/modes/components/status-line.d.ts +2 -0
  48. package/dist/types/modes/controllers/input-controller.d.ts +1 -0
  49. package/dist/types/modes/controllers/selector-controller.d.ts +9 -0
  50. package/dist/types/modes/index.d.ts +1 -0
  51. package/dist/types/modes/interactive-mode.d.ts +1 -0
  52. package/dist/types/modes/jobs-observer.d.ts +57 -0
  53. package/dist/types/modes/rpc/host-tools.d.ts +1 -16
  54. package/dist/types/modes/rpc/host-uris.d.ts +1 -38
  55. package/dist/types/modes/shared/agent-wire/command-dispatch.d.ts +20 -0
  56. package/dist/types/modes/shared/agent-wire/command-validation.d.ts +2 -0
  57. package/dist/types/modes/shared/agent-wire/event-envelope.d.ts +24 -0
  58. package/dist/types/modes/shared/agent-wire/handshake.d.ts +46 -0
  59. package/dist/types/modes/shared/agent-wire/host-tool-bridge.d.ts +16 -0
  60. package/dist/types/modes/shared/agent-wire/host-uri-bridge.d.ts +17 -0
  61. package/dist/types/modes/shared/agent-wire/protocol.d.ts +44 -0
  62. package/dist/types/modes/shared/agent-wire/responses.d.ts +4 -0
  63. package/dist/types/modes/shared/agent-wire/scopes.d.ts +18 -0
  64. package/dist/types/modes/shared/agent-wire/ui-request-broker.d.ts +42 -0
  65. package/dist/types/modes/shared/agent-wire/ui-result.d.ts +27 -0
  66. package/dist/types/modes/types.d.ts +2 -0
  67. package/dist/types/sdk.d.ts +3 -1
  68. package/dist/types/session/agent-session.d.ts +11 -1
  69. package/dist/types/skill-state/workflow-state-contract.d.ts +1 -2
  70. package/dist/types/skill-state/workflow-state-version.d.ts +3 -0
  71. package/dist/types/task/executor.d.ts +1 -0
  72. package/dist/types/task/id.d.ts +7 -0
  73. package/dist/types/task/index.d.ts +5 -0
  74. package/dist/types/task/receipt.d.ts +85 -0
  75. package/dist/types/task/spawn-gate.d.ts +38 -0
  76. package/dist/types/task/types.d.ts +143 -11
  77. package/dist/types/tools/cron.d.ts +6 -0
  78. package/dist/types/tools/hindsight-recall.d.ts +0 -2
  79. package/dist/types/tools/hindsight-reflect.d.ts +0 -2
  80. package/dist/types/tools/hindsight-retain.d.ts +0 -2
  81. package/dist/types/tools/index.d.ts +6 -4
  82. package/dist/types/tools/path-utils.d.ts +1 -0
  83. package/dist/types/tools/subagent.d.ts +15 -0
  84. package/package.json +7 -7
  85. package/scripts/build-binary.ts +7 -0
  86. package/src/async/job-manager.ts +36 -0
  87. package/src/cli/args.ts +19 -2
  88. package/src/commands/deep-interview.ts +1 -0
  89. package/src/commands/harness.ts +289 -19
  90. package/src/commands/launch.ts +10 -2
  91. package/src/commands/state.ts +2 -1
  92. package/src/commands/team.ts +22 -4
  93. package/src/config/keybindings.ts +6 -0
  94. package/src/config/model-profile-activation.ts +157 -0
  95. package/src/config/model-profiles.ts +155 -0
  96. package/src/config/model-registry.ts +19 -0
  97. package/src/config/model-resolver.ts +3 -2
  98. package/src/config/models-config-schema.ts +36 -0
  99. package/src/config/settings-schema.ts +16 -3
  100. package/src/dap/client.ts +17 -3
  101. package/src/debug/crash-diagnostics.ts +223 -0
  102. package/src/debug/runtime-gauges.ts +20 -0
  103. package/src/deep-interview/render-middleware.ts +6 -0
  104. package/src/defaults/gjc/skills/deep-interview/SKILL.md +1 -1
  105. package/src/defaults/gjc/skills/ralplan/SKILL.md +31 -2
  106. package/src/defaults/gjc/skills/ultragoal/SKILL.md +39 -3
  107. package/src/defaults/gjc/skills/ultragoal/ai-slop-cleaner.md +61 -0
  108. package/src/defaults/gjc-defaults.ts +7 -0
  109. package/src/eval/py/executor.ts +21 -1
  110. package/src/eval/py/kernel.ts +15 -0
  111. package/src/exec/bash-executor.ts +41 -0
  112. package/src/gjc-runtime/cli-write-receipt.ts +31 -0
  113. package/src/gjc-runtime/deep-interview-runtime.ts +69 -32
  114. package/src/gjc-runtime/ralplan-runtime.ts +213 -36
  115. package/src/gjc-runtime/state-migrations.ts +54 -7
  116. package/src/gjc-runtime/state-runtime.ts +461 -64
  117. package/src/gjc-runtime/state-schema.ts +192 -0
  118. package/src/gjc-runtime/state-writer.ts +32 -1
  119. package/src/gjc-runtime/team-runtime.ts +177 -105
  120. package/src/gjc-runtime/ultragoal-runtime.ts +231 -38
  121. package/src/gjc-runtime/workflow-command-ref.ts +239 -0
  122. package/src/gjc-runtime/workflow-manifest.generated.json +108 -4
  123. package/src/gjc-runtime/workflow-manifest.ts +3 -1
  124. package/src/harness-control-plane/control-endpoint.ts +19 -8
  125. package/src/harness-control-plane/owner.ts +57 -10
  126. package/src/harness-control-plane/state-machine.ts +2 -1
  127. package/src/hooks/skill-state.ts +176 -26
  128. package/src/internal-urls/agent-protocol.ts +68 -21
  129. package/src/internal-urls/artifact-protocol.ts +12 -17
  130. package/src/internal-urls/docs-index.generated.ts +8 -10
  131. package/src/internal-urls/registry-helpers.ts +19 -16
  132. package/src/internal-urls/types.ts +4 -0
  133. package/src/lsp/client.ts +18 -2
  134. package/src/main.ts +88 -6
  135. package/src/modes/bridge/auth.ts +41 -0
  136. package/src/modes/bridge/bridge-client-bridge.ts +47 -0
  137. package/src/modes/bridge/bridge-mode.ts +520 -0
  138. package/src/modes/bridge/bridge-ui-context.ts +200 -0
  139. package/src/modes/bridge/event-stream.ts +70 -0
  140. package/src/modes/components/custom-editor.ts +101 -0
  141. package/src/modes/components/custom-provider-wizard.ts +318 -0
  142. package/src/modes/components/hook-selector.ts +61 -18
  143. package/src/modes/components/jobs-overlay-model.ts +109 -0
  144. package/src/modes/components/jobs-overlay.ts +172 -0
  145. package/src/modes/components/model-selector.ts +108 -18
  146. package/src/modes/components/provider-onboarding-selector.ts +6 -1
  147. package/src/modes/components/status-line/presets.ts +7 -5
  148. package/src/modes/components/status-line/segments.ts +25 -0
  149. package/src/modes/components/status-line/types.ts +2 -0
  150. package/src/modes/components/status-line.ts +9 -1
  151. package/src/modes/controllers/extension-ui-controller.ts +39 -3
  152. package/src/modes/controllers/input-controller.ts +97 -9
  153. package/src/modes/controllers/selector-controller.ts +86 -1
  154. package/src/modes/index.ts +1 -0
  155. package/src/modes/interactive-mode.ts +27 -0
  156. package/src/modes/jobs-observer.ts +204 -0
  157. package/src/modes/rpc/host-tools.ts +1 -186
  158. package/src/modes/rpc/host-uris.ts +1 -235
  159. package/src/modes/rpc/rpc-client.ts +25 -10
  160. package/src/modes/rpc/rpc-mode.ts +12 -381
  161. package/src/modes/shared/agent-wire/command-dispatch.ts +341 -0
  162. package/src/modes/shared/agent-wire/command-validation.ts +131 -0
  163. package/src/modes/shared/agent-wire/event-envelope.ts +108 -0
  164. package/src/modes/shared/agent-wire/handshake.ts +117 -0
  165. package/src/modes/shared/agent-wire/host-tool-bridge.ts +194 -0
  166. package/src/modes/shared/agent-wire/host-uri-bridge.ts +236 -0
  167. package/src/modes/shared/agent-wire/protocol.ts +96 -0
  168. package/src/modes/shared/agent-wire/responses.ts +17 -0
  169. package/src/modes/shared/agent-wire/scopes.ts +89 -0
  170. package/src/modes/shared/agent-wire/ui-request-broker.ts +150 -0
  171. package/src/modes/shared/agent-wire/ui-result.ts +48 -0
  172. package/src/modes/types.ts +2 -0
  173. package/src/prompts/memories/consolidation.md +1 -1
  174. package/src/prompts/memories/read-path.md +6 -7
  175. package/src/prompts/memories/unavailable.md +2 -2
  176. package/src/prompts/tools/bash.md +1 -1
  177. package/src/prompts/tools/irc.md +1 -1
  178. package/src/prompts/tools/read.md +2 -2
  179. package/src/prompts/tools/recall.md +1 -0
  180. package/src/prompts/tools/reflect.md +1 -0
  181. package/src/prompts/tools/retain.md +1 -0
  182. package/src/prompts/tools/subagent.md +12 -7
  183. package/src/prompts/tools/task-summary.md +3 -9
  184. package/src/prompts/tools/task.md +5 -1
  185. package/src/sdk.ts +5 -1
  186. package/src/session/agent-session.ts +214 -38
  187. package/src/skill-state/deep-interview-mutation-guard.ts +23 -4
  188. package/src/skill-state/workflow-state-contract.ts +7 -4
  189. package/src/skill-state/workflow-state-version.ts +3 -0
  190. package/src/slash-commands/builtin-registry.ts +9 -1
  191. package/src/task/executor.ts +31 -5
  192. package/src/task/id.ts +33 -0
  193. package/src/task/index.ts +259 -67
  194. package/src/task/output-manager.ts +5 -4
  195. package/src/task/receipt.ts +297 -0
  196. package/src/task/render.ts +48 -131
  197. package/src/task/spawn-gate.ts +132 -0
  198. package/src/task/types.ts +48 -7
  199. package/src/tools/ask.ts +73 -33
  200. package/src/tools/ast-edit.ts +1 -0
  201. package/src/tools/ast-grep.ts +1 -0
  202. package/src/tools/bash.ts +1 -1
  203. package/src/tools/cron.ts +48 -0
  204. package/src/tools/find.ts +4 -1
  205. package/src/tools/hindsight-recall.ts +0 -2
  206. package/src/tools/hindsight-reflect.ts +0 -2
  207. package/src/tools/hindsight-retain.ts +0 -2
  208. package/src/tools/index.ts +6 -18
  209. package/src/tools/path-utils.ts +3 -2
  210. package/src/tools/read.ts +4 -3
  211. package/src/tools/search.ts +1 -0
  212. package/src/tools/skill.ts +6 -1
  213. package/src/tools/subagent.ts +237 -84
@@ -0,0 +1,42 @@
1
+ export type UiRequestCancelReason = "timeout" | "abort" | "disconnect";
2
+ export interface UiRequestCancelled {
3
+ status: "cancelled";
4
+ reason: UiRequestCancelReason;
5
+ }
6
+ export type UiRequestResolution<TResponse> = TResponse | UiRequestCancelled;
7
+ export type UiBrokerResponseResult = {
8
+ status: "accepted";
9
+ } | {
10
+ status: "rejected";
11
+ code: "not_controller" | "already_resolved" | "unknown_request";
12
+ };
13
+ export interface UiRequestBrokerOptions<TRequest> {
14
+ emitRequest: (correlationId: string, request: TRequest) => void;
15
+ }
16
+ export interface UiRequestOptions {
17
+ correlationId?: string;
18
+ timeoutMs?: number;
19
+ signal?: AbortSignal;
20
+ }
21
+ /**
22
+ * Broker for one active session. v1 supports one controller token at a time;
23
+ * other clients may observe frames but cannot answer correlated requests.
24
+ */
25
+ export declare class UiRequestBroker<TRequest, TResponse> {
26
+ #private;
27
+ constructor(options: UiRequestBrokerOptions<TRequest>);
28
+ get ownerToken(): string | undefined;
29
+ get pendingCount(): number;
30
+ claimController(ownerToken?: string): {
31
+ status: "claimed";
32
+ ownerToken: string;
33
+ } | {
34
+ status: "busy";
35
+ };
36
+ releaseController(ownerToken: string): boolean;
37
+ request(request: TRequest, options?: UiRequestOptions): Promise<UiRequestResolution<TResponse>>;
38
+ respond(correlationId: string, ownerToken: string, response: TResponse): UiBrokerResponseResult;
39
+ cancelAll(reason: UiRequestCancelReason): void;
40
+ cancel(correlationId: string, reason: UiRequestCancelReason): boolean;
41
+ disconnectController(ownerToken: string): boolean;
42
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Typed UI/manipulation result semantics for bridge-capability handling.
3
+ *
4
+ * `unsupported` is distinct from both a real value and user cancellation. This
5
+ * prevents local-only or undeclared `ExtensionUIContext` surfaces from becoming
6
+ * silent no-ops that look like user intent.
7
+ */
8
+ export interface BridgeUiValue<TValue> {
9
+ status: "value";
10
+ value: TValue;
11
+ }
12
+ export interface BridgeUiCancelled {
13
+ status: "cancelled";
14
+ reason?: "user" | "timeout" | "abort" | "disconnect";
15
+ }
16
+ export interface BridgeUiUnsupported {
17
+ status: "unsupported";
18
+ capability: string;
19
+ reason: string;
20
+ }
21
+ export type BridgeUiResult<TValue> = BridgeUiValue<TValue> | BridgeUiCancelled | BridgeUiUnsupported;
22
+ export declare function uiValue<TValue>(value: TValue): BridgeUiValue<TValue>;
23
+ export declare function uiCancelled(reason?: BridgeUiCancelled["reason"]): BridgeUiCancelled;
24
+ export declare function uiUnsupported(capability: string, reason: string): BridgeUiUnsupported;
25
+ export declare function isUiUnsupported<TValue>(result: BridgeUiResult<TValue>): result is BridgeUiUnsupported;
26
+ export declare function isUiCancelled<TValue>(result: BridgeUiResult<TValue>): result is BridgeUiCancelled;
27
+ export declare function isUiValue<TValue>(result: BridgeUiResult<TValue>): result is BridgeUiValue<TValue>;
@@ -123,6 +123,7 @@ export interface InteractiveModeContext {
123
123
  }): void;
124
124
  showError(message: string): void;
125
125
  showWarning(message: string): void;
126
+ notifyConfigChanged?: () => Promise<void> | void;
126
127
  showNewVersionNotification(newVersion: string): void;
127
128
  clearEditor(): void;
128
129
  updatePendingMessagesDisplay(): void;
@@ -228,6 +229,7 @@ export interface InteractiveModeContext {
228
229
  showHookConfirm(title: string, message: string): Promise<boolean>;
229
230
  showDebugSelector(): void;
230
231
  showSessionObserver(): void;
232
+ showJobsOverlay(): void;
231
233
  resetObserverRegistry(): void;
232
234
  handleCtrlC(): void;
233
235
  handleCtrlD(): void;
@@ -93,7 +93,9 @@ export interface CreateAgentSessionOptions {
93
93
  requireYieldTool?: boolean;
94
94
  /** Task recursion depth (for subagent sessions). Default: 0 */
95
95
  taskDepth?: number;
96
- /** Parent Hindsight state to alias for subagent memory tools. */
96
+ /** Current role-agent type/name for nested task sessions. */
97
+ currentAgentType?: string;
98
+ /** Parent Hindsight state to alias for subagent private memory backend compatibility. */
97
99
  parentHindsightSessionState?: HindsightSessionState;
98
100
  /** Pre-allocated agent identity for IRC routing. Default: "0-Main" for top-level, parentTaskPrefix-derived for sub. */
99
101
  agentId?: string;
@@ -133,7 +133,7 @@ export type AgentSessionEvent = AgentEvent | {
133
133
  };
134
134
  /** Listener function for agent session events */
135
135
  export type AgentSessionEventListener = (event: AgentSessionEvent) => void;
136
- export type AsyncJobSnapshotItem = Pick<AsyncJob, "id" | "type" | "status" | "label" | "startTime">;
136
+ export type AsyncJobSnapshotItem = Pick<AsyncJob, "id" | "type" | "status" | "label" | "startTime" | "metadata">;
137
137
  export interface AsyncJobSnapshot {
138
138
  running: AsyncJobSnapshotItem[];
139
139
  recent: AsyncJobSnapshotItem[];
@@ -358,6 +358,7 @@ export declare class AgentSession {
358
358
  * Does NOT push to the agent's steering/followUp queue — that happens
359
359
  * separately inside `sendCustomMessage`. */
360
360
  enqueueCustomMessageDisplay(text: string, mode: "steer" | "followUp"): string;
361
+ getAgentId(): string | undefined;
361
362
  getAsyncJobSnapshot(options?: {
362
363
  recentLimit?: number;
363
364
  }): AsyncJobSnapshot | null;
@@ -577,6 +578,10 @@ export declare class AgentSession {
577
578
  };
578
579
  /** Number of pending messages (includes steering, follow-up, and next-turn messages) */
579
580
  get queuedMessageCount(): number;
581
+ /** Whether the agent has queued steering messages that a `user_interrupt`
582
+ * abort would resume into (steer-on-interrupt). Drives the Esc-on-steer UX:
583
+ * the first Esc consumes the steer and auto-continues, a second Esc aborts. */
584
+ get hasQueuedSteering(): boolean;
580
585
  /** Get pending messages (read-only). Returns the public text-only view;
581
586
  * internal `{text, tag?}` records are mapped to `.text` so callers
582
587
  * (`updatePendingMessagesDisplay`, `restoreQueuedMessagesToEditor`) see
@@ -606,6 +611,11 @@ export declare class AgentSession {
606
611
  goalReason?: "interrupted" | "internal";
607
612
  timeoutMs?: number;
608
613
  cause?: "user_interrupt" | "new_session" | "session_switch" | "compaction" | "handoff" | "tool_abort" | "internal";
614
+ /** Suppress the "Operation aborted" line on the resulting aborted message
615
+ * by stamping `SILENT_ABORT_MARKER`. Used when Esc consumes a queued steer
616
+ * and resumes via steer-on-interrupt, so the interrupt reads as a quiet
617
+ * hand-off rather than a failure. */
618
+ silent?: boolean;
609
619
  }): Promise<void>;
610
620
  /**
611
621
  * Start a new session, optionally with initial messages and parent tracking.
@@ -1,7 +1,6 @@
1
1
  import { type CanonicalGjcWorkflowSkill } from "./active-state";
2
+ export { WORKFLOW_STATE_RECEIPT_FRESH_MS, WORKFLOW_STATE_RECEIPT_VERSION, WORKFLOW_STATE_VERSION, } from "./workflow-state-version";
2
3
  export type { CanonicalGjcWorkflowSkill };
3
- export declare const WORKFLOW_STATE_RECEIPT_VERSION = 1;
4
- export declare const WORKFLOW_STATE_RECEIPT_FRESH_MS: number;
5
4
  export type WorkflowStateMutationOwner = "gjc-state-cli" | "gjc-runtime" | "gjc-hook";
6
5
  export type WorkflowStateReceiptStatus = "fresh" | "stale";
7
6
  export interface WorkflowStateContentChecksum {
@@ -0,0 +1,3 @@
1
+ export declare const WORKFLOW_STATE_RECEIPT_VERSION = 1;
2
+ export declare const WORKFLOW_STATE_VERSION = 2;
3
+ export declare const WORKFLOW_STATE_RECEIPT_FRESH_MS: number;
@@ -37,6 +37,7 @@ export interface ExecutorOptions {
37
37
  * if the resolved subagent model has no working credentials. See #985.
38
38
  */
39
39
  parentActiveModelPattern?: string;
40
+ parentSessionId?: string;
40
41
  thinkingLevel?: ThinkingLevel;
41
42
  outputSchema?: unknown;
42
43
  /** Parent task recursion depth (0 = top-level, 1 = first child, etc.) */
@@ -0,0 +1,7 @@
1
+ export declare const TASK_ID_PATTERN: RegExp;
2
+ export declare const TASK_ID_DESCRIPTION = "filesystem-safe identifier matching ^[A-Za-z0-9][A-Za-z0-9_-]{0,47}$";
3
+ export declare function isValidTaskId(id: string): boolean;
4
+ export declare function getTaskIdValidationError(id: unknown): string | undefined;
5
+ export declare function validateTaskId(id: string): string;
6
+ export declare function isValidAllocatedTaskId(id: string): boolean;
7
+ export declare function validateAllocatedTaskId(id: string): string;
@@ -1,4 +1,5 @@
1
1
  import type { AgentTool, AgentToolResult, AgentToolUpdateCallback } from "@gajae-code/agent-core";
2
+ import type { Model } from "@gajae-code/ai";
2
3
  import type { ToolSession } from "..";
3
4
  import type { Theme } from "../modes/theme/theme";
4
5
  import { type TaskToolDetails, type TaskToolSchemaInstance } from "./types";
@@ -7,9 +8,13 @@ import { renderResult, renderCall as renderTaskCall } from "./render";
7
8
  export { loadBundledAgents as BUNDLED_AGENTS } from "./agents";
8
9
  export { discoverCommands, expandCommand, getCommand } from "./commands";
9
10
  export { discoverAgents, getAgent } from "./discovery";
11
+ export { isValidAllocatedTaskId, isValidTaskId, TASK_ID_DESCRIPTION, TASK_ID_PATTERN, validateAllocatedTaskId, validateTaskId, } from "./id";
10
12
  export { AgentOutputManager } from "./output-manager";
13
+ export type { TaskResultReceipt } from "./receipt";
14
+ export { assertNoRawTaskFields, buildTaskReceipt, buildTaskRoi, buildTaskRoiSummary, findRawTaskLeakKeys, sanitizeTaskToolDetails, } from "./receipt";
11
15
  export type { AgentDefinition, AgentProgress, SingleResult, SubagentLifecyclePayload, SubagentProgressPayload, TaskParams, TaskToolDetails, } from "./types";
12
16
  export { TASK_SUBAGENT_EVENT_CHANNEL, TASK_SUBAGENT_LIFECYCLE_CHANNEL, TASK_SUBAGENT_PROGRESS_CHANNEL, taskSchema, } from "./types";
17
+ export declare function resolveForkContextMaxTokens(configured: number, model: Model | undefined): number;
13
18
  /**
14
19
  * Task tool - Delegate tasks to specialized agents.
15
20
  *
@@ -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 */
@@ -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
  }
@@ -273,6 +387,8 @@ export interface SingleResult {
273
387
  branchName?: string;
274
388
  /** Nested repo patches to apply after parent merge */
275
389
  nestedPatches?: NestedRepoPatch[];
390
+ /** Whether isolated execution produced a non-empty root or nested patch. */
391
+ producedChanges?: boolean;
276
392
  /** Data extracted by registered subprocess tool handlers (keyed by tool name) */
277
393
  extractedToolData?: Record<string, unknown[]>;
278
394
  /**
@@ -289,16 +405,32 @@ export interface SingleResult {
289
405
  outputMeta?: {
290
406
  lineCount: number;
291
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;
292
415
  };
293
416
  }
294
417
  /** Tool details for TUI rendering */
295
418
  export interface TaskToolDetails {
296
419
  projectAgentsDir: string | null;
297
- results: SingleResult[];
420
+ results: TaskResultReceipt[];
298
421
  totalDurationMs: number;
299
422
  /** Aggregated usage across all subagents. */
300
423
  usage?: Usage;
301
- 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
+ };
302
434
  progress?: AgentProgress[];
303
435
  async?: {
304
436
  state: "running" | "paused" | "queued" | "completed" | "failed";
@@ -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: {
@@ -14,8 +14,6 @@ export declare class HindsightRecallTool implements AgentTool<typeof hindsightRe
14
14
  query: z.ZodString;
15
15
  }, z.core.$strip>;
16
16
  readonly strict = true;
17
- readonly loadMode = "discoverable";
18
- readonly summary = "Search hindsight memory for relevant prior context";
19
17
  constructor(session: ToolSession);
20
18
  static createIf(session: ToolSession): HindsightRecallTool | null;
21
19
  execute(_id: string, params: HindsightRecallParams, signal?: AbortSignal): Promise<AgentToolResult>;
@@ -16,8 +16,6 @@ export declare class HindsightReflectTool implements AgentTool<typeof hindsightR
16
16
  context: z.ZodOptional<z.ZodString>;
17
17
  }, z.core.$strip>;
18
18
  readonly strict = true;
19
- readonly loadMode = "discoverable";
20
- readonly summary = "Reflect on recent work and write hindsight memory";
21
19
  constructor(session: ToolSession);
22
20
  static createIf(session: ToolSession): HindsightReflectTool | null;
23
21
  execute(_id: string, params: HindsightReflectParams, signal?: AbortSignal): Promise<AgentToolResult>;
@@ -20,8 +20,6 @@ export declare class HindsightRetainTool implements AgentTool<typeof hindsightRe
20
20
  }, z.core.$strip>>;
21
21
  }, z.core.$strip>;
22
22
  readonly strict = true;
23
- readonly loadMode = "discoverable";
24
- readonly summary = "Store important facts in hindsight memory";
25
23
  constructor(session: ToolSession);
26
24
  static createIf(session: ToolSession): HindsightRetainTool | null;
27
25
  execute(_id: string, params: HindsightRetainParams): Promise<AgentToolResult>;
@@ -37,9 +37,6 @@ export * from "./debug";
37
37
  export * from "./eval";
38
38
  export * from "./find";
39
39
  export * from "./gh";
40
- export * from "./hindsight-recall";
41
- export * from "./hindsight-reflect";
42
- export * from "./hindsight-retain";
43
40
  export * from "./image-gen";
44
41
  export * from "./inspect-image";
45
42
  export * from "./irc";
@@ -102,6 +99,8 @@ export interface ToolSession {
102
99
  requireYieldTool?: boolean;
103
100
  /** Task recursion depth (0 = top-level, 1 = first child, etc.) */
104
101
  taskDepth?: number;
102
+ /** Current role-agent type/name for nested task sessions. */
103
+ currentAgentType?: string;
105
104
  /** Get session file */
106
105
  getSessionFile: () => string | null;
107
106
  /** Get eval kernel owner ID for session-scoped retained-kernel cleanup. */
@@ -243,7 +242,10 @@ export declare const DEFAULT_ESSENTIAL_TOOL_NAMES: readonly string[];
243
242
  export declare function computeEssentialBuiltinNames(settings: Settings): string[];
244
243
  /**
245
244
  * Public callable factory map. External callers may invoke `BUILTIN_TOOLS.read(session)` or
246
- * `BUILTIN_TOOLS[name](session)` to construct a tool directly.
245
+ * `BUILTIN_TOOLS[name](session)` to construct a public coding-harness tool directly.
246
+ *
247
+ * Hindsight memory helpers are intentionally excluded: memory is a private backend
248
+ * integration, not a public gajae-code tool surface.
247
249
  */
248
250
  export declare const BUILTIN_TOOLS: Record<string, ToolFactory>;
249
251
  export declare const HIDDEN_TOOLS: Record<string, ToolFactory>;
@@ -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. */