@arnilo/prism 0.9.0 → 0.11.0
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/CHANGELOG.md +50 -1
- package/README.md +19 -16
- package/dist/agent-approval.d.ts +7 -1
- package/dist/agent-approval.js +15 -6
- package/dist/agent-run-lifecycle.d.ts +2 -1
- package/dist/agent-run-lifecycle.js +20 -6
- package/dist/agent-run-state.d.ts +26 -5
- package/dist/agent-run-state.js +97 -1
- package/dist/agent-session/event-subscriber.d.ts +2 -0
- package/dist/agent-session/event-subscriber.js +3 -0
- package/dist/agent-session/session/assemble.js +165 -16
- package/dist/agent-session/session/persist.js +11 -5
- package/dist/agent-session/session/provider-round.js +54 -13
- package/dist/agent-session/session/tool-round.d.ts +2 -2
- package/dist/agent-session/session/tool-round.js +86 -23
- package/dist/agent-session/session/types.d.ts +21 -2
- package/dist/agent-session/session.d.ts +66 -4
- package/dist/agent-session/session.js +159 -18
- package/dist/checkpoint-restore.d.ts +50 -14
- package/dist/checkpoint-restore.js +104 -28
- package/dist/context-budget.d.ts +11 -0
- package/dist/context-budget.js +33 -2
- package/dist/contracts-core/agent.d.ts +26 -5
- package/dist/contracts-core/extensions.d.ts +3 -0
- package/dist/contracts-core/guardrail-packs.d.ts +8 -3
- package/dist/contracts-core/loop.d.ts +36 -0
- package/dist/contracts-core/provider.d.ts +6 -1
- package/dist/contracts-core/run-limits.d.ts +10 -1
- package/dist/contracts-core/session.d.ts +2 -1
- package/dist/contracts-protocol.d.ts +6 -4
- package/dist/contracts-run-state.d.ts +48 -6
- package/dist/contributions.d.ts +2 -1
- package/dist/contributions.js +1 -0
- package/dist/extensions.d.ts +15 -1
- package/dist/extensions.js +68 -0
- package/dist/guardrail-packs/types.d.ts +10 -0
- package/dist/guardrail-packs/validation-respect.js +16 -0
- package/dist/guardrails.d.ts +42 -1
- package/dist/guardrails.js +124 -15
- package/dist/index.d.ts +7 -7
- package/dist/index.js +4 -4
- package/dist/leases.js +32 -6
- package/dist/middleware.d.ts +1 -1
- package/dist/node/contribution-discovery.d.ts +16 -1
- package/dist/node/contribution-discovery.js +47 -0
- package/dist/node/session-store-jsonl.js +67 -17
- package/dist/run-bundle.d.ts +6 -1
- package/dist/run-bundle.js +4 -1
- package/dist/run-limits.d.ts +11 -5
- package/dist/run-limits.js +13 -0
- package/dist/session-stores.js +61 -12
- package/dist/testing/prefix-stability-conformance.d.ts +73 -1
- package/dist/testing/prefix-stability-conformance.js +158 -27
- package/dist/tools.js +10 -3
- package/dist/usage-estimation.d.ts +7 -1
- package/dist/usage-estimation.js +16 -10
- package/docs/acp.md +2 -2
- package/docs/agent-events.md +15 -10
- package/docs/agent-session-runtime.md +10 -7
- package/docs/coding-agent-tools.md +1 -1
- package/docs/coding-tools.md +7 -11
- package/docs/compaction-llm.md +2 -0
- package/docs/compaction-observational-memory.md +21 -1
- package/docs/context-and-skills.md +6 -7
- package/docs/contribution-discovery.md +13 -0
- package/docs/durable-runs.md +14 -6
- package/docs/embeddings.md +7 -1
- package/docs/execution-timeline.md +9 -2
- package/docs/extensions.md +21 -5
- package/docs/guardrails.md +16 -6
- package/docs/hooks.md +282 -0
- package/docs/impeccable.md +1 -2
- package/docs/index.md +28 -21
- package/docs/input-and-prompt-assembly.md +1 -1
- package/docs/instruction-injection.md +1 -0
- package/docs/live-testing.md +3 -2
- package/docs/memory-fabric.md +29 -0
- package/docs/middleware-hooks.md +54 -4
- package/docs/migrate-to-0.11.md +65 -0
- package/docs/migration.md +24 -0
- package/docs/node-jsonl-session-store.md +4 -3
- package/docs/operations.md +1 -1
- package/docs/options-index.md +3 -1
- package/docs/peer-dependencies.md +3 -5
- package/docs/policy-and-audit.md +15 -2
- package/docs/prefix-stability-conformance.md +82 -9
- package/docs/provider-packages.md +20 -20
- package/docs/public-contracts.md +2 -1
- package/docs/rag.md +94 -7
- package/docs/release-and-install.md +62 -59
- package/docs/runs-and-usage.md +21 -10
- package/docs/scoped-agent-memory.md +17 -9
- package/docs/scoped-memory.md +138 -0
- package/docs/session-stores.md +2 -2
- package/docs/supervisors.md +14 -6
- package/docs/testing.md +17 -9
- package/docs/tools.md +1 -1
- package/docs/wiki.md +4 -2
- package/docs/workflows.md +2 -2
- package/package.json +8 -5
- package/docs/caveman.md +0 -130
- package/docs/graft.md +0 -149
- package/docs/ponytail.md +0 -129
package/dist/extensions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CommandDefinition, ContextProvider, Extension, ExtensionEvent, ExtensionLifecycleEventName, InstructionInjector, Skill, ToolDefinition } from "./contracts.js";
|
|
1
|
+
import type { AgentEvent, CommandDefinition, ContextProvider, Extension, ExtensionEvent, ExtensionLifecycleEventName, InstructionInjector, Skill, StopHook, ToolDefinition } from "./contracts.js";
|
|
2
2
|
import { type ContributionRegistries } from "./contributions.js";
|
|
3
3
|
import { type MiddlewareRegistry } from "./middleware.js";
|
|
4
4
|
import { type PermissionPolicy } from "./security.js";
|
|
@@ -40,6 +40,18 @@ export interface ExtensionKernel {
|
|
|
40
40
|
}
|
|
41
41
|
export declare function createExtensionEventBus(options?: Pick<ExtensionKernelOptions, "errorPolicy" | "secrets">): ExtensionEventBus;
|
|
42
42
|
export declare function createExtensionKernel(options?: ExtensionKernelOptions): ExtensionKernel;
|
|
43
|
+
export interface AgentEventBridgeOptions {
|
|
44
|
+
/** Bridge-side failure (a source error, or a bus listener that throws under `errorPolicy: "throw"`).
|
|
45
|
+
* Never rethrown — the bridge must not fail the run it is observing. */
|
|
46
|
+
readonly onError?: (error: unknown) => void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Forward an `AgentEvent` iterable onto the extension bus, one mapped lifecycle event at a time
|
|
50
|
+
* (plan 106 R2). Handlers run in event order and never in the run's path, so a slow or throwing
|
|
51
|
+
* listener cannot stall or fail the observed run. Returns an unsubscribe that stops forwarding and
|
|
52
|
+
* releases the source iterator.
|
|
53
|
+
*/
|
|
54
|
+
export declare function forwardAgentEvents(source: AsyncIterable<AgentEvent>, events: Pick<ExtensionEventBus, "emit">, options?: AgentEventBridgeOptions): () => void;
|
|
43
55
|
/** Host-owned activation: copy contributed entries into the `createAgent()`
|
|
44
56
|
* fields that accept plain arrays. Contributions stay inert until the host
|
|
45
57
|
* passes the returned fields into runtime config. Array slots only —
|
|
@@ -51,6 +63,8 @@ export interface ActivatedKernelConfig {
|
|
|
51
63
|
readonly skills: readonly Skill[];
|
|
52
64
|
readonly instructionInjectors: readonly InstructionInjector[];
|
|
53
65
|
readonly context: readonly ContextProvider[];
|
|
66
|
+
/** Run-end stop hooks (plan 106 R1); pass to `createAgent({ stopHooks })`. */
|
|
67
|
+
readonly stopHooks: readonly StopHook[];
|
|
54
68
|
/** For host command surfaces (CLI/RPC/UI); not part of `AgentConfig`. */
|
|
55
69
|
readonly commands: readonly CommandDefinition[];
|
|
56
70
|
/** The kernel middleware registry itself; runs only when passed to runtime config. */
|
package/dist/extensions.js
CHANGED
|
@@ -143,6 +143,10 @@ export function createExtensionKernel(options = {}) {
|
|
|
143
143
|
registries.instructionInjectors.register(injector.name, injector);
|
|
144
144
|
track?.(() => registries.instructionInjectors.unregister(injector.name));
|
|
145
145
|
},
|
|
146
|
+
registerStopHook(hook) {
|
|
147
|
+
registries.stopHooks.register(hook.name, hook);
|
|
148
|
+
track?.(() => registries.stopHooks.unregister(hook.name));
|
|
149
|
+
},
|
|
146
150
|
});
|
|
147
151
|
const unwind = (undo) => {
|
|
148
152
|
for (const fn of undo.reverse()) {
|
|
@@ -190,12 +194,76 @@ export function createExtensionKernel(options = {}) {
|
|
|
190
194
|
},
|
|
191
195
|
};
|
|
192
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Lifecycle hook each forwarded `AgentEvent` maps onto (plan 106 R2). Notification only: the bus
|
|
199
|
+
* receives the original event as `payload` and nothing is transformed. Events not listed here are
|
|
200
|
+
* ignored — notably `agent_finished` stays an AgentEvent and is not re-emitted as a bus event.
|
|
201
|
+
*/
|
|
202
|
+
const AGENT_EVENT_BRIDGE = {
|
|
203
|
+
agent_started: "before_agent_start",
|
|
204
|
+
turn_started: "turn",
|
|
205
|
+
turn_finished: "turn",
|
|
206
|
+
tool_execution_started: "tool_call",
|
|
207
|
+
tool_execution_finished: "tool_result",
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Forward an `AgentEvent` iterable onto the extension bus, one mapped lifecycle event at a time
|
|
211
|
+
* (plan 106 R2). Handlers run in event order and never in the run's path, so a slow or throwing
|
|
212
|
+
* listener cannot stall or fail the observed run. Returns an unsubscribe that stops forwarding and
|
|
213
|
+
* releases the source iterator.
|
|
214
|
+
*/
|
|
215
|
+
export function forwardAgentEvents(source, events, options = {}) {
|
|
216
|
+
const iterator = source[Symbol.asyncIterator]();
|
|
217
|
+
const report = (error) => {
|
|
218
|
+
try {
|
|
219
|
+
options.onError?.(error);
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
// A throwing error callback must not become an unhandled rejection.
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
let stopped = false;
|
|
226
|
+
// Serially chained so a listener that awaits keeps event order; the run never awaits this chain.
|
|
227
|
+
let pending = Promise.resolve();
|
|
228
|
+
void (async () => {
|
|
229
|
+
try {
|
|
230
|
+
while (!stopped) {
|
|
231
|
+
const { value, done } = await iterator.next();
|
|
232
|
+
if (done || stopped)
|
|
233
|
+
return;
|
|
234
|
+
const type = AGENT_EVENT_BRIDGE[value.type];
|
|
235
|
+
if (type === undefined)
|
|
236
|
+
continue;
|
|
237
|
+
const event = { type, payload: value };
|
|
238
|
+
pending = pending.then(() => events.emit(event)).catch(report);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
if (!stopped)
|
|
243
|
+
report(error);
|
|
244
|
+
}
|
|
245
|
+
})();
|
|
246
|
+
return () => {
|
|
247
|
+
if (stopped)
|
|
248
|
+
return;
|
|
249
|
+
stopped = true;
|
|
250
|
+
void (async () => {
|
|
251
|
+
try {
|
|
252
|
+
await iterator.return?.();
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
report(error);
|
|
256
|
+
}
|
|
257
|
+
})();
|
|
258
|
+
};
|
|
259
|
+
}
|
|
193
260
|
export function activateKernel(kernel) {
|
|
194
261
|
return {
|
|
195
262
|
tools: kernel.registries.tools.list(),
|
|
196
263
|
skills: kernel.registries.skills.list(),
|
|
197
264
|
instructionInjectors: kernel.registries.instructionInjectors.list(),
|
|
198
265
|
context: kernel.registries.contextProviders.list(),
|
|
266
|
+
stopHooks: kernel.registries.stopHooks.list(),
|
|
199
267
|
commands: kernel.registries.commands.list(),
|
|
200
268
|
middleware: kernel.middleware,
|
|
201
269
|
};
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
/** Internal guardrail-pack definition types (plan 092 Task 2). Not SDK surface; hosts configure packs via `AgentSessionConfig.guardrailPacks`. */
|
|
2
2
|
import type { GuardrailRule, GuardrailRuleContext } from "../contracts-core/guardrail-packs.js";
|
|
3
3
|
import type { ToolResult } from "../contracts-protocol.js";
|
|
4
|
+
/** Plan 104 Task 2: pack-owned durable-state codec. The pack decides what a checkpoint carries. */
|
|
5
|
+
interface GuardrailPackStateCodec {
|
|
6
|
+
/** Serialize the live state for a checkpoint; `undefined` when nothing needs persisting. */
|
|
7
|
+
readonly snapshot: (state: Record<string, unknown>) => Readonly<Record<string, unknown>> | undefined;
|
|
8
|
+
/** Parse a persisted snapshot back into state fields; throw `GuardrailPackError` on a malformed value. */
|
|
9
|
+
readonly parse: (json: unknown) => Record<string, unknown>;
|
|
10
|
+
}
|
|
4
11
|
/** What a pack's `build` returns: restrictive rules plus an optional pure result observer. */
|
|
5
12
|
export interface GuardrailPackRules {
|
|
6
13
|
readonly rules: readonly GuardrailRule[];
|
|
7
14
|
/** Records tool results into pack-local state (never denies); a throw fails closed as a guardrail tripwire. */
|
|
8
15
|
readonly observe?: (state: Record<string, unknown>, result: ToolResult, context: GuardrailRuleContext) => void;
|
|
16
|
+
/** Optional codec making the pack's state survive a durable resume; a pack without one persists nothing. */
|
|
17
|
+
readonly state?: GuardrailPackStateCodec;
|
|
9
18
|
}
|
|
10
19
|
export interface GuardrailPackDefinition {
|
|
11
20
|
readonly id: string;
|
|
@@ -14,3 +23,4 @@ export interface GuardrailPackDefinition {
|
|
|
14
23
|
/** Pure factory: options in, rules out. No session access, no I/O. */
|
|
15
24
|
readonly build: (options: Readonly<Record<string, unknown>>) => GuardrailPackRules;
|
|
16
25
|
}
|
|
26
|
+
export {};
|
|
@@ -3,6 +3,7 @@ const MUTATING_TOOLS = ["write", "edit", "delete", "move"];
|
|
|
3
3
|
/** Validation-style tool names. `shell` is opt-in (`validationTools`): a non-zero shell exit is a failure signal too. */
|
|
4
4
|
const DEFAULT_VALIDATION_TOOLS = ["test", "run_tests", "validate", "validation", "lint", "typecheck", "check"];
|
|
5
5
|
const MAX_VALIDATION_TOOLS = 16;
|
|
6
|
+
const MAX_VALIDATION_TOOL_CHARS = 128;
|
|
6
7
|
/** A tool result failed when it carries an error, or reported a non-zero `exitCode` (the shell tool's shape). */
|
|
7
8
|
function resultFailed(result) {
|
|
8
9
|
if (result.error !== undefined)
|
|
@@ -39,6 +40,21 @@ export const validationRespectPack = {
|
|
|
39
40
|
return;
|
|
40
41
|
state.validationFailed = resultFailed(result) ? context.toolName : undefined;
|
|
41
42
|
},
|
|
43
|
+
// Plan 104 Task 2: one tool name (or nothing) survives a resume, so a mutation the suspended
|
|
44
|
+
// run denied stays denied. The codec is the pack's own bound: 128 chars, never arguments.
|
|
45
|
+
state: {
|
|
46
|
+
snapshot: (state) => (typeof state.validationFailed === "string" ? { validationFailed: state.validationFailed } : undefined),
|
|
47
|
+
parse: (json) => {
|
|
48
|
+
const record = typeof json === "object" && json !== null ? json : {};
|
|
49
|
+
const failed = record.validationFailed;
|
|
50
|
+
if (failed === undefined)
|
|
51
|
+
return {};
|
|
52
|
+
if (typeof failed !== "string" || !failed.trim() || failed.length > MAX_VALIDATION_TOOL_CHARS) {
|
|
53
|
+
throw new GuardrailPackError(`validation-respect persisted state.validationFailed must be a non-empty string of at most ${MAX_VALIDATION_TOOL_CHARS} chars`);
|
|
54
|
+
}
|
|
55
|
+
return { validationFailed: failed };
|
|
56
|
+
},
|
|
57
|
+
},
|
|
42
58
|
rules: [
|
|
43
59
|
{
|
|
44
60
|
id: "no-mutation-after-failed-validation",
|
package/dist/guardrails.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import type { AgentEvent, GuardrailContext, GuardrailPackRef, GuardrailRecord, GuardrailStage, Guardrails, GuardrailValue } from "./contracts.js";
|
|
1
|
+
import type { AgentEvent, GuardrailContext, GuardrailPackRef, GuardrailRecord, GuardrailRule, GuardrailStage, Guardrails, GuardrailValue } from "./contracts.js";
|
|
2
2
|
export { GuardrailPackError } from "./guardrail-packs/errors.js";
|
|
3
3
|
import type { SecretRedactor } from "./redaction.js";
|
|
4
4
|
export declare const MAX_GUARDRAIL_CONCURRENCY = 16;
|
|
5
5
|
/** Guardrail pack compile bounds (plan 092 Task 2). All ceilings are config-shape limits, not runtime budgets. */
|
|
6
6
|
export declare const MAX_GUARDRAIL_PACKS = 8;
|
|
7
7
|
export declare const MAX_GUARDRAIL_PACK_RULES = 64;
|
|
8
|
+
/**
|
|
9
|
+
* Plan 104 T4/T6: the bounded, redacted refusal line for a terminal record that came from a compiled
|
|
10
|
+
* pack rule — `<prefix> by guardrail rule pack:<pack>/<rule>`, plus the pack's own reason when it set
|
|
11
|
+
* one — or `undefined` for any other guardrail, so the caller keeps its own neutral text. Only the
|
|
12
|
+
* compiler writes the `pack`/`rule` metadata, so a host-written guardrail named `pack:…` is never
|
|
13
|
+
* presented as a pack rule. Reasons are redacted where the record is built, pack names are
|
|
14
|
+
* compiler-bounded to 128 bytes (the identity always survives the cap), and a long reason is
|
|
15
|
+
* truncated, so the same derivation serves the tool refusal and decision-time revalidation.
|
|
16
|
+
*/
|
|
17
|
+
export declare function guardrailRefusalText(record: GuardrailRecord, prefix?: string): string | undefined;
|
|
8
18
|
export declare class GuardrailError extends Error {
|
|
9
19
|
readonly code: string;
|
|
10
20
|
readonly record: GuardrailRecord;
|
|
@@ -33,6 +43,30 @@ export interface GuardrailPackRow {
|
|
|
33
43
|
readonly stage: "tool_input" | "tool_output";
|
|
34
44
|
readonly revision: string | null;
|
|
35
45
|
}
|
|
46
|
+
/** Plan 104 Task 2: one replayable pack row of a durable checkpoint (`id`, resolved version, host options). */
|
|
47
|
+
interface GuardrailPackRefRow {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
readonly version: number;
|
|
50
|
+
/** Host options the pack was compiled with, replayed verbatim on resume so enforcement is identical. */
|
|
51
|
+
readonly options?: Readonly<Record<string, unknown>>;
|
|
52
|
+
/**
|
|
53
|
+
* Plan 104 T3: the host's own rule list for an inline pack. Patterns are data and ride the
|
|
54
|
+
* checkpoint; a `deny` predicate or a `RegExp` pattern cannot round-trip and is refused at save.
|
|
55
|
+
*/
|
|
56
|
+
readonly rules?: readonly GuardrailRule[];
|
|
57
|
+
}
|
|
58
|
+
/** Plan 104 Task 2: a compile result that can round-trip through a durable checkpoint. */
|
|
59
|
+
interface CompiledGuardrailPacks {
|
|
60
|
+
readonly guardrails: Guardrails | undefined;
|
|
61
|
+
/** Rows a durable checkpoint replays; empty when no packs are configured. */
|
|
62
|
+
readonly packs: readonly GuardrailPackRefRow[];
|
|
63
|
+
/** Plan 104 T3: `ask` rules as the charge-time durable gate — a match records `interrupt`. */
|
|
64
|
+
readonly askGate?: Guardrails;
|
|
65
|
+
/** Plan 104 T3: the same rules as plain blocks, merged into a run that cannot suspend. */
|
|
66
|
+
readonly askBlocks?: Guardrails;
|
|
67
|
+
/** Pack-owned state snapshot (`{ <packId>: <pack state> }`); `undefined` when nothing needs persisting. */
|
|
68
|
+
readonly snapshotState: () => Record<string, Readonly<Record<string, unknown>>> | undefined;
|
|
69
|
+
}
|
|
36
70
|
/**
|
|
37
71
|
* Compiles `guardrailPacks` config onto the existing tool interception seams: one `tool_input`
|
|
38
72
|
* guardrail per rule (`name = pack:<pack>/<rule>`), plus one `tool_output` recorder for packs that
|
|
@@ -40,5 +74,12 @@ export interface GuardrailPackRow {
|
|
|
40
74
|
* Throws `GuardrailPackError` on malformed config (fail closed); returns `undefined` when unset.
|
|
41
75
|
*/
|
|
42
76
|
export declare function compileGuardrailPacks(refs: readonly GuardrailPackRef[] | undefined, registry?: ReadonlyMap<string, import("./guardrail-packs/types.js").GuardrailPackDefinition>): Guardrails | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Plan 104 Task 2: the internal compile entry behind `compileGuardrailPacks`. Passing `initial`
|
|
79
|
+
* marks a durable restore — rows must then come from the installed registry, match its version, and
|
|
80
|
+
* parse through the pack's own state codec, so a mismatch fails closed instead of restoring a
|
|
81
|
+
* weaker policy. `snapshotState` is the checkpoint-side counterpart.
|
|
82
|
+
*/
|
|
83
|
+
export declare function compileGuardrailPacksWithState(refs: readonly GuardrailPackRef[] | undefined, registry?: ReadonlyMap<string, import("./guardrail-packs/types.js").GuardrailPackDefinition>, initial?: Readonly<Record<string, unknown>>): CompiledGuardrailPacks;
|
|
43
84
|
/** Stable identity rows for the same config `compileGuardrailPacks` accepts (no state, no guardrails built). */
|
|
44
85
|
export declare function describeGuardrailPacks(refs: readonly GuardrailPackRef[] | undefined, registry?: ReadonlyMap<string, import("./guardrail-packs/types.js").GuardrailPackDefinition>): readonly GuardrailPackRow[];
|
package/dist/guardrails.js
CHANGED
|
@@ -17,6 +17,28 @@ const MAX_ARG_SCAN_STRINGS = 64;
|
|
|
17
17
|
const MAX_ARG_STRING_BYTES = 16 * 1024;
|
|
18
18
|
const MAX_PACK_NAME_BYTES = 128;
|
|
19
19
|
const OBSERVE_RULE_ID = "observe";
|
|
20
|
+
/** Bytes allowed for a rule-naming refusal line, so no rule text can grow a model or host message. */
|
|
21
|
+
const MAX_GUARDRAIL_REFUSAL_BYTES = 200;
|
|
22
|
+
/**
|
|
23
|
+
* Plan 104 T4/T6: the bounded, redacted refusal line for a terminal record that came from a compiled
|
|
24
|
+
* pack rule — `<prefix> by guardrail rule pack:<pack>/<rule>`, plus the pack's own reason when it set
|
|
25
|
+
* one — or `undefined` for any other guardrail, so the caller keeps its own neutral text. Only the
|
|
26
|
+
* compiler writes the `pack`/`rule` metadata, so a host-written guardrail named `pack:…` is never
|
|
27
|
+
* presented as a pack rule. Reasons are redacted where the record is built, pack names are
|
|
28
|
+
* compiler-bounded to 128 bytes (the identity always survives the cap), and a long reason is
|
|
29
|
+
* truncated, so the same derivation serves the tool refusal and decision-time revalidation.
|
|
30
|
+
*/
|
|
31
|
+
export function guardrailRefusalText(record, prefix = "Blocked") {
|
|
32
|
+
const pack = record.metadata?.pack;
|
|
33
|
+
const rule = record.metadata?.rule;
|
|
34
|
+
if (typeof pack !== "string" || typeof rule !== "string")
|
|
35
|
+
return undefined;
|
|
36
|
+
const line = `${prefix} by guardrail rule ${record.guardrail}`;
|
|
37
|
+
// The compiler synthesizes `guardrail pack rule <pack>/<rule>` when the rule set no reason; the
|
|
38
|
+
// identity already implies it, so only a real reason is appended.
|
|
39
|
+
const text = record.reason && record.reason !== `guardrail pack rule ${pack}/${rule}` ? `${line}: ${record.reason}` : line;
|
|
40
|
+
return boundText(text, MAX_GUARDRAIL_REFUSAL_BYTES);
|
|
41
|
+
}
|
|
20
42
|
export class GuardrailError extends Error {
|
|
21
43
|
code;
|
|
22
44
|
record;
|
|
@@ -76,6 +98,7 @@ export function assertGuardrailsAllowed(result) {
|
|
|
76
98
|
if (result.terminal)
|
|
77
99
|
throw new GuardrailError(result.terminal);
|
|
78
100
|
}
|
|
101
|
+
const EMPTY_COMPILED_PACKS = { guardrails: undefined, packs: [], snapshotState: () => undefined };
|
|
79
102
|
/**
|
|
80
103
|
* Compiles `guardrailPacks` config onto the existing tool interception seams: one `tool_input`
|
|
81
104
|
* guardrail per rule (`name = pack:<pack>/<rule>`), plus one `tool_output` recorder for packs that
|
|
@@ -83,19 +106,60 @@ export function assertGuardrailsAllowed(result) {
|
|
|
83
106
|
* Throws `GuardrailPackError` on malformed config (fail closed); returns `undefined` when unset.
|
|
84
107
|
*/
|
|
85
108
|
export function compileGuardrailPacks(refs, registry = BUILT_IN_GUARDRAIL_PACKS) {
|
|
86
|
-
|
|
109
|
+
return compileGuardrailPacksWithState(refs, registry).guardrails;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Plan 104 Task 2: the internal compile entry behind `compileGuardrailPacks`. Passing `initial`
|
|
113
|
+
* marks a durable restore — rows must then come from the installed registry, match its version, and
|
|
114
|
+
* parse through the pack's own state codec, so a mismatch fails closed instead of restoring a
|
|
115
|
+
* weaker policy. `snapshotState` is the checkpoint-side counterpart.
|
|
116
|
+
*/
|
|
117
|
+
export function compileGuardrailPacksWithState(refs, registry = BUILT_IN_GUARDRAIL_PACKS, initial) {
|
|
118
|
+
const packs = resolveGuardrailPacks(refs, registry, initial);
|
|
87
119
|
if (packs.length === 0)
|
|
88
|
-
return
|
|
120
|
+
return EMPTY_COMPILED_PACKS;
|
|
89
121
|
const toolInput = [];
|
|
90
122
|
const toolOutput = [];
|
|
123
|
+
const askGate = [];
|
|
124
|
+
const askBlocks = [];
|
|
91
125
|
for (const pack of packs) {
|
|
92
|
-
const state = {};
|
|
93
126
|
if (pack.observe)
|
|
94
|
-
toolOutput.push(observeGuardrail(pack, pack.observe, state));
|
|
95
|
-
for (const resolved of pack.rules)
|
|
96
|
-
|
|
127
|
+
toolOutput.push(observeGuardrail(pack, pack.observe, pack.state));
|
|
128
|
+
for (const resolved of pack.rules) {
|
|
129
|
+
if (resolved.action === "ask") {
|
|
130
|
+
// Plan 104 T3: `ask` is not an ordinary stage decision. A run that can suspend gates the
|
|
131
|
+
// call at charge time (`interrupt` is the record meaning "awaiting a decision"), while a run
|
|
132
|
+
// that cannot suspend evaluates the same rule as a plain block through `activeGuardrails`.
|
|
133
|
+
askGate.push(ruleGuardrail(pack, resolved, pack.state, "interrupt"));
|
|
134
|
+
askBlocks.push(ruleGuardrail(pack, resolved, pack.state, "block"));
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
toolInput.push(ruleGuardrail(pack, resolved, pack.state));
|
|
138
|
+
}
|
|
97
139
|
}
|
|
98
|
-
return
|
|
140
|
+
return {
|
|
141
|
+
guardrails: toolOutput.length > 0 ? { toolInput, toolOutput } : { toolInput },
|
|
142
|
+
packs: packs.map((pack) => pack.row),
|
|
143
|
+
...(askGate.length > 0 ? { askGate: { toolInput: askGate }, askBlocks: { toolInput: askBlocks } } : {}),
|
|
144
|
+
snapshotState: () => {
|
|
145
|
+
const state = {};
|
|
146
|
+
for (const pack of packs) {
|
|
147
|
+
// Plan 104 T3: an inline pack now rides the checkpoint as rules, so only the rule shapes
|
|
148
|
+
// that cannot round-trip matter: a closure has no JSON form, and a `RegExp` serializes to
|
|
149
|
+
// `{}`, which would restore as an invalid (or, worse, absent) pattern.
|
|
150
|
+
const unpersistable = pack.inline
|
|
151
|
+
? pack.rules.find((resolved) => resolved.rule.deny !== undefined || resolved.rule.pattern instanceof RegExp)
|
|
152
|
+
: undefined;
|
|
153
|
+
if (unpersistable) {
|
|
154
|
+
throw new GuardrailPackError(`guardrail pack "${pack.id}" rule "${unpersistable.rule.id}" cannot be persisted (deny predicate or RegExp pattern); use a pattern string or a registered pack id when \`persistSessionState\` is on`);
|
|
155
|
+
}
|
|
156
|
+
const snapshot = pack.stateCodec?.snapshot(pack.state);
|
|
157
|
+
if (snapshot !== undefined)
|
|
158
|
+
state[pack.id] = snapshot;
|
|
159
|
+
}
|
|
160
|
+
return Object.keys(state).length > 0 ? state : undefined;
|
|
161
|
+
},
|
|
162
|
+
};
|
|
99
163
|
}
|
|
100
164
|
/** Stable identity rows for the same config `compileGuardrailPacks` accepts (no state, no guardrails built). */
|
|
101
165
|
export function describeGuardrailPacks(refs, registry = BUILT_IN_GUARDRAIL_PACKS) {
|
|
@@ -114,13 +178,14 @@ function packRevision(pack) {
|
|
|
114
178
|
function packRuleName(packId, ruleId) {
|
|
115
179
|
return `pack:${packId}/${ruleId}`;
|
|
116
180
|
}
|
|
117
|
-
function resolveGuardrailPacks(refs, registry) {
|
|
181
|
+
function resolveGuardrailPacks(refs, registry, initial) {
|
|
118
182
|
if (refs === undefined)
|
|
119
183
|
return [];
|
|
120
184
|
if (!Array.isArray(refs))
|
|
121
185
|
throw new GuardrailPackError("guardrailPacks must be an array of pack ids or pack input objects");
|
|
122
186
|
if (refs.length > MAX_GUARDRAIL_PACKS)
|
|
123
187
|
throw new GuardrailPackError(`guardrailPacks accepts at most ${MAX_GUARDRAIL_PACKS} packs`);
|
|
188
|
+
const restoring = initial !== undefined;
|
|
124
189
|
const seenPacks = new Set();
|
|
125
190
|
return refs.map((ref) => {
|
|
126
191
|
const input = (typeof ref === "string" ? { id: ref } : ref) ?? {};
|
|
@@ -135,7 +200,22 @@ function resolveGuardrailPacks(refs, registry) {
|
|
|
135
200
|
}
|
|
136
201
|
const definition = registry.get(input.id);
|
|
137
202
|
if (definition === undefined && input.rules === undefined) {
|
|
138
|
-
throw
|
|
203
|
+
throw unknownGuardrailPack(input.id, registry);
|
|
204
|
+
}
|
|
205
|
+
// A restored checkpoint replays rows, so a registered id must still match its installed version
|
|
206
|
+
// while an inline pack needs its pattern rules back (a closure cannot ride a checkpoint, and a
|
|
207
|
+
// pack replaying without it would enforce less than it did).
|
|
208
|
+
if (restoring) {
|
|
209
|
+
if (input.rules === undefined) {
|
|
210
|
+
if (definition === undefined)
|
|
211
|
+
throw unknownGuardrailPack(input.id, registry);
|
|
212
|
+
if (input.version !== definition.version) {
|
|
213
|
+
throw new GuardrailPackError(`guardrail pack "${input.id}" was persisted at version ${input.version} but the installed version is ${definition.version}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
else if (input.rules.some((rule) => rule?.deny !== undefined)) {
|
|
217
|
+
throw new GuardrailPackError(`persisted guardrail pack "${input.id}" carries a deny predicate; only pattern rules can be restored`);
|
|
218
|
+
}
|
|
139
219
|
}
|
|
140
220
|
let built;
|
|
141
221
|
if (input.rules !== undefined) {
|
|
@@ -144,6 +224,8 @@ function resolveGuardrailPacks(refs, registry) {
|
|
|
144
224
|
built = { rules: input.rules };
|
|
145
225
|
}
|
|
146
226
|
else {
|
|
227
|
+
if (definition === undefined)
|
|
228
|
+
throw unknownGuardrailPack(input.id, registry);
|
|
147
229
|
built = definition.build(Object.freeze({ ...input.options }));
|
|
148
230
|
}
|
|
149
231
|
if (!built || !Array.isArray(built.rules) || built.rules.length === 0) {
|
|
@@ -155,19 +237,43 @@ function resolveGuardrailPacks(refs, registry) {
|
|
|
155
237
|
if (built.observe !== undefined && typeof built.observe !== "function") {
|
|
156
238
|
throw new GuardrailPackError(`guardrail pack "${input.id}" observe must be a function`);
|
|
157
239
|
}
|
|
240
|
+
if (built.state !== undefined && (typeof built.state.snapshot !== "function" || typeof built.state.parse !== "function")) {
|
|
241
|
+
throw new GuardrailPackError(`guardrail pack "${input.id}" state codec must declare snapshot and parse`);
|
|
242
|
+
}
|
|
158
243
|
const seenRules = new Set();
|
|
159
244
|
const rules = built.rules.map((rule) => resolveRule(input.id, rule, seenRules));
|
|
160
245
|
if (built.observe && byteLength(packRuleName(input.id, OBSERVE_RULE_ID)) > MAX_PACK_NAME_BYTES) {
|
|
161
246
|
throw new GuardrailPackError(`guardrail pack "${input.id}" name exceeds ${MAX_PACK_NAME_BYTES} bytes`);
|
|
162
247
|
}
|
|
248
|
+
const version = input.version ?? definition?.version ?? 1;
|
|
249
|
+
const state = {};
|
|
250
|
+
const persisted = initial === undefined ? undefined : initial[input.id];
|
|
251
|
+
if (persisted !== undefined) {
|
|
252
|
+
if (built.state === undefined) {
|
|
253
|
+
throw new GuardrailPackError(`guardrail pack "${input.id}" has persisted state but declares no state codec`);
|
|
254
|
+
}
|
|
255
|
+
Object.assign(state, built.state.parse(persisted));
|
|
256
|
+
}
|
|
163
257
|
return {
|
|
164
258
|
id: input.id,
|
|
165
|
-
version
|
|
259
|
+
version,
|
|
166
260
|
rules,
|
|
261
|
+
state,
|
|
262
|
+
inline: input.rules !== undefined,
|
|
263
|
+
row: {
|
|
264
|
+
id: input.id,
|
|
265
|
+
version,
|
|
266
|
+
...(input.options !== undefined ? { options: input.options } : {}),
|
|
267
|
+
...(input.rules !== undefined ? { rules: input.rules } : {}),
|
|
268
|
+
},
|
|
167
269
|
...(built.observe ? { observe: built.observe } : {}),
|
|
270
|
+
...(built.state !== undefined ? { stateCodec: built.state } : {}),
|
|
168
271
|
};
|
|
169
272
|
});
|
|
170
273
|
}
|
|
274
|
+
function unknownGuardrailPack(id, registry) {
|
|
275
|
+
return new GuardrailPackError(`unknown guardrail pack "${id}"; known packs: ${[...registry.keys()].join(", ") || "none"}`);
|
|
276
|
+
}
|
|
171
277
|
function resolveRule(packId, rule, seenRules) {
|
|
172
278
|
const where = `guardrail pack "${packId}"`;
|
|
173
279
|
if (!rule || typeof rule.id !== "string" || !rule.id.trim() || byteLength(rule.id) > MAX_RULE_ID_BYTES) {
|
|
@@ -177,8 +283,11 @@ function resolveRule(packId, rule, seenRules) {
|
|
|
177
283
|
throw new GuardrailPackError(`${where} has a duplicate rule id "${rule.id}"`);
|
|
178
284
|
seenRules.add(rule.id);
|
|
179
285
|
const action = rule.action ?? "deny";
|
|
180
|
-
if (action !== "deny" && action !== "tripwire") {
|
|
181
|
-
throw new GuardrailPackError(`${where} rule "${rule.id}" action must be "deny"
|
|
286
|
+
if (action !== "deny" && action !== "tripwire" && action !== "ask") {
|
|
287
|
+
throw new GuardrailPackError(`${where} rule "${rule.id}" action must be "deny", "tripwire", or "ask"`);
|
|
288
|
+
}
|
|
289
|
+
if (action === "ask" && rule.deny !== undefined) {
|
|
290
|
+
throw new GuardrailPackError(`${where} rule "${rule.id}" action "ask" requires "pattern": an opaque deny predicate cannot raise an approval`);
|
|
182
291
|
}
|
|
183
292
|
const hasPattern = rule.pattern !== undefined;
|
|
184
293
|
const hasDeny = rule.deny !== undefined;
|
|
@@ -229,7 +338,7 @@ function compileRulePattern(packId, ruleId, pattern) {
|
|
|
229
338
|
throw new GuardrailPackError(`${where} has an invalid pattern`, { cause: error });
|
|
230
339
|
}
|
|
231
340
|
}
|
|
232
|
-
function ruleGuardrail(pack, resolved, state) {
|
|
341
|
+
function ruleGuardrail(pack, resolved, state, askAction = "interrupt") {
|
|
233
342
|
return {
|
|
234
343
|
name: packRuleName(pack.id, resolved.rule.id),
|
|
235
344
|
revision: packRevision(pack),
|
|
@@ -244,8 +353,8 @@ function ruleGuardrail(pack, resolved, state) {
|
|
|
244
353
|
if (!matched)
|
|
245
354
|
return { action: "allow" };
|
|
246
355
|
return {
|
|
247
|
-
// Pack vocabulary is `deny`; the core guardrail
|
|
248
|
-
action: resolved.action === "deny" ? "block" : "tripwire",
|
|
356
|
+
// Pack vocabulary is `deny`/`ask`; the core guardrail actions are `block`/`interrupt`.
|
|
357
|
+
action: resolved.action === "deny" ? "block" : resolved.action === "ask" ? askAction : "tripwire",
|
|
249
358
|
reason: resolved.reason,
|
|
250
359
|
metadata: { pack: pack.id, rule: resolved.rule.id, version: pack.version },
|
|
251
360
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,6 @@ export { AgentEventSourceError, createMemoryAgentEventSource, isTerminalAgentEve
|
|
|
4
4
|
export { dispatchToolCallsInOrder, generateValidateReviseLoop, isAgentLoopOptions, resolveLoop, resolveToolConcurrency, singleShotLoop, } from "./agent-loops.js";
|
|
5
5
|
export type { AgentRunLifecycle, AgentRunLifecycleAgent, AgentRunLifecycleOptions, AgentRunLifecycleRequest, AgentRunLifecycleStreamRequest, } from "./agent-run-lifecycle.js";
|
|
6
6
|
export { createAgentRunLifecycle } from "./agent-run-lifecycle.js";
|
|
7
|
-
export type { CheckpointRestoreAudit, CheckpointRestoreAuditEntry, CheckpointRestoreHook, RunCheckpointRestoreHooksOptions, } from "./checkpoint-restore.js";
|
|
8
|
-
export { CheckpointRestoreError, DEFAULT_CHECKPOINT_RESTORE_TIMEOUT_MS, runCheckpointRestoreHooks } from "./checkpoint-restore.js";
|
|
9
7
|
export type { PendingToolCall, StoredAgentRunState } from "./agent-run-state.js";
|
|
10
8
|
export { AGENT_RUN_STATE_NAMESPACE, AGENT_RUN_STATE_SCHEMA_VERSION, agentFingerprint, boundCheckpointMetadata, DEFAULT_MAX_AGENT_RUN_STATE_BYTES, HARD_MAX_AGENT_RUN_STATE_BYTES, loadAgentRunState, MAX_AGENT_RUN_METADATA_BYTES, readCheckpointMetadata, resolveCheckpointMetadata, } from "./agent-run-state.js";
|
|
11
9
|
export { createAgent, createAgentSession, resumeAgentRun, resumeAgentRunStream } from "./agents.js";
|
|
@@ -19,6 +17,8 @@ export type { CacheTelemetry, CacheTelemetryOptions, CacheTelemetryReport, Cache
|
|
|
19
17
|
export { CACHE_TELEMETRY_OVERFLOW_KEY, CacheTelemetryError, createCacheTelemetry, DEFAULT_CACHE_TELEMETRY_CAP, } from "./cache-telemetry.js";
|
|
20
18
|
export type { ProviderCapture, ProviderCaptureEntry, ProviderCaptureOptions, ProviderCapturePolicy } from "./capture.js";
|
|
21
19
|
export { createProviderCapture } from "./capture.js";
|
|
20
|
+
export type { CheckpointRestoreAudit, CheckpointRestoreAuditEntry, CheckpointRestoreCompensation, CheckpointRestoreHandler, CheckpointRestoreHook, RunCheckpointRestoreHooksOptions, } from "./checkpoint-restore.js";
|
|
21
|
+
export { CheckpointRestoreError, DEFAULT_CHECKPOINT_RESTORE_TIMEOUT_MS, runCheckpointRestoreHooks } from "./checkpoint-restore.js";
|
|
22
22
|
export type { MemoryCheckpointStoreOptions } from "./checkpoints.js";
|
|
23
23
|
export { CHECKPOINT_CONFLICT_CODE, CheckpointConflictError, createMemoryCheckpointStore } from "./checkpoints.js";
|
|
24
24
|
export type { DefaultCompactionStrategyOptions } from "./compaction.js";
|
|
@@ -49,15 +49,15 @@ export type { ClaimGroundingEvidence, ClaimGroundingEvidenceExtractor, ClaimGrou
|
|
|
49
49
|
export { createClaimGroundingGuardrail } from "./evidence-grounding.js";
|
|
50
50
|
export type { ExecutionAction, ExecutionDecision, ExecutionPolicy, ExecutionRisk } from "./execution-policy.js";
|
|
51
51
|
export { applyExecutionDecision, assertExecutionAllowed, checkExecution, ExecutionDeniedError } from "./execution-policy.js";
|
|
52
|
-
export type { ActivatedKernelConfig, ExtensionErrorPolicy, ExtensionEventBus, ExtensionEventHandler, ExtensionKernel, ExtensionKernelOptions, ExtensionLoadPolicy, LoadedExtension, } from "./extensions.js";
|
|
53
|
-
export { activateKernel, createExtensionEventBus, createExtensionKernel } from "./extensions.js";
|
|
52
|
+
export type { ActivatedKernelConfig, AgentEventBridgeOptions, ExtensionErrorPolicy, ExtensionEventBus, ExtensionEventHandler, ExtensionKernel, ExtensionKernelOptions, ExtensionLoadPolicy, LoadedExtension, } from "./extensions.js";
|
|
53
|
+
export { activateKernel, createExtensionEventBus, createExtensionKernel, forwardAgentEvents } from "./extensions.js";
|
|
54
54
|
export type { MemoryRunFeedbackStoreOptions, PrepareRunFeedbackOptions, RunFeedbackLimits, RunFeedbackRun, RunFeedbackRunResolver, } from "./feedback.js";
|
|
55
55
|
export { createMemoryRunFeedbackStore, prepareRunFeedback, RunFeedbackError, requireRunFeedbackOwnership, runFeedbackPageLimit, } from "./feedback.js";
|
|
56
56
|
export type { ApplyFieldPolicyOptions, AuditFieldRedaction, AuditFieldRedactorLike, AuditFieldRedactorOptions, FieldPolicy, FieldPolicyAction, FieldPolicyDecision, FieldPolicyInput, ProtectedFieldPolicyOptions, } from "./field-policy.js";
|
|
57
57
|
export { ALLOW_FIELD_POLICY, applyFieldPolicy, createAuditFieldRedactor, createProtectedFieldPolicy, FIELD_POLICY_LIMITS, FieldPolicyError, } from "./field-policy.js";
|
|
58
|
+
export { BUILT_IN_GUARDRAIL_PACK_IDS } from "./guardrail-packs/index.js";
|
|
58
59
|
export type { GuardrailPackRow, GuardrailRunResult, RunGuardrailsOptions, } from "./guardrails.js";
|
|
59
60
|
export { assertGuardrailsAllowed, compileGuardrailPacks, describeGuardrailPacks, GuardrailError, GuardrailPackError, MAX_GUARDRAIL_CONCURRENCY, MAX_GUARDRAIL_PACK_RULES, MAX_GUARDRAIL_PACKS, runGuardrails, } from "./guardrails.js";
|
|
60
|
-
export { BUILT_IN_GUARDRAIL_PACK_IDS } from "./guardrail-packs/index.js";
|
|
61
61
|
export type { AgentIdentity, AssertIdentityActiveOptions, IdentityLimits, IdentityVerifier, NarrowIdentityOptions, Principal, ResolvedIdentityLimits, } from "./identity.js";
|
|
62
62
|
export { assertIdentityActive, assertIdentityMatchesOwnership, assertIdentityPropagation, DEFAULT_IDENTITY_LIMITS, HARD_IDENTITY_LIMITS, IdentityError, identityTelemetryAttributes, narrowIdentity, ownershipFromIdentity, resolveIdentityLimits, resolveRunIdentity, } from "./identity.js";
|
|
63
63
|
export type { AgentInput, AssembleProviderInputOptions, DefaultInputBuildContext, DefaultInputBuilder, DefaultPromptBuilder, InputAttachment, PromptInstruction, PromptTemplateOptions, ResolveContextOptions, } from "./input.js";
|
|
@@ -96,7 +96,7 @@ export type { RunBundleSnapshot, RunBundleSnapshotInput } from "./run-bundle.js"
|
|
|
96
96
|
export { RUN_BUNDLE_SCHEMA_VERSION, snapshotRunBundle } from "./run-bundle.js";
|
|
97
97
|
export type { BatchedRunLedgerOptions } from "./run-ledger.js";
|
|
98
98
|
export { createBatchedRunLedger, DEFAULT_LEDGER_BATCH_BYTES, DEFAULT_LEDGER_BATCH_DELAY_MS, DEFAULT_LEDGER_BATCH_ENTRIES, HARD_LEDGER_BATCH_BYTES, HARD_LEDGER_BATCH_DELAY_MS, HARD_LEDGER_BATCH_ENTRIES, isFlushableRunLedger, } from "./run-ledger.js";
|
|
99
|
-
export type { RunLimitTrackerOptions } from "./run-limits.js";
|
|
99
|
+
export type { BudgetExhaustionAttribution, RunLimitTrackerOptions } from "./run-limits.js";
|
|
100
100
|
export { createRunLimitTracker, DEFAULT_RUN_LIMITS, HARD_RUN_LIMITS, RunLimitError, RunLimitTracker, resolveRunLimits, } from "./run-limits.js";
|
|
101
101
|
export type { HostCompositionGovernance, HostCompositionOptions, HostCompositionProfile, HostCompositionReport, HostCompositionToolReport, } from "./secure-agent.js";
|
|
102
102
|
export { assertHostCompositionReadiness, createSecureAgent, HostCompositionError, inspectHostComposition, } from "./secure-agent.js";
|
|
@@ -131,5 +131,5 @@ export { MODEL_FAMILY_TOKENS, resolveModelFamily } from "./usage-estimation.js";
|
|
|
131
131
|
export type { ResolvedUseCaseModel, ResolveUseCaseModelInput, UseCaseModelBinding, } from "./use-case-model.js";
|
|
132
132
|
export { resolveUseCaseModel, resolveUseCaseModelBinding, useCaseCredentialProviderId, } from "./use-case-model.js";
|
|
133
133
|
export declare const name = "prism";
|
|
134
|
-
export declare const version = "0.
|
|
134
|
+
export declare const version = "0.11.0";
|
|
135
135
|
export declare const description = "Agent harness for AI providers, agents, sessions, and tools.";
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,6 @@ export { resolveAgentDefinition } from "./agent-definitions.js";
|
|
|
2
2
|
export { AgentEventSourceError, createMemoryAgentEventSource, isTerminalAgentEventType } from "./agent-event-source.js";
|
|
3
3
|
export { dispatchToolCallsInOrder, generateValidateReviseLoop, isAgentLoopOptions, resolveLoop, resolveToolConcurrency, singleShotLoop, } from "./agent-loops.js";
|
|
4
4
|
export { createAgentRunLifecycle } from "./agent-run-lifecycle.js";
|
|
5
|
-
export { CheckpointRestoreError, DEFAULT_CHECKPOINT_RESTORE_TIMEOUT_MS, runCheckpointRestoreHooks } from "./checkpoint-restore.js";
|
|
6
5
|
export { AGENT_RUN_STATE_NAMESPACE, AGENT_RUN_STATE_SCHEMA_VERSION, agentFingerprint, boundCheckpointMetadata, DEFAULT_MAX_AGENT_RUN_STATE_BYTES, HARD_MAX_AGENT_RUN_STATE_BYTES, loadAgentRunState, MAX_AGENT_RUN_METADATA_BYTES, readCheckpointMetadata, resolveCheckpointMetadata, } from "./agent-run-state.js";
|
|
7
6
|
export { createAgent, createAgentSession, resumeAgentRun, resumeAgentRunStream } from "./agents.js";
|
|
8
7
|
export { ARTIFACT_BODY_ERROR_CODES, ARTIFACT_CHECKPOINT_NAMESPACE, ArtifactBodyStoreError, ArtifactError, approvalEvidenceIntact, artifactApprovalState, artifactCheckpointKey, checkCitationIntegrity, citationBindingDigest, HARD_CITATION_EXCERPT_BYTES, } from "./artifacts.js";
|
|
@@ -10,6 +9,7 @@ export { ATTENTION_BUDGET_ERROR_CODE, AttentionBudgetError, createAttentionCompi
|
|
|
10
9
|
export { applyCacheControl, cacheHitRate, cacheSavings, cacheUsageReport, mapCacheRetention, resolveBreakpoint, sanitizeCacheKey, systemCacheControlField, } from "./cache-helpers.js";
|
|
11
10
|
export { CACHE_TELEMETRY_OVERFLOW_KEY, CacheTelemetryError, createCacheTelemetry, DEFAULT_CACHE_TELEMETRY_CAP, } from "./cache-telemetry.js";
|
|
12
11
|
export { createProviderCapture } from "./capture.js";
|
|
12
|
+
export { CheckpointRestoreError, DEFAULT_CHECKPOINT_RESTORE_TIMEOUT_MS, runCheckpointRestoreHooks } from "./checkpoint-restore.js";
|
|
13
13
|
export { CHECKPOINT_CONFLICT_CODE, CheckpointConflictError, createMemoryCheckpointStore } from "./checkpoints.js";
|
|
14
14
|
export { createDefaultCompactionStrategy, isCompactionEntryData } from "./compaction.js";
|
|
15
15
|
export { assertJsonObject, isJsonObject, loadConfigLayers, mergeConfigLayers } from "./config.js";
|
|
@@ -25,11 +25,11 @@ export { acceptDeviceChunk, assertDeviceAdmit, DEFAULT_DEVICE_MAX_CHUNK_BYTES, D
|
|
|
25
25
|
export { createEventMultiplexer, EVENT_MULTIPLEXER_SINGLE_CONSUMER_CODE, EventMultiplexerError } from "./event-multiplexer.js";
|
|
26
26
|
export { createClaimGroundingGuardrail } from "./evidence-grounding.js";
|
|
27
27
|
export { applyExecutionDecision, assertExecutionAllowed, checkExecution, ExecutionDeniedError } from "./execution-policy.js";
|
|
28
|
-
export { activateKernel, createExtensionEventBus, createExtensionKernel } from "./extensions.js";
|
|
28
|
+
export { activateKernel, createExtensionEventBus, createExtensionKernel, forwardAgentEvents } from "./extensions.js";
|
|
29
29
|
export { createMemoryRunFeedbackStore, prepareRunFeedback, RunFeedbackError, requireRunFeedbackOwnership, runFeedbackPageLimit, } from "./feedback.js";
|
|
30
30
|
export { ALLOW_FIELD_POLICY, applyFieldPolicy, createAuditFieldRedactor, createProtectedFieldPolicy, FIELD_POLICY_LIMITS, FieldPolicyError, } from "./field-policy.js";
|
|
31
|
-
export { assertGuardrailsAllowed, compileGuardrailPacks, describeGuardrailPacks, GuardrailError, GuardrailPackError, MAX_GUARDRAIL_CONCURRENCY, MAX_GUARDRAIL_PACK_RULES, MAX_GUARDRAIL_PACKS, runGuardrails, } from "./guardrails.js";
|
|
32
31
|
export { BUILT_IN_GUARDRAIL_PACK_IDS } from "./guardrail-packs/index.js";
|
|
32
|
+
export { assertGuardrailsAllowed, compileGuardrailPacks, describeGuardrailPacks, GuardrailError, GuardrailPackError, MAX_GUARDRAIL_CONCURRENCY, MAX_GUARDRAIL_PACK_RULES, MAX_GUARDRAIL_PACKS, runGuardrails, } from "./guardrails.js";
|
|
33
33
|
export { assertIdentityActive, assertIdentityMatchesOwnership, assertIdentityPropagation, DEFAULT_IDENTITY_LIMITS, HARD_IDENTITY_LIMITS, IdentityError, identityTelemetryAttributes, narrowIdentity, ownershipFromIdentity, resolveIdentityLimits, resolveRunIdentity, } from "./identity.js";
|
|
34
34
|
export { assembleProviderInput, createDefaultInputBuilder, createDefaultPromptBuilder, EMPTY_TOOL_RESULT_TEXT, renderPromptTemplate, resolveContextProviders, } from "./input.js";
|
|
35
35
|
export { resolveInstructionInjectors, runInstructionInjectors } from "./instruction-injection.js";
|
|
@@ -72,6 +72,6 @@ export { trimTrailingSlashes } from "./trim-trailing-slashes.js";
|
|
|
72
72
|
export { MODEL_FAMILY_TOKENS, resolveModelFamily } from "./usage-estimation.js";
|
|
73
73
|
export { resolveUseCaseModel, resolveUseCaseModelBinding, useCaseCredentialProviderId, } from "./use-case-model.js";
|
|
74
74
|
export const name = "prism";
|
|
75
|
-
export const version = "0.
|
|
75
|
+
export const version = "0.11.0";
|
|
76
76
|
export const description = "Agent harness for AI providers, agents, sessions, and tools.";
|
|
77
77
|
//# sourceMappingURL=index.js.map
|