@workerdeck/server 2.15.0 → 3.1.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/build/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { IncomingMessage, Server, ServerResponse } from "node:http";
2
- import { AttachmentInput, BridgeAnswer, BrowserBridgeExecutor, ClaudeAuthProbe, CostLedgerState, EngineAdapter, EngineSessionOptions, HostToolDefinition, LanguageModel, LocalShellSource, McpConnection, ParkedExecution, Runner, RunnerSnapshot, SHELL_REFUSAL, SessionInstructions, SessionRunnerConfig, ToolExecutionCall, ToolExecutionResult, ToolExecutor, ToolSet } from "@workerdeck/core";
2
+ import { AttachmentInput, BridgeAnswer, BrowserBridgeExecutor, ClaudeAuthProbe, CostLedgerState, EngineAdapter, EngineSessionOptions, HostToolDefinition, LanguageModel, LocalShellSource, McpConnection, ParkedExecution, Runner, RunnerSnapshot, SHELL_REFUSAL, SessionInstructions, SessionRunnerConfig, ShellDirectory, ToolExecutionCall, ToolExecutionResult, ToolExecutor, ToolSet } from "@workerdeck/core";
3
3
  import { JobQueue, QueueAdapter } from "@workerdeck/queue";
4
- import { ByModel, CreateSessionRequest, JobEvent, MessageAttachment, ModelRate, ProfileEngine, ProfileInfo, ProfileSpend, ProfileUsage, ProviderConfig, SdkSessionSummary, ServerFrame, SessionCapability, SessionInfo, SessionNotification, SessionWebhookConfig, ShellEndReason, ShellInfo, ShellOwner } from "@workerdeck/protocol";
4
+ import { ByModel, CreateSessionRequest, JobEvent, MessageAttachment, ModelRate, PricingTable, ProfileEngine, ProfileInfo, ProfileSpend, ProfileUsage, ProviderConfig, SdkSessionSummary, ServerFrame, SessionCapability, SessionInfo, SessionNotification, SessionWebhookConfig, ShellEndReason, ShellInfo, ShellOwner } from "@workerdeck/protocol";
5
5
  //#region src/services/bridge.d.ts
6
6
  type BridgeHubOptions = {
7
7
  timeoutMs?: number;
@@ -24,6 +24,11 @@ type SessionNotificationOptions = {
24
24
  attempts?: number;
25
25
  retryDelayMs?: number;
26
26
  decorateInfo?: (info: SessionInfo) => SessionInfo;
27
+ onError?: (error: unknown, context: NotificationErrorContext) => void;
28
+ };
29
+ type NotificationErrorContext = {
30
+ op: 'hook' | 'webhook';
31
+ sessionId: string;
27
32
  };
28
33
  declare class SessionNotifier {
29
34
  #private;
@@ -102,7 +107,7 @@ declare function createFileSessionStore(options?: FileSessionStoreOptions): Sess
102
107
  //#region src/services/parking.d.ts
103
108
  type ParkErrorContext = {
104
109
  sessionId: string;
105
- phase: 'park' | 'remember' | 'resume';
110
+ phase: 'park' | 'remember' | 'resume' | 'discard';
106
111
  };
107
112
  type SessionParkOptions = {
108
113
  registry: SessionRegistry;
@@ -113,6 +118,7 @@ type SessionParkOptions = {
113
118
  persistLive?: boolean;
114
119
  expiredGraceMs?: number;
115
120
  onParking?: (sessionId: string, executionId: string) => boolean;
121
+ onParked?: (sessionId: string, executionId: string) => void;
116
122
  onResumed?: (sessionId: string, runner: Runner) => void;
117
123
  onError?: (error: unknown, context: ParkErrorContext) => void;
118
124
  };
@@ -129,6 +135,7 @@ declare class SessionParkManager {
129
135
  onDetach(sessionId: string): void;
130
136
  sessionFor(executionId: string): string | undefined;
131
137
  get(id: string): Promise<StoredSessionRecord | null>;
138
+ retitle(id: string, title: string | undefined): Promise<SessionInfo | undefined>;
132
139
  listInfo(): Promise<SessionInfo[]>;
133
140
  ensureLive(id: string): Promise<Runner | undefined>;
134
141
  submitResult(executionId: string, result: ToolExecutionResult): Promise<{
@@ -164,7 +171,17 @@ type ProcessRow = {
164
171
  };
165
172
  type ProcessTable = () => ProcessRow[] | null;
166
173
  //#endregion
167
- //#region src/services/shells.d.ts
174
+ //#region src/lib/atomic-file.d.ts
175
+ type JsonWriteOptions = {
176
+ indent?: number;
177
+ trailingNewline?: boolean;
178
+ };
179
+ declare function isMissing(error: unknown): boolean;
180
+ declare function writeFileAtomic(path: string, data: string | Uint8Array): Promise<void>;
181
+ declare function writeJsonAtomic(path: string, value: unknown, options?: JsonWriteOptions): Promise<void>;
182
+ declare function readJsonOr(path: string, fallback: unknown): Promise<unknown>;
183
+ //#endregion
184
+ //#region src/services/shell-types.d.ts
168
185
  type ShellSize = {
169
186
  cols: number;
170
187
  rows: number;
@@ -188,7 +205,7 @@ type ShellAttachment = {
188
205
  detach: () => void;
189
206
  };
190
207
  type ShellOutputQuery = {
191
- view: 'text' | 'raw';
208
+ view: 'text' | 'raw' | 'screen';
192
209
  tail?: number;
193
210
  };
194
211
  type ShellErrorContext = {
@@ -196,6 +213,7 @@ type ShellErrorContext = {
196
213
  sessionId?: string;
197
214
  shellId?: string;
198
215
  };
216
+ type ShellErrorReporter = (error: unknown, context: ShellErrorContext) => void;
199
217
  type ShellRegistryOptions = {
200
218
  generation: string;
201
219
  artifactDir: string | null;
@@ -209,7 +227,7 @@ type ShellRegistryOptions = {
209
227
  tailFlushMs?: number;
210
228
  sweepIntervalMs?: number;
211
229
  processTable?: ProcessTable;
212
- onError?: (error: unknown, context: ShellErrorContext) => void;
230
+ onError?: ShellErrorReporter;
213
231
  };
214
232
  type StoredShellRecord = ShellInfo & {
215
233
  generation: string;
@@ -228,18 +246,29 @@ type ShellRegistry = {
228
246
  list: (sessionId: string) => ShellInfo[];
229
247
  running: () => ShellInfo[];
230
248
  kill: (sessionId: string, shellId: string, reason?: ShellEndReason) => ShellInfo | undefined;
249
+ setAgentWrite: (sessionId: string, shellId: string, enabled: boolean) => ShellInfo | undefined;
231
250
  killAll: (reason: ShellEndReason) => number;
232
251
  killAllSync: () => void;
233
252
  attach: (sessionId: string, shellId: string, sink: ShellSink) => Promise<ShellAttachment>;
234
253
  write: (sessionId: string, shellId: string, data: string) => void;
235
254
  resize: (sessionId: string, shellId: string, size: ShellSize) => ShellSize;
236
255
  output: (sessionId: string, shellId: string, query: ShellOutputQuery) => Promise<string | undefined>;
256
+ applicationCursorKeys: (sessionId: string, shellId: string) => Promise<boolean>;
257
+ changed: (sessionId: string, shellId: string, timeoutMs: number) => Promise<void>;
237
258
  hydrate: () => Promise<void>;
238
259
  sweep: () => Promise<void>;
239
260
  flush: () => Promise<void>;
240
261
  decorate: (info: SessionInfo) => SessionInfo;
241
262
  watch: (runner: Runner) => () => void;
242
263
  };
264
+ //#endregion
265
+ //#region src/services/shell-directory.d.ts
266
+ type ShellDirectoryDeps = {
267
+ runnerFor?: (sessionId: string) => Runner | undefined;
268
+ };
269
+ declare function createShellDirectory(registry: ShellRegistry, deps?: ShellDirectoryDeps): ShellDirectory;
270
+ //#endregion
271
+ //#region src/services/shells.d.ts
243
272
  declare function shellPermitted(shells: ShellRegistry | null, runner: Runner, operator: boolean): boolean;
244
273
  declare function createShellRegistry(options: ShellRegistryOptions): ShellRegistry;
245
274
  //#endregion
@@ -252,6 +281,7 @@ type SpendStore = {
252
281
  save(record: SpendRecord): Promise<void>;
253
282
  };
254
283
  type SpendLedgerOptions = {
284
+ pricing?: PricingTable;
255
285
  store?: SpendStore;
256
286
  monthlySubscriptionUsd?: (profile: string) => number | undefined;
257
287
  retentionDays?: number;
@@ -271,6 +301,7 @@ declare class SpendLedger {
271
301
  declare function createFileSpendStore(path: string, onError?: (error: unknown) => void): SpendStore;
272
302
  //#endregion
273
303
  //#region src/options.d.ts
304
+ type ShellAgentWriteOption = 'read-only' | 'gated' | 'allow';
274
305
  type SdkSessionLister = (options: {
275
306
  dir?: string;
276
307
  limit?: number;
@@ -296,6 +327,7 @@ type WorkerServerOptions = {
296
327
  artifactMaxBytes?: number;
297
328
  artifactTtlMs?: number;
298
329
  maxRunningPerSession?: number;
330
+ agentWrite?: ShellAgentWriteOption;
299
331
  };
300
332
  attachments?: {
301
333
  maxFileBytes?: number;
@@ -341,7 +373,9 @@ type WorkerServerOptions = {
341
373
  };
342
374
  createEngineRunner?: (context: EngineRunnerContext) => Runner | Promise<Runner>;
343
375
  engines?: Partial<Record<ProfileEngine, EngineAdapter>>;
376
+ onDiagnostic?: DiagnosticSink;
344
377
  };
378
+ type DiagnosticSink = (error: unknown, where: string) => void;
345
379
  type EngineRunnerContext = {
346
380
  config: SessionRunnerConfig;
347
381
  profile: ProfileInfo;
@@ -502,5 +536,5 @@ declare class ProfileUsageTracker {
502
536
  usage(profile: string, now?: number): ProfileUsage | undefined;
503
537
  }
504
538
  //#endregion
505
- export { AttachmentStore, type AttachmentStoreOptions, type Authenticator, BridgeHub, type BridgeHubOptions, type CarriedSession, type EngineRunnerContext, type FileSessionStoreOptions, MemorySessionStore, type ParkedSessionRecord, type ProcessRow, type ProcessTable, type ProducedFile, ProducedFileStore, type ProfileStore, ProfileUsageTracker, type ProviderRunnerOptions, type QueueServerOptions, type ReloadPlan, SHELL_REFUSAL, type SdkSessionLister, type SessionNotificationOptions, SessionNotifier, SessionParkManager, type SessionParkOptions, SessionRegistry, type SessionRegistryOptions, type SessionStore, type ShellRegistry, type ShellRegistryOptions, type ShellSink, SpendLedger, type SpendRecord, type SpendStore, type StoredSessionRecord, type StoredShellIndex, type StoredShellRecord, type WorkerServer, type WorkerServerOptions, createFileProfileStore, createFileSessionStore, createFileSpendStore, createMemoryProfileStore, createProviderRunner, createShellRegistry, createWorkerServer, dayKey, isDormant, reloadPlan, sandboxedProviderProfile, shellPermitted, toDurableRecord };
539
+ export { AttachmentStore, type AttachmentStoreOptions, type Authenticator, BridgeHub, type BridgeHubOptions, type CarriedSession, type DiagnosticSink, type EngineRunnerContext, type FileSessionStoreOptions, type JsonWriteOptions, MemorySessionStore, type NotificationErrorContext, type ParkedSessionRecord, type ProcessRow, type ProcessTable, type ProducedFile, ProducedFileStore, type ProfileStore, ProfileUsageTracker, type ProviderRunnerOptions, type QueueServerOptions, type ReloadPlan, SHELL_REFUSAL, type SdkSessionLister, type SessionNotificationOptions, SessionNotifier, SessionParkManager, type SessionParkOptions, SessionRegistry, type SessionRegistryOptions, type SessionStore, type ShellAgentWriteOption, type ShellDirectoryDeps, type ShellRegistry, type ShellRegistryOptions, type ShellSink, SpendLedger, type SpendRecord, type SpendStore, type StoredSessionRecord, type StoredShellIndex, type StoredShellRecord, type WorkerServer, type WorkerServerOptions, createFileProfileStore, createFileSessionStore, createFileSpendStore, createMemoryProfileStore, createProviderRunner, createShellDirectory, createShellRegistry, createWorkerServer, dayKey, isDormant, isMissing, readJsonOr, reloadPlan, sandboxedProviderProfile, shellPermitted, toDurableRecord, writeFileAtomic, writeJsonAtomic };
506
540
  //# sourceMappingURL=index.d.mts.map