@gajae-code/coding-agent 0.18.1 → 0.18.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.
- package/CHANGELOG.md +161 -0
- package/dist/types/cli/stats-cli.d.ts +0 -5
- package/dist/types/cli-commands.d.ts +10 -0
- package/dist/types/cli-ordinary.d.ts +13 -0
- package/dist/types/cli.d.ts +12 -3
- package/dist/types/commands/contribution-prep.d.ts +0 -3
- package/dist/types/commands/sdk.d.ts +3 -0
- package/dist/types/commands/update.d.ts +1 -0
- package/dist/types/config/autorouting-tier-map.d.ts +29 -2
- package/dist/types/config/model-profile-activation.d.ts +19 -0
- package/dist/types/config/model-registry.d.ts +16 -1
- package/dist/types/coordinator-mcp/session-reaper.d.ts +5 -0
- package/dist/types/edit/modes/replace.d.ts +3 -3
- package/dist/types/edit/streaming.d.ts +2 -2
- package/dist/types/exa/mcp-client.d.ts +1 -5
- package/dist/types/exec/bash-shell-guardian.d.ts +26 -0
- package/dist/types/exec/bash-shell-supervisor.d.ts +12 -0
- package/dist/types/hashline/parser.d.ts +28 -5
- package/dist/types/modes/acp/acp-agent.d.ts +6 -1
- package/dist/types/sdk/broker/discovery.d.ts +8 -0
- package/dist/types/sdk/broker/ensure.d.ts +1 -0
- package/dist/types/sdk/broker/lifecycle-ledger.d.ts +4 -0
- package/dist/types/sdk/broker/lifecycle.d.ts +6 -1
- package/dist/types/sdk/broker/recovery-backoff.d.ts +62 -0
- package/dist/types/sdk/broker/runtime.d.ts +21 -1
- package/dist/types/sdk/broker/startup-budget.d.ts +5 -1
- package/dist/types/sdk/bus/index.d.ts +1 -0
- package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +1 -1
- package/dist/types/sdk/bus/telegram-daemon.d.ts +1 -0
- package/dist/types/sdk/cli/diagnostics-cli.d.ts +18 -0
- package/dist/types/sdk/diagnostics/observe-broker.d.ts +185 -0
- package/dist/types/sdk/host/control/operations.d.ts +1 -1
- package/dist/types/sdk/host/session-runtime.d.ts +7 -0
- package/dist/types/sdk/index.d.ts +1 -0
- package/dist/types/sdk/prompt-watchdog.d.ts +1 -1
- package/dist/types/sdk/router/session-router.d.ts +2 -0
- package/dist/types/sdk/session.d.ts +13 -0
- package/dist/types/session/agent-session.d.ts +5 -1
- package/dist/types/tools/ask-contract.d.ts +75 -254
- package/dist/types/tools/bash.d.ts +1 -0
- package/package.json +7 -7
- package/scripts/build-sdk-package-smoke.ts +5 -0
- package/src/cli/public-command-entry.ts +5 -0
- package/src/cli/ssh-cli.ts +6 -3
- package/src/cli/stats-cli.ts +4 -36
- package/src/cli/web-search-cli.ts +9 -3
- package/src/cli-commands.ts +14 -0
- package/src/cli-main.ts +4 -8
- package/src/cli-ordinary.ts +197 -0
- package/src/cli.ts +25 -186
- package/src/commands/commit.ts +2 -2
- package/src/commands/contribution-prep.ts +1 -3
- package/src/commands/sdk.ts +60 -2
- package/src/commands/update.ts +15 -1
- package/src/config/autorouting-tier-map.ts +20 -2
- package/src/config/file-lock.ts +91 -2
- package/src/config/model-preset-registry.ts +17 -2
- package/src/config/model-profile-activation.ts +73 -5
- package/src/config/model-profile-contract.ts +4 -1
- package/src/config/model-profiles.ts +29 -29
- package/src/config/model-registry.ts +45 -17
- package/src/config/model-resolver.ts +9 -1
- package/src/coordinator-mcp/event-webhook.ts +19 -14
- package/src/coordinator-mcp/policy.ts +14 -4
- package/src/coordinator-mcp/server.ts +142 -7
- package/src/coordinator-mcp/session-reaper.ts +9 -1
- package/src/defaults/gjc/skills/deep-interview/SKILL.md +1 -1
- package/src/edit/modes/replace.ts +6 -6
- package/src/edit/streaming.ts +15 -15
- package/src/exa/mcp-client.ts +41 -8
- package/src/exec/bash-shell-guardian.ts +184 -34
- package/src/exec/bash-shell-supervisor.ts +60 -3
- package/src/hashline/execute.ts +51 -3
- package/src/hashline/parser.ts +63 -16
- package/src/internal-urls/docs-index.generated.ts +29 -28
- package/src/memories/index.ts +8 -2
- package/src/modes/acp/acp-agent.ts +688 -371
- package/src/modes/components/tool-execution.ts +1 -1
- package/src/modes/controllers/ssh-command-controller.ts +3 -1
- package/src/prompts/tools/ask.md +2 -0
- package/src/sdk/broker/broker.ts +46 -0
- package/src/sdk/broker/daemon-entry.ts +67 -6
- package/src/sdk/broker/discovery.ts +8 -0
- package/src/sdk/broker/ensure.ts +156 -20
- package/src/sdk/broker/lifecycle-ledger.ts +110 -12
- package/src/sdk/broker/lifecycle.ts +108 -34
- package/src/sdk/broker/recovery-backoff.ts +135 -0
- package/src/sdk/broker/runtime.ts +88 -1
- package/src/sdk/broker/startup-budget.ts +6 -1
- package/src/sdk/broker/transport.ts +5 -1
- package/src/sdk/bus/chat-daemon-control.ts +2 -2
- package/src/sdk/bus/index.ts +305 -19
- package/src/sdk/bus/telegram-daemon-contract.ts +1 -1
- package/src/sdk/bus/telegram-daemon-control.ts +15 -12
- package/src/sdk/bus/telegram-daemon.ts +34 -1
- package/src/sdk/cli/diagnostics-cli.ts +247 -0
- package/src/sdk/diagnostics/observe-broker.ts +654 -0
- package/src/sdk/host/control/dispatch.ts +52 -4
- package/src/sdk/host/control/operations.ts +1 -1
- package/src/sdk/host/session-runtime.test.ts +40 -2
- package/src/sdk/host/session-runtime.ts +112 -8
- package/src/sdk/index.ts +1 -0
- package/src/sdk/lifecycle-session.ts +1 -0
- package/src/sdk/prompt-watchdog.ts +17 -4
- package/src/sdk/protocol/operation-registry.ts +1 -1
- package/src/sdk/router/session-router.ts +7 -1
- package/src/sdk/session.ts +37 -8
- package/src/session/agent-session.ts +128 -41
- package/src/session/blob-store.ts +78 -33
- package/src/session/internal/managed-session-storage.ts +119 -3
- package/src/setup/hermes/templates/operator-instructions.v1.md +19 -1
- package/src/setup/hermes-setup.ts +4 -1
- package/src/slash-commands/builtin-registry.ts +8 -5
- package/src/tools/ask-contract.test.ts +76 -1
- package/src/tools/ask-contract.ts +57 -6
- package/src/tools/ask.ts +16 -7
- package/src/tools/bash.ts +77 -29
- package/src/tools/descriptors.test.ts +29 -0
- package/src/tools/tool-catalog.generated.ts +7 -4
- package/src/web/search/index.ts +2 -2
- package/dist/types/cli/grep-cli.d.ts +0 -17
- package/dist/types/cli/shell-cli.d.ts +0 -8
- package/dist/types/commands/grep.d.ts +0 -42
- package/dist/types/commands/shell.d.ts +0 -21
- package/src/cli/grep-cli.ts +0 -160
- package/src/cli/shell-cli.ts +0 -176
- package/src/commands/grep.ts +0 -48
- package/src/commands/shell.ts +0 -29
|
@@ -4,7 +4,7 @@ import type { SessionWorkLease } from "../../session/session-work-lease";
|
|
|
4
4
|
import type { SessionLifecycleMcpServer } from "../acp/mcp";
|
|
5
5
|
import { type SdkStartupFailure, type SdkStartupRollbackResult } from "../startup-capability";
|
|
6
6
|
import type { Broker, BrokerCleanupEvidence, BrokerResponse } from "./broker";
|
|
7
|
-
import type { LifecycleDurableEffectsReceipt, LifecycleStartupFailureReceipt } from "./lifecycle-ledger";
|
|
7
|
+
import type { LifecycleDurableEffectsReceipt, LifecycleEffectIntent, LifecycleStartupFailureReceipt } from "./lifecycle-ledger";
|
|
8
8
|
import { type ProcessIncarnationCommandRunner, type ProcessIncarnationOptions, parseDarwinProcessIncarnation, processIncarnation } from "./process-incarnation";
|
|
9
9
|
import { type SdkInternalSpawnCommand } from "./runtime";
|
|
10
10
|
import { type IndexedSession } from "./session-index";
|
|
@@ -52,6 +52,10 @@ export declare function setLifecycleHostPlatformForTest(platform: NodeJS.Platfor
|
|
|
52
52
|
export declare function readyThenExitToleranceEnabledForTest(): boolean;
|
|
53
53
|
export declare function hasValidLifecycleDeadlines(value: LifecycleDeadlines, now?: number): boolean;
|
|
54
54
|
type Input = Record<string, unknown>;
|
|
55
|
+
type LifecycleEffectIntentWithDeadline = LifecycleEffectIntent & {
|
|
56
|
+
lifecycleCleanupDeadlineAt?: number;
|
|
57
|
+
admissionCleanupDeadlineAt?: number;
|
|
58
|
+
};
|
|
55
59
|
export declare const isCanonicalSessionId: (value: string) => boolean;
|
|
56
60
|
export interface SessionLifecycleWorktreeTarget {
|
|
57
61
|
enabled: true;
|
|
@@ -260,6 +264,7 @@ export interface LifecycleExecutionOutcome {
|
|
|
260
264
|
startupFailure?: LifecycleStartupFailureReceipt;
|
|
261
265
|
deferredArtifactCleanup?: () => Promise<void>;
|
|
262
266
|
}
|
|
267
|
+
export declare function classifyLateAdmissionSpawnFailure(response: BrokerResponse, effectIntent: LifecycleEffectIntentWithDeadline | undefined, now: number, messageSource: BrokerResponse): BrokerResponse;
|
|
263
268
|
/** Returns the response together with every durable lifecycle fact needed for truthful replay. */
|
|
264
269
|
export declare function executeLifecycle(broker: Broker, operation: string, input: Input, identity: string, cleanup?: CleanupEvidence): Promise<LifecycleExecutionOutcome>;
|
|
265
270
|
/**
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded exponential backoff tracker for broker recovery failures per agent dir.
|
|
3
|
+
* Tracks repeated recovery failures and implements exponential backoff with a cap
|
|
4
|
+
* to prevent repeated spawns from destabilizing the system.
|
|
5
|
+
*/
|
|
6
|
+
/** Configuration for recovery backoff behavior. */
|
|
7
|
+
export interface RecoveryBackoffConfig {
|
|
8
|
+
/** Initial backoff delay in milliseconds (default: 1000ms). */
|
|
9
|
+
initialDelayMs: number;
|
|
10
|
+
/** Maximum backoff delay in milliseconds (default: 30000ms = 30s). */
|
|
11
|
+
maxDelayMs: number;
|
|
12
|
+
/** Backoff multiplier applied each retry (default: 2). */
|
|
13
|
+
multiplier: number;
|
|
14
|
+
/** Maximum number of recovery attempts per session (default: 5). */
|
|
15
|
+
maxAttempts: number;
|
|
16
|
+
}
|
|
17
|
+
/** State for a single agent dir's recovery backoff. */
|
|
18
|
+
export interface RecoveryBackoffState {
|
|
19
|
+
/** Timestamp of the last recovery failure. */
|
|
20
|
+
lastFailureAt: number;
|
|
21
|
+
/** Current backoff delay in milliseconds. */
|
|
22
|
+
currentDelayMs: number;
|
|
23
|
+
/** Number of consecutive failures. */
|
|
24
|
+
failureCount: number;
|
|
25
|
+
/** Whether recovery has been permanently stopped due to max attempts. */
|
|
26
|
+
stopped: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** Manages per-agent-dir recovery backoff state. */
|
|
29
|
+
export declare class RecoveryBackoffTracker {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(config?: Partial<RecoveryBackoffConfig>);
|
|
32
|
+
/** Test hook: inject a custom clock. */
|
|
33
|
+
setClockForTest(clock: {
|
|
34
|
+
now(): number;
|
|
35
|
+
}): void;
|
|
36
|
+
/**
|
|
37
|
+
* Check if recovery should proceed now, considering backoff.
|
|
38
|
+
* Returns true if sufficient time has elapsed since the last failure.
|
|
39
|
+
*/
|
|
40
|
+
canAttemptRecovery(agentDir: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Record a recovery failure and update backoff state.
|
|
43
|
+
* Returns true if recovery should continue to be attempted, false if max attempts reached.
|
|
44
|
+
*/
|
|
45
|
+
recordFailure(agentDir: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Record a successful recovery and reset backoff state.
|
|
48
|
+
*/
|
|
49
|
+
recordSuccess(agentDir: string): void;
|
|
50
|
+
/**
|
|
51
|
+
* Get the current backoff state for an agent dir (for testing/diagnostics).
|
|
52
|
+
*/
|
|
53
|
+
getState(agentDir: string): RecoveryBackoffState | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Get milliseconds until the next recovery attempt can proceed.
|
|
56
|
+
*/
|
|
57
|
+
getBackoffWaitMs(agentDir: string): number;
|
|
58
|
+
/**
|
|
59
|
+
* Reset all backoff state (for testing).
|
|
60
|
+
*/
|
|
61
|
+
resetForTest(): void;
|
|
62
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type SdkInternalAction = "broker-internal" | "session-host-internal" | "stderr-drain-internal";
|
|
1
|
+
export type SdkInternalAction = "broker-internal" | "broker-trampoline-internal" | "session-host-internal" | "stderr-drain-internal";
|
|
2
2
|
export type SdkInternalSpawnCommand = {
|
|
3
3
|
kind: "bun-source";
|
|
4
4
|
file: string;
|
|
@@ -40,6 +40,14 @@ export interface SdkInternalRuntimeDescriptorTestOptions {
|
|
|
40
40
|
* must not hide behind it.
|
|
41
41
|
*/
|
|
42
42
|
export declare function sdkInternalRuntimeImage(): string | undefined;
|
|
43
|
+
/** Identity of a runtime image: enough to detect replacement at the same path. */
|
|
44
|
+
export interface SdkInternalRuntimeImageIdentity {
|
|
45
|
+
path: string;
|
|
46
|
+
dev: number;
|
|
47
|
+
ino: number;
|
|
48
|
+
mtimeMs: number;
|
|
49
|
+
size: number;
|
|
50
|
+
}
|
|
43
51
|
/**
|
|
44
52
|
* Whether a published runtime image is still a regular file on disk. A resident broker keeps
|
|
45
53
|
* answering requests after the executable it was started from is deleted (a
|
|
@@ -50,6 +58,18 @@ export declare function sdkInternalRuntimeImage(): string | undefined;
|
|
|
50
58
|
* its bound: a false retirement kills a healthy broker.
|
|
51
59
|
*/
|
|
52
60
|
export declare function isSdkInternalRuntimeImagePresent(file: string): Promise<boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* Capture the runtime image identity (dev, ino, mtimeMs, size) at startup.
|
|
63
|
+
* Used to detect if the binary at the same path has been replaced.
|
|
64
|
+
*/
|
|
65
|
+
export declare function captureRuntimeImageIdentity(file: string): Promise<SdkInternalRuntimeImageIdentity | undefined>;
|
|
66
|
+
/**
|
|
67
|
+
* Check if the runtime image has been replaced since startup.
|
|
68
|
+
* Returns `true` if the path is gone, its dev/ino differ from the startup identity,
|
|
69
|
+
* or its size or modification time changed (an in-place rewrite keeps the inode).
|
|
70
|
+
* Returns `false` (inconclusive) if the file exists and matches, or on any error.
|
|
71
|
+
*/
|
|
72
|
+
export declare function isSdkInternalRuntimeImageReplaced(startupIdentity: SdkInternalRuntimeImageIdentity | undefined): Promise<boolean>;
|
|
53
73
|
/** Resolve the production descriptor from the statically imported marker and current Bun runtime evidence. */
|
|
54
74
|
export declare function resolveSdkInternalSpawnCommand(action: SdkInternalAction): SdkInternalSpawnCommand;
|
|
55
75
|
/** Test hook: injects runtime evidence without weakening the production marker authority. */
|
|
@@ -8,6 +8,8 @@ export declare const MIN_PREPARATION_TIMEOUT_MS = 1000;
|
|
|
8
8
|
export declare const MAX_PREPARATION_TIMEOUT_MS = 120000;
|
|
9
9
|
/** Bounded workspace install window; independent of child semantic readiness. */
|
|
10
10
|
export declare const DEFAULT_DEPENDENCY_PREPARATION_TIMEOUT_MS = 30000;
|
|
11
|
+
/** Non-worktree broker pre-spawn cap, also limited by the admission window remaining since receipt. */
|
|
12
|
+
export declare const DEFAULT_BROKER_PRESPAWN_PREPARATION_TIMEOUT_MS = 30000;
|
|
11
13
|
export declare function isValidReadinessTimeoutMs(value: unknown): value is number;
|
|
12
14
|
export declare function isValidPreparationTimeoutMs(value: unknown): value is number;
|
|
13
15
|
export declare const READINESS_TIMEOUT_INVALID_MESSAGE = "readinessTimeoutMs must be an integer between 4000 and 60000.";
|
|
@@ -51,7 +53,9 @@ export declare function lifecycleStartupBudgetMs(requestedReadinessTimeoutMs: nu
|
|
|
51
53
|
*
|
|
52
54
|
* Worktree launches add independent preparation budgets so git add / install cannot
|
|
53
55
|
* cut the caller while the broker still owns the request. One-arg
|
|
54
|
-
* {@link lifecycleStartupBudgetMs} stays queue+readiness for no-worktree callers
|
|
56
|
+
* {@link lifecycleStartupBudgetMs} stays queue+readiness for no-worktree callers:
|
|
57
|
+
* broker-derived pre-spawn work uses only the unspent admission window from receipt,
|
|
58
|
+
* and the fresh readiness window ends within that unchanged caller budget.
|
|
55
59
|
*/
|
|
56
60
|
export declare function lifecycleRequestTimeoutMs(operation: string, input: Record<string, unknown>): number | undefined;
|
|
57
61
|
/**
|
|
@@ -602,6 +602,7 @@ export declare function shouldAwaitNotificationStartup(event: {
|
|
|
602
602
|
origin: string;
|
|
603
603
|
};
|
|
604
604
|
}): boolean;
|
|
605
|
+
export declare function boundedCorrelatedAgentEndFrame(frame: Record<string, unknown>): Record<string, unknown>;
|
|
605
606
|
export declare function createNotificationsExtension(api: ExtensionAPI, options?: {
|
|
606
607
|
settings?: Settings;
|
|
607
608
|
ensureTelegramDaemon?: (input: {
|
|
@@ -292,7 +292,7 @@ export declare const SDK_LIFECYCLE_ROUTER_PROTOCOL_VERSION = 1;
|
|
|
292
292
|
* Generation 193 gates streamed content on negotiated observer capabilities,
|
|
293
293
|
* so existing owners are replaced before exposing the new observer path.
|
|
294
294
|
*/
|
|
295
|
-
export declare const DAEMON_GENERATION =
|
|
295
|
+
export declare const DAEMON_GENERATION = 200;
|
|
296
296
|
/**
|
|
297
297
|
* Serving-compatibility boundary for daemon lifecycle requests. Epoch 7
|
|
298
298
|
* requires durable publication receipts and acknowledged attachment dispatch,
|
|
@@ -1181,4 +1181,5 @@ export declare class TelegramNotificationDaemon {
|
|
|
1181
1181
|
run(): Promise<void>;
|
|
1182
1182
|
/** True when a signal-driven stop or an owner-scoped control request asks the loop to exit. */
|
|
1183
1183
|
private controlStopRequested;
|
|
1184
|
+
private checkControlStopRequested;
|
|
1184
1185
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Isolated `gjc sdk diagnostics` parser and renderer.
|
|
2
|
+
*
|
|
3
|
+
* Reached from the inert entry before any effectful branch, so this module must
|
|
4
|
+
* stay a pure leaf: no command registry, session CLI, runtime globals, managed
|
|
5
|
+
* owner admission, malloc guard, evidence publisher, broker client, directory
|
|
6
|
+
* resolver or logger import. Help and usage never resolve a root or open a file,
|
|
7
|
+
* and every outcome is a fixed bounded string with a fixed exit code.
|
|
8
|
+
*
|
|
9
|
+
* Observation itself must never start, ensure, retire, restart or recover a
|
|
10
|
+
* broker. The read-only observation facade (DESIGN §B3) is wired: `observe()`
|
|
11
|
+
* below routes to it and to nothing else, so this command can report only what a
|
|
12
|
+
* supporting broker publishes to the read-only reader. An unsupported runtime
|
|
13
|
+
* tuple, a missing or mismatched native artifact and an old broker without a
|
|
14
|
+
* published generation all still fail closed with the fixed `unsupported`
|
|
15
|
+
* outcome.
|
|
16
|
+
*/
|
|
17
|
+
/** Run `gjc sdk diagnostics <argv…>`; argv excludes the `sdk diagnostics` prefix. */
|
|
18
|
+
export declare function runDiagnosticsCli(argv: readonly string[]): Promise<void>;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observation-only broker diagnostics facade (SPEC "Result contract").
|
|
3
|
+
*
|
|
4
|
+
* The publication is read ONLY through the approved read-only native lease
|
|
5
|
+
* (`loadDiagnosticNativeReadOnly` -> `openDiagnosticSnapshot` -> bounded read ->
|
|
6
|
+
* revalidate -> close), so every ancestor ACL/owner/mode and filesystem check of the
|
|
7
|
+
* earlier slices governs this route too. Ordinary discovery is deliberately not used: it
|
|
8
|
+
* would bypass that gate. An unsupported runtime tuple or artifact resolves to
|
|
9
|
+
* `unsupported` BEFORE any publication access. The facade then opens exactly ONE client
|
|
10
|
+
* connection with no reconnect attempts, asks the broker for its published diagnostics
|
|
11
|
+
* and returns a detached frozen snapshot. It never ensures, starts, recovers, retires or spawns
|
|
12
|
+
* anything, never touches the session index, ledger or evidence store, and never hands
|
|
13
|
+
* the caller a token, socket coordinate, path, pid or environment value.
|
|
14
|
+
*/
|
|
15
|
+
/** Allowed unavailability reasons; messages are fixed literals keyed by the enum. */
|
|
16
|
+
export type BrokerObservationUnavailableReason = "absent" | "stale" | "incompatible" | "authentication_failed" | "unsupported" | "generation_mismatch" | "transport_unavailable" | "timeout" | "invalid_response" | "unsafe_discovery";
|
|
17
|
+
export interface BrokerObservationBuild {
|
|
18
|
+
readonly packageVersion: string;
|
|
19
|
+
readonly buildId: string | null;
|
|
20
|
+
}
|
|
21
|
+
export interface BrokerObservationSuccess {
|
|
22
|
+
readonly schema: "gjc.broker-observation";
|
|
23
|
+
readonly version: 1;
|
|
24
|
+
readonly ok: true;
|
|
25
|
+
readonly observedAt: string;
|
|
26
|
+
readonly broker: {
|
|
27
|
+
readonly generation: string;
|
|
28
|
+
readonly build: BrokerObservationBuild;
|
|
29
|
+
readonly diagnosticProtocol: 1;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface BrokerObservationUnavailable {
|
|
33
|
+
readonly schema: "gjc.broker-observation";
|
|
34
|
+
readonly version: 1;
|
|
35
|
+
readonly ok: false;
|
|
36
|
+
readonly observedAt: string;
|
|
37
|
+
readonly unavailable: {
|
|
38
|
+
readonly reason: BrokerObservationUnavailableReason;
|
|
39
|
+
readonly message: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export type BrokerObservation = BrokerObservationSuccess | BrokerObservationUnavailable;
|
|
43
|
+
export interface ObserveExistingBrokerOptions {
|
|
44
|
+
readonly agentDir: string;
|
|
45
|
+
readonly expectedGeneration?: string;
|
|
46
|
+
readonly timeoutMs?: number;
|
|
47
|
+
}
|
|
48
|
+
/** The broker's published diagnostics operation. */
|
|
49
|
+
export declare const BROKER_DIAGNOSTICS_OPERATION = "broker.diagnostics";
|
|
50
|
+
/** The only diagnostic protocol this client understands. */
|
|
51
|
+
export declare const BROKER_DIAGNOSTIC_PROTOCOL = 1;
|
|
52
|
+
/** Contract timeout: default 2000 ms, accepted range 1..10000 ms. */
|
|
53
|
+
export declare const OBSERVATION_TIMEOUT_DEFAULT_MS = 2000;
|
|
54
|
+
export declare const OBSERVATION_TIMEOUT_MIN_MS = 1;
|
|
55
|
+
export declare const OBSERVATION_TIMEOUT_MAX_MS = 10000;
|
|
56
|
+
export declare function setObservationClockForTest(clock: (() => number) | null): void;
|
|
57
|
+
/**
|
|
58
|
+
* Test-only observers for the native stage boundary. Production installs none, and the
|
|
59
|
+
* hooks never change a branch, a budget or an outcome: they only report what the
|
|
60
|
+
* observation did (`onNativeOpen`) and give a test a point to disturb the environment
|
|
61
|
+
* between the first publication read and the connection (`afterInitialRead`), which is how
|
|
62
|
+
* the pre-socket identity recheck is proven instead of argued.
|
|
63
|
+
*/
|
|
64
|
+
export interface ObservationTestHooks {
|
|
65
|
+
onNativeOpen?: (info: {
|
|
66
|
+
agentDir: string;
|
|
67
|
+
budgetMs: number;
|
|
68
|
+
}) => void;
|
|
69
|
+
afterInitialRead?: () => void;
|
|
70
|
+
/** Reports that the retained lease was released, on every exit path. */
|
|
71
|
+
onLeaseClosed?: () => void;
|
|
72
|
+
/**
|
|
73
|
+
* Decorates the retained lease so a test can identify the real operation phases and make
|
|
74
|
+
* a chosen phase refuse or throw. Production installs none.
|
|
75
|
+
*/
|
|
76
|
+
wrapLease?: (lease: DiagnosticSnapshotLease) => DiagnosticSnapshotLease;
|
|
77
|
+
/** Replaces the loader result so loader-stage outcomes can be observed deterministically. */
|
|
78
|
+
loaderOverride?: () => DiagnosticNativeLoad;
|
|
79
|
+
}
|
|
80
|
+
/** Minimal shapes this facade relies on from the approved read-only loader. */
|
|
81
|
+
interface DiagnosticSnapshotRead {
|
|
82
|
+
readonly ok: boolean;
|
|
83
|
+
readonly reason?: string | null;
|
|
84
|
+
readonly bytes?: Uint8Array | null;
|
|
85
|
+
}
|
|
86
|
+
interface DiagnosticSnapshotStatus {
|
|
87
|
+
readonly ok: boolean;
|
|
88
|
+
readonly reason?: string | null;
|
|
89
|
+
}
|
|
90
|
+
interface DiagnosticSnapshotLease {
|
|
91
|
+
readonly ok: boolean;
|
|
92
|
+
readonly reason?: string | null;
|
|
93
|
+
read(): DiagnosticSnapshotRead;
|
|
94
|
+
revalidate(): DiagnosticSnapshotStatus;
|
|
95
|
+
close(): void;
|
|
96
|
+
}
|
|
97
|
+
type DiagnosticNativeLoad = {
|
|
98
|
+
ok: true;
|
|
99
|
+
value: {
|
|
100
|
+
openDiagnosticSnapshot(agentDir: string, budgetMs: number): DiagnosticSnapshotLease;
|
|
101
|
+
};
|
|
102
|
+
} | {
|
|
103
|
+
ok: false;
|
|
104
|
+
reason: string;
|
|
105
|
+
};
|
|
106
|
+
export declare function setObservationTestHooksForTest(hooks: ObservationTestHooks | null): void;
|
|
107
|
+
/** Malformed arguments are a typed caller error, never an observed unavailability. */
|
|
108
|
+
export declare class DiagnosticOptionsError extends Error {
|
|
109
|
+
readonly code: "invalid_arguments";
|
|
110
|
+
readonly field: string;
|
|
111
|
+
constructor(field: string);
|
|
112
|
+
}
|
|
113
|
+
export type ObservationOptionsVerdict = {
|
|
114
|
+
ok: true;
|
|
115
|
+
value: {
|
|
116
|
+
agentDir: string;
|
|
117
|
+
expectedGeneration?: string;
|
|
118
|
+
timeoutMs: number;
|
|
119
|
+
};
|
|
120
|
+
} | {
|
|
121
|
+
ok: false;
|
|
122
|
+
error: {
|
|
123
|
+
code: "invalid_arguments";
|
|
124
|
+
field: string;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
/** Validate the caller's options against the exact contract. Pure and total. */
|
|
128
|
+
export declare function validateObservationOptions(options: unknown): ObservationOptionsVerdict;
|
|
129
|
+
/** Whether the endpoint is the canonical owned loopback endpoint with an in-range port. */
|
|
130
|
+
export declare function canonicalLoopbackEndpoint(url: string): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Parse verdicts for the publication bytes. A publication that is well formed but
|
|
133
|
+
* carries no diagnostic capability is NOT malformed: an old broker like that is
|
|
134
|
+
* `unsupported`, never `invalid_response` and never `absent`.
|
|
135
|
+
*/
|
|
136
|
+
export type PublicationVerdict = {
|
|
137
|
+
kind: "ok";
|
|
138
|
+
value: ObservedPublication;
|
|
139
|
+
} | {
|
|
140
|
+
kind: "no-capability";
|
|
141
|
+
} | {
|
|
142
|
+
kind: "malformed";
|
|
143
|
+
};
|
|
144
|
+
/** The publication fields this route reads; every other field is ignored, never trusted. */
|
|
145
|
+
export interface ObservedPublication {
|
|
146
|
+
readonly url: string;
|
|
147
|
+
readonly token: string;
|
|
148
|
+
readonly ownerId: string;
|
|
149
|
+
readonly pid: number;
|
|
150
|
+
readonly incarnation: string | null;
|
|
151
|
+
readonly agentRoot: string | null;
|
|
152
|
+
readonly generation: string;
|
|
153
|
+
readonly diagnosticProtocol: number;
|
|
154
|
+
}
|
|
155
|
+
/** Parse the publication bytes the native lease returned. Strict, bounded, total. */
|
|
156
|
+
export declare function parsePublicationVerdict(bytes: Uint8Array): PublicationVerdict;
|
|
157
|
+
/** Convenience wrapper for callers that only need the accepted shape. */
|
|
158
|
+
export declare function parsePublication(bytes: Uint8Array): ObservedPublication | null;
|
|
159
|
+
/** The exact answered payload this client accepts; unknown fields are refused. */
|
|
160
|
+
interface AnsweredDiagnostics {
|
|
161
|
+
readonly generation: string;
|
|
162
|
+
readonly build: BrokerObservationBuild;
|
|
163
|
+
readonly identity: {
|
|
164
|
+
readonly ownerId: string;
|
|
165
|
+
readonly pid: number;
|
|
166
|
+
readonly agentRoot: string;
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/** Strictly validate the broker's answer, mapping every refusal onto the reason enum. */
|
|
170
|
+
export declare function parseAnsweredDiagnostics(response: unknown): {
|
|
171
|
+
kind: "ok";
|
|
172
|
+
value: AnsweredDiagnostics;
|
|
173
|
+
} | {
|
|
174
|
+
kind: "unavailable";
|
|
175
|
+
reason: BrokerObservationUnavailableReason;
|
|
176
|
+
};
|
|
177
|
+
/** Two publication observations describe the same authority. */
|
|
178
|
+
export declare function sameAuthority(first: ObservedPublication, second: ObservedPublication): boolean;
|
|
179
|
+
/** The broker's answer agrees with the publication on generation and identity. */
|
|
180
|
+
export declare function answerMatchesAuthority(answer: AnsweredDiagnostics, publication: ObservedPublication): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Observe an already running broker. Never starts, ensures, recovers or retires one.
|
|
183
|
+
*/
|
|
184
|
+
export declare function observeExistingBroker(options: ObserveExistingBrokerOptions | unknown): Promise<BrokerObservation>;
|
|
185
|
+
export {};
|
|
@@ -20,7 +20,7 @@ export type ControlInput = Record<string, unknown>;
|
|
|
20
20
|
*/
|
|
21
21
|
export interface ControlSurface {
|
|
22
22
|
prompt(text: string, images?: ControlValue, clientRef?: string): Promise<ControlValue> | ControlValue;
|
|
23
|
-
steer(text: string, clientRef?: string): Promise<ControlValue> | ControlValue;
|
|
23
|
+
steer(text: string, clientRef?: string, expectedSdkRunToken?: string): Promise<ControlValue> | ControlValue;
|
|
24
24
|
followUp(text: string): Promise<ControlValue> | ControlValue;
|
|
25
25
|
abort(): Promise<ControlValue> | ControlValue;
|
|
26
26
|
/** Terminal abort: stop the current root turn (and optionally exact owned work). */
|
|
@@ -3,6 +3,7 @@ import { type Settings } from "../../config/settings";
|
|
|
3
3
|
import type { ExtensionAPI, ExtensionContext } from "../../extensibility/extensions";
|
|
4
4
|
import type { AgentEndEvent } from "../../extensibility/shared-events";
|
|
5
5
|
import { ensureBroker } from "../broker/ensure";
|
|
6
|
+
import { captureRuntimeImageIdentity } from "../broker/runtime";
|
|
6
7
|
import { type MasterRoleAttestationV2, SessionIndex, type SessionLocatorV2 } from "../broker/session-index";
|
|
7
8
|
import type { SdkPromptTerminalOutcome } from "../prompt-status";
|
|
8
9
|
import { type ReceiptState } from "../receipt-state";
|
|
@@ -286,6 +287,12 @@ export interface CreateSdkSessionRuntimeOptions {
|
|
|
286
287
|
onFailureDiagnosticKeyCountForTests?: (count: number) => void;
|
|
287
288
|
/** Test-only observation after a resolved invocation completion is reconciled. */
|
|
288
289
|
onInvocationCompletionReconciledForTests?: (kind: InvocationKind, correlation: InvocationCorrelation) => void;
|
|
290
|
+
/** Test hook: provides a function to inject a controlled clock for broker recovery backoff assertions. */
|
|
291
|
+
setRecoveryBackoffClockForTest?: (inject: (clock: {
|
|
292
|
+
now(): number;
|
|
293
|
+
}) => void) => void;
|
|
294
|
+
/** Test hook: inject mock runtime image identity and replacement detection for broker recovery tests. */
|
|
295
|
+
setRuntimeImageIdentityForTest?: (register: (captureFn: () => Awaited<ReturnType<typeof captureRuntimeImageIdentity>> | undefined, isReplacedFn: () => Promise<boolean>) => void) => void;
|
|
289
296
|
}
|
|
290
297
|
export interface InvocationCorrelation {
|
|
291
298
|
commandId: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { MODEL_PROFILE_DISCOVERY_QUERY, MODEL_PROFILE_ERROR_DETAIL_MAX_BYTES, type ModelProfileCatalogItem, type ModelProfileErrorCode, type ModelProfileErrorDetails, ModelProfileRegistryError, type ModelProfileRegistryErrorDetails, type UnknownModelProfileDetails, UnknownModelProfileError, } from "../config/model-profile-contract";
|
|
2
2
|
export type { QueuedInputAdmission, QueuedInputDelivery, QueuedInputExecution, QueuedInputQueuePolicy, QueuedInputRemovalReason, QueuedInputSubmission, QueuedInputTerminal, SendUserMessageOptions, TrackedSendUserMessageOptions, } from "../session/agent-session";
|
|
3
3
|
export * as bus from "./bus";
|
|
4
|
+
export * from "./diagnostics/observe-broker";
|
|
4
5
|
export * as host from "./host";
|
|
5
6
|
export * as lifecycle from "./lifecycle";
|
|
6
7
|
export * as mcp from "./mcp";
|
|
@@ -65,7 +65,7 @@ export declare const ACP_PROMPT_INFERENCE_TIMEOUT_MS: number;
|
|
|
65
65
|
export declare class PromptActivity {
|
|
66
66
|
#private;
|
|
67
67
|
/** Folds one inbound frame's lifecycle event into the in-flight tool and model state. */
|
|
68
|
-
observe(eventType: string | undefined, toolCallId: string | undefined, messageRole: string | undefined): void;
|
|
68
|
+
observe(eventType: string | undefined, toolCallId: string | undefined, messageRole: string | undefined, messageHasToolCall?: boolean): void;
|
|
69
69
|
/** True while at least one started tool call has not reported an end. */
|
|
70
70
|
get running(): boolean;
|
|
71
71
|
/** True while a dispatched model call has not produced the first frame of its response. */
|
|
@@ -177,6 +177,8 @@ export interface SessionRouterOptions {
|
|
|
177
177
|
agentDir: string;
|
|
178
178
|
/** Limits attachment to exact ids selected by a Broker-scoped operation. */
|
|
179
179
|
sessionIds?: readonly string[];
|
|
180
|
+
/** Dynamically limits attachment to sessions currently owned by the caller. */
|
|
181
|
+
attachFilter?: (sessionId: string) => boolean;
|
|
180
182
|
/** Marks default SDK clients as notification-only observers; demanding by default. */
|
|
181
183
|
observer?: boolean;
|
|
182
184
|
deps?: SessionRouterDeps;
|
|
@@ -188,6 +188,12 @@ export interface CreateAgentSessionOptions {
|
|
|
188
188
|
* @internal CLI-only ordering guard; SDK callers retain immediate startup by default.
|
|
189
189
|
*/
|
|
190
190
|
deferMemoryBackendStartup?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Skip optional model-catalog discovery during lifecycle startup. ACP hosts must
|
|
193
|
+
* publish their endpoint before unrelated provider credential refreshes begin.
|
|
194
|
+
* @internal lifecycle-only startup guard.
|
|
195
|
+
*/
|
|
196
|
+
deferOptionalModelRefresh?: boolean;
|
|
191
197
|
/** Enable LSP integration (tool, formatting, diagnostics, warmup). Default: true */
|
|
192
198
|
enableLsp?: boolean;
|
|
193
199
|
/** Skip Python kernel availability check and prelude warmup */
|
|
@@ -297,6 +303,13 @@ export interface CreateAgentSessionResult {
|
|
|
297
303
|
*/
|
|
298
304
|
gjcRuntimeSnapshot?: GjcRuntimeSnapshotProvider;
|
|
299
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Start optional provider/model discovery only when it is safe to add work to
|
|
308
|
+
* the caller's startup graph. Lifecycle hosts deliberately skip this during
|
|
309
|
+
* construction: discovery preflights every configured provider and may refresh
|
|
310
|
+
* an unrelated OAuth credential while several hosts are opening the same DB.
|
|
311
|
+
*/
|
|
312
|
+
export declare function startOptionalModelRefresh(modelRegistry: Pick<ModelRegistry, "refreshInBackground">, credentialSessionId: string | undefined, deferred: boolean): boolean;
|
|
300
313
|
export interface DeferredMcpConfigStartupResult {
|
|
301
314
|
loadedToolCount: number;
|
|
302
315
|
hasErrors: boolean;
|
|
@@ -1111,7 +1111,11 @@ export declare class AgentSession {
|
|
|
1111
1111
|
get sessionWorkLease(): SessionWorkLease;
|
|
1112
1112
|
/** Stable resource ownership identifier for the active prompt run. */
|
|
1113
1113
|
get activePromptHandle(): string | undefined;
|
|
1114
|
-
/**
|
|
1114
|
+
/**
|
|
1115
|
+
* All messages including custom types like BashExecutionMessage. Request-scoped
|
|
1116
|
+
* ephemeral copies are retained only in `agent.state.messages` to keep the provider
|
|
1117
|
+
* cache prefix stable; they are never part of this public view.
|
|
1118
|
+
*/
|
|
1115
1119
|
get messages(): AgentMessage[];
|
|
1116
1120
|
get transcriptPromptGeneration(): number;
|
|
1117
1121
|
static restoreFromMemoryGuardCheckpoint(input: AgentSessionMemoryGuardRestoreInput): Promise<AgentMemoryGuardRestoreResult>;
|