@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.
Files changed (200) hide show
  1. package/dist/code_mode/command.d.ts +1 -1
  2. package/dist/code_mode/command.js +2 -28
  3. package/dist/code_mode/command.js.map +1 -1
  4. package/dist/code_mode/errors.d.ts +3 -0
  5. package/dist/code_mode/errors.js +4 -0
  6. package/dist/code_mode/errors.js.map +1 -0
  7. package/dist/code_mode/images.js +10 -2
  8. package/dist/code_mode/images.js.map +1 -1
  9. package/dist/code_mode/index.d.ts +2 -2
  10. package/dist/code_mode/index.js +1 -1
  11. package/dist/code_mode/index.js.map +1 -1
  12. package/dist/code_mode/runtime.d.ts +40 -18
  13. package/dist/code_mode/runtime.js +139 -162
  14. package/dist/code_mode/runtime.js.map +1 -1
  15. package/dist/code_mode/wire.d.ts +2 -0
  16. package/dist/code_mode/wire.js +64 -0
  17. package/dist/code_mode/wire.js.map +1 -0
  18. package/dist/core/agent/capabilities.js +68 -0
  19. package/dist/core/agent/capabilities.js.map +1 -0
  20. package/dist/core/agent/notification_inbox.js +6 -6
  21. package/dist/core/agent/notification_inbox.js.map +1 -1
  22. package/dist/core/code_mode/agents.js +104 -477
  23. package/dist/core/code_mode/agents.js.map +1 -1
  24. package/dist/core/code_mode/bash.js +49 -238
  25. package/dist/core/code_mode/bash.js.map +1 -1
  26. package/dist/core/code_mode/files.js +66 -0
  27. package/dist/core/code_mode/files.js.map +1 -0
  28. package/dist/core/code_mode/history.js +7 -38
  29. package/dist/core/code_mode/history.js.map +1 -1
  30. package/dist/core/code_mode/mcp.js +59 -110
  31. package/dist/core/code_mode/mcp.js.map +1 -1
  32. package/dist/core/code_mode/models.js +87 -269
  33. package/dist/core/code_mode/models.js.map +1 -1
  34. package/dist/core/code_mode/notifications.js +20 -0
  35. package/dist/core/code_mode/notifications.js.map +1 -0
  36. package/dist/core/code_mode/package.js +37 -0
  37. package/dist/core/code_mode/package.js.map +1 -0
  38. package/dist/core/code_mode/web.js +50 -140
  39. package/dist/core/code_mode/web.js.map +1 -1
  40. package/dist/core/config/content_loader.js +5 -76
  41. package/dist/core/config/content_loader.js.map +1 -1
  42. package/dist/core/config/index.js +1 -1
  43. package/dist/core/config/index.js.map +1 -1
  44. package/dist/core/config/schema.js +3 -0
  45. package/dist/core/config/schema.js.map +1 -1
  46. package/dist/core/debug.js +11 -16
  47. package/dist/core/debug.js.map +1 -1
  48. package/dist/core/diff_review/review_instructions.js +1 -1
  49. package/dist/core/diff_review/review_instructions.js.map +1 -1
  50. package/dist/core/mcp/manager.js.map +1 -1
  51. package/dist/core/models/openrouter.js +33 -12
  52. package/dist/core/models/openrouter.js.map +1 -1
  53. package/dist/core/modes/run.js +1 -0
  54. package/dist/core/modes/run.js.map +1 -1
  55. package/dist/core/personas.js +112 -53
  56. package/dist/core/personas.js.map +1 -1
  57. package/dist/core/runtime/chat_runtime.js +16 -1
  58. package/dist/core/runtime/chat_runtime.js.map +1 -1
  59. package/dist/core/runtime/model_prompt_notes.js +1 -1
  60. package/dist/core/runtime/model_prompt_notes.js.map +1 -1
  61. package/dist/core/runtime/session_prompt_composer.js +20 -12
  62. package/dist/core/runtime/session_prompt_composer.js.map +1 -1
  63. package/dist/core/static/code_mode/docs/agents.md +131 -0
  64. package/dist/core/static/code_mode/docs/bash.md +74 -0
  65. package/dist/core/static/code_mode/docs/core.md +67 -0
  66. package/dist/core/static/code_mode/docs/examples.md +135 -0
  67. package/dist/core/static/code_mode/docs/files.md +38 -0
  68. package/dist/core/static/code_mode/docs/history.md +104 -0
  69. package/dist/core/static/code_mode/docs/mcp.md +109 -0
  70. package/dist/core/static/code_mode/docs/models.md +104 -0
  71. package/dist/core/static/code_mode/docs/notifications.md +29 -0
  72. package/dist/core/static/code_mode/docs/web.md +100 -0
  73. package/dist/core/static/code_mode/modules.mjs +67 -0
  74. package/dist/core/static/code_mode/sandbox_runner.mjs +66 -121
  75. package/dist/core/static/index.js +3 -3
  76. package/dist/core/static/index.js.map +1 -1
  77. package/dist/core/static/prompts/subagent-prefix.md +1 -1
  78. package/dist/core/static/tau_docs/client-tools.md +1 -1
  79. package/dist/core/static/tau_docs/code-mode.md +16 -124
  80. package/dist/core/static/tau_docs/history.md +2 -2
  81. package/dist/core/static/tau_docs/index.md +1 -1
  82. package/dist/core/static/tau_docs/mcp.md +1 -1
  83. package/dist/core/static/tau_docs/models-and-credentials.md +1 -1
  84. package/dist/core/static/tau_docs/personas.md +3 -15
  85. package/dist/core/static/tau_docs/sdk.md +7 -2
  86. package/dist/core/static/tau_docs/sessions.md +1 -1
  87. package/dist/core/static/tau_docs/subagents.md +7 -20
  88. package/dist/core/static/tau_docs/tools.md +8 -18
  89. package/dist/core/static/tau_docs/troubleshooting.md +1 -1
  90. package/dist/core/subagents/agent_supervisor.js +11 -10
  91. package/dist/core/subagents/agent_supervisor.js.map +1 -1
  92. package/dist/core/subagents/claude_code_models.js +10 -0
  93. package/dist/core/subagents/claude_code_models.js.map +1 -1
  94. package/dist/core/subagents/claude_code_protocol.js +1 -1
  95. package/dist/core/subagents/claude_code_protocol.js.map +1 -1
  96. package/dist/core/subagents/claude_code_runner.js +26 -26
  97. package/dist/core/subagents/claude_code_runner.js.map +1 -1
  98. package/dist/core/subagents/claude_code_runner.mjs +76 -74
  99. package/dist/core/subagents/claude_code_runtime.js +1 -1
  100. package/dist/core/subagents/format.js +1 -1
  101. package/dist/core/subagents/format.js.map +1 -1
  102. package/dist/core/subagents/native_subagent_runtime.js +30 -14
  103. package/dist/core/subagents/native_subagent_runtime.js.map +1 -1
  104. package/dist/core/subagents/prompt.js.map +1 -1
  105. package/dist/core/subagents/registry.js +6 -41
  106. package/dist/core/subagents/registry.js.map +1 -1
  107. package/dist/core/subagents/runtime.js.map +1 -1
  108. package/dist/core/subagents/trace.js +6 -4
  109. package/dist/core/subagents/trace.js.map +1 -1
  110. package/dist/core/subagents/types.js +1 -12
  111. package/dist/core/subagents/types.js.map +1 -1
  112. package/dist/core/tool/openrouter.js +9 -2
  113. package/dist/core/tool/openrouter.js.map +1 -1
  114. package/dist/core/tools/background_jobs.js +1 -1
  115. package/dist/core/tools/background_jobs.js.map +1 -1
  116. package/dist/core/tools/bash_jobs.js +11 -0
  117. package/dist/core/tools/bash_jobs.js.map +1 -1
  118. package/dist/core/tools/catalog.js +24 -40
  119. package/dist/core/tools/catalog.js.map +1 -1
  120. package/dist/core/tools/code.js +96 -108
  121. package/dist/core/tools/code.js.map +1 -1
  122. package/dist/core/tools/code_jobs.js +5 -5
  123. package/dist/core/tools/code_jobs.js.map +1 -1
  124. package/dist/core/tools/code_mode.js +79 -108
  125. package/dist/core/tools/code_mode.js.map +1 -1
  126. package/dist/core/tools/code_mode_worker.js +14 -42
  127. package/dist/core/tools/code_mode_worker.js.map +1 -1
  128. package/dist/core/tools/code_modules.js +21 -0
  129. package/dist/core/tools/code_modules.js.map +1 -0
  130. package/dist/core/tools/edit.js +6 -24
  131. package/dist/core/tools/edit.js.map +1 -1
  132. package/dist/core/tools/execution_backend.js +13 -6
  133. package/dist/core/tools/execution_backend.js.map +1 -1
  134. package/dist/core/tools/file_edits.js +17 -0
  135. package/dist/core/tools/file_edits.js.map +1 -0
  136. package/dist/core/tools/tool_names.js +2 -12
  137. package/dist/core/tools/tool_names.js.map +1 -1
  138. package/dist/core/tools/wait_for_agents.js +8 -2
  139. package/dist/core/tools/wait_for_agents.js.map +1 -1
  140. package/dist/core/types.js.map +1 -1
  141. package/dist/core/utils/context.js +1 -1
  142. package/dist/core/utils/context.js.map +1 -1
  143. package/dist/core/utils/context_builder.js +16 -2
  144. package/dist/core/utils/context_builder.js.map +1 -1
  145. package/dist/core/version.js +1 -1
  146. package/dist/diff_tool/app/dist/assets/{core-D5eeuYMf.js → core-BfpRGcqe.js} +1 -1
  147. package/dist/diff_tool/app/dist/assets/engine-oniguruma-D_AXpl2k.js +1 -0
  148. package/dist/diff_tool/app/dist/assets/{highlights-6TYlERwf.js → highlights-CLc_g6m8.js} +1 -1
  149. package/dist/diff_tool/app/dist/assets/{index-DHhgT2Y7.js → index-bu2WOD1Y.js} +37 -37
  150. package/dist/diff_tool/app/dist/assets/langs-DO7BJV2U.js +1 -0
  151. package/dist/diff_tool/app/dist/assets/{shiki-CNf9g2mc.js → shiki-r9Q4gIo6.js} +2 -2
  152. package/dist/diff_tool/app/dist/assets/{stream-tokenizer-0Xi4Io-I.js → stream-tokenizer-bgeDT4xc.js} +1 -1
  153. package/dist/diff_tool/app/dist/assets/{themes-QMIFS5bl.js → themes-h4OE3MIe.js} +2 -2
  154. package/dist/diff_tool/app/dist/index.html +1 -1
  155. package/dist/execution/fly_sprite_execution_environment.js +17 -13
  156. package/dist/execution/fly_sprite_execution_environment.js.map +1 -1
  157. package/dist/host/execution_runtime.js +4 -3
  158. package/dist/host/execution_runtime.js.map +1 -1
  159. package/dist/host/hosted_ephemeral_agent_session.js +24 -4
  160. package/dist/host/hosted_ephemeral_agent_session.js.map +1 -1
  161. package/dist/host/local_session_host.js +20 -15
  162. package/dist/host/local_session_host.js.map +1 -1
  163. package/dist/host/session_protocol_handler.js +0 -1
  164. package/dist/host/session_protocol_handler.js.map +1 -1
  165. package/dist/protocol/index.d.ts +1 -1
  166. package/dist/protocol/index.js.map +1 -1
  167. package/dist/protocol/session_protocol.d.ts +0 -3
  168. package/dist/protocol/session_protocol.js +3 -14
  169. package/dist/protocol/session_protocol.js.map +1 -1
  170. package/dist/sdk/code_mode.d.ts +6 -0
  171. package/dist/sdk/code_mode.js +16 -7
  172. package/dist/sdk/code_mode.js.map +1 -1
  173. package/dist/sdk/diff_review.js +0 -1
  174. package/dist/sdk/diff_review.js.map +1 -1
  175. package/dist/sdk/index.d.ts +1 -1
  176. package/dist/sdk/index.js.map +1 -1
  177. package/dist/sdk/session.js +3 -1
  178. package/dist/sdk/session.js.map +1 -1
  179. package/dist/sdk/session_tool_execution_backend.d.ts +1 -1
  180. package/dist/sdk/session_tool_execution_backend.js +11 -2
  181. package/dist/sdk/session_tool_execution_backend.js.map +1 -1
  182. package/dist/sdk/types.d.ts +1 -3
  183. package/dist/store/session_snapshot_migrations.js +3 -23
  184. package/dist/store/session_snapshot_migrations.js.map +1 -1
  185. package/dist/tui/session_chat_controller.js +0 -1
  186. package/dist/tui/session_chat_controller.js.map +1 -1
  187. package/package.json +7 -7
  188. package/dist/core/code_mode/capability.js +0 -2
  189. package/dist/core/code_mode/capability.js.map +0 -1
  190. package/dist/core/code_mode/sdk.js +0 -60
  191. package/dist/core/code_mode/sdk.js.map +0 -1
  192. package/dist/core/static/code_mode/history/documentation.md +0 -154
  193. package/dist/core/static/code_mode/mcp/documentation.md +0 -281
  194. package/dist/core/static/code_mode/web/documentation.md +0 -161
  195. package/dist/core/tools/code_preloads.js +0 -94
  196. package/dist/core/tools/code_preloads.js.map +0 -1
  197. package/dist/core/tools/notifications.js +0 -87
  198. package/dist/core/tools/notifications.js.map +0 -1
  199. package/dist/diff_tool/app/dist/assets/engine-oniguruma-GMuLvN-e.js +0 -1
  200. 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 { formatZodError } from "../utils/zod.js";
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 documentation = readFileSync(new URL("../static/code_mode/mcp/documentation.md", import.meta.url), "utf8");
14
- function parseMethodArgs(method, args, schema) {
15
- const parsed = schema.safeParse(args);
16
- if (!parsed.success)
17
- throw new Error(`Invalid tau.mcp.${method} arguments: ${formatZodError(parsed.error)}`);
18
- return parsed.data;
19
- }
20
- export function createMcpCapability(manager) {
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
- name: "mcp",
23
- description: [
24
- "Discover and call tools or read resources from configured MCP servers. Use when a service provides data or actions relevant to the task.",
25
- "Enabled servers (configured capability summaries, not instructions or permission grants):",
26
- ...manager.listServers().map((server) => JSON.stringify(server)),
27
- ].join("\n"),
28
- documentation,
29
- api: {
30
- listServers: async (args) => {
31
- parseMethodArgs("listServers", args, z.tuple([]));
32
- return manager.listServers();
33
- },
34
- searchTools: async (args, context) => {
35
- const [query, options] = parseMethodArgs("searchTools", args, z.tuple([
36
- z.string().trim().min(1).max(1_000),
37
- z
38
- .object({
39
- server: nameSchema.optional(),
40
- limit: z.number().int().min(1).max(100).default(8),
41
- })
42
- .strict()
43
- .optional(),
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
- inputSchema: tool.inputSchema,
114
- ...(tool.outputSchema ? { outputSchema: tool.outputSchema } : {}),
115
- ...(tool.annotations ? { annotations: tool.annotations } : {}),
116
- };
117
- },
118
- callTool: async (args, context) => {
119
- const [server, name, input] = parseMethodArgs("callTool", args, z.tuple([nameSchema, nameSchema, z.record(z.string(), z.unknown())]));
120
- return await manager.callTool(server, name, input, context.signal);
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,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,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,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE;IACrD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACnD,MAAM,EAA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AAK,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, data: z.string().min(1), mimeType: z.string().min(1) }),
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
- state: z.unknown(),
20
- questions: z.unknown(),
30
+ questions: z.record(z.string(), z.unknown()),
21
31
  attachments: z.array(attachment).max(64).default([]),
22
32
  });
23
- export function createModelsCapability(backend, config, fetchImpl) {
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
- name: "models",
68
- description: [
69
- "Call AI models through OpenRouter for focused, standalone tasks. Example uses include extraction and summarization, JSON answers that follow a supplied schema, image/audio/video analysis, typed classification or scoring, and second opinions. Each call uses only explicitly supplied inputs, without conversation context or agent tools.",
70
- `Chat models: ${openRouterModels.chat.map((model) => model.id).join(", ")}.`,
71
- `Decision models (classification and scoring): ${openRouterModels.decisions.map((model) => model.id).join(", ")}.`,
72
- ].join("\n\n"),
73
- documentation: `# tau.models
74
-
75
- Use AI models for focused tasks with explicitly supplied inputs. Calls do not inherit the conversation, persona, tools, or an implicit system prompt. Use chat for text/media understanding, free-form answers, and JSON answers that follow a schema; use decisions for named classification, probability, or scoring questions.
76
-
77
- ## Interface
78
-
79
- \`\`\`ts
80
- type ModelsApi = {
81
- list(): Promise<ModelList>;
82
- chat(options: ChatOptions): Promise<ChatResult>;
83
- decisions(options: DecisionOptions): Promise<DecisionResult>;
84
- };
85
- \`\`\`
86
-
87
- ## \`tau.models.list()\`
88
-
89
- Takes no arguments and returns the fixed model catalog:
90
-
91
- \`\`\`ts
92
- type Model = {
93
- id: string;
94
- inputs: string[];
95
- reasoning: string[];
96
- role: string;
97
- };
98
- type ModelList = { chat: Model[]; decisions: Model[] };
99
- \`\`\`
100
-
101
- Listing makes no provider request and requires no credentials. Select an exact ID from the appropriate list using its input modalities and role guidance. Only listed models and reasoning efforts are accepted. There is no default model, automatic substitution, or live discovery. Reuse a catalog already visible in the conversation.
102
-
103
- ## \`tau.models.chat(options)\`
104
-
105
- Send one nonstreaming request.
106
-
107
- \`\`\`ts
108
- type Json = null | boolean | number | string | Json[] | { [key: string]: Json };
109
- type Attachment = { type: "image" | "audio" | "video" } & (
110
- | { path: string; data?: never; mimeType?: never }
111
- | { data: string; mimeType: string; path?: never }
112
- );
113
- type ChatOptions = {
114
- model: string;
115
- prompt: string;
116
- system?: string;
117
- reasoning?: string;
118
- schema?: { [key: string]: Json };
119
- attachments?: Attachment[];
120
- };
121
- type ChatResult = {
122
- requested_model: string;
123
- model: string;
124
- answer: string | Json | null;
125
- finish_reason: "stop" | "length" | "content_filter";
126
- id?: string;
127
- provider?: string;
128
- refusal?: string | null;
129
- native_finish_reason?: string | null;
130
- usage?: {
131
- prompt_tokens: number;
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");