@karmaniverous/jeeves-meta 0.15.3 → 0.15.5
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/archive/index.d.ts +10 -0
- package/dist/archive/listArchive.d.ts +12 -0
- package/dist/archive/prune.d.ts +14 -0
- package/dist/archive/readArchive.d.ts +30 -0
- package/dist/archive/readLatest.d.ts +13 -0
- package/dist/archive/snapshot.d.ts +17 -0
- package/dist/bootstrap.d.ts +15 -0
- package/dist/cache.d.ts +22 -0
- package/dist/cli/jeeves-meta/architect.md +17 -0
- package/dist/cli/jeeves-meta/index.js +811 -734
- package/dist/cli.d.ts +10 -0
- package/dist/configHotReload.d.ts +30 -0
- package/dist/configLoader.d.ts +37 -0
- package/dist/constants.d.ts +13 -0
- package/dist/customCliCommands.d.ts +13 -0
- package/dist/descriptor.d.ts +19 -0
- package/dist/discovery/buildMinimalNode.d.ts +22 -0
- package/dist/discovery/computeSummary.d.ts +17 -0
- package/dist/discovery/discoverMetas.d.ts +19 -0
- package/dist/discovery/index.d.ts +11 -0
- package/dist/discovery/listMetas.d.ts +63 -0
- package/dist/discovery/ownershipTree.d.ts +25 -0
- package/dist/discovery/scope.d.ts +47 -0
- package/dist/discovery/types.d.ts +25 -0
- package/dist/ema.d.ts +14 -0
- package/dist/errors.d.ts +15 -0
- package/dist/escapeGlob.d.ts +23 -0
- package/dist/executor/GatewayExecutor.d.ts +48 -0
- package/dist/executor/SpawnAbortedError.d.ts +9 -0
- package/dist/executor/SpawnTimeoutError.d.ts +13 -0
- package/dist/executor/index.d.ts +8 -0
- package/dist/index.d.ts +34 -1660
- package/dist/index.js +1434 -1767
- package/dist/interfaces/MetaContext.d.ts +36 -0
- package/dist/interfaces/MetaExecutor.d.ts +46 -0
- package/dist/interfaces/WatcherClient.d.ts +75 -0
- package/dist/interfaces/index.d.ts +8 -0
- package/dist/lock.d.ts +70 -0
- package/dist/logger/index.d.ts +27 -0
- package/dist/mtimeFilter.d.ts +26 -0
- package/dist/normalizePath.d.ts +6 -0
- package/dist/orchestrator/buildTask.d.ts +38 -0
- package/dist/orchestrator/contextPackage.d.ts +30 -0
- package/dist/orchestrator/index.d.ts +10 -0
- package/dist/orchestrator/orchestratePhase.d.ts +38 -0
- package/dist/orchestrator/parseOutput.d.ts +41 -0
- package/dist/orchestrator/runPhase.d.ts +40 -0
- package/dist/phaseState/derivePhaseState.d.ts +41 -0
- package/dist/phaseState/index.d.ts +9 -0
- package/dist/phaseState/invalidate.d.ts +41 -0
- package/dist/phaseState/phaseScheduler.d.ts +57 -0
- package/dist/phaseState/phaseTransitions.d.ts +83 -0
- package/dist/progress/index.d.ts +38 -0
- package/dist/prompts/architect.md +17 -0
- package/dist/prompts/index.d.ts +15 -0
- package/dist/queue/index.d.ts +131 -0
- package/dist/readMetaJson.d.ts +17 -0
- package/dist/routes/__testUtils.d.ts +37 -0
- package/dist/routes/config.d.ts +11 -0
- package/dist/routes/configApply.d.ts +13 -0
- package/dist/routes/index.d.ts +50 -0
- package/dist/routes/metas.d.ts +9 -0
- package/dist/routes/metasUpdate.d.ts +11 -0
- package/dist/routes/preview.d.ts +8 -0
- package/dist/routes/queue.d.ts +13 -0
- package/dist/routes/seed.d.ts +8 -0
- package/dist/routes/status.d.ts +13 -0
- package/dist/routes/synthesize.d.ts +12 -0
- package/dist/routes/unlock.d.ts +8 -0
- package/dist/rules/healthCheck.d.ts +36 -0
- package/dist/rules/index.d.ts +39 -0
- package/dist/rules/verify.d.ts +22 -0
- package/dist/scheduler/index.d.ts +66 -0
- package/dist/scheduling/index.d.ts +7 -0
- package/dist/scheduling/staleness.d.ts +68 -0
- package/dist/scheduling/weightedFormula.d.ts +38 -0
- package/dist/schema/config.d.ts +54 -0
- package/dist/schema/error.d.ts +6 -0
- package/dist/schema/index.d.ts +8 -0
- package/dist/schema/meta.d.ts +71 -0
- package/dist/seed/autoSeed.d.ts +30 -0
- package/dist/seed/createMeta.d.ts +38 -0
- package/dist/seed/index.d.ts +7 -0
- package/dist/server.d.ts +24 -0
- package/dist/shutdown/index.d.ts +33 -0
- package/dist/structureHash.d.ts +15 -0
- package/dist/watcher-client/HttpWatcherClient.d.ts +38 -0
- package/dist/watcher-client/index.d.ts +6 -0
- package/package.json +17 -27
package/dist/index.d.ts
CHANGED
|
@@ -1,1661 +1,35 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { Command } from 'commander';
|
|
3
|
-
import { JeevesComponentDescriptor } from '@karmaniverous/jeeves';
|
|
4
|
-
export { sleepAsync as sleep } from '@karmaniverous/jeeves';
|
|
5
|
-
import pino, { Logger } from 'pino';
|
|
6
|
-
import * as fastify from 'fastify';
|
|
7
|
-
import { FastifyInstance, FastifyBaseLogger } from 'fastify';
|
|
8
|
-
import * as node_http from 'node:http';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* List archive snapshot files in chronological order.
|
|
12
|
-
*
|
|
13
|
-
* @module archive/listArchive
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* List archive .json files sorted chronologically (oldest first).
|
|
17
|
-
*
|
|
18
|
-
* @param metaPath - Absolute path to the .meta directory.
|
|
19
|
-
* @returns Array of absolute paths to archive files, or empty if none.
|
|
20
|
-
*/
|
|
21
|
-
declare function listArchiveFiles(metaPath: string): string[];
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Prune old archive snapshots beyond maxArchive.
|
|
25
|
-
*
|
|
26
|
-
* @module archive/prune
|
|
27
|
-
*/
|
|
28
|
-
/**
|
|
29
|
-
* Prune archive directory to keep at most maxArchive snapshots.
|
|
30
|
-
* Removes the oldest files.
|
|
31
|
-
*
|
|
32
|
-
* @param metaPath - Absolute path to the .meta directory.
|
|
33
|
-
* @param maxArchive - Maximum snapshots to retain.
|
|
34
|
-
* @returns Number of files pruned.
|
|
35
|
-
*/
|
|
36
|
-
declare function pruneArchive(metaPath: string, maxArchive: number): Promise<number>;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Per-cycle context package computed by the orchestrator.
|
|
40
|
-
*
|
|
41
|
-
* Shared inputs that multiple subprocesses need are computed once
|
|
42
|
-
* and serialized into each subprocess's task prompt.
|
|
43
|
-
*
|
|
44
|
-
* @module interfaces/MetaContext
|
|
45
|
-
*/
|
|
46
|
-
/**
|
|
47
|
-
* Context package for a single synthesis cycle.
|
|
48
|
-
*
|
|
49
|
-
* The orchestrator computes this once per cycle from the meta path,
|
|
50
|
-
* ownership tree, watcher walk results, and filesystem reads.
|
|
51
|
-
*/
|
|
52
|
-
interface MetaContext {
|
|
53
|
-
/** Absolute path to the .meta directory. */
|
|
54
|
-
path: string;
|
|
55
|
-
/** All files in scope (absolute paths). */
|
|
56
|
-
scopeFiles: string[];
|
|
57
|
-
/** Files changed since _generatedAt (absolute paths). */
|
|
58
|
-
deltaFiles: string[];
|
|
59
|
-
/** Child _content outputs, keyed by relative path. */
|
|
60
|
-
childMetas: Record<string, unknown>;
|
|
61
|
-
/** Cross-referenced meta _content outputs, keyed by owner path. */
|
|
62
|
-
crossRefMetas: Record<string, unknown>;
|
|
63
|
-
/** _content from the last cycle, or null on first run. */
|
|
64
|
-
previousContent: string | null;
|
|
65
|
-
/** _feedback from the last cycle, or null on first run. */
|
|
66
|
-
previousFeedback: string | null;
|
|
67
|
-
/** Current _steer value, or null if unset. */
|
|
68
|
-
steer: string | null;
|
|
69
|
-
/** _state from the last cycle, or null on first run. */
|
|
70
|
-
previousState: unknown;
|
|
71
|
-
/** Archive snapshot file paths (for steer change detection, etc.). */
|
|
72
|
-
archives: string[];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Pluggable executor interface for LLM subprocess invocation.
|
|
77
|
-
*
|
|
78
|
-
* @module interfaces/MetaExecutor
|
|
79
|
-
*/
|
|
80
|
-
/** Options for spawning a synthesis subprocess. */
|
|
81
|
-
interface MetaSpawnOptions {
|
|
82
|
-
/** Model override for this subprocess. */
|
|
83
|
-
model?: string;
|
|
84
|
-
/** Timeout in seconds. */
|
|
85
|
-
timeout?: number;
|
|
86
|
-
/** Label for the spawned session. */
|
|
87
|
-
label?: string;
|
|
88
|
-
/** Thinking level (e.g. "low", "medium", "high"). */
|
|
89
|
-
thinking?: string;
|
|
90
|
-
}
|
|
91
|
-
/** Result of a spawn call, including optional token usage. */
|
|
92
|
-
interface MetaSpawnResult {
|
|
93
|
-
/** Subprocess output text. */
|
|
94
|
-
output: string;
|
|
95
|
-
/** Token count for this call, if available from the executor. */
|
|
96
|
-
tokens?: number;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Interface for spawning synthesis subprocesses.
|
|
100
|
-
*
|
|
101
|
-
* The executor abstracts the LLM invocation mechanism. The orchestrator
|
|
102
|
-
* calls spawn() sequentially for architect, builder, and critic steps.
|
|
103
|
-
* Each call blocks until the subprocess completes and returns its result.
|
|
104
|
-
*/
|
|
105
|
-
interface MetaExecutor {
|
|
106
|
-
/**
|
|
107
|
-
* Spawn a subprocess with the given task prompt.
|
|
108
|
-
*
|
|
109
|
-
* @param task - Full task prompt for the subprocess.
|
|
110
|
-
* @param options - Optional model and timeout overrides.
|
|
111
|
-
* @returns The subprocess result with output and optional token count.
|
|
112
|
-
*/
|
|
113
|
-
spawn(task: string, options?: MetaSpawnOptions): Promise<MetaSpawnResult>;
|
|
114
|
-
/**
|
|
115
|
-
* Whether the executor has been aborted by the operator.
|
|
116
|
-
* When true, runPhase catch blocks should skip persisting _error
|
|
117
|
-
* because the abort route has already written the correct state.
|
|
118
|
-
*/
|
|
119
|
-
readonly aborted?: boolean;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Abstraction over the jeeves-watcher HTTP API.
|
|
124
|
-
*
|
|
125
|
-
* The service uses this for filesystem enumeration (POST /walk),
|
|
126
|
-
* virtual rule registration (POST /rules/register), and archive reads
|
|
127
|
-
* via filter-only point scans (POST /scan).
|
|
128
|
-
*
|
|
129
|
-
* @module interfaces/WatcherClient
|
|
130
|
-
*/
|
|
131
|
-
/** An inference rule to register with the watcher. */
|
|
132
|
-
interface InferenceRuleSpec {
|
|
133
|
-
/** Rule name. */
|
|
134
|
-
name: string;
|
|
135
|
-
/** Rule description. */
|
|
136
|
-
description: string;
|
|
137
|
-
/** JSON Schema match criteria. */
|
|
138
|
-
match: Record<string, unknown>;
|
|
139
|
-
/** Schema array with set keywords. */
|
|
140
|
-
schema: unknown[];
|
|
141
|
-
/** Declarative render config. */
|
|
142
|
-
render?: Record<string, unknown>;
|
|
143
|
-
/** Handlebars template name. */
|
|
144
|
-
template?: string;
|
|
145
|
-
/** Render output format. */
|
|
146
|
-
renderAs?: string;
|
|
147
|
-
}
|
|
148
|
-
/** Request shape for watcher scan queries. */
|
|
149
|
-
interface WatcherScanRequest {
|
|
150
|
-
filter: Record<string, unknown>;
|
|
151
|
-
limit?: number;
|
|
152
|
-
cursor?: string;
|
|
153
|
-
fields?: string[];
|
|
154
|
-
countOnly?: boolean;
|
|
155
|
-
}
|
|
156
|
-
/** A single point returned from watcher scan. */
|
|
157
|
-
interface WatcherScanPoint {
|
|
158
|
-
id?: string | number;
|
|
159
|
-
payload?: Record<string, unknown>;
|
|
160
|
-
}
|
|
161
|
-
/** Response shape for watcher scan queries. */
|
|
162
|
-
interface WatcherScanResult {
|
|
163
|
-
points: WatcherScanPoint[];
|
|
164
|
-
cursor: string | null;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Interface for watcher HTTP operations.
|
|
168
|
-
*
|
|
169
|
-
* Implementations handle retry with backoff internally.
|
|
170
|
-
*/
|
|
171
|
-
interface WatcherClient {
|
|
172
|
-
/**
|
|
173
|
-
* Register virtual inference rules with the watcher.
|
|
174
|
-
*
|
|
175
|
-
* @param source - Source identifier (e.g. 'jeeves-meta').
|
|
176
|
-
* @param rules - Array of inference rules to register.
|
|
177
|
-
*/
|
|
178
|
-
registerRules(source: string, rules: InferenceRuleSpec[]): Promise<void>;
|
|
179
|
-
/**
|
|
180
|
-
* Walk filesystem using glob patterns.
|
|
181
|
-
*
|
|
182
|
-
* @param globs - Array of glob patterns to match against.
|
|
183
|
-
* @returns Promise resolving to array of matching file paths.
|
|
184
|
-
*/
|
|
185
|
-
walk(globs: string[]): Promise<string[]>;
|
|
186
|
-
/**
|
|
187
|
-
* Run a filter-only point scan against the watcher index.
|
|
188
|
-
*
|
|
189
|
-
* Optional so narrow test doubles do not need to implement archive-read
|
|
190
|
-
* support unless a test exercises that path.
|
|
191
|
-
*
|
|
192
|
-
* @param request - Scan filter, pagination, and projection options.
|
|
193
|
-
* @returns Matching points and the next cursor.
|
|
194
|
-
*/
|
|
195
|
-
scan?(request: WatcherScanRequest): Promise<WatcherScanResult>;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Zod schema for jeeves-meta service configuration.
|
|
200
|
-
*
|
|
201
|
-
* The service config is a strict superset of the core (library-compatible) meta config.
|
|
202
|
-
*
|
|
203
|
-
* @module schema/config
|
|
204
|
-
*/
|
|
205
|
-
|
|
206
|
-
/** Zod schema for the core (library-compatible) meta configuration. */
|
|
207
|
-
declare const metaConfigSchema: z.ZodObject<{
|
|
208
|
-
watcherUrl: z.ZodURL;
|
|
209
|
-
gatewayUrl: z.ZodDefault<z.ZodURL>;
|
|
210
|
-
gatewayApiKey: z.ZodOptional<z.ZodString>;
|
|
211
|
-
architectEvery: z.ZodDefault<z.ZodNumber>;
|
|
212
|
-
depthWeight: z.ZodDefault<z.ZodNumber>;
|
|
213
|
-
maxArchive: z.ZodDefault<z.ZodNumber>;
|
|
214
|
-
maxLines: z.ZodDefault<z.ZodNumber>;
|
|
215
|
-
architectTimeout: z.ZodDefault<z.ZodNumber>;
|
|
216
|
-
builderTimeout: z.ZodDefault<z.ZodNumber>;
|
|
217
|
-
criticTimeout: z.ZodDefault<z.ZodNumber>;
|
|
218
|
-
thinking: z.ZodDefault<z.ZodString>;
|
|
219
|
-
defaultArchitect: z.ZodOptional<z.ZodString>;
|
|
220
|
-
defaultCritic: z.ZodOptional<z.ZodString>;
|
|
221
|
-
skipUnchanged: z.ZodDefault<z.ZodBoolean>;
|
|
222
|
-
metaProperty: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
223
|
-
metaArchiveProperty: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
224
|
-
}, z.core.$strip>;
|
|
225
|
-
/** Inferred type for core meta configuration. */
|
|
226
|
-
type MetaConfig = z.infer<typeof metaConfigSchema>;
|
|
227
|
-
/** Zod schema for jeeves-meta service configuration (superset of MetaConfig). */
|
|
228
|
-
declare const serviceConfigSchema: z.ZodObject<{
|
|
229
|
-
watcherUrl: z.ZodURL;
|
|
230
|
-
gatewayUrl: z.ZodDefault<z.ZodURL>;
|
|
231
|
-
gatewayApiKey: z.ZodOptional<z.ZodString>;
|
|
232
|
-
architectEvery: z.ZodDefault<z.ZodNumber>;
|
|
233
|
-
depthWeight: z.ZodDefault<z.ZodNumber>;
|
|
234
|
-
maxArchive: z.ZodDefault<z.ZodNumber>;
|
|
235
|
-
maxLines: z.ZodDefault<z.ZodNumber>;
|
|
236
|
-
architectTimeout: z.ZodDefault<z.ZodNumber>;
|
|
237
|
-
builderTimeout: z.ZodDefault<z.ZodNumber>;
|
|
238
|
-
criticTimeout: z.ZodDefault<z.ZodNumber>;
|
|
239
|
-
thinking: z.ZodDefault<z.ZodString>;
|
|
240
|
-
defaultArchitect: z.ZodOptional<z.ZodString>;
|
|
241
|
-
defaultCritic: z.ZodOptional<z.ZodString>;
|
|
242
|
-
skipUnchanged: z.ZodDefault<z.ZodBoolean>;
|
|
243
|
-
metaProperty: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
244
|
-
metaArchiveProperty: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
245
|
-
port: z.ZodDefault<z.ZodNumber>;
|
|
246
|
-
schedule: z.ZodDefault<z.ZodString>;
|
|
247
|
-
reportChannel: z.ZodOptional<z.ZodString>;
|
|
248
|
-
reportTarget: z.ZodOptional<z.ZodString>;
|
|
249
|
-
serverBaseUrl: z.ZodOptional<z.ZodString>;
|
|
250
|
-
watcherHealthIntervalMs: z.ZodDefault<z.ZodNumber>;
|
|
251
|
-
logging: z.ZodDefault<z.ZodObject<{
|
|
252
|
-
level: z.ZodDefault<z.ZodString>;
|
|
253
|
-
file: z.ZodOptional<z.ZodString>;
|
|
254
|
-
}, z.core.$strip>>;
|
|
255
|
-
autoSeed: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
256
|
-
match: z.ZodString;
|
|
257
|
-
steer: z.ZodOptional<z.ZodString>;
|
|
258
|
-
crossRefs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
259
|
-
}, z.core.$strip>>>>;
|
|
260
|
-
}, z.core.$strip>;
|
|
261
|
-
/** Inferred type for service configuration. */
|
|
262
|
-
type ServiceConfig = z.infer<typeof serviceConfigSchema>;
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Structured error from a synthesis step failure.
|
|
266
|
-
*
|
|
267
|
-
* @module schema/error
|
|
268
|
-
*/
|
|
269
|
-
|
|
270
|
-
/** Zod schema for synthesis step errors. */
|
|
271
|
-
declare const metaErrorSchema: z.ZodObject<{
|
|
272
|
-
step: z.ZodEnum<{
|
|
273
|
-
architect: "architect";
|
|
274
|
-
builder: "builder";
|
|
275
|
-
critic: "critic";
|
|
276
|
-
}>;
|
|
277
|
-
code: z.ZodString;
|
|
278
|
-
message: z.ZodString;
|
|
279
|
-
}, z.core.$strip>;
|
|
280
|
-
/** Inferred type for synthesis step errors. */
|
|
281
|
-
type MetaError = z.infer<typeof metaErrorSchema>;
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Zod schema for .meta/meta.json files.
|
|
285
|
-
*
|
|
286
|
-
* Reserved properties are underscore-prefixed and engine-managed.
|
|
287
|
-
* All other keys are open schema (builder output).
|
|
288
|
-
*
|
|
289
|
-
* @module schema/meta
|
|
290
|
-
*/
|
|
291
|
-
|
|
292
|
-
/** Phase names in pipeline order. */
|
|
293
|
-
declare const phaseNames: readonly ["architect", "builder", "critic"];
|
|
294
|
-
/** A single synthesis phase name. */
|
|
295
|
-
type PhaseName = (typeof phaseNames)[number];
|
|
296
|
-
/** Valid states for a synthesis phase. */
|
|
297
|
-
declare const phaseStatuses: readonly ["fresh", "stale", "pending", "running", "failed"];
|
|
298
|
-
/** A single phase status value. */
|
|
299
|
-
type PhaseStatus = (typeof phaseStatuses)[number];
|
|
300
|
-
/** Per-phase state record. */
|
|
301
|
-
type PhaseState = Record<PhaseName, PhaseStatus>;
|
|
302
|
-
/** Zod schema for the reserved (underscore-prefixed) meta.json properties. */
|
|
303
|
-
declare const metaJsonSchema: z.ZodObject<{
|
|
304
|
-
_id: z.ZodOptional<z.ZodUUID>;
|
|
305
|
-
_steer: z.ZodOptional<z.ZodString>;
|
|
306
|
-
_crossRefs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
307
|
-
_architect: z.ZodOptional<z.ZodString>;
|
|
308
|
-
_builder: z.ZodOptional<z.ZodString>;
|
|
309
|
-
_critic: z.ZodOptional<z.ZodString>;
|
|
310
|
-
_generatedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
311
|
-
_content: z.ZodOptional<z.ZodString>;
|
|
312
|
-
_structureHash: z.ZodOptional<z.ZodString>;
|
|
313
|
-
_synthesisCount: z.ZodOptional<z.ZodNumber>;
|
|
314
|
-
_feedback: z.ZodOptional<z.ZodString>;
|
|
315
|
-
_archived: z.ZodOptional<z.ZodBoolean>;
|
|
316
|
-
_archivedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
317
|
-
_depth: z.ZodOptional<z.ZodNumber>;
|
|
318
|
-
_emphasis: z.ZodOptional<z.ZodNumber>;
|
|
319
|
-
_architectTokens: z.ZodOptional<z.ZodNumber>;
|
|
320
|
-
_builderTokens: z.ZodOptional<z.ZodNumber>;
|
|
321
|
-
_criticTokens: z.ZodOptional<z.ZodNumber>;
|
|
322
|
-
_architectTokensAvg: z.ZodOptional<z.ZodNumber>;
|
|
323
|
-
_builderTokensAvg: z.ZodOptional<z.ZodNumber>;
|
|
324
|
-
_criticTokensAvg: z.ZodOptional<z.ZodNumber>;
|
|
325
|
-
_state: z.ZodOptional<z.ZodUnknown>;
|
|
326
|
-
_error: z.ZodOptional<z.ZodObject<{
|
|
327
|
-
step: z.ZodEnum<{
|
|
328
|
-
architect: "architect";
|
|
329
|
-
builder: "builder";
|
|
330
|
-
critic: "critic";
|
|
331
|
-
}>;
|
|
332
|
-
code: z.ZodString;
|
|
333
|
-
message: z.ZodString;
|
|
334
|
-
}, z.core.$strip>>;
|
|
335
|
-
_disabled: z.ZodOptional<z.ZodBoolean>;
|
|
336
|
-
_phaseState: z.ZodOptional<z.ZodObject<{
|
|
337
|
-
architect: z.ZodEnum<{
|
|
338
|
-
fresh: "fresh";
|
|
339
|
-
stale: "stale";
|
|
340
|
-
pending: "pending";
|
|
341
|
-
running: "running";
|
|
342
|
-
failed: "failed";
|
|
343
|
-
}>;
|
|
344
|
-
builder: z.ZodEnum<{
|
|
345
|
-
fresh: "fresh";
|
|
346
|
-
stale: "stale";
|
|
347
|
-
pending: "pending";
|
|
348
|
-
running: "running";
|
|
349
|
-
failed: "failed";
|
|
350
|
-
}>;
|
|
351
|
-
critic: z.ZodEnum<{
|
|
352
|
-
fresh: "fresh";
|
|
353
|
-
stale: "stale";
|
|
354
|
-
pending: "pending";
|
|
355
|
-
running: "running";
|
|
356
|
-
failed: "failed";
|
|
357
|
-
}>;
|
|
358
|
-
}, z.core.$strip>>;
|
|
359
|
-
}, z.core.$loose>;
|
|
360
|
-
/** Inferred type for meta.json. */
|
|
361
|
-
type MetaJson = z.infer<typeof metaJsonSchema>;
|
|
362
|
-
|
|
363
1
|
/**
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
* @
|
|
367
|
-
*/
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
* @module constants
|
|
399
|
-
*/
|
|
400
|
-
/** Default HTTP port for the jeeves-meta service. */
|
|
401
|
-
declare const DEFAULT_PORT = 1938;
|
|
402
|
-
/** Default port as a string (for Commander CLI defaults). */
|
|
403
|
-
declare const DEFAULT_PORT_STR: string;
|
|
404
|
-
/** Service name identifier. */
|
|
405
|
-
declare const SERVICE_NAME = "jeeves-meta";
|
|
406
|
-
/** Service version, read from package.json at startup. */
|
|
407
|
-
declare const SERVICE_VERSION: string;
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* Custom CLI commands for the jeeves-meta service.
|
|
411
|
-
*
|
|
412
|
-
* Registered via `descriptor.customCliCommands` and added to the
|
|
413
|
-
* standard service CLI produced by `createServiceCli`.
|
|
414
|
-
*
|
|
415
|
-
* @module customCliCommands
|
|
416
|
-
*/
|
|
417
|
-
|
|
418
|
-
/** Register all custom meta commands on the parent program. */
|
|
419
|
-
declare function registerCustomCliCommands(program: Command): void;
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* Hybrid 3-layer synthesis queue.
|
|
423
|
-
*
|
|
424
|
-
* Layer 1: Current — the single item currently executing (at most one).
|
|
425
|
-
* Layer 2: Overrides — items manually enqueued via POST /synthesize with path.
|
|
426
|
-
* FIFO among overrides, ahead of automatic candidates.
|
|
427
|
-
* Layer 3: Automatic — computed on read, not persisted. All metas with a
|
|
428
|
-
* pending phase, ranked by scheduler priority.
|
|
429
|
-
*
|
|
430
|
-
* Legacy: `pending` array is the union of overrides + automatic.
|
|
431
|
-
*
|
|
432
|
-
* @module queue
|
|
433
|
-
*/
|
|
434
|
-
|
|
435
|
-
/** A queued synthesis work item. */
|
|
436
|
-
interface QueueItem {
|
|
437
|
-
path: string;
|
|
438
|
-
priority: boolean;
|
|
439
|
-
enqueuedAt: string;
|
|
440
|
-
}
|
|
441
|
-
/** An override entry in the explicit queue layer. */
|
|
442
|
-
interface OverrideEntry {
|
|
443
|
-
path: string;
|
|
444
|
-
enqueuedAt: string;
|
|
445
|
-
}
|
|
446
|
-
/** The currently executing item with phase info. */
|
|
447
|
-
interface CurrentItem {
|
|
448
|
-
path: string;
|
|
449
|
-
phase: PhaseName;
|
|
450
|
-
startedAt: string;
|
|
451
|
-
}
|
|
452
|
-
/** Result returned by {@link SynthesisQueue.enqueue}. */
|
|
453
|
-
interface EnqueueResult {
|
|
454
|
-
position: number;
|
|
455
|
-
alreadyQueued: boolean;
|
|
456
|
-
}
|
|
457
|
-
/** Snapshot of queue state for the /status endpoint. */
|
|
458
|
-
interface QueueState {
|
|
459
|
-
depth: number;
|
|
460
|
-
items: Array<{
|
|
461
|
-
path: string;
|
|
462
|
-
priority: boolean;
|
|
463
|
-
enqueuedAt: string;
|
|
464
|
-
}>;
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* Hybrid 3-layer synthesis queue.
|
|
468
|
-
*
|
|
469
|
-
* Only one synthesis runs at a time. Override items (explicit triggers)
|
|
470
|
-
* take priority over automatic candidates.
|
|
471
|
-
*/
|
|
472
|
-
declare class SynthesisQueue {
|
|
473
|
-
/** Legacy queue (used by processQueue for backward compat). */
|
|
474
|
-
private queue;
|
|
475
|
-
private currentItem;
|
|
476
|
-
private processing;
|
|
477
|
-
private logger;
|
|
478
|
-
private onEnqueueCallback;
|
|
479
|
-
/** Explicit override entries (3-layer model). */
|
|
480
|
-
private overrideEntries;
|
|
481
|
-
/** Currently executing item with phase info (3-layer model). */
|
|
482
|
-
private currentPhaseItem;
|
|
483
|
-
constructor(logger: Logger);
|
|
484
|
-
/** Set a callback to invoke when a new (non-duplicate) item is enqueued. */
|
|
485
|
-
onEnqueue(callback: () => void): void;
|
|
486
|
-
/**
|
|
487
|
-
* Add an explicit override entry (from POST /synthesize with path).
|
|
488
|
-
* Deduped by path. Returns position and whether already queued.
|
|
489
|
-
*/
|
|
490
|
-
enqueueOverride(path: string): EnqueueResult;
|
|
491
|
-
/** Dequeue the next override entry, or undefined if empty. */
|
|
492
|
-
dequeueOverride(): OverrideEntry | undefined;
|
|
493
|
-
/** Get all override entries (shallow copy). */
|
|
494
|
-
get overrides(): OverrideEntry[];
|
|
495
|
-
/** Clear all override entries. Returns count removed. */
|
|
496
|
-
clearOverrides(): number;
|
|
497
|
-
/** Check if a path is in the override layer. */
|
|
498
|
-
hasOverride(path: string): boolean;
|
|
499
|
-
/** Set the currently executing phase item. */
|
|
500
|
-
setCurrentPhase(path: string, phase: PhaseName): void;
|
|
501
|
-
/** Clear the current phase item. */
|
|
502
|
-
clearCurrentPhase(): void;
|
|
503
|
-
/** The currently executing phase item, or null. */
|
|
504
|
-
get currentPhase(): CurrentItem | null;
|
|
505
|
-
/**
|
|
506
|
-
* Add a path to the synthesis queue.
|
|
507
|
-
*
|
|
508
|
-
* @param path - Meta path to synthesize.
|
|
509
|
-
* @param priority - If true, insert at front of queue.
|
|
510
|
-
* @returns Position and whether the path was already queued.
|
|
511
|
-
*/
|
|
512
|
-
enqueue(path: string, priority?: boolean): EnqueueResult;
|
|
513
|
-
/** Remove and return the next item from the queue. */
|
|
514
|
-
dequeue(): QueueItem | undefined;
|
|
515
|
-
/** Mark the currently-running synthesis as complete. */
|
|
516
|
-
complete(): void;
|
|
517
|
-
/** Number of items waiting in the queue (excludes current). */
|
|
518
|
-
get depth(): number;
|
|
519
|
-
/** The item currently being synthesized, or null. */
|
|
520
|
-
get current(): QueueItem | null;
|
|
521
|
-
/** A shallow copy of the queued items. */
|
|
522
|
-
get items(): QueueItem[];
|
|
523
|
-
/** A shallow copy of the pending items (alias for items). */
|
|
524
|
-
get pending(): QueueItem[];
|
|
525
|
-
/**
|
|
526
|
-
* Remove all pending items from the queue.
|
|
527
|
-
* Does not affect the currently-running item.
|
|
528
|
-
*
|
|
529
|
-
* @returns The number of items removed.
|
|
530
|
-
*/
|
|
531
|
-
clear(): number;
|
|
532
|
-
/** Check whether a path is in the queue or currently being synthesized. */
|
|
533
|
-
has(path: string): boolean;
|
|
534
|
-
/** Get the 0-indexed position of a path in the queue. */
|
|
535
|
-
getPosition(path: string): number | null;
|
|
536
|
-
/** Dequeue the next item: overrides first, then legacy queue. */
|
|
537
|
-
private nextItem;
|
|
538
|
-
/** Return a snapshot of queue state for the /status endpoint. */
|
|
539
|
-
getState(): QueueState;
|
|
540
|
-
/**
|
|
541
|
-
* Process queued items one at a time until all queues are empty.
|
|
542
|
-
*
|
|
543
|
-
* Override entries are processed first (FIFO), then legacy queue items.
|
|
544
|
-
* Re-entry is prevented: if already processing, the call returns
|
|
545
|
-
* immediately. Errors are logged and do not block subsequent items.
|
|
546
|
-
*
|
|
547
|
-
* @param synthesizeFn - Async function that performs synthesis for a path.
|
|
548
|
-
*/
|
|
549
|
-
processQueue(synthesizeFn: (path: string) => Promise<void>): Promise<void>;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
/**
|
|
553
|
-
* Virtual rule registration with jeeves-watcher.
|
|
554
|
-
*
|
|
555
|
-
* Service registers inference rules at startup (with retry) and
|
|
556
|
-
* re-registers opportunistically when watcher restart is detected.
|
|
557
|
-
*
|
|
558
|
-
* @module rules
|
|
559
|
-
*/
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* Manages virtual rule registration with watcher.
|
|
563
|
-
*
|
|
564
|
-
* - Registers at startup with exponential retry
|
|
565
|
-
* - Tracks watcher uptime for restart detection
|
|
566
|
-
* - Re-registers opportunistically when uptime decreases
|
|
567
|
-
*/
|
|
568
|
-
declare class RuleRegistrar {
|
|
569
|
-
private readonly config;
|
|
570
|
-
private readonly logger;
|
|
571
|
-
private readonly watcherClient;
|
|
572
|
-
private lastWatcherUptime;
|
|
573
|
-
private registered;
|
|
574
|
-
constructor(config: MetaConfig, logger: Logger, watcher: WatcherClient);
|
|
575
|
-
/** Whether rules have been successfully registered. */
|
|
576
|
-
get isRegistered(): boolean;
|
|
577
|
-
/**
|
|
578
|
-
* Register rules with watcher. Retries with exponential backoff.
|
|
579
|
-
* Non-blocking — logs errors but never throws.
|
|
580
|
-
*/
|
|
581
|
-
register(): Promise<void>;
|
|
582
|
-
/**
|
|
583
|
-
* Check watcher uptime and re-register if it decreased (restart detected).
|
|
584
|
-
*
|
|
585
|
-
* @param currentUptime - Current watcher uptime in seconds.
|
|
586
|
-
*/
|
|
587
|
-
checkAndReregister(currentUptime: number): Promise<void>;
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
/**
|
|
591
|
-
* HTTP implementation of the WatcherClient interface.
|
|
592
|
-
*
|
|
593
|
-
* Talks to jeeves-watcher's POST /walk and POST /rules/register endpoints
|
|
594
|
-
* with retry and exponential backoff.
|
|
595
|
-
*
|
|
596
|
-
* @module watcher-client/HttpWatcherClient
|
|
597
|
-
*/
|
|
598
|
-
|
|
599
|
-
/** Options for creating an HttpWatcherClient. */
|
|
600
|
-
interface HttpWatcherClientOptions {
|
|
601
|
-
/** Base URL for the watcher service (e.g. "http://localhost:1936"). */
|
|
602
|
-
baseUrl: string;
|
|
603
|
-
/** Maximum retry attempts for transient failures. Default: 3. */
|
|
604
|
-
maxRetries?: number;
|
|
605
|
-
/** Base delay in ms for exponential backoff. Default: 1000. */
|
|
606
|
-
backoffBaseMs?: number;
|
|
607
|
-
/** Multiplier for backoff. Default: 4 (1s, 4s, 16s). */
|
|
608
|
-
backoffFactor?: number;
|
|
609
|
-
/** Per-request timeout in ms. Default: 10000. */
|
|
610
|
-
timeoutMs?: number;
|
|
611
|
-
}
|
|
612
|
-
/**
|
|
613
|
-
* HTTP-based WatcherClient implementation with retry.
|
|
614
|
-
*/
|
|
615
|
-
declare class HttpWatcherClient implements WatcherClient {
|
|
616
|
-
private readonly baseUrl;
|
|
617
|
-
private readonly maxRetries;
|
|
618
|
-
private readonly backoffBaseMs;
|
|
619
|
-
private readonly backoffFactor;
|
|
620
|
-
private readonly timeoutMs;
|
|
621
|
-
constructor(options: HttpWatcherClientOptions);
|
|
622
|
-
/** POST JSON with retry. */
|
|
623
|
-
private post;
|
|
624
|
-
registerRules(source: string, rules: InferenceRuleSpec[]): Promise<void>;
|
|
625
|
-
walk(globs: string[]): Promise<string[]>;
|
|
626
|
-
scan(request: WatcherScanRequest): Promise<WatcherScanResult>;
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
/**
|
|
630
|
-
* Croner-based scheduler that discovers the highest-priority ready phase
|
|
631
|
-
* across the corpus each tick and enqueues it for execution.
|
|
632
|
-
*
|
|
633
|
-
* @module scheduler
|
|
634
|
-
*/
|
|
635
|
-
|
|
636
|
-
/**
|
|
637
|
-
* Periodic scheduler that discovers the highest-priority ready phase
|
|
638
|
-
* across all metas and enqueues it for execution.
|
|
639
|
-
*
|
|
640
|
-
* Supports adaptive backoff when no candidates are found and hot-reloadable
|
|
641
|
-
* cron expressions via {@link Scheduler.updateSchedule}.
|
|
642
|
-
*/
|
|
643
|
-
declare class Scheduler {
|
|
644
|
-
private job;
|
|
645
|
-
private backoffMultiplier;
|
|
646
|
-
private tickCount;
|
|
647
|
-
private readonly config;
|
|
648
|
-
private readonly queue;
|
|
649
|
-
private readonly logger;
|
|
650
|
-
private readonly watcher;
|
|
651
|
-
private registrar;
|
|
652
|
-
private currentExpression;
|
|
653
|
-
constructor(config: ServiceConfig, queue: SynthesisQueue, logger: Logger, watcher: HttpWatcherClient);
|
|
654
|
-
/** Set the rule registrar for watcher restart detection. */
|
|
655
|
-
setRegistrar(registrar: RuleRegistrar): void;
|
|
656
|
-
/** Start the cron job. */
|
|
657
|
-
start(): void;
|
|
658
|
-
/** Stop the cron job. */
|
|
659
|
-
stop(): void;
|
|
660
|
-
/** Hot-reload the cron schedule expression. */
|
|
661
|
-
updateSchedule(expression: string): void;
|
|
662
|
-
/** Reset backoff multiplier (call after successful phase execution). */
|
|
663
|
-
resetBackoff(): void;
|
|
664
|
-
/** Whether the scheduler is currently running. */
|
|
665
|
-
get isRunning(): boolean;
|
|
666
|
-
/** Next scheduled tick time, or null if not running. */
|
|
667
|
-
get nextRunAt(): Date | null;
|
|
668
|
-
/**
|
|
669
|
-
* Single tick: discover the highest-priority ready phase and enqueue it.
|
|
670
|
-
*
|
|
671
|
-
* Applies adaptive backoff when no candidates are found.
|
|
672
|
-
*/
|
|
673
|
-
private tick;
|
|
674
|
-
/**
|
|
675
|
-
* Discover the highest-priority ready phase across the corpus.
|
|
676
|
-
*
|
|
677
|
-
* Uses phase-state-aware scheduling: priority order is
|
|
678
|
-
* critic (band 1) \> builder (band 2) \> architect (band 3),
|
|
679
|
-
* with weighted staleness as tiebreaker within a band.
|
|
680
|
-
*/
|
|
681
|
-
private discoverNextPhase;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
/**
|
|
685
|
-
* Shared live config hot-reload support.
|
|
686
|
-
*
|
|
687
|
-
* Used by both file-watch reloads in bootstrap and POST /config/apply
|
|
688
|
-
* via the component descriptor's onConfigApply callback.
|
|
689
|
-
*
|
|
690
|
-
* @module configHotReload
|
|
691
|
-
*/
|
|
692
|
-
|
|
693
|
-
/**
|
|
694
|
-
* Fields that require a service restart to take effect.
|
|
695
|
-
*
|
|
696
|
-
* Shared between the descriptor's `onConfigApply` and the file-watcher
|
|
697
|
-
* hot-reload in `bootstrap.ts`.
|
|
698
|
-
*/
|
|
699
|
-
declare const RESTART_REQUIRED_FIELDS: readonly ["port", "watcherUrl", "gatewayUrl", "gatewayApiKey", "defaultArchitect", "defaultCritic"];
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* Load and resolve jeeves-meta service config.
|
|
703
|
-
*
|
|
704
|
-
* Supports \@file: indirection and environment-variable substitution (dollar-brace pattern).
|
|
705
|
-
*
|
|
706
|
-
* @module configLoader
|
|
707
|
-
*/
|
|
708
|
-
|
|
709
|
-
/**
|
|
710
|
-
* Migrate legacy config path to the new canonical location.
|
|
711
|
-
*
|
|
712
|
-
* If the old path `{configRoot}/jeeves-meta.config.json` exists and the new
|
|
713
|
-
* path `{configRoot}/jeeves-meta/config.json` does NOT exist, copies the file
|
|
714
|
-
* to the new location and logs a warning.
|
|
715
|
-
*
|
|
716
|
-
* @param configRoot - Root directory for configuration files.
|
|
717
|
-
* @param warn - Optional callback for logging the migration warning.
|
|
718
|
-
*/
|
|
719
|
-
declare function migrateConfigPath(configRoot: string, warn?: (msg: string) => void): void;
|
|
720
|
-
/**
|
|
721
|
-
* Resolve config path from --config flag or JEEVES_META_CONFIG env var.
|
|
722
|
-
*
|
|
723
|
-
* @param args - CLI arguments (process.argv.slice(2)).
|
|
724
|
-
* @returns Resolved config path.
|
|
725
|
-
* @throws If no config path found.
|
|
726
|
-
*/
|
|
727
|
-
declare function resolveConfigPath(args: string[]): string;
|
|
728
|
-
/**
|
|
729
|
-
* Load service config from a JSON file.
|
|
730
|
-
*
|
|
731
|
-
* Resolves \@file: references for defaultArchitect and defaultCritic,
|
|
732
|
-
* and substitutes environment-variable placeholders throughout.
|
|
733
|
-
*
|
|
734
|
-
* @param configPath - Path to config JSON file.
|
|
735
|
-
* @returns Validated ServiceConfig.
|
|
736
|
-
*/
|
|
737
|
-
declare function loadServiceConfig(configPath: string): ServiceConfig;
|
|
738
|
-
|
|
739
|
-
/**
|
|
740
|
-
* Jeeves component descriptor for jeeves-meta.
|
|
741
|
-
*
|
|
742
|
-
* Single source of truth consumed by the service CLI, plugin writer, and
|
|
743
|
-
* config-apply pipeline.
|
|
744
|
-
*
|
|
745
|
-
* @module descriptor
|
|
746
|
-
*/
|
|
747
|
-
|
|
748
|
-
/**
|
|
749
|
-
* Parsed jeeves-meta component descriptor.
|
|
750
|
-
*/
|
|
751
|
-
declare const metaDescriptor: JeevesComponentDescriptor;
|
|
752
|
-
|
|
753
|
-
/**
|
|
754
|
-
* Types for meta discovery and ownership tree.
|
|
755
|
-
*
|
|
756
|
-
* @module discovery/types
|
|
757
|
-
*/
|
|
758
|
-
/** A discovered meta node in the ownership tree. */
|
|
759
|
-
interface MetaNode {
|
|
760
|
-
/** Absolute path to the .meta directory. */
|
|
761
|
-
metaPath: string;
|
|
762
|
-
/** Absolute path to the parent directory that this meta owns. */
|
|
763
|
-
ownerPath: string;
|
|
764
|
-
/** Depth in the ownership tree (root = 0). */
|
|
765
|
-
treeDepth: number;
|
|
766
|
-
/** Child meta nodes (subtrees with their own .meta/). */
|
|
767
|
-
children: MetaNode[];
|
|
768
|
-
/** Parent meta node, or null for roots. */
|
|
769
|
-
parent: MetaNode | null;
|
|
770
|
-
}
|
|
771
|
-
/** The full ownership tree discovered from watchPaths. */
|
|
772
|
-
interface OwnershipTree {
|
|
773
|
-
/** All discovered meta nodes, keyed by metaPath. */
|
|
774
|
-
nodes: Map<string, MetaNode>;
|
|
775
|
-
/** Root nodes (metas with no parent meta). */
|
|
776
|
-
roots: MetaNode[];
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
/**
|
|
780
|
-
* Unified meta listing: scan, dedup, enrich.
|
|
781
|
-
*
|
|
782
|
-
* Single source of truth for all consumers that need a list of metas
|
|
783
|
-
* with enriched metadata. Replaces duplicated scan+dedup logic in
|
|
784
|
-
* plugin tools, CLI, and prompt injection.
|
|
785
|
-
*
|
|
786
|
-
* @module discovery/listMetas
|
|
787
|
-
*/
|
|
788
|
-
|
|
789
|
-
/** Enriched meta entry returned by listMetas(). */
|
|
790
|
-
interface MetaEntry {
|
|
791
|
-
/** Normalized .meta/ directory path. */
|
|
792
|
-
path: string;
|
|
793
|
-
/** Tree depth (0 = leaf, higher = more abstract). */
|
|
794
|
-
depth: number;
|
|
795
|
-
/** Scheduling emphasis multiplier. */
|
|
796
|
-
emphasis: number;
|
|
797
|
-
/** Seconds since last synthesis, or Infinity if never synthesized. */
|
|
798
|
-
stalenessSeconds: number;
|
|
799
|
-
/** ISO timestamp of last synthesis, or null. */
|
|
800
|
-
lastSynthesized: string | null;
|
|
801
|
-
/** Whether the last synthesis had an error. */
|
|
802
|
-
hasError: boolean;
|
|
803
|
-
/** Whether this meta is currently locked. */
|
|
804
|
-
locked: boolean;
|
|
805
|
-
/** Whether this meta is disabled (skipped during staleness scheduling). */
|
|
806
|
-
disabled: boolean;
|
|
807
|
-
/** Cumulative architect tokens, or null if never run. */
|
|
808
|
-
architectTokens: number | null;
|
|
809
|
-
/** Cumulative builder tokens, or null if never run. */
|
|
810
|
-
builderTokens: number | null;
|
|
811
|
-
/** Cumulative critic tokens, or null if never run. */
|
|
812
|
-
criticTokens: number | null;
|
|
813
|
-
/** Number of direct children in the ownership tree. */
|
|
814
|
-
children: number;
|
|
815
|
-
/** The underlying MetaNode from the ownership tree. */
|
|
816
|
-
node: MetaNode;
|
|
817
|
-
/** The parsed meta.json content. */
|
|
818
|
-
meta: MetaJson;
|
|
819
|
-
}
|
|
820
|
-
/** Summary statistics computed from the meta list. */
|
|
821
|
-
interface MetaListSummary {
|
|
822
|
-
total: number;
|
|
823
|
-
stale: number;
|
|
824
|
-
errors: number;
|
|
825
|
-
locked: number;
|
|
826
|
-
disabled: number;
|
|
827
|
-
neverSynthesized: number;
|
|
828
|
-
tokens: {
|
|
829
|
-
architect: number;
|
|
830
|
-
builder: number;
|
|
831
|
-
critic: number;
|
|
832
|
-
};
|
|
833
|
-
stalestPath: string | null;
|
|
834
|
-
lastSynthesizedPath: string | null;
|
|
835
|
-
lastSynthesizedAt: string | null;
|
|
836
|
-
}
|
|
837
|
-
/** Full result from listMetas(). */
|
|
838
|
-
interface MetaListResult {
|
|
839
|
-
summary: MetaListSummary;
|
|
840
|
-
entries: MetaEntry[];
|
|
841
|
-
tree: OwnershipTree;
|
|
842
|
-
}
|
|
843
|
-
/**
|
|
844
|
-
* Discover, deduplicate, and enrich all metas.
|
|
845
|
-
*
|
|
846
|
-
* This is the single consolidated function that replaces all duplicated
|
|
847
|
-
* scan+dedup+enrich logic across the codebase. All enrichment comes from
|
|
848
|
-
* reading meta.json on disk (the canonical source).
|
|
849
|
-
*
|
|
850
|
-
* @param config - Validated synthesis config.
|
|
851
|
-
* @param watcher - Watcher HTTP client for discovery.
|
|
852
|
-
* @returns Enriched meta list with summary statistics and ownership tree.
|
|
853
|
-
*/
|
|
854
|
-
declare function listMetas(config: MetaConfig, watcher: WatcherClient): Promise<MetaListResult>;
|
|
855
|
-
|
|
856
|
-
/**
|
|
857
|
-
* Discover .meta/ directories via watcher `/walk` endpoint.
|
|
858
|
-
*
|
|
859
|
-
* Uses filesystem enumeration through the watcher (not Qdrant) to find
|
|
860
|
-
* all `.meta/meta.json` files and returns deduplicated meta directory paths.
|
|
861
|
-
*
|
|
862
|
-
* @module discovery/discoverMetas
|
|
863
|
-
*/
|
|
864
|
-
|
|
865
|
-
/**
|
|
866
|
-
* Discover all .meta/ directories via watcher walk.
|
|
867
|
-
*
|
|
868
|
-
* Uses the watcher's `/walk` endpoint to find all `.meta/meta.json` files
|
|
869
|
-
* and returns deduplicated meta directory paths.
|
|
870
|
-
*
|
|
871
|
-
* @param watcher - WatcherClient for walk queries.
|
|
872
|
-
* @returns Array of normalized .meta/ directory paths.
|
|
873
|
-
*/
|
|
874
|
-
declare function discoverMetas(watcher: WatcherClient): Promise<string[]>;
|
|
875
|
-
|
|
876
|
-
/**
|
|
877
|
-
* Build the ownership tree from discovered .meta/ paths.
|
|
878
|
-
*
|
|
879
|
-
* Each .meta/ directory owns its parent directory and all descendants,
|
|
880
|
-
* except subtrees that contain their own .meta/. For those subtrees,
|
|
881
|
-
* the parent meta consumes the child meta's synthesis output.
|
|
882
|
-
*
|
|
883
|
-
* @module discovery/ownershipTree
|
|
884
|
-
*/
|
|
885
|
-
|
|
886
|
-
/**
|
|
887
|
-
* Build an ownership tree from an array of .meta/ directory paths.
|
|
888
|
-
*
|
|
889
|
-
* @param metaPaths - Absolute paths to .meta/ directories.
|
|
890
|
-
* @returns The ownership tree with parent/child relationships.
|
|
891
|
-
*/
|
|
892
|
-
declare function buildOwnershipTree(metaPaths: string[]): OwnershipTree;
|
|
893
|
-
/**
|
|
894
|
-
* Find a node in the ownership tree by meta path or owner path.
|
|
895
|
-
*
|
|
896
|
-
* @param tree - The ownership tree to search.
|
|
897
|
-
* @param targetPath - Path to search for (meta path or owner path).
|
|
898
|
-
* @returns The matching node, or undefined if not found.
|
|
899
|
-
*/
|
|
900
|
-
declare function findNode(tree: OwnershipTree, targetPath: string): MetaNode | undefined;
|
|
901
|
-
|
|
902
|
-
/**
|
|
903
|
-
* Pino logger factory.
|
|
904
|
-
*
|
|
905
|
-
* @module logger
|
|
906
|
-
*/
|
|
907
|
-
|
|
908
|
-
/** Minimal logger interface accepted by library functions. */
|
|
909
|
-
interface MinimalLogger {
|
|
910
|
-
debug: (obj: Record<string, unknown>, msg: string) => void;
|
|
911
|
-
info: (obj: Record<string, unknown>, msg: string) => void;
|
|
912
|
-
warn: (obj: Record<string, unknown>, msg: string) => void;
|
|
913
|
-
error: (obj: Record<string, unknown>, msg: string) => void;
|
|
914
|
-
}
|
|
915
|
-
/** Logger configuration options. */
|
|
916
|
-
interface LoggerConfig {
|
|
917
|
-
/** Log level (default: 'info'). */
|
|
918
|
-
level?: string;
|
|
919
|
-
/** Optional file path to write logs to. */
|
|
920
|
-
file?: string;
|
|
921
|
-
}
|
|
922
|
-
/**
|
|
923
|
-
* Create a pino logger instance.
|
|
924
|
-
*
|
|
925
|
-
* @param config - Optional logger configuration.
|
|
926
|
-
* @returns Configured pino logger.
|
|
927
|
-
*/
|
|
928
|
-
declare function createLogger(config?: LoggerConfig): pino.Logger;
|
|
929
|
-
|
|
930
|
-
/**
|
|
931
|
-
* Compute the file scope owned by a meta node.
|
|
932
|
-
*
|
|
933
|
-
* A meta owns: parent dir + all descendants, minus:
|
|
934
|
-
* - Its own .meta/ subtree (outputs, not inputs)
|
|
935
|
-
* - Child meta ownerPath subtrees (except their .meta/meta.json for rollups)
|
|
936
|
-
*
|
|
937
|
-
* All filesystem enumeration delegated to the watcher's `/walk` endpoint.
|
|
938
|
-
*
|
|
939
|
-
* @module discovery/scope
|
|
940
|
-
*/
|
|
941
|
-
|
|
942
|
-
/**
|
|
943
|
-
* Get the scope path prefix for a meta node.
|
|
944
|
-
*/
|
|
945
|
-
declare function getScopePrefix(node: MetaNode): string;
|
|
946
|
-
/**
|
|
947
|
-
* Filter a list of file paths to only those in scope for a meta node.
|
|
948
|
-
*
|
|
949
|
-
* Excludes:
|
|
950
|
-
* - The node's own .meta/ subtree (synthesis outputs are not scope inputs)
|
|
951
|
-
* - Child meta ownerPath subtrees (except child .meta/meta.json for rollups)
|
|
952
|
-
*
|
|
953
|
-
* Watcher walk returns normalized forward-slash paths.
|
|
954
|
-
*/
|
|
955
|
-
declare function filterInScope(node: MetaNode, files: string[]): string[];
|
|
956
|
-
|
|
957
|
-
/**
|
|
958
|
-
* Exponential moving average helper for token tracking.
|
|
959
|
-
*
|
|
960
|
-
* @module ema
|
|
961
|
-
*/
|
|
962
|
-
/**
|
|
963
|
-
* Compute exponential moving average.
|
|
964
|
-
*
|
|
965
|
-
* @param current - New observation.
|
|
966
|
-
* @param previous - Previous EMA value, or undefined for first observation.
|
|
967
|
-
* @param decay - Decay factor (0-1). Higher = more weight on new value. Default 0.3.
|
|
968
|
-
* @returns Updated EMA.
|
|
969
|
-
*/
|
|
970
|
-
declare function computeEma(current: number, previous: number | undefined, decay?: number): number;
|
|
971
|
-
|
|
972
|
-
/**
|
|
973
|
-
* Shared error utilities.
|
|
974
|
-
*
|
|
975
|
-
* @module errors
|
|
976
|
-
*/
|
|
977
|
-
|
|
978
|
-
/**
|
|
979
|
-
* Wrap an unknown caught value into a MetaError.
|
|
980
|
-
*
|
|
981
|
-
* @param step - Which synthesis step failed.
|
|
982
|
-
* @param err - The caught error value.
|
|
983
|
-
* @param code - Error classification code.
|
|
984
|
-
* @returns A structured MetaError.
|
|
985
|
-
*/
|
|
986
|
-
declare function toMetaError(step: MetaError['step'], err: unknown, code?: string): MetaError;
|
|
987
|
-
|
|
988
|
-
/**
|
|
989
|
-
* File-system lock for preventing concurrent synthesis on the same meta.
|
|
990
|
-
*
|
|
991
|
-
* Lock file: .meta/.lock containing `_lockPid` + `_lockStartedAt` (underscore-prefixed
|
|
992
|
-
* reserved keys, consistent with meta.json conventions).
|
|
993
|
-
* Stale timeout: 30 minutes.
|
|
994
|
-
*
|
|
995
|
-
* @module lock
|
|
996
|
-
*/
|
|
997
|
-
/**
|
|
998
|
-
* Resolve a path to a .meta directory.
|
|
999
|
-
*
|
|
1000
|
-
* If the path already ends with '.meta', returns it as-is.
|
|
1001
|
-
* Otherwise, appends '.meta' as a subdirectory.
|
|
1002
|
-
*
|
|
1003
|
-
* @param inputPath - Path that may or may not end with '.meta'.
|
|
1004
|
-
* @returns The resolved .meta directory path.
|
|
1005
|
-
*/
|
|
1006
|
-
declare function resolveMetaDir(inputPath: string): string;
|
|
1007
|
-
/** Parsed state of a .lock file. */
|
|
1008
|
-
interface LockState {
|
|
1009
|
-
/** Whether the lock file exists. */
|
|
1010
|
-
exists: boolean;
|
|
1011
|
-
/** Whether the lock contains a staged synthesis result. */
|
|
1012
|
-
staged: boolean;
|
|
1013
|
-
/** Whether the lock is actively held (non-stale PID lock). */
|
|
1014
|
-
active: boolean;
|
|
1015
|
-
/** Raw parsed data, or null if missing/corrupt. */
|
|
1016
|
-
data: Record<string, unknown> | null;
|
|
1017
|
-
}
|
|
1018
|
-
/**
|
|
1019
|
-
* Read and classify the state of a .meta/.lock file.
|
|
1020
|
-
*
|
|
1021
|
-
* @param metaPath - Absolute path to the .meta directory.
|
|
1022
|
-
* @returns Parsed lock state.
|
|
1023
|
-
*/
|
|
1024
|
-
declare function readLockState(metaPath: string): LockState;
|
|
1025
|
-
/**
|
|
1026
|
-
* Attempt to acquire a lock on a .meta directory.
|
|
1027
|
-
*
|
|
1028
|
-
* @param metaPath - Absolute path to the .meta directory.
|
|
1029
|
-
* @returns True if lock was acquired, false if already locked (non-stale).
|
|
1030
|
-
*/
|
|
1031
|
-
declare function acquireLock(metaPath: string): boolean;
|
|
1032
|
-
/**
|
|
1033
|
-
* Release a lock on a .meta directory.
|
|
1034
|
-
*
|
|
1035
|
-
* @param metaPath - Absolute path to the .meta directory.
|
|
1036
|
-
*/
|
|
1037
|
-
declare function releaseLock(metaPath: string): void;
|
|
1038
|
-
/**
|
|
1039
|
-
* Check if a .meta directory is currently locked (non-stale).
|
|
1040
|
-
*
|
|
1041
|
-
* @param metaPath - Absolute path to the .meta directory.
|
|
1042
|
-
* @returns True if locked and not stale.
|
|
1043
|
-
*/
|
|
1044
|
-
declare function isLocked(metaPath: string): boolean;
|
|
1045
|
-
/**
|
|
1046
|
-
* Clean up stale lock files on startup.
|
|
1047
|
-
*
|
|
1048
|
-
* For each .meta directory found via the provided paths:
|
|
1049
|
-
* - If lock contains PID-only data (synthesis incomplete), delete it.
|
|
1050
|
-
* - If lock contains staged result (_id present), log warning and delete.
|
|
1051
|
-
*
|
|
1052
|
-
* @param metaPaths - Array of .meta directory paths to check.
|
|
1053
|
-
* @param logger - Optional logger for warnings.
|
|
1054
|
-
*/
|
|
1055
|
-
declare function cleanupStaleLocks(metaPaths: string[], logger?: {
|
|
1056
|
-
warn: (obj: Record<string, unknown>, msg: string) => void;
|
|
1057
|
-
}): void;
|
|
1058
|
-
|
|
1059
|
-
/**
|
|
1060
|
-
* Normalize file paths to forward slashes for consistency with watcher-indexed paths.
|
|
1061
|
-
*
|
|
1062
|
-
* Watcher indexes paths with forward slashes (`j:/domains/...`). This utility
|
|
1063
|
-
* ensures all paths in the library use the same convention, regardless of
|
|
1064
|
-
* the platform's native separator.
|
|
1065
|
-
*
|
|
1066
|
-
* @module normalizePath
|
|
1067
|
-
*/
|
|
1068
|
-
/**
|
|
1069
|
-
* Normalize a file path to forward slashes.
|
|
1070
|
-
*
|
|
1071
|
-
* @param p - File path (may contain backslashes).
|
|
1072
|
-
* @returns Path with all backslashes replaced by forward slashes.
|
|
1073
|
-
*/
|
|
1074
|
-
declare function normalizePath(p: string): string;
|
|
1075
|
-
|
|
1076
|
-
/**
|
|
1077
|
-
* Compute a structure hash from a sorted file listing.
|
|
1078
|
-
*
|
|
1079
|
-
* Used to detect when directory structure changes, triggering
|
|
1080
|
-
* an architect re-run.
|
|
1081
|
-
*
|
|
1082
|
-
* @module structureHash
|
|
1083
|
-
*/
|
|
1084
|
-
/**
|
|
1085
|
-
* Compute a SHA-256 hash of a sorted file listing.
|
|
1086
|
-
*
|
|
1087
|
-
* @param filePaths - Array of file paths in scope.
|
|
1088
|
-
* @returns Hex-encoded SHA-256 hash of the sorted, newline-joined paths.
|
|
1089
|
-
*/
|
|
1090
|
-
declare function computeStructureHash(filePaths: string[]): string;
|
|
1091
|
-
|
|
1092
|
-
/**
|
|
1093
|
-
* MetaExecutor implementation using the OpenClaw gateway HTTP API.
|
|
1094
|
-
*
|
|
1095
|
-
* Lives in the library package so both plugin and runner can import it.
|
|
1096
|
-
* Spawns sub-agent sessions via the gateway's `/tools/invoke` endpoint,
|
|
1097
|
-
* polls for completion, and extracts output text.
|
|
1098
|
-
*
|
|
1099
|
-
* @module executor/GatewayExecutor
|
|
1100
|
-
*/
|
|
1101
|
-
|
|
1102
|
-
/** Options for the GatewayExecutor. */
|
|
1103
|
-
interface GatewayExecutorOptions {
|
|
1104
|
-
/** OpenClaw gateway base URL. Default: http://127.0.0.1:18789 */
|
|
1105
|
-
gatewayUrl?: string;
|
|
1106
|
-
/** Bearer token for gateway authentication. */
|
|
1107
|
-
apiKey?: string;
|
|
1108
|
-
/** Polling interval in ms. Default: 5000. */
|
|
1109
|
-
pollIntervalMs?: number;
|
|
1110
|
-
/** Workspace directory for output staging. Default: OS temp dir + /jeeves-meta. */
|
|
1111
|
-
workspaceDir?: string;
|
|
1112
|
-
}
|
|
1113
|
-
/**
|
|
1114
|
-
* MetaExecutor that spawns OpenClaw sessions via the gateway's
|
|
1115
|
-
* `/tools/invoke` endpoint.
|
|
1116
|
-
*
|
|
1117
|
-
* Used by both the OpenClaw plugin (in-process tool calls) and the
|
|
1118
|
-
* runner/CLI (external invocation). Constructs from `gatewayUrl` and
|
|
1119
|
-
* optional `apiKey` — typically sourced from `MetaConfig`.
|
|
1120
|
-
*/
|
|
1121
|
-
declare class GatewayExecutor implements MetaExecutor {
|
|
1122
|
-
private readonly gatewayUrl;
|
|
1123
|
-
private readonly apiKey;
|
|
1124
|
-
private readonly pollIntervalMs;
|
|
1125
|
-
private readonly workspaceDir;
|
|
1126
|
-
private controller;
|
|
1127
|
-
constructor(options?: GatewayExecutorOptions);
|
|
1128
|
-
/** Remove a temp output file if it exists. */
|
|
1129
|
-
private cleanupOutputFile;
|
|
1130
|
-
/** Invoke a gateway tool via the /tools/invoke HTTP endpoint. */
|
|
1131
|
-
private invoke;
|
|
1132
|
-
/** Look up totalTokens for a session via sessions_list. */
|
|
1133
|
-
private getSessionTokens;
|
|
1134
|
-
/** Whether this executor has been aborted by the operator. */
|
|
1135
|
-
get aborted(): boolean;
|
|
1136
|
-
/** Abort the currently running spawn, if any. */
|
|
1137
|
-
abort(): void;
|
|
1138
|
-
spawn(task: string, options?: MetaSpawnOptions): Promise<MetaSpawnResult>;
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
/**
|
|
1142
|
-
* Build task prompts for each synthesis step.
|
|
1143
|
-
*
|
|
1144
|
-
* Prompts are compiled as Handlebars templates with access to config,
|
|
1145
|
-
* meta, and scope context. The architect can write template expressions
|
|
1146
|
-
* into its _builder output; these resolve when the builder task is compiled.
|
|
1147
|
-
*
|
|
1148
|
-
* @module orchestrator/buildTask
|
|
1149
|
-
*/
|
|
1150
|
-
|
|
1151
|
-
/**
|
|
1152
|
-
* Build the architect task prompt.
|
|
1153
|
-
*
|
|
1154
|
-
* @param ctx - Synthesis context.
|
|
1155
|
-
* @param meta - Current meta.json.
|
|
1156
|
-
* @param config - Synthesis config.
|
|
1157
|
-
* @returns The architect task prompt string.
|
|
1158
|
-
*/
|
|
1159
|
-
declare function buildArchitectTask(ctx: MetaContext, meta: MetaJson, config: MetaConfig): string;
|
|
1160
|
-
/**
|
|
1161
|
-
* Build the builder task prompt.
|
|
1162
|
-
*
|
|
1163
|
-
* @param ctx - Synthesis context.
|
|
1164
|
-
* @param meta - Current meta.json.
|
|
1165
|
-
* @param config - Synthesis config.
|
|
1166
|
-
* @returns The builder task prompt string.
|
|
1167
|
-
*/
|
|
1168
|
-
declare function buildBuilderTask(ctx: MetaContext, meta: MetaJson, config: MetaConfig): string;
|
|
1169
|
-
/**
|
|
1170
|
-
* Build the critic task prompt.
|
|
1171
|
-
*
|
|
1172
|
-
* @param ctx - Synthesis context.
|
|
1173
|
-
* @param meta - Current meta.json (with _content already set by builder).
|
|
1174
|
-
* @param config - Synthesis config.
|
|
1175
|
-
* @returns The critic task prompt string.
|
|
1176
|
-
*/
|
|
1177
|
-
declare function buildCriticTask(ctx: MetaContext, meta: MetaJson, config: MetaConfig): string;
|
|
1178
|
-
|
|
1179
|
-
/**
|
|
1180
|
-
* Build the MetaContext for a synthesis cycle.
|
|
1181
|
-
*
|
|
1182
|
-
* Computes shared inputs once: scope files, delta files, child meta outputs,
|
|
1183
|
-
* previous content/feedback, steer, and archive paths.
|
|
1184
|
-
*
|
|
1185
|
-
* @module orchestrator/contextPackage
|
|
1186
|
-
*/
|
|
1187
|
-
|
|
1188
|
-
/**
|
|
1189
|
-
* Build the context package for a synthesis cycle.
|
|
1190
|
-
*
|
|
1191
|
-
* @param node - The meta node being synthesized.
|
|
1192
|
-
* @param meta - Current meta.json content.
|
|
1193
|
-
* @param watcher - WatcherClient for scope enumeration.
|
|
1194
|
-
* @returns The computed context package.
|
|
1195
|
-
*/
|
|
1196
|
-
declare function buildContextPackage(node: MetaNode, meta: MetaJson, watcher: WatcherClient, logger?: MinimalLogger): Promise<MetaContext>;
|
|
1197
|
-
|
|
1198
|
-
/**
|
|
1199
|
-
* Parse subprocess outputs for each synthesis step.
|
|
1200
|
-
*
|
|
1201
|
-
* - Architect: returns text \> _builder
|
|
1202
|
-
* - Builder: returns JSON \> _content + structured fields
|
|
1203
|
-
* - Critic: returns text \> _feedback
|
|
1204
|
-
*
|
|
1205
|
-
* @module orchestrator/parseOutput
|
|
1206
|
-
*/
|
|
1207
|
-
/** Parsed builder output. */
|
|
1208
|
-
interface BuilderOutput {
|
|
1209
|
-
/** Narrative synthesis content. */
|
|
1210
|
-
content: string;
|
|
1211
|
-
/** Additional structured fields (non-underscore keys). */
|
|
1212
|
-
fields: Record<string, unknown>;
|
|
1213
|
-
/** Opaque state for progressive synthesis, if provided by the builder. */
|
|
1214
|
-
state?: unknown;
|
|
1215
|
-
}
|
|
1216
|
-
/**
|
|
1217
|
-
* Parse architect output. The architect returns a task brief as text.
|
|
1218
|
-
*
|
|
1219
|
-
* @param output - Raw subprocess output.
|
|
1220
|
-
* @returns The task brief string.
|
|
1221
|
-
*/
|
|
1222
|
-
declare function parseArchitectOutput(output: string): string;
|
|
1223
|
-
/**
|
|
1224
|
-
* Parse builder output. The builder returns JSON with _content and optional fields.
|
|
1225
|
-
*
|
|
1226
|
-
* Attempts JSON parse first. If that fails, treats the entire output as _content.
|
|
1227
|
-
*
|
|
1228
|
-
* @param output - Raw subprocess output.
|
|
1229
|
-
* @returns Parsed builder output with content and structured fields.
|
|
1230
|
-
*/
|
|
1231
|
-
declare function parseBuilderOutput(output: string): BuilderOutput;
|
|
1232
|
-
/**
|
|
1233
|
-
* Parse critic output. The critic returns evaluation text.
|
|
1234
|
-
*
|
|
1235
|
-
* @param output - Raw subprocess output.
|
|
1236
|
-
* @returns The feedback string.
|
|
1237
|
-
*/
|
|
1238
|
-
declare function parseCriticOutput(output: string): string;
|
|
1239
|
-
|
|
1240
|
-
/**
|
|
1241
|
-
* Merge synthesis results into meta.json.
|
|
1242
|
-
*
|
|
1243
|
-
* Preserves human-set fields (_id, _steer, _depth).
|
|
1244
|
-
* Writes engine fields (_generatedAt, _structureHash, etc.).
|
|
1245
|
-
* Validates against schema before writing.
|
|
1246
|
-
*
|
|
1247
|
-
* @module orchestrator/merge
|
|
1248
|
-
*/
|
|
1249
|
-
|
|
1250
|
-
/** Options for merging synthesis results. */
|
|
1251
|
-
interface MergeOptions {
|
|
1252
|
-
/** Path to .meta directory. */
|
|
1253
|
-
metaPath: string;
|
|
1254
|
-
/** Current meta.json content. */
|
|
1255
|
-
current: MetaJson;
|
|
1256
|
-
/** Architect prompt used (or existing). */
|
|
1257
|
-
architect: string;
|
|
1258
|
-
/** Builder task brief (new or cached). */
|
|
1259
|
-
builder: string;
|
|
1260
|
-
/** Critic prompt used (or existing). */
|
|
1261
|
-
critic: string;
|
|
1262
|
-
/** Builder output (content + structured fields), or null if builder failed. */
|
|
1263
|
-
builderOutput: BuilderOutput | null;
|
|
1264
|
-
/** Critic feedback, or null if critic failed. */
|
|
1265
|
-
feedback: string | null;
|
|
1266
|
-
/** New structure hash. */
|
|
1267
|
-
structureHash: string;
|
|
1268
|
-
/** New synthesis count. */
|
|
1269
|
-
synthesisCount: number;
|
|
1270
|
-
/** Error from any step, or null on full success. */
|
|
1271
|
-
error: MetaError | null;
|
|
1272
|
-
/** Token count from architect step. */
|
|
1273
|
-
architectTokens?: number;
|
|
1274
|
-
/** Token count from builder step. */
|
|
1275
|
-
builderTokens?: number;
|
|
1276
|
-
/** Token count from critic step. */
|
|
1277
|
-
criticTokens?: number;
|
|
1278
|
-
/** Override output path (default: metaPath/meta.json). Used for lock staging. */
|
|
1279
|
-
outputPath?: string;
|
|
1280
|
-
/** Opaque state from builder output for progressive synthesis. */
|
|
1281
|
-
state?: unknown;
|
|
1282
|
-
/**
|
|
1283
|
-
* When true, preserve _content and _generatedAt from current meta.
|
|
1284
|
-
* Used for timeout recovery where state advanced but content did not.
|
|
1285
|
-
*/
|
|
1286
|
-
stateOnly?: boolean;
|
|
1287
|
-
/** Phase state record to persist. */
|
|
1288
|
-
phaseState?: PhaseState;
|
|
1289
|
-
}
|
|
1290
|
-
/**
|
|
1291
|
-
* Merge results into meta.json and write atomically.
|
|
1292
|
-
*
|
|
1293
|
-
* @param options - Merge options.
|
|
1294
|
-
* @returns The updated MetaJson.
|
|
1295
|
-
* @throws If validation fails (malformed output).
|
|
1296
|
-
*/
|
|
1297
|
-
declare function mergeAndWrite(options: MergeOptions): Promise<MetaJson>;
|
|
1298
|
-
|
|
1299
|
-
/**
|
|
1300
|
-
* Progress reporting via OpenClaw gateway `/tools/invoke` → `message` tool.
|
|
1301
|
-
*
|
|
1302
|
-
* @module progress
|
|
1303
|
-
*/
|
|
1304
|
-
|
|
1305
|
-
type ProgressPhase = 'architect' | 'builder' | 'critic';
|
|
1306
|
-
type ProgressEvent = {
|
|
1307
|
-
type: 'synthesis_start' | 'phase_start' | 'phase_complete' | 'synthesis_complete' | 'error';
|
|
1308
|
-
/** Owner path (not .meta path) of the entity being synthesized. */
|
|
1309
|
-
path: string;
|
|
1310
|
-
phase?: ProgressPhase;
|
|
1311
|
-
tokens?: number;
|
|
1312
|
-
durationMs?: number;
|
|
1313
|
-
error?: string;
|
|
1314
|
-
};
|
|
1315
|
-
type ProgressReporterConfig = {
|
|
1316
|
-
gatewayUrl: string;
|
|
1317
|
-
gatewayApiKey?: string;
|
|
1318
|
-
/**
|
|
1319
|
-
* Messaging channel name (e.g. 'slack'). When set alongside reportTarget,
|
|
1320
|
-
* included in the gateway message payload as `channel`.
|
|
1321
|
-
* Legacy: if reportTarget is unset, reportChannel is used as the target
|
|
1322
|
-
* (single-channel mode, backward compatible).
|
|
1323
|
-
*/
|
|
1324
|
-
reportChannel?: string;
|
|
1325
|
-
/** Channel/user ID to send messages to. Takes priority over reportChannel as target. */
|
|
1326
|
-
reportTarget?: string;
|
|
1327
|
-
/** Optional base URL for the service, used to construct entity links. */
|
|
1328
|
-
serverBaseUrl?: string;
|
|
1329
|
-
};
|
|
1330
|
-
declare function formatProgressEvent(event: ProgressEvent, serverBaseUrl?: string): string;
|
|
1331
|
-
declare class ProgressReporter {
|
|
1332
|
-
private readonly config;
|
|
1333
|
-
private readonly logger;
|
|
1334
|
-
constructor(config: ProgressReporterConfig, logger: Logger);
|
|
1335
|
-
report(event: ProgressEvent): Promise<void>;
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
/**
|
|
1339
|
-
* Main orchestration entry point — discovery, scheduling, candidate selection.
|
|
1340
|
-
*
|
|
1341
|
-
* @module orchestrator/orchestrate
|
|
1342
|
-
*/
|
|
1343
|
-
|
|
1344
|
-
/** Callback for synthesis progress events. */
|
|
1345
|
-
type ProgressCallback$1 = (event: ProgressEvent) => void | Promise<void>;
|
|
1346
|
-
/** Result of a single orchestration cycle. */
|
|
1347
|
-
interface OrchestrateResult {
|
|
1348
|
-
/** Whether a synthesis was performed. */
|
|
1349
|
-
synthesized: boolean;
|
|
1350
|
-
/** Path to the meta that was synthesized, if any. */
|
|
1351
|
-
metaPath?: string;
|
|
1352
|
-
/** Error if synthesis failed. */
|
|
1353
|
-
error?: MetaError;
|
|
1354
|
-
}
|
|
1355
|
-
/**
|
|
1356
|
-
* Run a single synthesis cycle.
|
|
1357
|
-
*
|
|
1358
|
-
* Selects the stalest candidate (or a specific target) and runs the
|
|
1359
|
-
* full architect/builder/critic pipeline.
|
|
1360
|
-
*
|
|
1361
|
-
* @param config - Validated synthesis config.
|
|
1362
|
-
* @param executor - Pluggable LLM executor.
|
|
1363
|
-
* @param watcher - Watcher HTTP client.
|
|
1364
|
-
* @param targetPath - Optional: specific meta/owner path to synthesize instead of stalest candidate.
|
|
1365
|
-
* @returns Array with a single result.
|
|
1366
|
-
*/
|
|
1367
|
-
declare function orchestrate(config: MetaConfig, executor: MetaExecutor, watcher: WatcherClient, targetPath?: string, onProgress?: ProgressCallback$1, logger?: MinimalLogger): Promise<OrchestrateResult[]>;
|
|
1368
|
-
|
|
1369
|
-
/**
|
|
1370
|
-
* Per-phase executors for the phase-state machine.
|
|
1371
|
-
*
|
|
1372
|
-
* Each function runs exactly one phase on one meta, updates _phaseState
|
|
1373
|
-
* via pure transitions, and persists via the lock-staged write.
|
|
1374
|
-
*
|
|
1375
|
-
* @module orchestrator/runPhase
|
|
1376
|
-
*/
|
|
1377
|
-
|
|
1378
|
-
/** Callback for synthesis progress events. */
|
|
1379
|
-
type ProgressCallback = (event: ProgressEvent) => void | Promise<void>;
|
|
1380
|
-
/** Result of running a single phase. */
|
|
1381
|
-
interface PhaseResult {
|
|
1382
|
-
/** Whether the phase executed (vs. was skipped). */
|
|
1383
|
-
executed: boolean;
|
|
1384
|
-
/** Updated phase state after execution. */
|
|
1385
|
-
phaseState: PhaseState;
|
|
1386
|
-
/** Updated meta.json content (if written). */
|
|
1387
|
-
updatedMeta?: MetaJson;
|
|
1388
|
-
/** Error if the phase failed. */
|
|
1389
|
-
error?: MetaError;
|
|
1390
|
-
/** Whether the full cycle is now complete (all phases fresh). */
|
|
1391
|
-
cycleComplete?: boolean;
|
|
1392
|
-
}
|
|
1393
|
-
declare function runArchitect(node: MetaNode, currentMeta: MetaJson, phaseState: PhaseState, config: MetaConfig, executor: MetaExecutor, watcher: WatcherClient, structureHash: string, onProgress?: ProgressCallback, logger?: MinimalLogger): Promise<PhaseResult>;
|
|
1394
|
-
declare function runBuilder(node: MetaNode, currentMeta: MetaJson, phaseState: PhaseState, config: MetaConfig, executor: MetaExecutor, watcher: WatcherClient, structureHash: string, onProgress?: ProgressCallback, logger?: MinimalLogger): Promise<PhaseResult>;
|
|
1395
|
-
declare function runCritic(node: MetaNode, currentMeta: MetaJson, phaseState: PhaseState, config: MetaConfig, executor: MetaExecutor, watcher: WatcherClient, structureHash: string, onProgress?: ProgressCallback, logger?: MinimalLogger): Promise<PhaseResult>;
|
|
1396
|
-
|
|
1397
|
-
/**
|
|
1398
|
-
* Phase-aware orchestration entry point.
|
|
1399
|
-
*
|
|
1400
|
-
* Replaces the old staleness-based orchestrate() with phase-state-machine
|
|
1401
|
-
* scheduling: each tick discovers all metas, computes invalidation,
|
|
1402
|
-
* auto-retries failed phases, selects the best phase candidate, and
|
|
1403
|
-
* executes exactly one phase.
|
|
1404
|
-
*
|
|
1405
|
-
* @module orchestrator/orchestratePhase
|
|
1406
|
-
*/
|
|
1407
|
-
|
|
1408
|
-
/** Callback for synthesis progress events. */
|
|
1409
|
-
type PhaseProgressCallback = (event: ProgressEvent) => void | Promise<void>;
|
|
1410
|
-
/** Result of a single phase-aware orchestration tick. */
|
|
1411
|
-
interface OrchestratePhaseResult {
|
|
1412
|
-
/** Whether a phase was executed. */
|
|
1413
|
-
executed: boolean;
|
|
1414
|
-
/** Path to the meta that was selected. */
|
|
1415
|
-
metaPath?: string;
|
|
1416
|
-
/** Which phase was run. */
|
|
1417
|
-
phase?: PhaseName;
|
|
1418
|
-
/** The phase result (if executed). */
|
|
1419
|
-
phaseResult?: PhaseResult;
|
|
1420
|
-
/** Whether a full synthesis cycle completed (all phases fresh). */
|
|
1421
|
-
cycleComplete?: boolean;
|
|
1422
|
-
}
|
|
1423
|
-
/**
|
|
1424
|
-
* Run a single phase-aware orchestration tick.
|
|
1425
|
-
*
|
|
1426
|
-
* When targetPath is provided (override entry), runs the owed phase for
|
|
1427
|
-
* that specific meta. Otherwise, discovers all metas, computes invalidation,
|
|
1428
|
-
* and selects the best phase candidate corpus-wide.
|
|
1429
|
-
*/
|
|
1430
|
-
declare function orchestratePhase(config: MetaConfig, executor: MetaExecutor, watcher: WatcherClient, targetPath?: string, onProgress?: PhaseProgressCallback, logger?: MinimalLogger): Promise<OrchestratePhaseResult>;
|
|
1431
|
-
|
|
1432
|
-
/**
|
|
1433
|
-
* Weighted staleness formula for candidate selection.
|
|
1434
|
-
*
|
|
1435
|
-
* effectiveStaleness = actualStaleness * (normalizedDepth + 1) ^ (depthWeight * emphasis)
|
|
1436
|
-
*
|
|
1437
|
-
* @module scheduling/weightedFormula
|
|
1438
|
-
*/
|
|
1439
|
-
|
|
1440
|
-
/** A candidate meta with computed staleness. */
|
|
1441
|
-
interface StalenessCandidate {
|
|
1442
|
-
/** The meta node. */
|
|
1443
|
-
node: MetaNode;
|
|
1444
|
-
/** Current meta.json content. */
|
|
1445
|
-
meta: MetaJson;
|
|
1446
|
-
/** Actual staleness in seconds. */
|
|
1447
|
-
actualStaleness: number;
|
|
1448
|
-
/** Effective staleness after depth weighting. */
|
|
1449
|
-
effectiveStaleness: number;
|
|
1450
|
-
}
|
|
1451
|
-
/**
|
|
1452
|
-
* Compute effective staleness for a set of candidates.
|
|
1453
|
-
*
|
|
1454
|
-
* Normalizes depths so the minimum becomes 0, then applies the formula:
|
|
1455
|
-
* effectiveStaleness = actualStaleness * (normalizedDepth + 1) ^ (depthWeight * emphasis)
|
|
1456
|
-
*
|
|
1457
|
-
* Per-meta _emphasis (default 1) multiplies depthWeight, allowing individual
|
|
1458
|
-
* metas to tune how much their tree position affects scheduling.
|
|
1459
|
-
*
|
|
1460
|
-
* @param candidates - Array of \{ node, meta, actualStaleness \}.
|
|
1461
|
-
* @param depthWeight - Exponent for depth weighting (0 = pure staleness).
|
|
1462
|
-
* @returns Same array with effectiveStaleness computed.
|
|
1463
|
-
*/
|
|
1464
|
-
declare function computeEffectiveStaleness(candidates: Array<{
|
|
1465
|
-
node: MetaNode;
|
|
1466
|
-
meta: MetaJson;
|
|
1467
|
-
actualStaleness: number;
|
|
1468
|
-
}>, depthWeight: number): StalenessCandidate[];
|
|
1469
|
-
|
|
1470
|
-
/**
|
|
1471
|
-
* Select the best synthesis candidate from stale metas.
|
|
1472
|
-
*
|
|
1473
|
-
* Picks the meta with highest effective staleness.
|
|
1474
|
-
*
|
|
1475
|
-
* @module scheduling/selectCandidate
|
|
1476
|
-
*/
|
|
1477
|
-
|
|
1478
|
-
/**
|
|
1479
|
-
* Select the candidate with the highest effective staleness.
|
|
1480
|
-
*
|
|
1481
|
-
* @param candidates - Array of candidates with computed effective staleness.
|
|
1482
|
-
* @returns The winning candidate, or null if no candidates.
|
|
1483
|
-
*/
|
|
1484
|
-
declare function selectCandidate(candidates: StalenessCandidate[]): StalenessCandidate | null;
|
|
1485
|
-
|
|
1486
|
-
/**
|
|
1487
|
-
* Staleness detection via watcher walk.
|
|
1488
|
-
*
|
|
1489
|
-
* A meta is stale when any watched file in its scope was modified after
|
|
1490
|
-
* `_generatedAt`.
|
|
1491
|
-
*
|
|
1492
|
-
* @module scheduling/staleness
|
|
1493
|
-
*/
|
|
1494
|
-
|
|
1495
|
-
/**
|
|
1496
|
-
* Check if a meta is stale.
|
|
1497
|
-
*
|
|
1498
|
-
* Uses watcher `/walk` to enumerate watched files under the scope prefix,
|
|
1499
|
-
* then applies a local mtime check (fast) to detect any modifications since
|
|
1500
|
-
* `_generatedAt`. Short-circuits on first match.
|
|
1501
|
-
*
|
|
1502
|
-
* @param scopePrefix - Path prefix for this meta's scope.
|
|
1503
|
-
* @param meta - Current meta.json content.
|
|
1504
|
-
* @param watcher - WatcherClient instance.
|
|
1505
|
-
* @returns True if any file in scope was modified after `_generatedAt`.
|
|
1506
|
-
*/
|
|
1507
|
-
declare function isStale(scopePrefix: string, meta: MetaJson, watcher: WatcherClient): Promise<boolean>;
|
|
1508
|
-
/** Maximum staleness for never-synthesized metas (1 year in seconds). */
|
|
1509
|
-
declare const MAX_STALENESS_SECONDS: number;
|
|
1510
|
-
/**
|
|
1511
|
-
* Compute actual staleness in seconds (now minus _generatedAt).
|
|
1512
|
-
*
|
|
1513
|
-
* Never-synthesized metas are capped at {@link MAX_STALENESS_SECONDS}
|
|
1514
|
-
* (1 year) so that depth weighting can differentiate them. Without
|
|
1515
|
-
* bounding, `Infinity * depthFactor` = `Infinity` for all depths.
|
|
1516
|
-
*
|
|
1517
|
-
* @param meta - Current meta.json content.
|
|
1518
|
-
* @returns Staleness in seconds, capped at 1 year for never-synthesized metas.
|
|
1519
|
-
*/
|
|
1520
|
-
declare function actualStaleness(meta: MetaJson): number;
|
|
1521
|
-
/**
|
|
1522
|
-
* Check whether the architect step should be triggered.
|
|
1523
|
-
*
|
|
1524
|
-
* @param meta - Current meta.json.
|
|
1525
|
-
* @param structureChanged - Whether the structure hash changed.
|
|
1526
|
-
* @param steerChanged - Whether the steer directive changed.
|
|
1527
|
-
* @param architectEvery - Config: run architect every N cycles.
|
|
1528
|
-
* @returns True if the architect step should run.
|
|
1529
|
-
*/
|
|
1530
|
-
declare function isArchitectTriggered(meta: MetaJson, structureChanged: boolean, steerChanged: boolean, architectEvery: number): boolean;
|
|
1531
|
-
/**
|
|
1532
|
-
* Detect whether the steer directive changed since the last archive.
|
|
1533
|
-
*
|
|
1534
|
-
* @param currentSteer - Current _steer value (or undefined).
|
|
1535
|
-
* @param archiveSteer - Archive _steer value (or undefined).
|
|
1536
|
-
* @param hasArchive - Whether an archive snapshot exists.
|
|
1537
|
-
* @returns True if steer changed.
|
|
1538
|
-
*/
|
|
1539
|
-
declare function hasSteerChanged(currentSteer: string | undefined, archiveSteer: string | undefined, hasArchive: boolean): boolean;
|
|
1540
|
-
|
|
1541
|
-
/**
|
|
1542
|
-
* Route registration for jeeves-meta service.
|
|
1543
|
-
*
|
|
1544
|
-
* @module routes
|
|
1545
|
-
*/
|
|
1546
|
-
|
|
1547
|
-
/** Runtime stats tracked by the service. */
|
|
1548
|
-
interface ServiceStats {
|
|
1549
|
-
totalSyntheses: number;
|
|
1550
|
-
totalTokens: number;
|
|
1551
|
-
totalErrors: number;
|
|
1552
|
-
lastCycleDurationMs: number | null;
|
|
1553
|
-
lastCycleAt: string | null;
|
|
1554
|
-
}
|
|
1555
|
-
/** Dependencies injected into route handlers. */
|
|
1556
|
-
interface RouteDeps {
|
|
1557
|
-
config: ServiceConfig;
|
|
1558
|
-
logger: Logger;
|
|
1559
|
-
queue: SynthesisQueue;
|
|
1560
|
-
watcher: WatcherClient;
|
|
1561
|
-
scheduler: Scheduler | null;
|
|
1562
|
-
stats: ServiceStats;
|
|
1563
|
-
/** Rule registrar for reporting registration state in /status. */
|
|
1564
|
-
registrar?: RuleRegistrar;
|
|
1565
|
-
/** Executor instance for abort support. */
|
|
1566
|
-
executor?: Pick<GatewayExecutor, 'abort'>;
|
|
1567
|
-
/** Set to true during graceful shutdown. */
|
|
1568
|
-
shuttingDown?: boolean;
|
|
1569
|
-
/** Runtime config file path for config-apply. */
|
|
1570
|
-
configPath?: string;
|
|
1571
|
-
}
|
|
1572
|
-
/** Register all HTTP routes on the Fastify instance. */
|
|
1573
|
-
declare function registerRoutes(app: FastifyInstance, deps: RouteDeps): void;
|
|
1574
|
-
|
|
1575
|
-
/**
|
|
1576
|
-
* Post-registration verification of virtual rule application.
|
|
1577
|
-
*
|
|
1578
|
-
* After rules are registered with the watcher, verifies that .meta/meta.json
|
|
1579
|
-
* files are discoverable via watcher walk (which depends on virtual rules
|
|
1580
|
-
* being applied). Logs a warning if expected metas are not found.
|
|
1581
|
-
*
|
|
1582
|
-
* @module rules/verify
|
|
1583
|
-
*/
|
|
1584
|
-
|
|
1585
|
-
/**
|
|
1586
|
-
* Verify that virtual rules are applied to indexed .meta/meta.json files.
|
|
1587
|
-
*
|
|
1588
|
-
* Runs a discovery pass and logs the result. If no metas are found but
|
|
1589
|
-
* the filesystem likely has some, logs a warning suggesting reindex.
|
|
1590
|
-
*
|
|
1591
|
-
* @param watcher - WatcherClient for discovery.
|
|
1592
|
-
* @param logger - Logger for reporting results.
|
|
1593
|
-
* @returns Number of metas discovered.
|
|
1594
|
-
*/
|
|
1595
|
-
declare function verifyRuleApplication(watcher: WatcherClient, logger: MinimalLogger): Promise<number>;
|
|
1596
|
-
|
|
1597
|
-
/** Options for creating the server. */
|
|
1598
|
-
interface ServerOptions {
|
|
1599
|
-
/** Pino logger instance. */
|
|
1600
|
-
logger: Logger;
|
|
1601
|
-
/** Shared route dependencies (mutable — late-bound properties like registrar are set after creation). */
|
|
1602
|
-
deps: RouteDeps;
|
|
1603
|
-
}
|
|
1604
|
-
/**
|
|
1605
|
-
* Create and configure the Fastify server.
|
|
1606
|
-
*
|
|
1607
|
-
* @param options - Server creation options.
|
|
1608
|
-
* @returns Configured Fastify instance (not yet listening).
|
|
1609
|
-
*/
|
|
1610
|
-
declare function createServer(options: ServerOptions): fastify.FastifyInstance<node_http.Server<typeof node_http.IncomingMessage, typeof node_http.ServerResponse>, node_http.IncomingMessage, node_http.ServerResponse<node_http.IncomingMessage>, FastifyBaseLogger, fastify.FastifyTypeProviderDefault> & PromiseLike<fastify.FastifyInstance<node_http.Server<typeof node_http.IncomingMessage, typeof node_http.ServerResponse>, node_http.IncomingMessage, node_http.ServerResponse<node_http.IncomingMessage>, FastifyBaseLogger, fastify.FastifyTypeProviderDefault>> & {
|
|
1611
|
-
__linterBrands: "SafePromiseLike";
|
|
1612
|
-
};
|
|
1613
|
-
|
|
1614
|
-
/**
|
|
1615
|
-
* Graceful shutdown handler.
|
|
1616
|
-
*
|
|
1617
|
-
* On SIGTERM/SIGINT: stops scheduler, drains queue, cleans up locks.
|
|
1618
|
-
*
|
|
1619
|
-
* @module shutdown
|
|
1620
|
-
*/
|
|
1621
|
-
|
|
1622
|
-
interface ShutdownDeps {
|
|
1623
|
-
server: {
|
|
1624
|
-
close: () => Promise<void>;
|
|
1625
|
-
};
|
|
1626
|
-
scheduler: Scheduler | null;
|
|
1627
|
-
queue: SynthesisQueue;
|
|
1628
|
-
logger: Logger;
|
|
1629
|
-
routeDeps?: RouteDeps;
|
|
1630
|
-
/** Optional cleanup callback (e.g., stop health check). */
|
|
1631
|
-
onShutdown?: () => void;
|
|
1632
|
-
}
|
|
1633
|
-
/**
|
|
1634
|
-
* Register shutdown handlers for SIGTERM and SIGINT.
|
|
1635
|
-
*
|
|
1636
|
-
* Flow:
|
|
1637
|
-
* 1. Stop scheduler (no new ticks)
|
|
1638
|
-
* 2. If synthesis in progress, release its lock
|
|
1639
|
-
* 3. Close Fastify server
|
|
1640
|
-
* 4. Exit
|
|
1641
|
-
*/
|
|
1642
|
-
declare function registerShutdownHandlers(deps: ShutdownDeps): void;
|
|
1643
|
-
|
|
1644
|
-
/**
|
|
1645
|
-
* Service bootstrap — wire up all components and start listening.
|
|
1646
|
-
*
|
|
1647
|
-
* @module bootstrap
|
|
1648
|
-
*/
|
|
1649
|
-
|
|
1650
|
-
/**
|
|
1651
|
-
* Bootstrap the service: create logger, build server, start listening,
|
|
1652
|
-
* wire scheduler, queue processing, rule registration, config hot-reload,
|
|
1653
|
-
* startup lock cleanup, and shutdown.
|
|
1654
|
-
*
|
|
1655
|
-
* @param config - Validated service configuration.
|
|
1656
|
-
* @param configPath - Optional path to config file for hot-reload.
|
|
1657
|
-
*/
|
|
1658
|
-
declare function startService(config: ServiceConfig, configPath?: string): Promise<void>;
|
|
1659
|
-
|
|
1660
|
-
export { DEFAULT_PORT, DEFAULT_PORT_STR, GatewayExecutor, HttpWatcherClient, MAX_STALENESS_SECONDS, ProgressReporter, RESTART_REQUIRED_FIELDS, RuleRegistrar, SERVICE_NAME, SERVICE_VERSION, Scheduler, SynthesisQueue, acquireLock, actualStaleness, buildArchitectTask, buildBuilderTask, buildContextPackage, buildCriticTask, buildOwnershipTree, cleanupStaleLocks, computeEffectiveStaleness, computeEma, computeStructureHash, createLogger, createServer, createSnapshot, discoverMetas, filterInScope, findNode, formatProgressEvent, getScopePrefix, hasSteerChanged, isArchitectTriggered, isLocked, isStale, listArchiveFiles, listMetas, loadServiceConfig, mergeAndWrite, metaConfigSchema, metaDescriptor, metaErrorSchema, metaJsonSchema, migrateConfigPath, normalizePath, orchestrate, orchestratePhase, parseArchitectOutput, parseBuilderOutput, parseCriticOutput, pruneArchive, readLatestArchive, readLockState, registerCustomCliCommands, registerRoutes, registerShutdownHandlers, releaseLock, resolveConfigPath, resolveMetaDir, runArchitect, runBuilder, runCritic, selectCandidate, serviceConfigSchema, startService, toMetaError, verifyRuleApplication };
|
|
1661
|
-
export type { BuilderOutput, EnqueueResult, GatewayExecutorOptions, HttpWatcherClientOptions, InferenceRuleSpec, LockState, LoggerConfig, MergeOptions, MetaConfig, MetaContext, MetaEntry, MetaError, MetaExecutor, MetaJson, MetaListResult, MetaListSummary, MetaNode, MetaSpawnOptions, MetaSpawnResult, MinimalLogger, OrchestratePhaseResult, OrchestrateResult, OwnershipTree, PhaseProgressCallback, PhaseResult, ProgressCallback$1 as ProgressCallback, ProgressEvent, ProgressPhase, ProgressReporterConfig, QueueItem, QueueState, RouteDeps, ServerOptions, ServiceConfig, ServiceStats, StalenessCandidate, WatcherClient, WatcherScanPoint, WatcherScanRequest, WatcherScanResult };
|
|
2
|
+
* Jeeves Meta Service — knowledge synthesis HTTP service for the Jeeves platform.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export { createSnapshot, listArchiveFiles, pruneArchive, readLatestArchive, } from './archive/index.js';
|
|
7
|
+
export { DEFAULT_PORT, DEFAULT_PORT_STR, SERVICE_NAME, SERVICE_VERSION, } from './constants.js';
|
|
8
|
+
export { registerCustomCliCommands } from './customCliCommands.js';
|
|
9
|
+
export { metaDescriptor, RESTART_REQUIRED_FIELDS } from './descriptor.js';
|
|
10
|
+
export { loadServiceConfig, migrateConfigPath, resolveConfigPath, } from './configLoader.js';
|
|
11
|
+
export { buildOwnershipTree, discoverMetas, filterInScope, findNode, getScopePrefix, listMetas, type MetaEntry, type MetaListResult, type MetaListSummary, type MetaNode, type OwnershipTree, } from './discovery/index.js';
|
|
12
|
+
export { computeEma } from './ema.js';
|
|
13
|
+
export { toMetaError } from './errors.js';
|
|
14
|
+
export { acquireLock, cleanupStaleLocks, isLocked, type LockState, readLockState, releaseLock, resolveMetaDir, } from './lock.js';
|
|
15
|
+
export { normalizePath } from './normalizePath.js';
|
|
16
|
+
export { computeStructureHash } from './structureHash.js';
|
|
17
|
+
export { GatewayExecutor, type GatewayExecutorOptions, } from './executor/index.js';
|
|
18
|
+
export type { InferenceRuleSpec, MetaContext, MetaExecutor, MetaSpawnOptions, MetaSpawnResult, WatcherClient, WatcherScanPoint, WatcherScanRequest, WatcherScanResult, } from './interfaces/index.js';
|
|
19
|
+
export type { LoggerConfig } from './logger/index.js';
|
|
20
|
+
export { createLogger, type MinimalLogger } from './logger/index.js';
|
|
21
|
+
export { buildArchitectTask, buildBuilderTask, buildContextPackage, buildCriticTask, type BuilderOutput, orchestratePhase, type OrchestratePhaseResult, parseArchitectOutput, parseBuilderOutput, parseCriticOutput, type PhaseProgressCallback, type PhaseResult, runArchitect, runBuilder, runCritic, } from './orchestrator/index.js';
|
|
22
|
+
export { formatProgressEvent, type ProgressEvent, type ProgressPhase, ProgressReporter, type ProgressReporterConfig, } from './progress/index.js';
|
|
23
|
+
export { actualStaleness, computeEffectiveStaleness, hasSteerChanged, isArchitectTriggered, isStale, MAX_STALENESS_SECONDS, type StalenessCandidate, } from './scheduling/index.js';
|
|
24
|
+
export { type MetaConfig, metaConfigSchema, type MetaError, metaErrorSchema, type MetaJson, metaJsonSchema, type ServiceConfig, serviceConfigSchema, } from './schema/index.js';
|
|
25
|
+
export { Scheduler } from './scheduler/index.js';
|
|
26
|
+
export { type EnqueueResult, type QueueItem, type QueueState, SynthesisQueue, } from './queue/index.js';
|
|
27
|
+
export { registerRoutes, type RouteDeps, type ServiceStats, } from './routes/index.js';
|
|
28
|
+
export { RuleRegistrar } from './rules/index.js';
|
|
29
|
+
export { verifyRuleApplication } from './rules/verify.js';
|
|
30
|
+
export { sleepAsync as sleep } from '@karmaniverous/jeeves';
|
|
31
|
+
export type { ServerOptions } from './server.js';
|
|
32
|
+
export { createServer } from './server.js';
|
|
33
|
+
export { registerShutdownHandlers } from './shutdown/index.js';
|
|
34
|
+
export { HttpWatcherClient, type HttpWatcherClientOptions, } from './watcher-client/index.js';
|
|
35
|
+
export { startService } from './bootstrap.js';
|