@nagi-js/core 0.1.1-rc.14 → 0.1.1-rc.15
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/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2026,6 +2026,21 @@ var RunId = {
|
|
|
2026
2026
|
return s;
|
|
2027
2027
|
}
|
|
2028
2028
|
};
|
|
2029
|
+
async function deriveChildRunId(parent) {
|
|
2030
|
+
const seed = `nagi:subflow:${parent.runId}:${parent.stepId}:${parent.attempt}`;
|
|
2031
|
+
const digest = await crypto.subtle.digest(
|
|
2032
|
+
"SHA-256",
|
|
2033
|
+
new TextEncoder().encode(seed)
|
|
2034
|
+
);
|
|
2035
|
+
const bytes = new Uint8Array(digest).subarray(0, 16);
|
|
2036
|
+
bytes[6] = (bytes[6] ?? 0) & 15 | 80;
|
|
2037
|
+
bytes[8] = (bytes[8] ?? 0) & 63 | 128;
|
|
2038
|
+
const hex2 = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join(
|
|
2039
|
+
""
|
|
2040
|
+
);
|
|
2041
|
+
const uuid = `${hex2.slice(0, 8)}-${hex2.slice(8, 12)}-${hex2.slice(12, 16)}-${hex2.slice(16, 20)}-${hex2.slice(20, 32)}`;
|
|
2042
|
+
return `run-${uuid}`;
|
|
2043
|
+
}
|
|
2029
2044
|
|
|
2030
2045
|
// src/exec/hooks.ts
|
|
2031
2046
|
function makeHooks(deps) {
|
|
@@ -3607,18 +3622,13 @@ async function nagiImpl(config) {
|
|
|
3607
3622
|
);
|
|
3608
3623
|
}
|
|
3609
3624
|
const validated = await validate(child.input, childInput);
|
|
3610
|
-
const childRunId =
|
|
3611
|
-
|
|
3625
|
+
const childRunId = await deriveChildRunId(parent);
|
|
3626
|
+
await startRunInternal({
|
|
3612
3627
|
flow: child,
|
|
3613
3628
|
validatedInput: validated,
|
|
3614
3629
|
runId: childRunId,
|
|
3615
3630
|
parent
|
|
3616
3631
|
});
|
|
3617
|
-
if (!started) {
|
|
3618
|
-
throw new NagiRuntimeError(
|
|
3619
|
-
`startChildRun: minted child runId collided with an existing run (${childRunId})`
|
|
3620
|
-
);
|
|
3621
|
-
}
|
|
3622
3632
|
return childRunId;
|
|
3623
3633
|
}
|
|
3624
3634
|
async function cancelRunRecursive(runId, args) {
|