@gajae-code/coding-agent 0.3.0 → 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 (175) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/types/async/job-manager.d.ts +7 -0
  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/config/keybindings.d.ts +5 -0
  6. package/dist/types/config/settings-schema.d.ts +4 -4
  7. package/dist/types/debug/crash-diagnostics.d.ts +45 -0
  8. package/dist/types/debug/runtime-gauges.d.ts +6 -0
  9. package/dist/types/deep-interview/render-middleware.d.ts +1 -0
  10. package/dist/types/eval/py/executor.d.ts +2 -0
  11. package/dist/types/eval/py/kernel.d.ts +2 -0
  12. package/dist/types/exec/bash-executor.d.ts +10 -0
  13. package/dist/types/gjc-runtime/cli-write-receipt.d.ts +24 -0
  14. package/dist/types/gjc-runtime/deep-interview-runtime.d.ts +1 -0
  15. package/dist/types/gjc-runtime/state-migrations.d.ts +9 -0
  16. package/dist/types/gjc-runtime/state-schema.d.ts +317 -0
  17. package/dist/types/gjc-runtime/state-writer.d.ts +10 -0
  18. package/dist/types/gjc-runtime/workflow-command-ref.d.ts +43 -0
  19. package/dist/types/harness-control-plane/control-endpoint.d.ts +3 -2
  20. package/dist/types/hooks/skill-state.d.ts +21 -0
  21. package/dist/types/internal-urls/agent-protocol.d.ts +2 -2
  22. package/dist/types/internal-urls/artifact-protocol.d.ts +2 -2
  23. package/dist/types/internal-urls/registry-helpers.d.ts +8 -7
  24. package/dist/types/internal-urls/types.d.ts +4 -0
  25. package/dist/types/lsp/index.d.ts +10 -10
  26. package/dist/types/modes/bridge/auth.d.ts +12 -0
  27. package/dist/types/modes/bridge/bridge-client-bridge.d.ts +9 -0
  28. package/dist/types/modes/bridge/bridge-mode.d.ts +44 -0
  29. package/dist/types/modes/bridge/bridge-ui-context.d.ts +88 -0
  30. package/dist/types/modes/bridge/event-stream.d.ts +8 -0
  31. package/dist/types/modes/components/custom-editor.d.ts +6 -0
  32. package/dist/types/modes/components/jobs-overlay-model.d.ts +31 -0
  33. package/dist/types/modes/components/jobs-overlay.d.ts +30 -0
  34. package/dist/types/modes/components/status-line/types.d.ts +2 -0
  35. package/dist/types/modes/components/status-line.d.ts +2 -0
  36. package/dist/types/modes/controllers/input-controller.d.ts +1 -0
  37. package/dist/types/modes/controllers/selector-controller.d.ts +8 -0
  38. package/dist/types/modes/index.d.ts +1 -0
  39. package/dist/types/modes/interactive-mode.d.ts +1 -0
  40. package/dist/types/modes/jobs-observer.d.ts +57 -0
  41. package/dist/types/modes/rpc/host-tools.d.ts +1 -16
  42. package/dist/types/modes/rpc/host-uris.d.ts +1 -38
  43. package/dist/types/modes/shared/agent-wire/command-dispatch.d.ts +20 -0
  44. package/dist/types/modes/shared/agent-wire/command-validation.d.ts +2 -0
  45. package/dist/types/modes/shared/agent-wire/event-envelope.d.ts +24 -0
  46. package/dist/types/modes/shared/agent-wire/handshake.d.ts +46 -0
  47. package/dist/types/modes/shared/agent-wire/host-tool-bridge.d.ts +16 -0
  48. package/dist/types/modes/shared/agent-wire/host-uri-bridge.d.ts +17 -0
  49. package/dist/types/modes/shared/agent-wire/protocol.d.ts +44 -0
  50. package/dist/types/modes/shared/agent-wire/responses.d.ts +4 -0
  51. package/dist/types/modes/shared/agent-wire/scopes.d.ts +18 -0
  52. package/dist/types/modes/shared/agent-wire/ui-request-broker.d.ts +42 -0
  53. package/dist/types/modes/shared/agent-wire/ui-result.d.ts +27 -0
  54. package/dist/types/modes/types.d.ts +1 -0
  55. package/dist/types/sdk.d.ts +2 -0
  56. package/dist/types/session/agent-session.d.ts +11 -1
  57. package/dist/types/skill-state/workflow-state-contract.d.ts +1 -2
  58. package/dist/types/skill-state/workflow-state-version.d.ts +3 -0
  59. package/dist/types/task/id.d.ts +7 -0
  60. package/dist/types/task/index.d.ts +5 -0
  61. package/dist/types/task/receipt.d.ts +85 -0
  62. package/dist/types/task/spawn-gate.d.ts +38 -0
  63. package/dist/types/task/types.d.ts +143 -11
  64. package/dist/types/tools/cron.d.ts +6 -0
  65. package/dist/types/tools/index.d.ts +2 -0
  66. package/dist/types/tools/path-utils.d.ts +1 -0
  67. package/dist/types/tools/subagent.d.ts +15 -0
  68. package/package.json +7 -7
  69. package/scripts/build-binary.ts +7 -0
  70. package/src/async/job-manager.ts +36 -0
  71. package/src/cli/args.ts +9 -2
  72. package/src/commands/deep-interview.ts +1 -0
  73. package/src/commands/harness.ts +289 -19
  74. package/src/commands/launch.ts +2 -2
  75. package/src/commands/state.ts +2 -1
  76. package/src/commands/team.ts +22 -4
  77. package/src/config/keybindings.ts +6 -0
  78. package/src/config/settings-schema.ts +6 -3
  79. package/src/dap/client.ts +17 -3
  80. package/src/debug/crash-diagnostics.ts +223 -0
  81. package/src/debug/runtime-gauges.ts +20 -0
  82. package/src/deep-interview/render-middleware.ts +6 -0
  83. package/src/defaults/gjc/skills/deep-interview/SKILL.md +1 -1
  84. package/src/defaults/gjc/skills/ralplan/SKILL.md +31 -2
  85. package/src/defaults/gjc/skills/ultragoal/SKILL.md +28 -2
  86. package/src/eval/py/executor.ts +21 -1
  87. package/src/eval/py/kernel.ts +15 -0
  88. package/src/exec/bash-executor.ts +41 -0
  89. package/src/gjc-runtime/cli-write-receipt.ts +31 -0
  90. package/src/gjc-runtime/deep-interview-runtime.ts +69 -32
  91. package/src/gjc-runtime/ralplan-runtime.ts +213 -36
  92. package/src/gjc-runtime/state-migrations.ts +54 -7
  93. package/src/gjc-runtime/state-runtime.ts +461 -64
  94. package/src/gjc-runtime/state-schema.ts +192 -0
  95. package/src/gjc-runtime/state-writer.ts +32 -1
  96. package/src/gjc-runtime/team-runtime.ts +177 -105
  97. package/src/gjc-runtime/ultragoal-runtime.ts +114 -26
  98. package/src/gjc-runtime/workflow-command-ref.ts +239 -0
  99. package/src/gjc-runtime/workflow-manifest.generated.json +108 -4
  100. package/src/gjc-runtime/workflow-manifest.ts +3 -1
  101. package/src/harness-control-plane/control-endpoint.ts +19 -8
  102. package/src/harness-control-plane/owner.ts +57 -10
  103. package/src/harness-control-plane/state-machine.ts +2 -1
  104. package/src/hooks/skill-state.ts +176 -26
  105. package/src/internal-urls/agent-protocol.ts +68 -21
  106. package/src/internal-urls/artifact-protocol.ts +12 -17
  107. package/src/internal-urls/docs-index.generated.ts +3 -2
  108. package/src/internal-urls/registry-helpers.ts +19 -16
  109. package/src/internal-urls/types.ts +4 -0
  110. package/src/lsp/client.ts +18 -2
  111. package/src/main.ts +21 -5
  112. package/src/modes/bridge/auth.ts +41 -0
  113. package/src/modes/bridge/bridge-client-bridge.ts +47 -0
  114. package/src/modes/bridge/bridge-mode.ts +520 -0
  115. package/src/modes/bridge/bridge-ui-context.ts +200 -0
  116. package/src/modes/bridge/event-stream.ts +70 -0
  117. package/src/modes/components/custom-editor.ts +101 -0
  118. package/src/modes/components/hook-selector.ts +61 -18
  119. package/src/modes/components/jobs-overlay-model.ts +109 -0
  120. package/src/modes/components/jobs-overlay.ts +172 -0
  121. package/src/modes/components/status-line/presets.ts +7 -5
  122. package/src/modes/components/status-line/segments.ts +25 -0
  123. package/src/modes/components/status-line/types.ts +2 -0
  124. package/src/modes/components/status-line.ts +9 -1
  125. package/src/modes/controllers/extension-ui-controller.ts +39 -3
  126. package/src/modes/controllers/input-controller.ts +97 -9
  127. package/src/modes/controllers/selector-controller.ts +29 -0
  128. package/src/modes/index.ts +1 -0
  129. package/src/modes/interactive-mode.ts +27 -0
  130. package/src/modes/jobs-observer.ts +204 -0
  131. package/src/modes/rpc/host-tools.ts +1 -186
  132. package/src/modes/rpc/host-uris.ts +1 -235
  133. package/src/modes/rpc/rpc-client.ts +25 -10
  134. package/src/modes/rpc/rpc-mode.ts +12 -381
  135. package/src/modes/shared/agent-wire/command-dispatch.ts +341 -0
  136. package/src/modes/shared/agent-wire/command-validation.ts +131 -0
  137. package/src/modes/shared/agent-wire/event-envelope.ts +108 -0
  138. package/src/modes/shared/agent-wire/handshake.ts +117 -0
  139. package/src/modes/shared/agent-wire/host-tool-bridge.ts +194 -0
  140. package/src/modes/shared/agent-wire/host-uri-bridge.ts +236 -0
  141. package/src/modes/shared/agent-wire/protocol.ts +96 -0
  142. package/src/modes/shared/agent-wire/responses.ts +17 -0
  143. package/src/modes/shared/agent-wire/scopes.ts +89 -0
  144. package/src/modes/shared/agent-wire/ui-request-broker.ts +150 -0
  145. package/src/modes/shared/agent-wire/ui-result.ts +48 -0
  146. package/src/modes/types.ts +1 -0
  147. package/src/prompts/tools/subagent.md +12 -7
  148. package/src/prompts/tools/task-summary.md +3 -9
  149. package/src/prompts/tools/task.md +5 -1
  150. package/src/sdk.ts +4 -0
  151. package/src/session/agent-session.ts +214 -38
  152. package/src/skill-state/deep-interview-mutation-guard.ts +23 -4
  153. package/src/skill-state/workflow-state-contract.ts +7 -4
  154. package/src/skill-state/workflow-state-version.ts +3 -0
  155. package/src/slash-commands/builtin-registry.ts +8 -0
  156. package/src/task/executor.ts +29 -5
  157. package/src/task/id.ts +33 -0
  158. package/src/task/index.ts +257 -67
  159. package/src/task/output-manager.ts +5 -4
  160. package/src/task/receipt.ts +297 -0
  161. package/src/task/render.ts +48 -131
  162. package/src/task/spawn-gate.ts +132 -0
  163. package/src/task/types.ts +48 -7
  164. package/src/tools/ask.ts +73 -33
  165. package/src/tools/ast-edit.ts +1 -0
  166. package/src/tools/ast-grep.ts +1 -0
  167. package/src/tools/bash.ts +1 -1
  168. package/src/tools/cron.ts +48 -0
  169. package/src/tools/find.ts +4 -1
  170. package/src/tools/index.ts +2 -0
  171. package/src/tools/path-utils.ts +3 -2
  172. package/src/tools/read.ts +1 -0
  173. package/src/tools/search.ts +1 -0
  174. package/src/tools/skill.ts +6 -1
  175. package/src/tools/subagent.ts +237 -84
package/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.3.1] - 2026-06-05
6
+ ### Added
7
+
8
+ - Added opt-in crash diagnostics for subprocess failures, with a shared crash taxonomy/report writer, bash/Python/LSP/DAP crash notices, and a native Rust panic-report hook gated by `GJC_NATIVE_CRASH_DIAGNOSTICS` / `GJC_CRASH_DIAGNOSTICS`.
9
+ - Started the GJC backend bridge foundation with a shared agent-wire protocol module, event envelopes, RPC command scope matrix, UI request broker, typed unsupported UI results, a guarded `--mode bridge` handshake surface, and RPC mode dispatch refactored onto the shared command dispatcher.
10
+ - Documented the experimental `--mode bridge` protocol in `docs/bridge.md` and the `GJC_BRIDGE_*` environment variables in `docs/environment-variables.md` (TLS-mandatory startup, bearer auth, coarse command scopes with a `prompt` floor, single live `AgentSession` per process, bounded event-stream replay with `reset`, and the semantic-not-pixel UI capability matrix), and added bridge event-stream/idempotency regression tests plus a docs-conformance check that pins the docs against the protocol version, scope/command catalog, negotiated capabilities/frame types, and unsupported UI surfaces. The bridge protocol/SDK are experimental (`BRIDGE_PROTOCOL_VERSION` 1) and may change in additive, version-negotiated ways.
11
+
12
+ ### Fixed
13
+
14
+ - Made opt-in crash diagnostics create/chmod report directories to `0700` and report files to `0600` so captured command, cwd, and stderr previews are private even under a permissive umask.
15
+ - Scoped `agent://` and `artifact://` resolution to the caller's artifacts directory plus explicitly authorized parent/child tree directories, removed registry-wide live-session lookup/enumeration, and made missing agent-output metadata sidecars fail closed.
16
+ - Fail-closed experimental bridge session endpoints by default for 0.3.1: events, commands, controller ownership, UI responses, host tool results, and host URI results are disabled unless an internal endpoint matrix explicitly enables them; only health/help and the authenticated handshake remain available, with the handshake advertising no enabled session surface by default.
17
+ - Render terminal-pasted clipboard image temp paths as compact `[image N]` prompt placeholders while attaching the image payload, instead of inserting raw `/var/folders/.../clipboard-*.png` path text.
18
+ - Preserved `gjc harness` `owner-vanished:*` blockers when a replacement owner becomes live so unrecovered prior-owner evidence remains visible until explicit recovery or terminal completion evidence; only safe startup liveness false-negatives such as `detached-owner-not-live` are auto-cleared.
19
+ - Fixed the interactive agent unexpectedly stopping after automatic context maintenance instead of resuming the in-flight task. Post-compaction continuation now schedules exactly one source per completion (overflow retry → queued messages → synthetic auto-continue prompt), the threshold/handoff auto-continue prompt skips a redundant pre-send compaction check, overflow retry strips only the context-overflow failed turn (never normal/aborted/silent-abort tails), and non-resumable or superseded continuations log a structured reason instead of stranding the session.
20
+ - Fixed the native Stop skill-state hook letting active GJC workflow skills stop prematurely. The Stop hook no longer treats a missing/unreadable mode-state file as terminal for handoff workflows, and handoff skills (`deep-interview`, `ralplan`) now keep blocking Stop even in the `handoff` phase until they are demoted (`active:false`) or cleared, so they always end by offering the next handoff step via the ask tool. Non-handoff skills (`team`, `ultragoal`) retain the fail-open safety valve when their mode-state file is corrupt or invalid.
21
+
5
22
  ## [0.3.0] - 2026-06-03
6
23
 
7
24
  ### Added
@@ -9,6 +26,7 @@
9
26
  - Added runtime-enforced Ultragoal executor QA/red-team evidence matrices for completion checkpoints, with plan-first contract coverage, user-surface evidence, adversarial cases, artifact references, scoped Executor red-team guidance, and focused rejection tests for shallow or contradictory QA evidence.
10
27
  ### Fixed
11
28
 
29
+ - Made `gjc harness observe` preserve completed RPC owner evidence after the owner exits, including a `completedOwnerExited` diagnostic and durable terminal-result cursor.
12
30
  - Clarified that `gjc team` requires an existing tmux-backed leader session from `gjc --tmux`, with actionable help, docs, and failure text.
13
31
  - Kept deep-interview ask options visible for long prompts by adding an opt-in scrollable selector title panel with selector-local `PageUp`/`PageDown` prompt scrolling, while leaving normal ask dialogs and global keybinding configuration unchanged.
14
32
 
@@ -26,6 +26,8 @@ export interface AsyncJobMetadata {
26
26
  description?: string;
27
27
  assignment?: string;
28
28
  };
29
+ /** True when this bash job was started by the `monitor` tool (vs plain async bash). */
30
+ monitor?: boolean;
29
31
  }
30
32
  /**
31
33
  * Typed outcome a subagent task run may produce. A `paused` outcome is
@@ -139,6 +141,11 @@ export declare class AsyncJobManager {
139
141
  /** Reset the process-global instance. Test-only. */
140
142
  static resetForTests(): void;
141
143
  constructor(options: AsyncJobManagerOptions);
144
+ /**
145
+ * Subscribe to live-job-set change events. Returns an unsubscribe function.
146
+ * Listener errors are isolated so one bad subscriber cannot break others.
147
+ */
148
+ onChange(cb: () => void): () => void;
142
149
  register(type: "bash" | "task", label: string, run: (ctx: {
143
150
  jobId: string;
144
151
  signal: AbortSignal;
@@ -2,7 +2,7 @@
2
2
  * CLI argument parsing and help display
3
3
  */
4
4
  import { type Effort } from "@gajae-code/ai";
5
- export type Mode = "text" | "json" | "rpc" | "acp" | "rpc-ui";
5
+ export type Mode = "text" | "json" | "rpc" | "acp" | "rpc-ui" | "bridge";
6
6
  export interface Args {
7
7
  cwd?: string;
8
8
  allowHome?: boolean;
@@ -39,6 +39,9 @@ export default class DeepInterview extends Command {
39
39
  deliberate: import("@gajae-code/utils/cli").FlagDescriptor<"boolean"> & {
40
40
  description: string;
41
41
  };
42
+ force: import("@gajae-code/utils/cli").FlagDescriptor<"boolean"> & {
43
+ description: string;
44
+ };
42
45
  json: import("@gajae-code/utils/cli").FlagDescriptor<"boolean"> & {
43
46
  description: string;
44
47
  };
@@ -26,6 +26,7 @@ interface AppKeybindings {
26
26
  "app.session.fork": true;
27
27
  "app.session.resume": true;
28
28
  "app.session.observe": true;
29
+ "app.jobs.open": true;
29
30
  "app.session.togglePath": true;
30
31
  "app.session.toggleSort": true;
31
32
  "app.session.rename": true;
@@ -258,6 +259,10 @@ export declare const KEYBINDINGS: {
258
259
  readonly defaultKeys: "ctrl+s";
259
260
  readonly description: "Observe subagent sessions";
260
261
  };
262
+ readonly "app.jobs.open": {
263
+ readonly defaultKeys: "alt+j";
264
+ readonly description: "Open monitor/cron jobs overlay";
265
+ };
261
266
  readonly "app.session.togglePath": {
262
267
  readonly defaultKeys: "ctrl+p";
263
268
  readonly description: "Toggle session path display";
@@ -24,7 +24,7 @@ export declare const TAB_METADATA: Record<SettingTab, {
24
24
  icon: `tab.${string}`;
25
25
  }>;
26
26
  /** Status line segment identifiers */
27
- export type StatusLineSegmentId = "gajae" | "pi" | "model" | "mode" | "path" | "git" | "pr" | "subagents" | "token_in" | "token_out" | "token_total" | "token_rate" | "cost" | "context_pct" | "context_total" | "time_spent" | "time" | "session" | "hostname" | "cache_read" | "cache_write" | "session_name" | "usage";
27
+ export type StatusLineSegmentId = "gajae" | "pi" | "model" | "mode" | "path" | "git" | "pr" | "subagents" | "jobs" | "token_in" | "token_out" | "token_total" | "token_rate" | "cost" | "context_pct" | "context_total" | "time_spent" | "time" | "session" | "hostname" | "cache_read" | "cache_write" | "session_name" | "usage";
28
28
  /** Submenu choice metadata. */
29
29
  export type SubmenuOption<V extends string = string> = {
30
30
  value: V;
@@ -2697,11 +2697,11 @@ export declare const SETTINGS_SCHEMA: {
2697
2697
  };
2698
2698
  readonly "task.maxConcurrency": {
2699
2699
  readonly type: "number";
2700
- readonly default: 32;
2700
+ readonly default: 8;
2701
2701
  readonly ui: {
2702
2702
  readonly tab: "tasks";
2703
2703
  readonly label: "Max Concurrent Tasks";
2704
- readonly description: "Concurrent limit for subagents";
2704
+ readonly description: "Safer concurrent limit for subagents; higher fan-out still requires an explicit plan above 4 tasks.";
2705
2705
  readonly options: readonly [{
2706
2706
  readonly value: "0";
2707
2707
  readonly label: "Unlimited";
@@ -2762,7 +2762,7 @@ export declare const SETTINGS_SCHEMA: {
2762
2762
  readonly ui: {
2763
2763
  readonly tab: "tasks";
2764
2764
  readonly label: "Fork Context Max Tokens";
2765
- readonly description: "Approximate token cap for fork-context seeds. 0 uses 25% of the target model context window.";
2765
+ readonly description: "Approximate token cap for explicit full fork-context seeds. 0 uses 15% of the target model context window, with a 15k fallback when the window is unknown.";
2766
2766
  };
2767
2767
  };
2768
2768
  readonly "task.maxRecursionDepth": {
@@ -0,0 +1,45 @@
1
+ export type CrashProcessKind = "bash" | "python" | "lsp" | "dap" | "mcp" | "browser" | "worker" | "native" | "unknown";
2
+ export type CrashClass = "clean_exit" | "non_zero_exit" | "signal_exit" | "timeout" | "cancelled" | "spawn_error" | "protocol_exit" | "native_panic" | "unknown";
3
+ export interface CrashClassificationInput {
4
+ kind: CrashProcessKind;
5
+ command?: string[];
6
+ exitCode?: number | null;
7
+ signal?: string | null;
8
+ cancelled?: boolean;
9
+ timedOut?: boolean;
10
+ spawnError?: unknown;
11
+ stderr?: string;
12
+ protocol?: string;
13
+ }
14
+ export interface CrashClassification {
15
+ kind: CrashProcessKind;
16
+ class: CrashClass;
17
+ crashed: boolean;
18
+ exitCode: number | null;
19
+ signal: string | null;
20
+ command?: string[];
21
+ protocol?: string;
22
+ reason: string;
23
+ }
24
+ export interface CrashReport extends CrashClassification {
25
+ schemaVersion: 1;
26
+ createdAt: string;
27
+ pid: number;
28
+ cwd: string;
29
+ stderrPreview?: string;
30
+ spawnError?: string;
31
+ }
32
+ export interface CrashReportWriteResult {
33
+ report: CrashReport;
34
+ path: string | null;
35
+ enabled: boolean;
36
+ }
37
+ export declare function crashDiagnosticsEnabled(env?: NodeJS.ProcessEnv): boolean;
38
+ export declare function getCrashDiagnosticsDirectory(env?: NodeJS.ProcessEnv): string;
39
+ export declare function classifyProcessCrash(input: CrashClassificationInput): CrashClassification;
40
+ export declare function writeCrashReport(input: CrashClassificationInput, options?: {
41
+ cwd?: string;
42
+ env?: NodeJS.ProcessEnv;
43
+ now?: Date;
44
+ }): Promise<CrashReportWriteResult>;
45
+ export declare function formatCrashDiagnosticNotice(result: CrashReportWriteResult): string | null;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Current runtime owner counts, keyed by `<owner>.<resource>`. Extend as more
3
+ * owners (Python kernels, LSP clients, browser tabs, async jobs, streaming
4
+ * queues) expose count getters.
5
+ */
6
+ export declare function getRuntimeResourceCounts(): Record<string, number>;
@@ -2,4 +2,5 @@ import { type Component } from "@gajae-code/tui";
2
2
  import { type Theme } from "../modes/theme/theme";
3
3
  export declare function renderDeepInterviewAssistantText(text: string, uiTheme: Theme): Component | null;
4
4
  export declare function renderDeepInterviewAskQuestion(question: string, uiTheme: Theme): Component | null;
5
+ export declare function isDeepInterviewAskQuestion(question: string): boolean;
5
6
  export declare function formatDeepInterviewSelectorPrompt(question: string): string | null;
@@ -52,6 +52,8 @@ export interface PythonExecutorOptions {
52
52
  }
53
53
  export interface PythonKernelExecutor {
54
54
  execute: (code: string, options?: KernelExecuteOptions) => Promise<KernelExecuteResult>;
55
+ getExitCode?: () => number | null;
56
+ peekStderr?: () => string;
55
57
  }
56
58
  export interface PythonResult {
57
59
  /** Combined stdout + stderr output (sanitized, possibly truncated) */
@@ -55,6 +55,8 @@ export declare class PythonKernel {
55
55
  private constructor();
56
56
  static start(options: KernelStartOptions): Promise<PythonKernel>;
57
57
  isAlive(): boolean;
58
+ getExitCode(): number | null;
59
+ peekStderr(): string;
58
60
  execute(code: string, options?: KernelExecuteOptions): Promise<KernelExecuteResult>;
59
61
  interrupt(): Promise<void>;
60
62
  shutdown(options?: KernelShutdownOptions): Promise<KernelShutdownResult>;
@@ -43,6 +43,16 @@ export interface BashResult {
43
43
  outputBytes: number;
44
44
  artifactId?: string;
45
45
  }
46
+ /** Number of persistent shell sessions currently retained (owner gauge). */
47
+ export declare function getShellSessionCount(): number;
48
+ /**
49
+ * Dispose all persistent shell sessions: abort in-flight work and drop the
50
+ * strong references so the native shells can be finalized. Healthy persistent
51
+ * sessions are otherwise retained for the whole process lifetime (MEM-7). This
52
+ * is registered as a postmortem cleanup so shutdown/signals release native
53
+ * shell resources, and is also callable directly (e.g. on owner teardown).
54
+ */
55
+ export declare function disposeAllShellSessions(): Promise<void>;
46
56
  /** Translate `ShellMinimizerSettings` into native `MinimizerOptions`, or `undefined` when disabled. */
47
57
  export declare function buildMinimizerOptions(group: ShellMinimizerSettings): MinimizerOptions | undefined;
48
58
  export declare function executeBash(command: string, options?: BashExecutorOptions): Promise<BashResult>;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * CLI write/mutation receipt shaping (Workstream B, v4).
3
+ *
4
+ * `CliWriteReceipt` is the compact **stdout presentation** returned by a GJC
5
+ * mutation command. It carries only routing/audit fields a caller needs; it
6
+ * NEVER echoes the persisted body (full `state` envelope, ultragoal `plan`,
7
+ * team task body, ralplan `task`, etc.) — echoing those back is a redundant
8
+ * token leak because the caller already has the content it just wrote.
9
+ *
10
+ * This is intentionally a *separate* concept from the persisted
11
+ * `WorkflowStateReceipt` (the on-disk envelope `receipt` integrity field).
12
+ * Do NOT use `CliWriteReceipt` as a persistence schema or validate persisted
13
+ * envelopes against it.
14
+ */
15
+ export interface CliWriteReceipt {
16
+ ok: boolean;
17
+ [field: string]: unknown;
18
+ }
19
+ /**
20
+ * Serialize a write/mutation receipt to compact stdout JSON.
21
+ * `undefined` fields are dropped so optional routing fields stay absent
22
+ * rather than serialized as `null`.
23
+ */
24
+ export declare function renderCliWriteReceipt(receipt: Record<string, unknown>): string;
@@ -20,6 +20,7 @@ export interface ResolvedDeepInterviewSpecWriteArgs {
20
20
  json: boolean;
21
21
  deliberate: boolean;
22
22
  handoff?: "ralplan";
23
+ force: boolean;
23
24
  }
24
25
  export interface PersistedDeepInterviewSpec {
25
26
  slug: string;
@@ -1,3 +1,4 @@
1
+ import type { CanonicalGjcWorkflowSkill } from "../skill-state/active-state";
1
2
  export interface NormalizeLegacyStateResult {
2
3
  state: Record<string, unknown>;
3
4
  changed: boolean;
@@ -12,6 +13,14 @@ export interface MigrateAndPersistLegacyStateResult {
12
13
  migrated: boolean;
13
14
  path: string;
14
15
  }
16
+ export interface MigrateWorkflowStateResult {
17
+ state: Record<string, unknown>;
18
+ fromVersion: number;
19
+ toVersion: number;
20
+ changed: boolean;
21
+ }
22
+ export type WorkflowStateMigration = (state: Record<string, unknown>, skill: CanonicalGjcWorkflowSkill) => Record<string, unknown>;
23
+ export declare function migrateWorkflowState(raw: Record<string, unknown>, skill: string): MigrateWorkflowStateResult;
15
24
  /**
16
25
  * Pure legacy state normalizer for background/internal readers.
17
26
  *
@@ -0,0 +1,317 @@
1
+ import { z } from "zod";
2
+ export declare const WorkflowStateContentChecksumSchema: z.ZodObject<{
3
+ algorithm: z.ZodLiteral<"sha256">;
4
+ value: z.ZodString;
5
+ covered_path: z.ZodString;
6
+ computed_at: z.ZodString;
7
+ }, z.core.$loose>;
8
+ /** Lenient receipt schema for reads (mirrors WorkflowStateReceipt). */
9
+ export declare const WorkflowStateReceiptSchema: z.ZodObject<{
10
+ version: z.ZodNumber;
11
+ skill: z.ZodEnum<{
12
+ "deep-interview": "deep-interview";
13
+ ralplan: "ralplan";
14
+ team: "team";
15
+ ultragoal: "ultragoal";
16
+ }>;
17
+ owner: z.ZodEnum<{
18
+ "gjc-hook": "gjc-hook";
19
+ "gjc-runtime": "gjc-runtime";
20
+ "gjc-state-cli": "gjc-state-cli";
21
+ }>;
22
+ command: z.ZodString;
23
+ state_path: z.ZodString;
24
+ storage_path: z.ZodString;
25
+ mutated_at: z.ZodString;
26
+ fresh_until: z.ZodString;
27
+ status: z.ZodEnum<{
28
+ fresh: "fresh";
29
+ stale: "stale";
30
+ }>;
31
+ mutation_id: z.ZodString;
32
+ verb: z.ZodOptional<z.ZodString>;
33
+ from_phase: z.ZodOptional<z.ZodString>;
34
+ to_phase: z.ZodOptional<z.ZodString>;
35
+ forced: z.ZodOptional<z.ZodBoolean>;
36
+ paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
37
+ content_sha256: z.ZodOptional<z.ZodObject<{
38
+ algorithm: z.ZodLiteral<"sha256">;
39
+ value: z.ZodString;
40
+ covered_path: z.ZodString;
41
+ computed_at: z.ZodString;
42
+ }, z.core.$loose>>;
43
+ }, z.core.$loose>;
44
+ /** Lenient envelope schema for reads. Every non-structural field optional. */
45
+ export declare const WorkflowStateEnvelopeSchema: z.ZodObject<{
46
+ skill: z.ZodOptional<z.ZodString>;
47
+ active: z.ZodOptional<z.ZodBoolean>;
48
+ current_phase: z.ZodOptional<z.ZodString>;
49
+ version: z.ZodOptional<z.ZodNumber>;
50
+ updated_at: z.ZodOptional<z.ZodString>;
51
+ session_id: z.ZodOptional<z.ZodString>;
52
+ receipt: z.ZodOptional<z.ZodObject<{
53
+ version: z.ZodNumber;
54
+ skill: z.ZodEnum<{
55
+ "deep-interview": "deep-interview";
56
+ ralplan: "ralplan";
57
+ team: "team";
58
+ ultragoal: "ultragoal";
59
+ }>;
60
+ owner: z.ZodEnum<{
61
+ "gjc-hook": "gjc-hook";
62
+ "gjc-runtime": "gjc-runtime";
63
+ "gjc-state-cli": "gjc-state-cli";
64
+ }>;
65
+ command: z.ZodString;
66
+ state_path: z.ZodString;
67
+ storage_path: z.ZodString;
68
+ mutated_at: z.ZodString;
69
+ fresh_until: z.ZodString;
70
+ status: z.ZodEnum<{
71
+ fresh: "fresh";
72
+ stale: "stale";
73
+ }>;
74
+ mutation_id: z.ZodString;
75
+ verb: z.ZodOptional<z.ZodString>;
76
+ from_phase: z.ZodOptional<z.ZodString>;
77
+ to_phase: z.ZodOptional<z.ZodString>;
78
+ forced: z.ZodOptional<z.ZodBoolean>;
79
+ paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
80
+ content_sha256: z.ZodOptional<z.ZodObject<{
81
+ algorithm: z.ZodLiteral<"sha256">;
82
+ value: z.ZodString;
83
+ covered_path: z.ZodString;
84
+ computed_at: z.ZodString;
85
+ }, z.core.$loose>>;
86
+ }, z.core.$loose>>;
87
+ }, z.core.$loose>;
88
+ /**
89
+ * Strict receipt required on WRITE (post checksum-stamping). Anchored to the
90
+ * fields the sanctioned writer emits — `content_sha256` is REQUIRED here.
91
+ */
92
+ export declare const RequiredWorkflowStateReceiptSchema: z.ZodObject<{
93
+ version: z.ZodNumber;
94
+ skill: z.ZodEnum<{
95
+ "deep-interview": "deep-interview";
96
+ ralplan: "ralplan";
97
+ team: "team";
98
+ ultragoal: "ultragoal";
99
+ }>;
100
+ owner: z.ZodEnum<{
101
+ "gjc-hook": "gjc-hook";
102
+ "gjc-runtime": "gjc-runtime";
103
+ "gjc-state-cli": "gjc-state-cli";
104
+ }>;
105
+ command: z.ZodString;
106
+ state_path: z.ZodString;
107
+ storage_path: z.ZodString;
108
+ mutated_at: z.ZodString;
109
+ fresh_until: z.ZodString;
110
+ status: z.ZodEnum<{
111
+ fresh: "fresh";
112
+ stale: "stale";
113
+ }>;
114
+ mutation_id: z.ZodString;
115
+ content_sha256: z.ZodObject<{
116
+ algorithm: z.ZodLiteral<"sha256">;
117
+ value: z.ZodString;
118
+ covered_path: z.ZodString;
119
+ computed_at: z.ZodString;
120
+ }, z.core.$loose>;
121
+ }, z.core.$loose>;
122
+ /**
123
+ * Write-side fail-closed gate: the serialized on-disk envelope must satisfy
124
+ * this after checksum stamping. Anchored to current sanctioned-writer output.
125
+ */
126
+ export declare const RequiredOnWriteEnvelopeSchema: z.ZodObject<{
127
+ skill: z.ZodEnum<{
128
+ "deep-interview": "deep-interview";
129
+ ralplan: "ralplan";
130
+ team: "team";
131
+ ultragoal: "ultragoal";
132
+ }>;
133
+ version: z.ZodLiteral<2>;
134
+ updated_at: z.ZodString;
135
+ current_phase: z.ZodString;
136
+ active: z.ZodBoolean;
137
+ receipt: z.ZodObject<{
138
+ version: z.ZodNumber;
139
+ skill: z.ZodEnum<{
140
+ "deep-interview": "deep-interview";
141
+ ralplan: "ralplan";
142
+ team: "team";
143
+ ultragoal: "ultragoal";
144
+ }>;
145
+ owner: z.ZodEnum<{
146
+ "gjc-hook": "gjc-hook";
147
+ "gjc-runtime": "gjc-runtime";
148
+ "gjc-state-cli": "gjc-state-cli";
149
+ }>;
150
+ command: z.ZodString;
151
+ state_path: z.ZodString;
152
+ storage_path: z.ZodString;
153
+ mutated_at: z.ZodString;
154
+ fresh_until: z.ZodString;
155
+ status: z.ZodEnum<{
156
+ fresh: "fresh";
157
+ stale: "stale";
158
+ }>;
159
+ mutation_id: z.ZodString;
160
+ content_sha256: z.ZodObject<{
161
+ algorithm: z.ZodLiteral<"sha256">;
162
+ value: z.ZodString;
163
+ covered_path: z.ZodString;
164
+ computed_at: z.ZodString;
165
+ }, z.core.$loose>;
166
+ }, z.core.$loose>;
167
+ }, z.core.$loose>;
168
+ /** Per-skill mode state consumed by hooks / the mutation guard. */
169
+ export declare const ModeStateSchema: z.ZodObject<{
170
+ active: z.ZodOptional<z.ZodBoolean>;
171
+ current_phase: z.ZodOptional<z.ZodString>;
172
+ skill: z.ZodOptional<z.ZodString>;
173
+ session_id: z.ZodOptional<z.ZodString>;
174
+ thread_id: z.ZodOptional<z.ZodString>;
175
+ cwd: z.ZodOptional<z.ZodString>;
176
+ updated_at: z.ZodOptional<z.ZodString>;
177
+ handoff_from: z.ZodOptional<z.ZodString>;
178
+ handoff_to: z.ZodOptional<z.ZodString>;
179
+ handoff_at: z.ZodOptional<z.ZodString>;
180
+ }, z.core.$loose>;
181
+ export declare const SkillActiveEntrySchema: z.ZodObject<{
182
+ skill: z.ZodString;
183
+ phase: z.ZodOptional<z.ZodString>;
184
+ active: z.ZodOptional<z.ZodBoolean>;
185
+ activated_at: z.ZodOptional<z.ZodString>;
186
+ updated_at: z.ZodOptional<z.ZodString>;
187
+ session_id: z.ZodOptional<z.ZodString>;
188
+ thread_id: z.ZodOptional<z.ZodString>;
189
+ turn_id: z.ZodOptional<z.ZodString>;
190
+ stale: z.ZodOptional<z.ZodBoolean>;
191
+ handoff_from: z.ZodOptional<z.ZodString>;
192
+ handoff_to: z.ZodOptional<z.ZodString>;
193
+ handoff_at: z.ZodOptional<z.ZodString>;
194
+ receipt: z.ZodOptional<z.ZodObject<{
195
+ version: z.ZodNumber;
196
+ skill: z.ZodEnum<{
197
+ "deep-interview": "deep-interview";
198
+ ralplan: "ralplan";
199
+ team: "team";
200
+ ultragoal: "ultragoal";
201
+ }>;
202
+ owner: z.ZodEnum<{
203
+ "gjc-hook": "gjc-hook";
204
+ "gjc-runtime": "gjc-runtime";
205
+ "gjc-state-cli": "gjc-state-cli";
206
+ }>;
207
+ command: z.ZodString;
208
+ state_path: z.ZodString;
209
+ storage_path: z.ZodString;
210
+ mutated_at: z.ZodString;
211
+ fresh_until: z.ZodString;
212
+ status: z.ZodEnum<{
213
+ fresh: "fresh";
214
+ stale: "stale";
215
+ }>;
216
+ mutation_id: z.ZodString;
217
+ verb: z.ZodOptional<z.ZodString>;
218
+ from_phase: z.ZodOptional<z.ZodString>;
219
+ to_phase: z.ZodOptional<z.ZodString>;
220
+ forced: z.ZodOptional<z.ZodBoolean>;
221
+ paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
222
+ content_sha256: z.ZodOptional<z.ZodObject<{
223
+ algorithm: z.ZodLiteral<"sha256">;
224
+ value: z.ZodString;
225
+ covered_path: z.ZodString;
226
+ computed_at: z.ZodString;
227
+ }, z.core.$loose>>;
228
+ }, z.core.$loose>>;
229
+ }, z.core.$loose>;
230
+ export declare const SkillActiveStateSchema: z.ZodObject<{
231
+ version: z.ZodOptional<z.ZodNumber>;
232
+ active: z.ZodOptional<z.ZodBoolean>;
233
+ skill: z.ZodOptional<z.ZodString>;
234
+ keyword: z.ZodOptional<z.ZodString>;
235
+ phase: z.ZodOptional<z.ZodString>;
236
+ activated_at: z.ZodOptional<z.ZodString>;
237
+ updated_at: z.ZodOptional<z.ZodString>;
238
+ source: z.ZodOptional<z.ZodString>;
239
+ session_id: z.ZodOptional<z.ZodString>;
240
+ thread_id: z.ZodOptional<z.ZodString>;
241
+ turn_id: z.ZodOptional<z.ZodString>;
242
+ active_skills: z.ZodOptional<z.ZodArray<z.ZodObject<{
243
+ skill: z.ZodString;
244
+ phase: z.ZodOptional<z.ZodString>;
245
+ active: z.ZodOptional<z.ZodBoolean>;
246
+ activated_at: z.ZodOptional<z.ZodString>;
247
+ updated_at: z.ZodOptional<z.ZodString>;
248
+ session_id: z.ZodOptional<z.ZodString>;
249
+ thread_id: z.ZodOptional<z.ZodString>;
250
+ turn_id: z.ZodOptional<z.ZodString>;
251
+ stale: z.ZodOptional<z.ZodBoolean>;
252
+ handoff_from: z.ZodOptional<z.ZodString>;
253
+ handoff_to: z.ZodOptional<z.ZodString>;
254
+ handoff_at: z.ZodOptional<z.ZodString>;
255
+ receipt: z.ZodOptional<z.ZodObject<{
256
+ version: z.ZodNumber;
257
+ skill: z.ZodEnum<{
258
+ "deep-interview": "deep-interview";
259
+ ralplan: "ralplan";
260
+ team: "team";
261
+ ultragoal: "ultragoal";
262
+ }>;
263
+ owner: z.ZodEnum<{
264
+ "gjc-hook": "gjc-hook";
265
+ "gjc-runtime": "gjc-runtime";
266
+ "gjc-state-cli": "gjc-state-cli";
267
+ }>;
268
+ command: z.ZodString;
269
+ state_path: z.ZodString;
270
+ storage_path: z.ZodString;
271
+ mutated_at: z.ZodString;
272
+ fresh_until: z.ZodString;
273
+ status: z.ZodEnum<{
274
+ fresh: "fresh";
275
+ stale: "stale";
276
+ }>;
277
+ mutation_id: z.ZodString;
278
+ verb: z.ZodOptional<z.ZodString>;
279
+ from_phase: z.ZodOptional<z.ZodString>;
280
+ to_phase: z.ZodOptional<z.ZodString>;
281
+ forced: z.ZodOptional<z.ZodBoolean>;
282
+ paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
283
+ content_sha256: z.ZodOptional<z.ZodObject<{
284
+ algorithm: z.ZodLiteral<"sha256">;
285
+ value: z.ZodString;
286
+ covered_path: z.ZodString;
287
+ computed_at: z.ZodString;
288
+ }, z.core.$loose>>;
289
+ }, z.core.$loose>>;
290
+ }, z.core.$loose>>>;
291
+ }, z.core.$loose>;
292
+ export type WorkflowStateEnvelope = z.infer<typeof WorkflowStateEnvelopeSchema>;
293
+ export type RequiredOnWriteEnvelope = z.infer<typeof RequiredOnWriteEnvelopeSchema>;
294
+ export type ModeStateParsed = z.infer<typeof ModeStateSchema>;
295
+ export type SkillActiveStateParsed = z.infer<typeof SkillActiveStateSchema>;
296
+ /**
297
+ * Validated read result.
298
+ * - `null` → file absent (ENOENT); callers treat as no state.
299
+ * - `{ok:true}` → parsed + schema-valid.
300
+ * - `{ok:false}` → present but unparseable or schema-invalid. Callers fail
301
+ * OPEN (normalize/log), never crash — preserving v2 reads.
302
+ */
303
+ export type ReadGjcJsonResult<T> = {
304
+ ok: true;
305
+ value: T;
306
+ raw: unknown;
307
+ } | {
308
+ ok: false;
309
+ error: string;
310
+ raw: unknown;
311
+ };
312
+ /**
313
+ * Parse + schema-validate a `.gjc` JSON file at the read boundary.
314
+ * Returns `null` when the file is absent. Fail-open: an invalid file yields
315
+ * `{ ok: false }` with the raw value attached so the caller can normalize/log.
316
+ */
317
+ export declare function readGjcJson<T>(filePath: string, schema: z.ZodType<T>): Promise<ReadGjcJsonResult<T> | null>;
@@ -93,6 +93,16 @@ export declare class AlreadyExistsError extends Error {
93
93
  readonly path: string;
94
94
  constructor(path: string);
95
95
  }
96
+ export type StrictMutationReadResult = {
97
+ kind: "absent";
98
+ } | {
99
+ kind: "corrupt";
100
+ error: string;
101
+ } | {
102
+ kind: "valid";
103
+ value: Record<string, unknown>;
104
+ };
105
+ export declare function readExistingStateForMutation(filePath: string): Promise<StrictMutationReadResult>;
96
106
  export declare function workflowEnvelopeContentSha256(value: unknown): string;
97
107
  export declare function stampWorkflowEnvelopeChecksum<T>(value: T, filePath: string, computedAt?: string): T;
98
108
  export declare function detectWorkflowEnvelopeIntegrityMismatch(filePath: string): Promise<WorkflowEnvelopeIntegrityMismatch | undefined>;
@@ -0,0 +1,43 @@
1
+ import type { CanonicalGjcWorkflowSkill } from "../skill-state/active-state";
2
+ export type CommandRefVisibility = "public" | "hidden" | "planned";
3
+ export type CommandRefIncludeWhen = "implemented-only" | "planned";
4
+ export interface CommandRefCommand {
5
+ tokens: string[];
6
+ rendered: string;
7
+ visibility: CommandRefVisibility;
8
+ includeWhen: CommandRefIncludeWhen;
9
+ note?: string;
10
+ }
11
+ export interface CommandRefExample {
12
+ label?: string;
13
+ bytes: string;
14
+ }
15
+ export interface CommandRefBridge {
16
+ from: string;
17
+ to: string;
18
+ rendered: string;
19
+ }
20
+ export interface CommandRefBlock {
21
+ skill: CanonicalGjcWorkflowSkill;
22
+ blockId: string;
23
+ sourcePath: string;
24
+ renderOrder: number;
25
+ markers: {
26
+ start: string;
27
+ end: string;
28
+ };
29
+ commands: CommandRefCommand[];
30
+ examples: CommandRefExample[];
31
+ aliasesAndBridges: CommandRefBridge[];
32
+ notes: string[];
33
+ }
34
+ export interface RenderedCommandRefBlock {
35
+ skill: CanonicalGjcWorkflowSkill;
36
+ blockId: string;
37
+ markers: CommandRefBlock["markers"];
38
+ bytes: string;
39
+ }
40
+ export declare const WORKFLOW_COMMAND_REF_BLOCKS: readonly CommandRefBlock[];
41
+ export declare function listCommandRefBlocks(skill?: CanonicalGjcWorkflowSkill): CommandRefBlock[];
42
+ export declare function renderCommandRefBlock(skill: CanonicalGjcWorkflowSkill, blockId?: string): RenderedCommandRefBlock;
43
+ export declare function isCanonicalGjcWorkflowSkill(value: string): value is CanonicalGjcWorkflowSkill;