@rasputin-ai/node 0.5.0-alpha.6 → 0.5.0-alpha.7
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/auto-instrumentation/instrument-compiled-esm.d.ts +2 -0
- package/dist/auto-instrumentation/instrument-compiled-esm.d.ts.map +1 -1
- package/dist/auto-instrumentation/instrumentation-manifest-delta.d.ts +2 -1
- package/dist/auto-instrumentation/instrumentation-manifest-delta.d.ts.map +1 -1
- package/dist/auto-instrumentation/instrumentation-manifest-registry.d.ts +1 -1
- package/dist/auto-instrumentation/instrumentation-manifest-registry.d.ts.map +1 -1
- package/dist/auto-instrumentation/transform-source.d.ts +6 -0
- package/dist/auto-instrumentation/transform-source.d.ts.map +1 -1
- package/dist/derivation/analyze-function.d.ts +40 -0
- package/dist/derivation/analyze-function.d.ts.map +1 -0
- package/dist/derivation/build-dependency-graph.d.ts +21 -0
- package/dist/derivation/build-dependency-graph.d.ts.map +1 -0
- package/dist/derivation/derivation-ir.d.ts +33 -0
- package/dist/derivation/derivation-ir.d.ts.map +1 -0
- package/dist/derivation/derivation-proof.d.ts +14 -0
- package/dist/derivation/derivation-proof.d.ts.map +1 -0
- package/dist/derivation/emit-capture-plan.d.ts +8 -0
- package/dist/derivation/emit-capture-plan.d.ts.map +1 -0
- package/dist/execution-recorder/automatic-runtime.d.ts +3 -1
- package/dist/execution-recorder/automatic-runtime.d.ts.map +1 -1
- package/dist/execution-recorder/execution-recorder-types.d.ts +13 -2
- package/dist/execution-recorder/execution-recorder-types.d.ts.map +1 -1
- package/dist/execution-recorder/execution-recorder.d.ts.map +1 -1
- package/dist/index.js +169 -36
- package/dist/instrument/build.js +761 -71
- package/dist/instrument/bun.js +742 -66
- package/dist/instrument/node.js +742 -66
- package/dist/sdk-meta.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -133,7 +133,7 @@ var definitionFromEncodedPlan = (plan) => {
|
|
|
133
133
|
var estimatedCallBytesFor = (functionId) => EVENT_PAIR_BASE_ESTIMATED_BYTES + Buffer.byteLength(functionId, "utf8") * 2;
|
|
134
134
|
|
|
135
135
|
// src/auto-instrumentation/instrumentation-manifest-registry.ts
|
|
136
|
-
var INSTRUMENTATION_MANIFEST_SYMBOL = "rasputin.instrumentation.manifest.
|
|
136
|
+
var INSTRUMENTATION_MANIFEST_SYMBOL = "rasputin.instrumentation.manifest.v3";
|
|
137
137
|
var registrySymbol = Symbol.for(INSTRUMENTATION_MANIFEST_SYMBOL);
|
|
138
138
|
var getRegistry = () => {
|
|
139
139
|
const existing = Reflect.get(globalThis, registrySymbol);
|
|
@@ -190,6 +190,7 @@ var snapshotInstrumentationManifest = (options = {}) => {
|
|
|
190
190
|
const functions = [];
|
|
191
191
|
const callSites = [];
|
|
192
192
|
const destructures = [];
|
|
193
|
+
const derivationPlans = [];
|
|
193
194
|
for (const delta of getRegistry().files.values()) {
|
|
194
195
|
for (const fn of delta.functions) {
|
|
195
196
|
const definition = definitionFromEncodedPlan(fn.plan);
|
|
@@ -241,6 +242,7 @@ var snapshotInstrumentationManifest = (options = {}) => {
|
|
|
241
242
|
binding: destructure.binding
|
|
242
243
|
});
|
|
243
244
|
}
|
|
245
|
+
derivationPlans.push(...delta.derivationPlans ?? []);
|
|
244
246
|
}
|
|
245
247
|
const registry = getRegistry();
|
|
246
248
|
if (registry.prebuilt && registry.files.size === 0) {
|
|
@@ -268,7 +270,8 @@ var snapshotInstrumentationManifest = (options = {}) => {
|
|
|
268
270
|
} : {},
|
|
269
271
|
functions,
|
|
270
272
|
callSites,
|
|
271
|
-
destructures
|
|
273
|
+
destructures,
|
|
274
|
+
derivationPlans
|
|
272
275
|
};
|
|
273
276
|
};
|
|
274
277
|
var markInstrumentationManifestUploaded = (generation) => {
|
|
@@ -384,7 +387,12 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
384
387
|
|
|
385
388
|
// src/execution-recorder/execution-recorder.ts
|
|
386
389
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
387
|
-
import {
|
|
390
|
+
import {
|
|
391
|
+
capturedValueCompleteness,
|
|
392
|
+
hashInstrumentationManifest,
|
|
393
|
+
rasputinOmitted,
|
|
394
|
+
runtimeFunctionId as runtimeFunctionId2
|
|
395
|
+
} from "@rasputin-ai/core";
|
|
388
396
|
|
|
389
397
|
// src/execution-recorder/execution-journal.ts
|
|
390
398
|
var KIND_ENTER = 1;
|
|
@@ -1415,6 +1423,7 @@ var createSourceExclusionMatcher = (exclusions) => {
|
|
|
1415
1423
|
|
|
1416
1424
|
// src/execution-recorder/execution-recorder.ts
|
|
1417
1425
|
var DEFAULT_MAX_ACTIVE_MEMORY_BYTES = 64 * 1024 * 1024;
|
|
1426
|
+
var DERIVATION_ROOT_RECORD_BYTES = 64;
|
|
1418
1427
|
var phaseTimingEnabled = process.env.RASPUTIN_RECORDER_PHASE_TIMING === "1";
|
|
1419
1428
|
var manualFunctionDefinition = (value) => {
|
|
1420
1429
|
const located = /^(.+):([^:@]+)@(\d+):(\d+)$/.exec(value);
|
|
@@ -1527,7 +1536,16 @@ var emptyStats = {
|
|
|
1527
1536
|
journalPoolHits: 0,
|
|
1528
1537
|
journalPoolMisses: 0,
|
|
1529
1538
|
journalPoolSize: 0,
|
|
1530
|
-
journalAllocatedCapacity: 0
|
|
1539
|
+
journalAllocatedCapacity: 0,
|
|
1540
|
+
derivationCandidateFunctions: 0,
|
|
1541
|
+
derivationElidedFunctionCalls: 0,
|
|
1542
|
+
derivationRootsCaptured: 0,
|
|
1543
|
+
derivationControlFactsCaptured: 0,
|
|
1544
|
+
derivationValuesAvoided: 0,
|
|
1545
|
+
derivationFallbackFunctions: 0,
|
|
1546
|
+
derivationFallbackExpressions: 0,
|
|
1547
|
+
derivationFallbackReasons: {},
|
|
1548
|
+
derivationRootBytes: 0
|
|
1531
1549
|
};
|
|
1532
1550
|
var noOpExecution = {
|
|
1533
1551
|
createScope: () => ({
|
|
@@ -1543,7 +1561,8 @@ var noOpExecution = {
|
|
|
1543
1561
|
prepareFunctionPlans: () => [],
|
|
1544
1562
|
runPreparedFunction: (_plan, _args, callback) => callback(),
|
|
1545
1563
|
trace: (_functionId, fn) => fn,
|
|
1546
|
-
getStats: () => ({ ...emptyStats })
|
|
1564
|
+
getStats: () => ({ ...emptyStats, derivationFallbackReasons: {} }),
|
|
1565
|
+
captureDerivationRoot: (_rootId, value) => value
|
|
1547
1566
|
};
|
|
1548
1567
|
var mergeExecutionMetadata = (target, metadata) => {
|
|
1549
1568
|
if (metadata.kind) target.kind = metadata.kind;
|
|
@@ -1608,7 +1627,16 @@ var createExecutionRecorder = (options) => {
|
|
|
1608
1627
|
partialErrorSnapshots: 0,
|
|
1609
1628
|
measuredExecutions: 0,
|
|
1610
1629
|
totalInlineWallTimeMs: 0,
|
|
1611
|
-
maxInlineWallTimeMs: 0
|
|
1630
|
+
maxInlineWallTimeMs: 0,
|
|
1631
|
+
derivationCandidateFunctions: 0,
|
|
1632
|
+
derivationElidedFunctionCalls: 0,
|
|
1633
|
+
derivationRootsCaptured: 0,
|
|
1634
|
+
derivationControlFactsCaptured: 0,
|
|
1635
|
+
derivationValuesAvoided: 0,
|
|
1636
|
+
derivationFallbackFunctions: 0,
|
|
1637
|
+
derivationFallbackExpressions: 0,
|
|
1638
|
+
derivationFallbackReasons: {},
|
|
1639
|
+
derivationRootBytes: 0
|
|
1612
1640
|
};
|
|
1613
1641
|
const addPhase = (key, nanoseconds) => {
|
|
1614
1642
|
if (phases && nanoseconds > 0n) phases[key] += nanoseconds;
|
|
@@ -1660,17 +1688,56 @@ var createExecutionRecorder = (options) => {
|
|
|
1660
1688
|
preparedModules.set(plans, prepared);
|
|
1661
1689
|
return prepared;
|
|
1662
1690
|
};
|
|
1691
|
+
const derivationMetrics = (recording) => {
|
|
1692
|
+
const manifest = snapshotInstrumentationManifest();
|
|
1693
|
+
const plans = manifest?.derivationPlans ?? [];
|
|
1694
|
+
const reasons = { ...stats.derivationFallbackReasons };
|
|
1695
|
+
return {
|
|
1696
|
+
derivationCandidateFunctions: plans.filter((plan) => !plan.fallbackReason).length,
|
|
1697
|
+
derivationElidedFunctionCalls: stats.derivationElidedFunctionCalls,
|
|
1698
|
+
derivationRootsCaptured: recording.derivationRoots.length,
|
|
1699
|
+
derivationControlFactsCaptured: stats.derivationControlFactsCaptured,
|
|
1700
|
+
derivationValuesAvoided: stats.derivationValuesAvoided,
|
|
1701
|
+
derivationFallbackFunctions: plans.filter((plan) => plan.fallbackReason).length,
|
|
1702
|
+
derivationFallbackExpressions: recording.derivationRoots.length,
|
|
1703
|
+
derivationFallbackReasons: reasons,
|
|
1704
|
+
derivationRootBytes: recording.derivationRootBytes
|
|
1705
|
+
};
|
|
1706
|
+
};
|
|
1707
|
+
const resolveCaptureMode = (recording) => {
|
|
1708
|
+
if (recording.derivationRoots.length > 0) return "derivation";
|
|
1709
|
+
const plans = snapshotInstrumentationManifest()?.derivationPlans ?? [];
|
|
1710
|
+
if (recording.sawAutomatic && plans.some(
|
|
1711
|
+
(plan) => !plan.fallbackReason && recording.executedFunctionIds.has(plan.functionId)
|
|
1712
|
+
)) {
|
|
1713
|
+
return "derivation";
|
|
1714
|
+
}
|
|
1715
|
+
if (recording.sawAutomatic) return "automatic-full";
|
|
1716
|
+
if (recording.sawManual) return "manual";
|
|
1717
|
+
return "scope-only";
|
|
1718
|
+
};
|
|
1719
|
+
const derivationCapture = (recording) => {
|
|
1720
|
+
const manifest = snapshotInstrumentationManifest();
|
|
1721
|
+
if (!manifest) return void 0;
|
|
1722
|
+
return {
|
|
1723
|
+
manifestHash: hashInstrumentationManifest(manifest),
|
|
1724
|
+
roots: recording.derivationRoots.slice(),
|
|
1725
|
+
controlFacts: []
|
|
1726
|
+
};
|
|
1727
|
+
};
|
|
1663
1728
|
const stateFrom = (recording, endedAtNs = process.hrtime.bigint()) => {
|
|
1664
1729
|
const recorderStartedAtNs = process.hrtime.bigint();
|
|
1665
1730
|
let events = [];
|
|
1666
1731
|
let functions = [];
|
|
1667
1732
|
let truncated;
|
|
1668
1733
|
let capture;
|
|
1734
|
+
let derivation;
|
|
1669
1735
|
if (recording.cachedState) {
|
|
1670
1736
|
events = recording.cachedState.events;
|
|
1671
1737
|
functions = recording.cachedState.functions;
|
|
1672
1738
|
truncated = recording.cachedState.truncated;
|
|
1673
1739
|
capture = recording.cachedState.capture;
|
|
1740
|
+
derivation = recording.cachedState.derivation;
|
|
1674
1741
|
} else {
|
|
1675
1742
|
if (recording.journal) {
|
|
1676
1743
|
const materialized = recording.journal.materialize(plansByRuntimeId, recording.startedAtNs);
|
|
@@ -1684,18 +1751,20 @@ var createExecutionRecorder = (options) => {
|
|
|
1684
1751
|
valuesDropped: recording.memory.valuesDropped,
|
|
1685
1752
|
eventsDropped: recording.memory.eventsDropped
|
|
1686
1753
|
} : void 0;
|
|
1754
|
+
derivation = derivationCapture(recording);
|
|
1687
1755
|
if (recording.finished && recording.inFlightCalls === 0 && recording.journal) {
|
|
1688
|
-
recording.cachedState = { events, functions, truncated, capture };
|
|
1756
|
+
recording.cachedState = { events, functions, truncated, capture, derivation };
|
|
1689
1757
|
journalPool.release(recording.journal);
|
|
1690
1758
|
recording.journal = void 0;
|
|
1691
1759
|
}
|
|
1692
1760
|
}
|
|
1693
1761
|
const state = {
|
|
1694
|
-
version:
|
|
1762
|
+
version: 3,
|
|
1763
|
+
captureMode: resolveCaptureMode(recording),
|
|
1695
1764
|
executionId: recording.executionId,
|
|
1696
1765
|
startedAt: recording.startedAt,
|
|
1697
1766
|
durationMs: elapsedMs2(recording.startedAtNs, endedAtNs),
|
|
1698
|
-
recorder: { inlineWallTimeMs: 0 },
|
|
1767
|
+
recorder: { inlineWallTimeMs: 0, derivation: derivationMetrics(recording) },
|
|
1699
1768
|
execution: {
|
|
1700
1769
|
...recording.execution,
|
|
1701
1770
|
...recording.execution.request ? { request: { ...recording.execution.request } } : {}
|
|
@@ -1703,12 +1772,16 @@ var createExecutionRecorder = (options) => {
|
|
|
1703
1772
|
functions: functions.slice(),
|
|
1704
1773
|
events: events.slice(),
|
|
1705
1774
|
...truncated ? { truncated: { ...truncated } } : {},
|
|
1706
|
-
...capture ? { capture: { ...capture } } : {}
|
|
1775
|
+
...capture ? { capture: { ...capture } } : {},
|
|
1776
|
+
...derivation ? { derivation: { ...derivation, roots: derivation.roots.slice() } } : {}
|
|
1707
1777
|
};
|
|
1708
1778
|
if (phaseTimingEnabled)
|
|
1709
1779
|
addPhase("materializeNs", process.hrtime.bigint() - recorderStartedAtNs);
|
|
1710
1780
|
addRecorderTime(recording, process.hrtime.bigint() - recorderStartedAtNs);
|
|
1711
|
-
state.recorder = {
|
|
1781
|
+
state.recorder = {
|
|
1782
|
+
inlineWallTimeMs: roundedMilliseconds2(recording.inlineRecorderTimeNs),
|
|
1783
|
+
derivation: derivationMetrics(recording)
|
|
1784
|
+
};
|
|
1712
1785
|
return state;
|
|
1713
1786
|
};
|
|
1714
1787
|
const rememberError = (error, recording) => {
|
|
@@ -1893,7 +1966,12 @@ var createExecutionRecorder = (options) => {
|
|
|
1893
1966
|
finished: false,
|
|
1894
1967
|
hasError: false,
|
|
1895
1968
|
memory: memoryBudget.startExecution(),
|
|
1896
|
-
partialSnapshotCounted: false
|
|
1969
|
+
partialSnapshotCounted: false,
|
|
1970
|
+
derivationRoots: [],
|
|
1971
|
+
derivationRootBytes: 0,
|
|
1972
|
+
sawAutomatic: false,
|
|
1973
|
+
sawManual: false,
|
|
1974
|
+
executedFunctionIds: /* @__PURE__ */ new Set()
|
|
1897
1975
|
};
|
|
1898
1976
|
stats.activeExecutions++;
|
|
1899
1977
|
stats.peakActiveExecutions = Math.max(stats.peakActiveExecutions, stats.activeExecutions);
|
|
@@ -1955,7 +2033,7 @@ var createExecutionRecorder = (options) => {
|
|
|
1955
2033
|
return void 0;
|
|
1956
2034
|
}
|
|
1957
2035
|
};
|
|
1958
|
-
const runPreparedFunction = (plan, args, callback) => {
|
|
2036
|
+
const runPreparedFunction = (plan, args, callback, omitValues) => {
|
|
1959
2037
|
const store = storage.getStore();
|
|
1960
2038
|
if (!store || store.recording.finished) return callback();
|
|
1961
2039
|
stats.functionCallsObserved++;
|
|
@@ -2064,7 +2142,7 @@ var createExecutionRecorder = (options) => {
|
|
|
2064
2142
|
}
|
|
2065
2143
|
const callId = ++recording.nextCallId;
|
|
2066
2144
|
const enterTimestampNs = process.hrtime.bigint() - recording.startedAtNs;
|
|
2067
|
-
const capturedArgs = Array.from(args, (argument) => captureValue(recording, argument));
|
|
2145
|
+
const capturedArgs = omitValues ? Array.from(args, () => rasputinOmitted()) : Array.from(args, (argument) => captureValue(recording, argument));
|
|
2068
2146
|
journal.startCall(plan.runtimePlanId, callId, parentCallId, enterTimestampNs, capturedArgs);
|
|
2069
2147
|
const callStore = { recording, currentCallId: callId };
|
|
2070
2148
|
return runStore(
|
|
@@ -2077,7 +2155,7 @@ var createExecutionRecorder = (options) => {
|
|
|
2077
2155
|
if (recording.journal) {
|
|
2078
2156
|
const timestampNs = process.hrtime.bigint() - recording.startedAtNs;
|
|
2079
2157
|
const durationNs = process.hrtime.bigint() - startedAtNs;
|
|
2080
|
-
const returnValue = captureValue(recording, value);
|
|
2158
|
+
const returnValue = omitValues ? rasputinOmitted() : captureValue(recording, value);
|
|
2081
2159
|
recording.journal.finishCall(KIND_EXIT, callId, timestampNs, durationNs, returnValue);
|
|
2082
2160
|
stats.functionCallsCaptured++;
|
|
2083
2161
|
}
|
|
@@ -2105,19 +2183,60 @@ var createExecutionRecorder = (options) => {
|
|
|
2105
2183
|
)
|
|
2106
2184
|
);
|
|
2107
2185
|
};
|
|
2108
|
-
const runFunction = (input, args, callback) =>
|
|
2109
|
-
|
|
2186
|
+
const runFunction = (input, args, callback) => {
|
|
2187
|
+
const store = storage.getStore();
|
|
2188
|
+
if (store && !store.recording.finished) store.recording.sawManual = true;
|
|
2189
|
+
return runPreparedFunction(preparePlan(normalizeFunctionDefinition(input)), args, callback);
|
|
2190
|
+
};
|
|
2191
|
+
const runFunctionPlans = (plans, planIndex, args, callback, omitValues) => {
|
|
2192
|
+
const store = storage.getStore();
|
|
2110
2193
|
const plan = preparedPlansFor(plans)[planIndex];
|
|
2111
|
-
|
|
2194
|
+
if (store && !store.recording.finished) {
|
|
2195
|
+
store.recording.sawAutomatic = true;
|
|
2196
|
+
if (plan) store.recording.executedFunctionIds.add(plan.functionId);
|
|
2197
|
+
}
|
|
2198
|
+
return plan ? runPreparedFunction(plan, args, callback, omitValues) : callback();
|
|
2112
2199
|
};
|
|
2113
2200
|
const prepareFunctionPlans = (plans) => preparedPlansFor(plans);
|
|
2114
2201
|
function trace(input, fn) {
|
|
2115
2202
|
const definition = typeof input === "string" ? manualFunctionDefinition(input) : { ...input, functionId: runtimeFunctionId2(input) };
|
|
2116
2203
|
const plan = preparePlan(definition);
|
|
2117
2204
|
return function traced(...args) {
|
|
2205
|
+
const store = storage.getStore();
|
|
2206
|
+
if (store && !store.recording.finished) store.recording.sawManual = true;
|
|
2118
2207
|
return runPreparedFunction(plan, args, () => fn.apply(this, args));
|
|
2119
2208
|
};
|
|
2120
2209
|
}
|
|
2210
|
+
const captureDerivationRoot = (rootId, value) => {
|
|
2211
|
+
const store = storage.getStore();
|
|
2212
|
+
if (!store || store.recording.finished || store.suppressCapture) return value;
|
|
2213
|
+
const recording = store.recording;
|
|
2214
|
+
if (recording.memory.mode !== "full") return value;
|
|
2215
|
+
if (recording.derivationRoots.length >= maxEventsPerExecution) return value;
|
|
2216
|
+
const recorderStartedAtNs = process.hrtime.bigint();
|
|
2217
|
+
try {
|
|
2218
|
+
const serialized = captureValue(recording, value);
|
|
2219
|
+
if (recording.memory.mode !== "full") return value;
|
|
2220
|
+
if (!memoryBudget.reserveStorage(recording.memory, DERIVATION_ROOT_RECORD_BYTES)) {
|
|
2221
|
+
return value;
|
|
2222
|
+
}
|
|
2223
|
+
const completeness = capturedValueCompleteness(serialized);
|
|
2224
|
+
const bytes = jsonLiteralUtf8Bytes(serialized);
|
|
2225
|
+
recording.derivationRoots.push({
|
|
2226
|
+
rootId,
|
|
2227
|
+
callId: store.currentCallId ?? 0,
|
|
2228
|
+
value: serialized,
|
|
2229
|
+
completeness
|
|
2230
|
+
});
|
|
2231
|
+
recording.derivationRootBytes += bytes;
|
|
2232
|
+
stats.derivationRootsCaptured++;
|
|
2233
|
+
stats.derivationRootBytes += bytes;
|
|
2234
|
+
stats.derivationFallbackExpressions++;
|
|
2235
|
+
return value;
|
|
2236
|
+
} finally {
|
|
2237
|
+
addRecorderTime(recording, process.hrtime.bigint() - recorderStartedAtNs);
|
|
2238
|
+
}
|
|
2239
|
+
};
|
|
2121
2240
|
return {
|
|
2122
2241
|
createScope,
|
|
2123
2242
|
run,
|
|
@@ -2127,21 +2246,30 @@ var createExecutionRecorder = (options) => {
|
|
|
2127
2246
|
prepareFunctionPlans,
|
|
2128
2247
|
runPreparedFunction,
|
|
2129
2248
|
trace,
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2249
|
+
captureDerivationRoot,
|
|
2250
|
+
getStats: () => {
|
|
2251
|
+
const manifest = snapshotInstrumentationManifest();
|
|
2252
|
+
const plans = manifest?.derivationPlans ?? [];
|
|
2253
|
+
return {
|
|
2254
|
+
...stats,
|
|
2255
|
+
...memoryBudget.getStats(),
|
|
2256
|
+
...journalPool.stats(),
|
|
2257
|
+
derivationCandidateFunctions: plans.filter((plan) => !plan.fallbackReason).length,
|
|
2258
|
+
derivationFallbackFunctions: plans.filter((plan) => plan.fallbackReason).length,
|
|
2259
|
+
derivationFallbackReasons: { ...stats.derivationFallbackReasons },
|
|
2260
|
+
...phases ? {
|
|
2261
|
+
phaseAlsNs: Number(phases.alsNs),
|
|
2262
|
+
phaseMaterializeNs: Number(phases.materializeNs)
|
|
2263
|
+
} : {}
|
|
2264
|
+
};
|
|
2265
|
+
}
|
|
2139
2266
|
};
|
|
2140
2267
|
};
|
|
2141
2268
|
|
|
2142
2269
|
// src/execution-recorder/automatic-runtime.ts
|
|
2143
2270
|
var AUTOMATIC_RUNTIME_SYMBOL = "rasputin.execution.runtime.v2";
|
|
2144
2271
|
var runtimeSymbol = Symbol.for(AUTOMATIC_RUNTIME_SYMBOL);
|
|
2272
|
+
var passthroughCapture = (_rootId, value) => value;
|
|
2145
2273
|
var passthrough = (_planIndex, _args, callback) => callback();
|
|
2146
2274
|
var bindPassthrough = (module) => {
|
|
2147
2275
|
module.cell.run = passthrough;
|
|
@@ -2152,12 +2280,13 @@ var registerModule = (registry, plans) => {
|
|
|
2152
2280
|
const module = { plans, cell };
|
|
2153
2281
|
registry.modules.push(module);
|
|
2154
2282
|
registry.runtimes.at(-1)?.bind(module);
|
|
2155
|
-
return (planIndex, args, callback) => cell.run(planIndex, args, callback);
|
|
2283
|
+
return (planIndex, args, callback, omitValues) => cell.run(planIndex, args, callback, omitValues);
|
|
2156
2284
|
};
|
|
2157
2285
|
var createRegistry = () => {
|
|
2158
2286
|
const registry = {
|
|
2159
2287
|
runtimes: [],
|
|
2160
2288
|
modules: [],
|
|
2289
|
+
captureRoot: passthroughCapture,
|
|
2161
2290
|
register(plans) {
|
|
2162
2291
|
return registerModule(registry, plans);
|
|
2163
2292
|
}
|
|
@@ -2166,7 +2295,12 @@ var createRegistry = () => {
|
|
|
2166
2295
|
};
|
|
2167
2296
|
var getAutomaticRuntimeRegistry = () => {
|
|
2168
2297
|
const existing = Reflect.get(globalThis, runtimeSymbol);
|
|
2169
|
-
if (existing && typeof existing === "object" && isRegistry(existing))
|
|
2298
|
+
if (existing && typeof existing === "object" && isRegistry(existing)) {
|
|
2299
|
+
if (typeof existing.captureRoot !== "function") {
|
|
2300
|
+
existing.captureRoot = passthroughCapture;
|
|
2301
|
+
}
|
|
2302
|
+
return existing;
|
|
2303
|
+
}
|
|
2170
2304
|
const registry = createRegistry();
|
|
2171
2305
|
Reflect.set(globalThis, runtimeSymbol, registry);
|
|
2172
2306
|
return registry;
|
|
@@ -2175,19 +2309,18 @@ var installAutomaticExecutionRuntime = (execution) => {
|
|
|
2175
2309
|
const registry = getAutomaticRuntimeRegistry();
|
|
2176
2310
|
const runtime = {
|
|
2177
2311
|
bind(module) {
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
return plan ? execution.runPreparedFunction(plan, args, callback) : callback();
|
|
2182
|
-
};
|
|
2183
|
-
}
|
|
2312
|
+
module.cell.run = (planIndex, args, callback, omitValues) => execution.runFunctionPlans(module.plans, planIndex, args, callback, omitValues);
|
|
2313
|
+
},
|
|
2314
|
+
captureRoot: (rootId, value) => execution.captureDerivationRoot(rootId, value)
|
|
2184
2315
|
};
|
|
2185
2316
|
registry.runtimes.push(runtime);
|
|
2317
|
+
registry.captureRoot = runtime.captureRoot;
|
|
2186
2318
|
for (const module of registry.modules) runtime.bind(module);
|
|
2187
2319
|
return () => {
|
|
2188
2320
|
const index = registry.runtimes.lastIndexOf(runtime);
|
|
2189
2321
|
if (index >= 0) registry.runtimes.splice(index, 1);
|
|
2190
2322
|
const current = registry.runtimes.at(-1);
|
|
2323
|
+
registry.captureRoot = current?.captureRoot ?? passthroughCapture;
|
|
2191
2324
|
for (const module of registry.modules) {
|
|
2192
2325
|
if (current) current.bind(module);
|
|
2193
2326
|
else bindPassthrough(module);
|
|
@@ -2252,7 +2385,7 @@ import {
|
|
|
2252
2385
|
|
|
2253
2386
|
// src/sdk-meta.ts
|
|
2254
2387
|
var SDK_NAME = "@rasputin-ai/node";
|
|
2255
|
-
var SDK_VERSION = "0.5.0-alpha.
|
|
2388
|
+
var SDK_VERSION = "0.5.0-alpha.7";
|
|
2256
2389
|
|
|
2257
2390
|
// src/rasputin-init.ts
|
|
2258
2391
|
var withExecution = (client, execution, installRuntime, manifest) => {
|