@byok-sdk/server 0.16.0 → 0.18.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 +77 -0
- package/dist/index.d.ts +20 -3
- package/dist/index.js +325 -24
- package/dist/index.js.map +1 -1
- package/dist/stores/sqlite/device-directory.d.ts +26 -0
- package/dist/stores/sqlite/index.d.ts +7 -2
- package/dist/types.d.ts +4 -0
- package/package.json +4 -4
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type PresenceStore, type TenantId, type TenantReadiness } from '@byok-sdk/core';
|
|
2
|
+
import type { DeviceDirectory, DeviceRecord, DeviceRegistration } from '@byok-sdk/cloud';
|
|
3
|
+
import { type HarnessInfo } from '@byok-sdk/protocol';
|
|
4
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
5
|
+
export declare const DEVICE_SCHEMA = "\nCREATE TABLE device_directory (\n tenant_id TEXT NOT NULL,\n device_id TEXT NOT NULL UNIQUE,\n product_id TEXT NOT NULL,\n machine_id TEXT,\n device_name TEXT NOT NULL,\n device_public_key TEXT NOT NULL,\n proof_key_id TEXT NOT NULL,\n proof_key_epoch INTEGER NOT NULL CHECK (proof_key_epoch >= 0),\n capabilities_json TEXT,\n harnesses_json TEXT,\n PRIMARY KEY (tenant_id, device_id)\n);\nCREATE UNIQUE INDEX device_directory_machine\n ON device_directory (tenant_id, product_id, machine_id) WHERE machine_id IS NOT NULL;\n";
|
|
6
|
+
interface Coordinator {
|
|
7
|
+
run<T>(operation: (db: DatabaseSync) => T | Promise<T>): Promise<T>;
|
|
8
|
+
transaction<T>(operation: (db: DatabaseSync) => T | Promise<T>): Promise<T>;
|
|
9
|
+
}
|
|
10
|
+
/** Enrollment, capability admission and pre-tenant auth read the same durable row. */
|
|
11
|
+
export declare class SqliteDeviceDirectory implements DeviceDirectory {
|
|
12
|
+
private readonly coordinator;
|
|
13
|
+
constructor(coordinator: Coordinator);
|
|
14
|
+
register(tenant: TenantId, input: DeviceRegistration): Promise<DeviceRecord>;
|
|
15
|
+
get(tenant: TenantId, deviceId: string): Promise<DeviceRecord | undefined>;
|
|
16
|
+
revoke(tenant: TenantId, deviceId: string): Promise<void>;
|
|
17
|
+
list(tenant: TenantId): Promise<readonly DeviceRecord[]>;
|
|
18
|
+
resolveByDeviceId(deviceId: string): Promise<DeviceRecord | undefined>;
|
|
19
|
+
recordCapabilities(tenant: TenantId, input: {
|
|
20
|
+
readonly deviceId: string;
|
|
21
|
+
readonly capabilities: readonly string[];
|
|
22
|
+
readonly harnesses?: readonly HarnessInfo[];
|
|
23
|
+
}): Promise<DeviceRecord | undefined>;
|
|
24
|
+
readiness(tenant: TenantId, presence: PresenceStore): Promise<TenantReadiness>;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -5,6 +5,7 @@ import type { DatabaseSync } from 'node:sqlite';
|
|
|
5
5
|
export interface SqliteEmbeddedStoreOptions {
|
|
6
6
|
readonly path: string;
|
|
7
7
|
readonly urlTtlMs?: number;
|
|
8
|
+
readonly migration?: 'v1-to-v3' | 'v2-to-v3';
|
|
8
9
|
}
|
|
9
10
|
export interface SqliteEmbeddedStores {
|
|
10
11
|
readonly core: CoreStores;
|
|
@@ -16,7 +17,7 @@ export interface SqliteEmbeddedStores {
|
|
|
16
17
|
declare class SqliteCoordinator {
|
|
17
18
|
#private;
|
|
18
19
|
readonly db: DatabaseSync;
|
|
19
|
-
constructor(path: string);
|
|
20
|
+
constructor(path: string, migration?: 'v1-to-v3' | 'v2-to-v3');
|
|
20
21
|
run<T>(operation: (db: DatabaseSync) => T | Promise<T>): Promise<T>;
|
|
21
22
|
transaction<T>(operation: (db: DatabaseSync) => T | Promise<T>): Promise<T>;
|
|
22
23
|
close(): Promise<void>;
|
|
@@ -45,6 +46,10 @@ export declare class SqliteTaskAttemptStore implements TaskAttemptStore {
|
|
|
45
46
|
messageId: string;
|
|
46
47
|
payloadBody: string;
|
|
47
48
|
}): Promise<'reserved' | 'pending' | 'rejected'>;
|
|
49
|
+
readTaskAgentMessage(tenant: TenantId, input: {
|
|
50
|
+
taskId: string;
|
|
51
|
+
deviceId: string;
|
|
52
|
+
}): Promise<AgentMessageAdmission | undefined>;
|
|
48
53
|
readAgentMessage(tenant: TenantId, input: {
|
|
49
54
|
taskId: string;
|
|
50
55
|
deviceId: string;
|
|
@@ -132,7 +137,7 @@ export declare class SqliteBlobContentProxy implements BlobContentProxy {
|
|
|
132
137
|
writeContent(blobId: string, data: Uint8Array): Promise<BlobWriteResult>;
|
|
133
138
|
readContent(blobId: string): Promise<BlobReadResult | undefined>;
|
|
134
139
|
}
|
|
135
|
-
/** Mixed embedded composition:
|
|
140
|
+
/** Mixed embedded composition: eight durable interfaces, every other port unchanged in-memory. */
|
|
136
141
|
export declare function createSqliteEmbeddedStores(options: SqliteEmbeddedStoreOptions, dependencies: {
|
|
137
142
|
readonly clock: Clock;
|
|
138
143
|
readonly crypto: CloudCrypto;
|
package/dist/types.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export type ByokServerStorage = {
|
|
|
11
11
|
readonly path: string;
|
|
12
12
|
/** Lifetime of signed blob upload/download URLs. Default 15 minutes. */
|
|
13
13
|
readonly urlTtlMs?: number;
|
|
14
|
+
/** One-shot adoption of a legacy database without task history. Stop all writers and back up first; old builds cannot reopen v3. */
|
|
15
|
+
readonly migration?: 'v1-to-v3' | 'v2-to-v3';
|
|
14
16
|
};
|
|
15
17
|
/** Options for {@link createByokServer}. */
|
|
16
18
|
export interface CreateByokServerOptions {
|
|
@@ -111,6 +113,8 @@ export interface CreateByokServerOptions {
|
|
|
111
113
|
}
|
|
112
114
|
/** Input to {@link ByokServer.dispatch}. */
|
|
113
115
|
export interface DispatchInput {
|
|
116
|
+
/** Pre-persisted execution identity. Requires explicit deviceId; retries may report a kernel conflict. */
|
|
117
|
+
taskId?: string;
|
|
114
118
|
instruction: string;
|
|
115
119
|
/**
|
|
116
120
|
* Authoritative web-selected target. When present, `runtime` is derived
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@byok-sdk/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.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",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"clean": "rm -rf dist"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@byok-sdk/cloud": "0.
|
|
48
|
-
"@byok-sdk/core": "0.
|
|
49
|
-
"@byok-sdk/protocol": "0.
|
|
47
|
+
"@byok-sdk/cloud": "0.18.0",
|
|
48
|
+
"@byok-sdk/core": "0.18.0",
|
|
49
|
+
"@byok-sdk/protocol": "0.18.0",
|
|
50
50
|
"@hono/node-server": "^2.0.10",
|
|
51
51
|
"hono": "^4.12.30"
|
|
52
52
|
},
|