@aaac/runtime 0.1.17 → 0.1.18
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 +54 -1
- package/dist/index.js +128 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -787,6 +787,59 @@ declare function parseRouterResponse(response: string, validNames: string[]): {
|
|
|
787
787
|
*/
|
|
788
788
|
declare function executePrompt(message: string, ir: ComponentIR, binding: RuntimeBinding, ctx: AaacInvocationContext, opts: PromptExecuteOptions): Promise<PromptResult>;
|
|
789
789
|
|
|
790
|
+
/**
|
|
791
|
+
* Toolchain Checker — runs check commands defined in toolchain-contracts
|
|
792
|
+
* and returns structured pass/fail results.
|
|
793
|
+
*
|
|
794
|
+
* Each toolchain may declare a `checks` map (checkType → shell command).
|
|
795
|
+
* This module iterates all checks, executes them via subprocess, and
|
|
796
|
+
* returns a ToolchainCheckResult[].
|
|
797
|
+
*
|
|
798
|
+
* For "drift" check types, a manifest-based fast path is available:
|
|
799
|
+
* if a .toolchain-manifest.json exists and the toolchain_id matches,
|
|
800
|
+
* the command execution can be skipped when the source hash is current.
|
|
801
|
+
*/
|
|
802
|
+
|
|
803
|
+
declare const ToolchainManifestSchema: z.ZodObject<{
|
|
804
|
+
schema: z.ZodString;
|
|
805
|
+
toolchain_id: z.ZodString;
|
|
806
|
+
generated_at: z.ZodString;
|
|
807
|
+
source_hash: z.ZodString;
|
|
808
|
+
output_hash: z.ZodString;
|
|
809
|
+
source_globs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
810
|
+
output_globs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
811
|
+
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
812
|
+
path: z.ZodString;
|
|
813
|
+
hash: z.ZodString;
|
|
814
|
+
}, z.core.$strip>>>;
|
|
815
|
+
}, z.core.$strip>;
|
|
816
|
+
type ToolchainManifest = z.infer<typeof ToolchainManifestSchema>;
|
|
817
|
+
interface ToolchainCheckResult {
|
|
818
|
+
toolchainId: string;
|
|
819
|
+
checkType: string;
|
|
820
|
+
status: "pass" | "fail" | "skip" | "error";
|
|
821
|
+
action: "block" | "warn" | "shadow";
|
|
822
|
+
message?: string;
|
|
823
|
+
durationMs?: number;
|
|
824
|
+
}
|
|
825
|
+
interface RunToolchainChecksOptions {
|
|
826
|
+
/** Absolute path to toolchain-contracts YAML */
|
|
827
|
+
toolchainsPath: string;
|
|
828
|
+
/** Absolute path to artifact-contracts YAML (optional, for manifest fast path) */
|
|
829
|
+
artifactsPath?: string;
|
|
830
|
+
/** Working directory for subprocess execution */
|
|
831
|
+
cwd?: string;
|
|
832
|
+
/** Filter: only run these check types */
|
|
833
|
+
checkTypes?: string[];
|
|
834
|
+
/** Filter: only run checks for these toolchain IDs */
|
|
835
|
+
toolchainFilter?: string[];
|
|
836
|
+
/** Policy-resolved action per check type. Key = check type, value = action. Special key "_default" for fallback. */
|
|
837
|
+
checkTypeActions?: Record<string, "block" | "warn" | "shadow">;
|
|
838
|
+
/** Default action when no policy match */
|
|
839
|
+
defaultAction?: "block" | "warn" | "shadow";
|
|
840
|
+
}
|
|
841
|
+
declare function runToolchainChecks(options: RunToolchainChecksOptions): Promise<ToolchainCheckResult[]>;
|
|
842
|
+
|
|
790
843
|
/**
|
|
791
844
|
* @aaac/runtime — public API
|
|
792
845
|
*
|
|
@@ -795,4 +848,4 @@ declare function executePrompt(message: string, ir: ComponentIR, binding: Runtim
|
|
|
795
848
|
/** Package version string. */
|
|
796
849
|
declare const version: string;
|
|
797
850
|
|
|
798
|
-
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, 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 };
|
|
851
|
+
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, type RunToolchainChecksOptions, type Runtime, type RuntimeBinding, type RuntimeConfig, SdkAdapter, type SdkFunctionTool, StepCompleteEvent, StepResult, TaskContext, TaskContractLike, type TaskHookContext, TaskOutcome, TaskRunResult, type ToolchainCheckResult, type ToolchainManifest, ToolchainManifestSchema, 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, runToolchainChecks, version };
|
package/dist/index.js
CHANGED
|
@@ -2946,8 +2946,8 @@ async function buildNavigationContext(options) {
|
|
|
2946
2946
|
dsl = options.embeddedDsl;
|
|
2947
2947
|
}
|
|
2948
2948
|
} else if (options.projectDslPath) {
|
|
2949
|
-
const { resolve:
|
|
2950
|
-
const result = await
|
|
2949
|
+
const { resolve: resolve5 } = await import("agent-contracts");
|
|
2950
|
+
const result = await resolve5(options.projectDslPath);
|
|
2951
2951
|
dsl = result.data;
|
|
2952
2952
|
} else {
|
|
2953
2953
|
throw new Error("buildNavigationContext requires embeddedDsl or projectDslPath");
|
|
@@ -3267,6 +3267,130 @@ async function executePrompt(message, ir, binding, ctx, opts) {
|
|
|
3267
3267
|
return { selectedOperation, mappedInput, output };
|
|
3268
3268
|
}
|
|
3269
3269
|
|
|
3270
|
+
// src/lib/toolchain-checker.ts
|
|
3271
|
+
import { execFile } from "child_process";
|
|
3272
|
+
import { readFile as readFile7 } from "fs/promises";
|
|
3273
|
+
import { existsSync as existsSync3 } from "fs";
|
|
3274
|
+
import { resolve as resolve4 } from "path";
|
|
3275
|
+
import { promisify } from "util";
|
|
3276
|
+
import { z as z2 } from "zod";
|
|
3277
|
+
import { parseToolchainFile } from "@aaac/toolchain";
|
|
3278
|
+
var execFileAsync = promisify(execFile);
|
|
3279
|
+
var SUBPROCESS_TIMEOUT_MS = 3e4;
|
|
3280
|
+
var MANIFEST_FILENAME = ".toolchain-manifest.json";
|
|
3281
|
+
var ToolchainManifestSchema = z2.object({
|
|
3282
|
+
schema: z2.string(),
|
|
3283
|
+
toolchain_id: z2.string(),
|
|
3284
|
+
generated_at: z2.string(),
|
|
3285
|
+
source_hash: z2.string(),
|
|
3286
|
+
output_hash: z2.string(),
|
|
3287
|
+
source_globs: z2.array(z2.string()).optional(),
|
|
3288
|
+
output_globs: z2.array(z2.string()).optional(),
|
|
3289
|
+
files: z2.array(
|
|
3290
|
+
z2.object({
|
|
3291
|
+
path: z2.string(),
|
|
3292
|
+
hash: z2.string()
|
|
3293
|
+
})
|
|
3294
|
+
).optional()
|
|
3295
|
+
});
|
|
3296
|
+
function resolveAction(checkType, checkTypeActions, defaultAction) {
|
|
3297
|
+
if (checkTypeActions?.[checkType]) return checkTypeActions[checkType];
|
|
3298
|
+
if (checkTypeActions?.["_default"]) return checkTypeActions["_default"];
|
|
3299
|
+
return defaultAction ?? "warn";
|
|
3300
|
+
}
|
|
3301
|
+
async function tryManifestFastPath(toolchainId, cwd) {
|
|
3302
|
+
const manifestPath = resolve4(cwd, MANIFEST_FILENAME);
|
|
3303
|
+
if (!existsSync3(manifestPath)) return null;
|
|
3304
|
+
try {
|
|
3305
|
+
const raw = await readFile7(manifestPath, "utf-8");
|
|
3306
|
+
const parsed = ToolchainManifestSchema.parse(JSON.parse(raw));
|
|
3307
|
+
if (parsed.toolchain_id !== toolchainId) return null;
|
|
3308
|
+
return {
|
|
3309
|
+
toolchainId,
|
|
3310
|
+
checkType: "drift",
|
|
3311
|
+
status: "pass",
|
|
3312
|
+
action: "warn",
|
|
3313
|
+
message: `Manifest fast path: ${MANIFEST_FILENAME} found, toolchain_id matches`,
|
|
3314
|
+
durationMs: 0
|
|
3315
|
+
};
|
|
3316
|
+
} catch {
|
|
3317
|
+
return null;
|
|
3318
|
+
}
|
|
3319
|
+
}
|
|
3320
|
+
async function executeCheck(command, cwd) {
|
|
3321
|
+
try {
|
|
3322
|
+
const { stdout, stderr } = await execFileAsync("sh", ["-c", command], {
|
|
3323
|
+
cwd,
|
|
3324
|
+
timeout: SUBPROCESS_TIMEOUT_MS
|
|
3325
|
+
});
|
|
3326
|
+
return { exitCode: 0, stdout, stderr };
|
|
3327
|
+
} catch (err) {
|
|
3328
|
+
const execErr = err;
|
|
3329
|
+
if (execErr.killed) {
|
|
3330
|
+
throw new Error(`Command timed out after ${SUBPROCESS_TIMEOUT_MS}ms: ${command}`);
|
|
3331
|
+
}
|
|
3332
|
+
const exitCode = typeof execErr.code === "number" ? execErr.code : 1;
|
|
3333
|
+
return {
|
|
3334
|
+
exitCode,
|
|
3335
|
+
stdout: execErr.stdout ?? "",
|
|
3336
|
+
stderr: execErr.stderr ?? ""
|
|
3337
|
+
};
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
async function runToolchainChecks(options) {
|
|
3341
|
+
const {
|
|
3342
|
+
toolchainsPath,
|
|
3343
|
+
cwd: workingDir,
|
|
3344
|
+
checkTypes,
|
|
3345
|
+
toolchainFilter,
|
|
3346
|
+
checkTypeActions,
|
|
3347
|
+
defaultAction
|
|
3348
|
+
} = options;
|
|
3349
|
+
const cwd = workingDir ?? process.cwd();
|
|
3350
|
+
const contracts = await parseToolchainFile(toolchainsPath);
|
|
3351
|
+
const results = [];
|
|
3352
|
+
for (const [toolchainId, toolchain] of Object.entries(contracts.toolchains)) {
|
|
3353
|
+
if (!toolchain.checks) continue;
|
|
3354
|
+
if (toolchainFilter && !toolchainFilter.includes(toolchainId)) continue;
|
|
3355
|
+
for (const [checkType, command] of Object.entries(toolchain.checks)) {
|
|
3356
|
+
if (checkTypes && !checkTypes.includes(checkType)) continue;
|
|
3357
|
+
const action = resolveAction(checkType, checkTypeActions, defaultAction);
|
|
3358
|
+
const start = performance.now();
|
|
3359
|
+
if (checkType === "drift" && options.artifactsPath) {
|
|
3360
|
+
const fastResult = await tryManifestFastPath(toolchainId, cwd);
|
|
3361
|
+
if (fastResult) {
|
|
3362
|
+
fastResult.action = action;
|
|
3363
|
+
results.push(fastResult);
|
|
3364
|
+
continue;
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
try {
|
|
3368
|
+
const { exitCode, stderr } = await executeCheck(command, cwd);
|
|
3369
|
+
const durationMs = Math.round(performance.now() - start);
|
|
3370
|
+
results.push({
|
|
3371
|
+
toolchainId,
|
|
3372
|
+
checkType,
|
|
3373
|
+
status: exitCode === 0 ? "pass" : "fail",
|
|
3374
|
+
action,
|
|
3375
|
+
message: exitCode === 0 ? void 0 : stderr.trim() || `exit code ${exitCode}`,
|
|
3376
|
+
durationMs
|
|
3377
|
+
});
|
|
3378
|
+
} catch (err) {
|
|
3379
|
+
const durationMs = Math.round(performance.now() - start);
|
|
3380
|
+
results.push({
|
|
3381
|
+
toolchainId,
|
|
3382
|
+
checkType,
|
|
3383
|
+
status: "error",
|
|
3384
|
+
action,
|
|
3385
|
+
message: err.message,
|
|
3386
|
+
durationMs
|
|
3387
|
+
});
|
|
3388
|
+
}
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
return results;
|
|
3392
|
+
}
|
|
3393
|
+
|
|
3270
3394
|
// src/index.ts
|
|
3271
3395
|
var require2 = createRequire(import.meta.url);
|
|
3272
3396
|
var pkg = require2("../package.json");
|
|
@@ -3279,6 +3403,7 @@ export {
|
|
|
3279
3403
|
InMemoryStore,
|
|
3280
3404
|
PROJECT_CONFIG_FILENAME,
|
|
3281
3405
|
PluginRegistry,
|
|
3406
|
+
ToolchainManifestSchema,
|
|
3282
3407
|
WorkflowBuilder,
|
|
3283
3408
|
buildCandidateAgents,
|
|
3284
3409
|
buildGateEvaluationPrompt,
|
|
@@ -3343,6 +3468,7 @@ export {
|
|
|
3343
3468
|
renderAgentSystemPrompt,
|
|
3344
3469
|
resolveArtifacts,
|
|
3345
3470
|
runTask,
|
|
3471
|
+
runToolchainChecks,
|
|
3346
3472
|
runWorkflow,
|
|
3347
3473
|
version,
|
|
3348
3474
|
zodSchemaToPromptDescription,
|