@allternit/gizzi-code 1.0.0 → 1.0.1

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 (158) hide show
  1. package/bin/gizzi +4 -0
  2. package/bin/gizzi-ink +5 -0
  3. package/package.json +137 -31
  4. package/src/Tool.ts +26 -0
  5. package/src/bootstrap/state.ts +165 -322
  6. package/src/commands.ts +209 -0
  7. package/src/context/QueuedMessageContext.tsx +63 -0
  8. package/src/context/fpsMetrics.tsx +30 -0
  9. package/src/context/mailbox.tsx +38 -0
  10. package/src/context/modalContext.tsx +58 -0
  11. package/src/context/notifications.tsx +240 -0
  12. package/src/context/overlayContext.tsx +151 -0
  13. package/src/context/promptOverlayContext.tsx +125 -0
  14. package/src/context/stats.tsx +220 -0
  15. package/src/context/voice.tsx +88 -0
  16. package/src/hooks/useCanUseTool.ts +11 -0
  17. package/src/hooks/useExitOnCtrlCD.ts +40 -187
  18. package/src/hooks/useExitOnCtrlCDWithKeybindings.ts +68 -0
  19. package/src/hooks/useKeybinding.ts +68 -209
  20. package/src/hooks/useTerminalSize.ts +31 -99
  21. package/src/hooks.ts +37 -0
  22. package/src/ink.ts +204 -0
  23. package/src/main.ts +7 -0
  24. package/src/types/command.ts +216 -0
  25. package/src/types/connectorText.ts +39 -0
  26. package/src/types/fileSuggestion.ts +15 -0
  27. package/src/types/generated/events_mono/claude_code/v1/claude_code_internal_event.ts +865 -0
  28. package/src/types/generated/events_mono/common/v1/auth.ts +100 -0
  29. package/src/types/generated/events_mono/growthbook/v1/growthbook_experiment_event.ts +223 -0
  30. package/src/types/generated/google/protobuf/timestamp.ts +187 -0
  31. package/src/types/hooks.ts +319 -0
  32. package/src/types/ids.ts +44 -0
  33. package/src/types/logs.ts +331 -0
  34. package/src/types/merged/index.ts +5 -0
  35. package/src/types/merged/message.ts +552 -0
  36. package/src/types/message.ts +927 -186
  37. package/src/types/messageQueueTypes.ts +21 -0
  38. package/src/types/notebook.ts +72 -0
  39. package/src/types/permissions.ts +447 -0
  40. package/src/types/plugin.ts +363 -0
  41. package/src/types/statusLine.ts +15 -0
  42. package/src/types/textInputTypes.ts +387 -0
  43. package/src/types/tools.ts +149 -0
  44. package/src/types/utils.ts +20 -0
  45. package/src/utils/advisor.ts +12 -0
  46. package/src/utils/api.ts +29 -0
  47. package/src/utils/array.ts +7 -0
  48. package/src/utils/attachments.ts +60 -0
  49. package/src/utils/auth.ts +3 -0
  50. package/src/utils/claudeInChrome/chromeNativeHost.ts +15 -0
  51. package/src/utils/claudeInChrome/common.ts +12 -0
  52. package/src/utils/claudeInChrome/mcpServer.ts +15 -0
  53. package/src/utils/computerUse/common.ts +19 -0
  54. package/src/utils/computerUse/mcpServer.ts +15 -0
  55. package/src/utils/config.ts +35 -0
  56. package/src/utils/context.ts +19 -0
  57. package/src/utils/cwd.ts +3 -0
  58. package/src/utils/debug.ts +3 -0
  59. package/src/utils/earlyInput.ts +7 -0
  60. package/src/utils/effort.ts +13 -0
  61. package/src/utils/embeddedTools.ts +12 -0
  62. package/src/utils/envUtils.ts +3 -0
  63. package/src/utils/errors.ts +3 -0
  64. package/src/utils/execFileNoThrow.ts +24 -0
  65. package/src/utils/feature-flags.ts +112 -0
  66. package/src/utils/file.ts +3 -0
  67. package/src/utils/fileHistory.ts +17 -0
  68. package/src/utils/fingerprint.ts +7 -0
  69. package/src/utils/format.ts +75 -305
  70. package/src/utils/frontmatterParser.ts +33 -0
  71. package/src/utils/fsOperations.ts +31 -0
  72. package/src/utils/fullscreen.ts +40 -350
  73. package/src/utils/git.ts +15 -0
  74. package/src/utils/imageResizer.ts +30 -0
  75. package/src/utils/lazySchema.ts +9 -0
  76. package/src/utils/log.ts +3 -0
  77. package/src/utils/markdownConfigLoader.ts +12 -0
  78. package/src/utils/messages.ts +13 -0
  79. package/src/utils/migration.ts +137 -0
  80. package/src/utils/model/providers.ts +15 -0
  81. package/src/utils/path.ts +3 -0
  82. package/src/utils/permissions/PermissionResult.ts +14 -0
  83. package/src/utils/permissions/autoModeState.ts +12 -0
  84. package/src/utils/permissions/filesystem.ts +12 -0
  85. package/src/utils/plugins/loadPluginOutputStyles.ts +12 -0
  86. package/src/utils/plugins/schemas.ts +25 -0
  87. package/src/utils/process.ts +16 -0
  88. package/src/utils/sandbox/sandbox-adapter.ts +19 -0
  89. package/src/utils/sessionStorage.ts +238 -472
  90. package/src/utils/settings/constants.ts +10 -0
  91. package/src/utils/settings/settings.ts +19 -0
  92. package/src/utils/settings/types.ts +18 -0
  93. package/src/utils/shell/shellToolUtils.ts +9 -0
  94. package/src/utils/sinks.ts +11 -0
  95. package/src/utils/sleep.ts +7 -0
  96. package/src/utils/sliceAnsi.ts +7 -0
  97. package/src/utils/slowOperations.ts +3 -0
  98. package/src/utils/startupProfiler.ts +11 -0
  99. package/src/utils/stringUtils.ts +106 -0
  100. package/src/utils/systemPromptType.ts +9 -0
  101. package/src/utils/teleport/api.ts +15 -0
  102. package/src/utils/textHighlighting.ts +16 -0
  103. package/src/utils/theme.ts +17 -0
  104. package/src/utils/thinking.ts +58 -0
  105. package/src/utils/tokens.ts +11 -0
  106. package/src/utils/toolResultStorage.ts +17 -0
  107. package/src/utils/worktreeModeEnabled.ts +7 -0
  108. package/WORKSPACE_INTEGRATION.md +0 -290
  109. package/chat-sessions/sessions-index.json +0 -98
  110. package/package.json.original +0 -31
  111. package/package.json.publish +0 -47
  112. package/src/bootstrap/state.d.ts +0 -169
  113. package/src/bootstrap/state.js +0 -261
  114. package/src/context/pack-builder.d.ts +0 -24
  115. package/src/context/pack-builder.js +0 -281
  116. package/src/hooks/useExitOnCtrlCD.d.ts +0 -86
  117. package/src/hooks/useExitOnCtrlCD.js +0 -130
  118. package/src/hooks/useKeybinding.d.ts +0 -89
  119. package/src/hooks/useKeybinding.js +0 -163
  120. package/src/hooks/useTerminalSize.d.ts +0 -41
  121. package/src/hooks/useTerminalSize.js +0 -90
  122. package/src/index.d.ts +0 -23
  123. package/src/index.js +0 -24
  124. package/src/runtime/brand/brand.d.ts +0 -488
  125. package/src/runtime/brand/brand.js +0 -464
  126. package/src/runtime/brand/brand.ts +0 -667
  127. package/src/runtime/services/tokenEstimation.d.ts +0 -187
  128. package/src/runtime/services/tokenEstimation.js +0 -423
  129. package/src/runtime/services/tokenEstimation.ts +0 -547
  130. package/src/runtime/tools/Tool.d.ts +0 -239
  131. package/src/runtime/tools/Tool.js +0 -285
  132. package/src/runtime/tools/Tool.ts +0 -524
  133. package/src/scheduler/TaskScheduler.d.ts +0 -98
  134. package/src/scheduler/TaskScheduler.js +0 -201
  135. package/src/scheduler/TaskScheduler.ts +0 -259
  136. package/src/state/AppStateStore.d.ts +0 -347
  137. package/src/state/AppStateStore.js +0 -439
  138. package/src/state/AppStateStore.ts +0 -658
  139. package/src/state/WorkspaceStateStore.d.ts +0 -43
  140. package/src/state/WorkspaceStateStore.js +0 -224
  141. package/src/state/WorkspaceStateStore.ts +0 -297
  142. package/src/types/message.d.ts +0 -190
  143. package/src/types/message.js +0 -77
  144. package/src/utils/format.d.ts +0 -126
  145. package/src/utils/format.js +0 -230
  146. package/src/utils/fullscreen.d.ts +0 -161
  147. package/src/utils/fullscreen.js +0 -277
  148. package/src/utils/sessionStorage.d.ts +0 -210
  149. package/src/utils/sessionStorage.js +0 -435
  150. package/src/watcher/WorkspaceWatcher.d.ts +0 -70
  151. package/src/watcher/WorkspaceWatcher.js +0 -191
  152. package/src/watcher/WorkspaceWatcher.ts +0 -251
  153. package/src/workspace/loader.d.ts +0 -30
  154. package/src/workspace/loader.js +0 -117
  155. package/src/workspace/types.d.ts +0 -91
  156. package/src/workspace/types.js +0 -7
  157. package/threads/thread_1775361175022.json +0 -9
  158. package/tsconfig.json +0 -14
@@ -0,0 +1,387 @@
1
+ import type { ContentBlockParam } from '@anthropic-ai/sdk/resources/messages.mjs'
2
+ type UUID = string
3
+ import type React from 'react'
4
+ import type { PermissionResult } from '../entrypoints/agentSdkTypes.js'
5
+ import type { Key } from '@/ink.js'
6
+ import type { PastedContent } from '../utils/config.js'
7
+ import type { ImageDimensions } from '../utils/imageResizer.js'
8
+ import type { TextHighlight } from '../utils/textHighlighting.js'
9
+ import type { AgentId } from './ids.js'
10
+ import type { AssistantMessage, MessageOrigin } from './message.js'
11
+
12
+ /**
13
+ * Inline ghost text for mid-input command autocomplete
14
+ */
15
+ export type InlineGhostText = {
16
+ /** The ghost text to display (e.g., "mit" for /commit) */
17
+ readonly text: string
18
+ /** The full command name (e.g., "commit") */
19
+ readonly fullCommand: string
20
+ /** Position in the input where the ghost text should appear */
21
+ readonly insertPosition: number
22
+ }
23
+
24
+ /**
25
+ * Base props for text input components
26
+ */
27
+ export type BaseTextInputProps = {
28
+ /**
29
+ * Optional callback for handling history navigation on up arrow at start of input
30
+ */
31
+ readonly onHistoryUp?: () => void
32
+
33
+ /**
34
+ * Optional callback for handling history navigation on down arrow at end of input
35
+ */
36
+ readonly onHistoryDown?: () => void
37
+
38
+ /**
39
+ * Text to display when `value` is empty.
40
+ */
41
+ readonly placeholder?: string
42
+
43
+ /**
44
+ * Allow multi-line input via line ending with backslash (default: `true`)
45
+ */
46
+ readonly multiline?: boolean
47
+
48
+ /**
49
+ * Listen to user's input. Useful in case there are multiple input components
50
+ * at the same time and input must be "routed" to a specific component.
51
+ */
52
+ readonly focus?: boolean
53
+
54
+ /**
55
+ * Replace all chars and mask the value. Useful for password inputs.
56
+ */
57
+ readonly mask?: string
58
+
59
+ /**
60
+ * Whether to show cursor and allow navigation inside text input with arrow keys.
61
+ */
62
+ readonly showCursor?: boolean
63
+
64
+ /**
65
+ * Highlight pasted text
66
+ */
67
+ readonly highlightPastedText?: boolean
68
+
69
+ /**
70
+ * Value to display in a text input.
71
+ */
72
+ readonly value: string
73
+
74
+ /**
75
+ * Function to call when value updates.
76
+ */
77
+ readonly onChange: (value: string) => void
78
+
79
+ /**
80
+ * Function to call when `Enter` is pressed, where first argument is a value of the input.
81
+ */
82
+ readonly onSubmit?: (value: string) => void
83
+
84
+ /**
85
+ * Function to call when Ctrl+C is pressed to exit.
86
+ */
87
+ readonly onExit?: () => void
88
+
89
+ /**
90
+ * Optional callback to show exit message
91
+ */
92
+ readonly onExitMessage?: (show: boolean, key?: string) => void
93
+
94
+ /**
95
+ * Optional callback to show custom message
96
+ */
97
+ // readonly onMessage?: (show: boolean, message?: string) => void
98
+
99
+ /**
100
+ * Optional callback to reset history position
101
+ */
102
+ readonly onHistoryReset?: () => void
103
+
104
+ /**
105
+ * Optional callback when input is cleared (e.g., double-escape)
106
+ */
107
+ readonly onClearInput?: () => void
108
+
109
+ /**
110
+ * Number of columns to wrap text at
111
+ */
112
+ readonly columns: number
113
+
114
+ /**
115
+ * Maximum visible lines for the input viewport. When the wrapped input
116
+ * exceeds this many lines, only lines around the cursor are rendered.
117
+ */
118
+ readonly maxVisibleLines?: number
119
+
120
+ /**
121
+ * Optional callback when an image is pasted
122
+ */
123
+ readonly onImagePaste?: (
124
+ base64Image: string,
125
+ mediaType?: string,
126
+ filename?: string,
127
+ dimensions?: ImageDimensions,
128
+ sourcePath?: string,
129
+ ) => void
130
+
131
+ /**
132
+ * Optional callback when a large text (over 800 chars) is pasted
133
+ */
134
+ readonly onPaste?: (text: string) => void
135
+
136
+ /**
137
+ * Callback when the pasting state changes
138
+ */
139
+ readonly onIsPastingChange?: (isPasting: boolean) => void
140
+
141
+ /**
142
+ * Whether to disable cursor movement for up/down arrow keys
143
+ */
144
+ readonly disableCursorMovementForUpDownKeys?: boolean
145
+
146
+ /**
147
+ * Skip the text-level double-press escape handler. Set this when a
148
+ * keybinding context (e.g. Autocomplete) owns escape — the keybinding's
149
+ * stopImmediatePropagation can't shield the text input because child
150
+ * effects register useInput listeners before parent effects.
151
+ */
152
+ readonly disableEscapeDoublePress?: boolean
153
+
154
+ /**
155
+ * The offset of the cursor within the text
156
+ */
157
+ readonly cursorOffset: number
158
+
159
+ /**
160
+ * Callback to set the offset of the cursor
161
+ */
162
+ onChangeCursorOffset: (offset: number) => void
163
+
164
+ /**
165
+ * Optional hint text to display after command input
166
+ * Used for showing available arguments for commands
167
+ */
168
+ readonly argumentHint?: string
169
+
170
+ /**
171
+ * Optional callback for undo functionality
172
+ */
173
+ readonly onUndo?: () => void
174
+
175
+ /**
176
+ * Whether to render the text with dim color
177
+ */
178
+ readonly dimColor?: boolean
179
+
180
+ /**
181
+ * Optional text highlights for search results or other highlighting
182
+ */
183
+ readonly highlights?: TextHighlight[]
184
+
185
+ /**
186
+ * Optional custom React element to render as placeholder.
187
+ * When provided, overrides the standard `placeholder` string rendering.
188
+ */
189
+ readonly placeholderElement?: React.ReactNode
190
+
191
+ /**
192
+ * Optional inline ghost text for mid-input command autocomplete
193
+ */
194
+ readonly inlineGhostText?: InlineGhostText
195
+
196
+ /**
197
+ * Optional filter applied to raw input before key routing. Return the
198
+ * (possibly transformed) input string; returning '' for a non-empty
199
+ * input drops the event.
200
+ */
201
+ readonly inputFilter?: (input: string, key: Key) => string
202
+ }
203
+
204
+ /**
205
+ * Extended props for VimTextInput
206
+ */
207
+ export type VimTextInputProps = BaseTextInputProps & {
208
+ /**
209
+ * Initial vim mode to use
210
+ */
211
+ readonly initialMode?: VimMode
212
+
213
+ /**
214
+ * Optional callback for mode changes
215
+ */
216
+ readonly onModeChange?: (mode: VimMode) => void
217
+ }
218
+
219
+ /**
220
+ * Vim editor modes
221
+ */
222
+ export type VimMode = 'INSERT' | 'NORMAL'
223
+
224
+ /**
225
+ * Common properties for input hook results
226
+ */
227
+ export type BaseInputState = {
228
+ onInput: (input: string, key: Key) => void
229
+ renderedValue: string
230
+ offset: number
231
+ setOffset: (offset: number) => void
232
+ /** Cursor line (0-indexed) within the rendered text, accounting for wrapping. */
233
+ cursorLine: number
234
+ /** Cursor column (display-width) within the current line. */
235
+ cursorColumn: number
236
+ /** Character offset in the full text where the viewport starts (0 when no windowing). */
237
+ viewportCharOffset: number
238
+ /** Character offset in the full text where the viewport ends (text.length when no windowing). */
239
+ viewportCharEnd: number
240
+
241
+ // For paste handling
242
+ isPasting?: boolean
243
+ pasteState?: {
244
+ chunks: string[]
245
+ timeoutId: ReturnType<typeof setTimeout> | null
246
+ }
247
+ }
248
+
249
+ /**
250
+ * State for text input
251
+ */
252
+ export type TextInputState = BaseInputState
253
+
254
+ /**
255
+ * State for vim input with mode
256
+ */
257
+ export type VimInputState = BaseInputState & {
258
+ mode: VimMode
259
+ setMode: (mode: VimMode) => void
260
+ }
261
+
262
+ /**
263
+ * Input modes for the prompt
264
+ */
265
+ export type PromptInputMode =
266
+ | 'bash'
267
+ | 'prompt'
268
+ | 'orphaned-permission'
269
+ | 'task-notification'
270
+
271
+ export type EditablePromptInputMode = Exclude<
272
+ PromptInputMode,
273
+ `${string}-notification`
274
+ >
275
+
276
+ /**
277
+ * Queue priority levels. Same semantics in both normal and proactive mode.
278
+ *
279
+ * - `now` — Interrupt and send immediately. Aborts any in-flight tool
280
+ * call (equivalent to Esc + send). Consumers (print.ts,
281
+ * REPL.tsx) subscribe to queue changes and abort when they
282
+ * see a 'now' command.
283
+ * - `next` — Mid-turn drain. Let the current tool call finish, then
284
+ * send this message between the tool result and the next API
285
+ * round-trip. Wakes an in-progress SleepTool call.
286
+ * - `later` — End-of-turn drain. Wait for the current turn to finish,
287
+ * then process as a new query. Wakes an in-progress SleepTool
288
+ * call (query.ts upgrades the drain threshold after sleep so
289
+ * the message is attached to the same turn).
290
+ *
291
+ * The SleepTool is only available in proactive mode, so "wakes SleepTool"
292
+ * is a no-op in normal mode.
293
+ */
294
+ export type QueuePriority = 'now' | 'next' | 'later'
295
+
296
+ /**
297
+ * Queued command type
298
+ */
299
+ export type QueuedCommand = {
300
+ value: string | Array<ContentBlockParam>
301
+ mode: PromptInputMode
302
+ /** Defaults to the priority implied by `mode` when enqueued. */
303
+ priority?: QueuePriority
304
+ uuid?: UUID
305
+ orphanedPermission?: OrphanedPermission
306
+ /** Raw pasted contents including images. Images are resized at execution time. */
307
+ pastedContents?: Record<number, PastedContent>
308
+ /**
309
+ * The input string before [Pasted text #N] placeholders were expanded.
310
+ * Used for ultraplan keyword detection so pasted content containing the
311
+ * keyword does not trigger a CCR session. Falls back to `value` when
312
+ * unset (bridge/UDS/MCP sources have no paste expansion).
313
+ */
314
+ preExpansionValue?: string
315
+ /**
316
+ * When true, the input is treated as plain text even if it starts with `/`.
317
+ * Used for remotely-received messages (e.g. bridge/CCR) that should not
318
+ * trigger local slash commands or skills.
319
+ */
320
+ skipSlashCommands?: boolean
321
+ /**
322
+ * When true, slash commands are dispatched but filtered through
323
+ * isBridgeSafeCommand() — 'local-jsx' and terminal-only commands return
324
+ * a helpful error instead of executing. Set by the Remote Control bridge
325
+ * inbound path so mobile/web clients can run skills and benign commands
326
+ * without re-exposing the PR #19134 bug (/model popping the local picker).
327
+ */
328
+ bridgeOrigin?: boolean
329
+ /**
330
+ * When true, the resulting UserMessage gets `isMeta: true` — hidden in the
331
+ * transcript UI but visible to the model. Used by system-generated prompts
332
+ * (proactive ticks, teammate messages, resource updates) that route through
333
+ * the queue instead of calling `onQuery` directly.
334
+ */
335
+ isMeta?: boolean
336
+ /**
337
+ * Provenance of this command. Stamped onto the resulting UserMessage so the
338
+ * transcript records origin structurally (not just via XML tags in content).
339
+ * undefined = human (keyboard).
340
+ */
341
+ origin?: MessageOrigin
342
+ /**
343
+ * Workload tag threaded through to cc_workload= in the billing-header
344
+ * attribution block. The queue is the async boundary between the cron
345
+ * scheduler firing and the turn actually running — a user prompt can slip
346
+ * in between — so the tag rides on the QueuedCommand itself and is only
347
+ * hoisted into bootstrap state when THIS command is dequeued.
348
+ */
349
+ workload?: string
350
+ /**
351
+ * Agent that should receive this notification. Undefined = main thread.
352
+ * Subagents run in-process and share the module-level command queue; the
353
+ * drain gate in query.ts filters by this field so a subagent's background
354
+ * task notifications don't leak into the coordinator's context (PR #18453
355
+ * unified the queue but lost the isolation the dual-queue accidentally had).
356
+ */
357
+ agentId?: AgentId
358
+ }
359
+
360
+ /**
361
+ * Type guard for image PastedContent with non-empty data. Empty-content
362
+ * images (e.g. from a 0-byte file drag) yield empty base64 strings that
363
+ * the API rejects with `image cannot be empty`. Use this at every site
364
+ * that converts PastedContent → ImageBlockParam so the filter and the
365
+ * ID list stay in sync.
366
+ */
367
+ export function isValidImagePaste(c: PastedContent): boolean {
368
+ return c.type === 'image' && c.content.length > 0
369
+ }
370
+
371
+ /** Extract image paste IDs from a QueuedCommand's pastedContents. */
372
+ export function getImagePasteIds(
373
+ pastedContents: Record<number, PastedContent> | undefined,
374
+ ): number[] | undefined {
375
+ if (!pastedContents) {
376
+ return undefined
377
+ }
378
+ const ids = Object.values(pastedContents)
379
+ .filter(isValidImagePaste)
380
+ .map(c => c.id)
381
+ return ids.length > 0 ? ids : undefined
382
+ }
383
+
384
+ export type OrphanedPermission = {
385
+ permissionResult: PermissionResult
386
+ assistantMessage: AssistantMessage
387
+ }
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Tool types
3
+ * TEMPORARY SHIM - Replace with proper Allternit SDK types
4
+ */
5
+
6
+ // ============================================================================
7
+ // Base Tool Types
8
+ // ============================================================================
9
+
10
+ export interface Tool {
11
+ name: string
12
+ description: string
13
+ input_schema: {
14
+ type: 'object'
15
+ properties?: Record<string, unknown>
16
+ required?: string[]
17
+ }
18
+ // Additional properties for tool handling
19
+ userFacingName?: (input?: unknown) => string
20
+ userFacingNameBackgroundColor?: (input?: unknown) => string | undefined
21
+ isTransparentWrapper?: () => boolean
22
+ inputSchema?: {
23
+ safeParse: (input: unknown) => { success: boolean; data?: unknown }
24
+ }
25
+ }
26
+
27
+ export interface ToolUse {
28
+ type: 'tool_use'
29
+ id: string
30
+ name: string
31
+ input: Record<string, unknown>
32
+ }
33
+
34
+ export interface ToolResult {
35
+ type: 'tool_result'
36
+ tool_use_id: string
37
+ content: string | Array<{type: string; text?: string; source?: unknown}>
38
+ is_error?: boolean
39
+ }
40
+
41
+ export interface ToolInputJSONSchema {
42
+ type: 'object'
43
+ properties?: Record<string, unknown>
44
+ required?: string[]
45
+ description?: string
46
+ }
47
+
48
+ // ============================================================================
49
+ // Tool Progress Types
50
+ // ============================================================================
51
+
52
+ export interface ToolProgressData {
53
+ toolUseId: string
54
+ toolName: string
55
+ status: 'pending' | 'running' | 'completed' | 'error'
56
+ progress?: number
57
+ message?: string
58
+ output?: string
59
+ type?: string
60
+ command?: string
61
+ exitCode?: number
62
+ // Additional properties for bash tool progress
63
+ fullOutput?: string
64
+ elapsedTimeSeconds?: number
65
+ totalLines?: number
66
+ totalBytes?: number
67
+ timeoutMs?: number
68
+ taskId?: string
69
+ }
70
+
71
+ export interface BashProgress extends ToolProgressData {
72
+ type: 'bash'
73
+ command: string
74
+ exitCode?: number
75
+ }
76
+
77
+ export interface ShellProgress extends ToolProgressData {
78
+ type: 'shell'
79
+ command: string
80
+ exitCode?: number
81
+ }
82
+
83
+ export interface PowerShellProgress extends ToolProgressData {
84
+ type: 'powershell'
85
+ command: string
86
+ exitCode?: number
87
+ }
88
+
89
+ export interface MCPProgress extends ToolProgressData {
90
+ type: 'mcp'
91
+ serverName: string
92
+ operation: string
93
+ }
94
+
95
+ export interface REPLToolProgress extends ToolProgressData {
96
+ type: 'repl'
97
+ language: string
98
+ code: string
99
+ }
100
+
101
+ export interface AgentToolProgress extends ToolProgressData {
102
+ type: 'agent'
103
+ agentName: string
104
+ task: string
105
+ }
106
+
107
+ export interface SkillToolProgress extends ToolProgressData {
108
+ type: 'skill'
109
+ skillName: string
110
+ action: string
111
+ }
112
+
113
+ export interface WebSearchProgress extends ToolProgressData {
114
+ type: 'web_search'
115
+ query: string
116
+ results?: unknown[]
117
+ }
118
+
119
+ export interface TaskOutputProgress extends ToolProgressData {
120
+ type: 'task_output'
121
+ taskId: string
122
+ content: string
123
+ }
124
+
125
+ export interface SdkWorkflowProgress extends ToolProgressData {
126
+ type: 'sdk_workflow'
127
+ workflowName: string
128
+ step?: string
129
+ }
130
+
131
+ // Union type for all progress types
132
+ export type ToolProgress =
133
+ | BashProgress
134
+ | ShellProgress
135
+ | PowerShellProgress
136
+ | MCPProgress
137
+ | REPLToolProgress
138
+ | AgentToolProgress
139
+ | SkillToolProgress
140
+ | WebSearchProgress
141
+ | TaskOutputProgress
142
+ | SdkWorkflowProgress
143
+
144
+ // ============================================================================
145
+ // Legacy Exports
146
+ // ============================================================================
147
+
148
+ export type ToolParam = ToolUse
149
+ export type ToolResultBlockParam = ToolResult
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Utility types
3
+ * TEMPORARY SHIM
4
+ */
5
+
6
+ export type DeepImmutable<T> = {
7
+ readonly [K in keyof T]: DeepImmutable<T[K]>
8
+ }
9
+
10
+ export type Nullable<T> = T | null | undefined
11
+
12
+ export type DeepReadonly<T> = {
13
+ readonly [P in keyof T]: DeepReadonly<T[P]>
14
+ }
15
+
16
+ export type ValueOf<T> = T[keyof T]
17
+
18
+ // Permutations of union types
19
+ export type Permutations<T extends string, U extends string = T> =
20
+ T extends any ? (U extends T ? never : U) | `${T}_${Permutations<Exclude<U, T>>}` : never
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Advisor Utilities
3
+ */
4
+
5
+ export interface AdvisorSuggestion {
6
+ type: string
7
+ message: string
8
+ }
9
+
10
+ export function getAdvisorSuggestions(): AdvisorSuggestion[] {
11
+ return []
12
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * API Utilities
3
+ */
4
+
5
+ export interface ApiRequestOptions {
6
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE'
7
+ headers?: Record<string, string>
8
+ body?: unknown
9
+ }
10
+
11
+ export async function apiRequest<T>(
12
+ url: string,
13
+ options?: ApiRequestOptions
14
+ ): Promise<T> {
15
+ const response = await fetch(url, {
16
+ method: options?.method || 'GET',
17
+ headers: options?.headers,
18
+ body: options?.body ? JSON.stringify(options.body) : undefined,
19
+ })
20
+ return response.json() as Promise<T>
21
+ }
22
+
23
+ export function prependUserContext(messages: unknown[], context: string): unknown[] {
24
+ return messages
25
+ }
26
+
27
+ export function appendSystemContext(messages: unknown[], context: string): unknown[] {
28
+ return messages
29
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Array Utilities
3
+ */
4
+
5
+ export function count<T>(arr: T[], predicate: (item: T) => boolean): number {
6
+ return arr.filter(predicate).length
7
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Attachment utilities
3
+ */
4
+
5
+ export interface Attachment {
6
+ id: string
7
+ filename: string
8
+ contentType: string
9
+ size: number
10
+ data: Buffer | string
11
+ }
12
+
13
+ export function createAttachment(filename: string, data: Buffer | string, contentType?: string): Attachment {
14
+ return {
15
+ id: generateAttachmentId(),
16
+ filename,
17
+ contentType: contentType || inferContentType(filename),
18
+ size: Buffer.isBuffer(data) ? data.length : Buffer.byteLength(data, 'utf8'),
19
+ data,
20
+ }
21
+ }
22
+
23
+ export function inferContentType(filename: string): string {
24
+ const ext = filename.split('.').pop()?.toLowerCase()
25
+ const types: Record<string, string> = {
26
+ 'txt': 'text/plain',
27
+ 'md': 'text/markdown',
28
+ 'json': 'application/json',
29
+ 'js': 'application/javascript',
30
+ 'ts': 'application/typescript',
31
+ 'png': 'image/png',
32
+ 'jpg': 'image/jpeg',
33
+ 'jpeg': 'image/jpeg',
34
+ 'gif': 'image/gif',
35
+ 'pdf': 'application/pdf',
36
+ }
37
+ return types[ext || ''] || 'application/octet-stream'
38
+ }
39
+
40
+ function generateAttachmentId(): string {
41
+ return `att_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`
42
+ }
43
+
44
+ export function validateAttachment(attachment: Attachment): boolean {
45
+ return !!(attachment.id && attachment.filename && attachment.contentType)
46
+ }
47
+
48
+ export function getAttachmentSizeString(attachment: Attachment): string {
49
+ const bytes = attachment.size
50
+ if (bytes < 1024) return `${bytes} B`
51
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`
52
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`
53
+ }
54
+
55
+ export default {
56
+ createAttachment,
57
+ inferContentType,
58
+ validateAttachment,
59
+ getAttachmentSizeString,
60
+ }
@@ -0,0 +1,3 @@
1
+ // Re-export from shared/utils
2
+ export * from '../shared/utils/auth.js'
3
+ export { default } from '../shared/utils/auth.js'
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Chrome Native Host
3
+ */
4
+
5
+ export interface ChromeNativeHost {
6
+ connect(): Promise<void>
7
+ disconnect(): Promise<void>
8
+ }
9
+
10
+ export function createChromeNativeHost(): ChromeNativeHost {
11
+ return {
12
+ connect: async () => {},
13
+ disconnect: async () => {},
14
+ }
15
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Claude in Chrome Common
3
+ */
4
+
5
+ export interface ChromeConnectionConfig {
6
+ host: string
7
+ port: number
8
+ }
9
+
10
+ export function getChromeConnectionConfig(): ChromeConnectionConfig {
11
+ return { host: 'localhost', port: 9222 }
12
+ }