@gajae-code/coding-agent 0.15.5 → 0.15.6

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 (155) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/dist/types/async/job-manager.d.ts +83 -0
  3. package/dist/types/cli/auth-gateway-cli.d.ts +17 -0
  4. package/dist/types/cli/model-presets-cli.d.ts +9 -0
  5. package/dist/types/cli/update-cli.d.ts +2 -0
  6. package/dist/types/commands/auth-gateway.d.ts +3 -0
  7. package/dist/types/commands/gc.d.ts +13 -0
  8. package/dist/types/commands/model-presets.d.ts +21 -0
  9. package/dist/types/config/autorouting-tier-map.d.ts +96 -0
  10. package/dist/types/config/file-lock.d.ts +49 -2
  11. package/dist/types/config/internal/model-preset-registry-test-state.d.ts +4 -0
  12. package/dist/types/config/internal/model-preset-registry-test-support.d.ts +3 -0
  13. package/dist/types/config/keybindings.d.ts +3 -2
  14. package/dist/types/config/model-preset-registry.d.ts +368 -0
  15. package/dist/types/config/model-profile-activation.d.ts +39 -0
  16. package/dist/types/config/model-profiles.d.ts +5 -3
  17. package/dist/types/config/model-registry.d.ts +11 -5
  18. package/dist/types/config/settings-schema.d.ts +9 -0
  19. package/dist/types/coordinator-mcp/model-preset.d.ts +7 -5
  20. package/dist/types/coordinator-mcp/projection-scan.d.ts +46 -0
  21. package/dist/types/extensibility/extensions/types.d.ts +2 -5
  22. package/dist/types/gjc-runtime/empty-delete-gc.d.ts +58 -0
  23. package/dist/types/gjc-runtime/gc-runtime.d.ts +2 -0
  24. package/dist/types/gjc-runtime/session-state-lock.d.ts +35 -6
  25. package/dist/types/gjc-runtime/session-state-sidecar.d.ts +6 -0
  26. package/dist/types/index.d.ts +1 -0
  27. package/dist/types/main.d.ts +3 -1
  28. package/dist/types/modes/components/jobs-overlay-model.d.ts +4 -2
  29. package/dist/types/modes/jobs-observer.d.ts +36 -0
  30. package/dist/types/sdk/broker/broker.d.ts +3 -0
  31. package/dist/types/sdk/bus/kind-aware-reconciliation.d.ts +3 -0
  32. package/dist/types/sdk/bus/prompt-reconciliation.d.ts +4 -0
  33. package/dist/types/sdk/client/discovery.d.ts +1 -0
  34. package/dist/types/sdk/host/model-pin.d.ts +7 -2
  35. package/dist/types/sdk/host/sdk-run-capability.d.ts +1 -0
  36. package/dist/types/sdk/host/session-runtime.d.ts +15 -1
  37. package/dist/types/sdk/prompt-deadline-manager.d.ts +11 -1
  38. package/dist/types/sdk/protocol/adapter-validation.d.ts +2 -0
  39. package/dist/types/sdk/router/session-router.d.ts +9 -0
  40. package/dist/types/session/account-inventory.d.ts +1 -0
  41. package/dist/types/session/agent-session.d.ts +19 -7
  42. package/dist/types/session/fold-coordinator.d.ts +201 -0
  43. package/dist/types/session/sdk-run-capability-internal.d.ts +7 -0
  44. package/dist/types/session/sdk-run-capability.d.ts +2 -0
  45. package/dist/types/telemetry/control.d.ts +11 -0
  46. package/dist/types/telemetry/events.d.ts +20 -0
  47. package/dist/types/telemetry/index.d.ts +3 -0
  48. package/dist/types/telemetry/transport.d.ts +22 -0
  49. package/dist/types/tools/bash-interactive.d.ts +23 -0
  50. package/dist/types/tools/index.d.ts +6 -5
  51. package/dist/types/web/search/providers/base.d.ts +9 -4
  52. package/dist/types/web/search/providers/xai.d.ts +2 -1
  53. package/dist/types/web/search/types.d.ts +14 -0
  54. package/package.json +10 -7
  55. package/scripts/generate-hotkeys-docs.ts +4 -0
  56. package/scripts/generate-sdk-operation-inventory.ts +3 -3
  57. package/src/async/job-manager.ts +671 -39
  58. package/src/cli/auth-broker-cli.ts +40 -12
  59. package/src/cli/auth-gateway-cli.ts +273 -97
  60. package/src/cli/config-cli.ts +2 -2
  61. package/src/cli/fast-help.ts +3 -0
  62. package/src/cli/model-presets-cli.ts +100 -0
  63. package/src/cli/update-cli.ts +40 -5
  64. package/src/cli.ts +6 -2
  65. package/src/commands/auth-gateway.ts +12 -8
  66. package/src/commands/gc.ts +19 -0
  67. package/src/commands/model-presets.ts +24 -0
  68. package/src/config/autorouting-tier-map.ts +32 -0
  69. package/src/config/file-lock-gc.ts +9 -4
  70. package/src/config/file-lock.ts +775 -59
  71. package/src/config/internal/model-preset-registry-test-state.ts +28 -0
  72. package/src/config/internal/model-preset-registry-test-support.ts +11 -0
  73. package/src/config/keybindings.ts +6 -2
  74. package/src/config/model-preset-registry.ts +2799 -0
  75. package/src/config/model-profile-activation.ts +115 -28
  76. package/src/config/model-profile-contract.ts +4 -1
  77. package/src/config/model-profiles.ts +51 -9
  78. package/src/config/model-registry.ts +1021 -122
  79. package/src/config/settings-schema.ts +11 -0
  80. package/src/config/settings.ts +6 -1
  81. package/src/coordinator-mcp/model-preset.ts +32 -17
  82. package/src/coordinator-mcp/projection-scan.ts +571 -0
  83. package/src/coordinator-mcp/server.ts +19 -24
  84. package/src/coordinator-mcp/session-reaper.ts +9 -3
  85. package/src/extensibility/extensions/loader.ts +0 -1
  86. package/src/extensibility/extensions/types.ts +2 -3
  87. package/src/extensibility/gjc-plugins/runtime-adapters.ts +1 -0
  88. package/src/gjc-runtime/empty-delete-gc.ts +301 -0
  89. package/src/gjc-runtime/gc-render.ts +29 -0
  90. package/src/gjc-runtime/gc-runtime.ts +174 -11
  91. package/src/gjc-runtime/session-state-lock.ts +1242 -141
  92. package/src/gjc-runtime/session-state-sidecar.ts +76 -3
  93. package/src/index.ts +1 -0
  94. package/src/internal-urls/docs-index.generated.ts +9 -8
  95. package/src/lsp/config.ts +4 -3
  96. package/src/lsp/path-trust.ts +12 -6
  97. package/src/main.ts +9 -2
  98. package/src/modes/acp/acp-agent.ts +11 -5
  99. package/src/modes/components/jobs-overlay-model.ts +99 -16
  100. package/src/modes/components/model-selector.ts +158 -18
  101. package/src/modes/components/status-line/segments.ts +6 -1
  102. package/src/modes/controllers/extension-ui-controller.ts +1 -1
  103. package/src/modes/controllers/input-controller.ts +23 -6
  104. package/src/modes/interactive-mode.ts +14 -1
  105. package/src/modes/jobs-observer.ts +149 -16
  106. package/src/modes/runtime-init.ts +1 -1
  107. package/src/modes/utils/injected-user-submission.ts +15 -1
  108. package/src/prompts/tools/bash.md +2 -2
  109. package/src/prompts/tools/fold-receipt.md +3 -0
  110. package/src/prompts/tools/job.md +1 -1
  111. package/src/sdk/acp/adapter.ts +17 -2
  112. package/src/sdk/broker/broker.ts +48 -21
  113. package/src/sdk/broker/lifecycle.ts +32 -6
  114. package/src/sdk/bus/chat-daemon-control.ts +2 -2
  115. package/src/sdk/bus/chat-daemon-runtime.ts +11 -1
  116. package/src/sdk/bus/kind-aware-reconciliation.ts +36 -6
  117. package/src/sdk/bus/prompt-reconciliation.ts +28 -4
  118. package/src/sdk/bus/slack-conversation.ts +5 -1
  119. package/src/sdk/cli/session-cli.ts +12 -1
  120. package/src/sdk/client/discovery.ts +3 -1
  121. package/src/sdk/host/control/dispatch.ts +3 -0
  122. package/src/sdk/host/model-pin.ts +185 -25
  123. package/src/sdk/host/sdk-run-capability.ts +1 -0
  124. package/src/sdk/host/session-runtime.test.ts +371 -37
  125. package/src/sdk/host/session-runtime.ts +364 -52
  126. package/src/sdk/prompt-deadline-manager.ts +16 -1
  127. package/src/sdk/protocol/adapter-validation.ts +27 -0
  128. package/src/sdk/protocol/operation-inventory.generated.json +2 -2
  129. package/src/sdk/protocol/operation-registry.ts +4 -1
  130. package/src/sdk/router/session-router.ts +228 -96
  131. package/src/sdk/session.ts +83 -12
  132. package/src/session/account-inventory.ts +27 -11
  133. package/src/session/agent-session.ts +678 -103
  134. package/src/session/fold-coordinator.ts +433 -0
  135. package/src/session/sdk-run-capability-internal.ts +15 -0
  136. package/src/session/sdk-run-capability.ts +2 -0
  137. package/src/session/session-manager.ts +5 -4
  138. package/src/setup/provider-presets.json +1 -1
  139. package/src/slash-commands/helpers/credential-switch.ts +6 -1
  140. package/src/task/executor.ts +19 -3
  141. package/src/telemetry/control.ts +26 -0
  142. package/src/telemetry/events.ts +142 -0
  143. package/src/telemetry/index.ts +3 -0
  144. package/src/telemetry/transport.ts +87 -0
  145. package/src/tools/bash-interactive.ts +182 -85
  146. package/src/tools/bash.ts +772 -67
  147. package/src/tools/index.ts +7 -5
  148. package/src/tools/tool-catalog.generated.ts +1 -1
  149. package/src/web/search/provider.ts +120 -11
  150. package/src/web/search/providers/anthropic.ts +89 -17
  151. package/src/web/search/providers/base.ts +9 -4
  152. package/src/web/search/providers/gemini.ts +87 -15
  153. package/src/web/search/providers/openai-compatible.ts +23 -8
  154. package/src/web/search/providers/xai.ts +98 -12
  155. package/src/web/search/types.ts +16 -0
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Official GC of already-quarantined empty `.gjc-delete-*` receipts.
3
+ * Roots are operator operands — never hardcoded host paths.
4
+ */
5
+ import type { BigIntStats } from "node:fs";
6
+ import { exactUnlinkDirect } from "@gajae-code/natives";
7
+ export declare const EMPTY_DELETE_PREFIX = ".gjc-delete-";
8
+ export interface EmptyDeleteIdentity {
9
+ dev: bigint;
10
+ ino: bigint;
11
+ nlink: bigint;
12
+ size: bigint;
13
+ mtimeNs: bigint;
14
+ parentDev: bigint;
15
+ parentIno: bigint;
16
+ sha256: string;
17
+ }
18
+ export interface EmptyDeleteGcRecord {
19
+ root: string;
20
+ path: string;
21
+ action: "would_remove" | "removed" | "kept" | "skipped";
22
+ reason: string;
23
+ identity?: EmptyDeleteIdentity;
24
+ /** A dry-run candidate is an observation, never deletion authority. */
25
+ observationOnly?: boolean;
26
+ /** Retained-object paths a native direct unlink left behind; operator-recoverable only there. */
27
+ retainedPaths?: {
28
+ detached?: string;
29
+ successor?: string;
30
+ placeholder?: string;
31
+ unknown?: string;
32
+ };
33
+ }
34
+ export interface EmptyDeleteGcReport {
35
+ dry_run: boolean;
36
+ roots: string[];
37
+ records: EmptyDeleteGcRecord[];
38
+ would_remove: number;
39
+ removed: number;
40
+ kept: number;
41
+ skipped: number;
42
+ errors: string[];
43
+ }
44
+ export interface EmptyDeleteGcOptions {
45
+ roots: string[];
46
+ prune: boolean;
47
+ }
48
+ export interface EmptyDeleteGcDependencies {
49
+ /** Internal seam for deterministic collect-to-prune race tests. */
50
+ collect?: (root: string) => Promise<EmptyDeleteGcRecord[]>;
51
+ exactUnlinkDirect?: typeof exactUnlinkDirect;
52
+ }
53
+ export declare function collectEmptyDeleteReceipts(root: string, deps?: {
54
+ lstat?: (file: string, options: {
55
+ bigint: true;
56
+ }) => Promise<BigIntStats>;
57
+ }): Promise<EmptyDeleteGcRecord[]>;
58
+ export declare function runEmptyDeleteGc(options: EmptyDeleteGcOptions, deps?: EmptyDeleteGcDependencies): Promise<EmptyDeleteGcReport>;
@@ -12,6 +12,7 @@
12
12
  * error all mean KEEP — a live process is never signalled or killed.
13
13
  * - Dry-run by default: nothing is deleted unless `--prune`/`--force`.
14
14
  */
15
+ import { type EmptyDeleteGcReport } from "./empty-delete-gc";
15
16
  import { type GcSessionScopeUsage } from "./gc-session-scope";
16
17
  export type GcStore = "harness_leases" | "file_locks" | "tmux_sessions" | "registry_entries" | "local_roots";
17
18
  export declare const GC_STORES: readonly GcStore[];
@@ -127,6 +128,7 @@ export interface GcReport {
127
128
  * PID-liveness axis above is unchanged by its absence or presence.
128
129
  */
129
130
  disk?: GcDiskReport;
131
+ empty_delete_receipts?: EmptyDeleteGcReport;
130
132
  }
131
133
  export interface GcRunResult {
132
134
  stdout: string;
@@ -62,6 +62,12 @@ export declare const SessionStateLockTestHooks: {
62
62
  unqualifiedOwnerIsLocal?: boolean;
63
63
  /** @internal Runs after final live-owner validation and before descriptor rewrite. */
64
64
  afterCurrentOwnerValidation?: (file: string) => void | Promise<void>;
65
+ /** @internal Fault seam immediately before a held owner record rewrite mutates bytes. */
66
+ beforeOwnerRecordRewrite?: (file: string) => void | Promise<void>;
67
+ /** @internal Fault seam immediately before final transition-generation validation. */
68
+ beforeTransitionReleaseLstat?: (transitionDir: string) => void | Promise<void>;
69
+ /** @internal Fault seam immediately before setup generation capture. */
70
+ beforeTransitionSetupLstat?: (transitionDir: string) => void | Promise<void>;
65
71
  /**
66
72
  * @internal Runs after a live owner has been proven and immediately before its
67
73
  * final pathname capture for release. Tests use it to replace the pathname and
@@ -69,10 +75,30 @@ export declare const SessionStateLockTestHooks: {
69
75
  */
70
76
  beforeCurrentOwnerRelease?: (file: string) => void | Promise<void>;
71
77
  beforeLegacyDirectoryRemoval?: (lockDir: string) => void | Promise<void>;
78
+ /** @internal Last quarantine name minted in the current lock cycle (tests). */
79
+ lastQuarantineName?: string;
80
+ /** @internal Count of quarantine names minted in the current lock cycle (tests). */
81
+ quarantineMints?: number;
82
+ /** @internal Force the next mint to this name so leftover-collision tests can plant it. */
83
+ forcedQuarantineName?: string;
84
+ /** @internal Observes bounded acquisition retries without changing their timing. */
85
+ afterAcquireContention?: (lockFile: string, attempt: number, elapsedMs: number) => void;
72
86
  };
73
87
  /** Raised when the lock could not be acquired; callers map it to their own refusal. */
88
+ export type SessionStateLockUnavailableReason = "acquire_timeout" | "legacy_directory_owner_unprovenanced" | "lock_initialization_failed" | "lock_inspection_failed" | "lock_owner_live_or_unverifiable" | "lock_owner_record_fresh" | "lock_owner_record_unprovenanced" | "lock_release_failed" | "transition_claim_timeout" | "unsafe_lock_path_type";
89
+ interface SessionStateLockUnavailableDetails {
90
+ lockPath: string;
91
+ reason: SessionStateLockUnavailableReason;
92
+ attempts?: number;
93
+ elapsedMs?: number;
94
+ cause?: unknown;
95
+ }
74
96
  export declare class SessionStateLockUnavailableError extends Error {
75
- constructor(cause?: unknown);
97
+ readonly lockPath?: string;
98
+ readonly reason?: SessionStateLockUnavailableReason;
99
+ readonly attempts?: number;
100
+ readonly elapsedMs?: number;
101
+ constructor(causeOrDetails?: unknown | SessionStateLockUnavailableDetails);
76
102
  }
77
103
  /**
78
104
  * The identity-bound deletion primitives this lock is built on.
@@ -85,7 +111,7 @@ export declare class SessionStateLockUnavailableError extends Error {
85
111
  * caller proved. A replacement is therefore never deleted, by construction rather than by
86
112
  * a narrower window.
87
113
  */
88
- export type SessionStateLockNativeBindings = Pick<typeof import("@gajae-code/natives"), "exactRemoveDirectoryTree" | "exactUnlink" | "snapshotDirectoryTree">;
114
+ export type SessionStateLockNativeBindings = Pick<typeof import("@gajae-code/natives"), "exactRemoveDirectoryTree" | "exactUnlink" | "exactUnlinkDirect" | "snapshotDirectoryTree">;
89
115
  /** How the deletion primitives are obtained. Throwing means they are unavailable. */
90
116
  type SessionStateLockNativeLoader = () => SessionStateLockNativeBindings;
91
117
  /**
@@ -102,12 +128,15 @@ type SessionStateLockNativeLoader = () => SessionStateLockNativeBindings;
102
128
  */
103
129
  export declare function setSessionStateLockNativeBindings(load: SessionStateLockNativeLoader | undefined): void;
104
130
  /**
105
- * Decide what actually occupies the lock path, without following it.
131
+ * Verified empty leftover at a reserved quarantine name is incomplete debris, not
132
+ * in-progress cleanup.
106
133
  *
107
- * @internal exported as the seam these decisions are tested through: a live legacy
108
- * directory owner must be provably left alone without waiting out a real stale window.
134
+ * Deletion authority is the native identity-bound direct unlink — never a plain
135
+ * pathname unlink. A replacement planted at the reserved name between observation
136
+ * and deletion has a different inode identity and is refused by construction.
109
137
  */
110
- export declare function reclaimStaleSessionStateLock(lockFile: string): Promise<void>;
138
+ export declare function removeVerifiedEmptyQuarantine(directory: string, name: string): Promise<void>;
139
+ export declare function reclaimStaleSessionStateLock(lockFile: string, quarantineName?: string): Promise<void>;
111
140
  /**
112
141
  * Serialize one read-modify-write of `stateFile` against every other holder of
113
142
  * `<stateFile>.lock`.
@@ -195,6 +195,12 @@ export declare function persistCoordinatorRuntimeStateFromEvent(event: RuntimeSt
195
195
  * sidecar never trusts a model-supplied name.
196
196
  */
197
197
  observation?: CoordinatorToolObservation): Promise<void>;
198
+ export declare function persistCoordinatorWorkerIntegrationOutcome(context: RuntimeStateContext, outcome: {
199
+ kind: "worker_integration" | "terminal_persistence";
200
+ status: "completed" | "failed" | "timed_out";
201
+ correlationId?: string;
202
+ error?: string;
203
+ }): Promise<void>;
198
204
  export declare function ownerTerminalContextFromEnvironment(): OwnerTerminalContext | "invalid" | null;
199
205
  export declare function persistCoordinatorRuntimeStateFromPostmortem(reason: postmortem.Reason, context: RuntimeStateContext): Promise<void>;
200
206
  export declare function registerCoordinatorRuntimeStateFinalizer(context: RuntimeStateContext): () => void;
@@ -28,6 +28,7 @@ export * from "./session/session-dump-format";
28
28
  export * from "./session/session-manager";
29
29
  export * from "./task/executor";
30
30
  export type * from "./task/types";
31
+ export * from "./telemetry";
31
32
  export * from "./tools";
32
33
  export * from "./utils/git";
33
34
  export { HookEditorComponent as ExtensionEditorComponent, HookInputComponent as ExtensionInputComponent, HookSelectorComponent as ExtensionSelectorComponent, };
@@ -47,7 +47,9 @@ export interface InteractiveModeNotify {
47
47
  kind: "warn" | "error" | "info";
48
48
  message: string;
49
49
  }
50
- export declare function submitInteractiveInput(mode: Pick<InteractiveMode, "markPendingSubmissionStarted" | "finishPendingSubmission" | "showError" | "checkShutdownRequested" | "waitForAgentEnd">, session: Pick<AgentSession, "prompt" | "promptCustomMessage">, input: SubmittedUserInput): Promise<void>;
50
+ export declare function submitInteractiveInput(mode: Pick<InteractiveMode, "markPendingSubmissionStarted" | "finishPendingSubmission" | "showError" | "checkShutdownRequested" | "waitForAgentEnd">, session: Pick<AgentSession, "prompt" | "promptCustomMessage"> & {
51
+ continuePersistedHistory?: AgentSession["continuePersistedHistory"];
52
+ }, input: SubmittedUserInput): Promise<void>;
51
53
  type StartupModelProfileArgs = {
52
54
  session: AgentSession;
53
55
  settings: Settings;
@@ -7,10 +7,11 @@
7
7
  */
8
8
  import type { SelectItem } from "@gajae-code/tui";
9
9
  import type { JobsSnapshot } from "../jobs-observer";
10
- export type JobRefKind = "monitor" | "cron";
10
+ export type JobRefKind = "monitor" | "cron" | "folded";
11
11
  export interface JobRef {
12
12
  kind: JobRefKind;
13
13
  id: string;
14
+ generation?: string;
14
15
  }
15
16
  /** Compact relative time, e.g. "in 5m", "2m ago", "now". */
16
17
  export declare function formatRelative(targetMs: number | undefined, nowMs?: number): string;
@@ -18,7 +19,8 @@ export declare function formatRelative(targetMs: number | undefined, nowMs?: num
18
19
  export declare function parseJobRef(value: string): JobRef | null;
19
20
  /**
20
21
  * Build the grouped jobs list: monitors first (newest-first), then crons
21
- * (newest-first). The snapshot arrays are already sorted newest-first.
22
+ * (newest-first), then read-only folded jobs. The snapshot arrays are already
23
+ * sorted newest-first where a source has a timestamp.
22
24
  */
23
25
  export declare function buildJobsListItems(snapshot: JobsSnapshot): SelectItem[];
24
26
  /**
@@ -14,11 +14,43 @@
14
14
  */
15
15
  import type { AsyncJob, AsyncJobManager } from "../async";
16
16
  export type JobsWorstState = "none" | "running" | "failed";
17
+ export type JobDeliveryState = "pending" | "delivered" | "failed-visible";
18
+ /** The manager-owned, one-pass job projection consumed by this observer. */
19
+ export interface AsyncJobSnapshotEntry {
20
+ id: string;
21
+ kind: string;
22
+ label: string;
23
+ status: AsyncJob["status"];
24
+ generation: string;
25
+ backgrounded: boolean;
26
+ deliveryState: JobDeliveryState;
27
+ }
28
+ /** Scalar delivery failure evidence that may outlive the AsyncJob record. */
29
+ export interface DeadLetteredJobSnapshotEntry {
30
+ jobId: string;
31
+ generation: string;
32
+ ownerId?: string;
33
+ backgrounded?: boolean;
34
+ attempt: number;
35
+ lastError?: string;
36
+ recordedAt: number;
37
+ }
38
+ export interface AsyncJobsSnapshot {
39
+ jobs: AsyncJobSnapshotEntry[];
40
+ deadLettered: DeadLetteredJobSnapshotEntry[];
41
+ }
17
42
  export interface MonitorJobView {
18
43
  id: string;
19
44
  label: string;
20
45
  status: AsyncJob["status"];
21
46
  startTime: number;
47
+ generation?: string;
48
+ backgrounded?: boolean;
49
+ deliveryState?: JobDeliveryState;
50
+ }
51
+ export interface FoldedJobView extends AsyncJobSnapshotEntry {
52
+ /** Safe diagnostic retained for a dead-lettered delivery, when available. */
53
+ errorText?: string;
22
54
  }
23
55
  export interface CronJobView {
24
56
  id: string;
@@ -34,6 +66,10 @@ export interface CronJobView {
34
66
  export interface JobsSnapshot {
35
67
  monitors: MonitorJobView[];
36
68
  crons: CronJobView[];
69
+ /** Backgrounded work and undeliverable terminal work that must stay visible. */
70
+ foldedJobs?: FoldedJobView[];
71
+ /** Scalar dead-letter evidence retained for diagnostics and red-drill-in. */
72
+ deadLettered?: DeadLetteredJobSnapshotEntry[];
37
73
  activeMonitorCount: number;
38
74
  activeCronCount: number;
39
75
  worstState: JobsWorstState;
@@ -1,5 +1,6 @@
1
1
  import type { NativeDirectoryTreeSnapshot } from "@gajae-code/natives";
2
2
  import type { ModelProfileErrorDetails } from "../../config/model-profile-contract";
3
+ import { type SdkHostModelResolver } from "../host/model-pin";
3
4
  import { type DirectoryMigrationPolicy } from "../session-directory";
4
5
  import { type BrokerDiscovery, type BrokerPublicationObservation, type RedactedBrokerDiscovery } from "./discovery";
5
6
  import { type LifecycleDurableEffectsReceipt, LifecycleLedger, type LifecycleStartupFailureReceipt } from "./lifecycle-ledger";
@@ -11,6 +12,8 @@ export interface BrokerSettings {
11
12
  heartbeatTtlMs?: number;
12
13
  /** Broker-owned migration policy. Client lifecycle frames cannot select it. */
13
14
  resolveDirectoryMigration?: (_cwd: string) => Promise<DirectoryMigrationPolicy>;
15
+ /** Host model resolver override for lifecycle tests and embedders. */
16
+ resolveModelPin?: SdkHostModelResolver;
14
17
  }
15
18
  type ResolvedBrokerSettings = {
16
19
  agentDir: string;
@@ -29,10 +29,13 @@ export interface KindAwareReconciliation {
29
29
  noteTransition(kind: ReconciliationKind, correlation: PromptCorrelation | undefined, frame: {
30
30
  type: "agent_start" | "agent_end";
31
31
  content?: TurnResultContent;
32
+ hasActivity?: boolean;
33
+ outcome?: SdkPromptTerminalOutcome;
32
34
  } | {
33
35
  type: "agent_failed";
34
36
  error: unknown;
35
37
  content?: TurnResultContent;
38
+ hasActivity?: boolean;
36
39
  }): Promise<void>;
37
40
  claimPendingOutcome(kind: ReconciliationKind, correlation: PromptCorrelation, outcome: SdkPromptTerminalOutcome, receiptState?: Extract<ReceiptState, "present" | "missing">): Promise<SdkPromptTerminalOutcome>;
38
41
  finalizeOutcome(kind: ReconciliationKind, correlation: PromptCorrelation, outcome?: SdkPromptTerminalOutcome, recordError?: {
@@ -22,6 +22,7 @@
22
22
  * record that has none, but never changes status, terminalAt, or retention.
23
23
  */
24
24
  import { PROMPT_FAILURE_CODE_MAX, sanitizePromptFailure } from "../prompt-failure";
25
+ import type { SdkPromptTerminalOutcome } from "../prompt-status";
25
26
  import type { ReceiptState } from "../receipt-state";
26
27
  export { PROMPT_FAILURE_CODE_MAX, sanitizePromptFailure };
27
28
  export declare const PROMPT_RECONCILIATION_ACTIVE_CAPACITY = 128;
@@ -102,10 +103,13 @@ export interface PromptReconciliation {
102
103
  } | {
103
104
  type: "agent_end";
104
105
  finalText?: string;
106
+ hasActivity?: boolean;
107
+ outcome?: SdkPromptTerminalOutcome;
105
108
  } | {
106
109
  type: "agent_failed";
107
110
  error: unknown;
108
111
  finalText?: string;
112
+ hasActivity?: boolean;
109
113
  }): void;
110
114
  lookup(selector: {
111
115
  commandId?: string;
@@ -22,6 +22,7 @@ export declare class SdkDiscoveryError extends Error {
22
22
  constructor(path: string, message: string);
23
23
  }
24
24
  export type SdkSessionEndpointScope = "default" | "chat";
25
+ export declare function endpointDirectory(repo: string, scope?: SdkSessionEndpointScope): string;
25
26
  /** Lists endpoint files and returns individual malformed or unreadable records as warnings. */
26
27
  export declare function listSdkSessionEndpoints(repo: string): Promise<SdkSessionEndpointList>;
27
28
  /** Resolves one per-session SDK endpoint discovery file. */
@@ -5,7 +5,10 @@ export interface SdkHostModelResolveContext {
5
5
  cwd?: string;
6
6
  }
7
7
  /** Registry loader owned by the SDK host, not by machine-facing adapters. */
8
- export type SdkHostModelRegistryLoader = (context?: SdkHostModelResolveContext) => ModelRegistry | Promise<ModelRegistry>;
8
+ export type SdkHostModelRegistryLoader = ((context?: SdkHostModelResolveContext) => ModelRegistry | Promise<ModelRegistry>) & {
9
+ acquire?: (context?: SdkHostModelResolveContext) => () => void;
10
+ dispose?: () => Promise<void>;
11
+ };
9
12
  /**
10
13
  * Builds an offline model resolver for a single SDK host process.
11
14
  *
@@ -22,7 +25,9 @@ export type SdkHostModelResolution = {
22
25
  model: string;
23
26
  error: string;
24
27
  };
25
- export type SdkHostModelResolver = (raw: unknown, context?: SdkHostModelResolveContext) => Promise<SdkHostModelResolution>;
28
+ export type SdkHostModelResolver = ((raw: unknown, context?: SdkHostModelResolveContext) => Promise<SdkHostModelResolution>) & {
29
+ dispose?: () => Promise<void>;
30
+ };
26
31
  /** Resolve the explicit model pin at the SDK host boundary. */
27
32
  export declare function resolveSdkHostModel(raw: unknown, loadRegistry: SdkHostModelRegistryLoader, context?: SdkHostModelResolveContext): Promise<SdkHostModelResolution>;
28
33
  /** Default resolver used by the SDK broker host. */
@@ -0,0 +1 @@
1
+ export { createSdkRunCapability } from "../../session/sdk-run-capability-internal";
@@ -1,5 +1,6 @@
1
1
  import { type Settings } from "../../config/settings";
2
2
  import type { ExtensionAPI, ExtensionContext } from "../../extensibility/extensions";
3
+ import { type TurnResultContent } from "../turn-result";
3
4
  import { SessionSdkHost, type SessionSdkHostOptions } from "./host";
4
5
  import { type SessionSurface } from "./query";
5
6
  import { type SdkCapabilities, type SdkSurfacePolicy } from "./surface-policy";
@@ -194,9 +195,18 @@ export interface InvocationReconciliation {
194
195
  noteAccepted(kind: InvocationKind, correlation: InvocationCorrelation, clientRef?: string): Promise<void>;
195
196
  noteTransition(kind: InvocationKind, correlation: InvocationCorrelation | undefined, frame: {
196
197
  type: "agent_start" | "agent_end";
198
+ content?: TurnResultContent;
199
+ hasActivity?: boolean;
200
+ outcome?: {
201
+ kind: "stopped";
202
+ reason: "cancelled";
203
+ provenance: "client_cancel";
204
+ };
197
205
  } | {
198
206
  type: "agent_failed";
199
207
  error: unknown;
208
+ content?: TurnResultContent;
209
+ hasActivity?: boolean;
200
210
  }): Promise<void>;
201
211
  lookup(kind: InvocationKind, selector: {
202
212
  commandId?: string;
@@ -228,7 +238,11 @@ export interface InvocationReconciliation {
228
238
  }, arg4?: (() => boolean) | {
229
239
  code: string;
230
240
  message: string;
231
- }, arg5?: unknown): Promise<void>;
241
+ }, arg5?: unknown, arg6?: {
242
+ content?: TurnResultContent;
243
+ hasActivity?: boolean;
244
+ outcomeKind?: string;
245
+ }): Promise<void>;
232
246
  markUncertain(kind: InvocationKind, correlation: InvocationCorrelation, isCurrent?: () => boolean, deadlineMaxAt?: number): Promise<void>;
233
247
  }
234
248
  export declare function createInvocationReconciliation(options?: {
@@ -1,5 +1,6 @@
1
1
  import type { KindAwareReconciliation } from "./bus/kind-aware-reconciliation";
2
2
  import type { InvocationCorrelation, InvocationReconciliation } from "./host/session-runtime";
3
+ import type { TurnResultContent } from "./turn-result";
3
4
  type DeadlineReconciliation = InvocationReconciliation | KindAwareReconciliation;
4
5
  export type PromptDeadlineOutcome = {
5
6
  kind: "failed";
@@ -7,6 +8,15 @@ export type PromptDeadlineOutcome = {
7
8
  message: string;
8
9
  provenance: "deadline";
9
10
  };
11
+ export interface PromptTerminalTransitionEvidence {
12
+ content?: TurnResultContent;
13
+ hasActivity?: boolean;
14
+ outcome?: {
15
+ kind: "stopped";
16
+ reason: "cancelled";
17
+ provenance: "client_cancel";
18
+ };
19
+ }
10
20
  export declare class PromptDeadlineManager {
11
21
  #private;
12
22
  constructor(options: {
@@ -28,7 +38,7 @@ export declare class PromptDeadlineManager {
28
38
  noteTerminalTransition(correlation: InvocationCorrelation, pendingFailure?: {
29
39
  code: string;
30
40
  message: string;
31
- }): void;
41
+ }, evidence?: PromptTerminalTransitionEvidence): void;
32
42
  clear(correlation: InvocationCorrelation): void;
33
43
  clearAll(): void;
34
44
  /** For tests: current deadline or undefined if no lease. */
@@ -9,6 +9,8 @@ export type AdapterValidationError = {
9
9
  code: "invalid_reload_component" | "invalid_input";
10
10
  message: string;
11
11
  };
12
+ /** Rejects instruction-bearing controls before correlation or provider work. */
13
+ export declare function validateRequiredPromptText(operation: string, input: Input): AdapterValidationError | undefined;
12
14
  /** Validates controls that adapters must reject before forwarding them to a host. */
13
15
  export declare function validateAdapterControl(operation: string, input: Input): AdapterValidationError | undefined;
14
16
  export {};
@@ -1,6 +1,13 @@
1
1
  import { type SessionIndex } from "../broker/session-index";
2
2
  import { type SdkDispatchContext, type SdkDispatchHandler } from "../client/client";
3
3
  import { type ActivatedPreparedSession } from "../session-activation";
4
+ export interface SessionEndpointIdentity {
5
+ readonly mtimeMs: number;
6
+ readonly mtimeNs: bigint;
7
+ readonly ctimeNs: bigint;
8
+ readonly size: bigint;
9
+ readonly ino: bigint;
10
+ }
4
11
  /**
5
12
  * Exact identity of one attached SDK session endpoint. Providers persist it next to
6
13
  * their conversation state and re-prove it before every resume, so it must be derived
@@ -14,6 +21,8 @@ export declare function sessionAttachmentAuthorityId(input: {
14
21
  endpointMtimeMs: number | undefined;
15
22
  url: string;
16
23
  token: string;
24
+ /** Proven no-follow endpoint identity, when the caller has one. */
25
+ endpointIdentity?: SessionEndpointIdentity;
17
26
  }): string;
18
27
  /** The only capability a provider may retain for an attached SDK session. */
19
28
  export interface SessionAttachment {
@@ -59,6 +59,7 @@ export interface AccountInventoryInput {
59
59
  provider: string;
60
60
  }>;
61
61
  getProviderBaseUrl?: (provider: string) => string | undefined;
62
+ getAuthStorageOwner?: () => object;
62
63
  };
63
64
  sessionId?: string;
64
65
  provider?: string;
@@ -109,6 +109,7 @@ import { type ConfiguredFallbackChain, type FallbackChainRuntimeState } from "./
109
109
  export { DefaultModelSelectionRecoveryError } from "./default-model-selection";
110
110
  import type { ClientBridge, ClientBridgePermissionOption, ClientBridgePermissionOutcome, ClientBridgePermissionToolCall } from "./client-bridge";
111
111
  import { type ContributionPrepOptions, type ContributionPrepResult } from "./contribution-prep";
112
+ import { type FoldAdapter, FoldCoordinator } from "./fold-coordinator";
112
113
  import type { MemoryGuardRestoreResult } from "./memory-guard-checkpoint-participant";
113
114
  import { type CustomMessage } from "./messages";
114
115
  import type { BranchSummaryEntry, CompactionEntry, NewSessionOptions, PreparedNewSession, RecoveryHydrationContext, RecoveryHydrationPromotionFence, SessionContext, SessionManagerCloseOutcome, SessionMemoryStats } from "./session-manager";
@@ -426,8 +427,8 @@ export interface PromptOptions {
426
427
  }) => void;
427
428
  /** Optional invocation-scoped cancellation fence used before an accepted skill starts execution. */
428
429
  preflightSignal?: AbortSignal;
429
- /** Internal SDK lifecycle owner token. */
430
- sdkRunToken?: string;
430
+ /** Internal host capability; ordinary package callers cannot construct the branded value. */
431
+ sdkRunCapability?: unknown;
431
432
  }
432
433
  /** Result from a handoff operation. */
433
434
  export interface HandoffResult {
@@ -553,6 +554,14 @@ export type BeforeAgentStartContributor = (event: {
553
554
  images?: ImageContent[];
554
555
  sessionId: string | undefined;
555
556
  }) => Promise<BeforeAgentStartInternalMessage | undefined>;
557
+ export type WorkerIntegrationOutcome = {
558
+ status: "completed";
559
+ } | {
560
+ status: "failed";
561
+ error: string;
562
+ } | {
563
+ status: "timed_out";
564
+ };
556
565
  export declare class WorkerIntegrationRequestScheduler {
557
566
  #private;
558
567
  readonly request: (signal: AbortSignal) => Promise<void>;
@@ -560,6 +569,7 @@ export declare class WorkerIntegrationRequestScheduler {
560
569
  constructor(request: (signal: AbortSignal) => Promise<void>, timeoutMs?: number);
561
570
  enqueue(): void;
562
571
  flush(): Promise<void>;
572
+ flushWithOutcome(): Promise<WorkerIntegrationOutcome>;
563
573
  }
564
574
  export type StreamingEditParsedToolCall = {
565
575
  toolCall: ToolCall;
@@ -837,7 +847,9 @@ export declare class AgentSession {
837
847
  * handler, so Ctrl+B-style folding fails closed instead of aborting or
838
848
  * shell-suspending arbitrary work.
839
849
  */
840
- registerForegroundBashBackgroundRequestHandler(handler: () => void): () => void;
850
+ registerForegroundFoldParticipant(adapter: FoldAdapter): () => void;
851
+ /** The session-owned fold coordinator, for delivery-side receipt lookup. */
852
+ get foldCoordinator(): FoldCoordinator;
841
853
  /**
842
854
  * Returns whether a managed foreground bash call is currently backgroundable.
843
855
  * UI key handlers use this to avoid consuming normal editor shortcuts when
@@ -854,7 +866,7 @@ export declare class AgentSession {
854
866
  * Ask the active managed foreground bash call to return as a background job.
855
867
  * Returns false when no supported foreground tool is currently backgroundable.
856
868
  */
857
- requestForegroundBashBackground(): boolean;
869
+ requestForegroundBashBackground(): Promise<boolean>;
858
870
  /**
859
871
  * Get all configured tool names (built-in via --tools or default, plus custom tools).
860
872
  */
@@ -947,7 +959,7 @@ export declare class AgentSession {
947
959
  /** Live SDK configuration values exposed through the session query surface. */
948
960
  getSdkConfigItems(): Record<string, string>;
949
961
  setPlanModeState(state: PlanModeState | undefined): void;
950
- invokeSkill(name: string, args?: string, options?: Pick<PromptOptions, "onPreflightAccepted" | "onPreflightAcceptCommit" | "onSkillPrepared" | "preflightSignal" | "sdkRunToken">): Promise<{
962
+ invokeSkill(name: string, args?: string, options?: Pick<PromptOptions, "onPreflightAccepted" | "onPreflightAcceptCommit" | "onSkillPrepared" | "preflightSignal" | "sdkRunCapability">): Promise<{
951
963
  name: string;
952
964
  path: string;
953
965
  args?: string;
@@ -1002,7 +1014,7 @@ export declare class AgentSession {
1002
1014
  * @throws Error if no model selected or no API key available (when not streaming)
1003
1015
  */
1004
1016
  prompt(text: string, options?: PromptOptions): Promise<void>;
1005
- promptCustomMessage<T = unknown>(message: Pick<CustomMessage<T>, "customType" | "content" | "display" | "details" | "attribution">, options?: Pick<PromptOptions, "streamingBehavior" | "toolChoice" | "followUpQueuePolicy" | "onPreflightAccepted" | "onPreflightAcceptCommit" | "preflightSignal" | "sdkRunToken">): Promise<void>;
1017
+ promptCustomMessage<T = unknown>(message: Pick<CustomMessage<T>, "customType" | "content" | "display" | "details" | "attribution">, options?: Pick<PromptOptions, "streamingBehavior" | "toolChoice" | "followUpQueuePolicy" | "onPreflightAccepted" | "onPreflightAcceptCommit" | "preflightSignal" | "sdkRunCapability">): Promise<void>;
1006
1018
  /**
1007
1019
  * Queue a steering message to interrupt the agent mid-run.
1008
1020
  */
@@ -1062,7 +1074,7 @@ export declare class AgentSession {
1062
1074
  startsOwnRun: boolean;
1063
1075
  }) => void;
1064
1076
  preflightSignal?: AbortSignal;
1065
- sdkRunToken?: string;
1077
+ sdkRunCapability?: unknown;
1066
1078
  }): Promise<void>;
1067
1079
  /**
1068
1080
  * Clear queued messages and return them.