@x-otto/service 0.1.0-alpha.43 → 0.3.0-beta.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/dist/ask-host.d.ts +18 -0
- package/dist/ask-validate.d.ts +47 -0
- package/dist/attached-writers.d.ts +9 -0
- package/dist/authorize.d.ts +8 -0
- package/dist/chat-routes.d.ts +4 -0
- package/dist/client-entry.d.ts +114 -0
- package/dist/client-entry.js +1414 -0
- package/dist/connection-binding.d.ts +9 -0
- package/dist/context.d.ts +51 -0
- package/dist/credential.d.ts +51 -0
- package/dist/errors.d.ts +11 -0
- package/dist/events.d.ts +21 -0
- package/dist/extension-approval.d.ts +41 -0
- package/dist/extension-rpc.d.ts +31 -0
- package/dist/fanout.d.ts +13 -0
- package/dist/handler-options.d.ts +252 -0
- package/dist/handlers.d.ts +23 -0
- package/dist/hub-capabilities.d.ts +15 -0
- package/dist/index.d.ts +1144 -624
- package/dist/index.js +8591 -43
- package/dist/methods.d.ts +5 -0
- package/dist/mock.d.ts +23 -0
- package/dist/resource-read.d.ts +4 -0
- package/dist/route-read-only.d.ts +1 -0
- package/dist/route-set.d.ts +22 -0
- package/dist/route-targets.d.ts +6 -0
- package/dist/route-validate.d.ts +15 -0
- package/dist/routes/ask-routes.d.ts +3 -0
- package/dist/routes/auth-routes.d.ts +3 -0
- package/dist/routes/core-routes.d.ts +3 -0
- package/dist/routes/extension-routes.d.ts +3 -0
- package/dist/routes/index.d.ts +6 -0
- package/dist/routes/plugin-routes.d.ts +3 -0
- package/dist/routes/repository-meta.d.ts +2 -0
- package/dist/routes/session-routes.d.ts +3 -0
- package/dist/routes/session-runtime-routes.d.ts +5 -0
- package/dist/routes/settings-routes.d.ts +3 -0
- package/dist/routes/support.d.ts +7 -0
- package/dist/routes/worker-routes.d.ts +2 -0
- package/dist/routes/workspace-routes.d.ts +3 -0
- package/dist/send-attempt-table.d.ts +35 -0
- package/dist/serialize-shared.d.ts +1 -0
- package/dist/source-for-session.d.ts +4 -0
- package/dist/subscription-backfill.d.ts +19 -0
- package/dist/target-extractors.d.ts +18 -0
- package/dist/token-verifier.d.ts +12 -0
- package/dist/vite.d.ts +11 -0
- package/dist/vite.js +4273 -0
- package/dist/web-host.d.ts +52 -0
- package/dist/wire-stats.d.ts +6 -0
- package/dist/wire.d.ts +12 -0
- package/dist/ws.d.ts +66 -0
- package/package.json +19 -31
- package/README.md +0 -135
package/dist/index.d.ts
CHANGED
|
@@ -1,656 +1,1176 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import * as _$_x_otto_kernel0 from "@x-otto/kernel";
|
|
2
|
+
import { ApprovalChannelPort, ApprovalDecision, ApprovalRequest, ApprovalRequestInput, AskClient, AskConnection, AskConnection as AskConnection$1, AskDescendantSummary, AskInvalidationReason, AskInvalidationReason as AskInvalidationReason$1, AskOutcome, AskPeer, AskPeer as AskPeer$1, AskReceipt, AskRef, AskRef as AskRef$1, AskRespond, AskRespond as AskRespond$1, AskScope, AskScope as AskScope$1, AskSubscription, AskSubscription as AskSubscription$1, AskViewMessage, AskViewMessage as AskViewMessage$1, AskWireFrame, AssemblyDiagnostic, EnvSnapshotRuntime, ExtensionCallerOrigin, ExtensionClientFrame, ExtensionRpcAccess, ExtensionRpcAttachmentHost, ExtensionRpcCatalogPort, ExtensionRpcLimits, ExtensionWirePayload, ExtensionWireRequest, HitlAnswer, HitlAnswer as HitlAnswer$1, HitlAskRequest, HitlAskRequest as HitlAskRequest$1, HitlReply, HitlReply as HitlReply$1, PendingAsk, PerformanceDiagnosticsSnapshot, PermissionAskRef, PermissionAskRef as PermissionAskRef$1, PermissionAskRequest, PermissionAskRequest as PermissionAskRequest$1, PermissionAskResponse, PermissionAskResponse as PermissionAskResponse$1, PermissionMode, RateLimitInfo, ResourceReadResult, RuntimeAskChannels, RuntimeAskChannels as RuntimeAskChannels$1, RuntimeDiagnosticInput, ServiceClientContract, ServiceEvent, ServiceEvent as ServiceEvent$1, ServiceMethod, ServiceMethodInput, ServiceMethodOutput, ServiceSource, ServiceSource as ServiceSource$1, SessionEntry, SessionPinApplied, SessionPinMode, SessionPinOutcome, SessionPinRejected, SessionPinResult, SessionPrepareResult, SessionRepository, SessionRestoreResult, SettingDescribeEntry, SettingFileScope, SettingWriteResult, StreamErrorKind, TrajectoryEvent, WireRequest, WireResponse, WorkspaceKey, WorkspaceReadiness } from "@x-otto/kernel";
|
|
3
|
+
import { PendingAskStore, PendingAskStore as PendingAskStore$1, createFilePendingAskStore } from "@x-otto/ask";
|
|
4
|
+
import { Hono } from "hono";
|
|
5
5
|
import { IncomingMessage, Server } from "node:http";
|
|
6
|
-
import {
|
|
7
|
-
import { AgentSession, ServiceHostPort } from "@x-otto/coding";
|
|
8
|
-
import { Socket } from "node:net";
|
|
9
|
-
import { Devtools, PauseResumePayload } from "@x-otto/devtools";
|
|
6
|
+
import { Duplex } from "node:stream";
|
|
10
7
|
|
|
11
|
-
//#region src/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
role: string;
|
|
19
|
-
content: string;
|
|
20
|
-
timestamp: number | undefined;
|
|
21
|
-
toolCalls: SerializedToolCall[];
|
|
22
|
-
/**
|
|
23
|
-
* RFC-210 D5(M4,评审 A5 REST 水合缺口修复):消息 content 数组中的 a2ui block
|
|
24
|
-
* 组件树透传(此前 extractContent 只取 text block,a2ui 数据在历史水合路径丢失)。
|
|
25
|
-
* 无 a2ui block 时字段缺省(不占 wire 体积)。web-ui 水合层(message-hydration)按
|
|
26
|
-
* 此字段渲染 React catalog(M5)。
|
|
27
|
-
*/
|
|
28
|
-
a2ui?: unknown[][];
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/types.d.ts
|
|
32
|
-
type WebSocketMessage = {
|
|
33
|
-
type: 'Runtime.connected';
|
|
34
|
-
data: {
|
|
35
|
-
clientId: string;
|
|
36
|
-
};
|
|
37
|
-
} | {
|
|
38
|
-
type: 'Runtime.pong';
|
|
39
|
-
data: {
|
|
40
|
-
timestamp: number;
|
|
41
|
-
};
|
|
42
|
-
} | {
|
|
43
|
-
type: 'Runtime.error';
|
|
44
|
-
data: {
|
|
45
|
-
sessionId?: string;
|
|
8
|
+
//#region src/ask-host.d.ts
|
|
9
|
+
type AskAccessAction = 'observe' | 'answer';
|
|
10
|
+
interface AskHostOptions {
|
|
11
|
+
resolveOwner: (scope: AskScope$1) => RuntimeAskChannels$1 | undefined | Promise<RuntimeAskChannels$1 | undefined>;
|
|
12
|
+
authorize?: (peer: AskPeer$1, scope: AskScope$1, action: AskAccessAction) => boolean | Promise<boolean>;
|
|
13
|
+
diagnose?: (input: {
|
|
14
|
+
code: string;
|
|
46
15
|
message: string;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
16
|
+
detail?: unknown;
|
|
17
|
+
}) => void;
|
|
18
|
+
}
|
|
19
|
+
interface AskHost {
|
|
20
|
+
connect(peer: AskPeer$1, send: (message: AskViewMessage$1) => void, onInvalidated?: (scope: AskScope$1, reason: AskInvalidationReason$1) => void): AskConnection$1;
|
|
21
|
+
invalidate(predicate: (peer: AskPeer$1, scope: AskScope$1) => boolean, reason: AskInvalidationReason$1): void;
|
|
22
|
+
revoke(peer: AskPeer$1, scope: AskScope$1, reason: AskInvalidationReason$1): boolean;
|
|
23
|
+
dispose(): void;
|
|
24
|
+
}
|
|
25
|
+
declare function createAskHost(options: AskHostOptions): AskHost;
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/events.d.ts
|
|
28
|
+
type BroadcastEvent = ServiceEvent$1 extends infer Event ? Event extends {
|
|
29
|
+
sessionId: string;
|
|
30
|
+
} ? Omit<Event, 'sessionId'> : never : never;
|
|
31
|
+
interface EventRelay {
|
|
32
|
+
push(sessionId: string, event: ServiceEvent$1): void;
|
|
33
|
+
subscribe(sessionId: string, handler: (event: ServiceEvent$1) => void): () => void;
|
|
34
|
+
sessionCount(): number;
|
|
35
|
+
broadcast(event: BroadcastEvent): void;
|
|
36
|
+
}
|
|
37
|
+
declare const GLOBAL_EVENTS_CHANNEL = "__global__";
|
|
38
|
+
declare function createEventRelay(): EventRelay;
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/target-extractors.d.ts
|
|
41
|
+
interface RouteTarget {
|
|
42
|
+
sessionId?: string;
|
|
43
|
+
workspaceKey?: string;
|
|
44
|
+
epoch?: string;
|
|
45
|
+
global?: true;
|
|
46
|
+
}
|
|
47
|
+
type TargetExtractor = (payload: unknown) => RouteTarget;
|
|
48
|
+
declare const globalTarget: TargetExtractor;
|
|
49
|
+
declare const bySession: TargetExtractor;
|
|
50
|
+
declare const byWorkspace: TargetExtractor;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/credential.d.ts
|
|
53
|
+
type TicketMode = 'read' | 'write';
|
|
54
|
+
interface TicketClaims {
|
|
55
|
+
mode: TicketMode;
|
|
56
|
+
sessionId?: string;
|
|
57
|
+
methods?: readonly ServiceMethod[];
|
|
58
|
+
events?: readonly string[];
|
|
59
|
+
clientId?: string;
|
|
60
|
+
}
|
|
61
|
+
type Credential = {
|
|
62
|
+
kind: 'owner';
|
|
50
63
|
} | {
|
|
51
|
-
|
|
52
|
-
data: {
|
|
53
|
-
sessionId: string;
|
|
54
|
-
state: 'acquired' | 'denied' | 'released' | 'not-held';
|
|
55
|
-
reason?: string; /** 当前持有者 clientId(acquired/denied/not-held 都为非空——语义否定据以下判定);released 则为 undefined */
|
|
56
|
-
leaseOwner?: string;
|
|
57
|
-
};
|
|
64
|
+
kind: 'reader';
|
|
58
65
|
} | {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
kind: 'ticket';
|
|
67
|
+
claims: TicketClaims;
|
|
68
|
+
};
|
|
69
|
+
type CredentialDenial = 'method-not-granted' | 'not-a-read' | 'cross-session';
|
|
70
|
+
declare const TICKET_READ_METHODS: readonly ServiceMethod[];
|
|
71
|
+
interface CredentialFacts {
|
|
72
|
+
source: PrincipalSource;
|
|
73
|
+
follow?: boolean;
|
|
74
|
+
sessionToken?: boolean;
|
|
75
|
+
sessionId?: string;
|
|
76
|
+
}
|
|
77
|
+
interface CredentialDecisionInput {
|
|
78
|
+
credential: Credential;
|
|
79
|
+
method: ServiceMethod;
|
|
80
|
+
readOnly: boolean;
|
|
81
|
+
payload: unknown;
|
|
82
|
+
target: RouteTarget | undefined;
|
|
83
|
+
}
|
|
84
|
+
interface WorkspaceScopeOptions {
|
|
85
|
+
tokenWorkspaceScope?: readonly string[] | '*';
|
|
86
|
+
readTokenWorkspaceScope?: readonly string[] | '*' | (() => readonly string[] | undefined);
|
|
87
|
+
}
|
|
88
|
+
declare function credentialDenialOf(input: CredentialDecisionInput): CredentialDenial | undefined;
|
|
89
|
+
declare function credentialWorkspaceScope(credential: Credential, options: WorkspaceScopeOptions): readonly string[] | '*' | undefined;
|
|
90
|
+
declare function credentialFromFacts(facts: CredentialFacts): Credential;
|
|
91
|
+
declare function credentialOf(context: {
|
|
92
|
+
credential?: Credential;
|
|
93
|
+
principal?: {
|
|
94
|
+
source?: PrincipalSource;
|
|
95
|
+
sessionToken?: boolean;
|
|
96
|
+
sessionId?: string;
|
|
62
97
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
98
|
+
follow?: boolean;
|
|
99
|
+
}): Credential;
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/context.d.ts
|
|
102
|
+
type RequestTransport = 'http' | 'ws' | 'in-process';
|
|
103
|
+
type PrincipalSource = 'token' | 'local' | 'anonymous';
|
|
104
|
+
interface Principal {
|
|
105
|
+
id: string;
|
|
106
|
+
tokenId?: string;
|
|
107
|
+
source: PrincipalSource;
|
|
108
|
+
sessionToken?: true;
|
|
109
|
+
sessionId?: string;
|
|
110
|
+
}
|
|
111
|
+
interface RequestContext {
|
|
112
|
+
principalId: string;
|
|
113
|
+
principal: Principal;
|
|
114
|
+
credential: Credential;
|
|
115
|
+
clientId: string;
|
|
116
|
+
transport: RequestTransport;
|
|
117
|
+
connectionId?: string;
|
|
118
|
+
remoteAddr?: string;
|
|
119
|
+
tokenId?: string;
|
|
120
|
+
workspaceScope?: readonly string[] | '*';
|
|
121
|
+
clientFeatures?: readonly string[];
|
|
122
|
+
follow?: boolean;
|
|
123
|
+
}
|
|
124
|
+
declare const ANONYMOUS_LOCAL_CONTEXT: RequestContext;
|
|
125
|
+
declare function contextWithClientId(clientId: string | undefined): RequestContext;
|
|
126
|
+
interface PrincipalOptions {
|
|
127
|
+
principalId?: string;
|
|
128
|
+
transport?: RequestTransport;
|
|
129
|
+
sessionToken?: boolean;
|
|
130
|
+
sessionId?: string;
|
|
131
|
+
clientFeatures?: readonly string[];
|
|
132
|
+
}
|
|
133
|
+
declare function tokenFingerprint(token: string): string;
|
|
134
|
+
declare function principalFromToken(token: string | undefined, options?: PrincipalOptions): Principal;
|
|
135
|
+
interface ContextFromTokenOptions {
|
|
136
|
+
principalId?: string;
|
|
137
|
+
clientId?: string;
|
|
138
|
+
transport?: RequestTransport;
|
|
139
|
+
connectionId?: string;
|
|
140
|
+
remoteAddr?: string;
|
|
141
|
+
tokenId?: string;
|
|
142
|
+
workspaceScope?: readonly string[] | '*';
|
|
143
|
+
sessionToken?: boolean;
|
|
144
|
+
sessionId?: string;
|
|
145
|
+
clientFeatures?: readonly string[];
|
|
146
|
+
follow?: boolean;
|
|
147
|
+
credential?: Credential;
|
|
148
|
+
}
|
|
149
|
+
declare function contextFromToken(token: string | undefined, options?: ContextFromTokenOptions): RequestContext;
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/extension-rpc.d.ts
|
|
152
|
+
interface ExtensionRpcRequest {
|
|
153
|
+
type: string;
|
|
154
|
+
payload: unknown;
|
|
155
|
+
contractVersion?: number;
|
|
156
|
+
}
|
|
157
|
+
interface ExtensionRequestHandlers {
|
|
158
|
+
handleExtension(request: ExtensionRpcRequest, context?: RequestContext, origin?: ExtensionCallerOrigin): Promise<unknown>;
|
|
159
|
+
bindExtension?(peer: AskPeer$1, receive: (frame: ExtensionClientFrame) => void): () => void;
|
|
160
|
+
}
|
|
161
|
+
interface ExtensionHumanProofPort {
|
|
162
|
+
consumeProof(proof: unknown, expected: {
|
|
163
|
+
workspaceKey: string;
|
|
164
|
+
method: string;
|
|
165
|
+
contractVersion: number;
|
|
166
|
+
action: string;
|
|
167
|
+
subject: string;
|
|
168
|
+
}): boolean;
|
|
169
|
+
}
|
|
170
|
+
interface ExtensionRpcDispatcherOptions {
|
|
171
|
+
reservedMethods?: ReadonlySet<string>;
|
|
172
|
+
origin?: ExtensionCallerOrigin;
|
|
173
|
+
limits?: Partial<ExtensionRpcLimits>;
|
|
174
|
+
proofs?: ExtensionHumanProofPort;
|
|
175
|
+
catalogOf(workspaceKey: string): ExtensionRpcCatalogPort | undefined;
|
|
176
|
+
}
|
|
177
|
+
declare const EXTENSION_RESERVED_METHODS: ReadonlySet<string>;
|
|
178
|
+
declare function createExtensionRpcDispatcher(options: ExtensionRpcDispatcherOptions): ExtensionRequestHandlers;
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/extension-approval.d.ts
|
|
181
|
+
interface ExtensionApprovalChannel {
|
|
182
|
+
request(input: ApprovalRequestInput): Promise<ApprovalDecision>;
|
|
183
|
+
pending?(): readonly ApprovalRequest[];
|
|
184
|
+
resolve?(nonce: string, decision: ApprovalDecision): boolean;
|
|
185
|
+
subscribe?(listener: () => void): () => void;
|
|
186
|
+
extensionApprovalNonce?(nonce: string): boolean;
|
|
187
|
+
}
|
|
188
|
+
interface ExtensionApprovalPending {
|
|
189
|
+
nonce: string;
|
|
190
|
+
workspaceKey: string;
|
|
191
|
+
method: string;
|
|
192
|
+
contractVersion: number;
|
|
193
|
+
action: string;
|
|
194
|
+
subject: string;
|
|
195
|
+
createdAt: string;
|
|
196
|
+
summary?: string;
|
|
197
|
+
}
|
|
198
|
+
interface ExtensionApprovalResponder {
|
|
199
|
+
pending(workspaceKey?: string): readonly ExtensionApprovalPending[];
|
|
200
|
+
subscribe(listener: () => void): () => void;
|
|
201
|
+
resolve(input: {
|
|
202
|
+
workspaceKey: string;
|
|
203
|
+
nonce: string;
|
|
204
|
+
decision: 'allow' | 'deny';
|
|
205
|
+
}): boolean;
|
|
206
|
+
}
|
|
207
|
+
interface ExtensionApprovalHandlers extends ExtensionRequestHandlers, ExtensionHumanProofPort {
|
|
208
|
+
responder: ExtensionApprovalResponder;
|
|
209
|
+
}
|
|
210
|
+
interface ExtensionApprovalOptions {
|
|
211
|
+
ttlMs?: number;
|
|
212
|
+
limits?: Partial<ExtensionRpcLimits>;
|
|
213
|
+
now?(): number;
|
|
214
|
+
randomId?(): string;
|
|
215
|
+
channelOf(workspaceKey: string): ExtensionApprovalChannel | undefined;
|
|
216
|
+
catalogOf(workspaceKey: string): ExtensionRpcCatalogPort | undefined;
|
|
217
|
+
}
|
|
218
|
+
declare function createExtensionApprovalHandlers(options: ExtensionApprovalOptions): ExtensionApprovalHandlers;
|
|
219
|
+
declare function createExtensionApprovalChannel(base: ExtensionApprovalChannel | undefined, responder: ExtensionApprovalResponder): ExtensionApprovalChannel;
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/route-set.d.ts
|
|
222
|
+
interface RouteMethodMeta {
|
|
223
|
+
readOnly: boolean;
|
|
224
|
+
target: TargetExtractor;
|
|
225
|
+
}
|
|
226
|
+
interface RouteSetEntry {
|
|
227
|
+
method: string;
|
|
228
|
+
meta: RouteMethodMeta;
|
|
229
|
+
handle: (payload: never, context: RequestContext) => Promise<unknown>;
|
|
230
|
+
}
|
|
231
|
+
interface RouteSet {
|
|
232
|
+
owner: string;
|
|
233
|
+
routes: Record<string, RouteSetEntry>;
|
|
234
|
+
}
|
|
235
|
+
declare function route<K extends ServiceMethod>(method: K, readOnly: boolean, target: TargetExtractor, handle: (payload: ServiceMethodInput<K>, context: RequestContext) => Promise<ServiceMethodOutput<K>>): RouteSetEntry;
|
|
236
|
+
declare function defineRoutes(owner: string, routes: Record<string, RouteSetEntry>): RouteSet;
|
|
237
|
+
type ComposedRouteTable = Record<string, RouteSetEntry>;
|
|
238
|
+
declare function composeRoutes(sets: readonly RouteSet[]): ComposedRouteTable;
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/handler-options.d.ts
|
|
241
|
+
type Authorizer = (context: RequestContext, action: ServiceMethod, payload: unknown, target?: RouteTarget) => Promise<void> | void;
|
|
242
|
+
interface AuthServicePort {
|
|
243
|
+
status(): Promise<readonly _$_x_otto_kernel0.AuthStatusEntry[]>;
|
|
244
|
+
login(request: _$_x_otto_kernel0.AuthLoginRequest, owner?: string, options?: {
|
|
245
|
+
async?: boolean;
|
|
246
|
+
}): Promise<_$_x_otto_kernel0.AuthLoginReceipt>;
|
|
247
|
+
loginStatus?(input: {
|
|
248
|
+
loginId: string;
|
|
249
|
+
}, owner?: string): Promise<_$_x_otto_kernel0.AuthLoginStatus | undefined>;
|
|
250
|
+
setKey(input: _$_x_otto_kernel0.LlmAuthSetKeyInput): Promise<{
|
|
251
|
+
status: 'success' | 'failed';
|
|
252
|
+
message?: string;
|
|
253
|
+
accountId?: string;
|
|
254
|
+
}>;
|
|
255
|
+
account?(input: _$_x_otto_kernel0.LlmAuthAccountInput): Promise<_$_x_otto_kernel0.LlmAuthAccountOutput>;
|
|
256
|
+
logout(providerId: string): Promise<{
|
|
257
|
+
loggedOut: boolean;
|
|
258
|
+
}>;
|
|
259
|
+
submitCode?(input: {
|
|
260
|
+
loginId: string;
|
|
261
|
+
code: string;
|
|
262
|
+
}, owner?: string): Promise<{
|
|
263
|
+
accepted: boolean;
|
|
264
|
+
message?: string;
|
|
265
|
+
}>;
|
|
266
|
+
cancel?(loginId: string, owner?: string): Promise<{
|
|
267
|
+
cancelled: boolean;
|
|
268
|
+
}>;
|
|
269
|
+
activeLoginCount?(): number;
|
|
270
|
+
abortAllLogins?(): void;
|
|
271
|
+
}
|
|
272
|
+
interface SettingsServicePort {
|
|
273
|
+
get(key: string): Promise<{
|
|
274
|
+
value?: unknown;
|
|
275
|
+
revision?: number;
|
|
276
|
+
}>;
|
|
277
|
+
getAll(): Promise<{
|
|
278
|
+
values: Record<string, unknown>;
|
|
279
|
+
registrants?: readonly string[];
|
|
280
|
+
}>;
|
|
281
|
+
set(key: string, value: unknown, scope?: SettingFileScope): Promise<SettingWriteResult>;
|
|
282
|
+
subscribe(keys: readonly string[] | undefined): Promise<{
|
|
283
|
+
subscribed: true;
|
|
284
|
+
}>;
|
|
285
|
+
clear?(key: string, scope?: SettingFileScope): Promise<SettingWriteResult>;
|
|
286
|
+
describe?(keys: readonly string[]): Promise<{
|
|
287
|
+
entries: readonly SettingDescribeEntry[];
|
|
288
|
+
}>;
|
|
289
|
+
adoptedPermissionMode?(): PermissionMode | undefined;
|
|
290
|
+
}
|
|
291
|
+
interface SchedulesServicePort {
|
|
292
|
+
list(sessionId: string): Promise<readonly _$_x_otto_kernel0.ScheduleEntryView[]>;
|
|
293
|
+
delete(sessionId: string, id: string): Promise<boolean>;
|
|
294
|
+
runPending?(sessionId: string, id: string): Promise<boolean>;
|
|
295
|
+
dismissPending?(sessionId: string, id: string): Promise<boolean>;
|
|
296
|
+
health?(sessionId: string): Promise<{
|
|
297
|
+
unrecoverablePreTrim: boolean;
|
|
298
|
+
}>;
|
|
299
|
+
}
|
|
300
|
+
interface SpaceCatalogServicePort {
|
|
301
|
+
catalog(): {
|
|
302
|
+
ref: _$_x_otto_kernel0.SpaceRef;
|
|
303
|
+
manifest: _$_x_otto_kernel0.SpaceManifest;
|
|
304
|
+
activated: readonly string[];
|
|
71
305
|
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
306
|
+
}
|
|
307
|
+
interface ProviderFallbackServicePort {
|
|
308
|
+
state(): {
|
|
309
|
+
active: boolean;
|
|
310
|
+
reason?: _$_x_otto_kernel0.ProviderUnavailableReason;
|
|
311
|
+
provider?: string;
|
|
312
|
+
hasEnvKey: boolean;
|
|
78
313
|
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
314
|
+
}
|
|
315
|
+
interface MemoryEntryServicePort {
|
|
316
|
+
list(cwd: string): Promise<readonly _$_x_otto_kernel0.MemoryEntrySummary[]>;
|
|
317
|
+
read(name: string, cwd: string): Promise<string | null>;
|
|
318
|
+
}
|
|
319
|
+
interface ActivationServicePort {
|
|
320
|
+
activation(ids?: readonly string[]): Promise<readonly _$_x_otto_kernel0.ActivationReport[]>;
|
|
321
|
+
}
|
|
322
|
+
interface UpdatesServicePort {
|
|
323
|
+
status(): _$_x_otto_kernel0.UpdateStatus;
|
|
324
|
+
check(options?: {
|
|
325
|
+
force?: boolean;
|
|
326
|
+
}): Promise<readonly _$_x_otto_kernel0.UpdateCandidateView[]>;
|
|
327
|
+
}
|
|
328
|
+
interface CostSummaryView {
|
|
329
|
+
totalCost: number;
|
|
330
|
+
entries: readonly {
|
|
331
|
+
sessionId: string;
|
|
332
|
+
model: {
|
|
333
|
+
provider: string;
|
|
334
|
+
id: string;
|
|
335
|
+
};
|
|
336
|
+
usage: {
|
|
337
|
+
inputTokens: number;
|
|
338
|
+
outputTokens: number;
|
|
339
|
+
cacheReadTokens?: number;
|
|
340
|
+
cacheWriteTokens?: number;
|
|
341
|
+
};
|
|
342
|
+
cost: number;
|
|
343
|
+
}[];
|
|
344
|
+
}
|
|
345
|
+
interface CostSummaryServicePort {
|
|
346
|
+
summary(sessionId?: string, options?: {
|
|
347
|
+
allowBackfill?: boolean;
|
|
348
|
+
}): CostSummaryView | Promise<CostSummaryView>;
|
|
349
|
+
summaryOf?(sessionIds: readonly string[]): CostSummaryView | Promise<CostSummaryView>;
|
|
350
|
+
}
|
|
351
|
+
interface FoldViewStateServicePort {
|
|
352
|
+
load(sessionId: string): Promise<_$_x_otto_kernel0.PersistedFoldViewState | undefined>;
|
|
353
|
+
save(sessionId: string, state: {
|
|
354
|
+
folded: readonly string[];
|
|
355
|
+
expanded: readonly string[];
|
|
356
|
+
}): Promise<void>;
|
|
357
|
+
}
|
|
358
|
+
interface ModelAvailabilityServicePort {
|
|
359
|
+
snapshot(): {
|
|
360
|
+
entries: readonly _$_x_otto_kernel0.ModelAvailability[];
|
|
361
|
+
version: number;
|
|
86
362
|
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
363
|
+
}
|
|
364
|
+
interface InputHistoryServicePort {
|
|
365
|
+
load(sessionId: string): Promise<readonly string[]>;
|
|
366
|
+
save(sessionId: string, entries: readonly string[]): Promise<void>;
|
|
367
|
+
}
|
|
368
|
+
interface DraftsServicePort {
|
|
369
|
+
list(workspaceKey: string): Promise<readonly _$_x_otto_kernel0.DraftRecord[]>;
|
|
370
|
+
save(workspaceKey: string, text: string): Promise<_$_x_otto_kernel0.DraftRecord>;
|
|
371
|
+
remove(workspaceKey: string, ids: readonly string[]): Promise<void>;
|
|
372
|
+
}
|
|
373
|
+
interface ExtensionPermissionsServicePort {
|
|
374
|
+
list(): Promise<{
|
|
375
|
+
records: Readonly<Record<string, _$_x_otto_kernel0.ExtensionPermissionRecord>>;
|
|
376
|
+
trustedPlugins?: readonly string[];
|
|
377
|
+
untrustedPlugins?: readonly string[];
|
|
378
|
+
trustAll?: boolean;
|
|
379
|
+
}>;
|
|
380
|
+
}
|
|
381
|
+
interface ProviderServicePort {
|
|
382
|
+
list(): Promise<readonly _$_x_otto_kernel0.ProviderSummary[]>;
|
|
383
|
+
}
|
|
384
|
+
interface InstallServicePort {
|
|
385
|
+
list(): Promise<readonly _$_x_otto_kernel0.InstalledItem[]>;
|
|
386
|
+
uninstall(id: string): Promise<_$_x_otto_kernel0.UninstallResult>;
|
|
387
|
+
}
|
|
388
|
+
interface ModelPreferencesServicePort {
|
|
389
|
+
snapshot(): Promise<_$_x_otto_kernel0.ModelPreferenceSnapshot>;
|
|
390
|
+
setEnabled(modelId: string, isEnabled: boolean): Promise<_$_x_otto_kernel0.ModelPreferenceSnapshot>;
|
|
391
|
+
setCapabilityOverride(catalogId: string, patch: _$_x_otto_kernel0.ModelCapabilityOverride): Promise<_$_x_otto_kernel0.ModelPreferenceSnapshot>;
|
|
392
|
+
clearCapabilityOverride(catalogId: string): Promise<_$_x_otto_kernel0.ModelPreferenceSnapshot>;
|
|
393
|
+
}
|
|
394
|
+
interface ModelOperationsServicePort {
|
|
395
|
+
refresh(providerId?: string): Promise<{
|
|
396
|
+
providers: number;
|
|
397
|
+
models: number;
|
|
398
|
+
failed: number;
|
|
399
|
+
reason?: string;
|
|
400
|
+
}>;
|
|
401
|
+
unfreeze(targetId: string): {
|
|
402
|
+
ok: boolean;
|
|
403
|
+
id: string;
|
|
91
404
|
};
|
|
405
|
+
}
|
|
406
|
+
interface SkillServicePort {
|
|
407
|
+
snapshot(): Promise<_$_x_otto_kernel0.SkillSnapshot>;
|
|
408
|
+
setEnabled(name: string, enabled: boolean): Promise<_$_x_otto_kernel0.SkillEnableState>;
|
|
409
|
+
reload(): Promise<_$_x_otto_kernel0.SkillRefreshOutcome>;
|
|
410
|
+
}
|
|
411
|
+
interface McpServicePort {
|
|
412
|
+
snapshot(): Promise<_$_x_otto_kernel0.McpCatalogSnapshot>;
|
|
413
|
+
setEnabled(name: string, enabled: boolean): Promise<_$_x_otto_kernel0.McpEnableOutcome>;
|
|
414
|
+
reload(): Promise<_$_x_otto_kernel0.McpReloadOutcome>;
|
|
415
|
+
reconnect(name: string): Promise<_$_x_otto_kernel0.McpReconnectOutcome>;
|
|
416
|
+
login(name: string): Promise<_$_x_otto_kernel0.McpAuthOutcome>;
|
|
417
|
+
logout(name: string): Promise<_$_x_otto_kernel0.McpAuthOutcome>;
|
|
418
|
+
}
|
|
419
|
+
interface TrustServicePort {
|
|
420
|
+
query(root: string): Promise<_$_x_otto_kernel0.TrustRecord | undefined>;
|
|
421
|
+
}
|
|
422
|
+
interface SessionDiagnosticsServicePort {
|
|
423
|
+
inspectSource(path: string, cwd: string): Promise<unknown>;
|
|
424
|
+
auditLogs(mode: 'verify' | 'compact' | 'keep', sessionIds: readonly string[]): Promise<unknown>;
|
|
425
|
+
}
|
|
426
|
+
interface JobsServicePort {
|
|
427
|
+
list(caller: string | undefined): Promise<readonly _$_x_otto_kernel0.JobSnapshot[]>;
|
|
428
|
+
kill(id: string, caller: string | undefined): Promise<void>;
|
|
429
|
+
read?(id: string, caller: string | undefined): Promise<string>;
|
|
430
|
+
}
|
|
431
|
+
interface HandlerOptions {
|
|
432
|
+
dataSource: ServiceSource$1;
|
|
433
|
+
authorize: Authorizer;
|
|
434
|
+
askHost?: AskHost;
|
|
435
|
+
instanceBoot?: string;
|
|
436
|
+
auth?: AuthServicePort;
|
|
437
|
+
settingsPort?: SettingsServicePort;
|
|
438
|
+
jobsPort?: JobsServicePort;
|
|
439
|
+
trustPort?: TrustServicePort;
|
|
440
|
+
skillPort?: SkillServicePort;
|
|
441
|
+
modelPreferencesPort?: ModelPreferencesServicePort;
|
|
442
|
+
modelOperationsPort?: ModelOperationsServicePort;
|
|
443
|
+
sessionDiagnosticsPort?: SessionDiagnosticsServicePort;
|
|
444
|
+
installPort?: InstallServicePort;
|
|
445
|
+
providerPort?: ProviderServicePort;
|
|
446
|
+
extensionPermissionsPort?: ExtensionPermissionsServicePort;
|
|
447
|
+
extension?: ExtensionRequestHandlers;
|
|
448
|
+
inputHistoryPort?: InputHistoryServicePort;
|
|
449
|
+
modelAvailabilityPort?: ModelAvailabilityServicePort;
|
|
450
|
+
foldViewStatePort?: FoldViewStateServicePort;
|
|
451
|
+
costSummaryPort?: CostSummaryServicePort;
|
|
452
|
+
updatesPort?: UpdatesServicePort;
|
|
453
|
+
activationPort?: ActivationServicePort;
|
|
454
|
+
memoryEntriesPort?: MemoryEntryServicePort;
|
|
455
|
+
providerFallbackPort?: ProviderFallbackServicePort;
|
|
456
|
+
spaceCatalogPort?: SpaceCatalogServicePort;
|
|
457
|
+
draftsPort?: DraftsServicePort;
|
|
458
|
+
mcpPort?: McpServicePort;
|
|
459
|
+
schedulesPort?: SchedulesServicePort;
|
|
460
|
+
routeSets?: () => readonly RouteSet[];
|
|
461
|
+
broadcastEvent?(event: BroadcastEvent): void;
|
|
462
|
+
reportDiagnostic?(diagnostic: RuntimeDiagnosticInput): void;
|
|
463
|
+
workspaceOf?(sessionId: string): Promise<string | undefined>;
|
|
464
|
+
workspaceKeyOfRuntime?(): string | undefined;
|
|
465
|
+
settingsPortOf?(workspaceKey: string): SettingsServicePort | undefined;
|
|
466
|
+
spaceCatalogPortOf?(workspaceKey: string): SpaceCatalogServicePort | undefined;
|
|
467
|
+
approvalChannelOf?(workspaceKey: string): ExtensionApprovalChannel | undefined;
|
|
468
|
+
assemblyDiagnostics?(): readonly AssemblyDiagnostic[];
|
|
469
|
+
performanceDiagnostics?(): PerformanceDiagnosticsSnapshot | undefined;
|
|
470
|
+
workspaceReadiness?(workspaceKey: string): WorkspaceReadiness | undefined;
|
|
471
|
+
envSnapshotOf?(names: readonly string[]): {
|
|
472
|
+
values: Readonly<Record<string, string | undefined>>;
|
|
473
|
+
runtime: EnvSnapshotRuntime;
|
|
474
|
+
} | undefined;
|
|
475
|
+
cwdContextOf?(workspaceKey: string): Promise<{
|
|
476
|
+
branch?: string;
|
|
477
|
+
dirty: boolean;
|
|
478
|
+
}> | undefined;
|
|
479
|
+
attachedWritersOf?(sessionId: string): readonly {
|
|
480
|
+
capable: boolean;
|
|
481
|
+
}[];
|
|
482
|
+
}
|
|
483
|
+
//#endregion
|
|
484
|
+
//#region src/attached-writers.d.ts
|
|
485
|
+
interface AttachedWriter {
|
|
486
|
+
connectionId: string;
|
|
487
|
+
capable: boolean;
|
|
488
|
+
}
|
|
489
|
+
interface AttachedWritersRegistry {
|
|
490
|
+
attach(sessionId: string, writer: AttachedWriter): () => void;
|
|
491
|
+
writersOf(sessionId: string): readonly AttachedWriter[];
|
|
492
|
+
}
|
|
493
|
+
//#endregion
|
|
494
|
+
//#region src/errors.d.ts
|
|
495
|
+
declare class ServiceError extends Error {
|
|
496
|
+
readonly code: string;
|
|
497
|
+
readonly details?: unknown | undefined;
|
|
498
|
+
constructor(code: string, message: string, details?: unknown | undefined);
|
|
499
|
+
}
|
|
500
|
+
declare function isServiceError(error: unknown): error is ServiceError;
|
|
501
|
+
declare class RequestForbiddenError extends ServiceError {
|
|
502
|
+
readonly action: string;
|
|
503
|
+
readonly principalId: string;
|
|
504
|
+
constructor(action: string, principalId: string);
|
|
505
|
+
}
|
|
506
|
+
//#endregion
|
|
507
|
+
//#region src/handlers.d.ts
|
|
508
|
+
interface Handlers {
|
|
509
|
+
attachedWriters?: AttachedWritersRegistry;
|
|
510
|
+
handle(type: ServiceMethod, payload?: ServiceMethodInput<ServiceMethod>, context?: RequestContext): Promise<ServiceMethodOutput<ServiceMethod>>;
|
|
511
|
+
handleExtension?(request: ExtensionRpcRequest, context?: RequestContext, origin?: ExtensionCallerOrigin): Promise<unknown>;
|
|
512
|
+
bindExtension?(peer: AskPeer$1, receive: (frame: ExtensionClientFrame) => void): () => void;
|
|
513
|
+
listTypes(): readonly ServiceMethod[];
|
|
514
|
+
bindAsk?(peer: AskPeer$1, receive: (message: AskViewMessage$1) => void, onInvalidated?: (scope: AskScope$1, reason: AskInvalidationReason$1) => void): BoundAskHandlers;
|
|
515
|
+
}
|
|
516
|
+
interface BoundAskHandlers extends Handlers {
|
|
517
|
+
close(): void;
|
|
518
|
+
}
|
|
519
|
+
declare function createHandlers(deps: HandlerOptions): Handlers;
|
|
520
|
+
declare function mergeHandlers(...sets: readonly Handlers[]): Handlers;
|
|
521
|
+
//#endregion
|
|
522
|
+
//#region src/authorize.d.ts
|
|
523
|
+
declare function isReadOnlyMethod(action: ServiceMethod): boolean;
|
|
524
|
+
declare function createDefaultAuthorizer(): Authorizer;
|
|
525
|
+
declare function assertCredentialAllowed(context: RequestContext, method: ServiceMethod, payload: unknown, target: RouteTarget | undefined): void;
|
|
526
|
+
//#endregion
|
|
527
|
+
//#region src/token-verifier.d.ts
|
|
528
|
+
type TokenChannel = 'auth' | 'read' | 'ticket' | 'anonymous';
|
|
529
|
+
interface TokenVerification {
|
|
530
|
+
credential: Credential;
|
|
531
|
+
channel: TokenChannel;
|
|
532
|
+
}
|
|
533
|
+
interface TokenVerificationOptions {
|
|
534
|
+
authToken?: string;
|
|
535
|
+
readToken?: string;
|
|
536
|
+
ticketOf?(token: string): TicketClaims | undefined;
|
|
537
|
+
}
|
|
538
|
+
declare function createTokenVerifier(options: TokenVerificationOptions): (token: string | undefined) => TokenVerification | undefined;
|
|
539
|
+
//#endregion
|
|
540
|
+
//#region src/ask-deadlines.d.ts
|
|
541
|
+
interface AskDeadlineConfig {
|
|
542
|
+
permissionMs?: number;
|
|
543
|
+
hitlMs?: number;
|
|
544
|
+
createdAt?: number;
|
|
545
|
+
now?: () => number;
|
|
546
|
+
}
|
|
547
|
+
//#endregion
|
|
548
|
+
//#region src/ask-scope-visibility.d.ts
|
|
549
|
+
type AskLineage = ReadonlyMap<string, string | undefined>;
|
|
550
|
+
type AskScopeGrant = 'none' | 'observe' | 'answer';
|
|
551
|
+
interface AskVisibilityPolicy {
|
|
552
|
+
parentGrant?: AskScopeGrant;
|
|
553
|
+
}
|
|
554
|
+
interface AskScopeView {
|
|
555
|
+
sessionId: string;
|
|
556
|
+
depth: number;
|
|
557
|
+
grant: AskScopeGrant;
|
|
558
|
+
}
|
|
559
|
+
declare function visibilityOf(input: {
|
|
560
|
+
viewerSessionId: string;
|
|
561
|
+
targetSessionId: string;
|
|
562
|
+
lineage: AskLineage;
|
|
563
|
+
policy?: AskVisibilityPolicy;
|
|
564
|
+
}): AskScopeView;
|
|
565
|
+
declare function visibleChildScopes(input: {
|
|
566
|
+
viewerSessionId: string;
|
|
567
|
+
lineage: AskLineage;
|
|
568
|
+
policy?: AskVisibilityPolicy;
|
|
569
|
+
}): AskScopeView[];
|
|
570
|
+
declare function canAnswerScope(view: AskScopeView): boolean;
|
|
571
|
+
interface AggregatedAskScope {
|
|
572
|
+
sessionId: string;
|
|
573
|
+
depth: number;
|
|
574
|
+
grant: AskScopeGrant;
|
|
575
|
+
pendingCount: number;
|
|
576
|
+
}
|
|
577
|
+
declare function aggregateAskScopes(input: {
|
|
578
|
+
viewerSessionId: string;
|
|
579
|
+
lineage: AskLineage;
|
|
580
|
+
policy?: AskVisibilityPolicy;
|
|
581
|
+
pendingOf(sessionId: string): number;
|
|
582
|
+
}): AggregatedAskScope[];
|
|
583
|
+
//#endregion
|
|
584
|
+
//#region src/ask-escalation.d.ts
|
|
585
|
+
interface AskSessionPolicy {
|
|
586
|
+
escalateToParent: boolean;
|
|
587
|
+
permissionTimeoutMs?: number;
|
|
588
|
+
}
|
|
589
|
+
declare const ASK_ESCALATION_PERMISSION_TIMEOUT_DEFAULT_MS: number;
|
|
590
|
+
declare function askSessionPolicyOf(raw: unknown): AskSessionPolicy | undefined;
|
|
591
|
+
declare function declaresAskEscalation(policy: AskSessionPolicy | undefined): boolean;
|
|
592
|
+
declare function escalatedPermissionTimeoutMsOf(policy: AskSessionPolicy): number;
|
|
593
|
+
declare function askDescendantScopesOf(input: {
|
|
594
|
+
viewerSessionId: string;
|
|
595
|
+
lineage: AskLineage;
|
|
596
|
+
declares(sessionId: string): boolean;
|
|
597
|
+
pendingCountOf(sessionId: string): number;
|
|
598
|
+
}): AskDescendantSummary[];
|
|
599
|
+
//#endregion
|
|
600
|
+
//#region src/ask-channels.d.ts
|
|
601
|
+
interface AskDiagnostic {
|
|
602
|
+
code: string;
|
|
603
|
+
message: string;
|
|
604
|
+
detail?: unknown;
|
|
605
|
+
}
|
|
606
|
+
interface RuntimeAskChannelsOptions {
|
|
607
|
+
epoch?: string;
|
|
608
|
+
timeoutMs?: number;
|
|
609
|
+
pendingStore?: PendingAskStore$1;
|
|
610
|
+
deferWhenNoAnswerer?: boolean;
|
|
611
|
+
deadlineConfig?: AskDeadlineConfig | (() => AskDeadlineConfig);
|
|
612
|
+
parentGrant?: AskScopeGrant;
|
|
613
|
+
lineage?: () => AskLineage;
|
|
614
|
+
sessionAskPolicy?: (sessionId: string) => AskSessionPolicy | undefined;
|
|
615
|
+
onPendingAskChanged?: (sessionId: string) => void;
|
|
616
|
+
id?: () => string;
|
|
617
|
+
ownsSession: (sessionId: string) => boolean;
|
|
618
|
+
diagnose?: (input: AskDiagnostic) => void;
|
|
619
|
+
}
|
|
620
|
+
declare const DEFAULT_ASK_TIMEOUT_MS: number;
|
|
621
|
+
type AskObserverCloseReason = 'observer-error' | 'disposed';
|
|
622
|
+
interface RuntimeAskSubscription extends AskSubscription$1 {
|
|
623
|
+
refresh(): void;
|
|
624
|
+
onClosed(handler: (reason: AskObserverCloseReason) => void): () => void;
|
|
625
|
+
}
|
|
626
|
+
type SessionAskScope = Extract<AskScope$1, {
|
|
627
|
+
kind: 'session';
|
|
628
|
+
}>;
|
|
629
|
+
declare function createRuntimeAskChannels(options: RuntimeAskChannelsOptions): RuntimeAskChannels$1;
|
|
630
|
+
//#endregion
|
|
631
|
+
//#region src/ask-validate.d.ts
|
|
632
|
+
declare function parseAskScope(value: unknown): AskScope$1 | undefined;
|
|
633
|
+
declare function scopeKey(scope: AskScope$1): string;
|
|
634
|
+
declare function parseAskRef(value: unknown): AskRef$1 | undefined;
|
|
635
|
+
declare function parsePermissionAskRef(value: unknown): PermissionAskRef$1 | undefined;
|
|
636
|
+
declare function parsePermissionAskResponse(value: unknown): PermissionAskResponse$1 | undefined;
|
|
637
|
+
declare function parseHitlAnswer(value: unknown): HitlAnswer$1 | undefined;
|
|
638
|
+
declare function parseHitlReply(value: unknown): HitlReply$1 | undefined;
|
|
639
|
+
declare function parsePermissionAskRequest(value: unknown): PermissionAskRequest$1 | undefined;
|
|
640
|
+
declare function parseHitlAskRequest(value: unknown): HitlAskRequest$1 | undefined;
|
|
641
|
+
declare function parseAskViewMessage(value: unknown): AskViewMessage$1 | undefined;
|
|
642
|
+
declare function viewMessageScope(message: AskViewMessage$1): AskScope$1;
|
|
643
|
+
type ParsedAskFrame = {
|
|
644
|
+
kind: 'message';
|
|
645
|
+
message: AskViewMessage$1;
|
|
92
646
|
} | {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
647
|
+
kind: 'invalidated';
|
|
648
|
+
scope: AskScope$1;
|
|
649
|
+
reason: AskInvalidationReason$1;
|
|
650
|
+
};
|
|
651
|
+
declare function parseAskFrame(value: unknown): ParsedAskFrame | undefined;
|
|
652
|
+
declare function parseAskOpenPayload(payload: unknown): {
|
|
653
|
+
scope: AskScope$1;
|
|
654
|
+
answer: boolean;
|
|
655
|
+
} | undefined;
|
|
656
|
+
declare function parseAskScopePayload(payload: unknown): AskScope$1 | undefined;
|
|
657
|
+
declare function parseApprovalRespondPayload(payload: unknown): {
|
|
658
|
+
ref: PermissionAskRef$1;
|
|
659
|
+
response: PermissionAskResponse$1;
|
|
660
|
+
} | undefined;
|
|
661
|
+
declare function parseHitlRespondPayload(payload: unknown): {
|
|
662
|
+
ref: AskRef$1;
|
|
663
|
+
reply: HitlReply$1;
|
|
664
|
+
} | undefined;
|
|
665
|
+
declare function parseAskRespond(command: unknown): AskRespond$1 | undefined;
|
|
666
|
+
declare function validatePermissionResponse(request: PermissionAskRequest$1, response: PermissionAskResponse$1): boolean;
|
|
667
|
+
declare function validateHitlReply(request: HitlAskRequest$1, reply: HitlReply$1): boolean;
|
|
668
|
+
//#endregion
|
|
669
|
+
//#region src/client.d.ts
|
|
670
|
+
interface ServiceClient extends ServiceClientContract {
|
|
671
|
+
asks?: AskConnection$1;
|
|
672
|
+
requestExtension?(type: string, payload: ExtensionWirePayload, contractVersion: number, access?: ExtensionRpcAccess): Promise<unknown>;
|
|
673
|
+
subscribe(sessionId: string, handler: (event: ServiceEvent$1) => void): () => void;
|
|
674
|
+
onReconnected?(handler: () => void): () => void;
|
|
675
|
+
onExtension?(handler: (frame: ExtensionClientFrame) => void): () => void;
|
|
676
|
+
subscribeAwaited?(sessionId: string): Promise<void>;
|
|
677
|
+
close(): void;
|
|
678
|
+
}
|
|
679
|
+
interface InProcessClient extends ServiceClient {
|
|
680
|
+
emit(sessionId: string, event: ServiceEvent$1): void;
|
|
681
|
+
}
|
|
682
|
+
interface InProcessClientOptions {
|
|
683
|
+
peer?: AskPeer$1;
|
|
684
|
+
origin?: ExtensionCallerOrigin;
|
|
685
|
+
clientId?: string;
|
|
686
|
+
}
|
|
687
|
+
declare function createInProcessClient(handlers: Handlers, options?: InProcessClientOptions): InProcessClient;
|
|
688
|
+
interface WireCloseInfo {
|
|
689
|
+
reason: 'local' | 'remote';
|
|
690
|
+
reconnecting: boolean;
|
|
691
|
+
}
|
|
692
|
+
type WireControlRequest = {
|
|
693
|
+
id: string;
|
|
694
|
+
type: 'session.subscribe';
|
|
695
|
+
payload: {
|
|
696
|
+
sessionId: string;
|
|
697
|
+
sinceSeq?: number;
|
|
96
698
|
};
|
|
97
699
|
} | {
|
|
98
|
-
|
|
99
|
-
|
|
700
|
+
id: string;
|
|
701
|
+
type: 'session.unsubscribe';
|
|
702
|
+
payload: {
|
|
100
703
|
sessionId: string;
|
|
101
|
-
seq: number;
|
|
102
|
-
event: TraceEvent;
|
|
103
704
|
};
|
|
104
705
|
};
|
|
105
|
-
interface
|
|
106
|
-
|
|
107
|
-
timestamp: string;
|
|
108
|
-
level: string;
|
|
109
|
-
module: string;
|
|
110
|
-
message: string;
|
|
111
|
-
data?: Record<string, unknown>;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* 客户端发来的消息在传输层统一为此形式,data 字段在各 handler 中按协议解析。
|
|
115
|
-
* 具体各消息的 data shape 见 WebSocketClientData 类型映射。
|
|
116
|
-
*/
|
|
117
|
-
interface WebSocketClientMessage {
|
|
118
|
-
type: WebSocketClientMessageType;
|
|
119
|
-
data: Record<string, unknown>;
|
|
120
|
-
}
|
|
121
|
-
type WebSocketClientMessageType = 'Runtime.ping' | 'Chat.query' | 'Chat.approval' | 'Chat.askUserResponse' | 'Chat.planApprovalResponse' | 'Session.subscribe' | 'Session.unsubscribe' | 'Session.writeLease.acquire' | 'Session.writeLease.release' | 'Session.writeLease.force_acquire' | 'Debugger.resume' | 'Debugger.stepOver' | 'Debugger.stepInto' | 'Debugger.disable' | 'Debugger.setBreakpoint' | 'Debugger.setBreakpointsActive';
|
|
122
|
-
/**
|
|
123
|
-
* RFC-419 M2:键集完整性由两道防线保障,无需额外类型体操:
|
|
124
|
-
* ① 各 parser 用索引访问 `WebSocketClientDataByType['<type>']` 标注返回类型——映射漏某键
|
|
125
|
-
* 时对应 parser 的索引访问报错;
|
|
126
|
-
* ② dispatch default 的 `const _exhaustive: never = type` 穷尽断言——联合新增 type 漏写 case
|
|
127
|
-
* 时 `type` 不再收窄为 never 而报错(inbound-router.ts)。
|
|
128
|
-
* 显式对象类型(而非映射类型)为可读性取舍:一眼可见每个 type 的 data 形状。
|
|
129
|
-
*/
|
|
130
|
-
interface ChatQueryData {
|
|
131
|
-
message: string;
|
|
132
|
-
sessionId?: string;
|
|
706
|
+
interface WireSendOptions {
|
|
707
|
+
access?: ExtensionRpcAccess;
|
|
133
708
|
}
|
|
134
|
-
interface
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
sessionId
|
|
709
|
+
interface WireTransport {
|
|
710
|
+
send(request: WireRequest | WireControlRequest | ExtensionWireRequest, options?: WireSendOptions): void;
|
|
711
|
+
subscribe(sessionId: string): void;
|
|
712
|
+
subscribeAwaited?(sessionId: string): Promise<void>;
|
|
713
|
+
unsubscribe(sessionId: string): void;
|
|
714
|
+
onGeneration?(handler: (generation: number) => void): () => void;
|
|
715
|
+
onReconnected?(handler: () => void): () => void;
|
|
716
|
+
onResponse(handler: (res: WireResponse) => void): void;
|
|
717
|
+
onEvent(handler: (event: ServiceEvent$1) => void): void;
|
|
718
|
+
onExtension?(handler: (frame: ExtensionClientFrame) => void): void;
|
|
719
|
+
onClose(handler: (info?: WireCloseInfo) => void): void;
|
|
720
|
+
onAskView?(handler: (message: AskViewMessage$1) => void): void;
|
|
721
|
+
onAskInvalidated?(handler: (scope: AskScope$1, reason: AskInvalidationReason$1) => void): void;
|
|
722
|
+
askOpen?(scope: AskScope$1, options: {
|
|
723
|
+
answer: boolean;
|
|
724
|
+
}): Promise<void>;
|
|
725
|
+
askRefresh?(scope: AskScope$1): Promise<void>;
|
|
726
|
+
askClose?(scope: AskScope$1): void;
|
|
727
|
+
closeReason?(): string | undefined;
|
|
728
|
+
close(): void;
|
|
138
729
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
730
|
+
declare function createHttpWsClient(transport: WireTransport): ServiceClient;
|
|
731
|
+
//#endregion
|
|
732
|
+
//#region src/mock.d.ts
|
|
733
|
+
type DistributeSessionId<T> = T extends unknown ? Omit<T, 'sessionId'> : never;
|
|
734
|
+
type TurnStep = DistributeSessionId<ServiceEvent$1>;
|
|
735
|
+
type TurnScript = (text: string, sessionId: string) => readonly TurnStep[];
|
|
736
|
+
declare function defaultTurnScript(text: string): readonly TurnStep[];
|
|
737
|
+
interface MockServiceOptions {
|
|
738
|
+
latency?: number;
|
|
739
|
+
errorRate?: number;
|
|
740
|
+
stepDelay?: number;
|
|
741
|
+
turnScript?: TurnScript;
|
|
742
|
+
initialSessions?: readonly SessionEntry[];
|
|
743
|
+
clock?: () => number;
|
|
744
|
+
random?: () => number;
|
|
745
|
+
id?: () => string;
|
|
144
746
|
}
|
|
145
|
-
interface
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
sessionId?: string;
|
|
747
|
+
interface MockService {
|
|
748
|
+
handlers: Handlers;
|
|
749
|
+
dataSource: ServiceSource;
|
|
750
|
+
setEmit(emitEvent: (sessionId: string, event: ServiceEvent$1) => void): void;
|
|
150
751
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
interface
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
interface DebuggerSetBreakpointData {
|
|
165
|
-
point: string;
|
|
166
|
-
enabled: boolean;
|
|
167
|
-
}
|
|
168
|
-
interface DebuggerSetBreakpointsActiveData {
|
|
169
|
-
active: boolean;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* RFC-335 M1:服务实例的只读 Authority 身份。客户端只能以此描述符识别
|
|
173
|
-
* 唯一 Session Authority,不能据此构造或持有 AgentSession。
|
|
174
|
-
*/
|
|
175
|
-
interface AuthorityDescriptor {
|
|
176
|
-
/** 每个 CodingService 实例生命周期内稳定;进程/服务重启后必变。非鉴权 token。 */
|
|
177
|
-
instanceId: string;
|
|
178
|
-
/** authority 所属 workspace;客户端不得把它当作跨 workspace 路由许可。 */
|
|
179
|
-
workspaceDir: string;
|
|
180
|
-
/** 当前只声明快照与 session 事件订阅能力。cursor 原子接续在 RFC-335 M3 才引入。 */
|
|
181
|
-
protocolVersion: 1;
|
|
182
|
-
capabilities: readonly ('session.snapshot' | 'session.subscribe')[];
|
|
183
|
-
}
|
|
184
|
-
/** RFC-335 M1 的只读 session 水合 DTO。它不是与 WS 增量原子接续的 cursor;M3 解决该竞态。 */
|
|
185
|
-
interface SessionSnapshot {
|
|
186
|
-
authority: AuthorityDescriptor;
|
|
187
|
-
session: {
|
|
188
|
-
id: string;
|
|
189
|
-
status: string;
|
|
190
|
-
messageCount: number; /** 与 `GET /api/sessions/:id/messages` 同一序列化契约(单一真源,消费方无需 assert)。 */
|
|
191
|
-
messages: SerializedMessage[];
|
|
192
|
-
};
|
|
193
|
-
/**
|
|
194
|
-
* RFC-335 M3:快照时刻的 `Session.event` 序列号。订阅时作为 `Session.subscribe.since`
|
|
195
|
-
* 传回,服务端据此补发期间事件,实现 snapshot→subscribe 无缝接续。
|
|
196
|
-
*
|
|
197
|
-
* 边界:只保证 `Session.event` 域;`Trace.event`/`Debugger.*` 不在其中(见
|
|
198
|
-
* `session-event-log.ts` 头注释)。
|
|
199
|
-
*
|
|
200
|
-
* 客户端 **MUST 按 `seq` 排序并去重**——补发走定向通道、实时流走订阅通道,
|
|
201
|
-
* 到达顺序不保证等于 seq 顺序。
|
|
202
|
-
*/
|
|
203
|
-
cursor: number;
|
|
204
|
-
snapshotAt: string;
|
|
205
|
-
}
|
|
206
|
-
interface CodingServiceOptions {
|
|
207
|
-
host?: string;
|
|
208
|
-
port: number;
|
|
209
|
-
/** 测试/嵌入式宿主可注入稳定 identity;生产默认由服务实例生成。 */
|
|
210
|
-
authorityId?: string;
|
|
211
|
-
staticDir?: string;
|
|
212
|
-
cors?: string;
|
|
213
|
-
wsAuthToken?: string;
|
|
214
|
-
apiToken?: string;
|
|
215
|
-
}
|
|
216
|
-
interface IMessageSender {
|
|
217
|
-
broadcast(message: WebSocketMessage): void;
|
|
218
|
-
sendToSession(sessionId: string, message: WebSocketMessage): void;
|
|
219
|
-
sendToSubscribers(sessionId: string, message: WebSocketMessage): void;
|
|
220
|
-
}
|
|
221
|
-
//#endregion
|
|
222
|
-
//#region src/session-event-log.d.ts
|
|
223
|
-
/** 单条已编号事件。`seq` 在单个 session 内单调递增,从 1 开始。 */
|
|
224
|
-
interface SequencedEvent {
|
|
225
|
-
seq: number;
|
|
226
|
-
message: WebSocketMessage;
|
|
227
|
-
}
|
|
228
|
-
type EventLogRead = /** 成功:`events` 是 cursor 之后的全部事件(可能为空,表示客户端已是最新)。 */{
|
|
229
|
-
ok: true;
|
|
230
|
-
events: SequencedEvent[];
|
|
752
|
+
declare function createMockService(options?: MockServiceOptions): MockService;
|
|
753
|
+
//#endregion
|
|
754
|
+
//#region src/fanout.d.ts
|
|
755
|
+
type ServiceEventHandler = (event: ServiceEvent$1) => void;
|
|
756
|
+
interface EventFanoutOptions {
|
|
757
|
+
onFirstSubscriber?: (sessionId: string) => void;
|
|
758
|
+
onLastSubscriberRemoved?: (sessionId: string) => void;
|
|
759
|
+
}
|
|
760
|
+
interface EventFanout {
|
|
761
|
+
add(sessionId: string, handler: ServiceEventHandler): () => void;
|
|
762
|
+
deliver(sessionId: string, deliver: (handler: ServiceEventHandler) => void): void;
|
|
763
|
+
clear(): void;
|
|
764
|
+
sessionCount(): number;
|
|
231
765
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
766
|
+
declare function createEventFanout(options?: EventFanoutOptions): EventFanout;
|
|
767
|
+
//#endregion
|
|
768
|
+
//#region src/wire.d.ts
|
|
769
|
+
interface WireRequestHandlers extends Partial<ExtensionRequestHandlers> {
|
|
770
|
+
handle<K extends ServiceMethod>(type: K, payload: ServiceMethodInput<K>, context?: RequestContext): Promise<ServiceMethodOutput<K>>;
|
|
771
|
+
}
|
|
772
|
+
declare function handleWireRequest(handlers: WireRequestHandlers, type: string, rawBody: string, context?: RequestContext, fallbackId?: string): Promise<WireResponse>;
|
|
773
|
+
//#endregion
|
|
774
|
+
//#region src/methods.d.ts
|
|
775
|
+
declare const SERVICE_WIRE_VERSION = 4;
|
|
776
|
+
declare const SERVICE_MIN_WIRE_VERSION = 4;
|
|
777
|
+
declare const SERVICE_METHODS: readonly ["session.list", "session.counts", "session.create", "session.descendants", "chat.attempt.status", "chat.send", "chat.submitIntent", "chat.clear", "chat.compact", "chat.interrupt", "chat.executionStatus", "chat.retryLastRound", "chat.continueWithPending", "chat.releaseAdmission", "chat.retryCancel", "chat.retryAccelerate", "chat.withdraw", "chat.steer", "chat.queue.append", "chat.queue.list", "chat.queue.remove", "chat.queue.clear", "chat.queue.promote", "chat.queue.update", "chat.queue.move", "chat.discardDanglingInput", "session.discardResultObligation", "session.resultObligations", "session.rearmResultObligation", "session.confirmResultObligation", "chat.resumeQueue", "chat.deferAwaitingResults", "composer.context", "session.entry", "session.rename", "session.model.select", "session.effort.select", "session.permission.select", "session.permission.mode", "session.pin", "session.archive", "session.reimport", "session.unarchive", "session.remove", "session.restore", "session.claim", "session.recordDiagnostic", "session.viewport", "session.work.snapshot", "session.timeline.snapshot", "session.timeline.detail", "session.contextArchive.read", "session.archivedHistory", "session.surface.read", "session.forkPoints.list", "session.fork", "session.recovery.list", "session.recovery.get", "session.recovery.retry", "session.recovery.resolve", "session.recovery.repair", "recorder.pending.export", "recorder.pending.recover", "runtime.askScope", "session.prepare", "session.deliver", "plugin.list", "plugin.add", "plugin.remove", "plugin.replace", "model.list", "model.select", "plan.list", "session.cwdContext", "devApproval.pending", "devApproval.respond", "extension.write.request", "extension.write.apply", "session.editedFiles", "workspace.list", "workspace.placement", "assembly.diagnostics", "assembly.performanceDiagnostics", "workspace.readiness", "ui.catalog", "ui.activity.record", "mention.search", "env.snapshot", "command.run", "command.catalog", "view.frame", "view.input", "view.close", "ui.preferences.get", "ui.preferences.set", "perf.residency", "worker.lifecycle", "worker.restart.prepare", "worker.restart.status", "worker.restart.resume", "worker.restart.cancel", "worker.exit", "resource.read", "approval.respond", "hitl.respond", "ask.open", "ask.refresh", "ask.close", "ask.descendants", "repository.capabilities", "repository.recovery.capabilities", "repository.recovery.save", "repository.recovery.get", "repository.recovery.list", "repository.recovery.remove", "repository.saveMeta", "repository.loadMeta", "repository.list", "repository.purge", "repository.appendEvents", "repository.readEvents", "repository.readArchivedEvents", "repository.countEvents", "repository.truncateBefore", "repository.archive", "repository.restoreArchived", "repository.releaseCache", "repository.readCommitted", "repository.committedNextSeq", "session.runtimeSnapshot", "session.releaseView", "session.reconcileLostJob", "service.handshake", "schedules.list", "schedules.delete", "schedules.runPending", "schedules.dismissPending", "schedules.health", "space.catalog", "provider.fallback", "memory.entries", "memory.read", "install.activation", "updates.status", "updates.check", "cost.summary", "fold.viewState", "fold.viewState.save", "model.availability", "input.history", "input.history.save", "drafts.list", "drafts.save", "drafts.remove", "extension.permissions", "provider.list", "install.list", "install.uninstall", "model.preferences", "model.setEnabled", "model.setCapabilityOverride", "model.clearCapabilityOverride", "model.refresh", "model.unfreeze", "skill.snapshot", "skill.setEnabled", "skill.reload", "mcp.snapshot", "mcp.setEnabled", "mcp.reload", "mcp.reconnect", "mcp.login", "mcp.logout", "session.inspectSource", "session.auditLogs", "trust.query", "jobs.list", "jobs.kill", "jobs.read", "settings.get", "permission.mode", "settings.getAll", "settings.set", "settings.clear", "settings.describe", "settings.subscribe", "auth.status", "auth.login", "auth.login.status", "auth.login.submit-code", "auth.login.cancel", "auth.set-key", "auth.account", "auth.logout"];
|
|
778
|
+
declare function isServiceMethod(type: string): type is ServiceMethod;
|
|
779
|
+
//#endregion
|
|
780
|
+
//#region src/connection-binding.d.ts
|
|
781
|
+
interface ConnectionBindingInput {
|
|
782
|
+
methodAllowList?: readonly ServiceMethod[];
|
|
783
|
+
}
|
|
784
|
+
interface ConnectionBinding {
|
|
785
|
+
allows(method: ServiceMethod): boolean;
|
|
786
|
+
reasonFor(method: ServiceMethod): 'method-not-in-bindings' | undefined;
|
|
787
|
+
}
|
|
788
|
+
declare function createConnectionBinding(input?: ConnectionBindingInput): ConnectionBinding;
|
|
789
|
+
//#endregion
|
|
790
|
+
//#region src/wire-compat.d.ts
|
|
791
|
+
interface WireCompatibilityInput {
|
|
792
|
+
clientWireVersion: number;
|
|
793
|
+
serverWireVersion: number;
|
|
794
|
+
serverMinWireVersion: number;
|
|
795
|
+
}
|
|
796
|
+
type WireCompatibility = {
|
|
797
|
+
ok: true;
|
|
798
|
+
} | {
|
|
237
799
|
ok: false;
|
|
238
|
-
reason: '
|
|
239
|
-
oldestAvailable: number;
|
|
800
|
+
reason: 'server-too-old' | 'client-too-old';
|
|
240
801
|
};
|
|
241
|
-
declare
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
* `after` 早于缓冲区最旧一条 → `gap` 失败(中间已被逐出,无法诚实补齐)。
|
|
255
|
-
*/
|
|
256
|
-
readFrom(sessionId: string, after: number): EventLogRead;
|
|
257
|
-
/** 会话结束/detach 时清理,避免 Map 无界增长。 */
|
|
258
|
-
clear(sessionId: string): void;
|
|
259
|
-
}
|
|
260
|
-
//#endregion
|
|
261
|
-
//#region src/websocket-manager.d.ts
|
|
262
|
-
interface WebSocketManagerEvents {
|
|
263
|
-
message: (clientId: string, message: WebSocketClientMessage) => void;
|
|
802
|
+
declare function judgeWireCompatibility(input: WireCompatibilityInput): WireCompatibility;
|
|
803
|
+
//#endregion
|
|
804
|
+
//#region src/resource-read.d.ts
|
|
805
|
+
declare const RESOURCE_READ_CAP_BYTES: number;
|
|
806
|
+
declare function parseResourceAddress(address: string): string;
|
|
807
|
+
declare function readResourceFile(root: string, filePath: string): Promise<ResourceReadResult>;
|
|
808
|
+
//#endregion
|
|
809
|
+
//#region src/hub-discovery-protocol.d.ts
|
|
810
|
+
declare const HUB_WIRE_VERSION = 4;
|
|
811
|
+
interface HostCapabilityView {
|
|
812
|
+
code: string;
|
|
813
|
+
available: boolean;
|
|
814
|
+
reason?: string;
|
|
264
815
|
}
|
|
265
|
-
interface
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
*
|
|
315
|
-
* 用于以 lease owner(身份 id)为收件人的定向通知——`sendToClient` 收的是连接 id,
|
|
316
|
-
* 直接把 owner 喂进去会静默投递失败(Map 查不到)。同一身份可能有多条连接
|
|
317
|
-
* (多个 attach 窗口 / web-ui 与 CLI 共用 token),全部通知。
|
|
318
|
-
*/
|
|
319
|
-
sendToIdentity(identity: string, message: WebSocketMessage): void;
|
|
816
|
+
interface HubDiscoveryInfo {
|
|
817
|
+
wireVersion?: number;
|
|
818
|
+
pid: number;
|
|
819
|
+
port: number;
|
|
820
|
+
host: string;
|
|
821
|
+
token?: string;
|
|
822
|
+
readToken?: string;
|
|
823
|
+
credentialPath?: string;
|
|
824
|
+
startedAt: number;
|
|
825
|
+
capabilities?: readonly string[];
|
|
826
|
+
hostCapabilities?: readonly HostCapabilityView[];
|
|
827
|
+
workspace?: WorkspaceKey;
|
|
828
|
+
principal?: string;
|
|
829
|
+
instanceBoot?: string;
|
|
830
|
+
expiresAt?: number;
|
|
831
|
+
}
|
|
832
|
+
declare function hubDiscoveryDir(home: string): string;
|
|
833
|
+
declare function hubDiscoveryPath(home: string, pid: number): string;
|
|
834
|
+
interface HubCredential {
|
|
835
|
+
version: number;
|
|
836
|
+
pid: number;
|
|
837
|
+
token: string;
|
|
838
|
+
readToken?: string;
|
|
839
|
+
}
|
|
840
|
+
declare function resolveHubCredential(info: HubDiscoveryInfo): Promise<{
|
|
841
|
+
token: string;
|
|
842
|
+
readToken?: string;
|
|
843
|
+
} | null>;
|
|
844
|
+
declare function isValidHubDiscoveryInfo(value: unknown): value is HubDiscoveryInfo;
|
|
845
|
+
declare function readHubDiscoveryFile(path: string): Promise<HubDiscoveryInfo | null>;
|
|
846
|
+
declare function listHubDiscoveryFiles(home: string): Promise<HubDiscoveryInfo[]>;
|
|
847
|
+
declare function removeHubDiscoveryFile(home: string, pid: number): Promise<void>;
|
|
848
|
+
interface HubDiscoveryLease {
|
|
849
|
+
path: string;
|
|
850
|
+
update(patch: Partial<HubDiscoveryInfo>): Promise<void>;
|
|
851
|
+
stop(): Promise<void>;
|
|
852
|
+
}
|
|
853
|
+
interface HubDiscoveryLeaseOptions {
|
|
854
|
+
ttlMs?: number;
|
|
855
|
+
intervalMs?: number;
|
|
856
|
+
}
|
|
857
|
+
declare function writeHubDiscoveryFile(home: string, info: HubDiscoveryInfo): Promise<string>;
|
|
858
|
+
declare function startHubDiscoveryLease(home: string, info: HubDiscoveryInfo, options?: HubDiscoveryLeaseOptions): Promise<HubDiscoveryLease>;
|
|
859
|
+
//#endregion
|
|
860
|
+
//#region src/hub-client.d.ts
|
|
861
|
+
interface ResolvedHubClient {
|
|
862
|
+
client: ServiceClient;
|
|
863
|
+
info: HubDiscoveryInfo;
|
|
864
|
+
transport?: WireTransport;
|
|
320
865
|
close(): void;
|
|
321
|
-
private onConnection;
|
|
322
|
-
private handleSystemClientMessage;
|
|
323
|
-
private handleRuntimePing;
|
|
324
|
-
private normalizeClientMessage;
|
|
325
|
-
private asRecord;
|
|
326
866
|
}
|
|
867
|
+
type HubCandidateRejectionReason = 'protocol-outdated' | 'pid-mismatch' | 'pid-dead' | 'workspace-mismatch' | 'principal-mismatch' | 'capability-mismatch';
|
|
868
|
+
interface HubCandidateRejection {
|
|
869
|
+
pid: number;
|
|
870
|
+
reason: HubCandidateRejectionReason;
|
|
871
|
+
requested: string;
|
|
872
|
+
actual?: string;
|
|
873
|
+
}
|
|
874
|
+
interface ResolveHubClientOptions {
|
|
875
|
+
home: string;
|
|
876
|
+
timeoutMs?: number;
|
|
877
|
+
deadlineMs?: number;
|
|
878
|
+
pid?: number;
|
|
879
|
+
workspaceKey?: string;
|
|
880
|
+
principal?: string;
|
|
881
|
+
capability?: string;
|
|
882
|
+
mode?: 'follow' | 'attach';
|
|
883
|
+
readOnly?: boolean;
|
|
884
|
+
attach?: boolean;
|
|
885
|
+
features?: readonly string[];
|
|
886
|
+
writeGate?: () => boolean;
|
|
887
|
+
now?: () => number;
|
|
888
|
+
isPidAlive?: (pid: number) => boolean;
|
|
889
|
+
onCandidateRejected?: (rejection: HubCandidateRejection) => void;
|
|
890
|
+
}
|
|
891
|
+
declare function resolveHubClient(options: ResolveHubClientOptions): Promise<ResolvedHubClient | null>;
|
|
892
|
+
//#endregion
|
|
893
|
+
//#region src/hub-capabilities.d.ts
|
|
894
|
+
declare const HUB_CAPABILITY_HTTP = "http";
|
|
895
|
+
declare const HUB_CAPABILITY_WS = "ws";
|
|
896
|
+
declare const HUB_CAPABILITY_ASK = "ask";
|
|
897
|
+
declare const HUB_CAPABILITY_REPOSITORY = "repository";
|
|
898
|
+
declare const HUB_CAPABILITY_WORK_IDENTITY_V2 = "work-identity-v2";
|
|
899
|
+
declare const HUB_CAPABILITY_FOLLOW_SCOPE = "follow-scope";
|
|
900
|
+
declare const HUB_CAPABILITY_EXTENSION_RPC = "extensionRpc";
|
|
901
|
+
declare function hubCapabilitiesOf(handlers: Handlers): readonly string[];
|
|
327
902
|
//#endregion
|
|
328
|
-
//#region src/
|
|
329
|
-
interface
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
903
|
+
//#region src/http.d.ts
|
|
904
|
+
interface HttpAppOptions {
|
|
905
|
+
health?: boolean;
|
|
906
|
+
authToken?: string;
|
|
907
|
+
tokenWorkspaceScope?: readonly string[];
|
|
908
|
+
ticketOf?(token: string): TicketClaims | undefined;
|
|
909
|
+
allowHost?(hostHeader: string | undefined): boolean;
|
|
910
|
+
allowOrigin?(origin: string | undefined): boolean;
|
|
334
911
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
*
|
|
378
|
-
* 唯一写权语义(同一 session 至多 1 client 持有写权):
|
|
379
|
-
* - acquire(idempotent by same clientId):同 clientId 重复 acquire 视为 no-op;
|
|
380
|
-
* 另一 clientId 申请在 released 前 deny。
|
|
381
|
-
* - release:仅持有者可 release;非持有者 release 视为 no-op(不报错——防下线风暴)。
|
|
382
|
-
* - releaseAllForClient:该 client 断连重置——唯一强清理端点。
|
|
383
|
-
*
|
|
384
|
-
* 实现主调点是 inbound-router:WS 显式 verb 派单 acquire/release,
|
|
385
|
-
* ws.onclose / server-shutdown 走 releaseAllForClient。
|
|
386
|
-
* RFC-381 M2 定义 + RFC-419 M1 接线:现已支持 heartbeat(sessionId,clientId) 刷新持有者
|
|
387
|
-
* 存活证明 + evictStale 周期驱逐死租约——WS Runtime.ping 触发 heartbeatAllForClient 刷新,
|
|
388
|
-
* CodingService 定时器周期调 evictStale 驱逐超 staleAfterMs 未心跳的死租约。
|
|
389
|
-
* 死租约终态:kill -9 / 网络断 → 心跳停止刷新 → 超时被 evictStale 驱逐,或下一 attach
|
|
390
|
-
* 收到 denied(deny reason 含另一 clientId),亦可 explicit `force_acquire` 人工接管。
|
|
391
|
-
*/
|
|
392
|
-
interface WriteLeaseManager {
|
|
393
|
-
/** 申请 sessionId 的唯一写权。返回结果不抛错:denied/acquired 当事儿类型。 */
|
|
394
|
-
acquire(sessionId: string, clientId: string): WriteLeaseAcquireResult;
|
|
395
|
-
/** 释放 sessionId 的写权。仅持有者可 release。返回是否真释放了(幂等)。 */
|
|
396
|
-
release(sessionId: string, clientId: string): boolean;
|
|
397
|
-
/** 清理某个 client 名下的所有写租约(断连清理点)。返回被释放的 sessionId 列表。 */
|
|
398
|
-
releaseAllForClient(clientId: string): string[];
|
|
399
|
-
/**
|
|
400
|
-
* RFC-419 M1:刷新某 client 名下**全部持有**租约的心跳(WS ping 触发)。对称于
|
|
401
|
-
* `releaseAllForClient`——遍历 owners,对该 clientId 持有的每个 sessionId 刷新心跳。
|
|
402
|
-
* 返回被刷新的 sessionId 列表。
|
|
403
|
-
*/
|
|
404
|
-
heartbeatAllForClient(clientId: string): string[];
|
|
405
|
-
/** ownerOf:debug/UI 需要现处 leaseOwner。 */
|
|
406
|
-
ownerOf(sessionId: string): string | undefined;
|
|
407
|
-
/** canClientWrite(sessionId, clientId):Chat.query/Chat.* 的前置校验。 */
|
|
408
|
-
canClientWrite(sessionId: string, clientId: string): boolean;
|
|
409
|
-
/**
|
|
410
|
-
* RFC-335 S4 补丁:force_acquire——强抢走 sessionId 的写权(不论原持有者问同)。
|
|
411
|
-
* 用于 kill -9 后原来 client 占着 lease 没释放的人工接管场景。
|
|
412
|
-
* 返回原 owner(若有)及新 owner 状态。
|
|
413
|
-
* **审计语义**:调用方负责把本 action 记为「显式人工 force」——非普通共享;
|
|
414
|
-
* 原 owner 后续才需改为「写权被剥夺」。
|
|
415
|
-
*/
|
|
416
|
-
forceAcquire(sessionId: string, clientId: string): {
|
|
417
|
-
previousOwner: string | undefined;
|
|
418
|
-
newOwner: string;
|
|
419
|
-
};
|
|
420
|
-
/**
|
|
421
|
-
* RFC-381 M2:刷新持有者心跳(kill -9 存活证明)。仅持有者可刷新(幂等 no-op)。
|
|
422
|
-
* 供 WS ping/pong 看门狗调用——心跳超时(如 3× ping 间隔)的持有者视为死租约,
|
|
423
|
-
* 可由 `evictStale` 接管。
|
|
424
|
-
*/
|
|
425
|
-
heartbeat(sessionId: string, clientId: string): void;
|
|
426
|
-
/**
|
|
427
|
-
* RFC-381 M2:驱逐超时未心跳的死租约。返回被驱逐的 sessionId 列表。
|
|
428
|
-
* 由看门狗定时调用(调用方定周期);被驱逐后新 acquire 可正常接管。
|
|
429
|
-
*/
|
|
430
|
-
evictStale(now?: number): string[];
|
|
431
|
-
}
|
|
432
|
-
type WriteLeaseAcquireResult = {
|
|
433
|
-
kind: 'acquired';
|
|
912
|
+
declare function createHttpApp(handlers: Handlers, options?: HttpAppOptions): Hono;
|
|
913
|
+
//#endregion
|
|
914
|
+
//#region src/web-host.d.ts
|
|
915
|
+
declare function effectiveHostname(request: Request): string | undefined;
|
|
916
|
+
declare function checkRequestHost(request: Request): HostGateDecision;
|
|
917
|
+
interface HostGateDecision {
|
|
918
|
+
readonly allowed: boolean;
|
|
919
|
+
readonly reason?: 'missing-host' | 'foreign-host';
|
|
920
|
+
}
|
|
921
|
+
declare function checkHostHeader(hostHeader: string | undefined): HostGateDecision;
|
|
922
|
+
interface WebLaunchTicket {
|
|
923
|
+
readonly code: string;
|
|
924
|
+
readonly token: string;
|
|
925
|
+
readonly sessionId?: string;
|
|
926
|
+
readonly expiresAt: number;
|
|
927
|
+
readonly tokenExpiresAt: number;
|
|
928
|
+
}
|
|
929
|
+
interface WebLaunchRegistry {
|
|
930
|
+
issue(sessionId?: string): WebLaunchTicket;
|
|
931
|
+
redeem(code: string): WebLaunchTicket | undefined;
|
|
932
|
+
accept(token: string): boolean;
|
|
933
|
+
sessionOf(token: string): string | undefined;
|
|
934
|
+
claimsOf(token: string): TicketClaims | undefined;
|
|
935
|
+
size(): number;
|
|
936
|
+
}
|
|
937
|
+
interface WebLaunchRegistryOptions {
|
|
938
|
+
readonly ttlMs?: number;
|
|
939
|
+
readonly sessionTtlMs?: number;
|
|
940
|
+
readonly now?: () => number;
|
|
941
|
+
readonly mintToken?: () => string;
|
|
942
|
+
}
|
|
943
|
+
declare function createWebLaunchRegistry(options?: WebLaunchRegistryOptions): WebLaunchRegistry;
|
|
944
|
+
interface StaticAsset {
|
|
945
|
+
readonly contentType: string;
|
|
946
|
+
readonly body: Buffer;
|
|
947
|
+
}
|
|
948
|
+
interface StaticRoot {
|
|
949
|
+
readonly root: string;
|
|
950
|
+
readonly fallbackFile?: string;
|
|
951
|
+
}
|
|
952
|
+
type StaticResolution = StaticAsset | {
|
|
953
|
+
readonly status: 404;
|
|
434
954
|
} | {
|
|
435
|
-
|
|
436
|
-
leaseOwner: string;
|
|
955
|
+
readonly fallback: string;
|
|
437
956
|
};
|
|
957
|
+
declare function resolveStaticAsset(roots: readonly StaticRoot[], requestPath: string): StaticResolution;
|
|
958
|
+
declare function checkHostHeaderWhenPresent(hostHeader: string | undefined): HostGateDecision;
|
|
959
|
+
declare function checkOriginHeader(origin: string | undefined): HostGateDecision;
|
|
960
|
+
declare function loopbackHostAllowList(): (hostHeader: string | undefined) => boolean;
|
|
438
961
|
//#endregion
|
|
439
|
-
//#region src/
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
interface
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
declare
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
962
|
+
//#region src/ws.d.ts
|
|
963
|
+
type WebSocketCloseReason = 'server-close' | 'client-close' | 'error' | 'stale' | 'auth-required' | 'auth-failed' | 'resync-required';
|
|
964
|
+
interface WebSocketManagerOptions {
|
|
965
|
+
path?: string;
|
|
966
|
+
authToken?: string;
|
|
967
|
+
readToken?: string;
|
|
968
|
+
readTokenWorkspaceScope?: readonly string[] | (() => readonly string[] | undefined);
|
|
969
|
+
tokenWorkspaceScope?: readonly string[];
|
|
970
|
+
principalId?: string;
|
|
971
|
+
heartbeatIntervalMs?: number;
|
|
972
|
+
heartbeatTimeoutMs?: number;
|
|
973
|
+
authFrameTimeoutMs?: number;
|
|
974
|
+
closeGraceMs?: number;
|
|
975
|
+
attachedWriters?: AttachedWritersRegistry;
|
|
976
|
+
requireHandshake?: boolean;
|
|
977
|
+
methodAllowList?: readonly ServiceMethod[];
|
|
978
|
+
onConnectionStale?: (info: {
|
|
979
|
+
connectionId: string;
|
|
980
|
+
lastSeenAt: number;
|
|
981
|
+
now: number;
|
|
982
|
+
}) => void;
|
|
983
|
+
onConnectionOpen?: (info: {
|
|
984
|
+
connectionId: string;
|
|
985
|
+
}) => void;
|
|
986
|
+
onConnectionClose?: (info: {
|
|
987
|
+
connectionId: string;
|
|
988
|
+
reason: WebSocketCloseReason;
|
|
989
|
+
bufferedBytes: number;
|
|
990
|
+
lastSeenAgoMs: number;
|
|
991
|
+
droppedFrames: number;
|
|
992
|
+
sessions: number;
|
|
993
|
+
}) => void;
|
|
994
|
+
onResponseUndeliverable?: (info: {
|
|
995
|
+
type: string;
|
|
996
|
+
id: string;
|
|
997
|
+
}) => void;
|
|
998
|
+
onConnectionAuthenticated?: (info: {
|
|
999
|
+
connectionId: string;
|
|
1000
|
+
isFollow: boolean;
|
|
1001
|
+
clientFeatures: readonly string[];
|
|
1002
|
+
}) => void;
|
|
1003
|
+
ticketOf?(token: string): TicketClaims | undefined;
|
|
1004
|
+
allowHost?(hostHeader: string | undefined): boolean;
|
|
1005
|
+
allowOrigin?(origin: string | undefined): boolean;
|
|
1006
|
+
}
|
|
1007
|
+
interface UpgradeServer {
|
|
1008
|
+
on(event: 'upgrade', listener: (req: IncomingMessage, socket: Duplex, head: Buffer) => void): unknown;
|
|
1009
|
+
off(event: 'upgrade', listener: (req: IncomingMessage, socket: Duplex, head: Buffer) => void): unknown;
|
|
1010
|
+
}
|
|
1011
|
+
interface WebSocketManager {
|
|
1012
|
+
attach(server: UpgradeServer): void;
|
|
1013
|
+
close(): void;
|
|
1014
|
+
}
|
|
1015
|
+
declare function createWebSocketManager(handlers: Handlers, relay: EventRelay, options?: WebSocketManagerOptions): WebSocketManager;
|
|
1016
|
+
//#endregion
|
|
1017
|
+
//#region src/server.d.ts
|
|
1018
|
+
interface ServiceServerOptions {
|
|
1019
|
+
handlers: Handlers;
|
|
1020
|
+
relay: EventRelay;
|
|
1021
|
+
http?: HttpAppOptions;
|
|
1022
|
+
ws?: WebSocketManagerOptions;
|
|
1023
|
+
ticketOf?(token: string): TicketClaims | undefined;
|
|
1024
|
+
}
|
|
1025
|
+
interface ServiceServer {
|
|
1026
|
+
httpApp: Hono;
|
|
1027
|
+
attach(server: Server): void;
|
|
1028
|
+
close(): void;
|
|
1029
|
+
}
|
|
1030
|
+
declare function createServiceServer(options: ServiceServerOptions): ServiceServer;
|
|
1031
|
+
//#endregion
|
|
1032
|
+
//#region src/extension-event-bus.d.ts
|
|
1033
|
+
interface ExtensionEventBus extends ExtensionRequestHandlers {
|
|
1034
|
+
publisherFor(workspaceKey: string, owner: string, isActive: () => boolean): ExtensionRpcAttachmentHost;
|
|
1035
|
+
}
|
|
1036
|
+
interface ExtensionEventBusOptions extends ExtensionRpcDispatcherOptions {
|
|
1037
|
+
epoch: string;
|
|
1038
|
+
}
|
|
1039
|
+
declare function createExtensionEventBus(options: ExtensionEventBusOptions): ExtensionEventBus;
|
|
1040
|
+
//#endregion
|
|
1041
|
+
//#region src/extension-catalog.d.ts
|
|
1042
|
+
interface ExtensionCatalogOptions extends ExtensionRpcDispatcherOptions {
|
|
1043
|
+
epoch: string;
|
|
1044
|
+
}
|
|
1045
|
+
declare function createExtensionCatalogHandlers(options: ExtensionCatalogOptions): ExtensionRequestHandlers;
|
|
1046
|
+
//#endregion
|
|
1047
|
+
//#region src/extension-request.d.ts
|
|
1048
|
+
interface ExtensionRequestHandlerOptions extends ExtensionCatalogOptions {
|
|
1049
|
+
approval?: ExtensionApprovalHandlers;
|
|
1050
|
+
events?: ExtensionEventBus;
|
|
1051
|
+
}
|
|
1052
|
+
declare function createExtensionRequestHandlers(options: ExtensionRequestHandlerOptions): ExtensionRequestHandlers;
|
|
1053
|
+
//#endregion
|
|
1054
|
+
//#region src/approval-channel.d.ts
|
|
1055
|
+
interface ApprovalChannelOptions {
|
|
1056
|
+
now(): number;
|
|
1057
|
+
randomId?(): string;
|
|
1058
|
+
}
|
|
1059
|
+
declare class ApprovalChannel implements ApprovalChannelPort {
|
|
1060
|
+
#private;
|
|
1061
|
+
constructor(options: ApprovalChannelOptions);
|
|
1062
|
+
request(input: ApprovalRequestInput): Promise<ApprovalDecision>;
|
|
1063
|
+
resolve(nonce: string, decision: ApprovalDecision): boolean;
|
|
1064
|
+
pending(): readonly ApprovalRequest[];
|
|
1065
|
+
subscribe(listener: () => void): () => void;
|
|
1066
|
+
private notify;
|
|
1067
|
+
}
|
|
1068
|
+
//#endregion
|
|
1069
|
+
//#region src/repository-routes.d.ts
|
|
1070
|
+
declare const REPOSITORY_READ_PAGE = 500;
|
|
1071
|
+
type RepositoryWorkspaceScope = '*' | readonly string[];
|
|
1072
|
+
interface RepositoryScopeDimensions {
|
|
1073
|
+
workspaces: RepositoryWorkspaceScope;
|
|
1074
|
+
principals?: RepositoryWorkspaceScope;
|
|
1075
|
+
}
|
|
1076
|
+
type RepositoryScope = '*' | RepositoryScopeDimensions;
|
|
1077
|
+
interface RepositoryRoutesOptions {
|
|
1078
|
+
repository: SessionRepository;
|
|
1079
|
+
scope: RepositoryScope | (() => RepositoryScope);
|
|
1080
|
+
methods?: readonly ServiceMethod[];
|
|
1081
|
+
}
|
|
1082
|
+
interface RepositoryReadPage {
|
|
1083
|
+
events: TrajectoryEvent[];
|
|
1084
|
+
nextSeq: number;
|
|
1085
|
+
done: boolean;
|
|
1086
|
+
}
|
|
1087
|
+
interface RepositoryConflictPayload {
|
|
1088
|
+
sessionId: string;
|
|
1089
|
+
expected: number;
|
|
1090
|
+
got: number;
|
|
1091
|
+
}
|
|
1092
|
+
declare class RepositoryConflictError extends ServiceError {
|
|
1093
|
+
readonly conflict: RepositoryConflictPayload;
|
|
1094
|
+
constructor(conflict: RepositoryConflictPayload);
|
|
1095
|
+
}
|
|
1096
|
+
declare function createRepositoryRoutes(options: RepositoryRoutesOptions): Handlers;
|
|
1097
|
+
//#endregion
|
|
1098
|
+
//#region src/transport.d.ts
|
|
1099
|
+
interface WebSocketReconnectOptions {
|
|
1100
|
+
maxAttempts: number;
|
|
1101
|
+
backoffMs?: number;
|
|
1102
|
+
maxBackoffMs?: number;
|
|
1103
|
+
}
|
|
1104
|
+
type WebSocketTransportCloseReason = 'local' | 'remote' | 'exhausted' | 'stale' | 'auth-failed' | 'resync-required';
|
|
1105
|
+
interface WebSocketTransportOptions {
|
|
1106
|
+
reconnect?: WebSocketReconnectOptions;
|
|
1107
|
+
authToken?: string;
|
|
1108
|
+
mode?: 'follow' | 'attach';
|
|
1109
|
+
features?: readonly string[];
|
|
1110
|
+
socketFactory?: (url: string) => WebSocket;
|
|
1111
|
+
writeGate?: () => boolean;
|
|
1112
|
+
}
|
|
1113
|
+
interface WebSocketTransportHandle {
|
|
1114
|
+
transport: WireTransport;
|
|
1115
|
+
ready: Promise<void>;
|
|
1116
|
+
close(): void;
|
|
1117
|
+
closeReason(): WebSocketTransportCloseReason | undefined;
|
|
1118
|
+
generation(): number;
|
|
1119
|
+
}
|
|
1120
|
+
declare function createWebSocketTransport(url: string, options?: WebSocketTransportOptions): WebSocketTransportHandle;
|
|
1121
|
+
//#endregion
|
|
1122
|
+
//#region src/quiescence-owner.d.ts
|
|
1123
|
+
interface AskPersistencePort {
|
|
1124
|
+
flushPendingWrites?(): Promise<{
|
|
1125
|
+
failures: number;
|
|
1126
|
+
remaining: number;
|
|
1127
|
+
}>;
|
|
1128
|
+
}
|
|
1129
|
+
interface AskPersistenceOwner {
|
|
1130
|
+
id: string;
|
|
1131
|
+
phase: 'flush-durable';
|
|
1132
|
+
cancelability: 'blocking';
|
|
1133
|
+
drain(deadlineAt: number): Promise<{
|
|
1134
|
+
drained: boolean;
|
|
1135
|
+
detail?: string;
|
|
1136
|
+
}>;
|
|
1137
|
+
}
|
|
1138
|
+
declare function askPersistenceQuiescenceOwner(port: AskPersistencePort, id?: string): AskPersistenceOwner;
|
|
1139
|
+
//#endregion
|
|
1140
|
+
//#region src/ask-notify.d.ts
|
|
1141
|
+
interface AskNotificationInput {
|
|
1142
|
+
requestId: string;
|
|
1143
|
+
runtimeEpoch: string;
|
|
1144
|
+
channel: 'permission' | 'hitl';
|
|
1145
|
+
summary: string;
|
|
1146
|
+
}
|
|
1147
|
+
interface AskNotifierOptions {
|
|
1148
|
+
cooldownMs?: number;
|
|
1149
|
+
now?: () => number;
|
|
1150
|
+
notify(input: AskNotificationInput): void;
|
|
1151
|
+
}
|
|
1152
|
+
interface AskNotifier {
|
|
1153
|
+
onPending(entries: readonly AskNotificationInput[]): number;
|
|
1154
|
+
seenCount(): number;
|
|
1155
|
+
}
|
|
1156
|
+
declare function redactedSummaryOf(input: {
|
|
1157
|
+
channel: 'permission' | 'hitl';
|
|
1158
|
+
tool?: string;
|
|
1159
|
+
text?: string;
|
|
1160
|
+
limit?: number;
|
|
1161
|
+
}): string;
|
|
1162
|
+
declare function createAskNotifier(options: AskNotifierOptions): AskNotifier;
|
|
1163
|
+
declare function identityOf(entry: {
|
|
1164
|
+
requestId: string;
|
|
1165
|
+
runtimeEpoch: string;
|
|
1166
|
+
}): string;
|
|
1167
|
+
//#endregion
|
|
1168
|
+
//#region src/hub-discovery-source.d.ts
|
|
1169
|
+
interface HubDiscoverySource {
|
|
1170
|
+
list(): Promise<readonly HubDiscoveryInfo[]>;
|
|
1171
|
+
credentialTokenOf(record: unknown): Promise<string | undefined>;
|
|
1172
|
+
credentialOf(record: unknown): Promise<HubCredential | null>;
|
|
1173
|
+
}
|
|
1174
|
+
declare function createHubDiscoverySource(home: string): HubDiscoverySource;
|
|
610
1175
|
//#endregion
|
|
611
|
-
|
|
612
|
-
/**
|
|
613
|
-
* 进程内事件总线(M29-04-01)。
|
|
614
|
-
*
|
|
615
|
-
* SSE 路由和 storage append 路由共享此实例:
|
|
616
|
-
* - SSE: `eventBus.on(topic, cb)` 订阅 append 事件 → SSE push
|
|
617
|
-
* - Storage: `eventBus.emit(event)` 发布 append 事件 → 广播给所有 SSE 订阅者
|
|
618
|
-
*
|
|
619
|
-
* 设计决策:模块级单例而非 CodingService 成员——
|
|
620
|
-
* 两个独立路由(events.ts 和 storage.ts)都需要访问同一实例,
|
|
621
|
-
* 单例避免了通过 CodingService 传参的耦合。
|
|
622
|
-
*/
|
|
623
|
-
interface AppendEvent {
|
|
624
|
-
/** topic,如 'sessions'。 */
|
|
625
|
-
namespace: string;
|
|
626
|
-
/**
|
|
627
|
-
* workspace 分区键。SSE live-push 据此按订阅者 wsKey 过滤——缺省(legacy/单租户)
|
|
628
|
-
* 不携带则订阅者收全量。多租户下 emit 必带,订阅者按 wsKey 隔离(防 B12 跨 workspace 泄漏)。
|
|
629
|
-
*/
|
|
630
|
-
wsKey?: string;
|
|
631
|
-
docId: string;
|
|
632
|
-
entry: unknown;
|
|
633
|
-
/** Unix ms。 */
|
|
634
|
-
ts: number;
|
|
635
|
-
}
|
|
636
|
-
type Unsubscribe = () => void;
|
|
637
|
-
declare class EventBus {
|
|
638
|
-
private listeners;
|
|
639
|
-
/**
|
|
640
|
-
* 订阅某个 namespace 的 append 事件。
|
|
641
|
-
* @returns 取消订阅函数。
|
|
642
|
-
*/
|
|
643
|
-
on(namespace: string, callback: (event: AppendEvent) => void): Unsubscribe;
|
|
644
|
-
/**
|
|
645
|
-
* 发布 append 事件到所有订阅了对应 namespace 的监听器。
|
|
646
|
-
* 单个监听器异常不影响其他监听器。
|
|
647
|
-
*/
|
|
648
|
-
emit(event: AppendEvent): void;
|
|
649
|
-
/** 仅测试使用。 */
|
|
650
|
-
reset(): void;
|
|
651
|
-
/** 调试/测试用。 */
|
|
652
|
-
get listenerCount(): number;
|
|
653
|
-
}
|
|
654
|
-
declare const eventBus: EventBus;
|
|
655
|
-
//#endregion
|
|
656
|
-
export { type AppendEvent, type AuthorityDescriptor, type ChatApprovalData, type ChatAskUserResponseData, type ChatPlanApprovalResponseData, type ChatQueryData, CodingService, type CodingServiceOptions, DebugBridge, type DebuggerCommandData, type DebuggerSetBreakpointData, type DebuggerSetBreakpointsActiveData, EventBridge, EventBus, type EventLogRead, type IMessageSender, InboundRouter, type LogEntryData, PERSISTENCED_DEFAULT_PORT, type PersistencedOptions, type ProjectorState, type SequencedEvent, type SerializedMessage, type SerializedToolCall, SessionEventLog, type SessionSnapshot, type SessionSubscribeData, type Unsubscribe, type WebSocketClientMessage, type WebSocketClientMessageType, WebSocketManager, type WebSocketMessage, createCodingService, createProjectorState, encodeSessionEvent, eventBus, startPersistenced };
|
|
1176
|
+
export { ANONYMOUS_LOCAL_CONTEXT, ASK_ESCALATION_PERMISSION_TIMEOUT_DEFAULT_MS, type ActivationServicePort, ApprovalChannel, type ApprovalChannelOptions, type AskAccessAction, type AskClient, type AskConnection, type AskDiagnostic, type AskHost, type AskHostOptions, type AskInvalidationReason, type AskLineage, type AskNotificationInput, type AskNotifier, type AskNotifierOptions, type AskObserverCloseReason, type AskOutcome, type AskPeer, type AskPersistenceOwner, type AskPersistencePort, type AskReceipt, type AskRef, type AskRespond, type AskScope, type AskScopeGrant, type AskScopeView, type AskSessionPolicy, type AskSubscription, type AskViewMessage, type AskVisibilityPolicy, type AskWireFrame, type AuthServicePort, type Authorizer, type BoundAskHandlers, type ConnectionBinding, type ConnectionBindingInput, type ContextFromTokenOptions, type CostSummaryServicePort, type Credential, type CredentialDecisionInput, type CredentialDenial, type CredentialFacts, DEFAULT_ASK_TIMEOUT_MS, type DraftsServicePort, EXTENSION_RESERVED_METHODS, type EventFanout, type EventFanoutOptions, type EventRelay, type ExtensionApprovalChannel, type ExtensionApprovalHandlers, type ExtensionApprovalOptions, type ExtensionApprovalPending, type ExtensionApprovalResponder, type ExtensionCatalogOptions, type ExtensionEventBus, type ExtensionEventBusOptions, type ExtensionPermissionsServicePort, type ExtensionRequestHandlerOptions, type ExtensionRequestHandlers, type ExtensionRpcDispatcherOptions, type ExtensionRpcRequest, type FoldViewStateServicePort, GLOBAL_EVENTS_CHANNEL, HUB_CAPABILITY_ASK, HUB_CAPABILITY_EXTENSION_RPC, HUB_CAPABILITY_FOLLOW_SCOPE, HUB_CAPABILITY_HTTP, HUB_CAPABILITY_REPOSITORY, HUB_CAPABILITY_WORK_IDENTITY_V2, HUB_CAPABILITY_WS, HUB_WIRE_VERSION, type HandlerOptions, type Handlers, type HitlAnswer, type HitlAskRequest, type HitlReply, type HostGateDecision, type HttpAppOptions, type HubCandidateRejection, type HubCandidateRejectionReason, type HubDiscoveryInfo, type HubDiscoveryLease, type HubDiscoveryLeaseOptions, type HubDiscoverySource, type InProcessClient, type InProcessClientOptions, type InputHistoryServicePort, type InstallServicePort, type JobsServicePort, type McpServicePort, type MemoryEntryServicePort, type MockService, type MockServiceOptions, type ModelAvailabilityServicePort, type ModelOperationsServicePort, type ModelPreferencesServicePort, type ParsedAskFrame, type PendingAsk, type PendingAskStore, type PermissionAskRef, type PermissionAskRequest, type PermissionAskResponse, type Principal, type PrincipalOptions, type PrincipalSource, type ProviderFallbackServicePort, type ProviderServicePort, REPOSITORY_READ_PAGE, RESOURCE_READ_CAP_BYTES, type RateLimitInfo, RepositoryConflictError, type RepositoryConflictPayload, type RepositoryReadPage, type RepositoryRoutesOptions, type RepositoryScope, type RepositoryScopeDimensions, type RepositoryWorkspaceScope, type RequestContext, RequestForbiddenError, type RequestTransport, type ResolveHubClientOptions, type ResolvedHubClient, type RouteMethodMeta, type RouteSet, type RouteSetEntry, type RouteTarget, type RuntimeAskChannels, type RuntimeAskChannelsOptions, type RuntimeAskSubscription, SERVICE_METHODS, SERVICE_MIN_WIRE_VERSION, SERVICE_WIRE_VERSION, type SchedulesServicePort, type ServiceClient, ServiceError, type ServiceEvent, type ServiceEventHandler, type ServiceServer, type ServiceServerOptions, type ServiceSource, type SessionAskScope, type SessionDiagnosticsServicePort, type SessionEntry, type SessionPinApplied, type SessionPinMode, type SessionPinOutcome, type SessionPinRejected, type SessionPinResult, type SessionPrepareResult, type SessionRestoreResult, type SettingsServicePort, type SkillServicePort, type SpaceCatalogServicePort, type StaticAsset, type StaticResolution, type StaticRoot, type StreamErrorKind, TICKET_READ_METHODS, type TargetExtractor, type TicketClaims, type TicketMode, type TokenChannel, type TokenVerification, type TokenVerificationOptions, type TrustServicePort, type TurnScript, type TurnStep, type UpdatesServicePort, type WebLaunchRegistry, type WebLaunchRegistryOptions, type WebLaunchTicket, type WebSocketManager, type WebSocketManagerOptions, type WebSocketReconnectOptions, type WebSocketTransportHandle, type WebSocketTransportOptions, type WireCloseInfo, type WireCompatibility, type WireCompatibilityInput, type WireRequestHandlers, type WireTransport, type WorkspaceScopeOptions, aggregateAskScopes, askDescendantScopesOf, askPersistenceQuiescenceOwner, askSessionPolicyOf, assertCredentialAllowed, bySession, byWorkspace, canAnswerScope, checkHostHeader, checkHostHeaderWhenPresent, checkOriginHeader, checkRequestHost, composeRoutes, contextFromToken, contextWithClientId, createAskHost, createAskNotifier, createConnectionBinding, createDefaultAuthorizer, createEventFanout, createEventRelay, createExtensionApprovalChannel, createExtensionApprovalHandlers, createExtensionCatalogHandlers, createExtensionEventBus, createExtensionRequestHandlers, createExtensionRpcDispatcher, createFilePendingAskStore, createHandlers, createHttpApp, createHttpWsClient, createHubDiscoverySource, createInProcessClient, createMockService, createRepositoryRoutes, createRuntimeAskChannels, createServiceServer, createTokenVerifier, createWebLaunchRegistry, createWebSocketManager, createWebSocketTransport, credentialDenialOf, credentialFromFacts, credentialOf, credentialWorkspaceScope, declaresAskEscalation, defaultTurnScript, defineRoutes, effectiveHostname, escalatedPermissionTimeoutMsOf, globalTarget, handleWireRequest, hubCapabilitiesOf, hubDiscoveryDir, hubDiscoveryPath, identityOf, isReadOnlyMethod, isServiceError, isServiceMethod, isValidHubDiscoveryInfo, judgeWireCompatibility, listHubDiscoveryFiles, loopbackHostAllowList, mergeHandlers, parseApprovalRespondPayload, parseAskFrame, parseAskOpenPayload, parseAskRef, parseAskRespond, parseAskScope, parseAskScopePayload, parseAskViewMessage, parseHitlAnswer, parseHitlAskRequest, parseHitlReply, parseHitlRespondPayload, parsePermissionAskRef, parsePermissionAskRequest, parsePermissionAskResponse, parseResourceAddress, principalFromToken, readHubDiscoveryFile, readResourceFile, redactedSummaryOf, removeHubDiscoveryFile, resolveHubClient, resolveHubCredential, resolveStaticAsset, route, scopeKey, startHubDiscoveryLease, tokenFingerprint, validateHitlReply, validatePermissionResponse, viewMessageScope, visibilityOf, visibleChildScopes, writeHubDiscoveryFile };
|