@markusylisiurunen/tau 0.3.111 → 0.3.113
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/dist/code_mode/command.d.ts +1 -1
- package/dist/code_mode/command.js +2 -28
- package/dist/code_mode/command.js.map +1 -1
- package/dist/code_mode/errors.d.ts +3 -0
- package/dist/code_mode/errors.js +4 -0
- package/dist/code_mode/errors.js.map +1 -0
- package/dist/code_mode/images.js +10 -2
- package/dist/code_mode/images.js.map +1 -1
- package/dist/code_mode/index.d.ts +2 -2
- package/dist/code_mode/index.js +1 -1
- package/dist/code_mode/index.js.map +1 -1
- package/dist/code_mode/runtime.d.ts +40 -18
- package/dist/code_mode/runtime.js +139 -162
- package/dist/code_mode/runtime.js.map +1 -1
- package/dist/code_mode/wire.d.ts +2 -0
- package/dist/code_mode/wire.js +64 -0
- package/dist/code_mode/wire.js.map +1 -0
- package/dist/core/agent/capabilities.js +68 -0
- package/dist/core/agent/capabilities.js.map +1 -0
- package/dist/core/agent/notification_inbox.js +6 -6
- package/dist/core/agent/notification_inbox.js.map +1 -1
- package/dist/core/code_mode/agents.js +104 -477
- package/dist/core/code_mode/agents.js.map +1 -1
- package/dist/core/code_mode/bash.js +49 -238
- package/dist/core/code_mode/bash.js.map +1 -1
- package/dist/core/code_mode/files.js +66 -0
- package/dist/core/code_mode/files.js.map +1 -0
- package/dist/core/code_mode/history.js +7 -38
- package/dist/core/code_mode/history.js.map +1 -1
- package/dist/core/code_mode/mcp.js +59 -110
- package/dist/core/code_mode/mcp.js.map +1 -1
- package/dist/core/code_mode/models.js +87 -269
- package/dist/core/code_mode/models.js.map +1 -1
- package/dist/core/code_mode/notifications.js +20 -0
- package/dist/core/code_mode/notifications.js.map +1 -0
- package/dist/core/code_mode/package.js +37 -0
- package/dist/core/code_mode/package.js.map +1 -0
- package/dist/core/code_mode/web.js +50 -140
- package/dist/core/code_mode/web.js.map +1 -1
- package/dist/core/config/content_loader.js +5 -76
- package/dist/core/config/content_loader.js.map +1 -1
- package/dist/core/config/index.js +1 -1
- package/dist/core/config/index.js.map +1 -1
- package/dist/core/config/schema.js +3 -0
- package/dist/core/config/schema.js.map +1 -1
- package/dist/core/debug.js +11 -16
- package/dist/core/debug.js.map +1 -1
- package/dist/core/diff_review/review_instructions.js +1 -1
- package/dist/core/diff_review/review_instructions.js.map +1 -1
- package/dist/core/mcp/manager.js.map +1 -1
- package/dist/core/models/openrouter.js +33 -12
- package/dist/core/models/openrouter.js.map +1 -1
- package/dist/core/modes/run.js +1 -0
- package/dist/core/modes/run.js.map +1 -1
- package/dist/core/personas.js +112 -53
- package/dist/core/personas.js.map +1 -1
- package/dist/core/runtime/chat_runtime.js +16 -1
- package/dist/core/runtime/chat_runtime.js.map +1 -1
- package/dist/core/runtime/model_prompt_notes.js +1 -1
- package/dist/core/runtime/model_prompt_notes.js.map +1 -1
- package/dist/core/runtime/session_prompt_composer.js +20 -12
- package/dist/core/runtime/session_prompt_composer.js.map +1 -1
- package/dist/core/static/code_mode/docs/agents.md +131 -0
- package/dist/core/static/code_mode/docs/bash.md +74 -0
- package/dist/core/static/code_mode/docs/core.md +67 -0
- package/dist/core/static/code_mode/docs/examples.md +135 -0
- package/dist/core/static/code_mode/docs/files.md +38 -0
- package/dist/core/static/code_mode/docs/history.md +104 -0
- package/dist/core/static/code_mode/docs/mcp.md +109 -0
- package/dist/core/static/code_mode/docs/models.md +104 -0
- package/dist/core/static/code_mode/docs/notifications.md +29 -0
- package/dist/core/static/code_mode/docs/web.md +100 -0
- package/dist/core/static/code_mode/modules.mjs +67 -0
- package/dist/core/static/code_mode/sandbox_runner.mjs +66 -121
- package/dist/core/static/index.js +3 -3
- package/dist/core/static/index.js.map +1 -1
- package/dist/core/static/prompts/subagent-prefix.md +1 -1
- package/dist/core/static/tau_docs/client-tools.md +1 -1
- package/dist/core/static/tau_docs/code-mode.md +16 -124
- package/dist/core/static/tau_docs/history.md +2 -2
- package/dist/core/static/tau_docs/index.md +1 -1
- package/dist/core/static/tau_docs/mcp.md +1 -1
- package/dist/core/static/tau_docs/models-and-credentials.md +1 -1
- package/dist/core/static/tau_docs/personas.md +3 -15
- package/dist/core/static/tau_docs/sdk.md +7 -2
- package/dist/core/static/tau_docs/sessions.md +1 -1
- package/dist/core/static/tau_docs/subagents.md +7 -20
- package/dist/core/static/tau_docs/tools.md +8 -18
- package/dist/core/static/tau_docs/troubleshooting.md +1 -1
- package/dist/core/subagents/agent_supervisor.js +11 -10
- package/dist/core/subagents/agent_supervisor.js.map +1 -1
- package/dist/core/subagents/claude_code_models.js +10 -0
- package/dist/core/subagents/claude_code_models.js.map +1 -1
- package/dist/core/subagents/claude_code_protocol.js +1 -1
- package/dist/core/subagents/claude_code_protocol.js.map +1 -1
- package/dist/core/subagents/claude_code_runner.js +26 -26
- package/dist/core/subagents/claude_code_runner.js.map +1 -1
- package/dist/core/subagents/claude_code_runner.mjs +76 -74
- package/dist/core/subagents/claude_code_runtime.js +1 -1
- package/dist/core/subagents/format.js +1 -1
- package/dist/core/subagents/format.js.map +1 -1
- package/dist/core/subagents/native_subagent_runtime.js +30 -14
- package/dist/core/subagents/native_subagent_runtime.js.map +1 -1
- package/dist/core/subagents/prompt.js.map +1 -1
- package/dist/core/subagents/registry.js +6 -41
- package/dist/core/subagents/registry.js.map +1 -1
- package/dist/core/subagents/runtime.js.map +1 -1
- package/dist/core/subagents/trace.js +6 -4
- package/dist/core/subagents/trace.js.map +1 -1
- package/dist/core/subagents/types.js +1 -12
- package/dist/core/subagents/types.js.map +1 -1
- package/dist/core/tool/openrouter.js +9 -2
- package/dist/core/tool/openrouter.js.map +1 -1
- package/dist/core/tools/background_jobs.js +1 -1
- package/dist/core/tools/background_jobs.js.map +1 -1
- package/dist/core/tools/bash_jobs.js +11 -0
- package/dist/core/tools/bash_jobs.js.map +1 -1
- package/dist/core/tools/catalog.js +24 -40
- package/dist/core/tools/catalog.js.map +1 -1
- package/dist/core/tools/code.js +96 -108
- package/dist/core/tools/code.js.map +1 -1
- package/dist/core/tools/code_jobs.js +5 -5
- package/dist/core/tools/code_jobs.js.map +1 -1
- package/dist/core/tools/code_mode.js +79 -108
- package/dist/core/tools/code_mode.js.map +1 -1
- package/dist/core/tools/code_mode_worker.js +14 -42
- package/dist/core/tools/code_mode_worker.js.map +1 -1
- package/dist/core/tools/code_modules.js +21 -0
- package/dist/core/tools/code_modules.js.map +1 -0
- package/dist/core/tools/edit.js +6 -24
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/execution_backend.js +13 -6
- package/dist/core/tools/execution_backend.js.map +1 -1
- package/dist/core/tools/file_edits.js +17 -0
- package/dist/core/tools/file_edits.js.map +1 -0
- package/dist/core/tools/tool_names.js +2 -12
- package/dist/core/tools/tool_names.js.map +1 -1
- package/dist/core/tools/wait_for_agents.js +8 -2
- package/dist/core/tools/wait_for_agents.js.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/utils/context.js +1 -1
- package/dist/core/utils/context.js.map +1 -1
- package/dist/core/utils/context_builder.js +16 -2
- package/dist/core/utils/context_builder.js.map +1 -1
- package/dist/core/version.js +1 -1
- package/dist/diff_tool/app/dist/assets/{core-D5eeuYMf.js → core-BfpRGcqe.js} +1 -1
- package/dist/diff_tool/app/dist/assets/engine-oniguruma-D_AXpl2k.js +1 -0
- package/dist/diff_tool/app/dist/assets/{highlights-6TYlERwf.js → highlights-CLc_g6m8.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{index-DHhgT2Y7.js → index-bu2WOD1Y.js} +37 -37
- package/dist/diff_tool/app/dist/assets/langs-DO7BJV2U.js +1 -0
- package/dist/diff_tool/app/dist/assets/{shiki-CNf9g2mc.js → shiki-r9Q4gIo6.js} +2 -2
- package/dist/diff_tool/app/dist/assets/{stream-tokenizer-0Xi4Io-I.js → stream-tokenizer-bgeDT4xc.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{themes-QMIFS5bl.js → themes-h4OE3MIe.js} +2 -2
- package/dist/diff_tool/app/dist/index.html +1 -1
- package/dist/execution/fly_sprite_execution_environment.js +17 -13
- package/dist/execution/fly_sprite_execution_environment.js.map +1 -1
- package/dist/host/execution_runtime.js +4 -3
- package/dist/host/execution_runtime.js.map +1 -1
- package/dist/host/hosted_ephemeral_agent_session.js +24 -4
- package/dist/host/hosted_ephemeral_agent_session.js.map +1 -1
- package/dist/host/local_session_host.js +20 -15
- package/dist/host/local_session_host.js.map +1 -1
- package/dist/host/session_protocol_handler.js +0 -1
- package/dist/host/session_protocol_handler.js.map +1 -1
- package/dist/protocol/index.d.ts +1 -1
- package/dist/protocol/index.js.map +1 -1
- package/dist/protocol/session_protocol.d.ts +0 -3
- package/dist/protocol/session_protocol.js +3 -14
- package/dist/protocol/session_protocol.js.map +1 -1
- package/dist/sdk/code_mode.d.ts +6 -0
- package/dist/sdk/code_mode.js +16 -7
- package/dist/sdk/code_mode.js.map +1 -1
- package/dist/sdk/diff_review.js +0 -1
- package/dist/sdk/diff_review.js.map +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/session.js +3 -1
- package/dist/sdk/session.js.map +1 -1
- package/dist/sdk/session_tool_execution_backend.d.ts +1 -1
- package/dist/sdk/session_tool_execution_backend.js +11 -2
- package/dist/sdk/session_tool_execution_backend.js.map +1 -1
- package/dist/sdk/types.d.ts +1 -3
- package/dist/store/session_snapshot_migrations.js +3 -23
- package/dist/store/session_snapshot_migrations.js.map +1 -1
- package/dist/tui/session_chat_controller.js +0 -1
- package/dist/tui/session_chat_controller.js.map +1 -1
- package/package.json +7 -7
- package/dist/core/code_mode/capability.js +0 -2
- package/dist/core/code_mode/capability.js.map +0 -1
- package/dist/core/code_mode/sdk.js +0 -60
- package/dist/core/code_mode/sdk.js.map +0 -1
- package/dist/core/static/code_mode/history/documentation.md +0 -154
- package/dist/core/static/code_mode/mcp/documentation.md +0 -281
- package/dist/core/static/code_mode/web/documentation.md +0 -161
- package/dist/core/tools/code_preloads.js +0 -94
- package/dist/core/tools/code_preloads.js.map +0 -1
- package/dist/core/tools/notifications.js +0 -87
- package/dist/core/tools/notifications.js.map +0 -1
- package/dist/diff_tool/app/dist/assets/engine-oniguruma-GMuLvN-e.js +0 -1
- package/dist/diff_tool/app/dist/assets/langs-7ebL77Wr.js +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
1
|
import { z } from "zod";
|
|
3
2
|
import { searchMcpTools } from "../mcp/search.js";
|
|
4
|
-
import {
|
|
3
|
+
import { definePackage, method } from "./package.js";
|
|
5
4
|
const nameSchema = z.string().trim().min(1).max(256);
|
|
6
5
|
const listOptionsSchema = z
|
|
7
6
|
.object({
|
|
@@ -10,116 +9,66 @@ const listOptionsSchema = z
|
|
|
10
9
|
offset: z.number().int().nonnegative().default(0),
|
|
11
10
|
})
|
|
12
11
|
.strict();
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
const listArgs = z.tuple([nameSchema, listOptionsSchema.optional()]);
|
|
13
|
+
// Every term must occur in the item's text; matching is case-insensitive.
|
|
14
|
+
function paginate(items, options, text) {
|
|
15
|
+
const { query, limit, offset } = options ?? listOptionsSchema.parse({});
|
|
16
|
+
const terms = query?.toLowerCase().split(/\s+/) ?? [];
|
|
17
|
+
const matching = items.filter((item) => {
|
|
18
|
+
const haystack = text(item).toLowerCase();
|
|
19
|
+
return terms.every((term) => haystack.includes(term));
|
|
20
|
+
});
|
|
21
|
+
const page = matching.slice(offset, offset + limit);
|
|
21
22
|
return {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return await searchMcpTools(manager, query, options ?? { limit: 8 }, context.signal);
|
|
46
|
-
},
|
|
47
|
-
listTools: async (args, context) => {
|
|
48
|
-
const [server, options] = parseMethodArgs("listTools", args, z.tuple([nameSchema, listOptionsSchema.optional()]));
|
|
49
|
-
const { query, limit, offset } = options ?? listOptionsSchema.parse({});
|
|
50
|
-
const catalog = await manager.listTools(server, context.signal);
|
|
51
|
-
const terms = query?.toLowerCase().split(/\s+/) ?? [];
|
|
52
|
-
const matching = catalog.tools.filter((tool) => {
|
|
53
|
-
const text = `${tool.name} ${tool.description ?? ""}`.toLowerCase();
|
|
54
|
-
return terms.every((term) => text.includes(term));
|
|
55
|
-
});
|
|
56
|
-
const tools = matching.slice(offset, offset + limit).map((tool) => ({
|
|
57
|
-
name: tool.name,
|
|
58
|
-
...(tool.description ? { description: tool.description } : {}),
|
|
59
|
-
}));
|
|
60
|
-
return {
|
|
61
|
-
...(catalog.instructions ? { instructions: catalog.instructions } : {}),
|
|
62
|
-
tools,
|
|
63
|
-
total: matching.length,
|
|
64
|
-
...(offset + tools.length < matching.length ? { nextOffset: offset + tools.length } : {}),
|
|
65
|
-
};
|
|
66
|
-
},
|
|
67
|
-
listResources: async (args, context) => {
|
|
68
|
-
const [server, options] = parseMethodArgs("listResources", args, z.tuple([nameSchema, listOptionsSchema.optional()]));
|
|
69
|
-
const { query, limit, offset } = options ?? listOptionsSchema.parse({});
|
|
70
|
-
const catalog = await manager.listResources(server, context.signal);
|
|
71
|
-
const terms = query?.toLowerCase().split(/\s+/) ?? [];
|
|
72
|
-
const matching = catalog.filter((resource) => {
|
|
73
|
-
const text = `${resource.uri} ${resource.name} ${resource.title ?? ""} ${resource.description ?? ""}`.toLowerCase();
|
|
74
|
-
return terms.every((term) => text.includes(term));
|
|
75
|
-
});
|
|
76
|
-
const resources = matching.slice(offset, offset + limit);
|
|
77
|
-
return {
|
|
78
|
-
resources,
|
|
79
|
-
total: matching.length,
|
|
80
|
-
...(offset + resources.length < matching.length
|
|
81
|
-
? { nextOffset: offset + resources.length }
|
|
82
|
-
: {}),
|
|
83
|
-
};
|
|
84
|
-
},
|
|
85
|
-
listResourceTemplates: async (args, context) => {
|
|
86
|
-
const [server, options] = parseMethodArgs("listResourceTemplates", args, z.tuple([nameSchema, listOptionsSchema.optional()]));
|
|
87
|
-
const { query, limit, offset } = options ?? listOptionsSchema.parse({});
|
|
88
|
-
const catalog = await manager.listResourceTemplates(server, context.signal);
|
|
89
|
-
const terms = query?.toLowerCase().split(/\s+/) ?? [];
|
|
90
|
-
const matching = catalog.filter((resource) => {
|
|
91
|
-
const text = `${resource.uriTemplate} ${resource.name} ${resource.title ?? ""} ${resource.description ?? ""}`.toLowerCase();
|
|
92
|
-
return terms.every((term) => text.includes(term));
|
|
93
|
-
});
|
|
94
|
-
const resourceTemplates = matching.slice(offset, offset + limit);
|
|
95
|
-
return {
|
|
96
|
-
resourceTemplates,
|
|
97
|
-
total: matching.length,
|
|
98
|
-
...(offset + resourceTemplates.length < matching.length
|
|
99
|
-
? { nextOffset: offset + resourceTemplates.length }
|
|
100
|
-
: {}),
|
|
101
|
-
};
|
|
102
|
-
},
|
|
103
|
-
readResource: async (args, context) => {
|
|
104
|
-
const [server, uri] = parseMethodArgs("readResource", args, z.tuple([nameSchema, z.string().trim().min(1).max(8_192)]));
|
|
105
|
-
return await manager.readResource(server, uri, context.signal);
|
|
106
|
-
},
|
|
107
|
-
describeTool: async (args, context) => {
|
|
108
|
-
const [server, name] = parseMethodArgs("describeTool", args, z.tuple([nameSchema, nameSchema]));
|
|
109
|
-
const tool = await manager.describeTool(server, name, context.signal);
|
|
110
|
-
return {
|
|
23
|
+
items: page,
|
|
24
|
+
total: matching.length,
|
|
25
|
+
...(offset + page.length < matching.length ? { nextOffset: offset + page.length } : {}),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function createMcpPackage(manager) {
|
|
29
|
+
return definePackage("mcp", "Call tools and read resources from the MCP servers listed in your instructions.", {
|
|
30
|
+
listServers: method(z.tuple([]), () => manager.listServers()),
|
|
31
|
+
searchTools: method(z.tuple([
|
|
32
|
+
z.string().trim().min(1).max(1_000),
|
|
33
|
+
z
|
|
34
|
+
.strictObject({
|
|
35
|
+
server: nameSchema.optional(),
|
|
36
|
+
limit: z.number().int().min(1).max(100).default(8),
|
|
37
|
+
})
|
|
38
|
+
.optional(),
|
|
39
|
+
]), ([query, options], { signal }) => searchMcpTools(manager, query, options ?? { limit: 8 }, signal)),
|
|
40
|
+
listTools: method(listArgs, async ([server, options], { signal }) => {
|
|
41
|
+
const catalog = await manager.listTools(server, signal);
|
|
42
|
+
const { items, ...page } = paginate(catalog.tools, options, (tool) => `${tool.name} ${tool.description ?? ""}`);
|
|
43
|
+
return {
|
|
44
|
+
...(catalog.instructions ? { instructions: catalog.instructions } : {}),
|
|
45
|
+
tools: items.map((tool) => ({
|
|
111
46
|
name: tool.name,
|
|
112
47
|
...(tool.description ? { description: tool.description } : {}),
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
48
|
+
})),
|
|
49
|
+
...page,
|
|
50
|
+
};
|
|
51
|
+
}),
|
|
52
|
+
describeTool: method(z.tuple([nameSchema, nameSchema]), async ([server, name], { signal }) => {
|
|
53
|
+
const tool = await manager.describeTool(server, name, signal);
|
|
54
|
+
return {
|
|
55
|
+
name: tool.name,
|
|
56
|
+
...(tool.description ? { description: tool.description } : {}),
|
|
57
|
+
inputSchema: tool.inputSchema,
|
|
58
|
+
...(tool.outputSchema ? { outputSchema: tool.outputSchema } : {}),
|
|
59
|
+
...(tool.annotations ? { annotations: tool.annotations } : {}),
|
|
60
|
+
};
|
|
61
|
+
}),
|
|
62
|
+
callTool: method(z.tuple([nameSchema, nameSchema, z.record(z.string(), z.unknown())]), ([server, name, input], { signal }) => manager.callTool(server, name, input, signal)),
|
|
63
|
+
listResources: method(listArgs, async ([server, options], { signal }) => {
|
|
64
|
+
const { items, ...page } = paginate(await manager.listResources(server, signal), options, (resource) => `${resource.uri} ${resource.name} ${resource.title ?? ""} ${resource.description ?? ""}`);
|
|
65
|
+
return { resources: items, ...page };
|
|
66
|
+
}),
|
|
67
|
+
listResourceTemplates: method(listArgs, async ([server, options], { signal }) => {
|
|
68
|
+
const { items, ...page } = paginate(await manager.listResourceTemplates(server, signal), options, (template) => `${template.uriTemplate} ${template.name} ${template.title ?? ""} ${template.description ?? ""}`);
|
|
69
|
+
return { resourceTemplates: items, ...page };
|
|
70
|
+
}),
|
|
71
|
+
readResource: method(z.tuple([nameSchema, z.string().trim().min(1).max(8_192)]), ([server, uri], { signal }) => manager.readResource(server, uri, signal)),
|
|
72
|
+
});
|
|
124
73
|
}
|
|
125
74
|
//# sourceMappingURL=mcp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../../src/core/code_mode/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../../src/core/code_mode/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAwB,aAAa,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3E,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACrD,MAAM,iBAAiB,GAAG,CAAC;KACxB,MAAM,CAAC;IACN,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,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jC,MAAM,OAAO,CAAC,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,EACnD,OAAO,EACP,CAAC,QAAQ,EAAE,EAAE,CACX,GAAG,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,KAAK,IAAI,EAAE,IAAI,QAAQ,CAAC,WAAW,IAAI,EAAE,EAAE,CACnG,CAAC;YACF,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,CAAC;QAC/C,CAAC,CAAC;QACF,YAAY,EAAE,MAAM,CAClB,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAC1D,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CACzE;KACF,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,26 +1,41 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { requireCapability } from "../agent/capabilities.js";
|
|
3
4
|
import { openRouterModels, requestOpenRouterChat, requestOpenRouterDecisions, } from "../models/openrouter.js";
|
|
5
|
+
import { definePackage, method } from "./package.js";
|
|
4
6
|
const kind = z.enum(["image", "audio", "video"]);
|
|
5
7
|
const attachment = z.union([
|
|
6
8
|
z.strictObject({ type: kind, path: z.string().min(1) }),
|
|
7
|
-
z.strictObject({ type: kind,
|
|
9
|
+
z.strictObject({ type: kind, bytes: z.instanceof(Uint8Array) }),
|
|
10
|
+
]);
|
|
11
|
+
const textPart = z.strictObject({ type: z.literal("text"), text: z.string().min(1) });
|
|
12
|
+
const userContent = z.union([z.string().min(1), z.array(z.union([textPart, attachment])).min(1)]);
|
|
13
|
+
const chatInput = z.union([
|
|
14
|
+
z.string().min(1),
|
|
15
|
+
z
|
|
16
|
+
.array(z.discriminatedUnion("role", [
|
|
17
|
+
z.strictObject({ role: z.literal("user"), content: userContent }),
|
|
18
|
+
z.strictObject({ role: z.literal("assistant"), content: z.string().min(1) }),
|
|
19
|
+
]))
|
|
20
|
+
.min(1),
|
|
8
21
|
]);
|
|
9
22
|
const chatOptions = z.strictObject({
|
|
10
23
|
model: z.string().min(1),
|
|
11
|
-
prompt: z.string().min(1),
|
|
12
24
|
system: z.string().min(1).optional(),
|
|
13
25
|
reasoning: z.string().optional(),
|
|
14
26
|
schema: z.record(z.string(), z.json()).optional(),
|
|
15
|
-
attachments: z.array(attachment).max(64).default([]),
|
|
16
27
|
});
|
|
17
28
|
const decisionOptions = z.strictObject({
|
|
18
29
|
model: z.string().min(1),
|
|
19
|
-
|
|
20
|
-
questions: z.unknown(),
|
|
30
|
+
questions: z.record(z.string(), z.unknown()),
|
|
21
31
|
attachments: z.array(attachment).max(64).default([]),
|
|
22
32
|
});
|
|
23
|
-
|
|
33
|
+
function providerAttachment(part) {
|
|
34
|
+
return "path" in part
|
|
35
|
+
? { kind: part.type, path: part.path }
|
|
36
|
+
: { kind: part.type, data: Buffer.from(part.bytes).toString("base64") };
|
|
37
|
+
}
|
|
38
|
+
export function createModelsPackage(backend, config, availability, fetchImpl) {
|
|
24
39
|
function mediaAdapter(signal) {
|
|
25
40
|
return {
|
|
26
41
|
readFile: async (path, limit) => {
|
|
@@ -63,269 +78,72 @@ export function createModelsCapability(backend, config, fetchImpl) {
|
|
|
63
78
|
},
|
|
64
79
|
};
|
|
65
80
|
}
|
|
66
|
-
return {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
completion_tokens: number;
|
|
133
|
-
total_tokens: number;
|
|
134
|
-
cost?: number | null;
|
|
135
|
-
[key: string]: unknown;
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
\`\`\`
|
|
139
|
-
|
|
140
|
-
\`prompt\` and optional \`system\` must be nonblank. Omitted attachments default to an empty array. Omitted system instructions send no system message. Omitted reasoning leaves that setting to the provider; it does not necessarily disable reasoning. Reasoning traces are not returned as answer text.
|
|
141
|
-
|
|
142
|
-
Attachments follow the prompt in array order. Paths resolve from the current working directory. Inline data must be canonical padded base64 with a MIME type matching the actual bytes. All arguments of one call must fit in 64 MiB of JSON, so pass large media as paths. Supply exactly one source form per attachment, not a URL. Audio/video require ffprobe on PATH. Unsupported media fail rather than being resized, converted, transcribed, or split automatically.
|
|
143
|
-
|
|
144
|
-
\`requested_model\` records the selected ID; \`model\` records the provider's returned ID. Inspect completion status before using the answer:
|
|
145
|
-
|
|
146
|
-
- \`stop\` with no refusal is complete.
|
|
147
|
-
- \`length\` is incomplete, even if answer text is empty.
|
|
148
|
-
- \`content_filter\` or a nonempty \`refusal\` is refusal, not a completed answer.
|
|
149
|
-
|
|
150
|
-
These statuses resolve normally. Invalid responses, unexpected tool calls, and a normal stop with neither answer nor refusal throw. No output token cap is sent; provider and model limits still apply.
|
|
151
|
-
|
|
152
|
-
Without \`schema\`, \`answer\` is text. With \`schema\` (a JSON Schema object), Tau requests structured output from the provider and returns the parsed JSON as \`answer\`. Use a complete answer directly for ordinary extraction and analysis. How strictly the schema is enforced varies by provider, so add targeted checks when a constraint matters for a consequential action. An incomplete or refused response keeps its status and refusal fields but returns \`answer: null\` and no partial output. A complete answer that is not valid JSON throws. The request goes only to providers that support structured outputs, so it fails if none can serve the selected model. Schemas work across the most providers when they use an object at the root, list every property in \`required\`, and set \`additionalProperties: false\` on every object.
|
|
153
|
-
|
|
154
|
-
For example, select a listed image-capable model and supply an existing screenshot:
|
|
155
|
-
|
|
156
|
-
\`\`\`js
|
|
157
|
-
const catalog = await tau.models.list();
|
|
158
|
-
const model = catalog.chat.find(item => item.id === "openai/gpt-6-luna");
|
|
159
|
-
if (!model || !model.inputs.includes("image")) throw new Error("model unavailable for images");
|
|
160
|
-
const result = await tau.models.chat({
|
|
161
|
-
model: model.id,
|
|
162
|
-
prompt: "Extract the error message and describe the visible failure.",
|
|
163
|
-
attachments: [{ type: "image", path: "./screenshot.png" }],
|
|
164
|
-
});
|
|
165
|
-
if (result.finish_reason !== "stop" || result.refusal || !result.answer)
|
|
166
|
-
throw new Error("model did not produce a complete answer");
|
|
167
|
-
printText(result.answer);
|
|
168
|
-
\`\`\`
|
|
169
|
-
|
|
170
|
-
Ask for the same screenshot's errors as data:
|
|
171
|
-
|
|
172
|
-
\`\`\`js
|
|
173
|
-
const result = await tau.models.chat({
|
|
174
|
-
model: "openai/gpt-6-luna",
|
|
175
|
-
prompt: "List every error message visible in the screenshot.",
|
|
176
|
-
attachments: [{ type: "image", path: "./screenshot.png" }],
|
|
177
|
-
schema: {
|
|
178
|
-
type: "object",
|
|
179
|
-
properties: { errors: { type: "array", items: { type: "string" } } },
|
|
180
|
-
required: ["errors"],
|
|
181
|
-
additionalProperties: false,
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
if (result.finish_reason !== "stop" || result.refusal)
|
|
185
|
-
throw new Error("model did not produce a complete answer");
|
|
186
|
-
for (const error of result.answer.errors) printText(error);
|
|
187
|
-
\`\`\`
|
|
188
|
-
|
|
189
|
-
## \`tau.models.decisions(options)\`
|
|
190
|
-
|
|
191
|
-
Ask several named questions about one supplied state. Independent questions can share a request; dependent questions require separate calls.
|
|
192
|
-
|
|
193
|
-
\`\`\`ts
|
|
194
|
-
type Guidance = string | Json[] | { [key: string]: Json };
|
|
195
|
-
type Question =
|
|
196
|
-
| { type: "noul"; instructions: Guidance; criteria?: { true: Guidance; false: Guidance } }
|
|
197
|
-
| { type: "choice"; instructions: Guidance; criteria: Record<string, Guidance | null> }
|
|
198
|
-
| { type: "score"; instructions: Guidance; criteria: Guidance[] };
|
|
199
|
-
type DecisionOptions = {
|
|
200
|
-
model: string;
|
|
201
|
-
state: Guidance;
|
|
202
|
-
questions: Record<string, Question>;
|
|
203
|
-
attachments?: Attachment[];
|
|
204
|
-
};
|
|
205
|
-
type Answer =
|
|
206
|
-
| { type: "noul"; noul: number }
|
|
207
|
-
| {
|
|
208
|
-
type: "choice";
|
|
209
|
-
choice: string;
|
|
210
|
-
confidence?: number;
|
|
211
|
-
probabilities?: Record<string, number>;
|
|
212
|
-
}
|
|
213
|
-
| {
|
|
214
|
-
type: "score";
|
|
215
|
-
score: number;
|
|
216
|
-
confidence?: number;
|
|
217
|
-
probabilities?: Record<string, number>;
|
|
218
|
-
legend?: Record<string, Guidance>;
|
|
219
|
-
};
|
|
220
|
-
type DecisionResult = {
|
|
221
|
-
requested_model: string;
|
|
222
|
-
model: string;
|
|
223
|
-
answers: Record<string, Answer>;
|
|
224
|
-
usage: { input_tokens: number; output_tokens: number; cost?: number; [key: string]: unknown };
|
|
225
|
-
id?: string;
|
|
226
|
-
provider?: string;
|
|
227
|
-
};
|
|
228
|
-
\`\`\`
|
|
229
|
-
|
|
230
|
-
\`questions\` must be nonempty with nonempty names. Choice criteria require at least one category; score criteria require a nonempty ordered rubric. Unknown question fields and the question/category name \`__proto__\` are rejected. Every question receives an answer of the corresponding type:
|
|
231
|
-
|
|
232
|
-
- \`noul\`: probability from 0 to 1, not a boolean.
|
|
233
|
-
- \`choice\`: one supplied category; optional confidence and category probabilities are from 0 to 1.
|
|
234
|
-
- \`score\`: position from 0 to the final rubric index, possibly fractional. Distribution and legend keys are rubric-index strings. Optional confidence and probabilities are from 0 to 1.
|
|
235
|
-
|
|
236
|
-
Prefer \`openai/gpt-6-luna-decisions\` for decisions, including text, JSON, and image-based judgments. Choose \`typesafe/jev-1.14\` for high-volume text, JSON, or image decisions when cost is the priority. Use \`google/gemini-decision-1\` when the judgment depends on audio or video, because it is the only decision model that accepts them.
|
|
237
|
-
|
|
238
|
-
Luna supports at most 200 questions, 255 categories per choice question, and 2–10 rubric levels per score question. Gemini supports at most 255 categories per choice question. These limits are checked before sending the request. Jev accepts single-level score rubrics.
|
|
239
|
-
|
|
240
|
-
Supply media through \`attachments\`, using the same path or inline forms as chat. Describe what to check in \`questions\`. Attachments follow \`state\` in array order and retain their original bytes. Objects and arrays in \`state\` are sent as JSON text, so media URLs inside \`state\` are treated as text.
|
|
241
|
-
|
|
242
|
-
Luna accepts up to 64 PNG/JPEG/WebP images. Gemini accepts up to 64 images, audio files, and videos in any mix, in the same formats as chat.
|
|
243
|
-
|
|
244
|
-
Jev accepts up to 16 PNG/JPEG images through the same attachment forms. Each side must be 256–1,568 pixels, with at least 78,400 pixels in total (inclusive limits). A 256×256 image is too small; 280×280 meets the minimum area. WebP is unsupported. These constraints are checked before sending, without resizing or conversion. Jev does not apply EXIF orientation, so rotate photos before attaching them. Provider-side processed-image and expanded-request limits may still reject locally valid requests. Bounding-box questions are unsupported.
|
|
245
|
-
|
|
246
|
-
The media limits below apply to decisions too. Omitting \`attachments\` sends no media.
|
|
247
|
-
|
|
248
|
-
Negative judgments and low confidence are normal results. Refusals and responses with mismatched names, types, categories, or ranges throw. The tool returns the model's answers without adding decision thresholds or prose explanations.
|
|
249
|
-
|
|
250
|
-
\`\`\`js
|
|
251
|
-
const catalog = await tau.models.list();
|
|
252
|
-
const model = catalog.decisions.find(item => item.id === "openai/gpt-6-luna-decisions");
|
|
253
|
-
if (!model) throw new Error("decision model unavailable");
|
|
254
|
-
const result = await tau.models.decisions({
|
|
255
|
-
model: model.id,
|
|
256
|
-
state: { ticket: "Checkout crashes when I click Pay." },
|
|
257
|
-
questions: {
|
|
258
|
-
is_bug: { type: "noul", instructions: "Does this describe broken behavior?" },
|
|
259
|
-
urgency: {
|
|
260
|
-
type: "score",
|
|
261
|
-
instructions: "How urgent is this issue?",
|
|
262
|
-
criteria: ["Can wait", "Fix soon", "Blocking revenue"],
|
|
263
|
-
},
|
|
264
|
-
},
|
|
265
|
-
});
|
|
266
|
-
printText(JSON.stringify(result.answers));
|
|
267
|
-
\`\`\`
|
|
268
|
-
|
|
269
|
-
Inspect an existing screenshot:
|
|
270
|
-
|
|
271
|
-
\`\`\`js
|
|
272
|
-
const result = await tau.models.decisions({
|
|
273
|
-
model: "openai/gpt-6-luna-decisions",
|
|
274
|
-
state: "Check the checkout screen for visible errors.",
|
|
275
|
-
questions: {
|
|
276
|
-
has_error: { type: "noul", instructions: "Is an error message visible?" },
|
|
277
|
-
},
|
|
278
|
-
attachments: [{ type: "image", path: "./checkout.png" }],
|
|
279
|
-
});
|
|
280
|
-
printText(JSON.stringify(result.answers));
|
|
281
|
-
\`\`\`
|
|
282
|
-
|
|
283
|
-
## Limits and failures
|
|
284
|
-
|
|
285
|
-
These limits reject abnormal input. A request within them can still exceed the model's context window or a provider limit.
|
|
286
|
-
|
|
287
|
-
- Text: 20 MiB of UTF-8 for the decisions input, and 20 MiB combined for a chat's prompt, system, and schema.
|
|
288
|
-
- Attachments: 64 per request in any mix of types; 16 for Jev.
|
|
289
|
-
- Each image: 32 MiB; PNG/JPEG/WebP, one frame, at most 32,768 pixels per edge and 100 megapixels.
|
|
290
|
-
- Each audio/video: 256 MiB; single-stream PCM16 WAV or MP3, or H.264 MP4 up to 3840×2160 with optional AAC. Positive known duration, at most 7,200 seconds (2 hours) combined.
|
|
291
|
-
- Encoded request: 512 MiB including base64 and text; response: 32 MiB.
|
|
292
|
-
|
|
293
|
-
Large requests share a memory budget, so a call may wait until earlier calls finish. Waiting counts toward the program's deadline.
|
|
294
|
-
|
|
295
|
-
Validation, authentication, service failures, and malformed responses throw. There are no automatic retries. A failed or interrupted request may already be billable: inspect the outcome before retrying. Returned usage contains provider-reported metadata, not estimates; external charges are not included in session cost or usage logs.`,
|
|
296
|
-
api: {
|
|
297
|
-
list: (args) => {
|
|
298
|
-
z.tuple([]).parse(args);
|
|
299
|
-
return structuredClone(openRouterModels);
|
|
300
|
-
},
|
|
301
|
-
chat: async (args, context) => {
|
|
302
|
-
const [input] = z.tuple([chatOptions]).parse(args);
|
|
303
|
-
return await requestOpenRouterChat({
|
|
304
|
-
...input,
|
|
305
|
-
attachments: input.attachments.map(({ type, ...source }) => ({
|
|
306
|
-
kind: type,
|
|
307
|
-
...source,
|
|
308
|
-
})),
|
|
309
|
-
}, {
|
|
310
|
-
config,
|
|
311
|
-
signal: context.signal,
|
|
312
|
-
fetchImpl,
|
|
313
|
-
mediaAdapter: mediaAdapter(context.signal),
|
|
314
|
-
});
|
|
315
|
-
},
|
|
316
|
-
decisions: async (args, context) => {
|
|
317
|
-
const [input] = z.tuple([decisionOptions]).parse(args);
|
|
318
|
-
return await requestOpenRouterDecisions({
|
|
319
|
-
model: input.model,
|
|
320
|
-
value: { state: input.state, questions: input.questions },
|
|
321
|
-
attachments: input.attachments.map(({ type, ...source }) => ({
|
|
322
|
-
kind: type,
|
|
323
|
-
...source,
|
|
324
|
-
})),
|
|
325
|
-
}, { config, signal: context.signal, fetchImpl, mediaAdapter: mediaAdapter(context.signal) });
|
|
326
|
-
},
|
|
327
|
-
},
|
|
328
|
-
};
|
|
81
|
+
return definePackage("models", "Make one-off LLM calls to analyze text and media, return structured output, and make typed decisions.", {
|
|
82
|
+
list: method(z.tuple([]), () => Object.fromEntries(Object.entries(openRouterModels).map(([operation, models]) => [
|
|
83
|
+
operation,
|
|
84
|
+
models.map(({ id, inputs, reasoning, role }) => ({ id, inputs, reasoning, role })),
|
|
85
|
+
]))),
|
|
86
|
+
chat: method(z.tuple([chatInput, chatOptions]), async ([input, options], context) => {
|
|
87
|
+
requireCapability(availability, "Model inference");
|
|
88
|
+
const turns = typeof input === "string" ? [{ role: "user", content: input }] : input;
|
|
89
|
+
const result = await requestOpenRouterChat({
|
|
90
|
+
...options,
|
|
91
|
+
messages: turns.map((turn) => turn.role === "assistant"
|
|
92
|
+
? turn
|
|
93
|
+
: {
|
|
94
|
+
role: "user",
|
|
95
|
+
content: typeof turn.content === "string"
|
|
96
|
+
? [{ type: "text", text: turn.content }]
|
|
97
|
+
: turn.content.map((part) => part.type === "text" ? part : providerAttachment(part)),
|
|
98
|
+
}),
|
|
99
|
+
}, {
|
|
100
|
+
config,
|
|
101
|
+
signal: context.signal,
|
|
102
|
+
fetchImpl,
|
|
103
|
+
mediaAdapter: mediaAdapter(context.signal),
|
|
104
|
+
});
|
|
105
|
+
const status = result.refusal || result.finish_reason === "content_filter"
|
|
106
|
+
? "refused"
|
|
107
|
+
: result.finish_reason === "length"
|
|
108
|
+
? "incomplete"
|
|
109
|
+
: "complete";
|
|
110
|
+
const usage = result.usage;
|
|
111
|
+
return {
|
|
112
|
+
status,
|
|
113
|
+
answer: status === "complete" ? result.answer : null,
|
|
114
|
+
...(usage
|
|
115
|
+
? {
|
|
116
|
+
usage: {
|
|
117
|
+
inputTokens: usage.prompt_tokens,
|
|
118
|
+
outputTokens: usage.completion_tokens,
|
|
119
|
+
...(usage.cost !== undefined ? { cost: usage.cost } : {}),
|
|
120
|
+
},
|
|
121
|
+
}
|
|
122
|
+
: {}),
|
|
123
|
+
};
|
|
124
|
+
}),
|
|
125
|
+
decisions: method(z.tuple([z.json(), decisionOptions]), async ([state, options], context) => {
|
|
126
|
+
requireCapability(availability, "Model inference");
|
|
127
|
+
const { answers, usage } = await requestOpenRouterDecisions({
|
|
128
|
+
model: options.model,
|
|
129
|
+
value: { state, questions: options.questions },
|
|
130
|
+
attachments: options.attachments.map(providerAttachment),
|
|
131
|
+
}, {
|
|
132
|
+
config,
|
|
133
|
+
signal: context.signal,
|
|
134
|
+
fetchImpl,
|
|
135
|
+
mediaAdapter: mediaAdapter(context.signal),
|
|
136
|
+
});
|
|
137
|
+
return {
|
|
138
|
+
answers,
|
|
139
|
+
usage: {
|
|
140
|
+
inputTokens: usage.input_tokens,
|
|
141
|
+
outputTokens: usage.output_tokens,
|
|
142
|
+
...(usage.cost !== undefined ? { cost: usage.cost } : {}),
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}),
|
|
146
|
+
});
|
|
329
147
|
}
|
|
330
148
|
const stageScript = `
|
|
331
149
|
const fs = require("node:fs");
|