@rasputin-ai/node 0.5.0-alpha.7 → 0.5.0-alpha.9
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/transform-source.d.ts +2 -2
- package/dist/derivation/analyze-function.d.ts +2 -0
- package/dist/derivation/analyze-function.d.ts.map +1 -1
- package/dist/execution-recorder/execution-recorder.d.ts.map +1 -1
- package/dist/index.js +37 -13
- package/dist/instrument/build.js +26 -12
- package/dist/instrument/bun.js +26 -12
- package/dist/instrument/node.js +26 -12
- package/dist/sdk-meta.d.ts +1 -1
- package/package.json +2 -2
|
@@ -4,8 +4,8 @@ export type TransformSourceOptions = {
|
|
|
4
4
|
filePath: string;
|
|
5
5
|
mapLocation?: SourceLocationMapper;
|
|
6
6
|
/**
|
|
7
|
-
* analysis
|
|
8
|
-
* serialization for exact helpers
|
|
7
|
+
* analysis (default): full call capture plus derivation.
|
|
8
|
+
* selective (experimental): omit argument/return serialization for exact helpers.
|
|
9
9
|
*/
|
|
10
10
|
derivationMode?: DerivationCaptureMode;
|
|
11
11
|
};
|
|
@@ -9,6 +9,8 @@ export type CaptureWrap = {
|
|
|
9
9
|
line: number;
|
|
10
10
|
column: number;
|
|
11
11
|
expressionId: number;
|
|
12
|
+
/** Object-literal shorthand must be expanded before its value can be wrapped. */
|
|
13
|
+
shorthandPropertyName?: string;
|
|
12
14
|
};
|
|
13
15
|
type NumericBinaryOp = 'add' | 'sub' | 'mul' | 'div' | 'mod';
|
|
14
16
|
export type GuardWrap = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze-function.d.ts","sourceRoot":"","sources":["../../src/derivation/analyze-function.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EAGb,cAAc,EAGd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAEN,KAAK,gBAAgB,EAErB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"analyze-function.d.ts","sourceRoot":"","sources":["../../src/derivation/analyze-function.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EAGb,cAAc,EAGd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAEN,KAAK,gBAAgB,EAErB,MAAM,0BAA0B,CAAC;AAGlC,MAAM,MAAM,WAAW,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,iFAAiF;IACjF,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,KAAK,eAAe,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAE7D,MAAM,MAAM,SAAS,GAAG;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,eAAe,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,EAAE,CAAC,uBAAuB,CAAC;IACjC,IAAI,EAAE,cAAc,CAAC;IACrB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,gBAAgB,EAAE,OAAO,CAAC;CAC1B,CAAC;AAojBF,MAAM,MAAM,oBAAoB,GAAG;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,EAAE,CAAC,uBAAuB,GAAG;QAAE,IAAI,EAAE,EAAE,CAAC,WAAW,CAAA;KAAE,CAAC;CAC5D,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAClC,YAAY,EAAE,CAAC,UAAU,EACzB,SAAS,oBAAoB,EAAE,KAC7B,gBAAgB,EA2ClB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-recorder.d.ts","sourceRoot":"","sources":["../../src/execution-recorder/execution-recorder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execution-recorder.d.ts","sourceRoot":"","sources":["../../src/execution-recorder/execution-recorder.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAGX,wBAAwB,EAExB,iBAAiB,EACjB,MAAM,4BAA4B,CAAC;AAiRpC,wEAAwE;AACxE,eAAO,MAAM,uBAAuB,GACnC,SAAS,wBAAwB,GAAG,SAAS,KAC3C,iBA4yBF,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -391,6 +391,7 @@ import {
|
|
|
391
391
|
capturedValueCompleteness,
|
|
392
392
|
hashInstrumentationManifest,
|
|
393
393
|
rasputinOmitted,
|
|
394
|
+
rasputinTagKind,
|
|
394
395
|
runtimeFunctionId as runtimeFunctionId2
|
|
395
396
|
} from "@rasputin-ai/core";
|
|
396
397
|
|
|
@@ -1704,21 +1705,44 @@ var createExecutionRecorder = (options) => {
|
|
|
1704
1705
|
derivationRootBytes: recording.derivationRootBytes
|
|
1705
1706
|
};
|
|
1706
1707
|
};
|
|
1707
|
-
const
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1708
|
+
const eventsHaveOmittedValues = (events) => {
|
|
1709
|
+
for (const event of events) {
|
|
1710
|
+
if (event.type === "function_enter" && event.args.some((arg) => rasputinTagKind(arg) === "omitted")) {
|
|
1711
|
+
return true;
|
|
1712
|
+
}
|
|
1713
|
+
if (event.type === "function_exit" && rasputinTagKind(event.returnValue) === "omitted") {
|
|
1714
|
+
return true;
|
|
1715
|
+
}
|
|
1714
1716
|
}
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1717
|
+
return false;
|
|
1718
|
+
};
|
|
1719
|
+
const resolveCaptureProfile = (recording, events, truncated, capture, derivation) => {
|
|
1720
|
+
const source = recording.sawAutomatic ? "automatic" : recording.sawManual ? "manual" : "scope-only";
|
|
1721
|
+
if (source === "scope-only") {
|
|
1722
|
+
return {
|
|
1723
|
+
source,
|
|
1724
|
+
functionBoundaries: "none",
|
|
1725
|
+
functionValues: "none",
|
|
1726
|
+
timings: "none",
|
|
1727
|
+
derivation: derivation ? "available" : "none"
|
|
1728
|
+
};
|
|
1729
|
+
}
|
|
1730
|
+
const droppedEvents = Boolean(truncated?.eventsDropped || capture?.eventsDropped);
|
|
1731
|
+
return {
|
|
1732
|
+
source,
|
|
1733
|
+
functionBoundaries: droppedEvents ? "partial" : "full",
|
|
1734
|
+
functionValues: eventsHaveOmittedValues(events) ? "selective" : "full",
|
|
1735
|
+
timings: droppedEvents ? "partial" : "full",
|
|
1736
|
+
derivation: derivation ? "available" : "none"
|
|
1737
|
+
};
|
|
1718
1738
|
};
|
|
1719
1739
|
const derivationCapture = (recording) => {
|
|
1720
1740
|
const manifest = snapshotInstrumentationManifest();
|
|
1721
1741
|
if (!manifest) return void 0;
|
|
1742
|
+
const plans = manifest.derivationPlans ?? [];
|
|
1743
|
+
if (!plans.some((plan) => recording.executedFunctionIds.has(plan.functionId))) {
|
|
1744
|
+
return void 0;
|
|
1745
|
+
}
|
|
1722
1746
|
return {
|
|
1723
1747
|
manifestHash: hashInstrumentationManifest(manifest),
|
|
1724
1748
|
roots: recording.derivationRoots.slice(),
|
|
@@ -1759,8 +1783,8 @@ var createExecutionRecorder = (options) => {
|
|
|
1759
1783
|
}
|
|
1760
1784
|
}
|
|
1761
1785
|
const state = {
|
|
1762
|
-
version:
|
|
1763
|
-
|
|
1786
|
+
version: 4,
|
|
1787
|
+
captureProfile: resolveCaptureProfile(recording, events, truncated, capture, derivation),
|
|
1764
1788
|
executionId: recording.executionId,
|
|
1765
1789
|
startedAt: recording.startedAt,
|
|
1766
1790
|
durationMs: elapsedMs2(recording.startedAtNs, endedAtNs),
|
|
@@ -2385,7 +2409,7 @@ import {
|
|
|
2385
2409
|
|
|
2386
2410
|
// src/sdk-meta.ts
|
|
2387
2411
|
var SDK_NAME = "@rasputin-ai/node";
|
|
2388
|
-
var SDK_VERSION = "0.5.0-alpha.
|
|
2412
|
+
var SDK_VERSION = "0.5.0-alpha.9";
|
|
2389
2413
|
|
|
2390
2414
|
// src/rasputin-init.ts
|
|
2391
2415
|
var withExecution = (client, execution, installRuntime, manifest) => {
|
package/dist/instrument/build.js
CHANGED
|
@@ -377,9 +377,6 @@ var emptyPlan = (functionId) => ({
|
|
|
377
377
|
controlFacts: []
|
|
378
378
|
});
|
|
379
379
|
|
|
380
|
-
// src/derivation/derivation-proof.ts
|
|
381
|
-
var functionIsExact = (plan) => plan.fallbackReason === void 0 && plan.captureBoundaries.length === 0 && plan.controlFacts.length === 0;
|
|
382
|
-
|
|
383
380
|
// src/derivation/analyze-function.ts
|
|
384
381
|
var loc = (node, sourceFile) => {
|
|
385
382
|
const position = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
@@ -542,6 +539,12 @@ var analyzeExpression = (ctx, node) => {
|
|
|
542
539
|
for (const property of node.properties) {
|
|
543
540
|
if (ts.isShorthandPropertyAssignment(property)) {
|
|
544
541
|
const nested = analyzeExpression(ctx, property.name);
|
|
542
|
+
if (nested.captured) {
|
|
543
|
+
const wrap = ctx.captureWraps.find(
|
|
544
|
+
(candidate) => candidate.expressionId === nested.expressionId
|
|
545
|
+
);
|
|
546
|
+
if (wrap) wrap.shorthandPropertyName = property.name.text;
|
|
547
|
+
}
|
|
545
548
|
properties.push({ key: property.name.text, value: nested.expressionId });
|
|
546
549
|
continue;
|
|
547
550
|
}
|
|
@@ -583,7 +586,7 @@ var analyzeExpression = (ctx, node) => {
|
|
|
583
586
|
if (!ts.isIdentifier(node.expression)) return capture(ctx, node, "dynamic_callee");
|
|
584
587
|
const calleeName = node.expression.text;
|
|
585
588
|
if (lookup(ctx, calleeName)) return capture(ctx, node, "opaque_call");
|
|
586
|
-
const provenId = ctx.
|
|
589
|
+
const provenId = ctx.moduleCallees.get(calleeName);
|
|
587
590
|
ctx.callEdges.push({
|
|
588
591
|
callerFunctionId: ctx.functionId,
|
|
589
592
|
calleeName,
|
|
@@ -773,7 +776,7 @@ var bindParams = (ctx, node) => {
|
|
|
773
776
|
index++;
|
|
774
777
|
}
|
|
775
778
|
};
|
|
776
|
-
var analyzeOne = (node, functionId, name, sourceFile,
|
|
779
|
+
var analyzeOne = (node, functionId, name, sourceFile, moduleCallees) => {
|
|
777
780
|
const ctx = {
|
|
778
781
|
sourceFile,
|
|
779
782
|
functionId,
|
|
@@ -789,7 +792,7 @@ var analyzeOne = (node, functionId, name, sourceFile, provenExact) => {
|
|
|
789
792
|
nextAssignmentId: { value: 0 },
|
|
790
793
|
hasThrow: false,
|
|
791
794
|
hasCoercionGuard: false,
|
|
792
|
-
|
|
795
|
+
moduleCallees,
|
|
793
796
|
identifierParams: []
|
|
794
797
|
};
|
|
795
798
|
if (node.asteriskToken || node.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword)) {
|
|
@@ -846,14 +849,20 @@ var analyzeModuleFunctions = (sourceFile, targets) => {
|
|
|
846
849
|
graph
|
|
847
850
|
);
|
|
848
851
|
const byId = new Map(targets.map((target) => [target.functionId, target]));
|
|
849
|
-
const
|
|
852
|
+
const moduleCallees = /* @__PURE__ */ new Map();
|
|
850
853
|
const analyzed = [];
|
|
851
854
|
for (const functionId of order) {
|
|
852
855
|
const target = byId.get(functionId);
|
|
853
856
|
if (!target) continue;
|
|
854
|
-
const result2 = analyzeOne(
|
|
855
|
-
|
|
856
|
-
|
|
857
|
+
const result2 = analyzeOne(
|
|
858
|
+
target.node,
|
|
859
|
+
target.functionId,
|
|
860
|
+
target.name,
|
|
861
|
+
sourceFile,
|
|
862
|
+
moduleCallees
|
|
863
|
+
);
|
|
864
|
+
if (nameCounts.get(result2.name) === 1) {
|
|
865
|
+
moduleCallees.set(result2.name, result2.functionId);
|
|
857
866
|
}
|
|
858
867
|
analyzed.push(result2);
|
|
859
868
|
}
|
|
@@ -861,11 +870,16 @@ var analyzeModuleFunctions = (sourceFile, targets) => {
|
|
|
861
870
|
(target) => !analyzed.some((fn) => fn.functionId === target.functionId)
|
|
862
871
|
);
|
|
863
872
|
for (const target of remaining) {
|
|
864
|
-
analyzed.push(
|
|
873
|
+
analyzed.push(
|
|
874
|
+
analyzeOne(target.node, target.functionId, target.name, sourceFile, moduleCallees)
|
|
875
|
+
);
|
|
865
876
|
}
|
|
866
877
|
return analyzed;
|
|
867
878
|
};
|
|
868
879
|
|
|
880
|
+
// src/derivation/derivation-proof.ts
|
|
881
|
+
var functionIsExact = (plan) => plan.fallbackReason === void 0 && plan.captureBoundaries.length === 0 && plan.controlFacts.length === 0;
|
|
882
|
+
|
|
869
883
|
// src/derivation/emit-capture-plan.ts
|
|
870
884
|
var captureWrapEdits = (wraps, capName) => {
|
|
871
885
|
const edits = [];
|
|
@@ -873,7 +887,7 @@ var captureWrapEdits = (wraps, capName) => {
|
|
|
873
887
|
for (const wrap of wraps) {
|
|
874
888
|
edits.push({
|
|
875
889
|
position: wrap.start,
|
|
876
|
-
text: `${capName}(${wrap.rootId},`,
|
|
890
|
+
text: `${wrap.shorthandPropertyName ? `${wrap.shorthandPropertyName}:` : ""}${capName}(${wrap.rootId},`,
|
|
877
891
|
order: order++
|
|
878
892
|
});
|
|
879
893
|
edits.push({
|
package/dist/instrument/bun.js
CHANGED
|
@@ -211,9 +211,6 @@ var emptyPlan = (functionId) => ({
|
|
|
211
211
|
controlFacts: []
|
|
212
212
|
});
|
|
213
213
|
|
|
214
|
-
// src/derivation/derivation-proof.ts
|
|
215
|
-
var functionIsExact = (plan) => plan.fallbackReason === void 0 && plan.captureBoundaries.length === 0 && plan.controlFacts.length === 0;
|
|
216
|
-
|
|
217
214
|
// src/derivation/analyze-function.ts
|
|
218
215
|
var loc = (node, sourceFile) => {
|
|
219
216
|
const position = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
@@ -376,6 +373,12 @@ var analyzeExpression = (ctx, node) => {
|
|
|
376
373
|
for (const property of node.properties) {
|
|
377
374
|
if (ts.isShorthandPropertyAssignment(property)) {
|
|
378
375
|
const nested = analyzeExpression(ctx, property.name);
|
|
376
|
+
if (nested.captured) {
|
|
377
|
+
const wrap = ctx.captureWraps.find(
|
|
378
|
+
(candidate) => candidate.expressionId === nested.expressionId
|
|
379
|
+
);
|
|
380
|
+
if (wrap) wrap.shorthandPropertyName = property.name.text;
|
|
381
|
+
}
|
|
379
382
|
properties.push({ key: property.name.text, value: nested.expressionId });
|
|
380
383
|
continue;
|
|
381
384
|
}
|
|
@@ -417,7 +420,7 @@ var analyzeExpression = (ctx, node) => {
|
|
|
417
420
|
if (!ts.isIdentifier(node.expression)) return capture(ctx, node, "dynamic_callee");
|
|
418
421
|
const calleeName = node.expression.text;
|
|
419
422
|
if (lookup(ctx, calleeName)) return capture(ctx, node, "opaque_call");
|
|
420
|
-
const provenId = ctx.
|
|
423
|
+
const provenId = ctx.moduleCallees.get(calleeName);
|
|
421
424
|
ctx.callEdges.push({
|
|
422
425
|
callerFunctionId: ctx.functionId,
|
|
423
426
|
calleeName,
|
|
@@ -607,7 +610,7 @@ var bindParams = (ctx, node) => {
|
|
|
607
610
|
index++;
|
|
608
611
|
}
|
|
609
612
|
};
|
|
610
|
-
var analyzeOne = (node, functionId, name, sourceFile,
|
|
613
|
+
var analyzeOne = (node, functionId, name, sourceFile, moduleCallees) => {
|
|
611
614
|
const ctx = {
|
|
612
615
|
sourceFile,
|
|
613
616
|
functionId,
|
|
@@ -623,7 +626,7 @@ var analyzeOne = (node, functionId, name, sourceFile, provenExact) => {
|
|
|
623
626
|
nextAssignmentId: { value: 0 },
|
|
624
627
|
hasThrow: false,
|
|
625
628
|
hasCoercionGuard: false,
|
|
626
|
-
|
|
629
|
+
moduleCallees,
|
|
627
630
|
identifierParams: []
|
|
628
631
|
};
|
|
629
632
|
if (node.asteriskToken || node.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword)) {
|
|
@@ -680,14 +683,20 @@ var analyzeModuleFunctions = (sourceFile, targets) => {
|
|
|
680
683
|
graph
|
|
681
684
|
);
|
|
682
685
|
const byId = new Map(targets.map((target) => [target.functionId, target]));
|
|
683
|
-
const
|
|
686
|
+
const moduleCallees = /* @__PURE__ */ new Map();
|
|
684
687
|
const analyzed = [];
|
|
685
688
|
for (const functionId of order) {
|
|
686
689
|
const target = byId.get(functionId);
|
|
687
690
|
if (!target) continue;
|
|
688
|
-
const result = analyzeOne(
|
|
689
|
-
|
|
690
|
-
|
|
691
|
+
const result = analyzeOne(
|
|
692
|
+
target.node,
|
|
693
|
+
target.functionId,
|
|
694
|
+
target.name,
|
|
695
|
+
sourceFile,
|
|
696
|
+
moduleCallees
|
|
697
|
+
);
|
|
698
|
+
if (nameCounts.get(result.name) === 1) {
|
|
699
|
+
moduleCallees.set(result.name, result.functionId);
|
|
691
700
|
}
|
|
692
701
|
analyzed.push(result);
|
|
693
702
|
}
|
|
@@ -695,11 +704,16 @@ var analyzeModuleFunctions = (sourceFile, targets) => {
|
|
|
695
704
|
(target) => !analyzed.some((fn) => fn.functionId === target.functionId)
|
|
696
705
|
);
|
|
697
706
|
for (const target of remaining) {
|
|
698
|
-
analyzed.push(
|
|
707
|
+
analyzed.push(
|
|
708
|
+
analyzeOne(target.node, target.functionId, target.name, sourceFile, moduleCallees)
|
|
709
|
+
);
|
|
699
710
|
}
|
|
700
711
|
return analyzed;
|
|
701
712
|
};
|
|
702
713
|
|
|
714
|
+
// src/derivation/derivation-proof.ts
|
|
715
|
+
var functionIsExact = (plan) => plan.fallbackReason === void 0 && plan.captureBoundaries.length === 0 && plan.controlFacts.length === 0;
|
|
716
|
+
|
|
703
717
|
// src/derivation/emit-capture-plan.ts
|
|
704
718
|
var captureWrapEdits = (wraps, capName) => {
|
|
705
719
|
const edits = [];
|
|
@@ -707,7 +721,7 @@ var captureWrapEdits = (wraps, capName) => {
|
|
|
707
721
|
for (const wrap of wraps) {
|
|
708
722
|
edits.push({
|
|
709
723
|
position: wrap.start,
|
|
710
|
-
text: `${capName}(${wrap.rootId},`,
|
|
724
|
+
text: `${wrap.shorthandPropertyName ? `${wrap.shorthandPropertyName}:` : ""}${capName}(${wrap.rootId},`,
|
|
711
725
|
order: order++
|
|
712
726
|
});
|
|
713
727
|
edits.push({
|
package/dist/instrument/node.js
CHANGED
|
@@ -266,9 +266,6 @@ var emptyPlan = (functionId) => ({
|
|
|
266
266
|
controlFacts: []
|
|
267
267
|
});
|
|
268
268
|
|
|
269
|
-
// src/derivation/derivation-proof.ts
|
|
270
|
-
var functionIsExact = (plan) => plan.fallbackReason === void 0 && plan.captureBoundaries.length === 0 && plan.controlFacts.length === 0;
|
|
271
|
-
|
|
272
269
|
// src/derivation/analyze-function.ts
|
|
273
270
|
var loc = (node, sourceFile) => {
|
|
274
271
|
const position = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
@@ -431,6 +428,12 @@ var analyzeExpression = (ctx, node) => {
|
|
|
431
428
|
for (const property of node.properties) {
|
|
432
429
|
if (ts.isShorthandPropertyAssignment(property)) {
|
|
433
430
|
const nested = analyzeExpression(ctx, property.name);
|
|
431
|
+
if (nested.captured) {
|
|
432
|
+
const wrap = ctx.captureWraps.find(
|
|
433
|
+
(candidate) => candidate.expressionId === nested.expressionId
|
|
434
|
+
);
|
|
435
|
+
if (wrap) wrap.shorthandPropertyName = property.name.text;
|
|
436
|
+
}
|
|
434
437
|
properties.push({ key: property.name.text, value: nested.expressionId });
|
|
435
438
|
continue;
|
|
436
439
|
}
|
|
@@ -472,7 +475,7 @@ var analyzeExpression = (ctx, node) => {
|
|
|
472
475
|
if (!ts.isIdentifier(node.expression)) return capture(ctx, node, "dynamic_callee");
|
|
473
476
|
const calleeName = node.expression.text;
|
|
474
477
|
if (lookup(ctx, calleeName)) return capture(ctx, node, "opaque_call");
|
|
475
|
-
const provenId = ctx.
|
|
478
|
+
const provenId = ctx.moduleCallees.get(calleeName);
|
|
476
479
|
ctx.callEdges.push({
|
|
477
480
|
callerFunctionId: ctx.functionId,
|
|
478
481
|
calleeName,
|
|
@@ -662,7 +665,7 @@ var bindParams = (ctx, node) => {
|
|
|
662
665
|
index++;
|
|
663
666
|
}
|
|
664
667
|
};
|
|
665
|
-
var analyzeOne = (node, functionId, name, sourceFile,
|
|
668
|
+
var analyzeOne = (node, functionId, name, sourceFile, moduleCallees) => {
|
|
666
669
|
const ctx = {
|
|
667
670
|
sourceFile,
|
|
668
671
|
functionId,
|
|
@@ -678,7 +681,7 @@ var analyzeOne = (node, functionId, name, sourceFile, provenExact) => {
|
|
|
678
681
|
nextAssignmentId: { value: 0 },
|
|
679
682
|
hasThrow: false,
|
|
680
683
|
hasCoercionGuard: false,
|
|
681
|
-
|
|
684
|
+
moduleCallees,
|
|
682
685
|
identifierParams: []
|
|
683
686
|
};
|
|
684
687
|
if (node.asteriskToken || node.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword)) {
|
|
@@ -735,14 +738,20 @@ var analyzeModuleFunctions = (sourceFile, targets) => {
|
|
|
735
738
|
graph
|
|
736
739
|
);
|
|
737
740
|
const byId = new Map(targets.map((target) => [target.functionId, target]));
|
|
738
|
-
const
|
|
741
|
+
const moduleCallees = /* @__PURE__ */ new Map();
|
|
739
742
|
const analyzed = [];
|
|
740
743
|
for (const functionId of order) {
|
|
741
744
|
const target = byId.get(functionId);
|
|
742
745
|
if (!target) continue;
|
|
743
|
-
const result = analyzeOne(
|
|
744
|
-
|
|
745
|
-
|
|
746
|
+
const result = analyzeOne(
|
|
747
|
+
target.node,
|
|
748
|
+
target.functionId,
|
|
749
|
+
target.name,
|
|
750
|
+
sourceFile,
|
|
751
|
+
moduleCallees
|
|
752
|
+
);
|
|
753
|
+
if (nameCounts.get(result.name) === 1) {
|
|
754
|
+
moduleCallees.set(result.name, result.functionId);
|
|
746
755
|
}
|
|
747
756
|
analyzed.push(result);
|
|
748
757
|
}
|
|
@@ -750,11 +759,16 @@ var analyzeModuleFunctions = (sourceFile, targets) => {
|
|
|
750
759
|
(target) => !analyzed.some((fn) => fn.functionId === target.functionId)
|
|
751
760
|
);
|
|
752
761
|
for (const target of remaining) {
|
|
753
|
-
analyzed.push(
|
|
762
|
+
analyzed.push(
|
|
763
|
+
analyzeOne(target.node, target.functionId, target.name, sourceFile, moduleCallees)
|
|
764
|
+
);
|
|
754
765
|
}
|
|
755
766
|
return analyzed;
|
|
756
767
|
};
|
|
757
768
|
|
|
769
|
+
// src/derivation/derivation-proof.ts
|
|
770
|
+
var functionIsExact = (plan) => plan.fallbackReason === void 0 && plan.captureBoundaries.length === 0 && plan.controlFacts.length === 0;
|
|
771
|
+
|
|
758
772
|
// src/derivation/emit-capture-plan.ts
|
|
759
773
|
var captureWrapEdits = (wraps, capName) => {
|
|
760
774
|
const edits = [];
|
|
@@ -762,7 +776,7 @@ var captureWrapEdits = (wraps, capName) => {
|
|
|
762
776
|
for (const wrap of wraps) {
|
|
763
777
|
edits.push({
|
|
764
778
|
position: wrap.start,
|
|
765
|
-
text: `${capName}(${wrap.rootId},`,
|
|
779
|
+
text: `${wrap.shorthandPropertyName ? `${wrap.shorthandPropertyName}:` : ""}${capName}(${wrap.rootId},`,
|
|
766
780
|
order: order++
|
|
767
781
|
});
|
|
768
782
|
edits.push({
|
package/dist/sdk-meta.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rasputin-ai/node",
|
|
3
|
-
"version": "0.5.0-alpha.
|
|
3
|
+
"version": "0.5.0-alpha.9",
|
|
4
4
|
"description": "Official Rasputin AI SDK for Node and Bun.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
47
|
-
"@rasputin-ai/core": "0.5.0-alpha.
|
|
47
|
+
"@rasputin-ai/core": "0.5.0-alpha.9",
|
|
48
48
|
"typescript": "5"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|