@mulmoclaude/core 1.11.0 → 1.13.0

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.
Files changed (70) hide show
  1. package/assets/helps/error-recovery.md +98 -0
  2. package/dist/collection/core/project.d.ts +11 -0
  3. package/dist/collection/index.cjs +3 -2
  4. package/dist/collection/index.js +3 -3
  5. package/dist/collection/registry/server/index.cjs +3 -3
  6. package/dist/collection/registry/server/index.js +3 -3
  7. package/dist/collection/server/index.cjs +2 -2
  8. package/dist/collection/server/index.js +2 -2
  9. package/dist/collection-watchers/index.cjs +3 -3
  10. package/dist/collection-watchers/index.js +3 -3
  11. package/dist/{discovery-B4CZvrXR.js → discovery-D-ZJ6a6z.js} +39 -18
  12. package/dist/discovery-D-ZJ6a6z.js.map +1 -0
  13. package/dist/{discovery-NRy3tyUA.cjs → discovery-DAoMnBYM.cjs} +39 -18
  14. package/dist/discovery-DAoMnBYM.cjs.map +1 -0
  15. package/dist/{dist-pWpC-b04.cjs → dist-21pMsI1a.cjs} +45 -1
  16. package/dist/{dist-pWpC-b04.cjs.map → dist-21pMsI1a.cjs.map} +1 -1
  17. package/dist/{dist-Cwk0e12G.js → dist-DP1FTGnO.js} +16 -2
  18. package/dist/{dist-Cwk0e12G.js.map → dist-DP1FTGnO.js.map} +1 -1
  19. package/dist/feeds/server/engine.d.ts +27 -0
  20. package/dist/feeds/server/index.cjs +72 -7
  21. package/dist/feeds/server/index.cjs.map +1 -1
  22. package/dist/feeds/server/index.d.ts +1 -1
  23. package/dist/feeds/server/index.js +71 -8
  24. package/dist/feeds/server/index.js.map +1 -1
  25. package/dist/google/calendarStateLock.d.ts +23 -0
  26. package/dist/google/calendarSyncDue.d.ts +10 -0
  27. package/dist/google/calendarSyncStore.d.ts +20 -1
  28. package/dist/google/collectionProjection.d.ts +0 -8
  29. package/dist/google/collectionSync.d.ts +104 -15
  30. package/dist/google/index.cjs +512 -89
  31. package/dist/google/index.cjs.map +1 -1
  32. package/dist/google/index.d.ts +6 -3
  33. package/dist/google/index.js +501 -91
  34. package/dist/google/index.js.map +1 -1
  35. package/dist/notifier/index.cjs +1 -1
  36. package/dist/notifier/index.js +1 -1
  37. package/dist/notifier/store.d.ts +4 -4
  38. package/dist/{notifier-tMsAXyXp.cjs → notifier-C3IhYxqh.cjs} +39 -25
  39. package/dist/notifier-C3IhYxqh.cjs.map +1 -0
  40. package/dist/{notifier-BdA5qzhe.js → notifier-CMFlw74b.js} +39 -25
  41. package/dist/notifier-CMFlw74b.js.map +1 -0
  42. package/dist/project-B9NSyr6L.js +28 -0
  43. package/dist/project-B9NSyr6L.js.map +1 -0
  44. package/dist/project-CCtT_fQr.cjs +39 -0
  45. package/dist/project-CCtT_fQr.cjs.map +1 -0
  46. package/dist/remote-host/server/index.cjs +1 -1
  47. package/dist/remote-host/server/index.js +1 -1
  48. package/dist/remote-view/index.cjs +1 -1
  49. package/dist/remote-view/index.js +1 -1
  50. package/dist/scheduler/index.cjs +1 -1
  51. package/dist/scheduler/index.js +1 -1
  52. package/dist/{server-7U-3DE2e.cjs → server-B_b0bLSW.cjs} +3 -3
  53. package/dist/{server-7U-3DE2e.cjs.map → server-B_b0bLSW.cjs.map} +1 -1
  54. package/dist/{server-DdyIvFhz.js → server-Ci_A3chZ.js} +3 -3
  55. package/dist/{server-DdyIvFhz.js.map → server-Ci_A3chZ.js.map} +1 -1
  56. package/dist/utils/index.cjs +1 -1
  57. package/dist/utils/index.js +1 -1
  58. package/dist/whisper/index.cjs +1 -1
  59. package/dist/whisper/index.js +1 -1
  60. package/dist/wiki/index.cjs +1 -1
  61. package/dist/wiki/index.js +1 -1
  62. package/package.json +1 -1
  63. package/dist/discovery-B4CZvrXR.js.map +0 -1
  64. package/dist/discovery-NRy3tyUA.cjs.map +0 -1
  65. package/dist/notifier-BdA5qzhe.js.map +0 -1
  66. package/dist/notifier-tMsAXyXp.cjs.map +0 -1
  67. package/dist/project-BWI5w_BT.cjs +0 -17
  68. package/dist/project-BWI5w_BT.cjs.map +0 -1
  69. package/dist/project-bU98ycsy.js +0 -12
  70. package/dist/project-bU98ycsy.js.map +0 -1
@@ -1,7 +1,8 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-D6vf50IK.cjs");
2
+ const require_dist = require("./dist-21pMsI1a.cjs");
2
3
  const require_atomic = require("./atomic-C_7YpMiM.cjs");
3
4
  const require_calendarGrid = require("./calendarGrid-CaS9er8i.cjs");
4
- const require_project = require("./project-BWI5w_BT.cjs");
5
+ const require_project = require("./project-CCtT_fQr.cjs");
5
6
  const require_templatePath = require("./templatePath-27vUZowm.cjs");
6
7
  let node_fs = require("node:fs");
7
8
  let node_path = require("node:path");
@@ -1057,14 +1058,23 @@ function pageFromFullRead(items, opts, primaryKey, truncated) {
1057
1058
  }
1058
1059
  //#endregion
1059
1060
  //#region src/collection/server/sqliteStore.ts
1061
+ /** A constructor's parameter and return types are not observable at runtime,
1062
+ * so the check stops at "DatabaseSync is constructible" — the only member of
1063
+ * the module this store ever touches. */
1064
+ function isSqliteModule(mod) {
1065
+ return require_dist.isRecord(mod) && typeof mod.DatabaseSync === "function";
1066
+ }
1060
1067
  var sqliteModule = null;
1068
+ /** Drops the memo first so a later call can retry (e.g. tests stubbing the
1069
+ * runtime), then reports why the backend is unusable. */
1070
+ function sqliteUnavailable(reason) {
1071
+ sqliteModule = null;
1072
+ throw new BackendUnavailableError(`sqlite storage needs the node:sqlite module (Node.js >= 22.5) — this runtime cannot load it: ${reason}`);
1073
+ }
1061
1074
  /** Lazy-load node:sqlite once. A runtime without it (Node < 22.5) throws a
1062
1075
  * clearly-worded error the caller surfaces — never a bare MODULE_NOT_FOUND. */
1063
1076
  function loadSqlite() {
1064
- sqliteModule ??= import("node:sqlite").then((mod) => mod, (err) => {
1065
- sqliteModule = null;
1066
- throw new BackendUnavailableError(`sqlite storage needs the node:sqlite module (Node.js >= 22.5) — this runtime cannot load it: ${String(err)}`);
1067
- });
1077
+ sqliteModule ??= import("node:sqlite").then((mod) => isSqliteModule(mod) ? mod : sqliteUnavailable("the module exposes no DatabaseSync constructor"), (err) => sqliteUnavailable(String(err)));
1068
1078
  return sqliteModule;
1069
1079
  }
1070
1080
  /** The db file's on-disk state. A symlink or non-regular file is refused
@@ -1076,7 +1086,7 @@ async function dbFileState(absPath) {
1076
1086
  try {
1077
1087
  return (await (0, node_fs_promises.lstat)(absPath)).isFile() ? "file" : "refused";
1078
1088
  } catch (err) {
1079
- if (err.code === "ENOENT") return "missing";
1089
+ if (require_dist.isErrorWithCode(err) && err.code === "ENOENT") return "missing";
1080
1090
  throw err;
1081
1091
  }
1082
1092
  }
@@ -1128,27 +1138,39 @@ async function withDb(absPath, workspaceRoot, mode, onUnavailable, operation) {
1128
1138
  handle.database.close();
1129
1139
  }
1130
1140
  }
1141
+ var SQLITE_CONSTRAINT_PRIMARYKEY = 1555;
1142
+ var SQLITE_CONSTRAINT_UNIQUE = 2067;
1131
1143
  /** node:sqlite throws ERR_SQLITE_ERROR with the SQLite extended result
1132
- * code on `errcode`. Our INSERT's duplicate-id failure is
1133
- * SQLITE_CONSTRAINT_PRIMARYKEY (1555); SQLITE_CONSTRAINT_UNIQUE (2067)
1134
- * covers a plain UNIQUE index. Checked structurally (message text kept
1135
- * only as a fallback for runtimes that don't expose `errcode`). */
1144
+ * code on `errcode`. Checked structurally (message text kept only as a
1145
+ * fallback for runtimes that don't expose `errcode`). */
1136
1146
  function isUniqueConstraintError(err) {
1137
- const { errcode } = err;
1138
- if (errcode !== void 0) return errcode === 1555 || errcode === 2067;
1147
+ if (require_dist.hasNumberProp(err, "errcode")) return err.errcode === SQLITE_CONSTRAINT_PRIMARYKEY || err.errcode === SQLITE_CONSTRAINT_UNIQUE;
1139
1148
  return String(err).includes("UNIQUE constraint");
1140
1149
  }
1141
1150
  function parseRow(raw) {
1142
1151
  if (typeof raw !== "string") return null;
1143
1152
  try {
1144
1153
  const parsed = JSON.parse(raw);
1145
- return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
1154
+ return require_dist.isRecord(parsed) ? parsed : null;
1146
1155
  } catch {
1147
1156
  return null;
1148
1157
  }
1149
1158
  }
1159
+ /** One column of a result row. node:sqlite types rows as `unknown`, so a
1160
+ * value that is not a row object yields no column at all. */
1161
+ function readColumn(row, column) {
1162
+ return require_dist.isRecord(row) ? row[column] : void 0;
1163
+ }
1150
1164
  function rowsToItems(rows) {
1151
- return rows.map((row) => parseRow(row.record)).filter((item) => item !== null);
1165
+ return rows.map((row) => parseRow(readColumn(row, "record"))).filter((item) => item !== null);
1166
+ }
1167
+ /** node:sqlite hands back an integer column as `number`, or as `bigint` once
1168
+ * it leaves the safe-integer range — COUNT(*) can be either. */
1169
+ function countRecords(database) {
1170
+ const count = readColumn(database.prepare("SELECT COUNT(*) AS n FROM records").get(), "n");
1171
+ if (typeof count === "number") return count;
1172
+ if (typeof count === "bigint") return Number(count);
1173
+ throw new Error(`sqlite COUNT(*) returned no numeric row count (got ${typeof count})`);
1152
1174
  }
1153
1175
  async function sqliteList(absPath, workspaceRoot) {
1154
1176
  return withDb(absPath, workspaceRoot, "read", () => [], (database) => rowsToItems(database.prepare("SELECT record FROM records ORDER BY id").all()));
@@ -1160,7 +1182,7 @@ async function sqlitePage(absPath, primaryKey, opts, workspaceRoot) {
1160
1182
  truncated: false
1161
1183
  };
1162
1184
  return withDb(absPath, workspaceRoot, "read", () => emptyPage, (database) => {
1163
- const total = Number(database.prepare("SELECT COUNT(*) AS n FROM records").get().n);
1185
+ const total = countRecords(database);
1164
1186
  const offset = Math.max(0, opts.offset ?? 0);
1165
1187
  const limit = opts.limit === void 0 ? -1 : Math.max(0, opts.limit);
1166
1188
  return {
@@ -1174,8 +1196,7 @@ async function sqliteRead(absPath, itemId, workspaceRoot) {
1174
1196
  const safeId = safeRecordId(itemId);
1175
1197
  if (safeId === null) return null;
1176
1198
  return withDb(absPath, workspaceRoot, "read", () => null, (database) => {
1177
- const row = database.prepare("SELECT record FROM records WHERE id = ?").get(safeId);
1178
- return row === void 0 ? null : parseRow(row.record);
1199
+ return parseRow(readColumn(database.prepare("SELECT record FROM records WHERE id = ?").get(safeId), "record"));
1179
1200
  });
1180
1201
  }
1181
1202
  async function sqliteWrite(absPath, itemId, item, opts) {
@@ -3006,4 +3027,4 @@ Object.defineProperty(exports, "writeItem", {
3006
3027
  }
3007
3028
  });
3008
3029
 
3009
- //# sourceMappingURL=discovery-NRy3tyUA.cjs.map
3030
+ //# sourceMappingURL=discovery-DAoMnBYM.cjs.map