@gajae-code/coding-agent 0.16.3 → 0.16.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 +113 -0
- package/dist/types/capability/types.d.ts +4 -0
- package/dist/types/cli/args.d.ts +2 -2
- package/dist/types/cli/customize-doctor.d.ts +22 -0
- package/dist/types/cli/root-flags.d.ts +4 -2
- package/dist/types/cli.d.ts +1 -1
- package/dist/types/commands/launch.d.ts +1 -1
- package/dist/types/config/autorouting-tier-map.d.ts +3 -0
- package/dist/types/config/file-lock.d.ts +31 -3
- package/dist/types/config/model-registry.d.ts +4 -0
- package/dist/types/config/model-resolver.d.ts +9 -0
- package/dist/types/config/settings-schema.d.ts +29 -1
- package/dist/types/coordinator-mcp/question-state.d.ts +7 -0
- package/dist/types/coordinator-mcp/server.d.ts +7 -0
- package/dist/types/discovery/claude-plugins.d.ts +3 -1
- package/dist/types/discovery/helpers.d.ts +35 -0
- package/dist/types/exec/bash-executor.d.ts +17 -1
- package/dist/types/exec/bash-shell-guardian.d.ts +15 -0
- package/dist/types/exec/bash-shell-runtime-entry.d.ts +2 -0
- package/dist/types/exec/bash-shell-signals.d.ts +2 -0
- package/dist/types/exec/bash-shell-supervisor-entry.d.ts +1 -0
- package/dist/types/exec/bash-shell-supervisor.d.ts +10 -0
- package/dist/types/exec/bash-shell-worker-entry.d.ts +2 -0
- package/dist/types/exec/bash-shell-worker-protocol.d.ts +63 -0
- package/dist/types/exec/bash-shell-worker.d.ts +1 -0
- package/dist/types/exec/isolated-shell.d.ts +19 -0
- package/dist/types/extensibility/extensions/function-hooks-internal.d.ts +9 -0
- package/dist/types/extensibility/extensions/function-hooks.d.ts +169 -0
- package/dist/types/extensibility/extensions/index.d.ts +1 -0
- package/dist/types/extensibility/extensions/runner.d.ts +46 -6
- package/dist/types/extensibility/extensions/types.d.ts +16 -0
- package/dist/types/extensibility/extensions/wrapper.d.ts +3 -1
- package/dist/types/extensibility/gjc-plugins/constrained-hooks.d.ts +35 -2
- package/dist/types/extensibility/gjc-plugins/mcp-policy.d.ts +16 -0
- package/dist/types/extensibility/gjc-plugins/paths.d.ts +2 -0
- package/dist/types/extensibility/gjc-plugins/types.d.ts +25 -0
- package/dist/types/extensibility/hooks/types.d.ts +4 -0
- package/dist/types/extensibility/runtime-skill-discovery.d.ts +5 -2
- package/dist/types/extensibility/shared-events.d.ts +1 -1
- package/dist/types/extensibility/skill-management.d.ts +9 -4
- package/dist/types/extensibility/skills.d.ts +2 -0
- package/dist/types/gjc-runtime/empty-delete-gc.d.ts +4 -1
- package/dist/types/gjc-runtime/linux-proc.d.ts +2 -0
- package/dist/types/gjc-runtime/session-state-lock.d.ts +14 -0
- package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +41 -3
- package/dist/types/gjc-runtime/ultragoal-succession.d.ts +251 -0
- package/dist/types/modes/components/assistant-message.d.ts +1 -2
- package/dist/types/modes/components/bash-execution.d.ts +1 -0
- package/dist/types/modes/components/execution-shared.d.ts +1 -0
- package/dist/types/modes/components/settings-selector.d.ts +6 -1
- package/dist/types/modes/components/status-line/command.d.ts +35 -0
- package/dist/types/modes/components/status-line/index.d.ts +1 -0
- package/dist/types/modes/components/status-line/types.d.ts +5 -0
- package/dist/types/modes/components/tool-status-header.d.ts +14 -0
- package/dist/types/modes/controllers/event-controller.d.ts +6 -0
- package/dist/types/modes/interactive-mode.d.ts +3 -0
- package/dist/types/modes/types.d.ts +7 -0
- package/dist/types/runtime-mcp/client.d.ts +9 -1
- package/dist/types/runtime-mcp/manager.d.ts +7 -1
- package/dist/types/runtime-mcp/pool.d.ts +22 -3
- package/dist/types/runtime-mcp/transports/stdio.d.ts +0 -4
- package/dist/types/runtime-mcp/types.d.ts +22 -0
- package/dist/types/sdk/broker/ensure.d.ts +32 -0
- package/dist/types/sdk/broker/lifecycle-ledger.d.ts +0 -1
- package/dist/types/sdk/broker/lifecycle.d.ts +6 -0
- package/dist/types/sdk/broker/startup-failure.d.ts +4 -1
- package/dist/types/sdk/bus/chat-daemon-control.d.ts +2 -0
- package/dist/types/sdk/bus/chat-daemon-runtime.d.ts +12 -0
- package/dist/types/sdk/bus/chat-effect-journal.d.ts +17 -2
- package/dist/types/sdk/bus/conversation-store.d.ts +11 -0
- package/dist/types/sdk/bus/lifecycle-commands.d.ts +8 -8
- package/dist/types/sdk/bus/slack-daemon.d.ts +1 -1
- package/dist/types/sdk/bus/slack-live-provider.d.ts +6 -0
- package/dist/types/sdk/bus/slack-provider.d.ts +12 -0
- package/dist/types/sdk/bus/topic-registry.d.ts +8 -0
- package/dist/types/sdk/client/client.d.ts +6 -0
- package/dist/types/sdk/host/host.d.ts +3 -1
- package/dist/types/sdk/host/session-runtime.d.ts +26 -1
- package/dist/types/sdk/lifecycle/service.d.ts +1 -0
- package/dist/types/sdk/router/session-router.d.ts +10 -2
- package/dist/types/sdk/session-api-key.d.ts +26 -0
- package/dist/types/sdk/session.d.ts +5 -1
- package/dist/types/sdk/transport/serve-cli.d.ts +1 -1
- package/dist/types/session/agent-session.d.ts +11 -0
- package/dist/types/session/fallback-chain-controller.d.ts +15 -0
- package/dist/types/session/internal/managed-session-storage.d.ts +7 -0
- package/dist/types/session/messages.d.ts +1 -0
- package/dist/types/session/session-manager.d.ts +3 -1
- package/dist/types/setup/paseo/announce.d.ts +112 -0
- package/dist/types/setup/paseo/setup-deps.d.ts +2 -1
- package/dist/types/skill-state/canonical-skills.d.ts +4 -0
- package/dist/types/system-prompt.d.ts +10 -0
- package/dist/types/task/executor.d.ts +5 -1
- package/dist/types/tools/bash.d.ts +1 -0
- package/dist/types/tools/fetch.d.ts +7 -0
- package/dist/types/tools/github-cache.d.ts +2 -1
- package/dist/types/tools/index.d.ts +10 -0
- package/dist/types/tools/path-utils.d.ts +2 -0
- package/dist/types/tools/search.d.ts +6 -0
- package/package.json +9 -7
- package/scripts/capture-status-line-custom-editor-showcase.ts +151 -0
- package/scripts/generate-sdk-operation-inventory.ts +11 -0
- package/scripts/verify-status-line-custom-editor-showcase.ts +309 -0
- package/src/capability/index.ts +14 -2
- package/src/capability/types.ts +4 -0
- package/src/cli/args.ts +20 -9
- package/src/cli/customize-doctor.ts +155 -12
- package/src/cli/root-flags.ts +5 -3
- package/src/cli.ts +22 -0
- package/src/commands/sdk.ts +74 -31
- package/src/config/autorouting-tier-map.ts +1 -0
- package/src/config/file-lock-gc.ts +40 -2
- package/src/config/file-lock.ts +379 -31
- package/src/config/model-preset-registry.ts +120 -19
- package/src/config/model-profiles.ts +40 -0
- package/src/config/model-registry.ts +73 -23
- package/src/config/model-resolver.ts +48 -0
- package/src/config/settings-schema.ts +33 -1
- package/src/config/settings.ts +1 -0
- package/src/coordinator-mcp/question-state.ts +33 -2
- package/src/coordinator-mcp/server.ts +477 -101
- package/src/crash/sanitize.ts +1 -1
- package/src/defaults/gjc/extensions/grok-cli-vendor/src/models/catalog.ts +11 -11
- package/src/defaults/gjc/extensions/grok-cli-vendor/src/provider/register.ts +13 -2
- package/src/defaults/gjc/skills/ultragoal/SKILL.md +22 -0
- package/src/discovery/builtin.ts +52 -55
- package/src/discovery/claude-plugins.ts +12 -4
- package/src/discovery/helpers.ts +307 -34
- package/src/exec/bash-executor.ts +330 -50
- package/src/exec/bash-shell-guardian.ts +388 -0
- package/src/exec/bash-shell-runtime-entry.ts +5 -0
- package/src/exec/bash-shell-signals.ts +29 -0
- package/src/exec/bash-shell-supervisor-entry.ts +3 -0
- package/src/exec/bash-shell-supervisor.ts +359 -0
- package/src/exec/bash-shell-worker-entry.ts +5 -0
- package/src/exec/bash-shell-worker-protocol.ts +36 -0
- package/src/exec/bash-shell-worker.ts +116 -0
- package/src/exec/isolated-shell.ts +393 -0
- package/src/extensibility/extensions/function-hooks-internal.ts +73 -0
- package/src/extensibility/extensions/function-hooks.ts +959 -0
- package/src/extensibility/extensions/index.ts +22 -0
- package/src/extensibility/extensions/loader.ts +53 -2
- package/src/extensibility/extensions/runner.ts +895 -264
- package/src/extensibility/extensions/types.ts +42 -0
- package/src/extensibility/extensions/wrapper.ts +56 -15
- package/src/extensibility/gjc-plugins/compiler.ts +228 -60
- package/src/extensibility/gjc-plugins/constrained-hooks.ts +321 -23
- package/src/extensibility/gjc-plugins/installer.ts +13 -12
- package/src/extensibility/gjc-plugins/mcp-policy.ts +81 -52
- package/src/extensibility/gjc-plugins/paths.ts +13 -0
- package/src/extensibility/gjc-plugins/registry.ts +113 -1
- package/src/extensibility/gjc-plugins/runtime-adapters.ts +758 -16
- package/src/extensibility/gjc-plugins/runtime-quarantine.ts +20 -2
- package/src/extensibility/gjc-plugins/schema.ts +121 -4
- package/src/extensibility/gjc-plugins/types.ts +25 -0
- package/src/extensibility/hooks/loader.ts +133 -16
- package/src/extensibility/hooks/types.ts +28 -0
- package/src/extensibility/runtime-skill-discovery.ts +149 -190
- package/src/extensibility/shared-events.ts +1 -1
- package/src/extensibility/skill-management.ts +200 -52
- package/src/extensibility/skills.ts +73 -25
- package/src/gjc-runtime/empty-delete-gc.ts +94 -4
- package/src/gjc-runtime/gc-runtime.ts +29 -0
- package/src/gjc-runtime/linux-proc.ts +14 -0
- package/src/gjc-runtime/repository-binding.ts +1 -1
- package/src/gjc-runtime/session-state-lock.ts +143 -10
- package/src/gjc-runtime/session-state-sidecar.ts +27 -11
- package/src/gjc-runtime/state-writer.ts +30 -29
- package/src/gjc-runtime/ultragoal-runtime.ts +189 -47
- package/src/gjc-runtime/ultragoal-succession.ts +1667 -0
- package/src/gjc-runtime/workflow-manifest.generated.json +52 -1
- package/src/gjc-runtime/workflow-manifest.ts +16 -0
- package/src/harness-control-plane/session-lease.ts +2 -2
- package/src/internal-urls/docs-index.generated.ts +12 -12
- package/src/lsp/config.ts +10 -3
- package/src/lsp/index.ts +1 -1
- package/src/lsp/path-trust.ts +69 -14
- package/src/main.ts +78 -35
- package/src/modes/DESIGN.md +54 -0
- package/src/modes/acp/acp-agent.ts +16 -3
- package/src/modes/components/assistant-message.ts +22 -9
- package/src/modes/components/bash-execution.ts +4 -1
- package/src/modes/components/execution-shared.ts +4 -1
- package/src/modes/components/model-selector.ts +166 -33
- package/src/modes/components/session-observer-overlay.ts +1 -1
- package/src/modes/components/settings-selector.ts +1075 -235
- package/src/modes/components/status-line/command.ts +190 -0
- package/src/modes/components/status-line/index.ts +1 -0
- package/src/modes/components/status-line/segments.ts +32 -5
- package/src/modes/components/status-line/types.ts +5 -0
- package/src/modes/components/tool-status-header.ts +396 -22
- package/src/modes/controllers/command-controller.ts +3 -0
- package/src/modes/controllers/event-controller.ts +151 -7
- package/src/modes/controllers/extension-ui-controller.ts +1 -0
- package/src/modes/controllers/input-controller.ts +6 -3
- package/src/modes/controllers/selector-controller.ts +21 -0
- package/src/modes/interactive-mode.ts +53 -6
- package/src/modes/print-mode.ts +5 -1
- package/src/modes/prompt-action-autocomplete.ts +54 -27
- package/src/modes/runtime-init.ts +2 -0
- package/src/modes/types.ts +17 -3
- package/src/modes/utils/ui-helpers.ts +2 -0
- package/src/prompts/system/system-prompt.md +8 -0
- package/src/prompts/tools/search.md +2 -0
- package/src/prompts/tools/subagent.md +1 -0
- package/src/runtime-mcp/client.ts +60 -17
- package/src/runtime-mcp/manager.ts +189 -14
- package/src/runtime-mcp/pool.test.ts +218 -0
- package/src/runtime-mcp/pool.ts +224 -23
- package/src/runtime-mcp/transports/stdio.ts +158 -24
- package/src/runtime-mcp/types.ts +24 -0
- package/src/sdk/broker/broker.ts +124 -32
- package/src/sdk/broker/ensure.ts +248 -41
- package/src/sdk/broker/lifecycle-ledger.ts +7 -17
- package/src/sdk/broker/lifecycle.ts +56 -6
- package/src/sdk/broker/startup-failure.ts +15 -6
- package/src/sdk/bus/chat-daemon-control.ts +3 -1
- package/src/sdk/bus/chat-daemon-runtime.ts +72 -6
- package/src/sdk/bus/chat-effect-journal.ts +132 -7
- package/src/sdk/bus/conversation-store.ts +29 -0
- package/src/sdk/bus/lifecycle-commands.ts +17 -11
- package/src/sdk/bus/slack-conversation.ts +1 -0
- package/src/sdk/bus/slack-daemon.ts +478 -49
- package/src/sdk/bus/slack-live-provider.ts +12 -0
- package/src/sdk/bus/slack-provider.ts +5 -0
- package/src/sdk/bus/telegram-daemon.ts +16 -2
- package/src/sdk/bus/topic-registry.ts +19 -0
- package/src/sdk/cli/master-cli.ts +1 -1
- package/src/sdk/cli/session-cli.ts +11 -8
- package/src/sdk/client/client.ts +66 -17
- package/src/sdk/host/host.ts +29 -9
- package/src/sdk/host/query/revision-store.ts +19 -13
- package/src/sdk/host/reverse-leases.ts +7 -4
- package/src/sdk/host/session-runtime.test.ts +52 -10
- package/src/sdk/host/session-runtime.ts +383 -44
- package/src/sdk/lifecycle/service.ts +4 -0
- package/src/sdk/protocol/operation-inventory.generated.json +77 -0
- package/src/sdk/router/session-router.ts +89 -38
- package/src/sdk/session-api-key.ts +94 -0
- package/src/sdk/session.ts +228 -55
- package/src/sdk/transport/relay.ts +35 -13
- package/src/sdk/transport/serve-cli.ts +3 -3
- package/src/session/agent-session.ts +240 -90
- package/src/session/contribution-prep.ts +214 -21
- package/src/session/fallback-chain-controller.ts +38 -0
- package/src/session/internal/managed-session-storage.ts +19 -5
- package/src/session/messages.ts +5 -0
- package/src/session/session-manager.ts +29 -5
- package/src/session-import/redact.ts +5 -1
- package/src/setup/paseo/announce.ts +456 -0
- package/src/setup/paseo/setup-deps.ts +15 -3
- package/src/skill-state/canonical-skills.ts +12 -0
- package/src/skills/skills.test.ts +41 -21
- package/src/slash-commands/builtin-registry.ts +1 -0
- package/src/system-prompt.ts +29 -3
- package/src/task/executor.ts +7 -1
- package/src/task/index.ts +21 -4
- package/src/tools/bash.ts +63 -19
- package/src/tools/cron.ts +1 -1
- package/src/tools/fetch.ts +29 -1
- package/src/tools/gh.ts +26 -3
- package/src/tools/github-cache.ts +68 -16
- package/src/tools/index.ts +10 -0
- package/src/tools/job.ts +21 -4
- package/src/tools/monitor.ts +8 -2
- package/src/tools/path-utils.ts +7 -0
- package/src/tools/read.ts +14 -2
- package/src/tools/render-utils.ts +1 -3
- package/src/tools/resource-gc.ts +28 -8
- package/src/tools/search.ts +116 -58
- package/src/tools/skill-discovery.ts +5 -0
- package/src/tools/skill.ts +37 -2
- package/src/tools/subagent.ts +6 -3
- package/src/tools/tool-catalog.generated.ts +10 -3
- package/src/tools/ultragoal-ask-guard.ts +2 -2
- package/src/web/insane/bridge.ts +113 -23
- package/src/web/search/providers/perplexity.ts +102 -41
|
@@ -57,6 +57,11 @@ export type ActivityIndicatorStopOptions = Readonly<{
|
|
|
57
57
|
/** The terminal event is authoritative even if the session's streaming flag has not settled yet. */
|
|
58
58
|
foregroundSettled?: boolean;
|
|
59
59
|
}>;
|
|
60
|
+
export declare function clearInteractiveActivityIndicator(ctx: {
|
|
61
|
+
loadingAnimation?: Loader;
|
|
62
|
+
statusContainer?: PartialActivityStatusContainer;
|
|
63
|
+
clearLoadingAnimation?: () => void;
|
|
64
|
+
}): void;
|
|
60
65
|
export declare function stopInteractiveActivityIndicator(ctx: {
|
|
61
66
|
loadingAnimation?: Loader;
|
|
62
67
|
statusContainer?: PartialActivityStatusContainer;
|
|
@@ -190,6 +195,7 @@ export interface InteractiveModeContext {
|
|
|
190
195
|
setWorkingMessage(message?: string): void;
|
|
191
196
|
applyPendingWorkingMessage(): void;
|
|
192
197
|
ensureLoadingAnimation(): void;
|
|
198
|
+
clearLoadingAnimation(): void;
|
|
193
199
|
syncActivityIndicator(): void;
|
|
194
200
|
suspendActivityIndicator(): () => void;
|
|
195
201
|
stopLoadingAnimation(options?: ActivityIndicatorStopOptions): void;
|
|
@@ -259,6 +265,7 @@ export interface InteractiveModeContext {
|
|
|
259
265
|
extractAssistantText(message: AssistantMessage): string;
|
|
260
266
|
/** Records one semantic visible-transcript mutation for the sticky viewport. */
|
|
261
267
|
recordVisibleTranscriptMutation?(): void;
|
|
268
|
+
resetAssistantTextPresentation(): void;
|
|
262
269
|
updateEditorTopBorder(): void;
|
|
263
270
|
updateEditorBorderColor(): void;
|
|
264
271
|
rebuildChatFromMessages(policy: TranscriptRebuildPolicy): void;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import type { MCPGetPromptResult, MCPPrompt, MCPRequestOptions, MCPResource, MCPResourceReadResult, MCPResourceTemplate, MCPServerCapabilities, MCPServerConfig, MCPServerConnection, MCPToolCallResult, MCPToolDefinition } from "./types";
|
|
1
|
+
import type { MCPGetPromptResult, MCPPrompt, MCPRequestOptions, MCPResource, MCPResourceReadResult, MCPResourceTemplate, MCPServerCapabilities, MCPServerConfig, MCPServerConnection, MCPToolCallResult, MCPToolDefinition, MCPTransport } from "./types";
|
|
2
|
+
import { MCPExpectedFailure } from "./types";
|
|
3
|
+
/** Failed connection whose still-owned transport cleanup can be retried explicitly. */
|
|
4
|
+
export declare class MCPConnectionCleanupFailure extends MCPExpectedFailure {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(cause: unknown, transport: MCPTransport);
|
|
7
|
+
/** Retry the same retained transport cleanup; failures preserve all prior causes. */
|
|
8
|
+
close(): Promise<void>;
|
|
9
|
+
}
|
|
2
10
|
/**
|
|
3
11
|
* Connect to an MCP server.
|
|
4
12
|
* Has a 30 second timeout to prevent blocking startup.
|
|
@@ -8,6 +8,7 @@ import { type TSchema } from "@gajae-code/ai/core";
|
|
|
8
8
|
import type { SourceMeta } from "../capability/types";
|
|
9
9
|
import type { CustomTool } from "../extensibility/custom-tools/types";
|
|
10
10
|
import type { AuthStorage } from "../session/auth-storage";
|
|
11
|
+
import { MCPConnectionCleanupFailure } from "./client";
|
|
11
12
|
import { MCPConnectionPool, type MCPPoolLease } from "./pool";
|
|
12
13
|
import type { MCPProtocolObservation } from "./protocol";
|
|
13
14
|
import type { MCPToolDetails } from "./tool-bridge";
|
|
@@ -200,6 +201,10 @@ export declare class MCPManager {
|
|
|
200
201
|
}): Promise<T>;
|
|
201
202
|
/** Read-only test seam for pending retired lease-release records. */
|
|
202
203
|
get retiredLeaseReleaseCountForTests(): number;
|
|
204
|
+
/** Read-only test seam for retained failed-connection cleanup owners. */
|
|
205
|
+
get pendingConnectionCleanupCountForTests(): number;
|
|
206
|
+
/** Read-only test seam for retained failed-connection cleanup causes. */
|
|
207
|
+
getPendingConnectionCleanupFailureForTests(name: string): MCPConnectionCleanupFailure | undefined;
|
|
203
208
|
/**
|
|
204
209
|
* Get all connected server names.
|
|
205
210
|
*/
|
|
@@ -223,7 +228,8 @@ export declare class MCPManager {
|
|
|
223
228
|
* Tears down the stale connection, re-resolves auth, establishes a new
|
|
224
229
|
* connection, reloads tools, and notifies consumers.
|
|
225
230
|
* Concurrent calls for the same server share one reconnection attempt.
|
|
226
|
-
* Returns the new connection, or null if reconnection
|
|
231
|
+
* Returns the new connection, or null if reconnection fails after cleanup.
|
|
232
|
+
* Throws a retryable cleanup failure while the previous transport owner remains incomplete.
|
|
227
233
|
*/
|
|
228
234
|
reconnectServer(name: string): Promise<MCPServerConnection | null>;
|
|
229
235
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MCPConnectionCleanupFailure } from "./client";
|
|
1
2
|
import { type MCPPoolKeyIdentity, type MCPPoolKeyOptions, type MCPPoolSharingMode } from "./pool-key";
|
|
2
3
|
import { type MCPRequestOptions, type MCPServerConfig, type MCPServerConnection } from "./types";
|
|
3
4
|
export type { MCPPoolCapabilityProfile, MCPPoolKeyIdentity, MCPPoolKeyOptions, MCPPoolSharingMode } from "./pool-key";
|
|
@@ -18,8 +19,9 @@ export declare class MCPPoolAcquireAbortError extends Error {
|
|
|
18
19
|
readonly code: "MCP_POOL_ACQUIRE_ABORTED";
|
|
19
20
|
readonly serverName: string;
|
|
20
21
|
readonly poolKey: string;
|
|
21
|
-
cleanup?: Promise<
|
|
22
|
-
|
|
22
|
+
readonly cleanup?: Promise<void>;
|
|
23
|
+
readonly cleanupGeneration?: number;
|
|
24
|
+
constructor(serverName: string, poolKey: string, cause: unknown, cleanup?: Promise<void>, cleanupGeneration?: number);
|
|
23
25
|
}
|
|
24
26
|
export declare class MCPPoolLeaseInvalidatedError extends Error {
|
|
25
27
|
readonly code: "MCP_POOL_LEASE_INVALIDATED";
|
|
@@ -60,6 +62,8 @@ export interface MCPPoolAcquireOptions extends MCPPoolKeyOptions {
|
|
|
60
62
|
advertiseRoots?: boolean;
|
|
61
63
|
onNotification?: (method: string, params: unknown) => void;
|
|
62
64
|
onRequest?: (method: string, params: unknown) => Promise<unknown>;
|
|
65
|
+
/** @internal Synchronous handoff for a pool-owned abandoned-acquire cleanup flight. */
|
|
66
|
+
onCleanupPending?: (error: MCPPoolAcquireAbortError) => void;
|
|
63
67
|
}
|
|
64
68
|
export interface MCPConnectionPoolOptions {
|
|
65
69
|
sharedPoolIdleMs?: number;
|
|
@@ -105,6 +109,7 @@ type PendingWaiter = {
|
|
|
105
109
|
settled: boolean;
|
|
106
110
|
claimed: boolean;
|
|
107
111
|
removeAbortListener?: () => void;
|
|
112
|
+
onCleanupPending?: (error: MCPPoolAcquireAbortError) => void;
|
|
108
113
|
};
|
|
109
114
|
type PendingEntry = {
|
|
110
115
|
claims: number;
|
|
@@ -118,7 +123,7 @@ type PendingEntry = {
|
|
|
118
123
|
cancellationReason?: unknown;
|
|
119
124
|
openAbortController: AbortController;
|
|
120
125
|
openSignal?: AbortSignal;
|
|
121
|
-
settlement?: Promise<
|
|
126
|
+
settlement?: Promise<void>;
|
|
122
127
|
};
|
|
123
128
|
/** A lease over one physical MCP connection. */
|
|
124
129
|
export interface MCPPoolLease {
|
|
@@ -182,6 +187,20 @@ export declare class MCPConnectionPool {
|
|
|
182
187
|
awaitRestart(key: string): Promise<boolean>;
|
|
183
188
|
finishRestart(key: string, error?: unknown): void;
|
|
184
189
|
releaseRestart(key: string): void;
|
|
190
|
+
private retainCancelledAcquireCleanup;
|
|
191
|
+
private notifyPendingAcquireCleanup;
|
|
192
|
+
/** @internal Whether this pool still owns the notified abandoned-acquire flight. */
|
|
193
|
+
hasPendingAcquireCleanup(error: MCPPoolAcquireAbortError): boolean;
|
|
194
|
+
/** @internal Current retained failure for one notified abandoned-acquire generation. */
|
|
195
|
+
getPendingAcquireCleanupFailure(error: MCPPoolAcquireAbortError): MCPConnectionCleanupFailure | undefined;
|
|
196
|
+
/** @internal Prevent manager-level duplication of the pool's retained cleanup owner. */
|
|
197
|
+
ownsPendingAcquireCleanupFailure(error: unknown): boolean;
|
|
198
|
+
/** Read-only test seam for abandoned-acquire cleanup owners. */
|
|
199
|
+
get pendingAcquireCleanupCountForTests(): number;
|
|
200
|
+
/** Read-only test seam for the current retained abandoned-acquire cleanup failure. */
|
|
201
|
+
getPendingAcquireCleanupFailureForTests(name: string): MCPConnectionCleanupFailure | undefined;
|
|
202
|
+
/** @internal Join and retry one generation of abandoned acquisition cleanup. */
|
|
203
|
+
closePendingAcquireCleanup(key: string, generation: number): Promise<void>;
|
|
185
204
|
acquire(name: string, config: MCPServerConfig, options?: MCPPoolAcquireOptions): Promise<MCPPoolLease>;
|
|
186
205
|
private waitForPendingEntry;
|
|
187
206
|
private scheduleZeroClaimCleanup;
|
|
@@ -23,7 +23,3 @@ export declare class StdioTransport implements MCPTransport {
|
|
|
23
23
|
notify(method: string, params?: Record<string, unknown>): Promise<void>;
|
|
24
24
|
close(): Promise<void>;
|
|
25
25
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Create and connect a stdio transport.
|
|
28
|
-
*/
|
|
29
|
-
export declare function createStdioTransport(config: MCPStdioServerConfig): Promise<StdioTransport>;
|
|
@@ -78,6 +78,20 @@ export interface MCPServerConfigBase {
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
/** Stdio server configuration */
|
|
81
|
+
export interface MCPStdioSpawnLaunch {
|
|
82
|
+
command: string;
|
|
83
|
+
args: readonly string[];
|
|
84
|
+
cwd: string;
|
|
85
|
+
/** Transport-supplied registrar for retryable cleanup before preparation allocates resources. */
|
|
86
|
+
registerCleanup?: (cleanup: () => Promise<void>) => void;
|
|
87
|
+
}
|
|
88
|
+
export interface MCPStdioPreparedLaunch extends MCPStdioSpawnLaunch {
|
|
89
|
+
/**
|
|
90
|
+
* Per-attempt cleanup run after confirmed child exit or failed spawn. The same
|
|
91
|
+
* callback may already have been registered during preparation.
|
|
92
|
+
*/
|
|
93
|
+
afterProcessExit?: () => Promise<void>;
|
|
94
|
+
}
|
|
81
95
|
export interface MCPStdioServerConfig extends MCPServerConfigBase {
|
|
82
96
|
type?: "stdio";
|
|
83
97
|
command: string;
|
|
@@ -91,6 +105,14 @@ export interface MCPStdioServerConfig extends MCPServerConfigBase {
|
|
|
91
105
|
*/
|
|
92
106
|
noInheritEnv?: boolean;
|
|
93
107
|
cwd?: string;
|
|
108
|
+
/** Internal trusted-boundary preparation of immutable per-spawn authority. */
|
|
109
|
+
prepareSpawn?: (launch: MCPStdioSpawnLaunch) => Promise<MCPStdioPreparedLaunch>;
|
|
110
|
+
/** Internal trusted-boundary check run immediately before process creation. */
|
|
111
|
+
spawnGuard?: (launch: MCPStdioSpawnLaunch) => Promise<void>;
|
|
112
|
+
/** Internal cleanup run only after the owned stdio child is confirmed exited. */
|
|
113
|
+
afterProcessExit?: () => Promise<void>;
|
|
114
|
+
/** Test seam for deterministic mutation after the guard and before process creation. */
|
|
115
|
+
afterSpawnGuardForTest?: () => Promise<void>;
|
|
94
116
|
}
|
|
95
117
|
/** HTTP server configuration (Streamable HTTP transport) */
|
|
96
118
|
export interface MCPHttpServerConfig extends MCPServerConfigBase {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type ChildProcess } from "node:child_process";
|
|
2
2
|
import type { FileHandle } from "node:fs/promises";
|
|
3
|
+
import { type FileLockOptions } from "../../config/file-lock";
|
|
3
4
|
import { type BrokerDiscovery } from "./discovery";
|
|
4
5
|
import { type SdkInternalSpawnCommand } from "./runtime";
|
|
6
|
+
export declare function isBrokerGenerationCompatible(discovery: BrokerDiscovery | null): boolean;
|
|
5
7
|
export interface EnsureBrokerSettings {
|
|
6
8
|
agentDir: string;
|
|
7
9
|
heartbeatTtlMs?: number;
|
|
@@ -12,6 +14,27 @@ export interface EnsureBrokerSettings {
|
|
|
12
14
|
*/
|
|
13
15
|
env?: NodeJS.ProcessEnv;
|
|
14
16
|
}
|
|
17
|
+
type SpawnLockOptions = Pick<FileLockOptions, "retries" | "retryDelayMs" | "signal">;
|
|
18
|
+
declare function readBrokerDiscoveryBeforeDeadline(agentDir: string, heartbeatTtlMs: number | undefined, deadline: number): Promise<BrokerDiscovery | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Cross-process single-flight for the detached broker spawn (#5198).
|
|
21
|
+
*
|
|
22
|
+
* `ensureInFlight` only dedupes within one process. Every CLI invocation is
|
|
23
|
+
* its own process, so N concurrent invocations that all miss discovery each
|
|
24
|
+
* spawn a broker; the losers of the runtime's ownership lock then leave
|
|
25
|
+
* quarantine tombstones behind and the next start fails with
|
|
26
|
+
* `quarantine_collision`. The spawn itself must be exclusive across process
|
|
27
|
+
* death and PID reuse, so it uses the shared identity-bound file-lock protocol:
|
|
28
|
+
* complete owner metadata is published atomically, stale removal is bound to
|
|
29
|
+
* the exact directory generation, and ownership includes the OS incarnation.
|
|
30
|
+
*/
|
|
31
|
+
declare function acquireSpawnLock(agentDir: string, options?: SpawnLockOptions): Promise<() => Promise<void>>;
|
|
32
|
+
/**
|
|
33
|
+
* Child-owned fence for the interval from bootstrap through discovery publication.
|
|
34
|
+
* The parent-held spawn lock prevents ordinary stampedes; this second fence keeps
|
|
35
|
+
* startup single-flight if that detached child's launcher dies and its lock is reclaimed.
|
|
36
|
+
*/
|
|
37
|
+
export declare function withBrokerStartupLock<T>(agentDir: string, operation: (deadline: number) => Promise<T>): Promise<T>;
|
|
15
38
|
/**
|
|
16
39
|
* Tail of the detached broker's stderr folded into a discovery failure.
|
|
17
40
|
*
|
|
@@ -62,6 +85,12 @@ interface ReapTiming {
|
|
|
62
85
|
killVerifyMs: number;
|
|
63
86
|
}
|
|
64
87
|
type BrokerOwnerIdentity = Pick<BrokerDiscovery, "ownerId" | "pid" | "incarnation">;
|
|
88
|
+
/** Start client teardown, but never await it past the retirement operation's absolute deadline. */
|
|
89
|
+
export declare function closeBrokerClientBeforeDeadline(client: {
|
|
90
|
+
close(): Promise<void>;
|
|
91
|
+
}, deadline: number): Promise<void>;
|
|
92
|
+
/** Reconcile an observed broker generation before entering a startup critical section. */
|
|
93
|
+
export declare function reconcileBrokerGenerationForStartup(settings: EnsureBrokerSettings, deadline?: number): Promise<BrokerDiscovery | undefined>;
|
|
65
94
|
/** Starts the detached broker entrypoint when discovery has no live owner. */
|
|
66
95
|
export declare function ensureBroker(settings: EnsureBrokerSettings): Promise<BrokerDiscovery>;
|
|
67
96
|
/** Starts one fresh fixture broker and returns its sole exact-child close lease. */
|
|
@@ -73,6 +102,9 @@ export declare function startFixtureBrokerWithLeaseForTest(settings: EnsureBroke
|
|
|
73
102
|
*/
|
|
74
103
|
export declare function startFixtureBrokerCommandWithLeaseForTest(command: FixtureBrokerCommand): StartedFixtureBrokerCommand;
|
|
75
104
|
/** Test hook: returns a stop handle for the detached broker this process spawned. */
|
|
105
|
+
export declare const acquireSpawnLockForTest: typeof acquireSpawnLock;
|
|
106
|
+
/** Test hook: proves discovery reads honor their enclosing absolute deadline. */
|
|
107
|
+
export declare const readBrokerDiscoveryBeforeDeadlineForTest: typeof readBrokerDiscoveryBeforeDeadline;
|
|
76
108
|
export declare function brokerOwnerForTest(agentDir: string): BrokerOwner | undefined;
|
|
77
109
|
/** Test hook: verifies the complete broker owner identity used during stale retirement. */
|
|
78
110
|
export declare function brokerOwnerIdentityMatchesForTest(left: BrokerOwnerIdentity | null, right: BrokerOwnerIdentity): boolean;
|
|
@@ -173,14 +173,20 @@ export declare function observeProcessForTest(pid: number, expectedIncarnation:
|
|
|
173
173
|
* deliberately left untouched.
|
|
174
174
|
*/
|
|
175
175
|
export declare function reapDeadLifecycleMarkers(root: string, limit?: number): Promise<number>;
|
|
176
|
+
export declare function writeEffectMarker(root: string, id: string, marker: EffectMarker): Promise<void>;
|
|
176
177
|
/** The child writes this only after its endpoint and semantic ready event are both live. */
|
|
177
178
|
export declare function writeSessionLifecycleReady(root: string, id: string, effectMarker: string): Promise<void>;
|
|
178
179
|
export interface LifecycleTranscriptEvidence {
|
|
179
180
|
digest: string;
|
|
180
181
|
identity: SessionLifecycleTranscriptIdentity;
|
|
181
182
|
}
|
|
183
|
+
type LifecycleFailureArtifact = EffectMarker & SdkStartupFailure & {
|
|
184
|
+
rollback: SdkStartupRollbackResult;
|
|
185
|
+
transcript?: LifecycleTranscriptEvidence;
|
|
186
|
+
};
|
|
182
187
|
/** Writes bounded startup diagnostics. The child stamps its own pid; the broker may stamp a proven child identity. */
|
|
183
188
|
export declare function writeSessionLifecycleFailure(root: string, id: string, effectMarker: string, failure: SdkStartupFailure, rollback: SdkStartupRollbackResult, transcript?: LifecycleTranscriptEvidence, ownerIncarnation?: string, ownerPid?: number): Promise<void>;
|
|
189
|
+
export declare function readSessionLifecycleFailure(root: string, id: string, expected: EffectMarker): Promise<LifecycleFailureArtifact | undefined>;
|
|
184
190
|
export declare function readSessionLifecycleFailureForTest(root: string, id: string, expected: {
|
|
185
191
|
pid: number;
|
|
186
192
|
effectMarker: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface BrokerStartupFailureMarker {
|
|
2
|
-
version:
|
|
2
|
+
version: 2;
|
|
3
3
|
reason: string;
|
|
4
4
|
exitCode: number | null;
|
|
5
5
|
signal: string | null;
|
|
@@ -13,6 +13,8 @@ export interface BrokerStartupFailureMarker {
|
|
|
13
13
|
* failure.
|
|
14
14
|
*/
|
|
15
15
|
pid: number;
|
|
16
|
+
/** Kernel-derived identity for the exact process incarnation that wrote the marker. */
|
|
17
|
+
incarnation: string;
|
|
16
18
|
}
|
|
17
19
|
export declare function brokerStartupFailurePath(agentDir: string): string;
|
|
18
20
|
/**
|
|
@@ -26,6 +28,7 @@ export declare function writeBrokerStartupFailureMarker(agentDir: string, failur
|
|
|
26
28
|
exitCode: number | null;
|
|
27
29
|
signal: string | null;
|
|
28
30
|
pid: number;
|
|
31
|
+
incarnation?: string;
|
|
29
32
|
}): Promise<void>;
|
|
30
33
|
/** Reads a bounded startup-failure marker; `undefined` when absent or malformed. */
|
|
31
34
|
export declare function readBrokerStartupFailureMarker(agentDir: string): Promise<BrokerStartupFailureMarker | undefined>;
|
|
@@ -105,6 +105,8 @@ export type ChatDaemonAction = "stop" | "reload";
|
|
|
105
105
|
* Discord generation 72 / Slack generation 75 serialize same-generation
|
|
106
106
|
* successor attachment admission behind predecessor provider retirement, so a
|
|
107
107
|
* pre-upgrade owner cannot retain the queue race fixed by #5120.
|
|
108
|
+
* Slack generation 80 persists and fences the inbound SDK dispatch boundary so
|
|
109
|
+
* crashes, recovery, and attachment retirement cannot replay ambiguous work.
|
|
108
110
|
*/
|
|
109
111
|
export declare const CHAT_DAEMON_GENERATIONS: Readonly<Record<ChatDaemonKind, number>>;
|
|
110
112
|
export declare function chatDaemonGeneration(kind: ChatDaemonKind): number;
|
|
@@ -36,6 +36,18 @@ export interface ChatDaemonRuntimeDeps {
|
|
|
36
36
|
createSlackProvider?: (config: NonNullable<ChatDaemonRuntimeConfig["notifications"]["slack"]>) => SlackProviderClient;
|
|
37
37
|
routerDeps?: SessionRouterDeps;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Chat notifications in lean mode are an answer surface, not a mirror of the
|
|
41
|
+
* session protocol. Lifecycle, identity, and activity frames remain available
|
|
42
|
+
* to verbose consumers, while finalized answers and action-needed events are
|
|
43
|
+
* delivered in lean mode.
|
|
44
|
+
*/
|
|
45
|
+
export declare function shouldPublishChatFrame(frame: Record<string, unknown>, verbosity: "lean" | "verbose" | undefined): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* A final answer's message ref identifies its one rendered message even when
|
|
48
|
+
* the SDK transport delivers an unpositioned duplicate frame.
|
|
49
|
+
*/
|
|
50
|
+
export declare function publicationIdForFinalChatAnswer(sessionId: string, frame: Record<string, unknown>): string | undefined;
|
|
39
51
|
/**
|
|
40
52
|
* Worker-owned session discovery and event fanout. It connects only through the
|
|
41
53
|
* public SDK transport and retains SDK credentials solely in live client objects.
|
|
@@ -2,7 +2,7 @@ import { type ConversationRecord, type ConversationStoreFs } from "./conversatio
|
|
|
2
2
|
export declare const CHAT_EFFECT_JOURNAL_VERSION = 1;
|
|
3
3
|
export declare const MAX_TERMINAL_CHAT_EFFECTS = 128;
|
|
4
4
|
export declare function chatEffectJournalPath(agentDir: string, transport: "discord" | "slack"): string;
|
|
5
|
-
export type ChatEffectState = "pending" | "leased" | "accepted" | "uncertain" | "terminal";
|
|
5
|
+
export type ChatEffectState = "pending" | "leased" | "dispatching" | "accepted" | "uncertain" | "terminal";
|
|
6
6
|
/** Provider receipts are identifiers/status only. Never put request or response bodies here. */
|
|
7
7
|
export interface ChatEffectReceipt {
|
|
8
8
|
provider?: string;
|
|
@@ -77,9 +77,24 @@ export declare class ChatEffectJournal {
|
|
|
77
77
|
enqueueAndClaim<TPayload>(input: EnqueueChatEffect<TPayload>, owner: string, leaseMs: number): Promise<ChatEffect<TPayload> | undefined>;
|
|
78
78
|
claim<TPayload = unknown>(id: string, owner: string, leaseMs: number): Promise<ChatEffect<TPayload> | undefined>;
|
|
79
79
|
renew<TPayload = unknown>(id: string, lease: ChatEffectLease, leaseMs: number): Promise<ChatEffect<TPayload> | undefined>;
|
|
80
|
+
markDispatching<TPayload = unknown>(id: string, lease: ChatEffectLease): Promise<ChatEffect<TPayload> | undefined>;
|
|
81
|
+
ownsDispatching(id: string, lease: ChatEffectLease): Promise<boolean>;
|
|
82
|
+
/** Hold the durable dispatching lease until the synchronous SDK prewire boundary. */
|
|
83
|
+
dispatchWithLeaseFence<R>(id: string, lease: ChatEffectLease, dispatch: () => Promise<R>, dispatched: Promise<void>): Promise<{
|
|
84
|
+
value: R;
|
|
85
|
+
} | undefined>;
|
|
86
|
+
recoverDispatchingAsUncertain<TPayload = unknown>(id: string, options?: {
|
|
87
|
+
onlyIfExpired?: boolean;
|
|
88
|
+
}): Promise<ChatEffect<TPayload> | undefined>;
|
|
80
89
|
/** Persists provider progress without releasing the owner/epoch fence. */
|
|
81
90
|
recordReceipt<TPayload = unknown>(id: string, lease: ChatEffectLease, receipt: ChatEffectReceipt): Promise<ChatEffect<TPayload> | undefined>;
|
|
82
|
-
record<TPayload = unknown>(id: string, lease: ChatEffectLease, state:
|
|
91
|
+
record<TPayload = unknown>(id: string, lease: ChatEffectLease, state: "accepted" | "uncertain" | "terminal", receipt?: ChatEffectReceipt): Promise<ChatEffect<TPayload> | undefined>;
|
|
83
92
|
/** Irreversibly rejects an effect whose mapping never accepted its authority. */
|
|
84
93
|
terminalize(id: string, receipt: ChatEffectReceipt, lease?: ChatEffectLease): Promise<ChatEffect | undefined>;
|
|
94
|
+
/**
|
|
95
|
+
* Terminalize only a decided effect. The uncertainty check and state change
|
|
96
|
+
* share one store transaction so a concurrent sender cannot publish an
|
|
97
|
+
* ambiguity tombstone between a caller's read and stale cleanup.
|
|
98
|
+
*/
|
|
99
|
+
terminalizeDecided(id: string, receipt: ChatEffectReceipt, lease?: ChatEffectLease): Promise<ChatEffect | undefined>;
|
|
85
100
|
}
|
|
@@ -88,4 +88,15 @@ export declare class ConversationStore<T extends ConversationRecord> {
|
|
|
88
88
|
* other writer uses.
|
|
89
89
|
*/
|
|
90
90
|
transactWithSnapshot(key: string, update: (current: T | undefined, conversations: Readonly<Record<string, T>>) => T | undefined | Promise<T | undefined>): Promise<T | undefined>;
|
|
91
|
+
/**
|
|
92
|
+
* Hold the cross-process mapping lock until a prepared dispatch either reaches
|
|
93
|
+
* its synchronous wire boundary or fails before sending. The result may remain
|
|
94
|
+
* pending after the lock is released while the remote response is awaited.
|
|
95
|
+
*/
|
|
96
|
+
dispatchWithSnapshotFence<R>(key: string, prepare: (current: T | undefined, conversations: Readonly<Record<string, T>>) => {
|
|
97
|
+
result: Promise<R>;
|
|
98
|
+
dispatched: Promise<void>;
|
|
99
|
+
} | undefined): Promise<{
|
|
100
|
+
value: R;
|
|
101
|
+
} | undefined>;
|
|
91
102
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { SessionCloseTarget, SessionCreateTarget, SessionLifecycleResponse, SessionResumeTarget } from "./index";
|
|
2
2
|
export type LifecycleCommandVerb = "session_create" | "session_close" | "session_resume";
|
|
3
|
+
export interface LifecycleCommandContext {
|
|
4
|
+
chatType?: string;
|
|
5
|
+
botUsername?: string;
|
|
6
|
+
/** Session durably associated with the Telegram topic containing the command. */
|
|
7
|
+
threadSessionId?: string;
|
|
8
|
+
}
|
|
3
9
|
/** A parsed, validated lifecycle command (transport identity added by caller). */
|
|
4
10
|
export type ParsedLifecycleCommand = {
|
|
5
11
|
kind: "create";
|
|
@@ -27,10 +33,7 @@ export type ParsedLifecycleCommand = {
|
|
|
27
33
|
/** True when the text begins with any /session_* token, regardless of addressability. */
|
|
28
34
|
export declare function isLifecycleCommandLikeText(text: string | undefined): boolean;
|
|
29
35
|
/** True when the text begins an addressable /session_* command (cheap pre-gate). */
|
|
30
|
-
export declare function isLifecycleCommandText(text: string | undefined, ctx?:
|
|
31
|
-
chatType?: string;
|
|
32
|
-
botUsername?: string;
|
|
33
|
-
}): boolean;
|
|
36
|
+
export declare function isLifecycleCommandText(text: string | undefined, ctx?: LifecycleCommandContext): boolean;
|
|
34
37
|
/**
|
|
35
38
|
* Parse a paired-chat message into a lifecycle command. Returns `none` for
|
|
36
39
|
* non-lifecycle text, `usage`/`reject` for malformed input (no side effect), or
|
|
@@ -39,10 +42,7 @@ export declare function isLifecycleCommandText(text: string | undefined, ctx?: {
|
|
|
39
42
|
* The caller MUST have already enforced paired-chat authorization; this function
|
|
40
43
|
* performs grammar + target validation only.
|
|
41
44
|
*/
|
|
42
|
-
export declare function parseLifecycleCommand(text: string | undefined, ctx?:
|
|
43
|
-
chatType?: string;
|
|
44
|
-
botUsername?: string;
|
|
45
|
-
}): ParsedLifecycleCommand;
|
|
45
|
+
export declare function parseLifecycleCommand(text: string | undefined, ctx?: LifecycleCommandContext): ParsedLifecycleCommand;
|
|
46
46
|
/** The canonical usage text (exported for the daemon's help replies). */
|
|
47
47
|
export declare function lifecycleUsage(): string;
|
|
48
48
|
/**
|
|
@@ -30,7 +30,7 @@ export interface SlackNotificationDaemonOptions {
|
|
|
30
30
|
resolveAttachment: (sessionId: string) => Promise<SessionAttachment | null>;
|
|
31
31
|
/** Exact Router proof for adopting an existing root. */
|
|
32
32
|
resolveBindingAuthority?: (sessionId: string) => Promise<SlackBindingAuthority | undefined>;
|
|
33
|
-
onCommand?: (sessionId: string, content: string, attachment: SessionAttachment, idempotencyKey: string) => Promise<boolean>;
|
|
33
|
+
onCommand?: (sessionId: string, content: string, attachment: SessionAttachment, idempotencyKey: string, beforeDispatch: () => void, dispatchFence: <T>(dispatch: () => Promise<T>) => Promise<T>) => Promise<boolean>;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Slack Socket Mode notification daemon. Accepted inbound SDK effects are
|
|
@@ -59,6 +59,12 @@ export declare class SlackLiveProvider implements SlackProviderClient, SlackDiag
|
|
|
59
59
|
clientMsgId: string;
|
|
60
60
|
signal?: AbortSignal;
|
|
61
61
|
}): Promise<SlackPostedMessage>;
|
|
62
|
+
addReaction(input: {
|
|
63
|
+
channel: string;
|
|
64
|
+
timestamp: string;
|
|
65
|
+
name: string;
|
|
66
|
+
signal?: AbortSignal;
|
|
67
|
+
}): Promise<void>;
|
|
62
68
|
findMessageByClientMsgId(input: {
|
|
63
69
|
channel: string;
|
|
64
70
|
clientMsgId: string;
|
|
@@ -52,6 +52,12 @@ export interface SlackProviderClient {
|
|
|
52
52
|
threadTs?: string;
|
|
53
53
|
signal?: AbortSignal;
|
|
54
54
|
}): Promise<SlackMessageSearchResult | null>;
|
|
55
|
+
addReaction?(input: {
|
|
56
|
+
channel: string;
|
|
57
|
+
timestamp: string;
|
|
58
|
+
name: string;
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
}): Promise<void>;
|
|
55
61
|
/**
|
|
56
62
|
* Prove that an operator-supplied timestamp addresses a real message in the
|
|
57
63
|
* requested channel. Adoption of an existing root is refused when a client
|
|
@@ -87,6 +93,12 @@ export declare class SlackProvider {
|
|
|
87
93
|
threadTs?: string;
|
|
88
94
|
signal?: AbortSignal;
|
|
89
95
|
}): Promise<SlackMessageSearchResult | null>;
|
|
96
|
+
addReaction(input: {
|
|
97
|
+
channel: string;
|
|
98
|
+
timestamp: string;
|
|
99
|
+
name: string;
|
|
100
|
+
signal?: AbortSignal;
|
|
101
|
+
}): Promise<void>;
|
|
90
102
|
/** Fail-closed root verification: a client without this capability can never confirm a root. */
|
|
91
103
|
findMessageByTimestamp(input: {
|
|
92
104
|
channel: string;
|
|
@@ -206,6 +206,14 @@ export declare class TopicRegistry {
|
|
|
206
206
|
private rebuildInboundRoutes;
|
|
207
207
|
/** Resolve the owning session for a topic id (for fail-closed inbound routing). */
|
|
208
208
|
sessionForTopic(topicId: string): string | undefined;
|
|
209
|
+
/**
|
|
210
|
+
* Resolve a durable topic association for explicit lifecycle controls.
|
|
211
|
+
*
|
|
212
|
+
* Unlike inbound message routing, this may return an inactive session so a
|
|
213
|
+
* user can resume it from its old topic. Ambiguous, malformed, cross-chat,
|
|
214
|
+
* and quarantined records fail closed.
|
|
215
|
+
*/
|
|
216
|
+
sessionForLifecycleTopic(topicId: string, chatId: string): string | undefined;
|
|
209
217
|
/** All session ids with a persisted topic record. */
|
|
210
218
|
sessionIds(): string[];
|
|
211
219
|
/** The existing topic record for a session, if any. */
|
|
@@ -12,6 +12,10 @@ export declare class SdkClientError extends Error {
|
|
|
12
12
|
readonly reconnect?: SdkReconnectExhaustedDetails;
|
|
13
13
|
constructor(code: SdkErrorCode, message: string, details?: unknown, reconnect?: SdkReconnectExhaustedDetails);
|
|
14
14
|
}
|
|
15
|
+
/** A prepared transport operation failed before any wire handoff. */
|
|
16
|
+
export declare class SdkPreparedDispatchError extends SdkClientError {
|
|
17
|
+
constructor(error: SdkClientError);
|
|
18
|
+
}
|
|
15
19
|
export type SdkReconnectTerminationReason = "attempts_exhausted" | "deadline" | "cancelled";
|
|
16
20
|
/**
|
|
17
21
|
* Reconnect-cycle termination diagnostics. `attemptsConsumed` counts retry slots,
|
|
@@ -66,6 +70,8 @@ export interface SdkRequestOptions {
|
|
|
66
70
|
* alter that settlement.
|
|
67
71
|
*/
|
|
68
72
|
onDispatch?: SdkDispatchHandler;
|
|
73
|
+
/** Internal prepared-dispatch mode: fail pre-send instead of reconnecting. */
|
|
74
|
+
connectedOnly?: boolean;
|
|
69
75
|
}
|
|
70
76
|
export type SdkFrame = Record<string, unknown>;
|
|
71
77
|
/**
|
|
@@ -117,6 +117,8 @@ export declare class SessionSdkHost {
|
|
|
117
117
|
* publishing a second readiness signal.
|
|
118
118
|
*/
|
|
119
119
|
activate(expectedGeneration?: number): Promise<SessionActivationOutcome>;
|
|
120
|
-
stop(
|
|
120
|
+
stop(options?: {
|
|
121
|
+
allowLockContention?: boolean;
|
|
122
|
+
}): Promise<"stopped" | "already">;
|
|
121
123
|
registerWithBroker(writer: BrokerIndexWriter): Promise<void>;
|
|
122
124
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Settings } from "../../config/settings";
|
|
2
2
|
import type { ExtensionAPI, ExtensionContext } from "../../extensibility/extensions";
|
|
3
|
+
import type { AgentEndEvent } from "../../extensibility/shared-events";
|
|
3
4
|
import { type MasterRoleAttestationV2, SessionIndex, type SessionLocatorV2 } from "../broker/session-index";
|
|
4
5
|
import type { SdkPromptTerminalOutcome } from "../prompt-status";
|
|
5
6
|
import { type ReceiptState } from "../receipt-state";
|
|
@@ -24,6 +25,16 @@ export declare function verifyMasterCapabilityFrame(input: {
|
|
|
24
25
|
nonce: string;
|
|
25
26
|
attestationEpoch: string;
|
|
26
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Normalize an agent-loop stop reason into the published terminal outcome.
|
|
30
|
+
*
|
|
31
|
+
* Only reached for a boundary that actually terminalizes an owned invocation,
|
|
32
|
+
* so every result is a `stopped` disposition: a failed run publishes its own
|
|
33
|
+
* correlated `agent_failed` frame with the sanitized cause instead.
|
|
34
|
+
*/
|
|
35
|
+
export declare function terminalStoppedOutcome(stopReason: AgentEndEvent["stopReason"], maintenanceOutcome: string | undefined): Extract<SdkPromptTerminalOutcome, {
|
|
36
|
+
kind: "stopped";
|
|
37
|
+
}>;
|
|
27
38
|
/** Transport-neutral endpoint contract consumed by the SDK session runtime. */
|
|
28
39
|
export interface SessionSdkTransport {
|
|
29
40
|
readonly sessionId: string;
|
|
@@ -167,6 +178,18 @@ export declare class SessionSdkSessionRuntime {
|
|
|
167
178
|
get generation(): number;
|
|
168
179
|
getProviderDefinitions(capability: string): unknown | undefined;
|
|
169
180
|
emitEvent(frame: SdkFrame): void;
|
|
181
|
+
/**
|
|
182
|
+
* Deliver a frame to specific connections without recording it.
|
|
183
|
+
*
|
|
184
|
+
* Deliberately not `emitEvent`: that assigns a ring position and broadcasts to
|
|
185
|
+
* every authenticated socket. Streamed turn content is high-frequency and
|
|
186
|
+
* unbounded in size, so a count-bounded ring would evict the lifecycle events
|
|
187
|
+
* clients depend on -- including the `agent_end` that settles their prompt --
|
|
188
|
+
* and broadcasting would hand every subscriber a stream only the submitter
|
|
189
|
+
* asked for. Delivery failure is ignored: a disconnected consumer must never
|
|
190
|
+
* disturb the turn producing the content.
|
|
191
|
+
*/
|
|
192
|
+
sendFrameTo(connectionId: string, frame: SdkFrame): void;
|
|
170
193
|
publish(frame: SdkFrame): void;
|
|
171
194
|
startHost(): Promise<"started" | "already">;
|
|
172
195
|
startTransport(): Promise<{
|
|
@@ -175,7 +198,9 @@ export declare class SessionSdkSessionRuntime {
|
|
|
175
198
|
start(): Promise<{
|
|
176
199
|
url: string;
|
|
177
200
|
}>;
|
|
178
|
-
stop(
|
|
201
|
+
stop(options?: {
|
|
202
|
+
allowLockContention?: boolean;
|
|
203
|
+
}): Promise<void>;
|
|
179
204
|
registerWithBroker(writer: BrokerIndexWriter): Promise<void>;
|
|
180
205
|
}
|
|
181
206
|
/** Narrow extension-facing factory for the SDK-only session path. */
|
|
@@ -137,6 +137,7 @@ export interface SessionLifecycleSessionResult {
|
|
|
137
137
|
readonly sessionId: string;
|
|
138
138
|
readonly cwd?: string;
|
|
139
139
|
readonly endpointGeneration?: number;
|
|
140
|
+
readonly endpointIncarnation?: string;
|
|
140
141
|
readonly reused?: boolean;
|
|
141
142
|
readonly note?: string;
|
|
142
143
|
}
|
|
@@ -2,6 +2,7 @@ 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
4
|
export interface SessionEndpointIdentity {
|
|
5
|
+
readonly dev: bigint;
|
|
5
6
|
readonly mtimeMs: number;
|
|
6
7
|
readonly mtimeNs: bigint;
|
|
7
8
|
readonly ctimeNs: bigint;
|
|
@@ -32,7 +33,10 @@ export interface SessionAttachment {
|
|
|
32
33
|
readonly connectionId?: string;
|
|
33
34
|
readonly generation: number;
|
|
34
35
|
isCurrent(): boolean;
|
|
35
|
-
send(frame: Record<string, unknown
|
|
36
|
+
send(frame: Record<string, unknown>, options?: {
|
|
37
|
+
beforeDispatch?: () => void;
|
|
38
|
+
dispatchFence?: (dispatch: () => Promise<void>) => Promise<void>;
|
|
39
|
+
}): unknown;
|
|
36
40
|
/**
|
|
37
41
|
* Idempotent provider-lease heartbeat send that skips the pre-send authority
|
|
38
42
|
* reconcile (#4689).
|
|
@@ -106,6 +110,7 @@ export interface SessionRouterClient {
|
|
|
106
110
|
connect?(): Promise<void>;
|
|
107
111
|
request(frame: Record<string, unknown>, options?: {
|
|
108
112
|
timeoutMs?: number;
|
|
113
|
+
connectedOnly?: boolean;
|
|
109
114
|
/** Synchronous pre-send observer; a throw aborts the dispatch before the wire. */
|
|
110
115
|
beforeDispatch?: (context: SdkDispatchContext) => void;
|
|
111
116
|
/** Synchronous post-send boundary observer for transport-close-aware consumers. */
|
|
@@ -208,6 +213,7 @@ export declare class SessionRouter {
|
|
|
208
213
|
timeoutMs?: number;
|
|
209
214
|
beforeDispatch?: (context: SdkDispatchContext) => void;
|
|
210
215
|
onDispatch?: SdkDispatchHandler;
|
|
216
|
+
dispatchFence?: (dispatch: () => Promise<Record<string, unknown>>) => Promise<Record<string, unknown>>;
|
|
211
217
|
}): Promise<Record<string, unknown>>;
|
|
212
218
|
/** Resolves the exact provider-neutral binding authority for operator adoption. */
|
|
213
219
|
bindingAuthority(sessionId: string): Promise<{
|
|
@@ -224,5 +230,7 @@ export declare class SessionRouter {
|
|
|
224
230
|
/** Activates a prepared session through one Router-owned, one-shot SDK client. */
|
|
225
231
|
activatePreparedSession(sessionId: string): Promise<ActivatedPreparedSession>;
|
|
226
232
|
/** Lists saved sessions through Router-owned Broker discovery without exposing credentials or mutation authority. */
|
|
227
|
-
listBrokerSessions(input: Record<string, unknown>, idempotencyKey: string
|
|
233
|
+
listBrokerSessions(input: Record<string, unknown>, idempotencyKey: string, options?: {
|
|
234
|
+
beforeDispatch?: (context: SdkDispatchContext) => void;
|
|
235
|
+
}, dispatchFence?: (dispatch: () => Promise<Record<string, unknown>>) => Promise<Record<string, unknown>>): Promise<Record<string, unknown>>;
|
|
228
236
|
}
|