@claude-flow/cli 3.19.0 → 3.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/commands/neural.d.ts.map +1 -1
- package/dist/src/commands/neural.js +57 -11
- package/dist/src/commands/neural.js.map +1 -1
- package/dist/src/mcp-tools/agenticow-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/agenticow-tools.js +182 -2
- package/dist/src/mcp-tools/agenticow-tools.js.map +1 -1
- package/dist/src/ruvector/index.d.ts +1 -1
- package/dist/src/ruvector/index.d.ts.map +1 -1
- package/dist/src/ruvector/index.js +1 -1
- package/dist/src/ruvector/index.js.map +1 -1
- package/dist/src/ruvector/lora-adapter.d.ts +35 -0
- package/dist/src/ruvector/lora-adapter.d.ts.map +1 -1
- package/dist/src/ruvector/lora-adapter.js +108 -1
- package/dist/src/ruvector/lora-adapter.js.map +1 -1
- package/dist/src/services/native-training.d.ts +28 -0
- package/dist/src/services/native-training.d.ts.map +1 -1
- package/dist/src/services/native-training.js +62 -5
- package/dist/src/services/native-training.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -25,6 +25,14 @@ export interface NativeTrainingResult {
|
|
|
25
25
|
earlyStopped: boolean;
|
|
26
26
|
checkpointPath?: string;
|
|
27
27
|
checkpointBytes?: number;
|
|
28
|
+
/** True when training resumed from a --resume checkpoint. */
|
|
29
|
+
resumed?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* How the resume happened: 'resumeFrom' (ruvllm >=2.6.0 — restores epoch
|
|
32
|
+
* position + optimizer state) or 'loadCheckpoint' (2.5.7 fallback —
|
|
33
|
+
* weights only, training restarts from epoch 0).
|
|
34
|
+
*/
|
|
35
|
+
resumeMode?: 'resumeFrom' | 'loadCheckpoint';
|
|
28
36
|
}
|
|
29
37
|
export interface NativeTrainingOptions {
|
|
30
38
|
embeddings: Float32Array[];
|
|
@@ -32,9 +40,29 @@ export interface NativeTrainingOptions {
|
|
|
32
40
|
batchSize: number;
|
|
33
41
|
learningRate: number;
|
|
34
42
|
dim: number;
|
|
43
|
+
/**
|
|
44
|
+
* Validation holdout fraction (0..1). >0 makes the pipeline report
|
|
45
|
+
* bestValLoss + early-stopping; 0 (or omitted) disables validation.
|
|
46
|
+
* validationSplit exists in ruvllm 2.5.7 — no version gate needed.
|
|
47
|
+
*/
|
|
48
|
+
validationSplit?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Resume weights (and, on >=2.6.0, epoch position) from this checkpoint
|
|
51
|
+
* BEFORE training. A missing/invalid path throws ResumeFailedError — an
|
|
52
|
+
* explicit --resume must fail loudly, never silently fresh-train.
|
|
53
|
+
*/
|
|
54
|
+
resumeFrom?: string;
|
|
35
55
|
/** When set, the TRAINED pipeline checkpoints here (ruvllm >=2.5.7). */
|
|
36
56
|
checkpointPath?: string;
|
|
37
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Thrown when an explicit --resume checkpoint cannot be found or loaded.
|
|
60
|
+
* Distinct from the generic "native unavailable → null" degradation so the
|
|
61
|
+
* caller can surface a loud, exit-1 failure rather than fresh training.
|
|
62
|
+
*/
|
|
63
|
+
export declare class ResumeFailedError extends Error {
|
|
64
|
+
constructor(message: string);
|
|
65
|
+
}
|
|
38
66
|
export declare function nativeTrainingAvailable(): boolean;
|
|
39
67
|
export declare function runNativeTraining(opts: NativeTrainingOptions): Promise<NativeTrainingResult | null>;
|
|
40
68
|
//# sourceMappingURL=native-training.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-training.d.ts","sourceRoot":"","sources":["../../../src/services/native-training.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"native-training.d.ts","sourceRoot":"","sources":["../../../src/services/native-training.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,YAAY,GAAG,gBAAgB,CAAC;CAC9C;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAgB,uBAAuB,IAAI,OAAO,CAOjD;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAsGtC"}
|
|
@@ -19,6 +19,17 @@
|
|
|
19
19
|
import { createRequire } from 'module';
|
|
20
20
|
import { mkdirSync, existsSync } from 'fs';
|
|
21
21
|
import { dirname } from 'path';
|
|
22
|
+
/**
|
|
23
|
+
* Thrown when an explicit --resume checkpoint cannot be found or loaded.
|
|
24
|
+
* Distinct from the generic "native unavailable → null" degradation so the
|
|
25
|
+
* caller can surface a loud, exit-1 failure rather than fresh training.
|
|
26
|
+
*/
|
|
27
|
+
export class ResumeFailedError extends Error {
|
|
28
|
+
constructor(message) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.name = 'ResumeFailedError';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
22
33
|
export function nativeTrainingAvailable() {
|
|
23
34
|
try {
|
|
24
35
|
createRequire(import.meta.url).resolve('@ruvector/ruvllm');
|
|
@@ -29,19 +40,53 @@ export function nativeTrainingAvailable() {
|
|
|
29
40
|
}
|
|
30
41
|
}
|
|
31
42
|
export async function runNativeTraining(opts) {
|
|
32
|
-
const { embeddings, epochs, batchSize, learningRate, dim, checkpointPath } = opts;
|
|
43
|
+
const { embeddings, epochs, batchSize, learningRate, dim, validationSplit, resumeFrom, checkpointPath } = opts;
|
|
33
44
|
if (embeddings.length < 2)
|
|
34
45
|
return null;
|
|
35
46
|
try {
|
|
36
47
|
const req = createRequire(import.meta.url);
|
|
37
48
|
const ruvllm = req('@ruvector/ruvllm');
|
|
38
|
-
const
|
|
49
|
+
const pipelineConfig = {
|
|
39
50
|
learningRate,
|
|
40
51
|
batchSize,
|
|
41
52
|
epochs,
|
|
42
53
|
inputDim: dim,
|
|
43
54
|
outputDim: dim,
|
|
44
|
-
}
|
|
55
|
+
};
|
|
56
|
+
// 0 (or omitted) disables validation; only pass a real holdout through.
|
|
57
|
+
if (typeof validationSplit === 'number' && validationSplit > 0) {
|
|
58
|
+
pipelineConfig.validationSplit = validationSplit;
|
|
59
|
+
}
|
|
60
|
+
const pipeline = new ruvllm.TrainingPipeline(pipelineConfig);
|
|
61
|
+
// Resume BEFORE training. Prefer resumeFrom() (2.6.0 — epoch position +
|
|
62
|
+
// optimizer state); fall back to loadCheckpoint() (2.5.7 — weights only).
|
|
63
|
+
// Any failure with an explicit --resume is loud (ResumeFailedError),
|
|
64
|
+
// never silent fresh training.
|
|
65
|
+
let resumed = false;
|
|
66
|
+
let resumeMode;
|
|
67
|
+
if (resumeFrom) {
|
|
68
|
+
if (!existsSync(resumeFrom)) {
|
|
69
|
+
throw new ResumeFailedError(`--resume checkpoint not found: ${resumeFrom}`);
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
if (typeof pipeline.resumeFrom === 'function') {
|
|
73
|
+
pipeline.resumeFrom(resumeFrom);
|
|
74
|
+
resumeMode = 'resumeFrom';
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const ok = pipeline.loadCheckpoint(resumeFrom);
|
|
78
|
+
if (ok === false)
|
|
79
|
+
throw new Error('loadCheckpoint returned false');
|
|
80
|
+
resumeMode = 'loadCheckpoint';
|
|
81
|
+
}
|
|
82
|
+
resumed = true;
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
if (e instanceof ResumeFailedError)
|
|
86
|
+
throw e;
|
|
87
|
+
throw new ResumeFailedError(`--resume failed to load checkpoint ${resumeFrom}: ${e.message}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
45
90
|
// Pattern-alignment pairs, chunked into pipeline batches.
|
|
46
91
|
const inputs = [];
|
|
47
92
|
const targets = [];
|
|
@@ -55,13 +100,21 @@ export async function runNativeTraining(opts) {
|
|
|
55
100
|
pipeline.addBatch(inputs.slice(i, i + batchSize), targets.slice(i, i + batchSize), qualities.slice(i, i + batchSize));
|
|
56
101
|
}
|
|
57
102
|
const r = pipeline.train();
|
|
103
|
+
// When validation is disabled the pipeline reports Infinity for
|
|
104
|
+
// bestValLoss — normalize any non-finite value to null so downstream
|
|
105
|
+
// "bestValLoss !== null ⇒ validation ran" holds for the results table.
|
|
106
|
+
const bestValLoss = typeof r.bestValLoss === 'number' && Number.isFinite(r.bestValLoss)
|
|
107
|
+
? r.bestValLoss
|
|
108
|
+
: null;
|
|
58
109
|
const result = {
|
|
59
110
|
epochs: r.epochs,
|
|
60
111
|
steps: r.steps,
|
|
61
112
|
finalLoss: r.finalLoss,
|
|
62
|
-
bestValLoss
|
|
113
|
+
bestValLoss,
|
|
63
114
|
durationMs: r.durationMs,
|
|
64
115
|
earlyStopped: !!r.earlyStopped,
|
|
116
|
+
resumed,
|
|
117
|
+
resumeMode,
|
|
65
118
|
};
|
|
66
119
|
if (checkpointPath) {
|
|
67
120
|
try {
|
|
@@ -77,7 +130,11 @@ export async function runNativeTraining(opts) {
|
|
|
77
130
|
}
|
|
78
131
|
return result;
|
|
79
132
|
}
|
|
80
|
-
catch {
|
|
133
|
+
catch (err) {
|
|
134
|
+
// An explicit --resume failure must propagate as a loud error; every
|
|
135
|
+
// other failure degrades to null so callers fall back to the WASM path.
|
|
136
|
+
if (err instanceof ResumeFailedError)
|
|
137
|
+
throw err;
|
|
81
138
|
return null;
|
|
82
139
|
}
|
|
83
140
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-training.js","sourceRoot":"","sources":["../../../src/services/native-training.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"native-training.js","sourceRoot":"","sources":["../../../src/services/native-training.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,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