@undefineds.co/xpod 0.3.32 → 0.3.34
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/dist/api/chatkit/pod-store.d.ts +3 -0
- package/dist/api/chatkit/pod-store.js +93 -59
- package/dist/api/chatkit/pod-store.js.map +1 -1
- package/dist/api/chatkit/schema.d.ts +5 -6
- package/dist/api/matrix/PodMatrixStore.js +26 -21
- package/dist/api/matrix/PodMatrixStore.js.map +1 -1
- package/dist/api/runs/InngestRunExecutionBackend.d.ts +2 -2
- package/dist/api/runs/schema.d.ts +5 -7
- package/dist/api/runs/store.js +6 -4
- package/dist/api/runs/store.js.map +1 -1
- package/dist/api/tasks/InngestTaskScheduler.d.ts +4 -4
- package/dist/api/tasks/schema.d.ts +17 -13
- package/dist/api/tasks/schema.js +7 -2
- package/dist/api/tasks/schema.js.map +1 -1
- package/dist/api/tasks/store.js +1 -2
- package/dist/api/tasks/store.js.map +1 -1
- package/dist/http/search/SearchHttpHandler.js +2 -2
- package/dist/http/search/SearchHttpHandler.js.map +1 -1
- package/dist/storage/SparqlUpdateResourceStore.d.ts +1 -0
- package/dist/storage/SparqlUpdateResourceStore.js +5 -0
- package/dist/storage/SparqlUpdateResourceStore.js.map +1 -1
- package/dist/storage/SparqlUpdateResourceStore.jsonld +4 -0
- package/dist/storage/vector/VectorIndexingListener.js +2 -2
- package/dist/storage/vector/VectorIndexingListener.js.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/exact-records.d.ts +21 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/exact-records.d.ts.map +1 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/exact-records.js +85 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/exact-records.js.map +1 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/default-id-template.d.ts +10 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/default-id-template.d.ts.map +1 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/default-id-template.js +365 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/default-id-template.js.map +1 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/index.d.ts +1 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/index.d.ts.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/index.js +3 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/index.js.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/insert-query-builder.d.ts.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/insert-query-builder.js +5 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/insert-query-builder.js.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/repository.d.ts +2 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/repository.d.ts.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/repository.js +2 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/repository.js.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-reference.d.ts +18 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-reference.d.ts.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-reference.js +234 -10
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-reference.js.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/schema/pod-table.d.ts +13 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/schema/pod-table.d.ts.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/schema/pod-table.js +19 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/core/schema/pod-table.js.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/exact-records.d.ts +21 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/exact-records.d.ts.map +1 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/exact-records.js +78 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/exact-records.js.map +1 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/default-id-template.d.ts +10 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/default-id-template.d.ts.map +1 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/default-id-template.js +362 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/default-id-template.js.map +1 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/index.d.ts +1 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/index.d.ts.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/index.js +1 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/index.js.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/insert-query-builder.d.ts.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/insert-query-builder.js +5 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/insert-query-builder.js.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/repository.d.ts +2 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/repository.d.ts.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/repository.js +1 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/repository.js.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-reference.d.ts +18 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-reference.d.ts.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-reference.js +225 -10
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-reference.js.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/schema/pod-table.d.ts +13 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/schema/pod-table.d.ts.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/schema/pod-table.js +19 -0
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/schema/pod-table.js.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/index.d.ts +5 -4
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/index.d.ts.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/index.js +4 -3
- package/node_modules/@undefineds.co/drizzle-solid/dist/esm/index.js.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/index.d.ts +5 -4
- package/node_modules/@undefineds.co/drizzle-solid/dist/index.d.ts.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/dist/index.js +20 -3
- package/node_modules/@undefineds.co/drizzle-solid/dist/index.js.map +1 -1
- package/node_modules/@undefineds.co/drizzle-solid/package.json +1 -1
- package/package.json +3 -3
|
@@ -61,6 +61,9 @@ export declare class PodChatKitStore implements ChatKitStore<StoreContext>, RunS
|
|
|
61
61
|
private isoToTimestamp;
|
|
62
62
|
private parseJsonObject;
|
|
63
63
|
private jsonObjectOrNull;
|
|
64
|
+
private getXpodMetadata;
|
|
65
|
+
private withXpodMetadata;
|
|
66
|
+
private withoutXpodMetadata;
|
|
64
67
|
private withTaskAuthBindingMetadata;
|
|
65
68
|
private parseTaskAuthBinding;
|
|
66
69
|
private isBaseRelativeDataResourceId;
|
|
@@ -316,9 +316,12 @@ class PodChatKitStore {
|
|
|
316
316
|
* ChatKit 边界继续暴露 metadata.chat_id;内部同一值叫 surface_id。
|
|
317
317
|
*/
|
|
318
318
|
threadRecordToMetadata(record, chatResourceMap) {
|
|
319
|
-
const commandKind = record.commandKind === 'task' ? 'task' : 'chat';
|
|
320
|
-
const surfaceId = record.surfaceId || this.resolveChatSurfaceFromResource(record.chat, chatResourceMap, PodChatKitStore.DEFAULT_CHAT_ID);
|
|
321
319
|
const extra = this.parseJsonObject(record.metadata);
|
|
320
|
+
const commandKind = record.commandKind === 'task' || extra?.commandKind === 'task' ? 'task' : 'chat';
|
|
321
|
+
const surfaceId = record.surfaceId
|
|
322
|
+
|| (typeof extra?.surface_id === 'string' ? extra.surface_id : undefined)
|
|
323
|
+
|| (typeof extra?.chat_id === 'string' ? extra.chat_id : undefined)
|
|
324
|
+
|| this.resolveChatSurfaceFromResource(record.chat, chatResourceMap, PodChatKitStore.DEFAULT_CHAT_ID);
|
|
322
325
|
return {
|
|
323
326
|
id: record.id,
|
|
324
327
|
title: record.title || undefined,
|
|
@@ -368,6 +371,29 @@ class PodChatKitStore {
|
|
|
368
371
|
jsonObjectOrNull(value) {
|
|
369
372
|
return value && Object.keys(value).length > 0 ? value : null;
|
|
370
373
|
}
|
|
374
|
+
getXpodMetadata(metadata) {
|
|
375
|
+
const value = metadata?.xpod;
|
|
376
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
377
|
+
? value
|
|
378
|
+
: undefined;
|
|
379
|
+
}
|
|
380
|
+
withXpodMetadata(metadata, xpod) {
|
|
381
|
+
return {
|
|
382
|
+
...(metadata ?? {}),
|
|
383
|
+
xpod: {
|
|
384
|
+
...(this.getXpodMetadata(metadata) ?? {}),
|
|
385
|
+
...xpod,
|
|
386
|
+
},
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
withoutXpodMetadata(metadata) {
|
|
390
|
+
if (!metadata) {
|
|
391
|
+
return undefined;
|
|
392
|
+
}
|
|
393
|
+
const result = { ...metadata };
|
|
394
|
+
delete result.xpod;
|
|
395
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
396
|
+
}
|
|
371
397
|
withTaskAuthBindingMetadata(metadata, authBinding) {
|
|
372
398
|
if (!authBinding) {
|
|
373
399
|
return metadata;
|
|
@@ -487,13 +513,15 @@ class PodChatKitStore {
|
|
|
487
513
|
return resource;
|
|
488
514
|
}
|
|
489
515
|
runRecordToData(record) {
|
|
516
|
+
const metadata = this.parseJsonObject(record.metadata);
|
|
517
|
+
const xpod = this.getXpodMetadata(metadata);
|
|
490
518
|
return {
|
|
491
519
|
id: record.id || '',
|
|
492
|
-
surfaceId: record.surfaceId || 'default',
|
|
520
|
+
surfaceId: record.surfaceId || (typeof xpod?.surfaceId === 'string' ? xpod.surfaceId : 'default'),
|
|
493
521
|
task: record.task || undefined,
|
|
494
522
|
thread: record.thread || '',
|
|
495
523
|
workspace: record.workspace || '',
|
|
496
|
-
commandKind: record.commandKind === 'task' ? 'task' : 'chat',
|
|
524
|
+
commandKind: record.commandKind === 'task' || xpod?.commandKind === 'task' ? 'task' : 'chat',
|
|
497
525
|
status: (record.status || 'queued'),
|
|
498
526
|
runner: record.runner || '',
|
|
499
527
|
prompt: record.prompt || undefined,
|
|
@@ -503,7 +531,7 @@ class PodChatKitStore {
|
|
|
503
531
|
heartbeatAt: this.isoToTimestamp(record.heartbeatAt),
|
|
504
532
|
cancelRequestedAt: this.isoToTimestamp(record.cancelRequestedAt),
|
|
505
533
|
error: record.error || undefined,
|
|
506
|
-
metadata
|
|
534
|
+
metadata,
|
|
507
535
|
createdAt: this.isoToTimestamp(record.createdAt) ?? (0, types_1.nowTimestamp)(),
|
|
508
536
|
startedAt: this.isoToTimestamp(record.startedAt),
|
|
509
537
|
completedAt: this.isoToTimestamp(record.completedAt),
|
|
@@ -511,36 +539,42 @@ class PodChatKitStore {
|
|
|
511
539
|
};
|
|
512
540
|
}
|
|
513
541
|
runStepRecordToData(record) {
|
|
542
|
+
const payload = this.parseJsonObject(record.payload) ?? this.parseJsonObject(record.data);
|
|
543
|
+
const xpod = this.getXpodMetadata(payload);
|
|
514
544
|
return {
|
|
515
545
|
id: record.id || '',
|
|
516
|
-
commandKind: record.commandKind === 'task' ? 'task' : 'chat',
|
|
517
|
-
surfaceId: record.surfaceId || 'default',
|
|
518
|
-
runId: record.runId || '',
|
|
546
|
+
commandKind: record.commandKind === 'task' || xpod?.commandKind === 'task' ? 'task' : 'chat',
|
|
547
|
+
surfaceId: record.surfaceId || (typeof xpod?.surfaceId === 'string' ? xpod.surfaceId : 'default'),
|
|
548
|
+
runId: record.runId || (typeof xpod?.runId === 'string' ? xpod.runId : ''),
|
|
519
549
|
run: record.run || '',
|
|
520
|
-
type: record.type || 'runtime.event',
|
|
550
|
+
type: record.type || record.stepType || 'runtime.event',
|
|
521
551
|
message: record.message || undefined,
|
|
522
|
-
data: this.
|
|
552
|
+
data: this.withoutXpodMetadata(payload),
|
|
523
553
|
createdAt: this.isoToTimestamp(record.createdAt) ?? (0, types_1.nowTimestamp)(),
|
|
524
554
|
};
|
|
525
555
|
}
|
|
526
556
|
taskRecordToData(record) {
|
|
557
|
+
const metadata = this.parseJsonObject(record.metadata);
|
|
558
|
+
const xpod = this.getXpodMetadata(metadata);
|
|
527
559
|
return {
|
|
528
560
|
id: record.id || '',
|
|
529
|
-
surfaceId: record.surfaceId || 'default',
|
|
561
|
+
surfaceId: record.surfaceId || (typeof xpod?.surfaceId === 'string' ? xpod.surfaceId : 'default'),
|
|
530
562
|
title: record.title || undefined,
|
|
531
563
|
prompt: record.prompt || '',
|
|
532
564
|
thread: record.thread || '',
|
|
533
565
|
workspace: record.workspace || '',
|
|
534
|
-
runner: record.runner || '',
|
|
566
|
+
runner: record.runner || (typeof xpod?.runner === 'string' ? xpod.runner : ''),
|
|
535
567
|
status: (record.status || 'active'),
|
|
536
|
-
triggerKind: (record.triggerKind || 'once'),
|
|
537
|
-
cron: record.cron || undefined,
|
|
538
|
-
intervalSeconds: typeof record.intervalSeconds === 'number'
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
568
|
+
triggerKind: (record.triggerKind || xpod?.triggerKind || 'once'),
|
|
569
|
+
cron: record.cron || (typeof xpod?.cron === 'string' ? xpod.cron : undefined),
|
|
570
|
+
intervalSeconds: typeof record.intervalSeconds === 'number'
|
|
571
|
+
? record.intervalSeconds
|
|
572
|
+
: (typeof xpod?.intervalSeconds === 'number' ? xpod.intervalSeconds : undefined),
|
|
573
|
+
eventName: record.eventName || (typeof xpod?.eventName === 'string' ? xpod.eventName : undefined),
|
|
574
|
+
nextRunAt: this.isoToTimestamp(record.nextRunAt) ?? (typeof xpod?.nextRunAt === 'number' ? xpod.nextRunAt : undefined),
|
|
575
|
+
lastRunAt: this.isoToTimestamp(record.lastRunAt) ?? (typeof xpod?.lastRunAt === 'number' ? xpod.lastRunAt : undefined),
|
|
576
|
+
authBinding: this.parseTaskAuthBinding(metadata?.authBinding),
|
|
577
|
+
metadata,
|
|
544
578
|
createdAt: this.isoToTimestamp(record.createdAt) ?? (0, types_1.nowTimestamp)(),
|
|
545
579
|
updatedAt: this.isoToTimestamp(record.updatedAt) ?? (0, types_1.nowTimestamp)(),
|
|
546
580
|
};
|
|
@@ -876,12 +910,7 @@ class PodChatKitStore {
|
|
|
876
910
|
surface_id: surfaceId,
|
|
877
911
|
chat_id: surfaceId,
|
|
878
912
|
};
|
|
879
|
-
|
|
880
|
-
const metadataToPersist = { ...(thread.metadata ?? {}) };
|
|
881
|
-
delete metadataToPersist.chat_id;
|
|
882
|
-
delete metadataToPersist.commandKind;
|
|
883
|
-
delete metadataToPersist.surface_id;
|
|
884
|
-
const metadataObject = this.jsonObjectOrNull(metadataToPersist);
|
|
913
|
+
const metadataObject = this.jsonObjectOrNull(thread.metadata);
|
|
885
914
|
if (commandKind === 'chat') {
|
|
886
915
|
await this.ensureChat(surfaceId, context);
|
|
887
916
|
}
|
|
@@ -898,9 +927,8 @@ class PodChatKitStore {
|
|
|
898
927
|
if (existing) {
|
|
899
928
|
// Update
|
|
900
929
|
await db.updateByIri(schema_1.Thread, threadResource, {
|
|
901
|
-
commandKind,
|
|
902
|
-
surfaceId,
|
|
903
930
|
chat: commandKind === 'chat' ? this.buildChatResourceId(surfaceId) : null,
|
|
931
|
+
task: commandKind === 'task' ? (0, store_2.buildTaskResourceId)(`index.ttl#${surfaceId}`) : null,
|
|
904
932
|
title: thread.title || null,
|
|
905
933
|
status: this.statusToString(thread.status),
|
|
906
934
|
workspace: thread.workspace || null,
|
|
@@ -912,9 +940,8 @@ class PodChatKitStore {
|
|
|
912
940
|
// Insert
|
|
913
941
|
await db.insert(schema_1.Thread).values({
|
|
914
942
|
id: threadResourceId,
|
|
915
|
-
commandKind,
|
|
916
|
-
surfaceId,
|
|
917
943
|
chat: commandKind === 'chat' ? this.buildChatResourceId(surfaceId) : null,
|
|
944
|
+
task: commandKind === 'task' ? (0, store_2.buildTaskResourceId)(`index.ttl#${surfaceId}`) : null,
|
|
918
945
|
title: thread.title || null,
|
|
919
946
|
status: this.statusToString(thread.status),
|
|
920
947
|
workspace: thread.workspace || null,
|
|
@@ -1094,8 +1121,6 @@ class PodChatKitStore {
|
|
|
1094
1121
|
}
|
|
1095
1122
|
const messageRecord = {
|
|
1096
1123
|
id: itemResourceId,
|
|
1097
|
-
commandKind: resolvedThread.commandKind,
|
|
1098
|
-
surfaceId: resolvedThread.surfaceId,
|
|
1099
1124
|
chat: resolvedThread.commandKind === 'chat' ? this.buildChatResourceId(resolvedThread.surfaceId) : null,
|
|
1100
1125
|
thread: resolvedThread.thread,
|
|
1101
1126
|
maker: role === schema_1.MessageRole.USER ? webId : null,
|
|
@@ -1104,7 +1129,12 @@ class PodChatKitStore {
|
|
|
1104
1129
|
status,
|
|
1105
1130
|
toolName,
|
|
1106
1131
|
toolCallId,
|
|
1107
|
-
metadata: this.jsonObjectOrNull(
|
|
1132
|
+
metadata: this.jsonObjectOrNull({
|
|
1133
|
+
...(metadata ?? {}),
|
|
1134
|
+
commandKind: resolvedThread.commandKind,
|
|
1135
|
+
surface_id: resolvedThread.surfaceId,
|
|
1136
|
+
chat_id: resolvedThread.surfaceId,
|
|
1137
|
+
}),
|
|
1108
1138
|
createdAt: new Date(item.created_at * 1000).toISOString(),
|
|
1109
1139
|
};
|
|
1110
1140
|
await db.insert(schema_1.Message).values(messageRecord);
|
|
@@ -1302,12 +1332,14 @@ WHERE { ${deletePatterns.join(' ')} }
|
|
|
1302
1332
|
}
|
|
1303
1333
|
run.id = (0, store_1.buildRunResourceId)(run);
|
|
1304
1334
|
const existing = await db.findById(schema_2.Run, run.id);
|
|
1305
|
-
const
|
|
1335
|
+
const metadata = this.withXpodMetadata(run.metadata, {
|
|
1336
|
+
commandKind: run.commandKind,
|
|
1306
1337
|
surfaceId: run.surfaceId,
|
|
1338
|
+
});
|
|
1339
|
+
const values = {
|
|
1307
1340
|
task: run.task || null,
|
|
1308
1341
|
thread: run.thread,
|
|
1309
1342
|
workspace: run.workspace,
|
|
1310
|
-
commandKind: run.commandKind,
|
|
1311
1343
|
status: run.status,
|
|
1312
1344
|
runner: run.runner || null,
|
|
1313
1345
|
prompt: run.prompt || null,
|
|
@@ -1317,7 +1349,7 @@ WHERE { ${deletePatterns.join(' ')} }
|
|
|
1317
1349
|
heartbeatAt: this.timestampToIso(run.heartbeatAt),
|
|
1318
1350
|
cancelRequestedAt: this.timestampToIso(run.cancelRequestedAt),
|
|
1319
1351
|
error: run.error || null,
|
|
1320
|
-
metadata: this.jsonObjectOrNull(
|
|
1352
|
+
metadata: this.jsonObjectOrNull(metadata),
|
|
1321
1353
|
createdAt: this.timestampToIso(run.createdAt) ?? new Date().toISOString(),
|
|
1322
1354
|
startedAt: this.timestampToIso(run.startedAt),
|
|
1323
1355
|
completedAt: this.timestampToIso(run.completedAt),
|
|
@@ -1358,9 +1390,6 @@ WHERE { ${deletePatterns.join(' ')} }
|
|
|
1358
1390
|
if (options.workspace) {
|
|
1359
1391
|
conditions.push((0, drizzle_solid_1.eq)(schema_2.Run.workspace, options.workspace));
|
|
1360
1392
|
}
|
|
1361
|
-
if (options.commandKind) {
|
|
1362
|
-
conditions.push((0, drizzle_solid_1.eq)(schema_2.Run.commandKind, options.commandKind));
|
|
1363
|
-
}
|
|
1364
1393
|
if (options.status) {
|
|
1365
1394
|
conditions.push((0, drizzle_solid_1.eq)(schema_2.Run.status, options.status));
|
|
1366
1395
|
}
|
|
@@ -1368,10 +1397,13 @@ WHERE { ${deletePatterns.join(' ')} }
|
|
|
1368
1397
|
const records = conditions.length > 0
|
|
1369
1398
|
? await query.where((0, drizzle_solid_1.and)(...conditions))
|
|
1370
1399
|
: await query;
|
|
1371
|
-
|
|
1372
|
-
|
|
1400
|
+
let runs = records.map((record) => this.runRecordToData(record));
|
|
1401
|
+
if (options.commandKind) {
|
|
1402
|
+
runs = runs.filter((run) => run.commandKind === options.commandKind);
|
|
1403
|
+
}
|
|
1404
|
+
return runs
|
|
1373
1405
|
.sort((a, b) => b.createdAt - a.createdAt || b.id.localeCompare(a.id))
|
|
1374
|
-
.slice(0, options.limit ??
|
|
1406
|
+
.slice(0, options.limit ?? runs.length);
|
|
1375
1407
|
}
|
|
1376
1408
|
async appendRunStep(event, context) {
|
|
1377
1409
|
const db = await this.getDb(context);
|
|
@@ -1384,13 +1416,14 @@ WHERE { ${deletePatterns.join(' ')} }
|
|
|
1384
1416
|
event.id = (0, store_1.buildRunStepResourceId)(event);
|
|
1385
1417
|
await db.insert(schema_2.RunStep).values({
|
|
1386
1418
|
id: event.id,
|
|
1387
|
-
commandKind: event.commandKind,
|
|
1388
|
-
surfaceId: event.surfaceId,
|
|
1389
|
-
runId: event.runId,
|
|
1390
1419
|
run: event.run,
|
|
1391
|
-
|
|
1420
|
+
stepType: event.type,
|
|
1392
1421
|
message: event.message || null,
|
|
1393
|
-
|
|
1422
|
+
payload: this.jsonObjectOrNull(this.withXpodMetadata(event.data, {
|
|
1423
|
+
commandKind: event.commandKind,
|
|
1424
|
+
surfaceId: event.surfaceId,
|
|
1425
|
+
runId: event.runId,
|
|
1426
|
+
})),
|
|
1394
1427
|
createdAt: this.timestampToIso(event.createdAt) ?? new Date().toISOString(),
|
|
1395
1428
|
});
|
|
1396
1429
|
}
|
|
@@ -1402,8 +1435,7 @@ WHERE { ${deletePatterns.join(' ')} }
|
|
|
1402
1435
|
if (!(0, store_1.isRunResourceId)(runId)) {
|
|
1403
1436
|
throw new Error(`loadRunSteps requires a base-relative Run id: ${runId}`);
|
|
1404
1437
|
}
|
|
1405
|
-
|
|
1406
|
-
const records = await db.select().from(schema_2.RunStep).where((0, drizzle_solid_1.eq)(schema_2.RunStep.runId, runId));
|
|
1438
|
+
const records = await db.select().from(schema_2.RunStep).where((0, drizzle_solid_1.eq)(schema_2.RunStep.run, this.resolveDataResource(runId, context)));
|
|
1407
1439
|
return records
|
|
1408
1440
|
.map((record) => this.runStepRecordToData(record))
|
|
1409
1441
|
.sort((a, b) => a.createdAt - b.createdAt || a.id.localeCompare(b.id));
|
|
@@ -1431,21 +1463,23 @@ WHERE { ${deletePatterns.join(' ')} }
|
|
|
1431
1463
|
}
|
|
1432
1464
|
task.id = (0, store_2.buildTaskResourceId)(task.id);
|
|
1433
1465
|
const existing = await db.findById(schema_3.Task, task.id);
|
|
1434
|
-
const
|
|
1466
|
+
const metadata = this.withXpodMetadata(this.withTaskAuthBindingMetadata(task.metadata, task.authBinding), {
|
|
1435
1467
|
surfaceId: task.surfaceId,
|
|
1468
|
+
runner: task.runner,
|
|
1469
|
+
triggerKind: task.triggerKind,
|
|
1470
|
+
cron: task.cron ?? null,
|
|
1471
|
+
intervalSeconds: task.intervalSeconds ?? null,
|
|
1472
|
+
eventName: task.eventName ?? null,
|
|
1473
|
+
nextRunAt: task.nextRunAt ?? null,
|
|
1474
|
+
lastRunAt: task.lastRunAt ?? null,
|
|
1475
|
+
});
|
|
1476
|
+
const values = {
|
|
1436
1477
|
title: task.title || null,
|
|
1478
|
+
instruction: task.prompt,
|
|
1437
1479
|
prompt: task.prompt,
|
|
1438
|
-
thread: task.thread,
|
|
1439
1480
|
workspace: task.workspace,
|
|
1440
|
-
runner: task.runner,
|
|
1441
1481
|
status: task.status,
|
|
1442
|
-
|
|
1443
|
-
cron: task.cron || null,
|
|
1444
|
-
intervalSeconds: task.intervalSeconds ?? null,
|
|
1445
|
-
eventName: task.eventName || null,
|
|
1446
|
-
nextRunAt: this.timestampToIso(task.nextRunAt),
|
|
1447
|
-
lastRunAt: this.timestampToIso(task.lastRunAt),
|
|
1448
|
-
metadata: this.jsonObjectOrNull(this.withTaskAuthBindingMetadata(task.metadata, task.authBinding)),
|
|
1482
|
+
metadata: this.jsonObjectOrNull(metadata),
|
|
1449
1483
|
createdAt: this.timestampToIso(task.createdAt) ?? new Date().toISOString(),
|
|
1450
1484
|
updatedAt: this.timestampToIso(task.updatedAt) ?? new Date().toISOString(),
|
|
1451
1485
|
};
|