@shareai-lab/kode 1.0.71 → 1.0.73

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 (106) hide show
  1. package/README.md +142 -1
  2. package/README.zh-CN.md +47 -1
  3. package/package.json +5 -1
  4. package/src/ProjectOnboarding.tsx +47 -29
  5. package/src/Tool.ts +33 -4
  6. package/src/commands/agents.tsx +3401 -0
  7. package/src/commands/help.tsx +2 -2
  8. package/src/commands/resume.tsx +2 -1
  9. package/src/commands/terminalSetup.ts +4 -4
  10. package/src/commands.ts +3 -0
  11. package/src/components/ApproveApiKey.tsx +1 -1
  12. package/src/components/Config.tsx +10 -6
  13. package/src/components/ConsoleOAuthFlow.tsx +5 -4
  14. package/src/components/CustomSelect/select-option.tsx +28 -2
  15. package/src/components/CustomSelect/select.tsx +14 -5
  16. package/src/components/CustomSelect/theme.ts +45 -0
  17. package/src/components/Help.tsx +4 -4
  18. package/src/components/InvalidConfigDialog.tsx +1 -1
  19. package/src/components/LogSelector.tsx +1 -1
  20. package/src/components/MCPServerApprovalDialog.tsx +1 -1
  21. package/src/components/Message.tsx +2 -0
  22. package/src/components/ModelListManager.tsx +10 -6
  23. package/src/components/ModelSelector.tsx +201 -23
  24. package/src/components/ModelStatusDisplay.tsx +7 -5
  25. package/src/components/PromptInput.tsx +117 -87
  26. package/src/components/SentryErrorBoundary.ts +3 -3
  27. package/src/components/StickerRequestForm.tsx +16 -0
  28. package/src/components/StructuredDiff.tsx +36 -29
  29. package/src/components/TextInput.tsx +13 -0
  30. package/src/components/TodoItem.tsx +11 -0
  31. package/src/components/TrustDialog.tsx +1 -1
  32. package/src/components/messages/AssistantLocalCommandOutputMessage.tsx +5 -1
  33. package/src/components/messages/AssistantToolUseMessage.tsx +14 -4
  34. package/src/components/messages/TaskProgressMessage.tsx +32 -0
  35. package/src/components/messages/TaskToolMessage.tsx +58 -0
  36. package/src/components/permissions/FallbackPermissionRequest.tsx +2 -4
  37. package/src/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.tsx +1 -1
  38. package/src/components/permissions/FileEditPermissionRequest/FileEditToolDiff.tsx +5 -3
  39. package/src/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.tsx +1 -1
  40. package/src/components/permissions/FileWritePermissionRequest/FileWriteToolDiff.tsx +5 -3
  41. package/src/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.tsx +2 -4
  42. package/src/components/permissions/PermissionRequest.tsx +3 -5
  43. package/src/constants/macros.ts +2 -0
  44. package/src/constants/modelCapabilities.ts +179 -0
  45. package/src/constants/models.ts +90 -0
  46. package/src/constants/product.ts +1 -1
  47. package/src/context.ts +7 -7
  48. package/src/entrypoints/cli.tsx +23 -3
  49. package/src/entrypoints/mcp.ts +10 -10
  50. package/src/hooks/useCanUseTool.ts +1 -1
  51. package/src/hooks/useTextInput.ts +5 -2
  52. package/src/hooks/useUnifiedCompletion.ts +1404 -0
  53. package/src/messages.ts +1 -0
  54. package/src/query.ts +3 -0
  55. package/src/screens/ConfigureNpmPrefix.tsx +1 -1
  56. package/src/screens/Doctor.tsx +1 -1
  57. package/src/screens/REPL.tsx +15 -9
  58. package/src/services/adapters/base.ts +38 -0
  59. package/src/services/adapters/chatCompletions.ts +90 -0
  60. package/src/services/adapters/responsesAPI.ts +170 -0
  61. package/src/services/claude.ts +198 -62
  62. package/src/services/customCommands.ts +43 -22
  63. package/src/services/gpt5ConnectionTest.ts +340 -0
  64. package/src/services/mcpClient.ts +1 -1
  65. package/src/services/mentionProcessor.ts +273 -0
  66. package/src/services/modelAdapterFactory.ts +69 -0
  67. package/src/services/openai.ts +521 -12
  68. package/src/services/responseStateManager.ts +90 -0
  69. package/src/services/systemReminder.ts +113 -12
  70. package/src/test/testAdapters.ts +96 -0
  71. package/src/tools/AskExpertModelTool/AskExpertModelTool.tsx +120 -56
  72. package/src/tools/BashTool/BashTool.tsx +4 -31
  73. package/src/tools/BashTool/BashToolResultMessage.tsx +1 -1
  74. package/src/tools/BashTool/OutputLine.tsx +1 -0
  75. package/src/tools/FileEditTool/FileEditTool.tsx +4 -5
  76. package/src/tools/FileReadTool/FileReadTool.tsx +43 -10
  77. package/src/tools/MCPTool/MCPTool.tsx +2 -1
  78. package/src/tools/MultiEditTool/MultiEditTool.tsx +2 -2
  79. package/src/tools/NotebookReadTool/NotebookReadTool.tsx +15 -23
  80. package/src/tools/StickerRequestTool/StickerRequestTool.tsx +1 -1
  81. package/src/tools/TaskTool/TaskTool.tsx +170 -86
  82. package/src/tools/TaskTool/prompt.ts +61 -25
  83. package/src/tools/ThinkTool/ThinkTool.tsx +1 -3
  84. package/src/tools/TodoWriteTool/TodoWriteTool.tsx +11 -10
  85. package/src/tools/lsTool/lsTool.tsx +5 -2
  86. package/src/tools.ts +16 -16
  87. package/src/types/conversation.ts +51 -0
  88. package/src/types/logs.ts +58 -0
  89. package/src/types/modelCapabilities.ts +64 -0
  90. package/src/types/notebook.ts +87 -0
  91. package/src/utils/advancedFuzzyMatcher.ts +290 -0
  92. package/src/utils/agentLoader.ts +284 -0
  93. package/src/utils/ask.tsx +1 -0
  94. package/src/utils/commands.ts +1 -1
  95. package/src/utils/commonUnixCommands.ts +161 -0
  96. package/src/utils/config.ts +173 -2
  97. package/src/utils/conversationRecovery.ts +1 -0
  98. package/src/utils/debugLogger.ts +13 -13
  99. package/src/utils/exampleCommands.ts +1 -0
  100. package/src/utils/fuzzyMatcher.ts +328 -0
  101. package/src/utils/messages.tsx +6 -5
  102. package/src/utils/responseState.ts +23 -0
  103. package/src/utils/secureFile.ts +559 -0
  104. package/src/utils/terminal.ts +1 -0
  105. package/src/utils/theme.ts +11 -0
  106. 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
 
@@ -136,7 +136,7 @@ export const TodoWriteTool = {
136
136
  renderToolUseRejectedMessage() {
137
137
  return <FallbackToolUseRejectedMessage />
138
138
  },
139
- renderToolResultMessage(output, { verbose }) {
139
+ renderToolResultMessage(output) {
140
140
  const isError = typeof output === 'string' && output.startsWith('Error')
141
141
 
142
142
  // If output contains todo data, render simple checkbox list
@@ -174,14 +174,15 @@ export const TodoWriteTool = {
174
174
  const text_color = status_color_map[todo.status]
175
175
 
176
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}
184
- </Text>
177
+ <React.Fragment key={todo.id || index}>
178
+ <Text
179
+ color={text_color}
180
+ bold={todo.status !== 'pending'}
181
+ strikethrough={todo.status === 'completed'}
182
+ >
183
+ {checkbox} {todo.content}
184
+ </Text>
185
+ </React.Fragment>
185
186
  )
186
187
  })}
187
188
  </Box>
@@ -263,7 +264,7 @@ export const TodoWriteTool = {
263
264
 
264
265
  yield {
265
266
  type: 'result',
266
- data: resultData,
267
+ data: summary, // Return string instead of object to match interface
267
268
  resultForAssistant: summary,
268
269
  }
269
270
  } catch (error) {
@@ -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
+ }