@seanhogg/builderforce-memory 2026.6.28 → 2026.6.31
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/README.md +28 -0
- package/dist/diagnostics/index.d.ts +7 -0
- package/dist/diagnostics/index.d.ts.map +1 -0
- package/dist/diagnostics/index.js +6 -0
- package/dist/diagnostics/index.js.map +1 -0
- package/dist/diagnostics/stack-diagnostic.d.ts +71 -0
- package/dist/diagnostics/stack-diagnostic.d.ts.map +1 -0
- package/dist/diagnostics/stack-diagnostic.js +43 -0
- package/dist/diagnostics/stack-diagnostic.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/workflow/index.d.ts +11 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/index.js +10 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/registry.d.ts +23 -0
- package/dist/workflow/registry.d.ts.map +1 -0
- package/dist/workflow/registry.js +47 -0
- package/dist/workflow/registry.js.map +1 -0
- package/dist/workflow/run.d.ts +26 -0
- package/dist/workflow/run.d.ts.map +1 -0
- package/dist/workflow/run.js +40 -0
- package/dist/workflow/run.js.map +1 -0
- package/dist/workflow/steps.d.ts +19 -0
- package/dist/workflow/steps.d.ts.map +1 -0
- package/dist/workflow/steps.js +318 -0
- package/dist/workflow/steps.js.map +1 -0
- package/dist/workflow/templates.d.ts +24 -0
- package/dist/workflow/templates.d.ts.map +1 -0
- package/dist/workflow/templates.js +80 -0
- package/dist/workflow/templates.js.map +1 -0
- package/dist/workflow/types.d.ts +38 -0
- package/dist/workflow/types.d.ts.map +1 -0
- package/dist/workflow/types.js +11 -0
- package/dist/workflow/types.js.map +1 -0
- package/package.json +7 -5
- package/src/diagnostics/index.ts +14 -0
- package/src/diagnostics/stack-diagnostic.ts +103 -0
- package/src/index.ts +36 -0
- package/src/workflow/index.ts +24 -0
- package/src/workflow/registry.ts +55 -0
- package/src/workflow/run.ts +58 -0
- package/src/workflow/steps.ts +325 -0
- package/src/workflow/templates.ts +87 -0
- package/src/workflow/types.ts +42 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* workflow/steps.ts — the built-in step types.
|
|
3
|
+
*
|
|
4
|
+
* Two families, both compiling to a runnable {@link StackStep}:
|
|
5
|
+
* • Agent-stack layers (L1..L7) — the diagnostic checks (the 7-layer template).
|
|
6
|
+
* • LLM-creation pipeline (BUILD) — train-tokenizer → train-model → evaluate →
|
|
7
|
+
* package, which produces a trained `.evermind` artifact (a custom LLM) into
|
|
8
|
+
* `ctx.artifacts.evermind`.
|
|
9
|
+
*
|
|
10
|
+
* A custom workflow mixes these freely; new step types register the same way.
|
|
11
|
+
*/
|
|
12
|
+
import { EvermindLM, EvermindLMTrainer, BPETokenizer, EvermindModelPackage, } from "@seanhogg/builderforce-memory-engine";
|
|
13
|
+
import { EvermindCognition } from "../cognition/index.js";
|
|
14
|
+
import { hybridRetrieve, chunkText } from "../retrieval/index.js";
|
|
15
|
+
import { MemoryStore } from "../memory/MemoryStore.js";
|
|
16
|
+
const KNOWLEDGE = "BuilderForce orchestrates many agents through a planning loop. " +
|
|
17
|
+
"The memory layer stores facts as SSM embeddings. " +
|
|
18
|
+
"Deployment runs on Cloudflare Workers and Durable Objects. " +
|
|
19
|
+
"Tools are gated by a capability registry.";
|
|
20
|
+
let dbSeq = 0;
|
|
21
|
+
// ── param readers (configurable per step) ──────────────────────────────────────
|
|
22
|
+
function pStr(cfg, key, def) {
|
|
23
|
+
const v = cfg.params?.[key];
|
|
24
|
+
return typeof v === "string" ? v : def;
|
|
25
|
+
}
|
|
26
|
+
function pNum(cfg, key, def) {
|
|
27
|
+
const v = cfg.params?.[key];
|
|
28
|
+
return typeof v === "number" && Number.isFinite(v) ? v : def;
|
|
29
|
+
}
|
|
30
|
+
function mkStep(cfg, layer, defaultLabel, run) {
|
|
31
|
+
return { id: cfg.id, layer, label: cfg.label ?? defaultLabel, run };
|
|
32
|
+
}
|
|
33
|
+
/** Encode a corpus into next-token training sequences (one per sentence). */
|
|
34
|
+
function corpusToSequences(corpus, tok) {
|
|
35
|
+
return corpus
|
|
36
|
+
.split(/(?<=\.)\s+/)
|
|
37
|
+
.map((s) => tok.encode(s.trim()))
|
|
38
|
+
.filter((ids) => ids.length >= 2);
|
|
39
|
+
}
|
|
40
|
+
export const BUILTIN_STEPS = {
|
|
41
|
+
// ── Agent-stack layers (the diagnostic / 7-layer template) ──────────────────
|
|
42
|
+
foundation: {
|
|
43
|
+
info: { type: "foundation", layer: "L1", label: "Foundation Model", description: "EvermindLM + tokenizer generate text" },
|
|
44
|
+
factory: (cfg) => mkStep(cfg, "L1", "Foundation Model — EvermindLM + tokenizer", async (ctx) => {
|
|
45
|
+
const tok = new BPETokenizer();
|
|
46
|
+
tok.train(KNOWLEDGE.repeat(4), { numMerges: 60 });
|
|
47
|
+
const model = new EvermindLM({ vocabSize: tok.vocabSize, dModel: 16, numLayers: 2, hiddenDim: 24, seed: 7 });
|
|
48
|
+
const out = model.generateText("Deployment", tok, { maxNewTokens: 4, temperature: 0 });
|
|
49
|
+
if (typeof out !== "string")
|
|
50
|
+
throw new Error("model did not produce text");
|
|
51
|
+
if (tok.decode(tok.encode("Cloudflare Workers")) !== "Cloudflare Workers")
|
|
52
|
+
throw new Error("tokenizer did not round-trip text");
|
|
53
|
+
ctx.bag.model = model;
|
|
54
|
+
ctx.bag.tokenizer = tok;
|
|
55
|
+
return `vocab ${tok.vocabSize}, generated ${out.length} chars`;
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
58
|
+
memory: {
|
|
59
|
+
info: { type: "memory", layer: "L3", label: "Memory", description: "Write-through cognition (replace-on-write)" },
|
|
60
|
+
factory: (cfg) => mkStep(cfg, "L3", "Memory — write-through cognition", async (ctx) => {
|
|
61
|
+
const store = new MemoryStore({ dbName: `wf-${ctx.now()}-${dbSeq++}`, idbFactory: ctx.idbFactory });
|
|
62
|
+
const cognition = new EvermindCognition({ store });
|
|
63
|
+
await cognition.commit({ subjectKey: "fact:deploy", content: "deploy target = unknown" });
|
|
64
|
+
const r = await cognition.commit({ subjectKey: "fact:deploy", content: "deploy target = Cloudflare" });
|
|
65
|
+
if (r.verdict !== "supersede")
|
|
66
|
+
throw new Error(`expected supersede, got ${r.verdict}`);
|
|
67
|
+
ctx.bag.cognition = cognition;
|
|
68
|
+
return `verdict ${r.verdict}`;
|
|
69
|
+
}),
|
|
70
|
+
},
|
|
71
|
+
rag: {
|
|
72
|
+
info: { type: "rag", layer: "L4", label: "RAG", description: "Chunk + hybrid (BM25 + dense) retrieve" },
|
|
73
|
+
factory: (cfg) => mkStep(cfg, "L4", "RAG — chunk + hybrid retrieve", async (ctx) => {
|
|
74
|
+
const candidates = chunkText(KNOWLEDGE, { chunkSize: 70, chunkOverlap: 0 }).map((c, i) => ({ id: `c${i}`, text: c.text }));
|
|
75
|
+
const hits = hybridRetrieve({ text: "where does deployment run" }, candidates, { topK: 2 });
|
|
76
|
+
if (hits.length === 0 || !hits[0].text.toLowerCase().includes("cloudflare"))
|
|
77
|
+
throw new Error("retriever did not surface the deployment passage");
|
|
78
|
+
ctx.bag.candidates = candidates;
|
|
79
|
+
return `top hit: ${hits[0].text.slice(0, 40)}…`;
|
|
80
|
+
}),
|
|
81
|
+
},
|
|
82
|
+
tools: {
|
|
83
|
+
info: { type: "tools", layer: "L5", label: "Tools", description: "Capability-gated tool registry" },
|
|
84
|
+
factory: (cfg) => mkStep(cfg, "L5", "Tools — capability-gated registry", async (ctx) => {
|
|
85
|
+
const tools = new Map([["shout", (a) => a.toUpperCase()]]);
|
|
86
|
+
if (tools.get("shout")?.("deploy") !== "DEPLOY")
|
|
87
|
+
throw new Error("tool invocation failed");
|
|
88
|
+
if (tools.get("missing"))
|
|
89
|
+
throw new Error("ungated tool resolved");
|
|
90
|
+
ctx.bag.tools = tools;
|
|
91
|
+
return "1 tool registered + invoked";
|
|
92
|
+
}),
|
|
93
|
+
},
|
|
94
|
+
orchestration: {
|
|
95
|
+
info: { type: "orchestration", layer: "L2", label: "Orchestration", description: "retrieve→recall→act→generate loop" },
|
|
96
|
+
factory: (cfg) => mkStep(cfg, "L2", "Orchestration — retrieve→recall→act→generate", async (ctx) => {
|
|
97
|
+
const model = ctx.bag.model;
|
|
98
|
+
const tokenizer = ctx.bag.tokenizer;
|
|
99
|
+
const cognition = ctx.bag.cognition;
|
|
100
|
+
const candidates = ctx.bag.candidates;
|
|
101
|
+
const tools = ctx.bag.tools;
|
|
102
|
+
if (!model || !tokenizer || !cognition || !candidates || !tools)
|
|
103
|
+
throw new Error("a prerequisite layer (L1/L3/L4/L5) did not complete");
|
|
104
|
+
const steps = [];
|
|
105
|
+
const hits = hybridRetrieve({ text: "deployment cloudflare" }, candidates, { topK: 1 });
|
|
106
|
+
steps.push("retrieve");
|
|
107
|
+
await cognition.recall("deployment", 3);
|
|
108
|
+
steps.push("recall");
|
|
109
|
+
tools.get("shout")(hits[0]?.text ?? "deploy");
|
|
110
|
+
steps.push("tool");
|
|
111
|
+
model.generateText("Deployment", tokenizer, { maxNewTokens: 3, temperature: 0 });
|
|
112
|
+
steps.push("model");
|
|
113
|
+
if (steps.join(",") !== "retrieve,recall,tool,model")
|
|
114
|
+
throw new Error("loop did not complete all stages");
|
|
115
|
+
return steps.join(" → ");
|
|
116
|
+
}),
|
|
117
|
+
},
|
|
118
|
+
observability: {
|
|
119
|
+
info: { type: "observability", layer: "L6", label: "Observability", description: "Trace captured every prior step" },
|
|
120
|
+
factory: (cfg) => mkStep(cfg, "L6", "Observability — trace captured prior steps", async (ctx) => {
|
|
121
|
+
if (ctx.trace.length === 0)
|
|
122
|
+
throw new Error("no spans captured");
|
|
123
|
+
for (const s of ctx.trace) {
|
|
124
|
+
if (typeof s.layer !== "string" || typeof s.status !== "string" || s.ms < 0)
|
|
125
|
+
throw new Error(`malformed span: ${s.id}`);
|
|
126
|
+
}
|
|
127
|
+
return `${ctx.trace.length} spans recorded`;
|
|
128
|
+
}),
|
|
129
|
+
},
|
|
130
|
+
deployment: {
|
|
131
|
+
info: { type: "deployment", layer: "L7", label: "Deployment", description: ".evermind artifact ships + runs identically" },
|
|
132
|
+
factory: (cfg) => mkStep(cfg, "L7", "Deployment — .evermind ships + runs identically", async (ctx) => {
|
|
133
|
+
const model = ctx.bag.model;
|
|
134
|
+
const tokenizer = ctx.bag.tokenizer;
|
|
135
|
+
if (!model || !tokenizer)
|
|
136
|
+
throw new Error("no model from L1 to deploy");
|
|
137
|
+
const before = model.generateText("Deployment", tokenizer, { maxNewTokens: 4, temperature: 0 });
|
|
138
|
+
const blob = EvermindModelPackage.fromLM(model, { name: "stack-demo", version: "1.0.0", card: { description: "diagnostic" } }).toBlob();
|
|
139
|
+
const pkg = EvermindModelPackage.fromBlob(blob);
|
|
140
|
+
if (!pkg.validate().ok)
|
|
141
|
+
throw new Error("packaged artifact failed validation");
|
|
142
|
+
const after = pkg.loadLM().generateText("Deployment", tokenizer, { maxNewTokens: 4, temperature: 0 });
|
|
143
|
+
if (after !== before)
|
|
144
|
+
throw new Error("deployed instance produced different output");
|
|
145
|
+
return `artifact ${blob.byteLength} bytes, output matches`;
|
|
146
|
+
}),
|
|
147
|
+
},
|
|
148
|
+
// ── LLM-creation pipeline (BUILD) — produces a custom .evermind model ────────
|
|
149
|
+
"train-tokenizer": {
|
|
150
|
+
info: { type: "train-tokenizer", layer: "BUILD", label: "Train tokenizer", description: "Learn a BPE vocab from your corpus (params: corpus, numMerges)" },
|
|
151
|
+
factory: (cfg) => mkStep(cfg, "BUILD", "Train tokenizer (BPE)", async (ctx) => {
|
|
152
|
+
const corpus = pStr(cfg, "corpus", KNOWLEDGE.repeat(4));
|
|
153
|
+
const numMerges = pNum(cfg, "numMerges", 100);
|
|
154
|
+
const tok = new BPETokenizer();
|
|
155
|
+
tok.train(corpus, { numMerges });
|
|
156
|
+
ctx.bag.tokenizer = tok;
|
|
157
|
+
ctx.bag.corpus = corpus;
|
|
158
|
+
return `vocab ${tok.vocabSize} (${numMerges} merges)`;
|
|
159
|
+
}),
|
|
160
|
+
},
|
|
161
|
+
"train-model": {
|
|
162
|
+
info: { type: "train-model", layer: "BUILD", label: "Train model", description: "Train an EvermindLM on the corpus (params: dModel, numLayers, hiddenDim, epochs, lr)" },
|
|
163
|
+
factory: (cfg) => mkStep(cfg, "BUILD", "Train model (EvermindLM)", async (ctx) => {
|
|
164
|
+
const tok = ctx.bag.tokenizer;
|
|
165
|
+
if (!tok)
|
|
166
|
+
throw new Error("no tokenizer — add a 'train-tokenizer' step first");
|
|
167
|
+
const corpus = pStr(cfg, "corpus", ctx.bag.corpus ?? KNOWLEDGE.repeat(4));
|
|
168
|
+
const sequences = corpusToSequences(corpus, tok);
|
|
169
|
+
if (sequences.length === 0)
|
|
170
|
+
throw new Error("corpus produced no trainable sequences");
|
|
171
|
+
const model = new EvermindLM({
|
|
172
|
+
vocabSize: tok.vocabSize,
|
|
173
|
+
dModel: pNum(cfg, "dModel", 16),
|
|
174
|
+
numLayers: pNum(cfg, "numLayers", 2),
|
|
175
|
+
hiddenDim: pNum(cfg, "hiddenDim", 24),
|
|
176
|
+
seed: pNum(cfg, "seed", 7),
|
|
177
|
+
});
|
|
178
|
+
const epochs = pNum(cfg, "epochs", 40);
|
|
179
|
+
const history = new EvermindLMTrainer(model, { lr: pNum(cfg, "lr", 0.03), epochs }).fit(sequences);
|
|
180
|
+
ctx.bag.model = model;
|
|
181
|
+
// Surface the loss curve so a `convergence` diagnostic / observability can
|
|
182
|
+
// assert training actually worked (it was previously discarded).
|
|
183
|
+
ctx.bag.trainingHistory = history;
|
|
184
|
+
const last = history.at(-1) ?? 0;
|
|
185
|
+
return `trained ${epochs} epochs over ${sequences.length} seqs, loss ${last.toFixed(3)}`;
|
|
186
|
+
}),
|
|
187
|
+
},
|
|
188
|
+
evaluate: {
|
|
189
|
+
info: { type: "evaluate", layer: "BUILD", label: "Evaluate", description: "Sanity-check the model generates text (params: prompt)" },
|
|
190
|
+
factory: (cfg) => mkStep(cfg, "BUILD", "Evaluate model", async (ctx) => {
|
|
191
|
+
const model = ctx.bag.model;
|
|
192
|
+
const tok = ctx.bag.tokenizer;
|
|
193
|
+
if (!model || !tok)
|
|
194
|
+
throw new Error("no trained model — add 'train-model' first");
|
|
195
|
+
const prompt = pStr(cfg, "prompt", "The");
|
|
196
|
+
const out = model.generateText(prompt, tok, { maxNewTokens: pNum(cfg, "maxNewTokens", 6), temperature: 0 });
|
|
197
|
+
if (typeof out !== "string")
|
|
198
|
+
throw new Error("evaluation generation failed");
|
|
199
|
+
ctx.bag.sample = out;
|
|
200
|
+
return `sample: "${out.slice(0, 40)}"`;
|
|
201
|
+
}),
|
|
202
|
+
},
|
|
203
|
+
"dataset-quality": {
|
|
204
|
+
info: { type: "dataset-quality", layer: "BUILD", label: "Dataset quality", description: "Validate the corpus is trainable before spending epochs (params: minSequences, minWords, maxDuplicateRatio)" },
|
|
205
|
+
factory: (cfg) => mkStep(cfg, "BUILD", "Dataset quality gate", async (ctx) => {
|
|
206
|
+
const tok = ctx.bag.tokenizer;
|
|
207
|
+
if (!tok)
|
|
208
|
+
throw new Error("no tokenizer — add a 'train-tokenizer' step first");
|
|
209
|
+
const corpus = pStr(cfg, "corpus", ctx.bag.corpus ?? "");
|
|
210
|
+
const words = corpus.trim().split(/\s+/).filter(Boolean).length;
|
|
211
|
+
const sequences = corpusToSequences(corpus, tok);
|
|
212
|
+
const seqLens = sequences.map((s) => s.length);
|
|
213
|
+
const avgSeqLen = seqLens.length ? seqLens.reduce((a, b) => a + b, 0) / seqLens.length : 0;
|
|
214
|
+
const uniqueSeqs = new Set(sequences.map((s) => s.join(","))).size;
|
|
215
|
+
const duplicateRatio = sequences.length ? 1 - uniqueSeqs / sequences.length : 1;
|
|
216
|
+
const minSequences = pNum(cfg, "minSequences", 3);
|
|
217
|
+
const minWords = pNum(cfg, "minWords", 20);
|
|
218
|
+
const maxDuplicateRatio = pNum(cfg, "maxDuplicateRatio", 0.7);
|
|
219
|
+
const metrics = { words, sequences: sequences.length, avgSeqLen: Number(avgSeqLen.toFixed(1)), duplicateRatio: Number(duplicateRatio.toFixed(2)) };
|
|
220
|
+
ctx.bag.datasetMetrics = metrics;
|
|
221
|
+
if (words < minWords)
|
|
222
|
+
throw new Error(`corpus too small: ${words} words < ${minWords}`);
|
|
223
|
+
if (sequences.length < minSequences)
|
|
224
|
+
throw new Error(`too few trainable sequences: ${sequences.length} < ${minSequences} (need more sentences)`);
|
|
225
|
+
if (duplicateRatio > maxDuplicateRatio)
|
|
226
|
+
throw new Error(`corpus too repetitive: ${(duplicateRatio * 100) | 0}% duplicate sequences > ${(maxDuplicateRatio * 100) | 0}%`);
|
|
227
|
+
return `${words} words, ${sequences.length} seqs (avg ${metrics.avgSeqLen} tok), ${(duplicateRatio * 100) | 0}% dup`;
|
|
228
|
+
}),
|
|
229
|
+
},
|
|
230
|
+
convergence: {
|
|
231
|
+
info: { type: "convergence", layer: "BUILD", label: "Convergence", description: "Assert the model actually learned — training loss decreased (params: minDrop)" },
|
|
232
|
+
factory: (cfg) => mkStep(cfg, "BUILD", "Training convergence", async (ctx) => {
|
|
233
|
+
const history = ctx.bag.trainingHistory;
|
|
234
|
+
if (!history || history.length === 0)
|
|
235
|
+
throw new Error("no training history — run 'train-model' first");
|
|
236
|
+
const first = history[0];
|
|
237
|
+
const last = history.at(-1);
|
|
238
|
+
if (!Number.isFinite(first) || !Number.isFinite(last))
|
|
239
|
+
throw new Error(`loss is not finite (first=${first}, last=${last}) — training diverged`);
|
|
240
|
+
const minDrop = pNum(cfg, "minDrop", 0); // require at least this absolute loss drop
|
|
241
|
+
if (last >= first - minDrop)
|
|
242
|
+
throw new Error(`loss did not decrease: ${first.toFixed(3)} → ${last.toFixed(3)} (model did not learn — raise epochs/lr)`);
|
|
243
|
+
ctx.bag.converged = true;
|
|
244
|
+
return `loss ${first.toFixed(3)} → ${last.toFixed(3)} (−${(first - last).toFixed(3)})`;
|
|
245
|
+
}),
|
|
246
|
+
},
|
|
247
|
+
"generate-check": {
|
|
248
|
+
info: { type: "generate-check", layer: "BUILD", label: "Generation check", description: "Validate the model generates non-empty, reproducible text (params: prompt, seed, temperature)" },
|
|
249
|
+
factory: (cfg) => mkStep(cfg, "BUILD", "Generation quality + determinism", async (ctx) => {
|
|
250
|
+
const model = ctx.bag.model;
|
|
251
|
+
const tok = ctx.bag.tokenizer;
|
|
252
|
+
if (!model || !tok)
|
|
253
|
+
throw new Error("no trained model — add 'train-model' first");
|
|
254
|
+
const prompt = pStr(cfg, "prompt", "The");
|
|
255
|
+
const maxNewTokens = pNum(cfg, "maxNewTokens", 8);
|
|
256
|
+
const seed = pNum(cfg, "seed", 1234);
|
|
257
|
+
const temperature = pNum(cfg, "temperature", 0.8);
|
|
258
|
+
// Same seed + temperature MUST reproduce — serving relies on it.
|
|
259
|
+
const a = model.generateText(prompt, tok, { maxNewTokens, temperature, seed });
|
|
260
|
+
const b = model.generateText(prompt, tok, { maxNewTokens, temperature, seed });
|
|
261
|
+
if (a !== b)
|
|
262
|
+
throw new Error("sampling is non-deterministic for a fixed seed — serving would be unreproducible");
|
|
263
|
+
const greedy = model.generateText(prompt, tok, { maxNewTokens, temperature: 0 });
|
|
264
|
+
if (typeof greedy !== "string" || greedy.trim().length === 0)
|
|
265
|
+
throw new Error("model produced empty output");
|
|
266
|
+
ctx.bag.sample = greedy;
|
|
267
|
+
return `deterministic@seed ${seed}; sample "${greedy.slice(0, 40)}"`;
|
|
268
|
+
}),
|
|
269
|
+
},
|
|
270
|
+
roundtrip: {
|
|
271
|
+
info: { type: "roundtrip", layer: "BUILD", label: "Deploy round-trip", description: "Package the TRAINED model → load → generate; output must match (the real serve smoke test)" },
|
|
272
|
+
factory: (cfg) => mkStep(cfg, "BUILD", "Deploy round-trip (.evermind)", async (ctx) => {
|
|
273
|
+
const model = ctx.bag.model;
|
|
274
|
+
const tok = ctx.bag.tokenizer;
|
|
275
|
+
if (!model || !tok)
|
|
276
|
+
throw new Error("no trained model — add 'train-model' first");
|
|
277
|
+
const prompt = pStr(cfg, "prompt", "The");
|
|
278
|
+
const maxNewTokens = pNum(cfg, "maxNewTokens", 6);
|
|
279
|
+
const before = model.generateText(prompt, tok, { maxNewTokens, temperature: 0 });
|
|
280
|
+
const blob = EvermindModelPackage.fromLM(model, {
|
|
281
|
+
name: pStr(cfg, "name", "custom-evermind"),
|
|
282
|
+
version: pStr(cfg, "version", "1.0.0"),
|
|
283
|
+
card: { description: pStr(cfg, "description", "round-trip validated model") },
|
|
284
|
+
}).toBlob();
|
|
285
|
+
const pkg = EvermindModelPackage.fromBlob(blob);
|
|
286
|
+
const v = pkg.validate();
|
|
287
|
+
if (!v.ok)
|
|
288
|
+
throw new Error(`packaged artifact failed validation: ${v.errors.join("; ")}`);
|
|
289
|
+
const after = pkg.loadLM().generateText(prompt, tok, { maxNewTokens, temperature: 0 });
|
|
290
|
+
if (after !== before)
|
|
291
|
+
throw new Error("served model produced different output than the trained model");
|
|
292
|
+
ctx.artifacts.evermind = blob;
|
|
293
|
+
ctx.artifacts.tokenizer = { vocab: Object.fromEntries(tok.vocab), merges: [...tok.merges.keys()] };
|
|
294
|
+
return `artifact ${blob.byteLength} bytes; trained vs served output matches`;
|
|
295
|
+
}),
|
|
296
|
+
},
|
|
297
|
+
package: {
|
|
298
|
+
info: { type: "package", layer: "BUILD", label: "Package", description: "Bundle the trained model into a portable .evermind artifact (params: name, version)" },
|
|
299
|
+
factory: (cfg) => mkStep(cfg, "BUILD", "Package .evermind artifact", async (ctx) => {
|
|
300
|
+
const model = ctx.bag.model;
|
|
301
|
+
if (!model)
|
|
302
|
+
throw new Error("no trained model — add 'train-model' first");
|
|
303
|
+
const blob = EvermindModelPackage.fromLM(model, {
|
|
304
|
+
name: pStr(cfg, "name", "custom-evermind"),
|
|
305
|
+
version: pStr(cfg, "version", "1.0.0"),
|
|
306
|
+
card: { description: pStr(cfg, "description", "workflow-built model") },
|
|
307
|
+
}).toBlob();
|
|
308
|
+
ctx.artifacts.evermind = blob;
|
|
309
|
+
// Ship the tokenizer alongside so the deployed model has text I/O.
|
|
310
|
+
const tok = ctx.bag.tokenizer;
|
|
311
|
+
if (tok) {
|
|
312
|
+
ctx.artifacts.tokenizer = { vocab: Object.fromEntries(tok.vocab), merges: [...tok.merges.keys()] };
|
|
313
|
+
}
|
|
314
|
+
return `packaged ${blob.byteLength} bytes${tok ? " + tokenizer" : ""}`;
|
|
315
|
+
}),
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
//# sourceMappingURL=steps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"steps.js","sourceRoot":"","sources":["../../src/workflow/steps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,GACrB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIvD,MAAM,SAAS,GACb,iEAAiE;IACjE,mDAAmD;IACnD,6DAA6D;IAC7D,2CAA2C,CAAC;AAE9C,IAAI,KAAK,GAAG,CAAC,CAAC;AAEd,kFAAkF;AAClF,SAAS,IAAI,CAAC,GAAuB,EAAE,GAAW,EAAE,GAAW;IAC7D,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IAC5B,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACzC,CAAC;AACD,SAAS,IAAI,CAAC,GAAuB,EAAE,GAAW,EAAE,GAAW;IAC7D,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CA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tC,IAAI,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,aAAa,EAAE,sBAAsB,CAAC,EAAE;aACxE,CAAC,CAAC,MAAM,EAAE,CAAC;YACZ,GAAG,CAAC,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC;YAC9B,mEAAmE;YACnE,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,SAAqC,CAAC;YAC1D,IAAI,GAAG,EAAE,CAAC;gBACR,GAAG,CAAC,SAAS,CAAC,SAAS,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YACrG,CAAC;YACD,OAAO,YAAY,IAAI,CAAC,UAAU,SAAS,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACzE,CAAC,CAAC;KACL;CACF,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* workflow/templates.ts — starter workflows.
|
|
3
|
+
*
|
|
4
|
+
* A template is just a {@link WorkflowConfig}. The 7-layer agentic stack is one;
|
|
5
|
+
* the LLM-creation pipeline is another. A user clones a template or authors their
|
|
6
|
+
* own; a custom workflow can produce an `.evermind` model (the "train your LLM"
|
|
7
|
+
* path) via the BUILD steps.
|
|
8
|
+
*/
|
|
9
|
+
import type { WorkflowConfig } from "./types.js";
|
|
10
|
+
/** The full Agentic 7-step stack (diagnostic). */
|
|
11
|
+
export declare const AGENTIC_SEVEN_LAYER: WorkflowConfig;
|
|
12
|
+
/**
|
|
13
|
+
* Create your own LLM — the GENERIC foundation pipeline (domain-agnostic).
|
|
14
|
+
* Train a tokenizer + model on any corpus, with the full diagnostic gates:
|
|
15
|
+
* dataset quality → train → convergence → evaluate → generation/determinism →
|
|
16
|
+
* deploy round-trip (packages the trained model and proves the served copy
|
|
17
|
+
* regenerates identical output). Pass your own text via the `corpus` param.
|
|
18
|
+
*/
|
|
19
|
+
export declare const TRAIN_LLM: WorkflowConfig;
|
|
20
|
+
export declare const WORKFLOW_TEMPLATES: WorkflowConfig[];
|
|
21
|
+
export declare function getTemplate(id: string): WorkflowConfig | undefined;
|
|
22
|
+
/** Deep-clone a template so a user can edit it as a custom workflow. */
|
|
23
|
+
export declare function cloneTemplate(id: string, overrides?: Partial<WorkflowConfig>): WorkflowConfig | undefined;
|
|
24
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/workflow/templates.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,kDAAkD;AAClD,eAAO,MAAM,mBAAmB,EAAE,cAcjC,CAAC;AAqBF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,EAAE,cAavB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,cAAc,EAAqC,CAAC;AAErF,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAElE;AAED,wEAAwE;AACxE,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,GAAE,OAAO,CAAC,cAAc,CAAM,GAAG,cAAc,GAAG,SAAS,CAU7G"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* workflow/templates.ts — starter workflows.
|
|
3
|
+
*
|
|
4
|
+
* A template is just a {@link WorkflowConfig}. The 7-layer agentic stack is one;
|
|
5
|
+
* the LLM-creation pipeline is another. A user clones a template or authors their
|
|
6
|
+
* own; a custom workflow can produce an `.evermind` model (the "train your LLM"
|
|
7
|
+
* path) via the BUILD steps.
|
|
8
|
+
*/
|
|
9
|
+
/** The full Agentic 7-step stack (diagnostic). */
|
|
10
|
+
export const AGENTIC_SEVEN_LAYER = {
|
|
11
|
+
id: "agentic-seven-layer",
|
|
12
|
+
name: "Agentic Stack — 7 Layers",
|
|
13
|
+
description: "Runs every layer of the agent stack end to end: Foundation model, Orchestration, Memory, RAG, Tools, Observability, Deployment.",
|
|
14
|
+
steps: [
|
|
15
|
+
{ id: "l1", type: "foundation" },
|
|
16
|
+
{ id: "l3", type: "memory" },
|
|
17
|
+
{ id: "l4", type: "rag" },
|
|
18
|
+
{ id: "l5", type: "tools" },
|
|
19
|
+
{ id: "l2", type: "orchestration" },
|
|
20
|
+
{ id: "l6", type: "observability" },
|
|
21
|
+
{ id: "l7", type: "deployment" },
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Generic default corpus so "Create an LLM" runs out-of-the-box. A real run
|
|
26
|
+
* passes the user's own text as the `corpus` param on the train steps — the
|
|
27
|
+
* pipeline is domain-agnostic (resume tailoring, support replies, code, prose…).
|
|
28
|
+
* Distinct sentences keep the dataset-quality duplicate-ratio gate happy.
|
|
29
|
+
*/
|
|
30
|
+
const DEFAULT_CORPUS = [
|
|
31
|
+
"BuilderForce orchestrates many agents through a planning loop.",
|
|
32
|
+
"The memory layer stores facts as SSM embeddings for fast recall.",
|
|
33
|
+
"Deployment runs on Cloudflare Workers and Durable Objects.",
|
|
34
|
+
"Tools are gated by a capability registry the planner consults.",
|
|
35
|
+
"Write-through cognition replaces a fact instead of appending a new copy.",
|
|
36
|
+
"Retrieval fuses BM25 keyword search with dense semantic scoring.",
|
|
37
|
+
"The runtime distills a frontier teacher into the on-device student.",
|
|
38
|
+
"A workflow compiles into runnable steps and emits an execution timeline.",
|
|
39
|
+
"Observability captures a span for every step so failures are localized.",
|
|
40
|
+
"A trained model packages into a portable evermind artifact for serving.",
|
|
41
|
+
].join(" ");
|
|
42
|
+
/**
|
|
43
|
+
* Create your own LLM — the GENERIC foundation pipeline (domain-agnostic).
|
|
44
|
+
* Train a tokenizer + model on any corpus, with the full diagnostic gates:
|
|
45
|
+
* dataset quality → train → convergence → evaluate → generation/determinism →
|
|
46
|
+
* deploy round-trip (packages the trained model and proves the served copy
|
|
47
|
+
* regenerates identical output). Pass your own text via the `corpus` param.
|
|
48
|
+
*/
|
|
49
|
+
export const TRAIN_LLM = {
|
|
50
|
+
id: "train-llm",
|
|
51
|
+
name: "Create an LLM",
|
|
52
|
+
description: "Train a custom EvermindLM on your corpus, validate it end to end, and package it as a portable .evermind artifact.",
|
|
53
|
+
steps: [
|
|
54
|
+
{ id: "tok", type: "train-tokenizer", params: { corpus: DEFAULT_CORPUS, numMerges: 120 } },
|
|
55
|
+
{ id: "data", type: "dataset-quality" },
|
|
56
|
+
{ id: "model", type: "train-model", params: { corpus: DEFAULT_CORPUS, epochs: 50, dModel: 24, numLayers: 2, hiddenDim: 32 } },
|
|
57
|
+
{ id: "converge", type: "convergence" },
|
|
58
|
+
{ id: "eval", type: "evaluate" },
|
|
59
|
+
{ id: "gen", type: "generate-check" },
|
|
60
|
+
{ id: "pkg", type: "roundtrip", params: { name: "my-llm" } },
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
export const WORKFLOW_TEMPLATES = [AGENTIC_SEVEN_LAYER, TRAIN_LLM];
|
|
64
|
+
export function getTemplate(id) {
|
|
65
|
+
return WORKFLOW_TEMPLATES.find((t) => t.id === id);
|
|
66
|
+
}
|
|
67
|
+
/** Deep-clone a template so a user can edit it as a custom workflow. */
|
|
68
|
+
export function cloneTemplate(id, overrides = {}) {
|
|
69
|
+
const t = getTemplate(id);
|
|
70
|
+
if (!t)
|
|
71
|
+
return undefined;
|
|
72
|
+
return {
|
|
73
|
+
...t,
|
|
74
|
+
id: overrides.id ?? `${t.id}-custom`,
|
|
75
|
+
name: overrides.name ?? `${t.name} (custom)`,
|
|
76
|
+
...(overrides.description ? { description: overrides.description } : {}),
|
|
77
|
+
steps: (overrides.steps ?? t.steps).map((s) => ({ ...s, params: { ...s.params } })),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/workflow/templates.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,kDAAkD;AAClD,MAAM,CAAC,MAAM,mBAAmB,GAAmB;IACjD,EAAE,EAAE,qBAAqB;IACzB,IAAI,EAAE,0BAA0B;IAChC,WAAW,EACT,iIAAiI;IACnI,KAAK,EAAE;QACL,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE;QAChC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC5B,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE;QACzB,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE;QAC3B,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE;QACnC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE;QACnC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE;KACjC;CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,cAAc,GAAG;IACrB,gEAAgE;IAChE,kEAAkE;IAClE,4DAA4D;IAC5D,gEAAgE;IAChE,0EAA0E;IAC1E,kEAAkE;IAClE,qEAAqE;IACrE,0EAA0E;IAC1E,yEAAyE;IACzE,yEAAyE;CAC1E,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAmB;IACvC,EAAE,EAAE,WAAW;IACf,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,oHAAoH;IACjI,KAAK,EAAE;QACL,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,cAAc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WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxE,KAAK,EAAE,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;KACpF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* workflow/types.ts — the configurable workflow definition.
|
|
3
|
+
*
|
|
4
|
+
* A workflow is data: an ordered list of step configs, each naming a registered
|
|
5
|
+
* step `type` (e.g. "foundation", "train-model") plus per-step `params`. Templates
|
|
6
|
+
* (the Agentic 7-layer stack, an LLM-creation pipeline) are just `WorkflowConfig`
|
|
7
|
+
* values; a user's custom workflow is one they author. Configs compile to runnable
|
|
8
|
+
* `StackStep[]` via the step registry.
|
|
9
|
+
*/
|
|
10
|
+
import type { StackStep } from "../diagnostics/stack-diagnostic.js";
|
|
11
|
+
export interface WorkflowStepConfig {
|
|
12
|
+
/** Unique id within the workflow (also the execution-output row id). */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Registered step type, e.g. "foundation" | "train-tokenizer" | "package". */
|
|
15
|
+
type: string;
|
|
16
|
+
/** Display label override (defaults to the type's built-in label). */
|
|
17
|
+
label?: string;
|
|
18
|
+
/** Per-step parameters consumed by the step factory (e.g. corpus, epochs). */
|
|
19
|
+
params?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
export interface WorkflowConfig {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
steps: WorkflowStepConfig[];
|
|
26
|
+
}
|
|
27
|
+
/** Metadata a registered step type advertises (for builders/validation/UI). */
|
|
28
|
+
export interface StepTypeInfo {
|
|
29
|
+
type: string;
|
|
30
|
+
/** Grouping tag used in the execution-output timeline (e.g. "L1", "BUILD"). */
|
|
31
|
+
layer: string;
|
|
32
|
+
label: string;
|
|
33
|
+
/** One-line description for a workflow-builder palette. */
|
|
34
|
+
description: string;
|
|
35
|
+
}
|
|
36
|
+
/** Builds a runnable step from its config. Throw inside `step.run` to fail it. */
|
|
37
|
+
export type StepFactory = (cfg: WorkflowStepConfig) => StackStep;
|
|
38
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/workflow/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAEpE,MAAM,WAAW,kBAAkB;IACjC,wEAAwE;IACxE,EAAE,EAAE,MAAM,CAAC;IACX,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,kBAAkB,EAAE,CAAC;CAC7B;AAED,+EAA+E;AAC/E,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,kFAAkF;AAClF,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,kBAAkB,KAAK,SAAS,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* workflow/types.ts — the configurable workflow definition.
|
|
3
|
+
*
|
|
4
|
+
* A workflow is data: an ordered list of step configs, each naming a registered
|
|
5
|
+
* step `type` (e.g. "foundation", "train-model") plus per-step `params`. Templates
|
|
6
|
+
* (the Agentic 7-layer stack, an LLM-creation pipeline) are just `WorkflowConfig`
|
|
7
|
+
* values; a user's custom workflow is one they author. Configs compile to runnable
|
|
8
|
+
* `StackStep[]` via the step registry.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/workflow/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seanhogg/builderforce-memory",
|
|
3
|
-
"version": "2026.6.
|
|
3
|
+
"version": "2026.6.31",
|
|
4
4
|
"description": "BuilderForce Agent Memory — runtime layer. SSM execution, Transformer orchestration, online distillation, hybrid RAG retrieval, and persistent agent memory for BuilderForce.ai agents.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"homepage": "https://github.com/SeanHogg/builderforce-memory/tree/main/packages/memory#readme",
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@seanhogg/builderforce-memory-engine": "^2026.6.
|
|
56
|
+
"@seanhogg/builderforce-memory-engine": "^2026.6.31"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@jest/globals": "^29.7.0",
|
|
@@ -65,8 +65,9 @@
|
|
|
65
65
|
"fake-indexeddb": "^6.0.0",
|
|
66
66
|
"jest": "^29.7.0",
|
|
67
67
|
"ts-jest": "^29.2.0",
|
|
68
|
-
"typescript": "^
|
|
69
|
-
"@
|
|
68
|
+
"typescript": "^6.0.3",
|
|
69
|
+
"@typescript/native-preview": "7.0.0-dev.20260627.2",
|
|
70
|
+
"@seanhogg/builderforce-memory-engine": "2026.6.31"
|
|
70
71
|
},
|
|
71
72
|
"jest": {
|
|
72
73
|
"preset": "ts-jest/presets/default-esm",
|
|
@@ -119,6 +120,7 @@
|
|
|
119
120
|
"build": "tsc",
|
|
120
121
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
121
122
|
"test:coverage": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage",
|
|
122
|
-
"lint": "eslint src/ tests/"
|
|
123
|
+
"lint": "eslint src/ tests/",
|
|
124
|
+
"typecheck:native": "tsgo --noEmit"
|
|
123
125
|
}
|
|
124
126
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diagnostics — the generic workflow runner + execution-output types.
|
|
3
|
+
* The configurable workflow / template layer lives in `../workflow/`.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export { runStackDiagnostic } from "./stack-diagnostic.js";
|
|
7
|
+
export type {
|
|
8
|
+
StackStep,
|
|
9
|
+
StackStepResult,
|
|
10
|
+
StackContext,
|
|
11
|
+
StackDiagnosticResult,
|
|
12
|
+
RunStackOptions,
|
|
13
|
+
StepStatus,
|
|
14
|
+
} from "./stack-diagnostic.js";
|