@aaac/runtime 0.1.19 → 0.1.20
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/index.d.ts +81 -1
- package/dist/index.js +302 -6
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
package/dist/index.d.ts
CHANGED
|
@@ -383,6 +383,86 @@ interface SdkFunctionTool {
|
|
|
383
383
|
*/
|
|
384
384
|
declare function buildSdkFunctionTools(registry: LibraryToolRegistry): SdkFunctionTool[];
|
|
385
385
|
|
|
386
|
+
/**
|
|
387
|
+
* Analyzer Bridge — integrates artifact-contracts-analyzer as a standard
|
|
388
|
+
* runtime tool provider.
|
|
389
|
+
*
|
|
390
|
+
* Wraps analyzeImpact, generateContextPack, and buildCallGraph behind a
|
|
391
|
+
* lazily-initialised DependencyGraph, and exposes them as SdkFunctionTool[]
|
|
392
|
+
* for adapter consumption.
|
|
393
|
+
*
|
|
394
|
+
* `artifact-contracts-analyzer` is a peerDependency (optional) loaded via
|
|
395
|
+
* dynamic import; when absent, every method returns a descriptive error
|
|
396
|
+
* rather than crashing.
|
|
397
|
+
*/
|
|
398
|
+
|
|
399
|
+
/** Subset of DependencyGraph that the bridge caches and exposes. */
|
|
400
|
+
type DependencyGraph = Record<string, unknown>;
|
|
401
|
+
/** Subset of ImpactReport returned by analyzeImpact. */
|
|
402
|
+
type ImpactReport = Record<string, unknown>;
|
|
403
|
+
/** Subset of ContextPack returned by generateContextPack. */
|
|
404
|
+
type ContextPack = {
|
|
405
|
+
entries: Array<{
|
|
406
|
+
path: string;
|
|
407
|
+
artifactId?: string;
|
|
408
|
+
relevanceScore: number;
|
|
409
|
+
contentMode: string;
|
|
410
|
+
content: string;
|
|
411
|
+
reason: string;
|
|
412
|
+
}>;
|
|
413
|
+
metadata: {
|
|
414
|
+
totalTokens: number;
|
|
415
|
+
budgetTokens: number;
|
|
416
|
+
filesIncluded: number;
|
|
417
|
+
filesExcluded: number;
|
|
418
|
+
filesReferenced: number;
|
|
419
|
+
artifactsCovered: string[];
|
|
420
|
+
generatedAt: string;
|
|
421
|
+
};
|
|
422
|
+
taskId?: string;
|
|
423
|
+
};
|
|
424
|
+
/** Subset of CallGraph returned by buildCallGraph. */
|
|
425
|
+
type CallGraph = Record<string, unknown>;
|
|
426
|
+
interface AnalyzerBridgeOptions {
|
|
427
|
+
projectRoot: string;
|
|
428
|
+
navigationIndex?: Record<string, unknown>;
|
|
429
|
+
artifactPatterns?: Map<string, string[]>;
|
|
430
|
+
manifests?: string[];
|
|
431
|
+
}
|
|
432
|
+
interface AnalyzeImpactInput {
|
|
433
|
+
direction: "downstream" | "upstream";
|
|
434
|
+
maxDepth: number;
|
|
435
|
+
limit: number;
|
|
436
|
+
}
|
|
437
|
+
interface GenerateContextPackInput {
|
|
438
|
+
budgetTokens: number;
|
|
439
|
+
granularity: "file" | "symbol";
|
|
440
|
+
}
|
|
441
|
+
interface BuildCallGraphInput {
|
|
442
|
+
maxDepth: number;
|
|
443
|
+
direction: "forward" | "reverse";
|
|
444
|
+
}
|
|
445
|
+
interface AnalyzerBridge {
|
|
446
|
+
buildGraph(): Promise<void>;
|
|
447
|
+
getGraph(): Promise<DependencyGraph>;
|
|
448
|
+
analyzeImpact(changed: string[], options?: Partial<AnalyzeImpactInput>): Promise<ImpactReport>;
|
|
449
|
+
generateContextPack(changed: string[], options?: Partial<GenerateContextPackInput>): Promise<ContextPack>;
|
|
450
|
+
buildCallGraph(entry: string, options?: Partial<BuildCallGraphInput>): Promise<CallGraph>;
|
|
451
|
+
invalidateCache(): void;
|
|
452
|
+
buildAnalyzerTools(): SdkFunctionTool[];
|
|
453
|
+
}
|
|
454
|
+
declare function createAnalyzerBridge(options: AnalyzerBridgeOptions): AnalyzerBridge;
|
|
455
|
+
/**
|
|
456
|
+
* Duck-type check: does `value` look like a ContextPack?
|
|
457
|
+
* Checks for the `entries` array and `metadata` object with expected fields.
|
|
458
|
+
*/
|
|
459
|
+
declare function isContextPack(value: unknown): value is ContextPack;
|
|
460
|
+
/**
|
|
461
|
+
* Render a ContextPack as a structured prompt section.
|
|
462
|
+
* Used by task-runner when `variables.analyzerContextPack` is present.
|
|
463
|
+
*/
|
|
464
|
+
declare function renderContextPackPrompt(pack: ContextPack): string;
|
|
465
|
+
|
|
386
466
|
/**
|
|
387
467
|
* Adapter Factory — public API for creating SDK adapters by name.
|
|
388
468
|
*
|
|
@@ -811,4 +891,4 @@ declare function executePrompt(message: string, ir: ComponentIR, binding: Runtim
|
|
|
811
891
|
/** Package version string. */
|
|
812
892
|
declare const version: string;
|
|
813
893
|
|
|
814
|
-
export { type AaacInvocationContext, type AaacObserver, type AaacPolicy, type AaacRuntime, AgentContractLike, AgentLogWriter, type AgentLogWriterOptions, type AgentPlugin, ArtifactBindingConfig, type ArtifactResolveOptions, type ArtifactResolveResult, type ComponentScope, type CreateAdapterOptions, type CreateComponentScopeOptions, type CreateProjectRuntimeOptions, DelegateStep, type DslContext, DslValidationError, type EvaluateGuardrailOptions, type EvaluateGuardrailResult, type ExecuteOptions, type ExecuteTaskOptions, type ExecuteWorkflowOptions, FileMemoryStore, type GuardStatusOptions, type GuardStatusResult, GuardrailCheckResult, GuardrailHooks, type GuardrailListEntry, type GuardrailResult, GuardrailRuleData, HandoffInput, HookResponse, LibraryToolDefinition, LibraryToolRegistry, type ListGuardrailsOptions, type ListGuardrailsResult, type LoadDslOptions, MemoryRef, MemoryStore, type MemoryStoreEntry, type NavigationContext, type NavigationContextOptions, ObserverEmitFn, type OperationHandler, type OperationMemoryRefConfig, type OperationToolDef, PROJECT_CONFIG_FILENAME, type PermissionMode, type PluginLoadResult, PluginRegistry, type ProcessEditOptions, type ProcessTaskOptions, type ProcessWorkflowOptions, type ProgressSink, type ProgressSinkOptions, type ProjectRuntime, type PromptBuilderArgs, PromptBuilderOptions, type PromptExecuteOptions, type PromptResult, type RequiredEntities, type ResolvedAdapterSelection, ResolvedComponent, ResolvedToolchain, type RunLogEvent, RunToolchainChecksOptions, type Runtime, type RuntimeBinding, type RuntimeConfig, SdkAdapter, type SdkFunctionTool, StepCompleteEvent, StepResult, TaskContext, TaskContractLike, type TaskHookContext, TaskOutcome, TaskRunResult, WorkflowBuilder, type WorkflowHookContext, WorkflowRegistries, WorkflowResult, buildGuardrailRulesFromDsl, buildNavigationContext, buildRegistriesFromDsl, buildSdkFunctionTools, createAdapter, createComponentScope, createProgressSink, createProjectRuntime, createRuntime, createRuntimeBinding, emitProcessEdit, emitProcessTaskClose, emitProcessTaskOpen, emitProcessWorkflowClose, emitProcessWorkflowOpen, evaluateGuardrail, executePrompt, executeTask, executeWorkflow, findProjectConfig, guardStatus, jsonSchemaToZod, listGuardrails, loadDslContext, loadPlugins, loadPluginsFromDirectory, loadPluginsFromPaths, operationsToTools, parseRouterResponse, pluginRegistry, resolveArtifacts, version };
|
|
894
|
+
export { type AaacInvocationContext, type AaacObserver, type AaacPolicy, type AaacRuntime, AgentContractLike, AgentLogWriter, type AgentLogWriterOptions, type AgentPlugin, type AnalyzeImpactInput, type AnalyzerBridge, type AnalyzerBridgeOptions, ArtifactBindingConfig, type ArtifactResolveOptions, type ArtifactResolveResult, type BuildCallGraphInput, type ComponentScope, type CreateAdapterOptions, type CreateComponentScopeOptions, type CreateProjectRuntimeOptions, DelegateStep, type DslContext, DslValidationError, type EvaluateGuardrailOptions, type EvaluateGuardrailResult, type ExecuteOptions, type ExecuteTaskOptions, type ExecuteWorkflowOptions, FileMemoryStore, type GenerateContextPackInput, type GuardStatusOptions, type GuardStatusResult, GuardrailCheckResult, GuardrailHooks, type GuardrailListEntry, type GuardrailResult, GuardrailRuleData, HandoffInput, HookResponse, LibraryToolDefinition, LibraryToolRegistry, type ListGuardrailsOptions, type ListGuardrailsResult, type LoadDslOptions, MemoryRef, MemoryStore, type MemoryStoreEntry, type NavigationContext, type NavigationContextOptions, ObserverEmitFn, type OperationHandler, type OperationMemoryRefConfig, type OperationToolDef, PROJECT_CONFIG_FILENAME, type PermissionMode, type PluginLoadResult, PluginRegistry, type ProcessEditOptions, type ProcessTaskOptions, type ProcessWorkflowOptions, type ProgressSink, type ProgressSinkOptions, type ProjectRuntime, type PromptBuilderArgs, PromptBuilderOptions, type PromptExecuteOptions, type PromptResult, type RequiredEntities, type ResolvedAdapterSelection, ResolvedComponent, ResolvedToolchain, type RunLogEvent, RunToolchainChecksOptions, type Runtime, type RuntimeBinding, type RuntimeConfig, SdkAdapter, type SdkFunctionTool, StepCompleteEvent, StepResult, TaskContext, TaskContractLike, type TaskHookContext, TaskOutcome, TaskRunResult, WorkflowBuilder, type WorkflowHookContext, WorkflowRegistries, WorkflowResult, buildGuardrailRulesFromDsl, buildNavigationContext, buildRegistriesFromDsl, buildSdkFunctionTools, createAdapter, createAnalyzerBridge, createComponentScope, createProgressSink, createProjectRuntime, createRuntime, createRuntimeBinding, emitProcessEdit, emitProcessTaskClose, emitProcessTaskOpen, emitProcessWorkflowClose, emitProcessWorkflowOpen, evaluateGuardrail, executePrompt, executeTask, executeWorkflow, findProjectConfig, guardStatus, isContextPack, jsonSchemaToZod, listGuardrails, loadDslContext, loadPlugins, loadPluginsFromDirectory, loadPluginsFromPaths, operationsToTools, parseRouterResponse, pluginRegistry, renderContextPackPrompt, resolveArtifacts, version };
|
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,
|
|
@@ -15,6 +11,10 @@ import {
|
|
|
15
11
|
import {
|
|
16
12
|
buildSdkFunctionTools
|
|
17
13
|
} from "./chunk-LONLL3K2.js";
|
|
14
|
+
import {
|
|
15
|
+
buildGuardrailContext,
|
|
16
|
+
loadProjectConfig
|
|
17
|
+
} from "./chunk-RL4TCIDU.js";
|
|
18
18
|
import {
|
|
19
19
|
jsonSchemaToZod
|
|
20
20
|
} from "./chunk-ET6TGQRT.js";
|
|
@@ -91,6 +91,290 @@ function buildCandidateAgents(agentRegistry, opts) {
|
|
|
91
91
|
return candidates;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
// src/lib/analyzer-bridge.ts
|
|
95
|
+
var ANALYZER_PKG = "artifact-contracts-analyzer";
|
|
96
|
+
async function loadAnalyzerModule() {
|
|
97
|
+
const mod = await import(
|
|
98
|
+
/* webpackIgnore: true */
|
|
99
|
+
ANALYZER_PKG
|
|
100
|
+
);
|
|
101
|
+
return mod;
|
|
102
|
+
}
|
|
103
|
+
function createAnalyzerBridge(options) {
|
|
104
|
+
const { projectRoot, navigationIndex, artifactPatterns, manifests } = options;
|
|
105
|
+
let cachedGraph = null;
|
|
106
|
+
let cachedFileContents = null;
|
|
107
|
+
let graphBuildPromise = null;
|
|
108
|
+
async function ensureGraph() {
|
|
109
|
+
if (cachedGraph) return cachedGraph;
|
|
110
|
+
if (graphBuildPromise) {
|
|
111
|
+
await graphBuildPromise;
|
|
112
|
+
return cachedGraph;
|
|
113
|
+
}
|
|
114
|
+
graphBuildPromise = doBuildGraph();
|
|
115
|
+
await graphBuildPromise;
|
|
116
|
+
return cachedGraph;
|
|
117
|
+
}
|
|
118
|
+
async function doBuildGraph() {
|
|
119
|
+
let mod;
|
|
120
|
+
try {
|
|
121
|
+
mod = await loadAnalyzerModule();
|
|
122
|
+
} catch (error) {
|
|
123
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
124
|
+
throw new Error(
|
|
125
|
+
`artifact-contracts-analyzer is not available. Install it to use analyzer features: ${msg}`
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
const patterns = artifactPatterns ?? /* @__PURE__ */ new Map();
|
|
129
|
+
const registry = mod.createDefaultRegistry();
|
|
130
|
+
const astResult = await mod.buildAstGraph({
|
|
131
|
+
projectRoot,
|
|
132
|
+
artifactPatterns: patterns,
|
|
133
|
+
registry
|
|
134
|
+
});
|
|
135
|
+
cachedFileContents = astResult.fileContents;
|
|
136
|
+
cachedGraph = await mod.buildDependencyGraph({
|
|
137
|
+
ast: astResult.graph,
|
|
138
|
+
projectRoot,
|
|
139
|
+
artifactPatterns: patterns,
|
|
140
|
+
manifests: manifests ?? []
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
const bridge = {
|
|
144
|
+
async buildGraph() {
|
|
145
|
+
await ensureGraph();
|
|
146
|
+
},
|
|
147
|
+
async getGraph() {
|
|
148
|
+
return ensureGraph();
|
|
149
|
+
},
|
|
150
|
+
async analyzeImpact(changed, opts) {
|
|
151
|
+
let mod;
|
|
152
|
+
try {
|
|
153
|
+
mod = await loadAnalyzerModule();
|
|
154
|
+
} catch {
|
|
155
|
+
return {
|
|
156
|
+
error: "artifact-contracts-analyzer is not installed. Install it as a peer dependency to use impact analysis.",
|
|
157
|
+
changed
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const graph = await ensureGraph();
|
|
161
|
+
return mod.analyzeImpact({
|
|
162
|
+
graph,
|
|
163
|
+
changed,
|
|
164
|
+
direction: opts?.direction ?? "downstream",
|
|
165
|
+
...opts?.maxDepth !== void 0 ? { maxDepth: opts.maxDepth } : {},
|
|
166
|
+
...opts?.limit !== void 0 ? { limit: opts.limit } : {},
|
|
167
|
+
...navigationIndex ? { navigationIndex } : {}
|
|
168
|
+
});
|
|
169
|
+
},
|
|
170
|
+
async generateContextPack(changed, opts) {
|
|
171
|
+
let mod;
|
|
172
|
+
try {
|
|
173
|
+
mod = await loadAnalyzerModule();
|
|
174
|
+
} catch {
|
|
175
|
+
return {
|
|
176
|
+
entries: [],
|
|
177
|
+
metadata: {
|
|
178
|
+
totalTokens: 0,
|
|
179
|
+
budgetTokens: opts?.budgetTokens ?? 5e4,
|
|
180
|
+
filesIncluded: 0,
|
|
181
|
+
filesExcluded: 0,
|
|
182
|
+
filesReferenced: 0,
|
|
183
|
+
artifactsCovered: [],
|
|
184
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const graph = await ensureGraph();
|
|
189
|
+
return mod.generateContextPack({
|
|
190
|
+
graph,
|
|
191
|
+
changed,
|
|
192
|
+
projectRoot,
|
|
193
|
+
...opts?.budgetTokens !== void 0 ? { budgetTokens: opts.budgetTokens } : {},
|
|
194
|
+
...opts?.granularity ? { granularity: opts.granularity } : {},
|
|
195
|
+
...navigationIndex ? { navigationIndex } : {},
|
|
196
|
+
...cachedFileContents ? { fileContents: cachedFileContents } : {}
|
|
197
|
+
});
|
|
198
|
+
},
|
|
199
|
+
async buildCallGraph(entry, opts) {
|
|
200
|
+
let mod;
|
|
201
|
+
try {
|
|
202
|
+
mod = await loadAnalyzerModule();
|
|
203
|
+
} catch {
|
|
204
|
+
return {
|
|
205
|
+
error: "artifact-contracts-analyzer is not installed. Install it as a peer dependency to use call graph analysis.",
|
|
206
|
+
entry
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
const graph = await ensureGraph();
|
|
210
|
+
return mod.buildCallGraph({
|
|
211
|
+
graph,
|
|
212
|
+
entry,
|
|
213
|
+
...opts?.maxDepth !== void 0 ? { maxDepth: opts.maxDepth } : {},
|
|
214
|
+
...opts?.direction ? { direction: opts.direction } : {}
|
|
215
|
+
});
|
|
216
|
+
},
|
|
217
|
+
invalidateCache() {
|
|
218
|
+
cachedGraph = null;
|
|
219
|
+
cachedFileContents = null;
|
|
220
|
+
graphBuildPromise = null;
|
|
221
|
+
},
|
|
222
|
+
buildAnalyzerTools() {
|
|
223
|
+
return [
|
|
224
|
+
{
|
|
225
|
+
name: "analyzer.analyzeImpact",
|
|
226
|
+
description: "Analyze the impact of changed files across the dependency graph",
|
|
227
|
+
inputSchema: {
|
|
228
|
+
type: "object",
|
|
229
|
+
properties: {
|
|
230
|
+
changed: {
|
|
231
|
+
type: "array",
|
|
232
|
+
items: { type: "string" },
|
|
233
|
+
description: "File paths that changed"
|
|
234
|
+
},
|
|
235
|
+
direction: {
|
|
236
|
+
type: "string",
|
|
237
|
+
enum: ["downstream", "upstream"],
|
|
238
|
+
description: "Traversal direction. downstream = what breaks if this changes"
|
|
239
|
+
},
|
|
240
|
+
maxDepth: {
|
|
241
|
+
type: "number",
|
|
242
|
+
description: "Maximum BFS depth to explore"
|
|
243
|
+
},
|
|
244
|
+
limit: {
|
|
245
|
+
type: "number",
|
|
246
|
+
description: "Cap the number of affected entries returned"
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
required: ["changed"]
|
|
250
|
+
},
|
|
251
|
+
handler: async (args) => {
|
|
252
|
+
const changed = args.changed;
|
|
253
|
+
const result = await bridge.analyzeImpact(changed, {
|
|
254
|
+
direction: args.direction,
|
|
255
|
+
maxDepth: args.maxDepth,
|
|
256
|
+
limit: args.limit
|
|
257
|
+
});
|
|
258
|
+
return JSON.stringify(result);
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
name: "analyzer.generateContextPack",
|
|
263
|
+
description: "Generate a token-budget-constrained context pack for changed files",
|
|
264
|
+
inputSchema: {
|
|
265
|
+
type: "object",
|
|
266
|
+
properties: {
|
|
267
|
+
changed: {
|
|
268
|
+
type: "array",
|
|
269
|
+
items: { type: "string" },
|
|
270
|
+
description: "File paths that changed"
|
|
271
|
+
},
|
|
272
|
+
budgetTokens: {
|
|
273
|
+
type: "number",
|
|
274
|
+
description: "Token budget for the context pack"
|
|
275
|
+
},
|
|
276
|
+
granularity: {
|
|
277
|
+
type: "string",
|
|
278
|
+
enum: ["file", "symbol"],
|
|
279
|
+
description: "Context granularity level"
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
required: ["changed"]
|
|
283
|
+
},
|
|
284
|
+
handler: async (args) => {
|
|
285
|
+
const changed = args.changed;
|
|
286
|
+
const result = await bridge.generateContextPack(changed, {
|
|
287
|
+
budgetTokens: args.budgetTokens,
|
|
288
|
+
granularity: args.granularity
|
|
289
|
+
});
|
|
290
|
+
return JSON.stringify(result);
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
name: "analyzer.buildCallGraph",
|
|
295
|
+
description: "Build a call graph rooted at a symbol",
|
|
296
|
+
inputSchema: {
|
|
297
|
+
type: "object",
|
|
298
|
+
properties: {
|
|
299
|
+
entry: {
|
|
300
|
+
type: "string",
|
|
301
|
+
description: "Entry symbolId (filePath#name) to root the call graph at"
|
|
302
|
+
},
|
|
303
|
+
maxDepth: {
|
|
304
|
+
type: "number",
|
|
305
|
+
description: "Maximum traversal depth"
|
|
306
|
+
},
|
|
307
|
+
direction: {
|
|
308
|
+
type: "string",
|
|
309
|
+
enum: ["forward", "reverse"],
|
|
310
|
+
description: "Traversal direction: forward (callees) or reverse (callers)"
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
required: ["entry"]
|
|
314
|
+
},
|
|
315
|
+
handler: async (args) => {
|
|
316
|
+
const entry = args.entry;
|
|
317
|
+
const result = await bridge.buildCallGraph(entry, {
|
|
318
|
+
maxDepth: args.maxDepth,
|
|
319
|
+
direction: args.direction
|
|
320
|
+
});
|
|
321
|
+
return JSON.stringify(result);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
];
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
return bridge;
|
|
328
|
+
}
|
|
329
|
+
function isContextPack(value) {
|
|
330
|
+
if (typeof value !== "object" || value === null) return false;
|
|
331
|
+
const obj = value;
|
|
332
|
+
if (!Array.isArray(obj.entries)) return false;
|
|
333
|
+
if (typeof obj.metadata !== "object" || obj.metadata === null) return false;
|
|
334
|
+
const meta = obj.metadata;
|
|
335
|
+
return typeof meta.totalTokens === "number" && typeof meta.budgetTokens === "number";
|
|
336
|
+
}
|
|
337
|
+
function renderContextPackPrompt(pack) {
|
|
338
|
+
const m = pack.metadata;
|
|
339
|
+
const sections = [];
|
|
340
|
+
sections.push("## Source Code Context");
|
|
341
|
+
sections.push(
|
|
342
|
+
`### Budget
|
|
343
|
+
- Tokens used: ${m.totalTokens} / ${m.budgetTokens}
|
|
344
|
+
- Files included: ${m.filesIncluded}, excluded: ${m.filesExcluded}, referenced: ${m.filesReferenced}`
|
|
345
|
+
);
|
|
346
|
+
if (m.artifactsCovered.length > 0) {
|
|
347
|
+
sections.push(
|
|
348
|
+
`### Affected Artifacts
|
|
349
|
+
${m.artifactsCovered.map((a) => `- ${a}`).join("\n")}`
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
if (pack.entries.length > 0) {
|
|
353
|
+
const fileBlocks = [];
|
|
354
|
+
for (const entry of pack.entries) {
|
|
355
|
+
const ext = entry.path.split(".").pop() ?? "";
|
|
356
|
+
const header = `#### ${entry.path} (relevance: ${entry.relevanceScore}, mode: ${entry.contentMode})`;
|
|
357
|
+
const reason = `> ${entry.reason}`;
|
|
358
|
+
if (entry.content) {
|
|
359
|
+
fileBlocks.push(
|
|
360
|
+
`${header}
|
|
361
|
+
${reason}
|
|
362
|
+
|
|
363
|
+
\`\`\`${ext}
|
|
364
|
+
${entry.content}
|
|
365
|
+
\`\`\``
|
|
366
|
+
);
|
|
367
|
+
} else {
|
|
368
|
+
fileBlocks.push(`${header}
|
|
369
|
+
${reason}`);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
sections.push(`### Files
|
|
373
|
+
${fileBlocks.join("\n\n")}`);
|
|
374
|
+
}
|
|
375
|
+
return sections.join("\n\n");
|
|
376
|
+
}
|
|
377
|
+
|
|
94
378
|
// src/lib/observability-bridge.ts
|
|
95
379
|
import { generateId } from "@aaac/observability";
|
|
96
380
|
function createExecutionEnvelope(params = {}) {
|
|
@@ -580,10 +864,19 @@ ${context.acceptance_criteria.map((c) => `- ${c}`).join("\n")}`
|
|
|
580
864
|
);
|
|
581
865
|
}
|
|
582
866
|
if (context.variables && Object.keys(context.variables).length > 0) {
|
|
583
|
-
const
|
|
584
|
-
|
|
867
|
+
const contextPack = context.variables.analyzerContextPack;
|
|
868
|
+
if (isContextPack(contextPack)) {
|
|
869
|
+
userSections.push(renderContextPackPrompt(contextPack));
|
|
870
|
+
}
|
|
871
|
+
const otherVars = Object.entries(context.variables).filter(
|
|
872
|
+
([k]) => k !== "analyzerContextPack"
|
|
873
|
+
);
|
|
874
|
+
if (otherVars.length > 0) {
|
|
875
|
+
const varLines = otherVars.map(([k, v]) => `- ${k}: ${typeof v === "string" ? v : JSON.stringify(v)}`).join("\n");
|
|
876
|
+
userSections.push(`## Context Variables
|
|
585
877
|
|
|
586
878
|
${varLines}`);
|
|
879
|
+
}
|
|
587
880
|
}
|
|
588
881
|
return {
|
|
589
882
|
system,
|
|
@@ -3519,6 +3812,7 @@ export {
|
|
|
3519
3812
|
buildSplitTaskPrompt,
|
|
3520
3813
|
buildTaskPrompt,
|
|
3521
3814
|
createAdapter,
|
|
3815
|
+
createAnalyzerBridge,
|
|
3522
3816
|
createComponentScope,
|
|
3523
3817
|
createExecutionEnvelope,
|
|
3524
3818
|
createGuardrailHooks,
|
|
@@ -3558,6 +3852,7 @@ export {
|
|
|
3558
3852
|
guardStatus,
|
|
3559
3853
|
guardrailContextToRuleData,
|
|
3560
3854
|
hasBlockingViolation,
|
|
3855
|
+
isContextPack,
|
|
3561
3856
|
jsonSchemaToZod,
|
|
3562
3857
|
listGuardrails,
|
|
3563
3858
|
loadDslContext,
|
|
@@ -3569,6 +3864,7 @@ export {
|
|
|
3569
3864
|
parseRouterResponse,
|
|
3570
3865
|
pluginRegistry,
|
|
3571
3866
|
renderAgentSystemPrompt,
|
|
3867
|
+
renderContextPackPrompt,
|
|
3572
3868
|
resolveArtifacts,
|
|
3573
3869
|
runTask,
|
|
3574
3870
|
runToolchainChecks,
|