@shareai-lab/kode 1.0.71 → 1.0.75

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 (108) hide show
  1. package/README.md +160 -1
  2. package/README.zh-CN.md +65 -1
  3. package/cli.js +5 -10
  4. package/package.json +6 -2
  5. package/src/ProjectOnboarding.tsx +47 -29
  6. package/src/Tool.ts +33 -4
  7. package/src/commands/agents.tsx +3401 -0
  8. package/src/commands/help.tsx +2 -2
  9. package/src/commands/resume.tsx +2 -1
  10. package/src/commands/terminalSetup.ts +4 -4
  11. package/src/commands.ts +3 -0
  12. package/src/components/ApproveApiKey.tsx +1 -1
  13. package/src/components/Config.tsx +10 -6
  14. package/src/components/ConsoleOAuthFlow.tsx +5 -4
  15. package/src/components/CustomSelect/select-option.tsx +28 -2
  16. package/src/components/CustomSelect/select.tsx +14 -5
  17. package/src/components/CustomSelect/theme.ts +45 -0
  18. package/src/components/Help.tsx +4 -4
  19. package/src/components/InvalidConfigDialog.tsx +1 -1
  20. package/src/components/LogSelector.tsx +1 -1
  21. package/src/components/MCPServerApprovalDialog.tsx +1 -1
  22. package/src/components/Message.tsx +2 -0
  23. package/src/components/ModelListManager.tsx +10 -6
  24. package/src/components/ModelSelector.tsx +201 -23
  25. package/src/components/ModelStatusDisplay.tsx +7 -5
  26. package/src/components/PromptInput.tsx +146 -96
  27. package/src/components/SentryErrorBoundary.ts +9 -3
  28. package/src/components/StickerRequestForm.tsx +16 -0
  29. package/src/components/StructuredDiff.tsx +36 -29
  30. package/src/components/TextInput.tsx +13 -0
  31. package/src/components/TodoItem.tsx +47 -0
  32. package/src/components/TrustDialog.tsx +1 -1
  33. package/src/components/messages/AssistantLocalCommandOutputMessage.tsx +5 -1
  34. package/src/components/messages/AssistantToolUseMessage.tsx +14 -4
  35. package/src/components/messages/TaskProgressMessage.tsx +32 -0
  36. package/src/components/messages/TaskToolMessage.tsx +58 -0
  37. package/src/components/permissions/FallbackPermissionRequest.tsx +2 -4
  38. package/src/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.tsx +1 -1
  39. package/src/components/permissions/FileEditPermissionRequest/FileEditToolDiff.tsx +5 -3
  40. package/src/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.tsx +1 -1
  41. package/src/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.tsx +5 -3
  42. package/src/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.tsx +2 -4
  43. package/src/components/permissions/PermissionRequest.tsx +3 -5
  44. package/src/constants/macros.ts +2 -0
  45. package/src/constants/modelCapabilities.ts +179 -0
  46. package/src/constants/models.ts +90 -0
  47. package/src/constants/product.ts +1 -1
  48. package/src/context.ts +7 -7
  49. package/src/entrypoints/cli.tsx +23 -3
  50. package/src/entrypoints/mcp.ts +10 -10
  51. package/src/hooks/useCanUseTool.ts +1 -1
  52. package/src/hooks/useTextInput.ts +5 -2
  53. package/src/hooks/useUnifiedCompletion.ts +1405 -0
  54. package/src/messages.ts +1 -0
  55. package/src/query.ts +3 -0
  56. package/src/screens/ConfigureNpmPrefix.tsx +1 -1
  57. package/src/screens/Doctor.tsx +1 -1
  58. package/src/screens/REPL.tsx +11 -12
  59. package/src/services/adapters/base.ts +38 -0
  60. package/src/services/adapters/chatCompletions.ts +90 -0
  61. package/src/services/adapters/responsesAPI.ts +170 -0
  62. package/src/services/claude.ts +198 -62
  63. package/src/services/customCommands.ts +43 -22
  64. package/src/services/gpt5ConnectionTest.ts +340 -0
  65. package/src/services/mcpClient.ts +1 -1
  66. package/src/services/mentionProcessor.ts +273 -0
  67. package/src/services/modelAdapterFactory.ts +69 -0
  68. package/src/services/openai.ts +534 -14
  69. package/src/services/responseStateManager.ts +90 -0
  70. package/src/services/systemReminder.ts +113 -12
  71. package/src/test/testAdapters.ts +96 -0
  72. package/src/tools/AskExpertModelTool/AskExpertModelTool.tsx +120 -56
  73. package/src/tools/BashTool/BashTool.tsx +4 -31
  74. package/src/tools/BashTool/BashToolResultMessage.tsx +1 -1
  75. package/src/tools/BashTool/OutputLine.tsx +1 -0
  76. package/src/tools/FileEditTool/FileEditTool.tsx +4 -5
  77. package/src/tools/FileReadTool/FileReadTool.tsx +43 -10
  78. package/src/tools/MCPTool/MCPTool.tsx +2 -1
  79. package/src/tools/MultiEditTool/MultiEditTool.tsx +2 -2
  80. package/src/tools/NotebookReadTool/NotebookReadTool.tsx +15 -23
  81. package/src/tools/StickerRequestTool/StickerRequestTool.tsx +1 -1
  82. package/src/tools/TaskTool/TaskTool.tsx +170 -86
  83. package/src/tools/TaskTool/prompt.ts +61 -25
  84. package/src/tools/ThinkTool/ThinkTool.tsx +1 -3
  85. package/src/tools/TodoWriteTool/TodoWriteTool.tsx +65 -41
  86. package/src/tools/lsTool/lsTool.tsx +5 -2
  87. package/src/tools.ts +16 -16
  88. package/src/types/conversation.ts +51 -0
  89. package/src/types/logs.ts +58 -0
  90. package/src/types/modelCapabilities.ts +64 -0
  91. package/src/types/notebook.ts +87 -0
  92. package/src/utils/advancedFuzzyMatcher.ts +290 -0
  93. package/src/utils/agentLoader.ts +284 -0
  94. package/src/utils/ask.tsx +1 -0
  95. package/src/utils/commands.ts +1 -1
  96. package/src/utils/commonUnixCommands.ts +161 -0
  97. package/src/utils/config.ts +173 -2
  98. package/src/utils/conversationRecovery.ts +1 -0
  99. package/src/utils/debugLogger.ts +13 -13
  100. package/src/utils/exampleCommands.ts +1 -0
  101. package/src/utils/fuzzyMatcher.ts +328 -0
  102. package/src/utils/messages.tsx +6 -5
  103. package/src/utils/model.ts +120 -42
  104. package/src/utils/responseState.ts +23 -0
  105. package/src/utils/secureFile.ts +559 -0
  106. package/src/utils/terminal.ts +1 -0
  107. package/src/utils/theme.ts +11 -0
  108. package/src/hooks/useSlashCommandTypeahead.ts +0 -137
@@ -8,6 +8,7 @@ import { NotebookEditTool } from '../NotebookEditTool/NotebookEditTool'
8
8
  import { GlobTool } from '../GlobTool/GlobTool'
9
9
  import { FileReadTool } from '../FileReadTool/FileReadTool'
10
10
  import { getModelManager } from '../../utils/model'
11
+ import { getActiveAgents } from '../../utils/agentLoader'
11
12
 
12
13
  export async function getTaskTools(safeMode: boolean): Promise<Tool[]> {
13
14
  // No recursive tasks, yet..
@@ -17,40 +18,75 @@ export async function getTaskTools(safeMode: boolean): Promise<Tool[]> {
17
18
  }
18
19
 
19
20
  export async function getPrompt(safeMode: boolean): Promise<string> {
20
- const tools = await getTaskTools(safeMode)
21
- const toolNames = tools.map(_ => _.name).join(', ')
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.
22
34
 
23
- // Add dynamic model information for Task tool prompts
24
- const modelManager = getModelManager()
25
- const availableModels = modelManager.getAllAvailableModelNames()
26
- const currentTaskModel =
27
- modelManager.getModelName('task') || '<Not configured>'
35
+ Available agent types and the tools they have access to:
36
+ ${agentDescriptions}
28
37
 
29
- const modelInfo =
30
- availableModels.length > 0
31
- ? `
38
+ When using the Task tool, you must specify a subagent_type parameter to select which agent type to use.
32
39
 
33
- Available models for Task tool: ${availableModels.join(', ')}
34
- Default task model: ${currentTaskModel}
35
- Specify model_name parameter to use a specific model for the task.`
36
- : ''
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")
37
42
 
38
- return `Launch a new agent that has access to the following tools: ${toolNames}. When you are searching for a keyword or file and are not confident that you will find the right match in the first few tries, use the Task tool to perform the search for you.${modelInfo}
39
-
40
- When to use the Task tool:
41
- - If you are searching for a keyword like "config" or "logger", or for questions like "which file does X?", the Task tool is strongly recommended
42
-
43
- When NOT to use the Task tool:
44
- - If you want to read a specific file path, use the ${FileReadTool.name} or ${GlobTool.name} tool instead of the Task tool, to find the match more quickly
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
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 Read tool instead of the Task tool, to find the match more quickly
47
- - Writing code and running bash commands (use other tools for that)
48
- - Other tasks that are not related to searching for a keyword or file
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
49
48
 
50
49
  Usage notes:
51
50
  1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
52
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.
53
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.
54
53
  4. The agent's outputs should generally be trusted
55
- 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`
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>`
56
92
  }
@@ -46,9 +46,7 @@ export const ThinkTool = {
46
46
 
47
47
  renderToolUseRejectedMessage() {
48
48
  return (
49
- <MessageResponse>
50
- <Text color={getTheme().error}>Thought cancelled</Text>
51
- </MessageResponse>
49
+ <MessageResponse children={<Text color={getTheme().error}>Thought cancelled</Text>} />
52
50
  )
53
51
  },
54
52
 
@@ -110,7 +110,7 @@ export const TodoWriteTool = {
110
110
  },
111
111
  inputSchema,
112
112
  userFacingName() {
113
- return 'Write Todos'
113
+ return 'Update Todos'
114
114
  },
115
115
  async isEnabled() {
116
116
  return true
@@ -129,22 +129,32 @@ export const TodoWriteTool = {
129
129
  return 'Todos have been modified successfully. Ensure that you continue to use the todo list to track your progress. Please proceed with the current tasks if applicable'
130
130
  },
131
131
  renderToolUseMessage(input, { verbose }) {
132
- // Return empty string to match reference implementation and avoid double rendering
133
- // The tool result message will show the todo list
134
- return ''
132
+ // Show a simple confirmation message when the tool is being used
133
+ return '{ params.todo }'
135
134
  },
136
135
  renderToolUseRejectedMessage() {
137
136
  return <FallbackToolUseRejectedMessage />
138
137
  },
139
- renderToolResultMessage(output, { verbose }) {
138
+ renderToolResultMessage(output) {
140
139
  const isError = typeof output === 'string' && output.startsWith('Error')
141
140
 
142
- // If output contains todo data, render simple checkbox list
143
- if (typeof output === 'object' && output && 'newTodos' in output) {
144
- const { newTodos = [] } = output as any
141
+ // For non-error output, get current todos from storage and render them
142
+ if (!isError && typeof output === 'string') {
143
+ const currentTodos = getTodos()
144
+
145
+ if (currentTodos.length === 0) {
146
+ return (
147
+ <Box flexDirection="column" width="100%">
148
+ <Box flexDirection="row">
149
+ <Text color="#6B7280">&nbsp;&nbsp;⎿ &nbsp;</Text>
150
+ <Text color="#9CA3AF">No todos currently</Text>
151
+ </Box>
152
+ </Box>
153
+ )
154
+ }
145
155
 
146
- // sort: [completed, in_progress, pending]
147
- newTodos.sort((a, b) => {
156
+ // Sort: [completed, in_progress, pending]
157
+ const sortedTodos = [...currentTodos].sort((a, b) => {
148
158
  const order = ['completed', 'in_progress', 'pending']
149
159
  return (
150
160
  order.indexOf(a.status) - order.indexOf(b.status) ||
@@ -152,40 +162,52 @@ export const TodoWriteTool = {
152
162
  )
153
163
  })
154
164
 
155
- // Render each todo item with proper styling
165
+ // Find the next pending task (first pending task after sorting)
166
+ const nextPendingIndex = sortedTodos.findIndex(todo => todo.status === 'pending')
167
+
156
168
  return (
157
- <Box justifyContent="space-between" overflowX="hidden" width="100%">
158
- <Box flexDirection="row">
159
- <Text>&nbsp;&nbsp;⎿ &nbsp;</Text>
160
- <Box flexDirection="column">
161
- {newTodos.map((todo: TodoItem, index: number) => {
162
- const status_icon_map = {
163
- completed: '🟢',
164
- in_progress: '🟢',
165
- pending: '🟡',
166
- }
167
- const checkbox = status_icon_map[todo.status]
169
+ <Box flexDirection="column" width="100%">
170
+ {sortedTodos.map((todo: TodoItem, index: number) => {
171
+ // Determine checkbox symbol and colors
172
+ let checkbox: string
173
+ let textColor: string
174
+ let isBold = false
175
+ let isStrikethrough = false
168
176
 
169
- const status_color_map = {
170
- completed: '#008000',
171
- in_progress: '#008000',
172
- pending: '#FFD700',
173
- }
174
- const text_color = status_color_map[todo.status]
177
+ if (todo.status === 'completed') {
178
+ checkbox = ''
179
+ textColor = '#6B7280' // Professional gray for completed
180
+ isStrikethrough = true
181
+ } else if (todo.status === 'in_progress') {
182
+ checkbox = '☐'
183
+ textColor = '#10B981' // Professional green for in progress
184
+ isBold = true
185
+ } else if (todo.status === 'pending') {
186
+ checkbox = '☐'
187
+ // Only the FIRST pending task gets purple highlight
188
+ if (index === nextPendingIndex) {
189
+ textColor = '#8B5CF6' // Professional purple for next pending
190
+ isBold = true
191
+ } else {
192
+ textColor = '#9CA3AF' // Muted gray for other pending
193
+ }
194
+ }
175
195
 
176
- return (
177
- <Text
178
- key={todo.id || index}
179
- color={text_color}
180
- bold={todo.status !== 'pending'}
181
- strikethrough={todo.status === 'completed'}
182
- >
183
- {checkbox} {todo.content}
196
+ return (
197
+ <Box key={todo.id || index} flexDirection="row" marginBottom={0}>
198
+ <Text color="#6B7280">&nbsp;&nbsp;⎿ &nbsp;</Text>
199
+ <Box flexDirection="row" flexGrow={1}>
200
+ <Text color={textColor} bold={isBold} strikethrough={isStrikethrough}>
201
+ {checkbox}
184
202
  </Text>
185
- )
186
- })}
187
- </Box>
188
- </Box>
203
+ <Text> </Text>
204
+ <Text color={textColor} bold={isBold} strikethrough={isStrikethrough}>
205
+ {todo.content}
206
+ </Text>
207
+ </Box>
208
+ </Box>
209
+ )
210
+ })}
189
211
  </Box>
190
212
  )
191
213
  }
@@ -263,8 +285,10 @@ export const TodoWriteTool = {
263
285
 
264
286
  yield {
265
287
  type: 'result',
266
- data: resultData,
288
+ data: summary, // Return string to satisfy interface
267
289
  resultForAssistant: summary,
290
+ // Store todo data in a way accessible to the renderer
291
+ // We'll modify the renderToolResultMessage to get todos from storage
268
292
  }
269
293
  } catch (error) {
270
294
  const errorMessage =
@@ -63,7 +63,8 @@ export const LSTool = {
63
63
  renderToolUseRejectedMessage() {
64
64
  return <FallbackToolUseRejectedMessage />
65
65
  },
66
- renderToolResultMessage(content, { verbose }) {
66
+ renderToolResultMessage(content) {
67
+ const verbose = false // Set default value for verbose
67
68
  if (typeof content !== 'string') {
68
69
  return null
69
70
  }
@@ -81,7 +82,9 @@ export const LSTool = {
81
82
  .filter(_ => _.trim() !== '')
82
83
  .slice(0, verbose ? undefined : MAX_LINES)
83
84
  .map((_, i) => (
84
- <Text key={i}>{_}</Text>
85
+ <React.Fragment key={i}>
86
+ <Text>{_}</Text>
87
+ </React.Fragment>
85
88
  ))}
86
89
  {!verbose && result.split('\n').length > MAX_LINES && (
87
90
  <Text color={getTheme().secondaryText}>
package/src/tools.ts CHANGED
@@ -19,25 +19,25 @@ import { TodoWriteTool } from './tools/TodoWriteTool/TodoWriteTool'
19
19
  import { getMCPTools } from './services/mcpClient'
20
20
  import { memoize } from 'lodash-es'
21
21
 
22
- const ANT_ONLY_TOOLS = [MemoryReadTool, MemoryWriteTool]
22
+ const ANT_ONLY_TOOLS = [MemoryReadTool as unknown as Tool, MemoryWriteTool as unknown as Tool]
23
23
 
24
24
  // Function to avoid circular dependencies that break bun
25
25
  export const getAllTools = (): Tool[] => {
26
26
  return [
27
- TaskTool,
28
- AskExpertModelTool,
29
- BashTool,
30
- GlobTool,
31
- GrepTool,
32
- LSTool,
33
- FileReadTool,
34
- FileEditTool,
35
- MultiEditTool,
36
- FileWriteTool,
37
- NotebookReadTool,
38
- NotebookEditTool,
39
- ThinkTool,
40
- TodoWriteTool,
27
+ TaskTool as unknown as Tool,
28
+ AskExpertModelTool as unknown as Tool,
29
+ BashTool as unknown as Tool,
30
+ GlobTool as unknown as Tool,
31
+ GrepTool as unknown as Tool,
32
+ LSTool as unknown as Tool,
33
+ FileReadTool as unknown as Tool,
34
+ FileEditTool as unknown as Tool,
35
+ MultiEditTool as unknown as Tool,
36
+ FileWriteTool as unknown as Tool,
37
+ NotebookReadTool as unknown as Tool,
38
+ NotebookEditTool as unknown as Tool,
39
+ ThinkTool as unknown as Tool,
40
+ TodoWriteTool as unknown as Tool,
41
41
  ...ANT_ONLY_TOOLS,
42
42
  ]
43
43
  }
@@ -48,7 +48,7 @@ export const getTools = memoize(
48
48
 
49
49
  // Only include Architect tool if enabled via config or CLI flag
50
50
  if (enableArchitect) {
51
- tools.push(ArchitectTool)
51
+ tools.push(ArchitectTool as unknown as Tool)
52
52
  }
53
53
 
54
54
  const isEnabled = await Promise.all(tools.map(tool => tool.isEnabled()))
@@ -0,0 +1,51 @@
1
+ // Type definitions for conversation and message functionality
2
+ // Used by debugLogger and other conversation-related utilities
3
+
4
+ import { UUID } from 'crypto'
5
+ import type { MessageParam } from '@anthropic-ai/sdk/resources/index.mjs'
6
+ import type { Message as APIAssistantMessage } from '@anthropic-ai/sdk/resources/index.mjs'
7
+
8
+ /**
9
+ * Base message interface used throughout the conversation system
10
+ * This is a union type that matches the Message type from query.ts
11
+ */
12
+ export type Message = UserMessage | AssistantMessage | ProgressMessage
13
+
14
+ /**
15
+ * User message structure
16
+ */
17
+ export interface UserMessage {
18
+ message: MessageParam
19
+ type: 'user'
20
+ uuid: UUID
21
+ toolUseResult?: any // FullToolUseResult type
22
+ options?: {
23
+ isKodingRequest?: boolean
24
+ kodingContext?: string
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Assistant message structure
30
+ */
31
+ export interface AssistantMessage {
32
+ costUSD: number
33
+ durationMs: number
34
+ message: APIAssistantMessage
35
+ type: 'assistant'
36
+ uuid: UUID
37
+ isApiErrorMessage?: boolean
38
+ }
39
+
40
+ /**
41
+ * Progress message structure for tool execution
42
+ */
43
+ export interface ProgressMessage {
44
+ content: AssistantMessage
45
+ normalizedMessages: any[] // NormalizedMessage type
46
+ siblingToolUseIDs: Set<string>
47
+ tools: any[] // Tool type
48
+ toolUseID: string
49
+ type: 'progress'
50
+ uuid: UUID
51
+ }
@@ -0,0 +1,58 @@
1
+ // Type definitions for log-related functionality
2
+ // Used by log selector, log list, and log utilities
3
+
4
+ import { UUID } from 'crypto'
5
+
6
+ /**
7
+ * Serialized message structure stored in log files
8
+ * Based on how messages are serialized and deserialized in log.ts
9
+ */
10
+ export interface SerializedMessage {
11
+ type: 'user' | 'assistant' | 'progress'
12
+ uuid: UUID
13
+ message?: {
14
+ content: string | Array<{ type: string; text?: string }>
15
+ role: 'user' | 'assistant' | 'system'
16
+ }
17
+ costUSD?: number
18
+ durationMs?: number
19
+ timestamp: string
20
+ cwd?: string
21
+ userType?: string
22
+ sessionId?: string
23
+ version?: string
24
+ }
25
+
26
+ /**
27
+ * Log option representing a single conversation log
28
+ * Used by LogSelector and LogList components
29
+ */
30
+ export interface LogOption {
31
+ // File metadata
32
+ date: string
33
+ fullPath: string
34
+ value: number // Index in the logs array
35
+
36
+ // Timestamps for sorting
37
+ created: Date
38
+ modified: Date
39
+
40
+ // Content metadata
41
+ firstPrompt: string
42
+ messageCount: number
43
+ messages: SerializedMessage[]
44
+
45
+ // Fork and branch info
46
+ forkNumber?: number
47
+ sidechainNumber?: number
48
+ }
49
+
50
+ /**
51
+ * Props for LogList component
52
+ * Used by LogList.tsx
53
+ */
54
+ export interface LogListProps {
55
+ context: {
56
+ unmount?: () => void
57
+ }
58
+ }
@@ -0,0 +1,64 @@
1
+ // Model capability type definitions for unified API support
2
+ export interface ModelCapabilities {
3
+ // API architecture type
4
+ apiArchitecture: {
5
+ primary: 'chat_completions' | 'responses_api'
6
+ fallback?: 'chat_completions' // Responses API models can fallback
7
+ }
8
+
9
+ // Parameter mapping
10
+ parameters: {
11
+ maxTokensField: 'max_tokens' | 'max_completion_tokens'
12
+ supportsReasoningEffort: boolean
13
+ supportsVerbosity: boolean
14
+ temperatureMode: 'flexible' | 'fixed_one' | 'restricted'
15
+ }
16
+
17
+ // Tool calling capabilities
18
+ toolCalling: {
19
+ mode: 'none' | 'function_calling' | 'custom_tools'
20
+ supportsFreeform: boolean
21
+ supportsAllowedTools: boolean
22
+ supportsParallelCalls: boolean
23
+ }
24
+
25
+ // State management
26
+ stateManagement: {
27
+ supportsResponseId: boolean
28
+ supportsConversationChaining: boolean
29
+ supportsPreviousResponseId: boolean
30
+ }
31
+
32
+ // Streaming support
33
+ streaming: {
34
+ supported: boolean
35
+ includesUsage: boolean
36
+ }
37
+ }
38
+
39
+ // Unified request parameters
40
+ export interface UnifiedRequestParams {
41
+ messages: any[]
42
+ systemPrompt: string[]
43
+ tools?: any[]
44
+ maxTokens: number
45
+ stream?: boolean
46
+ previousResponseId?: string
47
+ reasoningEffort?: 'minimal' | 'low' | 'medium' | 'high'
48
+ verbosity?: 'low' | 'medium' | 'high'
49
+ temperature?: number
50
+ allowedTools?: string[]
51
+ }
52
+
53
+ // Unified response format
54
+ export interface UnifiedResponse {
55
+ id: string
56
+ content: string
57
+ toolCalls?: any[]
58
+ usage: {
59
+ promptTokens: number
60
+ completionTokens: number
61
+ reasoningTokens?: number
62
+ }
63
+ responseId?: string // For Responses API state management
64
+ }
@@ -0,0 +1,87 @@
1
+ // Type definitions for Jupyter notebook functionality
2
+ // Used by NotebookReadTool and NotebookEditTool
3
+
4
+ /**
5
+ * Valid notebook cell types
6
+ */
7
+ export type NotebookCellType = 'code' | 'markdown'
8
+
9
+ /**
10
+ * Notebook output image structure
11
+ */
12
+ export interface NotebookOutputImage {
13
+ image_data: string
14
+ media_type: 'image/png' | 'image/jpeg'
15
+ }
16
+
17
+ /**
18
+ * Processed notebook cell output for display
19
+ */
20
+ export interface NotebookCellSourceOutput {
21
+ output_type: 'stream' | 'execute_result' | 'display_data' | 'error'
22
+ text?: string
23
+ image?: NotebookOutputImage
24
+ }
25
+
26
+ /**
27
+ * Processed notebook cell structure used by tools
28
+ */
29
+ export interface NotebookCellSource {
30
+ cell: number // Cell index
31
+ cellType: NotebookCellType
32
+ source: string
33
+ language: string
34
+ execution_count?: number | null
35
+ outputs?: NotebookCellSourceOutput[]
36
+ }
37
+
38
+ /**
39
+ * Raw notebook cell output from .ipynb file
40
+ */
41
+ export interface NotebookCellOutput {
42
+ output_type: 'stream' | 'execute_result' | 'display_data' | 'error'
43
+ name?: string
44
+ text?: string | string[]
45
+ data?: Record<string, unknown>
46
+ execution_count?: number | null
47
+ metadata?: Record<string, unknown>
48
+ // For error outputs
49
+ ename?: string
50
+ evalue?: string
51
+ traceback?: string[]
52
+ }
53
+
54
+ /**
55
+ * Raw notebook cell structure from .ipynb file
56
+ */
57
+ export interface NotebookCell {
58
+ cell_type: NotebookCellType
59
+ source: string | string[]
60
+ metadata: Record<string, unknown>
61
+ execution_count?: number | null
62
+ outputs?: NotebookCellOutput[]
63
+ id?: string
64
+ }
65
+
66
+ /**
67
+ * Complete notebook structure from .ipynb file
68
+ */
69
+ export interface NotebookContent {
70
+ cells: NotebookCell[]
71
+ metadata: {
72
+ kernelspec?: {
73
+ display_name?: string
74
+ language?: string
75
+ name?: string
76
+ }
77
+ language_info?: {
78
+ name?: string
79
+ version?: string
80
+ mimetype?: string
81
+ file_extension?: string
82
+ }
83
+ [key: string]: unknown
84
+ }
85
+ nbformat: number
86
+ nbformat_minor: number
87
+ }