@arnilo/prism 0.0.10 → 0.0.12
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 +27 -0
- package/dist/agent-loops.d.ts +1 -0
- package/dist/agent-loops.js +37 -2
- package/dist/agent-run-lifecycle.d.ts +5 -1
- package/dist/agent-run-lifecycle.js +17 -1
- package/dist/agents.d.ts +3 -1
- package/dist/agents.js +202 -24
- package/dist/context-budget.d.ts +63 -0
- package/dist/context-budget.js +235 -0
- package/dist/contracts.d.ts +109 -0
- package/dist/contracts.js +77 -0
- package/dist/index.d.ts +8 -6
- 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/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/docs/a2a.md +1 -0
- package/docs/ag-ui.md +123 -0
- package/docs/agent-events.md +2 -1
- package/docs/agent-loops.md +8 -1
- package/docs/agent-session-runtime.md +10 -2
- package/docs/cli-rpc.md +2 -1
- package/docs/coding-agent-tools.md +70 -1
- package/docs/compaction-and-retry.md +2 -1
- package/docs/compaction-llm.md +20 -1
- package/docs/credential-storage.md +2 -1
- package/docs/credentials-and-redaction.md +8 -0
- package/docs/evaluations.md +1 -1
- package/docs/host-security.md +2 -0
- package/docs/index.md +20 -17
- package/docs/input-and-prompt-assembly.md +4 -1
- package/docs/migration.md +32 -0
- package/docs/node-jsonl-session-store.md +1 -1
- package/docs/performance.md +36 -0
- package/docs/postgres-persistence.md +3 -3
- package/docs/provider-packages.md +11 -1
- package/docs/providers/anthropic.md +93 -0
- package/docs/providers/google.md +88 -0
- package/docs/providers/openai.md +2 -2
- package/docs/public-contracts.md +6 -0
- package/docs/release-and-install.md +232 -65
- package/docs/review-coverage-2026-07-22-phase-6.md +209 -0
- package/docs/review-coverage-2026-07-22-phase-7.md +173 -0
- package/docs/runs-and-usage.md +1 -0
- package/docs/server.md +1 -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 +7 -1
- package/docs/workflows.md +2 -0
- package/package.json +3 -2
|
@@ -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
|
@@ -449,6 +449,10 @@ export interface AgentRunResumeOptions {
|
|
|
449
449
|
readonly ownership?: OwnershipScope;
|
|
450
450
|
readonly fencingToken?: number;
|
|
451
451
|
}
|
|
452
|
+
/** Bounded, abortable options for `resumeAgentRunStream()`. */
|
|
453
|
+
export interface AgentRunResumeStreamOptions extends AgentRunResumeOptions, SubscribeOptions {
|
|
454
|
+
readonly signal?: AbortSignal;
|
|
455
|
+
}
|
|
452
456
|
export interface AgentRunRef {
|
|
453
457
|
readonly runId: string;
|
|
454
458
|
readonly sessionId?: string;
|
|
@@ -493,6 +497,22 @@ export declare class AgentRunError extends Error {
|
|
|
493
497
|
readonly cause?: unknown;
|
|
494
498
|
});
|
|
495
499
|
}
|
|
500
|
+
/** Mid-run steer queue: default pending message count (fail closed at this cap). */
|
|
501
|
+
export declare const DEFAULT_MAX_PENDING_STEERS = 8;
|
|
502
|
+
/** Absolute pending steer count ceiling if hosts later expose overrides. */
|
|
503
|
+
export declare const HARD_MAX_PENDING_STEERS = 32;
|
|
504
|
+
/** Mid-run steer queue: default total UTF-8 byte budget across pending messages. */
|
|
505
|
+
export declare const DEFAULT_MAX_PENDING_STEER_BYTES: number;
|
|
506
|
+
/** Absolute pending steer byte ceiling if hosts later expose overrides. */
|
|
507
|
+
export declare const HARD_MAX_PENDING_STEER_BYTES: number;
|
|
508
|
+
export interface SteerOptions {
|
|
509
|
+
/**
|
|
510
|
+
* When true, abort the in-flight provider stream and continue the same run after
|
|
511
|
+
* injecting steered user text. Default false: inject before the next provider turn
|
|
512
|
+
* (after the current tool batch completes).
|
|
513
|
+
*/
|
|
514
|
+
readonly softInterrupt?: boolean;
|
|
515
|
+
}
|
|
496
516
|
export interface AgentSession {
|
|
497
517
|
readonly id: string;
|
|
498
518
|
/** Current branch leaf entry id; advances on every append/run and is re-pointed by `checkout`.
|
|
@@ -500,6 +520,12 @@ export interface AgentSession {
|
|
|
500
520
|
readonly leafId: string | undefined;
|
|
501
521
|
run(input: string | Message | readonly Message[], options?: RunOptions): Promise<AgentRunResult>;
|
|
502
522
|
prompt(input: string, options?: RunOptions): Promise<AgentRunResult>;
|
|
523
|
+
/**
|
|
524
|
+
* Enqueue user text into an active run. Default injects before the next provider turn.
|
|
525
|
+
* `softInterrupt: true` aborts the current provider stream, then continues the same run.
|
|
526
|
+
* Fails closed when no run is active or the pending queue exceeds caps.
|
|
527
|
+
*/
|
|
528
|
+
steer(input: string | Message | readonly Message[], options?: SteerOptions): void;
|
|
503
529
|
/** Subscribe first, then start exactly one run and yield only that run's events until it terminates. */
|
|
504
530
|
stream(input: string | Message | readonly Message[], options?: RunOptions & SubscribeOptions): AsyncIterable<AgentEvent>;
|
|
505
531
|
compact(options?: CompactionOptions): Promise<CompactionResult>;
|
|
@@ -1022,7 +1048,80 @@ export interface SessionStore {
|
|
|
1022
1048
|
* avoid `list(sessionId)` (full-session scan) + in-memory rebuild. Optional — the
|
|
1023
1049
|
* built-in memory/JSONL stores omit it and the runtime falls back to `list()`. */
|
|
1024
1050
|
readBranchPath?(query: SessionBranchRead): Promise<PersistencePage<SessionEntry>>;
|
|
1051
|
+
/**
|
|
1052
|
+
* Optional bounded session search. Prefer implementing this **or** returning a companion
|
|
1053
|
+
* `SessionIndex` from the adapter factory — hosts must not need both. Call
|
|
1054
|
+
* `resolveSessionSearchQuery` before scan/query. Memory defaults to capped linear
|
|
1055
|
+
* search (`sessionSearchMode: "unsupported"` throws). JSONL throws unsupported.
|
|
1056
|
+
*/
|
|
1057
|
+
searchSessions?(query: SessionSearchQuery): Promise<PersistencePage<SessionSearchHit>>;
|
|
1058
|
+
}
|
|
1059
|
+
/** Host-written `SessionRecord.metadata` / session metadata key for workspace filtering. */
|
|
1060
|
+
export declare const SESSION_SEARCH_WORKSPACE_METADATA_KEY: "workspaceRoot";
|
|
1061
|
+
export declare const DEFAULT_SESSION_SEARCH_LIMIT = 20;
|
|
1062
|
+
export declare const HARD_MAX_SESSION_SEARCH_LIMIT = 100;
|
|
1063
|
+
export declare const DEFAULT_MAX_SESSION_SEARCH_QUERY_BYTES: number;
|
|
1064
|
+
export declare const HARD_MAX_SESSION_SEARCH_QUERY_BYTES: number;
|
|
1065
|
+
export declare const DEFAULT_MAX_SESSION_SEARCH_SNIPPET_BYTES = 512;
|
|
1066
|
+
export declare const HARD_MAX_SESSION_SEARCH_SNIPPET_BYTES: number;
|
|
1067
|
+
export declare const DEFAULT_MAX_SESSION_SEARCH_CURSOR_BYTES: number;
|
|
1068
|
+
export declare const HARD_MAX_SESSION_SEARCH_CURSOR_BYTES: number;
|
|
1069
|
+
export declare const DEFAULT_MAX_SESSION_SEARCH_LINEAR_SESSIONS = 1000;
|
|
1070
|
+
export declare const HARD_MAX_SESSION_SEARCH_LINEAR_SESSIONS = 5000;
|
|
1071
|
+
export declare const DEFAULT_MAX_SESSION_SEARCH_LINEAR_ENTRIES = 10000;
|
|
1072
|
+
export declare const HARD_MAX_SESSION_SEARCH_LINEAR_ENTRIES = 50000;
|
|
1073
|
+
export declare const DEFAULT_MAX_SESSION_SEARCH_LINEAR_BYTES: number;
|
|
1074
|
+
export declare const HARD_MAX_SESSION_SEARCH_LINEAR_BYTES: number;
|
|
1075
|
+
export declare const DEFAULT_MAX_SESSION_SEARCH_FTS_CANDIDATES = 1000;
|
|
1076
|
+
export declare const HARD_MAX_SESSION_SEARCH_FTS_CANDIDATES = 5000;
|
|
1077
|
+
/** Bounded session search filters. Workspace matches host-written `metadata.workspaceRoot`. */
|
|
1078
|
+
export interface SessionSearchQuery extends PersistenceQuery, OwnershipScope {
|
|
1079
|
+
readonly workspaceRoot?: string;
|
|
1080
|
+
/** Optional full-text / message+summary query (adapter-defined matching). */
|
|
1081
|
+
readonly query?: string;
|
|
1082
|
+
readonly provider?: string;
|
|
1083
|
+
readonly model?: string;
|
|
1084
|
+
readonly label?: string;
|
|
1085
|
+
readonly summary?: string;
|
|
1086
|
+
readonly fromUpdatedAt?: string;
|
|
1087
|
+
readonly toUpdatedAt?: string;
|
|
1088
|
+
readonly signal?: AbortSignal;
|
|
1025
1089
|
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Safe search hit for resume/checkout. Never includes credentials or raw full transcripts.
|
|
1092
|
+
* `leafId` is the branch tip for `session.checkout` when known.
|
|
1093
|
+
*/
|
|
1094
|
+
export interface SessionSearchHit {
|
|
1095
|
+
readonly sessionId: string;
|
|
1096
|
+
readonly leafId?: string;
|
|
1097
|
+
readonly updatedAt?: string;
|
|
1098
|
+
readonly label?: string;
|
|
1099
|
+
readonly summary?: string;
|
|
1100
|
+
readonly snippet?: string;
|
|
1101
|
+
/** Safe display fields only (e.g. workspaceRoot); never credentials. */
|
|
1102
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
1103
|
+
}
|
|
1104
|
+
/** Narrow search seam; adapters may implement this instead of `SessionStore.searchSessions`. */
|
|
1105
|
+
export interface SessionIndex {
|
|
1106
|
+
search(query: SessionSearchQuery): Promise<PersistencePage<SessionSearchHit>>;
|
|
1107
|
+
}
|
|
1108
|
+
/** Validated search query with finite `limit` / `order` filled in. */
|
|
1109
|
+
export interface ResolvedSessionSearchQuery extends SessionSearchQuery {
|
|
1110
|
+
readonly limit: number;
|
|
1111
|
+
readonly order: "asc" | "desc";
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* O(1) validation before any scan/query. Applies default page limit; rejects NaN,
|
|
1115
|
+
* non-positive limits, oversize query/cursor/filter strings, and invalid order.
|
|
1116
|
+
*/
|
|
1117
|
+
export declare function resolveSessionSearchQuery(query: SessionSearchQuery): ResolvedSessionSearchQuery;
|
|
1118
|
+
export declare const SESSION_SEARCH_UNSUPPORTED_CODE: "session_search_unsupported";
|
|
1119
|
+
/** Thrown when a store opts out of `searchSessions` (memory `unsupported`, JSONL). */
|
|
1120
|
+
export declare class SessionSearchUnsupportedError extends Error {
|
|
1121
|
+
readonly code: "session_search_unsupported";
|
|
1122
|
+
constructor(message?: string);
|
|
1123
|
+
}
|
|
1124
|
+
export declare function isSessionSearchUnsupported(error: unknown): error is SessionSearchUnsupportedError;
|
|
1026
1125
|
/** Query for a single branch's ancestor chain (DB-friendly: one recursive/ancestor query
|
|
1027
1126
|
* instead of a full-session scan). Honored by `SessionStore.readBranchPath` and the pure
|
|
1028
1127
|
* branch helpers' reader overload. `leafId` is optional (omit for the latest leaf). */
|
|
@@ -1642,6 +1741,10 @@ export interface LoopContext {
|
|
|
1642
1741
|
isToolCallExclusive?(call: ToolCallContent): boolean;
|
|
1643
1742
|
appendMessage(message: Message): Promise<void>;
|
|
1644
1743
|
emit(event: AgentEvent): void;
|
|
1744
|
+
/** True when mid-run steers are queued for the next provider turn. */
|
|
1745
|
+
hasPendingSteers?(): boolean;
|
|
1746
|
+
/** Drain pending steers into history/session. Returns true when any were applied. */
|
|
1747
|
+
applyPendingSteers?(): Promise<boolean>;
|
|
1645
1748
|
}
|
|
1646
1749
|
export interface AgentLoopStrategy {
|
|
1647
1750
|
readonly name: string;
|
|
@@ -1663,6 +1766,12 @@ export type AgentLoopOptions = {
|
|
|
1663
1766
|
readonly structuredOutput?: StructuredOutputOptions;
|
|
1664
1767
|
/** `native` maps schema to capable providers; `artifact-loop` keeps repair turns only. */
|
|
1665
1768
|
readonly structuredOutputMode?: "native" | "artifact-loop";
|
|
1769
|
+
/**
|
|
1770
|
+
* When to attach native `structuredOutput` under `toolCalls: "bounded"`.
|
|
1771
|
+
* `every-turn` (default): schema on every provider request (legacy).
|
|
1772
|
+
* `final-turn-only`: tool-eligible turns omit schema; artifact/revision turns send schema and withdraw tools.
|
|
1773
|
+
*/
|
|
1774
|
+
readonly structuredOutputTiming?: "every-turn" | "final-turn-only";
|
|
1666
1775
|
};
|
|
1667
1776
|
export interface ArtifactValidation {
|
|
1668
1777
|
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,7 +1,7 @@
|
|
|
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";
|
|
4
|
-
export { createAgent, createAgentSession, resumeAgentRun } from "./agents.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
|
+
export { createAgent, createAgentSession, resumeAgentRun, resumeAgentRunStream } 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";
|
|
7
7
|
export { createSecureAgent } from "./secure-agent.js";
|
|
@@ -11,7 +11,7 @@ export { CHECKPOINT_CONFLICT_CODE, CheckpointConflictError, createMemoryCheckpoi
|
|
|
11
11
|
export { AGENT_RUN_STATE_NAMESPACE, AGENT_RUN_STATE_SCHEMA_VERSION, DEFAULT_MAX_AGENT_RUN_STATE_BYTES, HARD_MAX_AGENT_RUN_STATE_BYTES, agentFingerprint, loadAgentRunState } from "./agent-run-state.js";
|
|
12
12
|
export type { StoredAgentRunState } from "./agent-run-state.js";
|
|
13
13
|
export { createAgentRunLifecycle } from "./agent-run-lifecycle.js";
|
|
14
|
-
export type { AgentRunLifecycle, AgentRunLifecycleAgent, AgentRunLifecycleOptions, AgentRunLifecycleRequest } from "./agent-run-lifecycle.js";
|
|
14
|
+
export type { AgentRunLifecycle, AgentRunLifecycleAgent, AgentRunLifecycleOptions, AgentRunLifecycleRequest, AgentRunLifecycleStreamRequest } from "./agent-run-lifecycle.js";
|
|
15
15
|
export type { MemoryCheckpointStoreOptions } from "./checkpoints.js";
|
|
16
16
|
export { LEASE_CONFLICT_CODE, LeaseConflictError, createMemoryLeaseStore } from "./leases.js";
|
|
17
17
|
export { createEventMultiplexer } from "./event-multiplexer.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,10 +55,12 @@ 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
65
|
export { providerContentDelta, providerDone, providerError, providerTextDelta, providerThinkingDelta, providerToolCall, providerToolCallDelta, providerUsage, toolCallContent, toolCallFromArgumentsText, } from "./provider-events.js";
|
|
64
66
|
export type { ProviderResolver } from "./contracts.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.12";
|
|
87
89
|
export declare const description = "Agent harness for AI providers, agents, sessions, and tools.";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { isSessionEntryKind, SESSION_APPEND_CONFLICT_CODE, SESSION_ENTRY_KINDS, SESSION_ENTRY_SCHEMA_VERSION, SessionAppendConflictError, isSessionAppendConflict, AgentRunError, AgentRunStateError } from "./contracts.js";
|
|
2
|
-
export { createAgent, createAgentSession, resumeAgentRun } from "./agents.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
|
+
export { createAgent, createAgentSession, resumeAgentRun, resumeAgentRunStream } 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";
|
|
5
5
|
export { createMemoryRunFeedbackStore, prepareRunFeedback, requireRunFeedbackOwnership, runFeedbackPageLimit, RunFeedbackError, } from "./feedback.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,6 +31,7 @@ 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
37
|
export { providerContentDelta, providerDone, providerError, providerTextDelta, providerThinkingDelta, providerToolCall, providerToolCallDelta, providerUsage, toolCallContent, toolCallFromArgumentsText, } from "./provider-events.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.12";
|
|
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[]>;
|