@gajae-code/coding-agent 0.21.0 → 0.21.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 (111) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/types/config/autorouting-contract.d.ts +4 -4
  3. package/dist/types/config/autorouting-tier-map.d.ts +1 -1
  4. package/dist/types/config/keybindings.d.ts +1 -5
  5. package/dist/types/config/model-profile-activation.d.ts +30 -3
  6. package/dist/types/config/model-registry.d.ts +2 -0
  7. package/dist/types/config/models-config-schema.d.ts +8 -0
  8. package/dist/types/config/settings-schema.d.ts +7 -3
  9. package/dist/types/coordinator-mcp/canonical-json.d.ts +7 -0
  10. package/dist/types/extensibility/gjc-plugins/metadata.d.ts +1 -1
  11. package/dist/types/harness-control-plane/receipts.d.ts +1 -1
  12. package/dist/types/modes/components/settings-selector.d.ts +5 -2
  13. package/dist/types/modes/controllers/command-controller.d.ts +1 -1
  14. package/dist/types/modes/controllers/input-controller.d.ts +12 -0
  15. package/dist/types/modes/controllers/selector-controller.d.ts +1 -1
  16. package/dist/types/modes/interactive-mode.d.ts +1 -1
  17. package/dist/types/modes/shared/agent-wire/workflow-gate-schema.d.ts +1 -1
  18. package/dist/types/modes/types.d.ts +1 -1
  19. package/dist/types/session/agent-session.d.ts +101 -6
  20. package/dist/types/session/session-manager.d.ts +124 -9
  21. package/dist/types/setup/provider-onboarding.d.ts +55 -2
  22. package/dist/types/slash-commands/builtin-registry.d.ts +11 -0
  23. package/dist/types/utils/clipboard.d.ts +18 -0
  24. package/dist/types/utils/pasted-image-path.d.ts +2 -0
  25. package/dist/types/web/search/providers/keenable.d.ts +30 -0
  26. package/dist/types/web/search/types.d.ts +2 -2
  27. package/package.json +7 -7
  28. package/scripts/generate-sdk-operation-inventory.ts +28 -0
  29. package/src/cli/doctor/config-repairs.ts +1 -4
  30. package/src/cli/local-provider-smoke.ts +1 -4
  31. package/src/cli/public-command-help.ts +1 -1
  32. package/src/config/autorouting-contract.ts +5 -8
  33. package/src/config/autorouting-tier-map.ts +1 -1
  34. package/src/config/keybindings.ts +1 -2
  35. package/src/config/model-profile-activation.ts +332 -28
  36. package/src/config/model-registry.ts +156 -8
  37. package/src/config/models-config-schema.ts +27 -0
  38. package/src/config/settings-schema.ts +6 -0
  39. package/src/coordinator-mcp/canonical-json.ts +15 -0
  40. package/src/coordinator-mcp/policy.ts +1 -0
  41. package/src/coordinator-mcp/question-gate-codec.ts +1 -2
  42. package/src/coordinator-mcp/question-state.ts +2 -12
  43. package/src/coordinator-mcp/server.ts +1 -10
  44. package/src/customization/import.ts +1 -5
  45. package/src/discovery/mcp-compat.ts +1 -5
  46. package/src/discovery/mcp-json.ts +1 -4
  47. package/src/edit/notebook.ts +1 -5
  48. package/src/extensibility/gjc-plugins/lifecycle.ts +1 -3
  49. package/src/extensibility/gjc-plugins/metadata.ts +2 -5
  50. package/src/extensibility/gjc-plugins/schema.ts +1 -4
  51. package/src/gjc-runtime/deep-interview-crystallize.ts +1 -4
  52. package/src/gjc-runtime/deep-interview-runtime.ts +1 -4
  53. package/src/gjc-runtime/state-renderer.ts +1 -5
  54. package/src/gjc-runtime/tmux-owner-isolation.ts +1 -3
  55. package/src/gjc-runtime/ultragoal-owner-loss-recovery.ts +1 -4
  56. package/src/gjc-runtime/ultragoal-succession.ts +1 -4
  57. package/src/goals/continuation-timeout-guard.ts +1 -4
  58. package/src/harness-control-plane/receipts.ts +1 -1
  59. package/src/internal-urls/docs-index.generated.ts +4 -4
  60. package/src/migrate/mcp-mapper.ts +2 -4
  61. package/src/modes/components/hook-editor.ts +4 -8
  62. package/src/modes/components/hook-selector.ts +3 -1
  63. package/src/modes/components/settings-selector.ts +26 -2
  64. package/src/modes/controllers/command-controller.ts +4 -98
  65. package/src/modes/controllers/extension-ui-controller.ts +6 -14
  66. package/src/modes/controllers/goal-mode-controller.ts +4 -4
  67. package/src/modes/controllers/input-controller.ts +110 -46
  68. package/src/modes/controllers/plan-mode-controller.ts +6 -10
  69. package/src/modes/controllers/selector-controller.ts +66 -23
  70. package/src/modes/controllers/todo-command-controller.ts +2 -2
  71. package/src/modes/interactive-mode.ts +2 -2
  72. package/src/modes/prompt-action-autocomplete.ts +1 -1
  73. package/src/modes/runtime-init.ts +4 -4
  74. package/src/modes/shared/agent-wire/workflow-gate-schema.ts +1 -1
  75. package/src/modes/types.ts +1 -1
  76. package/src/modes/utils/hotkeys-markdown.ts +1 -1
  77. package/src/runtime-mcp/client.ts +1 -4
  78. package/src/runtime-mcp/elicitation.ts +1 -5
  79. package/src/runtime-mcp/protocol.ts +2 -4
  80. package/src/sdk/broker/lifecycle-ledger.ts +1 -0
  81. package/src/sdk/broker/lifecycle.ts +1 -0
  82. package/src/sdk/cli/rows.ts +2 -3
  83. package/src/sdk/cli/session-cli.ts +2 -8
  84. package/src/sdk/host/query/cursor.ts +1 -0
  85. package/src/sdk/host/reverse-leases.ts +1 -0
  86. package/src/sdk/lifecycle/service.ts +1 -0
  87. package/src/sdk/protocol/operation-inventory.generated.json +154 -0
  88. package/src/session/agent-session.ts +1877 -224
  89. package/src/session/btw-prefix-ledger.ts +1 -4
  90. package/src/session/internal/managed-gc-retirement-codec.ts +1 -4
  91. package/src/session/session-manager.ts +732 -224
  92. package/src/session/task-artifact-owner-codec.ts +1 -4
  93. package/src/session-import/claude.ts +1 -4
  94. package/src/session-import/detect.ts +1 -6
  95. package/src/session-import/provider-codex.ts +1 -6
  96. package/src/session-import/provider-service.ts +4 -0
  97. package/src/setup/hermes-setup.ts +1 -4
  98. package/src/setup/provider-onboarding.ts +514 -26
  99. package/src/slash-commands/builtin-registry.ts +26 -13
  100. package/src/slash-commands/helpers/todo.ts +3 -1
  101. package/src/task/delegation-hint.ts +1 -4
  102. package/src/task/executor.ts +4 -2
  103. package/src/task/provider-retry-status.ts +1 -4
  104. package/src/tools/json-tree.ts +1 -4
  105. package/src/tools/recipe/runners/pkg.ts +1 -5
  106. package/src/utils/clipboard.ts +155 -2
  107. package/src/utils/mac-file-urls.applescript +37 -0
  108. package/src/utils/pasted-image-path.ts +5 -0
  109. package/src/web/search/provider.ts +6 -0
  110. package/src/web/search/providers/keenable.ts +207 -0
  111. package/src/web/search/types.ts +2 -0
@@ -77,9 +77,10 @@ import {
77
77
  type RoutingSettingsService,
78
78
  } from "../../sdk/routing-settings";
79
79
  import { clearPersistentPinForRemovedRows } from "../../session/account-inventory";
80
- import type {
81
- AgentSessionProfileInstalledOverrideState,
82
- DefaultFallbackRuntimeState,
80
+ import {
81
+ type AgentSessionProfileInstalledOverrideState,
82
+ type DefaultFallbackRuntimeState,
83
+ SharedControlPublicationError,
83
84
  } from "../../session/agent-session";
84
85
  import { CREDENTIAL_STORE_UNREADABLE_MESSAGE } from "../../session/credential-store-errors";
85
86
  import { type SessionInfo, SessionManager } from "../../session/session-manager";
@@ -128,6 +129,7 @@ import {
128
129
  } from "../../setup/model-onboarding-guidance";
129
130
  import {
130
131
  addApiCompatibleProvider,
132
+ assertProviderConfigLoaded,
131
133
  formatProviderSetupResult,
132
134
  probeOpenAIModelsList,
133
135
  reloadAndRefreshDiscoveryCatalog,
@@ -324,6 +326,18 @@ export class SelectorController {
324
326
  restoreProfileState: boolean = true,
325
327
  ): Promise<never> {
326
328
  if (!restoreLiveModel && !restoreProfileState) throw error;
329
+ // An unknown or committed-but-unapplied shared outcome already closed the session:
330
+ // its transcript may hold the forward write, so nothing is compensated over it (#7824).
331
+ if (
332
+ this.ctx.session.sessionLifecycle?.disposed ||
333
+ (error instanceof SharedControlPublicationError &&
334
+ (error.code === "unknown" || error.code === "committed_not_applied"))
335
+ )
336
+ throw error;
337
+ // A shared session restores the chain, resume default and live model as one admitted
338
+ // publication of only what actually differs, so a forward write known not to have
339
+ // happened leaves nothing to compensate.
340
+ const sharedCompensation = this.ctx.session.usesSharedControlPublication?.() === true;
327
341
  // Validate the durable owner under the same lock as compensation: the
328
342
  // in-memory settings may not have seen another process's winning commit.
329
343
  try {
@@ -384,16 +398,32 @@ export class SelectorController {
384
398
  ? this.ctx.settings.clearOverride("modelProfile.default")
385
399
  : this.ctx.settings.override("modelProfile.default", snapshot.profileOverride),
386
400
  );
401
+ if (sharedCompensation) {
402
+ try {
403
+ await this.ctx.session.restoreModelSelectionForRollback(
404
+ restoreLiveModel ? snapshot.model : this.ctx.session.model,
405
+ restoreLiveModel ? snapshot.thinkingLevel : this.ctx.session.thinkingLevel,
406
+ {
407
+ defaultChain: restoreProfileState ? { state: snapshot.chain } : undefined,
408
+ resumeDefault: restoreLiveModel ? { selector: snapshot.resumeDefaultSelector } : undefined,
409
+ },
410
+ );
411
+ } catch (rollbackError) {
412
+ rollbackErrors.push(rollbackError);
413
+ }
414
+ }
387
415
  if (restoreProfileState) {
388
- restore(() =>
389
- this.ctx.session.setConfiguredModelChain(
390
- "default",
391
- snapshot.chain?.entries ?? [],
392
- snapshot.chain?.origin ?? "rollback",
393
- snapshot.chain?.identity,
394
- snapshot.chain?.explicitHead ?? true,
395
- ),
396
- );
416
+ if (!sharedCompensation) {
417
+ restore(() =>
418
+ this.ctx.session.setConfiguredModelChain(
419
+ "default",
420
+ snapshot.chain?.entries ?? [],
421
+ snapshot.chain?.origin ?? "rollback",
422
+ snapshot.chain?.identity,
423
+ snapshot.chain?.explicitHead ?? true,
424
+ ),
425
+ );
426
+ }
397
427
  restore(() => this.ctx.session.restoreDefaultFallbackRuntimeState(snapshot.fallbackRuntimeState));
398
428
  restore(() => {
399
429
  if (snapshot.canonicalVariant) {
@@ -406,7 +436,7 @@ export class SelectorController {
406
436
  }
407
437
  });
408
438
  }
409
- if (restoreLiveModel) {
439
+ if (restoreLiveModel && !sharedCompensation) {
410
440
  restore(() => this.ctx.session.recordResumeDefaultModel(snapshot.resumeDefaultSelector));
411
441
  }
412
442
  restore(() => this.ctx.session.setActiveModelProfile?.(snapshot.activeProfile));
@@ -420,7 +450,7 @@ export class SelectorController {
420
450
  } catch (rollbackError) {
421
451
  rollbackErrors.push(rollbackError);
422
452
  }
423
- if (restoreLiveModel) {
453
+ if (restoreLiveModel && !sharedCompensation) {
424
454
  try {
425
455
  await this.ctx.session.restoreModelSelectionForRollback(snapshot.model, snapshot.thinkingLevel);
426
456
  } catch (rollbackError) {
@@ -916,6 +946,12 @@ export class SelectorController {
916
946
  } else {
917
947
  await this.ctx.session.modelRegistry.refresh("offline", this.ctx.session.credentialSessionId);
918
948
  }
949
+ assertProviderConfigLoaded(
950
+ this.ctx.session.modelRegistry,
951
+ result.providerId,
952
+ result.modelsPath,
953
+ result.credentialSource,
954
+ );
919
955
  await this.ctx.notifyConfigChanged?.();
920
956
  // A late settle after Esc-cancel or a mid-submit revision
921
957
  // must not drive completion UI: done() restores the
@@ -1366,7 +1402,7 @@ export class SelectorController {
1366
1402
  * Most settings are saved directly via SettingsManager in the definitions.
1367
1403
  * This handles side effects and session-specific settings.
1368
1404
  */
1369
- handleSettingChange(id: string, value: unknown): void {
1405
+ handleSettingChange(id: string, value: unknown): void | Promise<void> {
1370
1406
  // Discovery provider toggles
1371
1407
  if (id.startsWith("discovery.")) {
1372
1408
  const providerId = id.replace("discovery.", "");
@@ -1394,11 +1430,15 @@ export class SelectorController {
1394
1430
  this.ctx.session.setToolInterruptPolicy(value as "abort_tools" | "finish_tools");
1395
1431
  break;
1396
1432
  case "thinkingLevel":
1397
- case "defaultThinkingLevel":
1398
- this.ctx.session.setThinkingLevel(value as ThinkingLevel, true);
1399
- this.ctx.statusLine.invalidate();
1400
- this.ctx.updateEditorBorderColor();
1401
- break;
1433
+ case "defaultThinkingLevel": {
1434
+ const session = this.ctx.session;
1435
+ return session.setThinkingLevelForControl(value as ThinkingLevel, true).then(() => {
1436
+ if (this.ctx.session !== session || this.ctx.isStopped?.()) return;
1437
+ this.ctx.statusLine.invalidate();
1438
+ this.ctx.updateEditorBorderColor();
1439
+ this.ctx.ui.requestRender();
1440
+ });
1441
+ }
1402
1442
 
1403
1443
  case "modelProfile.default": {
1404
1444
  // Applying the default profile live mirrors the /model preset flow so the
@@ -1811,7 +1851,7 @@ export class SelectorController {
1811
1851
  },
1812
1852
  });
1813
1853
  if (thinkingLevel && thinkingLevel !== ThinkingLevel.Inherit) {
1814
- this.ctx.session.setThinkingLevel(thinkingLevel);
1854
+ await this.ctx.session.setThinkingLevelForSession(thinkingLevel);
1815
1855
  }
1816
1856
  }
1817
1857
  if (!includesDefault) {
@@ -1888,7 +1928,7 @@ export class SelectorController {
1888
1928
  });
1889
1929
 
1890
1930
  if (thinkingLevel && thinkingLevel !== ThinkingLevel.Inherit) {
1891
- this.ctx.session.setThinkingLevel(thinkingLevel);
1931
+ await this.ctx.session.setThinkingLevelForSession(thinkingLevel);
1892
1932
  }
1893
1933
  } catch (error) {
1894
1934
  await this.#restoreDefaultAssignmentRollback(
@@ -2336,7 +2376,10 @@ export class SelectorController {
2336
2376
  this.ctx.ui.requestRender();
2337
2377
  },
2338
2378
  (entryId, label) => {
2339
- this.ctx.sessionManager.appendLabelChange(entryId, label);
2379
+ // The tree navigator's submit callback is synchronous, so the label goes
2380
+ // through the session's admitted background path: after a canonical shared
2381
+ // append the legacy append is refused and the label would be lost on reload.
2382
+ void this.ctx.session.appendLabelChangeInBackground(entryId, label);
2340
2383
  this.ctx.ui.requestRender();
2341
2384
  },
2342
2385
  settings.get("treeFilterMode"),
@@ -478,7 +478,7 @@ export class TodoCommandController {
478
478
  this.ctx.setTodos(nextPhases);
479
479
 
480
480
  // 2. Persist for reload survival via custom session entry.
481
- this.ctx.sessionManager.appendCustomEntry(USER_TODO_EDIT_CUSTOM_TYPE, { phases: nextPhases });
481
+ this.ctx.session.appendCustomEntryInBackground(USER_TODO_EDIT_CUSTOM_TYPE, { phases: nextPhases });
482
482
 
483
483
  // 3. Inject system reminder so the agent learns about the change next turn.
484
484
  const reminderText = buildSystemReminder(action, nextPhases);
@@ -489,7 +489,7 @@ export class TodoCommandController {
489
489
  timestamp: Date.now(),
490
490
  };
491
491
  this.ctx.agent.appendMessage(message);
492
- this.ctx.sessionManager.appendMessage(message);
492
+ this.ctx.session.appendMessageInBackground(message);
493
493
  return true;
494
494
  }
495
495
  }
@@ -2410,8 +2410,8 @@ export class InteractiveMode implements InteractiveModeContext {
2410
2410
  return this.#commandController.handleShareCommand();
2411
2411
  }
2412
2412
 
2413
- handleCopyCommand(sub?: string) {
2414
- return this.#commandController.handleCopyCommand(sub);
2413
+ handleCopyCommand() {
2414
+ return this.#commandController.handleCopyCommand();
2415
2415
  }
2416
2416
 
2417
2417
  handleTodoCommand(args: string): Promise<void> {
@@ -461,7 +461,7 @@ export function createPromptActionAutocompleteProvider(
461
461
  },
462
462
  {
463
463
  id: "paste-image",
464
- label: "Paste image from clipboard",
464
+ label: "Paste image or text from clipboard",
465
465
  description: options.keybindings.getDisplayString("app.clipboard.pasteImage"),
466
466
  keywords: ["paste", "image", "clipboard", "screenshot", "attach", "vision"],
467
467
  execute: options.pasteImage,
@@ -104,10 +104,10 @@ export async function initializeExtensions(session: AgentSession, options: Initi
104
104
  return send;
105
105
  },
106
106
  appendEntry: (customType, data) => {
107
- session.sessionManager.appendCustomEntry(customType, data);
107
+ session.appendCustomEntryInBackground(customType, data);
108
108
  },
109
109
  setLabel: (targetId, label) => {
110
- session.sessionManager.appendLabelChange(targetId, label);
110
+ session.appendLabelChangeInBackground(targetId, label);
111
111
  },
112
112
  getActiveTools: () => session.getActiveToolNames(),
113
113
  getAllTools: () => session.getAllToolNames(),
@@ -132,7 +132,7 @@ export async function initializeExtensions(session: AgentSession, options: Initi
132
132
  getThinkingScopeForControl: () => session.getThinkingScopeForControl(),
133
133
  getSessionName: () => session.sessionManager.getSessionName(),
134
134
  setSessionName: async name => {
135
- await session.sessionManager.setSessionName(name, "user");
135
+ await session.setSessionName(name, "user");
136
136
  },
137
137
  },
138
138
  // ExtensionContextActions
@@ -451,7 +451,7 @@ export async function initializeExtensions(session: AgentSession, options: Initi
451
451
  await session.reload();
452
452
  return { reloaded: true };
453
453
  case "service_tier.set":
454
- session.setServiceTier(input.tier as never);
454
+ await session.setServiceTier(input.tier as never);
455
455
  return { changed: true };
456
456
  case "queue.message.remove": {
457
457
  const removed = session.removeQueuedMessageForEditing(String(input.id));
@@ -57,7 +57,7 @@ export class WorkflowGateSchemaError extends Error {
57
57
  }
58
58
  }
59
59
 
60
- /** Canonical (stable-key-ordered) JSON serialization used for hashing. */
60
+ /** Canonical (stable-key-ordered) JSON serialization used for hashing. Byte-identical to harness-control-plane/receipts.ts canonicalJson. */
61
61
  export function canonicalJson(value: unknown): string {
62
62
  if (value === null || typeof value !== "object") return JSON.stringify(value) ?? "null";
63
63
  if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
@@ -385,7 +385,7 @@ export interface InteractiveModeContext {
385
385
  // Command handling
386
386
  handleExportCommand(text: string): Promise<void>;
387
387
  handleShareCommand(): Promise<void>;
388
- handleCopyCommand(sub?: string): void;
388
+ handleCopyCommand(): void;
389
389
  handleTodoCommand(args: string): Promise<void>;
390
390
  handleSessionCommand(): Promise<void>;
391
391
  handleJobsCommand(): Promise<void>;
@@ -80,7 +80,7 @@ export function buildHotkeysMarkdown(bindings: HotkeysMarkdownBindings): string
80
80
  `| ${displayAppKey("app.tool.backgroundFold")} twice | Fold supported foreground bash into a background job |`,
81
81
  `| ${displayAppKey("app.thinking.toggle")} | Toggle thinking block visibility |`,
82
82
  `| ${displayAppKey("app.editor.external")} | Edit message in external editor |`,
83
- `| ${displayAppKey("app.clipboard.pasteImage")} | Paste image from clipboard |`,
83
+ `| ${displayAppKey("app.clipboard.pasteImage")} | Paste image or text from clipboard |`,
84
84
  `| ${displayAppKey("app.stt.toggle")} | Toggle speech-to-text recording |`,
85
85
  `| ${displayAppKey("app.irc.sidebar.toggle")} | Toggle IRC sidebar |`,
86
86
  "| `?` | Show help / shortcuts |",
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import * as path from "node:path";
9
9
  import * as url from "node:url";
10
- import { getProjectDir, logger, withTimeout } from "@gajae-code/utils";
10
+ import { getProjectDir, isRecord, logger, withTimeout } from "@gajae-code/utils";
11
11
  import {
12
12
  buildXMcpParamHeaders,
13
13
  classifyMcpProbeFailure,
@@ -67,9 +67,6 @@ const CLIENT_INFO = {
67
67
  name: "gjc-coding-agent",
68
68
  version: "1.0.0",
69
69
  };
70
- function isRecord(value: unknown): value is Record<string, unknown> {
71
- return typeof value === "object" && value !== null && !Array.isArray(value);
72
- }
73
70
 
74
71
  function decodeInitializeResult(value: unknown): MCPInitializeResult {
75
72
  if (
@@ -1,4 +1,4 @@
1
- import { untilAborted } from "@gajae-code/utils";
1
+ import { isRecord, untilAborted } from "@gajae-code/utils";
2
2
  import type { ExtensionUIContext } from "../extensibility/extensions/types";
3
3
  import type { AskAnswerSource, AskRemoteReceipt } from "../tools";
4
4
  import type { MCPInputRequestHandler } from "./types";
@@ -15,10 +15,6 @@ interface FormField {
15
15
  choices?: string[];
16
16
  }
17
17
 
18
- function isRecord(value: unknown): value is Record<string, unknown> {
19
- return typeof value === "object" && value !== null && !Array.isArray(value);
20
- }
21
-
22
18
  function displayText(value: string): string {
23
19
  return value.replace(/[\p{Cc}\p{Cf}\u2028\u2029]/gu, " ").slice(0, 4000);
24
20
  }
@@ -19,6 +19,8 @@
19
19
  * `Mcp-Method`, and `Mcp-Name` headers.
20
20
  */
21
21
 
22
+ import { isRecord } from "@gajae-code/utils";
23
+
22
24
  // =============================================================================
23
25
  // Protocol versions and eras
24
26
  // =============================================================================
@@ -198,10 +200,6 @@ export interface XMcpHeaderBindingsResult {
198
200
  violations: string[];
199
201
  }
200
202
 
201
- function isRecord(value: unknown): value is Record<string, unknown> {
202
- return typeof value === "object" && value !== null && !Array.isArray(value);
203
- }
204
-
205
203
  /**
206
204
  * Collect `x-mcp-header` bindings from a tool `inputSchema`, enforcing the
207
205
  * specification constraints: field-name token syntax, primitive (non-number)
@@ -206,6 +206,7 @@ export function isLifecycleLedgerEntry(value: unknown): value is LifecycleLedger
206
206
  (entry.fingerprint === undefined || typeof entry.fingerprint === "string")
207
207
  );
208
208
  }
209
+ /** Ledger digests: bigint becomes a decimal string and `undefined`-valued keys are omitted. */
209
210
  function canonicalJson(value: unknown): string {
210
211
  if (typeof value === "bigint") return JSON.stringify(value.toString());
211
212
  if (value === null || typeof value !== "object") return JSON.stringify(value);
@@ -2402,6 +2402,7 @@ type LifecycleFailureArtifact = EffectMarker &
2402
2402
  transcript?: LifecycleTranscriptEvidence;
2403
2403
  };
2404
2404
 
2405
+ /** Lifecycle artifact digests: byte-stable; `undefined`-valued keys are kept (unlike ./canonical-json.ts, which omits them). */
2405
2406
  function canonicalJson(value: unknown): string {
2406
2407
  if (value === null || typeof value !== "object") return JSON.stringify(value);
2407
2408
  if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
@@ -10,6 +10,7 @@
10
10
 
11
11
  import { isRecord } from "@gajae-code/utils";
12
12
  import { sessionOwnershipV1 } from "../broker/session-scope";
13
+ import { isSecretConfigKey } from "../protocol/adapter-validation";
13
14
 
14
15
  export const SESSION_ROWS_VERSION = 2;
15
16
 
@@ -145,15 +146,13 @@ export class TailRevisionBuffer {
145
146
  }
146
147
  }
147
148
 
148
- const SECRET_FIELD = /(?:secret|token|password|credential|authorization|api[_-]?key)/i;
149
-
150
149
  /** Recursively removes secret-shaped fields (defense in depth for DTO output). */
151
150
  export function stripSecretFields(value: unknown): unknown {
152
151
  if (Array.isArray(value)) return value.map(stripSecretFields);
153
152
  if (!value || typeof value !== "object") return value;
154
153
  const out: Record<string, unknown> = {};
155
154
  for (const [key, nested] of Object.entries(value)) {
156
- if (SECRET_FIELD.test(key)) continue;
155
+ if (isSecretConfigKey(key)) continue;
157
156
  out[key] = stripSecretFields(nested);
158
157
  }
159
158
  return out;
@@ -40,6 +40,7 @@ import type {
40
40
  import { isSessionLifecycleMutationOperation } from "../lifecycle/service";
41
41
  import { PROMPT_CLIENT_REF_MAX_LENGTH } from "../prompt-status";
42
42
  import {
43
+ containsSecretConfigKey,
43
44
  validateAdapterControl,
44
45
  validateAdapterSecretFields,
45
46
  validateRequiredPromptText,
@@ -125,7 +126,6 @@ export interface RetainedTranscriptTailReader {
125
126
  readRange(start: number, end: number): Promise<Uint8Array>;
126
127
  }
127
128
 
128
- const SECRET_FIELD = /(?:secret|token|password|credential|authorization|api[_-]?key)/i;
129
129
  const SDK_SESSION_CLI_LIFECYCLE_ACTOR = { id: "gjc-sdk-session-cli", namespace: "sdk:session-cli" } as const;
130
130
  const ROUTER_START_TIMEOUT_MS = 10_000;
131
131
  const ROUTER_STOP_TIMEOUT_MS = 5_000;
@@ -475,12 +475,6 @@ export async function readSecureJsonInputFile(filePath: string): Promise<string>
475
475
  }
476
476
  }
477
477
 
478
- function containsSecretField(value: unknown): boolean {
479
- if (Array.isArray(value)) return value.some(containsSecretField);
480
- if (!isRecord(value)) return false;
481
- return Object.entries(value).some(([key, nested]) => SECRET_FIELD.test(key) || containsSecretField(nested));
482
- }
483
-
484
478
  async function inputFromArgs(args: SdkSessionCliArgs): Promise<JsonRecord> {
485
479
  const sources = [
486
480
  args.jsonInput !== undefined,
@@ -490,7 +484,7 @@ async function inputFromArgs(args: SdkSessionCliArgs): Promise<JsonRecord> {
490
484
  if (sources > 1) throw new SdkSessionCliError("usage", "Use only one JSON input source.", 2);
491
485
  if (args.jsonInput !== undefined) {
492
486
  const input = parseInput(args.jsonInput, "--json-input");
493
- if (containsSecretField(input))
487
+ if (containsSecretConfigKey(input))
494
488
  throw new SdkSessionCliError(
495
489
  "secret_field_forbidden",
496
490
  "Secret values must use --json-input-file or --json-input-stdin.",
@@ -98,6 +98,7 @@ function canonicalise(value: unknown): unknown {
98
98
  return value;
99
99
  }
100
100
 
101
+ /** Cursor MAC basis: localeCompare key order, then JSON.stringify (drops undefined properties, array holes become null). */
101
102
  function canonicalJson(value: unknown): string {
102
103
  return JSON.stringify(canonicalise(value));
103
104
  }
@@ -63,6 +63,7 @@ export interface ReverseLeaseOptions {
63
63
  onDefinitionsRemoved?: (capability: string) => void;
64
64
  }
65
65
 
66
+ /** Fingerprint serializer: localeCompare key order, undefined entries dropped, and `"null"` for top-level undefined; not interchangeable with sdk/broker/canonical-json.ts (code-unit order). */
66
67
  function canonicalJson(value: unknown): string {
67
68
  if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
68
69
  if (value && typeof value === "object") {
@@ -462,6 +462,7 @@ const RETRYABLE_BROKER_ERRORS = new Set([
462
462
  "startup_admission_timeout",
463
463
  ]);
464
464
 
465
+ /** Lifecycle idempotency digests: sorted keys, omits undefined-valued keys, and stringifies non-record values (undefined becomes the string "undefined"). */
465
466
  function canonicalJson(value: unknown): string {
466
467
  if (value === null) return "null";
467
468
  if (typeof value === "string" || typeof value === "boolean" || typeof value === "number")
@@ -4993,6 +4993,83 @@
4993
4993
  "testIds": "not_applicable"
4994
4994
  }
4995
4995
  },
4996
+ {
4997
+ "sourceId": "agent_session:appendCustomEntryForSession",
4998
+ "sourceFile": "packages/coding-agent/src/session/agent-session.ts",
4999
+ "sourceKind": "agent_session",
5000
+ "decision": "exclude",
5001
+ "rationale": "internal shared-session transcript publication for in-process extension and controller writers, not a user-facing SDK control seam",
5002
+ "exclusionMetadata": {
5003
+ "adapterMappings": "not_applicable",
5004
+ "testIds": "not_applicable"
5005
+ }
5006
+ },
5007
+ {
5008
+ "sourceId": "agent_session:appendCustomEntryInBackground",
5009
+ "sourceFile": "packages/coding-agent/src/session/agent-session.ts",
5010
+ "sourceKind": "agent_session",
5011
+ "decision": "exclude",
5012
+ "rationale": "internal shared-session transcript publication from synchronous in-process call sites, not a user-facing SDK control seam",
5013
+ "exclusionMetadata": {
5014
+ "adapterMappings": "not_applicable",
5015
+ "testIds": "not_applicable"
5016
+ }
5017
+ },
5018
+ {
5019
+ "sourceId": "agent_session:appendMessageInBackground",
5020
+ "sourceFile": "packages/coding-agent/src/session/agent-session.ts",
5021
+ "sourceKind": "agent_session",
5022
+ "decision": "exclude",
5023
+ "rationale": "internal shared-session transcript publication from synchronous in-process call sites, not a user-facing SDK control seam",
5024
+ "exclusionMetadata": {
5025
+ "adapterMappings": "not_applicable",
5026
+ "testIds": "not_applicable"
5027
+ }
5028
+ },
5029
+ {
5030
+ "sourceId": "agent_session:appendMessageForSession",
5031
+ "sourceFile": "packages/coding-agent/src/session/agent-session.ts",
5032
+ "sourceKind": "agent_session",
5033
+ "decision": "exclude",
5034
+ "rationale": "internal shared-session transcript publication for in-process writers, not a user-facing SDK control seam",
5035
+ "exclusionMetadata": {
5036
+ "adapterMappings": "not_applicable",
5037
+ "testIds": "not_applicable"
5038
+ }
5039
+ },
5040
+ {
5041
+ "sourceId": "agent_session:appendSessionRecapForSession",
5042
+ "sourceFile": "packages/coding-agent/src/session/agent-session.ts",
5043
+ "sourceKind": "agent_session",
5044
+ "decision": "exclude",
5045
+ "rationale": "internal shared-session recap publication behind the reviewed session recap surfaces, not an independent public SDK operation",
5046
+ "exclusionMetadata": {
5047
+ "adapterMappings": "not_applicable",
5048
+ "testIds": "not_applicable"
5049
+ }
5050
+ },
5051
+ {
5052
+ "sourceId": "agent_session:appendLabelChangeInBackground",
5053
+ "sourceFile": "packages/coding-agent/src/session/agent-session.ts",
5054
+ "sourceKind": "agent_session",
5055
+ "decision": "exclude",
5056
+ "rationale": "internal shared-session label publication for the local TUI tree navigator, not a user-facing SDK control seam",
5057
+ "exclusionMetadata": {
5058
+ "adapterMappings": "not_applicable",
5059
+ "testIds": "not_applicable"
5060
+ }
5061
+ },
5062
+ {
5063
+ "sourceId": "agent_session:appendModeChangeInBackground",
5064
+ "sourceFile": "packages/coding-agent/src/session/agent-session.ts",
5065
+ "sourceKind": "agent_session",
5066
+ "decision": "exclude",
5067
+ "rationale": "internal shared-session mode-change publication for plan/goal mode persistence, not a user-facing SDK control seam",
5068
+ "exclusionMetadata": {
5069
+ "adapterMappings": "not_applicable",
5070
+ "testIds": "not_applicable"
5071
+ }
5072
+ },
4996
5073
  {
4997
5074
  "sourceId": "agent_session:prompt",
4998
5075
  "sourceFile": "packages/coding-agent/src/session/agent-session.ts",
@@ -5922,6 +5999,28 @@
5922
5999
  "testIds": "not_applicable"
5923
6000
  }
5924
6001
  },
6002
+ {
6003
+ "sourceId": "agent_session:assertConfiguredModelChainWritable",
6004
+ "sourceFile": "packages/coding-agent/src/session/agent-session.ts",
6005
+ "sourceKind": "agent_session",
6006
+ "decision": "exclude",
6007
+ "rationale": "internal fail-closed guard before profile/fallback-chain writes on adopted shared sessions, not a user-facing SDK control seam",
6008
+ "exclusionMetadata": {
6009
+ "adapterMappings": "not_applicable",
6010
+ "testIds": "not_applicable"
6011
+ }
6012
+ },
6013
+ {
6014
+ "sourceId": "agent_session:setConfiguredModelChainForControl",
6015
+ "sourceFile": "packages/coding-agent/src/session/agent-session.ts",
6016
+ "sourceKind": "agent_session",
6017
+ "decision": "exclude",
6018
+ "rationale": "internal shared-publication wrapper over profile and fallback-chain state for controls that already committed settings, not a user-facing SDK control seam",
6019
+ "exclusionMetadata": {
6020
+ "adapterMappings": "not_applicable",
6021
+ "testIds": "not_applicable"
6022
+ }
6023
+ },
5925
6024
  {
5926
6025
  "sourceId": "agent_session:setConfiguredModelChain",
5927
6026
  "sourceFile": "packages/coding-agent/src/session/agent-session.ts",
@@ -6065,6 +6164,50 @@
6065
6164
  "testIds": "not_applicable"
6066
6165
  }
6067
6166
  },
6167
+ {
6168
+ "sourceId": "agent_session:usesSharedControlPublication",
6169
+ "sourceFile": "packages/coding-agent/src/session/agent-session.ts",
6170
+ "sourceKind": "agent_session",
6171
+ "decision": "exclude",
6172
+ "rationale": "internal shared-publication eligibility query for in-process control paths, not a user-facing SDK control seam",
6173
+ "exclusionMetadata": {
6174
+ "adapterMappings": "not_applicable",
6175
+ "testIds": "not_applicable"
6176
+ }
6177
+ },
6178
+ {
6179
+ "sourceId": "agent_session:withModelProfilePublication",
6180
+ "sourceFile": "packages/coding-agent/src/session/agent-session.ts",
6181
+ "sourceKind": "agent_session",
6182
+ "decision": "exclude",
6183
+ "rationale": "internal shared publication scope behind the reviewed model.profile.set seam, not an independent public SDK operation",
6184
+ "exclusionMetadata": {
6185
+ "adapterMappings": "not_applicable",
6186
+ "testIds": "not_applicable"
6187
+ }
6188
+ },
6189
+ {
6190
+ "sourceId": "agent_session:appendModelProfileActivationForControl",
6191
+ "sourceFile": "packages/coding-agent/src/session/agent-session.ts",
6192
+ "sourceKind": "agent_session",
6193
+ "decision": "exclude",
6194
+ "rationale": "internal shared transcript append behind the reviewed model.profile.set seam, not an independent public SDK operation",
6195
+ "exclusionMetadata": {
6196
+ "adapterMappings": "not_applicable",
6197
+ "testIds": "not_applicable"
6198
+ }
6199
+ },
6200
+ {
6201
+ "sourceId": "agent_session:publishCommittedModelProfileSessionState",
6202
+ "sourceFile": "packages/coding-agent/src/session/agent-session.ts",
6203
+ "sourceKind": "agent_session",
6204
+ "decision": "exclude",
6205
+ "rationale": "internal receipt-bound live-state publication behind the reviewed model.profile.set seam, not an independent public SDK operation",
6206
+ "exclusionMetadata": {
6207
+ "adapterMappings": "not_applicable",
6208
+ "testIds": "not_applicable"
6209
+ }
6210
+ },
6068
6211
  {
6069
6212
  "sourceId": "agent_session:commitPreparedProfileModelSelection",
6070
6213
  "sourceFile": "packages/coding-agent/src/session/agent-session.ts",
@@ -6236,6 +6379,17 @@
6236
6379
  "testIds": "not_applicable"
6237
6380
  }
6238
6381
  },
6382
+ {
6383
+ "sourceId": "agent_session:setThinkingLevelForSession",
6384
+ "sourceFile": "packages/coding-agent/src/session/agent-session.ts",
6385
+ "sourceKind": "agent_session",
6386
+ "decision": "exclude",
6387
+ "rationale": "internal non-operator session-only thinking follow (plan mode, model assignment) over the reviewed thinking.set seam, not an independent public SDK operation",
6388
+ "exclusionMetadata": {
6389
+ "adapterMappings": "not_applicable",
6390
+ "testIds": "not_applicable"
6391
+ }
6392
+ },
6239
6393
  {
6240
6394
  "sourceId": "agent_session:getThinkingScopeForControl",
6241
6395
  "sourceFile": "packages/coding-agent/src/session/agent-session.ts",