@arnilo/prism 0.0.8 → 0.0.11
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 +44 -3
- package/dist/agent-loops.d.ts +1 -0
- package/dist/agent-loops.js +44 -5
- package/dist/agents.js +141 -7
- package/dist/context-budget.d.ts +63 -0
- package/dist/context-budget.js +235 -0
- package/dist/contracts.d.ts +107 -0
- package/dist/contracts.js +77 -0
- package/dist/index.d.ts +7 -5
- package/dist/index.js +5 -4
- package/dist/input.d.ts +3 -0
- package/dist/input.js +71 -28
- package/dist/node/session-store-jsonl.js +4 -1
- package/dist/provider-events.d.ts +2 -0
- package/dist/provider-events.js +21 -13
- package/dist/providers/openai-compatible.js +8 -5
- package/dist/providers/transport.d.ts +10 -1
- package/dist/providers/transport.js +24 -8
- package/dist/rpc.js +13 -2
- package/dist/session-stores.d.ts +7 -2
- package/dist/session-stores.js +174 -4
- package/dist/structured-output.d.ts +5 -1
- package/dist/structured-output.js +18 -0
- package/dist/testing/persistence-schema.d.ts +1 -1
- package/dist/testing/persistence-schema.js +8 -2
- package/dist/testing/session-store-conformance.d.ts +6 -0
- package/dist/testing/session-store-conformance.js +36 -1
- package/dist/tools.js +2 -0
- package/docs/agent-events.md +3 -2
- package/docs/agent-loops.md +10 -3
- package/docs/agent-session-runtime.md +5 -1
- package/docs/browser-automation.md +124 -0
- package/docs/cli-rpc.md +2 -1
- package/docs/coding-agent-tools.md +178 -14
- package/docs/coding-security.md +84 -11
- package/docs/evaluations.md +13 -2
- package/docs/guardrails.md +2 -1
- package/docs/host-security.md +4 -2
- package/docs/index.md +19 -15
- package/docs/input-and-prompt-assembly.md +4 -1
- package/docs/migration.md +84 -0
- package/docs/node-jsonl-session-store.md +1 -1
- package/docs/performance.md +46 -0
- package/docs/postgres-persistence.md +3 -3
- package/docs/provider-conformance.md +1 -1
- package/docs/provider-packages.md +1 -1
- package/docs/provider-primitives.md +7 -1
- package/docs/providers/anthropic.md +92 -0
- package/docs/providers/google.md +87 -0
- package/docs/public-contracts.md +4 -0
- package/docs/release-and-install.md +197 -64
- package/docs/review-coverage-2026-07-20-phase-4.md +175 -0
- package/docs/review-coverage-2026-07-21-phase-5.md +172 -0
- package/docs/review-coverage-2026-07-22-phase-6.md +209 -0
- package/docs/session-store-conformance.md +2 -0
- package/docs/session-stores.md +40 -1
- package/docs/sqlite-persistence.md +3 -3
- package/docs/structured-output.md +9 -3
- package/docs/tools.md +3 -0
- package/docs/web-tools.md +1 -1
- package/docs/workflows.md +3 -0
- package/package.json +6 -5
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
export const CONTEXT_BUDGET_REPORT_METADATA_KEY = "contextBudgetReport";
|
|
2
|
+
export const HARD_MAX_CONTEXT_BUDGET_TOKENS = 2_000_000;
|
|
3
|
+
export const HARD_MAX_CONTEXT_BUDGET_BYTES = 32 * 1024 * 1024;
|
|
4
|
+
export const DEFAULT_MAX_CONTEXT_BUDGET_OMISSIONS = 256;
|
|
5
|
+
export const HARD_MAX_CONTEXT_BUDGET_OMISSIONS = 1_024;
|
|
6
|
+
export const CONTEXT_BUDGET_ERROR_CODE = "context_budget_exceeded";
|
|
7
|
+
export class ContextBudgetError extends Error {
|
|
8
|
+
code = CONTEXT_BUDGET_ERROR_CODE;
|
|
9
|
+
constructor(message = "context budget exceeded: mandatory prefix cannot fit") {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "ContextBudgetError";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function isContextBudgetError(error) {
|
|
15
|
+
return error instanceof Error && error.code === CONTEXT_BUDGET_ERROR_CODE;
|
|
16
|
+
}
|
|
17
|
+
/** UTF-16 code units / 4. Estimate only — not billing. */
|
|
18
|
+
export function estimateTextTokens(text) {
|
|
19
|
+
return Math.ceil(text.length / 4);
|
|
20
|
+
}
|
|
21
|
+
export function estimateTextBytes(text) {
|
|
22
|
+
return new TextEncoder().encode(text).byteLength;
|
|
23
|
+
}
|
|
24
|
+
export function estimateMessageTokens(message) {
|
|
25
|
+
return estimateTextTokens(messageText(message));
|
|
26
|
+
}
|
|
27
|
+
export function estimateMessageBytes(message) {
|
|
28
|
+
return estimateTextBytes(messageText(message));
|
|
29
|
+
}
|
|
30
|
+
export function estimateAssemblyTokens(messages) {
|
|
31
|
+
return messages.reduce((sum, message) => sum + estimateMessageTokens(message), 0);
|
|
32
|
+
}
|
|
33
|
+
export function resolveContextBudget(budget) {
|
|
34
|
+
const hasTokens = budget.maxInputTokens !== undefined;
|
|
35
|
+
const hasBytes = budget.maxInputBytes !== undefined;
|
|
36
|
+
if (!hasTokens && !hasBytes) {
|
|
37
|
+
throw new TypeError("contextBudget requires maxInputTokens and/or maxInputBytes");
|
|
38
|
+
}
|
|
39
|
+
if (hasTokens)
|
|
40
|
+
assertPositiveCap(budget.maxInputTokens, "maxInputTokens", HARD_MAX_CONTEXT_BUDGET_TOKENS);
|
|
41
|
+
if (hasBytes)
|
|
42
|
+
assertPositiveCap(budget.maxInputBytes, "maxInputBytes", HARD_MAX_CONTEXT_BUDGET_BYTES);
|
|
43
|
+
return { ...budget, reportOmissions: budget.reportOmissions === true };
|
|
44
|
+
}
|
|
45
|
+
export function getContextBudgetReport(request) {
|
|
46
|
+
const value = request.metadata?.[CONTEXT_BUDGET_REPORT_METADATA_KEY];
|
|
47
|
+
return isContextBudgetReport(value) ? value : undefined;
|
|
48
|
+
}
|
|
49
|
+
export function applyContextBudget(options) {
|
|
50
|
+
const budget = resolveContextBudget(options.budget);
|
|
51
|
+
const layout = options.layout ?? "legacy";
|
|
52
|
+
const groups = {
|
|
53
|
+
instructions: [...options.groups.instructions],
|
|
54
|
+
summaries: [...options.groups.summaries],
|
|
55
|
+
history: [...options.groups.history],
|
|
56
|
+
input: [...options.groups.input],
|
|
57
|
+
attachments: [...options.groups.attachments],
|
|
58
|
+
toolResults: [...options.groups.toolResults],
|
|
59
|
+
};
|
|
60
|
+
const context = [...(options.context ?? [])];
|
|
61
|
+
const skills = [...(options.skills ?? [])].filter((skill) => skill.instructions);
|
|
62
|
+
const tools = options.tools ? [...options.tools] : undefined;
|
|
63
|
+
const omitted = [];
|
|
64
|
+
const cost = () => measureAll(groups, context, skills, tools);
|
|
65
|
+
while (overBudget(cost(), budget)) {
|
|
66
|
+
const drop = dropNext(groups, context, skills, layout);
|
|
67
|
+
if (!drop) {
|
|
68
|
+
throw new ContextBudgetError();
|
|
69
|
+
}
|
|
70
|
+
if (omitted.length < HARD_MAX_CONTEXT_BUDGET_OMISSIONS)
|
|
71
|
+
omitted.push(drop);
|
|
72
|
+
}
|
|
73
|
+
const kept = cost();
|
|
74
|
+
const reportOmissions = omitted.slice(0, DEFAULT_MAX_CONTEXT_BUDGET_OMISSIONS);
|
|
75
|
+
return {
|
|
76
|
+
groups,
|
|
77
|
+
context,
|
|
78
|
+
skills,
|
|
79
|
+
tools,
|
|
80
|
+
report: {
|
|
81
|
+
omitted: budget.reportOmissions ? reportOmissions : [],
|
|
82
|
+
keptTokens: kept.tokens,
|
|
83
|
+
keptBytes: kept.bytes,
|
|
84
|
+
maxInputTokens: budget.maxInputTokens,
|
|
85
|
+
maxInputBytes: budget.maxInputBytes,
|
|
86
|
+
truncated: omitted.length > 0,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function dropNext(groups, context, skills, layout) {
|
|
91
|
+
// ponytail: drop from end of keep-stack (history/tool_results first). cache_aware keeps
|
|
92
|
+
// attachments longer so stable prefix stays intact while budget still allows it.
|
|
93
|
+
const order = layout === "cache_aware"
|
|
94
|
+
? ["tool_results", "history", "summaries", "context", "skills", "attachments"]
|
|
95
|
+
: ["tool_results", "history", "summaries", "attachments", "context", "skills"];
|
|
96
|
+
for (const kind of order) {
|
|
97
|
+
if (kind === "tool_results" && groups.toolResults.length > 0) {
|
|
98
|
+
const message = groups.toolResults.pop();
|
|
99
|
+
return omission("tool_results", message.id ?? toolResultId(message), message);
|
|
100
|
+
}
|
|
101
|
+
if (kind === "history" && groups.history.length > 0) {
|
|
102
|
+
const message = groups.history.pop();
|
|
103
|
+
return omission("history", message.id, message);
|
|
104
|
+
}
|
|
105
|
+
if (kind === "summaries" && groups.summaries.length > 0) {
|
|
106
|
+
const message = groups.summaries.pop();
|
|
107
|
+
return omission("summaries", message.id, message);
|
|
108
|
+
}
|
|
109
|
+
if (kind === "attachments" && groups.attachments.length > 0) {
|
|
110
|
+
const message = groups.attachments.pop();
|
|
111
|
+
return omission("attachments", message.id, message);
|
|
112
|
+
}
|
|
113
|
+
if (kind === "context" && context.length > 0) {
|
|
114
|
+
const block = context.pop();
|
|
115
|
+
const text = `${block.title ? `${block.title}:\n` : "Context:\n"}${contextBlockText(block)}`;
|
|
116
|
+
return {
|
|
117
|
+
kind: "context",
|
|
118
|
+
id: block.id ?? block.title,
|
|
119
|
+
tokenEstimate: estimateTextTokens(text),
|
|
120
|
+
byteLength: estimateTextBytes(text),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
if (kind === "skills" && skills.length > 0) {
|
|
124
|
+
const skill = skills.pop();
|
|
125
|
+
const text = `Skill ${skill.name}:\n${skill.instructions ?? ""}`;
|
|
126
|
+
return {
|
|
127
|
+
kind: "skills",
|
|
128
|
+
id: skill.name,
|
|
129
|
+
tokenEstimate: estimateTextTokens(text),
|
|
130
|
+
byteLength: estimateTextBytes(text),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
function omission(kind, id, message) {
|
|
137
|
+
return {
|
|
138
|
+
kind,
|
|
139
|
+
id,
|
|
140
|
+
tokenEstimate: estimateMessageTokens(message),
|
|
141
|
+
byteLength: estimateMessageBytes(message),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function toolResultId(message) {
|
|
145
|
+
const block = message.content.find((part) => part.type === "tool_result");
|
|
146
|
+
return block && block.type === "tool_result" ? block.toolCallId : undefined;
|
|
147
|
+
}
|
|
148
|
+
function measureAll(groups, context, skills, tools) {
|
|
149
|
+
let tokens = 0;
|
|
150
|
+
let bytes = 0;
|
|
151
|
+
const addMessage = (message) => {
|
|
152
|
+
tokens += estimateMessageTokens(message);
|
|
153
|
+
bytes += estimateMessageBytes(message);
|
|
154
|
+
};
|
|
155
|
+
for (const message of groups.instructions)
|
|
156
|
+
addMessage(message);
|
|
157
|
+
for (const message of groups.summaries)
|
|
158
|
+
addMessage(message);
|
|
159
|
+
for (const message of groups.history)
|
|
160
|
+
addMessage(message);
|
|
161
|
+
for (const message of groups.input)
|
|
162
|
+
addMessage(message);
|
|
163
|
+
for (const message of groups.attachments)
|
|
164
|
+
addMessage(message);
|
|
165
|
+
for (const message of groups.toolResults)
|
|
166
|
+
addMessage(message);
|
|
167
|
+
for (const block of context) {
|
|
168
|
+
const text = `${block.title ? `${block.title}:\n` : "Context:\n"}${contextBlockText(block)}`;
|
|
169
|
+
tokens += estimateTextTokens(text);
|
|
170
|
+
bytes += estimateTextBytes(text);
|
|
171
|
+
}
|
|
172
|
+
for (const skill of skills) {
|
|
173
|
+
const text = `Skill ${skill.name}:\n${skill.instructions ?? ""}`;
|
|
174
|
+
tokens += estimateTextTokens(text);
|
|
175
|
+
bytes += estimateTextBytes(text);
|
|
176
|
+
}
|
|
177
|
+
if (tools?.length) {
|
|
178
|
+
const text = `Available tools:\n${tools.map((tool) => `- ${tool.name}${tool.description ? `: ${tool.description}` : ""}`).join("\n")}`;
|
|
179
|
+
tokens += estimateTextTokens(text);
|
|
180
|
+
bytes += estimateTextBytes(text);
|
|
181
|
+
}
|
|
182
|
+
return { tokens, bytes };
|
|
183
|
+
}
|
|
184
|
+
function overBudget(cost, budget) {
|
|
185
|
+
if (budget.maxInputTokens !== undefined && cost.tokens > budget.maxInputTokens)
|
|
186
|
+
return true;
|
|
187
|
+
if (budget.maxInputBytes !== undefined && cost.bytes > budget.maxInputBytes)
|
|
188
|
+
return true;
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
function assertPositiveCap(value, name, hardMax) {
|
|
192
|
+
if (!Number.isSafeInteger(value) || value < 1 || value > hardMax) {
|
|
193
|
+
throw new TypeError(`contextBudget.${name} must be a safe integer from 1 to ${hardMax}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function isContextBudgetReport(value) {
|
|
197
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
198
|
+
return false;
|
|
199
|
+
const report = value;
|
|
200
|
+
return Array.isArray(report.omitted)
|
|
201
|
+
&& typeof report.keptTokens === "number"
|
|
202
|
+
&& typeof report.keptBytes === "number"
|
|
203
|
+
&& typeof report.truncated === "boolean";
|
|
204
|
+
}
|
|
205
|
+
function messageText(message) {
|
|
206
|
+
return message.content.map((part) => {
|
|
207
|
+
if (part.type === "text" || part.type === "thinking")
|
|
208
|
+
return part.text;
|
|
209
|
+
if (part.type === "tool_result")
|
|
210
|
+
return JSON.stringify(part.result ?? part.error ?? null);
|
|
211
|
+
if (part.type === "tool_call")
|
|
212
|
+
return `${part.name}(${JSON.stringify(part.arguments)})`;
|
|
213
|
+
if (part.type === "tool_call_delta")
|
|
214
|
+
return `${part.name ?? "tool"}(${part.argumentsText ?? ""})`;
|
|
215
|
+
if (part.type === "image")
|
|
216
|
+
return part.url ?? part.resourceUri ?? part.mimeType ?? "[image]";
|
|
217
|
+
if (part.type === "audio")
|
|
218
|
+
return part.transcript ?? part.name ?? part.url ?? part.resourceUri ?? part.mediaType ?? "[audio]";
|
|
219
|
+
if (part.type === "file")
|
|
220
|
+
return part.name ?? part.url ?? part.resourceUri ?? part.mediaType ?? "[file]";
|
|
221
|
+
if (part.type === "document")
|
|
222
|
+
return part.transcript ?? part.name ?? part.url ?? part.resourceUri ?? part.mediaType ?? "[document]";
|
|
223
|
+
return "[content]";
|
|
224
|
+
}).join("\n");
|
|
225
|
+
}
|
|
226
|
+
function contextBlockText(block) {
|
|
227
|
+
if (typeof block.content === "string")
|
|
228
|
+
return block.content;
|
|
229
|
+
return block.content.map((part) => {
|
|
230
|
+
if (part.type === "text" || part.type === "thinking")
|
|
231
|
+
return part.text;
|
|
232
|
+
return "[content]";
|
|
233
|
+
}).join("\n");
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=context-budget.js.map
|
package/dist/contracts.d.ts
CHANGED
|
@@ -49,6 +49,8 @@ export interface ToolCallContent {
|
|
|
49
49
|
readonly id: string;
|
|
50
50
|
readonly name: string;
|
|
51
51
|
readonly arguments: JsonObject;
|
|
52
|
+
/** Set when streamed arguments failed JSON parse; dispatch blocks without execute(). */
|
|
53
|
+
readonly argumentsError?: ErrorInfo;
|
|
52
54
|
}
|
|
53
55
|
export interface ToolResultContent {
|
|
54
56
|
readonly type: "tool_result";
|
|
@@ -491,6 +493,22 @@ export declare class AgentRunError extends Error {
|
|
|
491
493
|
readonly cause?: unknown;
|
|
492
494
|
});
|
|
493
495
|
}
|
|
496
|
+
/** Mid-run steer queue: default pending message count (fail closed at this cap). */
|
|
497
|
+
export declare const DEFAULT_MAX_PENDING_STEERS = 8;
|
|
498
|
+
/** Absolute pending steer count ceiling if hosts later expose overrides. */
|
|
499
|
+
export declare const HARD_MAX_PENDING_STEERS = 32;
|
|
500
|
+
/** Mid-run steer queue: default total UTF-8 byte budget across pending messages. */
|
|
501
|
+
export declare const DEFAULT_MAX_PENDING_STEER_BYTES: number;
|
|
502
|
+
/** Absolute pending steer byte ceiling if hosts later expose overrides. */
|
|
503
|
+
export declare const HARD_MAX_PENDING_STEER_BYTES: number;
|
|
504
|
+
export interface SteerOptions {
|
|
505
|
+
/**
|
|
506
|
+
* When true, abort the in-flight provider stream and continue the same run after
|
|
507
|
+
* injecting steered user text. Default false: inject before the next provider turn
|
|
508
|
+
* (after the current tool batch completes).
|
|
509
|
+
*/
|
|
510
|
+
readonly softInterrupt?: boolean;
|
|
511
|
+
}
|
|
494
512
|
export interface AgentSession {
|
|
495
513
|
readonly id: string;
|
|
496
514
|
/** Current branch leaf entry id; advances on every append/run and is re-pointed by `checkout`.
|
|
@@ -498,6 +516,12 @@ export interface AgentSession {
|
|
|
498
516
|
readonly leafId: string | undefined;
|
|
499
517
|
run(input: string | Message | readonly Message[], options?: RunOptions): Promise<AgentRunResult>;
|
|
500
518
|
prompt(input: string, options?: RunOptions): Promise<AgentRunResult>;
|
|
519
|
+
/**
|
|
520
|
+
* Enqueue user text into an active run. Default injects before the next provider turn.
|
|
521
|
+
* `softInterrupt: true` aborts the current provider stream, then continues the same run.
|
|
522
|
+
* Fails closed when no run is active or the pending queue exceeds caps.
|
|
523
|
+
*/
|
|
524
|
+
steer(input: string | Message | readonly Message[], options?: SteerOptions): void;
|
|
501
525
|
/** Subscribe first, then start exactly one run and yield only that run's events until it terminates. */
|
|
502
526
|
stream(input: string | Message | readonly Message[], options?: RunOptions & SubscribeOptions): AsyncIterable<AgentEvent>;
|
|
503
527
|
compact(options?: CompactionOptions): Promise<CompactionResult>;
|
|
@@ -1020,7 +1044,80 @@ export interface SessionStore {
|
|
|
1020
1044
|
* avoid `list(sessionId)` (full-session scan) + in-memory rebuild. Optional — the
|
|
1021
1045
|
* built-in memory/JSONL stores omit it and the runtime falls back to `list()`. */
|
|
1022
1046
|
readBranchPath?(query: SessionBranchRead): Promise<PersistencePage<SessionEntry>>;
|
|
1047
|
+
/**
|
|
1048
|
+
* Optional bounded session search. Prefer implementing this **or** returning a companion
|
|
1049
|
+
* `SessionIndex` from the adapter factory — hosts must not need both. Call
|
|
1050
|
+
* `resolveSessionSearchQuery` before scan/query. Memory defaults to capped linear
|
|
1051
|
+
* search (`sessionSearchMode: "unsupported"` throws). JSONL throws unsupported.
|
|
1052
|
+
*/
|
|
1053
|
+
searchSessions?(query: SessionSearchQuery): Promise<PersistencePage<SessionSearchHit>>;
|
|
1054
|
+
}
|
|
1055
|
+
/** Host-written `SessionRecord.metadata` / session metadata key for workspace filtering. */
|
|
1056
|
+
export declare const SESSION_SEARCH_WORKSPACE_METADATA_KEY: "workspaceRoot";
|
|
1057
|
+
export declare const DEFAULT_SESSION_SEARCH_LIMIT = 20;
|
|
1058
|
+
export declare const HARD_MAX_SESSION_SEARCH_LIMIT = 100;
|
|
1059
|
+
export declare const DEFAULT_MAX_SESSION_SEARCH_QUERY_BYTES: number;
|
|
1060
|
+
export declare const HARD_MAX_SESSION_SEARCH_QUERY_BYTES: number;
|
|
1061
|
+
export declare const DEFAULT_MAX_SESSION_SEARCH_SNIPPET_BYTES = 512;
|
|
1062
|
+
export declare const HARD_MAX_SESSION_SEARCH_SNIPPET_BYTES: number;
|
|
1063
|
+
export declare const DEFAULT_MAX_SESSION_SEARCH_CURSOR_BYTES: number;
|
|
1064
|
+
export declare const HARD_MAX_SESSION_SEARCH_CURSOR_BYTES: number;
|
|
1065
|
+
export declare const DEFAULT_MAX_SESSION_SEARCH_LINEAR_SESSIONS = 1000;
|
|
1066
|
+
export declare const HARD_MAX_SESSION_SEARCH_LINEAR_SESSIONS = 5000;
|
|
1067
|
+
export declare const DEFAULT_MAX_SESSION_SEARCH_LINEAR_ENTRIES = 10000;
|
|
1068
|
+
export declare const HARD_MAX_SESSION_SEARCH_LINEAR_ENTRIES = 50000;
|
|
1069
|
+
export declare const DEFAULT_MAX_SESSION_SEARCH_LINEAR_BYTES: number;
|
|
1070
|
+
export declare const HARD_MAX_SESSION_SEARCH_LINEAR_BYTES: number;
|
|
1071
|
+
export declare const DEFAULT_MAX_SESSION_SEARCH_FTS_CANDIDATES = 1000;
|
|
1072
|
+
export declare const HARD_MAX_SESSION_SEARCH_FTS_CANDIDATES = 5000;
|
|
1073
|
+
/** Bounded session search filters. Workspace matches host-written `metadata.workspaceRoot`. */
|
|
1074
|
+
export interface SessionSearchQuery extends PersistenceQuery, OwnershipScope {
|
|
1075
|
+
readonly workspaceRoot?: string;
|
|
1076
|
+
/** Optional full-text / message+summary query (adapter-defined matching). */
|
|
1077
|
+
readonly query?: string;
|
|
1078
|
+
readonly provider?: string;
|
|
1079
|
+
readonly model?: string;
|
|
1080
|
+
readonly label?: string;
|
|
1081
|
+
readonly summary?: string;
|
|
1082
|
+
readonly fromUpdatedAt?: string;
|
|
1083
|
+
readonly toUpdatedAt?: string;
|
|
1084
|
+
readonly signal?: AbortSignal;
|
|
1023
1085
|
}
|
|
1086
|
+
/**
|
|
1087
|
+
* Safe search hit for resume/checkout. Never includes credentials or raw full transcripts.
|
|
1088
|
+
* `leafId` is the branch tip for `session.checkout` when known.
|
|
1089
|
+
*/
|
|
1090
|
+
export interface SessionSearchHit {
|
|
1091
|
+
readonly sessionId: string;
|
|
1092
|
+
readonly leafId?: string;
|
|
1093
|
+
readonly updatedAt?: string;
|
|
1094
|
+
readonly label?: string;
|
|
1095
|
+
readonly summary?: string;
|
|
1096
|
+
readonly snippet?: string;
|
|
1097
|
+
/** Safe display fields only (e.g. workspaceRoot); never credentials. */
|
|
1098
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
1099
|
+
}
|
|
1100
|
+
/** Narrow search seam; adapters may implement this instead of `SessionStore.searchSessions`. */
|
|
1101
|
+
export interface SessionIndex {
|
|
1102
|
+
search(query: SessionSearchQuery): Promise<PersistencePage<SessionSearchHit>>;
|
|
1103
|
+
}
|
|
1104
|
+
/** Validated search query with finite `limit` / `order` filled in. */
|
|
1105
|
+
export interface ResolvedSessionSearchQuery extends SessionSearchQuery {
|
|
1106
|
+
readonly limit: number;
|
|
1107
|
+
readonly order: "asc" | "desc";
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* O(1) validation before any scan/query. Applies default page limit; rejects NaN,
|
|
1111
|
+
* non-positive limits, oversize query/cursor/filter strings, and invalid order.
|
|
1112
|
+
*/
|
|
1113
|
+
export declare function resolveSessionSearchQuery(query: SessionSearchQuery): ResolvedSessionSearchQuery;
|
|
1114
|
+
export declare const SESSION_SEARCH_UNSUPPORTED_CODE: "session_search_unsupported";
|
|
1115
|
+
/** Thrown when a store opts out of `searchSessions` (memory `unsupported`, JSONL). */
|
|
1116
|
+
export declare class SessionSearchUnsupportedError extends Error {
|
|
1117
|
+
readonly code: "session_search_unsupported";
|
|
1118
|
+
constructor(message?: string);
|
|
1119
|
+
}
|
|
1120
|
+
export declare function isSessionSearchUnsupported(error: unknown): error is SessionSearchUnsupportedError;
|
|
1024
1121
|
/** Query for a single branch's ancestor chain (DB-friendly: one recursive/ancestor query
|
|
1025
1122
|
* instead of a full-session scan). Honored by `SessionStore.readBranchPath` and the pure
|
|
1026
1123
|
* branch helpers' reader overload. `leafId` is optional (omit for the latest leaf). */
|
|
@@ -1640,6 +1737,10 @@ export interface LoopContext {
|
|
|
1640
1737
|
isToolCallExclusive?(call: ToolCallContent): boolean;
|
|
1641
1738
|
appendMessage(message: Message): Promise<void>;
|
|
1642
1739
|
emit(event: AgentEvent): void;
|
|
1740
|
+
/** True when mid-run steers are queued for the next provider turn. */
|
|
1741
|
+
hasPendingSteers?(): boolean;
|
|
1742
|
+
/** Drain pending steers into history/session. Returns true when any were applied. */
|
|
1743
|
+
applyPendingSteers?(): Promise<boolean>;
|
|
1643
1744
|
}
|
|
1644
1745
|
export interface AgentLoopStrategy {
|
|
1645
1746
|
readonly name: string;
|
|
@@ -1661,6 +1762,12 @@ export type AgentLoopOptions = {
|
|
|
1661
1762
|
readonly structuredOutput?: StructuredOutputOptions;
|
|
1662
1763
|
/** `native` maps schema to capable providers; `artifact-loop` keeps repair turns only. */
|
|
1663
1764
|
readonly structuredOutputMode?: "native" | "artifact-loop";
|
|
1765
|
+
/**
|
|
1766
|
+
* When to attach native `structuredOutput` under `toolCalls: "bounded"`.
|
|
1767
|
+
* `every-turn` (default): schema on every provider request (legacy).
|
|
1768
|
+
* `final-turn-only`: tool-eligible turns omit schema; artifact/revision turns send schema and withdraw tools.
|
|
1769
|
+
*/
|
|
1770
|
+
readonly structuredOutputTiming?: "every-turn" | "final-turn-only";
|
|
1664
1771
|
};
|
|
1665
1772
|
export interface ArtifactValidation {
|
|
1666
1773
|
readonly ok: boolean;
|
package/dist/contracts.js
CHANGED
|
@@ -10,6 +10,14 @@ export class AgentRunError extends Error {
|
|
|
10
10
|
this.result = result;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
+
/** Mid-run steer queue: default pending message count (fail closed at this cap). */
|
|
14
|
+
export const DEFAULT_MAX_PENDING_STEERS = 8;
|
|
15
|
+
/** Absolute pending steer count ceiling if hosts later expose overrides. */
|
|
16
|
+
export const HARD_MAX_PENDING_STEERS = 32;
|
|
17
|
+
/** Mid-run steer queue: default total UTF-8 byte budget across pending messages. */
|
|
18
|
+
export const DEFAULT_MAX_PENDING_STEER_BYTES = 64 * 1024;
|
|
19
|
+
/** Absolute pending steer byte ceiling if hosts later expose overrides. */
|
|
20
|
+
export const HARD_MAX_PENDING_STEER_BYTES = 256 * 1024;
|
|
13
21
|
export const SESSION_ENTRY_KINDS = [
|
|
14
22
|
"message",
|
|
15
23
|
"event",
|
|
@@ -25,6 +33,75 @@ export const SESSION_ENTRY_SCHEMA_VERSION = 1;
|
|
|
25
33
|
export function isSessionEntryKind(value) {
|
|
26
34
|
return typeof value === "string" && SESSION_ENTRY_KIND_SET.has(value);
|
|
27
35
|
}
|
|
36
|
+
/** Host-written `SessionRecord.metadata` / session metadata key for workspace filtering. */
|
|
37
|
+
export const SESSION_SEARCH_WORKSPACE_METADATA_KEY = "workspaceRoot";
|
|
38
|
+
export const DEFAULT_SESSION_SEARCH_LIMIT = 20;
|
|
39
|
+
export const HARD_MAX_SESSION_SEARCH_LIMIT = 100;
|
|
40
|
+
export const DEFAULT_MAX_SESSION_SEARCH_QUERY_BYTES = 4 * 1024;
|
|
41
|
+
export const HARD_MAX_SESSION_SEARCH_QUERY_BYTES = 16 * 1024;
|
|
42
|
+
export const DEFAULT_MAX_SESSION_SEARCH_SNIPPET_BYTES = 512;
|
|
43
|
+
export const HARD_MAX_SESSION_SEARCH_SNIPPET_BYTES = 4 * 1024;
|
|
44
|
+
export const DEFAULT_MAX_SESSION_SEARCH_CURSOR_BYTES = 1 * 1024;
|
|
45
|
+
export const HARD_MAX_SESSION_SEARCH_CURSOR_BYTES = 4 * 1024;
|
|
46
|
+
export const DEFAULT_MAX_SESSION_SEARCH_LINEAR_SESSIONS = 1_000;
|
|
47
|
+
export const HARD_MAX_SESSION_SEARCH_LINEAR_SESSIONS = 5_000;
|
|
48
|
+
export const DEFAULT_MAX_SESSION_SEARCH_LINEAR_ENTRIES = 10_000;
|
|
49
|
+
export const HARD_MAX_SESSION_SEARCH_LINEAR_ENTRIES = 50_000;
|
|
50
|
+
export const DEFAULT_MAX_SESSION_SEARCH_LINEAR_BYTES = 8 * 1024 * 1024;
|
|
51
|
+
export const HARD_MAX_SESSION_SEARCH_LINEAR_BYTES = 64 * 1024 * 1024;
|
|
52
|
+
export const DEFAULT_MAX_SESSION_SEARCH_FTS_CANDIDATES = 1_000;
|
|
53
|
+
export const HARD_MAX_SESSION_SEARCH_FTS_CANDIDATES = 5_000;
|
|
54
|
+
/**
|
|
55
|
+
* O(1) validation before any scan/query. Applies default page limit; rejects NaN,
|
|
56
|
+
* non-positive limits, oversize query/cursor/filter strings, and invalid order.
|
|
57
|
+
*/
|
|
58
|
+
export function resolveSessionSearchQuery(query) {
|
|
59
|
+
const limit = query.limit === undefined ? DEFAULT_SESSION_SEARCH_LIMIT : query.limit;
|
|
60
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > HARD_MAX_SESSION_SEARCH_LIMIT) {
|
|
61
|
+
throw new TypeError(`SessionSearchQuery.limit must be a safe integer from 1 to ${HARD_MAX_SESSION_SEARCH_LIMIT}`);
|
|
62
|
+
}
|
|
63
|
+
const order = query.order ?? "desc";
|
|
64
|
+
if (order !== "asc" && order !== "desc") {
|
|
65
|
+
throw new TypeError('SessionSearchQuery.order must be "asc" or "desc"');
|
|
66
|
+
}
|
|
67
|
+
assertSearchStringBytes(query.query, "query", HARD_MAX_SESSION_SEARCH_QUERY_BYTES);
|
|
68
|
+
assertSearchStringBytes(query.cursor, "cursor", HARD_MAX_SESSION_SEARCH_CURSOR_BYTES);
|
|
69
|
+
assertSearchStringBytes(query.workspaceRoot, "workspaceRoot", HARD_MAX_SESSION_SEARCH_QUERY_BYTES);
|
|
70
|
+
assertSearchStringBytes(query.provider, "provider", HARD_MAX_SESSION_SEARCH_QUERY_BYTES);
|
|
71
|
+
assertSearchStringBytes(query.model, "model", HARD_MAX_SESSION_SEARCH_QUERY_BYTES);
|
|
72
|
+
assertSearchStringBytes(query.label, "label", HARD_MAX_SESSION_SEARCH_QUERY_BYTES);
|
|
73
|
+
assertSearchStringBytes(query.summary, "summary", HARD_MAX_SESSION_SEARCH_QUERY_BYTES);
|
|
74
|
+
assertSearchStringBytes(query.tenantId, "tenantId", HARD_MAX_SESSION_SEARCH_QUERY_BYTES);
|
|
75
|
+
assertSearchStringBytes(query.accountId, "accountId", HARD_MAX_SESSION_SEARCH_QUERY_BYTES);
|
|
76
|
+
assertSearchStringBytes(query.userId, "userId", HARD_MAX_SESSION_SEARCH_QUERY_BYTES);
|
|
77
|
+
assertSearchStringBytes(query.fromUpdatedAt, "fromUpdatedAt", HARD_MAX_SESSION_SEARCH_QUERY_BYTES);
|
|
78
|
+
assertSearchStringBytes(query.toUpdatedAt, "toUpdatedAt", HARD_MAX_SESSION_SEARCH_QUERY_BYTES);
|
|
79
|
+
return { ...query, limit, order };
|
|
80
|
+
}
|
|
81
|
+
function assertSearchStringBytes(value, name, hardMax) {
|
|
82
|
+
if (value === undefined)
|
|
83
|
+
return;
|
|
84
|
+
if (typeof value !== "string") {
|
|
85
|
+
throw new TypeError(`SessionSearchQuery.${name} must be a string`);
|
|
86
|
+
}
|
|
87
|
+
// ponytail: UTF-8 byte length via TextEncoder; upgrade only if a non-Unicode host appears.
|
|
88
|
+
const bytes = new TextEncoder().encode(value).byteLength;
|
|
89
|
+
if (bytes > hardMax) {
|
|
90
|
+
throw new TypeError(`SessionSearchQuery.${name} exceeds ${hardMax} bytes`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export const SESSION_SEARCH_UNSUPPORTED_CODE = "session_search_unsupported";
|
|
94
|
+
/** Thrown when a store opts out of `searchSessions` (memory `unsupported`, JSONL). */
|
|
95
|
+
export class SessionSearchUnsupportedError extends Error {
|
|
96
|
+
code = SESSION_SEARCH_UNSUPPORTED_CODE;
|
|
97
|
+
constructor(message = "session search is unsupported by this store") {
|
|
98
|
+
super(message);
|
|
99
|
+
this.name = "SessionSearchUnsupportedError";
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export function isSessionSearchUnsupported(error) {
|
|
103
|
+
return error instanceof Error && error.code === SESSION_SEARCH_UNSUPPORTED_CODE;
|
|
104
|
+
}
|
|
28
105
|
/** Stable error code carried by `SessionAppendConflictError`. */
|
|
29
106
|
export const SESSION_APPEND_CONFLICT_CODE = "session_append_conflict";
|
|
30
107
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type * from "./contracts.js";
|
|
2
2
|
export type { RunLimitCounters, RunLimitName, SecureAgentOptions } from "./contracts.js";
|
|
3
|
-
export { isSessionEntryKind, SESSION_APPEND_CONFLICT_CODE, SESSION_ENTRY_KINDS, SESSION_ENTRY_SCHEMA_VERSION, SessionAppendConflictError, isSessionAppendConflict, AgentRunError, AgentRunStateError } from "./contracts.js";
|
|
3
|
+
export { isSessionEntryKind, SESSION_APPEND_CONFLICT_CODE, SESSION_ENTRY_KINDS, SESSION_ENTRY_SCHEMA_VERSION, SessionAppendConflictError, isSessionAppendConflict, AgentRunError, AgentRunStateError, SESSION_SEARCH_WORKSPACE_METADATA_KEY, SESSION_SEARCH_UNSUPPORTED_CODE, SessionSearchUnsupportedError, isSessionSearchUnsupported, DEFAULT_SESSION_SEARCH_LIMIT, HARD_MAX_SESSION_SEARCH_LIMIT, DEFAULT_MAX_SESSION_SEARCH_QUERY_BYTES, HARD_MAX_SESSION_SEARCH_QUERY_BYTES, DEFAULT_MAX_SESSION_SEARCH_SNIPPET_BYTES, HARD_MAX_SESSION_SEARCH_SNIPPET_BYTES, DEFAULT_MAX_SESSION_SEARCH_CURSOR_BYTES, HARD_MAX_SESSION_SEARCH_CURSOR_BYTES, DEFAULT_MAX_SESSION_SEARCH_LINEAR_SESSIONS, HARD_MAX_SESSION_SEARCH_LINEAR_SESSIONS, DEFAULT_MAX_SESSION_SEARCH_LINEAR_ENTRIES, HARD_MAX_SESSION_SEARCH_LINEAR_ENTRIES, DEFAULT_MAX_SESSION_SEARCH_LINEAR_BYTES, HARD_MAX_SESSION_SEARCH_LINEAR_BYTES, DEFAULT_MAX_SESSION_SEARCH_FTS_CANDIDATES, HARD_MAX_SESSION_SEARCH_FTS_CANDIDATES, resolveSessionSearchQuery, DEFAULT_MAX_PENDING_STEERS, HARD_MAX_PENDING_STEERS, DEFAULT_MAX_PENDING_STEER_BYTES, HARD_MAX_PENDING_STEER_BYTES } from "./contracts.js";
|
|
4
4
|
export { createAgent, createAgentSession, resumeAgentRun } from "./agents.js";
|
|
5
5
|
export { createBatchedRunLedger, isFlushableRunLedger, DEFAULT_LEDGER_BATCH_ENTRIES, HARD_LEDGER_BATCH_ENTRIES, DEFAULT_LEDGER_BATCH_BYTES, HARD_LEDGER_BATCH_BYTES, DEFAULT_LEDGER_BATCH_DELAY_MS, HARD_LEDGER_BATCH_DELAY_MS, } from "./run-ledger.js";
|
|
6
6
|
export type { BatchedRunLedgerOptions } from "./run-ledger.js";
|
|
@@ -34,7 +34,7 @@ export type { ExtensionErrorPolicy, ExtensionEventBus, ExtensionEventHandler, Ex
|
|
|
34
34
|
export type { CredentialRecord, CredentialValueSource, MemoryCredentialStore } from "./credentials.js";
|
|
35
35
|
export { createModelRegistry } from "./models.js";
|
|
36
36
|
export { authMethodKey, defineProviderPackage, systemPromptContributionKey } from "./provider-packages.js";
|
|
37
|
-
export { assertStructuredOutputRequestSupported, DEFAULT_MAX_STRUCTURED_OUTPUT_NAME_LENGTH, DEFAULT_MAX_STRUCTURED_OUTPUT_SCHEMA_BYTES, modelSupportsStructuredOutput, resolveRunProviderOptions, StructuredOutputError, validateStructuredOutputOptions, } from "./structured-output.js";
|
|
37
|
+
export { assertStructuredOutputRequestSupported, artifactStructuredOutputRequest, DEFAULT_MAX_STRUCTURED_OUTPUT_NAME_LENGTH, DEFAULT_MAX_STRUCTURED_OUTPUT_SCHEMA_BYTES, modelSupportsStructuredOutput, resolveRunProviderOptions, StructuredOutputError, validateStructuredOutputOptions, withoutStructuredOutput, } from "./structured-output.js";
|
|
38
38
|
export { createProviderTurnMetadata, readProviderHttpStatus } from "./observability.js";
|
|
39
39
|
export { createProviderRequestPolicyChain, createSessionCachePolicy, mergeProviderRequestOptions } from "./provider-request-policy.js";
|
|
40
40
|
export type { SessionCachePolicyOptions } from "./provider-request-policy.js";
|
|
@@ -55,12 +55,14 @@ export { createChainedSettingsProvider, createStaticSettingsProvider } from "./s
|
|
|
55
55
|
export { createMiddlewareRegistry } from "./middleware.js";
|
|
56
56
|
export type { Middleware, MiddlewareHookName, MiddlewareNext, MiddlewareRegistry, MiddlewareRegistryOptions } from "./middleware.js";
|
|
57
57
|
export { assembleProviderInput, createDefaultInputBuilder, createDefaultPromptBuilder, renderPromptTemplate, resolveContextProviders } from "./input.js";
|
|
58
|
+
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";
|
|
59
|
+
export type { ContextBudget, ContextBudgetMessageGroups, ContextBudgetOmission, ContextBudgetOmissionKind, ContextBudgetReport, } from "./context-budget.js";
|
|
58
60
|
export type { AgentInput, AssembleProviderInputOptions, DefaultInputBuilder, DefaultInputBuildContext, DefaultPromptBuilder, InputAttachment, PromptInstruction, PromptTemplateOptions, ResolveContextOptions } from "./input.js";
|
|
59
61
|
export { createMockProvider } from "./mock-provider.js";
|
|
60
62
|
export { createMemorySessionStore, createSessionEntry, getSessionBranchEntries, listSessionBranches, rebuildSessionContext } from "./session-stores.js";
|
|
61
|
-
export type { CreateSessionEntryOptions, SessionBranch, SessionBranchOptions, SessionContextSnapshot } from "./session-stores.js";
|
|
63
|
+
export type { CreateMemorySessionStoreOptions, CreateSessionEntryOptions, MemorySessionSearchMode, SessionBranch, SessionBranchOptions, SessionContextSnapshot } from "./session-stores.js";
|
|
62
64
|
export type { MockProviderOptions } from "./mock-provider.js";
|
|
63
|
-
export { providerContentDelta, providerDone, providerError, providerTextDelta, providerThinkingDelta, providerToolCall, providerToolCallDelta, providerUsage, toolCallContent, } from "./provider-events.js";
|
|
65
|
+
export { providerContentDelta, providerDone, providerError, providerTextDelta, providerThinkingDelta, providerToolCall, providerToolCallDelta, providerUsage, toolCallContent, toolCallFromArgumentsText, } from "./provider-events.js";
|
|
64
66
|
export type { ProviderResolver } from "./contracts.js";
|
|
65
67
|
export { createProviderRegistry, createProviderResolver } from "./providers.js";
|
|
66
68
|
export type { ProviderRegistry, ProviderRegistryOptions } from "./providers.js";
|
|
@@ -83,5 +85,5 @@ export type { DispatchToolCallOptions, ToolArgumentValidationError, ToolArgument
|
|
|
83
85
|
export type { DuplicateRegistrationOptions, DuplicateRegistrationPolicy } from "./registry-options.js";
|
|
84
86
|
export { dispatchToolCallsInOrder, generateValidateReviseLoop, isAgentLoopOptions, resolveLoop, resolveToolConcurrency, singleShotLoop } from "./agent-loops.js";
|
|
85
87
|
export declare const name = "prism";
|
|
86
|
-
export declare const version = "0.0.
|
|
88
|
+
export declare const version = "0.0.11";
|
|
87
89
|
export declare const description = "Agent harness for AI providers, agents, sessions, and tools.";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { isSessionEntryKind, SESSION_APPEND_CONFLICT_CODE, SESSION_ENTRY_KINDS, SESSION_ENTRY_SCHEMA_VERSION, SessionAppendConflictError, isSessionAppendConflict, AgentRunError, AgentRunStateError } from "./contracts.js";
|
|
1
|
+
export { isSessionEntryKind, SESSION_APPEND_CONFLICT_CODE, SESSION_ENTRY_KINDS, SESSION_ENTRY_SCHEMA_VERSION, SessionAppendConflictError, isSessionAppendConflict, AgentRunError, AgentRunStateError, SESSION_SEARCH_WORKSPACE_METADATA_KEY, SESSION_SEARCH_UNSUPPORTED_CODE, SessionSearchUnsupportedError, isSessionSearchUnsupported, DEFAULT_SESSION_SEARCH_LIMIT, HARD_MAX_SESSION_SEARCH_LIMIT, DEFAULT_MAX_SESSION_SEARCH_QUERY_BYTES, HARD_MAX_SESSION_SEARCH_QUERY_BYTES, DEFAULT_MAX_SESSION_SEARCH_SNIPPET_BYTES, HARD_MAX_SESSION_SEARCH_SNIPPET_BYTES, DEFAULT_MAX_SESSION_SEARCH_CURSOR_BYTES, HARD_MAX_SESSION_SEARCH_CURSOR_BYTES, DEFAULT_MAX_SESSION_SEARCH_LINEAR_SESSIONS, HARD_MAX_SESSION_SEARCH_LINEAR_SESSIONS, DEFAULT_MAX_SESSION_SEARCH_LINEAR_ENTRIES, HARD_MAX_SESSION_SEARCH_LINEAR_ENTRIES, DEFAULT_MAX_SESSION_SEARCH_LINEAR_BYTES, HARD_MAX_SESSION_SEARCH_LINEAR_BYTES, DEFAULT_MAX_SESSION_SEARCH_FTS_CANDIDATES, HARD_MAX_SESSION_SEARCH_FTS_CANDIDATES, resolveSessionSearchQuery, DEFAULT_MAX_PENDING_STEERS, HARD_MAX_PENDING_STEERS, DEFAULT_MAX_PENDING_STEER_BYTES, HARD_MAX_PENDING_STEER_BYTES } from "./contracts.js";
|
|
2
2
|
export { createAgent, createAgentSession, resumeAgentRun } from "./agents.js";
|
|
3
3
|
export { createBatchedRunLedger, isFlushableRunLedger, DEFAULT_LEDGER_BATCH_ENTRIES, HARD_LEDGER_BATCH_ENTRIES, DEFAULT_LEDGER_BATCH_BYTES, HARD_LEDGER_BATCH_BYTES, DEFAULT_LEDGER_BATCH_DELAY_MS, HARD_LEDGER_BATCH_DELAY_MS, } from "./run-ledger.js";
|
|
4
4
|
export { createSecureAgent } from "./secure-agent.js";
|
|
@@ -19,7 +19,7 @@ export { createChainedCredentialResolver, createEnvCredentialResolver, createExp
|
|
|
19
19
|
export { createExtensionEventBus, createExtensionKernel } from "./extensions.js";
|
|
20
20
|
export { createModelRegistry } from "./models.js";
|
|
21
21
|
export { authMethodKey, defineProviderPackage, systemPromptContributionKey } from "./provider-packages.js";
|
|
22
|
-
export { assertStructuredOutputRequestSupported, DEFAULT_MAX_STRUCTURED_OUTPUT_NAME_LENGTH, DEFAULT_MAX_STRUCTURED_OUTPUT_SCHEMA_BYTES, modelSupportsStructuredOutput, resolveRunProviderOptions, StructuredOutputError, validateStructuredOutputOptions, } from "./structured-output.js";
|
|
22
|
+
export { assertStructuredOutputRequestSupported, artifactStructuredOutputRequest, DEFAULT_MAX_STRUCTURED_OUTPUT_NAME_LENGTH, DEFAULT_MAX_STRUCTURED_OUTPUT_SCHEMA_BYTES, modelSupportsStructuredOutput, resolveRunProviderOptions, StructuredOutputError, validateStructuredOutputOptions, withoutStructuredOutput, } from "./structured-output.js";
|
|
23
23
|
export { createProviderTurnMetadata, readProviderHttpStatus } from "./observability.js";
|
|
24
24
|
export { createProviderRequestPolicyChain, createSessionCachePolicy, mergeProviderRequestOptions } from "./provider-request-policy.js";
|
|
25
25
|
export { THINKING_LEVELS, applyThinkingLevel, isThinkingLevel, normalizeThinkingLevel, thinkingCompatFor, thinkingFamilyForModel, } from "./thinking.js";
|
|
@@ -31,9 +31,10 @@ export { loadBinaryResource, loadJsonResource, loadManifestResource, loadTextRes
|
|
|
31
31
|
export { createChainedSettingsProvider, createStaticSettingsProvider } from "./settings.js";
|
|
32
32
|
export { createMiddlewareRegistry } from "./middleware.js";
|
|
33
33
|
export { assembleProviderInput, createDefaultInputBuilder, createDefaultPromptBuilder, renderPromptTemplate, resolveContextProviders } from "./input.js";
|
|
34
|
+
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";
|
|
34
35
|
export { createMockProvider } from "./mock-provider.js";
|
|
35
36
|
export { createMemorySessionStore, createSessionEntry, getSessionBranchEntries, listSessionBranches, rebuildSessionContext } from "./session-stores.js";
|
|
36
|
-
export { providerContentDelta, providerDone, providerError, providerTextDelta, providerThinkingDelta, providerToolCall, providerToolCallDelta, providerUsage, toolCallContent, } from "./provider-events.js";
|
|
37
|
+
export { providerContentDelta, providerDone, providerError, providerTextDelta, providerThinkingDelta, providerToolCall, providerToolCallDelta, providerUsage, toolCallContent, toolCallFromArgumentsText, } from "./provider-events.js";
|
|
37
38
|
export { createProviderRegistry, createProviderResolver } from "./providers.js";
|
|
38
39
|
export { createSecretRedactor, errorToErrorInfo, redactAgentEvent, redactMessage, redactProviderRequest, redactRunLedgerRecord, redactSecrets, redactSessionEntry } from "./redaction.js";
|
|
39
40
|
export { assertPermission, assertTrusted, checkPermission, createStaticPermissionPolicy, createStaticTrustPolicy, denialToErrorInfo, isTrusted, PermissionDeniedError, TrustDeniedError } from "./security.js";
|
|
@@ -45,6 +46,6 @@ export { assertGuardrailsAllowed, GuardrailError, MAX_GUARDRAIL_CONCURRENCY, run
|
|
|
45
46
|
export { createRunLimitTracker, DEFAULT_RUN_LIMITS, HARD_MAX_RUN_COST, HARD_RUN_LIMITS, RunLimitError, RunLimitTracker, resolveRunLimits } from "./run-limits.js";
|
|
46
47
|
export { dispatchToolCallsInOrder, generateValidateReviseLoop, isAgentLoopOptions, resolveLoop, resolveToolConcurrency, singleShotLoop } from "./agent-loops.js";
|
|
47
48
|
export const name = "prism";
|
|
48
|
-
export const version = "0.0.
|
|
49
|
+
export const version = "0.0.11";
|
|
49
50
|
export const description = "Agent harness for AI providers, agents, sessions, and tools.";
|
|
50
51
|
//# sourceMappingURL=index.js.map
|
package/dist/input.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ContentBlock, ContextBlock, ContextProvider, ContextResolutionContext, InputBuilder, InstructionInjector, InputBuildContext, JsonObject, Message, ModelConfig, PromptBuilder, PromptBuildRequest, ProviderRequest, ProviderRequestOptions, ResourceLoader, Skill, ToolDefinition, ToolResult } from "./contracts.js";
|
|
2
2
|
import type { MiddlewareRegistry } from "./middleware.js";
|
|
3
3
|
import type { SecretRedactor } from "./redaction.js";
|
|
4
|
+
import { type ContextBudget } from "./context-budget.js";
|
|
4
5
|
export type AgentInput = string | Message | readonly Message[];
|
|
5
6
|
export interface PromptInstruction {
|
|
6
7
|
readonly text: string;
|
|
@@ -54,6 +55,8 @@ export interface AssembleProviderInputOptions extends DefaultInputBuildContext {
|
|
|
54
55
|
readonly skills?: readonly Skill[];
|
|
55
56
|
readonly tools?: readonly ToolDefinition[];
|
|
56
57
|
readonly providerOptions?: ProviderRequestOptions;
|
|
58
|
+
/** Assembler-time eviction; does not delete session store history. */
|
|
59
|
+
readonly contextBudget?: ContextBudget;
|
|
57
60
|
}
|
|
58
61
|
export declare function createDefaultInputBuilder(): DefaultInputBuilder;
|
|
59
62
|
export declare function resolveContextProviders(options: ResolveContextOptions): Promise<readonly ContextBlock[]>;
|