@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,524 +0,0 @@
1
- /**
2
- * @fileoverview Runtime tool base class and interfaces
3
- * @module runtime/tools/Tool
4
- *
5
- * Defines the abstract base class for all runtime tools, providing
6
- * a standardized interface for tool execution, validation, and schema generation.
7
- * All tools in the gizzi-code runtime must extend this base class.
8
- */
9
-
10
- import type { Message } from '../../types/message.js';
11
-
12
- /**
13
- * Context passed to tools during execution
14
- * @interface ToolContext
15
- */
16
- export interface ToolContext {
17
- /** Unique identifier for the current execution session */
18
- readonly sessionId: string;
19
-
20
- /** Current user identifier */
21
- readonly userId?: string;
22
-
23
- /** Messages in the current conversation context */
24
- readonly messages: readonly Message[];
25
-
26
- /** Abort signal for cancellation support */
27
- readonly signal?: AbortSignal;
28
-
29
- /** Additional metadata for the execution context */
30
- readonly metadata?: Readonly<Record<string, unknown>>;
31
-
32
- /** Callback for reporting progress during long-running operations */
33
- readonly onProgress?: (progress: ToolProgress) => void;
34
- }
35
-
36
- /**
37
- * Progress information for long-running tool operations
38
- * @interface ToolProgress
39
- */
40
- export interface ToolProgress {
41
- /** Current step number */
42
- readonly current: number;
43
-
44
- /** Total number of steps */
45
- readonly total: number;
46
-
47
- /** Human-readable status message */
48
- readonly message: string;
49
-
50
- /** Optional percentage completion (0-100) */
51
- readonly percent?: number;
52
- }
53
-
54
- /**
55
- * JSON Schema property definition for tool parameters
56
- * @interface ToolParameterSchema
57
- */
58
- export interface ToolParameterSchema {
59
- /** Parameter type */
60
- readonly type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'integer';
61
-
62
- /** Human-readable description of the parameter */
63
- readonly description: string;
64
-
65
- /** Whether the parameter is required */
66
- readonly required?: boolean;
67
-
68
- /** Default value for the parameter */
69
- readonly default?: unknown;
70
-
71
- /** Enum values for constrained parameters */
72
- readonly enum?: readonly unknown[];
73
-
74
- /** Array item schema for array types */
75
- readonly items?: ToolParameterSchema;
76
-
77
- /** Object properties schema for object types */
78
- readonly properties?: Readonly<Record<string, ToolParameterSchema>>;
79
-
80
- /** Format hint for string parameters (e.g., 'date', 'email', 'uri') */
81
- readonly format?: string;
82
- }
83
-
84
- /**
85
- * Complete tool schema definition for JSON Schema output
86
- * @interface ToolSchema
87
- */
88
- export interface ToolSchema {
89
- /** Tool name */
90
- readonly name: string;
91
-
92
- /** Tool description */
93
- readonly description: string;
94
-
95
- /** JSON Schema version */
96
- readonly schema: 'http://json-schema.org/draft-07/schema#';
97
-
98
- /** Parameter definitions */
99
- readonly parameters: {
100
- readonly type: 'object';
101
- readonly properties: Readonly<Record<string, ToolParameterSchema>>;
102
- readonly required: readonly string[];
103
- readonly additionalProperties: boolean;
104
- };
105
- }
106
-
107
- /**
108
- * Result of a tool execution
109
- * @interface ToolResult
110
- */
111
- export interface ToolResult<T = unknown> {
112
- /** Whether the execution was successful */
113
- readonly success: boolean;
114
-
115
- /** Result data (only present on success) */
116
- readonly data?: T;
117
-
118
- /** Error information (only present on failure) */
119
- readonly error?: ToolError;
120
-
121
- /** Execution metadata */
122
- readonly metadata?: {
123
- /** Execution duration in milliseconds */
124
- readonly duration: number;
125
-
126
- /** Timestamp when execution completed */
127
- readonly timestamp: Date;
128
-
129
- /** Additional metadata */
130
- readonly [key: string]: unknown;
131
- };
132
- }
133
-
134
- /**
135
- * Tool error information
136
- * @interface ToolError
137
- */
138
- export interface ToolError {
139
- /** Error code for programmatic handling */
140
- readonly code: ToolErrorCode;
141
-
142
- /** Human-readable error message */
143
- readonly message: string;
144
-
145
- /** Additional error details */
146
- readonly details?: Readonly<Record<string, unknown>>;
147
-
148
- /** Original error if wrapped */
149
- readonly cause?: Error;
150
- }
151
-
152
- /**
153
- * Standard tool error codes
154
- * @typedef {'validation_error' | 'execution_error' | 'timeout_error' | 'cancelled_error' | 'permission_error' | 'not_found_error' | 'rate_limit_error' | 'internal_error'} ToolErrorCode
155
- */
156
- export type ToolErrorCode =
157
- | 'validation_error'
158
- | 'execution_error'
159
- | 'timeout_error'
160
- | 'cancelled_error'
161
- | 'permission_error'
162
- | 'not_found_error'
163
- | 'rate_limit_error'
164
- | 'internal_error';
165
-
166
- /**
167
- * Tool parameter definitions mapping
168
- * @type ToolParameters
169
- */
170
- export type ToolParameters = Readonly<Record<string, ToolParameterSchema>>;
171
-
172
- /**
173
- * Abstract base class for all runtime tools
174
- * @abstract
175
- * @class Tool
176
- *
177
- * @example
178
- * ```typescript
179
- * class MyTool extends Tool<{ input: string }, { output: string }> {
180
- * name = 'my_tool';
181
- * description = 'A sample tool';
182
- * parameters = {
183
- * input: {
184
- * type: 'string',
185
- * description: 'Input text',
186
- * required: true
187
- * }
188
- * };
189
- *
190
- * async execute(args: { input: string }, context: ToolContext): Promise<ToolResult<{ output: string }>> {
191
- * return {
192
- * success: true,
193
- * data: { output: args.input.toUpperCase() },
194
- * metadata: { duration: 0, timestamp: new Date() }
195
- * };
196
- * }
197
- * }
198
- * ```
199
- */
200
- export abstract class Tool<TArgs = Record<string, unknown>, TResult = unknown> {
201
- /**
202
- * Unique tool identifier (kebab-case or snake_case)
203
- * @abstract
204
- * @readonly
205
- */
206
- abstract readonly name: string;
207
-
208
- /**
209
- * Human-readable description of what the tool does
210
- * @abstract
211
- * @readonly
212
- */
213
- abstract readonly description: string;
214
-
215
- /**
216
- * Parameter schema definitions for validation and documentation
217
- * @abstract
218
- * @readonly
219
- */
220
- abstract readonly parameters: ToolParameters;
221
-
222
- /**
223
- * Execute the tool with the given arguments and context
224
- * @abstract
225
- * @param {TArgs} args - Validated tool arguments
226
- * @param {ToolContext} context - Execution context
227
- * @returns {Promise<ToolResult<TResult>>} Tool execution result
228
- * @throws {never} Should never throw; errors should be returned as ToolResult with success: false
229
- */
230
- abstract execute(args: TArgs, context: ToolContext): Promise<ToolResult<TResult>>;
231
-
232
- /**
233
- * Validate tool arguments against the parameter schema
234
- * @param {unknown} args - Arguments to validate
235
- * @returns {{ valid: true } | { valid: false; errors: readonly string[] }} Validation result
236
- */
237
- validate(args: unknown): { valid: true } | { valid: false; errors: readonly string[] } {
238
- if (args === null || typeof args !== 'object') {
239
- return { valid: false, errors: ['Arguments must be an object'] };
240
- }
241
-
242
- const errors: string[] = [];
243
- const argsRecord = args as Record<string, unknown>;
244
-
245
- for (const [key, schema] of Object.entries(this.parameters)) {
246
- const value = argsRecord[key];
247
-
248
- // Check required fields
249
- if (schema.required !== false && value === undefined) {
250
- errors.push(`Missing required parameter: ${key}`);
251
- continue;
252
- }
253
-
254
- // Skip validation for undefined optional fields
255
- if (value === undefined) {
256
- continue;
257
- }
258
-
259
- // Type validation
260
- const typeError = this.validateType(key, value, schema);
261
- if (typeError) {
262
- errors.push(typeError);
263
- }
264
-
265
- // Enum validation
266
- if (schema.enum && !schema.enum.includes(value)) {
267
- errors.push(
268
- `Parameter ${key} must be one of: ${schema.enum.join(', ')}`
269
- );
270
- }
271
- }
272
-
273
- // Check for unknown parameters
274
- const knownKeys = Object.keys(this.parameters);
275
- const unknownKeys = Object.keys(argsRecord).filter((k) => !knownKeys.includes(k));
276
- if (unknownKeys.length > 0) {
277
- errors.push(`Unknown parameters: ${unknownKeys.join(', ')}`);
278
- }
279
-
280
- return errors.length === 0 ? { valid: true } : { valid: false, errors };
281
- }
282
-
283
- /**
284
- * Get the JSON Schema representation of this tool
285
- * @returns {ToolSchema} Complete JSON Schema for the tool
286
- */
287
- getSchema(): ToolSchema {
288
- const required = Object.entries(this.parameters)
289
- .filter(([, schema]) => schema.required !== false)
290
- .map(([key]) => key);
291
-
292
- return {
293
- name: this.name,
294
- description: this.description,
295
- schema: 'http://json-schema.org/draft-07/schema#',
296
- parameters: {
297
- type: 'object',
298
- properties: this.parameters,
299
- required,
300
- additionalProperties: false,
301
- },
302
- };
303
- }
304
-
305
- /**
306
- * Validate a single parameter value against its schema
307
- * @private
308
- * @param {string} key - Parameter name
309
- * @param {unknown} value - Parameter value
310
- * @param {ToolParameterSchema} schema - Parameter schema
311
- * @returns {string | null} Error message or null if valid
312
- */
313
- private validateType(
314
- key: string,
315
- value: unknown,
316
- schema: ToolParameterSchema
317
- ): string | null {
318
- const expectedType = schema.type;
319
-
320
- switch (expectedType) {
321
- case 'string':
322
- if (typeof value !== 'string') {
323
- return `Parameter ${key} must be a string`;
324
- }
325
- break;
326
-
327
- case 'number':
328
- case 'integer':
329
- if (typeof value !== 'number' || Number.isNaN(value)) {
330
- return `Parameter ${key} must be a number`;
331
- }
332
- if (expectedType === 'integer' && !Number.isInteger(value)) {
333
- return `Parameter ${key} must be an integer`;
334
- }
335
- break;
336
-
337
- case 'boolean':
338
- if (typeof value !== 'boolean') {
339
- return `Parameter ${key} must be a boolean`;
340
- }
341
- break;
342
-
343
- case 'array':
344
- if (!Array.isArray(value)) {
345
- return `Parameter ${key} must be an array`;
346
- }
347
- if (schema.items) {
348
- for (let i = 0; i < value.length; i++) {
349
- const itemError = this.validateType(`${key}[${i}]`, value[i], schema.items);
350
- if (itemError) {
351
- return itemError;
352
- }
353
- }
354
- }
355
- break;
356
-
357
- case 'object':
358
- if (value === null || typeof value !== 'object' || Array.isArray(value)) {
359
- return `Parameter ${key} must be an object`;
360
- }
361
- if (schema.properties) {
362
- const objValue = value as Record<string, unknown>;
363
- for (const [propKey, propSchema] of Object.entries(schema.properties)) {
364
- const propValue = objValue[propKey];
365
- if (propValue !== undefined) {
366
- const propError = this.validateType(`${key}.${propKey}`, propValue, propSchema);
367
- if (propError) {
368
- return propError;
369
- }
370
- }
371
- }
372
- }
373
- break;
374
-
375
- default:
376
- return `Unknown type for parameter ${key}: ${expectedType}`;
377
- }
378
-
379
- return null;
380
- }
381
-
382
- /**
383
- * Execute with automatic validation (helper method)
384
- * @param {unknown} args - Raw arguments to validate and execute
385
- * @param {ToolContext} context - Execution context
386
- * @returns {Promise<ToolResult<TResult>>} Tool execution result
387
- */
388
- async executeWithValidation(
389
- args: unknown,
390
- context: ToolContext
391
- ): Promise<ToolResult<TResult>> {
392
- const startTime = performance.now();
393
- const timestamp = new Date();
394
-
395
- // Validate arguments
396
- const validation = this.validate(args);
397
- if (!validation.valid) {
398
- return {
399
- success: false,
400
- error: {
401
- code: 'validation_error',
402
- message: `Validation failed: ${validation.errors.join(', ')}`,
403
- details: { errors: validation.errors },
404
- },
405
- metadata: {
406
- duration: Math.round(performance.now() - startTime),
407
- timestamp,
408
- },
409
- };
410
- }
411
-
412
- // Check for cancellation before execution
413
- if (context.signal?.aborted) {
414
- return {
415
- success: false,
416
- error: {
417
- code: 'cancelled_error',
418
- message: 'Tool execution was cancelled',
419
- },
420
- metadata: {
421
- duration: Math.round(performance.now() - startTime),
422
- timestamp,
423
- },
424
- };
425
- }
426
-
427
- try {
428
- const result = await this.execute(args as TArgs, context);
429
-
430
- // Add metadata if not present
431
- if (!result.metadata) {
432
- return {
433
- ...result,
434
- metadata: {
435
- duration: Math.round(performance.now() - startTime),
436
- timestamp,
437
- },
438
- };
439
- }
440
-
441
- return result;
442
- } catch (error) {
443
- return {
444
- success: false,
445
- error: {
446
- code: 'execution_error',
447
- message: error instanceof Error ? error.message : 'Unknown error occurred',
448
- cause: error instanceof Error ? error : undefined,
449
- },
450
- metadata: {
451
- duration: Math.round(performance.now() - startTime),
452
- timestamp,
453
- },
454
- };
455
- }
456
- }
457
- }
458
-
459
- /**
460
- * Type guard to check if a value is a ToolError
461
- * @param {unknown} value - Value to check
462
- * @returns {boolean} True if the value is a ToolError
463
- */
464
- export function isToolError(value: unknown): value is ToolError {
465
- return (
466
- typeof value === 'object' &&
467
- value !== null &&
468
- 'code' in value &&
469
- 'message' in value &&
470
- typeof (value as ToolError).code === 'string' &&
471
- typeof (value as ToolError).message === 'string'
472
- );
473
- }
474
-
475
- /**
476
- * Create a successful tool result
477
- * @template T
478
- * @param {T} data - Result data
479
- * @param {Partial<ToolResult<T>['metadata']>} metadata - Optional metadata
480
- * @returns {ToolResult<T>} Successful tool result
481
- */
482
- export function createSuccessResult<T>(
483
- data: T,
484
- metadata?: Partial<ToolResult<T>['metadata']>
485
- ): ToolResult<T> {
486
- return {
487
- success: true,
488
- data,
489
- metadata: {
490
- duration: 0,
491
- timestamp: new Date(),
492
- ...metadata,
493
- },
494
- };
495
- }
496
-
497
- /**
498
- * Create an error tool result
499
- * @param {ToolErrorCode} code - Error code
500
- * @param {string} message - Error message
501
- * @param {Partial<ToolError>} details - Additional error details
502
- * @returns {ToolResult<never>} Error tool result
503
- */
504
- export function createErrorResult(
505
- code: ToolErrorCode,
506
- message: string,
507
- details?: Partial<ToolError>
508
- ): ToolResult<never> {
509
- return {
510
- success: false,
511
- error: {
512
- code,
513
- message,
514
- ...details,
515
- },
516
- metadata: {
517
- duration: 0,
518
- timestamp: new Date(),
519
- },
520
- };
521
- }
522
-
523
- // Default export
524
- export default Tool;
@@ -1,98 +0,0 @@
1
- /**
2
- * Gizzi Task Scheduler
3
- *
4
- * Manages recurring tasks from HEARTBEAT.md
5
- * - Daily tasks: Run every 24 hours
6
- * - Weekly tasks: Run every 7 days
7
- * - Monthly tasks: Run every 30 days
8
- */
9
- export type TaskFrequency = 'startup' | 'daily' | 'weekly' | 'monthly';
10
- export interface ScheduledTask {
11
- id: string;
12
- action: string;
13
- frequency: TaskFrequency;
14
- completed: boolean;
15
- lastRun?: Date;
16
- nextRun?: Date;
17
- }
18
- export interface SchedulerJob {
19
- id: string;
20
- taskId: string;
21
- agentId: string;
22
- frequency: TaskFrequency;
23
- nextRunAt: number;
24
- lastRunAt?: number;
25
- enabled: boolean;
26
- }
27
- /**
28
- * Task Scheduler for Gizzi
29
- */
30
- export declare class TaskScheduler {
31
- private jobs;
32
- private intervalId;
33
- private checkIntervalMs;
34
- private isRunning;
35
- private onTaskExecute?;
36
- constructor(options?: {
37
- checkIntervalMs?: number;
38
- onTaskExecute?: (task: SchedulerJob) => Promise<void>;
39
- });
40
- /**
41
- * Start the scheduler
42
- */
43
- start(): void;
44
- /**
45
- * Stop the scheduler
46
- */
47
- stop(): void;
48
- /**
49
- * Register tasks from HEARTBEAT.md
50
- */
51
- registerTasks(agentId: string, tasks: ScheduledTask[]): void;
52
- /**
53
- * Unregister all tasks for an agent
54
- */
55
- unregisterAgentTasks(agentId: string): void;
56
- /**
57
- * Get all jobs
58
- */
59
- getJobs(): SchedulerJob[];
60
- /**
61
- * Get jobs for a specific agent
62
- */
63
- getJobsForAgent(agentId: string): SchedulerJob[];
64
- /**
65
- * Get jobs that are due for execution
66
- */
67
- getDueJobs(): SchedulerJob[];
68
- /**
69
- * Get scheduler status
70
- */
71
- getStatus(): {
72
- isRunning: boolean;
73
- totalJobs: number;
74
- dueJobs: number;
75
- nextJob: SchedulerJob | null;
76
- };
77
- /**
78
- * Enable a job
79
- */
80
- enableJob(jobId: string): void;
81
- /**
82
- * Disable a job
83
- */
84
- disableJob(jobId: string): void;
85
- /**
86
- * Record job execution
87
- */
88
- recordExecution(jobId: string, success: boolean): void;
89
- /**
90
- * Check and execute due jobs
91
- */
92
- private checkAndExecuteJobs;
93
- /**
94
- * Execute a single job
95
- */
96
- private executeJob;
97
- }
98
- export declare const taskScheduler: TaskScheduler;