@moda-ai/cli 1.55.86 → 1.55.88
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-515pvq3z.js → agent-85087h8a.js} +3 -3
- package/dist/{cli-gevrs592.js → cli-4g7gn0yn.js} +2 -2
- package/dist/{cli-gqrt2rbm.js → cli-fr85gngq.js} +3 -3
- package/dist/{cli-py31vwrx.js → cli-m5epf2gm.js} +11306 -11702
- package/dist/cli.js +7 -7
- package/dist/{doctor-k2xv4n03.js → doctor-6gjvc25v.js} +2 -2
- package/dist/{harness-tnhe63n3.js → harness-5v0wxmj7.js} +1 -1
- package/dist/{harness-github-actions-x2jgh0e8.js → harness-github-actions-gkhfqybk.js} +1 -1
- package/dist/index-c12v9gjq.js +554 -0
- package/dist/{index-h9r08433.js → index-jwg6s0gb.js} +1 -5
- package/dist/{index-zfg5y1b9.js → index-rcfrwtk2.js} +3 -3
- package/dist/{prompt-attribution-v6c51r59.js → prompt-attribution-13eyebd7.js} +1 -1
- package/dist/prompt-source-mcp.js +1 -1
- package/dist/{prompts-gsyrzgmg.js → prompts-ys1abkb1.js} +1 -1
- package/dist/{sync-60t12kz3.js → sync-vp8jwq7g.js} +2 -2
- package/package.json +1 -1
- package/skills/integration/index.json +2 -2
- package/dist/index-69xwrmrh.js +0 -33
package/dist/cli.js
CHANGED
|
@@ -2975,25 +2975,25 @@ function leafManifestFields(leaf, commands) {
|
|
|
2975
2975
|
import { fileURLToPath } from "url";
|
|
2976
2976
|
import { realpathSync } from "fs";
|
|
2977
2977
|
async function runPromptsCommand(...args) {
|
|
2978
|
-
return (await import("./prompts-
|
|
2978
|
+
return (await import("./prompts-ys1abkb1.js")).runPromptsCommand(...args);
|
|
2979
2979
|
}
|
|
2980
2980
|
async function runSkillsCommand(...args) {
|
|
2981
2981
|
return (await import("./skills-knpeqryb.js")).runSkillsCommand(...args);
|
|
2982
2982
|
}
|
|
2983
2983
|
async function runHarnessCommand(...args) {
|
|
2984
|
-
return (await import("./harness-
|
|
2984
|
+
return (await import("./harness-5v0wxmj7.js")).runHarnessCommand(...args);
|
|
2985
2985
|
}
|
|
2986
2986
|
async function runSyncCommand(...args) {
|
|
2987
|
-
return (await import("./sync-
|
|
2987
|
+
return (await import("./sync-vp8jwq7g.js")).runSyncCommand(...args);
|
|
2988
2988
|
}
|
|
2989
2989
|
async function runRegistryCommand(...args) {
|
|
2990
2990
|
return (await import("./registry-c64qr7ta.js")).runRegistryCommand(...args);
|
|
2991
2991
|
}
|
|
2992
2992
|
async function runDoctorCommand(...args) {
|
|
2993
|
-
return (await import("./doctor-
|
|
2993
|
+
return (await import("./doctor-6gjvc25v.js")).runDoctorCommand(...args);
|
|
2994
2994
|
}
|
|
2995
2995
|
async function runStatusCommand(...args) {
|
|
2996
|
-
return (await import("./doctor-
|
|
2996
|
+
return (await import("./doctor-6gjvc25v.js")).runStatusCommand(...args);
|
|
2997
2997
|
}
|
|
2998
2998
|
async function runAuthCommand(...args) {
|
|
2999
2999
|
return (await import("./profile-commands-1fdvrs5y.js")).runAuthCommand(...args);
|
|
@@ -3005,7 +3005,7 @@ async function runProfilesCommand(...args) {
|
|
|
3005
3005
|
return (await import("./profile-commands-1fdvrs5y.js")).runProfilesCommand(...args);
|
|
3006
3006
|
}
|
|
3007
3007
|
async function runAgentCommand(...args) {
|
|
3008
|
-
return (await import("./agent-
|
|
3008
|
+
return (await import("./agent-85087h8a.js")).runAgentCommand(...args);
|
|
3009
3009
|
}
|
|
3010
3010
|
async function runProductionCommand(...args) {
|
|
3011
3011
|
return (await import("./production-intelligence-f9sd68te.js")).runProductionCommand(...args);
|
|
@@ -6769,7 +6769,7 @@ var commandRegistry = createCommandRegistry([
|
|
|
6769
6769
|
resetApiRequestCountBeforeRun: true,
|
|
6770
6770
|
telemetry: "result-and-error",
|
|
6771
6771
|
handler: async (context) => {
|
|
6772
|
-
const { runInit } = await import("./index-
|
|
6772
|
+
const { runInit } = await import("./index-rcfrwtk2.js");
|
|
6773
6773
|
if (context.outputMode === "agent-stream") {
|
|
6774
6774
|
context.output.writeEvent({
|
|
6775
6775
|
event: "started",
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
promptsDiscoveredCheck,
|
|
4
4
|
runDoctorCommand,
|
|
5
5
|
runStatusCommand
|
|
6
|
-
} from "./cli-
|
|
6
|
+
} from "./cli-4g7gn0yn.js";
|
|
7
7
|
import"./cli-rrggdmf8.js";
|
|
8
|
-
import"./cli-
|
|
8
|
+
import"./cli-fr85gngq.js";
|
|
9
9
|
import"./cli-mm48br00.js";
|
|
10
10
|
import"./cli-k0vxtzxb.js";
|
|
11
11
|
import"./cli-22yvg5kh.js";
|
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EVAL_PATH,
|
|
3
|
+
TEST_PATH,
|
|
4
|
+
artifact,
|
|
5
|
+
componentId,
|
|
6
|
+
createAgentScopeResolver,
|
|
7
|
+
createFrameworkMemo,
|
|
8
|
+
emitToolsCached,
|
|
9
|
+
emptyResult,
|
|
10
|
+
enclosingClass,
|
|
11
|
+
enumerateAgents,
|
|
12
|
+
enumerationRepository,
|
|
13
|
+
frameworkBaseOf,
|
|
14
|
+
importOrigin,
|
|
15
|
+
nameOf,
|
|
16
|
+
resolvedSymbol,
|
|
17
|
+
returnExpressions,
|
|
18
|
+
stableResult,
|
|
19
|
+
surfaceOf,
|
|
20
|
+
toolArtifacts,
|
|
21
|
+
unwrap,
|
|
22
|
+
valueDeclaration,
|
|
23
|
+
visit,
|
|
24
|
+
workspacePackages
|
|
25
|
+
} from "./cli-m5epf2gm.js";
|
|
26
|
+
import"./cli-k0vxtzxb.js";
|
|
27
|
+
import"./cli-97fnztpy.js";
|
|
28
|
+
import"./cli-y333w08f.js";
|
|
29
|
+
import"./cli-22yvg5kh.js";
|
|
30
|
+
import"./cli-87xy1evx.js";
|
|
31
|
+
import"./cli-5ms8rw8x.js";
|
|
32
|
+
import"./cli-e0kbye4s.js";
|
|
33
|
+
import"./cli-z1t3sf7b.js";
|
|
34
|
+
import"./cli-k4tqwah4.js";
|
|
35
|
+
import {
|
|
36
|
+
require_typescript
|
|
37
|
+
} from "./cli-y7dtztan.js";
|
|
38
|
+
import"./cli-9kfxkxmk.js";
|
|
39
|
+
import"./cli-p5grm12t.js";
|
|
40
|
+
import {
|
|
41
|
+
__toESM
|
|
42
|
+
} from "./cli-0v6na3yp.js";
|
|
43
|
+
|
|
44
|
+
// src/harness-extract/enumerators/workflows.ts
|
|
45
|
+
var import_typescript = __toESM(require_typescript(), 1);
|
|
46
|
+
function enumerateWorkflows(result, ctx) {
|
|
47
|
+
const output = emptyResult();
|
|
48
|
+
const repo = enumerationRepository(ctx);
|
|
49
|
+
const nodeKey = (node) => `${node.getSourceFile().fileName}:${node.getStart()}`;
|
|
50
|
+
const bindings = new Set;
|
|
51
|
+
for (const worker of repo.workers) {
|
|
52
|
+
const file = repo.files.find((entry) => entry.path === worker.main), checker = file && ctx.checkerFor(file.path);
|
|
53
|
+
const module = file && checker?.getSymbolAtLocation(file.source);
|
|
54
|
+
if (!module || !checker)
|
|
55
|
+
continue;
|
|
56
|
+
for (const name of worker.workflowClasses) {
|
|
57
|
+
let exported = checker.getExportsOfModule(module).find((symbol) => symbol.name === name);
|
|
58
|
+
if (exported && exported.flags & import_typescript.default.SymbolFlags.Alias)
|
|
59
|
+
exported = checker.getAliasedSymbol(exported);
|
|
60
|
+
const declaration = exported && valueDeclaration(exported);
|
|
61
|
+
if (declaration && import_typescript.default.isClassDeclaration(declaration))
|
|
62
|
+
bindings.add(nodeKey(declaration));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const memo = createFrameworkMemo();
|
|
66
|
+
for (const file of repo.files) {
|
|
67
|
+
if (!/\.[cm]?[jt]sx?$/.test(file.path) || TEST_PATH.test(file.path) || EVAL_PATH.test(file.path))
|
|
68
|
+
continue;
|
|
69
|
+
visit(file.source, (node) => {
|
|
70
|
+
if (!import_typescript.default.isClassDeclaration(node) || !node.name || import_typescript.default.getCombinedModifierFlags(node) & import_typescript.default.ModifierFlags.Abstract)
|
|
71
|
+
return;
|
|
72
|
+
const checker = ctx.checkerFor(file.path);
|
|
73
|
+
const base = checker ? frameworkBaseOf(node, checker, memo)?.base : undefined;
|
|
74
|
+
const directBase = node.heritageClauses?.flatMap((h) => h.types).map((x) => x.expression.getText()) ?? [];
|
|
75
|
+
if (!bindings.has(nodeKey(node)) && base !== "WorkflowEntrypoint" && base !== "AgentWorkflow" && !directBase.some((x) => /^(?:WorkflowEntrypoint|AgentWorkflow)$/.test(x)))
|
|
76
|
+
return;
|
|
77
|
+
const entry = artifact("entrypoint", node.name.text, file, node, "Concrete Workflow class or Wrangler workflow binding", repo.status(file.path));
|
|
78
|
+
entry.id = componentId("workflow", file.path, node.name.text);
|
|
79
|
+
if (bindings.has(nodeKey(node))) {
|
|
80
|
+
Object.assign(entry, { componentKind: "workflow", trigger: "workflow_binding" });
|
|
81
|
+
}
|
|
82
|
+
output.artifacts.push(entry);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
for (const worker of repo.workers.filter((entry) => entry.cron)) {
|
|
86
|
+
const scopes = enumerateAgents(result, ctx).scopes;
|
|
87
|
+
const byKey = new Map(scopes.map((scope) => [scope.key, scope]));
|
|
88
|
+
const implementations = new Map, workerClasses = new Set;
|
|
89
|
+
const deployedCalls = (scope) => {
|
|
90
|
+
const calls = scope.callsByWorker.get(worker.id) ?? scope.deployedCalls;
|
|
91
|
+
const cls = enclosingClass(scope.node);
|
|
92
|
+
if (!cls || !workerClasses.has(nodeKey(cls)))
|
|
93
|
+
return calls;
|
|
94
|
+
const member = scope.node.parent === cls ? scope.node : scope.node.parent;
|
|
95
|
+
if (import_typescript.default.getCombinedModifierFlags(member) & import_typescript.default.ModifierFlags.Static)
|
|
96
|
+
return calls;
|
|
97
|
+
return new Set([...calls].map((key) => {
|
|
98
|
+
const method = scope.virtualCalls.get(key);
|
|
99
|
+
return method && implementations.has(method) ? implementations.get(method) : key;
|
|
100
|
+
}));
|
|
101
|
+
};
|
|
102
|
+
const modelScopes = new Set(scopes.filter((scope) => scope.modelWorkers.has(worker.id)).map((scope) => scope.key));
|
|
103
|
+
const mainFile = repo.files.find((file) => file.path === worker.main), checker = mainFile && ctx.checkerFor(mainFile.path);
|
|
104
|
+
const exportedNodes = new Set, visited = new Set;
|
|
105
|
+
const resolveWorker = (node) => {
|
|
106
|
+
if (!node || visited.has(node))
|
|
107
|
+
return;
|
|
108
|
+
visited.add(node);
|
|
109
|
+
if (import_typescript.default.isParenthesizedExpression(node) || import_typescript.default.isAsExpression(node) || import_typescript.default.isSatisfiesExpression(node) || import_typescript.default.isNonNullExpression(node)) {
|
|
110
|
+
resolveWorker(node.expression);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (import_typescript.default.isCallExpression(node) && /(?:^|\.)withSentry$/.test(node.expression.getText())) {
|
|
114
|
+
for (const argument of node.arguments)
|
|
115
|
+
resolveWorker(argument);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (import_typescript.default.isExportAssignment(node)) {
|
|
119
|
+
resolveWorker(node.expression);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (import_typescript.default.isVariableDeclaration(node)) {
|
|
123
|
+
resolveWorker(node.initializer);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (import_typescript.default.isIdentifier(node) && checker) {
|
|
127
|
+
resolveWorker(valueDeclaration(resolvedSymbol(node, checker)));
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
exportedNodes.add(node);
|
|
131
|
+
};
|
|
132
|
+
const module = mainFile && checker?.getSymbolAtLocation(mainFile.source);
|
|
133
|
+
const exported = module && checker?.getExportsOfModule(module).find((symbol2) => symbol2.name === "default");
|
|
134
|
+
const symbol = exported && checker && (exported.flags & import_typescript.default.SymbolFlags.Alias ? checker.getAliasedSymbol(exported) : exported);
|
|
135
|
+
resolveWorker(symbol && valueDeclaration(symbol));
|
|
136
|
+
const collectImplementations = (node) => {
|
|
137
|
+
if (!import_typescript.default.isClassLike(node) || workerClasses.has(nodeKey(node)))
|
|
138
|
+
return;
|
|
139
|
+
workerClasses.add(nodeKey(node));
|
|
140
|
+
for (const member of node.members) {
|
|
141
|
+
if (import_typescript.default.getCombinedModifierFlags(member) & import_typescript.default.ModifierFlags.Static)
|
|
142
|
+
continue;
|
|
143
|
+
const name = nameOf(member.name);
|
|
144
|
+
const implementation = byKey.get(nodeKey(member)) ?? (import_typescript.default.isPropertyDeclaration(member) && member.initializer ? byKey.get(nodeKey(member.initializer)) : undefined);
|
|
145
|
+
if (name && !implementations.has(name))
|
|
146
|
+
implementations.set(name, implementation?.key ?? "(non-callable override)");
|
|
147
|
+
}
|
|
148
|
+
if (checker)
|
|
149
|
+
for (const base of node.heritageClauses?.flatMap((clause) => clause.types) ?? []) {
|
|
150
|
+
const declaration = valueDeclaration(resolvedSymbol(base.expression, checker));
|
|
151
|
+
if (declaration)
|
|
152
|
+
collectImplementations(declaration);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
for (const node of exportedNodes)
|
|
156
|
+
collectImplementations(node);
|
|
157
|
+
let changed = true;
|
|
158
|
+
while (changed) {
|
|
159
|
+
changed = false;
|
|
160
|
+
for (const scope of scopes)
|
|
161
|
+
if (!modelScopes.has(scope.key) && [...deployedCalls(scope)].some((key) => modelScopes.has(key))) {
|
|
162
|
+
modelScopes.add(scope.key);
|
|
163
|
+
changed = true;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const scheduledNodes = new Set;
|
|
167
|
+
const resolveScheduled = (node, seen2 = new Set) => {
|
|
168
|
+
if (!node || seen2.has(node))
|
|
169
|
+
return;
|
|
170
|
+
seen2.add(node);
|
|
171
|
+
if (import_typescript.default.isIdentifier(node) && checker) {
|
|
172
|
+
resolveScheduled(valueDeclaration(resolvedSymbol(node, checker)), seen2);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (import_typescript.default.isVariableDeclaration(node) || import_typescript.default.isPropertyAssignment(node) || import_typescript.default.isPropertyDeclaration(node)) {
|
|
176
|
+
resolveScheduled(node.initializer, seen2);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (import_typescript.default.isShorthandPropertyAssignment(node)) {
|
|
180
|
+
resolveScheduled(checker && valueDeclaration(checker.getShorthandAssignmentValueSymbol(node)), seen2);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (import_typescript.default.isParenthesizedExpression(node) || import_typescript.default.isAsExpression(node) || import_typescript.default.isSatisfiesExpression(node) || import_typescript.default.isNonNullExpression(node)) {
|
|
184
|
+
resolveScheduled(node.expression, seen2);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
scheduledNodes.add(node);
|
|
188
|
+
};
|
|
189
|
+
const collectScheduled = (node, seen2 = new Set) => {
|
|
190
|
+
if (seen2.has(node))
|
|
191
|
+
return;
|
|
192
|
+
seen2.add(node);
|
|
193
|
+
const members = import_typescript.default.isObjectLiteralExpression(node) ? node.properties : import_typescript.default.isClassLike(node) ? node.members : [];
|
|
194
|
+
const handlers = members.filter((member) => nameOf(member.name) === "scheduled" && !(import_typescript.default.getCombinedModifierFlags(member) & import_typescript.default.ModifierFlags.Static));
|
|
195
|
+
for (const member of handlers)
|
|
196
|
+
resolveScheduled(member);
|
|
197
|
+
if (!handlers.length && import_typescript.default.isClassLike(node) && checker)
|
|
198
|
+
for (const base of node.heritageClauses?.flatMap((clause) => clause.types) ?? []) {
|
|
199
|
+
const declaration = valueDeclaration(resolvedSymbol(base.expression, checker));
|
|
200
|
+
if (declaration)
|
|
201
|
+
collectScheduled(declaration, seen2);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
for (const node of exportedNodes)
|
|
205
|
+
collectScheduled(node);
|
|
206
|
+
const roots = scopes.filter((scope) => [...scheduledNodes].some((node) => node.getSourceFile().fileName === scope.node.getSourceFile().fileName && node.getStart() === scope.node.getStart()));
|
|
207
|
+
const seen = new Set;
|
|
208
|
+
const queue = roots.flatMap((scope) => scope.modelWorkers.has(worker.id) ? [scope.key] : [...deployedCalls(scope)]);
|
|
209
|
+
for (let i = 0;i < queue.length; i++) {
|
|
210
|
+
const key = queue[i];
|
|
211
|
+
if (seen.has(key))
|
|
212
|
+
continue;
|
|
213
|
+
seen.add(key);
|
|
214
|
+
const scope = byKey.get(key);
|
|
215
|
+
if (!scope)
|
|
216
|
+
continue;
|
|
217
|
+
if (!modelScopes.has(scope.key)) {
|
|
218
|
+
if (/(?:Cron|Pipeline)$/.test(scope.label)) {
|
|
219
|
+
const entry = artifact("entrypoint", scope.label, scope.file, scope.node, "Scheduled entrypoint has no deployed model step on its own pipeline", repo.status(scope.file.path));
|
|
220
|
+
const proof = [...scope.calls].map((callee) => byKey.get(callee)).filter((callee) => callee?.reachesModel).map((callee) => `${callee.file.path}#${callee.label}`);
|
|
221
|
+
Object.assign(entry, { exclusionReason: scope.reachesModel ? "Model reachable only through a queue consumer or statically excluded fallback" : "No model reachable from scheduled pipeline", proofPath: [`${scope.file.path}#${scope.label}`, ...proof] });
|
|
222
|
+
output.artifacts.push(entry);
|
|
223
|
+
} else
|
|
224
|
+
queue.push(...deployedCalls(scope));
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (/(?:Cron|Pipeline)$/.test(scope.label) || scope.modelWorkers.has(worker.id)) {
|
|
228
|
+
const entry = artifact("entrypoint", scope.label, scope.file, scope.node, "Cron dispatch reaches this model-backed pipeline", repo.status(scope.file.path));
|
|
229
|
+
entry.id = componentId("workflow", scope.file.path, scope.label);
|
|
230
|
+
entry.componentKind = "workflow";
|
|
231
|
+
entry.trigger = "cron";
|
|
232
|
+
output.artifacts.push(entry);
|
|
233
|
+
if (roots.includes(scope))
|
|
234
|
+
queue.push(...deployedCalls(scope));
|
|
235
|
+
} else
|
|
236
|
+
queue.push(...deployedCalls(scope));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return stableResult(output);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// src/harness-extract/enumerators/catalog.ts
|
|
243
|
+
var import_typescript2 = __toESM(require_typescript(), 1);
|
|
244
|
+
var THINK_WORKSPACE_TOOLS = ["read", "write", "edit", "list", "find", "grep", "delete"];
|
|
245
|
+
function strings(expression, checker, seen = new Set) {
|
|
246
|
+
if (!expression)
|
|
247
|
+
return [];
|
|
248
|
+
const node = unwrap(expression);
|
|
249
|
+
if (seen.has(node))
|
|
250
|
+
return [];
|
|
251
|
+
seen.add(node);
|
|
252
|
+
if (import_typescript2.default.isIdentifier(node)) {
|
|
253
|
+
const declaration = checker && valueDeclaration(resolvedSymbol(node, checker));
|
|
254
|
+
if (!declaration || !import_typescript2.default.isVariableDeclaration(declaration))
|
|
255
|
+
return [];
|
|
256
|
+
return strings(declaration.initializer, checker, seen);
|
|
257
|
+
}
|
|
258
|
+
if (import_typescript2.default.isArrayLiteralExpression(node))
|
|
259
|
+
return node.elements.flatMap((entry) => import_typescript2.default.isSpreadElement(entry) ? strings(entry.expression, checker, seen) : strings(entry, checker, seen));
|
|
260
|
+
if (import_typescript2.default.isStringLiteralLike(node))
|
|
261
|
+
return [{ name: node.text, node }];
|
|
262
|
+
if (import_typescript2.default.isNewExpression(node) && node.expression.getText() === "Set")
|
|
263
|
+
return strings(node.arguments?.[0], checker, seen);
|
|
264
|
+
return [];
|
|
265
|
+
}
|
|
266
|
+
function property(object, name) {
|
|
267
|
+
const entry = object.properties.find((item) => item.name && nameOf(item.name) === name);
|
|
268
|
+
return entry && import_typescript2.default.isPropertyAssignment(entry) ? entry.initializer : entry && import_typescript2.default.isShorthandPropertyAssignment(entry) ? entry.name : undefined;
|
|
269
|
+
}
|
|
270
|
+
function inheritedTrue(node, propertyName, checker, seen = new Set) {
|
|
271
|
+
if (seen.has(node))
|
|
272
|
+
return false;
|
|
273
|
+
seen.add(node);
|
|
274
|
+
const own = node.members.find((member) => nameOf(member.name) === propertyName);
|
|
275
|
+
if (own && import_typescript2.default.isPropertyDeclaration(own) && own.initializer)
|
|
276
|
+
return unwrap(own.initializer).kind === import_typescript2.default.SyntaxKind.TrueKeyword;
|
|
277
|
+
if (checker)
|
|
278
|
+
for (const base of node.heritageClauses?.flatMap((h) => h.types) ?? []) {
|
|
279
|
+
const declaration = valueDeclaration(resolvedSymbol(base.expression, checker));
|
|
280
|
+
if (declaration && (import_typescript2.default.isClassDeclaration(declaration) || import_typescript2.default.isClassExpression(declaration)))
|
|
281
|
+
return inheritedTrue(declaration, propertyName, checker, seen);
|
|
282
|
+
}
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
function hasSkillSources(node, checker, seen = new Set) {
|
|
286
|
+
if (seen.has(node))
|
|
287
|
+
return false;
|
|
288
|
+
seen.add(node);
|
|
289
|
+
const member = node.members.find((member2) => nameOf(member2.name) === "getSkills" && !(import_typescript2.default.getCombinedModifierFlags(member2) & import_typescript2.default.ModifierFlags.Static));
|
|
290
|
+
if (member) {
|
|
291
|
+
const hook = import_typescript2.default.isMethodDeclaration(member) ? member : import_typescript2.default.isPropertyDeclaration(member) && member.initializer && (import_typescript2.default.isArrowFunction(unwrap(member.initializer)) || import_typescript2.default.isFunctionExpression(unwrap(member.initializer))) ? unwrap(member.initializer) : undefined;
|
|
292
|
+
if (!hook?.body)
|
|
293
|
+
return false;
|
|
294
|
+
const enabled = (expression, visited = new Set, depth = 0) => {
|
|
295
|
+
const value = unwrap(expression);
|
|
296
|
+
if (visited.has(value) || depth > 8)
|
|
297
|
+
return false;
|
|
298
|
+
visited.add(value);
|
|
299
|
+
if (import_typescript2.default.isConditionalExpression(value))
|
|
300
|
+
return enabled(value.whenTrue, new Set(visited), depth + 1) || enabled(value.whenFalse, new Set(visited), depth + 1);
|
|
301
|
+
if (checker && (import_typescript2.default.isIdentifier(value) || import_typescript2.default.isPropertyAccessExpression(value))) {
|
|
302
|
+
const declaration = valueDeclaration(resolvedSymbol(import_typescript2.default.isPropertyAccessExpression(value) ? value.name : value, checker));
|
|
303
|
+
if (declaration && import_typescript2.default.isVariableDeclaration(declaration) && declaration.initializer && declaration.parent.flags & import_typescript2.default.NodeFlags.Const) {
|
|
304
|
+
let populated = false;
|
|
305
|
+
const symbol = resolvedSymbol(declaration.name, checker);
|
|
306
|
+
const scan = (node2) => {
|
|
307
|
+
if (import_typescript2.default.isCallExpression(node2) && import_typescript2.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))
|
|
308
|
+
populated = true;
|
|
309
|
+
if (import_typescript2.default.isBinaryExpression(node2) && node2.operatorToken.kind === import_typescript2.default.SyntaxKind.EqualsToken && import_typescript2.default.isElementAccessExpression(node2.left) && resolvedSymbol(node2.left.expression, checker) === symbol)
|
|
310
|
+
populated = true;
|
|
311
|
+
import_typescript2.default.forEachChild(node2, scan);
|
|
312
|
+
};
|
|
313
|
+
scan(declaration.getSourceFile());
|
|
314
|
+
return populated || enabled(declaration.initializer, visited, depth + 1);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return value.kind !== import_typescript2.default.SyntaxKind.NullKeyword && value.getText() !== "undefined" && (!import_typescript2.default.isArrayLiteralExpression(value) || value.elements.length > 0);
|
|
318
|
+
};
|
|
319
|
+
return returnExpressions(hook).some((expression) => enabled(expression));
|
|
320
|
+
}
|
|
321
|
+
if (checker)
|
|
322
|
+
for (const base of node.heritageClauses?.flatMap((h) => h.types) ?? []) {
|
|
323
|
+
const declaration = valueDeclaration(resolvedSymbol(base.expression, checker));
|
|
324
|
+
if (declaration && (import_typescript2.default.isClassDeclaration(declaration) || import_typescript2.default.isClassExpression(declaration)) && hasSkillSources(declaration, checker, seen))
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
function enumerateToolCatalog(result, ctx) {
|
|
330
|
+
const output = emptyResult(), repo = enumerationRepository(ctx), agents = enumerateAgents(result, ctx);
|
|
331
|
+
const agentByName = new Map(agents.runtimeAgents.map((entry) => [entry.name, entry.id]));
|
|
332
|
+
const symbolOwners = new Map;
|
|
333
|
+
for (const scope of agents.scopes) {
|
|
334
|
+
const owners = agents.agentForScope(scope.key);
|
|
335
|
+
const checker = ctx.checkerFor(scope.file.path);
|
|
336
|
+
if (!owners.length || !checker)
|
|
337
|
+
continue;
|
|
338
|
+
visit(scope.node, (node) => {
|
|
339
|
+
if (!import_typescript2.default.isIdentifier(node) || !/ALLOW|MCP_NAME/.test(node.text))
|
|
340
|
+
return;
|
|
341
|
+
const declaration = valueDeclaration(resolvedSymbol(node, checker));
|
|
342
|
+
if (!declaration || !import_typescript2.default.isVariableDeclaration(declaration) || !import_typescript2.default.isIdentifier(declaration.name))
|
|
343
|
+
return;
|
|
344
|
+
const key = `${declaration.getSourceFile().fileName}:${declaration.name.text}`;
|
|
345
|
+
let existing = symbolOwners.get(key);
|
|
346
|
+
if (!existing)
|
|
347
|
+
symbolOwners.set(key, existing = new Set);
|
|
348
|
+
for (const id of owners)
|
|
349
|
+
existing.add(id);
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
const ownersAt = (node, path) => {
|
|
353
|
+
const scope = agents.scopes.filter((s) => s.file.path === path && s.node.getStart() <= node.getStart() && s.node.getEnd() >= node.getEnd()).sort((a, b) => a.node.getWidth() - b.node.getWidth())[0];
|
|
354
|
+
return scope ? agents.agentForScope(scope.key) : [];
|
|
355
|
+
};
|
|
356
|
+
const memo = createFrameworkMemo();
|
|
357
|
+
const thinkIds = new Set;
|
|
358
|
+
for (const runtime of agents.runtimeAgents) {
|
|
359
|
+
const file = repo.files.find((entry) => entry.path === runtime.evidence[0]?.path), checker = file && ctx.checkerFor(file.path);
|
|
360
|
+
if (!file || !checker)
|
|
361
|
+
continue;
|
|
362
|
+
visit(file.source, (node) => {
|
|
363
|
+
if ((import_typescript2.default.isClassDeclaration(node) || import_typescript2.default.isClassExpression(node)) && node.name?.text === runtime.name && frameworkBaseOf(node, checker, memo)?.base === "Think")
|
|
364
|
+
thinkIds.add(runtime.id);
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
const add = (name, file, node, source, reason, owners = []) => {
|
|
368
|
+
const evidenceFile = repo.files.find((entry2) => entry2.source.fileName === node.getSourceFile().fileName) ?? file;
|
|
369
|
+
const entry = artifact("tool", name, evidenceFile, node, reason, repo.status(file.path));
|
|
370
|
+
entry.catalogSource = source;
|
|
371
|
+
entry.usedByAgentIds = owners;
|
|
372
|
+
output.artifacts.push(entry);
|
|
373
|
+
return entry;
|
|
374
|
+
};
|
|
375
|
+
for (const file of repo.files) {
|
|
376
|
+
if (!/\.[cm]?[jt]sx?$/.test(file.path) || TEST_PATH.test(file.path) || EVAL_PATH.test(file.path) || /^scripts\//.test(file.path) && !repo.deployedFiles.has(file.path))
|
|
377
|
+
continue;
|
|
378
|
+
const checker = ctx.checkerFor(file.path), declarations = new Map;
|
|
379
|
+
visit(file.source, (node) => {
|
|
380
|
+
if (import_typescript2.default.isVariableDeclaration(node) && import_typescript2.default.isIdentifier(node.name) && node.initializer)
|
|
381
|
+
declarations.set(node.name.text, node.initializer);
|
|
382
|
+
});
|
|
383
|
+
visit(file.source, (node) => {
|
|
384
|
+
if ((import_typescript2.default.isClassDeclaration(node) || import_typescript2.default.isClassExpression(node)) && node.name && agentByName.has(node.name.text)) {
|
|
385
|
+
const info = checker ? frameworkBaseOf(node, checker, memo) : undefined;
|
|
386
|
+
const directThink = node.heritageClauses?.some((h) => h.types.some((t) => t.expression.getText() === "Think"));
|
|
387
|
+
if (info?.base === "Think" || directThink) {
|
|
388
|
+
const owners2 = agents.agentForScope(`${file.path}#${node.name.text}`);
|
|
389
|
+
const names = [...THINK_WORKSPACE_TOOLS];
|
|
390
|
+
if (inheritedTrue(node, "workspaceBash", checker))
|
|
391
|
+
names.push("bash");
|
|
392
|
+
if (hasSkillSources(node, checker))
|
|
393
|
+
names.push("read_skill_resource");
|
|
394
|
+
for (const name of names)
|
|
395
|
+
add(name, file, node, "think", "Think workspace tool inherited by this concrete agent", owners2);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (import_typescript2.default.isPropertyAccessExpression(node) && node.name.text === "activate_skill" || import_typescript2.default.isPropertyAssignment(node) && nameOf(node.name) === "activate_skill") {
|
|
399
|
+
const owner = ownersAt(node, file.path);
|
|
400
|
+
add("activate_skill", file, node, "think", "Source explicitly exposes Think skill activation", owner);
|
|
401
|
+
}
|
|
402
|
+
if (import_typescript2.default.isCallExpression(node) && import_typescript2.default.isPropertyAccessExpression(node.expression) && /^(?:registerTool|tool)$/.test(node.expression.name.text) && checker) {
|
|
403
|
+
const receiver = valueDeclaration(resolvedSymbol(node.expression.expression, checker));
|
|
404
|
+
const init = receiver && import_typescript2.default.isVariableDeclaration(receiver) && receiver.initializer ? unwrap(receiver.initializer) : undefined;
|
|
405
|
+
const origin = init && import_typescript2.default.isNewExpression(init) && import_typescript2.default.isIdentifier(init.expression) ? importOrigin(init.expression, checker) : undefined;
|
|
406
|
+
const name = node.arguments[0];
|
|
407
|
+
if (origin?.module.startsWith("@modelcontextprotocol/sdk/") && origin.imported === "McpServer" && name && import_typescript2.default.isStringLiteralLike(name)) {
|
|
408
|
+
add(name.text, file, name, "mcp_server", "MCP SDK server explicitly registers this model-facing tool name", ownersAt(node, file.path));
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
if (import_typescript2.default.isCallExpression(node) && import_typescript2.default.isPropertyAccessExpression(node.expression) && node.expression.expression.getText() === "Output" && node.expression.name.text === "object") {
|
|
412
|
+
const owners2 = ownersAt(node, file.path).filter((id) => thinkIds.has(id));
|
|
413
|
+
if (owners2.length && checker && import_typescript2.default.isIdentifier(node.expression.expression) && ["ai", "@cloudflare/think"].includes(importOrigin(node.expression.expression, checker)?.module ?? ""))
|
|
414
|
+
add("think_final_answer", file, node, "think", "Think structured output is offered as the framework final-answer tool", owners2);
|
|
415
|
+
}
|
|
416
|
+
if (import_typescript2.default.isCallExpression(node) && import_typescript2.default.isIdentifier(node.expression) && node.expression.text === "createExecuteRuntime") {
|
|
417
|
+
const owners2 = ownersAt(node, file.path).filter((id) => thinkIds.has(id));
|
|
418
|
+
if (owners2.length && checker && importOrigin(node.expression, checker)?.module.startsWith("@cloudflare/think"))
|
|
419
|
+
add("execute", file, node, "think", "Think Code Mode runtime explicitly enabled for this agent", owners2);
|
|
420
|
+
}
|
|
421
|
+
if (!import_typescript2.default.isObjectLiteralExpression(node))
|
|
422
|
+
return;
|
|
423
|
+
const serverNames = strings(property(node, "name"), checker), allow = property(node, "allow");
|
|
424
|
+
if (serverNames.length !== 1 || !allow || !property(node, "url"))
|
|
425
|
+
return;
|
|
426
|
+
const server = serverNames[0].name;
|
|
427
|
+
const owners = ownersAt(node, file.path);
|
|
428
|
+
if (import_typescript2.default.isStringLiteralLike(unwrap(allow)) && unwrap(allow).text === "all") {
|
|
429
|
+
const entry = add(`${server} dynamic MCP tools`, file, allow, "mcp_dynamic_group", "Server schemas are admitted dynamically as one bounded catalog group", owners);
|
|
430
|
+
entry.serverName = server;
|
|
431
|
+
entry.dynamicGroup = true;
|
|
432
|
+
entry.namePattern = `tool_<${server}ServerId>_*`;
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
for (const tool of strings(allow, checker)) {
|
|
436
|
+
const name = `tool_<${server}ServerIdNoDashes>_${tool.name}`;
|
|
437
|
+
const entry = add(name, file, tool.node, "mcp_allowlist", "Literal MCP allowlist converted by the Agents SDK tool_<serverId>_<name> contract", owners);
|
|
438
|
+
entry.id = componentId("tool", file.path, `${server}:${name}`);
|
|
439
|
+
entry.serverName = server;
|
|
440
|
+
entry.namePattern = name;
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
for (const [name, initializer] of declarations) {
|
|
444
|
+
const match = name.match(/^(.*)_ALLOWED_TOOLS$/);
|
|
445
|
+
if (!match)
|
|
446
|
+
continue;
|
|
447
|
+
const serverName = strings(declarations.get(`${match[1]}_MCP_NAME`), checker)[0]?.name;
|
|
448
|
+
if (!serverName)
|
|
449
|
+
continue;
|
|
450
|
+
for (const tool of strings(initializer, checker)) {
|
|
451
|
+
const entry = add(`${serverName}_${tool.name}`, file, tool.node, "mcp_allowlist", "Explicit named MCP allowlist with server-prefixed model name");
|
|
452
|
+
entry.serverName = serverName;
|
|
453
|
+
entry.usedByAgentIds = [...symbolOwners.get(`${file.source.fileName}:${name}`) ?? []].sort();
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
const merged = new Map;
|
|
458
|
+
const packageOf = workspacePackages(ctx.rootDir);
|
|
459
|
+
for (const item of output.artifacts) {
|
|
460
|
+
const path = item.sourcePath ?? "";
|
|
461
|
+
const surface = surfaceOf(path, packageOf(path));
|
|
462
|
+
const key = `${item.name}\x00${surface}`;
|
|
463
|
+
const previous = merged.get(key);
|
|
464
|
+
if (previous) {
|
|
465
|
+
previous.usedByAgentIds = [...new Set([...previous.usedByAgentIds, ...item.usedByAgentIds])].sort();
|
|
466
|
+
const seen = new Set(previous.evidence.map((e) => `${e.path}:${e.line}`));
|
|
467
|
+
previous.evidence.push(...item.evidence.filter((e) => !seen.has(`${e.path}:${e.line}`)));
|
|
468
|
+
if (item.status === "in_prod" || item.status === "reachable" && previous.status === "defined_only")
|
|
469
|
+
previous.status = item.status;
|
|
470
|
+
} else {
|
|
471
|
+
item.id = `tool:catalog:${item.name}@${encodeURIComponent(surface)}`;
|
|
472
|
+
merged.set(key, item);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
output.artifacts = [...merged.values()];
|
|
476
|
+
return stableResult(output);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// src/harness-extract/enumerators/index.ts
|
|
480
|
+
function enumerateHarnessComponents(result, ctx) {
|
|
481
|
+
const agents = enumerateAgents(result, ctx), workflows = enumerateWorkflows(result, ctx), catalog = enumerateToolCatalog(result, ctx);
|
|
482
|
+
return stableResult({ runtimeAgents: agents.runtimeAgents, artifacts: [...workflows.artifacts, ...toolArtifacts(emitToolsCached(result, ctx), agents.runtimeAgents), ...catalog.artifacts], warnings: [...workflows.warnings, ...catalog.warnings] });
|
|
483
|
+
}
|
|
484
|
+
function mergeEnumeratedComponents(artifacts, components) {
|
|
485
|
+
const merged = new Map;
|
|
486
|
+
const definitions = new Map;
|
|
487
|
+
const registry = components.artifacts.filter((item) => item.type === "tool" && item.id.startsWith("tool.extract."));
|
|
488
|
+
const extractedByName = new Map;
|
|
489
|
+
for (const item of registry) {
|
|
490
|
+
let list = extractedByName.get(item.name);
|
|
491
|
+
if (!list)
|
|
492
|
+
extractedByName.set(item.name, list = []);
|
|
493
|
+
list.push(item);
|
|
494
|
+
}
|
|
495
|
+
const toolKey = (item) => {
|
|
496
|
+
if (registry.includes(item))
|
|
497
|
+
return `tool:${item.id}`;
|
|
498
|
+
const candidates = extractedByName.get(item.name) ?? [];
|
|
499
|
+
if (candidates.length === 0)
|
|
500
|
+
return item.id.startsWith("tool:catalog:") ? `tool:${item.id}` : `tool:${item.name}`;
|
|
501
|
+
const paths = new Set([item.sourcePath, ...item.evidence.map((entry) => entry.path)].filter(Boolean));
|
|
502
|
+
const target = candidates.find((candidate) => candidate.sourcePath && paths.has(candidate.sourcePath) || candidate.definitionVariants?.some((variant) => variant.sourcePath && paths.has(variant.sourcePath))) ?? candidates.find((candidate) => !candidate.id.includes("@")) ?? candidates[0];
|
|
503
|
+
return `tool:${target.id}`;
|
|
504
|
+
};
|
|
505
|
+
for (const item of [...registry, ...artifacts, ...components.artifacts.filter((item2) => !registry.includes(item2))]) {
|
|
506
|
+
const key = item.type === "tool" ? toolKey(item) : item.id;
|
|
507
|
+
if (item.type === "tool") {
|
|
508
|
+
const own = item.definitionVariants ?? (item.body ? [{ sourcePath: item.sourcePath, body: item.body, evidence: item.evidence }] : []);
|
|
509
|
+
let variants = definitions.get(key);
|
|
510
|
+
for (const variant of own) {
|
|
511
|
+
if (!variant.body)
|
|
512
|
+
continue;
|
|
513
|
+
if (!variants)
|
|
514
|
+
definitions.set(key, variants = []);
|
|
515
|
+
if (!variants.some((entry) => entry.id === item.id && entry.sourcePath === variant.sourcePath && entry.body === variant.body))
|
|
516
|
+
variants.push({ id: item.id, sourcePath: variant.sourcePath, body: variant.body, evidence: [...variant.evidence ?? item.evidence], usedByAgentIds: [...item.usedByAgentIds] });
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
const previous = merged.get(key);
|
|
520
|
+
if (!previous) {
|
|
521
|
+
merged.set(key, { ...item, evidence: [...item.evidence], usedByAgentIds: [...item.usedByAgentIds] });
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
const rank = { defined_only: 0, reachable: 1, in_prod: 2 };
|
|
525
|
+
if (item.status && (!previous.status || rank[item.status] > rank[previous.status]))
|
|
526
|
+
previous.status = item.status;
|
|
527
|
+
previous.usedByAgentIds = [...new Set([...previous.usedByAgentIds, ...item.usedByAgentIds])].sort();
|
|
528
|
+
const evidence = new Set(previous.evidence.map((entry) => `${entry.path}:${entry.line}`));
|
|
529
|
+
previous.evidence.push(...item.evidence.filter((entry) => !evidence.has(`${entry.path}:${entry.line}`)));
|
|
530
|
+
if (!previous.body && item.body && !previous.definitionVariants)
|
|
531
|
+
previous.body = item.body;
|
|
532
|
+
}
|
|
533
|
+
for (const [key, variants] of definitions) {
|
|
534
|
+
const item = merged.get(key);
|
|
535
|
+
if (variants.length > 1 || item.id !== variants[0].id)
|
|
536
|
+
item.definitionVariants = variants;
|
|
537
|
+
if (new Set(variants.map((entry) => entry.body)).size > 1)
|
|
538
|
+
delete item.body;
|
|
539
|
+
}
|
|
540
|
+
const output = [...merged.values()].sort((a, b) => a.id.localeCompare(b.id));
|
|
541
|
+
const runtimeAgents = components.runtimeAgents.map((entry) => ({
|
|
542
|
+
...entry,
|
|
543
|
+
artifactIds: [...new Set([...entry.artifactIds, ...output.filter((item) => item.usedByAgentIds.includes(entry.id)).map((item) => item.id)])].sort()
|
|
544
|
+
}));
|
|
545
|
+
return { runtimeAgents, artifacts: output };
|
|
546
|
+
}
|
|
547
|
+
export {
|
|
548
|
+
mergeEnumeratedComponents,
|
|
549
|
+
enumerateWorkflows,
|
|
550
|
+
enumerateToolCatalog,
|
|
551
|
+
enumerateHarnessComponents,
|
|
552
|
+
enumerateAgents,
|
|
553
|
+
createAgentScopeResolver
|
|
554
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CALL_SINKS,
|
|
3
|
-
ENUMERATORS,
|
|
4
3
|
EXTRACT_SCHEMA_VERSION,
|
|
5
4
|
allValues,
|
|
6
5
|
assignAgentIds,
|
|
@@ -15,13 +14,12 @@ import {
|
|
|
15
14
|
registerCallSink,
|
|
16
15
|
registerClassSink,
|
|
17
16
|
renderings,
|
|
18
|
-
runEnumerators,
|
|
19
17
|
scopeOf,
|
|
20
18
|
selectKey,
|
|
21
19
|
serializeExtractResult,
|
|
22
20
|
toolNamesOf,
|
|
23
21
|
valueChildren
|
|
24
|
-
} from "./cli-
|
|
22
|
+
} from "./cli-m5epf2gm.js";
|
|
25
23
|
import"./cli-k0vxtzxb.js";
|
|
26
24
|
import"./cli-97fnztpy.js";
|
|
27
25
|
import"./cli-y333w08f.js";
|
|
@@ -41,7 +39,6 @@ export {
|
|
|
41
39
|
serializeExtractResult,
|
|
42
40
|
selectKey,
|
|
43
41
|
scopeOf,
|
|
44
|
-
runEnumerators,
|
|
45
42
|
renderings,
|
|
46
43
|
registerClassSink,
|
|
47
44
|
registerCallSink,
|
|
@@ -56,6 +53,5 @@ export {
|
|
|
56
53
|
assignAgentIds,
|
|
57
54
|
allValues,
|
|
58
55
|
EXTRACT_SCHEMA_VERSION,
|
|
59
|
-
ENUMERATORS,
|
|
60
56
|
CALL_SINKS
|
|
61
57
|
};
|