@workerdeck/server 0.7.0 → 0.9.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 +95 -5
- package/build/index.mjs +486 -71
- package/build/index.mjs.map +1 -1
- package/package.json +6 -6
package/build/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IncomingMessage, Server, ServerResponse } from "node:http";
|
|
2
|
-
import { BridgeAnswer, BrowserBridgeExecutor, ClaudeAuthProbe, ParkedExecution, Runner, RunnerSnapshot, SessionRunnerConfig, ToolExecutionResult } from "@workerdeck/core";
|
|
2
|
+
import { AttachmentInput, BridgeAnswer, BrowserBridgeExecutor, ClaudeAuthProbe, EngineAdapter, ParkedExecution, Runner, RunnerSnapshot, SessionRunnerConfig, ToolExecutionResult } from "@workerdeck/core";
|
|
3
3
|
import { JobQueue, QueueAdapter } from "@workerdeck/queue";
|
|
4
|
-
import { CreateSessionRequest, JobEvent, ProfileInfo, SdkSessionSummary, ServerFrame, SessionInfo, SessionNotification, SessionWebhookConfig } from "@workerdeck/protocol";
|
|
4
|
+
import { CreateSessionRequest, JobEvent, MessageAttachment, ProfileEngine, ProfileInfo, SdkSessionSummary, ServerFrame, SessionInfo, SessionNotification, SessionWebhookConfig } from "@workerdeck/protocol";
|
|
5
5
|
|
|
6
6
|
//#region src/registry.d.ts
|
|
7
7
|
type SessionRegistryOptions = {
|
|
@@ -369,6 +369,20 @@ type WorkerServerOptions = {
|
|
|
369
369
|
* that keeps a per-keystroke search cheap on a real source tree. */
|
|
370
370
|
ignore?: string[];
|
|
371
371
|
};
|
|
372
|
+
/**
|
|
373
|
+
* Message attachments (`{basePath}/sessions/:id/attachments`) — the photos and
|
|
374
|
+
* files a client sends alongside a message. Always on; these knobs only size it.
|
|
375
|
+
*
|
|
376
|
+
* There is no grant to make here the way `hostFiles.write` is one: an upload
|
|
377
|
+
* lands in the session's own in-memory hold and reaches the model as message
|
|
378
|
+
* content, which is exactly what typing does. What it *can* do is cost memory,
|
|
379
|
+
* so both caps default low enough that a phone camera roll cannot fill the
|
|
380
|
+
* gateway.
|
|
381
|
+
*/
|
|
382
|
+
attachments?: {
|
|
383
|
+
/** Largest single upload; over it is a 413. Default 10 MiB. */maxFileBytes?: number; /** Ceiling on what one session holds at once. Default 64 MiB. */
|
|
384
|
+
maxSessionBytes?: number;
|
|
385
|
+
};
|
|
372
386
|
/**
|
|
373
387
|
* Named Claude Code config directories sessions can run under (each becomes the
|
|
374
388
|
* session's CLAUDE_CONFIG_DIR — settings, memory, skills, and the credentials the
|
|
@@ -455,8 +469,11 @@ type WorkerServerOptions = {
|
|
|
455
469
|
probe?: ClaudeAuthProbe;
|
|
456
470
|
timeoutMs?: number;
|
|
457
471
|
};
|
|
458
|
-
/** Injectable lister for GET /sdk-sessions (tests)
|
|
459
|
-
*
|
|
472
|
+
/** Injectable lister for GET /sdk-sessions (tests) — honored for the CLAUDE
|
|
473
|
+
* engine only, like the injectable claude auth probe (it predates the adapter
|
|
474
|
+
* layer). Defaults to the claude adapter's lister (the SDK's on-disk session
|
|
475
|
+
* store); other engines always answer through their adapter's
|
|
476
|
+
* `listSessions`. */
|
|
460
477
|
listSdkSessions?: SdkSessionLister;
|
|
461
478
|
/** Enable the job queue (`/jobs` + `/queue` routes). Jobs run as ordinary registry
|
|
462
479
|
* sessions — attachable over the sessions WS — governed by these limits. */
|
|
@@ -509,6 +526,8 @@ type WorkerServerOptions = {
|
|
|
509
526
|
* Kept as a host hook so the server package neither imports a model SDK nor
|
|
510
527
|
* decides how provider credentials are resolved: the factory reads them from
|
|
511
528
|
* the operator's environment, exactly like the Claude credential chain.
|
|
529
|
+
* `claude` and `codex` profiles never come through here — those engines ship
|
|
530
|
+
* as in-repo adapters (`@workerdeck/core`'s `getEngineAdapter`).
|
|
512
531
|
*
|
|
513
532
|
* May be async: assembly that has to await — a per-session MCP connect, a
|
|
514
533
|
* credential lookup — belongs here, with `AiSdkRunnerConfig.onClose` as the
|
|
@@ -516,6 +535,13 @@ type WorkerServerOptions = {
|
|
|
516
535
|
* the message, a job goes straight to `failed`.
|
|
517
536
|
*/
|
|
518
537
|
createEngineRunner?: (context: EngineRunnerContext) => Runner | Promise<Runner>;
|
|
538
|
+
/**
|
|
539
|
+
* Adapter overrides, keyed by engine — **for tests only** (the server
|
|
540
|
+
* integration suite injects a fake codex engine so `pnpm test` spawns no
|
|
541
|
+
* binary). Not a public extension point: third engines belong in core as
|
|
542
|
+
* adapters, or behind `createEngineRunner` as provider profiles.
|
|
543
|
+
*/
|
|
544
|
+
engines?: Partial<Record<ProfileEngine, EngineAdapter>>;
|
|
519
545
|
};
|
|
520
546
|
type EngineRunnerContext = {
|
|
521
547
|
/** The session config, with profile defaults already applied. */config: SessionRunnerConfig; /** The profile that selected this engine. */
|
|
@@ -568,5 +594,69 @@ type WorkerServer = {
|
|
|
568
594
|
};
|
|
569
595
|
declare function createWorkerServer(options?: WorkerServerOptions): WorkerServer;
|
|
570
596
|
//#endregion
|
|
571
|
-
|
|
597
|
+
//#region src/attachments.d.ts
|
|
598
|
+
type AttachmentStoreOptions = {
|
|
599
|
+
/** Largest single upload. Default 10 MiB. */maxFileBytes?: number; /** Ceiling on everything one session is holding. Default 64 MiB. */
|
|
600
|
+
maxSessionBytes?: number;
|
|
601
|
+
};
|
|
602
|
+
type AttachmentRejection = {
|
|
603
|
+
code: 'too_large';
|
|
604
|
+
message: string;
|
|
605
|
+
} | {
|
|
606
|
+
code: 'session_full';
|
|
607
|
+
message: string;
|
|
608
|
+
} | {
|
|
609
|
+
code: 'unsupported_type';
|
|
610
|
+
message: string;
|
|
611
|
+
} | {
|
|
612
|
+
code: 'empty';
|
|
613
|
+
message: string;
|
|
614
|
+
};
|
|
615
|
+
type PutResult = {
|
|
616
|
+
ok: true;
|
|
617
|
+
attachment: MessageAttachment;
|
|
618
|
+
} | {
|
|
619
|
+
ok: false;
|
|
620
|
+
error: AttachmentRejection;
|
|
621
|
+
};
|
|
622
|
+
/**
|
|
623
|
+
* Per-session hold for files the user attached to a message.
|
|
624
|
+
*
|
|
625
|
+
* In memory, and deliberately so. An attachment is only *needed* for the instant
|
|
626
|
+
* between the upload and the message that names it; everything after that is
|
|
627
|
+
* convenience (a client re-rendering a thumbnail after a reattach). That is the
|
|
628
|
+
* same bargain `GET /sessions/:id/files` makes — the session's lifetime, no
|
|
629
|
+
* durability tier — and it keeps the gateway from accumulating a photo library
|
|
630
|
+
* on disk that nobody asked it to look after.
|
|
631
|
+
*
|
|
632
|
+
* Both caps are enforced here rather than at the route, so a host embedding the
|
|
633
|
+
* server cannot forget one: a single file that is too big is a 413, and so is a
|
|
634
|
+
* session whose total would go over.
|
|
635
|
+
*/
|
|
636
|
+
declare class AttachmentStore {
|
|
637
|
+
#private;
|
|
638
|
+
constructor(options?: AttachmentStoreOptions);
|
|
639
|
+
get maxFileBytes(): number;
|
|
640
|
+
put(sessionId: string, name: string, mediaType: string, body: Buffer): PutResult;
|
|
641
|
+
/** The stored record, bytes included — for the download route and for the send
|
|
642
|
+
* path that turns ids into content blocks. */
|
|
643
|
+
get(sessionId: string, id: string): AttachmentInput | undefined;
|
|
644
|
+
/**
|
|
645
|
+
* Resolve the ids a `user_message` named, in the order given.
|
|
646
|
+
*
|
|
647
|
+
* Missing ids are reported rather than skipped: a message that quietly lost its
|
|
648
|
+
* picture reads as the model ignoring it, which is a far worse failure than a
|
|
649
|
+
* command that errors.
|
|
650
|
+
*/
|
|
651
|
+
resolve(sessionId: string, ids: readonly string[]): {
|
|
652
|
+
ok: true;
|
|
653
|
+
attachments: AttachmentInput[];
|
|
654
|
+
} | {
|
|
655
|
+
ok: false;
|
|
656
|
+
missing: string[];
|
|
657
|
+
};
|
|
658
|
+
drop(sessionId: string): void;
|
|
659
|
+
}
|
|
660
|
+
//#endregion
|
|
661
|
+
export { AttachmentStore, type AttachmentStoreOptions, type Authenticator, BridgeHub, type BridgeHubOptions, type EngineRunnerContext, type FileSessionStoreOptions, MemorySessionStore, type ParkedSessionRecord, type ProfileStore, type QueueServerOptions, type SdkSessionLister, type SessionNotificationOptions, SessionNotifier, SessionParkManager, type SessionParkOptions, SessionRegistry, type SessionRegistryOptions, type SessionStore, type WorkerServer, type WorkerServerOptions, createFileProfileStore, createFileSessionStore, createMemoryProfileStore, createWorkerServer, toDurableRecord };
|
|
572
662
|
//# sourceMappingURL=index.d.mts.map
|