@nagi-js/core 0.1.1-rc.22 → 0.1.1-rc.23
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/{chunk-PUAV56FC.js → chunk-DPTPJZEG.js} +16 -8
- package/dist/chunk-DPTPJZEG.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +28 -24
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +75 -1
- package/dist/testing.js.map +1 -1
- package/dist/{types-Ct5xHI4W.d.ts → types-CezUTCly.d.ts} +2 -5
- package/package.json +1 -1
- package/dist/chunk-PUAV56FC.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InMemoryClock, makeEmit, registerFlows, fingerprintFlows, makeFlowOf, makeSignals, compact, validationError, NagiRuntimeError, NagiSnapshotDriftError, requireCurrent, serializeError, NagiSignalTimeoutError, validate, Facts, foldRun, stepStateOf, isStepTerminal, isTerminalRun,
|
|
2
|
-
export { DEFAULT_REAPER_INTERVAL_MS, DEFAULT_SWEEP_LIMIT, InMemoryClock, InMemoryQueue, InMemoryRunEventHub, InMemoryStore, InMemoryStreamHub, NagiCanceledError, NagiConcurrencyConflictError, NagiFlowSnapshotGoneError, NagiNonRetryableError, NagiRuntimeError, NagiSignalTimeoutError, NagiSnapshotDriftError, NagiStepTimeoutError, NagiValidationError, STREAM_REPLAY_BUFFER_CAP, STREAM_SUBSCRIBER_BUFFER_CAP, admitsRunEnd, attemptOf, decideExpiredLeaseAction, decideSignal, decideTimeout, defaultSnapshotGonePolicy, errorOf, factConsequences, isRunEnd, isStepTerminal, isStreamOver, isTerminalRun, isTerminalRunEvent, outputOf, foldRun as projectRunState, resolvedOf, runStatusOf, selectExpired, selectPruneBatch, stepStateOf, stepStatusOf, supersede, unwrap } from './chunk-
|
|
1
|
+
import { InMemoryClock, makeEmit, registerFlows, fingerprintFlows, makeFlowOf, makeSignals, compact, validationError, NagiRuntimeError, NagiSnapshotDriftError, requireCurrent, serializeError, NagiSignalTimeoutError, validate, Facts, foldRun, stepStateOf, isStepTerminal, isTerminalRun, dequeueBackoff, defaultSnapshotGonePolicy, DEFAULT_REAPER_INTERVAL_MS, runStatusOf, runCancelCause, asStepMapWithDefs, needsStepIds, getDef, stepStatusOf, handlerDef, resolveRetry, isAbortRequested, resolveNeeds, stepBackoff, NagiCanceledError, NagiStepTimeoutError, peekDef, attachDef, NagiNonRetryableError, pinRun, normalizeNeeds } from './chunk-DPTPJZEG.js';
|
|
2
|
+
export { DEFAULT_REAPER_INTERVAL_MS, DEFAULT_SWEEP_LIMIT, InMemoryClock, InMemoryQueue, InMemoryRunEventHub, InMemoryStore, InMemoryStreamHub, NagiCanceledError, NagiConcurrencyConflictError, NagiFlowSnapshotGoneError, NagiNonRetryableError, NagiRuntimeError, NagiSignalTimeoutError, NagiSnapshotDriftError, NagiStepTimeoutError, NagiValidationError, STREAM_REPLAY_BUFFER_CAP, STREAM_SUBSCRIBER_BUFFER_CAP, admitsRunEnd, attemptOf, decideExpiredLeaseAction, decideSignal, decideTimeout, defaultSnapshotGonePolicy, errorOf, factConsequences, isRunEnd, isStepTerminal, isStreamOver, isTerminalRun, isTerminalRunEvent, outputOf, foldRun as projectRunState, resolvedOf, runStatusOf, selectExpired, selectPruneBatch, stepStateOf, stepStatusOf, supersede, unwrap } from './chunk-DPTPJZEG.js';
|
|
3
3
|
|
|
4
4
|
// src/builder.ts
|
|
5
5
|
function makeBuilder() {
|
|
@@ -597,7 +597,7 @@ function makeMessage(deps, hooks, progression) {
|
|
|
597
597
|
return { tag: "parked" };
|
|
598
598
|
}
|
|
599
599
|
case "subflow":
|
|
600
|
-
return await executeSubflow({ def, runId, stepId,
|
|
600
|
+
return await executeSubflow({ def, runId, stepId, state });
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
603
|
async function interpret(args) {
|
|
@@ -733,7 +733,7 @@ function makeMessage(deps, hooks, progression) {
|
|
|
733
733
|
}
|
|
734
734
|
}
|
|
735
735
|
async function executeSubflow(args) {
|
|
736
|
-
const { def, runId, stepId,
|
|
736
|
+
const { def, runId, stepId, state } = args;
|
|
737
737
|
const child = deps.lookupFlow(def.childFlowId);
|
|
738
738
|
if (child === void 0) {
|
|
739
739
|
throw new Error(
|
|
@@ -753,7 +753,7 @@ function makeMessage(deps, hooks, progression) {
|
|
|
753
753
|
await deps.startChildRun({
|
|
754
754
|
child,
|
|
755
755
|
childInput,
|
|
756
|
-
parent: { runId, stepId
|
|
756
|
+
parent: { runId, stepId },
|
|
757
757
|
generation
|
|
758
758
|
});
|
|
759
759
|
return { tag: "parked" };
|
|
@@ -1310,30 +1310,34 @@ function makeReplay(deps) {
|
|
|
1310
1310
|
}
|
|
1311
1311
|
}
|
|
1312
1312
|
async function abortInFlight(state, stepId) {
|
|
1313
|
-
|
|
1314
|
-
if (step.tag !== "running") return;
|
|
1313
|
+
if (stepStateOf(state, stepId).tag !== "running") return;
|
|
1315
1314
|
const { runId } = state;
|
|
1316
|
-
|
|
1317
|
-
runId,
|
|
1318
|
-
Facts.stepAbortRequested({
|
|
1319
|
-
runId,
|
|
1320
|
-
stepId,
|
|
1321
|
-
attempt: step.attempt,
|
|
1322
|
-
at: clock.now()
|
|
1323
|
-
})
|
|
1324
|
-
);
|
|
1315
|
+
let aborted = 0;
|
|
1325
1316
|
const start = Date.now();
|
|
1326
|
-
|
|
1327
|
-
const
|
|
1328
|
-
|
|
1329
|
-
if (ss === void 0 || isStepTerminal(ss) || isTerminalRun(s) || attemptOf(ss) > step.attempt) {
|
|
1317
|
+
for (let s = state; ; s = await store.loadRunState(runId)) {
|
|
1318
|
+
const step = stepStateOf(s, stepId);
|
|
1319
|
+
if (step.tag === "pending" || isStepTerminal(step) || isTerminalRun(s)) {
|
|
1330
1320
|
return;
|
|
1331
1321
|
}
|
|
1322
|
+
if (step.tag === "running" && step.attempt > aborted) {
|
|
1323
|
+
aborted = step.attempt;
|
|
1324
|
+
await store.appendFact(
|
|
1325
|
+
runId,
|
|
1326
|
+
Facts.stepAbortRequested({
|
|
1327
|
+
runId,
|
|
1328
|
+
stepId,
|
|
1329
|
+
attempt: step.attempt,
|
|
1330
|
+
at: clock.now()
|
|
1331
|
+
})
|
|
1332
|
+
);
|
|
1333
|
+
}
|
|
1334
|
+
if (Date.now() - start >= ABORT_SETTLE_DEADLINE_MS) {
|
|
1335
|
+
throw new NagiRuntimeError(
|
|
1336
|
+
`replay({ from }): timed out after ${ABORT_SETTLE_DEADLINE_MS}ms waiting for step "${stepId}" (attempt ${aborted}) to honor abort signal. Handler may be ignoring ctx.signal.`
|
|
1337
|
+
);
|
|
1338
|
+
}
|
|
1332
1339
|
await new Promise((r) => setTimeout(r, ABORT_SETTLE_POLL_MS));
|
|
1333
1340
|
}
|
|
1334
|
-
throw new NagiRuntimeError(
|
|
1335
|
-
`replay({ from }): timed out after ${ABORT_SETTLE_DEADLINE_MS}ms waiting for step "${stepId}" (attempt ${step.attempt}) to honor abort signal. Handler may be ignoring ctx.signal.`
|
|
1336
|
-
);
|
|
1337
1341
|
}
|
|
1338
1342
|
return { replay };
|
|
1339
1343
|
}
|
|
@@ -1444,7 +1448,7 @@ function makeRunLifecycle(deps) {
|
|
|
1444
1448
|
codeVersion: deps.codeVersion,
|
|
1445
1449
|
flowHash: registry.hashOf(flow2.id),
|
|
1446
1450
|
...compact({
|
|
1447
|
-
parent
|
|
1451
|
+
parent
|
|
1448
1452
|
})
|
|
1449
1453
|
});
|
|
1450
1454
|
const concurrency = concurrencyOf(flow2, validatedInput);
|