@aaac/runtime 0.1.13 → 0.1.14
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/mock.d.ts +1 -1
- package/dist/adapters/openai-agents-sdk.d.ts +1 -1
- package/dist/index.d.ts +97 -3
- package/dist/index.js +155 -0
- package/dist/index.js.map +1 -1
- package/dist/{task-runner-3MPh_dn7.d.ts → task-runner-BPk-PcZA.d.ts} +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-
|
|
1
|
+
import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-BPk-PcZA.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import '../context-DKkamYX_.js';
|
|
4
4
|
import '@aaac/observability';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-
|
|
1
|
+
import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-BPk-PcZA.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import '../context-DKkamYX_.js';
|
|
4
4
|
import '@aaac/observability';
|
package/dist/adapters/mock.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SdkAdapter, A as AdapterSendOptions, M as MemoryRef } from '../task-runner-
|
|
1
|
+
import { S as SdkAdapter, A as AdapterSendOptions, M as MemoryRef } from '../task-runner-BPk-PcZA.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import '../context-DKkamYX_.js';
|
|
4
4
|
import '@aaac/observability';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-
|
|
1
|
+
import { S as SdkAdapter, G as GuardrailHooks, C as CacheConfig, A as AdapterSendOptions, a as AgentExecutionRequest, M as MemoryRef } from '../task-runner-BPk-PcZA.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import '../context-DKkamYX_.js';
|
|
4
4
|
import '@aaac/observability';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as ObserverEmitFn, T as TaskContext, b as TaskOutcome, c as AgentContractLike, d as TaskContractLike, P as PromptBuilderOptions, W as WorkflowResult, S as SdkAdapter, e as WorkflowRegistries, H as HandoffInput, f as StepCompleteEvent, g as StepResult, D as DelegateStep, h as GuardrailRuleData, i as MemoryStore, M as MemoryRef, L as LibraryToolRegistry, G as GuardrailHooks, R as ResolvedComponent, j as ArtifactBindingConfig, k as TaskRunResult, l as ResolvedToolchain, m as LibraryToolDefinition } from './task-runner-
|
|
2
|
-
export {
|
|
1
|
+
import { O as ObserverEmitFn, T as TaskContext, b as TaskOutcome, c as AgentContractLike, d as TaskContractLike, P as PromptBuilderOptions, W as WorkflowResult, S as SdkAdapter, e as WorkflowRegistries, H as HandoffInput, f as StepCompleteEvent, g as StepResult, D as DelegateStep, h as GuardrailRuleData, i as MemoryStore, M as MemoryRef, L as LibraryToolRegistry, G as GuardrailHooks, R as ResolvedComponent, j as ArtifactBindingConfig, k as TaskRunResult, l as ResolvedToolchain, m as LibraryToolDefinition, n as HookResponse, o as GuardrailCheckResult } from './task-runner-BPk-PcZA.js';
|
|
2
|
+
export { p as AdapterOrFactory, A as AdapterSendOptions, a as AgentExecutionRequest, q as AgentProgressEvent, B as BoundResolveOptions, r as BoundResolver, C as CacheConfig, s as CandidateAgent, t as ConvergenceEnvelope, u as ConvergenceEnvelopePayload, E as EnvelopeParams, v as EvaluateStep, w as GateStep, x as GuardrailCheckFunctions, y as GuardrailRule, z as HookContext, I as InMemoryStore, F as ModelAwareSdkAdapterFactory, J as ModelClass, K as ModelMappingConfig, N as ModelResolver, Q as ModelResolverOptions, U as ReceiveSpec, V as ResolvedModel, X as RetryDecision, Y as SdkAdapterFactory, Z as SplitPrompt, _ as TaskRunOptions, $ as WorkflowContractLike, a0 as WorkflowInvocation, a1 as WorkflowRunOptions, a2 as WorkflowStep, a3 as buildCandidateAgents, a4 as buildGateEvaluationPrompt, a5 as buildPerAgentGuardrails, a6 as buildRetryFollowUp, a7 as buildSplitTaskPrompt, a8 as buildTaskPrompt, a9 as createExecutionEnvelope, aa as createGuardrailHooks, ab as createGuardrailHooksForAgent, ac as createGuardrailHooksFromRules, ad as createLibraryToolRegistry, ae as createModelResolver, af as deriveToolchainsForAgents, ag as emitSessionClose, ah as emitSessionOpen, ai as emitSubagentClose, aj as emitSubagentOpen, ak as emitToolchainClose, al as emitToolchainOpen, am as extractStructuredResult, an as getBlockingViolations, ao as getEffectiveGuardrailIds, ap as getGuardrailRulesForAgent, aq as getWarnings, ar as guardrailContextToRuleData, as as hasBlockingViolation, at as parseGateEvaluationResponse, au as renderAgentSystemPrompt, av as runTask, aw as runWorkflow, ax as zodSchemaToPromptDescription, ay as zodSchemaToYamlExample } from './task-runner-BPk-PcZA.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { OperationIR, ComponentIR } from '@aaac/contracts';
|
|
5
5
|
import { ResolvedConfig } from './generator/index.js';
|
|
@@ -651,6 +651,100 @@ interface ArtifactResolveResult {
|
|
|
651
651
|
}
|
|
652
652
|
declare function resolveArtifacts(options: ArtifactResolveOptions): Promise<ArtifactResolveResult>;
|
|
653
653
|
|
|
654
|
+
/**
|
|
655
|
+
* Guard CLI commands — evaluate/list/status for guardrail enforcement.
|
|
656
|
+
*
|
|
657
|
+
* These functions back the `guard evaluate`, `guard list`, and `guard status`
|
|
658
|
+
* sub-commands that are auto-injected by @aaac/contracts cli-generator
|
|
659
|
+
* whenever `governance.guardrails: true` is declared in component.yaml.
|
|
660
|
+
*
|
|
661
|
+
* exit code contract (evaluate):
|
|
662
|
+
* 0 = allowed / pass / warn
|
|
663
|
+
* 2 = denied (permission === "deny")
|
|
664
|
+
*/
|
|
665
|
+
|
|
666
|
+
interface EvaluateGuardrailOptions {
|
|
667
|
+
/** Raw JSON string read from stdin (HookContext format). */
|
|
668
|
+
hookJson: string;
|
|
669
|
+
/** Component agent-contracts DSL (contains guardrails + guardrail_policies). */
|
|
670
|
+
dsl: Record<string, unknown>;
|
|
671
|
+
/** Paths to software binding YAML files (contain guardrail_impl matchers). */
|
|
672
|
+
bindingPaths: string[];
|
|
673
|
+
/** Active guardrail policy name (from project.yaml active_guardrail_policy). */
|
|
674
|
+
activeGuardrailPolicy?: string;
|
|
675
|
+
}
|
|
676
|
+
interface EvaluateGuardrailResult {
|
|
677
|
+
/** HookResponse to write to stdout. */
|
|
678
|
+
response: HookResponse;
|
|
679
|
+
/**
|
|
680
|
+
* CLI exit code.
|
|
681
|
+
* 0 = allowed (pass or warn)
|
|
682
|
+
* 2 = denied (permission === "deny")
|
|
683
|
+
*/
|
|
684
|
+
exitCode: 0 | 2;
|
|
685
|
+
/** All check results from all matchers. */
|
|
686
|
+
checks: GuardrailCheckResult[];
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Evaluate a guardrail hook from a JSON string (typically stdin).
|
|
690
|
+
*
|
|
691
|
+
* Detects the hook type from which fields are present in the input:
|
|
692
|
+
* - `command` → beforeShellExecution
|
|
693
|
+
* - `tool_name` / `tool_input` → preToolUse
|
|
694
|
+
* - `file_path` (without command) → afterFileEdit
|
|
695
|
+
*/
|
|
696
|
+
declare function evaluateGuardrail(opts: EvaluateGuardrailOptions): Promise<EvaluateGuardrailResult>;
|
|
697
|
+
interface ListGuardrailsOptions {
|
|
698
|
+
/** Component agent-contracts DSL. */
|
|
699
|
+
dsl: Record<string, unknown>;
|
|
700
|
+
/** Paths to software binding YAML files. */
|
|
701
|
+
bindingPaths: string[];
|
|
702
|
+
/** Active guardrail policy name. */
|
|
703
|
+
activeGuardrailPolicy?: string;
|
|
704
|
+
}
|
|
705
|
+
interface GuardrailListEntry {
|
|
706
|
+
guardrail_id: string;
|
|
707
|
+
description: string;
|
|
708
|
+
matcher_type: string;
|
|
709
|
+
action: string;
|
|
710
|
+
severity: string;
|
|
711
|
+
pattern: string;
|
|
712
|
+
}
|
|
713
|
+
interface ListGuardrailsResult {
|
|
714
|
+
policy: string | undefined;
|
|
715
|
+
entries: GuardrailListEntry[];
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* List all active guardrails and their enforcement settings.
|
|
719
|
+
*
|
|
720
|
+
* Reads DSL + binding files and builds the guardrail context for the active
|
|
721
|
+
* policy, returning a flat list of guardrail_id / matcher_type / action /
|
|
722
|
+
* severity rows for display.
|
|
723
|
+
*/
|
|
724
|
+
declare function listGuardrails(opts: ListGuardrailsOptions): Promise<ListGuardrailsResult>;
|
|
725
|
+
interface GuardStatusOptions {
|
|
726
|
+
/** Base directory for agent logs (defaults to ".agent-logs"). */
|
|
727
|
+
baseDir?: string;
|
|
728
|
+
/** Maximum number of recent run events to return (defaults to 10). */
|
|
729
|
+
limit?: number;
|
|
730
|
+
}
|
|
731
|
+
interface GuardStatusResult {
|
|
732
|
+
hasHistory: boolean;
|
|
733
|
+
message: string;
|
|
734
|
+
/** Recent run log events (operation_start/end, etc.). */
|
|
735
|
+
recentEvents: unknown[];
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Show recent guardrail evaluation summary.
|
|
739
|
+
*
|
|
740
|
+
* Phase 1 limitation: RunLogEvent does not yet include a `guardrail_evaluate`
|
|
741
|
+
* event type, so this command reports general run history from .agent-logs/runs/.
|
|
742
|
+
* Guard-specific event tracking will be added in a future phase.
|
|
743
|
+
*
|
|
744
|
+
* Gracefully returns "no evaluation history" when .agent-logs/ does not exist.
|
|
745
|
+
*/
|
|
746
|
+
declare function guardStatus(opts?: GuardStatusOptions): Promise<GuardStatusResult>;
|
|
747
|
+
|
|
654
748
|
/**
|
|
655
749
|
* @aaac/runtime — public API
|
|
656
750
|
*
|
|
@@ -659,4 +753,4 @@ declare function resolveArtifacts(options: ArtifactResolveOptions): Promise<Arti
|
|
|
659
753
|
/** Package version string. */
|
|
660
754
|
declare const version: string;
|
|
661
755
|
|
|
662
|
-
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 ExecuteOptions, type ExecuteTaskOptions, type ExecuteWorkflowOptions, FileMemoryStore, GuardrailHooks, type GuardrailResult, GuardrailRuleData, HandoffInput, LibraryToolDefinition, LibraryToolRegistry, type LoadDslOptions, MemoryRef, MemoryStore, type MemoryStoreEntry, type NavigationContext, type NavigationContextOptions, ObserverEmitFn, type OperationHandler, type OperationMemoryRefConfig, PROJECT_CONFIG_FILENAME, type PermissionMode, type PluginLoadResult, PluginRegistry, type ProcessEditOptions, type ProcessTaskOptions, type ProcessWorkflowOptions, type ProgressSink, type ProgressSinkOptions, type ProjectRuntime, type PromptBuilderArgs, PromptBuilderOptions, 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, executeTask, executeWorkflow, findProjectConfig, jsonSchemaToZod, loadDslContext, loadPlugins, loadPluginsFromDirectory, loadPluginsFromPaths, pluginRegistry, resolveArtifacts, version };
|
|
756
|
+
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, PROJECT_CONFIG_FILENAME, type PermissionMode, type PluginLoadResult, PluginRegistry, type ProcessEditOptions, type ProcessTaskOptions, type ProcessWorkflowOptions, type ProgressSink, type ProgressSinkOptions, type ProjectRuntime, type PromptBuilderArgs, PromptBuilderOptions, 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, executeTask, executeWorkflow, findProjectConfig, guardStatus, jsonSchemaToZod, listGuardrails, loadDslContext, loadPlugins, loadPluginsFromDirectory, loadPluginsFromPaths, pluginRegistry, resolveArtifacts, version };
|
package/dist/index.js
CHANGED
|
@@ -2906,6 +2906,158 @@ async function resolveArtifacts(options) {
|
|
|
2906
2906
|
};
|
|
2907
2907
|
}
|
|
2908
2908
|
|
|
2909
|
+
// src/lib/guard-commands.ts
|
|
2910
|
+
import { readFile as readFile6, readdir as readdir3 } from "fs/promises";
|
|
2911
|
+
import YAML4 from "yaml";
|
|
2912
|
+
async function evaluateGuardrail(opts) {
|
|
2913
|
+
let hookInput;
|
|
2914
|
+
try {
|
|
2915
|
+
hookInput = JSON.parse(opts.hookJson);
|
|
2916
|
+
} catch (cause) {
|
|
2917
|
+
throw new Error(
|
|
2918
|
+
`Invalid hook JSON: input must be valid JSON. ${cause.message}`
|
|
2919
|
+
);
|
|
2920
|
+
}
|
|
2921
|
+
let guardrailCtx = {
|
|
2922
|
+
commandChecks: [],
|
|
2923
|
+
fileChecks: [],
|
|
2924
|
+
contentChecks: [],
|
|
2925
|
+
allChecks: [],
|
|
2926
|
+
hasGuardrails: false
|
|
2927
|
+
};
|
|
2928
|
+
for (const bindingPath of opts.bindingPaths) {
|
|
2929
|
+
let raw;
|
|
2930
|
+
try {
|
|
2931
|
+
raw = await readFile6(bindingPath, "utf8");
|
|
2932
|
+
} catch (err) {
|
|
2933
|
+
const code = err.code;
|
|
2934
|
+
if (code === "ENOENT") continue;
|
|
2935
|
+
throw err;
|
|
2936
|
+
}
|
|
2937
|
+
const binding = YAML4.parse(raw);
|
|
2938
|
+
guardrailCtx = buildGuardrailContext(
|
|
2939
|
+
opts.dsl,
|
|
2940
|
+
binding,
|
|
2941
|
+
opts.activeGuardrailPolicy
|
|
2942
|
+
);
|
|
2943
|
+
}
|
|
2944
|
+
const ruleData = guardrailContextToRuleData(guardrailCtx);
|
|
2945
|
+
const hooks = createGuardrailHooksFromRules(ruleData);
|
|
2946
|
+
const command = hookInput.command;
|
|
2947
|
+
const toolName = hookInput.tool_name;
|
|
2948
|
+
const toolInput = hookInput.tool_input;
|
|
2949
|
+
const filePath = hookInput.file_path;
|
|
2950
|
+
const content = hookInput.content;
|
|
2951
|
+
let response = {};
|
|
2952
|
+
let checks = [];
|
|
2953
|
+
if (command !== void 0) {
|
|
2954
|
+
response = hooks.beforeShellExecution({ command });
|
|
2955
|
+
checks = hooks.runChecks({ command });
|
|
2956
|
+
} else if (toolName !== void 0 || toolInput !== void 0) {
|
|
2957
|
+
response = hooks.preToolUse({ tool_name: toolName, tool_input: toolInput });
|
|
2958
|
+
const checkFilePath = toolInput?.file_path ?? toolInput?.path ?? "";
|
|
2959
|
+
if (checkFilePath) {
|
|
2960
|
+
checks = hooks.runChecks({ filePath: checkFilePath });
|
|
2961
|
+
}
|
|
2962
|
+
} else if (filePath !== void 0) {
|
|
2963
|
+
response = hooks.afterFileEdit({ file_path: filePath, content });
|
|
2964
|
+
checks = hooks.runChecks({ filePath, content });
|
|
2965
|
+
}
|
|
2966
|
+
const exitCode = response.permission === "deny" ? 2 : 0;
|
|
2967
|
+
return { response, exitCode, checks };
|
|
2968
|
+
}
|
|
2969
|
+
async function listGuardrails(opts) {
|
|
2970
|
+
let guardrailCtx = {
|
|
2971
|
+
commandChecks: [],
|
|
2972
|
+
fileChecks: [],
|
|
2973
|
+
contentChecks: [],
|
|
2974
|
+
allChecks: [],
|
|
2975
|
+
hasGuardrails: false
|
|
2976
|
+
};
|
|
2977
|
+
for (const bindingPath of opts.bindingPaths) {
|
|
2978
|
+
let raw;
|
|
2979
|
+
try {
|
|
2980
|
+
raw = await readFile6(bindingPath, "utf8");
|
|
2981
|
+
} catch (err) {
|
|
2982
|
+
const code = err.code;
|
|
2983
|
+
if (code === "ENOENT") continue;
|
|
2984
|
+
throw err;
|
|
2985
|
+
}
|
|
2986
|
+
const binding = YAML4.parse(raw);
|
|
2987
|
+
guardrailCtx = buildGuardrailContext(
|
|
2988
|
+
opts.dsl,
|
|
2989
|
+
binding,
|
|
2990
|
+
opts.activeGuardrailPolicy
|
|
2991
|
+
);
|
|
2992
|
+
}
|
|
2993
|
+
const entries = guardrailCtx.allChecks.map(
|
|
2994
|
+
(c) => ({
|
|
2995
|
+
guardrail_id: c.guardrail_id,
|
|
2996
|
+
description: c.description,
|
|
2997
|
+
matcher_type: c.matcher_type,
|
|
2998
|
+
action: c.action,
|
|
2999
|
+
severity: c.severity,
|
|
3000
|
+
pattern: c.pattern
|
|
3001
|
+
})
|
|
3002
|
+
);
|
|
3003
|
+
return {
|
|
3004
|
+
policy: opts.activeGuardrailPolicy,
|
|
3005
|
+
entries
|
|
3006
|
+
};
|
|
3007
|
+
}
|
|
3008
|
+
async function guardStatus(opts = {}) {
|
|
3009
|
+
const baseDir = opts.baseDir ?? ".agent-logs";
|
|
3010
|
+
const runsDir = `${baseDir}/runs`;
|
|
3011
|
+
const limit = opts.limit ?? 10;
|
|
3012
|
+
let files = [];
|
|
3013
|
+
try {
|
|
3014
|
+
files = await readdir3(runsDir);
|
|
3015
|
+
} catch (err) {
|
|
3016
|
+
const code = err.code;
|
|
3017
|
+
if (code === "ENOENT") {
|
|
3018
|
+
return {
|
|
3019
|
+
hasHistory: false,
|
|
3020
|
+
message: "No evaluation history. Note: guardrail_evaluate event type is not yet tracked in Phase 1.",
|
|
3021
|
+
recentEvents: []
|
|
3022
|
+
};
|
|
3023
|
+
}
|
|
3024
|
+
throw err;
|
|
3025
|
+
}
|
|
3026
|
+
const jsonlFiles = files.filter((f) => f.endsWith(".jsonl")).sort().reverse().slice(0, limit);
|
|
3027
|
+
if (jsonlFiles.length === 0) {
|
|
3028
|
+
return {
|
|
3029
|
+
hasHistory: false,
|
|
3030
|
+
message: "No evaluation history.",
|
|
3031
|
+
recentEvents: []
|
|
3032
|
+
};
|
|
3033
|
+
}
|
|
3034
|
+
const recentEvents = [];
|
|
3035
|
+
for (const file of jsonlFiles) {
|
|
3036
|
+
const filePath = `${runsDir}/${file}`;
|
|
3037
|
+
let raw;
|
|
3038
|
+
try {
|
|
3039
|
+
raw = await readFile6(filePath, "utf8");
|
|
3040
|
+
} catch {
|
|
3041
|
+
continue;
|
|
3042
|
+
}
|
|
3043
|
+
const events = raw.split("\n").filter((line) => line.trim().length > 0).map((line) => {
|
|
3044
|
+
try {
|
|
3045
|
+
return JSON.parse(line);
|
|
3046
|
+
} catch {
|
|
3047
|
+
return null;
|
|
3048
|
+
}
|
|
3049
|
+
}).filter(Boolean);
|
|
3050
|
+
recentEvents.push(...events);
|
|
3051
|
+
if (recentEvents.length >= limit) break;
|
|
3052
|
+
}
|
|
3053
|
+
const count = recentEvents.length;
|
|
3054
|
+
return {
|
|
3055
|
+
hasHistory: count > 0,
|
|
3056
|
+
message: count > 0 ? `${count} recent run event(s) found. Note: guardrail_evaluate events are not yet tracked in Phase 1.` : "No evaluation history.",
|
|
3057
|
+
recentEvents: recentEvents.slice(0, limit)
|
|
3058
|
+
};
|
|
3059
|
+
}
|
|
3060
|
+
|
|
2909
3061
|
// src/index.ts
|
|
2910
3062
|
var require2 = createRequire(import.meta.url);
|
|
2911
3063
|
var pkg = require2("../package.json");
|
|
@@ -2953,6 +3105,7 @@ export {
|
|
|
2953
3105
|
emitSubagentOpen,
|
|
2954
3106
|
emitToolchainClose,
|
|
2955
3107
|
emitToolchainOpen,
|
|
3108
|
+
evaluateGuardrail,
|
|
2956
3109
|
executeTask,
|
|
2957
3110
|
executeWorkflow,
|
|
2958
3111
|
extractStructuredResult,
|
|
@@ -2961,9 +3114,11 @@ export {
|
|
|
2961
3114
|
getEffectiveGuardrailIds,
|
|
2962
3115
|
getGuardrailRulesForAgent,
|
|
2963
3116
|
getWarnings,
|
|
3117
|
+
guardStatus,
|
|
2964
3118
|
guardrailContextToRuleData,
|
|
2965
3119
|
hasBlockingViolation,
|
|
2966
3120
|
jsonSchemaToZod,
|
|
3121
|
+
listGuardrails,
|
|
2967
3122
|
loadDslContext,
|
|
2968
3123
|
loadPlugins,
|
|
2969
3124
|
loadPluginsFromDirectory,
|