@karmaniverous/jeeves-meta 0.15.4 → 0.15.6

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 (87) hide show
  1. package/dist/archive/index.d.ts +10 -0
  2. package/dist/archive/listArchive.d.ts +12 -0
  3. package/dist/archive/prune.d.ts +14 -0
  4. package/dist/archive/readArchive.d.ts +30 -0
  5. package/dist/archive/readLatest.d.ts +13 -0
  6. package/dist/archive/snapshot.d.ts +17 -0
  7. package/dist/bootstrap.d.ts +15 -0
  8. package/dist/cache.d.ts +22 -0
  9. package/dist/cli/jeeves-meta/index.js +199 -95
  10. package/dist/cli.d.ts +10 -0
  11. package/dist/configHotReload.d.ts +30 -0
  12. package/dist/configLoader.d.ts +37 -0
  13. package/dist/constants.d.ts +13 -0
  14. package/dist/customCliCommands.d.ts +13 -0
  15. package/dist/descriptor.d.ts +19 -0
  16. package/dist/discovery/buildMinimalNode.d.ts +22 -0
  17. package/dist/discovery/computeSummary.d.ts +17 -0
  18. package/dist/discovery/discoverMetas.d.ts +19 -0
  19. package/dist/discovery/index.d.ts +11 -0
  20. package/dist/discovery/listMetas.d.ts +63 -0
  21. package/dist/discovery/ownershipTree.d.ts +25 -0
  22. package/dist/discovery/scope.d.ts +47 -0
  23. package/dist/discovery/types.d.ts +25 -0
  24. package/dist/ema.d.ts +14 -0
  25. package/dist/errors.d.ts +15 -0
  26. package/dist/escapeGlob.d.ts +23 -0
  27. package/dist/executor/GatewayExecutor.d.ts +48 -0
  28. package/dist/executor/SpawnAbortedError.d.ts +9 -0
  29. package/dist/executor/SpawnTimeoutError.d.ts +13 -0
  30. package/dist/executor/index.d.ts +8 -0
  31. package/dist/index.d.ts +34 -1580
  32. package/dist/index.js +182 -109
  33. package/dist/interfaces/MetaContext.d.ts +36 -0
  34. package/dist/interfaces/MetaExecutor.d.ts +46 -0
  35. package/dist/interfaces/WatcherClient.d.ts +75 -0
  36. package/dist/interfaces/index.d.ts +8 -0
  37. package/dist/lock.d.ts +70 -0
  38. package/dist/logger/index.d.ts +27 -0
  39. package/dist/mtimeFilter.d.ts +26 -0
  40. package/dist/normalizePath.d.ts +6 -0
  41. package/dist/orchestrator/buildTask.d.ts +38 -0
  42. package/dist/orchestrator/contextPackage.d.ts +30 -0
  43. package/dist/orchestrator/index.d.ts +10 -0
  44. package/dist/orchestrator/orchestratePhase.d.ts +38 -0
  45. package/dist/orchestrator/parseOutput.d.ts +41 -0
  46. package/dist/orchestrator/runPhase.d.ts +40 -0
  47. package/dist/phaseState/derivePhaseState.d.ts +41 -0
  48. package/dist/phaseState/index.d.ts +9 -0
  49. package/dist/phaseState/invalidate.d.ts +41 -0
  50. package/dist/phaseState/phaseScheduler.d.ts +57 -0
  51. package/dist/phaseState/phaseTransitions.d.ts +83 -0
  52. package/dist/progress/index.d.ts +38 -0
  53. package/dist/prompts/index.d.ts +15 -0
  54. package/dist/queue/index.d.ts +131 -0
  55. package/dist/readMetaJson.d.ts +17 -0
  56. package/dist/routes/__testUtils.d.ts +37 -0
  57. package/dist/routes/config.d.ts +11 -0
  58. package/dist/routes/configApply.d.ts +13 -0
  59. package/dist/routes/index.d.ts +50 -0
  60. package/dist/routes/metas.d.ts +9 -0
  61. package/dist/routes/metasUpdate.d.ts +11 -0
  62. package/dist/routes/preview.d.ts +8 -0
  63. package/dist/routes/queue.d.ts +13 -0
  64. package/dist/routes/seed.d.ts +8 -0
  65. package/dist/routes/status.d.ts +13 -0
  66. package/dist/routes/synthesize.d.ts +12 -0
  67. package/dist/routes/unlock.d.ts +8 -0
  68. package/dist/rules/healthCheck.d.ts +36 -0
  69. package/dist/rules/index.d.ts +39 -0
  70. package/dist/rules/verify.d.ts +22 -0
  71. package/dist/scheduler/index.d.ts +66 -0
  72. package/dist/scheduling/index.d.ts +7 -0
  73. package/dist/scheduling/staleness.d.ts +68 -0
  74. package/dist/scheduling/weightedFormula.d.ts +38 -0
  75. package/dist/schema/config.d.ts +54 -0
  76. package/dist/schema/error.d.ts +6 -0
  77. package/dist/schema/index.d.ts +8 -0
  78. package/dist/schema/meta.d.ts +71 -0
  79. package/dist/seed/autoSeed.d.ts +30 -0
  80. package/dist/seed/createMeta.d.ts +38 -0
  81. package/dist/seed/index.d.ts +7 -0
  82. package/dist/server.d.ts +24 -0
  83. package/dist/shutdown/index.d.ts +33 -0
  84. package/dist/structureHash.d.ts +15 -0
  85. package/dist/watcher-client/HttpWatcherClient.d.ts +38 -0
  86. package/dist/watcher-client/index.d.ts +6 -0
  87. package/package.json +16 -26
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import fs, { readdirSync, readFileSync, existsSync, writeFileSync, renameSync, unlinkSync, statSync, mkdirSync, copyFileSync, watchFile } from 'node:fs';
2
2
  import path, { join, dirname, resolve, basename, relative, posix } from 'node:path';
3
3
  import { unlink, readFile, mkdir, writeFile, copyFile } from 'node:fs/promises';
4
+ import { z } from 'zod';
4
5
  import { fileURLToPath } from 'node:url';
5
6
  import process$1 from 'node:process';
6
7
  import { randomUUID, createHash } from 'node:crypto';
@@ -12,7 +13,6 @@ import require$$4 from 'util';
12
13
  import require$$5 from 'assert';
13
14
  import require$$2 from 'events';
14
15
  import vm from 'vm';
15
- import { z } from 'zod';
16
16
  import * as commander from 'commander';
17
17
  import 'node:child_process';
18
18
  import { tmpdir } from 'node:os';
@@ -67,6 +67,72 @@ async function pruneArchive(metaPath, maxArchive) {
67
67
  return toRemove;
68
68
  }
69
69
 
70
+ /**
71
+ * Shared component descriptor constants for jeeves-meta.
72
+ *
73
+ * Single source of truth consumed by both the service descriptor and
74
+ * the OpenClaw plugin registration.
75
+ */
76
+ /** Shared jeeves-meta component descriptor constants. */
77
+ const META_COMPONENT = {
78
+ name: 'meta',
79
+ servicePackage: '@karmaniverous/jeeves-meta',
80
+ pluginPackage: '@karmaniverous/jeeves-meta-openclaw',
81
+ defaultPort: 1938};
82
+
83
+ /**
84
+ * Structured error schema from a synthesis step failure.
85
+ *
86
+ */
87
+ /** Zod schema for synthesis step errors. */
88
+ const metaErrorSchema = z.object({
89
+ /** Which step failed: 'architect', 'builder', or 'critic'. */
90
+ step: z.enum(['architect', 'builder', 'critic']),
91
+ /** Error classification code. */
92
+ code: z.string(),
93
+ /** Human-readable error message. */
94
+ message: z.string(),
95
+ });
96
+
97
+ /** Zod schema for the core (library-compatible) meta configuration. */
98
+ /** Zod schema for the core (library-compatible) meta configuration. */
99
+ const metaConfigSchema = z.object({
100
+ /** Watcher service base URL. */
101
+ watcherUrl: z.url(),
102
+ /** OpenClaw gateway base URL for subprocess spawning. */
103
+ gatewayUrl: z.url().default('http://127.0.0.1:18789'),
104
+ /** Optional API key for gateway authentication. */
105
+ gatewayApiKey: z.string().optional(),
106
+ /** Run architect every N cycles (per meta). */
107
+ architectEvery: z.number().int().min(1).default(10),
108
+ /** Exponent for depth weighting in staleness formula. */
109
+ depthWeight: z.number().min(0).default(0.5),
110
+ /** Maximum archive snapshots to retain per meta. */
111
+ maxArchive: z.number().int().min(1).default(20),
112
+ /** Maximum lines of context to include in subprocess prompts. */
113
+ maxLines: z.number().int().min(50).default(500),
114
+ /** Architect subprocess timeout in seconds. */
115
+ architectTimeout: z.number().int().min(30).default(180),
116
+ /** Builder subprocess timeout in seconds. */
117
+ builderTimeout: z.number().int().min(60).default(360),
118
+ /** Critic subprocess timeout in seconds. */
119
+ criticTimeout: z.number().int().min(30).default(240),
120
+ /** Thinking level for spawned synthesis sessions. */
121
+ thinking: z.string().default('low'),
122
+ /** Resolved architect system prompt text. Falls back to built-in default. */
123
+ defaultArchitect: z.string().optional(),
124
+ /** Resolved critic system prompt text. Falls back to built-in default. */
125
+ defaultCritic: z.string().optional(),
126
+ /** Skip unchanged candidates, bump _generatedAt. */
127
+ skipUnchanged: z.boolean().default(true),
128
+ /** Watcher metadata properties applied to live .meta/meta.json files. */
129
+ metaProperty: z.record(z.string(), z.unknown()).default({ _meta: 'current' }),
130
+ /** Watcher metadata properties applied to archive snapshots. */
131
+ metaArchiveProperty: z
132
+ .record(z.string(), z.unknown())
133
+ .default({ _meta: 'archive' }),
134
+ });
135
+
70
136
  /**
71
137
  * Normalize file paths to forward slashes for consistency with watcher-indexed paths.
72
138
  *
@@ -74,7 +140,6 @@ async function pruneArchive(metaPath, maxArchive) {
74
140
  * ensures all paths in the library use the same convention, regardless of
75
141
  * the platform's native separator.
76
142
  *
77
- * @module normalizePath
78
143
  */
79
144
  /**
80
145
  * Normalize a file path to forward slashes.
@@ -85,6 +150,22 @@ async function pruneArchive(metaPath, maxArchive) {
85
150
  function normalizePath(p) {
86
151
  return p.replaceAll('\\', '/');
87
152
  }
153
+ /** Valid states for a synthesis phase. */
154
+ const phaseStatuses = [
155
+ 'fresh',
156
+ 'stale',
157
+ 'pending',
158
+ 'running',
159
+ 'failed',
160
+ ];
161
+ /** Zod schema for a per-phase status value. */
162
+ const phaseStatusSchema = z.enum(phaseStatuses);
163
+ /** Zod schema for the per-meta phase state record. */
164
+ const phaseStateSchema = z.object({
165
+ architect: phaseStatusSchema,
166
+ builder: phaseStatusSchema,
167
+ critic: phaseStatusSchema,
168
+ });
88
169
 
89
170
  /**
90
171
  * Archive reading helpers — watcher scan with filesystem fallback.
@@ -322,7 +403,7 @@ function packageDirectorySync({cwd, ignoreTypeOnlyPackageJson} = {}) {
322
403
  * @module constants
323
404
  */
324
405
  /** Default HTTP port for the jeeves-meta service. */
325
- const DEFAULT_PORT = 1938;
406
+ const DEFAULT_PORT = META_COMPONENT.defaultPort;
326
407
  /** Default port as a string (for Commander CLI defaults). */
327
408
  const DEFAULT_PORT_STR = String(DEFAULT_PORT);
328
409
  /** Service name identifier. */
@@ -1503,11 +1584,11 @@ var hasRequiredRetry$1;
1503
1584
  function requireRetry$1 () {
1504
1585
  if (hasRequiredRetry$1) return retry$1;
1505
1586
  hasRequiredRetry$1 = 1;
1506
- (function (exports$1) {
1587
+ (function (exports) {
1507
1588
  var RetryOperation = requireRetry_operation();
1508
1589
 
1509
- exports$1.operation = function(options) {
1510
- var timeouts = exports$1.timeouts(options);
1590
+ exports.operation = function(options) {
1591
+ var timeouts = exports.timeouts(options);
1511
1592
  return new RetryOperation(timeouts, {
1512
1593
  forever: options && options.forever,
1513
1594
  unref: options && options.unref,
@@ -1515,7 +1596,7 @@ function requireRetry$1 () {
1515
1596
  });
1516
1597
  };
1517
1598
 
1518
- exports$1.timeouts = function(options) {
1599
+ exports.timeouts = function(options) {
1519
1600
  if (options instanceof Array) {
1520
1601
  return [].concat(options);
1521
1602
  }
@@ -1552,7 +1633,7 @@ function requireRetry$1 () {
1552
1633
  return timeouts;
1553
1634
  };
1554
1635
 
1555
- exports$1.createTimeout = function(attempt, opts) {
1636
+ exports.createTimeout = function(attempt, opts) {
1556
1637
  var random = (opts.randomize)
1557
1638
  ? (Math.random() + 1)
1558
1639
  : 1;
@@ -1563,7 +1644,7 @@ function requireRetry$1 () {
1563
1644
  return timeout;
1564
1645
  };
1565
1646
 
1566
- exports$1.wrap = function(obj, options, methods) {
1647
+ exports.wrap = function(obj, options, methods) {
1567
1648
  if (options instanceof Array) {
1568
1649
  methods = options;
1569
1650
  options = null;
@@ -1583,7 +1664,7 @@ function requireRetry$1 () {
1583
1664
  var original = obj[method];
1584
1665
 
1585
1666
  obj[method] = function retryWrapper(original) {
1586
- var op = exports$1.operation(options);
1667
+ var op = exports.operation(options);
1587
1668
  var args = Array.prototype.slice.call(arguments, 1);
1588
1669
  var callback = args.pop();
1589
1670
 
@@ -4592,7 +4673,7 @@ var hasRequiredRe;
4592
4673
  function requireRe () {
4593
4674
  if (hasRequiredRe) return re.exports;
4594
4675
  hasRequiredRe = 1;
4595
- (function (module, exports$1) {
4676
+ (function (module, exports) {
4596
4677
 
4597
4678
  const {
4598
4679
  MAX_SAFE_COMPONENT_LENGTH,
@@ -4600,14 +4681,14 @@ function requireRe () {
4600
4681
  MAX_LENGTH,
4601
4682
  } = requireConstants();
4602
4683
  const debug = requireDebug();
4603
- exports$1 = module.exports = {};
4684
+ exports = module.exports = {};
4604
4685
 
4605
4686
  // The actual regexps go on exports.re
4606
- const re = exports$1.re = [];
4607
- const safeRe = exports$1.safeRe = [];
4608
- const src = exports$1.src = [];
4609
- const safeSrc = exports$1.safeSrc = [];
4610
- const t = exports$1.t = {};
4687
+ const re = exports.re = [];
4688
+ const safeRe = exports.safeRe = [];
4689
+ const src = exports.src = [];
4690
+ const safeSrc = exports.safeSrc = [];
4691
+ const t = exports.t = {};
4611
4692
  let R = 0;
4612
4693
 
4613
4694
  const LETTERDASHNUMBER = '[a-zA-Z0-9-]';
@@ -4730,7 +4811,7 @@ function requireRe () {
4730
4811
  createToken('GTLT', '((?:<|>)?=?)');
4731
4812
 
4732
4813
  // Something like "2.*" or "1.2.x".
4733
- // Note that "x.x" is a valid xRange identifer, meaning "any version"
4814
+ // Note that "x.x" is a valid xRange identifier, meaning "any version"
4734
4815
  // Only the first item is strictly required.
4735
4816
  createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
4736
4817
  createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
@@ -4771,7 +4852,7 @@ function requireRe () {
4771
4852
  createToken('LONETILDE', '(?:~>?)');
4772
4853
 
4773
4854
  createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
4774
- exports$1.tildeTrimReplace = '$1~';
4855
+ exports.tildeTrimReplace = '$1~';
4775
4856
 
4776
4857
  createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
4777
4858
  createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
@@ -4781,7 +4862,7 @@ function requireRe () {
4781
4862
  createToken('LONECARET', '(?:\\^)');
4782
4863
 
4783
4864
  createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
4784
- exports$1.caretTrimReplace = '$1^';
4865
+ exports.caretTrimReplace = '$1^';
4785
4866
 
4786
4867
  createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
4787
4868
  createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
@@ -4794,7 +4875,7 @@ function requireRe () {
4794
4875
  // it modifies, so that `> 1.2.3` ==> `>1.2.3`
4795
4876
  createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
4796
4877
  }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
4797
- exports$1.comparatorTrimReplace = '$1$2$3';
4878
+ exports.comparatorTrimReplace = '$1$2$3';
4798
4879
 
4799
4880
  // Something like `1.2.3 - 1.2.4`
4800
4881
  // Note that these all use the loose form, because they'll be
@@ -5726,6 +5807,62 @@ function requireCoerce () {
5726
5807
  return coerce_1;
5727
5808
  }
5728
5809
 
5810
+ var truncate_1;
5811
+ var hasRequiredTruncate;
5812
+
5813
+ function requireTruncate () {
5814
+ if (hasRequiredTruncate) return truncate_1;
5815
+ hasRequiredTruncate = 1;
5816
+
5817
+ const parse = requireParse();
5818
+ const constants = requireConstants();
5819
+ const SemVer = requireSemver$1();
5820
+
5821
+ const truncate = (version, truncation, options) => {
5822
+ if (!constants.RELEASE_TYPES.includes(truncation)) {
5823
+ return null
5824
+ }
5825
+
5826
+ const clonedVersion = cloneInputVersion(version, options);
5827
+ return clonedVersion && doTruncation(clonedVersion, truncation)
5828
+ };
5829
+
5830
+ const cloneInputVersion = (version, options) => {
5831
+ const versionStringToParse = (
5832
+ version instanceof SemVer ? version.version : version
5833
+ );
5834
+
5835
+ return parse(versionStringToParse, options)
5836
+ };
5837
+
5838
+ const doTruncation = (version, truncation) => {
5839
+ if (isPrerelease(truncation)) {
5840
+ return version.version
5841
+ }
5842
+
5843
+ version.prerelease = [];
5844
+
5845
+ switch (truncation) {
5846
+ case 'major':
5847
+ version.minor = 0;
5848
+ version.patch = 0;
5849
+ break
5850
+ case 'minor':
5851
+ version.patch = 0;
5852
+ break
5853
+ }
5854
+
5855
+ return version.format()
5856
+ };
5857
+
5858
+ const isPrerelease = (type) => {
5859
+ return type.startsWith('pre')
5860
+ };
5861
+
5862
+ truncate_1 = truncate;
5863
+ return truncate_1;
5864
+ }
5865
+
5729
5866
  var lrucache;
5730
5867
  var hasRequiredLrucache;
5731
5868
 
@@ -7175,6 +7312,7 @@ function requireSemver () {
7175
7312
  const lte = requireLte();
7176
7313
  const cmp = requireCmp();
7177
7314
  const coerce = requireCoerce();
7315
+ const truncate = requireTruncate();
7178
7316
  const Comparator = requireComparator();
7179
7317
  const Range = requireRange();
7180
7318
  const satisfies = requireSatisfies();
@@ -7213,6 +7351,7 @@ function requireSemver () {
7213
7351
  lte,
7214
7352
  cmp,
7215
7353
  coerce,
7354
+ truncate,
7216
7355
  Comparator,
7217
7356
  Range,
7218
7357
  satisfies,
@@ -7510,31 +7649,31 @@ var hasRequiredExtraTypings;
7510
7649
  function requireExtraTypings () {
7511
7650
  if (hasRequiredExtraTypings) return extraTypings.exports;
7512
7651
  hasRequiredExtraTypings = 1;
7513
- (function (module, exports$1) {
7652
+ (function (module, exports) {
7514
7653
  const commander = require$$0;
7515
7654
 
7516
- exports$1 = module.exports = {};
7655
+ exports = module.exports = {};
7517
7656
 
7518
7657
  // Return a different global program than commander,
7519
7658
  // and don't also return it as default export.
7520
- exports$1.program = new commander.Command();
7659
+ exports.program = new commander.Command();
7521
7660
 
7522
7661
  /**
7523
7662
  * Expose classes. The FooT versions are just types, so return Commander original implementations!
7524
7663
  */
7525
7664
 
7526
- exports$1.Argument = commander.Argument;
7527
- exports$1.Command = commander.Command;
7528
- exports$1.CommanderError = commander.CommanderError;
7529
- exports$1.Help = commander.Help;
7530
- exports$1.InvalidArgumentError = commander.InvalidArgumentError;
7531
- exports$1.InvalidOptionArgumentError = commander.InvalidArgumentError; // Deprecated
7532
- exports$1.Option = commander.Option;
7665
+ exports.Argument = commander.Argument;
7666
+ exports.Command = commander.Command;
7667
+ exports.CommanderError = commander.CommanderError;
7668
+ exports.Help = commander.Help;
7669
+ exports.InvalidArgumentError = commander.InvalidArgumentError;
7670
+ exports.InvalidOptionArgumentError = commander.InvalidArgumentError; // Deprecated
7671
+ exports.Option = commander.Option;
7533
7672
 
7534
- exports$1.createCommand = (name) => new commander.Command(name);
7535
- exports$1.createOption = (flags, description) =>
7673
+ exports.createCommand = (name) => new commander.Command(name);
7674
+ exports.createOption = (flags, description) =>
7536
7675
  new commander.Option(flags, description);
7537
- exports$1.createArgument = (name, description) =>
7676
+ exports.createArgument = (name, description) =>
7538
7677
  new commander.Argument(name, description);
7539
7678
  } (extraTypings, extraTypings.exports));
7540
7679
  return extraTypings.exports;
@@ -8879,43 +9018,6 @@ function applyHotReloadedConfig(newConfig) {
8879
9018
  *
8880
9019
  * @module schema/config
8881
9020
  */
8882
- /** Zod schema for the core (library-compatible) meta configuration. */
8883
- const metaConfigSchema = z.object({
8884
- /** Watcher service base URL. */
8885
- watcherUrl: z.url(),
8886
- /** OpenClaw gateway base URL for subprocess spawning. */
8887
- gatewayUrl: z.url().default('http://127.0.0.1:18789'),
8888
- /** Optional API key for gateway authentication. */
8889
- gatewayApiKey: z.string().optional(),
8890
- /** Run architect every N cycles (per meta). */
8891
- architectEvery: z.number().int().min(1).default(10),
8892
- /** Exponent for depth weighting in staleness formula. */
8893
- depthWeight: z.number().min(0).default(0.5),
8894
- /** Maximum archive snapshots to retain per meta. */
8895
- maxArchive: z.number().int().min(1).default(20),
8896
- /** Maximum lines of context to include in subprocess prompts. */
8897
- maxLines: z.number().int().min(50).default(500),
8898
- /** Architect subprocess timeout in seconds. */
8899
- architectTimeout: z.number().int().min(30).default(180),
8900
- /** Builder subprocess timeout in seconds. */
8901
- builderTimeout: z.number().int().min(60).default(360),
8902
- /** Critic subprocess timeout in seconds. */
8903
- criticTimeout: z.number().int().min(30).default(240),
8904
- /** Thinking level for spawned synthesis sessions. */
8905
- thinking: z.string().default('low'),
8906
- /** Resolved architect system prompt text. Falls back to built-in default. */
8907
- defaultArchitect: z.string().optional(),
8908
- /** Resolved critic system prompt text. Falls back to built-in default. */
8909
- defaultCritic: z.string().optional(),
8910
- /** Skip unchanged candidates, bump _generatedAt. */
8911
- skipUnchanged: z.boolean().default(true),
8912
- /** Watcher metadata properties applied to live .meta/meta.json files. */
8913
- metaProperty: z.record(z.string(), z.unknown()).default({ _meta: 'current' }),
8914
- /** Watcher metadata properties applied to archive snapshots. */
8915
- metaArchiveProperty: z
8916
- .record(z.string(), z.unknown())
8917
- .default({ _meta: 'archive' }),
8918
- });
8919
9021
  /** Zod schema for logging configuration. */
8920
9022
  const loggingSchema = z.object({
8921
9023
  /** Log level. */
@@ -9232,8 +9334,10 @@ class GatewayExecutor {
9232
9334
  ...(options?.thinking ? { thinking: options.thinking } : {}),
9233
9335
  ...(options?.model ? { model: options.model } : {}),
9234
9336
  });
9235
- const details = (spawnResult.result?.details ?? spawnResult.result);
9236
- const sessionKey = details?.childSessionKey ?? details?.sessionKey;
9337
+ const details = (spawnResult.result?.details ??
9338
+ spawnResult.result ??
9339
+ {});
9340
+ const sessionKey = details.childSessionKey ?? details.sessionKey;
9237
9341
  if (typeof sessionKey !== 'string' || !sessionKey) {
9238
9342
  throw new Error('Gateway sessions_spawn returned no sessionKey: ' +
9239
9343
  JSON.stringify(spawnResult));
@@ -12027,7 +12131,7 @@ function registerMetasUpdateRoute(app, deps) {
12027
12131
  const metaDir = resolveMetaDir(targetPath);
12028
12132
  let meta;
12029
12133
  try {
12030
- meta = (await readMetaJson(metaDir));
12134
+ meta = await readMetaJson(metaDir);
12031
12135
  }
12032
12136
  catch {
12033
12137
  return reply.status(404).send({
@@ -13024,11 +13128,11 @@ async function startService(config, configPath) {
13024
13128
  * Parsed jeeves-meta component descriptor.
13025
13129
  */
13026
13130
  const metaDescriptor = jeevesComponentDescriptorSchema.parse({
13027
- name: 'meta',
13131
+ name: META_COMPONENT.name,
13028
13132
  version: SERVICE_VERSION,
13029
- servicePackage: '@karmaniverous/jeeves-meta',
13030
- pluginPackage: '@karmaniverous/jeeves-meta-openclaw',
13031
- defaultPort: 1938,
13133
+ servicePackage: META_COMPONENT.servicePackage,
13134
+ pluginPackage: META_COMPONENT.pluginPackage,
13135
+ defaultPort: META_COMPONENT.defaultPort,
13032
13136
  // The runtime Zod custom validator only checks for a .parse() method.
13033
13137
  // Use unknown cast to bridge the Zod v4 (service) → v3 (core SDK) type gap.
13034
13138
  configSchema: serviceConfigSchema,
@@ -13079,21 +13183,6 @@ function computeEma(current, previous, decay = DEFAULT_DECAY) {
13079
13183
  return decay * current + (1 - decay) * previous;
13080
13184
  }
13081
13185
 
13082
- /**
13083
- * Structured error from a synthesis step failure.
13084
- *
13085
- * @module schema/error
13086
- */
13087
- /** Zod schema for synthesis step errors. */
13088
- const metaErrorSchema = z.object({
13089
- /** Which step failed: 'architect', 'builder', or 'critic'. */
13090
- step: z.enum(['architect', 'builder', 'critic']),
13091
- /** Error classification code. */
13092
- code: z.string(),
13093
- /** Human-readable error message. */
13094
- message: z.string(),
13095
- });
13096
-
13097
13186
  /**
13098
13187
  * Zod schema for .meta/meta.json files.
13099
13188
  *
@@ -13102,22 +13191,6 @@ const metaErrorSchema = z.object({
13102
13191
  *
13103
13192
  * @module schema/meta
13104
13193
  */
13105
- /** Valid states for a synthesis phase. */
13106
- const phaseStatuses = [
13107
- 'fresh',
13108
- 'stale',
13109
- 'pending',
13110
- 'running',
13111
- 'failed',
13112
- ];
13113
- /** Zod schema for a per-phase status value. */
13114
- const phaseStatusSchema = z.enum(phaseStatuses);
13115
- /** Zod schema for the per-meta phase state record. */
13116
- const phaseStateSchema = z.object({
13117
- architect: phaseStatusSchema,
13118
- builder: phaseStatusSchema,
13119
- critic: phaseStatusSchema,
13120
- });
13121
13194
  /** Zod schema for the reserved (underscore-prefixed) meta.json properties. */
13122
13195
  const metaJsonSchema = z
13123
13196
  .object({
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Per-cycle context package computed by the orchestrator.
3
+ *
4
+ * Shared inputs that multiple subprocesses need are computed once
5
+ * and serialized into each subprocess's task prompt.
6
+ *
7
+ * @module interfaces/MetaContext
8
+ */
9
+ /**
10
+ * Context package for a single synthesis cycle.
11
+ *
12
+ * The orchestrator computes this once per cycle from the meta path,
13
+ * ownership tree, watcher walk results, and filesystem reads.
14
+ */
15
+ export interface MetaContext {
16
+ /** Absolute path to the .meta directory. */
17
+ path: string;
18
+ /** All files in scope (absolute paths). */
19
+ scopeFiles: string[];
20
+ /** Files changed since _generatedAt (absolute paths). */
21
+ deltaFiles: string[];
22
+ /** Child _content outputs, keyed by relative path. */
23
+ childMetas: Record<string, unknown>;
24
+ /** Cross-referenced meta _content outputs, keyed by owner path. */
25
+ crossRefMetas: Record<string, unknown>;
26
+ /** _content from the last cycle, or null on first run. */
27
+ previousContent: string | null;
28
+ /** _feedback from the last cycle, or null on first run. */
29
+ previousFeedback: string | null;
30
+ /** Current _steer value, or null if unset. */
31
+ steer: string | null;
32
+ /** _state from the last cycle, or null on first run. */
33
+ previousState: unknown;
34
+ /** Archive snapshot file paths (for steer change detection, etc.). */
35
+ archives: string[];
36
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Pluggable executor interface for LLM subprocess invocation.
3
+ *
4
+ * @module interfaces/MetaExecutor
5
+ */
6
+ /** Options for spawning a synthesis subprocess. */
7
+ export interface MetaSpawnOptions {
8
+ /** Model override for this subprocess. */
9
+ model?: string;
10
+ /** Timeout in seconds. */
11
+ timeout?: number;
12
+ /** Label for the spawned session. */
13
+ label?: string;
14
+ /** Thinking level (e.g. "low", "medium", "high"). */
15
+ thinking?: string;
16
+ }
17
+ /** Result of a spawn call, including optional token usage. */
18
+ export interface MetaSpawnResult {
19
+ /** Subprocess output text. */
20
+ output: string;
21
+ /** Token count for this call, if available from the executor. */
22
+ tokens?: number;
23
+ }
24
+ /**
25
+ * Interface for spawning synthesis subprocesses.
26
+ *
27
+ * The executor abstracts the LLM invocation mechanism. The orchestrator
28
+ * calls spawn() sequentially for architect, builder, and critic steps.
29
+ * Each call blocks until the subprocess completes and returns its result.
30
+ */
31
+ export interface MetaExecutor {
32
+ /**
33
+ * Spawn a subprocess with the given task prompt.
34
+ *
35
+ * @param task - Full task prompt for the subprocess.
36
+ * @param options - Optional model and timeout overrides.
37
+ * @returns The subprocess result with output and optional token count.
38
+ */
39
+ spawn(task: string, options?: MetaSpawnOptions): Promise<MetaSpawnResult>;
40
+ /**
41
+ * Whether the executor has been aborted by the operator.
42
+ * When true, runPhase catch blocks should skip persisting _error
43
+ * because the abort route has already written the correct state.
44
+ */
45
+ readonly aborted?: boolean;
46
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Abstraction over the jeeves-watcher HTTP API.
3
+ *
4
+ * The service uses this for filesystem enumeration (POST /walk),
5
+ * virtual rule registration (POST /rules/register), and archive reads
6
+ * via filter-only point scans (POST /scan).
7
+ *
8
+ * @module interfaces/WatcherClient
9
+ */
10
+ /** An inference rule to register with the watcher. */
11
+ export interface InferenceRuleSpec {
12
+ /** Rule name. */
13
+ name: string;
14
+ /** Rule description. */
15
+ description: string;
16
+ /** JSON Schema match criteria. */
17
+ match: Record<string, unknown>;
18
+ /** Schema array with set keywords. */
19
+ schema: unknown[];
20
+ /** Declarative render config. */
21
+ render?: Record<string, unknown>;
22
+ /** Handlebars template name. */
23
+ template?: string;
24
+ /** Render output format. */
25
+ renderAs?: string;
26
+ }
27
+ /** Request shape for watcher scan queries. */
28
+ export interface WatcherScanRequest {
29
+ filter: Record<string, unknown>;
30
+ limit?: number;
31
+ cursor?: string;
32
+ fields?: string[];
33
+ countOnly?: boolean;
34
+ }
35
+ /** A single point returned from watcher scan. */
36
+ export interface WatcherScanPoint {
37
+ id?: string | number;
38
+ payload?: Record<string, unknown>;
39
+ }
40
+ /** Response shape for watcher scan queries. */
41
+ export interface WatcherScanResult {
42
+ points: WatcherScanPoint[];
43
+ cursor: string | null;
44
+ }
45
+ /**
46
+ * Interface for watcher HTTP operations.
47
+ *
48
+ * Implementations handle retry with backoff internally.
49
+ */
50
+ export interface WatcherClient {
51
+ /**
52
+ * Register virtual inference rules with the watcher.
53
+ *
54
+ * @param source - Source identifier (e.g. 'jeeves-meta').
55
+ * @param rules - Array of inference rules to register.
56
+ */
57
+ registerRules(source: string, rules: InferenceRuleSpec[]): Promise<void>;
58
+ /**
59
+ * Walk filesystem using glob patterns.
60
+ *
61
+ * @param globs - Array of glob patterns to match against.
62
+ * @returns Promise resolving to array of matching file paths.
63
+ */
64
+ walk(globs: string[]): Promise<string[]>;
65
+ /**
66
+ * Run a filter-only point scan against the watcher index.
67
+ *
68
+ * Optional so narrow test doubles do not need to implement archive-read
69
+ * support unless a test exercises that path.
70
+ *
71
+ * @param request - Scan filter, pagination, and projection options.
72
+ * @returns Matching points and the next cursor.
73
+ */
74
+ scan?(request: WatcherScanRequest): Promise<WatcherScanResult>;
75
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Re-exports for all interface modules.
3
+ *
4
+ * @module interfaces
5
+ */
6
+ export type { MetaContext } from './MetaContext.js';
7
+ export type { MetaExecutor, MetaSpawnOptions, MetaSpawnResult, } from './MetaExecutor.js';
8
+ export type { InferenceRuleSpec, WatcherClient, WatcherScanPoint, WatcherScanRequest, WatcherScanResult, } from './WatcherClient.js';