qlogicagent 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/dist/agent.js +1 -0
  2. package/dist/cli.js +9 -0
  3. package/dist/contracts.js +1 -0
  4. package/dist/index.js +5 -15
  5. package/dist/orchestration.js +118 -0
  6. package/package.json +56 -42
  7. package/dist/agent/agent.js +0 -113
  8. package/dist/agent/tool-loop.js +0 -575
  9. package/dist/agent/types.js +0 -14
  10. package/dist/cli/main.js +0 -23
  11. package/dist/cli/stdio-server.js +0 -463
  12. package/dist/config/config.js +0 -21
  13. package/dist/contracts/hooks.js +0 -7
  14. package/dist/contracts/index.js +0 -10
  15. package/dist/contracts/planner.js +0 -2
  16. package/dist/contracts/skill-candidate.js +0 -195
  17. package/dist/contracts/todo.js +0 -9
  18. package/dist/llm/builtin-providers.js +0 -531
  19. package/dist/llm/index.js +0 -14
  20. package/dist/llm/llm-client.js +0 -67
  21. package/dist/llm/model-catalog.js +0 -191
  22. package/dist/llm/provider-def.js +0 -12
  23. package/dist/llm/provider-registry.js +0 -147
  24. package/dist/llm/transport.js +0 -27
  25. package/dist/llm/transports/anthropic-messages.js +0 -293
  26. package/dist/llm/transports/openai-chat.js +0 -165
  27. package/dist/orchestration/agent-registry.js +0 -116
  28. package/dist/orchestration/approval-aware-tool-plan.js +0 -87
  29. package/dist/orchestration/context-compression.js +0 -583
  30. package/dist/orchestration/conversation-repair.js +0 -429
  31. package/dist/orchestration/curator-scheduler.js +0 -135
  32. package/dist/orchestration/embedded-failover-policy.js +0 -168
  33. package/dist/orchestration/error-classification.js +0 -77
  34. package/dist/orchestration/failover-classification.js +0 -381
  35. package/dist/orchestration/failover-error.js +0 -198
  36. package/dist/orchestration/fork-subagent.js +0 -98
  37. package/dist/orchestration/index.js +0 -267
  38. package/dist/orchestration/memory-flush-policy.js +0 -85
  39. package/dist/orchestration/memory-provider.js +0 -2
  40. package/dist/orchestration/parallel-tool-calls.js +0 -59
  41. package/dist/orchestration/prompt-cache-strategy.js +0 -228
  42. package/dist/orchestration/reactive-compact.js +0 -78
  43. package/dist/orchestration/retry-loop.js +0 -24
  44. package/dist/orchestration/skill-candidate.js +0 -141
  45. package/dist/orchestration/skill-consolidation.js +0 -220
  46. package/dist/orchestration/skill-improvement.js +0 -66
  47. package/dist/orchestration/skill-similarity.js +0 -131
  48. package/dist/orchestration/streaming-tool-executor.js +0 -96
  49. package/dist/orchestration/team-orchestration.js +0 -369
  50. package/dist/orchestration/team-tool-loop-wiring.js +0 -147
  51. package/dist/orchestration/tool-choice-policy.js +0 -164
  52. package/dist/orchestration/tool-loop-state.js +0 -133
  53. package/dist/orchestration/tool-schema.js +0 -297
  54. package/dist/orchestration/transcript-repair.js +0 -426
  55. package/dist/orchestration/turn-loop-guard.js +0 -92
  56. package/dist/orchestration/web-browser-policy.js +0 -39
  57. package/dist/runtime/context-compression.js +0 -274
  58. package/dist/runtime/hook-registry.js +0 -53
  59. package/dist/runtime/memory-hooks.js +0 -65
  60. package/dist/runtime/tool-eligibility.js +0 -111
  61. package/dist/skills/index.js +0 -82
  62. package/dist/skills/memory-extractor.js +0 -173
  63. package/dist/skills/memory-query-tool.js +0 -127
  64. package/dist/skills/memory-store.js +0 -228
  65. package/dist/skills/memory-tool.js +0 -192
  66. package/dist/skills/portable-tool.js +0 -14
  67. package/dist/skills/qmemory-adapter.js +0 -165
  68. package/dist/skills/skill-frontmatter.js +0 -344
  69. package/dist/skills/skill-guard.js +0 -229
  70. package/dist/skills/skill-loader.js +0 -303
  71. package/dist/skills/skill-source.js +0 -126
  72. package/dist/skills/skill-types.js +0 -6
  73. package/dist/skills/think-tool.js +0 -59
  74. package/dist/skills/todo-tool.js +0 -114
  75. package/dist/skills/tools/agent-tool.js +0 -142
  76. package/dist/skills/tools/apply-patch-tool.js +0 -184
  77. package/dist/skills/tools/ask-user-tool.js +0 -121
  78. package/dist/skills/tools/brief-tool.js +0 -95
  79. package/dist/skills/tools/browser-tool.js +0 -155
  80. package/dist/skills/tools/checkpoint-tool.js +0 -102
  81. package/dist/skills/tools/config-tool.js +0 -143
  82. package/dist/skills/tools/cron-tool.js +0 -175
  83. package/dist/skills/tools/edit-tool.js +0 -70
  84. package/dist/skills/tools/exec-tool.js +0 -133
  85. package/dist/skills/tools/image-generate-tool.js +0 -67
  86. package/dist/skills/tools/instructions-tool.js +0 -187
  87. package/dist/skills/tools/lsp-tool.js +0 -227
  88. package/dist/skills/tools/mcp-client-types.js +0 -53
  89. package/dist/skills/tools/mcp-tool.js +0 -503
  90. package/dist/skills/tools/memory-tool.js +0 -88
  91. package/dist/skills/tools/monitor-tool.js +0 -131
  92. package/dist/skills/tools/music-generate-tool.js +0 -62
  93. package/dist/skills/tools/notify-tool.js +0 -62
  94. package/dist/skills/tools/patch-tool.js +0 -505
  95. package/dist/skills/tools/pdf-tool.js +0 -88
  96. package/dist/skills/tools/plan-mode-tool.js +0 -122
  97. package/dist/skills/tools/read-tool.js +0 -84
  98. package/dist/skills/tools/repl-tool.js +0 -69
  99. package/dist/skills/tools/search-tool.js +0 -225
  100. package/dist/skills/tools/send-message-tool.js +0 -76
  101. package/dist/skills/tools/skill-list-tool.js +0 -54
  102. package/dist/skills/tools/skill-manage-tool.js +0 -153
  103. package/dist/skills/tools/skill-view-tool.js +0 -72
  104. package/dist/skills/tools/sleep-tool.js +0 -81
  105. package/dist/skills/tools/structured-output-tool.js +0 -176
  106. package/dist/skills/tools/task-tool.js +0 -161
  107. package/dist/skills/tools/team-tool.js +0 -105
  108. package/dist/skills/tools/tool-search-tool.js +0 -110
  109. package/dist/skills/tools/tts-tool.js +0 -45
  110. package/dist/skills/tools/video-edit-tool.js +0 -74
  111. package/dist/skills/tools/video-generate-tool.js +0 -66
  112. package/dist/skills/tools/video-merge-tool.js +0 -92
  113. package/dist/skills/tools/video-upscale-tool.js +0 -52
  114. package/dist/skills/tools/web-fetch-tool.js +0 -92
  115. package/dist/skills/tools/web-search-tool.js +0 -86
  116. package/dist/skills/tools/worktree-tool.js +0 -147
  117. package/dist/skills/tools/write-tool.js +0 -81
  118. /package/dist/{agent → types/agent}/agent.d.ts +0 -0
  119. /package/dist/{agent → types/agent}/tool-loop.d.ts +0 -0
  120. /package/dist/{agent → types/agent}/types.d.ts +0 -0
  121. /package/dist/{cli → types/cli}/main.d.ts +0 -0
  122. /package/dist/{cli → types/cli}/stdio-server.d.ts +0 -0
  123. /package/dist/{config → types/config}/config.d.ts +0 -0
  124. /package/dist/{contracts → types/contracts}/hooks.d.ts +0 -0
  125. /package/dist/{contracts → types/contracts}/index.d.ts +0 -0
  126. /package/dist/{contracts → types/contracts}/planner.d.ts +0 -0
  127. /package/dist/{contracts → types/contracts}/skill-candidate.d.ts +0 -0
  128. /package/dist/{contracts → types/contracts}/todo.d.ts +0 -0
  129. /package/dist/{index.d.ts → types/index.d.ts} +0 -0
  130. /package/dist/{llm → types/llm}/builtin-providers.d.ts +0 -0
  131. /package/dist/{llm → types/llm}/index.d.ts +0 -0
  132. /package/dist/{llm → types/llm}/llm-client.d.ts +0 -0
  133. /package/dist/{llm → types/llm}/model-catalog.d.ts +0 -0
  134. /package/dist/{llm → types/llm}/provider-def.d.ts +0 -0
  135. /package/dist/{llm → types/llm}/provider-registry.d.ts +0 -0
  136. /package/dist/{llm → types/llm}/transport.d.ts +0 -0
  137. /package/dist/{llm → types/llm}/transports/anthropic-messages.d.ts +0 -0
  138. /package/dist/{llm → types/llm}/transports/openai-chat.d.ts +0 -0
  139. /package/dist/{orchestration → types/orchestration}/agent-registry.d.ts +0 -0
  140. /package/dist/{orchestration → types/orchestration}/approval-aware-tool-plan.d.ts +0 -0
  141. /package/dist/{orchestration → types/orchestration}/context-compression.d.ts +0 -0
  142. /package/dist/{orchestration → types/orchestration}/conversation-repair.d.ts +0 -0
  143. /package/dist/{orchestration → types/orchestration}/curator-scheduler.d.ts +0 -0
  144. /package/dist/{orchestration → types/orchestration}/embedded-failover-policy.d.ts +0 -0
  145. /package/dist/{orchestration → types/orchestration}/error-classification.d.ts +0 -0
  146. /package/dist/{orchestration → types/orchestration}/failover-classification.d.ts +0 -0
  147. /package/dist/{orchestration → types/orchestration}/failover-error.d.ts +0 -0
  148. /package/dist/{orchestration → types/orchestration}/fork-subagent.d.ts +0 -0
  149. /package/dist/{orchestration → types/orchestration}/index.d.ts +0 -0
  150. /package/dist/{orchestration → types/orchestration}/memory-flush-policy.d.ts +0 -0
  151. /package/dist/{orchestration → types/orchestration}/memory-provider.d.ts +0 -0
  152. /package/dist/{orchestration → types/orchestration}/parallel-tool-calls.d.ts +0 -0
  153. /package/dist/{orchestration → types/orchestration}/prompt-cache-strategy.d.ts +0 -0
  154. /package/dist/{orchestration → types/orchestration}/reactive-compact.d.ts +0 -0
  155. /package/dist/{orchestration → types/orchestration}/retry-loop.d.ts +0 -0
  156. /package/dist/{orchestration → types/orchestration}/skill-candidate.d.ts +0 -0
  157. /package/dist/{orchestration → types/orchestration}/skill-consolidation.d.ts +0 -0
  158. /package/dist/{orchestration → types/orchestration}/skill-improvement.d.ts +0 -0
  159. /package/dist/{orchestration → types/orchestration}/skill-similarity.d.ts +0 -0
  160. /package/dist/{orchestration → types/orchestration}/streaming-tool-executor.d.ts +0 -0
  161. /package/dist/{orchestration → types/orchestration}/team-orchestration.d.ts +0 -0
  162. /package/dist/{orchestration → types/orchestration}/team-tool-loop-wiring.d.ts +0 -0
  163. /package/dist/{orchestration → types/orchestration}/tool-choice-policy.d.ts +0 -0
  164. /package/dist/{orchestration → types/orchestration}/tool-loop-state.d.ts +0 -0
  165. /package/dist/{orchestration → types/orchestration}/tool-schema.d.ts +0 -0
  166. /package/dist/{orchestration → types/orchestration}/transcript-repair.d.ts +0 -0
  167. /package/dist/{orchestration → types/orchestration}/turn-loop-guard.d.ts +0 -0
  168. /package/dist/{orchestration → types/orchestration}/web-browser-policy.d.ts +0 -0
  169. /package/dist/{runtime → types/runtime}/context-compression.d.ts +0 -0
  170. /package/dist/{runtime → types/runtime}/hook-registry.d.ts +0 -0
  171. /package/dist/{runtime → types/runtime}/memory-hooks.d.ts +0 -0
  172. /package/dist/{runtime → types/runtime}/tool-eligibility.d.ts +0 -0
  173. /package/dist/{skills → types/skills}/index.d.ts +0 -0
  174. /package/dist/{skills → types/skills}/memory-extractor.d.ts +0 -0
  175. /package/dist/{skills → types/skills}/memory-query-tool.d.ts +0 -0
  176. /package/dist/{skills → types/skills}/memory-store.d.ts +0 -0
  177. /package/dist/{skills → types/skills}/memory-tool.d.ts +0 -0
  178. /package/dist/{skills → types/skills}/portable-tool.d.ts +0 -0
  179. /package/dist/{skills → types/skills}/qmemory-adapter.d.ts +0 -0
  180. /package/dist/{skills → types/skills}/skill-frontmatter.d.ts +0 -0
  181. /package/dist/{skills → types/skills}/skill-guard.d.ts +0 -0
  182. /package/dist/{skills → types/skills}/skill-loader.d.ts +0 -0
  183. /package/dist/{skills → types/skills}/skill-source.d.ts +0 -0
  184. /package/dist/{skills → types/skills}/skill-types.d.ts +0 -0
  185. /package/dist/{skills → types/skills}/think-tool.d.ts +0 -0
  186. /package/dist/{skills → types/skills}/todo-tool.d.ts +0 -0
  187. /package/dist/{skills → types/skills}/tools/agent-tool.d.ts +0 -0
  188. /package/dist/{skills → types/skills}/tools/apply-patch-tool.d.ts +0 -0
  189. /package/dist/{skills → types/skills}/tools/ask-user-tool.d.ts +0 -0
  190. /package/dist/{skills → types/skills}/tools/brief-tool.d.ts +0 -0
  191. /package/dist/{skills → types/skills}/tools/browser-tool.d.ts +0 -0
  192. /package/dist/{skills → types/skills}/tools/checkpoint-tool.d.ts +0 -0
  193. /package/dist/{skills → types/skills}/tools/config-tool.d.ts +0 -0
  194. /package/dist/{skills → types/skills}/tools/cron-tool.d.ts +0 -0
  195. /package/dist/{skills → types/skills}/tools/edit-tool.d.ts +0 -0
  196. /package/dist/{skills → types/skills}/tools/exec-tool.d.ts +0 -0
  197. /package/dist/{skills → types/skills}/tools/image-generate-tool.d.ts +0 -0
  198. /package/dist/{skills → types/skills}/tools/instructions-tool.d.ts +0 -0
  199. /package/dist/{skills → types/skills}/tools/lsp-tool.d.ts +0 -0
  200. /package/dist/{skills → types/skills}/tools/mcp-client-types.d.ts +0 -0
  201. /package/dist/{skills → types/skills}/tools/mcp-tool.d.ts +0 -0
  202. /package/dist/{skills → types/skills}/tools/memory-tool.d.ts +0 -0
  203. /package/dist/{skills → types/skills}/tools/monitor-tool.d.ts +0 -0
  204. /package/dist/{skills → types/skills}/tools/music-generate-tool.d.ts +0 -0
  205. /package/dist/{skills → types/skills}/tools/notify-tool.d.ts +0 -0
  206. /package/dist/{skills → types/skills}/tools/patch-tool.d.ts +0 -0
  207. /package/dist/{skills → types/skills}/tools/pdf-tool.d.ts +0 -0
  208. /package/dist/{skills → types/skills}/tools/plan-mode-tool.d.ts +0 -0
  209. /package/dist/{skills → types/skills}/tools/read-tool.d.ts +0 -0
  210. /package/dist/{skills → types/skills}/tools/repl-tool.d.ts +0 -0
  211. /package/dist/{skills → types/skills}/tools/search-tool.d.ts +0 -0
  212. /package/dist/{skills → types/skills}/tools/send-message-tool.d.ts +0 -0
  213. /package/dist/{skills → types/skills}/tools/skill-list-tool.d.ts +0 -0
  214. /package/dist/{skills → types/skills}/tools/skill-manage-tool.d.ts +0 -0
  215. /package/dist/{skills → types/skills}/tools/skill-view-tool.d.ts +0 -0
  216. /package/dist/{skills → types/skills}/tools/sleep-tool.d.ts +0 -0
  217. /package/dist/{skills → types/skills}/tools/structured-output-tool.d.ts +0 -0
  218. /package/dist/{skills → types/skills}/tools/task-tool.d.ts +0 -0
  219. /package/dist/{skills → types/skills}/tools/team-tool.d.ts +0 -0
  220. /package/dist/{skills → types/skills}/tools/tool-search-tool.d.ts +0 -0
  221. /package/dist/{skills → types/skills}/tools/tts-tool.d.ts +0 -0
  222. /package/dist/{skills → types/skills}/tools/video-edit-tool.d.ts +0 -0
  223. /package/dist/{skills → types/skills}/tools/video-generate-tool.d.ts +0 -0
  224. /package/dist/{skills → types/skills}/tools/video-merge-tool.d.ts +0 -0
  225. /package/dist/{skills → types/skills}/tools/video-upscale-tool.d.ts +0 -0
  226. /package/dist/{skills → types/skills}/tools/web-fetch-tool.d.ts +0 -0
  227. /package/dist/{skills → types/skills}/tools/web-search-tool.d.ts +0 -0
  228. /package/dist/{skills → types/skills}/tools/worktree-tool.d.ts +0 -0
  229. /package/dist/{skills → types/skills}/tools/write-tool.d.ts +0 -0
@@ -1,105 +0,0 @@
1
- // ============================================================
2
- // Team Tool — create and manage multi-agent teams (Swarm).
3
- // Reference: claude-code-haha/src/tools/TeamCreateTool/TeamCreateTool.ts
4
- // claude-code-haha/src/tools/TeamDeleteTool/TeamDeleteTool.ts
5
- // Category: system
6
- // ============================================================
7
- export const TEAM_TOOL_NAME = "team";
8
- export const TEAM_TOOL_SCHEMA = {
9
- type: "object",
10
- properties: {
11
- action: {
12
- type: "string",
13
- enum: ["create", "delete", "list", "status"],
14
- description: "Team action: create (new team), delete (disband), list (all teams), status (team details).",
15
- },
16
- teamName: {
17
- type: "string",
18
- description: "Team name. Required for create/delete/status.",
19
- },
20
- description: {
21
- type: "string",
22
- description: "Team description/objective. Used for create.",
23
- },
24
- members: {
25
- type: "array",
26
- description: "Team members with roles and tool restrictions.",
27
- items: {
28
- type: "object",
29
- properties: {
30
- name: { type: "string", description: "Agent name/role identifier." },
31
- role: { type: "string", description: "Role description (e.g. 'frontend developer')." },
32
- tools: { type: "array", items: { type: "string" }, description: "Allowed tools for this member." },
33
- },
34
- required: ["name", "role"],
35
- },
36
- },
37
- },
38
- required: ["action"],
39
- };
40
- export function createTeamTool(deps) {
41
- return {
42
- name: TEAM_TOOL_NAME,
43
- label: "Team",
44
- description: "Manage multi-agent teams. Create teams of specialized agents that collaborate via send_message. " +
45
- "Each member has a role and optional tool restrictions. Use for complex tasks requiring parallel work.",
46
- parameters: TEAM_TOOL_SCHEMA,
47
- execute: async (_toolCallId, params) => {
48
- switch (params.action) {
49
- case "create": {
50
- if (!params.teamName) {
51
- return { content: [{ type: "text", text: "Error: teamName required for create." }], details: { type: "team", error: "missing_name" } };
52
- }
53
- const r = await deps.createTeam({ teamName: params.teamName, description: params.description, members: params.members });
54
- if (!r.success) {
55
- return { content: [{ type: "text", text: `Error: ${r.error}` }], details: { type: "team", error: r.error } };
56
- }
57
- const lines = [`Team "${r.team.name}" created.`, `Lead: ${r.team.leadId}`, `Members: ${r.team.members.length}`];
58
- for (const m of r.team.members) {
59
- lines.push(` - ${m.name} (${m.role})`);
60
- }
61
- return { content: [{ type: "text", text: lines.join("\n") }], details: { type: "team", action: "create", teamName: r.team.name } };
62
- }
63
- case "delete": {
64
- if (!params.teamName) {
65
- return { content: [{ type: "text", text: "Error: teamName required for delete." }], details: { type: "team", error: "missing_name" } };
66
- }
67
- const r = await deps.deleteTeam(params.teamName);
68
- if (!r.success) {
69
- return { content: [{ type: "text", text: `Error: ${r.error}` }], details: { type: "team", error: r.error } };
70
- }
71
- return { content: [{ type: "text", text: `Team "${params.teamName}" disbanded.` }], details: { type: "team", action: "delete", teamName: params.teamName } };
72
- }
73
- case "list": {
74
- const r = await deps.listTeams();
75
- if (!r.teams || r.teams.length === 0) {
76
- return { content: [{ type: "text", text: "No active teams." }], details: { type: "team", action: "list", count: 0 } };
77
- }
78
- const lines = [`Active teams (${r.teams.length}):`, ""];
79
- for (const t of r.teams) {
80
- lines.push(`- **${t.name}**: ${t.description || "(no description)"} — ${t.members.length} members`);
81
- }
82
- return { content: [{ type: "text", text: lines.join("\n") }], details: { type: "team", action: "list", count: r.teams.length } };
83
- }
84
- case "status": {
85
- if (!params.teamName) {
86
- return { content: [{ type: "text", text: "Error: teamName required for status." }], details: { type: "team", error: "missing_name" } };
87
- }
88
- const r = await deps.getTeamStatus(params.teamName);
89
- if (!r.success) {
90
- return { content: [{ type: "text", text: `Error: ${r.error}` }], details: { type: "team", error: r.error } };
91
- }
92
- const t = r.team;
93
- const lines = [`Team: ${t.name}`, `Description: ${t.description || "—"}`, `Lead: ${t.leadId}`, `Created: ${t.createdAt}`, "", `Members (${t.members.length}):`];
94
- for (const m of t.members) {
95
- const tools = m.tools ? ` [tools: ${m.tools.join(", ")}]` : "";
96
- lines.push(` - ${m.name} (${m.role})${tools}`);
97
- }
98
- return { content: [{ type: "text", text: lines.join("\n") }], details: { type: "team", action: "status", teamName: t.name } };
99
- }
100
- default:
101
- return { content: [{ type: "text", text: `Error: unknown action "${params.action}".` }], details: { type: "team", error: "unknown_action" } };
102
- }
103
- },
104
- };
105
- }
@@ -1,110 +0,0 @@
1
- // ============================================================
2
- // Tool Search Tool — discover deferred/hidden tools by keyword.
3
- // Reference: claude-code-haha/src/tools/ToolSearchTool/ToolSearchTool.ts
4
- // Category: system
5
- // ============================================================
6
- export const TOOL_SEARCH_TOOL_NAME = "tool_search";
7
- export const TOOL_SEARCH_TOOL_SCHEMA = {
8
- type: "object",
9
- properties: {
10
- query: {
11
- type: "string",
12
- description: 'Search query for tools. Use "select:toolName" to directly activate a deferred tool, ' +
13
- "or provide keywords to search tool names/descriptions. " +
14
- 'Prefix a term with "+" to mark it as required (all +terms must match).',
15
- },
16
- maxResults: {
17
- type: "number",
18
- description: "Maximum number of results to return (default: 5).",
19
- },
20
- },
21
- required: ["query"],
22
- };
23
- const DEFAULT_MAX_RESULTS = 5;
24
- export function createToolSearchTool(deps) {
25
- return {
26
- name: TOOL_SEARCH_TOOL_NAME,
27
- label: "Tool Search",
28
- description: "Search for available tools that are not currently loaded. " +
29
- "Many tools are deferred to save context tokens. " +
30
- 'Use "select:toolName" to directly activate a tool, ' +
31
- "or provide keywords to find relevant tools. " +
32
- "Activated tools become available in subsequent messages.",
33
- parameters: TOOL_SEARCH_TOOL_SCHEMA,
34
- execute: async (_toolCallId, params) => {
35
- if (!params.query || params.query.trim().length === 0) {
36
- return {
37
- content: [{ type: "text", text: "Error: query is required." }],
38
- details: { type: "tool_search", error: "empty_query" },
39
- };
40
- }
41
- const query = params.query.trim();
42
- const maxResults = params.maxResults ?? DEFAULT_MAX_RESULTS;
43
- // Handle direct selection: "select:toolName" or "select:A,B,C"
44
- if (query.startsWith("select:")) {
45
- const names = query.slice(7).split(",").map((n) => n.trim()).filter(Boolean);
46
- const activated = [];
47
- const notFound = [];
48
- if (deps.activateTool) {
49
- for (const name of names) {
50
- const ok = await deps.activateTool(name);
51
- if (ok)
52
- activated.push(name);
53
- else
54
- notFound.push(name);
55
- }
56
- }
57
- else {
58
- // No activation support — just search
59
- const result = await deps.searchTools(query, { maxResults });
60
- return formatSearchResult(result);
61
- }
62
- const parts = [];
63
- if (activated.length > 0) {
64
- parts.push(`Activated: ${activated.join(", ")}. These tools are now available.`);
65
- }
66
- if (notFound.length > 0) {
67
- parts.push(`Not found: ${notFound.join(", ")}.`);
68
- }
69
- return {
70
- content: [{ type: "text", text: parts.join("\n") }],
71
- details: { type: "tool_search", activated, notFound, mode: "select" },
72
- };
73
- }
74
- // Keyword search
75
- const result = await deps.searchTools(query, { maxResults });
76
- return formatSearchResult(result);
77
- },
78
- };
79
- }
80
- function formatSearchResult(result) {
81
- if (result.matches.length === 0) {
82
- return {
83
- content: [{
84
- type: "text",
85
- text: `No tools found matching "${result.query}". ` +
86
- `Total deferred tools available: ${result.totalDeferred}.`,
87
- }],
88
- details: { type: "tool_search", query: result.query, matchCount: 0, totalDeferred: result.totalDeferred },
89
- };
90
- }
91
- const lines = [
92
- `Found ${result.matches.length} tool(s) matching "${result.query}" (${result.totalDeferred} total deferred):`,
93
- "",
94
- ];
95
- for (const tool of result.matches) {
96
- lines.push(`- **${tool.name}**: ${tool.description}`);
97
- }
98
- lines.push("");
99
- lines.push('Use "select:toolName" to activate a tool for use in subsequent messages.');
100
- return {
101
- content: [{ type: "text", text: lines.join("\n") }],
102
- details: {
103
- type: "tool_search",
104
- query: result.query,
105
- matchCount: result.matches.length,
106
- totalDeferred: result.totalDeferred,
107
- matches: result.matches.map((m) => m.name),
108
- },
109
- };
110
- }
@@ -1,45 +0,0 @@
1
- // ============================================================
2
- // TTS Tool — text-to-speech via backend adapter.
3
- // Category: media
4
- // ============================================================
5
- export const TTS_TOOL_NAME = "tts";
6
- export const TTS_TOOL_SCHEMA = {
7
- type: "object",
8
- properties: {
9
- text: {
10
- type: "string",
11
- description: "Text to convert to speech.",
12
- },
13
- channel: {
14
- type: "string",
15
- description: "Optional channel id to pick output format (e.g. telegram).",
16
- },
17
- },
18
- required: ["text"],
19
- };
20
- export function createTtsTool(deps) {
21
- return {
22
- name: TTS_TOOL_NAME,
23
- label: "TTS",
24
- description: "Convert text to speech (TTS) — read text aloud as spoken audio. " +
25
- "Use for narration, voice messages, or any spoken-word output. " +
26
- "DO NOT use for music, songs, or melodies — use music_generate instead.",
27
- parameters: TTS_TOOL_SCHEMA,
28
- execute: async (_toolCallId, params) => {
29
- const result = await deps.textToSpeech({
30
- text: params.text,
31
- channel: params.channel,
32
- });
33
- return {
34
- content: [{ type: "text", text: "已成功生成语音。" }],
35
- details: {
36
- type: "tts",
37
- audioPath: result.audioPath,
38
- provider: result.provider,
39
- voiceCompatible: result.voiceCompatible,
40
- mediaUrls: result.mediaUrls,
41
- },
42
- };
43
- },
44
- };
45
- }
@@ -1,74 +0,0 @@
1
- // ============================================================
2
- // Video Edit Tool — edit existing videos via backend adapter.
3
- // Category: media
4
- // ============================================================
5
- export const VIDEO_EDIT_TOOL_NAME = "video_edit";
6
- export const VIDEO_EDIT_TOOL_SCHEMA = {
7
- type: "object",
8
- properties: {
9
- prompt: {
10
- type: "string",
11
- description: "Edit instruction. Reference videos as 视频1, 视频2, 视频3. " +
12
- "Reference images as 图片1, 图片2. " +
13
- "Operations: add/remove/modify elements, extend, track fill.",
14
- },
15
- source_videos: {
16
- type: "array",
17
- items: { type: "string" },
18
- minItems: 1,
19
- maxItems: 3,
20
- description: "Video(s) to edit (1-3 URLs). Order: [0]=视频1, [1]=视频2, [2]=视频3.",
21
- },
22
- reference_images: {
23
- type: "array",
24
- items: { type: "string" },
25
- description: "Optional reference images for element replacement (up to 9).",
26
- },
27
- duration: {
28
- type: "number",
29
- description: "Output duration in seconds (4-15s). Default: same as source.",
30
- },
31
- aspect_ratio: {
32
- type: "string",
33
- description: "Output aspect ratio: 16:9, 9:16, 1:1, 4:3, 3:4, 21:9. Default: same as source.",
34
- },
35
- resolution: {
36
- type: "string",
37
- description: "Output resolution: '480p' or '720p'. Default: '720p'.",
38
- },
39
- },
40
- required: ["prompt", "source_videos"],
41
- };
42
- export function createVideoEditTool(deps) {
43
- return {
44
- name: VIDEO_EDIT_TOOL_NAME,
45
- label: "Video Edit",
46
- description: "Edit existing videos: add/remove/modify elements, extend, or bridge clips. " +
47
- "Requires source_videos. Max 3 source videos, max 720p. " +
48
- "For generating NEW videos from scratch, use video_generate instead.",
49
- parameters: VIDEO_EDIT_TOOL_SCHEMA,
50
- execute: async (_toolCallId, params) => {
51
- if (!params.source_videos?.length) {
52
- return { content: [{ type: "text", text: "Error: source_videos is required." }] };
53
- }
54
- const result = await deps.editVideo({
55
- prompt: params.prompt,
56
- sourceVideos: params.source_videos,
57
- referenceImages: params.reference_images,
58
- duration: params.duration,
59
- aspectRatio: params.aspect_ratio,
60
- resolution: params.resolution,
61
- });
62
- const text = `Video edited successfully${result.model ? ` (model: ${result.model})` : ""}`;
63
- return {
64
- content: [{ type: "text", text }],
65
- details: {
66
- type: "video_edit",
67
- model: result.model,
68
- durationMs: result.durationMs,
69
- mediaUrls: result.mediaUrls,
70
- },
71
- };
72
- },
73
- };
74
- }
@@ -1,66 +0,0 @@
1
- // ============================================================
2
- // Video Generate Tool — generate video clips via backend.
3
- // Category: media
4
- // ============================================================
5
- export const VIDEO_GENERATE_TOOL_NAME = "video_generate";
6
- export const VIDEO_GENERATE_TOOL_SCHEMA = {
7
- type: "object",
8
- properties: {
9
- prompt: {
10
- type: "string",
11
- description: "Video generation prompt. MUST be in English. Include scene, movement, camera motion, lighting, style.",
12
- },
13
- purpose: {
14
- type: "string",
15
- description: "Intended use: 'social-media', 'short-video', 'presentation', etc.",
16
- },
17
- style: {
18
- type: "string",
19
- description: "Visual style: 'cinematic', 'anime', 'watercolor', etc.",
20
- },
21
- image_url: {
22
- type: "string",
23
- description: "Reference image for image-to-video. Preview image from storyboard Step 3, or user-uploaded image.",
24
- },
25
- aspect_ratio: {
26
- type: "string",
27
- description: "Video aspect ratio: '9:16' (vertical), '16:9' (horizontal), '1:1' (square). Default: '16:9'.",
28
- },
29
- duration: {
30
- type: "number",
31
- description: "Video duration in seconds (3-10s single-shot, >10s requires multi-shot workflow). Must be confirmed by user.",
32
- },
33
- },
34
- required: ["prompt"],
35
- };
36
- export function createVideoGenerateTool(deps) {
37
- return {
38
- name: VIDEO_GENERATE_TOOL_NAME,
39
- label: "Video Generate",
40
- description: "Generate a short video clip from a text prompt (and optional reference image). " +
41
- "Prompt MUST be in English. Include scene, movement, camera motion, lighting details. " +
42
- "Single-shot: 3–10s. For longer videos (>10s), use multi-shot storyboard workflow.",
43
- parameters: VIDEO_GENERATE_TOOL_SCHEMA,
44
- execute: async (_toolCallId, params) => {
45
- const result = await deps.generateVideo({
46
- prompt: params.prompt,
47
- purpose: params.purpose,
48
- style: params.style,
49
- imageUrl: params.image_url,
50
- aspectRatio: params.aspect_ratio,
51
- duration: params.duration,
52
- });
53
- const count = result.mediaUrls.length;
54
- const text = `Generated ${count} video${count > 1 ? "s" : ""}${result.model ? ` (model: ${result.model})` : ""}`;
55
- return {
56
- content: [{ type: "text", text }],
57
- details: {
58
- type: "video_generate",
59
- model: result.model,
60
- durationMs: result.durationMs,
61
- mediaUrls: result.mediaUrls,
62
- },
63
- };
64
- },
65
- };
66
- }
@@ -1,92 +0,0 @@
1
- // ============================================================
2
- // Video Merge Tool — merge multiple video clips with transitions.
3
- // Category: media
4
- // ============================================================
5
- export const VIDEO_MERGE_TOOL_NAME = "video_merge";
6
- export const VIDEO_MERGE_TOOL_SCHEMA = {
7
- type: "object",
8
- properties: {
9
- clips: {
10
- type: "array",
11
- items: {
12
- type: "object",
13
- properties: {
14
- video: { type: "string", description: "Video file path." },
15
- audio: { type: "string", description: "Narration audio file path (from TTS)." },
16
- trimStart: { type: "number", description: "Trim start in seconds (default 0)." },
17
- trimEnd: { type: "number", description: "Trim end in seconds (default: full)." },
18
- },
19
- required: ["video"],
20
- },
21
- minItems: 2,
22
- description: "Array of video clips to merge, in order.",
23
- },
24
- transition: {
25
- type: "string",
26
- description: "Transition effect: 'crossfade' (default), 'fade', 'wipeleft', 'cut', 'dissolve', etc.",
27
- },
28
- transitionDuration: {
29
- type: "number",
30
- description: "Transition duration in seconds (0.1-2.0, default 0.5).",
31
- },
32
- subtitles: {
33
- type: "string",
34
- description: "Path to SRT subtitle file to burn-in.",
35
- },
36
- bgm: {
37
- type: "string",
38
- description: "Background music file path.",
39
- },
40
- bgmVolume: {
41
- type: "number",
42
- description: "BGM volume (0.0-1.0, default 0.15).",
43
- },
44
- outputResolution: {
45
- type: "string",
46
- description: "Output resolution: '1920x1080', '1080x1920', etc. Default: auto.",
47
- },
48
- outputFps: {
49
- type: "number",
50
- description: "Output FPS (default 30).",
51
- },
52
- },
53
- required: ["clips"],
54
- };
55
- export function createVideoMergeTool(deps) {
56
- return {
57
- name: VIDEO_MERGE_TOOL_NAME,
58
- label: "Video Merge",
59
- description: "Merge multiple video clips into a single video with transitions, subtitles, and background music. " +
60
- "Requires at least 2 clips. Supports crossfade, fade, wipe, dissolve, and cut transitions. " +
61
- "Audio per clip is preserved; BGM is mixed at adjustable volume.",
62
- parameters: VIDEO_MERGE_TOOL_SCHEMA,
63
- execute: async (_toolCallId, params) => {
64
- if (!params.clips || params.clips.length < 2) {
65
- return { content: [{ type: "text", text: "Error: at least 2 clips are required for merging." }] };
66
- }
67
- const result = await deps.mergeVideos({
68
- clips: params.clips,
69
- transition: params.transition,
70
- transitionDuration: params.transitionDuration,
71
- subtitles: params.subtitles,
72
- bgm: params.bgm,
73
- bgmVolume: params.bgmVolume,
74
- outputResolution: params.outputResolution,
75
- outputFps: params.outputFps,
76
- });
77
- const text = `Merged ${result.clipCount} clips → ${result.durationSec.toFixed(1)}s video` +
78
- (params.transition ? ` (transition: ${params.transition})` : "");
79
- return {
80
- content: [{ type: "text", text }],
81
- details: {
82
- type: "video_merge",
83
- localPath: result.localPath,
84
- servePath: result.servePath,
85
- durationSec: result.durationSec,
86
- clipCount: result.clipCount,
87
- mediaUrls: result.mediaUrls,
88
- },
89
- };
90
- },
91
- };
92
- }
@@ -1,52 +0,0 @@
1
- // ============================================================
2
- // Video Upscale Tool — upscale video resolution + sharpen.
3
- // Category: media
4
- // ============================================================
5
- export const VIDEO_UPSCALE_TOOL_NAME = "video_upscale";
6
- export const VIDEO_UPSCALE_TOOL_SCHEMA = {
7
- type: "object",
8
- properties: {
9
- video: {
10
- type: "string",
11
- description: "Video file path (local or serve path).",
12
- },
13
- targetResolution: {
14
- type: "string",
15
- description: "Target resolution: '1080p' (default, 1920x1080/1080x1920), '2k' (2560x1440/1440x2560).",
16
- },
17
- sharpness: {
18
- type: "string",
19
- description: "Sharpening intensity: 'light' (default), 'medium', 'strong'.",
20
- },
21
- },
22
- required: ["video"],
23
- };
24
- export function createVideoUpscaleTool(deps) {
25
- return {
26
- name: VIDEO_UPSCALE_TOOL_NAME,
27
- label: "Video Upscale",
28
- description: "Upscale a video to higher resolution with optional sharpening. " +
29
- "Auto-detects orientation (landscape/portrait). Uses Lanczos interpolation + unsharp mask. " +
30
- "Supports 1080p and 2K targets. Best used as post-processing after video_merge.",
31
- parameters: VIDEO_UPSCALE_TOOL_SCHEMA,
32
- execute: async (_toolCallId, params) => {
33
- const result = await deps.upscaleVideo({
34
- video: params.video,
35
- targetResolution: params.targetResolution,
36
- sharpness: params.sharpness,
37
- });
38
- const text = `Upscaled to ${result.resolution}${params.sharpness ? ` (sharpness: ${params.sharpness})` : ""}`;
39
- return {
40
- content: [{ type: "text", text }],
41
- details: {
42
- type: "video_upscale",
43
- localPath: result.localPath,
44
- servePath: result.servePath,
45
- resolution: result.resolution,
46
- durationSec: result.durationSec,
47
- mediaUrls: result.mediaUrls,
48
- },
49
- };
50
- },
51
- };
52
- }
@@ -1,92 +0,0 @@
1
- // ============================================================
2
- // Web Fetch Tool — fetch and extract web page content.
3
- // Category: web
4
- // ============================================================
5
- export const WEB_FETCH_TOOL_NAME = "web_fetch";
6
- export const WEB_FETCH_TOOL_SCHEMA = {
7
- type: "object",
8
- properties: {
9
- url: {
10
- type: "string",
11
- description: "HTTP or HTTPS URL to fetch.",
12
- },
13
- extractMode: {
14
- type: "string",
15
- enum: ["markdown", "text", "json"],
16
- description: 'Extraction mode: "markdown" (default), "text", or "json" (LLM-driven structured extraction).',
17
- },
18
- maxChars: {
19
- type: "number",
20
- description: "Maximum characters to return (truncates when exceeded).",
21
- minimum: 100,
22
- },
23
- query: {
24
- type: "string",
25
- description: "Original search query. When provided, returns the most query-relevant sections.",
26
- },
27
- extract: {
28
- type: "boolean",
29
- description: "When true, returns structured extraction (title, summary, key facts, entities, topics, sentiment).",
30
- },
31
- summarize: {
32
- type: "boolean",
33
- description: "When true, returns a concise summary (< 500 chars) of the page content. " +
34
- "Useful for long pages to reduce context usage while preserving key information.",
35
- },
36
- },
37
- required: ["url"],
38
- };
39
- const DEFAULT_MAX_CHARS = 50000;
40
- export function createWebFetchTool(deps) {
41
- return {
42
- name: WEB_FETCH_TOOL_NAME,
43
- label: "Web Fetch",
44
- description: "Fetch content from a URL and extract it as markdown, text, or structured JSON. " +
45
- "Supports query-based relevance filtering and structured extraction " +
46
- "(title, summary, key facts, entities, topics, sentiment).",
47
- parameters: WEB_FETCH_TOOL_SCHEMA,
48
- execute: async (_toolCallId, params) => {
49
- const result = await deps.fetchUrl({
50
- url: params.url,
51
- extractMode: params.extractMode,
52
- maxChars: params.maxChars ?? DEFAULT_MAX_CHARS,
53
- query: params.query,
54
- extract: params.extract,
55
- });
56
- // Summarization: if requested and content is long enough to warrant it
57
- if (params.summarize && deps.summarizeContent && result.content.length > 1000) {
58
- const summary = await deps.summarizeContent(result.content, params.query);
59
- return {
60
- content: [{ type: "text", text: result.title ? `# ${result.title}\n\n${summary}` : summary }],
61
- details: {
62
- type: "web_fetch",
63
- url: params.url,
64
- summarized: true,
65
- originalLength: result.content.length,
66
- summaryLength: summary.length,
67
- },
68
- };
69
- }
70
- const parts = [];
71
- if (result.title)
72
- parts.push(`# ${result.title}\n`);
73
- parts.push(result.content);
74
- if (result.relevantExcerpts?.length) {
75
- parts.push("\n---\n## Relevant Excerpts\n");
76
- for (const excerpt of result.relevantExcerpts) {
77
- parts.push(`- ${excerpt}`);
78
- }
79
- }
80
- return {
81
- content: [{ type: "text", text: parts.join("\n") }],
82
- details: {
83
- type: "web_fetch",
84
- url: params.url,
85
- extractMode: params.extractMode ?? "markdown",
86
- hasExtraction: !!result.extraction,
87
- extraction: result.extraction,
88
- },
89
- };
90
- },
91
- };
92
- }