@antseed/ant-agent 0.1.14

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.
@@ -0,0 +1,66 @@
1
+ import type { KnowledgeModule } from './loader.js';
2
+ export type RequestFormat = 'anthropic' | 'openai' | 'openai-responses';
3
+ export declare function detectRequestFormat(path?: string): RequestFormat;
4
+ export declare const TOOL_PREFIX = "antseed_";
5
+ /** Result of executing an internal tool call. */
6
+ export interface ToolResult {
7
+ id: string;
8
+ content: string;
9
+ isError: boolean;
10
+ }
11
+ /** A parsed internal tool call extracted from an LLM response. */
12
+ export interface InternalToolCall {
13
+ id: string;
14
+ name: string;
15
+ arguments: Record<string, unknown>;
16
+ }
17
+ /** What the agent loop should do after inspecting a response. */
18
+ export type LoopAction = {
19
+ type: 'continue';
20
+ internalCalls: InternalToolCall[];
21
+ } | {
22
+ type: 'done';
23
+ };
24
+ /**
25
+ * A tool that the ant agent can use during the agent loop.
26
+ * The tool name is automatically prefixed with `antseed_` when injected.
27
+ */
28
+ export interface AntAgentTool {
29
+ /** Tool name (without the antseed_ prefix — it's added automatically). */
30
+ name: string;
31
+ /** Description shown to the LLM. */
32
+ description: string;
33
+ /** JSON Schema for the tool's parameters. */
34
+ parameters: Record<string, unknown>;
35
+ /** Execute the tool and return the result as a string. */
36
+ execute: (args: Record<string, unknown>) => Promise<string> | string;
37
+ }
38
+ /**
39
+ * Create a knowledge-loading tool from a set of knowledge modules.
40
+ * The module catalog is embedded in the tool description.
41
+ */
42
+ export declare function knowledgeTool(modules: KnowledgeModule[]): AntAgentTool;
43
+ export declare function isToolChoiceForced(body: Record<string, unknown>): boolean;
44
+ /**
45
+ * Inject antseed_* tools into the request body alongside buyer tools.
46
+ * Returns the body unchanged if no tools or tool_choice is forced.
47
+ */
48
+ export declare function injectTools(body: Record<string, unknown>, tools: AntAgentTool[], format: RequestFormat): Record<string, unknown>;
49
+ /**
50
+ * Inspect an LLM response body and determine what the agent loop should do.
51
+ */
52
+ export declare function inspectResponse(responseBody: Record<string, unknown>, format: RequestFormat): LoopAction;
53
+ /**
54
+ * Execute internal tool calls using the registered tool definitions.
55
+ */
56
+ export declare function executeTools(calls: InternalToolCall[], tools: AntAgentTool[]): Promise<ToolResult[]>;
57
+ /**
58
+ * Append the assistant's response (with tool calls) and tool results
59
+ * to the message history for the next agent loop iteration.
60
+ */
61
+ export declare function appendToolLoop(body: Record<string, unknown>, assistantResponse: Record<string, unknown>, results: ToolResult[], format: RequestFormat): Record<string, unknown>;
62
+ /**
63
+ * Strip antseed_* tool-call blocks from a response body.
64
+ */
65
+ export declare function stripInternalToolCalls(responseBody: Record<string, unknown>, format: RequestFormat): Record<string, unknown>;
66
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,QAAQ,GAAG,kBAAkB,CAAC;AAExE,wBAAgB,mBAAmB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAIhE;AAED,eAAO,MAAM,WAAW,aAAa,CAAC;AAEtC,iDAAiD;AACjD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,kEAAkE;AAClE,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,aAAa,EAAE,gBAAgB,EAAE,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,MAAM,C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OAAO,CAAC,CA+CzB;AAID;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,MAAM,EAAE,aAAa,GACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA8CzB"}
package/dist/tools.js ADDED
@@ -0,0 +1,260 @@
1
+ export function detectRequestFormat(path) {
2
+ if (path?.includes('/chat/completions'))
3
+ return 'openai';
4
+ if (path?.includes('/responses'))
5
+ return 'openai-responses';
6
+ return 'anthropic';
7
+ }
8
+ export const TOOL_PREFIX = 'antseed_';
9
+ /**
10
+ * Create a knowledge-loading tool from a set of knowledge modules.
11
+ * The module catalog is embedded in the tool description.
12
+ */
13
+ export function knowledgeTool(modules) {
14
+ const catalog = modules.map(m => `- ${m.name}: ${m.description}`).join('\n');
15
+ return {
16
+ name: 'load_knowledge',
17
+ description: `Load a knowledge module by name to get detailed information.\n\nAvailable modules:\n${catalog}`,
18
+ parameters: {
19
+ type: 'object',
20
+ properties: {
21
+ name: { type: 'string', description: 'The name of the knowledge module to load.' },
22
+ },
23
+ required: ['name'],
24
+ },
25
+ execute: (args) => {
26
+ const name = args.name;
27
+ const mod = name ? modules.find(m => m.name === name) : undefined;
28
+ if (!mod)
29
+ throw new Error(`Knowledge module "${name ?? ''}" not found.`);
30
+ return mod.content;
31
+ },
32
+ };
33
+ }
34
+ // ─── Tool injection ─────────────────────────────────────────────
35
+ export function isToolChoiceForced(body) {
36
+ const tc = body.tool_choice;
37
+ if (tc == null)
38
+ return false;
39
+ if (tc === 'none')
40
+ return true;
41
+ if (typeof tc === 'string')
42
+ return false;
43
+ const obj = tc;
44
+ if (obj.type === 'tool' && typeof obj.name === 'string')
45
+ return true;
46
+ if (obj.type === 'function') {
47
+ const fn = obj.function;
48
+ if (fn && typeof fn.name === 'string')
49
+ return true;
50
+ }
51
+ return false;
52
+ }
53
+ function toApiFormat(tool, format) {
54
+ const prefixedName = `${TOOL_PREFIX}${tool.name}`;
55
+ if (format === 'openai') {
56
+ return { type: 'function', function: { name: prefixedName, description: tool.description, parameters: tool.parameters } };
57
+ }
58
+ if (format === 'openai-responses') {
59
+ return { type: 'function', name: prefixedName, description: tool.description, parameters: tool.parameters };
60
+ }
61
+ return { name: prefixedName, description: tool.description, input_schema: tool.parameters };
62
+ }
63
+ /**
64
+ * Inject antseed_* tools into the request body alongside buyer tools.
65
+ * Returns the body unchanged if no tools or tool_choice is forced.
66
+ */
67
+ export function injectTools(body, tools, format) {
68
+ if (tools.length === 0)
69
+ return body;
70
+ if (isToolChoiceForced(body))
71
+ return body;
72
+ const existing = Array.isArray(body.tools) ? [...body.tools] : [];
73
+ for (const tool of tools) {
74
+ existing.push(toApiFormat(tool, format));
75
+ }
76
+ return { ...body, tools: existing };
77
+ }
78
+ // ─── Response inspection ────────────────────────────────────────
79
+ /**
80
+ * Inspect an LLM response body and determine what the agent loop should do.
81
+ */
82
+ export function inspectResponse(responseBody, format) {
83
+ const allCalls = extractToolCalls(responseBody, format);
84
+ const internalCalls = allCalls.filter(c => c.name.startsWith(TOOL_PREFIX));
85
+ const hasBuyerCalls = allCalls.length > internalCalls.length;
86
+ if (internalCalls.length === 0)
87
+ return { type: 'done' };
88
+ if (hasBuyerCalls)
89
+ return { type: 'done' };
90
+ return { type: 'continue', internalCalls };
91
+ }
92
+ function extractToolCalls(body, format) {
93
+ const calls = [];
94
+ if (format === 'openai') {
95
+ const choices = body.choices;
96
+ const toolCalls = choices?.[0]?.message?.tool_calls;
97
+ if (toolCalls) {
98
+ for (const tc of toolCalls) {
99
+ try {
100
+ const args = JSON.parse(tc.function.arguments);
101
+ calls.push({ id: tc.id, name: tc.function.name, arguments: args });
102
+ }
103
+ catch {
104
+ // Invalid JSON — skip
105
+ }
106
+ }
107
+ }
108
+ }
109
+ else if (format === 'openai-responses') {
110
+ const output = body.output;
111
+ if (output) {
112
+ for (const item of output) {
113
+ if (item.type === 'function_call' && item.call_id && item.name) {
114
+ try {
115
+ const args = JSON.parse(item.arguments ?? '{}');
116
+ calls.push({ id: item.call_id, name: item.name, arguments: args });
117
+ }
118
+ catch {
119
+ calls.push({ id: item.call_id, name: item.name, arguments: {} });
120
+ }
121
+ }
122
+ }
123
+ }
124
+ }
125
+ else {
126
+ const content = body.content;
127
+ if (content) {
128
+ for (const block of content) {
129
+ if (block.type === 'tool_use' && block.id && block.name) {
130
+ calls.push({ id: block.id, name: block.name, arguments: block.input ?? {} });
131
+ }
132
+ }
133
+ }
134
+ }
135
+ return calls;
136
+ }
137
+ // ─── Tool execution ─────────────────────────────────────────────
138
+ /**
139
+ * Execute internal tool calls using the registered tool definitions.
140
+ */
141
+ export async function executeTools(calls, tools) {
142
+ return Promise.all(calls.map(async (call) => {
143
+ const unprefixed = call.name.startsWith(TOOL_PREFIX)
144
+ ? call.name.slice(TOOL_PREFIX.length)
145
+ : call.name;
146
+ const tool = tools.find(t => t.name === unprefixed);
147
+ if (!tool) {
148
+ return { id: call.id, content: `Unknown tool: ${call.name}`, isError: true };
149
+ }
150
+ try {
151
+ const content = await tool.execute(call.arguments);
152
+ return { id: call.id, content, isError: false };
153
+ }
154
+ catch (err) {
155
+ return { id: call.id, content: err.message, isError: true };
156
+ }
157
+ }));
158
+ }
159
+ // ─── Message appending ──────────────────────────────────────────
160
+ /**
161
+ * Append the assistant's response (with tool calls) and tool results
162
+ * to the message history for the next agent loop iteration.
163
+ */
164
+ export function appendToolLoop(body, assistantResponse, results, format) {
165
+ if (format === 'openai-responses') {
166
+ const input = Array.isArray(body.input) ? [...body.input] : [];
167
+ // Append the function_call items from the response output
168
+ const output = assistantResponse.output;
169
+ if (output) {
170
+ for (const item of output) {
171
+ if (item.type === 'function_call')
172
+ input.push(item);
173
+ }
174
+ }
175
+ // Append function_call_output items for each result
176
+ for (const result of results) {
177
+ input.push({
178
+ type: 'function_call_output',
179
+ call_id: result.id,
180
+ output: result.content,
181
+ });
182
+ }
183
+ return { ...body, input };
184
+ }
185
+ const messages = Array.isArray(body.messages) ? [...body.messages] : [];
186
+ if (format === 'openai') {
187
+ const choices = assistantResponse.choices;
188
+ const assistantMsg = choices?.[0]?.message;
189
+ if (assistantMsg)
190
+ messages.push(assistantMsg);
191
+ for (const result of results) {
192
+ messages.push({
193
+ role: 'tool',
194
+ tool_call_id: result.id,
195
+ content: result.content,
196
+ });
197
+ }
198
+ }
199
+ else {
200
+ const content = assistantResponse.content;
201
+ if (content)
202
+ messages.push({ role: 'assistant', content });
203
+ const toolResultBlocks = results.map(r => ({
204
+ type: 'tool_result',
205
+ tool_use_id: r.id,
206
+ content: r.content,
207
+ is_error: r.isError,
208
+ }));
209
+ messages.push({ role: 'user', content: toolResultBlocks });
210
+ }
211
+ return { ...body, messages };
212
+ }
213
+ // ─── Response stripping ─────────────────────────────────────────
214
+ /**
215
+ * Strip antseed_* tool-call blocks from a response body.
216
+ */
217
+ export function stripInternalToolCalls(responseBody, format) {
218
+ if (format === 'openai') {
219
+ const choices = responseBody.choices;
220
+ if (!choices?.length)
221
+ return responseBody;
222
+ const cleaned = choices.map(choice => {
223
+ if (!choice.message?.tool_calls)
224
+ return choice;
225
+ const msg = { ...choice.message };
226
+ msg.tool_calls = msg.tool_calls.filter(tc => !tc.function.name.startsWith(TOOL_PREFIX));
227
+ if (msg.tool_calls.length === 0) {
228
+ delete msg.tool_calls;
229
+ return { ...choice, message: msg, finish_reason: 'stop' };
230
+ }
231
+ return { ...choice, message: msg };
232
+ });
233
+ return { ...responseBody, choices: cleaned };
234
+ }
235
+ if (format === 'openai-responses') {
236
+ const output = responseBody.output;
237
+ if (!output)
238
+ return responseBody;
239
+ const filtered = output.filter(item => !(item.type === 'function_call' && item.name?.startsWith(TOOL_PREFIX)));
240
+ const wasStripped = filtered.length < output.length;
241
+ const hasRemainingFunctionCall = filtered.some(i => i.type === 'function_call');
242
+ return {
243
+ ...responseBody,
244
+ output: filtered,
245
+ ...(wasStripped && !hasRemainingFunctionCall ? { status: 'completed' } : {}),
246
+ };
247
+ }
248
+ const content = responseBody.content;
249
+ if (!content)
250
+ return responseBody;
251
+ const filtered = content.filter(block => !(block.type === 'tool_use' && block.name?.startsWith(TOOL_PREFIX)));
252
+ const wasStripped = filtered.length < content.length;
253
+ const hasRemainingToolUse = filtered.some(b => b.type === 'tool_use');
254
+ return {
255
+ ...responseBody,
256
+ content: filtered,
257
+ ...(wasStripped && !hasRemainingToolUse ? { stop_reason: 'end_turn' } : {}),
258
+ };
259
+ }
260
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,mBAAmB,CAAC,IAAa;IAC/C,IAAI,IAAI,EAAE,QAAQ,CAAC,mBAAmB,CAAC;QAAE,OAAO,QAAQ,CAAC;IACzD,IAAI,IAAI,EAAE,QAAQ,CAAC,YAAY,CAAC;QAAE,OAAO,kBAAkB,CAAC;IAC5D,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;AAoCtC;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,OAA0B;IACtD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7E,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,WAAW,EAAE,uFAAuF,OAAO,EAAE;QAC7G,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,2CAA2C,EAAE;aACnF;YACD,QAAQ,EAAE,CAAC,MAAM,CAAC;SACnB;QACD,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YAChB,MAAM,IAAI,GAAG,IAAI,CAAC,IAA0B,CAAC;YAC7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C,IAAI,KAAK,UAAU,IAAI,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC,CAC7E,CAAC;IACF,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACrD,MAAM,mBAAmB,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC;IACtE,OAAO;QACL,GAAG,YAAY;QACf,OAAO,EAAE,QAAQ;QACjB,GAAG,CAAC,WAAW,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5E,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@antseed/ant-agent",
3
+ "version": "0.1.14",
4
+ "description": "Ant agent runtime for AntSeed — monetize knowledge with read-only, knowledge-augmented AI agents",
5
+ "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "peerDependencies": {
12
+ "@antseed/node": ">=0.1.0"
13
+ },
14
+ "devDependencies": {
15
+ "typescript": "^5.5.0",
16
+ "vitest": "^2.0.0",
17
+ "@antseed/node": "0.2.28"
18
+ },
19
+ "scripts": {
20
+ "prebuild": "node ../../scripts/remove-paths.mjs dist",
21
+ "build": "tsc",
22
+ "test": "vitest run",
23
+ "typecheck": "tsc --noEmit"
24
+ }
25
+ }