wave-agent-sdk 0.16.8 → 0.16.10

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 (96) hide show
  1. package/dist/agent.d.ts.map +1 -1
  2. package/dist/agent.js +3 -0
  3. package/dist/constants/tools.d.ts +0 -1
  4. package/dist/constants/tools.d.ts.map +1 -1
  5. package/dist/constants/tools.js +0 -1
  6. package/dist/managers/aiManager.d.ts +0 -8
  7. package/dist/managers/aiManager.d.ts.map +1 -1
  8. package/dist/managers/aiManager.js +0 -45
  9. package/dist/managers/mcpManager.d.ts +5 -0
  10. package/dist/managers/mcpManager.d.ts.map +1 -1
  11. package/dist/managers/mcpManager.js +107 -12
  12. package/dist/managers/toolManager.d.ts +0 -6
  13. package/dist/managers/toolManager.d.ts.map +1 -1
  14. package/dist/managers/toolManager.js +1 -28
  15. package/dist/prompts/index.d.ts.map +1 -1
  16. package/dist/prompts/index.js +1 -12
  17. package/dist/services/authService.d.ts +10 -0
  18. package/dist/services/authService.d.ts.map +1 -1
  19. package/dist/services/authService.js +45 -0
  20. package/dist/services/configurationService.d.ts +1 -0
  21. package/dist/services/configurationService.d.ts.map +1 -1
  22. package/dist/services/configurationService.js +48 -15
  23. package/dist/services/initializationService.d.ts.map +1 -1
  24. package/dist/services/initializationService.js +11 -0
  25. package/dist/services/pluginLoader.d.ts.map +1 -1
  26. package/dist/services/pluginLoader.js +2 -2
  27. package/dist/services/remoteSettingsService.d.ts +21 -0
  28. package/dist/services/remoteSettingsService.d.ts.map +1 -0
  29. package/dist/services/remoteSettingsService.js +279 -0
  30. package/dist/telemetry/instrumentation.d.ts +5 -2
  31. package/dist/telemetry/instrumentation.d.ts.map +1 -1
  32. package/dist/telemetry/instrumentation.js +8 -4
  33. package/dist/tools/buildTool.d.ts +0 -2
  34. package/dist/tools/buildTool.d.ts.map +1 -1
  35. package/dist/tools/buildTool.js +0 -2
  36. package/dist/tools/cronCreateTool.d.ts.map +1 -1
  37. package/dist/tools/cronCreateTool.js +0 -1
  38. package/dist/tools/cronDeleteTool.d.ts.map +1 -1
  39. package/dist/tools/cronDeleteTool.js +0 -1
  40. package/dist/tools/cronListTool.d.ts.map +1 -1
  41. package/dist/tools/cronListTool.js +0 -1
  42. package/dist/tools/enterWorktreeTool.d.ts.map +1 -1
  43. package/dist/tools/enterWorktreeTool.js +0 -1
  44. package/dist/tools/exitWorktreeTool.d.ts.map +1 -1
  45. package/dist/tools/exitWorktreeTool.js +0 -1
  46. package/dist/tools/taskManagementTools.d.ts.map +1 -1
  47. package/dist/tools/taskManagementTools.js +0 -4
  48. package/dist/tools/types.d.ts +0 -15
  49. package/dist/tools/types.d.ts.map +1 -1
  50. package/dist/tools/webFetchTool.d.ts.map +1 -1
  51. package/dist/tools/webFetchTool.js +0 -1
  52. package/dist/types/configuration.d.ts +20 -0
  53. package/dist/types/configuration.d.ts.map +1 -1
  54. package/dist/types/mcp.d.ts +3 -1
  55. package/dist/types/mcp.d.ts.map +1 -1
  56. package/dist/utils/containerSetup.d.ts.map +1 -1
  57. package/dist/utils/containerSetup.js +10 -0
  58. package/dist/utils/mcpUtils.d.ts.map +1 -1
  59. package/dist/utils/mcpUtils.js +0 -1
  60. package/dist/utils/openaiClient.d.ts.map +1 -1
  61. package/dist/utils/openaiClient.js +4 -2
  62. package/package.json +1 -1
  63. package/src/agent.ts +3 -0
  64. package/src/constants/tools.ts +0 -1
  65. package/src/managers/aiManager.ts +0 -48
  66. package/src/managers/mcpManager.ts +122 -16
  67. package/src/managers/toolManager.ts +1 -32
  68. package/src/prompts/index.ts +0 -13
  69. package/src/services/authService.ts +56 -0
  70. package/src/services/configurationService.ts +56 -19
  71. package/src/services/initializationService.ts +13 -0
  72. package/src/services/pluginLoader.ts +2 -2
  73. package/src/services/remoteSettingsService.ts +314 -0
  74. package/src/telemetry/instrumentation.ts +12 -4
  75. package/src/tools/buildTool.ts +0 -4
  76. package/src/tools/cronCreateTool.ts +0 -1
  77. package/src/tools/cronDeleteTool.ts +0 -1
  78. package/src/tools/cronListTool.ts +0 -1
  79. package/src/tools/enterWorktreeTool.ts +0 -1
  80. package/src/tools/exitWorktreeTool.ts +0 -1
  81. package/src/tools/taskManagementTools.ts +0 -4
  82. package/src/tools/types.ts +0 -15
  83. package/src/tools/webFetchTool.ts +0 -1
  84. package/src/types/configuration.ts +23 -0
  85. package/src/types/mcp.ts +8 -1
  86. package/src/utils/containerSetup.ts +10 -0
  87. package/src/utils/mcpUtils.ts +0 -1
  88. package/src/utils/openaiClient.ts +5 -2
  89. package/dist/tools/toolSearchTool.d.ts +0 -15
  90. package/dist/tools/toolSearchTool.d.ts.map +0 -1
  91. package/dist/tools/toolSearchTool.js +0 -200
  92. package/dist/utils/isDeferredTool.d.ts +0 -19
  93. package/dist/utils/isDeferredTool.d.ts.map +0 -1
  94. package/dist/utils/isDeferredTool.js +0 -31
  95. package/src/tools/toolSearchTool.ts +0 -245
  96. package/src/utils/isDeferredTool.ts +0 -36
@@ -1,245 +0,0 @@
1
- /**
2
- * ToolSearchTool - Discovers deferred tool schemas on demand.
3
- *
4
- * When tool deferral is enabled, deferred tools are not sent to the API.
5
- * The model must call this tool to discover a deferred tool's full schema
6
- * before it can invoke it.
7
- *
8
- * Query formats:
9
- * - "select:ToolName" — direct selection by name (comma-separated for multiple)
10
- * - "notebook jupyter" — keyword search, up to max_results best matches
11
- * - "+slack send" — require "slack" in the name, rank by remaining terms
12
- */
13
-
14
- import { ToolPlugin, ToolResult, ToolContext } from "./types.js";
15
- import {
16
- isDeferredTool,
17
- TOOL_SEARCH_TOOL_NAME,
18
- } from "../utils/isDeferredTool.js";
19
-
20
- function formatSchema(tool: ToolPlugin): string {
21
- const desc = tool.config.function.description || "";
22
- const params = JSON.stringify(tool.config.function.parameters || {}, null, 2);
23
- return `${tool.name}: ${desc}\nParameters: ${params}`;
24
- }
25
-
26
- /**
27
- * Parse tool name into searchable parts (handles CamelCase and underscores).
28
- */
29
- function parseToolName(name: string): string[] {
30
- return name
31
- .replace(/([a-z])([A-Z])/g, "$1 $2") // CamelCase to spaces
32
- .replace(/_/g, " ")
33
- .toLowerCase()
34
- .split(/\s+/)
35
- .filter(Boolean);
36
- }
37
-
38
- /**
39
- * Keyword search over deferred tools by name and description.
40
- * Matches Claude Code's scoring: required terms (+prefix) must all match,
41
- * optional terms contribute to ranking.
42
- */
43
- function keywordSearch(
44
- query: string,
45
- deferredTools: ToolPlugin[],
46
- maxResults: number,
47
- ): ToolPlugin[] {
48
- const queryLower = query.toLowerCase().trim();
49
- const queryTerms = queryLower.split(/\s+/).filter(Boolean);
50
-
51
- // Exact match fast path
52
- const exact = deferredTools.find((t) => t.name.toLowerCase() === queryLower);
53
- if (exact) return [exact];
54
-
55
- // Partition into required (+prefixed) and optional terms
56
- const requiredTerms: string[] = [];
57
- const optionalTerms: string[] = [];
58
- for (const term of queryTerms) {
59
- if (term.startsWith("+") && term.length > 1) {
60
- requiredTerms.push(term.slice(1));
61
- } else {
62
- optionalTerms.push(term);
63
- }
64
- }
65
-
66
- const allScoringTerms =
67
- requiredTerms.length > 0
68
- ? [...requiredTerms, ...optionalTerms]
69
- : queryTerms;
70
-
71
- // Pre-filter to tools matching ALL required terms
72
- let candidateTools = deferredTools;
73
- if (requiredTerms.length > 0) {
74
- candidateTools = deferredTools.filter((tool) => {
75
- const parts = parseToolName(tool.name);
76
- const desc = (tool.config.function.description || "").toLowerCase();
77
- return requiredTerms.every(
78
- (term) =>
79
- parts.includes(term) ||
80
- parts.some((p) => p.includes(term)) ||
81
- desc.includes(term),
82
- );
83
- });
84
- }
85
-
86
- // Score each tool
87
- const scored = candidateTools
88
- .map((tool) => {
89
- const parts = parseToolName(tool.name);
90
- const desc = (tool.config.function.description || "").toLowerCase();
91
- let score = 0;
92
-
93
- for (const term of allScoringTerms) {
94
- // Exact part match (high weight)
95
- if (parts.includes(term)) {
96
- score += tool.isMcp ? 12 : 10;
97
- } else if (parts.some((p) => p.includes(term))) {
98
- score += tool.isMcp ? 6 : 5;
99
- }
100
-
101
- // Full name fallback
102
- if (tool.name.toLowerCase().includes(term) && score === 0) {
103
- score += 3;
104
- }
105
-
106
- // Description match
107
- if (desc.includes(term)) {
108
- score += 2;
109
- }
110
- }
111
-
112
- return { tool, score };
113
- })
114
- .filter((s) => s.score > 0)
115
- .sort((a, b) => b.score - a.score)
116
- .slice(0, maxResults)
117
- .map((s) => s.tool);
118
-
119
- return scored;
120
- }
121
-
122
- export const toolSearchTool: ToolPlugin = {
123
- name: TOOL_SEARCH_TOOL_NAME,
124
- config: {
125
- type: "function",
126
- function: {
127
- name: TOOL_SEARCH_TOOL_NAME,
128
- description: `Fetches full schema definitions for deferred tools so they can be called.
129
-
130
- Deferred tools appear by name and description in <available-deferred-tools> messages. The full parameter schema is NOT loaded yet — use this tool to fetch it before invoking a deferred tool. This tool takes a query, matches it against the deferred tool list, and returns the matched tools' complete JSONSchema definitions inside a <functions> block. Once a tool's schema appears in that result, it is callable exactly like any tool defined at the top of the prompt.
131
-
132
- Result format: each matched tool appears as one <function>{"description": "...", "name": "...", "parameters": {...}}`,
133
- parameters: {
134
- type: "object",
135
- properties: {
136
- query: {
137
- type: "string",
138
- description:
139
- 'Search query for finding deferred tools. Supports: "select:ToolName" for direct lookup, or keyword search like "notebook jupyter". Use "+term" to require a term (e.g. "+slack send").',
140
- },
141
- max_results: {
142
- type: "number",
143
- description:
144
- "Maximum number of results to return for keyword search (default: 5).",
145
- },
146
- },
147
- required: ["query"],
148
- additionalProperties: false,
149
- },
150
- },
151
- },
152
- shouldDefer: false, // Always available
153
- execute: async (
154
- args: Record<string, unknown>,
155
- context: ToolContext,
156
- ): Promise<ToolResult> => {
157
- const { query, max_results = 5 } = args as {
158
- query?: string;
159
- max_results?: number;
160
- };
161
-
162
- if (!query) {
163
- return {
164
- success: false,
165
- content: "",
166
- error: "Missing required 'query' parameter",
167
- };
168
- }
169
-
170
- if (!context.toolManager) {
171
- return {
172
- success: false,
173
- content: "",
174
- error: "ToolManager not available in context",
175
- };
176
- }
177
-
178
- const allTools = context.toolManager.list();
179
- const deferredTools = allTools.filter(isDeferredTool);
180
-
181
- // Handle select: prefix
182
- const selectMatch = query.match(/^select:(.+)$/i);
183
- if (selectMatch) {
184
- const requested = selectMatch[1]!
185
- .split(",")
186
- .map((s) => s.trim())
187
- .filter(Boolean);
188
-
189
- const found: ToolPlugin[] = [];
190
- const missing: string[] = [];
191
-
192
- for (const toolName of requested) {
193
- const tool =
194
- deferredTools.find((t) => t.name === toolName) ??
195
- allTools.find((t) => t.name === toolName);
196
- if (tool) {
197
- if (!found.some((f) => f.name === tool.name)) found.push(tool);
198
- } else {
199
- missing.push(toolName);
200
- }
201
- }
202
-
203
- if (found.length === 0) {
204
- return {
205
- success: false,
206
- content: "",
207
- error: `No matching deferred tools found for: ${missing.join(", ")}`,
208
- };
209
- }
210
-
211
- const result = found.map(formatSchema).join("\n\n---\n\n");
212
- const shortResult = `Discovered tools: ${found.map((t) => t.name).join(", ")}`;
213
-
214
- return {
215
- success: true,
216
- content: result,
217
- shortResult,
218
- };
219
- }
220
-
221
- // Keyword search
222
- const matches = keywordSearch(query, deferredTools, max_results);
223
-
224
- if (matches.length === 0) {
225
- return {
226
- success: false,
227
- content: "",
228
- error: `No matching deferred tools found for query: "${query}". Available deferred tools: ${getDeferredToolNamesList(deferredTools)}`,
229
- };
230
- }
231
-
232
- const result = matches.map(formatSchema).join("\n\n---\n\n");
233
- const shortResult = `Found ${matches.length} tools: ${matches.map((t) => t.name).join(", ")}`;
234
-
235
- return {
236
- success: true,
237
- content: result,
238
- shortResult,
239
- };
240
- },
241
- };
242
-
243
- function getDeferredToolNamesList(tools: ToolPlugin[]): string {
244
- return tools.map((t) => t.name).join(", ");
245
- }
@@ -1,36 +0,0 @@
1
- /**
2
- * Determines if a tool should be deferred (not sent to the API until discovered).
3
- *
4
- * A tool is deferred if:
5
- * - It has shouldDefer: true
6
- * - It is an MCP tool (isMcp: true)
7
- *
8
- * A tool is NEVER deferred if:
9
- * - It has alwaysLoad: true
10
- * - It is the ToolSearch tool itself (must always be available)
11
- */
12
-
13
- import type { ToolPlugin } from "../tools/types.js";
14
-
15
- export const TOOL_SEARCH_TOOL_NAME = "ToolSearch";
16
-
17
- export function isDeferredTool(tool: ToolPlugin): boolean {
18
- // Never defer if explicitly marked as alwaysLoad
19
- if (tool.alwaysLoad === true) return false;
20
-
21
- // Never defer ToolSearch itself — the model needs it to discover other tools
22
- if (tool.name === TOOL_SEARCH_TOOL_NAME) return false;
23
-
24
- // MCP tools are always deferred (workflow-specific, potentially many)
25
- if (tool.isMcp === true) return true;
26
-
27
- // Defer if marked with shouldDefer flag
28
- return tool.shouldDefer === true;
29
- }
30
-
31
- /**
32
- * Get the list of deferred tool names from a tools array.
33
- */
34
- export function getDeferredToolNames(tools: ToolPlugin[]): string[] {
35
- return tools.filter(isDeferredTool).map((t) => t.name);
36
- }