@bitcobblers/wod-wiki-engine 0.59.2246 → 0.60.2248
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/agent.cjs +38 -26
- package/dist/agent.cjs.map +1 -1
- package/dist/agent.d.cts +7 -2
- package/dist/agent.d.ts +7 -2
- package/dist/agent.mjs +16 -5
- package/dist/agent.mjs.map +1 -1
- package/dist/{chunk-E6Y2XOUM.mjs → chunk-JRPNOWDS.mjs} +30 -29
- package/dist/chunk-JRPNOWDS.mjs.map +1 -0
- package/dist/index.cjs +28 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.mjs +1 -1
- package/dist/{ir-CQnh_Tid.d.cts → ir-B46Q9icI.d.cts} +2 -1
- package/dist/{ir-CQnh_Tid.d.ts → ir-B46Q9icI.d.ts} +2 -1
- package/package.json +5 -5
- package/dist/chunk-E6Y2XOUM.mjs.map +0 -1
package/dist/agent.cjs
CHANGED
|
@@ -28,7 +28,16 @@ async function requireDestructiveConfirmation(ctx, req, explicitConfirmId) {
|
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
if (ctx.confirmDestructive) {
|
|
31
|
-
const
|
|
31
|
+
const timeoutMs = ctx.confirmTimeoutMs ?? 1500;
|
|
32
|
+
let timer;
|
|
33
|
+
const approved = await Promise.race([
|
|
34
|
+
ctx.confirmDestructive(req).finally(() => {
|
|
35
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
36
|
+
}),
|
|
37
|
+
new Promise((resolve) => {
|
|
38
|
+
timer = setTimeout(() => resolve(false), timeoutMs);
|
|
39
|
+
})
|
|
40
|
+
]);
|
|
32
41
|
if (approved) return;
|
|
33
42
|
throw new AgentConfirmationRequiredError(
|
|
34
43
|
req,
|
|
@@ -1240,6 +1249,19 @@ function buildQueryServiceStoresFromStorage(storage, options = {}) {
|
|
|
1240
1249
|
},
|
|
1241
1250
|
feedCatalogStore
|
|
1242
1251
|
};
|
|
1252
|
+
const sessionStore = {
|
|
1253
|
+
getAll: async () => {
|
|
1254
|
+
const rows = await storage.readonly("sessions").getAll();
|
|
1255
|
+
return rows.map((s) => ({
|
|
1256
|
+
id: s.id,
|
|
1257
|
+
noteId: s.noteId,
|
|
1258
|
+
startedAt: s.startTime,
|
|
1259
|
+
...s.completed ? { completedAt: s.endTime } : {},
|
|
1260
|
+
createdAt: s.createdAt
|
|
1261
|
+
}));
|
|
1262
|
+
}
|
|
1263
|
+
};
|
|
1264
|
+
Object.assign(stores, { sessionStore });
|
|
1243
1265
|
if (options.datasetStore) {
|
|
1244
1266
|
stores.datasetStore = options.datasetStore;
|
|
1245
1267
|
}
|
|
@@ -2823,6 +2845,12 @@ async function setSessionPublic(storage, sessionId, isPublic) {
|
|
|
2823
2845
|
return updated;
|
|
2824
2846
|
});
|
|
2825
2847
|
}
|
|
2848
|
+
var portableTextDecoder = new TextDecoder();
|
|
2849
|
+
function decodePortableFileContent(entry) {
|
|
2850
|
+
if (typeof entry.content === "string") return entry.content;
|
|
2851
|
+
if (entry.bytes instanceof Uint8Array) return portableTextDecoder.decode(entry.bytes);
|
|
2852
|
+
throw new Error(`PortableFileEntry '${entry.path}' is missing both 'content' and 'bytes'.`);
|
|
2853
|
+
}
|
|
2826
2854
|
async function exportPortableFilesFromStorage(storage, options = {}) {
|
|
2827
2855
|
const telemetryFormat = options.telemetryFormat ?? "jsonl";
|
|
2828
2856
|
const [allNotes, allSessions, allEvents, allRevisions] = await Promise.all([
|
|
@@ -2906,12 +2934,12 @@ async function ingestPortableFilesIntoStorage(storage, files, options = {}) {
|
|
|
2906
2934
|
);
|
|
2907
2935
|
const telemetryBundles = [];
|
|
2908
2936
|
for (const jf of jsonlFiles) {
|
|
2909
|
-
const parsed = wodWikiCore.parseNoteBundleFromJsonl(jf
|
|
2937
|
+
const parsed = wodWikiCore.parseNoteBundleFromJsonl(decodePortableFileContent(jf));
|
|
2910
2938
|
errors.push(...parsed.errors.map((e) => `${jf.path}: ${e}`));
|
|
2911
2939
|
telemetryBundles.push(...parsed.bundles);
|
|
2912
2940
|
}
|
|
2913
2941
|
for (const cf of csvFiles) {
|
|
2914
|
-
const parsed = csvToTelemetryBundle(cf
|
|
2942
|
+
const parsed = csvToTelemetryBundle(decodePortableFileContent(cf));
|
|
2915
2943
|
errors.push(...parsed.errors.map((e) => `${cf.path}: ${e}`));
|
|
2916
2944
|
telemetryBundles.push(...parsed.bundles);
|
|
2917
2945
|
}
|
|
@@ -2935,7 +2963,7 @@ async function ingestPortableFilesIntoStorage(storage, files, options = {}) {
|
|
|
2935
2963
|
for (const mf of mdFiles) {
|
|
2936
2964
|
try {
|
|
2937
2965
|
const fallbackTitle = (mf.path.split("/").at(-1) ?? "Imported Note").replace(/\.md$/i, "");
|
|
2938
|
-
const parsed = parseNoteMarkdown(mf
|
|
2966
|
+
const parsed = parseNoteMarkdown(decodePortableFileContent(mf), { fallbackTitle });
|
|
2939
2967
|
const noteId = parsed.id ?? await seedNoteId(`import:${mf.path}:${now}`);
|
|
2940
2968
|
const existing = await noteStore.get(noteId);
|
|
2941
2969
|
const nextRev = existing && existing.rawContent !== parsed.rawContent ? existing.sourceRevision + 1 : existing?.sourceRevision ?? 1;
|
|
@@ -3094,7 +3122,7 @@ async function ingestPortableFilesIntoStorage(storage, files, options = {}) {
|
|
|
3094
3122
|
}
|
|
3095
3123
|
|
|
3096
3124
|
// src/version.ts
|
|
3097
|
-
var VERSION = "0.
|
|
3125
|
+
var VERSION = "0.60.2248";
|
|
3098
3126
|
|
|
3099
3127
|
// src/feed/qr.ts
|
|
3100
3128
|
var APP_ORIGIN = "https://wod.wiki";
|
|
@@ -4890,7 +4918,6 @@ var wodNotebookListTool = defineAgentTool({
|
|
|
4890
4918
|
if (link.targetKind === "note") bump(wodWikiCore.toNotebookId(link.notebookId), link.noteId);
|
|
4891
4919
|
}
|
|
4892
4920
|
for (const n of allNotes) {
|
|
4893
|
-
if (isLandingNote(n)) continue;
|
|
4894
4921
|
for (const nbId of wodWikiWql.notebooksOfItem(n)) {
|
|
4895
4922
|
bump(wodWikiCore.toNotebookId(nbId), n.id);
|
|
4896
4923
|
}
|
|
@@ -4934,7 +4961,7 @@ var wodNotebookListTool = defineAgentTool({
|
|
|
4934
4961
|
const notebooks = [...byId.values()].filter((nb) => filterOrigin === "all" || nb.origin === filterOrigin).map((nb) => ({
|
|
4935
4962
|
id: nb.notebookId,
|
|
4936
4963
|
...nb,
|
|
4937
|
-
url: `${prefix}/
|
|
4964
|
+
url: `${prefix}/notebook/${encodeURIComponent(nb.slug)}`
|
|
4938
4965
|
}));
|
|
4939
4966
|
return {
|
|
4940
4967
|
totalCount: notebooks.length,
|
|
@@ -5304,21 +5331,12 @@ async function prepareJournalSessionRun(storage, input) {
|
|
|
5304
5331
|
targetId: clonedNoteId,
|
|
5305
5332
|
noteId: clonedNoteId,
|
|
5306
5333
|
createdAt: startedAt
|
|
5307
|
-
},
|
|
5308
|
-
{
|
|
5309
|
-
id: makeNotebookLinkId("notebook/journal", "session", sessionId),
|
|
5310
|
-
notebookId: "notebook/journal",
|
|
5311
|
-
targetKind: "session",
|
|
5312
|
-
targetId: sessionId,
|
|
5313
|
-
noteId: clonedNoteId,
|
|
5314
|
-
createdAt: startedAt
|
|
5315
5334
|
}
|
|
5316
5335
|
];
|
|
5317
5336
|
await tx.readwrite("notes").put(clonedNote);
|
|
5318
5337
|
if (revisions.length > 0) await tx.readwrite("block_revisions").putMany(revisions);
|
|
5319
5338
|
if (projections.length > 0) await tx.readwrite("block_index").putMany(projections);
|
|
5320
5339
|
await tx.readwrite("page_notes").put(pageNote);
|
|
5321
|
-
await tx.readwrite("sessions").put(session2);
|
|
5322
5340
|
await tx.readwrite("notebook_links").putMany(links2);
|
|
5323
5341
|
return {
|
|
5324
5342
|
note: clonedNote,
|
|
@@ -5380,15 +5398,6 @@ async function prepareJournalSessionRun(storage, input) {
|
|
|
5380
5398
|
noteId: sourceNote.id,
|
|
5381
5399
|
createdAt: startedAt
|
|
5382
5400
|
}));
|
|
5383
|
-
links.push({
|
|
5384
|
-
id: makeNotebookLinkId("notebook/journal", "session", sessionId),
|
|
5385
|
-
notebookId: "notebook/journal",
|
|
5386
|
-
targetKind: "session",
|
|
5387
|
-
targetId: sessionId,
|
|
5388
|
-
noteId: sourceNote.id,
|
|
5389
|
-
createdAt: startedAt
|
|
5390
|
-
});
|
|
5391
|
-
await tx.readwrite("sessions").put(session);
|
|
5392
5401
|
await tx.readwrite("notebook_links").putMany(links);
|
|
5393
5402
|
return {
|
|
5394
5403
|
note: updatedNote,
|
|
@@ -5583,7 +5592,7 @@ var wodNoteGetTool = defineAgentTool({
|
|
|
5583
5592
|
date: note.date,
|
|
5584
5593
|
createdAt: note.createdAt,
|
|
5585
5594
|
tags: note.tags ?? [],
|
|
5586
|
-
notebooks,
|
|
5595
|
+
notebooks: notebooks.map((id) => ({ id, slug: wodWikiCore.notebookSlugFromId(id) })),
|
|
5587
5596
|
blocks,
|
|
5588
5597
|
sessionCount: sessions.length,
|
|
5589
5598
|
recentSessions: sessions.sort((a, b) => b.startTime - a.startTime).slice(0, 10).map((s) => ({
|
|
@@ -6055,6 +6064,9 @@ var wodSessionRunHeadlessTool = defineAgentTool({
|
|
|
6055
6064
|
outputs.push(out);
|
|
6056
6065
|
});
|
|
6057
6066
|
runtime.do(new wodWikiLang.StartSessionAction());
|
|
6067
|
+
if (stack.current?.key.toString().startsWith("waiting-to-start")) {
|
|
6068
|
+
runtime.handle(new wodWikiLang.NextEvent(void 0, { nowMs: () => clock.currentDate.getTime(), now: () => clock.currentDate }));
|
|
6069
|
+
}
|
|
6058
6070
|
const stepAdvanceMs = args.stepAdvanceMs ?? 1e4;
|
|
6059
6071
|
const maxSteps = args.maxSteps ?? 500;
|
|
6060
6072
|
let steps = 0;
|