@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,21 @@
1
+ /**
2
+ * Message queue types
3
+ */
4
+
5
+ export interface MessageQueueItem {
6
+ id: string
7
+ priority: number
8
+ data: unknown
9
+ }
10
+
11
+ export interface QueueOperation {
12
+ type: 'enqueue' | 'dequeue' | 'peek'
13
+ queueName: string
14
+ item?: MessageQueueItem
15
+ }
16
+
17
+ export interface QueueOperationMessage {
18
+ type: 'queue_operation'
19
+ operation: QueueOperation
20
+ timestamp: number
21
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Notebook types
3
+ */
4
+
5
+ export interface NotebookCell {
6
+ id: string
7
+ type: 'code' | 'markdown'
8
+ cell_type?: 'code' | 'markdown'
9
+ content?: string
10
+ source?: string | string[]
11
+ output?: string
12
+ executionCount?: number
13
+ execution_count?: number
14
+ outputs?: NotebookCellOutput[]
15
+ [key: string]: unknown
16
+ }
17
+
18
+ export interface NotebookCellOutput {
19
+ output_type: 'stream' | 'execute_result' | 'display_data' | 'error'
20
+ text?: string | string[]
21
+ data?: Record<string, unknown>
22
+ ename?: string
23
+ evalue?: string
24
+ traceback?: string[]
25
+ image?: {
26
+ image_data: string
27
+ media_type: string
28
+ }
29
+ [key: string]: unknown
30
+ }
31
+
32
+ export interface NotebookCellSource {
33
+ cellType?: 'code' | 'markdown'
34
+ source?: string
35
+ execution_count?: number
36
+ cell_id?: string
37
+ language?: string
38
+ [key: string]: unknown
39
+ }
40
+
41
+ export interface NotebookCellSourceOutput {
42
+ output_type?: string
43
+ text?: string | string[]
44
+ image?: {
45
+ image_data: string
46
+ media_type: string
47
+ }
48
+ [key: string]: unknown
49
+ }
50
+
51
+ export interface NotebookOutputImage {
52
+ image_data: string
53
+ media_type: string
54
+ [key: string]: unknown
55
+ }
56
+
57
+ export interface Notebook {
58
+ cells: NotebookCell[]
59
+ metadata: Record<string, unknown>
60
+ version: string
61
+ }
62
+
63
+ export interface NotebookEdit {
64
+ cellId: string
65
+ oldContent: string
66
+ newContent: string
67
+ }
68
+
69
+ export interface NotebookContent {
70
+ cells: NotebookCell[]
71
+ metadata: Record<string, unknown>
72
+ }
@@ -0,0 +1,447 @@
1
+ /**
2
+ * Pure permission type definitions extracted to break import cycles.
3
+ *
4
+ * This file contains only type definitions and constants with no runtime dependencies.
5
+ * Implementation files remain in src/utils/permissions/ but can now import from here
6
+ * to avoid circular dependencies.
7
+ */
8
+
9
+ import { feature } from 'bun:bundle'
10
+ import type { ContentBlockParam } from '@anthropic-ai/sdk/resources/messages.mjs'
11
+
12
+ // ============================================================================
13
+ // Permission Modes
14
+ // ============================================================================
15
+
16
+ export const EXTERNAL_PERMISSION_MODES = [
17
+ 'acceptEdits',
18
+ 'bypassPermissions',
19
+ 'default',
20
+ 'dontAsk',
21
+ 'plan',
22
+ ] as const
23
+
24
+ export type ExternalPermissionMode = (typeof EXTERNAL_PERMISSION_MODES)[number]
25
+
26
+ // Exhaustive mode union for typechecking. The user-addressable runtime set
27
+ // is INTERNAL_PERMISSION_MODES below.
28
+ export type InternalPermissionMode = ExternalPermissionMode | 'auto' | 'bubble'
29
+ export type PermissionMode = InternalPermissionMode
30
+
31
+ // Runtime validation set: modes that are user-addressable (settings.json
32
+ // defaultMode, --permission-mode CLI flag, conversation recovery).
33
+ export const INTERNAL_PERMISSION_MODES = [
34
+ ...EXTERNAL_PERMISSION_MODES,
35
+ ...(feature('TRANSCRIPT_CLASSIFIER') ? (['auto'] as const) : ([] as const)),
36
+ ] as const satisfies readonly PermissionMode[]
37
+
38
+ export const PERMISSION_MODES = INTERNAL_PERMISSION_MODES
39
+
40
+ // ============================================================================
41
+ // Permission Behaviors
42
+ // ============================================================================
43
+
44
+ export type PermissionBehavior = 'allow' | 'deny' | 'ask'
45
+
46
+ // ============================================================================
47
+ // Permission Rules
48
+ // ============================================================================
49
+
50
+ /**
51
+ * Where a permission rule originated from.
52
+ * Includes all SettingSource values plus additional rule-specific sources.
53
+ */
54
+ export type PermissionRuleSource =
55
+ | 'userSettings'
56
+ | 'projectSettings'
57
+ | 'localSettings'
58
+ | 'flagSettings'
59
+ | 'policySettings'
60
+ | 'cliArg'
61
+ | 'command'
62
+ | 'session'
63
+
64
+ /**
65
+ * The value of a permission rule - specifies which tool and optional content
66
+ */
67
+ export type PermissionRuleValue = {
68
+ toolName: string
69
+ ruleContent?: string
70
+ }
71
+
72
+ /**
73
+ * A permission rule with its source and behavior
74
+ */
75
+ export type PermissionRule = {
76
+ source: PermissionRuleSource
77
+ ruleBehavior: PermissionBehavior
78
+ ruleValue: PermissionRuleValue
79
+ }
80
+
81
+ // ============================================================================
82
+ // Permission Updates
83
+ // ============================================================================
84
+
85
+ /**
86
+ * Where a permission update should be persisted
87
+ */
88
+ export type PermissionUpdateDestination =
89
+ | 'userSettings'
90
+ | 'projectSettings'
91
+ | 'localSettings'
92
+ | 'session'
93
+ | 'cliArg'
94
+
95
+ /**
96
+ * Update operations for permission configuration
97
+ */
98
+ export type PermissionUpdate =
99
+ | {
100
+ type: 'addRules'
101
+ destination: PermissionUpdateDestination
102
+ rules: PermissionRuleValue[]
103
+ behavior: PermissionBehavior
104
+ }
105
+ | {
106
+ type: 'replaceRules'
107
+ destination: PermissionUpdateDestination
108
+ rules: PermissionRuleValue[]
109
+ behavior: PermissionBehavior
110
+ }
111
+ | {
112
+ type: 'removeRules'
113
+ destination: PermissionUpdateDestination
114
+ rules: PermissionRuleValue[]
115
+ behavior: PermissionBehavior
116
+ }
117
+ | {
118
+ type: 'setMode'
119
+ destination: PermissionUpdateDestination
120
+ mode: ExternalPermissionMode
121
+ }
122
+ | {
123
+ type: 'addDirectories'
124
+ destination: PermissionUpdateDestination
125
+ directories: string[]
126
+ }
127
+ | {
128
+ type: 'removeDirectories'
129
+ destination: PermissionUpdateDestination
130
+ directories: string[]
131
+ }
132
+
133
+ /**
134
+ * Source of an additional working directory permission.
135
+ * Note: This is currently the same as PermissionRuleSource but kept as a
136
+ * separate type for semantic clarity and potential future divergence.
137
+ */
138
+ export type WorkingDirectorySource = PermissionRuleSource
139
+
140
+ /**
141
+ * An additional directory included in permission scope
142
+ */
143
+ export type AdditionalWorkingDirectory = {
144
+ path: string
145
+ source: WorkingDirectorySource
146
+ }
147
+
148
+ // ============================================================================
149
+ // Permission Decisions & Results
150
+ // ============================================================================
151
+
152
+ /**
153
+ * Minimal command shape for permission metadata.
154
+ * This is intentionally a subset of the full Command type to avoid import cycles.
155
+ * Only includes properties needed by permission-related components.
156
+ */
157
+ export type PermissionCommandMetadata = {
158
+ name: string
159
+ description?: string
160
+ // Allow additional properties for forward compatibility
161
+ [key: string]: unknown
162
+ }
163
+
164
+ /**
165
+ * Metadata attached to permission decisions
166
+ */
167
+ export type PermissionMetadata =
168
+ | { command: PermissionCommandMetadata }
169
+ | undefined
170
+
171
+ /**
172
+ * Result when permission is granted
173
+ */
174
+ export type PermissionAllowDecision<
175
+ Input extends { [key: string]: unknown } = { [key: string]: unknown },
176
+ > = {
177
+ behavior: 'allow'
178
+ updatedInput?: Input
179
+ userModified?: boolean
180
+ decisionReason?: PermissionDecisionReason
181
+ toolUseID?: string
182
+ tool_use_id?: string // Snake case alias
183
+ acceptFeedback?: string
184
+ contentBlocks?: ContentBlockParam[]
185
+ }
186
+
187
+ /**
188
+ * Metadata for a pending classifier check that will run asynchronously.
189
+ * Used to enable non-blocking allow classifier evaluation.
190
+ */
191
+ export type PendingClassifierCheck = {
192
+ command: string
193
+ cwd: string
194
+ descriptions: string[]
195
+ }
196
+
197
+ /**
198
+ * Result when user should be prompted
199
+ */
200
+ export type PermissionAskDecision<
201
+ Input extends { [key: string]: unknown } = { [key: string]: unknown },
202
+ > = {
203
+ behavior: 'ask'
204
+ message: string
205
+ updatedInput?: Input
206
+ decisionReason?: PermissionDecisionReason
207
+ suggestions?: PermissionUpdate[]
208
+ blockedPath?: string
209
+ metadata?: PermissionMetadata
210
+ toolUseID?: string
211
+ tool_use_id?: string // Snake case alias
212
+ /**
213
+ * If true, this ask decision was triggered by a bashCommandIsSafe_DEPRECATED security check
214
+ * for patterns that splitCommand_DEPRECATED could misparse (e.g. line continuations, shell-quote
215
+ * transformations). Used by bashToolHasPermission to block early before splitCommand_DEPRECATED
216
+ * transforms the command. Not set for simple newline compound commands.
217
+ */
218
+ isBashSecurityCheckForMisparsing?: boolean
219
+ /**
220
+ * If set, an allow classifier check should be run asynchronously.
221
+ * The classifier may auto-approve the permission before the user responds.
222
+ */
223
+ pendingClassifierCheck?: PendingClassifierCheck
224
+ /**
225
+ * Optional content blocks (e.g., images) to include alongside the rejection
226
+ * message in the tool result. Used when users paste images as feedback.
227
+ */
228
+ contentBlocks?: ContentBlockParam[]
229
+ }
230
+
231
+ /**
232
+ * Result when permission is denied
233
+ */
234
+ export type PermissionDenyDecision = {
235
+ behavior: 'deny'
236
+ message: string
237
+ decisionReason: PermissionDecisionReason
238
+ toolUseID?: string
239
+ tool_use_id?: string // Snake case alias
240
+ }
241
+
242
+ /**
243
+ * A permission decision - allow, ask, or deny
244
+ */
245
+ export type PermissionDecision<
246
+ Input extends { [key: string]: unknown } = { [key: string]: unknown },
247
+ > =
248
+ | PermissionAllowDecision<Input>
249
+ | PermissionAskDecision<Input>
250
+ | PermissionDenyDecision
251
+
252
+ /**
253
+ * Permission result with additional passthrough option
254
+ */
255
+ export type PermissionResult<
256
+ Input extends { [key: string]: unknown } = { [key: string]: unknown },
257
+ > =
258
+ | PermissionDecision<Input>
259
+ | {
260
+ behavior: 'passthrough'
261
+ message: string
262
+ decisionReason?: PermissionDecision<Input>['decisionReason']
263
+ suggestions?: PermissionUpdate[]
264
+ blockedPath?: string
265
+ toolUseID?: string
266
+ tool_use_id?: string // Snake case alias
267
+ /**
268
+ * If set, an allow classifier check should be run asynchronously.
269
+ * The classifier may auto-approve the permission before the user responds.
270
+ */
271
+ pendingClassifierCheck?: PendingClassifierCheck
272
+ }
273
+
274
+ /**
275
+ * Explanation of why a permission decision was made
276
+ */
277
+ export type PermissionDecisionReason =
278
+ | {
279
+ type: 'rule'
280
+ rule: PermissionRule
281
+ }
282
+ | {
283
+ type: 'mode'
284
+ mode: PermissionMode
285
+ }
286
+ | {
287
+ type: 'subcommandResults'
288
+ reasons: Map<string, PermissionResult>
289
+ }
290
+ | {
291
+ type: 'permissionPromptTool'
292
+ permissionPromptToolName: string
293
+ toolResult: unknown
294
+ }
295
+ | {
296
+ type: 'hook'
297
+ hookName: string
298
+ hookSource?: string
299
+ reason?: string
300
+ }
301
+ | {
302
+ type: 'asyncAgent'
303
+ reason: string
304
+ }
305
+ | {
306
+ type: 'sandboxOverride'
307
+ reason: 'excludedCommand' | 'dangerouslyDisableSandbox'
308
+ }
309
+ | {
310
+ type: 'classifier'
311
+ classifier: string
312
+ reason: string
313
+ }
314
+ | {
315
+ type: 'workingDir'
316
+ reason: string
317
+ }
318
+ | {
319
+ type: 'safetyCheck'
320
+ reason: string
321
+ // When true, auto mode lets the classifier evaluate this instead of
322
+ // forcing a prompt. True for sensitive-file paths (.claude/, .git/,
323
+ // shell configs) — the classifier can see context and decide. False
324
+ // for Windows path bypass attempts and cross-machine bridge messages.
325
+ classifierApprovable: boolean
326
+ }
327
+ | {
328
+ type: 'other'
329
+ reason: string
330
+ }
331
+
332
+ // ============================================================================
333
+ // Bash Classifier Types
334
+ // ============================================================================
335
+
336
+ export type ClassifierResult = {
337
+ matches: boolean
338
+ matchedDescription?: string
339
+ confidence: 'high' | 'medium' | 'low'
340
+ reason: string
341
+ }
342
+
343
+ export type ClassifierBehavior = 'deny' | 'ask' | 'allow'
344
+
345
+ export type ClassifierUsage = {
346
+ inputTokens: number
347
+ outputTokens: number
348
+ cacheReadInputTokens: number
349
+ cacheCreationInputTokens: number
350
+ }
351
+
352
+ export type YoloClassifierResult = {
353
+ thinking?: string
354
+ shouldBlock: boolean
355
+ reason: string
356
+ unavailable?: boolean
357
+ /**
358
+ * API returned "prompt is too long" — the classifier transcript exceeded
359
+ * the context window. Deterministic (same transcript → same error), so
360
+ * callers should fall back to normal prompting rather than retry/fail-closed.
361
+ */
362
+ transcriptTooLong?: boolean
363
+ /** The model used for this classifier call */
364
+ model: string
365
+ /** Token usage from the classifier API call (for overhead telemetry) */
366
+ usage?: ClassifierUsage
367
+ /** Duration of the classifier API call in ms */
368
+ durationMs?: number
369
+ /** Character lengths of the prompt components sent to the classifier */
370
+ promptLengths?: {
371
+ systemPrompt: number
372
+ toolCalls: number
373
+ userPrompts: number
374
+ }
375
+ /** Path where error prompts were dumped (only set when unavailable due to API error) */
376
+ errorDumpPath?: string
377
+ /** Which classifier stage produced the final decision (2-stage XML only) */
378
+ stage?: 'fast' | 'thinking'
379
+ /** Token usage from stage 1 (fast) when stage 2 was also run */
380
+ stage1Usage?: ClassifierUsage
381
+ /** Duration of stage 1 in ms when stage 2 was also run */
382
+ stage1DurationMs?: number
383
+ /**
384
+ * API request_id (req_xxx) for stage 1. Enables joining to server-side
385
+ * api_usage logs for cache-miss / routing attribution. Also used for the
386
+ * legacy 1-stage (tool_use) classifier — the single request goes here.
387
+ */
388
+ stage1RequestId?: string
389
+ /**
390
+ * API message id (msg_xxx) for stage 1. Enables joining the
391
+ * tengu_auto_mode_decision analytics event to the classifier's actual
392
+ * prompt/completion in post-analysis.
393
+ */
394
+ stage1MsgId?: string
395
+ /** Token usage from stage 2 (thinking) when stage 2 was run */
396
+ stage2Usage?: ClassifierUsage
397
+ /** Duration of stage 2 in ms when stage 2 was run */
398
+ stage2DurationMs?: number
399
+ /** API request_id for stage 2 (set whenever stage 2 ran) */
400
+ stage2RequestId?: string
401
+ /** API message id (msg_xxx) for stage 2 (set whenever stage 2 ran) */
402
+ stage2MsgId?: string
403
+ }
404
+
405
+ // ============================================================================
406
+ // Permission Explainer Types
407
+ // ============================================================================
408
+
409
+ export type RiskLevel = 'LOW' | 'MEDIUM' | 'HIGH'
410
+
411
+ export type PermissionExplanation = {
412
+ riskLevel: RiskLevel
413
+ explanation: string
414
+ reasoning: string
415
+ risk: string
416
+ }
417
+
418
+ // ============================================================================
419
+ // Tool Permission Context
420
+ // ============================================================================
421
+
422
+ /**
423
+ * Mapping of permission rules by their source
424
+ */
425
+ export type ToolPermissionRulesBySource = {
426
+ [T in PermissionRuleSource]?: string[]
427
+ }
428
+
429
+ /**
430
+ * Context needed for permission checking in tools
431
+ * Note: Uses a simplified DeepImmutable approximation for this types-only file
432
+ */
433
+ export type ToolPermissionContext = {
434
+ readonly mode: PermissionMode
435
+ readonly additionalWorkingDirectories: ReadonlyMap<
436
+ string,
437
+ AdditionalWorkingDirectory
438
+ >
439
+ readonly alwaysAllowRules: ToolPermissionRulesBySource
440
+ readonly alwaysDenyRules: ToolPermissionRulesBySource
441
+ readonly alwaysAskRules: ToolPermissionRulesBySource
442
+ readonly isBypassPermissionsModeAvailable: boolean
443
+ readonly strippedDangerousRules?: ToolPermissionRulesBySource
444
+ readonly shouldAvoidPermissionPrompts?: boolean
445
+ readonly awaitAutomatedChecksBeforeDialog?: boolean
446
+ readonly prePlanMode?: PermissionMode
447
+ }