@prismer/runtime 1.9.6 → 1.9.21
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/CHANGELOG.md +56 -0
- package/dist/cli.cjs +1644 -928
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1469 -751
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1663 -953
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +90 -1
- package/dist/index.d.ts +90 -1
- package/dist/index.js +2136 -1420
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -208,6 +208,8 @@ declare const HermesProfileConfigSchema: z.ZodObject<{
|
|
|
208
208
|
*/
|
|
209
209
|
hermesSourceDir: z.ZodOptional<z.ZodString>;
|
|
210
210
|
nativeMirrorTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
211
|
+
/** Task authority level: executor (default) or orchestrator. */
|
|
212
|
+
taskAuthority: z.ZodDefault<z.ZodOptional<z.ZodEnum<["executor", "orchestrator"]>>>;
|
|
211
213
|
}, "strip", z.ZodTypeAny, {
|
|
212
214
|
port: number;
|
|
213
215
|
apiKey: string;
|
|
@@ -221,6 +223,7 @@ declare const HermesProfileConfigSchema: z.ZodObject<{
|
|
|
221
223
|
mirrorNativeKanban: boolean;
|
|
222
224
|
mirrorNativeGoals: boolean;
|
|
223
225
|
nativeMirrorTimeoutMs: number;
|
|
226
|
+
taskAuthority: "executor" | "orchestrator";
|
|
224
227
|
hermesProfileName?: string | undefined;
|
|
225
228
|
prismerMcpServerPath?: string | undefined;
|
|
226
229
|
prismerProviderBaseUrl?: string | undefined;
|
|
@@ -242,6 +245,7 @@ declare const HermesProfileConfigSchema: z.ZodObject<{
|
|
|
242
245
|
mirrorNativeGoals?: boolean | undefined;
|
|
243
246
|
hermesSourceDir?: string | undefined;
|
|
244
247
|
nativeMirrorTimeoutMs?: number | undefined;
|
|
248
|
+
taskAuthority?: "executor" | "orchestrator" | undefined;
|
|
245
249
|
}>;
|
|
246
250
|
type HermesProfileConfig = z.infer<typeof HermesProfileConfigSchema>;
|
|
247
251
|
declare const hermesAdapter: AdapterDef;
|
|
@@ -306,7 +310,7 @@ type LocalDb = Database.Database;
|
|
|
306
310
|
declare function openLocalDb(path: string): LocalDb;
|
|
307
311
|
declare function runMigrations(db: LocalDb): void;
|
|
308
312
|
declare function currentSchemaVersion(db: LocalDb): number;
|
|
309
|
-
declare const TARGET_SCHEMA_VERSION =
|
|
313
|
+
declare const TARGET_SCHEMA_VERSION = 3;
|
|
310
314
|
|
|
311
315
|
type SyncResourceType = 'workspace' | 'agent' | 'agent_profile';
|
|
312
316
|
type SyncOperation = 'create' | 'update' | 'delete';
|
|
@@ -1160,6 +1164,69 @@ declare class OutboxWatcher {
|
|
|
1160
1164
|
private upload;
|
|
1161
1165
|
}
|
|
1162
1166
|
|
|
1167
|
+
interface AssetMetadataRow {
|
|
1168
|
+
assetId: string;
|
|
1169
|
+
contentHash: string;
|
|
1170
|
+
filename: string | null;
|
|
1171
|
+
folderPath: string | null;
|
|
1172
|
+
mime: string;
|
|
1173
|
+
kind: string;
|
|
1174
|
+
sizeBytes: number;
|
|
1175
|
+
description: string | null;
|
|
1176
|
+
assetIndexSeq: number;
|
|
1177
|
+
}
|
|
1178
|
+
interface AssetMetadataIndexOptions {
|
|
1179
|
+
db: LocalDb;
|
|
1180
|
+
cloud: CloudClient;
|
|
1181
|
+
workspaceId: string;
|
|
1182
|
+
/**
|
|
1183
|
+
* Per-workspace state dir. Caller should pass ~/.prismer/<wid>/ so different
|
|
1184
|
+
* paired workspaces don't race on the cursor file.
|
|
1185
|
+
*/
|
|
1186
|
+
workspaceStateDir: string;
|
|
1187
|
+
}
|
|
1188
|
+
/**
|
|
1189
|
+
* AssetMetadataIndex mirrors cloud-side asset metadata into SQLite for fast
|
|
1190
|
+
* local `#filename` lookup. The cursor file is the only piece of state that
|
|
1191
|
+
* must survive daemon restart; the SQLite mirror is incremental between restarts
|
|
1192
|
+
* (cursor catch-up). Idempotent — safe to retry pullDelta() on errors.
|
|
1193
|
+
*/
|
|
1194
|
+
declare class AssetMetadataIndex {
|
|
1195
|
+
private readonly db;
|
|
1196
|
+
private readonly cloud;
|
|
1197
|
+
/** Workspace ID — exposed for prismer:// URI construction. */
|
|
1198
|
+
readonly workspaceId: string;
|
|
1199
|
+
private readonly cursorPath;
|
|
1200
|
+
private _lastSyncMs;
|
|
1201
|
+
constructor(opts: AssetMetadataIndexOptions);
|
|
1202
|
+
/** Persisted cursor for this workspace, or 0 on first run / corrupted file. */
|
|
1203
|
+
readCursor(): number;
|
|
1204
|
+
private writeCursor;
|
|
1205
|
+
/**
|
|
1206
|
+
* Pull incremental asset metadata changes since the persisted cursor and
|
|
1207
|
+
* upsert into the local index. Newer rows overwrite older ones by
|
|
1208
|
+
* (workspace_id, asset_id) primary key.
|
|
1209
|
+
*
|
|
1210
|
+
* Returns the count of items applied + the new cursor. Throttled: if called
|
|
1211
|
+
* within 30s of the last successful pull, returns immediately.
|
|
1212
|
+
*/
|
|
1213
|
+
pullDelta(opts?: {
|
|
1214
|
+
signal?: AbortSignal;
|
|
1215
|
+
}): Promise<{
|
|
1216
|
+
applied: number;
|
|
1217
|
+
cursor: number;
|
|
1218
|
+
}>;
|
|
1219
|
+
/**
|
|
1220
|
+
* Search local index by filename or description substring.
|
|
1221
|
+
* Escapes LIKE wildcards (% and _). Default limit 8.
|
|
1222
|
+
*/
|
|
1223
|
+
search(query: string, limit?: number): AssetMetadataRow[];
|
|
1224
|
+
/** Exact match on filename column. Returns undefined if not indexed. */
|
|
1225
|
+
resolveByFilename(filename: string): AssetMetadataRow | undefined;
|
|
1226
|
+
/** Batch exact match — returns Map for O(1) access. */
|
|
1227
|
+
resolveByFilenames(filenames: string[]): Map<string, AssetMetadataRow>;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1163
1230
|
interface DispatchDeps {
|
|
1164
1231
|
registry: AdapterRegistry;
|
|
1165
1232
|
cloud: CloudClient;
|
|
@@ -1183,6 +1250,11 @@ interface DispatchDeps {
|
|
|
1183
1250
|
outboxWatcher?: OutboxWatcher;
|
|
1184
1251
|
/** Daemon paths — used to derive the per-task outbox dir. */
|
|
1185
1252
|
paths?: ConfigPaths;
|
|
1253
|
+
/**
|
|
1254
|
+
* Multi-workspace asset metadata indexes for #filename resolution.
|
|
1255
|
+
* Keyed by workspaceId. If absent, #ref resolution is skipped entirely.
|
|
1256
|
+
*/
|
|
1257
|
+
assetMetadataIndexes?: Map<string, AssetMetadataIndex>;
|
|
1186
1258
|
}
|
|
1187
1259
|
declare function handleDispatch(payload: TaskDispatchRequestPayload, requestId: string | undefined, deps: DispatchDeps): Promise<TaskDispatchReplyPayload>;
|
|
1188
1260
|
/**
|
|
@@ -1250,6 +1322,14 @@ interface LocalServerOptions {
|
|
|
1250
1322
|
* Sink receives the parsed JSON body and returns a structured result.
|
|
1251
1323
|
*/
|
|
1252
1324
|
onAssetWrite?: (body: unknown) => Promise<AssetWriteHandlerResult>;
|
|
1325
|
+
/**
|
|
1326
|
+
* Optional handler for `/local/asset/*` routes. Returns true if the request
|
|
1327
|
+
* was handled (response written); false to let the normal route table fall
|
|
1328
|
+
* through. Wired by the daemon runner from `attachAssetRpc()` in
|
|
1329
|
+
* `daemon/asset/rpc.ts` when asset metadata index is enabled.
|
|
1330
|
+
* When set, /healthz reports `assetReady: true`.
|
|
1331
|
+
*/
|
|
1332
|
+
attachAsset?: (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
|
|
1253
1333
|
}
|
|
1254
1334
|
interface AssetWriteHandlerResult {
|
|
1255
1335
|
status: 200 | 400 | 502;
|
|
@@ -1334,6 +1414,7 @@ declare class LocalServer {
|
|
|
1334
1414
|
start(): Promise<void>;
|
|
1335
1415
|
stop(): Promise<void>;
|
|
1336
1416
|
private route;
|
|
1417
|
+
private runHandlers;
|
|
1337
1418
|
private routeStandard;
|
|
1338
1419
|
/**
|
|
1339
1420
|
* POST /v1/agents/install — cloud/controller installs one hosted agent on
|
|
@@ -1405,6 +1486,7 @@ declare class Runner extends EventEmitter {
|
|
|
1405
1486
|
private localServer?;
|
|
1406
1487
|
private outboxWatcher?;
|
|
1407
1488
|
private memoryWiring?;
|
|
1489
|
+
private assetMetadataIndexes;
|
|
1408
1490
|
private state;
|
|
1409
1491
|
private startedAt;
|
|
1410
1492
|
private workspaceId;
|
|
@@ -1458,8 +1540,15 @@ declare class Runner extends EventEmitter {
|
|
|
1458
1540
|
private syncProfileFromCloud;
|
|
1459
1541
|
private resolveOwnedAgent;
|
|
1460
1542
|
private onWorkspaceChanged;
|
|
1543
|
+
private onAssetChanged;
|
|
1461
1544
|
private onWorkspaceFileChanged;
|
|
1462
1545
|
private snapshotAdapterObservability;
|
|
1546
|
+
/**
|
|
1547
|
+
* Ensure an AssetMetadataIndex exists for the given workspace and pull
|
|
1548
|
+
* delta from cloud. Idempotent — creates the index on first call, reuses
|
|
1549
|
+
* it on subsequent calls. Same cursor-catch-up semantics as WorkspaceMirror.
|
|
1550
|
+
*/
|
|
1551
|
+
private syncAssetMetadata;
|
|
1463
1552
|
/**
|
|
1464
1553
|
* SyncWorker FlushFn — pushes local writes to cloud.
|
|
1465
1554
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -208,6 +208,8 @@ declare const HermesProfileConfigSchema: z.ZodObject<{
|
|
|
208
208
|
*/
|
|
209
209
|
hermesSourceDir: z.ZodOptional<z.ZodString>;
|
|
210
210
|
nativeMirrorTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
211
|
+
/** Task authority level: executor (default) or orchestrator. */
|
|
212
|
+
taskAuthority: z.ZodDefault<z.ZodOptional<z.ZodEnum<["executor", "orchestrator"]>>>;
|
|
211
213
|
}, "strip", z.ZodTypeAny, {
|
|
212
214
|
port: number;
|
|
213
215
|
apiKey: string;
|
|
@@ -221,6 +223,7 @@ declare const HermesProfileConfigSchema: z.ZodObject<{
|
|
|
221
223
|
mirrorNativeKanban: boolean;
|
|
222
224
|
mirrorNativeGoals: boolean;
|
|
223
225
|
nativeMirrorTimeoutMs: number;
|
|
226
|
+
taskAuthority: "executor" | "orchestrator";
|
|
224
227
|
hermesProfileName?: string | undefined;
|
|
225
228
|
prismerMcpServerPath?: string | undefined;
|
|
226
229
|
prismerProviderBaseUrl?: string | undefined;
|
|
@@ -242,6 +245,7 @@ declare const HermesProfileConfigSchema: z.ZodObject<{
|
|
|
242
245
|
mirrorNativeGoals?: boolean | undefined;
|
|
243
246
|
hermesSourceDir?: string | undefined;
|
|
244
247
|
nativeMirrorTimeoutMs?: number | undefined;
|
|
248
|
+
taskAuthority?: "executor" | "orchestrator" | undefined;
|
|
245
249
|
}>;
|
|
246
250
|
type HermesProfileConfig = z.infer<typeof HermesProfileConfigSchema>;
|
|
247
251
|
declare const hermesAdapter: AdapterDef;
|
|
@@ -306,7 +310,7 @@ type LocalDb = Database.Database;
|
|
|
306
310
|
declare function openLocalDb(path: string): LocalDb;
|
|
307
311
|
declare function runMigrations(db: LocalDb): void;
|
|
308
312
|
declare function currentSchemaVersion(db: LocalDb): number;
|
|
309
|
-
declare const TARGET_SCHEMA_VERSION =
|
|
313
|
+
declare const TARGET_SCHEMA_VERSION = 3;
|
|
310
314
|
|
|
311
315
|
type SyncResourceType = 'workspace' | 'agent' | 'agent_profile';
|
|
312
316
|
type SyncOperation = 'create' | 'update' | 'delete';
|
|
@@ -1160,6 +1164,69 @@ declare class OutboxWatcher {
|
|
|
1160
1164
|
private upload;
|
|
1161
1165
|
}
|
|
1162
1166
|
|
|
1167
|
+
interface AssetMetadataRow {
|
|
1168
|
+
assetId: string;
|
|
1169
|
+
contentHash: string;
|
|
1170
|
+
filename: string | null;
|
|
1171
|
+
folderPath: string | null;
|
|
1172
|
+
mime: string;
|
|
1173
|
+
kind: string;
|
|
1174
|
+
sizeBytes: number;
|
|
1175
|
+
description: string | null;
|
|
1176
|
+
assetIndexSeq: number;
|
|
1177
|
+
}
|
|
1178
|
+
interface AssetMetadataIndexOptions {
|
|
1179
|
+
db: LocalDb;
|
|
1180
|
+
cloud: CloudClient;
|
|
1181
|
+
workspaceId: string;
|
|
1182
|
+
/**
|
|
1183
|
+
* Per-workspace state dir. Caller should pass ~/.prismer/<wid>/ so different
|
|
1184
|
+
* paired workspaces don't race on the cursor file.
|
|
1185
|
+
*/
|
|
1186
|
+
workspaceStateDir: string;
|
|
1187
|
+
}
|
|
1188
|
+
/**
|
|
1189
|
+
* AssetMetadataIndex mirrors cloud-side asset metadata into SQLite for fast
|
|
1190
|
+
* local `#filename` lookup. The cursor file is the only piece of state that
|
|
1191
|
+
* must survive daemon restart; the SQLite mirror is incremental between restarts
|
|
1192
|
+
* (cursor catch-up). Idempotent — safe to retry pullDelta() on errors.
|
|
1193
|
+
*/
|
|
1194
|
+
declare class AssetMetadataIndex {
|
|
1195
|
+
private readonly db;
|
|
1196
|
+
private readonly cloud;
|
|
1197
|
+
/** Workspace ID — exposed for prismer:// URI construction. */
|
|
1198
|
+
readonly workspaceId: string;
|
|
1199
|
+
private readonly cursorPath;
|
|
1200
|
+
private _lastSyncMs;
|
|
1201
|
+
constructor(opts: AssetMetadataIndexOptions);
|
|
1202
|
+
/** Persisted cursor for this workspace, or 0 on first run / corrupted file. */
|
|
1203
|
+
readCursor(): number;
|
|
1204
|
+
private writeCursor;
|
|
1205
|
+
/**
|
|
1206
|
+
* Pull incremental asset metadata changes since the persisted cursor and
|
|
1207
|
+
* upsert into the local index. Newer rows overwrite older ones by
|
|
1208
|
+
* (workspace_id, asset_id) primary key.
|
|
1209
|
+
*
|
|
1210
|
+
* Returns the count of items applied + the new cursor. Throttled: if called
|
|
1211
|
+
* within 30s of the last successful pull, returns immediately.
|
|
1212
|
+
*/
|
|
1213
|
+
pullDelta(opts?: {
|
|
1214
|
+
signal?: AbortSignal;
|
|
1215
|
+
}): Promise<{
|
|
1216
|
+
applied: number;
|
|
1217
|
+
cursor: number;
|
|
1218
|
+
}>;
|
|
1219
|
+
/**
|
|
1220
|
+
* Search local index by filename or description substring.
|
|
1221
|
+
* Escapes LIKE wildcards (% and _). Default limit 8.
|
|
1222
|
+
*/
|
|
1223
|
+
search(query: string, limit?: number): AssetMetadataRow[];
|
|
1224
|
+
/** Exact match on filename column. Returns undefined if not indexed. */
|
|
1225
|
+
resolveByFilename(filename: string): AssetMetadataRow | undefined;
|
|
1226
|
+
/** Batch exact match — returns Map for O(1) access. */
|
|
1227
|
+
resolveByFilenames(filenames: string[]): Map<string, AssetMetadataRow>;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1163
1230
|
interface DispatchDeps {
|
|
1164
1231
|
registry: AdapterRegistry;
|
|
1165
1232
|
cloud: CloudClient;
|
|
@@ -1183,6 +1250,11 @@ interface DispatchDeps {
|
|
|
1183
1250
|
outboxWatcher?: OutboxWatcher;
|
|
1184
1251
|
/** Daemon paths — used to derive the per-task outbox dir. */
|
|
1185
1252
|
paths?: ConfigPaths;
|
|
1253
|
+
/**
|
|
1254
|
+
* Multi-workspace asset metadata indexes for #filename resolution.
|
|
1255
|
+
* Keyed by workspaceId. If absent, #ref resolution is skipped entirely.
|
|
1256
|
+
*/
|
|
1257
|
+
assetMetadataIndexes?: Map<string, AssetMetadataIndex>;
|
|
1186
1258
|
}
|
|
1187
1259
|
declare function handleDispatch(payload: TaskDispatchRequestPayload, requestId: string | undefined, deps: DispatchDeps): Promise<TaskDispatchReplyPayload>;
|
|
1188
1260
|
/**
|
|
@@ -1250,6 +1322,14 @@ interface LocalServerOptions {
|
|
|
1250
1322
|
* Sink receives the parsed JSON body and returns a structured result.
|
|
1251
1323
|
*/
|
|
1252
1324
|
onAssetWrite?: (body: unknown) => Promise<AssetWriteHandlerResult>;
|
|
1325
|
+
/**
|
|
1326
|
+
* Optional handler for `/local/asset/*` routes. Returns true if the request
|
|
1327
|
+
* was handled (response written); false to let the normal route table fall
|
|
1328
|
+
* through. Wired by the daemon runner from `attachAssetRpc()` in
|
|
1329
|
+
* `daemon/asset/rpc.ts` when asset metadata index is enabled.
|
|
1330
|
+
* When set, /healthz reports `assetReady: true`.
|
|
1331
|
+
*/
|
|
1332
|
+
attachAsset?: (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
|
|
1253
1333
|
}
|
|
1254
1334
|
interface AssetWriteHandlerResult {
|
|
1255
1335
|
status: 200 | 400 | 502;
|
|
@@ -1334,6 +1414,7 @@ declare class LocalServer {
|
|
|
1334
1414
|
start(): Promise<void>;
|
|
1335
1415
|
stop(): Promise<void>;
|
|
1336
1416
|
private route;
|
|
1417
|
+
private runHandlers;
|
|
1337
1418
|
private routeStandard;
|
|
1338
1419
|
/**
|
|
1339
1420
|
* POST /v1/agents/install — cloud/controller installs one hosted agent on
|
|
@@ -1405,6 +1486,7 @@ declare class Runner extends EventEmitter {
|
|
|
1405
1486
|
private localServer?;
|
|
1406
1487
|
private outboxWatcher?;
|
|
1407
1488
|
private memoryWiring?;
|
|
1489
|
+
private assetMetadataIndexes;
|
|
1408
1490
|
private state;
|
|
1409
1491
|
private startedAt;
|
|
1410
1492
|
private workspaceId;
|
|
@@ -1458,8 +1540,15 @@ declare class Runner extends EventEmitter {
|
|
|
1458
1540
|
private syncProfileFromCloud;
|
|
1459
1541
|
private resolveOwnedAgent;
|
|
1460
1542
|
private onWorkspaceChanged;
|
|
1543
|
+
private onAssetChanged;
|
|
1461
1544
|
private onWorkspaceFileChanged;
|
|
1462
1545
|
private snapshotAdapterObservability;
|
|
1546
|
+
/**
|
|
1547
|
+
* Ensure an AssetMetadataIndex exists for the given workspace and pull
|
|
1548
|
+
* delta from cloud. Idempotent — creates the index on first call, reuses
|
|
1549
|
+
* it on subsequent calls. Same cursor-catch-up semantics as WorkspaceMirror.
|
|
1550
|
+
*/
|
|
1551
|
+
private syncAssetMetadata;
|
|
1463
1552
|
/**
|
|
1464
1553
|
* SyncWorker FlushFn — pushes local writes to cloud.
|
|
1465
1554
|
*
|