@byok-sdk/server 0.2.0 → 0.4.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/README.md +19 -1
- package/dist/auth.d.ts +32 -10
- package/dist/hub.d.ts +3 -3
- package/dist/index.js +205 -75
- package/dist/index.js.map +1 -1
- package/dist/sqlite-blob-store.d.ts +1 -0
- package/dist/sqlite-support.d.ts +14 -1
- package/dist/sqlite-task-store.d.ts +1 -0
- package/dist/task-store.d.ts +2 -1
- package/dist/types.d.ts +31 -1
- package/package.json +3 -2
|
@@ -72,6 +72,7 @@ export declare class SqliteBlobStore implements BlobStore {
|
|
|
72
72
|
private readonly selectBlobStmt;
|
|
73
73
|
private readonly selectUploadedStmt;
|
|
74
74
|
private readonly writeContentStmt;
|
|
75
|
+
private closed;
|
|
75
76
|
constructor(opts: SqliteBlobStoreOptions);
|
|
76
77
|
createUpload(input: CreateUploadInput, requestedBlobId?: string): Promise<{
|
|
77
78
|
blobId: string;
|
package/dist/sqlite-support.d.ts
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import type { DatabaseSync, DatabaseSyncOptions } from 'node:sqlite';
|
|
2
|
+
export type SqliteOpenStep = 'after-open' | 'after-wal';
|
|
3
|
+
/** Test-only seam for proving that post-open initialization failures release the native handle. */
|
|
4
|
+
export interface SqliteOpenFaultSeam {
|
|
5
|
+
onStep?(step: SqliteOpenStep): void;
|
|
6
|
+
close?(db: DatabaseSync): void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Preserve the initialization error after deterministically releasing an
|
|
10
|
+
* already-open SQLite handle. If cleanup itself fails, surface both failures
|
|
11
|
+
* instead of losing the reason construction failed or pretending ownership
|
|
12
|
+
* was returned.
|
|
13
|
+
*/
|
|
14
|
+
export declare function closeSqliteDatabaseAfterInitializationFailure(db: DatabaseSync, initializationError: unknown, message: string, close?: (db: DatabaseSync) => void): never;
|
|
2
15
|
/**
|
|
3
16
|
* Thrown when `node:sqlite` isn't available in the running Node.js binary.
|
|
4
17
|
* `node:sqlite` shipped in Node.js 22.5.0 (https://nodejs.org/api/sqlite.html)
|
|
@@ -64,7 +77,7 @@ export declare function isSqliteAvailable(): boolean;
|
|
|
64
77
|
* {@link isSqliteAvailable}) — callers don't need their own guard for that;
|
|
65
78
|
* this is the single choke point.
|
|
66
79
|
*/
|
|
67
|
-
export declare function openSqliteDatabase(path: string, options?: DatabaseSyncOptions): DatabaseSync;
|
|
80
|
+
export declare function openSqliteDatabase(path: string, options?: DatabaseSyncOptions, faults?: SqliteOpenFaultSeam): DatabaseSync;
|
|
68
81
|
/**
|
|
69
82
|
* Restrict `dbPath` and its WAL/SHM sibling files (`<path>-wal`,
|
|
70
83
|
* `<path>-shm` — created by SQLite itself once WAL mode is active and a
|
|
@@ -75,6 +75,7 @@ export declare class SqliteTaskStore implements TaskStore {
|
|
|
75
75
|
private readonly selectStmt;
|
|
76
76
|
private readonly selectAllStmt;
|
|
77
77
|
private readonly updatePendingApprovalIdStmt;
|
|
78
|
+
private closed;
|
|
78
79
|
constructor(opts: SqliteTaskStoreOptions);
|
|
79
80
|
create(input: CreateTaskInput): TaskRecord;
|
|
80
81
|
get(taskId: string): TaskRecord | undefined;
|
package/dist/task-store.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PermissionPolicy, type RuntimeId, type TaskState } from '@byok-sdk/protocol';
|
|
1
|
+
import { type PermissionPolicy, type RuntimeId, type TaskState, type ToolsetId } from '@byok-sdk/protocol';
|
|
2
2
|
import type { TaskSnapshot } from './types';
|
|
3
3
|
/** Thrown by a {@link TaskStore}'s `transition` when `from -> to` is not in TASK_TRANSITIONS. Every implementation (in-memory, SQLite, or otherwise) must throw this rather than silently applying an invalid move. */
|
|
4
4
|
export declare class IllegalTaskTransitionError extends Error {
|
|
@@ -12,6 +12,7 @@ export interface CreateTaskInput {
|
|
|
12
12
|
instruction: string;
|
|
13
13
|
runtime?: RuntimeId;
|
|
14
14
|
policy: PermissionPolicy;
|
|
15
|
+
requiredToolsets?: ToolsetId[];
|
|
15
16
|
deviceId?: string;
|
|
16
17
|
sessionRef?: string;
|
|
17
18
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentEventOrUnknown, BlobRef, PermissionPolicy, RuntimeCapabilities, RuntimeId, RuntimeInfo, TaskApprovalResolvedPayload, TaskArtifactPayload, TaskState } from '@byok-sdk/protocol';
|
|
1
|
+
import type { AgentEventOrUnknown, BlobRef, DispatchSelection, PermissionPolicy, RuntimeCapabilities, RuntimeId, RuntimeInfo, TaskApprovalResolvedPayload, TaskArtifactPayload, TaskState, ToolsetId } from '@byok-sdk/protocol';
|
|
2
2
|
import type { BlobStore } from './blob-store';
|
|
3
3
|
import type { RateLimiterOptions } from './rate-limiter';
|
|
4
4
|
import type { TaskStore } from './task-store';
|
|
@@ -84,10 +84,17 @@ export interface CreateByokServerOptions {
|
|
|
84
84
|
/** Input to {@link ByokServer.dispatch}. */
|
|
85
85
|
export interface DispatchInput {
|
|
86
86
|
instruction: string;
|
|
87
|
+
/**
|
|
88
|
+
* Authoritative web-selected target. When present, `runtime` is derived
|
|
89
|
+
* from `runtimeId`; supplying a different legacy `runtime` is rejected.
|
|
90
|
+
*/
|
|
91
|
+
dispatchSelection?: DispatchSelection;
|
|
87
92
|
runtime?: RuntimeId;
|
|
88
93
|
policy?: PermissionPolicy;
|
|
89
94
|
deviceId?: string;
|
|
90
95
|
sessionRef?: string;
|
|
96
|
+
/** Logical device-local MCP toolsets required for this task; never executable definitions. */
|
|
97
|
+
requiredToolsets?: ToolsetId[];
|
|
91
98
|
}
|
|
92
99
|
/** Outcome of a task that reached a terminal state. */
|
|
93
100
|
export interface TaskResult {
|
|
@@ -97,6 +104,26 @@ export interface TaskResult {
|
|
|
97
104
|
artifactRefs?: BlobRef[];
|
|
98
105
|
reason?: string;
|
|
99
106
|
retryable?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* The task's structured terminal result, projected verbatim from
|
|
109
|
+
* `task.complete.document` (`@byok-sdk/protocol`'s `messages.ts`) — the
|
|
110
|
+
* product's own JSON output, as opposed to `summary` (prose for a human)
|
|
111
|
+
* or `artifactRefs` (files). `unknown` deliberately: this SDK never
|
|
112
|
+
* understands or transforms the embedder's document schema. The wire
|
|
113
|
+
* schema already enforced the only two rules there are (JSON-serializable,
|
|
114
|
+
* within `RESULT_DOCUMENT_MAX_BYTES`) before this value ever reached the
|
|
115
|
+
* hub, so the projection neither re-validates nor re-measures it.
|
|
116
|
+
*
|
|
117
|
+
* Absent whenever the daemon sent none — which covers both a daemon with
|
|
118
|
+
* no `resultDocument` extractor configured and a pre-`result-document`
|
|
119
|
+
* daemon build that has no notion of the field at all.
|
|
120
|
+
*
|
|
121
|
+
* Persisted WITH `summary`/`artifactRefs` rather than beside them: the
|
|
122
|
+
* whole `TaskResult` is stored as a single `result_json` document
|
|
123
|
+
* (`sqlite-task-store.ts`), so this field reaches durable storage with
|
|
124
|
+
* exact parity and introduces no second authority for it.
|
|
125
|
+
*/
|
|
126
|
+
document?: unknown;
|
|
100
127
|
}
|
|
101
128
|
/**
|
|
102
129
|
* Normalized event stream for a dispatched task: incoming `task.progress`
|
|
@@ -163,6 +190,8 @@ export interface MachineInfo {
|
|
|
163
190
|
lastSeen?: string;
|
|
164
191
|
/** Runtimes detected on this device, as reported in its last `conn.hello` (M1: typed, replaces the old untyped `agents`). */
|
|
165
192
|
runtimes?: RuntimeInfo[];
|
|
193
|
+
/** Logical toolset IDs reported by the current daemon; omission means legacy/unknown. */
|
|
194
|
+
configuredToolsets?: ToolsetId[];
|
|
166
195
|
}
|
|
167
196
|
/** Snapshot of a task as tracked by the in-memory {@link TaskStore}. */
|
|
168
197
|
export interface TaskSnapshot {
|
|
@@ -181,6 +210,7 @@ export interface TaskSnapshot {
|
|
|
181
210
|
*/
|
|
182
211
|
runtime?: RuntimeId;
|
|
183
212
|
policy: PermissionPolicy;
|
|
213
|
+
requiredToolsets?: ToolsetId[];
|
|
184
214
|
deviceId?: string;
|
|
185
215
|
sessionRef?: string;
|
|
186
216
|
createdAt: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@byok-sdk/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "BYOK SDK server: in-memory M0 reference implementation of the SaaS-side coordinator",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"hono": "^4.12.30",
|
|
41
41
|
"jose": "^6.2.3",
|
|
42
42
|
"ws": "^8.21.1",
|
|
43
|
-
"@byok-sdk/
|
|
43
|
+
"@byok-sdk/core": "0.4.0",
|
|
44
|
+
"@byok-sdk/protocol": "0.4.0"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@types/ws": "^8.18.1"
|