@arnilo/prism 0.6.0 → 0.7.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.
Files changed (129) hide show
  1. package/CHANGELOG.md +44 -5
  2. package/README.md +10 -10
  3. package/dist/agent-definitions.js +1 -0
  4. package/dist/agent-run-lifecycle.js +11 -0
  5. package/dist/agent-run-state.d.ts +6 -0
  6. package/dist/agent-run-state.js +29 -9
  7. package/dist/agent-session/session/assemble.js +33 -2
  8. package/dist/agent-session/session/persist.js +6 -2
  9. package/dist/agent-session/session/tool-round.js +1 -0
  10. package/dist/agent-session/session/types.d.ts +10 -0
  11. package/dist/agent-session/session.d.ts +14 -0
  12. package/dist/agent-session/session.js +40 -3
  13. package/dist/artifacts.d.ts +39 -1
  14. package/dist/artifacts.js +73 -0
  15. package/dist/attention-compiler.d.ts +121 -0
  16. package/dist/attention-compiler.js +479 -0
  17. package/dist/cli-init.js +20 -6
  18. package/dist/context-budget.d.ts +20 -1
  19. package/dist/context-budget.js +10 -1
  20. package/dist/contracts-core/agent.d.ts +7 -0
  21. package/dist/contracts-core/attention.d.ts +66 -0
  22. package/dist/contracts-core/attention.js +2 -0
  23. package/dist/contracts-core/compaction.d.ts +59 -0
  24. package/dist/contracts-core/compaction.js +77 -1
  25. package/dist/contracts-core/provider.d.ts +4 -0
  26. package/dist/contracts-core.d.ts +1 -0
  27. package/dist/contracts-core.js +1 -0
  28. package/dist/contracts-protocol.d.ts +29 -0
  29. package/dist/contracts-run-state.d.ts +6 -0
  30. package/dist/host-composition.d.ts +78 -0
  31. package/dist/host-composition.js +248 -0
  32. package/dist/index.d.ts +9 -6
  33. package/dist/index.js +5 -4
  34. package/dist/input.d.ts +13 -1
  35. package/dist/input.js +40 -1
  36. package/dist/secure-agent.d.ts +2 -0
  37. package/dist/secure-agent.js +6 -1
  38. package/dist/tool-result-fold.d.ts +12 -0
  39. package/dist/tool-result-fold.js +13 -6
  40. package/dist/tools.d.ts +10 -0
  41. package/dist/tools.js +41 -0
  42. package/docs/acp-agent.md +42 -11
  43. package/docs/acp.md +2 -1
  44. package/docs/ag-ui.md +5 -3
  45. package/docs/agent-definitions.md +9 -1
  46. package/docs/agent-events.md +4 -1
  47. package/docs/agent-session-runtime.md +6 -6
  48. package/docs/attention-compiler.md +272 -0
  49. package/docs/cli-rpc.md +4 -2
  50. package/docs/coding-agent-tools.md +1 -1
  51. package/docs/coding-security.md +5 -3
  52. package/docs/coding-tools.md +1 -1
  53. package/docs/coding-workspaces.md +22 -0
  54. package/docs/compaction-and-retry.md +36 -4
  55. package/docs/compaction-observational-memory.md +62 -9
  56. package/docs/context-and-skills.md +4 -2
  57. package/docs/conversations.md +1 -1
  58. package/docs/dev-inspector.md +4 -0
  59. package/docs/device-adapters.md +1 -0
  60. package/docs/document-reader.md +11 -3
  61. package/docs/documents.md +10 -2
  62. package/docs/enterprise-postgres-state.md +2 -2
  63. package/docs/evaluations.md +168 -4
  64. package/docs/execution-timeline.md +180 -0
  65. package/docs/history/0.7.0-primitive-review.md +254 -0
  66. package/docs/history/migration-0.0.md +2 -2
  67. package/docs/history/release-handoffs.md +37 -1
  68. package/docs/host-compositions.md +147 -0
  69. package/docs/hosted-sandboxes.md +94 -0
  70. package/docs/index.md +58 -39
  71. package/docs/input-and-prompt-assembly.md +1 -0
  72. package/docs/knowledge-sync.md +84 -0
  73. package/docs/language-intelligence.md +1 -1
  74. package/docs/live-testing.md +4 -1
  75. package/docs/mcp-tools.md +2 -1
  76. package/docs/memory-fabric.md +416 -0
  77. package/docs/migrate-to-0.5.md +1 -1
  78. package/docs/migrate-to-0.6.md +1 -0
  79. package/docs/migrate-to-0.7.md +345 -0
  80. package/docs/migration.md +13 -1
  81. package/docs/model-routing.md +79 -4
  82. package/docs/multi-agent-patterns.md +20 -6
  83. package/docs/observability.md +52 -1
  84. package/docs/operations.md +13 -1
  85. package/docs/options-index.md +13 -1
  86. package/docs/peer-dependencies.md +6 -4
  87. package/docs/process-sessions.md +3 -1
  88. package/docs/prompt-registry.md +1 -1
  89. package/docs/provider-caching.md +4 -2
  90. package/docs/provider-conformance.md +1 -1
  91. package/docs/provider-packages.md +22 -22
  92. package/docs/providers/bedrock.md +71 -7
  93. package/docs/providers/openai.md +1 -1
  94. package/docs/rag.md +24 -8
  95. package/docs/realtime-voice.md +87 -0
  96. package/docs/release-and-install.md +36 -34
  97. package/docs/runs-and-usage.md +3 -2
  98. package/docs/server.md +5 -3
  99. package/docs/speech.md +2 -0
  100. package/docs/supervisors.md +33 -5
  101. package/docs/testing.md +1 -1
  102. package/docs/thinking-and-reasoning.md +3 -1
  103. package/docs/tools.md +6 -5
  104. package/docs/web-tools.md +2 -1
  105. package/docs/work-artifacts-and-review.md +14 -4
  106. package/docs/work-connectors.md +3 -1
  107. package/docs/work-tools.md +14 -4
  108. package/docs/workflows.md +69 -1
  109. package/docs/working-and-semantic-memory.md +25 -14
  110. package/package.json +1 -1
  111. package/templates/README.md +2 -0
  112. package/templates/business-worker/README.md.tmpl +19 -0
  113. package/templates/business-worker/env.example.tmpl +1 -0
  114. package/templates/business-worker/gitignore.tmpl +11 -0
  115. package/templates/business-worker/manifest.json +11 -0
  116. package/templates/business-worker/package.json.tmpl +23 -0
  117. package/templates/business-worker/src/agent.ts.tmpl +92 -0
  118. package/templates/business-worker/src/index.ts.tmpl +13 -0
  119. package/templates/business-worker/src/tests/agent.test.ts.tmpl +77 -0
  120. package/templates/business-worker/tsconfig.json.tmpl +15 -0
  121. package/templates/personal-assistant/README.md.tmpl +18 -0
  122. package/templates/personal-assistant/env.example.tmpl +1 -0
  123. package/templates/personal-assistant/gitignore.tmpl +11 -0
  124. package/templates/personal-assistant/manifest.json +11 -0
  125. package/templates/personal-assistant/package.json.tmpl +23 -0
  126. package/templates/personal-assistant/src/agent.ts.tmpl +65 -0
  127. package/templates/personal-assistant/src/index.ts.tmpl +13 -0
  128. package/templates/personal-assistant/src/tests/agent.test.ts.tmpl +28 -0
  129. package/templates/personal-assistant/tsconfig.json.tmpl +15 -0
@@ -0,0 +1,248 @@
1
+ import { isAbsolute, relative } from "node:path";
2
+ import { assertIdentityActive, assertIdentityMatchesOwnership } from "./identity.js";
3
+ export class HostCompositionError extends Error {
4
+ code;
5
+ constructor(message, code = "ERR_PRISM_HOST_COMPOSITION") {
6
+ super(message);
7
+ this.code = code;
8
+ this.name = "HostCompositionError";
9
+ }
10
+ }
11
+ function resolveAgentConfig(input) {
12
+ if (!input)
13
+ return undefined;
14
+ if ("config" in input && typeof input.config === "object" && input.config !== null) {
15
+ return input.config;
16
+ }
17
+ return input;
18
+ }
19
+ function normalizeProfile(profile) {
20
+ if (!profile)
21
+ return "personal";
22
+ if (profile === "business" || profile === "business-worker" || profile === "multi-tenant-worker") {
23
+ return "business";
24
+ }
25
+ return "personal";
26
+ }
27
+ function extractTools(toolsConfig) {
28
+ if (!toolsConfig)
29
+ return [];
30
+ if (Array.isArray(toolsConfig))
31
+ return toolsConfig;
32
+ if (typeof toolsConfig.list === "function") {
33
+ return toolsConfig.list();
34
+ }
35
+ return [];
36
+ }
37
+ function sanitizeCredentialRefs(refs = [], redactor) {
38
+ const sanitized = [];
39
+ for (const ref of refs) {
40
+ if (!ref || typeof ref !== "string")
41
+ continue;
42
+ const trimmed = ref.trim();
43
+ if (!trimmed)
44
+ continue;
45
+ // Credential references must be identifier names (env vars or vault keys), never raw secrets.
46
+ if (/^(?:sk-|ghp_|ey|Bearer\s+)/i.test(trimmed)) {
47
+ sanitized.push("[REDACTED_SECRET_VALUE]");
48
+ continue;
49
+ }
50
+ if (redactor && typeof redactor.redact === "function") {
51
+ sanitized.push(redactor.redact(trimmed));
52
+ }
53
+ else {
54
+ sanitized.push(trimmed);
55
+ }
56
+ }
57
+ return Object.freeze(sanitized);
58
+ }
59
+ function isContainedPath(parent, child) {
60
+ const rel = relative(parent, child);
61
+ return !rel.startsWith("..") && !isAbsolute(rel);
62
+ }
63
+ function resolveStorage(store, checkpoints) {
64
+ const target = store ?? checkpoints;
65
+ if (!target || typeof target !== "object") {
66
+ return { kind: "none", durable: false };
67
+ }
68
+ const record = target;
69
+ const constructorName = target.constructor?.name ?? "";
70
+ const declaredKind = typeof record.kind === "string" ? record.kind.toLowerCase() : "";
71
+ // Explicit in-memory implementations are NEVER durable.
72
+ if (constructorName.includes("Memory") ||
73
+ declaredKind.includes("memory") ||
74
+ record.durable === false ||
75
+ record.durability === "ephemeral") {
76
+ return { kind: declaredKind || "memory", durable: false };
77
+ }
78
+ // Postgres, SQLite, or explicitly durable stores
79
+ if (record.durable === true ||
80
+ record.durability === "durable" ||
81
+ constructorName.includes("Postgres") ||
82
+ constructorName.includes("Sqlite") ||
83
+ declaredKind.includes("postgres") ||
84
+ declaredKind.includes("sqlite")) {
85
+ return { kind: declaredKind || constructorName.toLowerCase() || "durable", durable: true };
86
+ }
87
+ // Any store with saveCheckpoint / appendEntry / queryEntries without explicit durable: true is in-memory
88
+ if (typeof record.saveCheckpoint === "function" ||
89
+ typeof record.appendEntry === "function" ||
90
+ typeof record.queryEntries === "function" ||
91
+ typeof record.append === "function") {
92
+ return { kind: declaredKind || "memory", durable: false };
93
+ }
94
+ // Unknown store without explicit durable flag is treated as non-durable memory
95
+ return { kind: declaredKind || "memory", durable: false };
96
+ }
97
+ /**
98
+ * Inspects a host composition in an inert, bounded, and secret-redacting manner.
99
+ * Performs zero network calls by default.
100
+ */
101
+ export function inspectHostComposition(options) {
102
+ const normalizedProfile = normalizeProfile(options.profile);
103
+ const config = resolveAgentConfig(options.agent);
104
+ const redactor = options.redactor ?? config?.redactor;
105
+ // 1. Effective tools
106
+ const rawTools = extractTools(config?.tools);
107
+ const effectiveTools = rawTools.map((tool) => ({
108
+ name: tool.name,
109
+ description: tool.description,
110
+ hasParameters: Boolean(tool.parameters && Object.keys(tool.parameters).length > 0),
111
+ }));
112
+ // 2. Credential references (identifier references only, raw values redacted)
113
+ const credRefs = sanitizeCredentialRefs(options.credentialRefs, redactor);
114
+ // 3. Ownership
115
+ const rawOwnership = config?.ownership;
116
+ const ownership = {
117
+ tenantId: typeof rawOwnership?.tenantId === "string" ? rawOwnership.tenantId.trim() : undefined,
118
+ accountId: typeof rawOwnership?.accountId === "string" ? rawOwnership.accountId.trim() : undefined,
119
+ userId: typeof rawOwnership?.userId === "string" ? rawOwnership.userId.trim() : undefined,
120
+ };
121
+ // 4. Storage durability
122
+ const storage = resolveStorage(options.store, options.checkpoints ?? config?.runState?.checkpoints);
123
+ // 5. Sandbox capabilities
124
+ const workspaceRoot = options.workspaceRoot;
125
+ const sandboxRoots = options.sandboxRoots ?? [];
126
+ let isolated = true;
127
+ if (workspaceRoot && sandboxRoots.length > 0) {
128
+ for (const root of sandboxRoots) {
129
+ if (!isContainedPath(workspaceRoot, root)) {
130
+ isolated = false;
131
+ break;
132
+ }
133
+ }
134
+ }
135
+ // 6. Governance coverage
136
+ const hasValidator = Boolean((config && "validator" in config && typeof config.validator === "function") ||
137
+ (config &&
138
+ "toolArgumentValidator" in config &&
139
+ typeof config.toolArgumentValidator?.validate === "function"));
140
+ const isSecure = Boolean(config?.secure);
141
+ const governance = {
142
+ permission: Boolean(config?.permission && typeof config.permission.check === "function"),
143
+ trust: Boolean(config?.trust && typeof config.trust.check === "function"),
144
+ redactor: Boolean(redactor && typeof redactor.redact === "function"),
145
+ validator: hasValidator,
146
+ modelRouting: Boolean(options.governance?.modelRouter || config?.modelRouter),
147
+ secure: isSecure,
148
+ };
149
+ // 7. Readiness analysis
150
+ const errors = [];
151
+ const warnings = [];
152
+ // Required redactor check
153
+ if (!governance.redactor) {
154
+ errors.push("Missing required secret redactor");
155
+ }
156
+ // Required provider or model configuration
157
+ const hasProvider = Boolean(config?.provider);
158
+ const hasModel = Boolean(config?.model);
159
+ if (!hasProvider && !hasModel) {
160
+ errors.push("Missing required provider or model configuration");
161
+ }
162
+ // Ownership presence
163
+ const hasAnyOwner = Boolean(ownership.tenantId || ownership.userId || ownership.accountId);
164
+ if (!hasAnyOwner) {
165
+ errors.push("Ownership scope is required");
166
+ }
167
+ // Profile-specific readiness
168
+ if (normalizedProfile === "personal") {
169
+ if (!ownership.userId) {
170
+ errors.push("Personal composition requires userId in ownership");
171
+ }
172
+ if (!isolated) {
173
+ errors.push("Sandbox roots must be contained within workspaceRoot");
174
+ }
175
+ }
176
+ else {
177
+ // business composition
178
+ if (!ownership.tenantId) {
179
+ errors.push("Business worker requires non-empty tenantId in ownership");
180
+ }
181
+ // Verified identity verification
182
+ const identity = config?.identity;
183
+ if (identity) {
184
+ if (!identity.principal?.id || !identity.tenantId) {
185
+ errors.push("Business worker identity cannot be empty or fabricated");
186
+ }
187
+ else {
188
+ try {
189
+ assertIdentityActive(identity);
190
+ if (rawOwnership) {
191
+ assertIdentityMatchesOwnership(identity, rawOwnership);
192
+ }
193
+ }
194
+ catch (error) {
195
+ errors.push(error instanceof Error ? error.message : String(error));
196
+ }
197
+ }
198
+ }
199
+ // Storage durability verification (memory-only persistence is NOT permitted in business readiness)
200
+ if (!storage.durable) {
201
+ errors.push("Business composition requires durable storage; in-memory storage is not permitted in production readiness");
202
+ }
203
+ // Sandbox isolation verification
204
+ if (!isolated || (sandboxRoots.length > 0 && !workspaceRoot)) {
205
+ errors.push("Mixed sandbox workspace detected; business worker requires strict workspace containment");
206
+ }
207
+ // Governance coverage
208
+ if (options.governance?.supported === false) {
209
+ errors.push("Unsupported governance configuration");
210
+ }
211
+ if (!governance.permission) {
212
+ errors.push("Business composition requires a permission policy");
213
+ }
214
+ if (!governance.trust) {
215
+ errors.push("Business composition requires a trust policy");
216
+ }
217
+ }
218
+ return {
219
+ profile: normalizedProfile,
220
+ effectiveTools: Object.freeze(effectiveTools),
221
+ credentialReferences: credRefs,
222
+ ownership: Object.freeze(ownership),
223
+ storage: Object.freeze(storage),
224
+ sandbox: Object.freeze({
225
+ ...(workspaceRoot ? { workspaceRoot } : {}),
226
+ roots: Object.freeze([...sandboxRoots]),
227
+ isolated,
228
+ }),
229
+ governance: Object.freeze(governance),
230
+ readiness: Object.freeze({
231
+ ok: errors.length === 0,
232
+ errors: Object.freeze(errors),
233
+ warnings: Object.freeze(warnings),
234
+ }),
235
+ };
236
+ }
237
+ /**
238
+ * Asserts that a host composition meets all readiness requirements for its profile.
239
+ * Throws HostCompositionError on failure.
240
+ */
241
+ export function assertHostCompositionReadiness(options) {
242
+ const report = inspectHostComposition(options);
243
+ if (!report.readiness.ok) {
244
+ throw new HostCompositionError(report.readiness.errors.join("; "));
245
+ }
246
+ return report;
247
+ }
248
+ //# sourceMappingURL=host-composition.js.map
package/dist/index.d.ts CHANGED
@@ -7,8 +7,10 @@ export { createAgentRunLifecycle } from "./agent-run-lifecycle.js";
7
7
  export type { PendingToolCall, StoredAgentRunState } from "./agent-run-state.js";
8
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";
9
9
  export { createAgent, createAgentSession, resumeAgentRun, resumeAgentRunStream } from "./agents.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
+ export type { ArtifactApproval, ArtifactApprovalState, ArtifactBodyErrorCode, ArtifactBodyPresignOptions, ArtifactBodyRef, ArtifactBodyStore, ArtifactBodyTransferOptions, ArtifactCitation, ArtifactDecisionState, ArtifactDeliveryToken, ArtifactRecord, ArtifactRevision, CitationIntegrityReason, CitationIntegrityResult, CitationLiveSource, CitationSupport, } from "./artifacts.js";
11
+ export { ARTIFACT_BODY_ERROR_CODES, ARTIFACT_CHECKPOINT_NAMESPACE, ArtifactBodyStoreError, ArtifactError, approvalEvidenceIntact, artifactApprovalState, artifactCheckpointKey, checkCitationIntegrity, citationBindingDigest, HARD_CITATION_EXCERPT_BYTES, } from "./artifacts.js";
12
+ export { ATTENTION_BUDGET_ERROR_CODE, AttentionBudgetError, createAttentionCompiler, createAttentionTruncationTrigger, DEFAULT_ATTENTION_COMPACT_RATIO, DEFAULT_ATTENTION_KEEP_LAST, DEFAULT_ATTENTION_RESERVE_TOKENS, DEFAULT_ATTENTION_THINKING_KEEP_TURNS, DEFAULT_ATTENTION_TRIGGER_RATIO, DEFAULT_ATTENTION_TRUNCATION_THRESHOLD, isAttentionBudgetError, resolveAttentionReserveTokens, resolveInputCap, resolveRunAttentionCompiler, } from "./attention-compiler.js";
13
+ export type { AttentionTruncationTrigger, AttentionTruncationTriggerOptions, PersistedAttentionStickyFrontier, } from "./attention-compiler.js";
12
14
  export type { ApplyCacheControlOptions, CacheControlledContentBlock, CacheControlledMessage, CacheControlValue, CacheUsageReport, } from "./cache-helpers.js";
13
15
  export { applyCacheControl, cacheHitRate, cacheSavings, cacheUsageReport, mapCacheRetention, resolveBreakpoint, sanitizeCacheKey, systemCacheControlField, } from "./cache-helpers.js";
14
16
  export type { CacheTelemetry, CacheTelemetryOptions, CacheTelemetryReport, CacheTelemetrySample, } from "./cache-telemetry.js";
@@ -26,8 +28,8 @@ export { assertDeclaredMediaTypeMatches, assertMediaBlocksWithinBounds, assertMe
26
28
  export type { ContextBudget, ContextBudgetMessageGroups, ContextBudgetOmission, ContextBudgetOmissionKind, ContextBudgetReport, TokenEstimator, } from "./context-budget.js";
27
29
  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";
28
30
  export type * from "./contracts.js";
29
- 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";
30
- export { AgentDecisionError, AgentDelegationSuspendedError, AgentLoopStateError, AgentRunError, AgentRunStateError, assertBatchJobsSupported, assertEmbeddingsSupported, assertImageGenerationSupported, assertModerationSupported, assertSessionMetadataKey, assertSpeechSupported, assertTranscriptionSupported, assertVideoGenerationSupported, BatchJobsError, 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, DEFAULT_SNAPSHOT_CACHE_TTL_MS, EmbeddingsError, 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_SNAPSHOT_CACHE_TTL_MS, HARD_MAX_STICKY_DECISIONS, ImageGenerationError, isBatchJobTerminal, isSessionAppendConflict, isSessionEntryKind, isSessionMetadataConflict, isSessionSearchUnsupported, MAX_ACTION_CONSTRAINT_BYTES, MAX_ACTION_CONSTRAINTS, MAX_ATTRIBUTION_DEPTH, MAX_DECISION_REASON_BYTES, MAX_ELICITATION_BYTES, ModerationError, modelSupportsBatchJobs, modelSupportsEmbeddings, modelSupportsImageGeneration, modelSupportsModeration, modelSupportsSpeech, modelSupportsTranscription, modelSupportsVideoGeneration, pollBatch, resolveSessionSearchQuery, SESSION_APPEND_CONFLICT_CODE, SESSION_ENTRY_KINDS, SESSION_ENTRY_SCHEMA_VERSION, SESSION_METADATA_CONFLICT_CODE, SESSION_SEARCH_UNSUPPORTED_CODE, SESSION_SEARCH_WORKSPACE_METADATA_KEY, SessionAppendConflictError, SessionMetadataConflictError, SessionSearchUnsupportedError, SpeechError, TranscriptionError, VideoGenerationError, } from "./contracts.js";
31
+ export type { ApprovalOutcome, AttentionCompiler, AttentionCompilerContext, AttentionCompilerOptions, AttentionCompilerSetting, AttentionInputCapOptions, AttentionReport, CompactionTrigger, CompactionTriggerContext, DecisionScope, NestedRunApproval, NestedRunOutcome, NestedRunRef, PendingDecision, PendingDecisionKind, ProviderResolver, RealtimeCaps, RealtimeEvent, RealtimeSession, RealtimeSessionFactory, RealtimeSessionOptions, ResolveShouldCompactInput, ResolveShouldCompactOptions, ResumeNestedRun, RunDecision, RunLimitCounters, RunLimitName, SecureAgentOptions, StickyDecision, ToolCallAuthority, ToolEffectClassifier, ToolEffectDeclaration, ToolEffectIdempotency, ToolEffectKey, ToolEffectKind, ToolEffectRecord, ToolEffectStatus, ToolEffectStore, ToolEffectTransition, ToolElicitationRequest, } from "./contracts.js";
32
+ export { AgentDecisionError, AgentDelegationSuspendedError, AgentLoopStateError, AgentRunError, AgentRunStateError, assertBatchJobsSupported, assertCompactionTrigger, assertEmbeddingsSupported, assertImageGenerationSupported, assertModerationSupported, assertSessionMetadataKey, assertSpeechSupported, assertTranscriptionSupported, assertVideoGenerationSupported, BatchJobsError, 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, DEFAULT_SNAPSHOT_CACHE_TTL_MS, EmbeddingsError, 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_SNAPSHOT_CACHE_TTL_MS, HARD_MAX_STICKY_DECISIONS, ImageGenerationError, isBatchJobTerminal, isSessionAppendConflict, isSessionEntryKind, isSessionMetadataConflict, isSessionSearchUnsupported, MAX_ACTION_CONSTRAINT_BYTES, MAX_ACTION_CONSTRAINTS, MAX_ATTRIBUTION_DEPTH, MAX_DECISION_REASON_BYTES, MAX_ELICITATION_BYTES, ModerationError, modelSupportsBatchJobs, modelSupportsEmbeddings, modelSupportsImageGeneration, modelSupportsModeration, modelSupportsSpeech, modelSupportsTranscription, modelSupportsVideoGeneration, pollBatch, resolveSessionSearchQuery, resolveShouldCompact, SESSION_APPEND_CONFLICT_CODE, SESSION_ENTRY_KINDS, SESSION_ENTRY_SCHEMA_VERSION, SESSION_METADATA_CONFLICT_CODE, SESSION_SEARCH_UNSUPPORTED_CODE, SESSION_SEARCH_WORKSPACE_METADATA_KEY, SessionAppendConflictError, SessionMetadataConflictError, SessionSearchUnsupportedError, SpeechError, TranscriptionError, VideoGenerationError, } from "./contracts.js";
31
33
  export { parseAgentFile, parseSkillFile } from "./contribution-parsing.js";
32
34
  export type { ContributionRegistries, ContributionRegistriesOptions, ContributionRegistry, ContributionRegistryOptions, } from "./contributions.js";
33
35
  export { createContributionRegistries, createContributionRegistry, registerDiscoveredContributions } from "./contributions.js";
@@ -89,7 +91,8 @@ export type { BatchedRunLedgerOptions } from "./run-ledger.js";
89
91
  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";
90
92
  export type { RunLimitTrackerOptions } from "./run-limits.js";
91
93
  export { createRunLimitTracker, DEFAULT_RUN_LIMITS, HARD_RUN_LIMITS, RunLimitError, RunLimitTracker, resolveRunLimits, } from "./run-limits.js";
92
- export { createSecureAgent } from "./secure-agent.js";
94
+ export type { HostCompositionGovernance, HostCompositionOptions, HostCompositionProfile, HostCompositionReport, HostCompositionToolReport, } from "./secure-agent.js";
95
+ export { assertHostCompositionReadiness, createSecureAgent, HostCompositionError, inspectHostComposition, } from "./secure-agent.js";
93
96
  export type { PermissionDecision, PermissionPolicy, PermissionRequest, TrustDecision, TrustPolicy, TrustRequest } from "./security.js";
94
97
  export { assertPermission, assertTrusted, checkPermission, createStaticPermissionPolicy, createStaticTrustPolicy, denialToErrorInfo, isTrusted, PermissionDeniedError, TrustDeniedError, } from "./security.js";
95
98
  export type { CreateMemorySessionStoreOptions, CreateSessionEntryOptions, MemorySessionSearchMode, SessionBranch, SessionBranchOptions, SessionContextSnapshot, } from "./session-stores.js";
@@ -119,5 +122,5 @@ export { trimTrailingSlashes } from "./trim-trailing-slashes.js";
119
122
  export type { ResolvedUseCaseModel, ResolveUseCaseModelInput, UseCaseModelBinding, } from "./use-case-model.js";
120
123
  export { resolveUseCaseModel, resolveUseCaseModelBinding, useCaseCredentialProviderId, } from "./use-case-model.js";
121
124
  export declare const name = "prism";
122
- export declare const version = "0.6.0";
125
+ export declare const version = "0.7.0";
123
126
  export declare const description = "Agent harness for AI providers, agents, sessions, and tools.";
package/dist/index.js CHANGED
@@ -4,7 +4,8 @@ export { dispatchToolCallsInOrder, generateValidateReviseLoop, isAgentLoopOption
4
4
  export { createAgentRunLifecycle } from "./agent-run-lifecycle.js";
5
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";
6
6
  export { createAgent, createAgentSession, resumeAgentRun, resumeAgentRunStream } from "./agents.js";
7
- export { ARTIFACT_BODY_ERROR_CODES, ARTIFACT_CHECKPOINT_NAMESPACE, ArtifactBodyStoreError, ArtifactError, artifactApprovalState, artifactCheckpointKey, } from "./artifacts.js";
7
+ export { ARTIFACT_BODY_ERROR_CODES, ARTIFACT_CHECKPOINT_NAMESPACE, ArtifactBodyStoreError, ArtifactError, approvalEvidenceIntact, artifactApprovalState, artifactCheckpointKey, checkCitationIntegrity, citationBindingDigest, HARD_CITATION_EXCERPT_BYTES, } from "./artifacts.js";
8
+ export { ATTENTION_BUDGET_ERROR_CODE, AttentionBudgetError, createAttentionCompiler, createAttentionTruncationTrigger, DEFAULT_ATTENTION_COMPACT_RATIO, DEFAULT_ATTENTION_KEEP_LAST, DEFAULT_ATTENTION_RESERVE_TOKENS, DEFAULT_ATTENTION_THINKING_KEEP_TURNS, DEFAULT_ATTENTION_TRIGGER_RATIO, DEFAULT_ATTENTION_TRUNCATION_THRESHOLD, isAttentionBudgetError, resolveAttentionReserveTokens, resolveInputCap, resolveRunAttentionCompiler, } from "./attention-compiler.js";
8
9
  export { applyCacheControl, cacheHitRate, cacheSavings, cacheUsageReport, mapCacheRetention, resolveBreakpoint, sanitizeCacheKey, systemCacheControlField, } from "./cache-helpers.js";
9
10
  export { CACHE_TELEMETRY_OVERFLOW_KEY, CacheTelemetryError, createCacheTelemetry, DEFAULT_CACHE_TELEMETRY_CAP, } from "./cache-telemetry.js";
10
11
  export { createProviderCapture } from "./capture.js";
@@ -13,7 +14,7 @@ export { createDefaultCompactionStrategy, isCompactionEntryData } from "./compac
13
14
  export { assertJsonObject, isJsonObject, loadConfigLayers, mergeConfigLayers } from "./config.js";
14
15
  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";
15
16
  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";
16
- export { AgentDecisionError, AgentDelegationSuspendedError, AgentLoopStateError, AgentRunError, AgentRunStateError, assertBatchJobsSupported, assertEmbeddingsSupported, assertImageGenerationSupported, assertModerationSupported, assertSessionMetadataKey, assertSpeechSupported, assertTranscriptionSupported, assertVideoGenerationSupported, BatchJobsError, 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, DEFAULT_SNAPSHOT_CACHE_TTL_MS, EmbeddingsError, 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_SNAPSHOT_CACHE_TTL_MS, HARD_MAX_STICKY_DECISIONS, ImageGenerationError, isBatchJobTerminal, isSessionAppendConflict, isSessionEntryKind, isSessionMetadataConflict, isSessionSearchUnsupported, MAX_ACTION_CONSTRAINT_BYTES, MAX_ACTION_CONSTRAINTS, MAX_ATTRIBUTION_DEPTH, MAX_DECISION_REASON_BYTES, MAX_ELICITATION_BYTES, ModerationError, modelSupportsBatchJobs, modelSupportsEmbeddings, modelSupportsImageGeneration, modelSupportsModeration, modelSupportsSpeech, modelSupportsTranscription, modelSupportsVideoGeneration, pollBatch, resolveSessionSearchQuery, SESSION_APPEND_CONFLICT_CODE, SESSION_ENTRY_KINDS, SESSION_ENTRY_SCHEMA_VERSION, SESSION_METADATA_CONFLICT_CODE, SESSION_SEARCH_UNSUPPORTED_CODE, SESSION_SEARCH_WORKSPACE_METADATA_KEY, SessionAppendConflictError, SessionMetadataConflictError, SessionSearchUnsupportedError, SpeechError, TranscriptionError, VideoGenerationError, } from "./contracts.js";
17
+ export { AgentDecisionError, AgentDelegationSuspendedError, AgentLoopStateError, AgentRunError, AgentRunStateError, assertBatchJobsSupported, assertCompactionTrigger, assertEmbeddingsSupported, assertImageGenerationSupported, assertModerationSupported, assertSessionMetadataKey, assertSpeechSupported, assertTranscriptionSupported, assertVideoGenerationSupported, BatchJobsError, 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, DEFAULT_SNAPSHOT_CACHE_TTL_MS, EmbeddingsError, 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_SNAPSHOT_CACHE_TTL_MS, HARD_MAX_STICKY_DECISIONS, ImageGenerationError, isBatchJobTerminal, isSessionAppendConflict, isSessionEntryKind, isSessionMetadataConflict, isSessionSearchUnsupported, MAX_ACTION_CONSTRAINT_BYTES, MAX_ACTION_CONSTRAINTS, MAX_ATTRIBUTION_DEPTH, MAX_DECISION_REASON_BYTES, MAX_ELICITATION_BYTES, ModerationError, modelSupportsBatchJobs, modelSupportsEmbeddings, modelSupportsImageGeneration, modelSupportsModeration, modelSupportsSpeech, modelSupportsTranscription, modelSupportsVideoGeneration, pollBatch, resolveSessionSearchQuery, resolveShouldCompact, SESSION_APPEND_CONFLICT_CODE, SESSION_ENTRY_KINDS, SESSION_ENTRY_SCHEMA_VERSION, SESSION_METADATA_CONFLICT_CODE, SESSION_SEARCH_UNSUPPORTED_CODE, SESSION_SEARCH_WORKSPACE_METADATA_KEY, SessionAppendConflictError, SessionMetadataConflictError, SessionSearchUnsupportedError, SpeechError, TranscriptionError, VideoGenerationError, } from "./contracts.js";
17
18
  export { parseAgentFile, parseSkillFile } from "./contribution-parsing.js";
18
19
  export { createContributionRegistries, createContributionRegistry, registerDiscoveredContributions } from "./contributions.js";
19
20
  export { CONVERSATION_METADATA_KEY, ConversationError, conversationMarkerMetadata, conversationThreadFromRecord, DEFAULT_MAX_CONVERSATION_CURSOR_BYTES, decodeConversationReplayCursor, encodeConversationReplayCursor, HARD_MAX_CONVERSATION_CURSOR_BYTES, } from "./conversations.js";
@@ -48,7 +49,7 @@ export { loadBinaryResource, loadJsonResource, loadManifestResource, loadTextRes
48
49
  export { createDefaultRetryPolicy, isTransientErrorInfo, waitForRetry } from "./retry.js";
49
50
  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";
50
51
  export { createRunLimitTracker, DEFAULT_RUN_LIMITS, HARD_RUN_LIMITS, RunLimitError, RunLimitTracker, resolveRunLimits, } from "./run-limits.js";
51
- export { createSecureAgent } from "./secure-agent.js";
52
+ export { assertHostCompositionReadiness, createSecureAgent, HostCompositionError, inspectHostComposition, } from "./secure-agent.js";
52
53
  export { assertPermission, assertTrusted, checkPermission, createStaticPermissionPolicy, createStaticTrustPolicy, denialToErrorInfo, isTrusted, PermissionDeniedError, TrustDeniedError, } from "./security.js";
53
54
  export { createMemorySessionStore, createSessionEntry, getSessionBranchEntries, listSessionBranches, rebuildSessionContext, } from "./session-stores.js";
54
55
  export { createChainedSettingsProvider, createStaticSettingsProvider } from "./settings.js";
@@ -66,6 +67,6 @@ export { createToolParameterValidator, createToolRegistry, dispatchToolCall, fil
66
67
  export { trimTrailingSlashes } from "./trim-trailing-slashes.js";
67
68
  export { resolveUseCaseModel, resolveUseCaseModelBinding, useCaseCredentialProviderId, } from "./use-case-model.js";
68
69
  export const name = "prism";
69
- export const version = "0.6.0";
70
+ export const version = "0.7.0";
70
71
  export const description = "Agent harness for AI providers, agents, sessions, and tools.";
71
72
  //# sourceMappingURL=index.js.map
package/dist/input.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ import { type AttentionStickyFrontier } from "./attention-compiler.js";
1
2
  import { type ContextBudget } from "./context-budget.js";
2
- import type { ContentBlock, ContextBlock, ContextProvider, ContextResolutionContext, InputBuildContext, InputBuilder, InstructionInjector, JsonObject, Message, ModelConfig, PromptBuilder, PromptBuildRequest, ProviderRequest, ProviderRequestOptions, ResourceLoader, Skill, ToolDefinition, ToolResult } from "./contracts.js";
3
+ import type { AttentionCompiler, AttentionCompilerOptions, AttentionReport, ContentBlock, ContextBlock, ContextProvider, ContextResolutionContext, InputBuildContext, InputBuilder, InstructionInjector, JsonObject, Message, ModelConfig, PromptBuilder, PromptBuildRequest, ProviderRequest, ProviderRequestOptions, ResourceLoader, Skill, ToolDefinition, ToolResult } from "./contracts.js";
3
4
  import type { MiddlewareRegistry } from "./middleware.js";
4
5
  import type { SecretRedactor } from "./redaction.js";
5
6
  import { type LoadedSkillSet, type SkillsDisclosure } from "./skill-disclosure.js";
@@ -77,6 +78,17 @@ export interface AssembleProviderInputOptions extends DefaultInputBuildContext {
77
78
  readonly contextBudget?: ContextBudget;
78
79
  /** Resolved tool-result fold; projection-only, store untouched. */
79
80
  readonly toolResultFold?: ResolvedToolResultFoldOptions;
81
+ /**
82
+ * Opt-in attention compiler: options are validated here (per call) or pass an existing
83
+ * `AttentionCompiler` to reuse one validation. Mutually exclusive with `contextBudget`,
84
+ * which would otherwise evict as a silent last resort after the compiler's stages.
85
+ */
86
+ readonly attentionCompiler?: AttentionCompilerOptions | AttentionCompiler;
87
+ /** Per-session-leaf sticky frontier; omit for one-shot assemblies (no cross-turn stickiness). */
88
+ readonly attentionSticky?: AttentionStickyFrontier;
89
+ /** Called once per *mutated* turn with the report, so a host can emit telemetry: under-ratio
90
+ * turns never call it, and it runs before `input_assembly` middleware. */
91
+ readonly onAttentionReport?: (report: AttentionReport) => void;
80
92
  }
81
93
  export declare function createDefaultInputBuilder(): DefaultInputBuilder;
82
94
  export declare function resolveContextProviders(options: ResolveContextOptions): Promise<readonly ContextBlock[]>;
package/dist/input.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { compileAttention, createAttentionCompiler } from "./attention-compiler.js";
1
2
  import { assertMessagesSupportModelCapabilities } from "./content.js";
2
3
  import { applyContextBudget, CONTEXT_BUDGET_REPORT_METADATA_KEY } from "./context-budget.js";
3
4
  import { runInstructionInjectors } from "./instruction-injection.js";
@@ -133,7 +134,41 @@ export async function assembleProviderInput(options) {
133
134
  }
134
135
  let demotedSkillBodies;
135
136
  let budgetReport;
136
- if (options.contextBudget) {
137
+ if (options.attentionCompiler) {
138
+ if (options.contextBudget) {
139
+ throw new TypeError("attentionCompiler and contextBudget are mutually exclusive: the compiler raises AttentionBudgetError instead of evicting");
140
+ }
141
+ // Same default-groups path as the budget branch: the compiler needs the assembled groups
142
+ // (and the provider context blocks) to measure one cost for the whole request.
143
+ const groups = await buildDefaultInputMessageGroups(options.input, buildContext);
144
+ context = await resolveContextProviders({
145
+ providers: options.contextProviders,
146
+ messages: flattenInputGroups(groups, layout),
147
+ injectedBlocks: injectorContribs.contextBlocks.length ? injectorContribs.contextBlocks : undefined,
148
+ middleware: options.middleware,
149
+ ...baseContext,
150
+ });
151
+ const compiled = await compileAttention({
152
+ compiler: resolveAttentionCompiler(options.attentionCompiler, options.model),
153
+ groups,
154
+ context,
155
+ skills,
156
+ tools,
157
+ fold: options.toolResultFold,
158
+ frontier: options.attentionSticky,
159
+ redactor: options.redactor,
160
+ signal: options.signal,
161
+ turn,
162
+ sessionId: options.sessionId,
163
+ runId: options.runId,
164
+ });
165
+ if (compiled.mutated)
166
+ options.onAttentionReport?.(compiled.report);
167
+ messages = flattenInputGroups(compiled.groups, layout);
168
+ if (buildContext.middleware)
169
+ messages = await buildContext.middleware.run("input_assembly", messages);
170
+ }
171
+ else if (options.contextBudget) {
137
172
  // ponytail: budget path always uses default groups so eviction kinds stay deterministic;
138
173
  // custom inputBuilder still honored when contextBudget is absent.
139
174
  const groups = await buildDefaultInputMessageGroups(options.input, buildContext);
@@ -217,6 +252,10 @@ export async function assembleProviderInput(options) {
217
252
  signal: options.signal,
218
253
  }, { sessionId: options.sessionId });
219
254
  }
255
+ /** A resolved handle is reused as-is; raw options are validated for this call only. */
256
+ function resolveAttentionCompiler(value, model) {
257
+ return "inputCap" in value ? value : createAttentionCompiler(value, { model });
258
+ }
220
259
  async function buildDefaultInputMessageGroups(input, context) {
221
260
  return {
222
261
  instructions: [
@@ -1,3 +1,5 @@
1
1
  import type { Agent, SecureAgentOptions } from "./contracts.js";
2
+ import { assertHostCompositionReadiness, HostCompositionError, type HostCompositionGovernance, type HostCompositionOptions, type HostCompositionProfile, type HostCompositionReport, type HostCompositionToolReport, inspectHostComposition } from "./host-composition.js";
3
+ export { assertHostCompositionReadiness, HostCompositionError, type HostCompositionGovernance, type HostCompositionOptions, type HostCompositionProfile, type HostCompositionReport, type HostCompositionToolReport, inspectHostComposition, };
2
4
  /** Build an opt-in agent whose security-critical defaults cannot be replaced per run. */
3
5
  export declare function createSecureAgent(options: SecureAgentOptions): Agent;
@@ -1,8 +1,10 @@
1
1
  import { validateRunStateOptions } from "./agent-run-state.js";
2
2
  import { createAgent } from "./agents.js";
3
+ import { assertHostCompositionReadiness, HostCompositionError, inspectHostComposition, } from "./host-composition.js";
3
4
  import { assertIdentityActive, assertIdentityMatchesOwnership } from "./identity.js";
4
5
  import { resolveRunLimits } from "./run-limits.js";
5
6
  import { createToolParameterValidator, createToolRegistry } from "./tools.js";
7
+ export { assertHostCompositionReadiness, HostCompositionError, inspectHostComposition, };
6
8
  /** Build an opt-in agent whose security-critical defaults cannot be replaced per run. */
7
9
  export function createSecureAgent(options) {
8
10
  if (!options.id.trim())
@@ -32,6 +34,9 @@ export function createSecureAgent(options) {
32
34
  assertIdentityActive(options.identity);
33
35
  assertIdentityMatchesOwnership(options.identity, options.ownership);
34
36
  }
37
+ if (options.composition) {
38
+ assertHostCompositionReadiness({ ...options.composition, agent: options });
39
+ }
35
40
  const runState = Object.freeze({ ...options.runState, definitionRevision: options.definitionRevision, interruptBeforeTool: true });
36
41
  validateRunStateOptions(runState);
37
42
  const config = Object.freeze({
@@ -52,7 +57,7 @@ export function createSecureAgent(options) {
52
57
  return createAgent(config);
53
58
  }
54
59
  function withoutSecureFields(options) {
55
- const { tools: _tools, toolArgumentValidator: _validator, redactor: _redactor, permission: _permission, trust: _trust, ownership: _ownership, identity: _identity, limits: _limits, guardrails: _guardrails, definitionRevision: _revision, runState: _runState, ...config } = options;
60
+ const { tools: _tools, toolArgumentValidator: _validator, redactor: _redactor, permission: _permission, trust: _trust, ownership: _ownership, identity: _identity, limits: _limits, guardrails: _guardrails, definitionRevision: _revision, runState: _runState, composition: _composition, ...config } = options;
56
61
  return config;
57
62
  }
58
63
  function freezeGuardrails(guardrails) {
@@ -38,3 +38,15 @@ export declare function foldToolResultHistory(history: readonly Message[], optio
38
38
  export declare function foldToolResults(results: readonly ToolResult[], options: ResolvedToolResultFoldOptions, context: FoldToolResultsContext): Promise<readonly ToolResult[]>;
39
39
  export declare function formatFoldedToolResult(summary: string): string;
40
40
  export declare function foldedToolResultHeader(toolName: string, toolCallId: string, summary: string): string;
41
+ /** Text the fold summarizes for one tool result: the payload JSON, then any text blocks.
42
+ * Shared with the attention compiler so both hash/summarize the same bytes. */
43
+ export declare function toolResultFoldText(result: unknown, error: unknown, extra?: readonly {
44
+ readonly type: string;
45
+ }[]): string;
46
+ /** UTF-8 cap that never splits a multi-byte character. Shared with the attention
47
+ * compiler's host-summarize path so both cap host text identically. */
48
+ export declare function capToolResultSummary(summary: string, maxBytes: number): string;
49
+ /** Provider turn per history index: assistant messages advance the turn, tool rows use
50
+ * their `prismToolResultTurn` stamp when present and the last assistant turn otherwise.
51
+ * Shared with the attention compiler so age gates match the fold exactly. */
52
+ export declare function inferToolResultTurns(history: readonly Message[]): readonly number[];
@@ -58,7 +58,7 @@ async function foldToolResultMessage(message, options, context) {
58
58
  const block = message.content.find((part) => part.type === "tool_result");
59
59
  if (block?.type !== "tool_result")
60
60
  return message;
61
- const text = toolResultText(block.result, block.error, message.content);
61
+ const text = toolResultFoldText(block.result, block.error, message.content);
62
62
  const folded = await maybeFold({
63
63
  options,
64
64
  context,
@@ -80,7 +80,7 @@ async function foldToolResultMessage(message, options, context) {
80
80
  return folded ?? message;
81
81
  }
82
82
  async function foldToolResultValue(result, options, context) {
83
- const text = toolResultText(result.value, result.error, result.content);
83
+ const text = toolResultFoldText(result.value, result.error, result.content);
84
84
  const folded = await maybeFold({
85
85
  options,
86
86
  context,
@@ -112,7 +112,7 @@ async function maybeFold(input) {
112
112
  toolName: input.toolName,
113
113
  text: input.text,
114
114
  });
115
- return input.apply(capSummaryBytes(String(summary), input.options.maxSummaryBytes));
115
+ return input.apply(capToolResultSummary(String(summary), input.options.maxSummaryBytes));
116
116
  }
117
117
  catch {
118
118
  return undefined;
@@ -124,7 +124,9 @@ export function formatFoldedToolResult(summary) {
124
124
  export function foldedToolResultHeader(toolName, toolCallId, summary) {
125
125
  return `Tool result ${toolName} [${toolCallId}]: ${summary}`;
126
126
  }
127
- function toolResultText(result, error, extra) {
127
+ /** Text the fold summarizes for one tool result: the payload JSON, then any text blocks.
128
+ * Shared with the attention compiler so both hash/summarize the same bytes. */
129
+ export function toolResultFoldText(result, error, extra) {
128
130
  const parts = [JSON.stringify(error ?? result ?? null)];
129
131
  for (const block of extra ?? []) {
130
132
  if (block.type === "text" && "text" in block && typeof block.text === "string")
@@ -132,7 +134,9 @@ function toolResultText(result, error, extra) {
132
134
  }
133
135
  return parts.join("\n");
134
136
  }
135
- function capSummaryBytes(summary, maxBytes) {
137
+ /** UTF-8 cap that never splits a multi-byte character. Shared with the attention
138
+ * compiler's host-summarize path so both cap host text identically. */
139
+ export function capToolResultSummary(summary, maxBytes) {
136
140
  const bytes = estimateTextBytes(summary);
137
141
  if (bytes <= maxBytes)
138
142
  return summary;
@@ -143,7 +147,10 @@ function capSummaryBytes(summary, maxBytes) {
143
147
  end--;
144
148
  return `${new TextDecoder().decode(encoded.slice(0, end))}…`;
145
149
  }
146
- function inferToolResultTurns(history) {
150
+ /** Provider turn per history index: assistant messages advance the turn, tool rows use
151
+ * their `prismToolResultTurn` stamp when present and the last assistant turn otherwise.
152
+ * Shared with the attention compiler so age gates match the fold exactly. */
153
+ export function inferToolResultTurns(history) {
147
154
  const turns = new Array(history.length).fill(1);
148
155
  let providerTurn = 0;
149
156
  let toolTurn = 1;
package/dist/tools.d.ts CHANGED
@@ -56,5 +56,15 @@ export interface ToolRegistryOptions extends DuplicateRegistrationOptions {
56
56
  }
57
57
  export declare function createToolRegistry(tools?: readonly ToolDefinition[], options?: ToolRegistryOptions): ToolRegistry;
58
58
  export declare function filterTools(tools: readonly ToolDefinition[], filter?: ToolFilterInput): readonly ToolDefinition[];
59
+ /** Cap matches tool-search index; run allow-lists never exceed the disclosed set. */
60
+ export declare const HARD_RUN_TOOL_NAMES = 1024;
61
+ /**
62
+ * Per-run allow-list. Omitted grant → unchanged list. Checkpointed grant cannot widen.
63
+ * Fresh unknown names fail closed; resume drops names the current registry no longer has.
64
+ */
65
+ export declare function selectRunTools(listed: readonly ToolDefinition[], requested: readonly string[] | undefined, checkpoint?: readonly string[]): {
66
+ readonly tools: readonly ToolDefinition[];
67
+ readonly grant: readonly string[] | undefined;
68
+ };
59
69
  export declare function dispatchToolCall(options: DispatchToolCallOptions): Promise<ToolResult>;
60
70
  export declare function resolveToolEffectDeclaration(tool: ToolDefinition, args: JsonObject, context: ToolExecutionContext): ToolEffectDeclaration | undefined;
package/dist/tools.js CHANGED
@@ -58,6 +58,47 @@ export function filterTools(tools, filter) {
58
58
  .filter((item) => Boolean(item));
59
59
  return tools.filter((tool) => !denied.has(tool.name) && allows.every((allow) => allow.has(tool.name)));
60
60
  }
61
+ /** Cap matches tool-search index; run allow-lists never exceed the disclosed set. */
62
+ export const HARD_RUN_TOOL_NAMES = 1024;
63
+ const MAX_RUN_TOOL_NAME_CHARS = 256;
64
+ function assertRunToolNames(names) {
65
+ if (names.length > HARD_RUN_TOOL_NAMES) {
66
+ throw new TypeError(`RunOptions.toolNames exceeds ${HARD_RUN_TOOL_NAMES} entries`);
67
+ }
68
+ const out = [];
69
+ const seen = new Set();
70
+ for (const name of names) {
71
+ if (typeof name !== "string" || name.length === 0 || name.length > MAX_RUN_TOOL_NAME_CHARS) {
72
+ throw new TypeError(`RunOptions.toolNames entries must be non-empty strings of at most ${MAX_RUN_TOOL_NAME_CHARS} characters`);
73
+ }
74
+ if (!seen.has(name)) {
75
+ seen.add(name);
76
+ out.push(name);
77
+ }
78
+ }
79
+ return out;
80
+ }
81
+ /**
82
+ * Per-run allow-list. Omitted grant → unchanged list. Checkpointed grant cannot widen.
83
+ * Fresh unknown names fail closed; resume drops names the current registry no longer has.
84
+ */
85
+ export function selectRunTools(listed, requested, checkpoint) {
86
+ const req = requested === undefined ? undefined : assertRunToolNames(requested);
87
+ const grant = checkpoint === undefined ? req : req === undefined ? checkpoint : req.filter((name) => checkpoint.includes(name));
88
+ if (grant === undefined)
89
+ return { tools: listed, grant };
90
+ if (grant.length === 0)
91
+ return { tools: [], grant };
92
+ const available = new Set(listed.map((tool) => tool.name));
93
+ if (checkpoint === undefined) {
94
+ for (const name of grant) {
95
+ if (!available.has(name))
96
+ throw new TypeError(`Unknown run tool: ${name}`);
97
+ }
98
+ return { tools: filterTools(listed, { allow: grant }), grant };
99
+ }
100
+ return { tools: filterTools(listed, { allow: grant.filter((name) => available.has(name)) }), grant };
101
+ }
61
102
  function toolExecutionMetadata(startedAt, status) {
62
103
  return { durationMs: Math.max(0, Date.now() - Date.parse(startedAt)), status };
63
104
  }