@gajae-code/coding-agent 0.15.6 → 0.16.0
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 +59 -0
- package/dist/types/cli/args.d.ts +2 -0
- package/dist/types/cli/root-flags.d.ts +14 -0
- package/dist/types/cli/update-cli.d.ts +13 -0
- package/dist/types/cli.d.ts +7 -0
- package/dist/types/commands/launch.d.ts +10 -0
- package/dist/types/config/autorouting-tier-map.d.ts +24 -0
- package/dist/types/config/file-lock.d.ts +5 -0
- package/dist/types/config/model-registry.d.ts +6 -0
- package/dist/types/config/settings-schema.d.ts +10 -1
- package/dist/types/config/settings.d.ts +2 -0
- package/dist/types/coordinator-mcp/projection-scan.d.ts +8 -0
- package/dist/types/crash/record-loader.d.ts +15 -0
- package/dist/types/gjc-runtime/launch-worktree-reservation.d.ts +21 -0
- package/dist/types/gjc-runtime/managed-owner-supervisor.d.ts +2 -0
- package/dist/types/gjc-runtime/session-state-sidecar.d.ts +66 -1
- package/dist/types/gjc-runtime/tmux-owner-isolation.d.ts +1 -0
- package/dist/types/gjc-runtime/tmux-sessions.d.ts +27 -0
- package/dist/types/master-mode/context.d.ts +21 -0
- package/dist/types/master-mode/first-request.d.ts +34 -0
- package/dist/types/master-mode/snapshot.d.ts +32 -0
- package/dist/types/modes/components/frictionless-onboarding-selector.d.ts +10 -0
- package/dist/types/modes/components/oauth-selector.d.ts +1 -0
- package/dist/types/modes/components/status-line/model-name.d.ts +18 -0
- package/dist/types/modes/components/status-line/priority-row.d.ts +34 -0
- package/dist/types/modes/components/status-line/segments.d.ts +10 -0
- package/dist/types/modes/print-mode.d.ts +17 -0
- package/dist/types/modes/ui-language.d.ts +7 -1
- package/dist/types/sdk/broker/broker.d.ts +77 -1
- package/dist/types/sdk/broker/endpoint-authority.d.ts +24 -0
- package/dist/types/sdk/broker/index.d.ts +3 -0
- package/dist/types/sdk/broker/lifecycle.d.ts +26 -0
- package/dist/types/sdk/broker/master-capability.d.ts +10 -0
- package/dist/types/sdk/broker/session-index.d.ts +40 -11
- package/dist/types/sdk/broker/session-scope.d.ts +72 -0
- package/dist/types/sdk/broker/spawn-authority.d.ts +201 -0
- package/dist/types/sdk/broker/spawn-substrate.d.ts +30 -0
- package/dist/types/sdk/broker/state-version.d.ts +4 -1
- package/dist/types/sdk/broker/worktree-occupancy.d.ts +28 -0
- package/dist/types/sdk/bus/chat-daemon-control.d.ts +3 -0
- package/dist/types/sdk/bus/index.d.ts +6 -0
- package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +1 -1
- package/dist/types/sdk/cli/index.d.ts +1 -0
- package/dist/types/sdk/cli/master-cli.d.ts +63 -0
- package/dist/types/sdk/cli/rows.d.ts +4 -3
- package/dist/types/sdk/cli/session-cli.d.ts +18 -2
- package/dist/types/sdk/client/client.d.ts +3 -2
- package/dist/types/sdk/host/control/dispatch.d.ts +10 -0
- package/dist/types/sdk/host/control/index.d.ts +1 -1
- package/dist/types/sdk/host/control/operations.d.ts +2 -0
- package/dist/types/sdk/host/control/runtime-gate.d.ts +21 -7
- package/dist/types/sdk/host/host.d.ts +10 -0
- package/dist/types/sdk/host/session-runtime.d.ts +52 -0
- package/dist/types/sdk/lifecycle/broker-client.d.ts +6 -0
- package/dist/types/sdk/lifecycle/service.d.ts +15 -3
- package/dist/types/sdk/lifecycle-session.d.ts +2 -0
- package/dist/types/sdk/router/session-router.d.ts +2 -0
- package/dist/types/sdk/session.d.ts +16 -0
- package/dist/types/sdk/startup-capability.d.ts +2 -1
- package/dist/types/session/agent-session.d.ts +5 -0
- package/dist/types/session/credential-store-errors.d.ts +1 -0
- package/dist/types/session/session-manager.d.ts +65 -0
- package/dist/types/session/yield-queue.d.ts +5 -4
- package/dist/types/setup/frictionless-onboarding.d.ts +1 -0
- package/dist/types/tools/bash.d.ts +4 -0
- package/dist/types/tools/gh.d.ts +8 -0
- package/dist/types/tools/index.d.ts +4 -0
- package/package.json +7 -7
- package/scripts/generate-sdk-operation-inventory.ts +6 -0
- package/scripts/verify-gjc-sdk-canonicalization.ts +35 -1
- package/src/cli/accounts-cli.ts +9 -5
- package/src/cli/args.ts +17 -0
- package/src/cli/fast-help.ts +1 -0
- package/src/cli/root-flags.ts +5 -0
- package/src/cli/update-cli.ts +77 -11
- package/src/commands/launch.ts +86 -18
- package/src/commands/sdk.ts +113 -21
- package/src/config/autorouting-tier-map.ts +12 -0
- package/src/config/file-lock.ts +158 -83
- package/src/config/model-preset-registry.ts +1 -5
- package/src/config/model-profiles.ts +5 -5
- package/src/config/model-registry.ts +23 -0
- package/src/config/model-resolver.ts +5 -0
- package/src/config/settings-schema.ts +8 -1
- package/src/config/settings.ts +5 -0
- package/src/coordinator-mcp/projection-scan.ts +21 -0
- package/src/coordinator-mcp/question-state.ts +9 -11
- package/src/coordinator-mcp/server.ts +94 -20
- package/src/crash/index-store.ts +2 -0
- package/src/crash/record-loader.ts +10 -0
- package/src/gjc-runtime/launch-worktree-reservation.ts +242 -0
- package/src/gjc-runtime/managed-owner-supervisor.ts +63 -51
- package/src/gjc-runtime/session-state-lock.ts +79 -6
- package/src/gjc-runtime/session-state-sidecar.ts +929 -23
- package/src/gjc-runtime/tmux-owner-isolation-cli.ts +4 -7
- package/src/gjc-runtime/tmux-owner-isolation.ts +2 -2
- package/src/gjc-runtime/tmux-sessions.ts +252 -13
- package/src/hooks/skill-state.ts +6 -0
- package/src/internal-urls/docs-index.generated.ts +7 -7
- package/src/internal-urls/issue-pr-protocol.ts +4 -2
- package/src/main.ts +57 -2
- package/src/master-mode/context.ts +50 -0
- package/src/master-mode/first-request.ts +65 -0
- package/src/master-mode/snapshot.ts +205 -0
- package/src/modes/acp/acp-agent.ts +605 -156
- package/src/modes/components/footer.ts +4 -2
- package/src/modes/components/frictionless-onboarding-selector.ts +48 -2
- package/src/modes/components/oauth-selector.ts +6 -1
- package/src/modes/components/settings-selector.ts +1 -0
- package/src/modes/components/status-line/model-name.ts +53 -0
- package/src/modes/components/status-line/priority-row.ts +107 -0
- package/src/modes/components/status-line/segments.ts +23 -9
- package/src/modes/components/tool-status-header.ts +151 -15
- package/src/modes/controllers/input-controller.ts +28 -0
- package/src/modes/controllers/selector-controller.ts +191 -96
- package/src/modes/print-mode.ts +64 -0
- package/src/modes/ui-language.ts +49 -2
- package/src/prompts/system/master-mode.md +28 -0
- package/src/sdk/broker/broker.ts +1636 -26
- package/src/sdk/broker/endpoint-authority.ts +86 -0
- package/src/sdk/broker/ensure.ts +5 -0
- package/src/sdk/broker/index.ts +3 -0
- package/src/sdk/broker/lifecycle.ts +186 -41
- package/src/sdk/broker/master-capability.ts +232 -0
- package/src/sdk/broker/session-index.ts +121 -17
- package/src/sdk/broker/session-scope.ts +272 -0
- package/src/sdk/broker/spawn-authority.ts +1031 -0
- package/src/sdk/broker/spawn-substrate.ts +548 -0
- package/src/sdk/broker/state-version.ts +26 -14
- package/src/sdk/broker/transport.ts +1 -0
- package/src/sdk/broker/worktree-occupancy.ts +90 -0
- package/src/sdk/bus/chat-daemon-control.ts +5 -2
- package/src/sdk/bus/chat-daemon-runtime.ts +35 -4
- package/src/sdk/bus/index.ts +51 -4
- package/src/sdk/bus/telegram-daemon-contract.ts +1 -1
- package/src/sdk/cli/index.ts +1 -0
- package/src/sdk/cli/master-cli.ts +259 -0
- package/src/sdk/cli/rows.ts +11 -8
- package/src/sdk/cli/session-cli.ts +264 -5
- package/src/sdk/client/client.ts +14 -8
- package/src/sdk/host/control/dispatch.ts +99 -38
- package/src/sdk/host/control/index.ts +2 -0
- package/src/sdk/host/control/operations.ts +2 -0
- package/src/sdk/host/control/runtime-gate.ts +203 -11
- package/src/sdk/host/host.ts +27 -2
- package/src/sdk/host/session-runtime.test.ts +210 -6
- package/src/sdk/host/session-runtime.ts +291 -49
- package/src/sdk/lifecycle/broker-client.ts +28 -0
- package/src/sdk/lifecycle/service.ts +279 -20
- package/src/sdk/lifecycle-session.ts +10 -2
- package/src/sdk/protocol/operation-inventory.generated.json +51 -0
- package/src/sdk/protocol/operation-registry.ts +13 -3
- package/src/sdk/router/session-router.ts +67 -59
- package/src/sdk/session.ts +357 -155
- package/src/sdk/startup-capability.ts +1 -0
- package/src/session/agent-session.ts +640 -103
- package/src/session/blob-store.ts +15 -5
- package/src/session/credential-store-errors.ts +2 -0
- package/src/session/internal/managed-session-storage.ts +153 -78
- package/src/session/session-manager.ts +337 -24
- package/src/session/yield-queue.ts +24 -10
- package/src/setup/frictionless-onboarding.ts +2 -0
- package/src/telemetry/events.ts +1138 -12
- package/src/tools/bash.ts +256 -42
- package/src/tools/gh.ts +104 -48
- package/src/tools/github-cache.ts +2 -2
- package/src/tools/index.ts +4 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
export type SpawnClaimV2 = {
|
|
2
|
+
version: 2;
|
|
3
|
+
claimId: string;
|
|
4
|
+
lifecycleIdentity: string;
|
|
5
|
+
/** Opaque binding of the raw selector request, retained for catalog-independent replay. */
|
|
6
|
+
requestBindingMac?: string;
|
|
7
|
+
bindingMac: string;
|
|
8
|
+
state: "prepared" | "substrate_starting" | "authority_active" | "seed_prepared" | "dispatching" | "accepted" | "pre_send_rejected" | "uncertain" | "closed";
|
|
9
|
+
failure?: SpawnSubstrateFailure;
|
|
10
|
+
preSendLease?: {
|
|
11
|
+
epoch: string;
|
|
12
|
+
status: "owned" | "consumed";
|
|
13
|
+
};
|
|
14
|
+
childId?: string;
|
|
15
|
+
seed?: SeedDeliveryV2;
|
|
16
|
+
authorityRef?: string;
|
|
17
|
+
createdAt: number;
|
|
18
|
+
updatedAt: number;
|
|
19
|
+
};
|
|
20
|
+
export type SpawnSubstrateFailure = {
|
|
21
|
+
substrateKind: "tmux" | "psmux" | "headless";
|
|
22
|
+
code: string;
|
|
23
|
+
message: string;
|
|
24
|
+
};
|
|
25
|
+
export type SeedDeliveryV2 = {
|
|
26
|
+
version: 2;
|
|
27
|
+
phase: "prepared" | "dispatching" | "accepted" | "pre_send_rejected" | "uncertain";
|
|
28
|
+
clientRef: string;
|
|
29
|
+
commandId?: string;
|
|
30
|
+
turnId?: string;
|
|
31
|
+
acceptedAt?: number;
|
|
32
|
+
lastQ26Status?: "accepted" | "in_flight" | "terminal_ok" | "failed" | "unknown";
|
|
33
|
+
observedAt?: number;
|
|
34
|
+
};
|
|
35
|
+
/** Live-only capability check. Implementations must not retain either argument. */
|
|
36
|
+
export interface MasterCapabilityVerifier {
|
|
37
|
+
verifyMasterCapability(ownerSessionId: string, rawCapability: string, attestationEpoch: string): Promise<{
|
|
38
|
+
allowed: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
/** Structured, shell-free child launch contract owned by the Broker. */
|
|
42
|
+
export interface SpawnSubstrateLaunchSpec {
|
|
43
|
+
childSessionId: string;
|
|
44
|
+
cwd: string;
|
|
45
|
+
argv: readonly string[];
|
|
46
|
+
/** Broker-inherited values are filtered to the portable launch subset. */
|
|
47
|
+
inheritedEnv?: Readonly<Record<string, string>>;
|
|
48
|
+
/** Child-specific values are part of this spec and must be shell-safe. */
|
|
49
|
+
env?: Readonly<Record<string, string>>;
|
|
50
|
+
}
|
|
51
|
+
/** Durable facts required to re-prove one spawned substrate without task material. */
|
|
52
|
+
export type SpawnSubstrateProof = {
|
|
53
|
+
substrateKind: "tmux" | "psmux" | "headless";
|
|
54
|
+
providerIdentity: string;
|
|
55
|
+
nativeSessionId?: string;
|
|
56
|
+
pid?: number;
|
|
57
|
+
processIncarnation?: string;
|
|
58
|
+
ownerGeneration?: number;
|
|
59
|
+
stateFileProof?: Readonly<Record<string, string | number>>;
|
|
60
|
+
};
|
|
61
|
+
export interface SpawnSubstrateProvider {
|
|
62
|
+
launch(spec: SpawnSubstrateLaunchSpec): Promise<{
|
|
63
|
+
ok: true;
|
|
64
|
+
proof: SpawnSubstrateProof;
|
|
65
|
+
} | {
|
|
66
|
+
ok: false;
|
|
67
|
+
code: "substrate_unavailable" | "substrate_proof_failed";
|
|
68
|
+
message: string;
|
|
69
|
+
}>;
|
|
70
|
+
verify(proof: SpawnSubstrateProof): Promise<"verified" | "mismatch" | "gone">;
|
|
71
|
+
close(proof: SpawnSubstrateProof): Promise<{
|
|
72
|
+
ok: boolean;
|
|
73
|
+
code?: string;
|
|
74
|
+
}>;
|
|
75
|
+
}
|
|
76
|
+
export type SpawnAuthorityCloseState = "active" | "close_requested" | "closed" | "uncertain";
|
|
77
|
+
/**
|
|
78
|
+
* Exact, durable ownership evidence for a child substrate. It is deliberately
|
|
79
|
+
* structural: request text, capability material, and their derivatives never
|
|
80
|
+
* belong in this record.
|
|
81
|
+
*/
|
|
82
|
+
export type SpawnAuthorityV1 = {
|
|
83
|
+
version: 1;
|
|
84
|
+
authorityId: string;
|
|
85
|
+
claimId: string;
|
|
86
|
+
childId: string;
|
|
87
|
+
ownerSessionId: string;
|
|
88
|
+
lifecycleIdentity: string;
|
|
89
|
+
substrateKind: SpawnSubstrateProof["substrateKind"];
|
|
90
|
+
providerIdentity: string;
|
|
91
|
+
nativeSessionId?: string;
|
|
92
|
+
pid?: number;
|
|
93
|
+
processIncarnation?: string;
|
|
94
|
+
ownerGeneration?: number;
|
|
95
|
+
stateFileProof?: Readonly<Record<string, string | number>>;
|
|
96
|
+
/**
|
|
97
|
+
* Identity of the child HOST endpoint proven at registration. Distinct from
|
|
98
|
+
* the substrate `pid`/`processIncarnation` above: proving the multiplexer
|
|
99
|
+
* substrate is intact says nothing about which host answers on that session
|
|
100
|
+
* id. Optional so pre-pin v1 rows still reopen; recovery treats an absent
|
|
101
|
+
* pin as missing authority and fails closed rather than matching by id.
|
|
102
|
+
*/
|
|
103
|
+
endpointGeneration?: number;
|
|
104
|
+
endpointPid?: number;
|
|
105
|
+
endpointIncarnation?: string;
|
|
106
|
+
/** Launch locator, so a colliding generation/pid in another workspace cannot pass. */
|
|
107
|
+
endpointCwd?: string;
|
|
108
|
+
endpointStateRoot?: string;
|
|
109
|
+
closeState: SpawnAuthorityCloseState;
|
|
110
|
+
orphanedAt?: number;
|
|
111
|
+
orphanRecoveredAt?: number;
|
|
112
|
+
closeRequestedAt?: number;
|
|
113
|
+
closedAt?: number;
|
|
114
|
+
createdAt: number;
|
|
115
|
+
updatedAt: number;
|
|
116
|
+
};
|
|
117
|
+
export type SpawnClaimTransition = {
|
|
118
|
+
claimId: string;
|
|
119
|
+
from: SpawnClaimV2["state"];
|
|
120
|
+
to: SpawnClaimV2["state"];
|
|
121
|
+
/** Required when the transition consumes the one pre-send lease. */
|
|
122
|
+
leaseEpoch?: string;
|
|
123
|
+
/** The fresh child ID is committed before substrate launch. */
|
|
124
|
+
childId?: string;
|
|
125
|
+
/** Required for seed and terminal state transitions that carry Q26 facts. */
|
|
126
|
+
seed?: SeedDeliveryV2;
|
|
127
|
+
failure?: SpawnSubstrateFailure;
|
|
128
|
+
/** Required when exact substrate authority becomes active or closes. */
|
|
129
|
+
authority?: SpawnAuthorityV1;
|
|
130
|
+
/** Required to downgrade dispatching only when no frame was handed off. */
|
|
131
|
+
provenNoHandoff?: true;
|
|
132
|
+
};
|
|
133
|
+
export type SpawnAuthorityTransitionResult = {
|
|
134
|
+
claim: SpawnClaimV2;
|
|
135
|
+
authority?: SpawnAuthorityV1;
|
|
136
|
+
};
|
|
137
|
+
export declare class SpawnAuthorityTransitionError extends Error {
|
|
138
|
+
readonly code: "claim_not_found" | "stale_transition" | "illegal_transition" | "invalid_transition";
|
|
139
|
+
constructor(code: "claim_not_found" | "stale_transition" | "illegal_transition" | "invalid_transition");
|
|
140
|
+
}
|
|
141
|
+
export type SpawnClaimDecision = {
|
|
142
|
+
kind: "owner";
|
|
143
|
+
claim: SpawnClaimV2;
|
|
144
|
+
recovery: boolean;
|
|
145
|
+
} | {
|
|
146
|
+
kind: "in_progress";
|
|
147
|
+
claim: SpawnClaimV2;
|
|
148
|
+
} | {
|
|
149
|
+
kind: "replay";
|
|
150
|
+
claim: SpawnClaimV2;
|
|
151
|
+
} | {
|
|
152
|
+
kind: "terminal";
|
|
153
|
+
claim: SpawnClaimV2;
|
|
154
|
+
} | {
|
|
155
|
+
kind: "terminal_uncertain";
|
|
156
|
+
claim: SpawnClaimV2;
|
|
157
|
+
} | {
|
|
158
|
+
kind: "idempotency_conflict";
|
|
159
|
+
claim: SpawnClaimV2;
|
|
160
|
+
};
|
|
161
|
+
type SpawnAuthorityDurableWrite = {
|
|
162
|
+
claim: SpawnClaimV2;
|
|
163
|
+
authority?: SpawnAuthorityV1;
|
|
164
|
+
};
|
|
165
|
+
export interface SpawnAuthorityStoreOptions {
|
|
166
|
+
/** Test-only hook that runs before the journal record becomes durable. */
|
|
167
|
+
beforeSyncForTest?: (write: SpawnAuthorityDurableWrite) => Promise<void> | void;
|
|
168
|
+
/** Test-only hook after both file and parent-directory fsync complete. */
|
|
169
|
+
afterSyncForTest?: (write: SpawnAuthorityDurableWrite) => Promise<void> | void;
|
|
170
|
+
/** Test-only hook between the file barrier and the parent-directory barrier. */
|
|
171
|
+
beforeDirectorySyncForTest?: (write: SpawnAuthorityDurableWrite) => Promise<void> | void;
|
|
172
|
+
}
|
|
173
|
+
export declare function isSpawnSubstrateProof(value: unknown): value is SpawnSubstrateProof;
|
|
174
|
+
export declare function isSpawnAuthorityV1(value: unknown): value is SpawnAuthorityV1;
|
|
175
|
+
export declare function isSpawnClaimV2(value: unknown): value is SpawnClaimV2;
|
|
176
|
+
/**
|
|
177
|
+
* Append-only source of spawn-effect authority. It deliberately records no request
|
|
178
|
+
* input: the opaque identity and raw/canonical structural binding MACs are its
|
|
179
|
+
* only correlators.
|
|
180
|
+
*/
|
|
181
|
+
export declare class SpawnAuthorityStore {
|
|
182
|
+
#private;
|
|
183
|
+
constructor(agentDir: string, brokerIdentityKey: string, options?: SpawnAuthorityStoreOptions);
|
|
184
|
+
get file(): string;
|
|
185
|
+
claims(): readonly SpawnClaimV2[];
|
|
186
|
+
claim(lifecycleIdentity: string): SpawnClaimV2 | undefined;
|
|
187
|
+
authority(lifecycleIdentity: string): SpawnAuthorityV1 | undefined;
|
|
188
|
+
open(): Promise<void>;
|
|
189
|
+
claimOrJoin(lifecycleIdentity: string, bindingMac: string | undefined, requestBindingMac?: string | undefined): Promise<SpawnClaimDecision>;
|
|
190
|
+
/**
|
|
191
|
+
* Fsyncs one allowlisted state edge. Callers cannot patch claims in place,
|
|
192
|
+
* which prevents a retry from downgrading a handoff-capable state.
|
|
193
|
+
*/
|
|
194
|
+
persistTransition(lifecycleIdentity: string, transition: SpawnClaimTransition): Promise<SpawnAuthorityTransitionResult>;
|
|
195
|
+
/** Persists only an exact authority lifecycle update, never a proof replacement. */
|
|
196
|
+
persistAuthority(lifecycleIdentity: string, authority: SpawnAuthorityV1): Promise<SpawnAuthorityTransitionResult>;
|
|
197
|
+
/** Records an observed Q26 status without reopening or changing a state edge. */
|
|
198
|
+
persistSeedObservation(lifecycleIdentity: string, seed: SeedDeliveryV2): Promise<SpawnAuthorityTransitionResult>;
|
|
199
|
+
releaseOwner(lifecycleIdentity: string): Promise<void>;
|
|
200
|
+
}
|
|
201
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type ManagedTmuxLaunchProof } from "../../gjc-runtime/tmux-sessions";
|
|
2
|
+
import type { SpawnSubstrateLaunchSpec, SpawnSubstrateProvider } from "./spawn-authority";
|
|
3
|
+
export type SpawnMultiplexerSelection = "none" | "tmux" | "psmux" | "proof_failed";
|
|
4
|
+
export interface SpawnHeadlessProcess {
|
|
5
|
+
pid: number;
|
|
6
|
+
terminate(): void;
|
|
7
|
+
}
|
|
8
|
+
export interface SpawnSubstrateProviderDependencies {
|
|
9
|
+
platform?: NodeJS.Platform;
|
|
10
|
+
env?: NodeJS.ProcessEnv;
|
|
11
|
+
/** @internal Test seam for deterministic provider selection. */
|
|
12
|
+
selectMultiplexer?: () => SpawnMultiplexerSelection;
|
|
13
|
+
/** @internal Test seam for the managed multiplexer command layer. */
|
|
14
|
+
launchManaged?: (spec: SpawnSubstrateLaunchSpec, env: NodeJS.ProcessEnv, platform: NodeJS.Platform) => ManagedTmuxLaunchProof;
|
|
15
|
+
verifyManaged?: (proof: ManagedTmuxLaunchProof, env: NodeJS.ProcessEnv) => "verified" | "mismatch" | "gone";
|
|
16
|
+
closeManaged?: (proof: ManagedTmuxLaunchProof, env: NodeJS.ProcessEnv) => Promise<void>;
|
|
17
|
+
processIncarnation?: (pid: number) => string | undefined;
|
|
18
|
+
startHeadless?: (spec: SpawnSubstrateLaunchSpec, env: NodeJS.ProcessEnv) => SpawnHeadlessProcess;
|
|
19
|
+
signalHeadless?: (pid: number, incarnation: string, platform: NodeJS.Platform, signal: "SIGTERM" | "SIGKILL") => boolean;
|
|
20
|
+
isProcessGone?: (pid: number) => boolean;
|
|
21
|
+
/** @internal Test seam for bounded close polling. */
|
|
22
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
23
|
+
/** @internal Test seam for non-secret inherited-environment launch diagnostics. */
|
|
24
|
+
onInheritedEnvironmentDrop?: (names: readonly string[]) => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Provides the Broker's only substrate authority. Every close and replay starts
|
|
28
|
+
* from its durable opaque proof; no PID/name-only operation is exposed.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createSpawnSubstrateProvider(dependencies?: SpawnSubstrateProviderDependencies): SpawnSubstrateProvider;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const SDK_STATE_VERSION = 1;
|
|
2
|
-
export declare const SESSION_INDEX_SNAPSHOT_VERSION =
|
|
2
|
+
export declare const SESSION_INDEX_SNAPSHOT_VERSION = 4;
|
|
3
|
+
export declare const SESSION_INDEX_EVENT_VERSION = 4;
|
|
3
4
|
export declare class UnsupportedStateVersionError extends Error {
|
|
4
5
|
readonly file: string;
|
|
5
6
|
readonly version: number;
|
|
@@ -8,4 +9,6 @@ export declare class UnsupportedStateVersionError extends Error {
|
|
|
8
9
|
constructor(file: string, version: number, maximumSupportedVersion?: number);
|
|
9
10
|
}
|
|
10
11
|
export declare function assertSupportedStateVersion(file: string, value: unknown): void;
|
|
12
|
+
/** Rejects session-index events outside the known legacy and current formats. */
|
|
13
|
+
export declare function assertSupportedSessionIndexEventVersion(file: string, value: unknown): void;
|
|
11
14
|
export declare function assertSupportedSnapshotVersion(file: string, value: unknown): void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which session currently holds a GJC-managed worktree.
|
|
3
|
+
*
|
|
4
|
+
* Both launch paths need this answer and must not disagree about it: the broker
|
|
5
|
+
* refuses a lifecycle launch into an occupied worktree, and the interactive
|
|
6
|
+
* `gjc --worktree` launch refuses for the same reason. Keeping one predicate —
|
|
7
|
+
* and one definition of "still running" — here prevents the two from drifting
|
|
8
|
+
* into different notions of liveness.
|
|
9
|
+
*/
|
|
10
|
+
import type { IndexedSession } from "./session-index";
|
|
11
|
+
export type ProcessObservation = "alive" | "exited" | "uncertain";
|
|
12
|
+
/** Only ESRCH or a changed, readable incarnation proves the owned process exited. */
|
|
13
|
+
export declare function observeProcess(pid: number, expectedIncarnation: string | undefined, readIncarnation?: (pid: number) => string | undefined): ProcessObservation;
|
|
14
|
+
/**
|
|
15
|
+
* The id of a session still occupying `worktreePath`, or null when it is free.
|
|
16
|
+
*
|
|
17
|
+
* `ensureLaunchWorktree` reuses an existing worktree without asking whether
|
|
18
|
+
* anyone is in it, and an unnamed launch derives its directory deterministically
|
|
19
|
+
* from the repository's current branch. Two concurrent sessions in one
|
|
20
|
+
* repository therefore land in the same checkout and overwrite each other's
|
|
21
|
+
* files with no error.
|
|
22
|
+
*
|
|
23
|
+
* Only a process observed as definitively exited releases the worktree.
|
|
24
|
+
* `uncertain` counts as occupied: refusing a launch is recoverable by picking
|
|
25
|
+
* another worktree name, whereas two live sessions sharing a checkout corrupts
|
|
26
|
+
* work already done.
|
|
27
|
+
*/
|
|
28
|
+
export declare function worktreeOccupant(sessions: readonly IndexedSession[], worktreePath: string, observe?: (pid: number, expectedIncarnation: string | undefined) => ProcessObservation): string | null;
|
|
@@ -102,6 +102,9 @@ export type ChatDaemonAction = "stop" | "reload";
|
|
|
102
102
|
* session-index lock every 2s; staleness retirement moved to a 30s sweep and
|
|
103
103
|
* lease heartbeats no longer force an authority reconcile. A pre-upgrade owner
|
|
104
104
|
* would retain the old hot polling loop, so replacement is required.
|
|
105
|
+
* Discord generation 72 / Slack generation 75 serialize same-generation
|
|
106
|
+
* successor attachment admission behind predecessor provider retirement, so a
|
|
107
|
+
* pre-upgrade owner cannot retain the queue race fixed by #5120.
|
|
105
108
|
*/
|
|
106
109
|
export declare const CHAT_DAEMON_GENERATIONS: Readonly<Record<ChatDaemonKind, number>>;
|
|
107
110
|
export declare function chatDaemonGeneration(kind: ChatDaemonKind): number;
|
|
@@ -599,6 +599,12 @@ export declare function createNotificationsExtension(api: ExtensionAPI, options?
|
|
|
599
599
|
controller?: NotificationSessionController;
|
|
600
600
|
/** Whether this host mode can own the root SDK endpoint. Default: true. */
|
|
601
601
|
sdkHostModeSupported?: boolean;
|
|
602
|
+
/** In-memory master capability for private broker verification only. */
|
|
603
|
+
masterCapability?: string;
|
|
604
|
+
/** Opaque direct-role epoch this effective host may adopt. */
|
|
605
|
+
masterAttestationEpoch?: string;
|
|
606
|
+
/** Stable master lineage identity retained across session switches/branches. */
|
|
607
|
+
masterOwnerSessionId?: string;
|
|
602
608
|
onSdkRequest?: (kind: "control" | "query", connectionId: string, frame: Record<string, unknown>) => void;
|
|
603
609
|
runBtwTurn?: (question: string, signal: AbortSignal) => Promise<{
|
|
604
610
|
replyText: string;
|
|
@@ -286,7 +286,7 @@ export declare const SDK_LIFECYCLE_ROUTER_PROTOCOL_VERSION = 1;
|
|
|
286
286
|
* killing a session's mirroring after one transient rejection and must be
|
|
287
287
|
* replaced across this upgrade.
|
|
288
288
|
*/
|
|
289
|
-
export declare const DAEMON_GENERATION =
|
|
289
|
+
export declare const DAEMON_GENERATION = 180;
|
|
290
290
|
/**
|
|
291
291
|
* Serving-compatibility boundary for daemon lifecycle requests. Epoch 7
|
|
292
292
|
* requires durable publication receipts and acknowledged attachment dispatch,
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type IndexedSession } from "../broker/session-index";
|
|
2
|
+
export declare class SdkMasterCliError extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly exitCode: 1 | 2;
|
|
5
|
+
constructor(code: string, message: string, exitCode?: 1 | 2);
|
|
6
|
+
}
|
|
7
|
+
export interface SdkSpawnArgs {
|
|
8
|
+
cwd?: string;
|
|
9
|
+
prompt?: string;
|
|
10
|
+
model?: string;
|
|
11
|
+
profile?: string;
|
|
12
|
+
agentDir?: string;
|
|
13
|
+
idempotencyKey?: string;
|
|
14
|
+
json?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** The allowlisted spawn result projection rendered to the operator. */
|
|
17
|
+
export interface SdkSpawnRendered {
|
|
18
|
+
code: string;
|
|
19
|
+
claimId?: string;
|
|
20
|
+
sessionId?: string;
|
|
21
|
+
substrateKind?: string;
|
|
22
|
+
seed?: {
|
|
23
|
+
phase?: string;
|
|
24
|
+
clientRef?: string;
|
|
25
|
+
commandId?: string;
|
|
26
|
+
turnId?: string;
|
|
27
|
+
status?: string;
|
|
28
|
+
};
|
|
29
|
+
idempotencyKey?: string;
|
|
30
|
+
error?: {
|
|
31
|
+
code: string;
|
|
32
|
+
message: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface SdkSpawnDependencies {
|
|
36
|
+
env: Record<string, string | undefined>;
|
|
37
|
+
dispatch: (agentDir: string, input: Record<string, unknown>, idempotencyKey: string) => Promise<unknown>;
|
|
38
|
+
resolveAttestationEpoch: (agentDir: string, ownerSessionId: string) => Promise<string | undefined>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Select the newest retained master attestation for an owner session.
|
|
42
|
+
*
|
|
43
|
+
* `listSessionIdentities()` can retain both the direct-role row and one or
|
|
44
|
+
* more endpoint generations. Its iteration order is a projection detail, not
|
|
45
|
+
* authority ordering, so selecting the first matching row can resurrect an
|
|
46
|
+
* older epoch after a master relaunch. The broker's monotonically increasing
|
|
47
|
+
* `indexSeq` is the authoritative retained ordering.
|
|
48
|
+
*/
|
|
49
|
+
export declare function selectNewestMasterAttestationEpoch(rows: readonly IndexedSession[], ownerSessionId: string): string | undefined;
|
|
50
|
+
/** Projects an arbitrary Broker response onto the allowlisted render shape. */
|
|
51
|
+
export declare function safeSpawnRender(response: unknown): {
|
|
52
|
+
rendered: SdkSpawnRendered;
|
|
53
|
+
exitCode: 0 | 1;
|
|
54
|
+
};
|
|
55
|
+
export declare function renderSpawnTable(rendered: SdkSpawnRendered): string;
|
|
56
|
+
/**
|
|
57
|
+
* Runs one local master spawn. A caller-provided idempotency key replays the
|
|
58
|
+
* matching durable claim; otherwise each invocation receives a fresh key.
|
|
59
|
+
*/
|
|
60
|
+
export declare function runSdkSpawn(args: SdkSpawnArgs, dependencies?: Partial<SdkSpawnDependencies>): Promise<{
|
|
61
|
+
rendered: SdkSpawnRendered;
|
|
62
|
+
exitCode: 0 | 1;
|
|
63
|
+
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Versioned DTO rows for `gjc sdk session` semantic verbs (row DTO
|
|
2
|
+
* Versioned DTO rows for `gjc sdk session` semantic verbs (row DTO v2, DR-12).
|
|
3
3
|
*
|
|
4
4
|
* Every semantic verb renders its output through these rows so machine
|
|
5
5
|
* consumers get one deterministic, versioned envelope per verb. Credentials
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* credentials, and pass-through host payloads are redacted recursively before
|
|
8
8
|
* rendering.
|
|
9
9
|
*/
|
|
10
|
-
export declare const SESSION_ROWS_VERSION =
|
|
10
|
+
export declare const SESSION_ROWS_VERSION = 2;
|
|
11
11
|
export type SdkSessionActivityState = "active" | "idle";
|
|
12
12
|
export interface SdkSessionActivityV1 {
|
|
13
13
|
state: SdkSessionActivityState;
|
|
@@ -16,7 +16,8 @@ export interface SdkSessionActivityV1 {
|
|
|
16
16
|
export interface SdkSessionRowV1 {
|
|
17
17
|
sessionId: string;
|
|
18
18
|
locator: {
|
|
19
|
-
|
|
19
|
+
cwd: string;
|
|
20
|
+
worktreeRoot: string | null;
|
|
20
21
|
stateRoot: string;
|
|
21
22
|
};
|
|
22
23
|
endpointGeneration: number;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { type SdkSearchResultV1, type SdkSearchRowV1 } from "../broker/session-scope";
|
|
2
|
+
import type { SessionLifecycleService } from "../lifecycle/service";
|
|
1
3
|
import { SessionRouter } from "../router";
|
|
2
4
|
import { type SdkSessionRowV1 } from "./rows";
|
|
3
|
-
export type SdkSessionCliAction = "list" | "inspect" | "send" | "status" | "tail" | "retire" | "global" | "raw" | "control" | "query" | "global";
|
|
5
|
+
export type SdkSessionCliAction = "list" | "search" | "inspect" | "send" | "status" | "tail" | "retire" | "global" | "raw" | "control" | "query" | "global";
|
|
4
6
|
export type SdkSessionListScope = "repo" | "cwd" | "worktree" | "all";
|
|
5
7
|
export type SdkSessionCliRawKind = "control" | "query" | "global";
|
|
6
8
|
export interface SdkSessionCliArgs {
|
|
@@ -15,7 +17,6 @@ export interface SdkSessionCliArgs {
|
|
|
15
17
|
jsonInputFile?: string;
|
|
16
18
|
jsonInputStdin?: boolean;
|
|
17
19
|
idempotencyKey?: string;
|
|
18
|
-
scope?: string;
|
|
19
20
|
confirm?: boolean;
|
|
20
21
|
cursor?: string;
|
|
21
22
|
wait?: boolean;
|
|
@@ -24,12 +25,24 @@ export interface SdkSessionCliArgs {
|
|
|
24
25
|
untilIdle?: boolean;
|
|
25
26
|
allEvents?: boolean;
|
|
26
27
|
repo?: string;
|
|
28
|
+
scope?: string;
|
|
29
|
+
limit?: number;
|
|
30
|
+
json?: boolean;
|
|
27
31
|
agentDir?: string;
|
|
28
32
|
}
|
|
33
|
+
type JsonRecord = Record<string, unknown>;
|
|
29
34
|
export interface RetainedTranscriptTailReader {
|
|
30
35
|
readonly size: number;
|
|
31
36
|
readRange(start: number, end: number): Promise<Uint8Array>;
|
|
32
37
|
}
|
|
38
|
+
export declare function mergeProbedSearchRows(rows: readonly SdkSearchRowV1[], probedRows: readonly SdkSearchRowV1[]): readonly SdkSearchRowV1[];
|
|
39
|
+
/** Resolves, lists, and probes only the exact rows selected by the Broker-scoped search. */
|
|
40
|
+
export declare function runSdkSearch(args: Pick<SdkSessionCliArgs, "agentDir" | "repo" | "scope" | "limit" | "cursor">, createService?: (agentDir: string) => SessionLifecycleService, probe?: (agentDir: string, result: SdkSearchResultV1) => Promise<SdkSearchResultV1>): Promise<{
|
|
41
|
+
result: SdkSearchResultV1;
|
|
42
|
+
exitCode: 0 | 1;
|
|
43
|
+
}>;
|
|
44
|
+
/** Renders a credential-free scope/status preamble and bounded search table. */
|
|
45
|
+
export declare function renderSdkSearchTable(result: SdkSearchResultV1): string;
|
|
33
46
|
interface WorkspaceIdentity {
|
|
34
47
|
/** Canonical workspace path (realpath when it exists, lexical resolve otherwise). */
|
|
35
48
|
canonicalPath: string;
|
|
@@ -69,6 +82,9 @@ export declare function filterSessionRowsByScope(rows: readonly SdkSessionRowV1[
|
|
|
69
82
|
}>;
|
|
70
83
|
/** Creates a lowercase ULID operation reference for prompt reconciliation. */
|
|
71
84
|
export declare function createOperationRef(now?: number): string;
|
|
85
|
+
/** Builds the public CLI control envelope without leaking envelope fields into operation input. */
|
|
86
|
+
export declare function controlRequestFrame(operation: string, input: JsonRecord, args: Pick<SdkSessionCliArgs, "confirm" | "idempotencyKey">): JsonRecord;
|
|
87
|
+
export declare function operatorAbortBrokerRequest(sessionId: string, operation: string, input: JsonRecord, args: Pick<SdkSessionCliArgs, "confirm" | "idempotencyKey">): JsonRecord | undefined;
|
|
72
88
|
/** Exported for tests: each status poll must stay inside the caller's wait window. */
|
|
73
89
|
export declare function waitForTerminalStatus(router: SessionRouter, sessionId: string, clientRef: string, timeoutMs: number | undefined): Promise<{
|
|
74
90
|
terminal: boolean;
|
|
@@ -90,12 +90,13 @@ export interface SdkDispatchContext {
|
|
|
90
90
|
readonly connectionId: string | undefined;
|
|
91
91
|
readonly generation: number;
|
|
92
92
|
}
|
|
93
|
-
/** Request identity retained after an uncertain send
|
|
93
|
+
/** Request identity retained after an uncertain send. */
|
|
94
94
|
export interface SdkSentRecord {
|
|
95
95
|
readonly id: string;
|
|
96
96
|
readonly operation?: string;
|
|
97
97
|
readonly idempotencyKey?: string;
|
|
98
|
-
|
|
98
|
+
/** Present for lifecycle lookups; `session.spawn` replays through its idempotency key. */
|
|
99
|
+
readonly fingerprint?: string;
|
|
99
100
|
}
|
|
100
101
|
export type SdkFrameHandler = (frame: SdkFrame) => void;
|
|
101
102
|
export type SdkReconnectHandler = () => void;
|
|
@@ -31,5 +31,15 @@ export declare class BusyError extends TypedControlError {
|
|
|
31
31
|
constructor(message?: string);
|
|
32
32
|
}
|
|
33
33
|
export declare function controlRequestFromFrame(frame: Record<string, unknown>): ControlRequest;
|
|
34
|
+
export interface TerminalAbortIdentity {
|
|
35
|
+
input: {
|
|
36
|
+
mode: "terminal";
|
|
37
|
+
scope: "turn" | "owned";
|
|
38
|
+
operator?: true;
|
|
39
|
+
};
|
|
40
|
+
inputHash: string;
|
|
41
|
+
}
|
|
42
|
+
/** One strict, capability-free identity shared by dispatch, durable admission, and delivery observation. */
|
|
43
|
+
export declare function terminalAbortIdentity(input: unknown, operatorAuthorized: boolean): TerminalAbortIdentity | undefined;
|
|
34
44
|
/** Dispatches a registry-defined per-session control operation. */
|
|
35
45
|
export declare function dispatchControl(surface: ControlSurface, registryRow: Operation | undefined, request: ControlRequest): Promise<ControlResponse>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { BusyError, type ControlError, type ControlErrorCode, type ControlRequest, type ControlResponse, controlRequestFromFrame, dispatchControl, TypedControlError, } from "./dispatch";
|
|
1
|
+
export { BusyError, type ControlError, type ControlErrorCode, type ControlRequest, type ControlResponse, controlRequestFromFrame, dispatchControl, type TerminalAbortIdentity, TypedControlError, terminalAbortIdentity, } from "./dispatch";
|
|
2
2
|
export type { AbortScope, ControlInput, ControlSurface, ControlValue } from "./operations";
|
|
@@ -10,6 +10,8 @@ export type AbortScope = "turn" | "owned";
|
|
|
10
10
|
export interface TerminalAbortInput {
|
|
11
11
|
mode: "terminal";
|
|
12
12
|
scope?: AbortScope;
|
|
13
|
+
/** Broker-authorized local override; public SDK callers cannot grant this authority. */
|
|
14
|
+
operator?: boolean;
|
|
13
15
|
}
|
|
14
16
|
export type ControlInput = Record<string, unknown>;
|
|
15
17
|
/**
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Private
|
|
2
|
+
* Private fields carried only on Broker-authorized endpoint controls.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* never published in endpoint discovery or lifecycle service results;
|
|
6
|
-
* that do not hold the Broker's indexed lifecycle record cannot satisfy
|
|
7
|
-
* gate.
|
|
4
|
+
* Their values are lifecycle effect markers bound to the serving process. They
|
|
5
|
+
* are never published in endpoint discovery or lifecycle service results;
|
|
6
|
+
* callers that do not hold the Broker's indexed lifecycle record cannot satisfy
|
|
7
|
+
* either gate.
|
|
8
8
|
*/
|
|
9
9
|
export declare const BROKER_RUNTIME_CLOSE_CAPABILITY_FIELD = "__gjcBrokerCloseCapability";
|
|
10
|
+
/** Private field carried only on the Broker-authorized terminal-abort request. */
|
|
11
|
+
export declare const BROKER_RUNTIME_ABORT_CAPABILITY_FIELD = "__gjcBrokerAbortCapability";
|
|
10
12
|
export declare function brokerRuntimeCloseCapability(input: unknown): string | undefined;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
export declare function brokerRuntimeAbortCapability(input: unknown): string | undefined;
|
|
14
|
+
/** Remove private Broker capabilities before a request is exposed to diagnostics. */
|
|
15
|
+
export declare function redactBrokerRuntimeCapabilities(frame: Record<string, unknown>): Record<string, unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* Strips caller content from a request frame before it reaches a diagnostic
|
|
18
|
+
* observer. Known protocol operation names and finite enum values survive so
|
|
19
|
+
* instrumentation stays useful; caller-chosen ids and all other values are
|
|
20
|
+
* redacted, including nested objects, so a field this module has never heard
|
|
21
|
+
* of cannot leak.
|
|
22
|
+
*/
|
|
23
|
+
export declare function redactObservedRequestContent(frame: Record<string, unknown>): Record<string, unknown>;
|
|
13
24
|
/**
|
|
14
25
|
* Runtime-local authority check for the Broker-only graceful close executor.
|
|
15
26
|
*
|
|
@@ -17,3 +28,6 @@ export declare function redactBrokerRuntimeCloseCapability(frame: Record<string,
|
|
|
17
28
|
* environment. Generic SDK requests never receive that private marker.
|
|
18
29
|
*/
|
|
19
30
|
export declare function hasBrokerRuntimeCloseCapability(input: unknown): boolean;
|
|
31
|
+
/** Test-only override for the abort gate; production authority remains process-local. */
|
|
32
|
+
export declare function setBrokerRuntimeAbortCapabilityForTest(capability: string | undefined): void;
|
|
33
|
+
export declare function hasBrokerRuntimeAbortCapability(input: unknown): boolean;
|
|
@@ -64,6 +64,16 @@ export interface SessionSdkHostOptions extends HostEndpointAdapters {
|
|
|
64
64
|
* that fails is never read as authorization.
|
|
65
65
|
*/
|
|
66
66
|
activationGate?: SessionActivationGate;
|
|
67
|
+
/** Private one-shot master-capability verification; never durable or public SDK surface. */
|
|
68
|
+
masterCapabilityVerify?: (frame: {
|
|
69
|
+
nonce: unknown;
|
|
70
|
+
attestationEpoch: unknown;
|
|
71
|
+
capability: unknown;
|
|
72
|
+
}) => {
|
|
73
|
+
ok: boolean;
|
|
74
|
+
nonce: string;
|
|
75
|
+
attestationEpoch: string;
|
|
76
|
+
};
|
|
67
77
|
}
|
|
68
78
|
/** Shared by the replay filter and transport live broadcasts: a connection
|
|
69
79
|
* must see the same capability-gated event kinds on both legs, or live and
|
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
import { type Settings } from "../../config/settings";
|
|
2
2
|
import type { ExtensionAPI, ExtensionContext } from "../../extensibility/extensions";
|
|
3
|
+
import { type MasterRoleAttestationV2, SessionIndex, type SessionLocatorV2 } from "../broker/session-index";
|
|
3
4
|
import { type TurnResultContent } from "../turn-result";
|
|
4
5
|
import { SessionSdkHost, type SessionSdkHostOptions } from "./host";
|
|
5
6
|
import { type SessionSurface } from "./query";
|
|
6
7
|
import { type SdkCapabilities, type SdkSurfacePolicy } from "./surface-policy";
|
|
7
8
|
import type { BrokerIndexWriter, SdkFrame } from "./types";
|
|
9
|
+
export type MasterCapabilityReplayState = Map<string, number>;
|
|
10
|
+
export declare function verifyMasterCapabilityFrame(input: {
|
|
11
|
+
frame: {
|
|
12
|
+
nonce: unknown;
|
|
13
|
+
attestationEpoch: unknown;
|
|
14
|
+
capability: unknown;
|
|
15
|
+
};
|
|
16
|
+
expectedCapability: string | undefined;
|
|
17
|
+
expectedEpoch: string | undefined;
|
|
18
|
+
replay: MasterCapabilityReplayState;
|
|
19
|
+
now?: number;
|
|
20
|
+
}): {
|
|
21
|
+
ok: boolean;
|
|
22
|
+
nonce: string;
|
|
23
|
+
attestationEpoch: string;
|
|
24
|
+
};
|
|
8
25
|
/** Transport-neutral endpoint contract consumed by the SDK session runtime. */
|
|
9
26
|
export interface SessionSdkTransport {
|
|
10
27
|
readonly sessionId: string;
|
|
@@ -27,6 +44,8 @@ export interface SessionSdkRuntimeOptions extends Omit<SessionSdkHostOptions, "s
|
|
|
27
44
|
settings?: Settings;
|
|
28
45
|
/** Mutable shadow of patched config values merged into query readback. */
|
|
29
46
|
configOverrides?: Map<string, unknown>;
|
|
47
|
+
/** Stable master lineage identity retained across session switches/branches. */
|
|
48
|
+
masterOwnerSessionId?: string;
|
|
30
49
|
}
|
|
31
50
|
export interface SdkOnlyInvocationRecord extends InvocationCorrelation {
|
|
32
51
|
kind: InvocationKind | "terminal" | "steer";
|
|
@@ -161,6 +180,8 @@ export interface CreateSdkSessionRuntimeOptions {
|
|
|
161
180
|
agentDir: string;
|
|
162
181
|
/** Lifecycle-owned sessions require broker publication before they become usable. */
|
|
163
182
|
brokerRegistrationRequired?: boolean;
|
|
183
|
+
/** Trusted broker-issued lifecycle marker bound to lifecycle host index events. */
|
|
184
|
+
lifecycleRequestId?: string;
|
|
164
185
|
createTransport(input: {
|
|
165
186
|
sessionId: string;
|
|
166
187
|
stateRoot: string;
|
|
@@ -172,6 +193,12 @@ export interface CreateSdkSessionRuntimeOptions {
|
|
|
172
193
|
onSdkRequest?: SessionSdkHostOptions["onRequest"];
|
|
173
194
|
/** Mutable shadow of patched config values merged into query readback. */
|
|
174
195
|
configOverrides?: Map<string, unknown>;
|
|
196
|
+
/** In-memory master capability for private broker verification only. */
|
|
197
|
+
masterCapability?: string;
|
|
198
|
+
/** Opaque direct-role epoch this effective host may adopt. */
|
|
199
|
+
masterAttestationEpoch?: string;
|
|
200
|
+
/** Stable master lineage identity retained across session switches/branches. */
|
|
201
|
+
masterOwnerSessionId?: string;
|
|
175
202
|
/** Private session-owned terminal-abort capabilities; never exposed on ExtensionContext. */
|
|
176
203
|
terminalAbortSeams?: SdkOnlyTerminalAbortSeams;
|
|
177
204
|
/** Callback when a frame is admitted to the runtime (test harness). */
|
|
@@ -293,6 +320,31 @@ export declare function createSdkSurfaceFactory(options: SdkSurfaceFactoryOption
|
|
|
293
320
|
}): SdkSurfaceFactory;
|
|
294
321
|
/** Register the default-session notification command without loading notification adapters. */
|
|
295
322
|
export declare function registerSdkOnlyNotificationCommand(api: ExtensionAPI): void;
|
|
323
|
+
export declare function masterAttestationForEffectiveHost(input: {
|
|
324
|
+
masterCapability: string | undefined;
|
|
325
|
+
attestationEpoch: string | undefined;
|
|
326
|
+
ownerSessionId?: string;
|
|
327
|
+
sessionId: string;
|
|
328
|
+
pid: number;
|
|
329
|
+
processIncarnation: string | undefined;
|
|
330
|
+
direct: MasterRoleAttestationV2 | undefined;
|
|
331
|
+
}): MasterRoleAttestationV2 | undefined;
|
|
332
|
+
/**
|
|
333
|
+
* Establish direct master authority for the session currently hosted by this
|
|
334
|
+
* process. Session identity transitions retain the master capability and epoch
|
|
335
|
+
* but require a new direct attestation before their effective endpoint can
|
|
336
|
+
* adopt that authority.
|
|
337
|
+
*/
|
|
338
|
+
export declare function reattestMasterSessionIdentity(input: {
|
|
339
|
+
index: SessionIndex;
|
|
340
|
+
locator: SessionLocatorV2;
|
|
341
|
+
masterCapability: string | undefined;
|
|
342
|
+
attestationEpoch: string | undefined;
|
|
343
|
+
ownerSessionId?: string;
|
|
344
|
+
sessionId: string;
|
|
345
|
+
pid: number;
|
|
346
|
+
processIncarnation: string | undefined;
|
|
347
|
+
}): Promise<MasterRoleAttestationV2 | undefined>;
|
|
296
348
|
/** Install a complete SDK host for a session when notifications are inactive. */
|
|
297
349
|
export declare function createSdkSessionRuntimeExtension(api: ExtensionAPI, options: CreateSdkSessionRuntimeOptions): void;
|
|
298
350
|
export {};
|