@allternit/gizzi-code 1.0.0

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 (64) hide show
  1. package/WORKSPACE_INTEGRATION.md +290 -0
  2. package/chat-sessions/sessions-index.json +98 -0
  3. package/package.json +43 -0
  4. package/package.json.original +31 -0
  5. package/package.json.publish +47 -0
  6. package/src/bootstrap/state.d.ts +169 -0
  7. package/src/bootstrap/state.js +261 -0
  8. package/src/bootstrap/state.ts +371 -0
  9. package/src/context/pack-builder.d.ts +24 -0
  10. package/src/context/pack-builder.js +281 -0
  11. package/src/context/pack-builder.ts +334 -0
  12. package/src/hooks/useExitOnCtrlCD.d.ts +86 -0
  13. package/src/hooks/useExitOnCtrlCD.js +130 -0
  14. package/src/hooks/useExitOnCtrlCD.ts +202 -0
  15. package/src/hooks/useKeybinding.d.ts +89 -0
  16. package/src/hooks/useKeybinding.js +163 -0
  17. package/src/hooks/useKeybinding.ts +226 -0
  18. package/src/hooks/useTerminalSize.d.ts +41 -0
  19. package/src/hooks/useTerminalSize.js +90 -0
  20. package/src/hooks/useTerminalSize.ts +117 -0
  21. package/src/index.d.ts +23 -0
  22. package/src/index.js +24 -0
  23. package/src/index.ts +132 -0
  24. package/src/runtime/brand/brand.d.ts +488 -0
  25. package/src/runtime/brand/brand.js +464 -0
  26. package/src/runtime/brand/brand.ts +667 -0
  27. package/src/runtime/services/tokenEstimation.d.ts +187 -0
  28. package/src/runtime/services/tokenEstimation.js +423 -0
  29. package/src/runtime/services/tokenEstimation.ts +547 -0
  30. package/src/runtime/tools/Tool.d.ts +239 -0
  31. package/src/runtime/tools/Tool.js +285 -0
  32. package/src/runtime/tools/Tool.ts +524 -0
  33. package/src/scheduler/TaskScheduler.d.ts +98 -0
  34. package/src/scheduler/TaskScheduler.js +201 -0
  35. package/src/scheduler/TaskScheduler.ts +259 -0
  36. package/src/state/AppStateStore.d.ts +347 -0
  37. package/src/state/AppStateStore.js +439 -0
  38. package/src/state/AppStateStore.ts +658 -0
  39. package/src/state/WorkspaceStateStore.d.ts +43 -0
  40. package/src/state/WorkspaceStateStore.js +224 -0
  41. package/src/state/WorkspaceStateStore.ts +297 -0
  42. package/src/types/message.d.ts +190 -0
  43. package/src/types/message.js +77 -0
  44. package/src/types/message.ts +277 -0
  45. package/src/utils/format.d.ts +126 -0
  46. package/src/utils/format.js +230 -0
  47. package/src/utils/format.ts +336 -0
  48. package/src/utils/fullscreen.d.ts +161 -0
  49. package/src/utils/fullscreen.js +277 -0
  50. package/src/utils/fullscreen.ts +382 -0
  51. package/src/utils/sessionStorage.d.ts +210 -0
  52. package/src/utils/sessionStorage.js +435 -0
  53. package/src/utils/sessionStorage.ts +559 -0
  54. package/src/watcher/WorkspaceWatcher.d.ts +70 -0
  55. package/src/watcher/WorkspaceWatcher.js +191 -0
  56. package/src/watcher/WorkspaceWatcher.ts +251 -0
  57. package/src/workspace/loader.d.ts +30 -0
  58. package/src/workspace/loader.js +117 -0
  59. package/src/workspace/loader.ts +171 -0
  60. package/src/workspace/types.d.ts +91 -0
  61. package/src/workspace/types.js +7 -0
  62. package/src/workspace/types.ts +122 -0
  63. package/threads/thread_1775361175022.json +9 -0
  64. package/tsconfig.json +14 -0
@@ -0,0 +1,347 @@
1
+ /**
2
+ * @fileoverview Application state store with React integration
3
+ * @module state/AppStateStore
4
+ *
5
+ * Centralized state management using the store pattern with subscription-based
6
+ * reactivity. Provides React hooks for component integration.
7
+ */
8
+ import type { TypedMessage } from '../types/message';
9
+ /**
10
+ * User preferences and settings
11
+ * @interface UserPreferences
12
+ */
13
+ export interface UserPreferences {
14
+ /** UI theme preference */
15
+ readonly theme: 'light' | 'dark' | 'system';
16
+ /** Language code */
17
+ readonly language: string;
18
+ /** Notification preferences */
19
+ readonly notifications: {
20
+ readonly enabled: boolean;
21
+ readonly sound: boolean;
22
+ readonly desktop: boolean;
23
+ };
24
+ /** Editor preferences */
25
+ readonly editor: {
26
+ readonly fontSize: number;
27
+ readonly fontFamily: string;
28
+ readonly wordWrap: boolean;
29
+ readonly lineNumbers: boolean;
30
+ readonly tabSize: number;
31
+ };
32
+ }
33
+ /**
34
+ * User session information
35
+ * @interface UserSession
36
+ */
37
+ export interface UserSession {
38
+ /** User identifier */
39
+ readonly userId: string;
40
+ /** User display name */
41
+ readonly displayName: string;
42
+ /** User email */
43
+ readonly email: string;
44
+ /** User type/role */
45
+ readonly userType: 'free' | 'pro' | 'enterprise' | 'admin';
46
+ /** Session token */
47
+ readonly token: string;
48
+ /** Session expiration timestamp */
49
+ readonly expiresAt: Date;
50
+ /** Authentication provider */
51
+ readonly provider: 'local' | 'oauth' | 'sso';
52
+ }
53
+ /**
54
+ * Connection status types
55
+ * @typedef {'online' | 'offline' | 'connecting' | 'reconnecting'} ConnectionStatus
56
+ */
57
+ export type ConnectionStatus = 'online' | 'offline' | 'connecting' | 'reconnecting';
58
+ /**
59
+ * Complete application state structure
60
+ * @interface AppState
61
+ */
62
+ export interface AppState {
63
+ /** Current user session, null if not authenticated */
64
+ readonly session: UserSession | null;
65
+ /** User preferences */
66
+ readonly preferences: UserPreferences;
67
+ /** Active conversation messages */
68
+ readonly messages: readonly TypedMessage[];
69
+ /** Connection status to backend services */
70
+ readonly connectionStatus: ConnectionStatus;
71
+ /** Whether the application is currently loading */
72
+ readonly isLoading: boolean;
73
+ /** Current loading message or operation description */
74
+ readonly loadingMessage: string | null;
75
+ /** Active errors to display */
76
+ readonly errors: readonly AppError[];
77
+ /** Current view/route */
78
+ readonly currentView: string;
79
+ /** View-specific state data */
80
+ readonly viewState: Readonly<Record<string, unknown>>;
81
+ /** Timestamp of last state update */
82
+ readonly lastUpdated: Date;
83
+ }
84
+ /**
85
+ * Application error structure
86
+ * @interface AppError
87
+ */
88
+ export interface AppError {
89
+ /** Unique error identifier */
90
+ readonly id: string;
91
+ /** Error severity level */
92
+ readonly severity: 'info' | 'warning' | 'error' | 'critical';
93
+ /** Error code for programmatic handling */
94
+ readonly code: string;
95
+ /** Human-readable error message */
96
+ readonly message: string;
97
+ /** Error timestamp */
98
+ readonly timestamp: Date;
99
+ /** Whether the error has been dismissed by the user */
100
+ readonly dismissed: boolean;
101
+ /** Additional error context */
102
+ readonly context?: Readonly<Record<string, unknown>>;
103
+ }
104
+ /**
105
+ * State change listener callback type
106
+ * @typedef {(state: AppState, prevState: AppState) => void} StateListener
107
+ */
108
+ type StateListener = (state: AppState, prevState: AppState) => void;
109
+ /**
110
+ * Selector function type for deriving values from state
111
+ * @template T
112
+ * @typedef {(state: AppState) => T} StateSelector
113
+ */
114
+ type StateSelector<T> = (state: AppState) => T;
115
+ /**
116
+ * Application state store class
117
+ * Implements the observable store pattern with subscription-based updates
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * const store = new AppStateStore();
122
+ * const unsubscribe = store.subscribe((state, prevState) => {
123
+ * console.log('State updated:', state);
124
+ * });
125
+ * store.setState({ isLoading: true });
126
+ * ```
127
+ */
128
+ export declare class AppStateStore {
129
+ private state;
130
+ private listeners;
131
+ private isBatching;
132
+ private pendingUpdates;
133
+ constructor(initialState?: Partial<AppState>);
134
+ /**
135
+ * Gets the current state
136
+ * @returns {Readonly<AppState>} The current application state
137
+ */
138
+ getState(): Readonly<AppState>;
139
+ /**
140
+ * Gets a derived value from state using a selector function
141
+ *
142
+ * @template T
143
+ * @param {StateSelector<T>} selector - Function to extract value from state
144
+ * @returns {T} The selected value
145
+ * @example
146
+ * ```typescript
147
+ * const userName = store.select(state => state.session?.displayName);
148
+ * ```
149
+ */
150
+ select<T>(selector: StateSelector<T>): T;
151
+ /**
152
+ * Updates the state with partial changes
153
+ * Automatically notifies all subscribers
154
+ *
155
+ * @param {Partial<AppState>} updates - Partial state updates
156
+ * @param {Object} [options] - Update options
157
+ * @param {boolean} [options.silent=false] - If true, does not notify subscribers
158
+ * @returns {Readonly<AppState>} The updated state
159
+ */
160
+ setState(updates: Partial<AppState>, options?: {
161
+ silent?: boolean;
162
+ }): Readonly<AppState>;
163
+ /**
164
+ * Batches multiple state updates into a single notification
165
+ *
166
+ * @param {() => void} callback - Function containing state updates to batch
167
+ * @returns {Readonly<AppState>} The final state after all updates
168
+ * @example
169
+ * ```typescript
170
+ * store.batch(() => {
171
+ * store.setState({ isLoading: true });
172
+ * store.setState({ loadingMessage: 'Fetching data...' });
173
+ * });
174
+ * // Subscribers are notified once after both updates
175
+ * ```
176
+ */
177
+ batch(callback: () => void): Readonly<AppState>;
178
+ /**
179
+ * Subscribes to state changes
180
+ *
181
+ * @param {StateListener} listener - Callback invoked on state changes
182
+ * @returns {() => void} Unsubscribe function
183
+ */
184
+ subscribe(listener: StateListener): () => void;
185
+ /**
186
+ * Subscribes to a specific derived value using a selector
187
+ * Only notifies when the selected value changes
188
+ *
189
+ * @template T
190
+ * @param {StateSelector<T>} selector - Function to extract value
191
+ * @param {(value: T) => void} callback - Callback invoked when value changes
192
+ * @returns {() => void} Unsubscribe function
193
+ * @example
194
+ * ```typescript
195
+ * store.subscribeTo(
196
+ * state => state.connectionStatus,
197
+ * status => console.log('Connection:', status)
198
+ * );
199
+ * ```
200
+ */
201
+ subscribeTo<T>(selector: StateSelector<T>, callback: (value: T) => void): () => void;
202
+ /**
203
+ * Resets the store to initial state
204
+ *
205
+ * @param {Partial<AppState>} [mergeState] - Optional state to merge after reset
206
+ * @returns {Readonly<AppState>} The reset state
207
+ */
208
+ reset(mergeState?: Partial<AppState>): Readonly<AppState>;
209
+ /**
210
+ * Adds an error to the state
211
+ *
212
+ * @param {Omit<AppError, 'id' | 'timestamp' | 'dismissed'>} error - Error details
213
+ * @returns {Readonly<AppState>} The updated state
214
+ */
215
+ addError(error: Omit<AppError, 'id' | 'timestamp' | 'dismissed'>): Readonly<AppState>;
216
+ /**
217
+ * Dismisses an error by ID
218
+ *
219
+ * @param {string} errorId - The error ID to dismiss
220
+ * @returns {Readonly<AppState>} The updated state
221
+ */
222
+ dismissError(errorId: string): Readonly<AppState>;
223
+ /**
224
+ * Clears all dismissed errors
225
+ *
226
+ * @returns {Readonly<AppState>} The updated state
227
+ */
228
+ clearDismissedErrors(): Readonly<AppState>;
229
+ /**
230
+ * Adds a message to the conversation
231
+ *
232
+ * @param {TypedMessage} message - The message to add
233
+ * @returns {Readonly<AppState>} The updated state
234
+ */
235
+ addMessage(message: TypedMessage): Readonly<AppState>;
236
+ /**
237
+ * Clears all messages
238
+ *
239
+ * @returns {Readonly<AppState>} The updated state
240
+ */
241
+ clearMessages(): Readonly<AppState>;
242
+ /**
243
+ * Sets the user session
244
+ *
245
+ * @param {UserSession | null} session - The session or null to logout
246
+ * @returns {Readonly<AppState>} The updated state
247
+ */
248
+ setSession(session: UserSession | null): Readonly<AppState>;
249
+ /**
250
+ * Updates user preferences
251
+ *
252
+ * @param {Partial<UserPreferences>} prefs - Preference updates
253
+ * @returns {Readonly<AppState>} The updated state
254
+ */
255
+ setPreferences(prefs: Partial<UserPreferences>): Readonly<AppState>;
256
+ /**
257
+ * Sets the loading state
258
+ *
259
+ * @param {boolean} isLoading - Whether loading is active
260
+ * @param {string} [message] - Optional loading message
261
+ * @returns {Readonly<AppState>} The updated state
262
+ */
263
+ setLoading(isLoading: boolean, message?: string): Readonly<AppState>;
264
+ /**
265
+ * Updates view-specific state
266
+ *
267
+ * @param {string} view - View identifier
268
+ * @param {unknown} data - View state data
269
+ * @returns {Readonly<AppState>} The updated state
270
+ */
271
+ setViewState(view: string, data: unknown): Readonly<AppState>;
272
+ private notifyListeners;
273
+ }
274
+ /**
275
+ * Gets or creates the global AppStateStore instance
276
+ *
277
+ * @returns {AppStateStore} The global store instance
278
+ */
279
+ export declare function getGlobalStore(): AppStateStore;
280
+ /**
281
+ * Sets the global store instance (useful for testing)
282
+ *
283
+ * @param {AppStateStore | null} store - The store instance or null to reset
284
+ */
285
+ export declare function setGlobalStore(store: AppStateStore | null): void;
286
+ /**
287
+ * React hook for accessing the app state store
288
+ * Provides reactive updates and selector support
289
+ *
290
+ * @template T
291
+ * @param {StateSelector<T>} [selector] - Optional selector function
292
+ * @returns {T | AppState} The selected state or full state
293
+ * @example
294
+ * ```typescript
295
+ * // Get full state
296
+ * const state = useAppStateStore();
297
+ *
298
+ * // Get specific value
299
+ * const isLoading = useAppStateStore(state => state.isLoading);
300
+ *
301
+ * // Get derived value
302
+ * const messageCount = useAppStateStore(state => state.messages.length);
303
+ * ```
304
+ */
305
+ export declare function useAppStateStore<T>(selector?: StateSelector<T>): T | AppState;
306
+ /**
307
+ * React hook for accessing a specific slice of state with optional transformation
308
+ *
309
+ * @template T
310
+ * @param {StateSelector<T>} selector - Function to extract value from state
311
+ * @param {(left: T, right: T) => boolean} [isEqual] - Custom equality function
312
+ * @returns {T} The selected value
313
+ * @example
314
+ * ```typescript
315
+ * const userName = useAppStateSelector(state => state.session?.displayName);
316
+ * ```
317
+ */
318
+ export declare function useAppStateSelector<T>(selector: StateSelector<T>, isEqual?: (left: T, right: T) => boolean): T;
319
+ /**
320
+ * React hook for state setters
321
+ * Returns stable callback functions for common state operations
322
+ *
323
+ * @returns {Object} Object containing state setter callbacks
324
+ * @example
325
+ * ```typescript
326
+ * const { setLoading, addMessage, setSession } = useAppStateActions();
327
+ * ```
328
+ */
329
+ export declare function useAppStateActions(): {
330
+ setState: (updates: Partial<AppState>) => Readonly<AppState>;
331
+ setLoading: (isLoading: boolean, message?: string) => Readonly<AppState>;
332
+ addMessage: (message: TypedMessage) => Readonly<AppState>;
333
+ setSession: (session: UserSession | null) => Readonly<AppState>;
334
+ addError: (error: Omit<AppError, "id" | "timestamp" | "dismissed">) => Readonly<AppState>;
335
+ dismissError: (errorId: string) => Readonly<AppState>;
336
+ setPreferences: (prefs: Partial<UserPreferences>) => Readonly<AppState>;
337
+ clearMessages: () => Readonly<AppState>;
338
+ };
339
+ declare const _default: {
340
+ AppStateStore: typeof AppStateStore;
341
+ getGlobalStore: typeof getGlobalStore;
342
+ setGlobalStore: typeof setGlobalStore;
343
+ useAppStateStore: typeof useAppStateStore;
344
+ useAppStateSelector: typeof useAppStateSelector;
345
+ useAppStateActions: typeof useAppStateActions;
346
+ };
347
+ export default _default;