@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
@@ -1,371 +1,214 @@
1
1
  /**
2
- * @fileoverview Bootstrap state management for gizzi-code integration
3
- * @module bootstrap/state
4
- *
5
- * Manages application initialization state, loading phases, and bootstrap
6
- * lifecycle events. Provides centralized state tracking during application startup.
2
+ * Bootstrap state management
3
+ * Core application state and signals
7
4
  */
8
5
 
9
- import type { TypedMessage } from '../types/message';
6
+ import { createSignal, type Signal } from '../runtime/util/signal.js'
7
+ import { log } from '../runtime/util/log.js'
10
8
 
11
- /**
12
- * Loading phase identifiers for the bootstrap process
13
- * @typedef {'idle' | 'initializing' | 'loading_config' | 'connecting' | 'authenticating' | 'ready' | 'error'} LoadingPhase
14
- */
15
- export type LoadingPhase =
16
- | 'idle'
17
- | 'initializing'
18
- | 'loading_config'
19
- | 'connecting'
20
- | 'authenticating'
21
- | 'ready'
22
- | 'error';
23
-
24
- /**
25
- * Valid loading phase transitions
26
- * @constant {Record<LoadingPhase, readonly LoadingPhase[]>}
27
- */
28
- export const VALID_PHASE_TRANSITIONS: Readonly<Record<LoadingPhase, readonly LoadingPhase[]>> = {
29
- idle: ['initializing'],
30
- initializing: ['loading_config', 'error'],
31
- loading_config: ['connecting', 'error'],
32
- connecting: ['authenticating', 'error'],
33
- authenticating: ['ready', 'error'],
34
- ready: ['idle', 'initializing'],
35
- error: ['idle', 'initializing'],
36
- } as const;
37
-
38
- /**
39
- * Bootstrap error structure
40
- * @interface BootstrapError
41
- */
42
- export interface BootstrapError {
43
- /** Error code for programmatic handling */
44
- readonly code: string;
45
-
46
- /** Human-readable error message */
47
- readonly message: string;
48
-
49
- /** Error timestamp */
50
- readonly timestamp: Date;
51
-
52
- /** Optional error details or stack trace */
53
- readonly details?: string;
54
-
55
- /** Phase where the error occurred */
56
- readonly phase: LoadingPhase;
9
+ // Model settings
10
+ export interface ModelSetting {
11
+ model: string
12
+ provider: string
13
+ temperature?: number
14
+ maxTokens?: number
57
15
  }
58
16
 
59
- /**
60
- * Bootstrap state interface tracking initialization progress
61
- * @interface BootstrapState
62
- */
63
- export interface BootstrapState {
64
- /** Current loading phase */
65
- readonly phase: LoadingPhase;
17
+ export type SessionId = string & { readonly __brand: 'SessionId' }
66
18
 
67
- /** Overall progress percentage (0-100) */
68
- readonly progress: number;
69
-
70
- /** Whether the application has completed bootstrap */
71
- readonly isComplete: boolean;
72
-
73
- /** Whether an error has occurred during bootstrap */
74
- readonly hasError: boolean;
75
-
76
- /** Current error if any */
77
- readonly error: BootstrapError | null;
19
+ // Session management
20
+ interface SessionState {
21
+ id: SessionId
22
+ createdAt: Date
23
+ lastActiveAt: Date
24
+ modelSetting: ModelSetting
25
+ }
78
26
 
79
- /** Timestamp when bootstrap started */
80
- readonly startTime: Date | null;
27
+ // Global bootstrap state
28
+ let currentSession: SessionState | null = null
29
+ const slowOperations: { description: string; duration: number; timestamp: Date }[] = []
30
+
31
+ // Signals for reactive state
32
+ const sessionSignal = createSignal<SessionState | null>(null)
33
+ const modelSettingSignal = createSignal<ModelSetting | null>(null)
34
+
35
+ // Session management
36
+ export function createSession(modelSetting: ModelSetting): SessionId {
37
+ const id = `sess_${Date.now()}_${Math.random().toString(36).slice(2, 11)}` as SessionId
38
+ const session: SessionState = {
39
+ id,
40
+ createdAt: new Date(),
41
+ lastActiveAt: new Date(),
42
+ modelSetting,
43
+ }
44
+
45
+ currentSession = session
46
+ sessionSignal.set(session)
47
+ modelSettingSignal.set(modelSetting)
48
+
49
+ log('info', 'Session created', { sessionId: id, model: modelSetting.model })
50
+ return id
51
+ }
81
52
 
82
- /** Timestamp when bootstrap completed */
83
- readonly endTime: Date | null;
53
+ export function getCurrentSession(): SessionState | null {
54
+ return currentSession
55
+ }
84
56
 
85
- /** Messages collected during initialization */
86
- readonly messages: readonly TypedMessage[];
57
+ export function getSessionId(): SessionId | null {
58
+ return currentSession?.id || null
59
+ }
87
60
 
88
- /** Configuration data loaded during bootstrap */
89
- readonly config: Readonly<Record<string, unknown>>;
61
+ export function setSessionId(id: SessionId): void {
62
+ if (currentSession) {
63
+ currentSession.id = id
64
+ sessionSignal.set(currentSession)
65
+ }
66
+ }
90
67
 
91
- /** Services initialized during bootstrap */
92
- readonly services: readonly string[];
68
+ export function updateSessionActivity(): void {
69
+ if (currentSession) {
70
+ currentSession.lastActiveAt = new Date()
71
+ sessionSignal.set(currentSession)
72
+ }
93
73
  }
94
74
 
95
- /**
96
- * Initial bootstrap state
97
- * @constant {BootstrapState}
98
- */
99
- const INITIAL_STATE: BootstrapState = {
100
- phase: 'idle',
101
- progress: 0,
102
- isComplete: false,
103
- hasError: false,
104
- error: null,
105
- startTime: null,
106
- endTime: null,
107
- messages: [],
108
- config: {},
109
- services: [],
110
- } as const;
75
+ export function clearSession(): void {
76
+ currentSession = null
77
+ sessionSignal.set(null)
78
+ modelSettingSignal.set(null)
79
+ log('info', 'Session cleared')
80
+ }
111
81
 
112
- /**
113
- * Listener callback type for state changes
114
- * @typedef {(state: BootstrapState) => void} StateChangeListener
115
- */
116
- type StateChangeListener = (state: BootstrapState) => void;
82
+ // Model settings
83
+ export function getModelSetting(): ModelSetting | null {
84
+ return currentSession?.modelSetting || modelSettingSignal.get()
85
+ }
117
86
 
118
- // Module-level state (singleton pattern)
119
- let currentState: BootstrapState = { ...INITIAL_STATE };
120
- const listeners: Set<StateChangeListener> = new Set();
87
+ export function setModelSetting(setting: ModelSetting): void {
88
+ if (currentSession) {
89
+ currentSession.modelSetting = setting
90
+ sessionSignal.set(currentSession)
91
+ }
92
+ modelSettingSignal.set(setting)
93
+ }
121
94
 
122
- /**
123
- * Gets the current bootstrap state
124
- * @returns {Readonly<BootstrapState>} The current bootstrap state (immutable)
125
- * @example
126
- * ```typescript
127
- * const state = getBootstrapState();
128
- * if (state.phase === 'ready') {
129
- * console.log('Application is ready');
130
- * }
131
- * ```
132
- */
133
- export function getBootstrapState(): Readonly<BootstrapState> {
134
- return Object.freeze({ ...currentState });
95
+ // Session subscriptions
96
+ export function subscribeToSession(listener: (session: SessionState | null) => void): () => void {
97
+ return sessionSignal.subscribe(() => listener(sessionSignal.get()))
135
98
  }
136
99
 
137
- /**
138
- * Sets the bootstrap state with partial updates
139
- * Automatically notifies all registered listeners
140
- *
141
- * @param {Partial<BootstrapState>} updates - Partial state updates to apply
142
- * @returns {Readonly<BootstrapState>} The updated state
143
- * @throws {Error} If attempting an invalid phase transition
144
- * @example
145
- * ```typescript
146
- * setBootstrapState({ phase: 'initializing', progress: 10 });
147
- * ```
148
- */
149
- export function setBootstrapState(updates: Partial<BootstrapState>): Readonly<BootstrapState> {
150
- // Validate phase transition if phase is being updated
151
- if (updates.phase && updates.phase !== currentState.phase) {
152
- if (!isValidPhaseTransition(currentState.phase, updates.phase)) {
153
- throw new Error(
154
- `Invalid phase transition from '${currentState.phase}' to '${updates.phase}'. ` +
155
- `Valid transitions: ${VALID_PHASE_TRANSITIONS[currentState.phase].join(', ')}`
156
- );
157
- }
158
- }
100
+ export function subscribeToModelSetting(listener: (setting: ModelSetting | null) => void): () => void {
101
+ return modelSettingSignal.subscribe(() => listener(modelSettingSignal.get()))
102
+ }
159
103
 
160
- // Create new state with updates
161
- const previousState = currentState;
162
- currentState = {
163
- ...currentState,
164
- ...updates,
165
- // Merge nested objects carefully
166
- config: updates.config ? { ...currentState.config, ...updates.config } : currentState.config,
167
- messages: updates.messages ?? currentState.messages,
168
- services: updates.services ?? currentState.services,
169
- };
170
-
171
- // Update computed fields
172
- currentState = {
173
- ...currentState,
174
- isComplete: currentState.phase === 'ready',
175
- hasError: currentState.phase === 'error' || currentState.error !== null,
176
- };
177
-
178
- // Notify listeners (async to avoid blocking)
179
- queueMicrotask(() => {
180
- listeners.forEach((listener) => {
181
- try {
182
- listener(currentState);
183
- } catch (error) {
184
- console.error('Bootstrap state listener error:', error);
185
- }
186
- });
187
- });
188
-
189
- // Log state change in development
190
- if (process.env.NODE_ENV === 'development') {
191
- console.debug('[BootstrapState]', previousState.phase, '->', currentState.phase);
104
+ // Slow operation tracking
105
+ export function addSlowOperation(description: string, duration: number): void {
106
+ slowOperations.push({
107
+ description,
108
+ duration,
109
+ timestamp: new Date(),
110
+ })
111
+
112
+ // Keep only recent operations
113
+ const cutoff = Date.now() - 5 * 60 * 1000 // 5 minutes
114
+ while (slowOperations.length > 0 && slowOperations[0].timestamp.getTime() < cutoff) {
115
+ slowOperations.shift()
192
116
  }
117
+
118
+ log('warn', `Slow operation detected: ${description} (${duration.toFixed(1)}ms)`)
119
+ }
193
120
 
194
- return Object.freeze({ ...currentState });
121
+ export function getSlowOperations(): typeof slowOperations {
122
+ return [...slowOperations]
195
123
  }
196
124
 
197
- /**
198
- * Subscribes to bootstrap state changes
199
- *
200
- * @param {StateChangeListener} listener - Callback function to invoke on state changes
201
- * @returns {() => void} Unsubscribe function
202
- * @example
203
- * ```typescript
204
- * const unsubscribe = subscribeToBootstrapState((state) => {
205
- * console.log('Phase:', state.phase);
206
- * });
207
- * // Later: unsubscribe();
208
- * ```
209
- */
210
- export function subscribeToBootstrapState(listener: StateChangeListener): () => void {
211
- listeners.add(listener);
125
+ export function clearSlowOperations(): void {
126
+ slowOperations.length = 0
127
+ }
212
128
 
213
- // Immediately notify with current state
214
- listener(currentState);
129
+ // Working directory management
130
+ let originalCwd = process.cwd()
131
+ let kairosActive = false
132
+ let isRemoteMode = false
215
133
 
216
- return () => {
217
- listeners.delete(listener);
218
- };
134
+ export function setOriginalCwd(cwd: string): void {
135
+ originalCwd = cwd
219
136
  }
220
137
 
221
- /**
222
- * Resets the bootstrap state to initial values
223
- * Useful for testing or re-initializing the application
224
- *
225
- * @param {boolean} [notifyListeners=true] - Whether to notify listeners of the reset
226
- * @returns {Readonly<BootstrapState>} The reset state
227
- */
228
- export function resetBootstrapState(notifyListeners = true): Readonly<BootstrapState> {
229
- currentState = { ...INITIAL_STATE };
230
-
231
- if (notifyListeners) {
232
- queueMicrotask(() => {
233
- listeners.forEach((listener) => {
234
- try {
235
- listener(currentState);
236
- } catch (error) {
237
- console.error('Bootstrap state listener error:', error);
238
- }
239
- });
240
- });
241
- }
242
-
243
- return Object.freeze({ ...currentState });
138
+ export function getOriginalCwd(): string {
139
+ return originalCwd
244
140
  }
245
141
 
246
- /**
247
- * Starts the bootstrap process
248
- * Sets phase to 'initializing' and records start time
249
- *
250
- * @returns {Readonly<BootstrapState>} The updated state
251
- */
252
- export function startBootstrap(): Readonly<BootstrapState> {
253
- return setBootstrapState({
254
- phase: 'initializing',
255
- startTime: new Date(),
256
- progress: 5,
257
- });
142
+ export function setKairosActive(active: boolean): void {
143
+ kairosActive = active
258
144
  }
259
145
 
260
- /**
261
- * Reports a bootstrap error
262
- * Sets phase to 'error' and records error details
263
- *
264
- * @param {string} code - Error code
265
- * @param {string} message - Error message
266
- * @param {string} [details] - Optional error details
267
- * @returns {Readonly<BootstrapState>} The updated state
268
- */
269
- export function setBootstrapError(
270
- code: string,
271
- message: string,
272
- details?: string
273
- ): Readonly<BootstrapState> {
274
- const error: BootstrapError = {
275
- code,
276
- message,
277
- timestamp: new Date(),
278
- details,
279
- phase: currentState.phase,
280
- };
281
-
282
- return setBootstrapState({
283
- phase: 'error',
284
- error,
285
- endTime: new Date(),
286
- });
146
+ export function getKairosActive(): boolean {
147
+ return kairosActive
287
148
  }
288
149
 
289
- /**
290
- * Completes the bootstrap process
291
- * Sets phase to 'ready' and records completion time
292
- *
293
- * @returns {Readonly<BootstrapState>} The updated state
294
- */
295
- export function completeBootstrap(): Readonly<BootstrapState> {
296
- return setBootstrapState({
297
- phase: 'ready',
298
- progress: 100,
299
- endTime: new Date(),
300
- });
150
+ export function setIsRemoteMode(remote: boolean): void {
151
+ isRemoteMode = remote
301
152
  }
302
153
 
303
- /**
304
- * Validates if a phase transition is allowed
305
- *
306
- * @param {LoadingPhase} from - Current phase
307
- * @param {LoadingPhase} to - Target phase
308
- * @returns {boolean} Whether the transition is valid
309
- */
310
- function isValidPhaseTransition(from: LoadingPhase, to: LoadingPhase): boolean {
311
- return VALID_PHASE_TRANSITIONS[from].includes(to);
154
+ export function getIsRemoteMode(): boolean {
155
+ return isRemoteMode
312
156
  }
313
157
 
314
- /**
315
- * Gets the estimated time remaining for bootstrap
316
- *
317
- * @returns {number | null} Estimated milliseconds remaining, or null if not available
318
- */
319
- export function getEstimatedTimeRemaining(): number | null {
320
- if (!currentState.startTime || currentState.progress === 0) {
321
- return null;
322
- }
158
+ // Permission mode
159
+ export type PermissionMode = 'ask' | 'acceptEdits' | 'bypassPermissions' | 'acceptAll'
323
160
 
324
- const elapsed = Date.now() - currentState.startTime.getTime();
325
- const progressRemaining = 100 - currentState.progress;
326
- const estimatedTotal = (elapsed / currentState.progress) * 100;
161
+ let currentPermissionMode: PermissionMode = 'ask'
327
162
 
328
- return Math.max(0, (estimatedTotal * progressRemaining) / 100);
163
+ export function setPermissionMode(mode: PermissionMode): void {
164
+ currentPermissionMode = mode
165
+ log('info', `Permission mode set to: ${mode}`)
329
166
  }
330
167
 
331
- /**
332
- * Adds a message to the bootstrap state
333
- *
334
- * @param {TypedMessage} message - The message to add
335
- * @returns {Readonly<BootstrapState>} The updated state
336
- */
337
- export function addBootstrapMessage(message: TypedMessage): Readonly<BootstrapState> {
338
- return setBootstrapState({
339
- messages: [...currentState.messages, message],
340
- });
168
+ export function getPermissionMode(): PermissionMode {
169
+ return currentPermissionMode
341
170
  }
342
171
 
343
- /**
344
- * Registers a service as initialized
345
- *
346
- * @param {string} serviceName - Name of the service
347
- * @returns {Readonly<BootstrapState>} The updated state
348
- */
349
- export function registerService(serviceName: string): Readonly<BootstrapState> {
350
- if (currentState.services.includes(serviceName)) {
351
- return getBootstrapState();
352
- }
172
+ // Debug mode
173
+ let debugMode = false
174
+
175
+ export function setDebugMode(enabled: boolean): void {
176
+ debugMode = enabled
177
+ }
178
+
179
+ export function isDebugMode(): boolean {
180
+ return debugMode
181
+ }
353
182
 
354
- return setBootstrapState({
355
- services: [...currentState.services, serviceName],
356
- });
183
+ // Initialization
184
+ export function initializeBootstrapState(): void {
185
+ log('info', 'Bootstrap state initialized')
357
186
  }
358
187
 
359
188
  // Default export
360
189
  export default {
361
- getBootstrapState,
362
- setBootstrapState,
363
- subscribeToBootstrapState,
364
- resetBootstrapState,
365
- startBootstrap,
366
- completeBootstrap,
367
- setBootstrapError,
368
- addBootstrapMessage,
369
- registerService,
370
- getEstimatedTimeRemaining,
371
- };
190
+ createSession,
191
+ getCurrentSession,
192
+ getSessionId,
193
+ setSessionId,
194
+ updateSessionActivity,
195
+ clearSession,
196
+ getModelSetting,
197
+ setModelSetting,
198
+ subscribeToSession,
199
+ subscribeToModelSetting,
200
+ addSlowOperation,
201
+ getSlowOperations,
202
+ clearSlowOperations,
203
+ setOriginalCwd,
204
+ getOriginalCwd,
205
+ setKairosActive,
206
+ getKairosActive,
207
+ setIsRemoteMode,
208
+ getIsRemoteMode,
209
+ setPermissionMode,
210
+ getPermissionMode,
211
+ setDebugMode,
212
+ isDebugMode,
213
+ initializeBootstrapState,
214
+ }