@gajae-code/coding-agent 0.11.9 → 0.11.11

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 (150) hide show
  1. package/CHANGELOG.md +56 -1
  2. package/dist/types/cli.d.ts +8 -1
  3. package/dist/types/config/model-profile-activation.d.ts +1 -0
  4. package/dist/types/config/model-profile-contract.d.ts +2 -0
  5. package/dist/types/config/model-registry.d.ts +2 -0
  6. package/dist/types/config/settings-schema.d.ts +57 -2
  7. package/dist/types/config/settings.d.ts +1 -0
  8. package/dist/types/extensibility/extensions/types.d.ts +21 -0
  9. package/dist/types/gjc-runtime/linux-proc.d.ts +22 -14
  10. package/dist/types/gjc-runtime/ralplan-runtime.d.ts +60 -0
  11. package/dist/types/gjc-runtime/state-runtime.d.ts +3 -1
  12. package/dist/types/gjc-runtime/state-writer.d.ts +1 -0
  13. package/dist/types/modes/acp/acp-agent.d.ts +14 -9
  14. package/dist/types/modes/components/queue-pane.d.ts +8 -0
  15. package/dist/types/modes/components/queued-message-selector.d.ts +6 -0
  16. package/dist/types/modes/components/welcome.d.ts +1 -0
  17. package/dist/types/modes/controllers/selector-controller.d.ts +16 -8
  18. package/dist/types/modes/interactive-mode.d.ts +5 -1
  19. package/dist/types/runtime/memory-domain.d.ts +9 -0
  20. package/dist/types/runtime/memory-guard-contract.d.ts +71 -0
  21. package/dist/types/runtime/memory-guard.d.ts +39 -0
  22. package/dist/types/runtime/memory-limit.d.ts +11 -0
  23. package/dist/types/runtime-mcp/manager.d.ts +8 -0
  24. package/dist/types/sdk/acp/final-text.d.ts +19 -0
  25. package/dist/types/sdk/acp/mcp.d.ts +23 -0
  26. package/dist/types/sdk/broker/lifecycle.d.ts +2 -0
  27. package/dist/types/sdk/bus/chat-daemon-control.d.ts +2 -1
  28. package/dist/types/sdk/bus/daemon-paths.d.ts +1 -0
  29. package/dist/types/sdk/bus/index.d.ts +11 -2
  30. package/dist/types/sdk/bus/operator-runtime.d.ts +1 -0
  31. package/dist/types/sdk/bus/rate-limit-pool.d.ts +2 -0
  32. package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +14 -7
  33. package/dist/types/sdk/bus/telegram-daemon.d.ts +97 -8
  34. package/dist/types/sdk/host/control/operations.d.ts +1 -0
  35. package/dist/types/sdk/lifecycle-session.d.ts +10 -1
  36. package/dist/types/sdk/session.d.ts +7 -0
  37. package/dist/types/sdk/startup-capability.d.ts +6 -0
  38. package/dist/types/session/agent-session.d.ts +11 -11
  39. package/dist/types/session/fallback-chain-controller.d.ts +18 -2
  40. package/dist/types/session/internal/managed-session-scope.d.ts +28 -1
  41. package/dist/types/session/session-manager.d.ts +34 -0
  42. package/dist/types/task/executor.d.ts +6 -0
  43. package/dist/types/task/provider-retry-status.d.ts +13 -0
  44. package/dist/types/task/types.d.ts +39 -0
  45. package/dist/types/task/ultragoal-redteam-activation.d.ts +33 -0
  46. package/dist/types/tools/index.d.ts +3 -1
  47. package/dist/types/tools/resource-gc.d.ts +19 -0
  48. package/package.json +8 -8
  49. package/scripts/generate-sdk-operation-inventory.ts +3 -0
  50. package/scripts/run-test-manifest.ts +6 -4
  51. package/src/cli/args.ts +14 -8
  52. package/src/cli/fast-help.ts +1 -1
  53. package/src/cli/notify-cli.ts +1 -0
  54. package/src/cli.ts +48 -2
  55. package/src/commands/sdk.ts +91 -7
  56. package/src/config/model-profile-activation.ts +1 -0
  57. package/src/config/model-profile-contract.ts +13 -0
  58. package/src/config/model-profiles.ts +31 -7
  59. package/src/config/model-registry.ts +4 -2
  60. package/src/config/settings-schema.ts +61 -2
  61. package/src/config/settings.ts +8 -0
  62. package/src/defaults/gjc/skills/ralplan/SKILL.md +21 -2
  63. package/src/defaults/gjc/skills/ultragoal/SKILL.md +1 -1
  64. package/src/eval/js/tool-bridge.ts +1 -1
  65. package/src/extensibility/extensions/runner.ts +4 -0
  66. package/src/extensibility/extensions/types.ts +14 -0
  67. package/src/gjc-runtime/deep-interview-ambiguity.ts +16 -2
  68. package/src/gjc-runtime/deep-interview-draft.ts +2 -1
  69. package/src/gjc-runtime/deep-interview-recorder.ts +16 -1
  70. package/src/gjc-runtime/deep-interview-state.ts +25 -3
  71. package/src/gjc-runtime/linux-proc.ts +70 -36
  72. package/src/gjc-runtime/ralplan-runtime.ts +252 -1
  73. package/src/gjc-runtime/state-runtime.ts +48 -11
  74. package/src/gjc-runtime/state-writer.ts +1 -1
  75. package/src/hooks/skill-state.ts +23 -1
  76. package/src/internal-urls/docs-index.generated.ts +7 -7
  77. package/src/internal-urls/local-protocol.ts +23 -4
  78. package/src/modes/acp/acp-agent.ts +554 -60
  79. package/src/modes/acp/acp-event-mapper.ts +93 -6
  80. package/src/modes/components/model-selector.ts +15 -1
  81. package/src/modes/components/notifications-settings-editor.ts +1 -1
  82. package/src/modes/components/queue-pane.ts +55 -9
  83. package/src/modes/components/queued-message-selector.ts +53 -10
  84. package/src/modes/components/tool-status-header.ts +1 -4
  85. package/src/modes/components/welcome.ts +18 -3
  86. package/src/modes/controllers/command-controller.ts +4 -0
  87. package/src/modes/controllers/extension-ui-controller.ts +4 -10
  88. package/src/modes/controllers/input-controller.ts +44 -3
  89. package/src/modes/controllers/selector-controller.ts +38 -8
  90. package/src/modes/interactive-mode.ts +65 -26
  91. package/src/modes/runtime-init.ts +1 -0
  92. package/src/prompts/agent-fragments/restricted-bash.md +1 -1
  93. package/src/prompts/agents/architect.md +8 -1
  94. package/src/prompts/agents/critic.md +8 -1
  95. package/src/prompts/agents/executor.md +1 -1
  96. package/src/prompts/agents/planner.md +8 -1
  97. package/src/runtime/memory-domain.ts +66 -0
  98. package/src/runtime/memory-guard-contract.ts +73 -0
  99. package/src/runtime/memory-guard.ts +292 -0
  100. package/src/runtime/memory-limit.ts +50 -0
  101. package/src/runtime-mcp/manager.ts +26 -6
  102. package/src/sdk/acp/adapter.ts +8 -1
  103. package/src/sdk/acp/final-text.ts +40 -0
  104. package/src/sdk/acp/mcp.ts +26 -0
  105. package/src/sdk/broker/identity.ts +22 -12
  106. package/src/sdk/broker/lifecycle.ts +82 -1
  107. package/src/sdk/bus/chat-daemon-cli.ts +2 -2
  108. package/src/sdk/bus/chat-daemon-control.ts +4 -3
  109. package/src/sdk/bus/config.ts +1 -1
  110. package/src/sdk/bus/daemon-paths.ts +2 -0
  111. package/src/sdk/bus/index.ts +222 -27
  112. package/src/sdk/bus/notification-service.ts +19 -5
  113. package/src/sdk/bus/operator-runtime.ts +31 -5
  114. package/src/sdk/bus/rate-limit-pool.ts +8 -0
  115. package/src/sdk/bus/telegram-cli.ts +6 -13
  116. package/src/sdk/bus/telegram-daemon-cli.ts +8 -3
  117. package/src/sdk/bus/telegram-daemon-contract.ts +15 -7
  118. package/src/sdk/bus/telegram-daemon-control.ts +14 -5
  119. package/src/sdk/bus/telegram-daemon.ts +1191 -164
  120. package/src/sdk/host/control/dispatch.ts +2 -0
  121. package/src/sdk/host/control/operations.ts +1 -0
  122. package/src/sdk/host/host.ts +2 -2
  123. package/src/sdk/lifecycle-session.ts +19 -3
  124. package/src/sdk/protocol/operation-inventory.generated.json +58 -0
  125. package/src/sdk/protocol/operation-registry.ts +1 -0
  126. package/src/sdk/session.ts +24 -1
  127. package/src/sdk/startup-capability.ts +6 -0
  128. package/src/session/agent-session.ts +290 -132
  129. package/src/session/fallback-chain-controller.ts +47 -8
  130. package/src/session/internal/managed-session-scope.ts +173 -127
  131. package/src/session/internal/native-publish-outcome.ts +8 -3
  132. package/src/session/session-manager.ts +608 -25
  133. package/src/skill-state/workflow-mutation-guard.ts +41 -7
  134. package/src/task/executor.ts +152 -42
  135. package/src/task/index.ts +2 -0
  136. package/src/task/provider-retry-status.ts +88 -0
  137. package/src/task/render.ts +45 -26
  138. package/src/task/types.ts +25 -11
  139. package/src/task/ultragoal-redteam-activation.ts +75 -0
  140. package/src/tools/bash-allowed-prefixes.ts +45 -1
  141. package/src/tools/index.ts +3 -1
  142. package/src/tools/resource-gc.ts +496 -120
  143. package/src/tools/subagent-render.ts +74 -16
  144. package/src/tools/subagent.ts +2 -0
  145. package/src/workflow/workflow-intent-diff.ts +4 -1
  146. package/vendor/insane-search/MANIFEST.json +4 -1
  147. package/vendor/insane-search/engine/bias_check.py +5 -0
  148. package/vendor/insane-search/engine/fetch_chain.py +67 -1
  149. package/vendor/insane-search/engine/transport.py +13 -2
  150. package/vendor/insane-search/engine/validators.py +4 -1
@@ -1,6 +1,9 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import * as fs from "node:fs/promises";
3
3
  import * as path from "node:path";
4
+ // Subpath import keeps this module native-free for the gjc-state-gates shards:
5
+ // the package barrel pulls procmgr/ptree → @gajae-code/natives.
6
+ import * as logger from "@gajae-code/utils/logger";
4
7
  import type { WorkflowHudSummary } from "../skill-state/active-state";
5
8
  import {
6
9
  applyHandoffToActiveState,
@@ -265,7 +268,21 @@ async function describeStaleClearState(
265
268
  return undefined;
266
269
  }
267
270
 
268
- async function readJsonFile(filePath: string): Promise<Record<string, unknown> | null> {
271
+ /**
272
+ * Route a workflow-state warning through the TUI-safe centralized file logger
273
+ * (console transport off by default) so interactive sessions never paint raw
274
+ * bytes into the alternate-screen stream (#3002). CLI command handlers may also
275
+ * collect the warning via an `onWarning` sink to surface it on the structured
276
+ * {@link StateCommandResult.stderr} channel, so `gjc state` automation still
277
+ * distinguishes corrupt state from absent state.
278
+ */
279
+ function emitStateWarning(warning: string, context?: Record<string, unknown>): void {
280
+ logger.warn(warning, context);
281
+ }
282
+
283
+ type StateWarningSink = (warning: string) => void;
284
+
285
+ async function readJsonFile(filePath: string, onWarning?: StateWarningSink): Promise<Record<string, unknown> | null> {
269
286
  try {
270
287
  const raw = await fs.readFile(filePath, "utf-8");
271
288
  const parsed = JSON.parse(raw);
@@ -276,18 +293,22 @@ async function readJsonFile(filePath: string): Promise<Record<string, unknown> |
276
293
  } catch (error) {
277
294
  const err = error as NodeJS.ErrnoException;
278
295
  if (err.code === "ENOENT") return null;
279
- process.stderr.write(`WARNING: failed to read ${filePath}; ignoring corrupt state: ${err.message}\n`);
296
+ const warning = `WARNING: failed to read ${filePath}; ignoring corrupt state: ${err.message}`;
297
+ emitStateWarning(warning, { filePath, error: err.message });
298
+ onWarning?.(warning);
280
299
  return null;
281
300
  }
282
301
  }
283
302
 
284
- async function readJsonValue(filePath: string): Promise<unknown | null> {
303
+ async function readJsonValue(filePath: string, onWarning?: StateWarningSink): Promise<unknown | null> {
285
304
  try {
286
305
  return JSON.parse(await fs.readFile(filePath, "utf-8"));
287
306
  } catch (error) {
288
307
  const err = error as NodeJS.ErrnoException;
289
308
  if (err.code === "ENOENT") return null;
290
- process.stderr.write(`WARNING: failed to read ${filePath}; ignoring corrupt state: ${err.message}\n`);
309
+ const warning = `WARNING: failed to read ${filePath}; ignoring corrupt state: ${err.message}`;
310
+ emitStateWarning(warning, { filePath, error: err.message });
311
+ onWarning?.(warning);
291
312
  return null;
292
313
  }
293
314
  }
@@ -1101,21 +1122,30 @@ export async function readWorkflowStateJson(
1101
1122
  cwd: string,
1102
1123
  skill: CanonicalGjcWorkflowSkill,
1103
1124
  sessionId?: string,
1125
+ onWarning?: StateWarningSink,
1104
1126
  ): Promise<Record<string, unknown>> {
1105
1127
  const session = await resolveGjcSessionForRead(cwd, {
1106
1128
  payloadSessionId: sessionId,
1107
1129
  envSessionId: process.env.GJC_SESSION_ID,
1108
1130
  });
1109
- return (await readJsonFile(modeStateFile(cwd, skill, session.gjcSessionId))) ?? {};
1131
+ return (await readJsonFile(modeStateFile(cwd, skill, session.gjcSessionId), onWarning)) ?? {};
1110
1132
  }
1111
1133
 
1112
1134
  async function handleRead(args: readonly string[], cwd: string): Promise<StateCommandResult> {
1113
1135
  const selectors = await resolveSelectors(args, cwd, "read");
1114
1136
  const mode = selectors.mode ?? (await inferModeFromActiveState(cwd, selectors.gjcSessionId));
1115
1137
  const fields = parseFieldsFlag(args);
1138
+ // Corrupt-state warnings are TUI-safe file-logged inside the readers; the CLI
1139
+ // path also surfaces them on the command result so `gjc state read`
1140
+ // automation can tell corrupt state from absent state (#3002).
1141
+ const warnings: string[] = [];
1142
+ const warningStderr = (): Pick<StateCommandResult, "stderr"> =>
1143
+ warnings.length ? { stderr: warnings.map(warning => `${warning}\n`).join("") } : {};
1116
1144
  if (mode) {
1117
1145
  const filePath = modeStateFile(cwd, mode, selectors.gjcSessionId);
1118
- const existing = await readWorkflowStateJson(cwd, mode, selectors.gjcSessionId);
1146
+ const existing = await readWorkflowStateJson(cwd, mode, selectors.gjcSessionId, warning =>
1147
+ warnings.push(warning),
1148
+ );
1119
1149
  const envelope = { skill: mode, state: existing, storage_path: filePath };
1120
1150
  const manifest = getSkillManifest(mode);
1121
1151
  if (fields) {
@@ -1125,6 +1155,7 @@ async function handleRead(args: readonly string[], cwd: string): Promise<StateCo
1125
1155
  stdout: hasFlag(args, "--json")
1126
1156
  ? `${JSON.stringify(projected, null, 2)}\n`
1127
1157
  : renderStateMarkdown(mode, projected, manifest),
1158
+ ...warningStderr(),
1128
1159
  };
1129
1160
  }
1130
1161
  if (hasFlag(args, "--compact")) {
@@ -1134,6 +1165,7 @@ async function handleRead(args: readonly string[], cwd: string): Promise<StateCo
1134
1165
  stdout: hasFlag(args, "--json")
1135
1166
  ? `${JSON.stringify(compact, null, 2)}\n`
1136
1167
  : renderStateMarkdown(mode, envelope, manifest),
1168
+ ...warningStderr(),
1137
1169
  };
1138
1170
  }
1139
1171
  return {
@@ -1141,12 +1173,13 @@ async function handleRead(args: readonly string[], cwd: string): Promise<StateCo
1141
1173
  stdout: hasFlag(args, "--json")
1142
1174
  ? `${JSON.stringify(envelope, null, 2)}\n`
1143
1175
  : renderStateMarkdown(mode, envelope, manifest),
1176
+ ...warningStderr(),
1144
1177
  };
1145
1178
  }
1146
1179
  const filePath = activeStateFile(cwd, selectors.gjcSessionId);
1147
- const existingRaw = await readJsonValue(filePath);
1180
+ const existingRaw = await readJsonValue(filePath, warning => warnings.push(warning));
1148
1181
  const existing = isPlainObject(existingRaw) ? existingRaw : null;
1149
- return { status: 0, stdout: `${JSON.stringify(existing ?? {}, null, 2)}\n` };
1182
+ return { status: 0, stdout: `${JSON.stringify(existing ?? {}, null, 2)}\n`, ...warningStderr() };
1150
1183
  }
1151
1184
 
1152
1185
  async function handleStatus(args: readonly string[], cwd: string): Promise<StateCommandResult> {
@@ -1159,7 +1192,8 @@ async function handleStatus(args: readonly string[], cwd: string): Promise<State
1159
1192
  );
1160
1193
  }
1161
1194
  const filePath = modeStateFile(cwd, mode, selectors.gjcSessionId);
1162
- const existing = await readWorkflowStateJson(cwd, mode, selectors.gjcSessionId);
1195
+ const warnings: string[] = [];
1196
+ const existing = await readWorkflowStateJson(cwd, mode, selectors.gjcSessionId, warning => warnings.push(warning));
1163
1197
  const summary = buildStateStatusSummary(
1164
1198
  mode,
1165
1199
  { skill: mode, state: existing, storage_path: filePath },
@@ -1169,6 +1203,7 @@ async function handleStatus(args: readonly string[], cwd: string): Promise<State
1169
1203
  return {
1170
1204
  status: 0,
1171
1205
  stdout: hasFlag(args, "--json") ? `${JSON.stringify(summary, null, 2)}\n` : renderStateStatusLine(summary),
1206
+ ...(warnings.length ? { stderr: warnings.map(warning => `${warning}\n`).join("") } : {}),
1172
1207
  };
1173
1208
  }
1174
1209
 
@@ -1603,7 +1638,7 @@ async function handleHandoffUnlocked(args: readonly string[], cwd: string): Prom
1603
1638
  toPhase: "handoff",
1604
1639
  });
1605
1640
  await updateWorkflowTransactionJournal(cwd, sessionId, mutationId, { steps: ["caller-mode-state"] });
1606
- if (callerWrite.warning) process.stderr.write(`${callerWrite.warning}\n`);
1641
+ if (callerWrite.warning) emitStateWarning(callerWrite.warning);
1607
1642
  const stampedCallerReceipt = isPlainObject(callerWrite.stamped.receipt) ? callerWrite.stamped.receipt : {};
1608
1643
  await syncSkillActiveState({
1609
1644
  cwd,
@@ -1646,6 +1681,7 @@ async function handleHandoffUnlocked(args: readonly string[], cwd: string): Prom
1646
1681
  active_state: activeStateFile(cwd, sessionId),
1647
1682
  },
1648
1683
  }),
1684
+ ...(callerWrite.warning ? { stderr: `${callerWrite.warning}\n` } : {}),
1649
1685
  };
1650
1686
  }
1651
1687
 
@@ -1746,7 +1782,7 @@ async function handleHandoffUnlocked(args: readonly string[], cwd: string): Prom
1746
1782
  );
1747
1783
  const stampedCallerReceipt = isPlainObject(callerWrite.stamped.receipt) ? callerWrite.stamped.receipt : {};
1748
1784
  const stampedCalleeReceipt = isPlainObject(calleeWrite.stamped.receipt) ? calleeWrite.stamped.receipt : {};
1749
- for (const warning of warnings) process.stderr.write(`${warning}\n`);
1785
+ for (const warning of warnings) emitStateWarning(warning);
1750
1786
  if (process.env.GJC_STATE_HANDOFF_FAIL_AFTER_CALLER === mutationId) {
1751
1787
  throw new StateCommandError(1, `injected handoff failure after caller write for ${mutationId}`);
1752
1788
  }
@@ -1818,6 +1854,7 @@ async function handleHandoffUnlocked(args: readonly string[], cwd: string): Prom
1818
1854
  active_state: activeStateFile(cwd, sessionId),
1819
1855
  },
1820
1856
  }),
1857
+ ...(warnings.length ? { stderr: warnings.map(warning => `${warning}\n`).join("") } : {}),
1821
1858
  };
1822
1859
  }
1823
1860
 
@@ -298,7 +298,7 @@ export function workflowEnvelopeContentSha256(value: unknown): string {
298
298
  .update(JSON.stringify(canonicalizeJson(withoutReceiptChecksum(value))))
299
299
  .digest("hex");
300
300
  }
301
- function isNativeDeepInterviewV1(value: Record<string, unknown>): boolean {
301
+ export function isNativeDeepInterviewV1(value: Record<string, unknown>): boolean {
302
302
  if (value.skill !== "deep-interview") return false;
303
303
  return value.schema_version === 1 || (isPlainObject(value.state) && value.state.schema_version === 1);
304
304
  }
@@ -3,6 +3,7 @@ import * as path from "node:path";
3
3
  import { logger } from "@gajae-code/utils";
4
4
  import type { SkillDiscoverySettings } from "../config/skill-settings-defaults";
5
5
  import { detectDeepInterviewPlaintextAskLeak } from "../deep-interview/plaintext-gate-guard";
6
+ import { scoreToUnits } from "../gjc-runtime/deep-interview-ambiguity";
6
7
  import { activeSnapshotPath, modeStatePath as sessionModeStatePath } from "../gjc-runtime/session-layout";
7
8
  import { resolveGjcSessionForRead } from "../gjc-runtime/session-resolution";
8
9
  import { ModeStateSchema, SkillActiveStateSchema } from "../gjc-runtime/state-schema";
@@ -410,8 +411,29 @@ async function seedSkillActivationState(
410
411
  ...(input.turnId ? { turn_id: input.turnId } : {}),
411
412
  };
412
413
  if (skill === "deep-interview") {
413
- modeState.threshold = DEFAULT_DEEP_INTERVIEW_AMBIGUITY_THRESHOLD;
414
+ const threshold = DEFAULT_DEEP_INTERVIEW_AMBIGUITY_THRESHOLD;
415
+ const thresholdUnits = scoreToUnits(threshold);
416
+ modeState.schema_version = 1;
417
+ modeState.resolution = "standard";
418
+ modeState.threshold = threshold;
419
+ modeState.threshold_units = thresholdUnits;
414
420
  modeState.threshold_source = "default";
421
+ modeState.state = {
422
+ setup: { status: "unresolved" },
423
+ type: "greenfield",
424
+ intent_contract_required: true,
425
+ rounds: [],
426
+ established_facts: [],
427
+ topology: { status: "pending", components: [], deferred_components: [] },
428
+ ontology_snapshots: [],
429
+ auto_researched_rounds: [],
430
+ auto_answered_rounds: [],
431
+ architect_failures: 0,
432
+ current_ambiguity: 1.0,
433
+ threshold,
434
+ threshold_units: thresholdUnits,
435
+ threshold_source: "default",
436
+ };
415
437
  }
416
438
 
417
439
  await readExistingStateForMutation(initializedStatePath);