@arnilo/prism 0.2.6 → 0.2.8
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 +10 -2
- package/README.md +3 -2
- package/dist/agent-loops.js +4 -0
- package/dist/agent-run-lifecycle.js +2 -2
- package/dist/agent-session/helpers.d.ts +1 -1
- package/dist/agent-session/helpers.js +2 -1
- package/dist/agent-session/session.d.ts +1 -1
- package/dist/agent-session/session.js +28 -20
- package/dist/agent-session.d.ts +1 -1
- package/dist/agent-session.js +1 -1
- package/dist/agents.d.ts +1 -1
- package/dist/agents.js +1 -1
- package/dist/contracts-core/agent.d.ts +5 -5
- package/dist/contracts-core/agent.js +2 -0
- package/dist/contracts-core/extensions.d.ts +3 -3
- package/dist/contracts-core/extensions.js +2 -0
- package/dist/contracts-core/loop.d.ts +6 -1
- package/dist/contracts-core/session.d.ts +1 -1
- package/dist/contracts-core.d.ts +6 -6
- package/dist/contracts-core.js +6 -6
- package/dist/contracts-protocol.d.ts +8 -2
- package/dist/contracts.d.ts +1 -1
- package/dist/contracts.js +1 -1
- package/dist/field-policy.d.ts +119 -0
- package/dist/field-policy.js +418 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +5 -4
- package/dist/input.js +1 -1
- package/dist/redaction.d.ts +6 -5
- package/dist/redaction.js +18 -10
- package/dist/tools.d.ts +1 -1
- package/dist/tools.js +1 -1
- package/docs/0.1.0-readiness.md +7 -7
- package/docs/acp-agent.md +78 -0
- package/docs/acp.md +21 -10
- package/docs/ag-ui.md +1 -1
- package/docs/agent-definitions.md +1 -1
- package/docs/agent-events.md +2 -2
- package/docs/agent-loops.md +2 -2
- package/docs/audit-export.md +151 -0
- package/docs/coding-agent-tools.md +3 -1
- package/docs/coding-security.md +6 -0
- package/docs/data-classification.md +82 -0
- package/docs/disaster-recovery.md +71 -0
- package/docs/enterprise-postgres-state.md +60 -7
- package/docs/evaluations.md +45 -0
- package/docs/host-security.md +4 -0
- package/docs/index.md +11 -5
- package/docs/migration.md +27 -0
- package/docs/operations.md +104 -0
- package/docs/policy-and-audit.md +34 -0
- package/docs/release-0.2.7-evidence.md +514 -0
- package/docs/release-and-install.md +55 -8
- package/docs/structured-output.md +10 -10
- package/docs/workflows.md +48 -3
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
## [0.2.8] - 2026-08-18
|
|
2
|
+
|
|
3
|
+
### Changed
|
|
4
|
+
- **Release 0.2.8 (plan 028)** is the ACP adoption-fixes cut on the 0.2.x review-remediation line. API surface **additive-only** (plain reviewed compat gate at 0.2.8: expected deltas are the version literal plus the plan 028 additive exports — `ToolKind`/`ToolDefinition.kind`, `AgentFinishReason`/`agent_finished.finishReason`, `AgUiProjectedImage`/`AgUiProjectedToolResult`/`createCodingToolProjection`, `AcpCommand`/`AcpCommandsSeam`, `ERR_PRISM_ACP_RUN`, `acpImageBytes`/`acpCommandsPerUpdate`, and the new `@arnilo/prism-acp-agent` package; zero removals; baselines regenerated with `--update-baseline`, no `--allow-break`). Client names are scrubbed from the tree and `scripts/check-client-neutrality.mjs` is wired into `npm run release:gate`. ACP bugs B1–B5: truthful `usage_update` via a host `contextWindow` seam (omit when unknown); run-level `error` rejects `session/prompt` with `ERR_PRISM_ACP_RUN` (no fake transcript chunks); only boolean config options are advertised/`set_config_option` (select fails `ERR_PRISM_ACP_CAPABILITY`); `tool_call.kind` prefers registry `ToolDefinition.kind`; permission docs match SDK wire kinds (`allow_always`/`reject_always`). Features F1–F10: thinking → `agent_thought_chunk`; bounded redacted transcript replay on `session/load`/`resume`; spawnable `@arnilo/prism-acp-agent` over stdio; `session/prompt` `StopReason` fidelity; UNSTABLE-gated `plan_update`/`plan_removed` from coding plan lifecycle; host-owned `session_info_update` titles; opt-in `createCodingToolProjection()` for first-party edit/write diffs+locations; projected `toolResult` images as ACP content/image blocks (`acpImageBytes`); host slash commands as `available_commands_update` (`acpCommandsPerUpdate`); Windows sandbox policy documented (native backend stays Linux-only, fail-closed). Release graph is **51** publishable manifests at exact **0.2.8** (root + 50 workspace; `+1` `@arnilo/prism-acp-agent`). Store compatibility with 0.2.7: **compatible, no migration**. Exit gate green (`sdk:ready`, `release:check` including the client-neutrality guard, audit 0 moderate, scan-secrets 0, SBOM regenerated). **Publication remains the operator handoff** (`docs/release-and-install.md` `0.2.8 publish handoff` — signed `v0.2.8` tag + npm OIDC).
|
|
5
|
+
|
|
6
|
+
## [0.2.7] - 2026-08-17
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
- **Release 0.2.7 (plan 027)** is the enterprise ERP production-readiness cut on the 0.2.x review-remediation line. API surface **additive-only** (plain reviewed compat gate at 0.2.7: expected deltas are the version literal plus the plan 027 additive exports — ERP outbox/inbox stores + bounded dispatcher, saga compensation/reconciliation engine, multi-party SoD approvals, signed hash-chained audit export with WORM/SIEM seams, field-level classification + fail-closed redaction, deterministic ERP invariant evals; zero removals; baselines regenerated with `--update-baseline`, no `--allow-break`; freeze manifest `scripts/phase27-freeze-manifest.json` records per-task evidence tokens, state machines, caps, the demand registry, measured HA/DR/classification/journey numbers, and the 0.3.0 blocker). Nine roadmap items with threat model ERP-T1–ERP-T10, ownership/tenant tests, no exactly-once claim, no implicit credential discovery, package budget, docs entries, and protected end-to-end evidence: (1) **transactional outbox/inbox** (`erp-messaging`, Task 1) — `ErpOutboxStore`/`ErpInboxStore` + bounded `ErpOutboxDispatcher` with claim-token CAS, `FOR UPDATE SKIP LOCKED`, `ON CONFLICT DO NOTHING` idempotent append, at-least-once delivery with explicit unknown-outcome, dead-letter/replay requiring verified tenant `AgentIdentity`; migrations 004 (`prism_erp_outbox`/`prism_erp_inbox`). (2) **saga compensation and reconciliation** (`saga`, Task 2) — `defineSaga`/`runSaga`/`resumeSaga` over existing CheckpointStore + LeaseStore with reverse-order compensation, unknown-outcome detection, manual resolution requiring verified identity + bounded reason + audit ref, stable tenant-scoped operation keys, redacted snapshots, `MAX_SAGA_STEPS=100`. (3) **multi-party SoD approvals** (`approvals`, Task 3) — `ApprovalStore` with role/quorum rules, requester/approver separation, any-party-veto rejection, delegated authority (max depth 8), expiry checked at every protected transition, atomic grant consumption in the host transaction, `policyRevision` pin denying on mismatch; migration 005 (`prism_erp_approvals`). (4) **tamper-evident audit export** (`audit-export`, Task 4) — `createAuditExporter` with WORM-then-SIEM ordering, hash-chained record envelopes (genesis 0x64 zeros), `verifyAuditBatch` independent verification, `AuditCursorStore` CAS, SIEM best-effort pending replay (8-entry cap), legal-hold flag preservation, RFC 8785 canonical JSON for digests. (5) **secret-manager adapters** (Task 5) — Vault/AWS/Azure/GCP stay **deferred** behind the demand gate (no named consumer; no adapter ships; `scripts/phase27-demand-gate.mjs` enforces zero ambient discovery). (6) **HA registries and recovery** (`ha-dr`, Task 6) — two-replica drill on real Postgres proves failover within lease TTL+5s (measured 4100 ms vs 9000 ms ceiling), idempotent outbox re-append on uncertain-commit replay, stale fence/revision write rejection, exactly-one lease owner, tenant isolation fail-closed. (7) **backup/restore/migration rollback evidence** (Task 7) — `pg_dump`/`pg_restore` custom-format backup (108,291 B / 122 ms / 382 ms restore), 0.2.6→0.2.7 migration forward+rollback rehearsed (5 migrations), PITR RPO 0 s / RTO 1 s (recovery 1163 ms); production rollback is roll-forward repair only (no down migrations). (8) **field-level classification and fail-closed redaction** (`field-policy`, Task 8) — `applyFieldPolicy`/`FieldPolicy`/`createProtectedFieldPolicy` at the redaction, audit-export, and OpenTelemetry seams; unknown-label deny-on-outbound fail-closed default, sparse-copy walker, measured overhead peak 99.8% of the redactor-walk baseline (cap 110%). (9) **ERP release journey** (`erp-evals`, Task 9) — `erpInvariantDataset` + `createErpInvariantScorers` (8 hard 0/1 gates consuming structured facts only) + `scripts/phase27-erp-journey.test.mjs` exercising identity/policy/budget/SoD-approval/outbox/saga-compensation/audit-export/legal-hold/classification/failover/restore end-to-end (4815 ms, all 8 invariants pass). Release graph stays **50** publishable manifests at exact **0.2.7**; zero new runtime dependency names (core remains dependency-free). Store compatibility with 0.2.6: **compatible, additive** (two new ERP migrations 004/005 + outbox/inbox/approvals tables; rollback = stop 0.2.7 workers, restore the 0.2.6 manifests/tag — see `docs/migration.md` `0.2.6 → 0.2.7`). Exit gate green (core + script gates incl. `phase27-freeze` 9, `phase27-release` 12, `phase27-ha`/`phase27-dr`/`phase27-erp-journey` protected legs, coverage gate, `sdk:ready`, audit 0 moderate, pack dry-run 50/50 twice byte-identical, plain reviewed compat gate at 0.2.7 — version literal + additive exports only, release-evidence manifest with zero blocked surfaces, evidence in `scripts/phase27-release-evidence.json`). **"ERP production ready" remains blocked until the 0.3.0 live-service matrix is recorded** — passing 0.2.7 gates unblocks the release cut, not the 0.3.0 live-service matrix. **Publication remains the operator handoff** (`docs/release-and-install.md` `0.2.7 publish handoff` — signed `v0.2.7` tag + npm OIDC).
|
|
2
10
|
|
|
3
11
|
## [0.2.6] - 2026-08-16
|
|
4
12
|
|
|
@@ -109,7 +117,7 @@
|
|
|
109
117
|
### Changed
|
|
110
118
|
- `@arnilo/prism-ag-ui` depends on `@arnilo/prism-coding-agent` (workspace) for Phase 9 output-chunk caps and lifecycle types; publishable graph stays **48** manifests.
|
|
111
119
|
- SBOM license policy allows `Unlicense` (tweetnacl via `@nats-io/nkeys`); readiness SBOM evidence refreshed (227 packages / 12 licenses).
|
|
112
|
-
- `@arnilo/prism-ag-ui/renderer` now exports the DOM-free A2UI core values (`A2UiSurfaceState`, `reduceA2UiOps`, `readA2UiBatch`, `resolvePointer`, `A2UI_VERSION`) —
|
|
120
|
+
- `@arnilo/prism-ag-ui/renderer` now exports the DOM-free A2UI core values (`A2UiSurfaceState`, `reduceA2UiOps`, `readA2UiBatch`, `resolvePointer`, `A2UI_VERSION`) — host FR, hosts can drive the surface state machine without mounting; `createA2UiRenderer` behavior and frozen A2UI caps unchanged.
|
|
113
121
|
|
|
114
122
|
### Breaking (advertise/surface for ACP hosts only)
|
|
115
123
|
- `initialize` advertisement now reflects wired seams (previously minimal close-session); new session methods are registered only with their seams; `session/resume` of a live session rejects; `agentInfo.version` now comes from the package.json. Core, AG-UI, and coding-agent behavior unchanged. See [migration guide](docs/migration.md) `0.0.26 → 0.0.27`.
|
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ packages. Prism defines contracts, not apps.
|
|
|
11
11
|
- **Agent/session runtime**: `createAgent`/`createAgentSession`, run prompts,
|
|
12
12
|
dispatch host tools, subscribe to normalized `AgentEvent` streams, abort runs,
|
|
13
13
|
compact, and navigate branches.
|
|
14
|
+
- **Field-level classification (0.2.7)**: `applyFieldPolicy` + the fail-closed protected default walk JSON-like values across prompt/tool/artifact/audit/telemetry/persistence/export boundaries with `allow`/`redact`/`tokenize`/`deny` decisions, explicit per-boundary `labelFor` hints, bounded traversal, and sparse-copy allocation; seams at the egress redaction functions, the audit-export redactor hook, and the OpenTelemetry attribute policy. See [docs/data-classification.md](docs/data-classification.md).
|
|
14
15
|
- **Providers and models**: provider/model registries, provider event helpers,
|
|
15
16
|
credential redaction helpers, mock provider, and an optional
|
|
16
17
|
OpenAI-compatible provider subpath. Cache support is provider-specific:
|
|
@@ -55,7 +56,7 @@ npm install @arnilo/prism @arnilo/prism-provider-openai # core + one provider
|
|
|
55
56
|
npm install @arnilo/prism-base # core + compaction + validation
|
|
56
57
|
npm install @arnilo/prism-code @arnilo/prism-provider-openai # coding-agent profile
|
|
57
58
|
npm install @arnilo/prism-sdk @arnilo/prism-provider-openai # application profile
|
|
58
|
-
npm install @arnilo/prism-all # broad umbrella (
|
|
59
|
+
npm install @arnilo/prism-all # broad umbrella (21 direct / 44 transitive packages)
|
|
59
60
|
npm install @arnilo/prism-server @arnilo/prism-workflows # optional Web API boundary
|
|
60
61
|
npm install @arnilo/prism-supervisor # optional local delegation + A2A 1.0
|
|
61
62
|
npm install @arnilo/prism-web-tools # optional bounded Brave/Exa/Firecrawl research
|
|
@@ -182,7 +183,7 @@ printf '{"id":"1","command":"prompt","params":{"input":"Hi"}}\n' \
|
|
|
182
183
|
| `@arnilo/prism-base` | profile: core + compaction + JSON Schema validation |
|
|
183
184
|
| `@arnilo/prism-code` | profile: base + coding tools/security + MCP |
|
|
184
185
|
| `@arnilo/prism-sdk` | profile: base + workflows + MCP + credentials + OpenTelemetry |
|
|
185
|
-
| `@arnilo/prism-all` | broad umbrella:
|
|
186
|
+
| `@arnilo/prism-all` | broad umbrella: 21 first-party packages (44 transitive) across runtime, capability, provider, and persistence — omits document-reader, OpenAPI tools, NATS, Caveman, and Ponytail |
|
|
186
187
|
|
|
187
188
|
## Scripts
|
|
188
189
|
|
package/dist/agent-loops.js
CHANGED
|
@@ -47,6 +47,9 @@ export const singleShotLoop = {
|
|
|
47
47
|
ctx.emit({ type: "turn_finished", sessionId: ctx.sessionId, runId: ctx.runId, turn });
|
|
48
48
|
const dispatchable = dispatchableToolCalls(calls);
|
|
49
49
|
if (dispatchable.length === 0 || toolRounds >= ctx.maxToolRounds) {
|
|
50
|
+
// F4: the tool-round ceiling ended the run cleanly (not a natural end).
|
|
51
|
+
if (dispatchable.length > 0 && toolRounds >= ctx.maxToolRounds)
|
|
52
|
+
ctx.finishReason = "turn_limit";
|
|
50
53
|
// Soft-interrupt / late steer: keep same run going when queue still has text.
|
|
51
54
|
if (await ctx.applyPendingSteers?.()) {
|
|
52
55
|
nextInput = [];
|
|
@@ -155,6 +158,7 @@ export function generateValidateReviseLoop(opts) {
|
|
|
155
158
|
errors: [{ message: "maximum tool rounds exceeded" }],
|
|
156
159
|
metadata: { reason: "tool_round_limit" },
|
|
157
160
|
};
|
|
161
|
+
ctx.finishReason = "turn_limit";
|
|
158
162
|
ctx.emit({ type: "artifact_failed", sessionId: ctx.sessionId, runId: ctx.runId, turn, attempt: attempts + 1, result });
|
|
159
163
|
return usage;
|
|
160
164
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { agentFingerprint, loadAgentRunState, publicState, saveAgentRunState } from "./agent-run-state.js";
|
|
2
|
-
import { AgentRunStateError } from "./contracts.js";
|
|
3
1
|
import { assertValidAgentRunResume, pendingDecisionsOf, resolveRunDecisions } from "./agent-approval.js";
|
|
2
|
+
import { agentFingerprint, loadAgentRunState, publicState, saveAgentRunState } from "./agent-run-state.js";
|
|
4
3
|
import { RuntimeAgentSession, throwIfAbortedSignal } from "./agent-session.js";
|
|
4
|
+
import { AgentRunStateError } from "./contracts.js";
|
|
5
5
|
function assertAgentId(actual, expected) {
|
|
6
6
|
if (expected !== undefined && actual !== expected)
|
|
7
7
|
throw new AgentRunStateError("Agent run capability mismatch");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** helpers (0.2.5 plan 025 Task 1 split). Moved verbatim from agent-session.ts; public surface unchanged behind the barrel. */
|
|
2
2
|
import type { CompactionOptions, ContentBlock, ErrorInfo, Guardrails, Message, ProviderEvent, RetryOptions, ToolCallContent, Usage } from "../contracts.js";
|
|
3
|
-
import type { AgentInput } from "../input.js";
|
|
4
3
|
import { createId } from "../ids.js";
|
|
4
|
+
import type { AgentInput } from "../input.js";
|
|
5
5
|
export declare function providerContent(event: Extract<ProviderEvent, {
|
|
6
6
|
type: "content_delta" | "tool_call";
|
|
7
7
|
}>): ContentBlock;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/** helpers (0.2.5 plan 025 Task 1 split). Moved verbatim from agent-session.ts; public surface unchanged behind the barrel. */
|
|
2
|
+
import { singleShotLoop } from "../agent-loops.js";
|
|
1
3
|
import { createId } from "../ids.js";
|
|
2
4
|
import { reconstructToolCallDeltas } from "../provider-events.js";
|
|
3
|
-
import { singleShotLoop } from "../agent-loops.js";
|
|
4
5
|
export function providerContent(event) {
|
|
5
6
|
return event.type === "content_delta" ? event.content : event.call;
|
|
6
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** session (0.2.5 plan 025 Task 1 split). Moved verbatim from agent-session.ts; public surface unchanged behind the barrel. */
|
|
2
|
+
import type { StoredAgentRunState } from "../agent-run-state.js";
|
|
2
3
|
import type { Agent, AgentEvent, AgentRunResult, AgentRunStateOptions, AgentSession, AgentSessionConfig, CompactionOptions, CompactionResult, OwnershipScope, RunDecision, RunOptions, SessionEntry, SteerOptions, SubscribeOptions } from "../contracts.js";
|
|
3
4
|
import type { AgentInput } from "../input.js";
|
|
4
5
|
import type { LoadedSkillBodiesEntry } from "../skill-load.js";
|
|
5
|
-
import type { StoredAgentRunState } from "../agent-run-state.js";
|
|
6
6
|
export declare class RuntimeAgentSession implements AgentSession {
|
|
7
7
|
readonly id: string;
|
|
8
8
|
private readonly agent;
|
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
/** session (0.2.5 plan 025 Task 1 split). Moved verbatim from agent-session.ts; public surface unchanged behind the barrel. */
|
|
2
2
|
import { AgentRunSuspended, decisionIdentityRef, decisionScopesEqual, nestedApprovalId, nestedOutcomeToolResult, pathsEqual, } from "../agent-approval.js";
|
|
3
|
-
import {
|
|
4
|
-
import { assembleProviderInput } from "../input.js";
|
|
5
|
-
import { GuardrailError, assertGuardrailsAllowed, runGuardrails } from "../guardrails.js";
|
|
6
|
-
import { applyRestoredSkillBodies, snapshotLoadedSkillBodies, validateLoadedSkillBodies } from "../skill-load.js";
|
|
3
|
+
import { resolveLoop, resolveToolConcurrency } from "../agent-loops.js";
|
|
7
4
|
import { boundedLoopSnapshot, initialAgentRunState, publicState, saveAgentRunState, validateRunStateOptions } from "../agent-run-state.js";
|
|
8
|
-
import { RunLimitError, RunLimitTracker, resolveRunLimits } from "../run-limits.js";
|
|
9
|
-
import { errorToErrorInfo, redactAgentEvent, redactProviderRequest, redactRunLedgerRecord, redactSecrets, redactSessionEntry, } from "../redaction.js";
|
|
10
|
-
import { createMemorySessionStore, createSessionEntry, getSessionBranchEntries, rebuildSessionContext } from "../session-stores.js";
|
|
11
5
|
import { activeTools, policyList, toolElicitationRequest } from "../agent-tool-dispatch.js";
|
|
12
|
-
import { assertStructuredOutputRequestSupported, resolveRunProviderOptions } from "../structured-output.js";
|
|
13
|
-
import { canonicalToolEffectJson, toolEffectArgumentsHash } from "../tool-effects.js";
|
|
14
|
-
import { composeSystemPrompt, mergeSystemPromptConfig } from "../system-prompts.js";
|
|
15
6
|
import { createDefaultCompactionStrategy, isCompactionEntryData } from "../compaction.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
7
|
+
import { AgentDecisionError, AgentDelegationSuspendedError, AgentLoopStateError, AgentRunError, AgentRunStateError, DEFAULT_MAX_PENDING_DECISIONS, DEFAULT_MAX_PENDING_STEER_BYTES, DEFAULT_MAX_PENDING_STEERS, HARD_MAX_PENDING_DECISIONS, MAX_ATTRIBUTION_DEPTH, } from "../contracts.js";
|
|
8
|
+
import { assertGuardrailsAllowed, GuardrailError, runGuardrails } from "../guardrails.js";
|
|
9
|
+
import { identityTelemetryAttributes, ownershipFromIdentity, resolveRunIdentity } from "../identity.js";
|
|
10
|
+
import { assembleProviderInput } from "../input.js";
|
|
19
11
|
import { createProviderTurnMetadata, readProviderHttpStatus } from "../observability.js";
|
|
20
|
-
import { dispatchToolCall, resolveToolEffectDeclaration } from "../tools.js";
|
|
21
|
-
import { isFlushableRunLedger } from "../run-ledger.js";
|
|
22
12
|
import { providerToolCallDeltaContent } from "../provider-events.js";
|
|
13
|
+
import { createProviderRequestPolicyChain, normalizeProviderRequestPolicyResult } from "../provider-request-policy.js";
|
|
14
|
+
import { errorToErrorInfo, redactAgentEvent, redactProviderRequest, redactRunLedgerRecord, redactSecrets, redactSessionEntry, } from "../redaction.js";
|
|
15
|
+
import { createDefaultRetryPolicy, waitForRetry } from "../retry.js";
|
|
16
|
+
import { isFlushableRunLedger } from "../run-ledger.js";
|
|
17
|
+
import { RunLimitError, RunLimitTracker, resolveRunLimits } from "../run-limits.js";
|
|
18
|
+
import { createMemorySessionStore, createSessionEntry, getSessionBranchEntries, rebuildSessionContext } from "../session-stores.js";
|
|
19
|
+
import { createLoadedSkillSet, resolveSkillsDisclosure } from "../skill-disclosure.js";
|
|
20
|
+
import { applyRestoredSkillBodies, snapshotLoadedSkillBodies, validateLoadedSkillBodies } from "../skill-load.js";
|
|
23
21
|
import { resolveActiveSkills } from "../skills.js";
|
|
24
|
-
import {
|
|
22
|
+
import { assertStructuredOutputRequestSupported, resolveRunProviderOptions } from "../structured-output.js";
|
|
23
|
+
import { composeSystemPrompt, mergeSystemPromptConfig } from "../system-prompts.js";
|
|
24
|
+
import { canonicalToolEffectJson, toolEffectArgumentsHash } from "../tool-effects.js";
|
|
25
25
|
import { resolveToolResultFold } from "../tool-result-fold.js";
|
|
26
|
-
import {
|
|
27
|
-
import { ProviderTurnFailure, SteerSoftInterrupt, bridgeAbort, createUsageAccumulator, errorFromInfo, finalAssistantMessage, inputToMessages, isDurableLoop, isSteerSoftInterrupt, jsonBytes, mergeCompaction, mergeGuardrails, mergeRetry, messageTextBytes, providerContent, randomId, reconstructMissingToolCalls, throwIfAborted, throwIfAbortedSignal, withoutTrailingInput, } from "./helpers.js";
|
|
26
|
+
import { dispatchToolCall, resolveToolEffectDeclaration } from "../tools.js";
|
|
28
27
|
import { createAgentSession } from "./create-agent.js";
|
|
28
|
+
import { EventSubscriber } from "./event-subscriber.js";
|
|
29
|
+
import { bridgeAbort, createUsageAccumulator, errorFromInfo, finalAssistantMessage, inputToMessages, isDurableLoop, isSteerSoftInterrupt, jsonBytes, mergeCompaction, mergeGuardrails, mergeRetry, messageTextBytes, ProviderTurnFailure, providerContent, randomId, reconstructMissingToolCalls, SteerSoftInterrupt, throwIfAborted, throwIfAbortedSignal, withoutTrailingInput, } from "./helpers.js";
|
|
29
30
|
export class RuntimeAgentSession {
|
|
30
31
|
id;
|
|
31
32
|
agent;
|
|
@@ -850,7 +851,14 @@ export class RuntimeAgentSession {
|
|
|
850
851
|
loopState: undefined,
|
|
851
852
|
})
|
|
852
853
|
: undefined;
|
|
853
|
-
this.emit({
|
|
854
|
+
this.emit({
|
|
855
|
+
type: "agent_finished",
|
|
856
|
+
sessionId: this.id,
|
|
857
|
+
runId,
|
|
858
|
+
usage,
|
|
859
|
+
// F4: loop strategies record why a ceiling ended the run cleanly (e.g. turn_limit).
|
|
860
|
+
...(ctx.finishReason ? { finishReason: ctx.finishReason } : {}),
|
|
861
|
+
});
|
|
854
862
|
return this.buildRunResult({ runId, status: "succeeded", usage, runState });
|
|
855
863
|
}
|
|
856
864
|
catch (error) {
|
package/dist/agent-session.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** agent-session.ts barrel (0.2.5 plan 025 Task 1 god-module split): re-exports the
|
|
2
2
|
* public surface from cohesive family modules (0.1.4 barrel precedent). */
|
|
3
3
|
export * from "./agent-session/create-agent.js";
|
|
4
|
-
export * from "./agent-session/session.js";
|
|
5
4
|
export * from "./agent-session/event-subscriber.js";
|
|
6
5
|
export * from "./agent-session/helpers.js";
|
|
6
|
+
export * from "./agent-session/session.js";
|
package/dist/agent-session.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** agent-session.ts barrel (0.2.5 plan 025 Task 1 god-module split): re-exports the
|
|
2
2
|
* public surface from cohesive family modules (0.1.4 barrel precedent). */
|
|
3
3
|
export * from "./agent-session/create-agent.js";
|
|
4
|
-
export * from "./agent-session/session.js";
|
|
5
4
|
export * from "./agent-session/event-subscriber.js";
|
|
6
5
|
export * from "./agent-session/helpers.js";
|
|
6
|
+
export * from "./agent-session/session.js";
|
|
7
7
|
//# sourceMappingURL=agent-session.js.map
|
package/dist/agents.d.ts
CHANGED
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
* agents.d.ts and change the declared surface — the 0.1.4 promise is an
|
|
13
13
|
* identical surface.
|
|
14
14
|
*/
|
|
15
|
-
export { createAgent, createAgentSession } from "./agent-session.js";
|
|
16
15
|
export { resumeAgentRun, resumeAgentRunStream } from "./agent-run-lifecycle.js";
|
|
16
|
+
export { createAgent, createAgentSession } from "./agent-session.js";
|
package/dist/agents.js
CHANGED
|
@@ -12,6 +12,6 @@
|
|
|
12
12
|
* agents.d.ts and change the declared surface — the 0.1.4 promise is an
|
|
13
13
|
* identical surface.
|
|
14
14
|
*/
|
|
15
|
-
export { createAgent, createAgentSession } from "./agent-session.js";
|
|
16
15
|
export { resumeAgentRun, resumeAgentRunStream } from "./agent-run-lifecycle.js";
|
|
16
|
+
export { createAgent, createAgentSession } from "./agent-session.js";
|
|
17
17
|
//# sourceMappingURL=agents.js.map
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/** Contracts-core agent family (0.2.5 plan 025 Task 1 split).
|
|
2
2
|
* Moved verbatim from contracts-core.ts; public surface unchanged behind the barrel. */
|
|
3
|
+
import type { InputAssemblyLayout, RunLedger, ToolDefinition, ToolEffectStore, ToolRegistry } from "../contracts-protocol.js";
|
|
3
4
|
import type { AgentRunStateOptions, AgentSession } from "../contracts-run-state.js";
|
|
4
5
|
import type { ContributionRegistries } from "../contributions.js";
|
|
5
|
-
import type { InputAssemblyLayout, RunLedger, ToolDefinition, ToolEffectStore, ToolRegistry } from "../contracts-protocol.js";
|
|
6
6
|
import type { MiddlewareRegistry } from "../middleware.js";
|
|
7
|
-
import type { PermissionPolicy, TrustPolicy } from "../security.js";
|
|
8
7
|
import type { SecretRedactor } from "../redaction.js";
|
|
8
|
+
import type { PermissionPolicy, TrustPolicy } from "../security.js";
|
|
9
9
|
import type { ToolValidator } from "../tools.js";
|
|
10
|
-
import type { AIProvider, ProviderRequestOptions, ProviderResolver } from "./provider.js";
|
|
11
|
-
import type { AgentLoopOptions, AgentLoopStrategy } from "./loop.js";
|
|
12
10
|
import type { CompactionOptions, RetryOptions } from "./compaction.js";
|
|
13
11
|
import type { ContentBlock, ErrorInfo, JsonObject, Message, ModelConfig } from "./content.js";
|
|
14
12
|
import type { ProviderRequestPolicy, SystemPromptConfig } from "./extensions.js";
|
|
15
|
-
import type {
|
|
13
|
+
import type { AgentLoopOptions, AgentLoopStrategy } from "./loop.js";
|
|
16
14
|
import type { OwnershipScope } from "./persistence.js";
|
|
15
|
+
import type { AIProvider, ProviderRequestOptions, ProviderResolver } from "./provider.js";
|
|
17
16
|
import type { ResourceLoader } from "./resources.js";
|
|
17
|
+
import type { Guardrails, RunLimits } from "./run-limits.js";
|
|
18
18
|
import type { SessionStore } from "./session.js";
|
|
19
19
|
export interface AgentDefinition {
|
|
20
20
|
readonly name: string;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** Contracts-core agent family (0.2.5 plan 025 Task 1 split).
|
|
2
|
+
* Moved verbatim from contracts-core.ts; public surface unchanged behind the barrel. */
|
|
1
3
|
export {};
|
|
2
4
|
/** Directory-name spelling for discovered contribution kinds. Maps to a
|
|
3
5
|
* {@link ManifestContributionDeclaration} kind for non-skill kinds:
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/** Contracts-core extensions family (0.2.5 plan 025 Task 1 split).
|
|
2
2
|
* Moved verbatim from contracts-core.ts; public surface unchanged behind the barrel. */
|
|
3
|
+
import type { ToolDefinition } from "../contracts-protocol.js";
|
|
3
4
|
import type { ContributionRegistries } from "../contributions.js";
|
|
4
5
|
import type { ManifestContributionDeclaration } from "../manifests.js";
|
|
5
6
|
import type { Middleware, MiddlewareHookName, MiddlewareRegistry } from "../middleware.js";
|
|
6
|
-
import type { ToolDefinition } from "../contracts-protocol.js";
|
|
7
|
-
import type { AIProvider, ProviderRequest } from "./provider.js";
|
|
8
7
|
import type { AgentDefinition, CommandDefinition, ContextProvider, InputBuilder, InstructionInjector, PromptBuilder, Skill } from "./agent.js";
|
|
9
8
|
import type { CompactionStrategy, RetryPolicy } from "./compaction.js";
|
|
10
|
-
import type { Credential, CredentialResolver, ResourceLoader, SettingsProvider } from "./resources.js";
|
|
11
9
|
import type { ErrorInfo, ModelConfig } from "./content.js";
|
|
12
10
|
import type { StoreFactory } from "./persistence.js";
|
|
11
|
+
import type { AIProvider, ProviderRequest } from "./provider.js";
|
|
12
|
+
import type { Credential, CredentialResolver, ResourceLoader, SettingsProvider } from "./resources.js";
|
|
13
13
|
export type ContributionFileKind = "skill" | "tool" | "context" | "instructions";
|
|
14
14
|
/** Inert envelope emitted by the host/CLI discovery scanner. Carries the
|
|
15
15
|
* realized {@link Skill} for skill kinds and a manifest-referenced
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Contracts-core loop family (0.2.5 plan 025 Task 1 split).
|
|
2
2
|
* Moved verbatim from contracts-core.ts; public surface unchanged behind the barrel. */
|
|
3
|
-
import type { AgentEvent, ProviderTurnResult, ToolResult } from "../contracts-protocol.js";
|
|
3
|
+
import type { AgentEvent, AgentFinishReason, ProviderTurnResult, ToolResult } from "../contracts-protocol.js";
|
|
4
4
|
import type { AgentInput } from "../input.js";
|
|
5
5
|
import type { JsonValue, Message, ToolCallContent, Usage } from "./content.js";
|
|
6
6
|
import type { ProviderRequest, StructuredOutputOptions } from "./provider.js";
|
|
@@ -13,6 +13,11 @@ export interface LoopContext {
|
|
|
13
13
|
readonly input: AgentInput;
|
|
14
14
|
readonly inputMessages: readonly Message[];
|
|
15
15
|
readonly maxToolRounds: number;
|
|
16
|
+
/**
|
|
17
|
+
* Why the loop stopped, when a limit/ceiling ends the run cleanly (F4). Strategies set
|
|
18
|
+
* this at ceiling exits (e.g. `turn_limit`); the runtime copies it onto `agent_finished`.
|
|
19
|
+
*/
|
|
20
|
+
finishReason?: AgentFinishReason;
|
|
16
21
|
/** Maximum independent tool calls dispatched concurrently per provider turn. Default `1`. */
|
|
17
22
|
readonly toolConcurrency: number;
|
|
18
23
|
assemble(nextInput: AgentInput, toolResults?: readonly ToolResult[], turn?: number): Promise<ProviderRequest>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** Contracts-core session family (0.2.5 plan 025 Task 1 split).
|
|
2
2
|
* Moved verbatim from contracts-core.ts; public surface unchanged behind the barrel. */
|
|
3
3
|
import type { AgentEvent } from "../contracts-protocol.js";
|
|
4
|
-
import type { OwnershipScope, PersistencePage, PersistenceQuery } from "./persistence.js";
|
|
5
4
|
import type { Message, ModelConfig } from "./content.js";
|
|
5
|
+
import type { OwnershipScope, PersistencePage, PersistenceQuery } from "./persistence.js";
|
|
6
6
|
export type SessionEntryKind = "message" | "event" | "summary" | "metadata" | "model_change" | "label" | "custom" | "compaction";
|
|
7
7
|
export declare const SESSION_ENTRY_KINDS: readonly SessionEntryKind[];
|
|
8
8
|
export declare const SESSION_ENTRY_SCHEMA_VERSION = 1;
|
package/dist/contracts-core.d.ts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* public contracts surface from cohesive family modules so the import surface
|
|
3
3
|
* of `./contracts-core.js` is unchanged (0.1.4 barrel precedent). */
|
|
4
4
|
export type { AudioContent, DocumentContent, FileContent } from "./content.js";
|
|
5
|
-
export * from "./contracts-core/content.js";
|
|
6
|
-
export * from "./contracts-core/run-limits.js";
|
|
7
|
-
export * from "./contracts-core/provider.js";
|
|
8
5
|
export * from "./contracts-core/agent.js";
|
|
6
|
+
export * from "./contracts-core/compaction.js";
|
|
7
|
+
export * from "./contracts-core/content.js";
|
|
9
8
|
export * from "./contracts-core/extensions.js";
|
|
10
|
-
export * from "./contracts-core/
|
|
9
|
+
export * from "./contracts-core/loop.js";
|
|
11
10
|
export * from "./contracts-core/persistence.js";
|
|
12
|
-
export * from "./contracts-core/
|
|
11
|
+
export * from "./contracts-core/provider.js";
|
|
13
12
|
export * from "./contracts-core/resources.js";
|
|
14
|
-
export * from "./contracts-core/
|
|
13
|
+
export * from "./contracts-core/run-limits.js";
|
|
14
|
+
export * from "./contracts-core/session.js";
|
package/dist/contracts-core.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * from "./contracts-core/content.js";
|
|
2
|
-
export * from "./contracts-core/run-limits.js";
|
|
3
|
-
export * from "./contracts-core/provider.js";
|
|
4
1
|
export * from "./contracts-core/agent.js";
|
|
2
|
+
export * from "./contracts-core/compaction.js";
|
|
3
|
+
export * from "./contracts-core/content.js";
|
|
5
4
|
export * from "./contracts-core/extensions.js";
|
|
6
|
-
export * from "./contracts-core/
|
|
5
|
+
export * from "./contracts-core/loop.js";
|
|
7
6
|
export * from "./contracts-core/persistence.js";
|
|
8
|
-
export * from "./contracts-core/
|
|
7
|
+
export * from "./contracts-core/provider.js";
|
|
9
8
|
export * from "./contracts-core/resources.js";
|
|
10
|
-
export * from "./contracts-core/
|
|
9
|
+
export * from "./contracts-core/run-limits.js";
|
|
10
|
+
export * from "./contracts-core/session.js";
|
|
11
11
|
//# sourceMappingURL=contracts-core.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { AgentLoopOptions, AgentLoopStrategy, ArtifactValidation, CompactionOptions, ContentBlock, ErrorInfo, GuardrailRecord, Guardrails, InstructionInjector, JsonObject, Message, ModelConfig, OwnershipScope, ProviderRequestPolicy, ProviderResolver, RetryOptions, RunLimitBreach, RunLimits, Skill, SubscriberOverflowPolicy, SystemPromptConfig, ToolCallAuthority, ToolCallContent, Usage } from "./contracts-core.js";
|
|
1
|
+
import type { AgentLoopOptions, AgentLoopStrategy, ArtifactValidation, CompactionOptions, ContentBlock, ErrorInfo, GuardrailRecord, Guardrails, InstructionInjector, JsonObject, Message, ModelConfig, OwnershipScope, ProviderRequestOptions, ProviderRequestPolicy, ProviderResolver, RetryOptions, RunLimitBreach, RunLimits, Skill, SubscriberOverflowPolicy, SystemPromptConfig, ToolCallAuthority, ToolCallContent, Usage } from "./contracts-core.js";
|
|
2
2
|
import type { AgentRunInterruption, AgentRunStateOptions } from "./contracts-run-state.js";
|
|
3
|
-
import type { ProviderRequestOptions } from "./contracts-core.js";
|
|
4
3
|
import type { SecretRedactor } from "./redaction.js";
|
|
5
4
|
import type { ToolValidator } from "./tools.js";
|
|
6
5
|
export type ProviderEvent = {
|
|
@@ -109,6 +108,7 @@ export interface ToolExecutionMetadata {
|
|
|
109
108
|
readonly durationMs: number;
|
|
110
109
|
readonly status: ToolCallStatus;
|
|
111
110
|
}
|
|
111
|
+
export type AgentFinishReason = "turn_limit" | "token_limit" | "refusal";
|
|
112
112
|
export type AgentEvent = {
|
|
113
113
|
readonly type: "agent_started";
|
|
114
114
|
readonly sessionId: string;
|
|
@@ -118,6 +118,8 @@ export type AgentEvent = {
|
|
|
118
118
|
readonly sessionId: string;
|
|
119
119
|
readonly runId: string;
|
|
120
120
|
readonly usage?: Usage;
|
|
121
|
+
/** Why the loop stopped, when a limit/ceiling ended the run cleanly (F4). Absent = natural end. */
|
|
122
|
+
readonly finishReason?: AgentFinishReason;
|
|
121
123
|
} | {
|
|
122
124
|
readonly type: "agent_suspended";
|
|
123
125
|
readonly sessionId: string;
|
|
@@ -318,8 +320,12 @@ export interface ToolElicitationRequest {
|
|
|
318
320
|
/** Answer-shape validation beyond structural schema checks; throw to reject the payload. */
|
|
319
321
|
readonly validate?: (payload: JsonObject) => void;
|
|
320
322
|
}
|
|
323
|
+
/** Neutral tool-kind union mirroring the ACP `ToolKind` set (B4); never an ACP import in `src/`. */
|
|
324
|
+
export type ToolKind = "read" | "edit" | "delete" | "move" | "search" | "execute" | "think" | "fetch" | "switch_mode" | "other";
|
|
321
325
|
export interface ToolDefinition {
|
|
322
326
|
readonly name: string;
|
|
327
|
+
/** Optional explicit kind; consumers (e.g. the ACP mapper) use it instead of name heuristics. */
|
|
328
|
+
readonly kind?: ToolKind;
|
|
323
329
|
readonly description?: string;
|
|
324
330
|
readonly parameters?: JsonObject;
|
|
325
331
|
/** Force any provider turn containing this tool to dispatch sequentially. */
|
package/dist/contracts.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* import surface of `./contracts.js` is unchanged.
|
|
6
6
|
*/
|
|
7
7
|
export * from "./contracts-core.js";
|
|
8
|
-
export * from "./contracts-run-state.js";
|
|
9
8
|
export * from "./contracts-protocol.js";
|
|
9
|
+
export * from "./contracts-run-state.js";
|
|
10
10
|
/** Alias re-exports so `dist/contracts.d.ts` exposes implementer contract names. */
|
|
11
11
|
export type AgentIdentity = import("./identity.js").AgentIdentity;
|
|
12
12
|
export type Principal = import("./identity.js").Principal;
|
package/dist/contracts.js
CHANGED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field-level classification and fail-closed redaction (plan 027 Task 8).
|
|
3
|
+
*
|
|
4
|
+
* A dependency-free, JSON-like structured-value walker that evaluates an
|
|
5
|
+
* explicit host policy against every field of a value destined to cross a
|
|
6
|
+
* data boundary (provider prompt egress, tool dispatch/result persistence,
|
|
7
|
+
* artifact write/read/export, audit hashing, telemetry attributes/events,
|
|
8
|
+
* lifecycle export). The policy classifies fields by label, path, destination,
|
|
9
|
+
* and tenant; unknown fields fail closed under the protected default.
|
|
10
|
+
*
|
|
11
|
+
* Non-goals (frozen): no automatic sensitive-data discovery (labels come from
|
|
12
|
+
* an explicit `labelFor` hint function supplied by the boundary owner), no
|
|
13
|
+
* global registry, no decorator framework, no second policy language. Existing
|
|
14
|
+
* hardcoded secret redaction (`createSecretRedactor`) stays in place as
|
|
15
|
+
* defense in depth and runs *after* policy transformation at egress seams.
|
|
16
|
+
*/
|
|
17
|
+
export type FieldPolicyAction = "allow" | "redact" | "tokenize" | "deny";
|
|
18
|
+
export interface FieldPolicyDecision {
|
|
19
|
+
readonly action: FieldPolicyAction;
|
|
20
|
+
/** Bounded reason recorded in audit redaction lists; never includes values. */
|
|
21
|
+
readonly reason?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface FieldPolicyInput {
|
|
24
|
+
/** Dot/bracket path from the value root, e.g. `user.credentials[2].apiKey`. */
|
|
25
|
+
readonly path: string;
|
|
26
|
+
/** Boundary destination: prompt, tool, artifact, audit, telemetry, persistence, export, ... */
|
|
27
|
+
readonly destination: string;
|
|
28
|
+
/** Explicit caller-assigned label from `labelFor`; undefined = unknown. */
|
|
29
|
+
readonly label?: string;
|
|
30
|
+
readonly kind: "string" | "number" | "boolean" | "null" | "array" | "object";
|
|
31
|
+
readonly tenantId?: string;
|
|
32
|
+
readonly direction: "inbound" | "outbound";
|
|
33
|
+
readonly purpose?: string;
|
|
34
|
+
}
|
|
35
|
+
export type FieldPolicy = (input: FieldPolicyInput) => FieldPolicyDecision;
|
|
36
|
+
export interface ApplyFieldPolicyOptions {
|
|
37
|
+
readonly destination: string;
|
|
38
|
+
readonly direction?: "inbound" | "outbound";
|
|
39
|
+
readonly tenantId?: string;
|
|
40
|
+
readonly purpose?: string;
|
|
41
|
+
/** Explicit key→label hints owned by the boundary; no automatic discovery. */
|
|
42
|
+
readonly labelFor?: (key: string, path: string) => string | undefined;
|
|
43
|
+
/** Called for every non-allow decision with {path, reason}; used by audit adapters. */
|
|
44
|
+
readonly onRedact?: (path: string, reason: string) => void;
|
|
45
|
+
readonly maxDepth?: number;
|
|
46
|
+
readonly maxKeys?: number;
|
|
47
|
+
readonly maxChars?: number;
|
|
48
|
+
/** Wall-clock budget for the whole walk; a slow policy trips it (fail closed). */
|
|
49
|
+
readonly maxPolicyMs?: number;
|
|
50
|
+
/** Deterministic token prefix (stable across runs; safe for audit chains). */
|
|
51
|
+
readonly tokenPrefix?: string;
|
|
52
|
+
}
|
|
53
|
+
export declare class FieldPolicyError extends Error {
|
|
54
|
+
readonly code = "ERR_PRISM_FIELD_POLICY";
|
|
55
|
+
readonly path: string;
|
|
56
|
+
constructor(path: string, message: string);
|
|
57
|
+
}
|
|
58
|
+
export declare const FIELD_POLICY_LIMITS: Readonly<{
|
|
59
|
+
readonly maxDepth: 32;
|
|
60
|
+
readonly maxKeys: 10000;
|
|
61
|
+
readonly maxChars: 1000000;
|
|
62
|
+
readonly maxPolicyMs: 5000;
|
|
63
|
+
readonly tokenPrefix: "tok_";
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Applies `policy` to every field of a JSON-like value.
|
|
67
|
+
*
|
|
68
|
+
* Decisions: `allow` keeps the value; `redact` replaces string leaves with
|
|
69
|
+
* `[REDACTED]` while preserving container shape; `tokenize` replaces string
|
|
70
|
+
* leaves with a deterministic token; `deny` replaces the value with `[DENIED]`.
|
|
71
|
+
* Unknown labels fail closed under the protected default. Hostile values
|
|
72
|
+
* (cycles, unsupported types, over-budget walks) throw `FieldPolicyError`
|
|
73
|
+
* instead of stringifying guesses. The input is never mutated; only fields the
|
|
74
|
+
* policy changed are allocated.
|
|
75
|
+
*/
|
|
76
|
+
export declare function applyFieldPolicy<T>(value: T, policy: FieldPolicy, options: ApplyFieldPolicyOptions): T;
|
|
77
|
+
export interface ProtectedFieldPolicyOptions {
|
|
78
|
+
/** Labels allowed to cross outbound/persisted boundaries unchanged. */
|
|
79
|
+
readonly publicLabels?: readonly string[];
|
|
80
|
+
/** Labels denied with the given reason; default `secret` and `financial`. */
|
|
81
|
+
readonly deniedLabels?: Readonly<Record<string, string>>;
|
|
82
|
+
/** Labels redacted with the given reason; default `personal`. */
|
|
83
|
+
readonly redactedLabels?: Readonly<Record<string, string>>;
|
|
84
|
+
/** Labels tokenized; default none. */
|
|
85
|
+
readonly tokenizedLabels?: Readonly<Record<string, string>>;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Fail-closed default for the protected profile (frozen behavior):
|
|
89
|
+
* unknown labels are denied on outbound boundaries and allowed inbound;
|
|
90
|
+
* `secret`/`financial` denied, `personal` redacted, listed public labels
|
|
91
|
+
* allowed. Labels are never auto-discovered — `labelFor` decides them.
|
|
92
|
+
*/
|
|
93
|
+
export declare function createProtectedFieldPolicy(options?: ProtectedFieldPolicyOptions): FieldPolicy;
|
|
94
|
+
/** Identity policy: every field allowed (explicit override for trusted marks). */
|
|
95
|
+
export declare const ALLOW_FIELD_POLICY: FieldPolicy;
|
|
96
|
+
export interface AuditFieldRedaction {
|
|
97
|
+
readonly path: string;
|
|
98
|
+
readonly reason: string;
|
|
99
|
+
}
|
|
100
|
+
/** Structural match for `AuditRedactionPolicy` in @arnilo/prism-policy. */
|
|
101
|
+
export interface AuditFieldRedactorLike {
|
|
102
|
+
apply(record: Readonly<Record<string, unknown>>): {
|
|
103
|
+
record: Readonly<Record<string, unknown>>;
|
|
104
|
+
redactions?: readonly AuditFieldRedaction[];
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export interface AuditFieldRedactorOptions {
|
|
108
|
+
readonly tenantId?: string;
|
|
109
|
+
readonly purpose?: string;
|
|
110
|
+
readonly labelFor?: (key: string, path: string) => string | undefined;
|
|
111
|
+
/** Default true; denial instead would fail export (protected profile fails closed). */
|
|
112
|
+
readonly collectProvenance?: boolean;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Adapts a `FieldPolicy` to the audit-export redaction hook. Transformation
|
|
116
|
+
* runs BEFORE canonical hashing so the exported chain verifies exactly.
|
|
117
|
+
* Only `{path, reason}` provenance survives; values never echo into the list.
|
|
118
|
+
*/
|
|
119
|
+
export declare function createAuditFieldRedactor(policy: FieldPolicy, options?: AuditFieldRedactorOptions): AuditFieldRedactorLike;
|