@bitcobblers/wod-wiki-engine 0.59.2236 → 0.59.2240
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 +539 -171
- package/dist/agent.cjs.map +1 -1
- package/dist/agent.d.cts +103 -25
- package/dist/agent.d.ts +103 -25
- package/dist/agent.mjs +153 -205
- package/dist/agent.mjs.map +1 -1
- package/dist/{chunk-KQYTRLW3.mjs → chunk-F6DE535O.mjs} +428 -28
- package/dist/chunk-F6DE535O.mjs.map +1 -0
- package/dist/index.cjs +949 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +99 -15
- package/dist/index.d.ts +99 -15
- package/dist/index.mjs +514 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{ir-CKImc4T0.d.cts → ir-CQnh_Tid.d.cts} +42 -1
- package/dist/{ir-CKImc4T0.d.ts → ir-CQnh_Tid.d.ts} +42 -1
- package/package.json +5 -5
- package/dist/chunk-KQYTRLW3.mjs.map +0 -1
package/dist/agent.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extractNoteIdentity, extractTypedTags, makeNotebookLinkId, resolveScopedPropertyCatalog, effortToMarkdown, equipmentToMarkdown, saveScopedPropertyOverride, seedMetaKey, checkUnpublishedFeedChanges, MemoryFeedTree, publishFeedFromStorage, ingestPortableFilesIntoStorage, exportPortableFilesFromStorage, readFrontmatterMeta, createUserNotebookLanding, setNotebookPublic, promoteNoteToNotebooks, removeNoteFromNotebook, getNoteNotebooks, resolveUpstreamProvenance, getNotePublicationSummary, composeNoteMarkdown, buildNoteProvenance, buildStatementTree, prepareJournalSessionRun, setSessionPublic } from './chunk-
|
|
1
|
+
import { buildQueryServiceStoresFromStorage, extractNoteIdentity, extractTypedTags, makeNotebookLinkId, resolveScopedPropertyCatalog, effortToMarkdown, equipmentToMarkdown, saveScopedPropertyOverride, listFeedSubscriptionsHeadless, seedMetaKey, subscribeFeedSourceHeadless, unsubscribeFeedSourceHeadless, deleteFeedSourceHeadless, checkUnpublishedFeedChanges, MemoryFeedTree, publishFeedFromStorage, ingestPortableFilesIntoStorage, exportPortableFilesFromStorage, readFrontmatterMeta, createUserNotebookLanding, setNotebookPublic, promoteNoteToNotebooks, removeNoteFromNotebook, getNoteNotebooks, resolveUpstreamProvenance, getNotePublicationSummary, composeNoteMarkdown, buildNoteProvenance, buildStatementTree, prepareJournalSessionRun, setSessionPublic } from './chunk-F6DE535O.mjs';
|
|
2
2
|
import { BUILTIN_NOTEBOOKS, parseDocumentSections, KNOWN_SECTION_WIDGETS, isNoteEditable, reconcileNoteBlocks, validateNoteBlocks, toNotebookId, blockContentId, MetricType, orderPlacements, isSystemReadOnlyNotebook, notebookSlugFromId, isNonPublishableNotebook } from '@bitcobblers/wod-wiki-core';
|
|
3
3
|
import { bundledEfforts, createReferenceIndex, parseScript, extractStatementRefs, createParser, findUnresolvedChoices, createMockClock, RuntimeStack, EventBus, frozenNow, ScriptRuntime, createCompiler, createAnalyticsEngineForBlock, StartSessionAction, NextEvent, toStoredOutputStatement } from '@bitcobblers/wod-wiki-lang';
|
|
4
4
|
import { rowsEqual, userDeletedSeedKey } from '@bitcobblers/wod-wiki-storage';
|
|
@@ -95,168 +95,6 @@ function civilDateKey(input, nowMs = Date.now()) {
|
|
|
95
95
|
}
|
|
96
96
|
return trimmed;
|
|
97
97
|
}
|
|
98
|
-
function buildQueryServiceStoresFromStorage(storage) {
|
|
99
|
-
const asRange = (lower, upper) => typeof IDBKeyRange !== "undefined" ? IDBKeyRange.bound(lower, upper) : { lower, upper };
|
|
100
|
-
const resultRows = (key) => asRange([key, ""], [`${key}\uFFFF`, "\uFFFF"]);
|
|
101
|
-
const eventStore = {
|
|
102
|
-
getEventsByTimeRange: async (start, end) => storage.readonly("events").getAllFromIndex("by-timestamp", asRange(start, end)),
|
|
103
|
-
getEventsByResult: async (resultId) => storage.readonly("events").getAllFromIndex("by-result-grain", resultRows(resultId)),
|
|
104
|
-
getEventsForNote: async (noteId) => (await storage.readonly("events").getAll()).filter((row) => row.noteId === noteId),
|
|
105
|
-
getEventsByContent: async (cid) => storage.readonly("events").getAllFromIndex("by-content-grain", resultRows(cid)),
|
|
106
|
-
scanAll: () => storage.readonly("events").getAll(),
|
|
107
|
-
appendEvents: async (rows) => {
|
|
108
|
-
if (rows.length > 0) await storage.readwrite("events").putMany(rows);
|
|
109
|
-
},
|
|
110
|
-
finalizeSummaries: async (resultId, rows) => {
|
|
111
|
-
await storage.transaction(["events"], "readwrite", async (tx) => {
|
|
112
|
-
const allForResult = (await tx.readonly("events").getAll()).filter(
|
|
113
|
-
(r) => r.resultId === resultId && r.grain === "summary" && r.origin !== "user"
|
|
114
|
-
);
|
|
115
|
-
for (const r of allForResult) await tx.readwrite("events").delete(r.id);
|
|
116
|
-
if (rows.length > 0) await tx.readwrite("events").putMany(rows);
|
|
117
|
-
});
|
|
118
|
-
},
|
|
119
|
-
deleteEvents: async (ids) => {
|
|
120
|
-
for (const id of ids) await storage.readwrite("events").delete(id);
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
const noteStore = {
|
|
124
|
-
getAllNotes: () => storage.readonly("notes").getAll(),
|
|
125
|
-
getNotesByIds: async (ids) => {
|
|
126
|
-
const rows = await storage.readonly("notes").getMany([...ids]);
|
|
127
|
-
return rows.filter((row) => row !== void 0);
|
|
128
|
-
},
|
|
129
|
-
getNoteIdsForTag: async (label) => {
|
|
130
|
-
const ids = /* @__PURE__ */ new Set();
|
|
131
|
-
for (const tag of await storage.readonly("tags").getAllFromIndex("by-label", label)) {
|
|
132
|
-
for (const link of await storage.readonly("note_tags").getAllFromIndex("by-tag", tag.id)) {
|
|
133
|
-
ids.add(link.noteId);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return ids;
|
|
137
|
-
},
|
|
138
|
-
getNoteTagLabels: async (noteId) => {
|
|
139
|
-
const links = await storage.readonly("note_tags").getAllFromIndex("by-note", noteId);
|
|
140
|
-
const tags = await storage.readonly("tags").getMany(links.map((l) => l.tagId));
|
|
141
|
-
return tags.flatMap((t) => t ? [t.label] : []);
|
|
142
|
-
},
|
|
143
|
-
queryDomain: async (request) => {
|
|
144
|
-
if (!storage.queryDomain) return void 0;
|
|
145
|
-
const result = await storage.queryDomain({ ...request, plan: "notes" });
|
|
146
|
-
return result && result.plan === "notes" ? result : void 0;
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
const blockStore = {
|
|
150
|
-
getAllBlocks: () => storage.readonly("block_index").getAll(),
|
|
151
|
-
queryDomain: async (request) => {
|
|
152
|
-
if (!storage.queryDomain) return void 0;
|
|
153
|
-
const result = await storage.queryDomain({ ...request, plan: "blocks" });
|
|
154
|
-
return result && result.plan === "blocks" ? result : void 0;
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
const effortStore = {
|
|
158
|
-
getAllEfforts: async () => {
|
|
159
|
-
const stored = await storage.readonly("efforts").getAll();
|
|
160
|
-
const bySlug = /* @__PURE__ */ new Map();
|
|
161
|
-
for (const eff of bundledEfforts) bySlug.set(eff.slug, eff);
|
|
162
|
-
for (const eff of stored) bySlug.set(eff.slug, eff);
|
|
163
|
-
return [...bySlug.values()];
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
return {
|
|
167
|
-
eventStore,
|
|
168
|
-
noteStore,
|
|
169
|
-
blockStore,
|
|
170
|
-
effortStore,
|
|
171
|
-
blockEffortsStore: {
|
|
172
|
-
getAllFromIndex: (index, key) => storage.readonly("block_efforts").getAllFromIndex(index, key)
|
|
173
|
-
},
|
|
174
|
-
blockEquipmentStore: {
|
|
175
|
-
getAllFromIndex: (index, key) => storage.readonly("block_equipment").getAllFromIndex(index, key)
|
|
176
|
-
},
|
|
177
|
-
tagsStore: {
|
|
178
|
-
getAllFromIndex: (index, key) => storage.readonly("tags").getAllFromIndex(index, key),
|
|
179
|
-
getAll: () => storage.readonly("tags").getAll()
|
|
180
|
-
},
|
|
181
|
-
noteTagsStore: {
|
|
182
|
-
getAllFromIndex: (index, key) => storage.readonly("note_tags").getAllFromIndex(index, key)
|
|
183
|
-
},
|
|
184
|
-
pageStore: {
|
|
185
|
-
getNotePages: (noteId) => storage.readonly("page_notes").getAllFromIndex("by-note", noteId),
|
|
186
|
-
getPage: (pageId) => storage.readonly("page").get(pageId),
|
|
187
|
-
getAllPages: () => storage.readonly("page").getAll(),
|
|
188
|
-
getAllLinks: () => storage.readonly("page_notes").getAll()
|
|
189
|
-
},
|
|
190
|
-
relationStore: {
|
|
191
|
-
getBatches: async (noteIds) => {
|
|
192
|
-
const bundles = /* @__PURE__ */ new Map();
|
|
193
|
-
for (const noteId of noteIds) {
|
|
194
|
-
const links = await storage.readonly("page_notes").getAllFromIndex("by-note", noteId);
|
|
195
|
-
const tagLinks = await storage.readonly("note_tags").getAllFromIndex("by-note", noteId);
|
|
196
|
-
const tags = await storage.readonly("tags").getMany(tagLinks.map((l) => l.tagId));
|
|
197
|
-
const pages = await storage.readonly("page").getMany([...new Set(links.map((l) => l.pageId))]);
|
|
198
|
-
bundles.set(noteId, {
|
|
199
|
-
tags: tags.flatMap((t) => t ? [{ label: t.label, ...t.type ? { type: t.type } : {} }] : []),
|
|
200
|
-
links,
|
|
201
|
-
pages: pages.filter((p) => p !== void 0)
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
return bundles;
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
feedCatalogStore: {
|
|
208
|
-
getAllFeeds: async () => {
|
|
209
|
-
const rows = [];
|
|
210
|
-
for (const row of await storage.readonly("meta").getAll()) {
|
|
211
|
-
const key = row.key;
|
|
212
|
-
if (typeof key !== "string" || !key.startsWith("seed:") || key === seedMetaKey("user")) continue;
|
|
213
|
-
const id = key.slice("seed:".length);
|
|
214
|
-
rows.push({
|
|
215
|
-
id,
|
|
216
|
-
label: id,
|
|
217
|
-
url: `https://${id}.example/feed/`,
|
|
218
|
-
tier: "imported",
|
|
219
|
-
subscribed: true,
|
|
220
|
-
installed: true,
|
|
221
|
-
notebookCount: 0,
|
|
222
|
-
itemCount: 0
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
return rows;
|
|
226
|
-
},
|
|
227
|
-
getAllNotebooks: async () => {
|
|
228
|
-
const links = await storage.readonly("notebook_links").getAll().catch(() => []);
|
|
229
|
-
const notes = await storage.readonly("notes").getAll();
|
|
230
|
-
const memberCount = /* @__PURE__ */ new Map();
|
|
231
|
-
for (const link of links) {
|
|
232
|
-
if (link.targetKind === "note") {
|
|
233
|
-
memberCount.set(link.notebookId, (memberCount.get(link.notebookId) ?? 0) + 1);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
const rows = [];
|
|
237
|
-
for (const [notebookId, count] of memberCount) {
|
|
238
|
-
const slug = notebookId.startsWith("notebook/") ? notebookId.slice("notebook/".length) : notebookId;
|
|
239
|
-
const landing = notes.find((n) => n.id === notebookId);
|
|
240
|
-
const feedSourceId = landing?.feedSourceId;
|
|
241
|
-
rows.push({
|
|
242
|
-
id: notebookId,
|
|
243
|
-
feedId: feedSourceId ?? "local",
|
|
244
|
-
feedLabel: feedSourceId ?? "Yours (Local)",
|
|
245
|
-
chunkId: `notebook.${slug}`,
|
|
246
|
-
slug,
|
|
247
|
-
label: landing?.title ?? slug,
|
|
248
|
-
count,
|
|
249
|
-
subscribed: feedSourceId !== void 0,
|
|
250
|
-
installed: true,
|
|
251
|
-
origin: feedSourceId ? "feed" : "user",
|
|
252
|
-
...landing?.public !== void 0 ? { public: landing.public } : {}
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
return rows;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
98
|
function createQueryServiceForStorage(storage) {
|
|
261
99
|
return new QueryService(buildQueryServiceStoresFromStorage(storage));
|
|
262
100
|
}
|
|
@@ -629,7 +467,7 @@ function noteDeepLink(note, baseUrl = "") {
|
|
|
629
467
|
const prefix = baseUrl.replace(/\/+$/, "");
|
|
630
468
|
return `${prefix}/note/${encodeURIComponent(note.id)}`;
|
|
631
469
|
}
|
|
632
|
-
var catalogLookupInputSchema = z.
|
|
470
|
+
var catalogLookupInputSchema = z.strictObject({
|
|
633
471
|
kind: z.enum(["effort", "equipment", "tag", "tag-type"]).describe("Catalog family to search or inspect."),
|
|
634
472
|
search: z.string().optional().describe("Case-insensitive slug, label, or alias filter."),
|
|
635
473
|
slug: z.string().optional().describe("Exact canonical slug/name to look up."),
|
|
@@ -729,7 +567,7 @@ var wodCatalogLookupTool = defineAgentTool({
|
|
|
729
567
|
};
|
|
730
568
|
}
|
|
731
569
|
});
|
|
732
|
-
var catalogUpsertInputSchema = z.
|
|
570
|
+
var catalogUpsertInputSchema = z.strictObject({
|
|
733
571
|
kind: z.enum(["effort", "equipment", "tag", "tag-type"]).describe("Property definition family to create or override."),
|
|
734
572
|
slug: z.string().min(1).describe('Canonical kebab-case slug (e.g. "kettlebell-swing", "barbell").'),
|
|
735
573
|
label: z.string().optional().describe("Human-readable display label."),
|
|
@@ -841,13 +679,17 @@ var wodCatalogUpsertTool = defineAgentTool({
|
|
|
841
679
|
}
|
|
842
680
|
});
|
|
843
681
|
var CATALOG_AGENT_TOOLS = [wodCatalogLookupTool, wodCatalogUpsertTool];
|
|
844
|
-
var feedManageInputSchema = z.
|
|
845
|
-
action: z.enum(["list", "status", "publish", "import-bundle"]).describe("Feed or portability operation to run."),
|
|
682
|
+
var feedManageInputSchema = z.strictObject({
|
|
683
|
+
action: z.enum(["list", "status", "publish", "import-bundle", "subscribe", "unsubscribe", "delete"]).describe("Feed or portability operation to run."),
|
|
684
|
+
sourceId: z.string().min(1).optional().describe('Target Feed source ID when action is "subscribe", "unsubscribe", or "delete".'),
|
|
685
|
+
notebookIds: z.array(z.string().min(1)).optional().describe('Optional subset of Notebook IDs when action="subscribe".'),
|
|
686
|
+
url: z.string().min(1).optional().describe("Optional Feed manifest URL when subscribing to a custom source."),
|
|
687
|
+
confirmId: z.string().optional().describe("Confirmation token (must match sourceId) for non-interactive unsubscribe/delete calls."),
|
|
846
688
|
notebookSlug: z.string().optional().describe("Optional Notebook slug filter when publishing."),
|
|
847
|
-
name: z.string().optional().describe("Optional Feed display name when publishing."),
|
|
689
|
+
name: z.string().optional().describe("Optional Feed display name when publishing or subscribing."),
|
|
848
690
|
description: z.string().optional().describe("Optional Feed description when publishing."),
|
|
849
691
|
files: z.array(
|
|
850
|
-
z.
|
|
692
|
+
z.strictObject({
|
|
851
693
|
path: z.string().min(1),
|
|
852
694
|
content: z.string()
|
|
853
695
|
})
|
|
@@ -856,7 +698,7 @@ var feedManageInputSchema = z.object({
|
|
|
856
698
|
var wodFeedManageTool = defineAgentTool({
|
|
857
699
|
name: "wod_feed_manage",
|
|
858
700
|
title: "Manage Feeds & Portability",
|
|
859
|
-
description: "Inspect installed Seed/Feed sources (`list`), check unpublished public Notebook changes (`status`), compile and publish public Notebooks (`publish`),
|
|
701
|
+
description: "Inspect installed Seed/Feed sources (`list`), check unpublished public Notebook changes (`status`), compile and publish public Notebooks (`publish`), import portable Markdown + JSONL/CSV files (`import-bundle`), or subscribe/unsubscribe/delete a Feed source.",
|
|
860
702
|
tier: 1,
|
|
861
703
|
domain: "feed",
|
|
862
704
|
annotations: {
|
|
@@ -867,27 +709,120 @@ var wodFeedManageTool = defineAgentTool({
|
|
|
867
709
|
openWorldHint: false
|
|
868
710
|
},
|
|
869
711
|
inputSchema: feedManageInputSchema,
|
|
870
|
-
cliEquivalent: "wod feed <list|status|publish> --json",
|
|
712
|
+
cliEquivalent: "wod feed <list|status|publish|subscribe|unsubscribe|delete> --json",
|
|
871
713
|
async execute(args, ctx) {
|
|
872
714
|
if (args.action === "list") {
|
|
873
715
|
const metaRows = await ctx.storage.readonly("meta").getAll();
|
|
716
|
+
const subscriptions = await listFeedSubscriptionsHeadless(ctx.storage);
|
|
874
717
|
const installedFeeds = [];
|
|
875
718
|
for (const row of metaRows) {
|
|
876
719
|
const obj = row;
|
|
877
720
|
if (typeof obj.key === "string" && obj.key.startsWith("seed:") && obj.key !== seedMetaKey("user")) {
|
|
721
|
+
const sourceId = obj.key.slice("seed:".length);
|
|
878
722
|
installedFeeds.push({
|
|
879
|
-
sourceId
|
|
723
|
+
sourceId,
|
|
880
724
|
seedVersion: obj.seedVersion,
|
|
881
725
|
builtAt: obj.builtAt,
|
|
882
726
|
importedAt: obj.importedAt,
|
|
883
|
-
chunkCount: Object.keys(obj.chunks ?? {}).length
|
|
727
|
+
chunkCount: Object.keys(obj.chunks ?? {}).length,
|
|
728
|
+
subscribed: subscriptions[sourceId]?.subscribed ?? true
|
|
884
729
|
});
|
|
885
730
|
}
|
|
886
731
|
}
|
|
887
732
|
return {
|
|
888
733
|
action: "list",
|
|
889
734
|
installedCount: installedFeeds.length,
|
|
890
|
-
feeds: installedFeeds
|
|
735
|
+
feeds: installedFeeds,
|
|
736
|
+
subscriptions
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
if (args.action === "subscribe") {
|
|
740
|
+
if (!args.sourceId) {
|
|
741
|
+
throw new Error('Provide `sourceId` when action="subscribe".');
|
|
742
|
+
}
|
|
743
|
+
const res = ctx.feedLifecycle?.subscribe ? await ctx.feedLifecycle.subscribe(args.sourceId, {
|
|
744
|
+
notebookIds: args.notebookIds,
|
|
745
|
+
url: args.url,
|
|
746
|
+
name: args.name
|
|
747
|
+
}) : await subscribeFeedSourceHeadless(ctx.storage, args.sourceId, {
|
|
748
|
+
notebookIds: args.notebookIds,
|
|
749
|
+
url: args.url,
|
|
750
|
+
name: args.name
|
|
751
|
+
});
|
|
752
|
+
await ctx.onMutated?.(["meta", "notes"]);
|
|
753
|
+
return {
|
|
754
|
+
action: "subscribe",
|
|
755
|
+
...res
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
if (args.action === "unsubscribe") {
|
|
759
|
+
if (!args.sourceId) {
|
|
760
|
+
throw new Error('Provide `sourceId` when action="unsubscribe".');
|
|
761
|
+
}
|
|
762
|
+
if (args.sourceId === "core") {
|
|
763
|
+
throw new Error("Core feed cannot be unsubscribed.");
|
|
764
|
+
}
|
|
765
|
+
await requireDestructiveConfirmation(
|
|
766
|
+
ctx,
|
|
767
|
+
{
|
|
768
|
+
action: "wod_feed_manage:unsubscribe",
|
|
769
|
+
targetId: args.sourceId,
|
|
770
|
+
summary: `Unsubscribe from feed '${args.sourceId}' and purge its imported notes`
|
|
771
|
+
},
|
|
772
|
+
args.confirmId
|
|
773
|
+
);
|
|
774
|
+
const res = ctx.feedLifecycle?.unsubscribe ? await ctx.feedLifecycle.unsubscribe(args.sourceId) : await unsubscribeFeedSourceHeadless(ctx.storage, args.sourceId);
|
|
775
|
+
await ctx.onMutated?.([
|
|
776
|
+
"meta",
|
|
777
|
+
"notes",
|
|
778
|
+
"tags",
|
|
779
|
+
"note_tags",
|
|
780
|
+
"block_index",
|
|
781
|
+
"block_efforts",
|
|
782
|
+
"block_equipment",
|
|
783
|
+
"page_notes",
|
|
784
|
+
"efforts",
|
|
785
|
+
"equipment",
|
|
786
|
+
"property_overrides"
|
|
787
|
+
]);
|
|
788
|
+
return {
|
|
789
|
+
action: "unsubscribe",
|
|
790
|
+
...res
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
if (args.action === "delete") {
|
|
794
|
+
if (!args.sourceId) {
|
|
795
|
+
throw new Error('Provide `sourceId` when action="delete".');
|
|
796
|
+
}
|
|
797
|
+
if (args.sourceId === "core") {
|
|
798
|
+
throw new Error("Core feed cannot be deleted.");
|
|
799
|
+
}
|
|
800
|
+
await requireDestructiveConfirmation(
|
|
801
|
+
ctx,
|
|
802
|
+
{
|
|
803
|
+
action: "wod_feed_manage:delete",
|
|
804
|
+
targetId: args.sourceId,
|
|
805
|
+
summary: `Delete feed source '${args.sourceId}' and purge all of its imported notes`
|
|
806
|
+
},
|
|
807
|
+
args.confirmId
|
|
808
|
+
);
|
|
809
|
+
const res = ctx.feedLifecycle?.delete ? await ctx.feedLifecycle.delete(args.sourceId) : await deleteFeedSourceHeadless(ctx.storage, args.sourceId);
|
|
810
|
+
await ctx.onMutated?.([
|
|
811
|
+
"meta",
|
|
812
|
+
"notes",
|
|
813
|
+
"tags",
|
|
814
|
+
"note_tags",
|
|
815
|
+
"block_index",
|
|
816
|
+
"block_efforts",
|
|
817
|
+
"block_equipment",
|
|
818
|
+
"page_notes",
|
|
819
|
+
"efforts",
|
|
820
|
+
"equipment",
|
|
821
|
+
"property_overrides"
|
|
822
|
+
]);
|
|
823
|
+
return {
|
|
824
|
+
action: "delete",
|
|
825
|
+
...res
|
|
891
826
|
};
|
|
892
827
|
}
|
|
893
828
|
if (args.action === "status") {
|
|
@@ -936,7 +871,7 @@ var wodFeedManageTool = defineAgentTool({
|
|
|
936
871
|
};
|
|
937
872
|
}
|
|
938
873
|
});
|
|
939
|
-
var exportBundleInputSchema = z.
|
|
874
|
+
var exportBundleInputSchema = z.strictObject({
|
|
940
875
|
noteIds: z.array(z.string()).optional().describe("Optional Note IDs to export (defaults to all user-owned Notes)."),
|
|
941
876
|
telemetryFormat: z.enum(["jsonl", "csv", "both"]).optional().describe('Format for companion Session/Event telemetry files (default "jsonl").')
|
|
942
877
|
});
|
|
@@ -966,7 +901,7 @@ var wodExportBundleTool = defineAgentTool({
|
|
|
966
901
|
};
|
|
967
902
|
}
|
|
968
903
|
});
|
|
969
|
-
var resetStorageInputSchema = z.
|
|
904
|
+
var resetStorageInputSchema = z.strictObject({
|
|
970
905
|
confirmToken: z.string().optional().describe('For non-interactive MCP/CLI calls, pass confirmToken="WIPE_STORAGE" to confirm wiping user storage.')
|
|
971
906
|
});
|
|
972
907
|
var wodResetStorageTool = defineAgentTool({
|
|
@@ -1004,7 +939,7 @@ var FEED_AGENT_TOOLS = [
|
|
|
1004
939
|
wodExportBundleTool,
|
|
1005
940
|
wodResetStorageTool
|
|
1006
941
|
];
|
|
1007
|
-
var journalDayInputSchema = z.
|
|
942
|
+
var journalDayInputSchema = z.strictObject({
|
|
1008
943
|
date: z.string().optional().describe('Calendar date in YYYY-MM-DD format, or "today" (defaults to "today").')
|
|
1009
944
|
});
|
|
1010
945
|
var wodJournalDayTool = defineAgentTool({
|
|
@@ -1099,7 +1034,7 @@ var wodJournalDayTool = defineAgentTool({
|
|
|
1099
1034
|
};
|
|
1100
1035
|
}
|
|
1101
1036
|
});
|
|
1102
|
-
var journalAddInputSchema = z.
|
|
1037
|
+
var journalAddInputSchema = z.strictObject({
|
|
1103
1038
|
date: z.string().optional().describe('Target Journal date in YYYY-MM-DD format or "today" (defaults to "today").'),
|
|
1104
1039
|
title: z.string().optional().describe("Workout title (defaults to # H1 heading or date)."),
|
|
1105
1040
|
content: z.string().min(1).describe("Markdown workout note or bare Whiteboard Script to schedule onto the Journal day."),
|
|
@@ -1163,7 +1098,7 @@ function isLandingNote(note) {
|
|
|
1163
1098
|
return note.id.startsWith("notebook/") && note.notebookId === note.id;
|
|
1164
1099
|
}
|
|
1165
1100
|
var RESERVED_SLUGS = new Set(BUILTIN_NOTEBOOKS.map((b) => b.slug));
|
|
1166
|
-
var notebookListInputSchema = z.
|
|
1101
|
+
var notebookListInputSchema = z.strictObject({
|
|
1167
1102
|
origin: z.enum(["all", "default", "user", "feed"]).optional().describe('Filter notebooks by origin (default "all").')
|
|
1168
1103
|
});
|
|
1169
1104
|
var wodNotebookListTool = defineAgentTool({
|
|
@@ -1250,7 +1185,7 @@ var wodNotebookListTool = defineAgentTool({
|
|
|
1250
1185
|
};
|
|
1251
1186
|
}
|
|
1252
1187
|
});
|
|
1253
|
-
var notebookSaveInputSchema = z.
|
|
1188
|
+
var notebookSaveInputSchema = z.strictObject({
|
|
1254
1189
|
action: z.enum(["create", "update", "promote", "detach", "set-public"]).describe("Operation to perform on a user Notebook."),
|
|
1255
1190
|
notebookId: z.string().optional().describe("Target Notebook slug or ID (required for update, promote, detach, set-public)."),
|
|
1256
1191
|
name: z.string().optional().describe("Display name when creating or renaming a Notebook."),
|
|
@@ -1379,7 +1314,7 @@ icon: ${JSON.stringify(nextIcon)}
|
|
|
1379
1314
|
};
|
|
1380
1315
|
}
|
|
1381
1316
|
});
|
|
1382
|
-
var notebookDeleteInputSchema = z.
|
|
1317
|
+
var notebookDeleteInputSchema = z.strictObject({
|
|
1383
1318
|
notebookId: z.string().min(1).describe("User Notebook ID or slug to delete (member Notes stay safe in notebook/journal)."),
|
|
1384
1319
|
confirmId: z.string().optional().describe("For non-interactive MCP/CLI calls, repeat the exact notebookId or slug to confirm deletion.")
|
|
1385
1320
|
});
|
|
@@ -1450,7 +1385,7 @@ var NOTEBOOK_AGENT_TOOLS = [
|
|
|
1450
1385
|
function isLandingNote2(note) {
|
|
1451
1386
|
return note.id.startsWith("notebook/") && note.notebookId === note.id;
|
|
1452
1387
|
}
|
|
1453
|
-
var noteListInputSchema = z.
|
|
1388
|
+
var noteListInputSchema = z.strictObject({
|
|
1454
1389
|
notebookId: z.string().optional().describe('Filter by notebook ID or slug (e.g. "journal", "custom", "guides", "notebook/strength").'),
|
|
1455
1390
|
search: z.string().optional().describe("Case-insensitive substring filter over title and Markdown content."),
|
|
1456
1391
|
tag: z.string().optional().describe("Filter to Notes carrying this tag label."),
|
|
@@ -1473,23 +1408,30 @@ var wodNoteListTool = defineAgentTool({
|
|
|
1473
1408
|
inputSchema: noteListInputSchema,
|
|
1474
1409
|
cliEquivalent: "wod note list --json",
|
|
1475
1410
|
async execute(args, ctx) {
|
|
1476
|
-
const allNotes = await ctx.storage.readonly("notes").getAll();
|
|
1477
1411
|
const targetNb = args.notebookId ? toNotebookId(args.notebookId) : void 0;
|
|
1478
1412
|
const includeSeed = args.includeSeed ?? Boolean(targetNb);
|
|
1479
1413
|
const searchLower = args.search?.trim().toLowerCase();
|
|
1480
1414
|
const tagLower = args.tag?.trim().toLowerCase();
|
|
1481
1415
|
const limit = args.limit ?? 50;
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
)
|
|
1489
|
-
|
|
1490
|
-
|
|
1416
|
+
const { allNotes, linkedNoteIdsForNb } = await ctx.storage.transaction(
|
|
1417
|
+
["notes", "notebook_links"],
|
|
1418
|
+
"readonly",
|
|
1419
|
+
async (tx) => {
|
|
1420
|
+
const notes = await tx.readonly("notes").getAll();
|
|
1421
|
+
let linkedIds;
|
|
1422
|
+
if (targetNb) {
|
|
1423
|
+
try {
|
|
1424
|
+
const links = await tx.readonly("notebook_links").getAllFromIndex("by-notebook", targetNb);
|
|
1425
|
+
linkedIds = new Set(
|
|
1426
|
+
links.filter((l) => l.targetKind === "note").map((l) => l.noteId)
|
|
1427
|
+
);
|
|
1428
|
+
} catch {
|
|
1429
|
+
linkedIds = /* @__PURE__ */ new Set();
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
return { allNotes: notes, linkedNoteIdsForNb: linkedIds };
|
|
1491
1433
|
}
|
|
1492
|
-
|
|
1434
|
+
);
|
|
1493
1435
|
const filtered = allNotes.filter((n) => {
|
|
1494
1436
|
if (isLandingNote2(n)) return false;
|
|
1495
1437
|
if (!includeSeed && (n.seedOrigin === "seed" || n.feedOrigin === "feed")) return false;
|
|
@@ -1526,7 +1468,7 @@ var wodNoteListTool = defineAgentTool({
|
|
|
1526
1468
|
};
|
|
1527
1469
|
}
|
|
1528
1470
|
});
|
|
1529
|
-
var noteGetInputSchema = z.
|
|
1471
|
+
var noteGetInputSchema = z.strictObject({
|
|
1530
1472
|
noteId: z.string().min(1).describe("Unique Note ID (UUID or seed route ID).")
|
|
1531
1473
|
});
|
|
1532
1474
|
var wodNoteGetTool = defineAgentTool({
|
|
@@ -1602,7 +1544,7 @@ var wodNoteGetTool = defineAgentTool({
|
|
|
1602
1544
|
};
|
|
1603
1545
|
}
|
|
1604
1546
|
});
|
|
1605
|
-
var noteUpsertInputSchema = z.
|
|
1547
|
+
var noteUpsertInputSchema = z.strictObject({
|
|
1606
1548
|
noteId: z.string().optional().describe("Existing Note ID to update, or omit to create a new Note."),
|
|
1607
1549
|
title: z.string().optional().describe("Note title (defaults to # H1 heading in content)."),
|
|
1608
1550
|
content: z.string().min(1).describe("Full Markdown document or Whiteboard Script body."),
|
|
@@ -1662,7 +1604,7 @@ var wodNoteUpsertTool = defineAgentTool({
|
|
|
1662
1604
|
};
|
|
1663
1605
|
}
|
|
1664
1606
|
});
|
|
1665
|
-
var noteCloneInputSchema = z.
|
|
1607
|
+
var noteCloneInputSchema = z.strictObject({
|
|
1666
1608
|
sourceNoteId: z.string().min(1).describe("Source Note ID (including read-only Seed/Feed Notes) to clone."),
|
|
1667
1609
|
targetNotebookId: z.string().optional().describe('Target writable user Notebook ID/slug (defaults to "notebook/journal").'),
|
|
1668
1610
|
title: z.string().optional().describe("Optional title override for the cloned Note."),
|
|
@@ -1729,7 +1671,7 @@ var wodNoteCloneTool = defineAgentTool({
|
|
|
1729
1671
|
};
|
|
1730
1672
|
}
|
|
1731
1673
|
});
|
|
1732
|
-
var noteDeleteInputSchema = z.
|
|
1674
|
+
var noteDeleteInputSchema = z.strictObject({
|
|
1733
1675
|
noteId: z.string().min(1).describe("ID of the Note to delete."),
|
|
1734
1676
|
confirmId: z.string().optional().describe("For non-interactive MCP/CLI calls, repeat the exact noteId to confirm deletion.")
|
|
1735
1677
|
});
|
|
@@ -1800,7 +1742,7 @@ function collectCollectibles(node, out = []) {
|
|
|
1800
1742
|
}
|
|
1801
1743
|
return out;
|
|
1802
1744
|
}
|
|
1803
|
-
var parseScriptInputSchema = z.
|
|
1745
|
+
var parseScriptInputSchema = z.strictObject({
|
|
1804
1746
|
source: z.string().min(1).describe("Whiteboard Script body OR full Markdown document containing ```time / ```wod blocks."),
|
|
1805
1747
|
sport: z.string().optional().describe('Optional sport fence dialect override (e.g. "crossfit", "climbing", "running").'),
|
|
1806
1748
|
save: z.boolean().optional().describe("Default false (dry-run syntax & metric inspection). Set true to persist as a Note."),
|
|
@@ -1914,7 +1856,7 @@ function applyCollectibleOverrides(body, overrides) {
|
|
|
1914
1856
|
}
|
|
1915
1857
|
return updated;
|
|
1916
1858
|
}
|
|
1917
|
-
var sessionRunHeadlessInputSchema = z.
|
|
1859
|
+
var sessionRunHeadlessInputSchema = z.strictObject({
|
|
1918
1860
|
noteId: z.string().optional().describe("Existing Note ID to execute (read-only Seed/Feed Notes are automatically cloned to notebook/journal)."),
|
|
1919
1861
|
blockId: z.string().optional().describe("Optional workout block ID on `noteId` (defaults to first wod block)."),
|
|
1920
1862
|
source: z.string().optional().describe("Inline Whiteboard Script or Markdown to persist & run when `noteId` is not supplied."),
|
|
@@ -2068,7 +2010,7 @@ var wodSessionRunHeadlessTool = defineAgentTool({
|
|
|
2068
2010
|
};
|
|
2069
2011
|
}
|
|
2070
2012
|
});
|
|
2071
|
-
var sessionListInputSchema = z.
|
|
2013
|
+
var sessionListInputSchema = z.strictObject({
|
|
2072
2014
|
noteId: z.string().optional().describe("Filter Sessions by owning Note ID."),
|
|
2073
2015
|
completedOnly: z.boolean().optional().describe("Filter to completed Sessions only."),
|
|
2074
2016
|
limit: z.number().int().min(1).max(200).optional().describe("Max Sessions to return (default 50).")
|
|
@@ -2130,7 +2072,7 @@ var wodSessionListTool = defineAgentTool({
|
|
|
2130
2072
|
};
|
|
2131
2073
|
}
|
|
2132
2074
|
});
|
|
2133
|
-
var sessionGetInputSchema = z.
|
|
2075
|
+
var sessionGetInputSchema = z.strictObject({
|
|
2134
2076
|
sessionId: z.string().min(1).describe("Session ID to inspect.")
|
|
2135
2077
|
});
|
|
2136
2078
|
var wodSessionGetTool = defineAgentTool({
|
|
@@ -2169,7 +2111,7 @@ var wodSessionGetTool = defineAgentTool({
|
|
|
2169
2111
|
};
|
|
2170
2112
|
}
|
|
2171
2113
|
});
|
|
2172
|
-
var sessionDeleteInputSchema = z.
|
|
2114
|
+
var sessionDeleteInputSchema = z.strictObject({
|
|
2173
2115
|
sessionId: z.string().min(1).describe("Session ID to delete."),
|
|
2174
2116
|
confirmId: z.string().optional().describe("For non-interactive MCP/CLI calls, repeat the exact sessionId to confirm deletion.")
|
|
2175
2117
|
});
|
|
@@ -2215,7 +2157,7 @@ var SESSION_AGENT_TOOLS = [
|
|
|
2215
2157
|
wodSessionGetTool,
|
|
2216
2158
|
wodSessionDeleteTool
|
|
2217
2159
|
];
|
|
2218
|
-
var validateWqlInputSchema = z.
|
|
2160
|
+
var validateWqlInputSchema = z.strictObject({
|
|
2219
2161
|
query: z.string().describe('WQL query string to validate and inspect (e.g. ":note{notebook:journal} last 7d" or "sum:volume by {effort}").'),
|
|
2220
2162
|
targetHint: z.string().optional().describe("Optional target plane to list valid filter keys & grouping dimensions for (note, session, effort, equipment, tag, feed, block, event).")
|
|
2221
2163
|
});
|
|
@@ -2254,7 +2196,7 @@ var wodValidateWqlTool = defineAgentTool({
|
|
|
2254
2196
|
};
|
|
2255
2197
|
}
|
|
2256
2198
|
});
|
|
2257
|
-
var queryWqlInputSchema = z.
|
|
2199
|
+
var queryWqlInputSchema = z.strictObject({
|
|
2258
2200
|
query: z.string().min(1).describe('WQL query expression (e.g. ":note{notebook:journal}", ":session last 30d", "sum:volume by {week}").'),
|
|
2259
2201
|
preferredUnit: z.string().optional().describe('Optional display unit conversion preference (e.g. "lb", "kg", "m", "mi").'),
|
|
2260
2202
|
limit: z.number().int().min(1).max(500).optional().describe("Maximum rows/items to return in the response payload (default 100).")
|
|
@@ -2640,6 +2582,7 @@ function zodSchemaToJsonSchema(schema) {
|
|
|
2640
2582
|
return z.toJSONSchema(schema, { target: "draft-2020-12" });
|
|
2641
2583
|
}
|
|
2642
2584
|
function exportAgentCapabilitiesManifest(options) {
|
|
2585
|
+
const isStatic = options?.deploymentTarget === "static";
|
|
2643
2586
|
return {
|
|
2644
2587
|
schemaVersion: "1.0.0",
|
|
2645
2588
|
name: "WOD Wiki Agent Surface",
|
|
@@ -2650,7 +2593,12 @@ function exportAgentCapabilitiesManifest(options) {
|
|
|
2650
2593
|
globalNamespace: "navigator.modelContext",
|
|
2651
2594
|
library: "@mcp-b/react-webmcp"
|
|
2652
2595
|
},
|
|
2653
|
-
mcp: {
|
|
2596
|
+
mcp: isStatic ? {
|
|
2597
|
+
httpEndpoint: null,
|
|
2598
|
+
stdioCommand: "wod mcp",
|
|
2599
|
+
sdk: "@modelcontextprotocol/sdk",
|
|
2600
|
+
deploymentNote: "HTTP /api/mcp is only mounted on self-hosted `wod server` deployments, not on static hosting."
|
|
2601
|
+
} : {
|
|
2654
2602
|
httpEndpoint: "/api/mcp",
|
|
2655
2603
|
stdioCommand: "wod mcp",
|
|
2656
2604
|
sdk: "@modelcontextprotocol/sdk"
|