@shareai-lab/kode 1.1.13 → 1.1.16

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 (288) hide show
  1. package/dist/entrypoints/cli.js +2 -1
  2. package/dist/entrypoints/cli.js.map +2 -2
  3. package/dist/index.js +5 -26
  4. package/dist/package.json +4 -1
  5. package/package.json +9 -104
  6. package/dist/test/testAdapters.js +0 -88
  7. package/dist/test/testAdapters.js.map +0 -1
  8. package/src/ProjectOnboarding.tsx +0 -198
  9. package/src/Tool.ts +0 -83
  10. package/src/commands/agents.tsx +0 -3416
  11. package/src/commands/approvedTools.ts +0 -53
  12. package/src/commands/bug.tsx +0 -20
  13. package/src/commands/clear.ts +0 -43
  14. package/src/commands/compact.ts +0 -120
  15. package/src/commands/config.tsx +0 -19
  16. package/src/commands/cost.ts +0 -18
  17. package/src/commands/ctx_viz.ts +0 -209
  18. package/src/commands/doctor.ts +0 -24
  19. package/src/commands/help.tsx +0 -19
  20. package/src/commands/init.ts +0 -37
  21. package/src/commands/listen.ts +0 -42
  22. package/src/commands/login.tsx +0 -51
  23. package/src/commands/logout.tsx +0 -40
  24. package/src/commands/mcp.ts +0 -41
  25. package/src/commands/model.tsx +0 -40
  26. package/src/commands/modelstatus.tsx +0 -20
  27. package/src/commands/onboarding.tsx +0 -34
  28. package/src/commands/pr_comments.ts +0 -59
  29. package/src/commands/refreshCommands.ts +0 -54
  30. package/src/commands/release-notes.ts +0 -34
  31. package/src/commands/resume.tsx +0 -31
  32. package/src/commands/review.ts +0 -49
  33. package/src/commands/terminalSetup.ts +0 -221
  34. package/src/commands.ts +0 -139
  35. package/src/components/ApproveApiKey.tsx +0 -93
  36. package/src/components/AsciiLogo.tsx +0 -13
  37. package/src/components/AutoUpdater.tsx +0 -148
  38. package/src/components/Bug.tsx +0 -367
  39. package/src/components/Config.tsx +0 -293
  40. package/src/components/ConsoleOAuthFlow.tsx +0 -327
  41. package/src/components/Cost.tsx +0 -23
  42. package/src/components/CostThresholdDialog.tsx +0 -46
  43. package/src/components/CustomSelect/option-map.ts +0 -42
  44. package/src/components/CustomSelect/select-option.tsx +0 -78
  45. package/src/components/CustomSelect/select.tsx +0 -152
  46. package/src/components/CustomSelect/theme.ts +0 -45
  47. package/src/components/CustomSelect/use-select-state.ts +0 -414
  48. package/src/components/CustomSelect/use-select.ts +0 -35
  49. package/src/components/FallbackToolUseRejectedMessage.tsx +0 -15
  50. package/src/components/FileEditToolUpdatedMessage.tsx +0 -66
  51. package/src/components/Help.tsx +0 -215
  52. package/src/components/HighlightedCode.tsx +0 -33
  53. package/src/components/InvalidConfigDialog.tsx +0 -113
  54. package/src/components/Link.tsx +0 -32
  55. package/src/components/LogSelector.tsx +0 -86
  56. package/src/components/Logo.tsx +0 -170
  57. package/src/components/MCPServerApprovalDialog.tsx +0 -100
  58. package/src/components/MCPServerDialogCopy.tsx +0 -25
  59. package/src/components/MCPServerMultiselectDialog.tsx +0 -109
  60. package/src/components/Message.tsx +0 -221
  61. package/src/components/MessageResponse.tsx +0 -15
  62. package/src/components/MessageSelector.tsx +0 -211
  63. package/src/components/ModeIndicator.tsx +0 -88
  64. package/src/components/ModelConfig.tsx +0 -301
  65. package/src/components/ModelListManager.tsx +0 -227
  66. package/src/components/ModelSelector.tsx +0 -3387
  67. package/src/components/ModelStatusDisplay.tsx +0 -230
  68. package/src/components/Onboarding.tsx +0 -274
  69. package/src/components/PressEnterToContinue.tsx +0 -11
  70. package/src/components/PromptInput.tsx +0 -760
  71. package/src/components/SentryErrorBoundary.ts +0 -39
  72. package/src/components/Spinner.tsx +0 -129
  73. package/src/components/StickerRequestForm.tsx +0 -16
  74. package/src/components/StructuredDiff.tsx +0 -191
  75. package/src/components/TextInput.tsx +0 -259
  76. package/src/components/TodoItem.tsx +0 -47
  77. package/src/components/TokenWarning.tsx +0 -31
  78. package/src/components/ToolUseLoader.tsx +0 -40
  79. package/src/components/TrustDialog.tsx +0 -106
  80. package/src/components/binary-feedback/BinaryFeedback.tsx +0 -63
  81. package/src/components/binary-feedback/BinaryFeedbackOption.tsx +0 -111
  82. package/src/components/binary-feedback/BinaryFeedbackView.tsx +0 -172
  83. package/src/components/binary-feedback/utils.ts +0 -220
  84. package/src/components/messages/AssistantBashOutputMessage.tsx +0 -22
  85. package/src/components/messages/AssistantLocalCommandOutputMessage.tsx +0 -49
  86. package/src/components/messages/AssistantRedactedThinkingMessage.tsx +0 -19
  87. package/src/components/messages/AssistantTextMessage.tsx +0 -144
  88. package/src/components/messages/AssistantThinkingMessage.tsx +0 -40
  89. package/src/components/messages/AssistantToolUseMessage.tsx +0 -132
  90. package/src/components/messages/TaskProgressMessage.tsx +0 -32
  91. package/src/components/messages/TaskToolMessage.tsx +0 -58
  92. package/src/components/messages/UserBashInputMessage.tsx +0 -28
  93. package/src/components/messages/UserCommandMessage.tsx +0 -30
  94. package/src/components/messages/UserKodingInputMessage.tsx +0 -28
  95. package/src/components/messages/UserPromptMessage.tsx +0 -35
  96. package/src/components/messages/UserTextMessage.tsx +0 -39
  97. package/src/components/messages/UserToolResultMessage/UserToolCanceledMessage.tsx +0 -12
  98. package/src/components/messages/UserToolResultMessage/UserToolErrorMessage.tsx +0 -36
  99. package/src/components/messages/UserToolResultMessage/UserToolRejectMessage.tsx +0 -31
  100. package/src/components/messages/UserToolResultMessage/UserToolResultMessage.tsx +0 -57
  101. package/src/components/messages/UserToolResultMessage/UserToolSuccessMessage.tsx +0 -35
  102. package/src/components/messages/UserToolResultMessage/utils.tsx +0 -56
  103. package/src/components/permissions/BashPermissionRequest/BashPermissionRequest.tsx +0 -121
  104. package/src/components/permissions/FallbackPermissionRequest.tsx +0 -153
  105. package/src/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.tsx +0 -182
  106. package/src/components/permissions/FileEditPermissionRequest/FileEditToolDiff.tsx +0 -77
  107. package/src/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.tsx +0 -164
  108. package/src/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.tsx +0 -83
  109. package/src/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.tsx +0 -240
  110. package/src/components/permissions/PermissionRequest.tsx +0 -101
  111. package/src/components/permissions/PermissionRequestTitle.tsx +0 -69
  112. package/src/components/permissions/hooks.ts +0 -44
  113. package/src/components/permissions/toolUseOptions.ts +0 -59
  114. package/src/components/permissions/utils.ts +0 -23
  115. package/src/constants/betas.ts +0 -5
  116. package/src/constants/claude-asterisk-ascii-art.tsx +0 -238
  117. package/src/constants/figures.ts +0 -4
  118. package/src/constants/keys.ts +0 -3
  119. package/src/constants/macros.ts +0 -11
  120. package/src/constants/modelCapabilities.ts +0 -179
  121. package/src/constants/models.ts +0 -1025
  122. package/src/constants/oauth.ts +0 -18
  123. package/src/constants/product.ts +0 -17
  124. package/src/constants/prompts.ts +0 -168
  125. package/src/constants/releaseNotes.ts +0 -7
  126. package/src/context/PermissionContext.tsx +0 -149
  127. package/src/context.ts +0 -278
  128. package/src/cost-tracker.ts +0 -84
  129. package/src/entrypoints/cli.tsx +0 -1561
  130. package/src/entrypoints/mcp.ts +0 -175
  131. package/src/history.ts +0 -25
  132. package/src/hooks/useApiKeyVerification.ts +0 -59
  133. package/src/hooks/useArrowKeyHistory.ts +0 -55
  134. package/src/hooks/useCanUseTool.ts +0 -138
  135. package/src/hooks/useCancelRequest.ts +0 -39
  136. package/src/hooks/useDoublePress.ts +0 -41
  137. package/src/hooks/useExitOnCtrlCD.ts +0 -31
  138. package/src/hooks/useInterval.ts +0 -25
  139. package/src/hooks/useLogMessages.ts +0 -16
  140. package/src/hooks/useLogStartupTime.ts +0 -12
  141. package/src/hooks/useNotifyAfterTimeout.ts +0 -65
  142. package/src/hooks/usePermissionRequestLogging.ts +0 -44
  143. package/src/hooks/useTerminalSize.ts +0 -49
  144. package/src/hooks/useTextInput.ts +0 -317
  145. package/src/hooks/useUnifiedCompletion.ts +0 -1405
  146. package/src/index.ts +0 -34
  147. package/src/messages.ts +0 -38
  148. package/src/permissions.ts +0 -268
  149. package/src/query.ts +0 -720
  150. package/src/screens/ConfigureNpmPrefix.tsx +0 -197
  151. package/src/screens/Doctor.tsx +0 -219
  152. package/src/screens/LogList.tsx +0 -68
  153. package/src/screens/REPL.tsx +0 -813
  154. package/src/screens/ResumeConversation.tsx +0 -68
  155. package/src/services/adapters/base.ts +0 -38
  156. package/src/services/adapters/chatCompletions.ts +0 -90
  157. package/src/services/adapters/responsesAPI.ts +0 -170
  158. package/src/services/browserMocks.ts +0 -66
  159. package/src/services/claude.ts +0 -2197
  160. package/src/services/customCommands.ts +0 -704
  161. package/src/services/fileFreshness.ts +0 -377
  162. package/src/services/gpt5ConnectionTest.ts +0 -340
  163. package/src/services/mcpClient.ts +0 -564
  164. package/src/services/mcpServerApproval.tsx +0 -50
  165. package/src/services/mentionProcessor.ts +0 -273
  166. package/src/services/modelAdapterFactory.ts +0 -69
  167. package/src/services/notifier.ts +0 -40
  168. package/src/services/oauth.ts +0 -357
  169. package/src/services/openai.ts +0 -1359
  170. package/src/services/responseStateManager.ts +0 -90
  171. package/src/services/sentry.ts +0 -3
  172. package/src/services/statsig.ts +0 -172
  173. package/src/services/statsigStorage.ts +0 -86
  174. package/src/services/systemReminder.ts +0 -507
  175. package/src/services/vcr.ts +0 -161
  176. package/src/test/testAdapters.ts +0 -96
  177. package/src/tools/ArchitectTool/ArchitectTool.tsx +0 -135
  178. package/src/tools/ArchitectTool/prompt.ts +0 -15
  179. package/src/tools/AskExpertModelTool/AskExpertModelTool.tsx +0 -576
  180. package/src/tools/BashTool/BashTool.tsx +0 -243
  181. package/src/tools/BashTool/BashToolResultMessage.tsx +0 -38
  182. package/src/tools/BashTool/OutputLine.tsx +0 -49
  183. package/src/tools/BashTool/prompt.ts +0 -174
  184. package/src/tools/BashTool/utils.ts +0 -56
  185. package/src/tools/FileEditTool/FileEditTool.tsx +0 -319
  186. package/src/tools/FileEditTool/prompt.ts +0 -51
  187. package/src/tools/FileEditTool/utils.ts +0 -58
  188. package/src/tools/FileReadTool/FileReadTool.tsx +0 -404
  189. package/src/tools/FileReadTool/prompt.ts +0 -7
  190. package/src/tools/FileWriteTool/FileWriteTool.tsx +0 -301
  191. package/src/tools/FileWriteTool/prompt.ts +0 -10
  192. package/src/tools/GlobTool/GlobTool.tsx +0 -119
  193. package/src/tools/GlobTool/prompt.ts +0 -8
  194. package/src/tools/GrepTool/GrepTool.tsx +0 -147
  195. package/src/tools/GrepTool/prompt.ts +0 -11
  196. package/src/tools/MCPTool/MCPTool.tsx +0 -107
  197. package/src/tools/MCPTool/prompt.ts +0 -3
  198. package/src/tools/MemoryReadTool/MemoryReadTool.tsx +0 -127
  199. package/src/tools/MemoryReadTool/prompt.ts +0 -3
  200. package/src/tools/MemoryWriteTool/MemoryWriteTool.tsx +0 -89
  201. package/src/tools/MemoryWriteTool/prompt.ts +0 -3
  202. package/src/tools/MultiEditTool/MultiEditTool.tsx +0 -388
  203. package/src/tools/MultiEditTool/prompt.ts +0 -45
  204. package/src/tools/NotebookEditTool/NotebookEditTool.tsx +0 -298
  205. package/src/tools/NotebookEditTool/prompt.ts +0 -3
  206. package/src/tools/NotebookReadTool/NotebookReadTool.tsx +0 -258
  207. package/src/tools/NotebookReadTool/prompt.ts +0 -3
  208. package/src/tools/StickerRequestTool/StickerRequestTool.tsx +0 -107
  209. package/src/tools/StickerRequestTool/prompt.ts +0 -19
  210. package/src/tools/TaskTool/TaskTool.tsx +0 -438
  211. package/src/tools/TaskTool/constants.ts +0 -1
  212. package/src/tools/TaskTool/prompt.ts +0 -92
  213. package/src/tools/ThinkTool/ThinkTool.tsx +0 -54
  214. package/src/tools/ThinkTool/prompt.ts +0 -12
  215. package/src/tools/TodoWriteTool/TodoWriteTool.tsx +0 -313
  216. package/src/tools/TodoWriteTool/prompt.ts +0 -63
  217. package/src/tools/URLFetcherTool/URLFetcherTool.tsx +0 -178
  218. package/src/tools/URLFetcherTool/cache.ts +0 -55
  219. package/src/tools/URLFetcherTool/htmlToMarkdown.ts +0 -55
  220. package/src/tools/URLFetcherTool/prompt.ts +0 -17
  221. package/src/tools/WebSearchTool/WebSearchTool.tsx +0 -103
  222. package/src/tools/WebSearchTool/prompt.ts +0 -13
  223. package/src/tools/WebSearchTool/searchProviders.ts +0 -66
  224. package/src/tools/lsTool/lsTool.tsx +0 -272
  225. package/src/tools/lsTool/prompt.ts +0 -2
  226. package/src/tools.ts +0 -67
  227. package/src/types/PermissionMode.ts +0 -120
  228. package/src/types/RequestContext.ts +0 -72
  229. package/src/types/common.d.ts +0 -2
  230. package/src/types/conversation.ts +0 -51
  231. package/src/types/logs.ts +0 -58
  232. package/src/types/modelCapabilities.ts +0 -64
  233. package/src/types/notebook.ts +0 -87
  234. package/src/utils/Cursor.ts +0 -436
  235. package/src/utils/PersistentShell.ts +0 -552
  236. package/src/utils/advancedFuzzyMatcher.ts +0 -290
  237. package/src/utils/agentLoader.ts +0 -278
  238. package/src/utils/agentStorage.ts +0 -97
  239. package/src/utils/array.ts +0 -3
  240. package/src/utils/ask.tsx +0 -99
  241. package/src/utils/auth.ts +0 -13
  242. package/src/utils/autoCompactCore.ts +0 -223
  243. package/src/utils/autoUpdater.ts +0 -458
  244. package/src/utils/betas.ts +0 -20
  245. package/src/utils/browser.ts +0 -14
  246. package/src/utils/cleanup.ts +0 -72
  247. package/src/utils/commands.ts +0 -261
  248. package/src/utils/commonUnixCommands.ts +0 -161
  249. package/src/utils/config.ts +0 -945
  250. package/src/utils/conversationRecovery.ts +0 -55
  251. package/src/utils/debugLogger.ts +0 -1235
  252. package/src/utils/diff.ts +0 -42
  253. package/src/utils/env.ts +0 -57
  254. package/src/utils/errors.ts +0 -21
  255. package/src/utils/exampleCommands.ts +0 -109
  256. package/src/utils/execFileNoThrow.ts +0 -51
  257. package/src/utils/expertChatStorage.ts +0 -136
  258. package/src/utils/file.ts +0 -405
  259. package/src/utils/fileRecoveryCore.ts +0 -71
  260. package/src/utils/format.tsx +0 -44
  261. package/src/utils/fuzzyMatcher.ts +0 -328
  262. package/src/utils/generators.ts +0 -62
  263. package/src/utils/git.ts +0 -92
  264. package/src/utils/globalLogger.ts +0 -77
  265. package/src/utils/http.ts +0 -10
  266. package/src/utils/imagePaste.ts +0 -38
  267. package/src/utils/json.ts +0 -13
  268. package/src/utils/log.ts +0 -382
  269. package/src/utils/markdown.ts +0 -213
  270. package/src/utils/messageContextManager.ts +0 -294
  271. package/src/utils/messages.tsx +0 -945
  272. package/src/utils/model.ts +0 -914
  273. package/src/utils/permissions/filesystem.ts +0 -127
  274. package/src/utils/responseState.ts +0 -23
  275. package/src/utils/ripgrep.ts +0 -167
  276. package/src/utils/secureFile.ts +0 -564
  277. package/src/utils/sessionState.ts +0 -49
  278. package/src/utils/state.ts +0 -25
  279. package/src/utils/style.ts +0 -29
  280. package/src/utils/terminal.ts +0 -50
  281. package/src/utils/theme.ts +0 -127
  282. package/src/utils/thinking.ts +0 -144
  283. package/src/utils/todoStorage.ts +0 -431
  284. package/src/utils/tokens.ts +0 -43
  285. package/src/utils/toolExecutionController.ts +0 -163
  286. package/src/utils/unaryLogging.ts +0 -26
  287. package/src/utils/user.ts +0 -37
  288. package/src/utils/validate.ts +0 -165
@@ -1,438 +0,0 @@
1
- import { TextBlock } from '@anthropic-ai/sdk/resources/index.mjs'
2
- import chalk from 'chalk'
3
- import { last, memoize } from 'lodash-es'
4
- import { EOL } from 'os'
5
- import React, { useState, useEffect } from 'react'
6
- import { Box, Text } from 'ink'
7
- import { z } from 'zod'
8
- import { Tool, ValidationResult } from '../../Tool'
9
- import { FallbackToolUseRejectedMessage } from '../../components/FallbackToolUseRejectedMessage'
10
- import { getAgentPrompt } from '../../constants/prompts'
11
- import { getContext } from '../../context'
12
- import { hasPermissionsToUseTool } from '../../permissions'
13
- import { AssistantMessage, Message as MessageType, query } from '../../query'
14
- import { formatDuration, formatNumber } from '../../utils/format'
15
- import {
16
- getMessagesPath,
17
- getNextAvailableLogSidechainNumber,
18
- overwriteLog,
19
- } from '../../utils/log.js'
20
- import { applyMarkdown } from '../../utils/markdown'
21
- import {
22
- createAssistantMessage,
23
- createUserMessage,
24
- getLastAssistantMessageId,
25
- INTERRUPT_MESSAGE,
26
- normalizeMessages,
27
- } from '../../utils/messages.js'
28
- import { getModelManager } from '../../utils/model'
29
- import { getMaxThinkingTokens } from '../../utils/thinking'
30
- import { getTheme } from '../../utils/theme'
31
- import { generateAgentId } from '../../utils/agentStorage'
32
- import { debug as debugLogger } from '../../utils/debugLogger'
33
- import { getTaskTools, getPrompt } from './prompt'
34
- import { TOOL_NAME } from './constants'
35
- import { getActiveAgents, getAgentByType, getAvailableAgentTypes } from '../../utils/agentLoader'
36
-
37
- const inputSchema = z.object({
38
- description: z
39
- .string()
40
- .describe('A short (3-5 word) description of the task'),
41
- prompt: z.string().describe('The task for the agent to perform'),
42
- model_name: z
43
- .string()
44
- .optional()
45
- .describe(
46
- 'Optional: Specific model name to use for this task. If not provided, uses the default task model pointer.',
47
- ),
48
- subagent_type: z
49
- .string()
50
- .optional()
51
- .describe(
52
- 'The type of specialized agent to use for this task',
53
- ),
54
- })
55
-
56
- export const TaskTool = {
57
- async prompt({ safeMode }) {
58
- // Match original Claude Code - prompt returns full agent descriptions
59
- return await getPrompt(safeMode)
60
- },
61
- name: TOOL_NAME,
62
- async description() {
63
- // Match original Claude Code exactly - simple description
64
- return "Launch a new task"
65
- },
66
- inputSchema,
67
-
68
- async *call(
69
- { description, prompt, model_name, subagent_type },
70
- {
71
- abortController,
72
- options: { safeMode = false, forkNumber, messageLogName, verbose },
73
- readFileTimestamps,
74
- },
75
- ): AsyncGenerator<{ type: 'result'; data: TextBlock[]; resultForAssistant?: string }, void, unknown> {
76
- const startTime = Date.now()
77
-
78
- // Default to general-purpose if no subagent_type specified
79
- const agentType = subagent_type || 'general-purpose'
80
-
81
- // Apply subagent configuration
82
- let effectivePrompt = prompt
83
- let effectiveModel = model_name || 'task'
84
- let toolFilter = null
85
- let temperature = undefined
86
-
87
- // Load agent configuration dynamically
88
- if (agentType) {
89
- const agentConfig = await getAgentByType(agentType)
90
-
91
- if (!agentConfig) {
92
- // If agent type not found, return helpful message instead of throwing
93
- const availableTypes = await getAvailableAgentTypes()
94
- const helpMessage = `Agent type '${agentType}' not found.\n\nAvailable agents:\n${availableTypes.map(t => ` • ${t}`).join('\n')}\n\nUse /agents command to manage agent configurations.`
95
-
96
- yield {
97
- type: 'result',
98
- data: [{ type: 'text', text: helpMessage }] as TextBlock[],
99
- resultForAssistant: helpMessage,
100
- }
101
- return
102
- }
103
-
104
- // Apply system prompt if configured
105
- if (agentConfig.systemPrompt) {
106
- effectivePrompt = `${agentConfig.systemPrompt}\n\n${prompt}`
107
- }
108
-
109
- // Apply model if not overridden by model_name parameter
110
- if (!model_name && agentConfig.model_name) {
111
- // Support inherit: keep pointer-based default
112
- if (agentConfig.model_name !== 'inherit') {
113
- effectiveModel = agentConfig.model_name as string
114
- }
115
- }
116
-
117
- // Store tool filter for later application
118
- toolFilter = agentConfig.tools
119
-
120
- // Note: temperature is not currently in our agent configs
121
- // but could be added in the future
122
- }
123
-
124
- const messages: MessageType[] = [createUserMessage(effectivePrompt)]
125
- let tools = await getTaskTools(safeMode)
126
-
127
- // Apply tool filtering if specified by subagent config
128
- if (toolFilter) {
129
- // Back-compat: ['*'] means all tools
130
- const isAllArray = Array.isArray(toolFilter) && toolFilter.length === 1 && toolFilter[0] === '*'
131
- if (toolFilter === '*' || isAllArray) {
132
- // no-op, keep all tools
133
- } else if (Array.isArray(toolFilter)) {
134
- tools = tools.filter(tool => toolFilter.includes(tool.name))
135
- }
136
- }
137
-
138
- // Skip initial progress yield - only yield results for Tool interface
139
-
140
- const [taskPrompt, context, maxThinkingTokens] = await Promise.all([
141
- getAgentPrompt(),
142
- getContext(),
143
- getMaxThinkingTokens(messages),
144
- ])
145
-
146
- // Model already resolved in effectiveModel variable above
147
- const modelToUse = effectiveModel
148
-
149
- // Inject model context to prevent self-referential expert consultations
150
- taskPrompt.push(`\nIMPORTANT: You are currently running as ${modelToUse}. You do not need to consult ${modelToUse} via AskExpertModel since you ARE ${modelToUse}. Complete tasks directly using your capabilities.`)
151
-
152
- let toolUseCount = 0
153
-
154
- const getSidechainNumber = memoize(() =>
155
- getNextAvailableLogSidechainNumber(messageLogName, forkNumber),
156
- )
157
-
158
- // Generate unique Task ID for this task execution
159
- const taskId = generateAgentId()
160
-
161
- // 🔧 ULTRA SIMPLIFIED: Exact original AgentTool pattern
162
- // Build query options, adding temperature if specified
163
- const queryOptions = {
164
- safeMode,
165
- forkNumber,
166
- messageLogName,
167
- tools,
168
- commands: [],
169
- verbose,
170
- maxThinkingTokens,
171
- model: modelToUse,
172
- }
173
-
174
- // Add temperature if specified by subagent config
175
- if (temperature !== undefined) {
176
- queryOptions['temperature'] = temperature
177
- }
178
-
179
- for await (const message of query(
180
- messages,
181
- taskPrompt,
182
- context,
183
- hasPermissionsToUseTool,
184
- {
185
- abortController,
186
- options: queryOptions,
187
- messageId: getLastAssistantMessageId(messages),
188
- agentId: taskId,
189
- readFileTimestamps,
190
- setToolJSX: () => {}, // No-op implementation for TaskTool
191
- },
192
- )) {
193
- messages.push(message)
194
-
195
- overwriteLog(
196
- getMessagesPath(messageLogName, forkNumber, getSidechainNumber()),
197
- messages.filter(_ => _.type !== 'progress'),
198
- )
199
-
200
- if (message.type !== 'assistant') {
201
- continue
202
- }
203
-
204
- const normalizedMessages = normalizeMessages(messages)
205
-
206
- // Process tool uses and text content for better visibility
207
- for (const content of message.message.content) {
208
- if (content.type === 'text' && content.text && content.text !== INTERRUPT_MESSAGE) {
209
- // Show agent's reasoning/responses
210
- const preview = content.text.length > 200 ? content.text.substring(0, 200) + '...' : content.text
211
- // Skip progress yield - only yield results for Tool interface
212
- } else if (content.type === 'tool_use') {
213
- toolUseCount++
214
-
215
- // Show which tool is being used with agent context
216
- const toolMessage = normalizedMessages.find(
217
- _ =>
218
- _.type === 'assistant' &&
219
- _.message.content[0]?.type === 'tool_use' &&
220
- _.message.content[0].id === content.id,
221
- ) as AssistantMessage
222
-
223
- if (toolMessage) {
224
- // Clone and modify the message to show agent context
225
- const modifiedMessage = {
226
- ...toolMessage,
227
- message: {
228
- ...toolMessage.message,
229
- content: toolMessage.message.content.map(c => {
230
- if (c.type === 'tool_use' && c.id === content.id) {
231
- // Add agent context to tool name display
232
- return {
233
- ...c,
234
- name: c.name // Keep original name, UI will handle display
235
- }
236
- }
237
- return c
238
- })
239
- }
240
- }
241
-
242
- // Skip progress yield - only yield results for Tool interface
243
- }
244
- }
245
- }
246
- }
247
-
248
- const normalizedMessages = normalizeMessages(messages)
249
- const lastMessage = last(messages)
250
- if (lastMessage?.type !== 'assistant') {
251
- throw new Error('Last message was not an assistant message')
252
- }
253
-
254
- // 🔧 CRITICAL FIX: Match original AgentTool interrupt handling pattern exactly
255
- if (
256
- lastMessage.message.content.some(
257
- _ => _.type === 'text' && _.text === INTERRUPT_MESSAGE,
258
- )
259
- ) {
260
- // Skip progress yield - only yield final result
261
- } else {
262
- const result = [
263
- toolUseCount === 1 ? '1 tool use' : `${toolUseCount} tool uses`,
264
- formatNumber(
265
- (lastMessage.message.usage.cache_creation_input_tokens ?? 0) +
266
- (lastMessage.message.usage.cache_read_input_tokens ?? 0) +
267
- lastMessage.message.usage.input_tokens +
268
- lastMessage.message.usage.output_tokens,
269
- ) + ' tokens',
270
- formatDuration(Date.now() - startTime),
271
- ]
272
- // Skip progress yield - only yield final result
273
- }
274
-
275
- // Output is an AssistantMessage, but since TaskTool is a tool, it needs
276
- // to serialize its response to UserMessage-compatible content.
277
- const data = lastMessage.message.content.filter(_ => _.type === 'text')
278
- yield {
279
- type: 'result',
280
- data,
281
- resultForAssistant: this.renderResultForAssistant(data),
282
- }
283
- },
284
-
285
- isReadOnly() {
286
- return true // for now...
287
- },
288
- isConcurrencySafe() {
289
- return true // Task tool supports concurrent execution in official implementation
290
- },
291
- async validateInput(input, context) {
292
- if (!input.description || typeof input.description !== 'string') {
293
- return {
294
- result: false,
295
- message: 'Description is required and must be a string',
296
- }
297
- }
298
- if (!input.prompt || typeof input.prompt !== 'string') {
299
- return {
300
- result: false,
301
- message: 'Prompt is required and must be a string',
302
- }
303
- }
304
-
305
- // Model validation - similar to Edit tool error handling
306
- if (input.model_name) {
307
- const modelManager = getModelManager()
308
- const availableModels = modelManager.getAllAvailableModelNames()
309
-
310
- if (!availableModels.includes(input.model_name)) {
311
- return {
312
- result: false,
313
- message: `Model '${input.model_name}' does not exist. Available models: ${availableModels.join(', ')}`,
314
- meta: {
315
- model_name: input.model_name,
316
- availableModels,
317
- },
318
- }
319
- }
320
- }
321
-
322
- // Validate subagent_type if provided
323
- if (input.subagent_type) {
324
- const availableTypes = await getAvailableAgentTypes()
325
- if (!availableTypes.includes(input.subagent_type)) {
326
- return {
327
- result: false,
328
- message: `Agent type '${input.subagent_type}' does not exist. Available types: ${availableTypes.join(', ')}`,
329
- meta: {
330
- subagent_type: input.subagent_type,
331
- availableTypes,
332
- },
333
- }
334
- }
335
- }
336
-
337
- return { result: true }
338
- },
339
- async isEnabled() {
340
- return true
341
- },
342
- userFacingName(input?: any) {
343
- // Return agent name with proper prefix
344
- const agentType = input?.subagent_type || 'general-purpose'
345
- return `agent-${agentType}`
346
- },
347
- needsPermissions() {
348
- return false
349
- },
350
- renderResultForAssistant(data: TextBlock[]) {
351
- return data.map(block => block.type === 'text' ? block.text : '').join('\n')
352
- },
353
- renderToolUseMessage({ description, prompt, model_name, subagent_type }, { verbose }) {
354
- if (!description || !prompt) return null
355
-
356
- const modelManager = getModelManager()
357
- const defaultTaskModel = modelManager.getModelName('task')
358
- const actualModel = model_name || defaultTaskModel
359
- const agentType = subagent_type || 'general-purpose'
360
- const promptPreview =
361
- prompt.length > 80 ? prompt.substring(0, 80) + '...' : prompt
362
-
363
- const theme = getTheme()
364
-
365
- if (verbose) {
366
- return (
367
- <Box flexDirection="column">
368
- <Text>
369
- [{agentType}] {actualModel}: {description}
370
- </Text>
371
- <Box
372
- paddingLeft={2}
373
- borderLeftStyle="single"
374
- borderLeftColor={theme.secondaryBorder}
375
- >
376
- <Text color={theme.secondaryText}>{promptPreview}</Text>
377
- </Box>
378
- </Box>
379
- )
380
- }
381
-
382
- // Simple display: agent type, model and description
383
- return `[${agentType}] ${actualModel}: ${description}`
384
- },
385
- renderToolUseRejectedMessage() {
386
- return <FallbackToolUseRejectedMessage />
387
- },
388
- renderToolResultMessage(content) {
389
- const theme = getTheme()
390
-
391
- if (Array.isArray(content)) {
392
- const textBlocks = content.filter(block => block.type === 'text')
393
- const totalLength = textBlocks.reduce(
394
- (sum, block) => sum + block.text.length,
395
- 0,
396
- )
397
- // 🔧 CRITICAL FIX: Use exact match for interrupt detection, not .includes()
398
- const isInterrupted = content.some(
399
- block =>
400
- block.type === 'text' && block.text === INTERRUPT_MESSAGE,
401
- )
402
-
403
- if (isInterrupted) {
404
- // 🔧 CRITICAL FIX: Match original system interrupt rendering exactly
405
- return (
406
- <Box flexDirection="row">
407
- <Text>&nbsp;&nbsp;⎿ &nbsp;</Text>
408
- <Text color={theme.error}>Interrupted by user</Text>
409
- </Box>
410
- )
411
- }
412
-
413
- return (
414
- <Box flexDirection="column">
415
- <Box justifyContent="space-between" width="100%">
416
- <Box flexDirection="row">
417
- <Text>&nbsp;&nbsp;⎿ &nbsp;</Text>
418
- <Text>Task completed</Text>
419
- {textBlocks.length > 0 && (
420
- <Text color={theme.secondaryText}>
421
- {' '}
422
- ({totalLength} characters)
423
- </Text>
424
- )}
425
- </Box>
426
- </Box>
427
- </Box>
428
- )
429
- }
430
-
431
- return (
432
- <Box flexDirection="row">
433
- <Text>&nbsp;&nbsp;⎿ &nbsp;</Text>
434
- <Text color={theme.secondaryText}>Task completed</Text>
435
- </Box>
436
- )
437
- },
438
- } satisfies Tool<typeof inputSchema, TextBlock[]>
@@ -1 +0,0 @@
1
- export const TOOL_NAME = 'Task'
@@ -1,92 +0,0 @@
1
- import { type Tool } from '../../Tool'
2
- import { getTools, getReadOnlyTools } from '../../tools'
3
- import { TaskTool } from './TaskTool'
4
- import { BashTool } from '../BashTool/BashTool'
5
- import { FileWriteTool } from '../FileWriteTool/FileWriteTool'
6
- import { FileEditTool } from '../FileEditTool/FileEditTool'
7
- import { NotebookEditTool } from '../NotebookEditTool/NotebookEditTool'
8
- import { GlobTool } from '../GlobTool/GlobTool'
9
- import { FileReadTool } from '../FileReadTool/FileReadTool'
10
- import { getModelManager } from '../../utils/model'
11
- import { getActiveAgents } from '../../utils/agentLoader'
12
-
13
- export async function getTaskTools(safeMode: boolean): Promise<Tool[]> {
14
- // No recursive tasks, yet..
15
- return (await (!safeMode ? getTools() : getReadOnlyTools())).filter(
16
- _ => _.name !== TaskTool.name,
17
- )
18
- }
19
-
20
- export async function getPrompt(safeMode: boolean): Promise<string> {
21
- // Extracted directly from original Claude Code obfuscated source
22
- const agents = await getActiveAgents()
23
-
24
- // Format exactly as in original: (Tools: tool1, tool2)
25
- const agentDescriptions = agents.map(agent => {
26
- const toolsStr = Array.isArray(agent.tools)
27
- ? agent.tools.join(', ')
28
- : '*'
29
- return `- ${agent.agentType}: ${agent.whenToUse} (Tools: ${toolsStr})`
30
- }).join('\n')
31
-
32
- // 100% exact copy from original Claude Code source
33
- return `Launch a new agent to handle complex, multi-step tasks autonomously.
34
-
35
- Available agent types and the tools they have access to:
36
- ${agentDescriptions}
37
-
38
- When using the Task tool, you must specify a subagent_type parameter to select which agent type to use.
39
-
40
- When to use the Agent tool:
41
- - When you are instructed to execute custom slash commands. Use the Agent tool with the slash command invocation as the entire prompt. The slash command can take arguments. For example: Task(description="Check the file", prompt="/check-file path/to/file.py")
42
-
43
- When NOT to use the Agent tool:
44
- - If you want to read a specific file path, use the ${FileReadTool.name} or ${GlobTool.name} tool instead of the Agent tool, to find the match more quickly
45
- - If you are searching for a specific class definition like "class Foo", use the ${GlobTool.name} tool instead, to find the match more quickly
46
- - If you are searching for code within a specific file or set of 2-3 files, use the ${FileReadTool.name} tool instead of the Agent tool, to find the match more quickly
47
- - Other tasks that are not related to the agent descriptions above
48
-
49
- Usage notes:
50
- 1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
51
- 2. When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result.
52
- 3. Each agent invocation is stateless. You will not be able to send additional messages to the agent, nor will the agent be able to communicate with you outside of its final report. Therefore, your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.
53
- 4. The agent's outputs should generally be trusted
54
- 5. Clearly tell the agent whether you expect it to write code or just to do research (search, file reads, web fetches, etc.), since it is not aware of the user's intent
55
- 6. If the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.
56
-
57
- Example usage:
58
-
59
- <example_agent_descriptions>
60
- "code-reviewer": use this agent after you are done writing a signficant piece of code
61
- "greeting-responder": use this agent when to respond to user greetings with a friendly joke
62
- </example_agent_description>
63
-
64
- <example>
65
- user: "Please write a function that checks if a number is prime"
66
- assistant: Sure let me write a function that checks if a number is prime
67
- assistant: First let me use the ${FileWriteTool.name} tool to write a function that checks if a number is prime
68
- assistant: I'm going to use the ${FileWriteTool.name} tool to write the following code:
69
- <code>
70
- function isPrime(n) {
71
- if (n <= 1) return false
72
- for (let i = 2; i * i <= n; i++) {
73
- if (n % i === 0) return false
74
- }
75
- return true
76
- }
77
- </code>
78
- <commentary>
79
- Since a signficant piece of code was written and the task was completed, now use the code-reviewer agent to review the code
80
- </commentary>
81
- assistant: Now let me use the code-reviewer agent to review the code
82
- assistant: Uses the Task tool to launch the with the code-reviewer agent
83
- </example>
84
-
85
- <example>
86
- user: "Hello"
87
- <commentary>
88
- Since the user is greeting, use the greeting-responder agent to respond with a friendly joke
89
- </commentary>
90
- assistant: "I'm going to use the Task tool to launch the with the greeting-responder agent"
91
- </example>`
92
- }
@@ -1,54 +0,0 @@
1
- import { z } from 'zod'
2
- import React from 'react'
3
- import { Text } from 'ink'
4
- import { Tool } from '../../Tool'
5
- import { DESCRIPTION, PROMPT } from './prompt'
6
- import { getTheme } from '../../utils/theme'
7
- import { MessageResponse } from '../../components/MessageResponse'
8
- import { checkGate, logEvent } from '../../services/statsig'
9
- import { USE_BEDROCK, USE_VERTEX } from '../../utils/model'
10
-
11
- const thinkToolSchema = z.object({
12
- thought: z.string().describe('Your thoughts.'),
13
- })
14
-
15
- export const ThinkTool = {
16
- name: 'Think',
17
- userFacingName: () => 'Think',
18
- description: async () => DESCRIPTION,
19
- inputSchema: thinkToolSchema,
20
- isEnabled: async () =>
21
- Boolean(process.env.THINK_TOOL) && (await checkGate('tengu_think_tool')),
22
- isReadOnly: () => true,
23
- isConcurrencySafe: () => true, // ThinkTool is read-only, safe for concurrent execution
24
- needsPermissions: () => false,
25
- prompt: async () => PROMPT,
26
-
27
- async *call(input, { messageId }) {
28
- logEvent('tengu_thinking', {
29
- messageId,
30
- thoughtLength: input.thought.length.toString(),
31
- method: 'tool',
32
- provider: USE_BEDROCK ? 'bedrock' : USE_VERTEX ? 'vertex' : '1p',
33
- })
34
-
35
- yield {
36
- type: 'result',
37
- resultForAssistant: 'Your thought has been logged.',
38
- data: { thought: input.thought },
39
- }
40
- },
41
-
42
- // This is never called -- it's special-cased in AssistantToolUseMessage
43
- renderToolUseMessage(input) {
44
- return input.thought
45
- },
46
-
47
- renderToolUseRejectedMessage() {
48
- return (
49
- <MessageResponse children={<Text color={getTheme().error}>Thought cancelled</Text>} />
50
- )
51
- },
52
-
53
- renderResultForAssistant: () => 'Your thought has been logged.',
54
- } satisfies Tool<typeof thinkToolSchema>
@@ -1,12 +0,0 @@
1
- export const DESCRIPTION =
2
- 'This is a no-op tool that logs a thought. It is inspired by the tau-bench think tool.'
3
- export const PROMPT = `Use the tool to think about something. It will not obtain new information or make any changes to the repository, but just log the thought. Use it when complex reasoning or brainstorming is needed.
4
-
5
- Common use cases:
6
- 1. When exploring a repository and discovering the source of a bug, call this tool to brainstorm several unique ways of fixing the bug, and assess which change(s) are likely to be simplest and most effective
7
- 2. After receiving test results, use this tool to brainstorm ways to fix failing tests
8
- 3. When planning a complex refactoring, use this tool to outline different approaches and their tradeoffs
9
- 4. When designing a new feature, use this tool to think through architecture decisions and implementation details
10
- 5. When debugging a complex issue, use this tool to organize your thoughts and hypotheses
11
-
12
- The tool simply logs your thought process for better transparency and does not execute any code or make changes.`