@gajae-code/coding-agent 0.22.2 → 0.22.3
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 +115 -0
- package/dist/types/cli/append-system-prompt.d.ts +7 -0
- package/dist/types/cli/doctor/session-owners.d.ts +8 -2
- package/dist/types/cli/public-command-errors.d.ts +1 -0
- package/dist/types/cli/session-picker.d.ts +16 -3
- package/dist/types/cli/update-cli.d.ts +0 -2
- package/dist/types/cli-ordinary.d.ts +1 -1
- package/dist/types/commands/sdk.d.ts +2 -0
- package/dist/types/config/machine-identity.d.ts +11 -0
- package/dist/types/config/model-registry.d.ts +9 -0
- package/dist/types/config/settings-schema.d.ts +84 -4
- package/dist/types/lsp/client.d.ts +9 -0
- package/dist/types/lsp/types.d.ts +2 -0
- package/dist/types/main.d.ts +40 -3
- package/dist/types/modes/components/session-held-warning.d.ts +27 -0
- package/dist/types/modes/components/session-selector.d.ts +32 -1
- package/dist/types/modes/controllers/selector-controller.d.ts +8 -1
- package/dist/types/modes/interactive-mode.d.ts +12 -1
- package/dist/types/sdk/broker/broker.d.ts +3 -0
- package/dist/types/sdk/broker/lifecycle-ledger.d.ts +5 -2
- package/dist/types/sdk/broker/lifecycle.d.ts +2 -0
- package/dist/types/sdk/broker/session-index.d.ts +11 -0
- package/dist/types/sdk/bus/index.d.ts +1 -1
- package/dist/types/sdk/host/control/dispatch.d.ts +3 -0
- package/dist/types/sdk/host/registration-test-hold.d.ts +7 -0
- package/dist/types/sdk/index.d.ts +1 -0
- package/dist/types/sdk/lifecycle/service.d.ts +3 -0
- package/dist/types/sdk/session-api-key.d.ts +11 -4
- package/dist/types/sdk/session-readonly/format.d.ts +7 -0
- package/dist/types/sdk/session.d.ts +11 -0
- package/dist/types/sdk/startup-capability.d.ts +11 -2
- package/dist/types/session/agent-session.d.ts +1 -2
- package/dist/types/session/internal/managed-session-storage.d.ts +1 -1
- package/dist/types/session/internal/session-claim-set.d.ts +168 -13
- package/dist/types/session/session-handover.d.ts +62 -0
- package/dist/types/session/session-manager.d.ts +75 -15
- package/dist/types/session/session-owner-holder.d.ts +77 -0
- package/dist/types/session/session-ownership-mode.d.ts +45 -2
- package/dist/types/session/session-ownership.d.ts +25 -29
- package/dist/types/session/yield-queue.d.ts +13 -0
- package/dist/types/tools/bash.d.ts +7 -0
- package/dist/types/tools/browser/deferred-profile-cleanup.d.ts +3 -0
- package/dist/types/tools/browser/launch.d.ts +24 -1
- package/dist/types/tools/index.d.ts +6 -0
- package/dist/types/tools/output-meta.d.ts +17 -11
- package/dist/types/tools/tool-result.d.ts +1 -0
- package/package.json +9 -7
- package/scripts/compile-args.ts +6 -3
- package/scripts/run-acp-conformance.ts +36 -10
- package/scripts/verify-gjc-sdk-canonicalization.ts +2 -0
- package/src/cli/append-system-prompt.ts +34 -0
- package/src/cli/auth-broker-cli.ts +5 -1
- package/src/cli/doctor/session-owners.ts +8 -2
- package/src/cli/public-command-errors.ts +4 -0
- package/src/cli/session-picker.ts +57 -7
- package/src/cli/update-cli.ts +0 -22
- package/src/cli-ordinary.ts +2 -17
- package/src/commands/sdk.ts +37 -15
- package/src/config/machine-identity.ts +31 -2
- package/src/config/model-registry.ts +40 -6
- package/src/config/settings-schema.ts +50 -6
- package/src/config/settings.ts +65 -3
- package/src/gjc-runtime/launch-tmux.ts +4 -1
- package/src/internal-urls/docs-index.generated.ts +12 -12
- package/src/lsp/client.ts +60 -6
- package/src/lsp/index.ts +2 -6
- package/src/lsp/types.ts +2 -0
- package/src/main.ts +364 -93
- package/src/modes/DESIGN.md +36 -0
- package/src/modes/acp/acp-agent.ts +215 -31
- package/src/modes/components/session-held-warning.ts +62 -0
- package/src/modes/components/session-selector.ts +234 -11
- package/src/modes/controllers/goal-mode-controller.ts +14 -2
- package/src/modes/controllers/selector-controller.ts +192 -3
- package/src/modes/interactive-mode.ts +40 -2
- package/src/prompts/tools/bash.md +1 -1
- package/src/prompts/tools/monitor.md +1 -1
- package/src/runtime-mcp/manager.ts +5 -1
- package/src/sdk/acp/adapter.ts +2 -0
- package/src/sdk/broker/broker.ts +29 -2
- package/src/sdk/broker/lifecycle-ledger.ts +9 -7
- package/src/sdk/broker/lifecycle.ts +280 -39
- package/src/sdk/broker/session-index.ts +24 -0
- package/src/sdk/bus/index.ts +1 -0
- package/src/sdk/bus/lifecycle-commands.ts +4 -0
- package/src/sdk/cli/session-cli.ts +8 -0
- package/src/sdk/host/control/dispatch.ts +18 -0
- package/src/sdk/host/host.ts +5 -0
- package/src/sdk/host/registration-test-hold.ts +51 -0
- package/src/sdk/host/session-runtime.test.ts +42 -0
- package/src/sdk/index.ts +10 -0
- package/src/sdk/lifecycle/service.ts +33 -10
- package/src/sdk/prompt-failure.ts +4 -0
- package/src/sdk/protocol/operation-registry.ts +7 -1
- package/src/sdk/session-api-key.ts +31 -16
- package/src/sdk/session-readonly/format.ts +10 -0
- package/src/sdk/session-readonly/scope.ts +2 -1
- package/src/sdk/session.ts +60 -7
- package/src/sdk/startup-capability.ts +27 -2
- package/src/session/agent-session.ts +411 -58
- package/src/session/internal/managed-session-storage.ts +16 -2
- package/src/session/internal/session-claim-set.ts +527 -49
- package/src/session/session-handover.ts +283 -0
- package/src/session/session-manager.ts +907 -148
- package/src/session/session-owner-holder.ts +177 -0
- package/src/session/session-ownership-mode.ts +84 -12
- package/src/session/session-ownership.ts +115 -89
- package/src/session/yield-queue.ts +43 -0
- package/src/session-import/provider-service.ts +8 -0
- package/src/setup/provider-onboarding.ts +5 -5
- package/src/task/executor.ts +2 -0
- package/src/tools/bash.ts +10 -0
- package/src/tools/browser/deferred-profile-cleanup.ts +20 -0
- package/src/tools/browser/launch.ts +133 -14
- package/src/tools/browser/registry.ts +72 -19
- package/src/tools/index.ts +10 -1
- package/src/tools/monitor.ts +267 -29
- package/src/tools/output-meta.ts +61 -28
- package/src/tools/tool-catalog.generated.ts +2 -2
- package/src/tools/tool-result.ts +5 -0
- package/dist/types/cli/macos-community-app.d.ts +0 -41
- package/src/cli/macos-community-app.ts +0 -1449
|
@@ -85,7 +85,14 @@ export declare class SelectorController {
|
|
|
85
85
|
showUserMessageSelector(onCommitted?: () => void): void;
|
|
86
86
|
showTreeSelector(): void;
|
|
87
87
|
showSessionSelector(): Promise<void>;
|
|
88
|
-
|
|
88
|
+
/**
|
|
89
|
+
* `cancelledStatus`: what Cancel on the held-session warning says (default `Resume cancelled`);
|
|
90
|
+
* `continueHere: false` offers Fork and Cancel only.
|
|
91
|
+
*/
|
|
92
|
+
handleResumeSession(sessionPath: string, options?: {
|
|
93
|
+
readonly cancelledStatus?: string;
|
|
94
|
+
readonly continueHere?: boolean;
|
|
95
|
+
}): Promise<void>;
|
|
89
96
|
handleSessionDeleteCommand(): Promise<void>;
|
|
90
97
|
showOAuthSelector(mode: "login" | "logout", providerId?: string, options?: OAuthSelectorOptions): Promise<void>;
|
|
91
98
|
showDebugSelector(): void;
|
|
@@ -12,6 +12,7 @@ import type { NotificationSessionReconcileResult, NotificationSessionStatus } fr
|
|
|
12
12
|
import { type AgentSession, type AgentSessionEvent, type AsyncJobSnapshotItem } from "../session/agent-session";
|
|
13
13
|
import type { HistoryStorage } from "../session/history-storage";
|
|
14
14
|
import type { SessionContext, SessionManager } from "../session/session-manager";
|
|
15
|
+
import { SessionHeldError, type SessionOwnershipError } from "../session/session-ownership";
|
|
15
16
|
import type { LspStartupServerInfo } from "../tools";
|
|
16
17
|
import type { EventBus } from "../utils/event-bus";
|
|
17
18
|
import type { AssistantMessageComponent } from "./components/assistant-message";
|
|
@@ -298,7 +299,17 @@ export declare class InteractiveMode implements InteractiveModeContext {
|
|
|
298
299
|
showUserMessageSelector(): void;
|
|
299
300
|
showTreeSelector(): void;
|
|
300
301
|
showSessionSelector(): void;
|
|
301
|
-
handleResumeSession(sessionPath: string
|
|
302
|
+
handleResumeSession(sessionPath: string, options?: {
|
|
303
|
+
readonly cancelledStatus?: string;
|
|
304
|
+
readonly continueHere?: boolean;
|
|
305
|
+
}): Promise<void>;
|
|
306
|
+
/**
|
|
307
|
+
* A turn enforce refused before it wrote anything (single-owner design §2.7, §3.1): another
|
|
308
|
+
* process now holds this session, or gjc could not check. The optimistic message goes and the draft
|
|
309
|
+
* comes back to the editor, after any text typed since. A held session then gets the held-session
|
|
310
|
+
* warning, through `/resume`'s flow for this session's own file, with Fork and Cancel only.
|
|
311
|
+
*/
|
|
312
|
+
handleRefusedSessionTurn(error: SessionHeldError | SessionOwnershipError, input: SubmittedUserInput): void;
|
|
302
313
|
handleSessionDeleteCommand(): Promise<void>;
|
|
303
314
|
showOAuthSelector(mode: "login" | "logout", providerId?: string, options?: import("./types").OAuthSelectorOptions): Promise<void>;
|
|
304
315
|
showHookConfirm(title: string, message: string): Promise<boolean>;
|
|
@@ -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 { SessionOwnerHolderSummary } from "../../session/session-ownership";
|
|
3
4
|
import type { TaskArtifactOwnerDeletionEvidence, TaskArtifactOwnerRetirementContinuation } from "../../session/task-artifact-owner-codec";
|
|
4
5
|
import { type SdkHostModelResolver } from "../host/model-pin";
|
|
5
6
|
import { type DirectoryMigrationPolicy } from "../session-directory";
|
|
@@ -197,6 +198,8 @@ export type BrokerResponse = {
|
|
|
197
198
|
code: BrokerErrorCode;
|
|
198
199
|
message: string;
|
|
199
200
|
details?: ModelProfileErrorDetails | SpawnSubstrateFailure;
|
|
201
|
+
/** `live_session` from `session.resume` or `session.delete`: the process that holds the session (single-owner). */
|
|
202
|
+
holder?: SessionOwnerHolderSummary;
|
|
200
203
|
endpoint?: "unavailable";
|
|
201
204
|
cleanup?: BrokerCleanupEvidence;
|
|
202
205
|
};
|
|
@@ -195,8 +195,11 @@ export declare class LifecycleLedger {
|
|
|
195
195
|
closeAuthorityBound?: boolean;
|
|
196
196
|
spawnAnchor?: true;
|
|
197
197
|
}, conflictsWithKeyHolder?: (holder: LifecycleLedgerEntry) => boolean): Promise<BeginResult>;
|
|
198
|
-
/**
|
|
199
|
-
|
|
198
|
+
/**
|
|
199
|
+
* A refusal that proves no effect keeps its key binding, not a terminal result: a runtime busy
|
|
200
|
+
* close, or a delete refused while its row is still `accepted` (a live or held session, `unavailable`).
|
|
201
|
+
*/
|
|
202
|
+
retryRefusal(identity: string): Promise<void>;
|
|
200
203
|
transition(identity: string, state: LifecycleState, fields?: Omit<Partial<LifecycleLedgerEntry>, "identity" | "requestHash" | "state" | "ts">): Promise<LifecycleLedgerEntry>;
|
|
201
204
|
assertSupportedStateVersions(): Promise<void>;
|
|
202
205
|
findCleanupPendingByDeleteTarget(target: {
|
|
@@ -161,6 +161,8 @@ export declare function lifecycleSessionHostBaseEnv(inherited: NodeJS.ProcessEnv
|
|
|
161
161
|
type CleanupEvidence = BrokerCleanupEvidence;
|
|
162
162
|
export declare function validateBrokerModelPresetSync(agentDir: string, requestedProfile: string): string | BrokerResponse;
|
|
163
163
|
export declare function validateBrokerModelPresetForTest(agentDir: string, requestedProfile: string): string | BrokerResponse;
|
|
164
|
+
/** Record a lifecycle request's arrival, so a resume's wait counts the time it spent queued. */
|
|
165
|
+
export declare function markLifecycleRequestReceived(broker: Broker, input: Input): void;
|
|
164
166
|
/** Test seam: the session-host command override as resolved from trusted env. */
|
|
165
167
|
export declare function sdkSessionCommandOverrideForTest(): {
|
|
166
168
|
file: string;
|
|
@@ -197,6 +197,17 @@ export declare const SESSION_HEARTBEAT_INTERVAL_MS = 60000;
|
|
|
197
197
|
export declare const DEAD_HOST_HEARTBEAT_SILENCE_MS: number;
|
|
198
198
|
export declare const DEFAULT_SESSION_RETENTION_MAX_AGE_MS: number;
|
|
199
199
|
export declare const DEFAULT_SESSION_RETENTION_MAX_ROWS = 25000;
|
|
200
|
+
/**
|
|
201
|
+
* Appends allowed for one direct-session registration, or its withdrawal, before giving up.
|
|
202
|
+
* `SessionIndex.append` takes the shared index lock independently per append, so a peer holding
|
|
203
|
+
* it is a transient failure.
|
|
204
|
+
*/
|
|
205
|
+
export declare const DIRECT_SESSION_REGISTRATION_ATTEMPTS = 3;
|
|
206
|
+
/**
|
|
207
|
+
* An index append that failed on lock contention, which a short retry heals. A refused lock
|
|
208
|
+
* release is an identity verdict, not contention, and is never retried.
|
|
209
|
+
*/
|
|
210
|
+
export declare function isTransientSessionIndexLockError(error: unknown): boolean;
|
|
200
211
|
/** Bound ordinary bootstrap waits; authorized doctor successors may use the full prepared window. */
|
|
201
212
|
export declare function sessionIndexStartupLockOptions(deadline: number, signal?: AbortSignal, policy?: "ordinary" | "authorized-successor"): FileLockOptions;
|
|
202
213
|
/** One elapsed budget for queueing, probing and every reacquisition in a pass. */
|
|
@@ -122,7 +122,7 @@ export interface SessionResumeResponseFrame {
|
|
|
122
122
|
sessionId: string;
|
|
123
123
|
mode: ResumeMode;
|
|
124
124
|
}
|
|
125
|
-
export type LifecycleErrorReason = "unauthorized" | "rate_limited" | "duplicate_conflict" | "invalid_target" | "ambiguous_target" | "spawn_failed" | "discovery_timeout" | "readiness_timeout" | "worktree_preparation_timeout" | "dependency_preparation_timeout" | "close_refused" | "not_found" | "terminal_uncertain" | "unsupported_platform";
|
|
125
|
+
export type LifecycleErrorReason = "unauthorized" | "rate_limited" | "duplicate_conflict" | "invalid_target" | "ambiguous_target" | "spawn_failed" | "discovery_timeout" | "readiness_timeout" | "worktree_preparation_timeout" | "dependency_preparation_timeout" | "close_refused" | "not_found" | "live_session" | "terminal_uncertain" | "unsupported_platform";
|
|
126
126
|
export interface ResumeCandidate {
|
|
127
127
|
sessionId: string;
|
|
128
128
|
path?: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SessionOwnerHolderSummary } from "../../../session/session-owner-holder";
|
|
1
2
|
import { type Operation } from "../../protocol/operation-registry";
|
|
2
3
|
import { type ControlSurface, type ControlValue } from "./operations";
|
|
3
4
|
export interface ControlRequest {
|
|
@@ -16,6 +17,8 @@ export interface ControlError {
|
|
|
16
17
|
message: string;
|
|
17
18
|
currentRevision?: string;
|
|
18
19
|
details?: ControlValue;
|
|
20
|
+
/** The process that holds the session, on a `live_session` refusal (as the broker reports it). */
|
|
21
|
+
holder?: SessionOwnerHolderSummary;
|
|
19
22
|
}
|
|
20
23
|
export interface ControlResponse {
|
|
21
24
|
id: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* While `<dir>/<sessionId>.hold` exists, defer this host's broker registration (at most 60 s).
|
|
3
|
+
* `SessionSdkHost.registerWithBroker` calls it, so it holds an interactive TUI and a broker-launched
|
|
4
|
+
* host alike: both register through that method. `undefined`, with nothing awaited, when the seam
|
|
5
|
+
* is not set, so registration keeps its ordering outside the tests that use it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function awaitHostRegistrationTestHold(sessionId: string): Promise<void> | undefined;
|
|
@@ -3,6 +3,7 @@ export * from "../modes/runtime-init";
|
|
|
3
3
|
export { PROJECT_PROGRESS_SNAPSHOT_SCHEMA, type ProgressSnapshotAttention, type ProgressSnapshotStory, type ProgressSnapshotTodo, type ProgressSnapshotWorkflow, type ProjectProgressSnapshot, } from "../progress/progress-contract";
|
|
4
4
|
export type { AgentSessionLifecycleState, AutoSessionTitleResult, QueuedInputAdmission, QueuedInputDelivery, QueuedInputExecution, QueuedInputQueuePolicy, QueuedInputRemovalReason, QueuedInputSubmission, QueuedInputTerminal, SendUserMessageOptions, SessionAgentModelRole, TrackedSendUserMessageOptions, } from "../session/agent-session";
|
|
5
5
|
export { getSessionMessageEntryId } from "../session/session-manager";
|
|
6
|
+
export { probeSessionOwners, SessionHeldError, type SessionOwnerBaseSurface, type SessionOwnerHolder, type SessionOwnerProbe, type SessionOwnerSurface, type SessionOwnerUnknownReason, } from "../session/session-ownership";
|
|
6
7
|
export { ACP_BUILTIN_SLASH_COMMANDS, executeAcpBuiltinSlashCommand } from "../slash-commands/acp-builtins";
|
|
7
8
|
export type { SlashCommandResult, SlashCommandRuntime } from "../slash-commands/types";
|
|
8
9
|
export * from "./activity-controls";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SessionOwnerHolderSummary } from "../../session/session-owner-holder";
|
|
1
2
|
import { type ScopeRequestV1, type SdkSearchResultV1 } from "../broker/session-scope";
|
|
2
3
|
import { type SdkRevisionInput, type SdkRevisionResult } from "../protocol/revision-contracts";
|
|
3
4
|
import type { SessionBindingAuthority } from "../session-authority";
|
|
@@ -264,6 +265,8 @@ export interface SessionLifecycleLookupFailure {
|
|
|
264
265
|
export interface SessionLifecycleError {
|
|
265
266
|
readonly code: string;
|
|
266
267
|
readonly message: string;
|
|
268
|
+
/** The process that holds the session, when a resume was refused under `enforce` (`live_session`). */
|
|
269
|
+
readonly holder?: SessionOwnerHolderSummary;
|
|
267
270
|
}
|
|
268
271
|
export type SessionCreateFailure = {
|
|
269
272
|
readonly ok: false;
|
|
@@ -8,16 +8,23 @@ export type SessionApiKeyModel = {
|
|
|
8
8
|
provider: string;
|
|
9
9
|
baseUrl?: string;
|
|
10
10
|
};
|
|
11
|
+
/** A resolved key plus the stored credential row that supplied it, when any. */
|
|
12
|
+
export type SessionApiKeyLookup = {
|
|
13
|
+
apiKey: string | undefined;
|
|
14
|
+
credentialRowId: number | undefined;
|
|
15
|
+
};
|
|
11
16
|
export type SessionApiKeyRegistry = {
|
|
12
|
-
|
|
17
|
+
getApiKeyWithCredentialRowId(model: SessionApiKeyModel, sessionId?: string, options?: {
|
|
13
18
|
signal?: AbortSignal;
|
|
14
|
-
}): Promise<
|
|
15
|
-
|
|
19
|
+
}): Promise<SessionApiKeyLookup>;
|
|
20
|
+
getApiKeyForProviderWithCredentialRowId(provider: string, sessionId?: string, baseUrl?: string, options?: {
|
|
16
21
|
signal?: AbortSignal;
|
|
17
|
-
}): Promise<
|
|
22
|
+
}): Promise<SessionApiKeyLookup>;
|
|
18
23
|
};
|
|
19
24
|
export type SessionApiKeyResolution = {
|
|
20
25
|
apiKey: string;
|
|
26
|
+
/** Stored credential row behind `apiKey`; undefined for runtime, config, env, or fallback keys. */
|
|
27
|
+
credentialRowId: number | undefined;
|
|
21
28
|
credentialSessionId: string | undefined;
|
|
22
29
|
};
|
|
23
30
|
export type SessionApiKeyCredentialType = "api_key" | "oauth" | undefined;
|
|
@@ -34,6 +34,13 @@ export interface EntryPatchRecord<TMessage = unknown> {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
export type StoredSessionPatchRecord = HeaderPatchRecord | EntryPatchRecord;
|
|
37
|
+
/**
|
|
38
|
+
* True when a directory entry name can be a session transcript. Transcripts are
|
|
39
|
+
* named `<timestamp>_<sessionId>.jsonl`; a dot-prefixed `.jsonl` file is an
|
|
40
|
+
* in-flight staging copy (such as an unpromoted memory-guard restore) and never
|
|
41
|
+
* a session of its own, even when a crash leaves it behind.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isSessionTranscriptFileName(name: string): boolean;
|
|
37
44
|
export declare function isSupportedSessionVersion(version: unknown): boolean;
|
|
38
45
|
export declare function isHeaderPatchRecord(record: StoredSessionRecord | StoredSessionPatchRecord): record is HeaderPatchRecord;
|
|
39
46
|
export declare function applyHeaderPatch(header: MutableSessionHeaderFields & {
|
|
@@ -28,6 +28,7 @@ import { type SessionMcpControlGrant } from "../runtime-mcp/session-controls-gra
|
|
|
28
28
|
import { AgentSession, type ForkContextSeed } from "../session/agent-session";
|
|
29
29
|
import { AuthStorage } from "../session/auth-storage";
|
|
30
30
|
import { SessionManager } from "../session/session-manager";
|
|
31
|
+
import { type SessionOwnerSurface } from "../session/session-ownership";
|
|
31
32
|
import { type StartupAuthConfigSnapshot } from "../session/startup-auth-config";
|
|
32
33
|
import { type BuildSystemPromptResult } from "../system-prompt";
|
|
33
34
|
import { type AutomationTools, BUILTIN_TOOLS, createTools, HIDDEN_TOOLS, type Tool, type ToolSession } from "../tools";
|
|
@@ -265,6 +266,16 @@ export interface CreateAgentSessionOptions {
|
|
|
265
266
|
inheritedMcpManager?: import("../runtime-mcp/manager").MCPManager;
|
|
266
267
|
/** Session manager. Default: session stored under the configured agentDir sessions root */
|
|
267
268
|
sessionManager?: SessionManager;
|
|
269
|
+
/**
|
|
270
|
+
* How this process is named to others while it holds the session it creates (design §3.4).
|
|
271
|
+
* Default: `sdk`. A supplied `sessionManager` keeps the surface its factory claimed under; pass
|
|
272
|
+
* the same `{ surface }` as that factory's ownership argument. When the session is open for
|
|
273
|
+
* writing in another process, under `session.ownership.mode: enforce`, the factories and this
|
|
274
|
+
* function throw `SessionHeldError`.
|
|
275
|
+
*/
|
|
276
|
+
owner?: {
|
|
277
|
+
readonly surface: SessionOwnerSurface;
|
|
278
|
+
};
|
|
268
279
|
/** Override local:// protocol options for subagent local:// sharing. Default: uses the session's own artifacts dir and session ID. */
|
|
269
280
|
localProtocolOptions?: LocalProtocolOptions;
|
|
270
281
|
/** Settings instance. Default: a scope-local Settings.loadForScope({ cwd, agentDir }). */
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { type ModelProfileErrorCode, type ModelProfileErrorDetails } from "../config/model-profile-contract";
|
|
2
|
+
import { type SessionOwnerHolderSummary } from "../session/session-owner-holder";
|
|
2
3
|
export type SdkStartupPhase = "registration" | "startup";
|
|
4
|
+
/**
|
|
5
|
+
* A lifecycle host refused to open its session because another process holds it (single-owner,
|
|
6
|
+
* `enforce`). The broker reports it as the same `live_session` outcome its resume wait ends in.
|
|
7
|
+
*/
|
|
8
|
+
export declare const SDK_STARTUP_SESSION_HELD_CODE = "session_held";
|
|
9
|
+
export interface SdkStartupSessionHeldDetails {
|
|
10
|
+
holder?: SessionOwnerHolderSummary;
|
|
11
|
+
}
|
|
3
12
|
export type SdkStartupReason = "disabled" | "ineligible" | "factory_absent" | "runner_absent" | "admission_timeout" | "pending" | "failed";
|
|
4
13
|
export interface SdkStartupFailure {
|
|
5
14
|
phase: SdkStartupPhase;
|
|
6
15
|
reason: SdkStartupReason;
|
|
7
16
|
message: string;
|
|
8
|
-
code?: ModelProfileErrorCode;
|
|
9
|
-
details?: ModelProfileErrorDetails;
|
|
17
|
+
code?: ModelProfileErrorCode | typeof SDK_STARTUP_SESSION_HELD_CODE;
|
|
18
|
+
details?: ModelProfileErrorDetails | SdkStartupSessionHeldDetails;
|
|
10
19
|
}
|
|
11
20
|
export type SdkStartupResult = {
|
|
12
21
|
status: "started";
|
|
@@ -317,8 +317,6 @@ export interface AgentSessionLifecycleState {
|
|
|
317
317
|
export interface AgentSessionConfig {
|
|
318
318
|
agent: Agent;
|
|
319
319
|
sessionManager: SessionManager;
|
|
320
|
-
/** Internal root-TUI experiment only; never inherited by child sessions. */
|
|
321
|
-
rootInteractiveSharedAppend?: boolean;
|
|
322
320
|
settings: Settings;
|
|
323
321
|
/** The session's REQUESTED effective agent directory, independent of the
|
|
324
322
|
* global Settings singleton (which may be reused across sessions). */
|
|
@@ -2381,6 +2379,7 @@ export declare class AgentSession {
|
|
|
2381
2379
|
* Aborts current operation, loads messages, restores model/thinking.
|
|
2382
2380
|
* Listeners are preserved and will continue receiving events.
|
|
2383
2381
|
* @returns true if switch completed, false if cancelled by hook
|
|
2382
|
+
* @throws SessionHeldError under enforce, before any event, for a target another process holds
|
|
2384
2383
|
*/
|
|
2385
2384
|
switchSession(sessionPath: string, options?: {
|
|
2386
2385
|
transition?: SessionSwitchEvent["transition"];
|
|
@@ -12,7 +12,7 @@ export declare const RESUME_REJECTED_OPERATOR_MESSAGE = "Session was resumed by
|
|
|
12
12
|
export declare class ManagedAppendIdentityMismatchError extends Error {
|
|
13
13
|
readonly code = "managed_append_identity_mismatch";
|
|
14
14
|
readonly relativePath: string;
|
|
15
|
-
readonly operatorMessage = "Another process changed this session's transcript, so this process stopped saving to it. To continue, reopen the session with /resume (or gjc --resume), or fork it with
|
|
15
|
+
readonly operatorMessage = "Another process changed this session's transcript, so this process stopped saving to it. To continue, reopen the session with /resume (or gjc --resume), or fork it with gjc --fork.";
|
|
16
16
|
constructor(relativePath: string);
|
|
17
17
|
}
|
|
18
18
|
export declare class ManagedPublishError extends Error {
|
|
@@ -1,7 +1,103 @@
|
|
|
1
1
|
import type { SessionManager } from "../session-manager";
|
|
2
|
-
import { type SessionOwnerClaim } from "../session-ownership";
|
|
2
|
+
import { SessionHeldError, type SessionOwnerClaim, type SessionOwnerHolder, type SessionOwnerSurface, SessionOwnershipError } from "../session-ownership";
|
|
3
|
+
import { type SessionOwnershipMode } from "../session-ownership-mode";
|
|
4
|
+
/**
|
|
5
|
+
* A factory's ownership decision (design §2.4): claim under `surface`, or never claim (`exempt`).
|
|
6
|
+
* `mode` is the mode as the factory read it; a factory reads it once and hands it on.
|
|
7
|
+
*/
|
|
8
|
+
export type SessionOwnershipDecision = "exempt" | {
|
|
9
|
+
readonly surface: SessionOwnerSurface;
|
|
10
|
+
readonly mode?: SessionOwnershipMode;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The decision a persisting manager is constructed with. Required by the constructor, so a factory
|
|
14
|
+
* cannot build a manager without deciding.
|
|
15
|
+
*/
|
|
16
|
+
export type ResolvedSessionOwnership = "exempt" | {
|
|
17
|
+
readonly surface: SessionOwnerSurface;
|
|
18
|
+
readonly mode: SessionOwnershipMode;
|
|
19
|
+
};
|
|
20
|
+
/** Read the mode once, for one factory; without a decision, claim as this process's surface. */
|
|
21
|
+
export declare function resolveSessionOwnership(decision?: SessionOwnershipDecision): ResolvedSessionOwnership;
|
|
22
|
+
/**
|
|
23
|
+
* Whether `ownership` takes claims at all. Callers check this before awaiting a claim, so `off` and
|
|
24
|
+
* exempt managers add no await and keep their ordering exactly as before ownership existed.
|
|
25
|
+
*/
|
|
26
|
+
export declare function claimsUnder(ownership: ResolvedSessionOwnership): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The outcome of one claim attempt. `none`: nothing was attempted (off, exempt) or the claim failed
|
|
29
|
+
* open, with `skipped` naming why (`unavailable` is permanent, `timed_out` is that one call);
|
|
30
|
+
* `failed`: a failure enforce refuses (counted `claim_failed`), with that failure; `held`: another
|
|
31
|
+
* process holds the session (counted `claim_conflict`), with its holder if known.
|
|
32
|
+
*/
|
|
33
|
+
type SessionClaimRefusable = {
|
|
34
|
+
readonly status: "held";
|
|
35
|
+
readonly holder?: SessionOwnerHolder;
|
|
36
|
+
} | {
|
|
37
|
+
readonly status: "failed";
|
|
38
|
+
readonly error: SessionOwnershipError;
|
|
39
|
+
};
|
|
40
|
+
type SessionClaimNone = {
|
|
41
|
+
readonly status: "none";
|
|
42
|
+
readonly skipped?: "unavailable" | "timed_out";
|
|
43
|
+
};
|
|
44
|
+
export type SessionClaimOutcome = {
|
|
45
|
+
readonly status: "claimed";
|
|
46
|
+
} | SessionClaimNone | SessionClaimRefusable;
|
|
47
|
+
export type SessionClaimAttempt = {
|
|
48
|
+
readonly status: "claimed";
|
|
49
|
+
readonly claim: SessionOwnerClaim;
|
|
50
|
+
} | SessionClaimNone | SessionClaimRefusable;
|
|
51
|
+
export type SessionClaimStatus = SessionClaimOutcome["status"];
|
|
52
|
+
/**
|
|
53
|
+
* One claim attempt under `ownership`, never throwing (design §13 M2). A held session (counted
|
|
54
|
+
* `claim_conflict`) and an owners-directory failure (counted `claim_failed`) are logged and returned;
|
|
55
|
+
* {@link claimRefusal} decides whether enforce refuses them. `previous`, the outcome a re-attempt
|
|
56
|
+
* repeats, keeps the same outcome again from being counted or logged again. `admission` marks an
|
|
57
|
+
* open's or a switch's cover, which the opener's own claim releases when it lands.
|
|
58
|
+
*/
|
|
59
|
+
export declare function attemptSessionClaim(ownership: ResolvedSessionOwnership, sessionId: string, previous?: SessionClaimOutcome, options?: {
|
|
60
|
+
readonly admission?: boolean;
|
|
61
|
+
}): Promise<SessionClaimAttempt>;
|
|
62
|
+
/**
|
|
63
|
+
* The one refusal decision (design §3.3, 5a): the error enforce raises for a claim outcome, or
|
|
64
|
+
* `undefined` to go on without a claim. Only `held` (a {@link SessionHeldError} naming the holder)
|
|
65
|
+
* and `failed` (the owners-directory failure, fail-closed like the append lock) refuse, and only when
|
|
66
|
+
* both the mode the factory read and the live mode are `enforce`: the live read only ever lowers it.
|
|
67
|
+
*/
|
|
68
|
+
export declare function claimRefusal(ownership: ResolvedSessionOwnership, sessionId: string, outcome: SessionClaimOutcome | SessionClaimAttempt | undefined): SessionHeldError | SessionOwnershipError | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Run `write`, a short write to a session that is not the caller's own (a picker star or delete,
|
|
71
|
+
* design §1 row 17), under a scoped claim: claim, write, release. Enforce refuses a session another
|
|
72
|
+
* process holds, and a claim that failed, with `Can't <action> this session: …` (the refusal is the
|
|
73
|
+
* `cause`), so the holder keeps its transcript; observe logs and counts the conflict and writes as
|
|
74
|
+
* before; off and exempt make no lock call. A session this process holds shares its claim (D10).
|
|
75
|
+
*/
|
|
76
|
+
export declare function withScopedSessionClaim<T>(ownership: ResolvedSessionOwnership, sessionId: string, action: string, write: () => Promise<T>): Promise<T>;
|
|
77
|
+
/**
|
|
78
|
+
* The sessions enforce would refuse because another process holds them, each with the refusal that
|
|
79
|
+
* names its holder: what the held-session warning and the session list's markers show (design §1
|
|
80
|
+
* rows 1-3). A probe, never a claim: the claim stays the authority, and a race falls back to its
|
|
81
|
+
* refusal. `undefined`, with nothing awaited, outside enforce; a probe that fails reads as free.
|
|
82
|
+
*/
|
|
83
|
+
export declare function probeHeldSessions(ownership: ResolvedSessionOwnership, sessionIds: readonly string[]): Promise<Map<string, SessionHeldError>> | undefined;
|
|
3
84
|
/** How long a deferred owner shutdown may keep its predecessor's claim (design §2.5). */
|
|
4
85
|
export declare const DEFERRED_RELEASE_CAP_MS = 60000;
|
|
86
|
+
/**
|
|
87
|
+
* Turn start's re-attempt backoff (design §13.1, timeout-latch policy). A held session costs one
|
|
88
|
+
* non-blocking lock call, so it is retried after a short floor; a timed-out or failed claim can cost
|
|
89
|
+
* the full native budget, so it backs off exponentially up to the cap.
|
|
90
|
+
*/
|
|
91
|
+
export declare const RECLAIM_HELD_FLOOR_MS = 5000;
|
|
92
|
+
export declare const RECLAIM_BACKOFF_BASE_MS = 10000;
|
|
93
|
+
export declare const RECLAIM_BACKOFF_CAP_MS = 300000;
|
|
94
|
+
/** What turn start's re-attempt found ({@link SessionClaimSet.reclaimCurrent}). */
|
|
95
|
+
export interface SessionReclaim {
|
|
96
|
+
/** The current session's outcome now; `timed_out` is a `none` that a lock stall caused. */
|
|
97
|
+
readonly status: SessionClaimStatus | "timed_out";
|
|
98
|
+
/** Enforce's refusal of the turn ({@link claimRefusal}): the holder keeps the session. */
|
|
99
|
+
readonly refusal?: SessionHeldError | SessionOwnershipError;
|
|
100
|
+
}
|
|
5
101
|
/** Thrown only under the strict test seam, for a write the detector flags. */
|
|
6
102
|
export declare class SessionWriteWithoutClaimError extends Error {
|
|
7
103
|
readonly code = "session_write_without_claim";
|
|
@@ -10,21 +106,81 @@ export declare class SessionWriteWithoutClaimError extends Error {
|
|
|
10
106
|
}
|
|
11
107
|
export declare class SessionClaimSet {
|
|
12
108
|
#private;
|
|
13
|
-
constructor();
|
|
109
|
+
constructor(ownership?: ResolvedSessionOwnership);
|
|
110
|
+
/** False in `off` and for an exempt manager: check it before awaiting {@link claim} or {@link settled}. */
|
|
111
|
+
get claiming(): boolean;
|
|
112
|
+
/** The decision this set claims under, for a scoped claim made on the manager's behalf. */
|
|
113
|
+
get ownership(): ResolvedSessionOwnership;
|
|
14
114
|
/** The session id the manager's identity helper last bound. */
|
|
15
115
|
get currentSessionId(): string | undefined;
|
|
16
116
|
get sessionIds(): readonly string[];
|
|
17
117
|
has(sessionId: string): boolean;
|
|
18
118
|
/**
|
|
19
|
-
* The identity helper's record of the manager's id. It never claims
|
|
20
|
-
*
|
|
119
|
+
* The identity helper's record of the manager's id. It never claims. A change of id outside any
|
|
120
|
+
* transition is counted (when ownership is on): nothing settles after it. The first bind settles,
|
|
121
|
+
* so a claim a factory took for an id it did not adopt (a fork attempt that fell back) goes.
|
|
21
122
|
*/
|
|
22
123
|
bind(sessionId: string): void;
|
|
124
|
+
/**
|
|
125
|
+
* Claim `sessionId` into this set (design §2.4): a factory's id before its first write, or a
|
|
126
|
+
* transition's target before its rotation. Catches lock errors, but rejects if `add` throws
|
|
127
|
+
* `session_claim_released`; a no-op in `off`, for an exempt manager, and for an id already held.
|
|
128
|
+
*
|
|
129
|
+
* Outside any transition the claim is a factory's, made before the factory's first write and
|
|
130
|
+
* before it hands the manager out: there enforce refuses a held or failed outcome by throwing
|
|
131
|
+
* {@link claimRefusal}'s error. A transition's claim never refuses: a switch is refused before its
|
|
132
|
+
* transition begins, by the manager's switch-target admission.
|
|
133
|
+
*/
|
|
134
|
+
claim(sessionId: string): Promise<SessionClaimStatus>;
|
|
135
|
+
/**
|
|
136
|
+
* A sync factory's claim (`create`): started now, settled later. A write made while it is in flight
|
|
137
|
+
* is covered, because the id is fresh and no other process can hold it.
|
|
138
|
+
*/
|
|
139
|
+
claimInBackground(sessionId: string): void;
|
|
140
|
+
/** Record the outcome of a claim taken before this set existed (a strict open's, handed over). */
|
|
141
|
+
noteOutcome(sessionId: string, outcome: SessionClaimOutcome): void;
|
|
142
|
+
/**
|
|
143
|
+
* Wait for the claims in flight, then the outcome for the current id. `undefined` when nothing
|
|
144
|
+
* was attempted.
|
|
145
|
+
*/
|
|
146
|
+
settled(): Promise<SessionClaimStatus | undefined>;
|
|
147
|
+
/**
|
|
148
|
+
* The gate for a manager about to be used for writing (`createAgentSession`, session import):
|
|
149
|
+
* waits for the claims in flight and returns enforce's refusal for the current id, if any. It
|
|
150
|
+
* catches what no factory refused, such as the background claim of `create`.
|
|
151
|
+
*/
|
|
152
|
+
refusal(): Promise<SessionHeldError | SessionOwnershipError | undefined>;
|
|
153
|
+
/**
|
|
154
|
+
* Turn start's re-attempt of the current id's claim (design §2.7, §13.1): a claim another process
|
|
155
|
+
* held, or one that timed out or failed, is tried again, so a writer whose open did not claim
|
|
156
|
+
* becomes visible once it can. `undefined`, with nothing awaited, when there is nothing to
|
|
157
|
+
* re-attempt (off, exempt, closed, inside a transition, already claimed, a permanent fail-open, a
|
|
158
|
+
* live mode lowered to off, inside the backoff) and whenever the turn does not depend on it: in
|
|
159
|
+
* observe, or with the live mode lowered from enforce, the re-attempt runs in the background, and
|
|
160
|
+
* the writes it overlaps are covered as a pending claim's are. Only under enforce does the turn wait,
|
|
161
|
+
* joining a claim already in flight; there a held or failed claim is re-attempted at every turn, so
|
|
162
|
+
* no turn passes it unchecked. Never rejects: enforce's refusal comes back as a value, and the
|
|
163
|
+
* session is never taken from its holder.
|
|
164
|
+
*/
|
|
165
|
+
reclaimCurrent(): Promise<SessionReclaim> | undefined;
|
|
166
|
+
/**
|
|
167
|
+
* Enforce's write gate (design §2.5, §13.1): a write to an id whose recorded outcome enforce
|
|
168
|
+
* refuses (`held`: a turn-start re-attempt found another holder, or a transition landed held;
|
|
169
|
+
* `failed`: the claim failed, fail-closed) is refused with {@link claimRefusal}'s error, so no
|
|
170
|
+
* writer outside a turn (a title, a rename, a compaction, an extension's entry, an SDK append)
|
|
171
|
+
* writes over a holder. It reads only the recorded outcome and makes no lock call; the turn gate is
|
|
172
|
+
* what finds the holder. A refusal starts a background re-attempt (within the backoff), so the gate
|
|
173
|
+
* lifts on its own soon after the holder exits. Inside a transition nothing is refused.
|
|
174
|
+
*/
|
|
175
|
+
refuseWriteIfRefused(sessionId?: string | undefined): void;
|
|
23
176
|
/**
|
|
24
177
|
* The write-path detector (design §2.5), called before a transcript write. When ownership is on
|
|
25
178
|
* and this set holds no claim for `sessionId` (the current id unless a successor is named), it
|
|
26
179
|
* logs `session_write_without_claim` with the call site and counts it. It never claims, and it
|
|
27
180
|
* throws only under the strict test seam. In `off` it returns at once.
|
|
181
|
+
*
|
|
182
|
+
* A write made before the manager's first bind (a factory publishing a new transcript before it
|
|
183
|
+
* adopts it) must name its id: with nothing bound there is no current id.
|
|
28
184
|
*/
|
|
29
185
|
checkWrite(site: string, sessionId?: string | undefined): void;
|
|
30
186
|
/**
|
|
@@ -49,17 +205,10 @@ export declare class SessionClaimSet {
|
|
|
49
205
|
* reaches the cap releases anyway and counts `release_after_deferred_timeout`.
|
|
50
206
|
*/
|
|
51
207
|
holdUntil(sessionId: string, finalization: Promise<unknown>, capMs?: number): void;
|
|
52
|
-
/**
|
|
53
|
-
* Cold-sidecar manager swap: every claim and hold moves to `target`, and this set is emptied
|
|
54
|
-
* without unlocking anything. The target then settles: a claim for its current id and any held
|
|
55
|
-
* claim survive, everything else is released (a fork's predecessor, once the swap commits).
|
|
56
|
-
* Open transitions are not carried across: a caller that swaps inside a transition must call
|
|
57
|
-
* this after that transition ends, or open one on the target.
|
|
58
|
-
*/
|
|
59
|
-
moveTo(target: SessionClaimSet): void;
|
|
60
208
|
/**
|
|
61
209
|
* `close()`: release every claim. A claim under a deferred hold is released when its hold ends,
|
|
62
|
-
* at most the cap later; nothing can be added afterwards
|
|
210
|
+
* at most the cap later; nothing can be added afterwards, and a claim still in flight is released
|
|
211
|
+
* when it lands.
|
|
63
212
|
*/
|
|
64
213
|
releaseAll(): void;
|
|
65
214
|
}
|
|
@@ -67,3 +216,9 @@ export declare class SessionClaimSet {
|
|
|
67
216
|
export declare const sessionClaimSetCapability: unique symbol;
|
|
68
217
|
/** The claim set of a SessionManager, for factories, transitions and tests in this package. */
|
|
69
218
|
export declare function sessionClaimSetOf(manager: SessionManager): SessionClaimSet;
|
|
219
|
+
/**
|
|
220
|
+
* Turn start's re-attempt for `manager`'s current session ({@link SessionClaimSet.reclaimCurrent});
|
|
221
|
+
* `undefined` for a stand-in manager that has no claim set, as a test's double has none.
|
|
222
|
+
*/
|
|
223
|
+
export declare function reclaimCurrentSession(manager: SessionManager): Promise<SessionReclaim> | undefined;
|
|
224
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type ResolvedSessionOwnership } from "./internal/session-claim-set";
|
|
2
|
+
import { SessionHeldError, type SessionOwnerClaim } from "./session-ownership";
|
|
3
|
+
/** The host Continue here closes: its index row's endpoint authority, and where remote clients look for it. */
|
|
4
|
+
export interface SessionHandoverTarget {
|
|
5
|
+
readonly sessionId: string;
|
|
6
|
+
readonly agentDir: string;
|
|
7
|
+
readonly cwd: string;
|
|
8
|
+
readonly endpointGeneration: number;
|
|
9
|
+
readonly endpointIncarnation: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* `closed`: the host exited and this process holds the claim (`undefined` only when claims fail
|
|
13
|
+
* open); the caller keeps it until its own open or switch has claimed, then releases it.
|
|
14
|
+
*/
|
|
15
|
+
export type SessionHandoverOutcome = {
|
|
16
|
+
readonly kind: "closed";
|
|
17
|
+
readonly claim: SessionOwnerClaim | undefined;
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: "refused";
|
|
20
|
+
readonly message: string;
|
|
21
|
+
};
|
|
22
|
+
export declare const SESSION_HANDOVER_BUSY_MESSAGE = "The session is running a turn; try again when it finishes.";
|
|
23
|
+
export interface SessionHandoverWaitOptions {
|
|
24
|
+
/** Ends the wait at the next poll: the caller was cancelled or is exiting. */
|
|
25
|
+
readonly signal?: AbortSignal;
|
|
26
|
+
/** Called once, when the warning starts waiting for the host to publish. */
|
|
27
|
+
readonly onWaiting?: () => void;
|
|
28
|
+
}
|
|
29
|
+
/** The held-session warning's input for a refusal, as it stands after any wait. */
|
|
30
|
+
export interface SessionHandoverCheck {
|
|
31
|
+
/** Who to warn about now; `undefined` once nothing holds the session, so it opens as unheld. */
|
|
32
|
+
readonly error: SessionHeldError | undefined;
|
|
33
|
+
/** The host Continue here closes, when it is offered for `error`. */
|
|
34
|
+
readonly target: SessionHandoverTarget | undefined;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Whether Continue here is offered for `error`, and for which host: the holder must be the live,
|
|
38
|
+
* broker-launched host in the session index (its row carries a `lifecycleRequestId`, design §13
|
|
39
|
+
* L1), not a terminal, the app or an embedding. The surface label in the holder record does not
|
|
40
|
+
* decide it.
|
|
41
|
+
*
|
|
42
|
+
* A host claims before it publishes (a remote resume that reached the broker first, design §13
|
|
43
|
+
* H3), so when the holder claimed as a host and its row is not there yet, this waits for the row,
|
|
44
|
+
* at most {@link HOST_PUBLICATION_WAIT_MS}, while that host still holds the session and has not
|
|
45
|
+
* published an endpoint. A holder that let go meanwhile is not warned about: a free session opens
|
|
46
|
+
* as unheld, and a new holder is looked up once, without waiting.
|
|
47
|
+
*/
|
|
48
|
+
export declare function checkSessionHandover(error: SessionHeldError, agentDir: string, options?: SessionHandoverWaitOptions): Promise<SessionHandoverCheck>;
|
|
49
|
+
/**
|
|
50
|
+
* Hand the session over to this process (design §13 L1):
|
|
51
|
+
* 1. A generation-0 row for this process fences the gap, so a remote resume after the host exits
|
|
52
|
+
* sees the session live and waits instead of launching another host.
|
|
53
|
+
* 2. The broker closes the host only between turns (`ifIdle`, atomic in the host); a running turn
|
|
54
|
+
* or work lease answers `busy`. It answers once the host process has exited.
|
|
55
|
+
* 3. This process claims the session. From here the broker's resume waits on the claim until this
|
|
56
|
+
* process publishes its endpoint, so the fence row is withdrawn on every outcome.
|
|
57
|
+
*
|
|
58
|
+
* The host is looked up again on every attempt, without waiting (the warning already waited for
|
|
59
|
+
* it), so a retry after `busy` uses its current endpoint authority; a host that has exited
|
|
60
|
+
* meanwhile leaves only the claim to take.
|
|
61
|
+
*/
|
|
62
|
+
export declare function handOverSession(error: SessionHeldError, agentDir: string, ownership: ResolvedSessionOwnership): Promise<SessionHandoverOutcome>;
|