@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 CHANGED
@@ -1031,6 +1031,24 @@ async function getNoteNotebooks(storage, noteId) {
1031
1031
  var SEED_SCHEMA = 9;
1032
1032
  var SEED_REGISTERED_WIDGETS = wodWikiCore.KNOWN_SECTION_WIDGETS;
1033
1033
  var SEED_NAMESPACE = "1b671a64-40d5-491e-99b0-da01ff1f3341";
1034
+ var SEED_PRECEDENCE_RANK = {
1035
+ core: 0,
1036
+ community: 1,
1037
+ imported: 2,
1038
+ user: 3
1039
+ };
1040
+ function seedSourceTier(sourceIdOrMetaKey, explicitTier) {
1041
+ if (explicitTier) return explicitTier;
1042
+ if (!sourceIdOrMetaKey) return "core";
1043
+ if (sourceIdOrMetaKey === "user") return "user";
1044
+ const id = sourceIdOrMetaKey.startsWith("seed:") ? sourceIdOrMetaKey.slice(5) : sourceIdOrMetaKey;
1045
+ if (id === "core" || id === "efforts" || id === "equipment") return "core";
1046
+ if (id === "community" || id.startsWith("community-") || id === "common") return "community";
1047
+ return "imported";
1048
+ }
1049
+ function seedPrecedenceRank(sourceIdOrMetaKey, explicitTier) {
1050
+ return SEED_PRECEDENCE_RANK[seedSourceTier(sourceIdOrMetaKey, explicitTier)];
1051
+ }
1034
1052
  var EFFORTS_CHUNK_ID = "efforts";
1035
1053
  var EQUIPMENT_CHUNK_ID = "equipment";
1036
1054
  function seedMetaKey(sourceId) {
@@ -1041,68 +1059,22 @@ function notebookSlugForChunkId(chunkId) {
1041
1059
  return value && value !== "_root" ? value : void 0;
1042
1060
  }
1043
1061
 
1044
- // src/agent/helpers.ts
1045
- function mintAgentUuid() {
1046
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
1047
- return crypto.randomUUID();
1048
- }
1049
- const bytes = new Uint8Array(16);
1050
- crypto.getRandomValues(bytes);
1051
- bytes[6] = bytes[6] & 15 | 64;
1052
- bytes[8] = bytes[8] & 63 | 128;
1053
- const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
1054
- return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
1055
- }
1056
- function extractHeadingTitleFromMarkdown(rawContent) {
1057
- const withoutFm = rawContent.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, "");
1058
- for (const line of withoutFm.split(/\r?\n/)) {
1059
- const m = line.match(/^#\s+(.+)$/);
1060
- if (m?.[1]?.trim()) return m[1].trim();
1061
- }
1062
- return void 0;
1063
- }
1064
- function normalizeMarkdownOrBareScript(source, sport, title) {
1065
- const trimmed = source.trim();
1066
- if (!trimmed) return title ? `# ${title}
1067
- ` : "";
1068
- const rewrittenFences = source.replace(/^(\s*`{3,})(?:wod|whiteboard)(?=(?::[\w-]+)?\s*$)/gim, "$1time");
1069
- const sections = wodWikiCore.parseDocumentSections(rewrittenFences, { registeredWidgets: wodWikiCore.KNOWN_SECTION_WIDGETS });
1070
- if (sections.some((s) => s.scriptBlock) || /^---\r?\n/.test(rewrittenFences) || /^#\s+/m.test(rewrittenFences)) {
1071
- return rewrittenFences.endsWith("\n") ? rewrittenFences : `${rewrittenFences}
1072
- `;
1073
- }
1074
- let fenceLen = 3;
1075
- for (const match of rewrittenFences.matchAll(/`+/g)) {
1076
- fenceLen = Math.max(fenceLen, match[0].length + 1);
1077
- }
1078
- const fence = "`".repeat(fenceLen);
1079
- const heading = title ? `# ${title}
1080
-
1081
- ` : "";
1082
- return `${heading}${fence}time${sport ? `:${sport}` : ""}
1083
- ${trimmed}
1084
- ${fence}
1085
- `;
1086
- }
1087
- function civilDateKey(input, nowMs = Date.now()) {
1088
- if (!input || input.trim().toLowerCase() === "today") {
1089
- const d = new Date(nowMs);
1090
- const y = d.getUTCFullYear();
1091
- const m = String(d.getUTCMonth() + 1).padStart(2, "0");
1092
- const day = String(d.getUTCDate()).padStart(2, "0");
1093
- return `${y}-${m}-${day}`;
1094
- }
1095
- const trimmed = input.trim();
1096
- if (!/^\d{4}-\d{2}-\d{2}$/.test(trimmed)) {
1097
- throw new Error(`Invalid date '${input}'; expected YYYY-MM-DD or 'today'.`);
1098
- }
1099
- return trimmed;
1100
- }
1101
- function buildQueryServiceStoresFromStorage(storage) {
1062
+ // src/storage/queryServiceStores.ts
1063
+ function buildQueryServiceStoresFromStorage(storage, options = {}) {
1102
1064
  const asRange = (lower, upper) => typeof IDBKeyRange !== "undefined" ? IDBKeyRange.bound(lower, upper) : { lower, upper };
1103
1065
  const resultRows = (key) => asRange([key, ""], [`${key}\uFFFF`, "\uFFFF"]);
1104
- const eventStore = {
1066
+ const rawEventStore = {
1105
1067
  getEventsByTimeRange: async (start, end) => storage.readonly("events").getAllFromIndex("by-timestamp", asRange(start, end)),
1068
+ getEventsByMetricDates: async (dates) => {
1069
+ const store = storage.readonly("events");
1070
+ const byId = /* @__PURE__ */ new Map();
1071
+ for (const date of dates) {
1072
+ for (const row of await store.getAllFromIndex("by-metric-date", date)) {
1073
+ byId.set(row.id, row);
1074
+ }
1075
+ }
1076
+ return Array.from(byId.values());
1077
+ },
1106
1078
  getEventsByResult: async (resultId) => storage.readonly("events").getAllFromIndex("by-result-grain", resultRows(resultId)),
1107
1079
  getEventsForNote: async (noteId) => (await storage.readonly("events").getAll()).filter((row) => row.noteId === noteId),
1108
1080
  getEventsByContent: async (cid) => storage.readonly("events").getAllFromIndex("by-content-grain", resultRows(cid)),
@@ -1123,6 +1095,7 @@ function buildQueryServiceStoresFromStorage(storage) {
1123
1095
  for (const id of ids) await storage.readwrite("events").delete(id);
1124
1096
  }
1125
1097
  };
1098
+ const eventStore = options.coalesce !== false ? wodWikiWql.coalescingEventStore(rawEventStore) : rawEventStore;
1126
1099
  const noteStore = {
1127
1100
  getAllNotes: () => storage.readonly("notes").getAll(),
1128
1101
  getNotesByIds: async (ids) => {
@@ -1157,7 +1130,7 @@ function buildQueryServiceStoresFromStorage(storage) {
1157
1130
  return result && result.plan === "blocks" ? result : void 0;
1158
1131
  }
1159
1132
  };
1160
- const effortStore = {
1133
+ const effortStore = options.effortStore ?? {
1161
1134
  getAllEfforts: async () => {
1162
1135
  const stored = await storage.readonly("efforts").getAll();
1163
1136
  const bySlug = /* @__PURE__ */ new Map();
@@ -1166,7 +1139,65 @@ function buildQueryServiceStoresFromStorage(storage) {
1166
1139
  return [...bySlug.values()];
1167
1140
  }
1168
1141
  };
1169
- return {
1142
+ const feedCatalogStore = options.feedCatalogStore ?? {
1143
+ getAllFeeds: async () => {
1144
+ const rows = [];
1145
+ for (const row of await storage.readonly("meta").getAll()) {
1146
+ const key = row.key;
1147
+ if (typeof key !== "string" || !key.startsWith("seed:") || key === seedMetaKey("user")) continue;
1148
+ const id = key.slice("seed:".length);
1149
+ rows.push({
1150
+ id,
1151
+ label: id,
1152
+ url: `https://${id}.example/feed/`,
1153
+ tier: "imported",
1154
+ subscribed: true,
1155
+ installed: true,
1156
+ notebookCount: 0,
1157
+ itemCount: 0
1158
+ });
1159
+ }
1160
+ return rows;
1161
+ },
1162
+ getAllNotebooks: async () => {
1163
+ const links = await storage.readonly("notebook_links").getAll().catch(() => []);
1164
+ const notes = await storage.readonly("notes").getAll();
1165
+ const memberCount = /* @__PURE__ */ new Map();
1166
+ for (const link of links) {
1167
+ if (link.targetKind === "note") {
1168
+ memberCount.set(link.notebookId, (memberCount.get(link.notebookId) ?? 0) + 1);
1169
+ }
1170
+ }
1171
+ const rows = [];
1172
+ for (const [notebookId, count] of memberCount) {
1173
+ const slug = notebookId.startsWith("notebook/") ? notebookId.slice("notebook/".length) : notebookId;
1174
+ const landing = notes.find((n) => n.id === notebookId);
1175
+ const feedSourceId = landing?.feedSourceId;
1176
+ const chunkId = `notebook.${slug}`;
1177
+ const feedId = feedSourceId ?? "local";
1178
+ let subscribed = feedSourceId !== void 0;
1179
+ if (options.isNotebookSubscribed) {
1180
+ const res = options.isNotebookSubscribed(feedId, chunkId);
1181
+ subscribed = typeof res === "boolean" ? res : Boolean(await res);
1182
+ }
1183
+ rows.push({
1184
+ id: notebookId,
1185
+ feedId,
1186
+ feedLabel: feedSourceId ?? "Yours (Local)",
1187
+ chunkId,
1188
+ slug,
1189
+ label: landing?.title ?? slug,
1190
+ count,
1191
+ subscribed,
1192
+ installed: true,
1193
+ origin: feedSourceId ? "feed" : "user",
1194
+ ...landing?.public !== void 0 ? { public: landing.public } : {}
1195
+ });
1196
+ }
1197
+ return rows;
1198
+ }
1199
+ };
1200
+ const stores = {
1170
1201
  eventStore,
1171
1202
  noteStore,
1172
1203
  blockStore,
@@ -1207,58 +1238,76 @@ function buildQueryServiceStoresFromStorage(storage) {
1207
1238
  return bundles;
1208
1239
  }
1209
1240
  },
1210
- feedCatalogStore: {
1211
- getAllFeeds: async () => {
1212
- const rows = [];
1213
- for (const row of await storage.readonly("meta").getAll()) {
1214
- const key = row.key;
1215
- if (typeof key !== "string" || !key.startsWith("seed:") || key === seedMetaKey("user")) continue;
1216
- const id = key.slice("seed:".length);
1217
- rows.push({
1218
- id,
1219
- label: id,
1220
- url: `https://${id}.example/feed/`,
1221
- tier: "imported",
1222
- subscribed: true,
1223
- installed: true,
1224
- notebookCount: 0,
1225
- itemCount: 0
1226
- });
1227
- }
1228
- return rows;
1229
- },
1230
- getAllNotebooks: async () => {
1231
- const links = await storage.readonly("notebook_links").getAll().catch(() => []);
1232
- const notes = await storage.readonly("notes").getAll();
1233
- const memberCount = /* @__PURE__ */ new Map();
1234
- for (const link of links) {
1235
- if (link.targetKind === "note") {
1236
- memberCount.set(link.notebookId, (memberCount.get(link.notebookId) ?? 0) + 1);
1237
- }
1238
- }
1239
- const rows = [];
1240
- for (const [notebookId, count] of memberCount) {
1241
- const slug = notebookId.startsWith("notebook/") ? notebookId.slice("notebook/".length) : notebookId;
1242
- const landing = notes.find((n) => n.id === notebookId);
1243
- const feedSourceId = landing?.feedSourceId;
1244
- rows.push({
1245
- id: notebookId,
1246
- feedId: feedSourceId ?? "local",
1247
- feedLabel: feedSourceId ?? "Yours (Local)",
1248
- chunkId: `notebook.${slug}`,
1249
- slug,
1250
- label: landing?.title ?? slug,
1251
- count,
1252
- subscribed: feedSourceId !== void 0,
1253
- installed: true,
1254
- origin: feedSourceId ? "feed" : "user",
1255
- ...landing?.public !== void 0 ? { public: landing.public } : {}
1256
- });
1257
- }
1258
- return rows;
1259
- }
1260
- }
1241
+ feedCatalogStore
1261
1242
  };
1243
+ if (options.datasetStore) {
1244
+ stores.datasetStore = options.datasetStore;
1245
+ }
1246
+ if (options.isNotebookSubscribed) {
1247
+ stores.isNotebookSubscribed = (feedId, chunkId) => {
1248
+ const res = options.isNotebookSubscribed(feedId, chunkId);
1249
+ return typeof res === "boolean" ? res : true;
1250
+ };
1251
+ }
1252
+ return stores;
1253
+ }
1254
+
1255
+ // src/agent/helpers.ts
1256
+ function mintAgentUuid() {
1257
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
1258
+ return crypto.randomUUID();
1259
+ }
1260
+ const bytes = new Uint8Array(16);
1261
+ crypto.getRandomValues(bytes);
1262
+ bytes[6] = bytes[6] & 15 | 64;
1263
+ bytes[8] = bytes[8] & 63 | 128;
1264
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
1265
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
1266
+ }
1267
+ function extractHeadingTitleFromMarkdown(rawContent) {
1268
+ const withoutFm = rawContent.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, "");
1269
+ for (const line of withoutFm.split(/\r?\n/)) {
1270
+ const m = line.match(/^#\s+(.+)$/);
1271
+ if (m?.[1]?.trim()) return m[1].trim();
1272
+ }
1273
+ return void 0;
1274
+ }
1275
+ function normalizeMarkdownOrBareScript(source, sport, title) {
1276
+ const trimmed = source.trim();
1277
+ if (!trimmed) return title ? `# ${title}
1278
+ ` : "";
1279
+ const rewrittenFences = source.replace(/^(\s*`{3,})(?:wod|whiteboard)(?=(?::[\w-]+)?\s*$)/gim, "$1time");
1280
+ const sections = wodWikiCore.parseDocumentSections(rewrittenFences, { registeredWidgets: wodWikiCore.KNOWN_SECTION_WIDGETS });
1281
+ if (sections.some((s) => s.scriptBlock) || /^---\r?\n/.test(rewrittenFences) || /^#\s+/m.test(rewrittenFences)) {
1282
+ return rewrittenFences.endsWith("\n") ? rewrittenFences : `${rewrittenFences}
1283
+ `;
1284
+ }
1285
+ let fenceLen = 3;
1286
+ for (const match of rewrittenFences.matchAll(/`+/g)) {
1287
+ fenceLen = Math.max(fenceLen, match[0].length + 1);
1288
+ }
1289
+ const fence = "`".repeat(fenceLen);
1290
+ const heading = title ? `# ${title}
1291
+
1292
+ ` : "";
1293
+ return `${heading}${fence}time${sport ? `:${sport}` : ""}
1294
+ ${trimmed}
1295
+ ${fence}
1296
+ `;
1297
+ }
1298
+ function civilDateKey(input, nowMs = Date.now()) {
1299
+ if (!input || input.trim().toLowerCase() === "today") {
1300
+ const d = new Date(nowMs);
1301
+ const y = d.getUTCFullYear();
1302
+ const m = String(d.getUTCMonth() + 1).padStart(2, "0");
1303
+ const day = String(d.getUTCDate()).padStart(2, "0");
1304
+ return `${y}-${m}-${day}`;
1305
+ }
1306
+ const trimmed = input.trim();
1307
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(trimmed)) {
1308
+ throw new Error(`Invalid date '${input}'; expected YYYY-MM-DD or 'today'.`);
1309
+ }
1310
+ return trimmed;
1262
1311
  }
1263
1312
  function createQueryServiceForStorage(storage) {
1264
1313
  return new wodWikiWql.QueryService(buildQueryServiceStoresFromStorage(storage));
@@ -2028,7 +2077,7 @@ async function promoteReferencedOverridesToNotebook(storage, input) {
2028
2077
  }
2029
2078
 
2030
2079
  // src/agent/tools/catalogTools.ts
2031
- var catalogLookupInputSchema = zod.z.object({
2080
+ var catalogLookupInputSchema = zod.z.strictObject({
2032
2081
  kind: zod.z.enum(["effort", "equipment", "tag", "tag-type"]).describe("Catalog family to search or inspect."),
2033
2082
  search: zod.z.string().optional().describe("Case-insensitive slug, label, or alias filter."),
2034
2083
  slug: zod.z.string().optional().describe("Exact canonical slug/name to look up."),
@@ -2128,7 +2177,7 @@ var wodCatalogLookupTool = defineAgentTool({
2128
2177
  };
2129
2178
  }
2130
2179
  });
2131
- var catalogUpsertInputSchema = zod.z.object({
2180
+ var catalogUpsertInputSchema = zod.z.strictObject({
2132
2181
  kind: zod.z.enum(["effort", "equipment", "tag", "tag-type"]).describe("Property definition family to create or override."),
2133
2182
  slug: zod.z.string().min(1).describe('Canonical kebab-case slug (e.g. "kettlebell-swing", "barbell").'),
2134
2183
  label: zod.z.string().optional().describe("Human-readable display label."),
@@ -2240,6 +2289,208 @@ var wodCatalogUpsertTool = defineAgentTool({
2240
2289
  }
2241
2290
  });
2242
2291
  var CATALOG_AGENT_TOOLS = [wodCatalogLookupTool, wodCatalogUpsertTool];
2292
+ var FEED_SUBSCRIPTIONS_META_KEY = "feed:subscriptions";
2293
+ async function removeSeedSourceContent(storage, meta) {
2294
+ return await storage.transaction(
2295
+ [
2296
+ "notes",
2297
+ "attachments",
2298
+ "tags",
2299
+ "note_tags",
2300
+ "block_index",
2301
+ "block_efforts",
2302
+ "block_equipment",
2303
+ "page_notes",
2304
+ "efforts",
2305
+ "equipment",
2306
+ "property_overrides",
2307
+ "meta"
2308
+ ],
2309
+ "readwrite",
2310
+ async (tx) => {
2311
+ const targetIds = /* @__PURE__ */ new Set();
2312
+ const legacyChunks = [];
2313
+ for (const [chunkId, chunk] of Object.entries(meta.chunks)) {
2314
+ if (chunk.noteIds?.length) {
2315
+ for (const id of chunk.noteIds) targetIds.add(id);
2316
+ } else {
2317
+ legacyChunks.push(chunkId);
2318
+ }
2319
+ }
2320
+ if (legacyChunks.length) {
2321
+ for (const note of await tx.readwrite("notes").getAll()) {
2322
+ if (note.seedOrigin === "seed" && note.seedChunkId && legacyChunks.includes(note.seedChunkId)) {
2323
+ targetIds.add(note.id);
2324
+ }
2325
+ }
2326
+ }
2327
+ const metaStore = tx.readwrite("meta");
2328
+ const otherCheckpoints = [];
2329
+ for (const row of await metaStore.getAll()) {
2330
+ const other = row;
2331
+ if (!other || typeof other.key !== "string" || !other.key.startsWith("seed:") || other.key === meta.key) {
2332
+ continue;
2333
+ }
2334
+ const noteIds = /* @__PURE__ */ new Set();
2335
+ for (const chunk of Object.values(other.chunks ?? {})) {
2336
+ for (const id of chunk.noteIds ?? []) noteIds.add(id);
2337
+ }
2338
+ otherCheckpoints.push({
2339
+ key: other.key,
2340
+ sourceId: other.key.slice(5),
2341
+ rank: seedPrecedenceRank(other.key, other.tier),
2342
+ meta: other,
2343
+ noteIds
2344
+ });
2345
+ }
2346
+ otherCheckpoints.sort((a, b) => b.rank - a.rank);
2347
+ const isClaimedByOther = (noteId) => otherCheckpoints.some((cp) => cp.noteIds.has(noteId));
2348
+ const removedSourceId = meta.key.startsWith("seed:") ? meta.key.slice(5) : meta.key;
2349
+ const notes = tx.readwrite("notes");
2350
+ const noteTags = tx.readwrite("note_tags");
2351
+ let deleted = 0;
2352
+ const removedPaths = /* @__PURE__ */ new Set();
2353
+ const touchedTagIds = /* @__PURE__ */ new Set();
2354
+ for (const id of targetIds) {
2355
+ if (isClaimedByOther(id)) continue;
2356
+ const note = await notes.get(id);
2357
+ if (!note || note.seedOrigin !== "seed") continue;
2358
+ if (note.seedChunkId && !meta.chunks[note.seedChunkId]) continue;
2359
+ if (note.sourcePath) removedPaths.add(note.sourcePath);
2360
+ await notes.delete(id);
2361
+ const attachments = tx.readwrite("attachments");
2362
+ for (const attachment of await attachments.getAllFromIndex("by-note", id)) {
2363
+ await attachments.delete(attachment.id);
2364
+ }
2365
+ for (const link of await noteTags.getAllFromIndex("by-note", id)) {
2366
+ touchedTagIds.add(link.tagId);
2367
+ await noteTags.delete(link.id);
2368
+ }
2369
+ const blockIndex = tx.readwrite("block_index");
2370
+ for (const row of await blockIndex.getAllFromIndex("by-note", id)) await blockIndex.delete(row.id);
2371
+ const blockEfforts = tx.readwrite("block_efforts");
2372
+ for (const row of await blockEfforts.getAllFromIndex("by-note", id)) await blockEfforts.delete(row.id);
2373
+ const blockEquipment = tx.readwrite("block_equipment");
2374
+ for (const row of await blockEquipment.getAllFromIndex("by-note", id)) await blockEquipment.delete(row.id);
2375
+ const pageNotes = tx.readwrite("page_notes");
2376
+ for (const link of await pageNotes.getAllFromIndex("by-note", id)) await pageNotes.delete(link.id);
2377
+ deleted++;
2378
+ }
2379
+ if (touchedTagIds.size > 0) {
2380
+ const tagsStore = tx.readwrite("tags");
2381
+ for (const tagId of touchedTagIds) {
2382
+ const remainingLinks = await noteTags.countFromIndex("by-tag", tagId);
2383
+ if (remainingLinks > 0) continue;
2384
+ const tag = await tagsStore.get(tagId);
2385
+ if (!tag) continue;
2386
+ if (tag.contributions && tag.contributions.length > 0) continue;
2387
+ const refNote = await notes.get(`t/${tag.type ?? "tag"}/${tag.label}`);
2388
+ if (refNote) continue;
2389
+ await tagsStore.delete(tagId);
2390
+ }
2391
+ }
2392
+ const defFamilies = [
2393
+ { storeName: "efforts", familyPathPrefix: "markdown/efforts/", parse: wodWikiLang.parseEffortFile },
2394
+ { storeName: "equipment", familyPathPrefix: "markdown/equipment/", parse: wodWikiLang.parseEquipmentFile }
2395
+ ];
2396
+ for (const { storeName, familyPathPrefix, parse } of defFamilies) {
2397
+ const store = tx.readwrite(storeName);
2398
+ for (const row of await store.getAll()) {
2399
+ if (row.registrySource !== "bundled") continue;
2400
+ const owned = row.sourceId === removedSourceId || row.ownerNoteId !== void 0 && targetIds.has(row.ownerNoteId) && (!row.sourceId || row.sourceId === storeName) || row.sourcePath !== void 0 && row.sourcePath.startsWith(familyPathPrefix) && removedPaths.has(row.sourcePath);
2401
+ if (!owned) continue;
2402
+ let restored = false;
2403
+ for (const cp of otherCheckpoints) {
2404
+ const candidateIds = cp.meta.chunks?.[storeName]?.noteIds ?? [];
2405
+ for (const candidateId of candidateIds) {
2406
+ const candidateNote = await notes.get(candidateId);
2407
+ if (!candidateNote || candidateNote.seedOrigin !== "seed") continue;
2408
+ const parsed = parse(candidateNote.rawContent);
2409
+ if (parsed && parsed.slug === row.slug) {
2410
+ await store.put({
2411
+ ...parsed,
2412
+ registrySource: "bundled",
2413
+ ownerNoteId: candidateNote.id,
2414
+ sourceId: cp.sourceId,
2415
+ feedSourceId: cp.sourceId,
2416
+ sourcePath: candidateNote.sourcePath ?? ""
2417
+ });
2418
+ restored = true;
2419
+ break;
2420
+ }
2421
+ }
2422
+ if (restored) break;
2423
+ }
2424
+ if (!restored) await store.delete(row.slug);
2425
+ }
2426
+ }
2427
+ try {
2428
+ const overrideStore = tx.readwrite("property_overrides");
2429
+ for (const ov of await overrideStore.getAll()) {
2430
+ if (ov.seedOrigin === "seed" && ov.feedSourceId === removedSourceId) {
2431
+ await overrideStore.delete(ov.id);
2432
+ }
2433
+ }
2434
+ } catch {
2435
+ }
2436
+ await metaStore.delete(meta.key);
2437
+ return deleted;
2438
+ }
2439
+ );
2440
+ }
2441
+ async function readFeedSubscriptionsMap(storage) {
2442
+ const row = await storage.readonly("meta").get(FEED_SUBSCRIPTIONS_META_KEY);
2443
+ return { ...row?.entries ?? {} };
2444
+ }
2445
+ async function writeFeedSubscriptionEntry(storage, sourceId, entry) {
2446
+ await storage.transaction(["meta"], "readwrite", async (tx) => {
2447
+ const metaStore = tx.readwrite("meta");
2448
+ const existing = await metaStore.get(FEED_SUBSCRIPTIONS_META_KEY);
2449
+ const entries = { ...existing?.entries ?? {}, [sourceId]: entry };
2450
+ await metaStore.put({ key: FEED_SUBSCRIPTIONS_META_KEY, entries });
2451
+ });
2452
+ }
2453
+ async function listFeedSubscriptionsHeadless(storage) {
2454
+ return readFeedSubscriptionsMap(storage);
2455
+ }
2456
+ async function subscribeFeedSourceHeadless(storage, sourceId, options) {
2457
+ const notebookIds = options?.notebookIds && options.notebookIds.length > 0 ? options.notebookIds : null;
2458
+ await writeFeedSubscriptionEntry(storage, sourceId, {
2459
+ subscribed: true,
2460
+ notebookIds,
2461
+ hidden: false,
2462
+ ...options?.url ? { url: options.url } : {},
2463
+ ...options?.name ? { name: options.name } : {},
2464
+ updatedAt: Date.now()
2465
+ });
2466
+ return { sourceId, subscribed: true, notebookIds };
2467
+ }
2468
+ async function unsubscribeFeedSourceHeadless(storage, sourceId) {
2469
+ if (sourceId === "core") {
2470
+ throw new Error("Core feed cannot be unsubscribed.");
2471
+ }
2472
+ const meta = await storage.readonly("meta").get(seedMetaKey(sourceId));
2473
+ const deletedNotes = meta ? await removeSeedSourceContent(storage, meta) : 0;
2474
+ await writeFeedSubscriptionEntry(storage, sourceId, {
2475
+ subscribed: false,
2476
+ hidden: false,
2477
+ updatedAt: Date.now()
2478
+ });
2479
+ return { sourceId, unsubscribed: true, deletedNotes };
2480
+ }
2481
+ async function deleteFeedSourceHeadless(storage, sourceId) {
2482
+ if (sourceId === "core") {
2483
+ throw new Error("Core feed cannot be deleted.");
2484
+ }
2485
+ const meta = await storage.readonly("meta").get(seedMetaKey(sourceId));
2486
+ const deletedNotes = meta ? await removeSeedSourceContent(storage, meta) : 0;
2487
+ await writeFeedSubscriptionEntry(storage, sourceId, {
2488
+ subscribed: false,
2489
+ hidden: true,
2490
+ updatedAt: Date.now()
2491
+ });
2492
+ return { sourceId, deleted: true, deletedNotes };
2493
+ }
2243
2494
  function object(value) {
2244
2495
  return typeof value === "object" && value !== null && !Array.isArray(value);
2245
2496
  }
@@ -2843,7 +3094,7 @@ async function ingestPortableFilesIntoStorage(storage, files, options = {}) {
2843
3094
  }
2844
3095
 
2845
3096
  // src/version.ts
2846
- var VERSION = "0.59.2236";
3097
+ var VERSION = "0.59.2240";
2847
3098
 
2848
3099
  // src/feed/qr.ts
2849
3100
  var APP_ORIGIN = "https://wod.wiki";
@@ -3778,10 +4029,26 @@ async function collectPublicStorageState(storage, options = {}) {
3778
4029
  storedCheckpoint
3779
4030
  };
3780
4031
  }
4032
+ async function recordPublishedFeedCheckpoint(storage, report) {
4033
+ const chunkShas = {};
4034
+ for (const c of report.manifest.chunks) chunkShas[c.id] = c.sha256;
4035
+ const cp = {
4036
+ key: PUBLISHED_FEED_META_KEY,
4037
+ version: report.manifest.version,
4038
+ builtAt: report.manifest.builtAt,
4039
+ manifestSha256: report.manifestSha256,
4040
+ chunkShas
4041
+ };
4042
+ await storage.transaction(["meta"], "readwrite", async (tx) => {
4043
+ await tx.readwrite("meta").put(cp);
4044
+ });
4045
+ }
3781
4046
  async function publishFeedFromStorage(storage, tree, options = {}) {
4047
+ options.signal?.throwIfAborted();
3782
4048
  const t0 = Date.now();
3783
4049
  const layout = options.layout ?? "feed";
3784
4050
  const state = await collectPublicStorageState(storage, options);
4051
+ options.signal?.throwIfAborted();
3785
4052
  if (state.notebooks.size === 0) {
3786
4053
  throw new Error("No public notebooks found to publish. Mark at least one user-owned notebook as Public first.");
3787
4054
  }
@@ -4069,28 +4336,19 @@ ${group.description ?? ""}
4069
4336
  const manifestBytes = encodeUtf8(JSON.stringify(manifest, null, 2) + "\n");
4070
4337
  const manifestSha256 = await sha256HexAsync(manifestBytes);
4071
4338
  await tree.write(`${artifactPrefix}manifest.json`, manifestBytes);
4072
- const shouldCheckpoint = options.recordCheckpoint ?? (layout === "feed" && !options.notebookSlug);
4073
- if (shouldCheckpoint) {
4074
- const chunkShas = {};
4075
- for (const c of manifestChunks) chunkShas[c.id] = c.sha256;
4076
- const cp = {
4077
- key: PUBLISHED_FEED_META_KEY,
4078
- version: nextVersion,
4079
- builtAt,
4080
- manifestSha256,
4081
- chunkShas
4082
- };
4083
- await storage.transaction(["meta"], "readwrite", async (tx) => {
4084
- await tx.readwrite("meta").put(cp);
4085
- });
4086
- }
4087
- return {
4339
+ const report = {
4088
4340
  manifest,
4089
4341
  notebooks: sortedSlugs,
4090
4342
  totalNotes,
4091
4343
  totalPublicSessions,
4092
4344
  manifestSha256
4093
4345
  };
4346
+ const shouldCheckpoint = options.recordCheckpoint ?? (layout === "feed" && !options.notebookSlug);
4347
+ if (shouldCheckpoint) {
4348
+ options.signal?.throwIfAborted();
4349
+ await recordPublishedFeedCheckpoint(storage, report);
4350
+ }
4351
+ return report;
4094
4352
  }
4095
4353
  async function checkUnpublishedFeedChanges(storage, currentTree, options = {}) {
4096
4354
  const state = await collectPublicStorageState(storage, options);
@@ -4178,13 +4436,17 @@ async function checkUnpublishedFeedChanges(storage, currentTree, options = {}) {
4178
4436
  }
4179
4437
 
4180
4438
  // src/agent/tools/feedTools.ts
4181
- var feedManageInputSchema = zod.z.object({
4182
- action: zod.z.enum(["list", "status", "publish", "import-bundle"]).describe("Feed or portability operation to run."),
4439
+ var feedManageInputSchema = zod.z.strictObject({
4440
+ action: zod.z.enum(["list", "status", "publish", "import-bundle", "subscribe", "unsubscribe", "delete"]).describe("Feed or portability operation to run."),
4441
+ sourceId: zod.z.string().min(1).optional().describe('Target Feed source ID when action is "subscribe", "unsubscribe", or "delete".'),
4442
+ notebookIds: zod.z.array(zod.z.string().min(1)).optional().describe('Optional subset of Notebook IDs when action="subscribe".'),
4443
+ url: zod.z.string().min(1).optional().describe("Optional Feed manifest URL when subscribing to a custom source."),
4444
+ confirmId: zod.z.string().optional().describe("Confirmation token (must match sourceId) for non-interactive unsubscribe/delete calls."),
4183
4445
  notebookSlug: zod.z.string().optional().describe("Optional Notebook slug filter when publishing."),
4184
- name: zod.z.string().optional().describe("Optional Feed display name when publishing."),
4446
+ name: zod.z.string().optional().describe("Optional Feed display name when publishing or subscribing."),
4185
4447
  description: zod.z.string().optional().describe("Optional Feed description when publishing."),
4186
4448
  files: zod.z.array(
4187
- zod.z.object({
4449
+ zod.z.strictObject({
4188
4450
  path: zod.z.string().min(1),
4189
4451
  content: zod.z.string()
4190
4452
  })
@@ -4193,7 +4455,7 @@ var feedManageInputSchema = zod.z.object({
4193
4455
  var wodFeedManageTool = defineAgentTool({
4194
4456
  name: "wod_feed_manage",
4195
4457
  title: "Manage Feeds & Portability",
4196
- description: "Inspect installed Seed/Feed sources (`list`), check unpublished public Notebook changes (`status`), compile and publish public Notebooks (`publish`), or import portable Markdown + JSONL/CSV files (`import-bundle`).",
4458
+ 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.",
4197
4459
  tier: 1,
4198
4460
  domain: "feed",
4199
4461
  annotations: {
@@ -4204,27 +4466,120 @@ var wodFeedManageTool = defineAgentTool({
4204
4466
  openWorldHint: false
4205
4467
  },
4206
4468
  inputSchema: feedManageInputSchema,
4207
- cliEquivalent: "wod feed <list|status|publish> --json",
4469
+ cliEquivalent: "wod feed <list|status|publish|subscribe|unsubscribe|delete> --json",
4208
4470
  async execute(args, ctx) {
4209
4471
  if (args.action === "list") {
4210
4472
  const metaRows = await ctx.storage.readonly("meta").getAll();
4473
+ const subscriptions = await listFeedSubscriptionsHeadless(ctx.storage);
4211
4474
  const installedFeeds = [];
4212
4475
  for (const row of metaRows) {
4213
4476
  const obj = row;
4214
4477
  if (typeof obj.key === "string" && obj.key.startsWith("seed:") && obj.key !== seedMetaKey("user")) {
4478
+ const sourceId = obj.key.slice("seed:".length);
4215
4479
  installedFeeds.push({
4216
- sourceId: obj.key.slice("seed:".length),
4480
+ sourceId,
4217
4481
  seedVersion: obj.seedVersion,
4218
4482
  builtAt: obj.builtAt,
4219
4483
  importedAt: obj.importedAt,
4220
- chunkCount: Object.keys(obj.chunks ?? {}).length
4484
+ chunkCount: Object.keys(obj.chunks ?? {}).length,
4485
+ subscribed: subscriptions[sourceId]?.subscribed ?? true
4221
4486
  });
4222
4487
  }
4223
4488
  }
4224
4489
  return {
4225
4490
  action: "list",
4226
4491
  installedCount: installedFeeds.length,
4227
- feeds: installedFeeds
4492
+ feeds: installedFeeds,
4493
+ subscriptions
4494
+ };
4495
+ }
4496
+ if (args.action === "subscribe") {
4497
+ if (!args.sourceId) {
4498
+ throw new Error('Provide `sourceId` when action="subscribe".');
4499
+ }
4500
+ const res = ctx.feedLifecycle?.subscribe ? await ctx.feedLifecycle.subscribe(args.sourceId, {
4501
+ notebookIds: args.notebookIds,
4502
+ url: args.url,
4503
+ name: args.name
4504
+ }) : await subscribeFeedSourceHeadless(ctx.storage, args.sourceId, {
4505
+ notebookIds: args.notebookIds,
4506
+ url: args.url,
4507
+ name: args.name
4508
+ });
4509
+ await ctx.onMutated?.(["meta", "notes"]);
4510
+ return {
4511
+ action: "subscribe",
4512
+ ...res
4513
+ };
4514
+ }
4515
+ if (args.action === "unsubscribe") {
4516
+ if (!args.sourceId) {
4517
+ throw new Error('Provide `sourceId` when action="unsubscribe".');
4518
+ }
4519
+ if (args.sourceId === "core") {
4520
+ throw new Error("Core feed cannot be unsubscribed.");
4521
+ }
4522
+ await requireDestructiveConfirmation(
4523
+ ctx,
4524
+ {
4525
+ action: "wod_feed_manage:unsubscribe",
4526
+ targetId: args.sourceId,
4527
+ summary: `Unsubscribe from feed '${args.sourceId}' and purge its imported notes`
4528
+ },
4529
+ args.confirmId
4530
+ );
4531
+ const res = ctx.feedLifecycle?.unsubscribe ? await ctx.feedLifecycle.unsubscribe(args.sourceId) : await unsubscribeFeedSourceHeadless(ctx.storage, args.sourceId);
4532
+ await ctx.onMutated?.([
4533
+ "meta",
4534
+ "notes",
4535
+ "tags",
4536
+ "note_tags",
4537
+ "block_index",
4538
+ "block_efforts",
4539
+ "block_equipment",
4540
+ "page_notes",
4541
+ "efforts",
4542
+ "equipment",
4543
+ "property_overrides"
4544
+ ]);
4545
+ return {
4546
+ action: "unsubscribe",
4547
+ ...res
4548
+ };
4549
+ }
4550
+ if (args.action === "delete") {
4551
+ if (!args.sourceId) {
4552
+ throw new Error('Provide `sourceId` when action="delete".');
4553
+ }
4554
+ if (args.sourceId === "core") {
4555
+ throw new Error("Core feed cannot be deleted.");
4556
+ }
4557
+ await requireDestructiveConfirmation(
4558
+ ctx,
4559
+ {
4560
+ action: "wod_feed_manage:delete",
4561
+ targetId: args.sourceId,
4562
+ summary: `Delete feed source '${args.sourceId}' and purge all of its imported notes`
4563
+ },
4564
+ args.confirmId
4565
+ );
4566
+ const res = ctx.feedLifecycle?.delete ? await ctx.feedLifecycle.delete(args.sourceId) : await deleteFeedSourceHeadless(ctx.storage, args.sourceId);
4567
+ await ctx.onMutated?.([
4568
+ "meta",
4569
+ "notes",
4570
+ "tags",
4571
+ "note_tags",
4572
+ "block_index",
4573
+ "block_efforts",
4574
+ "block_equipment",
4575
+ "page_notes",
4576
+ "efforts",
4577
+ "equipment",
4578
+ "property_overrides"
4579
+ ]);
4580
+ return {
4581
+ action: "delete",
4582
+ ...res
4228
4583
  };
4229
4584
  }
4230
4585
  if (args.action === "status") {
@@ -4273,7 +4628,7 @@ var wodFeedManageTool = defineAgentTool({
4273
4628
  };
4274
4629
  }
4275
4630
  });
4276
- var exportBundleInputSchema = zod.z.object({
4631
+ var exportBundleInputSchema = zod.z.strictObject({
4277
4632
  noteIds: zod.z.array(zod.z.string()).optional().describe("Optional Note IDs to export (defaults to all user-owned Notes)."),
4278
4633
  telemetryFormat: zod.z.enum(["jsonl", "csv", "both"]).optional().describe('Format for companion Session/Event telemetry files (default "jsonl").')
4279
4634
  });
@@ -4303,7 +4658,7 @@ var wodExportBundleTool = defineAgentTool({
4303
4658
  };
4304
4659
  }
4305
4660
  });
4306
- var resetStorageInputSchema = zod.z.object({
4661
+ var resetStorageInputSchema = zod.z.strictObject({
4307
4662
  confirmToken: zod.z.string().optional().describe('For non-interactive MCP/CLI calls, pass confirmToken="WIPE_STORAGE" to confirm wiping user storage.')
4308
4663
  });
4309
4664
  var wodResetStorageTool = defineAgentTool({
@@ -4341,7 +4696,7 @@ var FEED_AGENT_TOOLS = [
4341
4696
  wodExportBundleTool,
4342
4697
  wodResetStorageTool
4343
4698
  ];
4344
- var journalDayInputSchema = zod.z.object({
4699
+ var journalDayInputSchema = zod.z.strictObject({
4345
4700
  date: zod.z.string().optional().describe('Calendar date in YYYY-MM-DD format, or "today" (defaults to "today").')
4346
4701
  });
4347
4702
  var wodJournalDayTool = defineAgentTool({
@@ -4436,7 +4791,7 @@ var wodJournalDayTool = defineAgentTool({
4436
4791
  };
4437
4792
  }
4438
4793
  });
4439
- var journalAddInputSchema = zod.z.object({
4794
+ var journalAddInputSchema = zod.z.strictObject({
4440
4795
  date: zod.z.string().optional().describe('Target Journal date in YYYY-MM-DD format or "today" (defaults to "today").'),
4441
4796
  title: zod.z.string().optional().describe("Workout title (defaults to # H1 heading or date)."),
4442
4797
  content: zod.z.string().min(1).describe("Markdown workout note or bare Whiteboard Script to schedule onto the Journal day."),
@@ -4500,7 +4855,7 @@ function isLandingNote(note) {
4500
4855
  return note.id.startsWith("notebook/") && note.notebookId === note.id;
4501
4856
  }
4502
4857
  var RESERVED_SLUGS = new Set(wodWikiCore.BUILTIN_NOTEBOOKS.map((b) => b.slug));
4503
- var notebookListInputSchema = zod.z.object({
4858
+ var notebookListInputSchema = zod.z.strictObject({
4504
4859
  origin: zod.z.enum(["all", "default", "user", "feed"]).optional().describe('Filter notebooks by origin (default "all").')
4505
4860
  });
4506
4861
  var wodNotebookListTool = defineAgentTool({
@@ -4587,7 +4942,7 @@ var wodNotebookListTool = defineAgentTool({
4587
4942
  };
4588
4943
  }
4589
4944
  });
4590
- var notebookSaveInputSchema = zod.z.object({
4945
+ var notebookSaveInputSchema = zod.z.strictObject({
4591
4946
  action: zod.z.enum(["create", "update", "promote", "detach", "set-public"]).describe("Operation to perform on a user Notebook."),
4592
4947
  notebookId: zod.z.string().optional().describe("Target Notebook slug or ID (required for update, promote, detach, set-public)."),
4593
4948
  name: zod.z.string().optional().describe("Display name when creating or renaming a Notebook."),
@@ -4716,7 +5071,7 @@ icon: ${JSON.stringify(nextIcon)}
4716
5071
  };
4717
5072
  }
4718
5073
  });
4719
- var notebookDeleteInputSchema = zod.z.object({
5074
+ var notebookDeleteInputSchema = zod.z.strictObject({
4720
5075
  notebookId: zod.z.string().min(1).describe("User Notebook ID or slug to delete (member Notes stay safe in notebook/journal)."),
4721
5076
  confirmId: zod.z.string().optional().describe("For non-interactive MCP/CLI calls, repeat the exact notebookId or slug to confirm deletion.")
4722
5077
  });
@@ -5087,7 +5442,7 @@ function buildNoteProvenance(sourceNote, sourceNotebookId, clonedAt) {
5087
5442
  function isLandingNote2(note) {
5088
5443
  return note.id.startsWith("notebook/") && note.notebookId === note.id;
5089
5444
  }
5090
- var noteListInputSchema = zod.z.object({
5445
+ var noteListInputSchema = zod.z.strictObject({
5091
5446
  notebookId: zod.z.string().optional().describe('Filter by notebook ID or slug (e.g. "journal", "custom", "guides", "notebook/strength").'),
5092
5447
  search: zod.z.string().optional().describe("Case-insensitive substring filter over title and Markdown content."),
5093
5448
  tag: zod.z.string().optional().describe("Filter to Notes carrying this tag label."),
@@ -5110,23 +5465,30 @@ var wodNoteListTool = defineAgentTool({
5110
5465
  inputSchema: noteListInputSchema,
5111
5466
  cliEquivalent: "wod note list --json",
5112
5467
  async execute(args, ctx) {
5113
- const allNotes = await ctx.storage.readonly("notes").getAll();
5114
5468
  const targetNb = args.notebookId ? wodWikiCore.toNotebookId(args.notebookId) : void 0;
5115
5469
  const includeSeed = args.includeSeed ?? Boolean(targetNb);
5116
5470
  const searchLower = args.search?.trim().toLowerCase();
5117
5471
  const tagLower = args.tag?.trim().toLowerCase();
5118
5472
  const limit = args.limit ?? 50;
5119
- let linkedNoteIdsForNb;
5120
- if (targetNb) {
5121
- try {
5122
- const links = await ctx.storage.readonly("notebook_links").getAllFromIndex("by-notebook", targetNb);
5123
- linkedNoteIdsForNb = new Set(
5124
- links.filter((l) => l.targetKind === "note").map((l) => l.noteId)
5125
- );
5126
- } catch {
5127
- linkedNoteIdsForNb = /* @__PURE__ */ new Set();
5473
+ const { allNotes, linkedNoteIdsForNb } = await ctx.storage.transaction(
5474
+ ["notes", "notebook_links"],
5475
+ "readonly",
5476
+ async (tx) => {
5477
+ const notes = await tx.readonly("notes").getAll();
5478
+ let linkedIds;
5479
+ if (targetNb) {
5480
+ try {
5481
+ const links = await tx.readonly("notebook_links").getAllFromIndex("by-notebook", targetNb);
5482
+ linkedIds = new Set(
5483
+ links.filter((l) => l.targetKind === "note").map((l) => l.noteId)
5484
+ );
5485
+ } catch {
5486
+ linkedIds = /* @__PURE__ */ new Set();
5487
+ }
5488
+ }
5489
+ return { allNotes: notes, linkedNoteIdsForNb: linkedIds };
5128
5490
  }
5129
- }
5491
+ );
5130
5492
  const filtered = allNotes.filter((n) => {
5131
5493
  if (isLandingNote2(n)) return false;
5132
5494
  if (!includeSeed && (n.seedOrigin === "seed" || n.feedOrigin === "feed")) return false;
@@ -5163,7 +5525,7 @@ var wodNoteListTool = defineAgentTool({
5163
5525
  };
5164
5526
  }
5165
5527
  });
5166
- var noteGetInputSchema = zod.z.object({
5528
+ var noteGetInputSchema = zod.z.strictObject({
5167
5529
  noteId: zod.z.string().min(1).describe("Unique Note ID (UUID or seed route ID).")
5168
5530
  });
5169
5531
  var wodNoteGetTool = defineAgentTool({
@@ -5239,7 +5601,7 @@ var wodNoteGetTool = defineAgentTool({
5239
5601
  };
5240
5602
  }
5241
5603
  });
5242
- var noteUpsertInputSchema = zod.z.object({
5604
+ var noteUpsertInputSchema = zod.z.strictObject({
5243
5605
  noteId: zod.z.string().optional().describe("Existing Note ID to update, or omit to create a new Note."),
5244
5606
  title: zod.z.string().optional().describe("Note title (defaults to # H1 heading in content)."),
5245
5607
  content: zod.z.string().min(1).describe("Full Markdown document or Whiteboard Script body."),
@@ -5299,7 +5661,7 @@ var wodNoteUpsertTool = defineAgentTool({
5299
5661
  };
5300
5662
  }
5301
5663
  });
5302
- var noteCloneInputSchema = zod.z.object({
5664
+ var noteCloneInputSchema = zod.z.strictObject({
5303
5665
  sourceNoteId: zod.z.string().min(1).describe("Source Note ID (including read-only Seed/Feed Notes) to clone."),
5304
5666
  targetNotebookId: zod.z.string().optional().describe('Target writable user Notebook ID/slug (defaults to "notebook/journal").'),
5305
5667
  title: zod.z.string().optional().describe("Optional title override for the cloned Note."),
@@ -5366,7 +5728,7 @@ var wodNoteCloneTool = defineAgentTool({
5366
5728
  };
5367
5729
  }
5368
5730
  });
5369
- var noteDeleteInputSchema = zod.z.object({
5731
+ var noteDeleteInputSchema = zod.z.strictObject({
5370
5732
  noteId: zod.z.string().min(1).describe("ID of the Note to delete."),
5371
5733
  confirmId: zod.z.string().optional().describe("For non-interactive MCP/CLI calls, repeat the exact noteId to confirm deletion.")
5372
5734
  });
@@ -5483,7 +5845,7 @@ function collectCollectibles(node, out = []) {
5483
5845
  }
5484
5846
  return out;
5485
5847
  }
5486
- var parseScriptInputSchema = zod.z.object({
5848
+ var parseScriptInputSchema = zod.z.strictObject({
5487
5849
  source: zod.z.string().min(1).describe("Whiteboard Script body OR full Markdown document containing ```time / ```wod blocks."),
5488
5850
  sport: zod.z.string().optional().describe('Optional sport fence dialect override (e.g. "crossfit", "climbing", "running").'),
5489
5851
  save: zod.z.boolean().optional().describe("Default false (dry-run syntax & metric inspection). Set true to persist as a Note."),
@@ -5597,7 +5959,7 @@ function applyCollectibleOverrides(body, overrides) {
5597
5959
  }
5598
5960
  return updated;
5599
5961
  }
5600
- var sessionRunHeadlessInputSchema = zod.z.object({
5962
+ var sessionRunHeadlessInputSchema = zod.z.strictObject({
5601
5963
  noteId: zod.z.string().optional().describe("Existing Note ID to execute (read-only Seed/Feed Notes are automatically cloned to notebook/journal)."),
5602
5964
  blockId: zod.z.string().optional().describe("Optional workout block ID on `noteId` (defaults to first wod block)."),
5603
5965
  source: zod.z.string().optional().describe("Inline Whiteboard Script or Markdown to persist & run when `noteId` is not supplied."),
@@ -5751,7 +6113,7 @@ var wodSessionRunHeadlessTool = defineAgentTool({
5751
6113
  };
5752
6114
  }
5753
6115
  });
5754
- var sessionListInputSchema = zod.z.object({
6116
+ var sessionListInputSchema = zod.z.strictObject({
5755
6117
  noteId: zod.z.string().optional().describe("Filter Sessions by owning Note ID."),
5756
6118
  completedOnly: zod.z.boolean().optional().describe("Filter to completed Sessions only."),
5757
6119
  limit: zod.z.number().int().min(1).max(200).optional().describe("Max Sessions to return (default 50).")
@@ -5813,7 +6175,7 @@ var wodSessionListTool = defineAgentTool({
5813
6175
  };
5814
6176
  }
5815
6177
  });
5816
- var sessionGetInputSchema = zod.z.object({
6178
+ var sessionGetInputSchema = zod.z.strictObject({
5817
6179
  sessionId: zod.z.string().min(1).describe("Session ID to inspect.")
5818
6180
  });
5819
6181
  var wodSessionGetTool = defineAgentTool({
@@ -5852,7 +6214,7 @@ var wodSessionGetTool = defineAgentTool({
5852
6214
  };
5853
6215
  }
5854
6216
  });
5855
- var sessionDeleteInputSchema = zod.z.object({
6217
+ var sessionDeleteInputSchema = zod.z.strictObject({
5856
6218
  sessionId: zod.z.string().min(1).describe("Session ID to delete."),
5857
6219
  confirmId: zod.z.string().optional().describe("For non-interactive MCP/CLI calls, repeat the exact sessionId to confirm deletion.")
5858
6220
  });
@@ -5898,7 +6260,7 @@ var SESSION_AGENT_TOOLS = [
5898
6260
  wodSessionGetTool,
5899
6261
  wodSessionDeleteTool
5900
6262
  ];
5901
- var validateWqlInputSchema = zod.z.object({
6263
+ var validateWqlInputSchema = zod.z.strictObject({
5902
6264
  query: zod.z.string().describe('WQL query string to validate and inspect (e.g. ":note{notebook:journal} last 7d" or "sum:volume by {effort}").'),
5903
6265
  targetHint: zod.z.string().optional().describe("Optional target plane to list valid filter keys & grouping dimensions for (note, session, effort, equipment, tag, feed, block, event).")
5904
6266
  });
@@ -5937,7 +6299,7 @@ var wodValidateWqlTool = defineAgentTool({
5937
6299
  };
5938
6300
  }
5939
6301
  });
5940
- var queryWqlInputSchema = zod.z.object({
6302
+ var queryWqlInputSchema = zod.z.strictObject({
5941
6303
  query: zod.z.string().min(1).describe('WQL query expression (e.g. ":note{notebook:journal}", ":session last 30d", "sum:volume by {week}").'),
5942
6304
  preferredUnit: zod.z.string().optional().describe('Optional display unit conversion preference (e.g. "lb", "kg", "m", "mi").'),
5943
6305
  limit: zod.z.number().int().min(1).max(500).optional().describe("Maximum rows/items to return in the response payload (default 100).")
@@ -6323,6 +6685,7 @@ function zodSchemaToJsonSchema(schema) {
6323
6685
  return zod.z.toJSONSchema(schema, { target: "draft-2020-12" });
6324
6686
  }
6325
6687
  function exportAgentCapabilitiesManifest(options) {
6688
+ const isStatic = options?.deploymentTarget === "static";
6326
6689
  return {
6327
6690
  schemaVersion: "1.0.0",
6328
6691
  name: "WOD Wiki Agent Surface",
@@ -6333,7 +6696,12 @@ function exportAgentCapabilitiesManifest(options) {
6333
6696
  globalNamespace: "navigator.modelContext",
6334
6697
  library: "@mcp-b/react-webmcp"
6335
6698
  },
6336
- mcp: {
6699
+ mcp: isStatic ? {
6700
+ httpEndpoint: null,
6701
+ stdioCommand: "wod mcp",
6702
+ sdk: "@modelcontextprotocol/sdk",
6703
+ deploymentNote: "HTTP /api/mcp is only mounted on self-hosted `wod server` deployments, not on static hosting."
6704
+ } : {
6337
6705
  httpEndpoint: "/api/mcp",
6338
6706
  stdioCommand: "wod mcp",
6339
6707
  sdk: "@modelcontextprotocol/sdk"