@arnilo/prism 0.0.27 → 0.1.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 +29 -0
- package/dist/artifacts.d.ts +54 -0
- package/dist/artifacts.js +20 -0
- package/dist/index.d.ts +15 -15
- package/dist/index.js +8 -8
- package/dist/tool-effects.js +18 -4
- package/dist/tool-result-fold.js +15 -3
- package/docs/0.1.0-readiness.md +108 -63
- package/docs/agent-identity.md +33 -0
- package/docs/credential-storage.md +2 -0
- package/docs/enterprise-postgres-state.md +1 -0
- package/docs/host-security.md +11 -2
- package/docs/index.md +10 -9
- package/docs/mcp-tools.md +37 -0
- package/docs/migration.md +37 -0
- package/docs/openapi-tools.md +56 -0
- package/docs/performance.md +99 -0
- package/docs/policy-and-audit.md +31 -0
- package/docs/public-contracts.md +47 -0
- package/docs/release-and-install.md +129 -14
- package/docs/tools.md +1 -0
- package/docs/work-artifacts-and-review.md +3 -1
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.0] - 2026-08-09
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
- **Release 0.1.0 (Phase 12, plan 012)** is the release-candidate hardening cut of the 0.0.28 graph: no new packages, public exports, schema migrations, or runtime dependencies (frozen in `scripts/phase12-freeze-manifest.json`; deviations require a recorded plan 012 Task 0 entry). Store compatibility with 0.0.28: **compatible, no migration**; the `0.0.17 → 0.1.0` upgrade matrix in [docs/migration.md](docs/migration.md) documents every intermediate line (compatible / tested migration / tested refusal).
|
|
7
|
+
- **Compatibility matrix machine-checked** (plan 012 Task 1): [docs/release-and-install.md](docs/release-and-install.md) publishes the supported/measured matrix (Node 20+24, PostgreSQL 16, linux-x64, five protocol SDK pins, security-support boundary); release.yml CI legs match it, asserted by tripwires.
|
|
8
|
+
- **Upgrade/migration + release-integrity repair** (Task 2): per-release store-compatibility sections for 0.0.18–0.1.0; release-evidence matrix with tag presence + evidence pointers for every release (0.0.21 and 0.0.28 are the documented untagged lines); persistence schema contract reconciled to version 7 (7 checksummed migrations) across freeze manifest, docs, and tests; postgres upgrade-chain/refusal tests.
|
|
9
|
+
- **Packed-install e2e journeys** (Task 3): `scripts/e2e-enterprise-journey.test.mjs` + `scripts/e2e-coding-journey.test.mjs` install the exact packed manifest graph into fresh consumers (never workspace paths) and run the enterprise journey (OIDC → OPA ledger → durable events → batched approval → OpenAPI idempotent side effect → artifact signed delivery) and coding journey (ACP editor session → bounded coding tools → sandboxed process session → forge handoff) against public exports only.
|
|
10
|
+
- **Protected restart-recovery evidence** (Task 4): `scripts/phase12-restart-recovery.test.mjs` (in `npm run test:postgres`) proves multi-replica kill/resume with no event gap/duplicate, tool-effect unknown-outcome fail-closed replay, database-restart-during-streaming catch-up, and reconnect/contention p95 against frozen ceilings; missing `PRISM_TEST_POSTGRES_URL` is a named blocked gate.
|
|
11
|
+
- **Capacity envelopes frozen** (Task 5): `scripts/benchmark-0.1.0.mjs` composes the six phase benchmark scripts into one envelope report (`scripts/benchmark-0.1.0.json` — 24 network-free + 16 protected rows) gated on every `npm test` against the freeze-manifest ceilings; [docs/performance.md](docs/performance.md) publishes the full table with methodology and pass/fail thresholds. Budget baselines regenerated once via freeze deviation dev-001 (evidence scripts added ~35 kB to the root tarball; tolerance unchanged).
|
|
12
|
+
- **Security policy hardened** (Task 6): `npm audit --audit-level=moderate` enforced in `security.yml` and `release.yml` (0 vulnerabilities at every severity for the 0.1.0 tree, 317 locked deps); named threat-suites leg `npm run security:threat-suites` (Phase 8–11 conformance, 28/28); supply-chain negative fixtures (unexpected file types/credential material in tarballs, suppressed-provenance detection in dry-run args); live-canary blocked-gate semantics documented.
|
|
13
|
+
- **Docs freeze + version bump** (Task 7): `docs/0.1.0-readiness.md` current-line table at 0.1.0 with per-gate 0.1.0-tree evidence and the explicit remaining operator list for 1.0; `docs/public-contracts.md` publishes the frozen 0.1.x contract (declaration/exports surface, events, protocol payloads, migration checksums, additive-only patch promise); every public page, package README, and changelog verified consistent with 0.1.0 behavior (docs tripwires green); all 48 manifests + lockfile at exact 0.1.0 via scripted bump; publish dry-run verified deterministic (49/49 twice, byte-identical); signed-tag + npm OIDC publication documented as explicit operator steps with rollback notes ([docs/release-and-install.md](docs/release-and-install.md) `0.1.0 publish handoff`).
|
|
14
|
+
|
|
15
|
+
## [0.0.28] - 2026-08-08
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- Phase 11 enterprise adapter seams (plan 011), all optional and fail-closed; hosts that wire none keep exact prior behavior.
|
|
19
|
+
- `@arnilo/prism-credentials-node/oidc`: `createOidcIdentityVerifier` — OIDC/JWKS identity verification over native WebCrypto (RS256/ES256), host-pinned SSRF-checked JWKS URL with bounded single-flight cache and exactly one refetch on unknown `kid`, bounded clock skew/claims, host revocation callback; fail-closed `IdentityError` reasons `ERR_PRISM_OIDC_*`.
|
|
20
|
+
- `@arnilo/prism-policy/opa`: `createOpaPolicyEvaluator` — OPA REST decision adapter for the durable Phase 6 policy ledger; default deny on timeout/transport failure (`onFailure`), bounded input/response/retries, redacted mapped reasons/evidence, optional bundle-revision pin (`requirePolicyVersion`); frozen codes `ERR_PRISM_OPA_*`.
|
|
21
|
+
- MCP OAuth (0.0.28) in `@arnilo/prism-mcp`: `createMcpOAuthTransport`/`createMcpOAuthFetch`/`createMcpClientAuth` reusing `@modelcontextprotocol/sdk` auth helpers — RFC 9728/8414 discovery with bounded SSRF-checked zero-redirect fetch, PKCE interactive flow, RFC 8707 resource-bound audience validation (confused-deputy defense), RFC 7009 revocation, host-owned `McpClientAuthState` persistence; server side gains `protectedResource` metadata route + `WWW-Authenticate` challenges. Frozen codes `ERR_PRISM_MCP_OAUTH_*`.
|
|
22
|
+
- New package `@arnilo/prism-openapi-tools`: `createOpenApiTools` compiles host-listed OpenAPI 3.1 `operationId`s at setup into bounded `ToolDefinition`s — pinned origin (drift fails closed), resolved/bounded schemas, mutation operations get `external_mutation` + `idempotency: required` (approval/idempotency via the core run loop), bounded body/response/retries/pagination, host credential resolver, untrusted redacted output. Frozen codes `ERR_PRISM_OPENAPI_*`.
|
|
23
|
+
- Artifact body contract + reference adapter: core `ArtifactBodyStore`/`ArtifactBodyRef`/`ArtifactBodyStoreError` (storage-free types, frozen `ERR_PRISM_ARTIFACT_BODY_*`), optional `size` on `ArtifactRevision`, `createArtifactService` `bodies` option with presigned `url` on delivery links (fail closed without recorded size); `@arnilo/prism-server/artifact-bodies` ships `createS3ArtifactBodyStore` — hand-rolled SigV4 over native fetch/WebCrypto, verified hash/size/mime on put/get, legal-hold-aware delete, bounded presign TTL, optional host KMS callback (`ERR_PRISM_S3_*`).
|
|
24
|
+
- Phase 11 evidence: network-free `scripts/phase11-conformance.test.mjs` (in `npm test`: composed OIDC → OPA ledger → MCP OAuth tool → OpenAPI side effect → artifact body + signed delivery; adapter-absent baseline; hostile origins and limit ladder; redaction sweep), `scripts/benchmark-0.0.28.mjs` + `scripts/benchmark-0.0.28.json` evidence, `scripts/budgets.json` `phase11` gate, `scripts/phase11-freeze-manifest.json` schema-gated by `scripts/phase11-freeze.test.mjs`.
|
|
25
|
+
- Docs: new [docs/openapi-tools.md](docs/openapi-tools.md); OIDC verifier section in [docs/agent-identity.md](docs/agent-identity.md); OPA section in [docs/policy-and-audit.md](docs/policy-and-audit.md); MCP OAuth section in [docs/mcp-tools.md](docs/mcp-tools.md); artifact body store section in [docs/work-artifacts-and-review.md](docs/work-artifacts-and-review.md); migration `0.0.27 → 0.0.28`; Phase 11 p95 evidence in [docs/performance.md](docs/performance.md); protected live-canary slot recorded as a blocked release gate in [docs/0.1.0-readiness.md](docs/0.1.0-readiness.md).
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
- `createPrismMcpWebHandler` accepts `McpServer | (() => McpServer | Promise<McpServer>)`; stateless operation now requires a factory (a shared stateless transport threw on the second request). SSE (`text/event-stream`) responses are relayed instead of buffered, so streaming responses no longer stall the handler.
|
|
29
|
+
- Publishable graph stays **48** manifests (includes the new `@arnilo/prism-openapi-tools`); core remains dependency-free and every new seam is opt-in.
|
|
30
|
+
- Version bumped to exact `0.0.28` across the root, all workspace manifests, and the lockfile; compatibility baselines refreshed (additive surfaces only).
|
|
31
|
+
|
|
3
32
|
## [0.0.27] - 2026-08-07
|
|
4
33
|
|
|
5
34
|
### Added
|
package/dist/artifacts.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export interface ArtifactRevision {
|
|
|
24
24
|
readonly mime: string;
|
|
25
25
|
/** Host-computed content hash for integrity compare. */
|
|
26
26
|
readonly hash: string;
|
|
27
|
+
/** Expected body byte length; required when a blob store is wired for delivery. */
|
|
28
|
+
readonly size?: number;
|
|
27
29
|
readonly changeNote?: string;
|
|
28
30
|
/** Run that produced this revision, if any. */
|
|
29
31
|
readonly producerRunId?: string;
|
|
@@ -65,6 +67,58 @@ export interface ArtifactDeliveryToken extends OwnershipScope {
|
|
|
65
67
|
readonly issuedAt: string;
|
|
66
68
|
readonly expiresAt: string;
|
|
67
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Opaque, ownership-scoped reference to one artifact body revision. The store derives its
|
|
72
|
+
* internal object key from these fields; hosts never see or store bucket/path/key internals.
|
|
73
|
+
* `size` is the expected byte length and `hash` the expected SHA-256 hex; both are verified
|
|
74
|
+
* on every put/get (fail closed on mismatch).
|
|
75
|
+
*/
|
|
76
|
+
export interface ArtifactBodyRef extends OwnershipScope {
|
|
77
|
+
readonly artifactId: string;
|
|
78
|
+
readonly threadId: string;
|
|
79
|
+
readonly version: number;
|
|
80
|
+
readonly mime: string;
|
|
81
|
+
/** Expected body byte length; verified against the actual body on put and get. */
|
|
82
|
+
readonly size: number;
|
|
83
|
+
/** Expected SHA-256 hex digest of the body; verified on put and get. */
|
|
84
|
+
readonly hash: string;
|
|
85
|
+
}
|
|
86
|
+
/** Transfer options shared by put/get/delete. */
|
|
87
|
+
export interface ArtifactBodyTransferOptions {
|
|
88
|
+
readonly signal?: AbortSignal;
|
|
89
|
+
}
|
|
90
|
+
/** Presign options: bounded TTL for the returned delivery URL. */
|
|
91
|
+
export interface ArtifactBodyPresignOptions extends ArtifactBodyTransferOptions {
|
|
92
|
+
/** Bounded by the store's presignTtlMs cap; defaults to the store default. */
|
|
93
|
+
readonly ttlMs?: number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Host-owned blob storage contract (Phase 11 / 0.0.28). Core exports the contract only;
|
|
97
|
+
* the reference S3-compatible adapter lives in `@arnilo/prism-server/artifact-bodies`.
|
|
98
|
+
* Implementations must verify ownership on every operation, verify hash/size/MIME on
|
|
99
|
+
* put/get (fail closed), refuse delete under legal hold, and never disclose bucket/path/key
|
|
100
|
+
* in errors, telemetry, or records. All failures surface typed errors, never silent success.
|
|
101
|
+
*/
|
|
102
|
+
export interface ArtifactBodyStore {
|
|
103
|
+
/** Store a body; verifies size + SHA-256 hash against the ref before persisting. */
|
|
104
|
+
put(ref: ArtifactBodyRef, body: Uint8Array | ReadableStream<Uint8Array>, options?: ArtifactBodyTransferOptions): Promise<void>;
|
|
105
|
+
/** Retrieve a body; verifies size, MIME, and SHA-256 hash before returning bytes. */
|
|
106
|
+
get(ref: ArtifactBodyRef, options?: ArtifactBodyTransferOptions): Promise<ReadableStream<Uint8Array>>;
|
|
107
|
+
/** Delete a body; idempotent. Refuses while the resource is under legal hold. */
|
|
108
|
+
delete(ref: ArtifactBodyRef, options?: ArtifactBodyTransferOptions): Promise<void>;
|
|
109
|
+
/** Return a bounded-TTL, single-object delivery URL (never a bucket listing or wildcard). */
|
|
110
|
+
presign(ref: ArtifactBodyRef, options?: ArtifactBodyPresignOptions): Promise<string>;
|
|
111
|
+
}
|
|
112
|
+
/** Frozen ArtifactBodyStore failure reasons (fail-closed posture). */
|
|
113
|
+
export type ArtifactBodyErrorCode = "OWNERSHIP" | "HASH_MISMATCH" | "SIZE_MISMATCH" | "MIME_MISMATCH" | "HELD" | "STORE";
|
|
114
|
+
/** Well-known error codes for ArtifactBodyStore failures. */
|
|
115
|
+
export declare const ARTIFACT_BODY_ERROR_CODES: Readonly<Record<ArtifactBodyErrorCode, `ERR_PRISM_ARTIFACT_BODY_${ArtifactBodyErrorCode}`>>;
|
|
116
|
+
/** Typed ArtifactBodyStore failure; `code` is one of the frozen ERR_PRISM_ARTIFACT_BODY_* codes. */
|
|
117
|
+
export declare class ArtifactBodyStoreError extends Error {
|
|
118
|
+
readonly reason: ArtifactBodyErrorCode;
|
|
119
|
+
readonly code: `ERR_PRISM_ARTIFACT_BODY_${ArtifactBodyErrorCode}`;
|
|
120
|
+
constructor(message: string, reason: ArtifactBodyErrorCode);
|
|
121
|
+
}
|
|
68
122
|
/** Well-known checkpoint namespace for artifact records. */
|
|
69
123
|
export declare const ARTIFACT_CHECKPOINT_NAMESPACE = "prism.artifact";
|
|
70
124
|
export declare class ArtifactError extends Error {
|
package/dist/artifacts.js
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
/** Well-known error codes for ArtifactBodyStore failures. */
|
|
2
|
+
export const ARTIFACT_BODY_ERROR_CODES = {
|
|
3
|
+
OWNERSHIP: "ERR_PRISM_ARTIFACT_BODY_OWNERSHIP",
|
|
4
|
+
HASH_MISMATCH: "ERR_PRISM_ARTIFACT_BODY_HASH_MISMATCH",
|
|
5
|
+
SIZE_MISMATCH: "ERR_PRISM_ARTIFACT_BODY_SIZE_MISMATCH",
|
|
6
|
+
MIME_MISMATCH: "ERR_PRISM_ARTIFACT_BODY_MIME_MISMATCH",
|
|
7
|
+
HELD: "ERR_PRISM_ARTIFACT_BODY_HELD",
|
|
8
|
+
STORE: "ERR_PRISM_ARTIFACT_BODY_STORE",
|
|
9
|
+
};
|
|
10
|
+
/** Typed ArtifactBodyStore failure; `code` is one of the frozen ERR_PRISM_ARTIFACT_BODY_* codes. */
|
|
11
|
+
export class ArtifactBodyStoreError extends Error {
|
|
12
|
+
reason;
|
|
13
|
+
code;
|
|
14
|
+
constructor(message, reason) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.reason = reason;
|
|
17
|
+
this.name = "ArtifactBodyStoreError";
|
|
18
|
+
this.code = ARTIFACT_BODY_ERROR_CODES[reason];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
1
21
|
/** Well-known checkpoint namespace for artifact records. */
|
|
2
22
|
export const ARTIFACT_CHECKPOINT_NAMESPACE = "prism.artifact";
|
|
3
23
|
export class ArtifactError extends Error {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export { resolveAgentDefinition } from "./agent-definitions.js";
|
|
2
|
+
export type { AgentEventSourceErrorCode } from "./agent-event-source.js";
|
|
3
|
+
export { AgentEventSourceError, createMemoryAgentEventSource } from "./agent-event-source.js";
|
|
2
4
|
export { dispatchToolCallsInOrder, generateValidateReviseLoop, isAgentLoopOptions, resolveLoop, resolveToolConcurrency, singleShotLoop, } from "./agent-loops.js";
|
|
3
5
|
export type { AgentRunLifecycle, AgentRunLifecycleAgent, AgentRunLifecycleOptions, AgentRunLifecycleRequest, AgentRunLifecycleStreamRequest, } from "./agent-run-lifecycle.js";
|
|
4
6
|
export { createAgentRunLifecycle } from "./agent-run-lifecycle.js";
|
|
5
7
|
export type { PendingToolCall, StoredAgentRunState } from "./agent-run-state.js";
|
|
6
8
|
export { AGENT_RUN_STATE_NAMESPACE, AGENT_RUN_STATE_SCHEMA_VERSION, agentFingerprint, DEFAULT_MAX_AGENT_RUN_STATE_BYTES, HARD_MAX_AGENT_RUN_STATE_BYTES, loadAgentRunState, } from "./agent-run-state.js";
|
|
7
9
|
export { createAgent, createAgentSession, resumeAgentRun, resumeAgentRunStream } from "./agents.js";
|
|
8
|
-
export type { ArtifactApproval, ArtifactApprovalState, ArtifactCitation, ArtifactDecisionState, ArtifactDeliveryToken, ArtifactRecord, ArtifactRevision, } from "./artifacts.js";
|
|
9
|
-
export { ARTIFACT_CHECKPOINT_NAMESPACE, ArtifactError, artifactApprovalState, artifactCheckpointKey, } from "./artifacts.js";
|
|
10
|
+
export type { ArtifactApproval, ArtifactApprovalState, ArtifactBodyErrorCode, ArtifactBodyPresignOptions, ArtifactBodyRef, ArtifactBodyStore, ArtifactBodyTransferOptions, ArtifactCitation, ArtifactDecisionState, ArtifactDeliveryToken, ArtifactRecord, ArtifactRevision, } from "./artifacts.js";
|
|
11
|
+
export { ARTIFACT_BODY_ERROR_CODES, ARTIFACT_CHECKPOINT_NAMESPACE, ArtifactBodyStoreError, ArtifactError, artifactApprovalState, artifactCheckpointKey, } from "./artifacts.js";
|
|
10
12
|
export type { ApplyCacheControlOptions, CacheControlledContentBlock, CacheControlledMessage, CacheControlValue, CacheUsageReport, } from "./cache-helpers.js";
|
|
11
13
|
export { applyCacheControl, cacheHitRate, cacheSavings, cacheUsageReport, mapCacheRetention, sanitizeCacheKey } from "./cache-helpers.js";
|
|
12
14
|
export type { MemoryCheckpointStoreOptions } from "./checkpoints.js";
|
|
@@ -20,8 +22,8 @@ export { assertDeclaredMediaTypeMatches, assertMediaBlocksWithinBounds, assertMe
|
|
|
20
22
|
export type { ContextBudget, ContextBudgetMessageGroups, ContextBudgetOmission, ContextBudgetOmissionKind, ContextBudgetReport, } from "./context-budget.js";
|
|
21
23
|
export { applyContextBudget, CONTEXT_BUDGET_ERROR_CODE, CONTEXT_BUDGET_REPORT_METADATA_KEY, ContextBudgetError, DEFAULT_MAX_CONTEXT_BUDGET_OMISSIONS, estimateAssemblyTokens, estimateMessageBytes, estimateMessageTokens, estimateTextBytes, estimateTextTokens, getContextBudgetReport, HARD_MAX_CONTEXT_BUDGET_BYTES, HARD_MAX_CONTEXT_BUDGET_OMISSIONS, HARD_MAX_CONTEXT_BUDGET_TOKENS, isContextBudgetError, resolveContextBudget, } from "./context-budget.js";
|
|
22
24
|
export type * from "./contracts.js";
|
|
23
|
-
export type { ApprovalOutcome, DecisionScope, NestedRunApproval, NestedRunOutcome, NestedRunRef, PendingDecision, PendingDecisionKind, ProviderResolver,
|
|
24
|
-
export { AgentDecisionError, AgentDelegationSuspendedError, AgentLoopStateError,
|
|
25
|
+
export type { ApprovalOutcome, DecisionScope, NestedRunApproval, NestedRunOutcome, NestedRunRef, PendingDecision, PendingDecisionKind, ProviderResolver, RealtimeCaps, RealtimeEvent, RealtimeSession, RealtimeSessionFactory, RealtimeSessionOptions, ResumeNestedRun, RunDecision, RunLimitCounters, RunLimitName, SecureAgentOptions, StickyDecision, ToolCallAuthority, ToolEffectClassifier, ToolEffectDeclaration, ToolEffectIdempotency, ToolEffectKey, ToolEffectKind, ToolEffectRecord, ToolEffectStatus, ToolEffectStore, ToolEffectTransition, ToolElicitationRequest, } from "./contracts.js";
|
|
26
|
+
export { AgentDecisionError, AgentDelegationSuspendedError, AgentLoopStateError, AgentRunError, AgentRunStateError, assertSessionMetadataKey, DEFAULT_MAX_PENDING_DECISIONS, DEFAULT_MAX_PENDING_STEER_BYTES, DEFAULT_MAX_PENDING_STEERS, DEFAULT_MAX_SESSION_SEARCH_CURSOR_BYTES, DEFAULT_MAX_SESSION_SEARCH_FTS_CANDIDATES, DEFAULT_MAX_SESSION_SEARCH_LINEAR_BYTES, DEFAULT_MAX_SESSION_SEARCH_LINEAR_ENTRIES, DEFAULT_MAX_SESSION_SEARCH_LINEAR_SESSIONS, DEFAULT_MAX_SESSION_SEARCH_QUERY_BYTES, DEFAULT_MAX_SESSION_SEARCH_SNIPPET_BYTES, DEFAULT_MAX_STICKY_DECISIONS, DEFAULT_SESSION_SEARCH_LIMIT, HARD_MAX_ACTION_CONSTRAINT_BYTES, HARD_MAX_ACTION_CONSTRAINTS, HARD_MAX_DECISION_REASON_BYTES, HARD_MAX_ELICITATION_BYTES, HARD_MAX_PENDING_DECISIONS, HARD_MAX_PENDING_STEER_BYTES, HARD_MAX_PENDING_STEERS, HARD_MAX_SESSION_SEARCH_CURSOR_BYTES, HARD_MAX_SESSION_SEARCH_FTS_CANDIDATES, HARD_MAX_SESSION_SEARCH_LIMIT, HARD_MAX_SESSION_SEARCH_LINEAR_BYTES, HARD_MAX_SESSION_SEARCH_LINEAR_ENTRIES, HARD_MAX_SESSION_SEARCH_LINEAR_SESSIONS, HARD_MAX_SESSION_SEARCH_QUERY_BYTES, HARD_MAX_SESSION_SEARCH_SNIPPET_BYTES, HARD_MAX_STICKY_DECISIONS, isSessionAppendConflict, isSessionEntryKind, isSessionSearchUnsupported, MAX_ACTION_CONSTRAINT_BYTES, MAX_ACTION_CONSTRAINTS, MAX_ATTRIBUTION_DEPTH, MAX_DECISION_REASON_BYTES, MAX_ELICITATION_BYTES, resolveSessionSearchQuery, SESSION_APPEND_CONFLICT_CODE, SESSION_ENTRY_KINDS, SESSION_ENTRY_SCHEMA_VERSION, SESSION_SEARCH_UNSUPPORTED_CODE, SESSION_SEARCH_WORKSPACE_METADATA_KEY, SessionAppendConflictError, SessionSearchUnsupportedError, } from "./contracts.js";
|
|
25
27
|
export { parseAgentFile, parseSkillFile } from "./contribution-parsing.js";
|
|
26
28
|
export type { ContributionRegistries, ContributionRegistriesOptions, ContributionRegistry, ContributionRegistryOptions, } from "./contributions.js";
|
|
27
29
|
export { createContributionRegistries, createContributionRegistry, registerDiscoveredContributions } from "./contributions.js";
|
|
@@ -31,9 +33,6 @@ export type { CredentialRecord, CredentialValueSource, MemoryCredentialStore, Re
|
|
|
31
33
|
export { createChainedCredentialResolver, createEnvCredentialResolver, createExplicitCredentialResolver, createMemoryCredentialStore, refreshOAuthCredential, resolveCredentialValue, revokeOAuthCredential, } from "./credentials.js";
|
|
32
34
|
export type { DeviceAdapter, DeviceAdmitRequest, DeviceChunkResult, DeviceConformanceResult, DeviceKind, DevicePolicyErrorCode, DevicePolicyOptions, DeviceStreamLimits, ResolvedDevicePolicy, } from "./devices.js";
|
|
33
35
|
export { acceptDeviceChunk, assertDeviceAdmit, DEFAULT_DEVICE_MAX_CHUNK_BYTES, DEFAULT_DEVICE_MAX_CONCURRENT_SESSIONS, DevicePolicyError, HARD_DEVICE_MAX_CHUNK_BYTES, HARD_DEVICE_MAX_CONCURRENT_SESSIONS, redactDeviceTelemetry, resolveDevicePolicy, runDevicePolicyConformance, } from "./devices.js";
|
|
34
|
-
export type { AgentEventSourceErrorCode } from "./agent-event-source.js";
|
|
35
|
-
export { AgentEventSourceError, createMemoryAgentEventSource } from "./agent-event-source.js";
|
|
36
|
-
export { assertAgentEventSourceConforms } from "./testing/agent-event-source-conformance.js";
|
|
37
36
|
export type { EventMultiplexer, EventMultiplexerOptions, EventOverflowInfo, EventOverflowPolicy } from "./event-multiplexer.js";
|
|
38
37
|
export { createEventMultiplexer } from "./event-multiplexer.js";
|
|
39
38
|
export type { ExecutionAction, ExecutionDecision, ExecutionPolicy, ExecutionRisk } from "./execution-policy.js";
|
|
@@ -85,25 +84,26 @@ export { assertPermission, assertTrusted, checkPermission, createStaticPermissio
|
|
|
85
84
|
export type { CreateMemorySessionStoreOptions, CreateSessionEntryOptions, MemorySessionSearchMode, SessionBranch, SessionBranchOptions, SessionContextSnapshot, } from "./session-stores.js";
|
|
86
85
|
export { createMemorySessionStore, createSessionEntry, getSessionBranchEntries, listSessionBranches, rebuildSessionContext, } from "./session-stores.js";
|
|
87
86
|
export { createChainedSettingsProvider, createStaticSettingsProvider } from "./settings.js";
|
|
88
|
-
export type { ResolveActiveSkillsOptions, SkillRegistryOptions } from "./skills.js";
|
|
89
|
-
export { createSkillRegistry, resolveActiveSkills } from "./skills.js";
|
|
90
|
-
export { createLoadedSkillSet, DEFAULT_MAX_SKILL_CATALOG_ENTRIES, DEFAULT_MAX_SKILL_DESCRIPTION_BYTES, DEFAULT_MAX_SKILL_INSTRUCTION_BYTES, EMPTY_SKILL_DESCRIPTION, HARD_MAX_SKILL_CATALOG_ENTRIES, HARD_MAX_SKILL_DESCRIPTION_BYTES, HARD_MAX_SKILL_INSTRUCTION_BYTES, isSkillDisclosureError, resolveSkillsDisclosure, SkillDisclosureError, } from "./skill-disclosure.js";
|
|
91
87
|
export type { LoadedSkillSet, SkillRenderContext, SkillsDisclosure } from "./skill-disclosure.js";
|
|
88
|
+
export { createLoadedSkillSet, DEFAULT_MAX_SKILL_CATALOG_ENTRIES, DEFAULT_MAX_SKILL_DESCRIPTION_BYTES, DEFAULT_MAX_SKILL_INSTRUCTION_BYTES, EMPTY_SKILL_DESCRIPTION, HARD_MAX_SKILL_CATALOG_ENTRIES, HARD_MAX_SKILL_DESCRIPTION_BYTES, HARD_MAX_SKILL_INSTRUCTION_BYTES, isSkillDisclosureError, resolveSkillsDisclosure, SkillDisclosureError, } from "./skill-disclosure.js";
|
|
92
89
|
export type { CreateLoadSkillToolOptions, ResolveSkillLoadOptions } from "./skill-load.js";
|
|
93
90
|
export { createLoadSkillTool, DEFAULT_LOAD_SKILL_TOOL_NAME, isSkillLoadError, MAX_LOAD_SKILL_RESULT_BYTES, resolveSkillLoad, SKILL_LOAD_ERROR_CODE, SkillLoadError, } from "./skill-load.js";
|
|
94
|
-
export {
|
|
95
|
-
export
|
|
91
|
+
export type { ResolveActiveSkillsOptions, SkillRegistryOptions } from "./skills.js";
|
|
92
|
+
export { createSkillRegistry, resolveActiveSkills } from "./skills.js";
|
|
96
93
|
export { artifactStructuredOutputRequest, assertStructuredOutputRequestSupported, DEFAULT_MAX_STRUCTURED_OUTPUT_NAME_LENGTH, DEFAULT_MAX_STRUCTURED_OUTPUT_SCHEMA_BYTES, modelSupportsStructuredOutput, resolveRunProviderOptions, StructuredOutputError, validateStructuredOutputOptions, withoutStructuredOutput, } from "./structured-output.js";
|
|
97
94
|
export type { ComposeSystemPromptOptions } from "./system-prompts.js";
|
|
98
95
|
export { composeSystemPrompt, mergeSystemPromptConfig } from "./system-prompts.js";
|
|
96
|
+
export { assertAgentEventSourceConforms } from "./testing/agent-event-source-conformance.js";
|
|
99
97
|
export type { ThinkingCompatFamily, ThinkingLevel } from "./thinking.js";
|
|
100
98
|
export { applyThinkingLevel, isThinkingLevel, normalizeThinkingLevel, THINKING_LEVELS, thinkingCompatFor, thinkingFamilyForModel, } from "./thinking.js";
|
|
99
|
+
export type { ToolEffectErrorCode } from "./tool-effects.js";
|
|
100
|
+
export { createMemoryToolEffectStore, ToolEffectError } from "./tool-effects.js";
|
|
101
|
+
export type { FoldToolResultsContext, ResolvedToolResultFoldOptions, ToolResultFoldInput, ToolResultFoldOptions, } from "./tool-result-fold.js";
|
|
102
|
+
export { DEFAULT_TOOL_RESULT_FOLD_MAX_SUMMARY_BYTES, DEFAULT_TOOL_RESULT_FOLD_MIN_AGE_TURNS, DEFAULT_TOOL_RESULT_FOLD_MIN_BYTES, foldedToolResultHeader, foldToolResultHistory, foldToolResults, formatFoldedToolResult, HARD_TOOL_RESULT_FOLD_MAX_SUMMARY_BYTES, resolveToolResultFold, TOOL_RESULT_FOLD_TURN_METADATA_KEY, } from "./tool-result-fold.js";
|
|
101
103
|
export type { DispatchToolCallOptions, ToolArgumentValidationError, ToolArgumentValidationResult, ToolArgumentValidator, ToolFilter, ToolFilterInput, ToolParameterValidatorOptions, ToolRegistryOptions, ToolValidator, } from "./tools.js";
|
|
102
104
|
export { createToolParameterValidator, createToolRegistry, dispatchToolCall, filterTools } from "./tools.js";
|
|
103
|
-
export { createMemoryToolEffectStore, ToolEffectError } from "./tool-effects.js";
|
|
104
|
-
export type { ToolEffectErrorCode } from "./tool-effects.js";
|
|
105
105
|
export type { ResolvedUseCaseModel, ResolveUseCaseModelInput, UseCaseModelBinding, } from "./use-case-model.js";
|
|
106
106
|
export { resolveUseCaseModel, resolveUseCaseModelBinding, useCaseCredentialProviderId, } from "./use-case-model.js";
|
|
107
107
|
export declare const name = "prism";
|
|
108
|
-
export declare const version = "0.0
|
|
108
|
+
export declare const version = "0.1.0";
|
|
109
109
|
export declare const description = "Agent harness for AI providers, agents, sessions, and tools.";
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
export { resolveAgentDefinition } from "./agent-definitions.js";
|
|
2
|
+
export { AgentEventSourceError, createMemoryAgentEventSource } from "./agent-event-source.js";
|
|
2
3
|
export { dispatchToolCallsInOrder, generateValidateReviseLoop, isAgentLoopOptions, resolveLoop, resolveToolConcurrency, singleShotLoop, } from "./agent-loops.js";
|
|
3
4
|
export { createAgentRunLifecycle } from "./agent-run-lifecycle.js";
|
|
4
5
|
export { AGENT_RUN_STATE_NAMESPACE, AGENT_RUN_STATE_SCHEMA_VERSION, agentFingerprint, DEFAULT_MAX_AGENT_RUN_STATE_BYTES, HARD_MAX_AGENT_RUN_STATE_BYTES, loadAgentRunState, } from "./agent-run-state.js";
|
|
5
6
|
export { createAgent, createAgentSession, resumeAgentRun, resumeAgentRunStream } from "./agents.js";
|
|
6
|
-
export { ARTIFACT_CHECKPOINT_NAMESPACE, ArtifactError, artifactApprovalState, artifactCheckpointKey, } from "./artifacts.js";
|
|
7
|
+
export { ARTIFACT_BODY_ERROR_CODES, ARTIFACT_CHECKPOINT_NAMESPACE, ArtifactBodyStoreError, ArtifactError, artifactApprovalState, artifactCheckpointKey, } from "./artifacts.js";
|
|
7
8
|
export { applyCacheControl, cacheHitRate, cacheSavings, cacheUsageReport, mapCacheRetention, sanitizeCacheKey } from "./cache-helpers.js";
|
|
8
9
|
export { CHECKPOINT_CONFLICT_CODE, CheckpointConflictError, createMemoryCheckpointStore } from "./checkpoints.js";
|
|
9
10
|
export { createDefaultCompactionStrategy, isCompactionEntryData } from "./compaction.js";
|
|
10
11
|
export { assertJsonObject, isJsonObject, loadConfigLayers, mergeConfigLayers } from "./config.js";
|
|
11
12
|
export { assertDeclaredMediaTypeMatches, assertMediaBlocksWithinBounds, assertMessagesSupportModelCapabilities, assertModelSupportsContentBlocks, assertSsrfAllowedUrl, collectMessageContentBlocks, contentBlockInputModality, DEFAULT_MAX_AUDIO_DURATION_MS, DEFAULT_MAX_MEDIA_ITEM_BYTES, DEFAULT_MAX_MEDIA_ITEMS_PER_REQUEST, DEFAULT_MAX_MEDIA_REQUEST_BYTES, DEFAULT_MEDIA_FETCH_TIMEOUT_MS, loadBoundedBinaryResource, MediaContentError, MODEL_INPUT_CAPABILITIES, resolveMediaContentBlock, resolveMediaContentBlocks, sniffMediaMimeType, UnsupportedModalityError, } from "./content.js";
|
|
12
13
|
export { applyContextBudget, CONTEXT_BUDGET_ERROR_CODE, CONTEXT_BUDGET_REPORT_METADATA_KEY, ContextBudgetError, DEFAULT_MAX_CONTEXT_BUDGET_OMISSIONS, estimateAssemblyTokens, estimateMessageBytes, estimateMessageTokens, estimateTextBytes, estimateTextTokens, getContextBudgetReport, HARD_MAX_CONTEXT_BUDGET_BYTES, HARD_MAX_CONTEXT_BUDGET_OMISSIONS, HARD_MAX_CONTEXT_BUDGET_TOKENS, isContextBudgetError, resolveContextBudget, } from "./context-budget.js";
|
|
13
|
-
export { AgentDecisionError, AgentDelegationSuspendedError, AgentLoopStateError,
|
|
14
|
+
export { AgentDecisionError, AgentDelegationSuspendedError, AgentLoopStateError, AgentRunError, AgentRunStateError, assertSessionMetadataKey, DEFAULT_MAX_PENDING_DECISIONS, DEFAULT_MAX_PENDING_STEER_BYTES, DEFAULT_MAX_PENDING_STEERS, DEFAULT_MAX_SESSION_SEARCH_CURSOR_BYTES, DEFAULT_MAX_SESSION_SEARCH_FTS_CANDIDATES, DEFAULT_MAX_SESSION_SEARCH_LINEAR_BYTES, DEFAULT_MAX_SESSION_SEARCH_LINEAR_ENTRIES, DEFAULT_MAX_SESSION_SEARCH_LINEAR_SESSIONS, DEFAULT_MAX_SESSION_SEARCH_QUERY_BYTES, DEFAULT_MAX_SESSION_SEARCH_SNIPPET_BYTES, DEFAULT_MAX_STICKY_DECISIONS, DEFAULT_SESSION_SEARCH_LIMIT, HARD_MAX_ACTION_CONSTRAINT_BYTES, HARD_MAX_ACTION_CONSTRAINTS, HARD_MAX_DECISION_REASON_BYTES, HARD_MAX_ELICITATION_BYTES, HARD_MAX_PENDING_DECISIONS, HARD_MAX_PENDING_STEER_BYTES, HARD_MAX_PENDING_STEERS, HARD_MAX_SESSION_SEARCH_CURSOR_BYTES, HARD_MAX_SESSION_SEARCH_FTS_CANDIDATES, HARD_MAX_SESSION_SEARCH_LIMIT, HARD_MAX_SESSION_SEARCH_LINEAR_BYTES, HARD_MAX_SESSION_SEARCH_LINEAR_ENTRIES, HARD_MAX_SESSION_SEARCH_LINEAR_SESSIONS, HARD_MAX_SESSION_SEARCH_QUERY_BYTES, HARD_MAX_SESSION_SEARCH_SNIPPET_BYTES, HARD_MAX_STICKY_DECISIONS, isSessionAppendConflict, isSessionEntryKind, isSessionSearchUnsupported, MAX_ACTION_CONSTRAINT_BYTES, MAX_ACTION_CONSTRAINTS, MAX_ATTRIBUTION_DEPTH, MAX_DECISION_REASON_BYTES, MAX_ELICITATION_BYTES, resolveSessionSearchQuery, SESSION_APPEND_CONFLICT_CODE, SESSION_ENTRY_KINDS, SESSION_ENTRY_SCHEMA_VERSION, SESSION_SEARCH_UNSUPPORTED_CODE, SESSION_SEARCH_WORKSPACE_METADATA_KEY, SessionAppendConflictError, SessionSearchUnsupportedError, } from "./contracts.js";
|
|
14
15
|
export { parseAgentFile, parseSkillFile } from "./contribution-parsing.js";
|
|
15
16
|
export { createContributionRegistries, createContributionRegistry, registerDiscoveredContributions } from "./contributions.js";
|
|
16
17
|
export { CONVERSATION_METADATA_KEY, ConversationError, conversationMarkerMetadata, conversationThreadFromRecord, DEFAULT_MAX_CONVERSATION_CURSOR_BYTES, decodeConversationReplayCursor, encodeConversationReplayCursor, HARD_MAX_CONVERSATION_CURSOR_BYTES, } from "./conversations.js";
|
|
17
18
|
export { createChainedCredentialResolver, createEnvCredentialResolver, createExplicitCredentialResolver, createMemoryCredentialStore, refreshOAuthCredential, resolveCredentialValue, revokeOAuthCredential, } from "./credentials.js";
|
|
18
19
|
export { acceptDeviceChunk, assertDeviceAdmit, DEFAULT_DEVICE_MAX_CHUNK_BYTES, DEFAULT_DEVICE_MAX_CONCURRENT_SESSIONS, DevicePolicyError, HARD_DEVICE_MAX_CHUNK_BYTES, HARD_DEVICE_MAX_CONCURRENT_SESSIONS, redactDeviceTelemetry, resolveDevicePolicy, runDevicePolicyConformance, } from "./devices.js";
|
|
19
|
-
export { AgentEventSourceError, createMemoryAgentEventSource } from "./agent-event-source.js";
|
|
20
|
-
export { assertAgentEventSourceConforms } from "./testing/agent-event-source-conformance.js";
|
|
21
20
|
export { createEventMultiplexer } from "./event-multiplexer.js";
|
|
22
21
|
export { applyExecutionDecision, assertExecutionAllowed, checkExecution, ExecutionDeniedError } from "./execution-policy.js";
|
|
23
22
|
export { createExtensionEventBus, createExtensionKernel } from "./extensions.js";
|
|
@@ -46,17 +45,18 @@ export { createSecureAgent } from "./secure-agent.js";
|
|
|
46
45
|
export { assertPermission, assertTrusted, checkPermission, createStaticPermissionPolicy, createStaticTrustPolicy, denialToErrorInfo, isTrusted, PermissionDeniedError, TrustDeniedError, } from "./security.js";
|
|
47
46
|
export { createMemorySessionStore, createSessionEntry, getSessionBranchEntries, listSessionBranches, rebuildSessionContext, } from "./session-stores.js";
|
|
48
47
|
export { createChainedSettingsProvider, createStaticSettingsProvider } from "./settings.js";
|
|
49
|
-
export { createSkillRegistry, resolveActiveSkills } from "./skills.js";
|
|
50
48
|
export { createLoadedSkillSet, DEFAULT_MAX_SKILL_CATALOG_ENTRIES, DEFAULT_MAX_SKILL_DESCRIPTION_BYTES, DEFAULT_MAX_SKILL_INSTRUCTION_BYTES, EMPTY_SKILL_DESCRIPTION, HARD_MAX_SKILL_CATALOG_ENTRIES, HARD_MAX_SKILL_DESCRIPTION_BYTES, HARD_MAX_SKILL_INSTRUCTION_BYTES, isSkillDisclosureError, resolveSkillsDisclosure, SkillDisclosureError, } from "./skill-disclosure.js";
|
|
51
49
|
export { createLoadSkillTool, DEFAULT_LOAD_SKILL_TOOL_NAME, isSkillLoadError, MAX_LOAD_SKILL_RESULT_BYTES, resolveSkillLoad, SKILL_LOAD_ERROR_CODE, SkillLoadError, } from "./skill-load.js";
|
|
52
|
-
export {
|
|
50
|
+
export { createSkillRegistry, resolveActiveSkills } from "./skills.js";
|
|
53
51
|
export { artifactStructuredOutputRequest, assertStructuredOutputRequestSupported, DEFAULT_MAX_STRUCTURED_OUTPUT_NAME_LENGTH, DEFAULT_MAX_STRUCTURED_OUTPUT_SCHEMA_BYTES, modelSupportsStructuredOutput, resolveRunProviderOptions, StructuredOutputError, validateStructuredOutputOptions, withoutStructuredOutput, } from "./structured-output.js";
|
|
54
52
|
export { composeSystemPrompt, mergeSystemPromptConfig } from "./system-prompts.js";
|
|
53
|
+
export { assertAgentEventSourceConforms } from "./testing/agent-event-source-conformance.js";
|
|
55
54
|
export { applyThinkingLevel, isThinkingLevel, normalizeThinkingLevel, THINKING_LEVELS, thinkingCompatFor, thinkingFamilyForModel, } from "./thinking.js";
|
|
56
|
-
export { createToolParameterValidator, createToolRegistry, dispatchToolCall, filterTools } from "./tools.js";
|
|
57
55
|
export { createMemoryToolEffectStore, ToolEffectError } from "./tool-effects.js";
|
|
56
|
+
export { DEFAULT_TOOL_RESULT_FOLD_MAX_SUMMARY_BYTES, DEFAULT_TOOL_RESULT_FOLD_MIN_AGE_TURNS, DEFAULT_TOOL_RESULT_FOLD_MIN_BYTES, foldedToolResultHeader, foldToolResultHistory, foldToolResults, formatFoldedToolResult, HARD_TOOL_RESULT_FOLD_MAX_SUMMARY_BYTES, resolveToolResultFold, TOOL_RESULT_FOLD_TURN_METADATA_KEY, } from "./tool-result-fold.js";
|
|
57
|
+
export { createToolParameterValidator, createToolRegistry, dispatchToolCall, filterTools } from "./tools.js";
|
|
58
58
|
export { resolveUseCaseModel, resolveUseCaseModelBinding, useCaseCredentialProviderId, } from "./use-case-model.js";
|
|
59
59
|
export const name = "prism";
|
|
60
|
-
export const version = "0.0
|
|
60
|
+
export const version = "0.1.0";
|
|
61
61
|
export const description = "Agent harness for AI providers, agents, sessions, and tools.";
|
|
62
62
|
//# sourceMappingURL=index.js.map
|
package/dist/tool-effects.js
CHANGED
|
@@ -74,15 +74,26 @@ export function createMemoryToolEffectStore(options = {}) {
|
|
|
74
74
|
const ttl = claimTtl(input.claimTtlMs);
|
|
75
75
|
const attempts = maxAttempts(input.maxAttempts);
|
|
76
76
|
if (!existing)
|
|
77
|
-
return {
|
|
77
|
+
return {
|
|
78
|
+
outcome: "acquired",
|
|
79
|
+
record: save(claim(input, 1, timestamp, ttl), input.identity),
|
|
80
|
+
};
|
|
78
81
|
if (existing.status === "failed_retryable" && existing.attempt < attempts) {
|
|
79
|
-
return {
|
|
82
|
+
return {
|
|
83
|
+
outcome: "acquired",
|
|
84
|
+
record: save(claim(input, existing.attempt + 1, timestamp, ttl, existing), input.identity),
|
|
85
|
+
};
|
|
80
86
|
}
|
|
81
87
|
return { outcome: "existing", record: existing };
|
|
82
88
|
},
|
|
83
89
|
async markDispatched(input) {
|
|
84
90
|
const record = requireClaim(current(input), input, ["pending"]);
|
|
85
|
-
return save({
|
|
91
|
+
return save({
|
|
92
|
+
...record,
|
|
93
|
+
status: "dispatched",
|
|
94
|
+
version: record.version + 1,
|
|
95
|
+
updatedAt: timestamp(now()),
|
|
96
|
+
}, input.identity);
|
|
86
97
|
},
|
|
87
98
|
async complete(input) {
|
|
88
99
|
const record = requireClaim(current(input), input, ["dispatched"]);
|
|
@@ -254,7 +265,10 @@ function validateReference(reference) {
|
|
|
254
265
|
}
|
|
255
266
|
function validateFailure(failure) {
|
|
256
267
|
validateText(failure.code, 128, "effect failure code");
|
|
257
|
-
return Object.freeze({
|
|
268
|
+
return Object.freeze({
|
|
269
|
+
...failure,
|
|
270
|
+
...(failure.reference === undefined ? {} : { reference: validateReference(failure.reference) }),
|
|
271
|
+
});
|
|
258
272
|
}
|
|
259
273
|
function assertRecordSize(record) {
|
|
260
274
|
void jsonSnapshot(record, MAX_RECORD_BYTES, "tool effect record");
|
package/dist/tool-result-fold.js
CHANGED
|
@@ -15,7 +15,12 @@ export function resolveToolResultFold(run, agent) {
|
|
|
15
15
|
assertPositiveInt(minAgeTurns, "minAgeTurns", 1, 1_024);
|
|
16
16
|
assertPositiveInt(minBytes, "minBytes", 1, 32 * 1024 * 1024);
|
|
17
17
|
assertPositiveInt(maxSummaryBytes, "maxSummaryBytes", 1, HARD_TOOL_RESULT_FOLD_MAX_SUMMARY_BYTES);
|
|
18
|
-
return {
|
|
18
|
+
return {
|
|
19
|
+
minAgeTurns,
|
|
20
|
+
minBytes,
|
|
21
|
+
maxSummaryBytes,
|
|
22
|
+
summarize: options.summarize,
|
|
23
|
+
};
|
|
19
24
|
}
|
|
20
25
|
/** Projection-only fold for history tool messages; does not mutate the input array. */
|
|
21
26
|
export async function foldToolResultHistory(history, options, context) {
|
|
@@ -39,7 +44,10 @@ export async function foldToolResults(results, options, context) {
|
|
|
39
44
|
return results;
|
|
40
45
|
const out = [];
|
|
41
46
|
for (const result of results) {
|
|
42
|
-
const folded = await foldToolResultValue(result, options, {
|
|
47
|
+
const folded = await foldToolResultValue(result, options, {
|
|
48
|
+
...context,
|
|
49
|
+
toolResultTurn: context.turn,
|
|
50
|
+
});
|
|
43
51
|
out.push(folded);
|
|
44
52
|
}
|
|
45
53
|
return out;
|
|
@@ -60,7 +68,11 @@ async function foldToolResultMessage(message, options, context) {
|
|
|
60
68
|
apply: (summary) => ({
|
|
61
69
|
...message,
|
|
62
70
|
content: message.content.map((part) => part.type === "tool_result"
|
|
63
|
-
? {
|
|
71
|
+
? {
|
|
72
|
+
...part,
|
|
73
|
+
result: foldedToolResultHeader(block.name, block.toolCallId, summary),
|
|
74
|
+
error: undefined,
|
|
75
|
+
}
|
|
64
76
|
: part),
|
|
65
77
|
metadata: { ...message.metadata, prismFolded: true },
|
|
66
78
|
}),
|