@moda-ai/cli 1.55.85 → 1.55.87
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/{agent-anya3x2b.js → agent-qn9ymfs0.js} +3 -3
- package/dist/{cli-v43q6cg9.js → cli-aedmnm1c.js} +3 -3
- package/dist/{cli-aj336k6v.js → cli-hedrh5p9.js} +2 -2
- package/dist/{cli-7vywvw8v.js → cli-vvn3x5tj.js} +389 -141
- package/dist/cli.js +7 -7
- package/dist/{doctor-sa0q9ca6.js → doctor-dhgzp9p2.js} +2 -2
- package/dist/{harness-w3fnq796.js → harness-b6z16pgd.js} +1 -1
- package/dist/{harness-github-actions-ma33g263.js → harness-github-actions-q2j5hhqb.js} +1 -1
- package/dist/{index-jvs3ksx6.js → index-fg91fjtb.js} +1 -1
- package/dist/{index-zzyx7qgy.js → index-h0ay0dp2.js} +3 -3
- package/dist/{index-2bctz222.js → index-z8cpym48.js} +1 -1
- package/dist/{prompt-attribution-51shashb.js → prompt-attribution-tpf7gr3x.js} +1 -1
- package/dist/prompt-source-mcp.js +1 -1
- package/dist/{prompts-d484wq58.js → prompts-83y14sh2.js} +1 -1
- package/dist/{sync-tpkqgm6r.js → sync-wzx6ewqz.js} +2 -2
- package/package.json +1 -1
- package/skills/integration/index.json +2 -2
|
@@ -109,10 +109,10 @@ import {
|
|
|
109
109
|
} from "./cli-0v6na3yp.js";
|
|
110
110
|
|
|
111
111
|
// src/harness-extract/enumerators/agents.ts
|
|
112
|
-
var
|
|
112
|
+
var import_typescript15 = __toESM(require_typescript(), 1);
|
|
113
113
|
|
|
114
114
|
// src/harness-extract/index.ts
|
|
115
|
-
var
|
|
115
|
+
var import_typescript14 = __toESM(require_typescript(), 1);
|
|
116
116
|
import { resolve as resolve13 } from "node:path";
|
|
117
117
|
|
|
118
118
|
// src/harness-extract/ast.ts
|
|
@@ -18072,6 +18072,8 @@ class PromptResolver {
|
|
|
18072
18072
|
callersByName = new Map;
|
|
18073
18073
|
aliasesByName = new Map;
|
|
18074
18074
|
callersIndexed = false;
|
|
18075
|
+
resolvedCallers = new WeakMap;
|
|
18076
|
+
locallyWrittenParameters = new WeakMap;
|
|
18075
18077
|
methodIndex;
|
|
18076
18078
|
constructor(context, options) {
|
|
18077
18079
|
this.context = context;
|
|
@@ -18463,8 +18465,48 @@ class PromptResolver {
|
|
|
18463
18465
|
return;
|
|
18464
18466
|
}
|
|
18465
18467
|
const checker = this.context.checkerFor(this.relative(callee.expression.getSourceFile().fileName));
|
|
18466
|
-
const
|
|
18467
|
-
|
|
18468
|
+
const arrayType = (type, awaited = false) => {
|
|
18469
|
+
if (!type)
|
|
18470
|
+
return false;
|
|
18471
|
+
if (import_typescript8.default.isArrayTypeNode(type) || import_typescript8.default.isTupleTypeNode(type))
|
|
18472
|
+
return true;
|
|
18473
|
+
if (import_typescript8.default.isTypeOperatorNode(type))
|
|
18474
|
+
return arrayType(type.type, awaited);
|
|
18475
|
+
if (!import_typescript8.default.isTypeReferenceNode(type))
|
|
18476
|
+
return false;
|
|
18477
|
+
const name = type.typeName.getText();
|
|
18478
|
+
return /^(?:Readonly)?Array$/.test(name) || awaited && name === "Promise" && arrayType(type.typeArguments?.[0]);
|
|
18479
|
+
};
|
|
18480
|
+
const arraySeen = new Set;
|
|
18481
|
+
const isArrayReceiver = (expression, awaited = false) => {
|
|
18482
|
+
const raw = unwrapNode(expression);
|
|
18483
|
+
if (import_typescript8.default.isAwaitExpression(raw))
|
|
18484
|
+
return isArrayReceiver(raw.expression, true);
|
|
18485
|
+
const receiver = unwrap2(expression);
|
|
18486
|
+
if (arraySeen.has(receiver))
|
|
18487
|
+
return false;
|
|
18488
|
+
arraySeen.add(receiver);
|
|
18489
|
+
if (import_typescript8.default.isAwaitExpression(receiver))
|
|
18490
|
+
return isArrayReceiver(receiver.expression, true);
|
|
18491
|
+
if (import_typescript8.default.isIdentifier(receiver)) {
|
|
18492
|
+
for (const declaration of this.declarationsOf(receiver)) {
|
|
18493
|
+
if ((import_typescript8.default.isVariableDeclaration(declaration) || import_typescript8.default.isParameter(declaration)) && (arrayType(declaration.type) || declaration.initializer && isArrayReceiver(declaration.initializer)))
|
|
18494
|
+
return true;
|
|
18495
|
+
}
|
|
18496
|
+
}
|
|
18497
|
+
if (import_typescript8.default.isCallExpression(receiver)) {
|
|
18498
|
+
for (const declaration of this.declarationsOf(import_typescript8.default.isPropertyAccessExpression(receiver.expression) ? receiver.expression.name : receiver.expression)) {
|
|
18499
|
+
const fn = functionOf(declaration);
|
|
18500
|
+
if (fn && arrayType(fn.type, awaited))
|
|
18501
|
+
return true;
|
|
18502
|
+
}
|
|
18503
|
+
}
|
|
18504
|
+
const type = checker?.getTypeAtLocation(receiver);
|
|
18505
|
+
if (import_typescript8.default.isArrayLiteralExpression(this.objectLiteralOf(receiver) ?? receiver) || !!checker && !!type && (type.isUnion() ? type.types : [type]).every((item) => checker.isArrayType(item) || checker.isTupleType(item)))
|
|
18506
|
+
return true;
|
|
18507
|
+
return import_typescript8.default.isCallExpression(receiver) && import_typescript8.default.isPropertyAccessExpression(receiver.expression) && ARRAY_ASSEMBLY_METHODS.has(receiver.expression.name.text) && receiver.expression.name.text !== "join" && isArrayReceiver(receiver.expression.expression);
|
|
18508
|
+
};
|
|
18509
|
+
const arrayReceiver = isArrayReceiver(callee.expression);
|
|
18468
18510
|
if ((method === "find" || method === "findLast") && arrayReceiver) {
|
|
18469
18511
|
this.value(callee.expression, owner, { ...flag(walk, "dynamic-key"), project: [ARRAY_ELEMENT, ...walk.project] });
|
|
18470
18512
|
return;
|
|
@@ -18570,6 +18612,10 @@ class PromptResolver {
|
|
|
18570
18612
|
if (walk.seen.has(fn))
|
|
18571
18613
|
continue;
|
|
18572
18614
|
const name = functionName2(fn);
|
|
18615
|
+
if (walk.depth + 1 > this.maxDepth) {
|
|
18616
|
+
this.markUnresolved(call, "depth-limit", walk);
|
|
18617
|
+
continue;
|
|
18618
|
+
}
|
|
18573
18619
|
const next = this.step(walk, fn, `builder ${name ?? "function"} called at ${this.where(call)}`);
|
|
18574
18620
|
if (!next)
|
|
18575
18621
|
continue;
|
|
@@ -18676,6 +18722,8 @@ class PromptResolver {
|
|
|
18676
18722
|
return;
|
|
18677
18723
|
}
|
|
18678
18724
|
if (import_typescript8.default.isVariableDeclaration(declaration)) {
|
|
18725
|
+
if (/^\d+$/.test(next.project[0] ?? "") && this.assembly(declaration, ownerFor(declaration, name, owner), next, at, true))
|
|
18726
|
+
return;
|
|
18679
18727
|
if (!owner && next.flags.includes("interpolated") && declaration.initializer) {
|
|
18680
18728
|
let scope = declaration.parent;
|
|
18681
18729
|
while (scope && !import_typescript8.default.isFunctionLike(scope))
|
|
@@ -18749,12 +18797,12 @@ class PromptResolver {
|
|
|
18749
18797
|
if (fn)
|
|
18750
18798
|
this.builderBody(fn, { node: declaration, name, kind: "builder" }, next);
|
|
18751
18799
|
}
|
|
18752
|
-
assembly(declaration, owner, walk, at) {
|
|
18800
|
+
assembly(declaration, owner, walk, at, probe = false) {
|
|
18753
18801
|
if (!import_typescript8.default.isIdentifier(declaration.name))
|
|
18754
|
-
return;
|
|
18802
|
+
return false;
|
|
18755
18803
|
const scope = enclosingScope2(declaration);
|
|
18756
18804
|
if (!scope)
|
|
18757
|
-
return;
|
|
18805
|
+
return false;
|
|
18758
18806
|
const assignments = [];
|
|
18759
18807
|
const findRebinding = (node) => {
|
|
18760
18808
|
if (import_typescript8.default.isFunctionLike(node))
|
|
@@ -18800,7 +18848,7 @@ class PromptResolver {
|
|
|
18800
18848
|
return new Set;
|
|
18801
18849
|
const next = new Set(seen).add(value);
|
|
18802
18850
|
if (import_typescript8.default.isIdentifier(value)) {
|
|
18803
|
-
const entry = this.declarationsOf(value).find((item) => import_typescript8.default.isVariableDeclaration(item));
|
|
18851
|
+
const entry = this.declarationsOf(value).find((item) => import_typescript8.default.isVariableDeclaration(item) || import_typescript8.default.isParameter(item));
|
|
18804
18852
|
if (entry === declaration)
|
|
18805
18853
|
return versionsAt(value);
|
|
18806
18854
|
if (entry && import_typescript8.default.isVariableDeclaration(entry) && entry.initializer && entry.parent.flags & import_typescript8.default.NodeFlags.Const)
|
|
@@ -18911,15 +18959,24 @@ class PromptResolver {
|
|
|
18911
18959
|
});
|
|
18912
18960
|
};
|
|
18913
18961
|
const isThis = (identifier) => references(identifier);
|
|
18962
|
+
let indexedMutation = false;
|
|
18914
18963
|
const visit = (node) => {
|
|
18915
18964
|
if (import_typescript8.default.isFunctionLike(node) && !invoked(node))
|
|
18916
18965
|
return;
|
|
18917
18966
|
if (import_typescript8.default.isCallExpression(node) && import_typescript8.default.isPropertyAccessExpression(node.expression) && references(node.expression.expression) && /^(?:push|unshift|splice)$/.test(node.expression.name.text)) {
|
|
18967
|
+
if (/^\d+$/.test(walk.project[0] ?? "")) {
|
|
18968
|
+
indexedMutation = true;
|
|
18969
|
+
this.markUnresolved(node, "dynamic-key", walk);
|
|
18970
|
+
return;
|
|
18971
|
+
}
|
|
18972
|
+
if (probe)
|
|
18973
|
+
return;
|
|
18918
18974
|
const args = node.expression.name.text === "splice" ? node.arguments.slice(2) : node.arguments;
|
|
18975
|
+
const elementWalk = walk.project[0] === ARRAY_ELEMENT || walk.project[0] === FLATMAP_ELEMENT ? { ...walk, project: walk.project.slice(1) } : walk;
|
|
18919
18976
|
for (const argument of args)
|
|
18920
|
-
this.value(argument, owner,
|
|
18977
|
+
this.value(argument, owner, elementWalk);
|
|
18921
18978
|
}
|
|
18922
|
-
if (import_typescript8.default.isBinaryExpression(node) && import_typescript8.default.isIdentifier(node.left) && (isThis(node.left) || readVersions.has(node))) {
|
|
18979
|
+
if (!probe && import_typescript8.default.isBinaryExpression(node) && import_typescript8.default.isIdentifier(node.left) && (isThis(node.left) || readVersions.has(node))) {
|
|
18923
18980
|
if (node.operatorToken.kind === import_typescript8.default.SyntaxKind.PlusEqualsToken)
|
|
18924
18981
|
this.value(node.right, owner, walk);
|
|
18925
18982
|
if (node.operatorToken.kind === import_typescript8.default.SyntaxKind.EqualsToken && node.right !== declaration.initializer)
|
|
@@ -18928,8 +18985,37 @@ class PromptResolver {
|
|
|
18928
18985
|
import_typescript8.default.forEachChild(node, visit);
|
|
18929
18986
|
};
|
|
18930
18987
|
visit(scope);
|
|
18988
|
+
return indexedMutation;
|
|
18989
|
+
}
|
|
18990
|
+
parameterHasLocalWrites(parameter) {
|
|
18991
|
+
const cached = this.locallyWrittenParameters.get(parameter);
|
|
18992
|
+
if (cached !== undefined)
|
|
18993
|
+
return cached;
|
|
18994
|
+
let written = false;
|
|
18995
|
+
const name = import_typescript8.default.isIdentifier(parameter.name) ? parameter.name.text : undefined;
|
|
18996
|
+
const scope = enclosingScope2(parameter);
|
|
18997
|
+
const isParameter = (expression) => import_typescript8.default.isIdentifier(expression) && expression.text === name && this.declarationsOf(expression).includes(parameter);
|
|
18998
|
+
const visit = (node) => {
|
|
18999
|
+
if (written)
|
|
19000
|
+
return;
|
|
19001
|
+
if (import_typescript8.default.isBinaryExpression(node) && [import_typescript8.default.SyntaxKind.EqualsToken, import_typescript8.default.SyntaxKind.PlusEqualsToken].includes(node.operatorToken.kind)) {
|
|
19002
|
+
written = isParameter(node.left) || import_typescript8.default.isElementAccessExpression(node.left) && isParameter(node.left.expression);
|
|
19003
|
+
} else if (import_typescript8.default.isCallExpression(node) && import_typescript8.default.isPropertyAccessExpression(node.expression) && /^(?:push|unshift|splice)$/.test(node.expression.name.text)) {
|
|
19004
|
+
written = isParameter(node.expression.expression);
|
|
19005
|
+
}
|
|
19006
|
+
if (!written)
|
|
19007
|
+
import_typescript8.default.forEachChild(node, visit);
|
|
19008
|
+
};
|
|
19009
|
+
if (scope)
|
|
19010
|
+
visit(scope);
|
|
19011
|
+
this.locallyWrittenParameters.set(parameter, written);
|
|
19012
|
+
return written;
|
|
18931
19013
|
}
|
|
18932
19014
|
parameter(declaration, at, owner, walk) {
|
|
19015
|
+
if (import_typescript8.default.isParameter(declaration) && import_typescript8.default.isIdentifier(declaration.name) && !walk.seen.has(declaration) && this.parameterHasLocalWrites(declaration)) {
|
|
19016
|
+
const local = { ...walk, seen: new Set(walk.seen).add(declaration) };
|
|
19017
|
+
this.assembly(declaration, owner, local, at);
|
|
19018
|
+
}
|
|
18933
19019
|
const bound = walk.bindings.get(declaration);
|
|
18934
19020
|
if (bound) {
|
|
18935
19021
|
const project = [...bound.project ?? [], ...walk.project];
|
|
@@ -18991,6 +19077,9 @@ class PromptResolver {
|
|
|
18991
19077
|
}
|
|
18992
19078
|
}
|
|
18993
19079
|
callersOf(fn) {
|
|
19080
|
+
const cached = this.resolvedCallers.get(fn);
|
|
19081
|
+
if (cached)
|
|
19082
|
+
return cached;
|
|
18994
19083
|
const name = functionName2(fn);
|
|
18995
19084
|
if (!name)
|
|
18996
19085
|
return [];
|
|
@@ -18998,12 +19087,14 @@ class PromptResolver {
|
|
|
18998
19087
|
const names = [name, ...this.aliasesByName.get(name) ?? []];
|
|
18999
19088
|
const candidates = names.flatMap((alias) => this.callersByName.get(alias) ?? []);
|
|
19000
19089
|
const signatures = this.implementedSignatures(fn, name);
|
|
19001
|
-
|
|
19090
|
+
const callers = candidates.filter((call) => {
|
|
19002
19091
|
const callee = import_typescript8.default.isPropertyAccessExpression(call.expression) ? call.expression.name : call.expression;
|
|
19003
19092
|
const checker = this.context.checkerFor(this.relative(call.getSourceFile().fileName));
|
|
19004
19093
|
const members = checker && import_typescript8.default.isPropertyAccessExpression(call.expression) ? receiverClasses(call.expression.expression, checker).flatMap((cls) => cls.members.filter((member) => member.name?.getText() === name)) : [];
|
|
19005
19094
|
return [...this.declarationsOf(callee), ...members].some((declaration) => functionOf(declaration) === fn || declaration === fn || signatures.has(declaration) && !!checker && contextualReceiverMatches(call, fn, checker));
|
|
19006
19095
|
});
|
|
19096
|
+
this.resolvedCallers.set(fn, callers);
|
|
19097
|
+
return callers;
|
|
19007
19098
|
}
|
|
19008
19099
|
implementedSignatures(fn, name) {
|
|
19009
19100
|
const checker = this.context.checkerFor(this.relative(fn.getSourceFile().fileName));
|
|
@@ -19305,6 +19396,8 @@ function contains(outer, inner) {
|
|
|
19305
19396
|
return inner.getStart() >= outer.getStart() && inner.getEnd() <= outer.getEnd();
|
|
19306
19397
|
}
|
|
19307
19398
|
function enclosingScope2(declaration) {
|
|
19399
|
+
if (import_typescript8.default.isParameter(declaration) && import_typescript8.default.isFunctionLike(declaration.parent) && "body" in declaration.parent)
|
|
19400
|
+
return declaration.parent.body;
|
|
19308
19401
|
for (let node = declaration.parent;node; node = node.parent) {
|
|
19309
19402
|
if (import_typescript8.default.isBlock(node) || import_typescript8.default.isSourceFile(node) || import_typescript8.default.isModuleBlock(node))
|
|
19310
19403
|
return node;
|
|
@@ -19472,7 +19565,7 @@ function unresolvedReports(resolution, sites) {
|
|
|
19472
19565
|
const resolvedSites = new Set(resolution.refs.flatMap((ref) => ref.callSiteIds.map((id) => `${id}|${ref.role}`)));
|
|
19473
19566
|
const reports = new Map;
|
|
19474
19567
|
for (const value of resolution.unresolved) {
|
|
19475
|
-
if (resolvedSites.has(`${value.callSiteId}|${value.role}`))
|
|
19568
|
+
if (value.reason !== "depth-limit" && resolvedSites.has(`${value.callSiteId}|${value.role}`))
|
|
19476
19569
|
continue;
|
|
19477
19570
|
const site = sites.get(value.callSiteId);
|
|
19478
19571
|
if (!site)
|
|
@@ -19823,7 +19916,7 @@ async function runHarnessCommand(context) {
|
|
|
19823
19916
|
throw new CliInputError("Focused remote prompt analysis is not supported yet.", "Use local --analyst=claude|codex|cursor|local-scan, or drop --concern for a full remote report.");
|
|
19824
19917
|
}
|
|
19825
19918
|
if (context.flags["github-actions"] === "true") {
|
|
19826
|
-
const { runGithubActionsAnalyze } = await import("./harness-github-actions-
|
|
19919
|
+
const { runGithubActionsAnalyze } = await import("./harness-github-actions-q2j5hhqb.js");
|
|
19827
19920
|
const result = await runGithubActionsAnalyze(rootDir, {
|
|
19828
19921
|
writeReport: (report2) => {
|
|
19829
19922
|
const normalized = normalizeHarnessReport(report2);
|
|
@@ -19974,8 +20067,8 @@ async function runHarnessCommand(context) {
|
|
|
19974
20067
|
}
|
|
19975
20068
|
const { artifacts, unknowns, canonicalAgentIdentities } = deterministicGraphItems(rootDir, promote === "all" ? undefined : promote);
|
|
19976
20069
|
tagComponentStatus({ runtimeAgents: [], artifacts }, rootDir);
|
|
19977
|
-
const { extractHarnessWithContext: extractHarnessWithContext2 } = await import("./index-
|
|
19978
|
-
const { enumerateHarnessComponents, mergeEnumeratedComponents } = await import("./index-
|
|
20070
|
+
const { extractHarnessWithContext: extractHarnessWithContext2 } = await import("./index-z8cpym48.js");
|
|
20071
|
+
const { enumerateHarnessComponents, mergeEnumeratedComponents } = await import("./index-fg91fjtb.js");
|
|
19979
20072
|
let components = { runtimeAgents: [], artifacts: [], warnings: [] };
|
|
19980
20073
|
if (promote === "all" || promote === "topology" || promote === "tools") {
|
|
19981
20074
|
const { result, ctx } = extractHarnessWithContext2(rootDir);
|
|
@@ -20009,12 +20102,16 @@ async function runHarnessCommand(context) {
|
|
|
20009
20102
|
}
|
|
20010
20103
|
case "extract": {
|
|
20011
20104
|
writeHumanProgress(context, "Harness extract: tracing model call sites (no LLM, no network)...");
|
|
20012
|
-
const { extractHarnessWithContext: extractHarnessWithContext2, serializeExtractResult } = await import("./index-
|
|
20013
|
-
const { enumerateHarnessComponents, mergeEnumeratedComponents } = await import("./index-
|
|
20105
|
+
const { extractHarnessWithContext: extractHarnessWithContext2, serializeExtractResult } = await import("./index-z8cpym48.js");
|
|
20106
|
+
const { enumerateHarnessComponents, mergeEnumeratedComponents } = await import("./index-fg91fjtb.js");
|
|
20014
20107
|
const { result, ctx } = extractHarnessWithContext2(rootDir, { fresh: true });
|
|
20015
|
-
const
|
|
20108
|
+
const items = deterministicGraphItems(rootDir);
|
|
20109
|
+
const artifacts = items.artifacts;
|
|
20016
20110
|
tagComponentStatus({ runtimeAgents: [], artifacts }, rootDir);
|
|
20017
|
-
const graph =
|
|
20111
|
+
const graph = {
|
|
20112
|
+
...mergeEnumeratedComponents(artifacts, enumerateHarnessComponents(result, ctx)),
|
|
20113
|
+
unknowns: items.unknowns.filter((item) => item.id.startsWith("unresolved_prompt_depth_"))
|
|
20114
|
+
};
|
|
20018
20115
|
writeHumanProgress(context, `Harness extract: ${result.callSites.length} call sites, ${result.roles.length} traced roles across ${result.files} files (${result.programs} programs, ${result.durationMs.toLocaleString()} ms).`);
|
|
20019
20116
|
context.output.writeData({ ...serializeExtractResult(result), graph }, {
|
|
20020
20117
|
status: result.warnings.length > 0 ? "degraded" : "success",
|
|
@@ -20913,8 +21010,8 @@ var CONCERN_PROMOTED_ARTIFACT_TYPES = {
|
|
|
20913
21010
|
evals: new Set(["model_config", "eval"])
|
|
20914
21011
|
};
|
|
20915
21012
|
async function deterministicFloorGraph(rootDir, options = {}) {
|
|
20916
|
-
const { extractHarnessWithContext: extractHarnessWithContext2 } = await import("./index-
|
|
20917
|
-
const { enumerateHarnessComponents, mergeEnumeratedComponents } = await import("./index-
|
|
21013
|
+
const { extractHarnessWithContext: extractHarnessWithContext2 } = await import("./index-z8cpym48.js");
|
|
21014
|
+
const { enumerateHarnessComponents, mergeEnumeratedComponents } = await import("./index-fg91fjtb.js");
|
|
20918
21015
|
const { result, ctx } = extractHarnessWithContext2(rootDir);
|
|
20919
21016
|
const items = deterministicGraphItems(rootDir);
|
|
20920
21017
|
const components = mergeEnumeratedComponents(items.artifacts, enumerateHarnessComponents(result, ctx));
|
|
@@ -21062,7 +21159,7 @@ function mergeDeterministicArtifacts(graph, rootDir, options = {}) {
|
|
|
21062
21159
|
try {
|
|
21063
21160
|
promoted = promoteHarnessCandidates(detectHarnessCandidates(rootDir), rootDir, { fullEvidence: true });
|
|
21064
21161
|
if (!allowedTypes || allowedTypes.has("prompt"))
|
|
21065
|
-
promoted = withCallSitePrompts(rootDir, promoted);
|
|
21162
|
+
promoted = withCallSitePrompts(rootDir, promoted, graph.unknowns ??= []);
|
|
21066
21163
|
} catch {
|
|
21067
21164
|
promoted = [];
|
|
21068
21165
|
}
|
|
@@ -21203,14 +21300,32 @@ function remapCanonicalArtifactAgents(graph, artifacts = graph.artifacts, dropUn
|
|
|
21203
21300
|
});
|
|
21204
21301
|
}
|
|
21205
21302
|
}
|
|
21206
|
-
function withCallSitePrompts(rootDir, promoted) {
|
|
21303
|
+
function withCallSitePrompts(rootDir, promoted, unknowns = []) {
|
|
21207
21304
|
if (process.env.MODA_HARNESS_CALLSITE_PROMPTS === "0")
|
|
21208
21305
|
return promoted;
|
|
21209
21306
|
try {
|
|
21210
21307
|
const { result, ctx } = extractHarnessWithContext(rootDir);
|
|
21211
21308
|
const sites = result.callSites.filter((site) => !site.isTest);
|
|
21212
21309
|
const toolDefinitions = result.toolDefinitions ?? [];
|
|
21213
|
-
|
|
21310
|
+
const assembled = promptArtifactsFromCallSites(sites, ctx, promoted, { toolDefinitions, agentForScope: createAgentScopeResolver(result, ctx) });
|
|
21311
|
+
for (const report of assembled.unresolved) {
|
|
21312
|
+
const limited = report.values.filter((value) => value.reason === "depth-limit");
|
|
21313
|
+
if (!limited.length)
|
|
21314
|
+
continue;
|
|
21315
|
+
const id = stableId("unresolved_prompt_depth", `${report.callSiteId}:${report.role}`);
|
|
21316
|
+
if (unknowns.some((unknown) => unknown.id === id))
|
|
21317
|
+
continue;
|
|
21318
|
+
unknowns.push({
|
|
21319
|
+
id,
|
|
21320
|
+
question: `trace depth limit: ${report.role} prompt at ${report.path}:${report.line} has unresolved source paths.`,
|
|
21321
|
+
candidateIds: [],
|
|
21322
|
+
evidence: [
|
|
21323
|
+
{ path: report.path, line: report.line, reason: "trace depth limit at model call site" },
|
|
21324
|
+
...limited.map((value) => ({ path: value.path, line: value.line, reason: `trace depth limit: ${value.expression}` }))
|
|
21325
|
+
]
|
|
21326
|
+
});
|
|
21327
|
+
}
|
|
21328
|
+
return assembled.artifacts;
|
|
21214
21329
|
} catch {
|
|
21215
21330
|
return promoted;
|
|
21216
21331
|
}
|
|
@@ -28882,6 +28997,126 @@ function toolArtifacts(tools, runtimeAgents = []) {
|
|
|
28882
28997
|
});
|
|
28883
28998
|
}
|
|
28884
28999
|
|
|
29000
|
+
// src/harness-extract/handoffs.ts
|
|
29001
|
+
var import_typescript13 = __toESM(require_typescript(), 1);
|
|
29002
|
+
var MAX_OWNER_HOPS = 6;
|
|
29003
|
+
var MAX_CALLERS_PER_HOP = 25;
|
|
29004
|
+
function collectHandoffs(inputs) {
|
|
29005
|
+
const { rootDir } = inputs;
|
|
29006
|
+
const handoffs = [];
|
|
29007
|
+
const classes = [];
|
|
29008
|
+
const ref = (cls) => {
|
|
29009
|
+
const name = className(cls);
|
|
29010
|
+
return name ? { name, path: relPath(rootDir, cls.getSourceFile().fileName), line: lineOf(cls) } : undefined;
|
|
29011
|
+
};
|
|
29012
|
+
const repoClass = (found) => {
|
|
29013
|
+
const init = found && import_typescript13.default.isVariableDeclaration(found) && found.initializer ? unwrap(found.initializer) : undefined;
|
|
29014
|
+
const decl = init && import_typescript13.default.isClassExpression(init) ? init : found;
|
|
29015
|
+
if (!decl || !(import_typescript13.default.isClassDeclaration(decl) || import_typescript13.default.isClassExpression(decl)))
|
|
29016
|
+
return;
|
|
29017
|
+
const file = decl.getSourceFile();
|
|
29018
|
+
return file.isDeclarationFile || /[\\/]node_modules[\\/]/.test(file.fileName) ? undefined : decl;
|
|
29019
|
+
};
|
|
29020
|
+
const targetsOf = (expression, checker, depth = 0) => {
|
|
29021
|
+
if (depth > 4)
|
|
29022
|
+
return [];
|
|
29023
|
+
const node = unwrap(expression);
|
|
29024
|
+
if (import_typescript13.default.isPropertyAccessExpression(node) || import_typescript13.default.isElementAccessExpression(node)) {
|
|
29025
|
+
const object = objectOf(node.expression, checker);
|
|
29026
|
+
if (object) {
|
|
29027
|
+
const key = import_typescript13.default.isPropertyAccessExpression(node) ? node.name.text : import_typescript13.default.isStringLiteralLike(unwrap(node.argumentExpression)) ? unwrap(node.argumentExpression).text : undefined;
|
|
29028
|
+
const members = object.properties.filter((p2) => import_typescript13.default.isPropertyAssignment(p2) || import_typescript13.default.isShorthandPropertyAssignment(p2));
|
|
29029
|
+
const picked = key !== undefined ? members.filter((p2) => propertyNameText(p2.name) === key) : [];
|
|
29030
|
+
return (picked.length > 0 ? picked : members).flatMap((p2) => import_typescript13.default.isPropertyAssignment(p2) ? targetsOf(p2.initializer, checker, depth + 1) : targetsOf(p2.name, checker, depth + 1));
|
|
29031
|
+
}
|
|
29032
|
+
}
|
|
29033
|
+
const cls = repoClass(valueDeclaration(resolvedSymbol(node, checker)));
|
|
29034
|
+
return cls ? [cls] : [];
|
|
29035
|
+
};
|
|
29036
|
+
const ownersOf = (call) => {
|
|
29037
|
+
const own = enclosingClass(call);
|
|
29038
|
+
const owned = own && ref(own);
|
|
29039
|
+
if (owned)
|
|
29040
|
+
return [{ ...owned, via: "own code" }];
|
|
29041
|
+
const out = [];
|
|
29042
|
+
const seen = new Set;
|
|
29043
|
+
const withOuter = (node) => {
|
|
29044
|
+
const out2 = [];
|
|
29045
|
+
for (let f = inputs.namedEnclosingFunction(node);f; f = inputs.namedEnclosingFunction(f.fn))
|
|
29046
|
+
out2.push(f);
|
|
29047
|
+
return out2;
|
|
29048
|
+
};
|
|
29049
|
+
let frontier = withOuter(call);
|
|
29050
|
+
for (let hop = 0;hop < MAX_OWNER_HOPS && frontier.length > 0; hop += 1) {
|
|
29051
|
+
const next = [];
|
|
29052
|
+
for (const fn of frontier) {
|
|
29053
|
+
if (seen.has(fn.fn))
|
|
29054
|
+
continue;
|
|
29055
|
+
seen.add(fn.fn);
|
|
29056
|
+
for (const caller of inputs.calls.callersOf(fn.fn, fn.name, MAX_CALLERS_PER_HOP)) {
|
|
29057
|
+
const cls = enclosingClass(caller);
|
|
29058
|
+
const owner = cls && ref(cls);
|
|
29059
|
+
if (owner) {
|
|
29060
|
+
const via = `${relPath(rootDir, caller.getSourceFile().fileName)}:${lineOf(caller)}`;
|
|
29061
|
+
if (!out.some((o) => o.name === owner.name && o.path === owner.path))
|
|
29062
|
+
out.push({ ...owner, via });
|
|
29063
|
+
} else {
|
|
29064
|
+
next.push(...withOuter(caller));
|
|
29065
|
+
}
|
|
29066
|
+
}
|
|
29067
|
+
}
|
|
29068
|
+
frontier = next;
|
|
29069
|
+
}
|
|
29070
|
+
return out;
|
|
29071
|
+
};
|
|
29072
|
+
for (const { source, checker } of inputs.files) {
|
|
29073
|
+
const visit2 = (node) => {
|
|
29074
|
+
if ((import_typescript13.default.isClassDeclaration(node) || import_typescript13.default.isClassExpression(node)) && node.heritageClauses) {
|
|
29075
|
+
const extended = node.heritageClauses.find((clause) => clause.token === import_typescript13.default.SyntaxKind.ExtendsKeyword)?.types[0];
|
|
29076
|
+
const named = ref(node);
|
|
29077
|
+
if (extended && named)
|
|
29078
|
+
classes.push({ ...named, base: extended.expression.getText(source) });
|
|
29079
|
+
}
|
|
29080
|
+
if (import_typescript13.default.isCallExpression(node) && node.arguments.length > 0) {
|
|
29081
|
+
const targets = targetsOf(node.arguments[0], checker).map(ref).filter((r) => Boolean(r));
|
|
29082
|
+
if (targets.length > 0) {
|
|
29083
|
+
const cls = enclosingClass(node);
|
|
29084
|
+
const fn = inputs.namedEnclosingFunction(node);
|
|
29085
|
+
handoffs.push({
|
|
29086
|
+
path: relPath(rootDir, source.fileName),
|
|
29087
|
+
line: lineOf(node),
|
|
29088
|
+
col: colOf(node),
|
|
29089
|
+
callee: node.expression.getText(source).replace(/\s+/g, ""),
|
|
29090
|
+
targets: dedupe(targets),
|
|
29091
|
+
...cls && className(cls) ? { enclosingClass: className(cls) } : {},
|
|
29092
|
+
...fn ? { enclosingFunction: fn.name } : {},
|
|
29093
|
+
scope: inputs.scopeOf(node),
|
|
29094
|
+
owners: ownersOf(node)
|
|
29095
|
+
});
|
|
29096
|
+
}
|
|
29097
|
+
}
|
|
29098
|
+
import_typescript13.default.forEachChild(node, visit2);
|
|
29099
|
+
};
|
|
29100
|
+
visit2(source);
|
|
29101
|
+
}
|
|
29102
|
+
return { handoffs, classes };
|
|
29103
|
+
}
|
|
29104
|
+
function objectOf(expression, checker) {
|
|
29105
|
+
const node = unwrap(expression);
|
|
29106
|
+
if (import_typescript13.default.isObjectLiteralExpression(node))
|
|
29107
|
+
return node;
|
|
29108
|
+
const decl = valueDeclaration(resolvedSymbol(node, checker));
|
|
29109
|
+
if (decl && import_typescript13.default.isVariableDeclaration(decl) && decl.initializer) {
|
|
29110
|
+
const init = unwrap(decl.initializer);
|
|
29111
|
+
return import_typescript13.default.isObjectLiteralExpression(init) ? init : undefined;
|
|
29112
|
+
}
|
|
29113
|
+
return;
|
|
29114
|
+
}
|
|
29115
|
+
function dedupe(refs) {
|
|
29116
|
+
const seen = new Set;
|
|
29117
|
+
return refs.filter((r) => !seen.has(`${r.path}:${r.name}`) && seen.add(`${r.path}:${r.name}`));
|
|
29118
|
+
}
|
|
29119
|
+
|
|
28885
29120
|
// src/harness-extract/types.ts
|
|
28886
29121
|
var EXTRACT_SCHEMA_VERSION = 1;
|
|
28887
29122
|
|
|
@@ -28934,7 +29169,7 @@ function functionScope(rootDir, fn, name) {
|
|
|
28934
29169
|
const parts = [qualifiedName(fn, name)];
|
|
28935
29170
|
const object = objectLiteralOf2(fn);
|
|
28936
29171
|
if (object) {
|
|
28937
|
-
const holder = object.parent &&
|
|
29172
|
+
const holder = object.parent && import_typescript14.default.isVariableDeclaration(object.parent) && import_typescript14.default.isIdentifier(object.parent.name) ? object.parent.name.text : `L${lineOf(object)}`;
|
|
28938
29173
|
parts.unshift(holder);
|
|
28939
29174
|
}
|
|
28940
29175
|
for (let outer = namedEnclosingFunction(object ?? fn);outer; outer = namedEnclosingFunction(outer.fn))
|
|
@@ -28942,8 +29177,8 @@ function functionScope(rootDir, fn, name) {
|
|
|
28942
29177
|
return `${relPath(rootDir, fn.getSourceFile().fileName)}#${parts.join(".")}`;
|
|
28943
29178
|
}
|
|
28944
29179
|
function objectLiteralOf2(fn) {
|
|
28945
|
-
const member2 =
|
|
28946
|
-
return member2 &&
|
|
29180
|
+
const member2 = import_typescript14.default.isMethodDeclaration(fn) || import_typescript14.default.isGetAccessorDeclaration(fn) || import_typescript14.default.isSetAccessorDeclaration(fn) ? fn : import_typescript14.default.isPropertyAssignment(fn.parent) ? fn.parent : undefined;
|
|
29181
|
+
return member2 && import_typescript14.default.isObjectLiteralExpression(member2.parent) ? member2.parent : undefined;
|
|
28947
29182
|
}
|
|
28948
29183
|
function scopeOf(rootDir, node) {
|
|
28949
29184
|
const named = namedEnclosingFunction(node);
|
|
@@ -28982,12 +29217,12 @@ function findAgentClasses(program, checker, memo) {
|
|
|
28982
29217
|
if (source.isDeclarationFile || /[\\/]node_modules[\\/]/.test(source.fileName))
|
|
28983
29218
|
continue;
|
|
28984
29219
|
const visit2 = (node) => {
|
|
28985
|
-
if ((
|
|
29220
|
+
if ((import_typescript14.default.isClassDeclaration(node) || import_typescript14.default.isClassExpression(node)) && node.heritageClauses) {
|
|
28986
29221
|
const base = frameworkBaseOf(node, checker, memo).base;
|
|
28987
29222
|
if (base && AGENT_CLASS_BASES.has(base))
|
|
28988
29223
|
out.push(node);
|
|
28989
29224
|
}
|
|
28990
|
-
|
|
29225
|
+
import_typescript14.default.forEachChild(node, visit2);
|
|
28991
29226
|
};
|
|
28992
29227
|
visit2(source);
|
|
28993
29228
|
}
|
|
@@ -29031,35 +29266,35 @@ function siteFields(sources, rootDir) {
|
|
|
29031
29266
|
return out;
|
|
29032
29267
|
}
|
|
29033
29268
|
function paramFlow(node, fn, checker, hops = 0) {
|
|
29034
|
-
if (!
|
|
29269
|
+
if (!import_typescript14.default.isExpression(node) || hops > 2)
|
|
29035
29270
|
return;
|
|
29036
29271
|
const expr = unwrap(node);
|
|
29037
|
-
if (
|
|
29272
|
+
if (import_typescript14.default.isBinaryExpression(expr) && (expr.operatorToken.kind === import_typescript14.default.SyntaxKind.QuestionQuestionToken || expr.operatorToken.kind === import_typescript14.default.SyntaxKind.BarBarToken)) {
|
|
29038
29273
|
return paramFlow(expr.left, fn, checker, hops);
|
|
29039
29274
|
}
|
|
29040
|
-
if (
|
|
29275
|
+
if (import_typescript14.default.isPropertyAccessExpression(expr) && import_typescript14.default.isIdentifier(unwrap(expr.expression))) {
|
|
29041
29276
|
const inner = paramFlow(expr.expression, fn, checker, hops);
|
|
29042
29277
|
return inner && inner.key === undefined ? { param: inner.param, key: expr.name.text } : undefined;
|
|
29043
29278
|
}
|
|
29044
|
-
if (!
|
|
29279
|
+
if (!import_typescript14.default.isIdentifier(expr))
|
|
29045
29280
|
return;
|
|
29046
29281
|
const declaration = valueDeclaration(resolvedSymbol(expr, checker));
|
|
29047
29282
|
if (!declaration)
|
|
29048
29283
|
return;
|
|
29049
|
-
if (
|
|
29284
|
+
if (import_typescript14.default.isParameter(declaration) && declaration.parent === fn && !declaration.dotDotDotToken)
|
|
29050
29285
|
return { param: declaration };
|
|
29051
|
-
if (
|
|
29286
|
+
if (import_typescript14.default.isBindingElement(declaration) && import_typescript14.default.isObjectBindingPattern(declaration.parent) && import_typescript14.default.isParameter(declaration.parent.parent) && declaration.parent.parent.parent === fn && !declaration.dotDotDotToken) {
|
|
29052
29287
|
const key = propertyNameText(declaration.propertyName ?? declaration.name);
|
|
29053
29288
|
return key ? { param: declaration.parent.parent, key } : undefined;
|
|
29054
29289
|
}
|
|
29055
|
-
if (
|
|
29290
|
+
if (import_typescript14.default.isVariableDeclaration(declaration) && declaration.initializer && enclosingFunction(declaration) === fn && declaration.parent.flags & import_typescript14.default.NodeFlags.Const) {
|
|
29056
29291
|
return paramFlow(declaration.initializer, fn, checker, hops + 1);
|
|
29057
29292
|
}
|
|
29058
29293
|
return;
|
|
29059
29294
|
}
|
|
29060
29295
|
function roleParamFlow(arg, fn, checker) {
|
|
29061
29296
|
const object = unwrap(arg.node);
|
|
29062
|
-
if (arg.key !== undefined && !arg.key.includes(".") &&
|
|
29297
|
+
if (arg.key !== undefined && !arg.key.includes(".") && import_typescript14.default.isObjectLiteralExpression(object)) {
|
|
29063
29298
|
const value = propertyValue(object, arg.key);
|
|
29064
29299
|
const flow = value ? paramFlow(value, fn, checker) : undefined;
|
|
29065
29300
|
return flow ? { ...flow, viaProperty: true } : undefined;
|
|
@@ -29071,9 +29306,9 @@ function descendArg(argument, path) {
|
|
|
29071
29306
|
let index = 0;
|
|
29072
29307
|
for (;index < path.length; index += 1) {
|
|
29073
29308
|
let value = unwrap(node);
|
|
29074
|
-
if (
|
|
29309
|
+
if (import_typescript14.default.isCallExpression(value) && value.expression.getText() === "JSON.stringify" && value.arguments[0])
|
|
29075
29310
|
value = unwrap(value.arguments[0]);
|
|
29076
|
-
const next =
|
|
29311
|
+
const next = import_typescript14.default.isObjectLiteralExpression(value) ? propertyValue(value, path[index]) : undefined;
|
|
29077
29312
|
if (!next)
|
|
29078
29313
|
break;
|
|
29079
29314
|
node = next;
|
|
@@ -29151,7 +29386,7 @@ function runExtract(rootDir, options) {
|
|
|
29151
29386
|
sites.push({ site, entry, anchor, sources, level: 0 });
|
|
29152
29387
|
};
|
|
29153
29388
|
const visit2 = (node) => {
|
|
29154
|
-
if (
|
|
29389
|
+
if (import_typescript14.default.isCallExpression(node) || import_typescript14.default.isNewExpression(node)) {
|
|
29155
29390
|
for (const recognizer of CALL_SINKS) {
|
|
29156
29391
|
let match;
|
|
29157
29392
|
const begin = performance.now();
|
|
@@ -29166,7 +29401,7 @@ function runExtract(rootDir, options) {
|
|
|
29166
29401
|
break;
|
|
29167
29402
|
}
|
|
29168
29403
|
}
|
|
29169
|
-
} else if (
|
|
29404
|
+
} else if (import_typescript14.default.isClassDeclaration(node) || import_typescript14.default.isClassExpression(node)) {
|
|
29170
29405
|
for (const recognizer of classRecognizers) {
|
|
29171
29406
|
try {
|
|
29172
29407
|
for (const match of recognizer.match(node, ctx2))
|
|
@@ -29176,7 +29411,7 @@ function runExtract(rootDir, options) {
|
|
|
29176
29411
|
}
|
|
29177
29412
|
}
|
|
29178
29413
|
}
|
|
29179
|
-
|
|
29414
|
+
import_typescript14.default.forEachChild(node, visit2);
|
|
29180
29415
|
};
|
|
29181
29416
|
visit2(source);
|
|
29182
29417
|
}
|
|
@@ -29228,7 +29463,7 @@ function runExtract(rootDir, options) {
|
|
|
29228
29463
|
const sources = [];
|
|
29229
29464
|
for (const { source: role, flow } of flowing) {
|
|
29230
29465
|
const argument = call.arguments[named.fn.parameters.indexOf(flow.param)];
|
|
29231
|
-
if (!argument ||
|
|
29466
|
+
if (!argument || import_typescript14.default.isSpreadElement(argument))
|
|
29232
29467
|
continue;
|
|
29233
29468
|
const arg = descendArg(argument, [flow.key, flow.viaProperty ? undefined : role.arg.key].filter((part) => Boolean(part)));
|
|
29234
29469
|
sources.push({ ...role, bindings: extendBindings(role.bindings, callerBindings), arg });
|
|
@@ -29367,6 +29602,19 @@ function runExtract(rootDir, options) {
|
|
|
29367
29602
|
timings.tools = Date.now() - begin;
|
|
29368
29603
|
result.durationMs = Date.now() - started;
|
|
29369
29604
|
}
|
|
29605
|
+
if (options.handoffs ?? true) {
|
|
29606
|
+
const begin = Date.now();
|
|
29607
|
+
try {
|
|
29608
|
+
const files2 = [...repo?.owner.entries() ?? []].filter(([file]) => !isTestPath(relPath(rootDir, file))).map(([file, entry]) => ({ source: entry.program.getSourceFile(file), checker: entry.checker() })).filter((f) => Boolean(f.source));
|
|
29609
|
+
const found = collectHandoffs({ rootDir, files: files2, calls, scopeOf: (node) => scopeOf(rootDir, node), namedEnclosingFunction });
|
|
29610
|
+
result.handoffs = found.handoffs;
|
|
29611
|
+
result.classes = found.classes;
|
|
29612
|
+
} catch (error) {
|
|
29613
|
+
warnings.push(`handoffs: ${error.message}`);
|
|
29614
|
+
}
|
|
29615
|
+
timings.handoffs = Date.now() - begin;
|
|
29616
|
+
result.durationMs = Date.now() - started;
|
|
29617
|
+
}
|
|
29370
29618
|
return { result, ctx };
|
|
29371
29619
|
}
|
|
29372
29620
|
function nodeSpanning(source, start, end) {
|
|
@@ -29380,7 +29628,7 @@ function nodeSpanning(source, start, end) {
|
|
|
29380
29628
|
return;
|
|
29381
29629
|
}
|
|
29382
29630
|
best = node;
|
|
29383
|
-
|
|
29631
|
+
import_typescript14.default.forEachChild(node, visit2);
|
|
29384
29632
|
};
|
|
29385
29633
|
visit2(source);
|
|
29386
29634
|
return best;
|
|
@@ -29441,8 +29689,8 @@ function routeOf(fn, file) {
|
|
|
29441
29689
|
if (name && HTTP_METHODS2.has(name) && /(?:^|\/)(?:route|\+server)\.[cm]?[jt]sx?$/.test(file.path))
|
|
29442
29690
|
return `${name} ${file.path}`;
|
|
29443
29691
|
const parent = fn.parent;
|
|
29444
|
-
if (parent &&
|
|
29445
|
-
const path = parent.arguments.find(
|
|
29692
|
+
if (parent && import_typescript15.default.isCallExpression(parent) && import_typescript15.default.isPropertyAccessExpression(parent.expression) && /^(get|post|put|patch|delete|all|on)$/.test(parent.expression.name.text)) {
|
|
29693
|
+
const path = parent.arguments.find(import_typescript15.default.isStringLiteralLike);
|
|
29446
29694
|
if (path)
|
|
29447
29695
|
return `${parent.expression.name.text.toUpperCase()} ${path.text} (${file.path})`;
|
|
29448
29696
|
}
|
|
@@ -29464,18 +29712,18 @@ function enumerateAgents(result, ctx) {
|
|
|
29464
29712
|
continue;
|
|
29465
29713
|
const checker = ctx.checkerFor(file.path);
|
|
29466
29714
|
visit(file.source, (node) => {
|
|
29467
|
-
if ((
|
|
29715
|
+
if ((import_typescript15.default.isClassDeclaration(node) || import_typescript15.default.isClassExpression(node)) && node.name) {
|
|
29468
29716
|
const name2 = node.name.text;
|
|
29469
29717
|
const info = checker ? frameworkBaseOf(node, checker, memo) : undefined;
|
|
29470
29718
|
const directBase = node.heritageClauses?.flatMap((h) => h.types).map((x) => x.expression.getText()) ?? [];
|
|
29471
29719
|
const protocolEvents = new Set;
|
|
29472
29720
|
visit(node, (member2) => {
|
|
29473
|
-
if (
|
|
29721
|
+
if (import_typescript15.default.isStringLiteralLike(member2))
|
|
29474
29722
|
protocolEvents.add(member2.text);
|
|
29475
29723
|
});
|
|
29476
29724
|
const realtime = protocolEvents.has("session.update") && protocolEvents.has("response.create") && [...protocolEvents].some((event) => event.includes("function_call"));
|
|
29477
|
-
const exported =
|
|
29478
|
-
const abstract =
|
|
29725
|
+
const exported = import_typescript15.default.getCombinedModifierFlags(node) & import_typescript15.default.ModifierFlags.Export;
|
|
29726
|
+
const abstract = import_typescript15.default.getCombinedModifierFlags(node) & import_typescript15.default.ModifierFlags.Abstract;
|
|
29479
29727
|
if (!abstract && (exported || bound.has(name2)) && (info?.base && AGENT_BASES4.has(info.base) || directBase.some((x) => AGENT_BASES4.has(x)) || exported && realtime)) {
|
|
29480
29728
|
classes.push({ file, node, name: name2, chain: info?.chain ?? [name2, ...directBase] });
|
|
29481
29729
|
}
|
|
@@ -29513,10 +29761,10 @@ function enumerateAgents(result, ctx) {
|
|
|
29513
29761
|
};
|
|
29514
29762
|
if (name) {
|
|
29515
29763
|
const parts = [qualified(node, name)];
|
|
29516
|
-
const member2 =
|
|
29517
|
-
const object = member2 &&
|
|
29764
|
+
const member2 = import_typescript15.default.isMethodDeclaration(node) || import_typescript15.default.isGetAccessorDeclaration(node) || import_typescript15.default.isSetAccessorDeclaration(node) ? node : import_typescript15.default.isPropertyAssignment(node.parent) ? node.parent : undefined;
|
|
29765
|
+
const object = member2 && import_typescript15.default.isObjectLiteralExpression(member2.parent) ? member2.parent : undefined;
|
|
29518
29766
|
if (object)
|
|
29519
|
-
parts.unshift(
|
|
29767
|
+
parts.unshift(import_typescript15.default.isVariableDeclaration(object.parent) && import_typescript15.default.isIdentifier(object.parent.name) ? object.parent.name.text : `L${lineOf5(object)}`);
|
|
29520
29768
|
for (let outer = (object ?? node).parent;outer; outer = outer.parent) {
|
|
29521
29769
|
if (isFunctionLike(outer)) {
|
|
29522
29770
|
const outerName = functionName(outer);
|
|
@@ -29538,7 +29786,7 @@ function enumerateAgents(result, ctx) {
|
|
|
29538
29786
|
const checker = ctx.checkerFor(node.getSourceFile().fileName.slice(ctx.rootDir.length + 1));
|
|
29539
29787
|
const bases = node.heritageClauses?.flatMap((clause) => clause.types).flatMap((base) => {
|
|
29540
29788
|
const declaration = checker && valueDeclaration(resolvedSymbol(base.expression, checker));
|
|
29541
|
-
return declaration &&
|
|
29789
|
+
return declaration && import_typescript15.default.isClassLike(declaration) ? classChain(declaration, seen) : [];
|
|
29542
29790
|
}) ?? [];
|
|
29543
29791
|
return [node, ...bases];
|
|
29544
29792
|
};
|
|
@@ -29554,32 +29802,32 @@ function enumerateAgents(result, ctx) {
|
|
|
29554
29802
|
return;
|
|
29555
29803
|
};
|
|
29556
29804
|
const bindingTruth = (condition, worker) => {
|
|
29557
|
-
if (condition.kind ===
|
|
29805
|
+
if (condition.kind === import_typescript15.default.SyntaxKind.TrueKeyword)
|
|
29558
29806
|
return true;
|
|
29559
|
-
if (condition.kind ===
|
|
29807
|
+
if (condition.kind === import_typescript15.default.SyntaxKind.FalseKeyword)
|
|
29560
29808
|
return false;
|
|
29561
|
-
if (
|
|
29809
|
+
if (import_typescript15.default.isPrefixUnaryExpression(condition) && condition.operator === import_typescript15.default.SyntaxKind.ExclamationToken) {
|
|
29562
29810
|
const value = bindingTruth(condition.operand, worker);
|
|
29563
29811
|
return value === undefined ? undefined : !value;
|
|
29564
29812
|
}
|
|
29565
|
-
if (
|
|
29813
|
+
if (import_typescript15.default.isPropertyAccessExpression(condition) && /^(?:this\.)?env$/.test(condition.expression.getText()) && (worker ? repo.workers.find((entry) => entry.id === worker)?.queueBindings : repo.queueBindingsFor(condition.getSourceFile().fileName.slice(ctx.rootDir.length + 1)))?.has(condition.name.text))
|
|
29566
29814
|
return true;
|
|
29567
29815
|
return;
|
|
29568
29816
|
};
|
|
29569
|
-
const returns = (node) => Boolean(node && (
|
|
29817
|
+
const returns = (node) => Boolean(node && (import_typescript15.default.isReturnStatement(node) || import_typescript15.default.isBlock(node) && node.statements.length && import_typescript15.default.isReturnStatement(node.statements[node.statements.length - 1])));
|
|
29570
29818
|
const deployed = (node, worker) => {
|
|
29571
29819
|
for (let current = node;current.parent; current = current.parent) {
|
|
29572
29820
|
const parent = current.parent;
|
|
29573
|
-
if (
|
|
29821
|
+
if (import_typescript15.default.isIfStatement(parent)) {
|
|
29574
29822
|
const truth = bindingTruth(parent.expression, worker);
|
|
29575
29823
|
if (truth !== undefined && (current === parent.thenStatement ? !truth : current === parent.elseStatement ? truth : false))
|
|
29576
29824
|
return false;
|
|
29577
29825
|
}
|
|
29578
|
-
if (
|
|
29826
|
+
if (import_typescript15.default.isBlock(parent))
|
|
29579
29827
|
for (const prior of parent.statements) {
|
|
29580
29828
|
if (prior.getStart() >= current.getStart())
|
|
29581
29829
|
break;
|
|
29582
|
-
if (
|
|
29830
|
+
if (import_typescript15.default.isIfStatement(prior)) {
|
|
29583
29831
|
const truth = bindingTruth(prior.expression, worker);
|
|
29584
29832
|
if (truth !== undefined && returns(truth ? prior.thenStatement : prior.elseStatement))
|
|
29585
29833
|
return false;
|
|
@@ -29605,7 +29853,7 @@ function enumerateAgents(result, ctx) {
|
|
|
29605
29853
|
const descend = (node) => {
|
|
29606
29854
|
if (node.getStart() <= offset && node.getEnd() >= offset) {
|
|
29607
29855
|
anchor = node;
|
|
29608
|
-
|
|
29856
|
+
import_typescript15.default.forEachChild(node, descend);
|
|
29609
29857
|
}
|
|
29610
29858
|
};
|
|
29611
29859
|
descend(file.source);
|
|
@@ -29614,21 +29862,21 @@ function enumerateAgents(result, ctx) {
|
|
|
29614
29862
|
continue;
|
|
29615
29863
|
markModel(scope, anchor);
|
|
29616
29864
|
const tools = site.toolsArg ? ctx.nodeAt(site.toolsArg) : undefined;
|
|
29617
|
-
scope.hasTools ||= Boolean(tools && !(
|
|
29865
|
+
scope.hasTools ||= Boolean(tools && !(import_typescript15.default.isObjectLiteralExpression(tools) && tools.properties.length === 0) && !(import_typescript15.default.isArrayLiteralExpression(tools) && tools.elements.length === 0));
|
|
29618
29866
|
scope.aliases.push(site.scope);
|
|
29619
29867
|
}
|
|
29620
29868
|
const targetsOf = (node, file) => {
|
|
29621
29869
|
const checker = ctx.checkerFor(file.path);
|
|
29622
29870
|
if (!checker)
|
|
29623
29871
|
return [];
|
|
29624
|
-
const at =
|
|
29872
|
+
const at = import_typescript15.default.isPropertyAccessExpression(node) ? node.name : node;
|
|
29625
29873
|
const declaration = valueDeclaration(resolvedSymbol(at, checker));
|
|
29626
29874
|
if (!declaration)
|
|
29627
29875
|
return [];
|
|
29628
29876
|
const direct = byNode.get(declaration) ?? scopes.get(keyOf(declaration));
|
|
29629
29877
|
if (direct)
|
|
29630
29878
|
return [direct];
|
|
29631
|
-
if ((
|
|
29879
|
+
if ((import_typescript15.default.isVariableDeclaration(declaration) || import_typescript15.default.isPropertyAssignment(declaration) || import_typescript15.default.isPropertyDeclaration(declaration)) && declaration.initializer) {
|
|
29632
29880
|
const fn = byNode.get(declaration.initializer) ?? scopes.get(keyOf(declaration.initializer));
|
|
29633
29881
|
if (fn)
|
|
29634
29882
|
return [fn];
|
|
@@ -29640,19 +29888,19 @@ function enumerateAgents(result, ctx) {
|
|
|
29640
29888
|
if (node !== scope.node && isFunctionLike(node)) {
|
|
29641
29889
|
return;
|
|
29642
29890
|
}
|
|
29643
|
-
if (
|
|
29891
|
+
if (import_typescript15.default.isWhileStatement(node) || import_typescript15.default.isDoStatement(node) || import_typescript15.default.isForStatement(node) || import_typescript15.default.isForOfStatement(node))
|
|
29644
29892
|
scope.hasLoop = true;
|
|
29645
|
-
if ((
|
|
29893
|
+
if ((import_typescript15.default.isIdentifier(node) || import_typescript15.default.isStringLiteralLike(node)) && /^(?:tool_calls|toolCalls|tool_use|tool_result|tool_results|toolResults)$/.test(node.text)) {
|
|
29646
29894
|
scope.hasTools = true;
|
|
29647
29895
|
scope.toolFeedback = true;
|
|
29648
29896
|
}
|
|
29649
|
-
if (
|
|
29650
|
-
const fields = new Map(node.properties.filter(
|
|
29897
|
+
if (import_typescript15.default.isObjectLiteralExpression(node)) {
|
|
29898
|
+
const fields = new Map(node.properties.filter(import_typescript15.default.isPropertyAssignment).map((p2) => [nameOf(p2.name), p2.initializer]));
|
|
29651
29899
|
const type = fields.get("type");
|
|
29652
|
-
if (type &&
|
|
29900
|
+
if (type && import_typescript15.default.isStringLiteralLike(type) && type.text === "tool" && fields.has("name"))
|
|
29653
29901
|
scope.forcedOutput = true;
|
|
29654
29902
|
}
|
|
29655
|
-
if (
|
|
29903
|
+
if (import_typescript15.default.isCallExpression(node) || import_typescript15.default.isNewExpression(node)) {
|
|
29656
29904
|
const callee = node.expression.getText();
|
|
29657
29905
|
if (/(?:chat\.)?completions\.create$|messages\.(?:create|stream)$|responses\.(?:create|stream)$/.test(callee))
|
|
29658
29906
|
markModel(scope, node);
|
|
@@ -29660,7 +29908,7 @@ function enumerateAgents(result, ctx) {
|
|
|
29660
29908
|
markModel(scope, node);
|
|
29661
29909
|
const connect = (at) => {
|
|
29662
29910
|
for (const target of byNode.has(at) ? [byNode.get(at)] : targetsOf(at, scope.file)) {
|
|
29663
|
-
if (
|
|
29911
|
+
if (import_typescript15.default.isPropertyAccessExpression(at) && at.expression.kind === import_typescript15.default.SyntaxKind.ThisKeyword) {
|
|
29664
29912
|
virtualEdges.set(`${scope.key}|${target.key}`, at.name.text);
|
|
29665
29913
|
scope.virtualCalls.set(target.key, at.name.text);
|
|
29666
29914
|
}
|
|
@@ -29679,30 +29927,30 @@ function enumerateAgents(result, ctx) {
|
|
|
29679
29927
|
connect(at);
|
|
29680
29928
|
return;
|
|
29681
29929
|
}
|
|
29682
|
-
if (
|
|
29930
|
+
if (import_typescript15.default.isIdentifier(at) || import_typescript15.default.isPropertyAccessExpression(at))
|
|
29683
29931
|
connect(at);
|
|
29684
|
-
|
|
29932
|
+
import_typescript15.default.forEachChild(at, connectArgument);
|
|
29685
29933
|
};
|
|
29686
29934
|
for (const argument of node.arguments ?? [])
|
|
29687
29935
|
connectArgument(argument);
|
|
29688
29936
|
for (const argument of node.arguments ?? [])
|
|
29689
|
-
if (
|
|
29937
|
+
if (import_typescript15.default.isObjectLiteralExpression(argument)) {
|
|
29690
29938
|
const fields = new Set(argument.properties.map((p2) => nameOf(p2.name)));
|
|
29691
29939
|
if (fields.has("model") && fields.has("messages") && fields.has("tools")) {
|
|
29692
29940
|
markModel(scope, node);
|
|
29693
29941
|
scope.hasTools = true;
|
|
29694
29942
|
}
|
|
29695
29943
|
}
|
|
29696
|
-
if (/(?:^|\.)(?:stepCountIs|isStepCount)$/.test(node.expression.getText()) && node.arguments?.[0] &&
|
|
29944
|
+
if (/(?:^|\.)(?:stepCountIs|isStepCount)$/.test(node.expression.getText()) && node.arguments?.[0] && import_typescript15.default.isNumericLiteral(node.arguments?.[0]) && Number(node.arguments?.[0].text) > 1) {
|
|
29697
29945
|
scope.hasLoop = true;
|
|
29698
29946
|
scope.configuredSteps = true;
|
|
29699
29947
|
}
|
|
29700
29948
|
}
|
|
29701
|
-
if (
|
|
29949
|
+
if (import_typescript15.default.isPropertyAssignment(node) && nameOf(node.name) === "maxSteps" && import_typescript15.default.isNumericLiteral(node.initializer) && Number(node.initializer.text) > 1) {
|
|
29702
29950
|
scope.hasLoop = true;
|
|
29703
29951
|
scope.configuredSteps = true;
|
|
29704
29952
|
}
|
|
29705
|
-
|
|
29953
|
+
import_typescript15.default.forEachChild(node, inspect);
|
|
29706
29954
|
};
|
|
29707
29955
|
inspect(scope.node);
|
|
29708
29956
|
}
|
|
@@ -29732,14 +29980,14 @@ function enumerateAgents(result, ctx) {
|
|
|
29732
29980
|
}
|
|
29733
29981
|
for (const scope of scopes.values()) {
|
|
29734
29982
|
let nestedInFunction = false;
|
|
29735
|
-
for (let parent = scope.node.parent;parent && !
|
|
29983
|
+
for (let parent = scope.node.parent;parent && !import_typescript15.default.isClassLike(parent); parent = parent.parent)
|
|
29736
29984
|
if (isFunctionLike(parent)) {
|
|
29737
29985
|
nestedInFunction = true;
|
|
29738
29986
|
break;
|
|
29739
29987
|
}
|
|
29740
29988
|
if (scope.className && !nestedInFunction) {
|
|
29741
29989
|
let member2 = scope.node;
|
|
29742
|
-
while (member2.parent && !
|
|
29990
|
+
while (member2.parent && !import_typescript15.default.isClassLike(member2.parent))
|
|
29743
29991
|
member2 = member2.parent;
|
|
29744
29992
|
const memberName = "name" in member2 ? nameOf(member2.name) : undefined;
|
|
29745
29993
|
for (const cls of classes) {
|
|
@@ -29779,8 +30027,8 @@ function enumerateAgents(result, ctx) {
|
|
|
29779
30027
|
const virtual = virtualEdges.get(`${scope.key}|${callee}`), concrete = classes.find((cls) => componentId("agent", cls.file.path, cls.name) === id);
|
|
29780
30028
|
const callerClass = enclosingClass(scope.node);
|
|
29781
30029
|
if (virtual && concrete && callerClass && concrete.nodes.some((node) => keyOf(node) === keyOf(callerClass))) {
|
|
29782
|
-
const implementation = concrete.nodes.flatMap((node) => node.members.filter((member2) => nameOf(member2.name) === virtual && !(
|
|
29783
|
-
const implementationKey = implementation && (scopes.has(keyOf(implementation)) ? keyOf(implementation) :
|
|
30030
|
+
const implementation = concrete.nodes.flatMap((node) => node.members.filter((member2) => nameOf(member2.name) === virtual && !(import_typescript15.default.getCombinedModifierFlags(member2) & import_typescript15.default.ModifierFlags.Static)))[0];
|
|
30031
|
+
const implementationKey = implementation && (scopes.has(keyOf(implementation)) ? keyOf(implementation) : import_typescript15.default.isPropertyDeclaration(implementation) && implementation.initializer && scopes.has(keyOf(implementation.initializer)) ? keyOf(implementation.initializer) : undefined);
|
|
29784
30032
|
if (implementationKey)
|
|
29785
30033
|
targetKey = implementationKey;
|
|
29786
30034
|
}
|
|
@@ -29835,7 +30083,7 @@ function enumerateAgents(result, ctx) {
|
|
|
29835
30083
|
}
|
|
29836
30084
|
|
|
29837
30085
|
// src/harness-extract/enumerators/workflows.ts
|
|
29838
|
-
var
|
|
30086
|
+
var import_typescript16 = __toESM(require_typescript(), 1);
|
|
29839
30087
|
function enumerateWorkflows(result, ctx) {
|
|
29840
30088
|
const output = emptyResult();
|
|
29841
30089
|
const repo = enumerationRepository(ctx);
|
|
@@ -29848,10 +30096,10 @@ function enumerateWorkflows(result, ctx) {
|
|
|
29848
30096
|
continue;
|
|
29849
30097
|
for (const name of worker.workflowClasses) {
|
|
29850
30098
|
let exported = checker.getExportsOfModule(module).find((symbol) => symbol.name === name);
|
|
29851
|
-
if (exported && exported.flags &
|
|
30099
|
+
if (exported && exported.flags & import_typescript16.default.SymbolFlags.Alias)
|
|
29852
30100
|
exported = checker.getAliasedSymbol(exported);
|
|
29853
30101
|
const declaration = exported && valueDeclaration(exported);
|
|
29854
|
-
if (declaration &&
|
|
30102
|
+
if (declaration && import_typescript16.default.isClassDeclaration(declaration))
|
|
29855
30103
|
bindings.add(nodeKey(declaration));
|
|
29856
30104
|
}
|
|
29857
30105
|
}
|
|
@@ -29860,7 +30108,7 @@ function enumerateWorkflows(result, ctx) {
|
|
|
29860
30108
|
if (!/\.[cm]?[jt]sx?$/.test(file.path) || TEST_PATH4.test(file.path) || EVAL_PATH2.test(file.path))
|
|
29861
30109
|
continue;
|
|
29862
30110
|
visit(file.source, (node) => {
|
|
29863
|
-
if (!
|
|
30111
|
+
if (!import_typescript16.default.isClassDeclaration(node) || !node.name || import_typescript16.default.getCombinedModifierFlags(node) & import_typescript16.default.ModifierFlags.Abstract)
|
|
29864
30112
|
return;
|
|
29865
30113
|
const checker = ctx.checkerFor(file.path);
|
|
29866
30114
|
const base = checker ? frameworkBaseOf(node, checker, memo)?.base : undefined;
|
|
@@ -29885,7 +30133,7 @@ function enumerateWorkflows(result, ctx) {
|
|
|
29885
30133
|
if (!cls || !workerClasses.has(nodeKey(cls)))
|
|
29886
30134
|
return calls;
|
|
29887
30135
|
const member2 = scope.node.parent === cls ? scope.node : scope.node.parent;
|
|
29888
|
-
if (
|
|
30136
|
+
if (import_typescript16.default.getCombinedModifierFlags(member2) & import_typescript16.default.ModifierFlags.Static)
|
|
29889
30137
|
return calls;
|
|
29890
30138
|
return new Set([...calls].map((key) => {
|
|
29891
30139
|
const method = scope.virtualCalls.get(key);
|
|
@@ -29899,24 +30147,24 @@ function enumerateWorkflows(result, ctx) {
|
|
|
29899
30147
|
if (!node || visited.has(node))
|
|
29900
30148
|
return;
|
|
29901
30149
|
visited.add(node);
|
|
29902
|
-
if (
|
|
30150
|
+
if (import_typescript16.default.isParenthesizedExpression(node) || import_typescript16.default.isAsExpression(node) || import_typescript16.default.isSatisfiesExpression(node) || import_typescript16.default.isNonNullExpression(node)) {
|
|
29903
30151
|
resolveWorker(node.expression);
|
|
29904
30152
|
return;
|
|
29905
30153
|
}
|
|
29906
|
-
if (
|
|
30154
|
+
if (import_typescript16.default.isCallExpression(node) && /(?:^|\.)withSentry$/.test(node.expression.getText())) {
|
|
29907
30155
|
for (const argument of node.arguments)
|
|
29908
30156
|
resolveWorker(argument);
|
|
29909
30157
|
return;
|
|
29910
30158
|
}
|
|
29911
|
-
if (
|
|
30159
|
+
if (import_typescript16.default.isExportAssignment(node)) {
|
|
29912
30160
|
resolveWorker(node.expression);
|
|
29913
30161
|
return;
|
|
29914
30162
|
}
|
|
29915
|
-
if (
|
|
30163
|
+
if (import_typescript16.default.isVariableDeclaration(node)) {
|
|
29916
30164
|
resolveWorker(node.initializer);
|
|
29917
30165
|
return;
|
|
29918
30166
|
}
|
|
29919
|
-
if (
|
|
30167
|
+
if (import_typescript16.default.isIdentifier(node) && checker) {
|
|
29920
30168
|
resolveWorker(valueDeclaration(resolvedSymbol(node, checker)));
|
|
29921
30169
|
return;
|
|
29922
30170
|
}
|
|
@@ -29924,17 +30172,17 @@ function enumerateWorkflows(result, ctx) {
|
|
|
29924
30172
|
};
|
|
29925
30173
|
const module = mainFile && checker?.getSymbolAtLocation(mainFile.source);
|
|
29926
30174
|
const exported = module && checker?.getExportsOfModule(module).find((symbol2) => symbol2.name === "default");
|
|
29927
|
-
const symbol = exported && checker && (exported.flags &
|
|
30175
|
+
const symbol = exported && checker && (exported.flags & import_typescript16.default.SymbolFlags.Alias ? checker.getAliasedSymbol(exported) : exported);
|
|
29928
30176
|
resolveWorker(symbol && valueDeclaration(symbol));
|
|
29929
30177
|
const collectImplementations = (node) => {
|
|
29930
|
-
if (!
|
|
30178
|
+
if (!import_typescript16.default.isClassLike(node) || workerClasses.has(nodeKey(node)))
|
|
29931
30179
|
return;
|
|
29932
30180
|
workerClasses.add(nodeKey(node));
|
|
29933
30181
|
for (const member2 of node.members) {
|
|
29934
|
-
if (
|
|
30182
|
+
if (import_typescript16.default.getCombinedModifierFlags(member2) & import_typescript16.default.ModifierFlags.Static)
|
|
29935
30183
|
continue;
|
|
29936
30184
|
const name = nameOf(member2.name);
|
|
29937
|
-
const implementation = byKey.get(nodeKey(member2)) ?? (
|
|
30185
|
+
const implementation = byKey.get(nodeKey(member2)) ?? (import_typescript16.default.isPropertyDeclaration(member2) && member2.initializer ? byKey.get(nodeKey(member2.initializer)) : undefined);
|
|
29938
30186
|
if (name && !implementations.has(name))
|
|
29939
30187
|
implementations.set(name, implementation?.key ?? "(non-callable override)");
|
|
29940
30188
|
}
|
|
@@ -29961,19 +30209,19 @@ function enumerateWorkflows(result, ctx) {
|
|
|
29961
30209
|
if (!node || seen2.has(node))
|
|
29962
30210
|
return;
|
|
29963
30211
|
seen2.add(node);
|
|
29964
|
-
if (
|
|
30212
|
+
if (import_typescript16.default.isIdentifier(node) && checker) {
|
|
29965
30213
|
resolveScheduled(valueDeclaration(resolvedSymbol(node, checker)), seen2);
|
|
29966
30214
|
return;
|
|
29967
30215
|
}
|
|
29968
|
-
if (
|
|
30216
|
+
if (import_typescript16.default.isVariableDeclaration(node) || import_typescript16.default.isPropertyAssignment(node) || import_typescript16.default.isPropertyDeclaration(node)) {
|
|
29969
30217
|
resolveScheduled(node.initializer, seen2);
|
|
29970
30218
|
return;
|
|
29971
30219
|
}
|
|
29972
|
-
if (
|
|
30220
|
+
if (import_typescript16.default.isShorthandPropertyAssignment(node)) {
|
|
29973
30221
|
resolveScheduled(checker && valueDeclaration(checker.getShorthandAssignmentValueSymbol(node)), seen2);
|
|
29974
30222
|
return;
|
|
29975
30223
|
}
|
|
29976
|
-
if (
|
|
30224
|
+
if (import_typescript16.default.isParenthesizedExpression(node) || import_typescript16.default.isAsExpression(node) || import_typescript16.default.isSatisfiesExpression(node) || import_typescript16.default.isNonNullExpression(node)) {
|
|
29977
30225
|
resolveScheduled(node.expression, seen2);
|
|
29978
30226
|
return;
|
|
29979
30227
|
}
|
|
@@ -29983,11 +30231,11 @@ function enumerateWorkflows(result, ctx) {
|
|
|
29983
30231
|
if (seen2.has(node))
|
|
29984
30232
|
return;
|
|
29985
30233
|
seen2.add(node);
|
|
29986
|
-
const members =
|
|
29987
|
-
const handlers = members.filter((member2) => nameOf(member2.name) === "scheduled" && !(
|
|
30234
|
+
const members = import_typescript16.default.isObjectLiteralExpression(node) ? node.properties : import_typescript16.default.isClassLike(node) ? node.members : [];
|
|
30235
|
+
const handlers = members.filter((member2) => nameOf(member2.name) === "scheduled" && !(import_typescript16.default.getCombinedModifierFlags(member2) & import_typescript16.default.ModifierFlags.Static));
|
|
29988
30236
|
for (const member2 of handlers)
|
|
29989
30237
|
resolveScheduled(member2);
|
|
29990
|
-
if (!handlers.length &&
|
|
30238
|
+
if (!handlers.length && import_typescript16.default.isClassLike(node) && checker)
|
|
29991
30239
|
for (const base of node.heritageClauses?.flatMap((clause) => clause.types) ?? []) {
|
|
29992
30240
|
const declaration = valueDeclaration(resolvedSymbol(base.expression, checker));
|
|
29993
30241
|
if (declaration)
|
|
@@ -30033,7 +30281,7 @@ function enumerateWorkflows(result, ctx) {
|
|
|
30033
30281
|
}
|
|
30034
30282
|
|
|
30035
30283
|
// src/harness-extract/enumerators/catalog.ts
|
|
30036
|
-
var
|
|
30284
|
+
var import_typescript17 = __toESM(require_typescript(), 1);
|
|
30037
30285
|
var THINK_WORKSPACE_TOOLS = ["read", "write", "edit", "list", "find", "grep", "delete"];
|
|
30038
30286
|
function strings(expression, checker, seen = new Set) {
|
|
30039
30287
|
if (!expression)
|
|
@@ -30042,35 +30290,35 @@ function strings(expression, checker, seen = new Set) {
|
|
|
30042
30290
|
if (seen.has(node))
|
|
30043
30291
|
return [];
|
|
30044
30292
|
seen.add(node);
|
|
30045
|
-
if (
|
|
30293
|
+
if (import_typescript17.default.isIdentifier(node)) {
|
|
30046
30294
|
const declaration = checker && valueDeclaration(resolvedSymbol(node, checker));
|
|
30047
|
-
if (!declaration || !
|
|
30295
|
+
if (!declaration || !import_typescript17.default.isVariableDeclaration(declaration))
|
|
30048
30296
|
return [];
|
|
30049
30297
|
return strings(declaration.initializer, checker, seen);
|
|
30050
30298
|
}
|
|
30051
|
-
if (
|
|
30052
|
-
return node.elements.flatMap((entry) =>
|
|
30053
|
-
if (
|
|
30299
|
+
if (import_typescript17.default.isArrayLiteralExpression(node))
|
|
30300
|
+
return node.elements.flatMap((entry) => import_typescript17.default.isSpreadElement(entry) ? strings(entry.expression, checker, seen) : strings(entry, checker, seen));
|
|
30301
|
+
if (import_typescript17.default.isStringLiteralLike(node))
|
|
30054
30302
|
return [{ name: node.text, node }];
|
|
30055
|
-
if (
|
|
30303
|
+
if (import_typescript17.default.isNewExpression(node) && node.expression.getText() === "Set")
|
|
30056
30304
|
return strings(node.arguments?.[0], checker, seen);
|
|
30057
30305
|
return [];
|
|
30058
30306
|
}
|
|
30059
30307
|
function property(object, name) {
|
|
30060
30308
|
const entry = object.properties.find((item) => item.name && nameOf(item.name) === name);
|
|
30061
|
-
return entry &&
|
|
30309
|
+
return entry && import_typescript17.default.isPropertyAssignment(entry) ? entry.initializer : entry && import_typescript17.default.isShorthandPropertyAssignment(entry) ? entry.name : undefined;
|
|
30062
30310
|
}
|
|
30063
30311
|
function inheritedTrue(node, propertyName2, checker, seen = new Set) {
|
|
30064
30312
|
if (seen.has(node))
|
|
30065
30313
|
return false;
|
|
30066
30314
|
seen.add(node);
|
|
30067
30315
|
const own = node.members.find((member2) => nameOf(member2.name) === propertyName2);
|
|
30068
|
-
if (own &&
|
|
30069
|
-
return unwrap(own.initializer).kind ===
|
|
30316
|
+
if (own && import_typescript17.default.isPropertyDeclaration(own) && own.initializer)
|
|
30317
|
+
return unwrap(own.initializer).kind === import_typescript17.default.SyntaxKind.TrueKeyword;
|
|
30070
30318
|
if (checker)
|
|
30071
30319
|
for (const base of node.heritageClauses?.flatMap((h) => h.types) ?? []) {
|
|
30072
30320
|
const declaration = valueDeclaration(resolvedSymbol(base.expression, checker));
|
|
30073
|
-
if (declaration && (
|
|
30321
|
+
if (declaration && (import_typescript17.default.isClassDeclaration(declaration) || import_typescript17.default.isClassExpression(declaration)))
|
|
30074
30322
|
return inheritedTrue(declaration, propertyName2, checker, seen);
|
|
30075
30323
|
}
|
|
30076
30324
|
return false;
|
|
@@ -30079,9 +30327,9 @@ function hasSkillSources(node, checker, seen = new Set) {
|
|
|
30079
30327
|
if (seen.has(node))
|
|
30080
30328
|
return false;
|
|
30081
30329
|
seen.add(node);
|
|
30082
|
-
const member2 = node.members.find((member3) => nameOf(member3.name) === "getSkills" && !(
|
|
30330
|
+
const member2 = node.members.find((member3) => nameOf(member3.name) === "getSkills" && !(import_typescript17.default.getCombinedModifierFlags(member3) & import_typescript17.default.ModifierFlags.Static));
|
|
30083
30331
|
if (member2) {
|
|
30084
|
-
const hook =
|
|
30332
|
+
const hook = import_typescript17.default.isMethodDeclaration(member2) ? member2 : import_typescript17.default.isPropertyDeclaration(member2) && member2.initializer && (import_typescript17.default.isArrowFunction(unwrap(member2.initializer)) || import_typescript17.default.isFunctionExpression(unwrap(member2.initializer))) ? unwrap(member2.initializer) : undefined;
|
|
30085
30333
|
if (!hook?.body)
|
|
30086
30334
|
return false;
|
|
30087
30335
|
const enabled = (expression, visited = new Set, depth = 0) => {
|
|
@@ -30089,32 +30337,32 @@ function hasSkillSources(node, checker, seen = new Set) {
|
|
|
30089
30337
|
if (visited.has(value) || depth > 8)
|
|
30090
30338
|
return false;
|
|
30091
30339
|
visited.add(value);
|
|
30092
|
-
if (
|
|
30340
|
+
if (import_typescript17.default.isConditionalExpression(value))
|
|
30093
30341
|
return enabled(value.whenTrue, new Set(visited), depth + 1) || enabled(value.whenFalse, new Set(visited), depth + 1);
|
|
30094
|
-
if (checker && (
|
|
30095
|
-
const declaration = valueDeclaration(resolvedSymbol(
|
|
30096
|
-
if (declaration &&
|
|
30342
|
+
if (checker && (import_typescript17.default.isIdentifier(value) || import_typescript17.default.isPropertyAccessExpression(value))) {
|
|
30343
|
+
const declaration = valueDeclaration(resolvedSymbol(import_typescript17.default.isPropertyAccessExpression(value) ? value.name : value, checker));
|
|
30344
|
+
if (declaration && import_typescript17.default.isVariableDeclaration(declaration) && declaration.initializer && declaration.parent.flags & import_typescript17.default.NodeFlags.Const) {
|
|
30097
30345
|
let populated = false;
|
|
30098
30346
|
const symbol = resolvedSymbol(declaration.name, checker);
|
|
30099
30347
|
const scan = (node2) => {
|
|
30100
|
-
if (
|
|
30348
|
+
if (import_typescript17.default.isCallExpression(node2) && import_typescript17.default.isPropertyAccessExpression(node2.expression) && ["push", "unshift", "splice"].includes(node2.expression.name.text) && resolvedSymbol(node2.expression.expression, checker) === symbol && node2.arguments.length > (node2.expression.name.text === "splice" ? 2 : 0))
|
|
30101
30349
|
populated = true;
|
|
30102
|
-
if (
|
|
30350
|
+
if (import_typescript17.default.isBinaryExpression(node2) && node2.operatorToken.kind === import_typescript17.default.SyntaxKind.EqualsToken && import_typescript17.default.isElementAccessExpression(node2.left) && resolvedSymbol(node2.left.expression, checker) === symbol)
|
|
30103
30351
|
populated = true;
|
|
30104
|
-
|
|
30352
|
+
import_typescript17.default.forEachChild(node2, scan);
|
|
30105
30353
|
};
|
|
30106
30354
|
scan(declaration.getSourceFile());
|
|
30107
30355
|
return populated || enabled(declaration.initializer, visited, depth + 1);
|
|
30108
30356
|
}
|
|
30109
30357
|
}
|
|
30110
|
-
return value.kind !==
|
|
30358
|
+
return value.kind !== import_typescript17.default.SyntaxKind.NullKeyword && value.getText() !== "undefined" && (!import_typescript17.default.isArrayLiteralExpression(value) || value.elements.length > 0);
|
|
30111
30359
|
};
|
|
30112
30360
|
return returnExpressions(hook).some((expression) => enabled(expression));
|
|
30113
30361
|
}
|
|
30114
30362
|
if (checker)
|
|
30115
30363
|
for (const base of node.heritageClauses?.flatMap((h) => h.types) ?? []) {
|
|
30116
30364
|
const declaration = valueDeclaration(resolvedSymbol(base.expression, checker));
|
|
30117
|
-
if (declaration && (
|
|
30365
|
+
if (declaration && (import_typescript17.default.isClassDeclaration(declaration) || import_typescript17.default.isClassExpression(declaration)) && hasSkillSources(declaration, checker, seen))
|
|
30118
30366
|
return true;
|
|
30119
30367
|
}
|
|
30120
30368
|
return false;
|
|
@@ -30129,10 +30377,10 @@ function enumerateToolCatalog(result, ctx) {
|
|
|
30129
30377
|
if (!owners.length || !checker)
|
|
30130
30378
|
continue;
|
|
30131
30379
|
visit(scope.node, (node) => {
|
|
30132
|
-
if (!
|
|
30380
|
+
if (!import_typescript17.default.isIdentifier(node) || !/ALLOW|MCP_NAME/.test(node.text))
|
|
30133
30381
|
return;
|
|
30134
30382
|
const declaration = valueDeclaration(resolvedSymbol(node, checker));
|
|
30135
|
-
if (!declaration || !
|
|
30383
|
+
if (!declaration || !import_typescript17.default.isVariableDeclaration(declaration) || !import_typescript17.default.isIdentifier(declaration.name))
|
|
30136
30384
|
return;
|
|
30137
30385
|
const key = `${declaration.getSourceFile().fileName}:${declaration.name.text}`;
|
|
30138
30386
|
let existing = symbolOwners.get(key);
|
|
@@ -30153,7 +30401,7 @@ function enumerateToolCatalog(result, ctx) {
|
|
|
30153
30401
|
if (!file || !checker)
|
|
30154
30402
|
continue;
|
|
30155
30403
|
visit(file.source, (node) => {
|
|
30156
|
-
if ((
|
|
30404
|
+
if ((import_typescript17.default.isClassDeclaration(node) || import_typescript17.default.isClassExpression(node)) && node.name?.text === runtime.name && frameworkBaseOf(node, checker, memo)?.base === "Think")
|
|
30157
30405
|
thinkIds.add(runtime.id);
|
|
30158
30406
|
});
|
|
30159
30407
|
}
|
|
@@ -30170,11 +30418,11 @@ function enumerateToolCatalog(result, ctx) {
|
|
|
30170
30418
|
continue;
|
|
30171
30419
|
const checker = ctx.checkerFor(file.path), declarations = new Map;
|
|
30172
30420
|
visit(file.source, (node) => {
|
|
30173
|
-
if (
|
|
30421
|
+
if (import_typescript17.default.isVariableDeclaration(node) && import_typescript17.default.isIdentifier(node.name) && node.initializer)
|
|
30174
30422
|
declarations.set(node.name.text, node.initializer);
|
|
30175
30423
|
});
|
|
30176
30424
|
visit(file.source, (node) => {
|
|
30177
|
-
if ((
|
|
30425
|
+
if ((import_typescript17.default.isClassDeclaration(node) || import_typescript17.default.isClassExpression(node)) && node.name && agentByName.has(node.name.text)) {
|
|
30178
30426
|
const info = checker ? frameworkBaseOf(node, checker, memo) : undefined;
|
|
30179
30427
|
const directThink = node.heritageClauses?.some((h) => h.types.some((t) => t.expression.getText() === "Think"));
|
|
30180
30428
|
if (info?.base === "Think" || directThink) {
|
|
@@ -30188,37 +30436,37 @@ function enumerateToolCatalog(result, ctx) {
|
|
|
30188
30436
|
add(name, file, node, "think", "Think workspace tool inherited by this concrete agent", owners2);
|
|
30189
30437
|
}
|
|
30190
30438
|
}
|
|
30191
|
-
if (
|
|
30439
|
+
if (import_typescript17.default.isPropertyAccessExpression(node) && node.name.text === "activate_skill" || import_typescript17.default.isPropertyAssignment(node) && nameOf(node.name) === "activate_skill") {
|
|
30192
30440
|
const owner = ownersAt(node, file.path);
|
|
30193
30441
|
add("activate_skill", file, node, "think", "Source explicitly exposes Think skill activation", owner);
|
|
30194
30442
|
}
|
|
30195
|
-
if (
|
|
30443
|
+
if (import_typescript17.default.isCallExpression(node) && import_typescript17.default.isPropertyAccessExpression(node.expression) && /^(?:registerTool|tool)$/.test(node.expression.name.text) && checker) {
|
|
30196
30444
|
const receiver = valueDeclaration(resolvedSymbol(node.expression.expression, checker));
|
|
30197
|
-
const init = receiver &&
|
|
30198
|
-
const origin = init &&
|
|
30445
|
+
const init = receiver && import_typescript17.default.isVariableDeclaration(receiver) && receiver.initializer ? unwrap(receiver.initializer) : undefined;
|
|
30446
|
+
const origin = init && import_typescript17.default.isNewExpression(init) && import_typescript17.default.isIdentifier(init.expression) ? importOrigin(init.expression, checker) : undefined;
|
|
30199
30447
|
const name = node.arguments[0];
|
|
30200
|
-
if (origin?.module.startsWith("@modelcontextprotocol/sdk/") && origin.imported === "McpServer" && name &&
|
|
30448
|
+
if (origin?.module.startsWith("@modelcontextprotocol/sdk/") && origin.imported === "McpServer" && name && import_typescript17.default.isStringLiteralLike(name)) {
|
|
30201
30449
|
add(name.text, file, name, "mcp_server", "MCP SDK server explicitly registers this model-facing tool name", ownersAt(node, file.path));
|
|
30202
30450
|
}
|
|
30203
30451
|
}
|
|
30204
|
-
if (
|
|
30452
|
+
if (import_typescript17.default.isCallExpression(node) && import_typescript17.default.isPropertyAccessExpression(node.expression) && node.expression.expression.getText() === "Output" && node.expression.name.text === "object") {
|
|
30205
30453
|
const owners2 = ownersAt(node, file.path).filter((id) => thinkIds.has(id));
|
|
30206
|
-
if (owners2.length && checker &&
|
|
30454
|
+
if (owners2.length && checker && import_typescript17.default.isIdentifier(node.expression.expression) && ["ai", "@cloudflare/think"].includes(importOrigin(node.expression.expression, checker)?.module ?? ""))
|
|
30207
30455
|
add("think_final_answer", file, node, "think", "Think structured output is offered as the framework final-answer tool", owners2);
|
|
30208
30456
|
}
|
|
30209
|
-
if (
|
|
30457
|
+
if (import_typescript17.default.isCallExpression(node) && import_typescript17.default.isIdentifier(node.expression) && node.expression.text === "createExecuteRuntime") {
|
|
30210
30458
|
const owners2 = ownersAt(node, file.path).filter((id) => thinkIds.has(id));
|
|
30211
30459
|
if (owners2.length && checker && importOrigin(node.expression, checker)?.module.startsWith("@cloudflare/think"))
|
|
30212
30460
|
add("execute", file, node, "think", "Think Code Mode runtime explicitly enabled for this agent", owners2);
|
|
30213
30461
|
}
|
|
30214
|
-
if (!
|
|
30462
|
+
if (!import_typescript17.default.isObjectLiteralExpression(node))
|
|
30215
30463
|
return;
|
|
30216
30464
|
const serverNames = strings(property(node, "name"), checker), allow = property(node, "allow");
|
|
30217
30465
|
if (serverNames.length !== 1 || !allow || !property(node, "url"))
|
|
30218
30466
|
return;
|
|
30219
30467
|
const server = serverNames[0].name;
|
|
30220
30468
|
const owners = ownersAt(node, file.path);
|
|
30221
|
-
if (
|
|
30469
|
+
if (import_typescript17.default.isStringLiteralLike(unwrap(allow)) && unwrap(allow).text === "all") {
|
|
30222
30470
|
const entry = add(`${server} dynamic MCP tools`, file, allow, "mcp_dynamic_group", "Server schemas are admitted dynamically as one bounded catalog group", owners);
|
|
30223
30471
|
entry.serverName = server;
|
|
30224
30472
|
entry.dynamicGroup = true;
|