nexus-ai-pro 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API_STABILITY.md +39 -0
- package/CHANGELOG.md +142 -1
- package/README.md +10 -5
- package/dist/agent/capabilities.d.ts +39 -0
- package/dist/agent/capabilities.js +36 -0
- package/dist/agent/create-agent.d.ts +61 -11
- package/dist/agent/create-agent.js +136 -22
- package/dist/agent/index.d.ts +3 -2
- package/dist/agent/index.js +1 -1
- package/dist/agent/middleware/approval.d.ts +26 -0
- package/dist/agent/middleware/approval.js +23 -0
- package/dist/agent/{middleware.d.ts → middleware/basic.d.ts} +5 -4
- package/dist/agent/{middleware.js → middleware/basic.js} +3 -5
- package/dist/agent/middleware/context-editor.d.ts +52 -0
- package/dist/agent/middleware/context-editor.js +66 -0
- package/dist/agent/middleware/filesystem.d.ts +44 -0
- package/dist/agent/middleware/filesystem.js +83 -0
- package/dist/agent/middleware/index.d.ts +19 -0
- package/dist/agent/middleware/index.js +9 -0
- package/dist/agent/middleware/limits.d.ts +42 -0
- package/dist/agent/middleware/limits.js +52 -0
- package/dist/agent/middleware/models.d.ts +48 -0
- package/dist/agent/middleware/models.js +44 -0
- package/dist/agent/middleware/pii.d.ts +67 -0
- package/dist/agent/middleware/pii.js +173 -0
- package/dist/agent/middleware/retry.d.ts +66 -0
- package/dist/agent/middleware/retry.js +59 -0
- package/dist/agent/middleware/shared.d.ts +41 -0
- package/dist/agent/middleware/shared.js +73 -0
- package/dist/agent/middleware/tool-selector.d.ts +64 -0
- package/dist/agent/middleware/tool-selector.js +106 -0
- package/dist/agent/permissions.d.ts +113 -0
- package/dist/agent/permissions.js +180 -0
- package/dist/agent/sandbox.d.ts +151 -0
- package/dist/agent/sandbox.js +257 -0
- package/dist/agent/tool.d.ts +8 -3
- package/dist/agent/tool.js +14 -3
- package/dist/deep-agent/index.d.ts +109 -0
- package/dist/deep-agent/index.js +216 -0
- package/dist/graph/functional.d.ts +9 -0
- package/dist/graph/functional.js +20 -3
- package/dist/graph/graph.js +25 -4
- package/dist/graph/lint.d.ts +4 -1
- package/dist/graph/lint.js +35 -0
- package/dist/postgres/fulltext.d.ts +67 -0
- package/dist/postgres/fulltext.js +91 -0
- package/dist/rag/elasticsearch.d.ts +71 -0
- package/dist/rag/elasticsearch.js +130 -0
- package/dist/rag/pipeline.d.ts +140 -0
- package/dist/rag/pipeline.js +187 -0
- package/dist/rag/rerankers.d.ts +92 -0
- package/dist/rag/rerankers.js +97 -0
- package/dist/rag/retrievers.d.ts +12 -1
- package/dist/server/assistant.d.ts +5 -1
- package/dist/server/assistant.js +4 -2
- package/dist/server/auth.d.ts +250 -0
- package/dist/server/auth.js +392 -0
- package/dist/store/memory.d.ts +10 -0
- package/dist/store/memory.js +10 -0
- package/dist/types/graph.d.ts +38 -0
- package/dist/types/messages.d.ts +36 -2
- package/dist/types/principal.d.ts +21 -0
- package/dist/types/principal.js +1 -0
- package/dist/types/server.d.ts +2 -9
- package/dist/utils/tenant.d.ts +11 -0
- package/dist/utils/tenant.js +14 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist-cjs/agent/capabilities.d.ts +39 -0
- package/dist-cjs/agent/capabilities.js +41 -0
- package/dist-cjs/agent/create-agent.d.ts +61 -11
- package/dist-cjs/agent/create-agent.js +136 -22
- package/dist-cjs/agent/index.d.ts +3 -2
- package/dist-cjs/agent/index.js +4 -4
- package/dist-cjs/agent/middleware/approval.d.ts +26 -0
- package/dist-cjs/agent/middleware/approval.js +26 -0
- package/dist-cjs/agent/{middleware.d.ts → middleware/basic.d.ts} +5 -4
- package/dist-cjs/agent/{middleware.js → middleware/basic.js} +3 -5
- package/dist-cjs/agent/middleware/context-editor.d.ts +52 -0
- package/dist-cjs/agent/middleware/context-editor.js +70 -0
- package/dist-cjs/agent/middleware/filesystem.d.ts +44 -0
- package/dist-cjs/agent/middleware/filesystem.js +86 -0
- package/dist-cjs/agent/middleware/index.d.ts +19 -0
- package/dist-cjs/agent/middleware/index.js +28 -0
- package/dist-cjs/agent/middleware/limits.d.ts +42 -0
- package/dist-cjs/agent/middleware/limits.js +57 -0
- package/dist-cjs/agent/middleware/models.d.ts +48 -0
- package/dist-cjs/agent/middleware/models.js +48 -0
- package/dist-cjs/agent/middleware/pii.d.ts +67 -0
- package/dist-cjs/agent/middleware/pii.js +178 -0
- package/dist-cjs/agent/middleware/retry.d.ts +66 -0
- package/dist-cjs/agent/middleware/retry.js +63 -0
- package/dist-cjs/agent/middleware/shared.d.ts +41 -0
- package/dist-cjs/agent/middleware/shared.js +83 -0
- package/dist-cjs/agent/middleware/tool-selector.d.ts +64 -0
- package/dist-cjs/agent/middleware/tool-selector.js +109 -0
- package/dist-cjs/agent/permissions.d.ts +113 -0
- package/dist-cjs/agent/permissions.js +189 -0
- package/dist-cjs/agent/sandbox.d.ts +151 -0
- package/dist-cjs/agent/sandbox.js +297 -0
- package/dist-cjs/agent/tool.d.ts +8 -3
- package/dist-cjs/agent/tool.js +14 -3
- package/dist-cjs/deep-agent/index.d.ts +109 -0
- package/dist-cjs/deep-agent/index.js +219 -0
- package/dist-cjs/graph/functional.d.ts +9 -0
- package/dist-cjs/graph/functional.js +20 -3
- package/dist-cjs/graph/graph.js +25 -4
- package/dist-cjs/graph/lint.d.ts +4 -1
- package/dist-cjs/graph/lint.js +35 -0
- package/dist-cjs/postgres/fulltext.d.ts +67 -0
- package/dist-cjs/postgres/fulltext.js +129 -0
- package/dist-cjs/rag/elasticsearch.d.ts +71 -0
- package/dist-cjs/rag/elasticsearch.js +135 -0
- package/dist-cjs/rag/pipeline.d.ts +140 -0
- package/dist-cjs/rag/pipeline.js +191 -0
- package/dist-cjs/rag/rerankers.d.ts +92 -0
- package/dist-cjs/rag/rerankers.js +107 -0
- package/dist-cjs/rag/retrievers.d.ts +12 -1
- package/dist-cjs/server/assistant.d.ts +5 -1
- package/dist-cjs/server/assistant.js +4 -2
- package/dist-cjs/server/auth.d.ts +250 -0
- package/dist-cjs/server/auth.js +402 -0
- package/dist-cjs/store/memory.d.ts +10 -0
- package/dist-cjs/store/memory.js +10 -0
- package/dist-cjs/types/graph.d.ts +38 -0
- package/dist-cjs/types/messages.d.ts +36 -2
- package/dist-cjs/types/principal.d.ts +21 -0
- package/dist-cjs/types/principal.js +2 -0
- package/dist-cjs/types/server.d.ts +2 -9
- package/dist-cjs/utils/tenant.d.ts +11 -0
- package/dist-cjs/utils/tenant.js +15 -0
- package/dist-cjs/version.d.ts +1 -1
- package/dist-cjs/version.js +1 -1
- package/llms.txt +4 -3
- package/package.json +118 -1
|
@@ -6,6 +6,7 @@ exports.agentAsTool = agentAsTool;
|
|
|
6
6
|
const channels_js_1 = require("../graph/channels.js");
|
|
7
7
|
const graph_js_1 = require("../graph/graph.js");
|
|
8
8
|
const graph_js_2 = require("../types/graph.js");
|
|
9
|
+
const capabilities_js_1 = require("./capabilities.js");
|
|
9
10
|
const tool_js_1 = require("./tool.js");
|
|
10
11
|
const agentChannels = () => ({
|
|
11
12
|
messages: (0, channels_js_1.appendList)(),
|
|
@@ -39,24 +40,47 @@ function createAgent(options) {
|
|
|
39
40
|
...(options.responseFormat ? { responseFormat: options.responseFormat } : {}),
|
|
40
41
|
...(options.metadata ? { metadata: options.metadata } : {}),
|
|
41
42
|
};
|
|
43
|
+
const hooks = hookContext(context, state, options.store);
|
|
42
44
|
for (const item of middleware) {
|
|
43
|
-
request = (await item.beforeModel?.({
|
|
45
|
+
request = (await item.beforeModel?.({ ...hooks, request })) ?? request;
|
|
44
46
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
const streaming = Boolean(options.streamTokens && options.client.stream);
|
|
48
|
+
const send = (next) => streaming && options.client.stream
|
|
49
|
+
? streamed(options.client.stream(next), (chunk) => context.message(chunk))
|
|
50
|
+
: options.client.complete(next);
|
|
51
|
+
const stops = new WeakSet();
|
|
52
|
+
const modelContext = {
|
|
53
|
+
...hooks,
|
|
54
|
+
stop: (answer) => {
|
|
55
|
+
const stopped = stopResponse(answer, request.model);
|
|
56
|
+
stops.add(stopped);
|
|
57
|
+
return stopped;
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
const wrapped = middleware.reduceRight((next, item) => {
|
|
61
|
+
const wrap = item.wrapModelCall?.bind(item);
|
|
62
|
+
return wrap ? (current) => Promise.resolve(wrap(current, next, modelContext)) : next;
|
|
63
|
+
}, send);
|
|
64
|
+
let response = await wrapped(request);
|
|
65
|
+
const stopped = stops.has(response);
|
|
66
|
+
if ((!streaming || stopped) && response.content) {
|
|
49
67
|
context.message({ content: response.content });
|
|
50
68
|
}
|
|
51
69
|
for (const item of middleware) {
|
|
52
|
-
response = (await item.afterModel?.({
|
|
70
|
+
response = (await item.afterModel?.({ ...hooks, response })) ?? response;
|
|
53
71
|
}
|
|
54
72
|
const assistant = {
|
|
55
73
|
role: 'assistant',
|
|
56
74
|
content: response.content,
|
|
57
|
-
...(response.toolCalls?.length ? { toolCalls: response.toolCalls } : {}),
|
|
75
|
+
...(response.toolCalls?.length && !stopped ? { toolCalls: response.toolCalls } : {}),
|
|
58
76
|
};
|
|
59
|
-
const calls = response.toolCalls ?? [];
|
|
77
|
+
const calls = stopped ? [] : (response.toolCalls ?? []);
|
|
78
|
+
if (stopped) {
|
|
79
|
+
return new graph_js_2.Command({
|
|
80
|
+
update: { messages: [assistant], iterations: 1, answer: response.content, stopReason: 'stopped' },
|
|
81
|
+
goto: graph_js_2.END,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
60
84
|
if (calls.length === 0) {
|
|
61
85
|
return new graph_js_2.Command({
|
|
62
86
|
update: { messages: [assistant], iterations: 1, answer: response.content, stopReason: 'completed' },
|
|
@@ -81,27 +105,82 @@ function createAgent(options) {
|
|
|
81
105
|
return { messages: [toolMessage(call, { ok: false, error: parsed.error })] };
|
|
82
106
|
}
|
|
83
107
|
let args = parsed.args;
|
|
84
|
-
const
|
|
108
|
+
const definition = executor.get(call.function.name);
|
|
109
|
+
const capabilities = (0, capabilities_js_1.capabilitiesOf)(definition, args);
|
|
110
|
+
const description = {
|
|
111
|
+
id: call.id,
|
|
112
|
+
name: call.function.name,
|
|
113
|
+
args,
|
|
114
|
+
...(capabilities ? { capabilities } : {}),
|
|
115
|
+
};
|
|
116
|
+
const refuse = (error) => {
|
|
117
|
+
context.tool({ phase: 'error', id: call.id, name: description.name, error });
|
|
118
|
+
return { messages: [toolMessage(call, { ok: false, error })] };
|
|
119
|
+
};
|
|
120
|
+
let permission;
|
|
121
|
+
if (options.permissions) {
|
|
122
|
+
const verdict = await options.permissions.decide({
|
|
123
|
+
tool: description.name,
|
|
124
|
+
args,
|
|
125
|
+
capabilities,
|
|
126
|
+
...(context.principal ? { principal: context.principal } : {}),
|
|
127
|
+
});
|
|
128
|
+
if (verdict.decision === 'deny')
|
|
129
|
+
return refuse(`Permission denied: ${verdict.reason}`);
|
|
130
|
+
if (verdict.decision === 'ask')
|
|
131
|
+
permission = verdict.reason;
|
|
132
|
+
}
|
|
85
133
|
const policy = approvals[description.name];
|
|
86
|
-
if (policy) {
|
|
134
|
+
if (policy || permission) {
|
|
135
|
+
const asked = permission ? { ...description, permission } : description;
|
|
87
136
|
const decision = context.interrupt({
|
|
88
|
-
reason: (policy
|
|
89
|
-
|
|
137
|
+
reason: (policy && policy !== true ? policy.reason?.(asked) : undefined) ??
|
|
138
|
+
(permission ? `${defaultReason(asked)} (${permission})` : defaultReason(asked)),
|
|
139
|
+
payload: asked,
|
|
90
140
|
});
|
|
91
141
|
const verdict = normalizeApproval(decision);
|
|
92
|
-
if (!verdict.approved)
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
if (verdict.args)
|
|
142
|
+
if (!verdict.approved)
|
|
143
|
+
return refuse(verdict.reason ?? 'A human refused this tool call');
|
|
144
|
+
if (verdict.args) {
|
|
98
145
|
args = verdict.args;
|
|
146
|
+
if (options.permissions) {
|
|
147
|
+
const recheck = await options.permissions.decide({
|
|
148
|
+
tool: description.name,
|
|
149
|
+
args,
|
|
150
|
+
capabilities: (0, capabilities_js_1.capabilitiesOf)(definition, args),
|
|
151
|
+
});
|
|
152
|
+
if (recheck.decision === 'deny')
|
|
153
|
+
return refuse(`Permission denied: ${recheck.reason}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
99
156
|
}
|
|
100
|
-
const run = async () =>
|
|
157
|
+
const run = async (current) => {
|
|
158
|
+
if (options.permissions && current.args !== args) {
|
|
159
|
+
const recheck = await options.permissions.decide({
|
|
160
|
+
tool: description.name,
|
|
161
|
+
args: current.args,
|
|
162
|
+
capabilities: (0, capabilities_js_1.capabilitiesOf)(definition, current.args),
|
|
163
|
+
});
|
|
164
|
+
if (recheck.decision === 'deny')
|
|
165
|
+
return { ok: false, error: `Permission denied: ${recheck.reason}` };
|
|
166
|
+
}
|
|
167
|
+
return executor.execute(description.name, current.args, {
|
|
168
|
+
toolCallId: call.id,
|
|
169
|
+
threadId: context.threadId,
|
|
170
|
+
...(context.tenantId !== undefined ? { tenantId: context.tenantId } : {}),
|
|
171
|
+
...(context.principal ? { principal: context.principal } : {}),
|
|
172
|
+
signal: context.signal,
|
|
173
|
+
...(context.store ? { store: context.store } : {}),
|
|
174
|
+
});
|
|
175
|
+
};
|
|
101
176
|
context.tool({ phase: 'start', id: call.id, name: description.name, args });
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
177
|
+
const hooks = hookContext(context, context.state, options.store);
|
|
178
|
+
const result = await middleware.reduceRight((next, item) => {
|
|
179
|
+
const wrap = item.wrapToolCall?.bind(item);
|
|
180
|
+
return wrap
|
|
181
|
+
? (current) => Promise.resolve(wrap(current, (changed) => next(changed ?? current), hooks))
|
|
182
|
+
: next;
|
|
183
|
+
}, run)({ ...description, args });
|
|
105
184
|
context.tool(result.ok
|
|
106
185
|
? { phase: 'result', id: call.id, name: description.name, result: result.result }
|
|
107
186
|
: { phase: 'error', id: call.id, name: description.name, error: result.error ?? 'The tool failed' });
|
|
@@ -116,6 +195,12 @@ function createAgent(options) {
|
|
|
116
195
|
...(options.store ? { store: options.store } : {}),
|
|
117
196
|
...(options.name ? { name: options.name } : {}),
|
|
118
197
|
...(options.lifecycle ? { lifecycle: options.lifecycle, lifecycleFamily: 'agent' } : {}),
|
|
198
|
+
tools: executor.list().map((definition) => ({
|
|
199
|
+
name: definition.name,
|
|
200
|
+
...(Array.isArray(definition.capabilities) ? { capabilities: [...definition.capabilities] } : {}),
|
|
201
|
+
...(typeof definition.capabilities === 'function' ? { dynamic: true } : {}),
|
|
202
|
+
approval: approvals[definition.name] ? 'interrupt' : options.permissions ? 'policy' : 'none',
|
|
203
|
+
})),
|
|
119
204
|
});
|
|
120
205
|
}
|
|
121
206
|
function agentAsTool(options) {
|
|
@@ -170,6 +255,35 @@ function parseArguments(raw) {
|
|
|
170
255
|
return { ok: false, error: `Tool arguments are not valid JSON (${reason}); the tool was not run` };
|
|
171
256
|
}
|
|
172
257
|
}
|
|
258
|
+
function hookContext(context, state, store) {
|
|
259
|
+
return {
|
|
260
|
+
state,
|
|
261
|
+
...((context.store ?? store) ? { store: context.store ?? store } : {}),
|
|
262
|
+
threadId: context.threadId,
|
|
263
|
+
...(context.tenantId ? { tenantId: context.tenantId } : {}),
|
|
264
|
+
...(context.principal ? { principal: context.principal } : {}),
|
|
265
|
+
signal: context.signal,
|
|
266
|
+
interrupt: (request) => context.interrupt(request),
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function stopResponse(answer, model) {
|
|
270
|
+
return {
|
|
271
|
+
content: answer,
|
|
272
|
+
role: 'assistant',
|
|
273
|
+
finishReason: 'stop',
|
|
274
|
+
meta: {
|
|
275
|
+
requestId: '',
|
|
276
|
+
providerUsed: 'none',
|
|
277
|
+
modelUsed: model,
|
|
278
|
+
latencyMs: 0,
|
|
279
|
+
tokensInput: 0,
|
|
280
|
+
tokensOutput: 0,
|
|
281
|
+
tokensSaved: 0,
|
|
282
|
+
cacheHit: false,
|
|
283
|
+
guardrailsApplied: ['stopped-by-middleware'],
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
}
|
|
173
287
|
async function streamed(chunks, onChunk) {
|
|
174
288
|
let content = '';
|
|
175
289
|
const toolCalls = [];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { AgentLoop, type AgentModelClient as AgentLoopModelClient } from './loop.js';
|
|
2
2
|
export { isToolOutput, tool, ToolExecutor, toolMessageContent, toolOutput } from './tool.js';
|
|
3
|
-
export { limitToolCalls, redactMessages, type RedactOptions, summarizeHistory, type SummarizeOptions, } from './middleware.js';
|
|
4
|
-
export { agentAsTool, agentInput, type AgentApproval, type AgentApprovalPolicy, type AgentChannels, type AgentGraph, type AgentMiddleware, type AgentModelClient, type AgentState, type AgentStopReason, type AgentToolCall, type AgentToolResult, createAgent, type CreateAgentOptions, } from './create-agent.js';
|
|
3
|
+
export { limitToolCalls, redactMessages, type RedactOptions, summarizeHistory, type SummarizeOptions, } from './middleware/basic.js';
|
|
4
|
+
export { agentAsTool, agentInput, type AgentApproval, type AgentApprovalPolicy, type AgentChannels, type AgentGraph, type AgentMiddleware, type AgentMiddlewareContext, type AgentModelCallContext, type AgentModelClient, type AgentState, type AgentStopReason, type AgentToolCall, type AgentToolResult, createAgent, type CreateAgentOptions, } from './create-agent.js';
|
|
5
5
|
export type { AgentConfig, AgentResult, AgentStep, ToolExecutionResult } from '../types/agent.js';
|
|
6
|
+
export type { ToolContext } from '../types/messages.js';
|
package/dist-cjs/agent/index.js
CHANGED
|
@@ -9,10 +9,10 @@ Object.defineProperty(exports, "tool", { enumerable: true, get: function () { re
|
|
|
9
9
|
Object.defineProperty(exports, "ToolExecutor", { enumerable: true, get: function () { return tool_js_1.ToolExecutor; } });
|
|
10
10
|
Object.defineProperty(exports, "toolMessageContent", { enumerable: true, get: function () { return tool_js_1.toolMessageContent; } });
|
|
11
11
|
Object.defineProperty(exports, "toolOutput", { enumerable: true, get: function () { return tool_js_1.toolOutput; } });
|
|
12
|
-
var
|
|
13
|
-
Object.defineProperty(exports, "limitToolCalls", { enumerable: true, get: function () { return
|
|
14
|
-
Object.defineProperty(exports, "redactMessages", { enumerable: true, get: function () { return
|
|
15
|
-
Object.defineProperty(exports, "summarizeHistory", { enumerable: true, get: function () { return
|
|
12
|
+
var basic_js_1 = require("./middleware/basic.js");
|
|
13
|
+
Object.defineProperty(exports, "limitToolCalls", { enumerable: true, get: function () { return basic_js_1.limitToolCalls; } });
|
|
14
|
+
Object.defineProperty(exports, "redactMessages", { enumerable: true, get: function () { return basic_js_1.redactMessages; } });
|
|
15
|
+
Object.defineProperty(exports, "summarizeHistory", { enumerable: true, get: function () { return basic_js_1.summarizeHistory; } });
|
|
16
16
|
var create_agent_js_1 = require("./create-agent.js");
|
|
17
17
|
Object.defineProperty(exports, "agentAsTool", { enumerable: true, get: function () { return create_agent_js_1.agentAsTool; } });
|
|
18
18
|
Object.defineProperty(exports, "agentInput", { enumerable: true, get: function () { return create_agent_js_1.agentInput; } });
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AgentApproval, AgentMiddleware, AgentMiddlewareContext, AgentToolCall } from '../create-agent.js';
|
|
2
|
+
/** Options for `humanApproval()`. */
|
|
3
|
+
export interface HumanApprovalOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Which calls need a person's approval. Defaults to every call whose tool declares nothing, or
|
|
6
|
+
* declares a capability that does anything but read.
|
|
7
|
+
*/
|
|
8
|
+
when?: (call: AgentToolCall, context: AgentMiddlewareContext) => boolean;
|
|
9
|
+
/** The question a person sees. Defaults to naming the tool and its arguments. */
|
|
10
|
+
reason?: (call: AgentToolCall) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Asks out of band instead of suspending the run: posts to a chat and waits for the answer, or
|
|
13
|
+
* applies a rule of your own. Without it, the run suspends through `interrupt()` until `resume()`
|
|
14
|
+
* answers, as `interruptOn` does.
|
|
15
|
+
*/
|
|
16
|
+
approve?: (call: AgentToolCall, context: AgentMiddlewareContext) => AgentApproval | Promise<AgentApproval>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Asks a person before a tool call runs, decided per call rather than per tool name.
|
|
20
|
+
*
|
|
21
|
+
* `interruptOn` approves every call to a named tool; this approves the calls a rule picks: a refund
|
|
22
|
+
* over a limit, a write outside a draft folder, anything a tool does that is not a read. An
|
|
23
|
+
* approver may refuse, or correct the arguments, which the permission policy then decides again.
|
|
24
|
+
* Put it before `toolRetry()`, so a retried call is not asked about twice.
|
|
25
|
+
*/
|
|
26
|
+
export declare function humanApproval(options?: HumanApprovalOptions): AgentMiddleware;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.humanApproval = humanApproval;
|
|
4
|
+
const capabilities_js_1 = require("../capabilities.js");
|
|
5
|
+
function humanApproval(options = {}) {
|
|
6
|
+
const when = options.when ??
|
|
7
|
+
((call) => call.capabilities === undefined || call.capabilities.some(capabilities_js_1.isSensitiveCapability));
|
|
8
|
+
const reason = options.reason ?? ((call) => `Run tool "${call.name}" with ${JSON.stringify(call.args)}?`);
|
|
9
|
+
return {
|
|
10
|
+
name: 'human-approval',
|
|
11
|
+
async wrapToolCall(call, next, context) {
|
|
12
|
+
if (!when(call, context))
|
|
13
|
+
return next();
|
|
14
|
+
const answer = options.approve
|
|
15
|
+
? await options.approve(call, context)
|
|
16
|
+
: context.interrupt({ reason: reason(call), payload: call });
|
|
17
|
+
if (answer === false || (typeof answer === 'object' && !answer.approved)) {
|
|
18
|
+
const why = typeof answer === 'object' && !answer.approved ? answer.reason : undefined;
|
|
19
|
+
return { ok: false, error: why ?? 'A person refused this tool call' };
|
|
20
|
+
}
|
|
21
|
+
return typeof answer === 'object' && answer.approved && answer.args
|
|
22
|
+
? next({ ...call, args: answer.args })
|
|
23
|
+
: next();
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Message } from '
|
|
2
|
-
import type { AgentMiddleware } from '
|
|
1
|
+
import type { Message } from '../../types/messages.js';
|
|
2
|
+
import type { AgentMiddleware } from '../create-agent.js';
|
|
3
3
|
/**
|
|
4
4
|
* Middleware that ships with the agent.
|
|
5
5
|
*
|
|
@@ -40,9 +40,10 @@ export interface RedactOptions {
|
|
|
40
40
|
*/
|
|
41
41
|
export declare function redactMessages(options: RedactOptions): AgentMiddleware;
|
|
42
42
|
/**
|
|
43
|
-
* Caps how often a tool may be called in one run.
|
|
43
|
+
* Caps how often a tool may be called in one run: one turn, from a user message to the answer.
|
|
44
44
|
*
|
|
45
45
|
* A model that loops on the same call otherwise burns the iteration budget, and with an expensive
|
|
46
|
-
* tool it burns money too.
|
|
46
|
+
* tool it burns money too. Calls are counted from the transcript, so the count survives a restart
|
|
47
|
+
* and a resumed approval, and two threads never share one.
|
|
47
48
|
*/
|
|
48
49
|
export declare function limitToolCalls(limits: Record<string, number>): AgentMiddleware;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.summarizeHistory = summarizeHistory;
|
|
4
4
|
exports.redactMessages = redactMessages;
|
|
5
5
|
exports.limitToolCalls = limitToolCalls;
|
|
6
|
+
const shared_js_1 = require("./shared.js");
|
|
6
7
|
function summarizeHistory(options) {
|
|
7
8
|
const keepLast = options.keepLast ?? 6;
|
|
8
9
|
const triggerAfter = options.triggerAfter ?? 20;
|
|
@@ -45,18 +46,15 @@ function redactMessages(options) {
|
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
function limitToolCalls(limits) {
|
|
48
|
-
const counts = new Map();
|
|
49
49
|
return {
|
|
50
50
|
name: 'limit-tool-calls',
|
|
51
|
-
async wrapToolCall(call, next) {
|
|
51
|
+
async wrapToolCall(call, next, context) {
|
|
52
52
|
const limit = limits[call.name];
|
|
53
53
|
if (limit === undefined)
|
|
54
54
|
return next();
|
|
55
|
-
|
|
56
|
-
if (used >= limit) {
|
|
55
|
+
if ((0, shared_js_1.callPosition)(context.state.messages, call) > limit) {
|
|
57
56
|
return { ok: false, error: `Tool "${call.name}" has already run ${limit} times in this run` };
|
|
58
57
|
}
|
|
59
|
-
counts.set(call.name, used + 1);
|
|
60
58
|
return next();
|
|
61
59
|
},
|
|
62
60
|
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { CompletionRequest } from '../../types/messages.js';
|
|
2
|
+
import type { AgentMiddleware } from '../create-agent.js';
|
|
3
|
+
/** One cleared result, for a custom placeholder. */
|
|
4
|
+
export interface ClearedToolResult {
|
|
5
|
+
/** The tool whose result was cleared. */
|
|
6
|
+
tool: string;
|
|
7
|
+
/** How long the result was, in characters. */
|
|
8
|
+
length: number;
|
|
9
|
+
}
|
|
10
|
+
/** What one edit did, for logs and for measuring what it saves. */
|
|
11
|
+
export interface ContextEdit {
|
|
12
|
+
/** Tool results cleared. */
|
|
13
|
+
cleared: number;
|
|
14
|
+
/** The request's estimated tokens before. */
|
|
15
|
+
tokensBefore: number;
|
|
16
|
+
/** And after. */
|
|
17
|
+
tokensAfter: number;
|
|
18
|
+
}
|
|
19
|
+
/** Options for `contextEditor()`. */
|
|
20
|
+
export interface ContextEditorOptions {
|
|
21
|
+
/** Editing starts once the request's estimated tokens pass this. Defaults to 30,000. */
|
|
22
|
+
triggerTokens?: number;
|
|
23
|
+
/** The most recent tool results, kept whole. Defaults to 3. */
|
|
24
|
+
keepToolResults?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Results are cleared this many at a time, so the edited prefix stays the same for several calls
|
|
27
|
+
* and a provider's prompt cache keeps working between edits. Defaults to 5.
|
|
28
|
+
*/
|
|
29
|
+
batch?: number;
|
|
30
|
+
/** Tools whose results are never cleared. */
|
|
31
|
+
exclude?: readonly string[];
|
|
32
|
+
/** Also empties the arguments of each call whose result is cleared, for tools that take large inputs. */
|
|
33
|
+
clearArguments?: boolean;
|
|
34
|
+
/** What a cleared result says instead. Defaults to a line naming the tool and how to get it back. */
|
|
35
|
+
placeholder?: string | ((cleared: ClearedToolResult) => string);
|
|
36
|
+
/** Estimates a request's tokens. Defaults to about four characters a token. */
|
|
37
|
+
estimateTokens?: (request: CompletionRequest) => number;
|
|
38
|
+
/** Called after each edit. */
|
|
39
|
+
onEdit?: (edit: ContextEdit) => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Clears old tool results from what the model is sent, once the request grows past a threshold.
|
|
43
|
+
*
|
|
44
|
+
* Tool output is most of a long agent's context, and the model rarely needs a result from twenty
|
|
45
|
+
* steps ago verbatim. Every result but the most recent few is replaced by a short placeholder, in
|
|
46
|
+
* batches, so the edited prefix stays the same between edits and a provider's prompt cache keeps
|
|
47
|
+
* working. Only the request changes: the transcript in state keeps every result, and checkpoints,
|
|
48
|
+
* events, and a later summary still see them.
|
|
49
|
+
*/
|
|
50
|
+
export declare function contextEditor(options?: ContextEditorOptions): AgentMiddleware;
|
|
51
|
+
/** About four characters a token, over the messages, the tool calls, and the tool schemas. */
|
|
52
|
+
export declare function estimateRequestTokens(request: CompletionRequest): number;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.contextEditor = contextEditor;
|
|
4
|
+
exports.estimateRequestTokens = estimateRequestTokens;
|
|
5
|
+
const shared_js_1 = require("./shared.js");
|
|
6
|
+
function contextEditor(options = {}) {
|
|
7
|
+
const triggerTokens = options.triggerTokens ?? 30_000;
|
|
8
|
+
const keep = Math.max(0, options.keepToolResults ?? 3);
|
|
9
|
+
const batch = Math.max(1, options.batch ?? 5);
|
|
10
|
+
const exclude = new Set(options.exclude ?? []);
|
|
11
|
+
const estimate = options.estimateTokens ?? estimateRequestTokens;
|
|
12
|
+
const placeholder = (cleared) => typeof options.placeholder === 'function'
|
|
13
|
+
? options.placeholder(cleared)
|
|
14
|
+
: (options.placeholder ??
|
|
15
|
+
`[Cleared to save context: the result of ${cleared.tool}, ${cleared.length} characters. Call the tool again if you need it.]`);
|
|
16
|
+
return {
|
|
17
|
+
name: 'context-editor',
|
|
18
|
+
beforeModel({ request }) {
|
|
19
|
+
const tokensBefore = estimate(request);
|
|
20
|
+
if (tokensBefore <= triggerTokens)
|
|
21
|
+
return;
|
|
22
|
+
const names = new Map();
|
|
23
|
+
for (const message of request.messages) {
|
|
24
|
+
for (const call of message.toolCalls ?? [])
|
|
25
|
+
names.set(call.id, call.function.name);
|
|
26
|
+
}
|
|
27
|
+
const results = request.messages.flatMap((message, index) => (message.role === 'tool' ? [index] : []));
|
|
28
|
+
const eligible = Math.max(0, results.length - keep);
|
|
29
|
+
const count = eligible < batch ? eligible : eligible - (eligible % batch);
|
|
30
|
+
const clearable = new Set(results.slice(0, count).filter((index) => {
|
|
31
|
+
const id = request.messages[index]?.toolCallId;
|
|
32
|
+
return !exclude.has(names.get(id ?? '') ?? '');
|
|
33
|
+
}));
|
|
34
|
+
if (clearable.size === 0)
|
|
35
|
+
return;
|
|
36
|
+
const clearedIds = new Set();
|
|
37
|
+
const messages = request.messages.map((message, index) => {
|
|
38
|
+
if (!clearable.has(index))
|
|
39
|
+
return message;
|
|
40
|
+
const text = (0, shared_js_1.textOf)(message.content);
|
|
41
|
+
const tool = names.get(message.toolCallId ?? '') ?? 'a tool';
|
|
42
|
+
clearedIds.add(message.toolCallId ?? '');
|
|
43
|
+
return { ...message, content: placeholder({ tool, length: text.length }) };
|
|
44
|
+
});
|
|
45
|
+
const edited = options.clearArguments
|
|
46
|
+
? messages.map((message) => message.toolCalls?.some((call) => clearedIds.has(call.id))
|
|
47
|
+
? {
|
|
48
|
+
...message,
|
|
49
|
+
toolCalls: message.toolCalls.map((call) => clearedIds.has(call.id) ? { ...call, function: { ...call.function, arguments: '{}' } } : call),
|
|
50
|
+
}
|
|
51
|
+
: message)
|
|
52
|
+
: messages;
|
|
53
|
+
const next = { ...request, messages: edited };
|
|
54
|
+
options.onEdit?.({ cleared: clearable.size, tokensBefore, tokensAfter: estimate(next) });
|
|
55
|
+
return next;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function estimateRequestTokens(request) {
|
|
60
|
+
let characters = 0;
|
|
61
|
+
for (const message of request.messages) {
|
|
62
|
+
characters += (0, shared_js_1.textOf)(message.content).length + 4;
|
|
63
|
+
for (const call of message.toolCalls ?? [])
|
|
64
|
+
characters += call.function.name.length + call.function.arguments.length;
|
|
65
|
+
}
|
|
66
|
+
for (const tool of request.tools ?? []) {
|
|
67
|
+
characters += tool.name.length + tool.description.length + JSON.stringify(tool.parameters ?? {}).length;
|
|
68
|
+
}
|
|
69
|
+
return Math.ceil(characters / 4);
|
|
70
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { AgentMiddleware } from '../create-agent.js';
|
|
2
|
+
import type { Sandbox } from '../sandbox.js';
|
|
3
|
+
/** Where `filesystemContext()` reads and writes: a `Sandbox`, or anything with the same file methods. */
|
|
4
|
+
export type FilesystemContextSource = Pick<Sandbox, 'readFile'> & Partial<Pick<Sandbox, 'writeFile' | 'listFiles'>>;
|
|
5
|
+
/** Where large tool results go instead of the transcript. */
|
|
6
|
+
export interface ContextOffloadOptions {
|
|
7
|
+
/** Results longer than this, in characters, are offloaded. Defaults to 20,000. */
|
|
8
|
+
overChars?: number;
|
|
9
|
+
/** The directory they are written to, inside the source. Defaults to `.context`. */
|
|
10
|
+
directory?: string;
|
|
11
|
+
/** How much of a result stays in the transcript as a preview, in characters. Defaults to 1,000. */
|
|
12
|
+
previewChars?: number;
|
|
13
|
+
/** Tools whose results are never offloaded. Defaults to `read_file`, so reading one back cannot loop. */
|
|
14
|
+
exclude?: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
/** Options for `filesystemContext()`. */
|
|
17
|
+
export interface FilesystemContextOptions {
|
|
18
|
+
/** Where files are read from and offloaded to. */
|
|
19
|
+
source: FilesystemContextSource;
|
|
20
|
+
/**
|
|
21
|
+
* Files whose contents the model sees on every call, after the system prompt: project
|
|
22
|
+
* instructions such as `AGENTS.md`, conventions, a glossary. A missing file is skipped.
|
|
23
|
+
*/
|
|
24
|
+
include?: readonly string[];
|
|
25
|
+
/** Lists a directory after the files, so the model knows what exists without a tool call. Needs `listFiles`. */
|
|
26
|
+
listing?: {
|
|
27
|
+
directory?: string;
|
|
28
|
+
maxEntries?: number;
|
|
29
|
+
};
|
|
30
|
+
/** The most characters of included files, together. Defaults to 32,000; the rest is cut. */
|
|
31
|
+
maxChars?: number;
|
|
32
|
+
/** Writes large tool results to a file and leaves a preview and the path. Needs `writeFile`. */
|
|
33
|
+
offload?: ContextOffloadOptions | boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The filesystem as the agent's context: files in, large results out.
|
|
37
|
+
*
|
|
38
|
+
* Instruction files reach the model on every call without a tool call, read once per run and placed
|
|
39
|
+
* right after the system prompt, so the prefix a provider caches stays the same. A tool result too
|
|
40
|
+
* large for the context is written to a file instead, and the model reads a preview and a path it can
|
|
41
|
+
* open with `read_file` when it needs the rest: the transcript stays small however much a tool
|
|
42
|
+
* returns, and nothing is lost.
|
|
43
|
+
*/
|
|
44
|
+
export declare function filesystemContext(options: FilesystemContextOptions): AgentMiddleware;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filesystemContext = filesystemContext;
|
|
4
|
+
function filesystemContext(options) {
|
|
5
|
+
const maxChars = options.maxChars ?? 32_000;
|
|
6
|
+
const offload = options.offload === true
|
|
7
|
+
? {}
|
|
8
|
+
: options.offload === false || options.offload === undefined
|
|
9
|
+
? undefined
|
|
10
|
+
: options.offload;
|
|
11
|
+
if (offload && !options.source.writeFile) {
|
|
12
|
+
throw new TypeError('filesystemContext() offloading needs a source with writeFile()');
|
|
13
|
+
}
|
|
14
|
+
const loaded = new Map();
|
|
15
|
+
const load = async () => {
|
|
16
|
+
const sections = [];
|
|
17
|
+
let budget = maxChars;
|
|
18
|
+
for (const file of options.include ?? []) {
|
|
19
|
+
if (budget <= 0)
|
|
20
|
+
break;
|
|
21
|
+
let text;
|
|
22
|
+
try {
|
|
23
|
+
text = await options.source.readFile(file);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const cut = text.length > budget ? `${text.slice(0, budget)}\n[cut: ${text.length - budget} more characters]` : text;
|
|
29
|
+
budget -= text.length;
|
|
30
|
+
sections.push(`<file path="${file}">\n${cut}\n</file>`);
|
|
31
|
+
}
|
|
32
|
+
if (options.listing && options.source.listFiles) {
|
|
33
|
+
try {
|
|
34
|
+
const entries = await options.source.listFiles(options.listing.directory ?? '.');
|
|
35
|
+
const max = options.listing.maxEntries ?? 200;
|
|
36
|
+
const shown = entries.slice(0, max).join('\n');
|
|
37
|
+
sections.push(`<listing directory="${options.listing.directory ?? '.'}">\n${shown}${entries.length > max ? `\n[${entries.length - max} more]` : ''}\n</listing>`);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return sections.length ? `Files from the workspace:\n\n${sections.join('\n\n')}` : undefined;
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
name: 'filesystem-context',
|
|
46
|
+
async beforeModel({ request, state, threadId }) {
|
|
47
|
+
if (!options.include?.length && !options.listing)
|
|
48
|
+
return;
|
|
49
|
+
const turn = state.messages.filter((message) => message.role === 'user').length;
|
|
50
|
+
const key = `${threadId}:${turn}`;
|
|
51
|
+
let pending = loaded.get(key);
|
|
52
|
+
if (!pending) {
|
|
53
|
+
pending = load();
|
|
54
|
+
loaded.set(key, pending);
|
|
55
|
+
if (loaded.size > 256)
|
|
56
|
+
loaded.delete(loaded.keys().next().value);
|
|
57
|
+
}
|
|
58
|
+
const text = await pending;
|
|
59
|
+
if (!text)
|
|
60
|
+
return;
|
|
61
|
+
const systemCount = request.messages.findIndex((message) => message.role !== 'system');
|
|
62
|
+
const at = systemCount === -1 ? request.messages.length : systemCount;
|
|
63
|
+
const context = { role: 'system', content: text };
|
|
64
|
+
return { ...request, messages: [...request.messages.slice(0, at), context, ...request.messages.slice(at)] };
|
|
65
|
+
},
|
|
66
|
+
async wrapToolCall(call, next) {
|
|
67
|
+
const result = await next();
|
|
68
|
+
if (!offload || !result.ok || (offload.exclude ?? ['read_file']).includes(call.name))
|
|
69
|
+
return result;
|
|
70
|
+
const value = result.result;
|
|
71
|
+
if (value?.type === 'tool_output')
|
|
72
|
+
return result;
|
|
73
|
+
const text = typeof value === 'string' ? value : JSON.stringify(value);
|
|
74
|
+
if (text === undefined || text.length <= (offload.overChars ?? 20_000))
|
|
75
|
+
return result;
|
|
76
|
+
const directory = (offload.directory ?? '.context').replace(/\/+$/, '');
|
|
77
|
+
const file = `${directory}/${`${call.name}-${call.id}`.replace(/[^A-Za-z0-9._-]/g, '_')}.txt`;
|
|
78
|
+
await options.source.writeFile?.(file, text);
|
|
79
|
+
const preview = text.slice(0, offload.previewChars ?? 1_000);
|
|
80
|
+
return {
|
|
81
|
+
ok: true,
|
|
82
|
+
result: `${preview}\n\n[This result is ${text.length} characters; the first ${preview.length} are above. The whole result is in ${file}: read it with read_file when you need the rest.]`,
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Middleware for `createAgent()`, each its own import: retries, fallbacks, model choice, tool
|
|
3
|
+
* selection, context editing, personal data, approvals, limits, and the filesystem as context.
|
|
4
|
+
*
|
|
5
|
+
* Each is ordinary `AgentMiddleware` built on the same hooks an application's own middleware uses,
|
|
6
|
+
* so any of them can be read, copied, and changed. None adds a dependency, and a bundler keeps only
|
|
7
|
+
* the ones imported.
|
|
8
|
+
*/
|
|
9
|
+
export { limitToolCalls, redactMessages, type RedactOptions, summarizeHistory, type SummarizeOptions, } from './basic.js';
|
|
10
|
+
export { type ClearedToolResult, type ContextEdit, contextEditor, type ContextEditorOptions, estimateRequestTokens, } from './context-editor.js';
|
|
11
|
+
export { type ContextOffloadOptions, filesystemContext, type FilesystemContextOptions, type FilesystemContextSource, } from './filesystem.js';
|
|
12
|
+
export { humanApproval, type HumanApprovalOptions } from './approval.js';
|
|
13
|
+
export { modelCallLimit, ModelCallLimitError, type ModelCallLimitOptions } from './limits.js';
|
|
14
|
+
export { type DynamicModelContext, dynamicModel, modelFallback, type ModelFallbackEvent, type ModelFallbackOptions, type ModelFallbackTarget, } from './models.js';
|
|
15
|
+
export { PiiBlockedError, type PiiFinding, type PiiKind, piiMiddleware, type PiiMiddlewareOptions, type PiiStrategy, type PiiWhere, } from './pii.js';
|
|
16
|
+
export { modelRetry, type ModelRetryOptions, type RetryEvent, toolRetry, type ToolRetryOptions } from './retry.js';
|
|
17
|
+
export type { RetryBackoff } from './shared.js';
|
|
18
|
+
export { type ToolSelection, type ToolSelectionContext, toolSelector, type ToolSelectorOptions, } from './tool-selector.js';
|
|
19
|
+
export type { AgentMiddleware, AgentMiddlewareContext, AgentModelCallContext, AgentToolCall, AgentToolResult, } from '../create-agent.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toolSelector = exports.toolRetry = exports.modelRetry = exports.piiMiddleware = exports.PiiBlockedError = exports.modelFallback = exports.dynamicModel = exports.ModelCallLimitError = exports.modelCallLimit = exports.humanApproval = exports.filesystemContext = exports.estimateRequestTokens = exports.contextEditor = exports.summarizeHistory = exports.redactMessages = exports.limitToolCalls = void 0;
|
|
4
|
+
var basic_js_1 = require("./basic.js");
|
|
5
|
+
Object.defineProperty(exports, "limitToolCalls", { enumerable: true, get: function () { return basic_js_1.limitToolCalls; } });
|
|
6
|
+
Object.defineProperty(exports, "redactMessages", { enumerable: true, get: function () { return basic_js_1.redactMessages; } });
|
|
7
|
+
Object.defineProperty(exports, "summarizeHistory", { enumerable: true, get: function () { return basic_js_1.summarizeHistory; } });
|
|
8
|
+
var context_editor_js_1 = require("./context-editor.js");
|
|
9
|
+
Object.defineProperty(exports, "contextEditor", { enumerable: true, get: function () { return context_editor_js_1.contextEditor; } });
|
|
10
|
+
Object.defineProperty(exports, "estimateRequestTokens", { enumerable: true, get: function () { return context_editor_js_1.estimateRequestTokens; } });
|
|
11
|
+
var filesystem_js_1 = require("./filesystem.js");
|
|
12
|
+
Object.defineProperty(exports, "filesystemContext", { enumerable: true, get: function () { return filesystem_js_1.filesystemContext; } });
|
|
13
|
+
var approval_js_1 = require("./approval.js");
|
|
14
|
+
Object.defineProperty(exports, "humanApproval", { enumerable: true, get: function () { return approval_js_1.humanApproval; } });
|
|
15
|
+
var limits_js_1 = require("./limits.js");
|
|
16
|
+
Object.defineProperty(exports, "modelCallLimit", { enumerable: true, get: function () { return limits_js_1.modelCallLimit; } });
|
|
17
|
+
Object.defineProperty(exports, "ModelCallLimitError", { enumerable: true, get: function () { return limits_js_1.ModelCallLimitError; } });
|
|
18
|
+
var models_js_1 = require("./models.js");
|
|
19
|
+
Object.defineProperty(exports, "dynamicModel", { enumerable: true, get: function () { return models_js_1.dynamicModel; } });
|
|
20
|
+
Object.defineProperty(exports, "modelFallback", { enumerable: true, get: function () { return models_js_1.modelFallback; } });
|
|
21
|
+
var pii_js_1 = require("./pii.js");
|
|
22
|
+
Object.defineProperty(exports, "PiiBlockedError", { enumerable: true, get: function () { return pii_js_1.PiiBlockedError; } });
|
|
23
|
+
Object.defineProperty(exports, "piiMiddleware", { enumerable: true, get: function () { return pii_js_1.piiMiddleware; } });
|
|
24
|
+
var retry_js_1 = require("./retry.js");
|
|
25
|
+
Object.defineProperty(exports, "modelRetry", { enumerable: true, get: function () { return retry_js_1.modelRetry; } });
|
|
26
|
+
Object.defineProperty(exports, "toolRetry", { enumerable: true, get: function () { return retry_js_1.toolRetry; } });
|
|
27
|
+
var tool_selector_js_1 = require("./tool-selector.js");
|
|
28
|
+
Object.defineProperty(exports, "toolSelector", { enumerable: true, get: function () { return tool_selector_js_1.toolSelector; } });
|