@aaac/runtime 0.1.19 → 0.1.21
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/adapters/adk-sdk.d.ts +1 -1
- package/dist/adapters/claude-agent-sdk.d.ts +1 -1
- package/dist/adapters/claude-agent-sdk.js +73 -5
- package/dist/adapters/claude-agent-sdk.js.map +1 -1
- package/dist/adapters/mock.d.ts +1 -1
- package/dist/adapters/openai-agents-sdk.d.ts +1 -1
- package/dist/chunk-FNB3PE74.js +299 -0
- package/dist/chunk-FNB3PE74.js.map +1 -0
- package/dist/index.d.ts +83 -3
- package/dist/index.js +329 -228
- package/dist/index.js.map +1 -1
- package/dist/{task-runner-DV49qwpk.d.ts → task-runner-CuJ3uLj8.d.ts} +44 -1
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildGuardrailContext,
|
|
3
|
-
loadProjectConfig
|
|
4
|
-
} from "./chunk-RL4TCIDU.js";
|
|
5
1
|
import {
|
|
6
2
|
PluginRegistry,
|
|
7
3
|
createGuardrailHooks,
|
|
@@ -12,9 +8,29 @@ import {
|
|
|
12
8
|
hasBlockingViolation,
|
|
13
9
|
pluginRegistry
|
|
14
10
|
} from "./chunk-GZCEEIXQ.js";
|
|
11
|
+
import {
|
|
12
|
+
createExecutionEnvelope,
|
|
13
|
+
emitIterationClose,
|
|
14
|
+
emitIterationMetric,
|
|
15
|
+
emitIterationOpen,
|
|
16
|
+
emitLlmTurnClose,
|
|
17
|
+
emitLlmTurnOpen,
|
|
18
|
+
emitSessionClose,
|
|
19
|
+
emitSessionOpen,
|
|
20
|
+
emitSubagentClose,
|
|
21
|
+
emitSubagentOpen,
|
|
22
|
+
emitToolExecClose,
|
|
23
|
+
emitToolExecOpen,
|
|
24
|
+
emitToolchainClose,
|
|
25
|
+
emitToolchainOpen
|
|
26
|
+
} from "./chunk-FNB3PE74.js";
|
|
15
27
|
import {
|
|
16
28
|
buildSdkFunctionTools
|
|
17
29
|
} from "./chunk-LONLL3K2.js";
|
|
30
|
+
import {
|
|
31
|
+
buildGuardrailContext,
|
|
32
|
+
loadProjectConfig
|
|
33
|
+
} from "./chunk-RL4TCIDU.js";
|
|
18
34
|
import {
|
|
19
35
|
jsonSchemaToZod
|
|
20
36
|
} from "./chunk-ET6TGQRT.js";
|
|
@@ -91,219 +107,288 @@ function buildCandidateAgents(agentRegistry, opts) {
|
|
|
91
107
|
return candidates;
|
|
92
108
|
}
|
|
93
109
|
|
|
94
|
-
// src/lib/
|
|
95
|
-
|
|
96
|
-
function
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
// src/lib/analyzer-bridge.ts
|
|
111
|
+
var ANALYZER_PKG = "artifact-contracts-analyzer";
|
|
112
|
+
async function loadAnalyzerModule() {
|
|
113
|
+
const mod = await import(
|
|
114
|
+
/* webpackIgnore: true */
|
|
115
|
+
ANALYZER_PKG
|
|
116
|
+
);
|
|
117
|
+
return mod;
|
|
118
|
+
}
|
|
119
|
+
function createAnalyzerBridge(options) {
|
|
120
|
+
const { projectRoot, navigationIndex, artifactPatterns, manifests } = options;
|
|
121
|
+
let cachedGraph = null;
|
|
122
|
+
let cachedFileContents = null;
|
|
123
|
+
let graphBuildPromise = null;
|
|
124
|
+
async function ensureGraph() {
|
|
125
|
+
if (cachedGraph) return cachedGraph;
|
|
126
|
+
if (graphBuildPromise) {
|
|
127
|
+
await graphBuildPromise;
|
|
128
|
+
return cachedGraph;
|
|
129
|
+
}
|
|
130
|
+
graphBuildPromise = doBuildGraph();
|
|
131
|
+
await graphBuildPromise;
|
|
132
|
+
return cachedGraph;
|
|
133
|
+
}
|
|
134
|
+
async function doBuildGraph() {
|
|
135
|
+
let mod;
|
|
136
|
+
try {
|
|
137
|
+
mod = await loadAnalyzerModule();
|
|
138
|
+
} catch (error) {
|
|
139
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
140
|
+
throw new Error(
|
|
141
|
+
`artifact-contracts-analyzer is not available. Install it to use analyzer features: ${msg}`
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
const patterns = artifactPatterns ?? /* @__PURE__ */ new Map();
|
|
145
|
+
const registry = mod.createDefaultRegistry();
|
|
146
|
+
const astResult = await mod.buildAstGraph({
|
|
147
|
+
projectRoot,
|
|
148
|
+
artifactPatterns: patterns,
|
|
149
|
+
registry
|
|
150
|
+
});
|
|
151
|
+
cachedFileContents = astResult.fileContents;
|
|
152
|
+
cachedGraph = await mod.buildDependencyGraph({
|
|
153
|
+
ast: astResult.graph,
|
|
154
|
+
projectRoot,
|
|
155
|
+
artifactPatterns: patterns,
|
|
156
|
+
manifests: manifests ?? []
|
|
157
|
+
});
|
|
115
158
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
159
|
+
const bridge = {
|
|
160
|
+
async buildGraph() {
|
|
161
|
+
await ensureGraph();
|
|
162
|
+
},
|
|
163
|
+
async getGraph() {
|
|
164
|
+
return ensureGraph();
|
|
165
|
+
},
|
|
166
|
+
async analyzeImpact(changed, opts) {
|
|
167
|
+
let mod;
|
|
168
|
+
try {
|
|
169
|
+
mod = await loadAnalyzerModule();
|
|
170
|
+
} catch {
|
|
171
|
+
return {
|
|
172
|
+
error: "artifact-contracts-analyzer is not installed. Install it as a peer dependency to use impact analysis.",
|
|
173
|
+
changed
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
const graph = await ensureGraph();
|
|
177
|
+
return mod.analyzeImpact({
|
|
178
|
+
graph,
|
|
179
|
+
changed,
|
|
180
|
+
direction: opts?.direction ?? "downstream",
|
|
181
|
+
...opts?.maxDepth !== void 0 ? { maxDepth: opts.maxDepth } : {},
|
|
182
|
+
...opts?.limit !== void 0 ? { limit: opts.limit } : {},
|
|
183
|
+
...navigationIndex ? { navigationIndex } : {}
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
|
+
async generateContextPack(changed, opts) {
|
|
187
|
+
let mod;
|
|
188
|
+
try {
|
|
189
|
+
mod = await loadAnalyzerModule();
|
|
190
|
+
} catch {
|
|
191
|
+
return {
|
|
192
|
+
entries: [],
|
|
193
|
+
metadata: {
|
|
194
|
+
totalTokens: 0,
|
|
195
|
+
budgetTokens: opts?.budgetTokens ?? 5e4,
|
|
196
|
+
filesIncluded: 0,
|
|
197
|
+
filesExcluded: 0,
|
|
198
|
+
filesReferenced: 0,
|
|
199
|
+
artifactsCovered: [],
|
|
200
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
const graph = await ensureGraph();
|
|
205
|
+
return mod.generateContextPack({
|
|
206
|
+
graph,
|
|
207
|
+
changed,
|
|
208
|
+
projectRoot,
|
|
209
|
+
...opts?.budgetTokens !== void 0 ? { budgetTokens: opts.budgetTokens } : {},
|
|
210
|
+
...opts?.granularity ? { granularity: opts.granularity } : {},
|
|
211
|
+
...navigationIndex ? { navigationIndex } : {},
|
|
212
|
+
...cachedFileContents ? { fileContents: cachedFileContents } : {}
|
|
213
|
+
});
|
|
214
|
+
},
|
|
215
|
+
async buildCallGraph(entry, opts) {
|
|
216
|
+
let mod;
|
|
217
|
+
try {
|
|
218
|
+
mod = await loadAnalyzerModule();
|
|
219
|
+
} catch {
|
|
220
|
+
return {
|
|
221
|
+
error: "artifact-contracts-analyzer is not installed. Install it as a peer dependency to use call graph analysis.",
|
|
222
|
+
entry
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
const graph = await ensureGraph();
|
|
226
|
+
return mod.buildCallGraph({
|
|
227
|
+
graph,
|
|
228
|
+
entry,
|
|
229
|
+
...opts?.maxDepth !== void 0 ? { maxDepth: opts.maxDepth } : {},
|
|
230
|
+
...opts?.direction ? { direction: opts.direction } : {}
|
|
231
|
+
});
|
|
232
|
+
},
|
|
233
|
+
invalidateCache() {
|
|
234
|
+
cachedGraph = null;
|
|
235
|
+
cachedFileContents = null;
|
|
236
|
+
graphBuildPromise = null;
|
|
237
|
+
},
|
|
238
|
+
buildAnalyzerTools() {
|
|
239
|
+
return [
|
|
240
|
+
{
|
|
241
|
+
name: "analyzer.analyzeImpact",
|
|
242
|
+
description: "Analyze the impact of changed files across the dependency graph",
|
|
243
|
+
inputSchema: {
|
|
244
|
+
type: "object",
|
|
245
|
+
properties: {
|
|
246
|
+
changed: {
|
|
247
|
+
type: "array",
|
|
248
|
+
items: { type: "string" },
|
|
249
|
+
description: "File paths that changed"
|
|
250
|
+
},
|
|
251
|
+
direction: {
|
|
252
|
+
type: "string",
|
|
253
|
+
enum: ["downstream", "upstream"],
|
|
254
|
+
description: "Traversal direction. downstream = what breaks if this changes"
|
|
255
|
+
},
|
|
256
|
+
maxDepth: {
|
|
257
|
+
type: "number",
|
|
258
|
+
description: "Maximum BFS depth to explore"
|
|
259
|
+
},
|
|
260
|
+
limit: {
|
|
261
|
+
type: "number",
|
|
262
|
+
description: "Cap the number of affected entries returned"
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
required: ["changed"]
|
|
266
|
+
},
|
|
267
|
+
handler: async (args) => {
|
|
268
|
+
const changed = args.changed;
|
|
269
|
+
const result = await bridge.analyzeImpact(changed, {
|
|
270
|
+
direction: args.direction,
|
|
271
|
+
maxDepth: args.maxDepth,
|
|
272
|
+
limit: args.limit
|
|
273
|
+
});
|
|
274
|
+
return JSON.stringify(result);
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
name: "analyzer.generateContextPack",
|
|
279
|
+
description: "Generate a token-budget-constrained context pack for changed files",
|
|
280
|
+
inputSchema: {
|
|
281
|
+
type: "object",
|
|
282
|
+
properties: {
|
|
283
|
+
changed: {
|
|
284
|
+
type: "array",
|
|
285
|
+
items: { type: "string" },
|
|
286
|
+
description: "File paths that changed"
|
|
287
|
+
},
|
|
288
|
+
budgetTokens: {
|
|
289
|
+
type: "number",
|
|
290
|
+
description: "Token budget for the context pack"
|
|
291
|
+
},
|
|
292
|
+
granularity: {
|
|
293
|
+
type: "string",
|
|
294
|
+
enum: ["file", "symbol"],
|
|
295
|
+
description: "Context granularity level"
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
required: ["changed"]
|
|
299
|
+
},
|
|
300
|
+
handler: async (args) => {
|
|
301
|
+
const changed = args.changed;
|
|
302
|
+
const result = await bridge.generateContextPack(changed, {
|
|
303
|
+
budgetTokens: args.budgetTokens,
|
|
304
|
+
granularity: args.granularity
|
|
305
|
+
});
|
|
306
|
+
return JSON.stringify(result);
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
name: "analyzer.buildCallGraph",
|
|
311
|
+
description: "Build a call graph rooted at a symbol",
|
|
312
|
+
inputSchema: {
|
|
313
|
+
type: "object",
|
|
314
|
+
properties: {
|
|
315
|
+
entry: {
|
|
316
|
+
type: "string",
|
|
317
|
+
description: "Entry symbolId (filePath#name) to root the call graph at"
|
|
318
|
+
},
|
|
319
|
+
maxDepth: {
|
|
320
|
+
type: "number",
|
|
321
|
+
description: "Maximum traversal depth"
|
|
322
|
+
},
|
|
323
|
+
direction: {
|
|
324
|
+
type: "string",
|
|
325
|
+
enum: ["forward", "reverse"],
|
|
326
|
+
description: "Traversal direction: forward (callees) or reverse (callers)"
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
required: ["entry"]
|
|
330
|
+
},
|
|
331
|
+
handler: async (args) => {
|
|
332
|
+
const entry = args.entry;
|
|
333
|
+
const result = await bridge.buildCallGraph(entry, {
|
|
334
|
+
maxDepth: args.maxDepth,
|
|
335
|
+
direction: args.direction
|
|
336
|
+
});
|
|
337
|
+
return JSON.stringify(result);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
];
|
|
171
341
|
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
342
|
+
};
|
|
343
|
+
return bridge;
|
|
344
|
+
}
|
|
345
|
+
function isContextPack(value) {
|
|
346
|
+
if (typeof value !== "object" || value === null) return false;
|
|
347
|
+
const obj = value;
|
|
348
|
+
if (!Array.isArray(obj.entries)) return false;
|
|
349
|
+
if (typeof obj.metadata !== "object" || obj.metadata === null) return false;
|
|
350
|
+
const meta = obj.metadata;
|
|
351
|
+
return typeof meta.totalTokens === "number" && typeof meta.budgetTokens === "number";
|
|
352
|
+
}
|
|
353
|
+
function renderContextPackPrompt(pack) {
|
|
354
|
+
const m = pack.metadata;
|
|
355
|
+
const sections = [];
|
|
356
|
+
sections.push("## Source Code Context");
|
|
357
|
+
sections.push(
|
|
358
|
+
`### Budget
|
|
359
|
+
- Tokens used: ${m.totalTokens} / ${m.budgetTokens}
|
|
360
|
+
- Files included: ${m.filesIncluded}, excluded: ${m.filesExcluded}, referenced: ${m.filesReferenced}`
|
|
361
|
+
);
|
|
362
|
+
if (m.artifactsCovered.length > 0) {
|
|
363
|
+
sections.push(
|
|
364
|
+
`### Affected Artifacts
|
|
365
|
+
${m.artifactsCovered.map((a) => `- ${a}`).join("\n")}`
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
if (pack.entries.length > 0) {
|
|
369
|
+
const fileBlocks = [];
|
|
370
|
+
for (const entry of pack.entries) {
|
|
371
|
+
const ext = entry.path.split(".").pop() ?? "";
|
|
372
|
+
const header = `#### ${entry.path} (relevance: ${entry.relevanceScore}, mode: ${entry.contentMode})`;
|
|
373
|
+
const reason = `> ${entry.reason}`;
|
|
374
|
+
if (entry.content) {
|
|
375
|
+
fileBlocks.push(
|
|
376
|
+
`${header}
|
|
377
|
+
${reason}
|
|
378
|
+
|
|
379
|
+
\`\`\`${ext}
|
|
380
|
+
${entry.content}
|
|
381
|
+
\`\`\``
|
|
382
|
+
);
|
|
383
|
+
} else {
|
|
384
|
+
fileBlocks.push(`${header}
|
|
385
|
+
${reason}`);
|
|
386
|
+
}
|
|
216
387
|
}
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const spanId = generateId();
|
|
222
|
-
observer({
|
|
223
|
-
source: "aaac-runtime",
|
|
224
|
-
eventType: "evaluate.iteration",
|
|
225
|
-
lifecycle: "open",
|
|
226
|
-
spanId,
|
|
227
|
-
parentSpanId,
|
|
228
|
-
attributes: attrs({
|
|
229
|
-
axis: "agent",
|
|
230
|
-
"evaluate.task": evaluateTaskId,
|
|
231
|
-
"evaluate.loop_to": loopTo,
|
|
232
|
-
"evaluate.iteration": iterationNumber,
|
|
233
|
-
"evaluate.max_iterations": maxIterations
|
|
234
|
-
})
|
|
235
|
-
});
|
|
236
|
-
return spanId;
|
|
237
|
-
}
|
|
238
|
-
function emitIterationClose(observer, spanId, evaluateTaskId, iterationNumber, verdict, durationMs, feedbackInjected) {
|
|
239
|
-
if (!observer) return;
|
|
240
|
-
observer({
|
|
241
|
-
source: "aaac-runtime",
|
|
242
|
-
eventType: "evaluate.iteration",
|
|
243
|
-
lifecycle: "close",
|
|
244
|
-
spanId,
|
|
245
|
-
attributes: attrs({
|
|
246
|
-
axis: "agent",
|
|
247
|
-
"evaluate.task": evaluateTaskId,
|
|
248
|
-
"evaluate.iteration": iterationNumber,
|
|
249
|
-
"evaluate.verdict": verdict,
|
|
250
|
-
"evaluate.duration_ms": durationMs,
|
|
251
|
-
"evaluate.feedback_injected": feedbackInjected
|
|
252
|
-
})
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
function emitIterationMetric(observer, parentSpanId, evaluateTaskId, totalIterations, terminalOutcome) {
|
|
256
|
-
if (!observer) return;
|
|
257
|
-
const spanId = generateId();
|
|
258
|
-
observer({
|
|
259
|
-
source: "aaac-runtime",
|
|
260
|
-
eventType: "evaluate.metric",
|
|
261
|
-
lifecycle: "instant",
|
|
262
|
-
spanId,
|
|
263
|
-
parentSpanId,
|
|
264
|
-
attributes: attrs({
|
|
265
|
-
axis: "agent",
|
|
266
|
-
"evaluate.task": evaluateTaskId,
|
|
267
|
-
"evaluate.total_iterations": totalIterations,
|
|
268
|
-
"evaluate.terminal_outcome": terminalOutcome
|
|
269
|
-
})
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
function emitToolchainOpen(observer, parentSpanId, toolchainId, operation, artifactIds, componentId) {
|
|
273
|
-
if (!observer) return void 0;
|
|
274
|
-
const spanId = generateId();
|
|
275
|
-
observer({
|
|
276
|
-
source: "aaac-runtime",
|
|
277
|
-
eventType: "toolchain.execution",
|
|
278
|
-
lifecycle: "open",
|
|
279
|
-
spanId,
|
|
280
|
-
parentSpanId,
|
|
281
|
-
attributes: attrs({
|
|
282
|
-
axis: "toolchain",
|
|
283
|
-
"toolchain.id": toolchainId,
|
|
284
|
-
"toolchain.operation": operation,
|
|
285
|
-
"toolchain.artifact_ids": artifactIds.join(","),
|
|
286
|
-
"agent.component_id": componentId
|
|
287
|
-
})
|
|
288
|
-
});
|
|
289
|
-
return spanId;
|
|
290
|
-
}
|
|
291
|
-
function emitToolchainClose(observer, spanId, toolchainId, operation, durationMs, status, errorMessage) {
|
|
292
|
-
if (!observer) return;
|
|
293
|
-
observer({
|
|
294
|
-
source: "aaac-runtime",
|
|
295
|
-
eventType: "toolchain.execution",
|
|
296
|
-
lifecycle: "close",
|
|
297
|
-
spanId,
|
|
298
|
-
attributes: attrs({
|
|
299
|
-
axis: "toolchain",
|
|
300
|
-
"toolchain.id": toolchainId,
|
|
301
|
-
"toolchain.operation": operation,
|
|
302
|
-
"toolchain.status": status,
|
|
303
|
-
"toolchain.duration_ms": durationMs,
|
|
304
|
-
...errorMessage ? { "toolchain.error": errorMessage } : {}
|
|
305
|
-
})
|
|
306
|
-
});
|
|
388
|
+
sections.push(`### Files
|
|
389
|
+
${fileBlocks.join("\n\n")}`);
|
|
390
|
+
}
|
|
391
|
+
return sections.join("\n\n");
|
|
307
392
|
}
|
|
308
393
|
|
|
309
394
|
// src/lib/task-runner.ts
|
|
@@ -580,10 +665,19 @@ ${context.acceptance_criteria.map((c) => `- ${c}`).join("\n")}`
|
|
|
580
665
|
);
|
|
581
666
|
}
|
|
582
667
|
if (context.variables && Object.keys(context.variables).length > 0) {
|
|
583
|
-
const
|
|
584
|
-
|
|
668
|
+
const contextPack = context.variables.analyzerContextPack;
|
|
669
|
+
if (isContextPack(contextPack)) {
|
|
670
|
+
userSections.push(renderContextPackPrompt(contextPack));
|
|
671
|
+
}
|
|
672
|
+
const otherVars = Object.entries(context.variables).filter(
|
|
673
|
+
([k]) => k !== "analyzerContextPack"
|
|
674
|
+
);
|
|
675
|
+
if (otherVars.length > 0) {
|
|
676
|
+
const varLines = otherVars.map(([k, v]) => `- ${k}: ${typeof v === "string" ? v : JSON.stringify(v)}`).join("\n");
|
|
677
|
+
userSections.push(`## Context Variables
|
|
585
678
|
|
|
586
679
|
${varLines}`);
|
|
680
|
+
}
|
|
587
681
|
}
|
|
588
682
|
return {
|
|
589
683
|
system,
|
|
@@ -850,10 +944,10 @@ async function runTask(adapter, taskId, context, options) {
|
|
|
850
944
|
memoryRef,
|
|
851
945
|
splitPrompt,
|
|
852
946
|
agents,
|
|
853
|
-
options: { readonly: isReadonly, onProgress, splitPrompt, agents, allowDynamicWorkflow, libraryTools: options?.libraryTools, maxFollowUps, attempt: 0 }
|
|
947
|
+
options: { readonly: isReadonly, onProgress, splitPrompt, agents, allowDynamicWorkflow, libraryTools: options?.libraryTools, observer: options?.observer, parentSpanId: subagentSpanId, maxFollowUps, attempt: 0 }
|
|
854
948
|
});
|
|
855
949
|
} else {
|
|
856
|
-
fullOutput = await adapter.send(prompt, { readonly: isReadonly, onProgress, splitPrompt, agents, allowDynamicWorkflow, libraryTools: options?.libraryTools });
|
|
950
|
+
fullOutput = await adapter.send(prompt, { readonly: isReadonly, onProgress, splitPrompt, agents, allowDynamicWorkflow, libraryTools: options?.libraryTools, observer: options?.observer, parentSpanId: subagentSpanId });
|
|
857
951
|
}
|
|
858
952
|
} catch (err) {
|
|
859
953
|
closeStatus = "error";
|
|
@@ -1646,8 +1740,8 @@ function emitStepEvent(options, workflowId, stepIndex, step, result) {
|
|
|
1646
1740
|
}
|
|
1647
1741
|
|
|
1648
1742
|
// src/lib/process-axis-bridge.ts
|
|
1649
|
-
import { generateId
|
|
1650
|
-
function
|
|
1743
|
+
import { generateId } from "@aaac/observability";
|
|
1744
|
+
function attrs(base) {
|
|
1651
1745
|
const out = {};
|
|
1652
1746
|
for (const [k, v] of Object.entries(base)) {
|
|
1653
1747
|
if (v !== void 0 && v !== "") out[k] = v;
|
|
@@ -1656,14 +1750,14 @@ function attrs2(base) {
|
|
|
1656
1750
|
}
|
|
1657
1751
|
function emitProcessWorkflowOpen(options) {
|
|
1658
1752
|
if (!options.observer) return void 0;
|
|
1659
|
-
const spanId =
|
|
1753
|
+
const spanId = generateId();
|
|
1660
1754
|
options.observer({
|
|
1661
1755
|
source: "aaac-runtime",
|
|
1662
1756
|
eventType: "process.workflow",
|
|
1663
1757
|
lifecycle: "open",
|
|
1664
1758
|
spanId,
|
|
1665
1759
|
parentSpanId: options.parentSpanId,
|
|
1666
|
-
attributes:
|
|
1760
|
+
attributes: attrs({
|
|
1667
1761
|
axis: "process",
|
|
1668
1762
|
"agent.session_id": options.sessionId,
|
|
1669
1763
|
"workflow.id": options.workflowId
|
|
@@ -1678,7 +1772,7 @@ function emitProcessWorkflowClose(spanId, options) {
|
|
|
1678
1772
|
eventType: "process.workflow",
|
|
1679
1773
|
lifecycle: "close",
|
|
1680
1774
|
spanId,
|
|
1681
|
-
attributes:
|
|
1775
|
+
attributes: attrs({
|
|
1682
1776
|
axis: "process",
|
|
1683
1777
|
"workflow.status": options.status,
|
|
1684
1778
|
...options.durationMs !== void 0 ? { "workflow.duration_ms": options.durationMs } : {}
|
|
@@ -1687,14 +1781,14 @@ function emitProcessWorkflowClose(spanId, options) {
|
|
|
1687
1781
|
}
|
|
1688
1782
|
function emitProcessTaskOpen(options) {
|
|
1689
1783
|
if (!options.observer) return void 0;
|
|
1690
|
-
const spanId =
|
|
1784
|
+
const spanId = generateId();
|
|
1691
1785
|
options.observer({
|
|
1692
1786
|
source: "aaac-runtime",
|
|
1693
1787
|
eventType: "process.task",
|
|
1694
1788
|
lifecycle: "open",
|
|
1695
1789
|
spanId,
|
|
1696
1790
|
parentSpanId: options.parentSpanId,
|
|
1697
|
-
attributes:
|
|
1791
|
+
attributes: attrs({
|
|
1698
1792
|
axis: "process",
|
|
1699
1793
|
"agent.session_id": options.sessionId,
|
|
1700
1794
|
"task.id": options.taskId,
|
|
@@ -1711,7 +1805,7 @@ function emitProcessTaskClose(spanId, options) {
|
|
|
1711
1805
|
eventType: "process.task",
|
|
1712
1806
|
lifecycle: "close",
|
|
1713
1807
|
spanId,
|
|
1714
|
-
attributes:
|
|
1808
|
+
attributes: attrs({
|
|
1715
1809
|
axis: "process",
|
|
1716
1810
|
"task.status": options.status,
|
|
1717
1811
|
...options.durationMs !== void 0 ? { "task.duration_ms": options.durationMs } : {}
|
|
@@ -1720,14 +1814,14 @@ function emitProcessTaskClose(spanId, options) {
|
|
|
1720
1814
|
}
|
|
1721
1815
|
function emitProcessEdit(options) {
|
|
1722
1816
|
if (!options.observer) return void 0;
|
|
1723
|
-
const spanId =
|
|
1817
|
+
const spanId = generateId();
|
|
1724
1818
|
options.observer({
|
|
1725
1819
|
source: "aaac-runtime",
|
|
1726
1820
|
eventType: "process.edit",
|
|
1727
1821
|
lifecycle: "instant",
|
|
1728
1822
|
spanId,
|
|
1729
1823
|
parentSpanId: options.parentSpanId,
|
|
1730
|
-
attributes:
|
|
1824
|
+
attributes: attrs({
|
|
1731
1825
|
axis: "process",
|
|
1732
1826
|
"agent.session_id": options.sessionId,
|
|
1733
1827
|
"edit.path": options.filePath,
|
|
@@ -3519,6 +3613,7 @@ export {
|
|
|
3519
3613
|
buildSplitTaskPrompt,
|
|
3520
3614
|
buildTaskPrompt,
|
|
3521
3615
|
createAdapter,
|
|
3616
|
+
createAnalyzerBridge,
|
|
3522
3617
|
createComponentScope,
|
|
3523
3618
|
createExecutionEnvelope,
|
|
3524
3619
|
createGuardrailHooks,
|
|
@@ -3534,6 +3629,8 @@ export {
|
|
|
3534
3629
|
emitIterationClose,
|
|
3535
3630
|
emitIterationMetric,
|
|
3536
3631
|
emitIterationOpen,
|
|
3632
|
+
emitLlmTurnClose,
|
|
3633
|
+
emitLlmTurnOpen,
|
|
3537
3634
|
emitProcessEdit,
|
|
3538
3635
|
emitProcessTaskClose,
|
|
3539
3636
|
emitProcessTaskOpen,
|
|
@@ -3543,6 +3640,8 @@ export {
|
|
|
3543
3640
|
emitSessionOpen,
|
|
3544
3641
|
emitSubagentClose,
|
|
3545
3642
|
emitSubagentOpen,
|
|
3643
|
+
emitToolExecClose,
|
|
3644
|
+
emitToolExecOpen,
|
|
3546
3645
|
emitToolchainClose,
|
|
3547
3646
|
emitToolchainOpen,
|
|
3548
3647
|
evaluateGuardrail,
|
|
@@ -3558,6 +3657,7 @@ export {
|
|
|
3558
3657
|
guardStatus,
|
|
3559
3658
|
guardrailContextToRuleData,
|
|
3560
3659
|
hasBlockingViolation,
|
|
3660
|
+
isContextPack,
|
|
3561
3661
|
jsonSchemaToZod,
|
|
3562
3662
|
listGuardrails,
|
|
3563
3663
|
loadDslContext,
|
|
@@ -3569,6 +3669,7 @@ export {
|
|
|
3569
3669
|
parseRouterResponse,
|
|
3570
3670
|
pluginRegistry,
|
|
3571
3671
|
renderAgentSystemPrompt,
|
|
3672
|
+
renderContextPackPrompt,
|
|
3572
3673
|
resolveArtifacts,
|
|
3573
3674
|
runTask,
|
|
3574
3675
|
runToolchainChecks,
|