@gajae-code/coding-agent 0.12.0 → 0.12.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 (247) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/dist/types/async/job-manager.d.ts +17 -3
  3. package/dist/types/config/settings-schema.d.ts +56 -2
  4. package/dist/types/exa/mcp-client.d.ts +10 -1
  5. package/dist/types/exec/bash-executor.d.ts +45 -12
  6. package/dist/types/extensibility/extensions/types.d.ts +16 -2
  7. package/dist/types/extensibility/gjc-plugins/index.d.ts +12 -2
  8. package/dist/types/extensibility/gjc-plugins/installer.d.ts +63 -7
  9. package/dist/types/extensibility/gjc-plugins/lifecycle-reconciliation.d.ts +55 -0
  10. package/dist/types/extensibility/gjc-plugins/lifecycle.d.ts +64 -0
  11. package/dist/types/extensibility/gjc-plugins/runtime-quarantine.d.ts +67 -0
  12. package/dist/types/extensibility/gjc-plugins/session-validation.d.ts +3 -1
  13. package/dist/types/extensibility/gjc-plugins/types.d.ts +124 -0
  14. package/dist/types/gjc-runtime/launch-tmux.d.ts +1 -0
  15. package/dist/types/gjc-runtime/ralplan-review-conflicts.d.ts +114 -0
  16. package/dist/types/gjc-runtime/ralplan-runtime.d.ts +23 -3
  17. package/dist/types/gjc-runtime/team-launch.d.ts +1 -1
  18. package/dist/types/gjc-runtime/team-runtime.d.ts +25 -0
  19. package/dist/types/gjc-runtime/team-worker-heartbeat.d.ts +43 -0
  20. package/dist/types/gjc-runtime/tmux-owner-isolation.d.ts +10 -0
  21. package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +37 -80
  22. package/dist/types/modes/acp/acp-agent.d.ts +2 -19
  23. package/dist/types/modes/components/gjc-bundle-settings.d.ts +34 -0
  24. package/dist/types/modes/components/irc-sidebar.d.ts +16 -0
  25. package/dist/types/modes/components/notifications-settings-editor.d.ts +1 -0
  26. package/dist/types/modes/components/session-observer-overlay.d.ts +18 -0
  27. package/dist/types/modes/components/settings-selector.d.ts +9 -0
  28. package/dist/types/modes/components/status-line/gh.d.ts +5 -0
  29. package/dist/types/modes/components/transcript-viewer-overlay.d.ts +18 -1
  30. package/dist/types/modes/controllers/command-controller.d.ts +1 -1
  31. package/dist/types/modes/controllers/event-controller.d.ts +1 -1
  32. package/dist/types/modes/controllers/extension-ui-controller.d.ts +2 -1
  33. package/dist/types/modes/controllers/selector-controller.d.ts +1 -1
  34. package/dist/types/modes/interactive-mode.d.ts +9 -0
  35. package/dist/types/modes/theme/theme.d.ts +3 -1
  36. package/dist/types/modes/types.d.ts +32 -0
  37. package/dist/types/reminders/star-reminder.d.ts +3 -13
  38. package/dist/types/runtime-mcp/manager.d.ts +1 -0
  39. package/dist/types/sdk/acp/adapter.d.ts +3 -1
  40. package/dist/types/sdk/broker/transport.d.ts +2 -0
  41. package/dist/types/sdk/bus/attachment-registry.d.ts +1 -0
  42. package/dist/types/sdk/bus/chat-daemon-control.d.ts +5 -1
  43. package/dist/types/sdk/bus/config.d.ts +6 -2
  44. package/dist/types/sdk/bus/index.d.ts +29 -0
  45. package/dist/types/sdk/bus/kind-aware-reconciliation.d.ts +8 -1
  46. package/dist/types/sdk/bus/lifecycle-control-runtime.d.ts +4 -0
  47. package/dist/types/sdk/bus/reconciliation-store.d.ts +7 -3
  48. package/dist/types/sdk/bus/rich-draft.d.ts +1 -0
  49. package/dist/types/sdk/bus/rich-render.d.ts +2 -0
  50. package/dist/types/sdk/bus/telegram-adoption-intent.d.ts +165 -0
  51. package/dist/types/sdk/bus/telegram-cli.d.ts +12 -0
  52. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +12 -4
  53. package/dist/types/sdk/bus/telegram-daemon.d.ts +25 -1
  54. package/dist/types/sdk/bus/telegram-reference.d.ts +11 -1
  55. package/dist/types/sdk/bus/threaded-render.d.ts +3 -2
  56. package/dist/types/sdk/bus/topic-registry.d.ts +11 -1
  57. package/dist/types/sdk/host/query/revision-store.d.ts +2 -0
  58. package/dist/types/sdk/host/reverse-leases.d.ts +1 -1
  59. package/dist/types/sdk/prompt-status.d.ts +23 -3
  60. package/dist/types/sdk/session.d.ts +6 -0
  61. package/dist/types/session/agent-session.d.ts +40 -2
  62. package/dist/types/session/artifacts.d.ts +8 -0
  63. package/dist/types/session/blob-store.d.ts +57 -4
  64. package/dist/types/session/internal/managed-session-storage.d.ts +30 -4
  65. package/dist/types/session/session-manager.d.ts +23 -6
  66. package/dist/types/session/session-storage.d.ts +4 -0
  67. package/dist/types/session/streaming-output.d.ts +36 -7
  68. package/dist/types/setup/credential-import.d.ts +12 -0
  69. package/dist/types/skill-state/active-state.d.ts +12 -0
  70. package/dist/types/skill-state/workflow-hud.d.ts +6 -0
  71. package/dist/types/task/executor.d.ts +3 -2
  72. package/dist/types/task/index.d.ts +7 -1
  73. package/dist/types/task/output-manager.d.ts +1 -0
  74. package/dist/types/task/provider-retry-status.d.ts +8 -0
  75. package/dist/types/task/receipt.d.ts +9 -1
  76. package/dist/types/task/types.d.ts +23 -0
  77. package/dist/types/tools/ask-answer-registry.d.ts +2 -2
  78. package/dist/types/tools/bash-interactive.d.ts +4 -1
  79. package/dist/types/tools/bash.d.ts +3 -1
  80. package/dist/types/tools/image-gen.d.ts +4 -0
  81. package/dist/types/tools/index.d.ts +6 -0
  82. package/dist/types/tools/output-meta.d.ts +23 -2
  83. package/dist/types/tools/path-utils.d.ts +1 -0
  84. package/dist/types/tools/read.d.ts +0 -6
  85. package/dist/types/tools/review.d.ts +5 -7
  86. package/dist/types/tools/subagent.d.ts +2 -0
  87. package/dist/types/utils/gh.d.ts +13 -0
  88. package/dist/types/utils/image-resize.d.ts +1 -0
  89. package/dist/types/web/search/providers/kimi.d.ts +2 -0
  90. package/dist/types/web/search/providers/searxng.d.ts +7 -0
  91. package/dist/types/web/search/providers/xai.d.ts +2 -0
  92. package/package.json +10 -8
  93. package/scripts/acp-conformance-agent.ts +218 -0
  94. package/scripts/capture-gjc-bundle-settings.ts +306 -0
  95. package/scripts/dogfood-ralplan-review-conflicts.ts +272 -0
  96. package/scripts/generate-sdk-operation-inventory.ts +5 -0
  97. package/scripts/resident-memory-bench.ts +1341 -0
  98. package/scripts/run-acp-conformance.ts +290 -0
  99. package/src/async/job-manager.ts +99 -39
  100. package/src/cli/fast-help.ts +1 -1
  101. package/src/cli/plugin-cli.ts +176 -18
  102. package/src/commands/team.ts +19 -1
  103. package/src/config/file-lock.ts +11 -2
  104. package/src/config/settings-schema.ts +53 -2
  105. package/src/coordinator-mcp/question-gate-codec.ts +1 -1
  106. package/src/coordinator-mcp/server.ts +5 -12
  107. package/src/debug/index.ts +42 -17
  108. package/src/defaults/gjc/skills/deep-interview/SKILL.md +1 -0
  109. package/src/defaults/gjc/skills/ralplan/SKILL.md +25 -20
  110. package/src/defaults/gjc/skills/team/SKILL.md +2 -0
  111. package/src/defaults/gjc/skills/ultragoal/SKILL.md +39 -26
  112. package/src/defaults/gjc/skills/ultragoal/validation-batch-contracts.md +12 -0
  113. package/src/defaults/gjc-defaults.ts +4 -4
  114. package/src/exa/mcp-client.ts +12 -3
  115. package/src/exec/bash-executor.ts +144 -27
  116. package/src/extensibility/extensions/runner.ts +15 -0
  117. package/src/extensibility/extensions/types.ts +18 -1
  118. package/src/extensibility/gjc-plugins/constrained-hooks.ts +8 -2
  119. package/src/extensibility/gjc-plugins/index.ts +19 -2
  120. package/src/extensibility/gjc-plugins/installer.ts +189 -50
  121. package/src/extensibility/gjc-plugins/lifecycle-reconciliation.ts +199 -0
  122. package/src/extensibility/gjc-plugins/lifecycle.ts +626 -0
  123. package/src/extensibility/gjc-plugins/observability.ts +3 -3
  124. package/src/extensibility/gjc-plugins/prompt-appendix.ts +5 -1
  125. package/src/extensibility/gjc-plugins/runtime-adapters.ts +12 -2
  126. package/src/extensibility/gjc-plugins/runtime-quarantine.ts +121 -0
  127. package/src/extensibility/gjc-plugins/schema.ts +84 -12
  128. package/src/extensibility/gjc-plugins/session-validation.ts +9 -3
  129. package/src/extensibility/gjc-plugins/types.ts +141 -0
  130. package/src/extensibility/gjc-plugins/validation.ts +9 -0
  131. package/src/gjc-runtime/launch-tmux.ts +25 -6
  132. package/src/gjc-runtime/launch-worktree.ts +103 -1
  133. package/src/gjc-runtime/ledger-event-renderer.ts +1 -0
  134. package/src/gjc-runtime/managed-owner-admission.ts +1 -1
  135. package/src/gjc-runtime/ralplan-review-conflicts.ts +472 -0
  136. package/src/gjc-runtime/ralplan-runtime.ts +491 -27
  137. package/src/gjc-runtime/team-launch.ts +8 -0
  138. package/src/gjc-runtime/team-runtime.ts +140 -32
  139. package/src/gjc-runtime/team-worker-heartbeat.ts +149 -0
  140. package/src/gjc-runtime/tmux-owner-isolation.ts +10 -0
  141. package/src/gjc-runtime/tmux-sessions.ts +58 -13
  142. package/src/gjc-runtime/ultragoal-evidence.ts +6 -74
  143. package/src/gjc-runtime/ultragoal-runtime.ts +635 -612
  144. package/src/gjc-runtime/workflow-manifest.generated.json +37 -99
  145. package/src/gjc-runtime/workflow-manifest.ts +21 -70
  146. package/src/internal-urls/docs-index.generated.ts +16 -16
  147. package/src/modes/DESIGN.md +104 -0
  148. package/src/modes/acp/acp-agent.ts +298 -186
  149. package/src/modes/components/gjc-bundle-settings.ts +508 -0
  150. package/src/modes/components/irc-sidebar.ts +30 -1
  151. package/src/modes/components/notifications-settings-editor.ts +12 -1
  152. package/src/modes/components/oauth-selector.ts +68 -30
  153. package/src/modes/components/session-observer-overlay.ts +305 -86
  154. package/src/modes/components/settings-selector.ts +56 -5
  155. package/src/modes/components/status-line/gh.ts +16 -0
  156. package/src/modes/components/tool-status-header.ts +3 -15
  157. package/src/modes/components/transcript-viewer-overlay.ts +99 -24
  158. package/src/modes/controllers/command-controller.ts +42 -34
  159. package/src/modes/controllers/event-controller.ts +27 -16
  160. package/src/modes/controllers/extension-ui-controller.ts +193 -34
  161. package/src/modes/controllers/selector-controller.ts +160 -22
  162. package/src/modes/interactive-mode.ts +189 -62
  163. package/src/modes/jobs-observer.ts +1 -1
  164. package/src/modes/runtime-init.ts +3 -0
  165. package/src/modes/theme/theme.ts +11 -9
  166. package/src/modes/types.ts +88 -0
  167. package/src/prompts/agent-fragments/ralplan-persistence.md +4 -3
  168. package/src/prompts/system/eager-todo.md +8 -4
  169. package/src/prompts/system/system-prompt.md +11 -4
  170. package/src/prompts/tools/bash.md +5 -5
  171. package/src/prompts/tools/search-tool-bm25.md +5 -0
  172. package/src/prompts/tools/task.md +1 -1
  173. package/src/reminders/star-reminder.ts +4 -42
  174. package/src/runtime-mcp/manager.ts +19 -4
  175. package/src/sdk/acp/adapter.ts +22 -6
  176. package/src/sdk/broker/lifecycle.ts +18 -13
  177. package/src/sdk/broker/transport.ts +35 -3
  178. package/src/sdk/bus/attachment-registry.ts +5 -1
  179. package/src/sdk/bus/chat-daemon-cli.ts +4 -39
  180. package/src/sdk/bus/chat-daemon-control.ts +7 -3
  181. package/src/sdk/bus/config.ts +18 -2
  182. package/src/sdk/bus/index.ts +661 -126
  183. package/src/sdk/bus/kind-aware-reconciliation.ts +148 -73
  184. package/src/sdk/bus/lifecycle-commands.ts +4 -1
  185. package/src/sdk/bus/lifecycle-control-runtime.ts +403 -88
  186. package/src/sdk/bus/reconciliation-store.ts +95 -16
  187. package/src/sdk/bus/rich-draft.ts +1 -1
  188. package/src/sdk/bus/rich-render.ts +2 -2
  189. package/src/sdk/bus/telegram-adoption-intent.ts +574 -0
  190. package/src/sdk/bus/telegram-cli.ts +33 -8
  191. package/src/sdk/bus/telegram-daemon-cli.ts +1 -0
  192. package/src/sdk/bus/telegram-daemon-contract.ts +12 -4
  193. package/src/sdk/bus/telegram-daemon.ts +916 -23
  194. package/src/sdk/bus/telegram-reference.ts +40 -3
  195. package/src/sdk/bus/threaded-render.ts +48 -3
  196. package/src/sdk/bus/topic-registry.ts +20 -0
  197. package/src/sdk/host/query/revision-store.ts +36 -2
  198. package/src/sdk/host/reverse-leases.ts +44 -7
  199. package/src/sdk/prompt-status.ts +16 -3
  200. package/src/sdk/protocol/operation-inventory.generated.json +33 -0
  201. package/src/sdk/session.ts +89 -9
  202. package/src/session/agent-session.ts +844 -173
  203. package/src/session/artifacts.ts +22 -0
  204. package/src/session/auth-broker-config.ts +10 -3
  205. package/src/session/blob-store.ts +915 -24
  206. package/src/session/internal/managed-session-scope.ts +200 -111
  207. package/src/session/internal/managed-session-storage.ts +492 -62
  208. package/src/session/session-manager.ts +1614 -435
  209. package/src/session/session-storage.ts +38 -45
  210. package/src/session/streaming-output.ts +238 -68
  211. package/src/setup/credential-import.ts +75 -13
  212. package/src/skill-state/active-state.ts +32 -0
  213. package/src/skill-state/workflow-hud.ts +17 -0
  214. package/src/skill-state/workflow-mutation-guard.ts +496 -2
  215. package/src/task/executor.ts +122 -39
  216. package/src/task/index.ts +280 -45
  217. package/src/task/output-manager.ts +24 -14
  218. package/src/task/provider-retry-status.ts +16 -0
  219. package/src/task/receipt.ts +34 -8
  220. package/src/task/render.ts +6 -2
  221. package/src/task/types.ts +108 -0
  222. package/src/tools/ask-answer-registry.ts +12 -6
  223. package/src/tools/ask.ts +86 -55
  224. package/src/tools/ast-edit.ts +1 -0
  225. package/src/tools/ast-grep.ts +1 -0
  226. package/src/tools/bash-interactive.ts +8 -3
  227. package/src/tools/bash.ts +503 -60
  228. package/src/tools/find.ts +1 -0
  229. package/src/tools/image-gen.ts +29 -5
  230. package/src/tools/index.ts +6 -0
  231. package/src/tools/output-meta.ts +108 -14
  232. package/src/tools/path-utils.ts +3 -2
  233. package/src/tools/read.ts +18 -0
  234. package/src/tools/review.ts +5 -7
  235. package/src/tools/search.ts +1 -0
  236. package/src/tools/subagent-render.ts +6 -2
  237. package/src/tools/subagent.ts +6 -0
  238. package/src/tools/telegram-send.ts +6 -3
  239. package/src/utils/gh.ts +39 -0
  240. package/src/utils/image-resize.ts +3 -0
  241. package/src/web/search/providers/anthropic.ts +4 -4
  242. package/src/web/search/providers/kimi.ts +15 -5
  243. package/src/web/search/providers/searxng.ts +47 -4
  244. package/src/web/search/providers/xai.ts +7 -2
  245. package/dist/types/gjc-runtime/ultragoal-pipeline.d.ts +0 -23
  246. package/src/defaults/gjc/skills/ultragoal/pipeline-validation-contracts.md +0 -30
  247. package/src/gjc-runtime/ultragoal-pipeline.ts +0 -306
@@ -8,12 +8,125 @@ import { executeShell, type MinimizerOptions, Shell } from "@gajae-code/natives"
8
8
  import { postmortem } from "@gajae-code/utils";
9
9
  import { Settings, type ShellMinimizerSettings } from "../config/settings";
10
10
  import { formatCrashDiagnosticNotice, writeCrashReport } from "../debug/crash-diagnostics";
11
- import { OutputSink } from "../session/streaming-output";
12
- import { resolveOutputMaxColumns, resolveOutputSinkHeadBytes } from "../tools/output-meta";
11
+ import {
12
+ DEFAULT_ARTIFACT_MAX_BYTES,
13
+ DEFAULT_MAX_BYTES,
14
+ OutputSink,
15
+ type TerminalArtifactPublisher,
16
+ truncateHeadBytes,
17
+ } from "../session/streaming-output";
18
+ import { formatArtifactReference, resolveOutputMaxColumns, resolveOutputSinkHeadBytes } from "../tools/output-meta";
13
19
  import { getOrCreateSnapshot } from "../utils/shell-snapshot";
14
20
  import { NON_INTERACTIVE_ENV } from "./non-interactive-env";
15
21
 
22
+ export interface BashArtifactSaveSummary {
23
+ artifactId: string;
24
+ complete: boolean;
25
+ omittedBytes?: number;
26
+ }
27
+
28
+ export type BashMinimizedSaveReturn = BashArtifactSaveResult | BashArtifactSaveSummary | string | undefined;
29
+
30
+ export type BashArtifactSaveResult =
31
+ | { status: "saved"; artifactId: string; complete: true; omittedBytes?: undefined }
32
+ | { status: "saved"; artifactId: string; complete: false; omittedBytes: number }
33
+ | { status: "unavailable" }
34
+ | { status: "failed"; diagnostic: string };
35
+
36
+ function summarizeLegacyArtifactSave(artifactId: string, originalText: string): BashArtifactSaveResult {
37
+ const inputBytes = Buffer.byteLength(originalText, "utf-8");
38
+ if (inputBytes <= DEFAULT_ARTIFACT_MAX_BYTES) {
39
+ return { status: "saved", artifactId, complete: true };
40
+ }
41
+ const retainedBytes = truncateHeadBytes(originalText, DEFAULT_ARTIFACT_MAX_BYTES).bytes;
42
+ return {
43
+ status: "saved",
44
+ artifactId,
45
+ complete: false,
46
+ omittedBytes: inputBytes - retainedBytes,
47
+ };
48
+ }
49
+
50
+ function normalizeExplicitSavedArtifact(
51
+ artifactId: string,
52
+ complete: boolean,
53
+ omittedBytes: number | undefined,
54
+ ): BashArtifactSaveResult {
55
+ if (complete) {
56
+ return (omittedBytes ?? 0) > 0
57
+ ? { status: "failed", diagnostic: "artifact save reported complete output with omitted bytes" }
58
+ : { status: "saved", artifactId, complete: true };
59
+ }
60
+ return typeof omittedBytes === "number" && omittedBytes > 0
61
+ ? { status: "saved", artifactId, complete: false, omittedBytes }
62
+ : { status: "failed", diagnostic: "artifact save reported incomplete output without omitted bytes" };
63
+ }
64
+
65
+ function normalizeMinimizedSaveResult(value: BashMinimizedSaveReturn, originalText: string): BashArtifactSaveResult {
66
+ if (typeof value === "string") return summarizeLegacyArtifactSave(value, originalText);
67
+ if (!value) return { status: "unavailable" };
68
+ if (!("status" in value)) {
69
+ return normalizeExplicitSavedArtifact(value.artifactId, value.complete, value.omittedBytes);
70
+ }
71
+ if (value.status !== "saved") return value;
72
+ return normalizeExplicitSavedArtifact(value.artifactId, value.complete, value.omittedBytes);
73
+ }
74
+
75
+ export function normalizeMinimizedSaveResultForTests(
76
+ value: BashMinimizedSaveReturn,
77
+ originalText: string,
78
+ ): BashArtifactSaveResult {
79
+ return normalizeMinimizedSaveResult(value, originalText);
80
+ }
81
+
82
+ function completeRawArtifactAvailable(summary: {
83
+ artifactId?: string;
84
+ artifactTruncatedBytes?: number;
85
+ artifactFailureDiagnostic?: string;
86
+ }): boolean {
87
+ return (
88
+ summary.artifactId !== undefined &&
89
+ (summary.artifactTruncatedBytes ?? 0) <= 0 &&
90
+ summary.artifactFailureDiagnostic === undefined
91
+ );
92
+ }
93
+
94
+ function appendModelNotice(output: string, notice: string): string {
95
+ const separator = output.length > 0 && !output.endsWith("\n") ? "\n" : "";
96
+ return `${output}${separator}${notice}\n`;
97
+ }
98
+
99
+ function minimizedSaveNotice(
100
+ result: BashArtifactSaveResult,
101
+ summary: { artifactId?: string; artifactTruncatedBytes?: number; artifactFailureDiagnostic?: string },
102
+ ): string | undefined {
103
+ if (result.status === "failed") return `Bash output artifact save failed: ${result.diagnostic}`;
104
+ if (result.status === "unavailable" && !completeRawArtifactAvailable(summary)) {
105
+ return "Bash output artifact unavailable: full original output could not be stored because artifact storage is unavailable.";
106
+ }
107
+ return undefined;
108
+ }
109
+
110
+ function minimizedArtifactFooter(result: Extract<BashArtifactSaveResult, { status: "saved" }>): string {
111
+ const reference = result.complete
112
+ ? `artifact://${result.artifactId}`
113
+ : formatArtifactReference(result.artifactId, result.omittedBytes);
114
+ return `[raw output: ${reference}]`;
115
+ }
116
+
16
117
  export interface BashExecutorOptions {
118
+ /**
119
+ * Invoked when the native minimizer rewrote the command's output, giving
120
+ * the caller a chance to persist the lossless original capture (typically
121
+ * via the session's `ArtifactManager`). Complete saves preserve the
122
+ * historical `[raw output: artifact://<id>]` footer; capped saves carry an
123
+ * honest retained/omitted reference. A legacy string id is still accepted
124
+ * for non-tool callers and is classified from the original UTF-8 byte count.
125
+ */
126
+ onMinimizedSave?: (
127
+ originalText: string,
128
+ info: { filter: string; inputBytes: number; outputBytes: number },
129
+ ) => Promise<BashMinimizedSaveReturn>;
17
130
  cwd?: string;
18
131
  timeout?: number | null;
19
132
  onChunk?: (chunk: string) => void;
@@ -32,23 +145,18 @@ export interface BashExecutorOptions {
32
145
  /** Artifact path/id for full output storage */
33
146
  artifactPath?: string;
34
147
  artifactId?: string;
148
+ /** Optional terminal publisher for managed artifacts without writable paths. */
149
+ artifactPublisher?: TerminalArtifactPublisher;
150
+ /** Optional Bash-specific retained tail budget in bytes. */
151
+ spillThreshold?: number;
152
+ /** Optional Bash-specific retained head budget in bytes. */
153
+ headBytes?: number;
35
154
  /** Execute without retaining a native Shell in the persistent session registry. */
36
155
  oneShot?: boolean;
37
156
  /** Ignore user-configured shell command prefixes. Used by constrained read-only shells. */
38
157
  ignoreShellPrefix?: boolean;
39
158
  /** Skip sourced shell snapshots. Used by constrained read-only shells. */
40
159
  disableShellSnapshot?: boolean;
41
- /**
42
- * Invoked when the native minimizer rewrote the command's output, giving
43
- * the caller a chance to persist the lossless original capture (typically
44
- * via the session's `ArtifactManager`). The returned id is spliced into
45
- * the sink output as `artifact://<id>` so the agent can retrieve the raw
46
- * bytes. Return `undefined` to skip the footer.
47
- */
48
- onMinimizedSave?: (
49
- originalText: string,
50
- info: { filter: string; inputBytes: number; outputBytes: number },
51
- ) => Promise<string | undefined>;
52
160
  }
53
161
 
54
162
  export interface BashResult {
@@ -61,6 +169,8 @@ export interface BashResult {
61
169
  outputLines: number;
62
170
  outputBytes: number;
63
171
  artifactId?: string;
172
+ artifactTruncatedBytes?: number;
173
+ artifactFailureDiagnostic?: string;
64
174
  }
65
175
 
66
176
  const shellSessions = new Map<string, Shell>();
@@ -144,7 +254,9 @@ export async function executeBash(command: string, options?: BashExecutorOptions
144
254
  onRawChunk: options?.onRawChunk,
145
255
  artifactPath: options?.artifactPath,
146
256
  artifactId: options?.artifactId,
147
- headBytes: resolveOutputSinkHeadBytes(settings),
257
+ artifactPublisher: options?.artifactPublisher,
258
+ spillThreshold: options?.spillThreshold ?? DEFAULT_MAX_BYTES,
259
+ headBytes: options?.headBytes ?? resolveOutputSinkHeadBytes(settings),
148
260
  maxColumns: resolveOutputMaxColumns(settings),
149
261
  // Throttle the streaming preview callback to avoid saturating the
150
262
  // event loop when commands produce massive output (e.g. seq 1 50M).
@@ -332,21 +444,23 @@ export async function executeBash(command: string, options?: BashExecutorOptions
332
444
 
333
445
  // When the native minimizer rewrote the output, swap the sink's accumulated
334
446
  // raw stream for the minimized text, persist the original as a session
335
- // artifact, and splice an `artifact://<id>` footer into the visible text so
336
- // the agent can retrieve the raw bytes losslessly.
447
+ // artifact, and splice an artifact footer into the visible text so the agent
448
+ // can retrieve retained raw bytes without a false completeness claim.
337
449
  const minimized = winner.result.minimized;
450
+ let minimizedSaveResult: BashArtifactSaveResult | undefined;
338
451
  if (minimized && minimized.text !== minimized.originalText) {
339
452
  sink.replace(minimized.text);
340
- if (options?.onMinimizedSave) {
341
- const artifactId = await options.onMinimizedSave(minimized.originalText, {
342
- filter: minimized.filter,
343
- inputBytes: minimized.inputBytes,
344
- outputBytes: minimized.outputBytes,
345
- });
346
- if (artifactId) {
347
- const sep = minimized.text.endsWith("\n") ? "" : "\n";
348
- sink.push(`${sep}[raw output: artifact://${artifactId}]\n`);
349
- }
453
+ const saved = options?.onMinimizedSave
454
+ ? await options.onMinimizedSave(minimized.originalText, {
455
+ filter: minimized.filter,
456
+ inputBytes: minimized.inputBytes,
457
+ outputBytes: minimized.outputBytes,
458
+ })
459
+ : undefined;
460
+ minimizedSaveResult = normalizeMinimizedSaveResult(saved, minimized.originalText);
461
+ if (minimizedSaveResult.status === "saved") {
462
+ const sep = minimized.text.endsWith("\n") ? "" : "\n";
463
+ sink.push(`${sep}${minimizedArtifactFooter(minimizedSaveResult)}\n`);
350
464
  }
351
465
  }
352
466
 
@@ -366,10 +480,13 @@ export async function executeBash(command: string, options?: BashExecutorOptions
366
480
  }
367
481
 
368
482
  // Normal completion
483
+ const summary = await sink.dump();
484
+ const saveNotice = minimizedSaveResult ? minimizedSaveNotice(minimizedSaveResult, summary) : undefined;
369
485
  return {
370
486
  exitCode: winner.result.exitCode,
371
487
  cancelled: false,
372
- ...(await sink.dump()),
488
+ ...summary,
489
+ ...(saveNotice ? { output: appendModelNotice(summary.output, saveNotice) } : {}),
373
490
  };
374
491
  } catch (err) {
375
492
  resetSession = true;
@@ -179,8 +179,12 @@ export class ExtensionRunner {
179
179
 
180
180
  #getModel: () => Model | undefined = () => undefined;
181
181
  #isIdleFn: () => boolean = () => true;
182
+ #getActivePromptHandleFn: () => string | undefined = () => undefined;
182
183
  #waitForIdleFn: () => Promise<void> = async () => {};
183
184
  #abortFn: () => void = () => {};
185
+ #abortPromptAndWaitFn: NonNullable<ExtensionContextActions["abortPromptAndWait"]> = async () => {
186
+ throw new Error("abortPromptAndWait binding is unavailable");
187
+ };
184
188
  #hasPendingMessagesFn: () => boolean = () => false;
185
189
  #getPendingMessageCountsFn: () => { steering: number; followUp: number; nextTurn: number } = () => ({
186
190
  steering: 0,
@@ -214,6 +218,7 @@ export class ExtensionRunner {
214
218
  #getJobsFn: ExtensionContextActions["getJobs"] = undefined;
215
219
  #sdkControlFn: ExtensionContextActions["sdkControl"] = undefined;
216
220
  #setSdkPermissionProviderFn: ExtensionContextActions["setSdkPermissionProvider"] = undefined;
221
+ #setSdkClientBridgeFn: ExtensionContextActions["setSdkClientBridge"] = undefined;
217
222
 
218
223
  #invokeSkillFn: ExtensionContextActions["invokeSkill"] = undefined;
219
224
  #setPlanModeFn: ExtensionContextActions["setPlanMode"] = undefined;
@@ -297,7 +302,13 @@ export class ExtensionRunner {
297
302
  // Context actions (required)
298
303
  this.#getModel = contextActions.getModel;
299
304
  this.#isIdleFn = contextActions.isIdle;
305
+ this.#getActivePromptHandleFn = contextActions.getActivePromptHandle ?? (() => undefined);
300
306
  this.#abortFn = contextActions.abort;
307
+ this.#abortPromptAndWaitFn =
308
+ contextActions.abortPromptAndWait ??
309
+ (async () => {
310
+ throw new Error("abortPromptAndWait binding is unavailable");
311
+ });
301
312
  this.#hasPendingMessagesFn = contextActions.hasPendingMessages;
302
313
  this.#getPendingMessageCountsFn =
303
314
  contextActions.getPendingMessageCounts ?? (() => ({ steering: 0, followUp: 0, nextTurn: 0 }));
@@ -331,6 +342,7 @@ export class ExtensionRunner {
331
342
  this.#getJobsFn = contextActions.getJobs;
332
343
  this.#sdkControlFn = contextActions.sdkControl;
333
344
  this.#setSdkPermissionProviderFn = contextActions.setSdkPermissionProvider;
345
+ this.#setSdkClientBridgeFn = contextActions.setSdkClientBridge;
334
346
 
335
347
  // Command context actions (optional, only for interactive mode)
336
348
  if (commandContextActions) {
@@ -551,8 +563,10 @@ export class ExtensionRunner {
551
563
  get model() {
552
564
  return getModel();
553
565
  },
566
+ getActivePromptHandle: () => this.#getActivePromptHandleFn(),
554
567
  isIdle: () => this.#isIdleFn(),
555
568
  abort: () => this.#abortFn(),
569
+ abortPromptAndWait: (handle, options) => this.#abortPromptAndWaitFn(handle, options),
556
570
  hasPendingMessages: () => this.#hasPendingMessagesFn(),
557
571
  getPendingMessageCounts: () => this.#getPendingMessageCountsFn(),
558
572
  getTranscript: () => this.#getTranscriptFn(),
@@ -582,6 +596,7 @@ export class ExtensionRunner {
582
596
  getJobs: () => this.#getJobsFn?.(),
583
597
  sdkControl: (operation, input) => this.#sdkControlFn?.(operation, input),
584
598
  setSdkPermissionProvider: provider => this.#setSdkPermissionProviderFn?.(provider),
599
+ setSdkClientBridge: bridge => this.#setSdkClientBridgeFn?.(bridge),
585
600
  sdkBindings: () => [
586
601
  ...(this.#cycleModelFn ? ["cycleModel"] : []),
587
602
  ...(this.#setModelProfileFn ? ["setModelProfile"] : []),
@@ -8,7 +8,13 @@
8
8
  * - Interact with the user via UI primitives
9
9
  */
10
10
 
11
- import type { AgentMessage, AgentToolResult, AgentToolUpdateCallback, ThinkingLevel } from "@gajae-code/agent-core";
11
+ import type {
12
+ AgentMessage,
13
+ AgentToolResult,
14
+ AgentToolUpdateCallback,
15
+ RunSettlementProof,
16
+ ThinkingLevel,
17
+ } from "@gajae-code/agent-core";
12
18
  import type { CompactionResult } from "@gajae-code/agent-core/compaction";
13
19
  import type {
14
20
  Api,
@@ -38,6 +44,7 @@ import type { CustomEditor } from "../../modes/components/custom-editor";
38
44
  import type { WorkflowGateEmitter } from "../../modes/shared/agent-wire/workflow-gate-broker";
39
45
  import type { Theme } from "../../modes/theme/theme";
40
46
  import type {
47
+ ClientBridge,
41
48
  ClientBridgePermissionOption,
42
49
  ClientBridgePermissionOutcome,
43
50
  ClientBridgePermissionToolCall,
@@ -355,8 +362,12 @@ export interface ExtensionContext {
355
362
  model: Model | undefined;
356
363
  /** Whether the agent is idle (not streaming) */
357
364
  isIdle(): boolean;
365
+ /** Stable resource ownership identifier for the active prompt run. */
366
+ getActivePromptHandle(): string | undefined;
358
367
  /** Abort the current agent operation */
359
368
  abort(): void;
369
+ /** Abort and prove whether resources for a specific prompt settled. */
370
+ abortPromptAndWait?(handle: string, options: { graceMs: number }): Promise<RunSettlementProof>;
360
371
  /** Whether there are queued messages waiting */
361
372
  hasPendingMessages(): boolean;
362
373
  /** Typed pending-message counts per queue (steering, follow-up, next-turn). */
@@ -416,6 +427,8 @@ export interface ExtensionContext {
416
427
  ) => Promise<ClientBridgePermissionOutcome>)
417
428
  | undefined,
418
429
  ): void;
430
+ /** Install a client bridge backed by a live SDK reverse provider lease. */
431
+ setSdkClientBridge?(bridge: ClientBridge | undefined): void;
419
432
  /** Names of session SDK seams actually installed by the active runtime. */
420
433
  sdkBindings?(): readonly string[];
421
434
 
@@ -1436,7 +1449,10 @@ export interface ExtensionActions {
1436
1449
  export interface ExtensionContextActions {
1437
1450
  getModel: () => Model | undefined;
1438
1451
  isIdle: () => boolean;
1452
+ /** Stable resource ownership identifier for the active prompt run. */
1453
+ getActivePromptHandle?: () => string | undefined;
1439
1454
  abort: () => void;
1455
+ abortPromptAndWait?: (handle: string, options: { graceMs: number }) => Promise<RunSettlementProof>;
1440
1456
  hasPendingMessages: () => boolean;
1441
1457
  /** Typed pending-message counts per queue; optional for embedders without a counted queue. */
1442
1458
  getPendingMessageCounts?: () => { steering: number; followUp: number; nextTurn: number };
@@ -1484,6 +1500,7 @@ export interface ExtensionContextActions {
1484
1500
  ) => Promise<ClientBridgePermissionOutcome>)
1485
1501
  | undefined,
1486
1502
  ) => void;
1503
+ setSdkClientBridge?: (bridge: ClientBridge | undefined) => void;
1487
1504
  sdkControl?: (operation: string, input: Record<string, unknown>) => unknown | Promise<unknown>;
1488
1505
  invokeSkill?: (
1489
1506
  name: string,
@@ -1,8 +1,8 @@
1
1
  import { logger } from "@gajae-code/utils";
2
-
2
+ import { bundleIdentity } from "./lifecycle-reconciliation";
3
3
  import { loadEffectiveGjcPluginRegistry } from "./registry";
4
4
  import { type SessionQuarantine, validateSessionBundles, verifyEntryHashes } from "./session-validation";
5
- import { GjcPluginLoadError, type GjcPluginRegistryEntry } from "./types";
5
+ import { GjcPluginLoadError, type GjcPluginRegistryEntry, type GjcPluginScope } from "./types";
6
6
 
7
7
  /**
8
8
  * Constrained plugin-hook loader.
@@ -37,6 +37,7 @@ const DENIED_API_METHODS = [
37
37
 
38
38
  interface DeclaredHook {
39
39
  plugin: string;
40
+ scope: GjcPluginScope;
40
41
  event: string;
41
42
  target?: string;
42
43
  phase?: "before" | "after";
@@ -52,6 +53,7 @@ function collectDeclaredHooks(entries: readonly GjcPluginRegistryEntry[]): Decla
52
53
  if (disabled.has(h.extensionId)) continue;
53
54
  out.push({
54
55
  plugin: entry.name,
56
+ scope: entry.scope,
55
57
  event: h.event,
56
58
  target: h.target,
57
59
  phase: h.phase,
@@ -88,6 +90,7 @@ async function loadOneHook(
88
90
  return {
89
91
  hook: null,
90
92
  quarantine: {
93
+ identity: bundleIdentity(declared.scope, declared.plugin),
91
94
  plugin: declared.plugin,
92
95
  surfaceId: `hook:${declared.event}:${declared.target ?? ""}`,
93
96
  code: "invalid_hook",
@@ -99,6 +102,7 @@ async function loadOneHook(
99
102
  return {
100
103
  hook: null,
101
104
  quarantine: {
105
+ identity: bundleIdentity(declared.scope, declared.plugin),
102
106
  plugin: declared.plugin,
103
107
  surfaceId: `hook:${declared.event}`,
104
108
  code: "invalid_hook",
@@ -113,6 +117,7 @@ async function loadOneHook(
113
117
  return {
114
118
  hook: null,
115
119
  quarantine: {
120
+ identity: bundleIdentity(declared.scope, declared.plugin),
116
121
  plugin: declared.plugin,
117
122
  surfaceId: `hook:${declared.event}`,
118
123
  code,
@@ -125,6 +130,7 @@ async function loadOneHook(
125
130
  return {
126
131
  hook: null,
127
132
  quarantine: {
133
+ identity: bundleIdentity(declared.scope, declared.plugin),
128
134
  plugin: declared.plugin,
129
135
  surfaceId: `hook:${declared.event}`,
130
136
  code: "runtime_mismatch",
@@ -2,14 +2,31 @@ export * from "./activation";
2
2
  export * from "./compiler";
3
3
  export * from "./constrained-hooks";
4
4
  export * from "./injection";
5
- export * from "./installer";
5
+ /**
6
+ * Public barrel. Mutation primitives are deliberately NOT re-exported here:
7
+ * `lifecycle.ts` is the sole policy and persistence writer, so the installer
8
+ * transaction and the registry writers stay reachable only through their own
9
+ * modules. Re-exporting them would let a caller commit a replacement and
10
+ * bypass the create-only rule.
11
+ */
12
+ export { isGjcPluginBundleSource, isGjcPluginSourceShape } from "./installer";
13
+ export * from "./lifecycle";
14
+ export * from "./lifecycle-reconciliation";
6
15
  export * from "./loader";
7
16
  export * from "./mcp-policy";
8
17
  export * from "./observability";
9
18
  export * from "./paths";
10
19
  export * from "./prompt-appendix";
11
- export * from "./registry";
20
+ export {
21
+ loadEffectiveGjcPluginRegistry,
22
+ readRegistry,
23
+ registryEntryFingerprint,
24
+ registryPathForScope,
25
+ registryRootForScope,
26
+ sortRegistryEntries,
27
+ } from "./registry";
12
28
  export * from "./runtime-adapters";
29
+ export * from "./runtime-quarantine";
13
30
  export * from "./schema";
14
31
  export * from "./session-validation";
15
32
  export * from "./state";