@x-otto/service 0.1.0-alpha.9 → 0.4.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.
Files changed (56) hide show
  1. package/dist/ask-host.d.ts +18 -0
  2. package/dist/ask-validate.d.ts +47 -0
  3. package/dist/attached-writers.d.ts +9 -0
  4. package/dist/authorize.d.ts +8 -0
  5. package/dist/chat-routes.d.ts +4 -0
  6. package/dist/client-entry.d.ts +114 -0
  7. package/dist/client-entry.js +1414 -0
  8. package/dist/connection-binding.d.ts +9 -0
  9. package/dist/context.d.ts +51 -0
  10. package/dist/credential.d.ts +51 -0
  11. package/dist/errors.d.ts +11 -0
  12. package/dist/events.d.ts +21 -0
  13. package/dist/extension-approval.d.ts +41 -0
  14. package/dist/extension-rpc.d.ts +31 -0
  15. package/dist/fanout.d.ts +13 -0
  16. package/dist/handler-options.d.ts +252 -0
  17. package/dist/handlers.d.ts +23 -0
  18. package/dist/hub-capabilities.d.ts +15 -0
  19. package/dist/index.d.ts +1144 -625
  20. package/dist/index.js +8591 -44
  21. package/dist/methods.d.ts +5 -0
  22. package/dist/mock.d.ts +23 -0
  23. package/dist/resource-read.d.ts +4 -0
  24. package/dist/route-read-only.d.ts +1 -0
  25. package/dist/route-set.d.ts +22 -0
  26. package/dist/route-targets.d.ts +6 -0
  27. package/dist/route-validate.d.ts +15 -0
  28. package/dist/routes/ask-routes.d.ts +3 -0
  29. package/dist/routes/auth-routes.d.ts +3 -0
  30. package/dist/routes/core-routes.d.ts +3 -0
  31. package/dist/routes/extension-routes.d.ts +3 -0
  32. package/dist/routes/index.d.ts +6 -0
  33. package/dist/routes/plugin-routes.d.ts +3 -0
  34. package/dist/routes/repository-meta.d.ts +2 -0
  35. package/dist/routes/session-routes.d.ts +3 -0
  36. package/dist/routes/session-runtime-routes.d.ts +5 -0
  37. package/dist/routes/settings-routes.d.ts +3 -0
  38. package/dist/routes/support.d.ts +7 -0
  39. package/dist/routes/worker-routes.d.ts +2 -0
  40. package/dist/routes/workspace-routes.d.ts +3 -0
  41. package/dist/send-attempt-table.d.ts +35 -0
  42. package/dist/serialize-shared.d.ts +1 -0
  43. package/dist/source-for-session.d.ts +4 -0
  44. package/dist/subscription-backfill.d.ts +19 -0
  45. package/dist/target-extractors.d.ts +18 -0
  46. package/dist/token-verifier.d.ts +12 -0
  47. package/dist/vite.d.ts +11 -0
  48. package/dist/vite.js +4273 -0
  49. package/dist/web-host.d.ts +52 -0
  50. package/dist/wire-stats.d.ts +6 -0
  51. package/dist/wire.d.ts +12 -0
  52. package/dist/ws.d.ts +66 -0
  53. package/package.json +19 -31
  54. package/README.md +0 -135
  55. package/dist/index.d.ts.map +0 -1
  56. package/dist/index.js.map +0 -1
@@ -0,0 +1,9 @@
1
+ import type { ServiceMethod } from '@x-otto/kernel';
2
+ export interface ConnectionBindingInput {
3
+ methodAllowList?: readonly ServiceMethod[];
4
+ }
5
+ export interface ConnectionBinding {
6
+ allows(method: ServiceMethod): boolean;
7
+ reasonFor(method: ServiceMethod): 'method-not-in-bindings' | undefined;
8
+ }
9
+ export declare function createConnectionBinding(input?: ConnectionBindingInput): ConnectionBinding;
@@ -0,0 +1,51 @@
1
+ import type { Credential } from './credential.ts';
2
+ export type RequestTransport = 'http' | 'ws' | 'in-process';
3
+ export type PrincipalSource = 'token' | 'local' | 'anonymous';
4
+ export interface Principal {
5
+ id: string;
6
+ tokenId?: string;
7
+ source: PrincipalSource;
8
+ sessionToken?: true;
9
+ sessionId?: string;
10
+ }
11
+ export interface RequestContext {
12
+ principalId: string;
13
+ principal: Principal;
14
+ credential: Credential;
15
+ clientId: string;
16
+ transport: RequestTransport;
17
+ connectionId?: string;
18
+ remoteAddr?: string;
19
+ tokenId?: string;
20
+ workspaceScope?: readonly string[] | '*';
21
+ clientFeatures?: readonly string[];
22
+ follow?: boolean;
23
+ }
24
+ export declare const ANONYMOUS_LOCAL_CONTEXT: RequestContext;
25
+ export declare function contextWithClientId(clientId: string | undefined): RequestContext;
26
+ export interface PrincipalOptions {
27
+ principalId?: string;
28
+ transport?: RequestTransport;
29
+ sessionToken?: boolean;
30
+ sessionId?: string;
31
+ clientFeatures?: readonly string[];
32
+ }
33
+ export declare function tokensMatch(provided: string | undefined, expected: string): boolean;
34
+ export declare function tokenFingerprint(token: string): string;
35
+ export declare function principalSourceOf(token: string | undefined, transport: RequestTransport | undefined): PrincipalSource;
36
+ export declare function principalFromToken(token: string | undefined, options?: PrincipalOptions): Principal;
37
+ export interface ContextFromTokenOptions {
38
+ principalId?: string;
39
+ clientId?: string;
40
+ transport?: RequestTransport;
41
+ connectionId?: string;
42
+ remoteAddr?: string;
43
+ tokenId?: string;
44
+ workspaceScope?: readonly string[] | '*';
45
+ sessionToken?: boolean;
46
+ sessionId?: string;
47
+ clientFeatures?: readonly string[];
48
+ follow?: boolean;
49
+ credential?: Credential;
50
+ }
51
+ export declare function contextFromToken(token: string | undefined, options?: ContextFromTokenOptions): RequestContext;
@@ -0,0 +1,51 @@
1
+ import type { ServiceMethod } from '@x-otto/kernel';
2
+ import type { PrincipalSource } from './context.ts';
3
+ import type { RouteTarget } from './route-targets.ts';
4
+ export type TicketMode = 'read' | 'write';
5
+ export interface TicketClaims {
6
+ mode: TicketMode;
7
+ sessionId?: string;
8
+ methods?: readonly ServiceMethod[];
9
+ events?: readonly string[];
10
+ clientId?: string;
11
+ }
12
+ export declare function eventsOfCredential(credential: Credential): readonly string[] | undefined;
13
+ export type Credential = {
14
+ kind: 'owner';
15
+ } | {
16
+ kind: 'reader';
17
+ } | {
18
+ kind: 'ticket';
19
+ claims: TicketClaims;
20
+ };
21
+ export type CredentialDenial = 'method-not-granted' | 'not-a-read' | 'cross-session';
22
+ export declare const TICKET_READ_METHODS: readonly ServiceMethod[];
23
+ export interface CredentialFacts {
24
+ source: PrincipalSource;
25
+ follow?: boolean;
26
+ sessionToken?: boolean;
27
+ sessionId?: string;
28
+ }
29
+ export interface CredentialDecisionInput {
30
+ credential: Credential;
31
+ method: ServiceMethod;
32
+ readOnly: boolean;
33
+ payload: unknown;
34
+ target: RouteTarget | undefined;
35
+ }
36
+ export interface WorkspaceScopeOptions {
37
+ tokenWorkspaceScope?: readonly string[] | '*';
38
+ readTokenWorkspaceScope?: readonly string[] | '*' | (() => readonly string[] | undefined);
39
+ }
40
+ export declare function credentialDenialOf(input: CredentialDecisionInput): CredentialDenial | undefined;
41
+ export declare function credentialWorkspaceScope(credential: Credential, options: WorkspaceScopeOptions): readonly string[] | '*' | undefined;
42
+ export declare function credentialFromFacts(facts: CredentialFacts): Credential;
43
+ export declare function credentialOf(context: {
44
+ credential?: Credential;
45
+ principal?: {
46
+ source?: PrincipalSource;
47
+ sessionToken?: boolean;
48
+ sessionId?: string;
49
+ };
50
+ follow?: boolean;
51
+ }): Credential;
@@ -0,0 +1,11 @@
1
+ export declare class ServiceError extends Error {
2
+ readonly code: string;
3
+ readonly details?: unknown | undefined;
4
+ constructor(code: string, message: string, details?: unknown | undefined);
5
+ }
6
+ export declare function isServiceError(error: unknown): error is ServiceError;
7
+ export declare class RequestForbiddenError extends ServiceError {
8
+ readonly action: string;
9
+ readonly principalId: string;
10
+ constructor(action: string, principalId: string);
11
+ }
@@ -0,0 +1,21 @@
1
+ import type { ServiceEvent } from '@x-otto/kernel';
2
+ export type BroadcastEvent = ServiceEvent extends infer Event ? Event extends {
3
+ sessionId: string;
4
+ } ? Omit<Event, 'sessionId'> : never : never;
5
+ export interface EventRelay {
6
+ push(sessionId: string, event: ServiceEvent): void;
7
+ subscribe(sessionId: string, handler: (event: ServiceEvent) => void): () => void;
8
+ sessionCount(): number;
9
+ broadcast(event: BroadcastEvent): void;
10
+ }
11
+ export declare const GLOBAL_EVENTS_CHANNEL = "__global__";
12
+ export declare function isPrivateAskEvent(event: unknown): boolean;
13
+ export declare function isPerSessionOnlyEvent(event: unknown): boolean;
14
+ export declare function isScopedGlobalEvent(event: unknown): boolean;
15
+ export declare function lacksGlobalScope(event: unknown): boolean;
16
+ export type SessionMetaChangedEvent = Extract<ServiceEvent, {
17
+ kind: 'session.meta.changed';
18
+ }>;
19
+ export declare function isSessionMetaChangedEvent(event: unknown): event is SessionMetaChangedEvent;
20
+ export declare function filterPrivateAskEvents(handler: (event: ServiceEvent) => void): (event: ServiceEvent) => void;
21
+ export declare function createEventRelay(): EventRelay;
@@ -0,0 +1,41 @@
1
+ import type { ApprovalDecision, ApprovalRequest, ApprovalRequestInput, ExtensionRpcCatalogPort, ExtensionRpcLimits } from '@x-otto/kernel';
2
+ import type { ExtensionHumanProofPort, ExtensionRequestHandlers } from './extension-rpc.ts';
3
+ export interface ExtensionApprovalChannel {
4
+ request(input: ApprovalRequestInput): Promise<ApprovalDecision>;
5
+ pending?(): readonly ApprovalRequest[];
6
+ resolve?(nonce: string, decision: ApprovalDecision): boolean;
7
+ subscribe?(listener: () => void): () => void;
8
+ extensionApprovalNonce?(nonce: string): boolean;
9
+ }
10
+ export interface ExtensionApprovalPending {
11
+ nonce: string;
12
+ workspaceKey: string;
13
+ method: string;
14
+ contractVersion: number;
15
+ action: string;
16
+ subject: string;
17
+ createdAt: string;
18
+ summary?: string;
19
+ }
20
+ export interface ExtensionApprovalResponder {
21
+ pending(workspaceKey?: string): readonly ExtensionApprovalPending[];
22
+ subscribe(listener: () => void): () => void;
23
+ resolve(input: {
24
+ workspaceKey: string;
25
+ nonce: string;
26
+ decision: 'allow' | 'deny';
27
+ }): boolean;
28
+ }
29
+ export interface ExtensionApprovalHandlers extends ExtensionRequestHandlers, ExtensionHumanProofPort {
30
+ responder: ExtensionApprovalResponder;
31
+ }
32
+ export interface ExtensionApprovalOptions {
33
+ ttlMs?: number;
34
+ limits?: Partial<ExtensionRpcLimits>;
35
+ now?(): number;
36
+ randomId?(): string;
37
+ channelOf(workspaceKey: string): ExtensionApprovalChannel | undefined;
38
+ catalogOf(workspaceKey: string): ExtensionRpcCatalogPort | undefined;
39
+ }
40
+ export declare function createExtensionApprovalHandlers(options: ExtensionApprovalOptions): ExtensionApprovalHandlers;
41
+ export declare function createExtensionApprovalChannel(base: ExtensionApprovalChannel | undefined, responder: ExtensionApprovalResponder): ExtensionApprovalChannel;
@@ -0,0 +1,31 @@
1
+ import { DEFAULT_EXTENSION_RPC_LIMITS } from '@x-otto/kernel';
2
+ import type { AskPeer, ExtensionCallerOrigin, ExtensionClientFrame, ExtensionRpcCatalogPort, ExtensionRpcLimits } from '@x-otto/kernel';
3
+ import type { RequestContext } from './context.ts';
4
+ export { DEFAULT_EXTENSION_RPC_LIMITS };
5
+ export interface ExtensionRpcRequest {
6
+ type: string;
7
+ payload: unknown;
8
+ contractVersion?: number;
9
+ }
10
+ export interface ExtensionRequestHandlers {
11
+ handleExtension(request: ExtensionRpcRequest, context?: RequestContext, origin?: ExtensionCallerOrigin): Promise<unknown>;
12
+ bindExtension?(peer: AskPeer, receive: (frame: ExtensionClientFrame) => void): () => void;
13
+ }
14
+ export interface ExtensionHumanProofPort {
15
+ consumeProof(proof: unknown, expected: {
16
+ workspaceKey: string;
17
+ method: string;
18
+ contractVersion: number;
19
+ action: string;
20
+ subject: string;
21
+ }): boolean;
22
+ }
23
+ export interface ExtensionRpcDispatcherOptions {
24
+ reservedMethods?: ReadonlySet<string>;
25
+ origin?: ExtensionCallerOrigin;
26
+ limits?: Partial<ExtensionRpcLimits>;
27
+ proofs?: ExtensionHumanProofPort;
28
+ catalogOf(workspaceKey: string): ExtensionRpcCatalogPort | undefined;
29
+ }
30
+ export declare const EXTENSION_RESERVED_METHODS: ReadonlySet<string>;
31
+ export declare function createExtensionRpcDispatcher(options: ExtensionRpcDispatcherOptions): ExtensionRequestHandlers;
@@ -0,0 +1,13 @@
1
+ import type { ServiceEvent } from '@x-otto/kernel';
2
+ export type ServiceEventHandler = (event: ServiceEvent) => void;
3
+ export interface EventFanoutOptions {
4
+ onFirstSubscriber?: (sessionId: string) => void;
5
+ onLastSubscriberRemoved?: (sessionId: string) => void;
6
+ }
7
+ export interface EventFanout {
8
+ add(sessionId: string, handler: ServiceEventHandler): () => void;
9
+ deliver(sessionId: string, deliver: (handler: ServiceEventHandler) => void): void;
10
+ clear(): void;
11
+ sessionCount(): number;
12
+ }
13
+ export declare function createEventFanout(options?: EventFanoutOptions): EventFanout;
@@ -0,0 +1,252 @@
1
+ import type { EnvSnapshotRuntime } from '@x-otto/kernel';
2
+ import type { RuntimeDiagnosticInput } from '@x-otto/kernel';
3
+ import type { AssemblyDiagnostic, PerformanceDiagnosticsSnapshot, PermissionMode, ServiceMethod, ServiceSource, SettingDescribeEntry, SettingFileScope, SettingWriteResult, WorkspaceReadiness } from '@x-otto/kernel';
4
+ import type { AskHost } from './ask-host.ts';
5
+ import type { BroadcastEvent } from './events.ts';
6
+ import type { RequestContext } from './context.ts';
7
+ import type { RouteTarget } from './route-targets.ts';
8
+ import type { ExtensionApprovalChannel } from './extension-approval.ts';
9
+ import type { ExtensionRequestHandlers } from './extension-rpc.ts';
10
+ import type { RouteSet } from './route-set.ts';
11
+ export type Authorizer = (context: RequestContext, action: ServiceMethod, payload: unknown, target?: RouteTarget) => Promise<void> | void;
12
+ export interface AuthServicePort {
13
+ status(): Promise<readonly import('@x-otto/kernel').AuthStatusEntry[]>;
14
+ login(request: import('@x-otto/kernel').AuthLoginRequest, owner?: string, options?: {
15
+ async?: boolean;
16
+ }): Promise<import('@x-otto/kernel').AuthLoginReceipt>;
17
+ loginStatus?(input: {
18
+ loginId: string;
19
+ }, owner?: string): Promise<import('@x-otto/kernel').AuthLoginStatus | undefined>;
20
+ setKey(input: import('@x-otto/kernel').LlmAuthSetKeyInput): Promise<{
21
+ status: 'success' | 'failed';
22
+ message?: string;
23
+ accountId?: string;
24
+ }>;
25
+ account?(input: import('@x-otto/kernel').LlmAuthAccountInput): Promise<import('@x-otto/kernel').LlmAuthAccountOutput>;
26
+ logout(providerId: string): Promise<{
27
+ loggedOut: boolean;
28
+ }>;
29
+ submitCode?(input: {
30
+ loginId: string;
31
+ code: string;
32
+ }, owner?: string): Promise<{
33
+ accepted: boolean;
34
+ message?: string;
35
+ }>;
36
+ cancel?(loginId: string, owner?: string): Promise<{
37
+ cancelled: boolean;
38
+ }>;
39
+ activeLoginCount?(): number;
40
+ abortAllLogins?(): void;
41
+ }
42
+ export interface SettingsServicePort {
43
+ get(key: string): Promise<{
44
+ value?: unknown;
45
+ revision?: number;
46
+ }>;
47
+ getAll(): Promise<{
48
+ values: Record<string, unknown>;
49
+ registrants?: readonly string[];
50
+ }>;
51
+ set(key: string, value: unknown, scope?: SettingFileScope): Promise<SettingWriteResult>;
52
+ subscribe(keys: readonly string[] | undefined): Promise<{
53
+ subscribed: true;
54
+ }>;
55
+ clear?(key: string, scope?: SettingFileScope): Promise<SettingWriteResult>;
56
+ describe?(keys: readonly string[]): Promise<{
57
+ entries: readonly SettingDescribeEntry[];
58
+ }>;
59
+ adoptedPermissionMode?(): PermissionMode | undefined;
60
+ }
61
+ export interface SchedulesServicePort {
62
+ list(sessionId: string): Promise<readonly import('@x-otto/kernel').ScheduleEntryView[]>;
63
+ delete(sessionId: string, id: string): Promise<boolean>;
64
+ runPending?(sessionId: string, id: string): Promise<boolean>;
65
+ dismissPending?(sessionId: string, id: string): Promise<boolean>;
66
+ health?(sessionId: string): Promise<{
67
+ unrecoverablePreTrim: boolean;
68
+ }>;
69
+ }
70
+ export interface SpaceCatalogServicePort {
71
+ catalog(): {
72
+ ref: import('@x-otto/kernel').SpaceRef;
73
+ manifest: import('@x-otto/kernel').SpaceManifest;
74
+ activated: readonly string[];
75
+ };
76
+ }
77
+ export interface ProviderFallbackServicePort {
78
+ state(): {
79
+ active: boolean;
80
+ reason?: import('@x-otto/kernel').ProviderUnavailableReason;
81
+ provider?: string;
82
+ hasEnvKey: boolean;
83
+ };
84
+ }
85
+ export interface MemoryEntryServicePort {
86
+ list(cwd: string): Promise<readonly import('@x-otto/kernel').MemoryEntrySummary[]>;
87
+ read(name: string, cwd: string): Promise<string | null>;
88
+ }
89
+ export interface ActivationServicePort {
90
+ activation(ids?: readonly string[]): Promise<readonly import('@x-otto/kernel').ActivationReport[]>;
91
+ }
92
+ export interface UpdatesServicePort {
93
+ status(): import('@x-otto/kernel').UpdateStatus;
94
+ check(options?: {
95
+ force?: boolean;
96
+ }): Promise<readonly import('@x-otto/kernel').UpdateCandidateView[]>;
97
+ }
98
+ export interface CostSummaryView {
99
+ totalCost: number;
100
+ entries: readonly {
101
+ sessionId: string;
102
+ model: {
103
+ provider: string;
104
+ id: string;
105
+ };
106
+ usage: {
107
+ inputTokens: number;
108
+ outputTokens: number;
109
+ cacheReadTokens?: number;
110
+ cacheWriteTokens?: number;
111
+ };
112
+ cost: number;
113
+ }[];
114
+ }
115
+ export interface CostSummaryServicePort {
116
+ summary(sessionId?: string, options?: {
117
+ allowBackfill?: boolean;
118
+ }): CostSummaryView | Promise<CostSummaryView>;
119
+ summaryOf?(sessionIds: readonly string[]): CostSummaryView | Promise<CostSummaryView>;
120
+ }
121
+ export interface FoldViewStateServicePort {
122
+ load(sessionId: string): Promise<import('@x-otto/kernel').PersistedFoldViewState | undefined>;
123
+ save(sessionId: string, state: {
124
+ folded: readonly string[];
125
+ expanded: readonly string[];
126
+ }): Promise<void>;
127
+ }
128
+ export interface ModelAvailabilityServicePort {
129
+ snapshot(): {
130
+ entries: readonly import('@x-otto/kernel').ModelAvailability[];
131
+ version: number;
132
+ };
133
+ }
134
+ export interface InputHistoryServicePort {
135
+ load(sessionId: string): Promise<readonly string[]>;
136
+ save(sessionId: string, entries: readonly string[]): Promise<void>;
137
+ }
138
+ export interface DraftsServicePort {
139
+ list(workspaceKey: string): Promise<readonly import('@x-otto/kernel').DraftRecord[]>;
140
+ save(workspaceKey: string, text: string): Promise<import('@x-otto/kernel').DraftRecord>;
141
+ remove(workspaceKey: string, ids: readonly string[]): Promise<void>;
142
+ }
143
+ export interface ExtensionPermissionsServicePort {
144
+ list(): Promise<{
145
+ records: Readonly<Record<string, import('@x-otto/kernel').ExtensionPermissionRecord>>;
146
+ trustedPlugins?: readonly string[];
147
+ untrustedPlugins?: readonly string[];
148
+ trustAll?: boolean;
149
+ }>;
150
+ }
151
+ export interface ProviderServicePort {
152
+ list(): Promise<readonly import('@x-otto/kernel').ProviderSummary[]>;
153
+ }
154
+ export interface InstallServicePort {
155
+ list(): Promise<readonly import('@x-otto/kernel').InstalledItem[]>;
156
+ uninstall(id: string): Promise<import('@x-otto/kernel').UninstallResult>;
157
+ }
158
+ export interface ModelPreferencesServicePort {
159
+ snapshot(): Promise<import('@x-otto/kernel').ModelPreferenceSnapshot>;
160
+ setEnabled(modelId: string, isEnabled: boolean): Promise<import('@x-otto/kernel').ModelPreferenceSnapshot>;
161
+ setCapabilityOverride(catalogId: string, patch: import('@x-otto/kernel').ModelCapabilityOverride): Promise<import('@x-otto/kernel').ModelPreferenceSnapshot>;
162
+ clearCapabilityOverride(catalogId: string): Promise<import('@x-otto/kernel').ModelPreferenceSnapshot>;
163
+ }
164
+ export interface ModelOperationsServicePort {
165
+ refresh(providerId?: string): Promise<{
166
+ providers: number;
167
+ models: number;
168
+ failed: number;
169
+ reason?: string;
170
+ }>;
171
+ unfreeze(targetId: string): {
172
+ ok: boolean;
173
+ id: string;
174
+ };
175
+ }
176
+ export interface SkillServicePort {
177
+ snapshot(): Promise<import('@x-otto/kernel').SkillSnapshot>;
178
+ setEnabled(name: string, enabled: boolean): Promise<import('@x-otto/kernel').SkillEnableState>;
179
+ reload(): Promise<import('@x-otto/kernel').SkillRefreshOutcome>;
180
+ }
181
+ export interface McpServicePort {
182
+ snapshot(): Promise<import('@x-otto/kernel').McpCatalogSnapshot>;
183
+ setEnabled(name: string, enabled: boolean): Promise<import('@x-otto/kernel').McpEnableOutcome>;
184
+ reload(): Promise<import('@x-otto/kernel').McpReloadOutcome>;
185
+ reconnect(name: string): Promise<import('@x-otto/kernel').McpReconnectOutcome>;
186
+ login(name: string): Promise<import('@x-otto/kernel').McpAuthOutcome>;
187
+ logout(name: string): Promise<import('@x-otto/kernel').McpAuthOutcome>;
188
+ }
189
+ export interface TrustServicePort {
190
+ query(root: string): Promise<import('@x-otto/kernel').TrustRecord | undefined>;
191
+ }
192
+ export interface SessionDiagnosticsServicePort {
193
+ inspectSource(path: string, cwd: string): Promise<unknown>;
194
+ auditLogs(mode: 'verify' | 'compact' | 'keep', sessionIds: readonly string[]): Promise<unknown>;
195
+ }
196
+ export interface JobsServicePort {
197
+ list(caller: string | undefined): Promise<readonly import('@x-otto/kernel').JobSnapshot[]>;
198
+ kill(id: string, caller: string | undefined): Promise<void>;
199
+ read?(id: string, caller: string | undefined): Promise<string>;
200
+ }
201
+ export interface HandlerOptions {
202
+ dataSource: ServiceSource;
203
+ authorize: Authorizer;
204
+ askHost?: AskHost;
205
+ instanceBoot?: string;
206
+ auth?: AuthServicePort;
207
+ settingsPort?: SettingsServicePort;
208
+ jobsPort?: JobsServicePort;
209
+ trustPort?: TrustServicePort;
210
+ skillPort?: SkillServicePort;
211
+ modelPreferencesPort?: ModelPreferencesServicePort;
212
+ modelOperationsPort?: ModelOperationsServicePort;
213
+ sessionDiagnosticsPort?: SessionDiagnosticsServicePort;
214
+ installPort?: InstallServicePort;
215
+ providerPort?: ProviderServicePort;
216
+ extensionPermissionsPort?: ExtensionPermissionsServicePort;
217
+ extension?: ExtensionRequestHandlers;
218
+ inputHistoryPort?: InputHistoryServicePort;
219
+ modelAvailabilityPort?: ModelAvailabilityServicePort;
220
+ foldViewStatePort?: FoldViewStateServicePort;
221
+ costSummaryPort?: CostSummaryServicePort;
222
+ updatesPort?: UpdatesServicePort;
223
+ activationPort?: ActivationServicePort;
224
+ memoryEntriesPort?: MemoryEntryServicePort;
225
+ providerFallbackPort?: ProviderFallbackServicePort;
226
+ spaceCatalogPort?: SpaceCatalogServicePort;
227
+ draftsPort?: DraftsServicePort;
228
+ mcpPort?: McpServicePort;
229
+ schedulesPort?: SchedulesServicePort;
230
+ routeSets?: () => readonly RouteSet[];
231
+ broadcastEvent?(event: BroadcastEvent): void;
232
+ reportDiagnostic?(diagnostic: RuntimeDiagnosticInput): void;
233
+ workspaceOf?(sessionId: string): Promise<string | undefined>;
234
+ workspaceKeyOfRuntime?(): string | undefined;
235
+ settingsPortOf?(workspaceKey: string): SettingsServicePort | undefined;
236
+ spaceCatalogPortOf?(workspaceKey: string): SpaceCatalogServicePort | undefined;
237
+ approvalChannelOf?(workspaceKey: string): ExtensionApprovalChannel | undefined;
238
+ assemblyDiagnostics?(): readonly AssemblyDiagnostic[];
239
+ performanceDiagnostics?(): PerformanceDiagnosticsSnapshot | undefined;
240
+ workspaceReadiness?(workspaceKey: string): WorkspaceReadiness | undefined;
241
+ envSnapshotOf?(names: readonly string[]): {
242
+ values: Readonly<Record<string, string | undefined>>;
243
+ runtime: EnvSnapshotRuntime;
244
+ } | undefined;
245
+ cwdContextOf?(workspaceKey: string): Promise<{
246
+ branch?: string;
247
+ dirty: boolean;
248
+ }> | undefined;
249
+ attachedWritersOf?(sessionId: string): readonly {
250
+ capable: boolean;
251
+ }[];
252
+ }
@@ -0,0 +1,23 @@
1
+ import type { AskInvalidationReason, AskPeer, AskScope, AskViewMessage, ServiceMethod, ServiceMethodInput, ServiceMethodOutput } from '@x-otto/kernel';
2
+ import type { ExtensionCallerOrigin, ExtensionClientFrame } from '@x-otto/kernel';
3
+ import type { ExtensionRpcRequest } from './extension-rpc.ts';
4
+ import type { RequestContext } from './context.ts';
5
+ import type { HandlerOptions } from './handler-options.ts';
6
+ export { isServiceError, ServiceError, RequestForbiddenError } from './errors.ts';
7
+ export { DEFAULT_SURFACE_READ_LIMIT, MAX_SURFACE_READ_LIMIT } from './routes/session-runtime-routes.ts';
8
+ export type { Authorizer, HandlerOptions } from './handler-options.ts';
9
+ export type { RouteMethodMeta, RouteSet, RouteSetEntry } from './route-set.ts';
10
+ export type { ServiceSource, SessionEntry, SessionListQuery, SessionPinApplied, SessionPinMode, SessionPinOutcome, SessionPinRejected, SessionPinResult, SessionRestoreResult, } from '@x-otto/kernel';
11
+ export interface Handlers {
12
+ attachedWriters?: import('./attached-writers.ts').AttachedWritersRegistry;
13
+ handle(type: ServiceMethod, payload?: ServiceMethodInput<ServiceMethod>, context?: RequestContext): Promise<ServiceMethodOutput<ServiceMethod>>;
14
+ handleExtension?(request: ExtensionRpcRequest, context?: RequestContext, origin?: ExtensionCallerOrigin): Promise<unknown>;
15
+ bindExtension?(peer: AskPeer, receive: (frame: ExtensionClientFrame) => void): () => void;
16
+ listTypes(): readonly ServiceMethod[];
17
+ bindAsk?(peer: AskPeer, receive: (message: AskViewMessage) => void, onInvalidated?: (scope: AskScope, reason: AskInvalidationReason) => void): BoundAskHandlers;
18
+ }
19
+ export interface BoundAskHandlers extends Handlers {
20
+ close(): void;
21
+ }
22
+ export declare function createHandlers(deps: HandlerOptions): Handlers;
23
+ export declare function mergeHandlers(...sets: readonly Handlers[]): Handlers;
@@ -0,0 +1,15 @@
1
+ import type { Handlers } from './handlers.ts';
2
+ export declare const HUB_CAPABILITY_HTTP = "http";
3
+ export declare const HUB_CAPABILITY_WS = "ws";
4
+ export declare const HUB_CAPABILITY_ASK = "ask";
5
+ export declare const HUB_CAPABILITY_REPOSITORY = "repository";
6
+ export declare const HUB_CAPABILITY_WORK_IDENTITY_V2 = "work-identity-v2";
7
+ export declare const HUB_CAPABILITY_FOLLOW_SCOPE = "follow-scope";
8
+ export declare const HUB_CAPABILITY_EXTENSION_RPC = "extensionRpc";
9
+ export interface HubCapabilityFacts {
10
+ types: readonly string[];
11
+ hasAsk: boolean;
12
+ hasExtension?: boolean;
13
+ }
14
+ export declare function hubCapabilitiesOf(handlers: Handlers): readonly string[];
15
+ export declare function hubCapabilitiesFrom(facts: HubCapabilityFacts): readonly string[];