art-framework 0.4.13 → 0.4.15
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.
- package/README.md +27 -29
- package/dist/index.cjs +44 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +678 -8
- package/dist/index.d.ts +678 -8
- package/dist/index.js +44 -33
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -51,6 +51,484 @@ declare class TypedSocket<DataType, FilterType = any> {
|
|
|
51
51
|
clearAllSubscriptions(): void;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* @module types/hitl-types
|
|
56
|
+
*
|
|
57
|
+
* This module defines the types and contracts for Human-in-the-Loop (HITL) functionality
|
|
58
|
+
* in the ART framework. It establishes a clear contract for blocking tools to declare
|
|
59
|
+
* expected feedback types and for the framework to programmatically handle user responses.
|
|
60
|
+
*
|
|
61
|
+
* Key Design Principle:
|
|
62
|
+
* User feedback IS the tool result. When a user provides feedback (approval, text input,
|
|
63
|
+
* selection, etc.), the framework programmatically marks the tool call as SUCCESS with
|
|
64
|
+
* the feedback as the output. The LLM never needs to re-invoke the tool.
|
|
65
|
+
*/
|
|
66
|
+
/**
|
|
67
|
+
* Defines the three categories of tools in the ART framework.
|
|
68
|
+
*
|
|
69
|
+
* @remarks
|
|
70
|
+
* Each category has different execution semantics and framework handling:
|
|
71
|
+
*
|
|
72
|
+
* - `functional`: Regular tools that execute synchronously and return results immediately.
|
|
73
|
+
* Examples: webSearch, calculator, fileRead, apiCall
|
|
74
|
+
*
|
|
75
|
+
* - `blocking`: Tools that require human input to complete. They return 'suspended' status
|
|
76
|
+
* initially, and the framework waits for user feedback. The user's feedback becomes
|
|
77
|
+
* the tool's result - no re-execution needed.
|
|
78
|
+
* Examples: confirmAction, getUserInput, selectOption, requestApproval
|
|
79
|
+
*
|
|
80
|
+
* - `display`: Tools for generative UI that render content without producing a traditional
|
|
81
|
+
* "result". They complete immediately but their output is visual/interactive.
|
|
82
|
+
* Examples: renderChart, showModal, displayProgress, generateUI
|
|
83
|
+
*/
|
|
84
|
+
type ToolExecutionMode = 'functional' | 'blocking' | 'display';
|
|
85
|
+
/**
|
|
86
|
+
* Defines the type of user input expected for HITL feedback.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* This enables blocking tools to declare what kind of UI the application
|
|
90
|
+
* should render to collect user feedback.
|
|
91
|
+
*/
|
|
92
|
+
type HITLInputType = 'boolean' | 'text' | 'select' | 'multiselect' | 'number' | 'date' | 'datetime' | 'file' | 'confirm' | 'custom';
|
|
93
|
+
/**
|
|
94
|
+
* Schema for what kind of feedback a blocking tool expects.
|
|
95
|
+
*
|
|
96
|
+
* @remarks
|
|
97
|
+
* Tools declare this schema to inform the UI layer what input to collect.
|
|
98
|
+
* The framework uses this to validate feedback and construct the tool result.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* // Simple confirmation
|
|
102
|
+
* {
|
|
103
|
+
* inputType: 'confirm',
|
|
104
|
+
* prompt: 'Are you sure you want to delete this file?',
|
|
105
|
+
* confirmLabel: 'Delete',
|
|
106
|
+
* cancelLabel: 'Keep'
|
|
107
|
+
* }
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* // Selection from options
|
|
111
|
+
* {
|
|
112
|
+
* inputType: 'select',
|
|
113
|
+
* prompt: 'Which deployment environment should we use?',
|
|
114
|
+
* options: [
|
|
115
|
+
* { value: 'staging', label: 'Staging', description: 'Test environment' },
|
|
116
|
+
* { value: 'production', label: 'Production', description: 'Live environment' }
|
|
117
|
+
* ],
|
|
118
|
+
* required: true
|
|
119
|
+
* }
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* // Text input with validation
|
|
123
|
+
* {
|
|
124
|
+
* inputType: 'text',
|
|
125
|
+
* prompt: 'Please provide the API key for the service:',
|
|
126
|
+
* placeholder: 'sk-...',
|
|
127
|
+
* validation: {
|
|
128
|
+
* required: true,
|
|
129
|
+
* pattern: '^sk-[a-zA-Z0-9]{32,}$',
|
|
130
|
+
* patternMessage: 'Must be a valid API key starting with sk-'
|
|
131
|
+
* }
|
|
132
|
+
* }
|
|
133
|
+
*/
|
|
134
|
+
interface HITLFeedbackSchema {
|
|
135
|
+
/**
|
|
136
|
+
* The type of input expected from the user.
|
|
137
|
+
*/
|
|
138
|
+
inputType: HITLInputType;
|
|
139
|
+
/**
|
|
140
|
+
* Human-readable prompt shown to the user.
|
|
141
|
+
* This should clearly explain what input is needed and why.
|
|
142
|
+
*/
|
|
143
|
+
prompt: string;
|
|
144
|
+
/**
|
|
145
|
+
* Optional title for the feedback dialog/section.
|
|
146
|
+
*/
|
|
147
|
+
title?: string;
|
|
148
|
+
/**
|
|
149
|
+
* For select/multiselect: available options to choose from.
|
|
150
|
+
*/
|
|
151
|
+
options?: HITLSelectOption[];
|
|
152
|
+
/**
|
|
153
|
+
* Validation constraints for the input.
|
|
154
|
+
*/
|
|
155
|
+
validation?: HITLInputValidation;
|
|
156
|
+
/**
|
|
157
|
+
* Optional default value to pre-fill.
|
|
158
|
+
*/
|
|
159
|
+
defaultValue?: unknown;
|
|
160
|
+
/**
|
|
161
|
+
* Placeholder text for text/number inputs.
|
|
162
|
+
*/
|
|
163
|
+
placeholder?: string;
|
|
164
|
+
/**
|
|
165
|
+
* For confirm type: custom label for the approve button.
|
|
166
|
+
* @default 'Approve'
|
|
167
|
+
*/
|
|
168
|
+
confirmLabel?: string;
|
|
169
|
+
/**
|
|
170
|
+
* For confirm type: custom label for the reject button.
|
|
171
|
+
* @default 'Reject'
|
|
172
|
+
*/
|
|
173
|
+
cancelLabel?: string;
|
|
174
|
+
/**
|
|
175
|
+
* If true, user can modify the original tool arguments before submitting.
|
|
176
|
+
* The modified args are returned in the feedback.
|
|
177
|
+
* @default false
|
|
178
|
+
*/
|
|
179
|
+
allowModifyArgs?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* For custom inputType: application-defined JSON schema for the input.
|
|
182
|
+
*/
|
|
183
|
+
customSchema?: Record<string, unknown>;
|
|
184
|
+
/**
|
|
185
|
+
* Optional hint text shown below the input.
|
|
186
|
+
*/
|
|
187
|
+
hint?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Whether this is a sensitive input (e.g., password, API key).
|
|
190
|
+
* UI should mask the input if true.
|
|
191
|
+
* @default false
|
|
192
|
+
*/
|
|
193
|
+
sensitive?: boolean;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* An option for select/multiselect input types.
|
|
197
|
+
*/
|
|
198
|
+
interface HITLSelectOption {
|
|
199
|
+
/**
|
|
200
|
+
* The value returned when this option is selected.
|
|
201
|
+
*/
|
|
202
|
+
value: string | number | boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Human-readable label displayed to the user.
|
|
205
|
+
*/
|
|
206
|
+
label: string;
|
|
207
|
+
/**
|
|
208
|
+
* Optional description providing more context about this option.
|
|
209
|
+
*/
|
|
210
|
+
description?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Whether this option is disabled (shown but not selectable).
|
|
213
|
+
* @default false
|
|
214
|
+
*/
|
|
215
|
+
disabled?: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Optional icon identifier for UI rendering.
|
|
218
|
+
*/
|
|
219
|
+
icon?: string;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Validation constraints for HITL input.
|
|
223
|
+
*/
|
|
224
|
+
interface HITLInputValidation {
|
|
225
|
+
/**
|
|
226
|
+
* Whether the input is required (non-empty).
|
|
227
|
+
* @default false
|
|
228
|
+
*/
|
|
229
|
+
required?: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* For text: minimum character length.
|
|
232
|
+
*/
|
|
233
|
+
minLength?: number;
|
|
234
|
+
/**
|
|
235
|
+
* For text: maximum character length.
|
|
236
|
+
*/
|
|
237
|
+
maxLength?: number;
|
|
238
|
+
/**
|
|
239
|
+
* For number: minimum value.
|
|
240
|
+
*/
|
|
241
|
+
min?: number;
|
|
242
|
+
/**
|
|
243
|
+
* For number: maximum value.
|
|
244
|
+
*/
|
|
245
|
+
max?: number;
|
|
246
|
+
/**
|
|
247
|
+
* For text: regex pattern the input must match.
|
|
248
|
+
*/
|
|
249
|
+
pattern?: string;
|
|
250
|
+
/**
|
|
251
|
+
* Custom error message when pattern validation fails.
|
|
252
|
+
*/
|
|
253
|
+
patternMessage?: string;
|
|
254
|
+
/**
|
|
255
|
+
* For multiselect: minimum number of selections required.
|
|
256
|
+
*/
|
|
257
|
+
minSelections?: number;
|
|
258
|
+
/**
|
|
259
|
+
* For multiselect: maximum number of selections allowed.
|
|
260
|
+
*/
|
|
261
|
+
maxSelections?: number;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* The standardized feedback structure returned by the user.
|
|
265
|
+
*
|
|
266
|
+
* @remarks
|
|
267
|
+
* This is the canonical format for user feedback. The framework converts this
|
|
268
|
+
* into a successful tool result when resuming execution. The LLM sees this
|
|
269
|
+
* as a normal tool completion.
|
|
270
|
+
*/
|
|
271
|
+
interface HITLFeedback {
|
|
272
|
+
/**
|
|
273
|
+
* Whether the action was approved/confirmed.
|
|
274
|
+
* For non-boolean input types, this is true if the user submitted
|
|
275
|
+
* (vs. cancelled/dismissed).
|
|
276
|
+
*/
|
|
277
|
+
approved: boolean;
|
|
278
|
+
/**
|
|
279
|
+
* The user's input value, type depends on the inputType:
|
|
280
|
+
* - boolean: true/false
|
|
281
|
+
* - text: string
|
|
282
|
+
* - number: number
|
|
283
|
+
* - select: the selected option's value
|
|
284
|
+
* - multiselect: array of selected values
|
|
285
|
+
* - date/datetime: ISO string
|
|
286
|
+
* - file: file reference object
|
|
287
|
+
* - confirm: undefined (use approved field)
|
|
288
|
+
* - custom: matches customSchema
|
|
289
|
+
*/
|
|
290
|
+
value?: unknown;
|
|
291
|
+
/**
|
|
292
|
+
* For text input type, the raw text entered.
|
|
293
|
+
* @deprecated Use `value` instead
|
|
294
|
+
*/
|
|
295
|
+
textInput?: string;
|
|
296
|
+
/**
|
|
297
|
+
* For select/multiselect, the selected value(s).
|
|
298
|
+
* @deprecated Use `value` instead
|
|
299
|
+
*/
|
|
300
|
+
selectedValues?: (string | number | boolean)[];
|
|
301
|
+
/**
|
|
302
|
+
* Modified tool arguments if allowModifyArgs was true and user modified them.
|
|
303
|
+
*/
|
|
304
|
+
modifiedArgs?: Record<string, unknown>;
|
|
305
|
+
/**
|
|
306
|
+
* Optional reason/comment provided by the user.
|
|
307
|
+
* Particularly useful for rejections to explain why.
|
|
308
|
+
*/
|
|
309
|
+
reason?: string;
|
|
310
|
+
/**
|
|
311
|
+
* Timestamp when feedback was provided.
|
|
312
|
+
*/
|
|
313
|
+
timestamp: number;
|
|
314
|
+
/**
|
|
315
|
+
* Optional metadata about the feedback context.
|
|
316
|
+
*/
|
|
317
|
+
metadata?: Record<string, unknown>;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Configuration for blocking tools in the ToolSchema.
|
|
321
|
+
*
|
|
322
|
+
* @remarks
|
|
323
|
+
* This is added to ToolSchema when executionMode is 'blocking'.
|
|
324
|
+
* It defines how the tool interacts with the HITL system.
|
|
325
|
+
*/
|
|
326
|
+
interface BlockingToolConfig {
|
|
327
|
+
/**
|
|
328
|
+
* The schema for feedback this tool expects.
|
|
329
|
+
* If not provided, defaults to a simple confirm schema.
|
|
330
|
+
*/
|
|
331
|
+
feedbackSchema?: HITLFeedbackSchema;
|
|
332
|
+
/**
|
|
333
|
+
* Message to show in the approval dialog.
|
|
334
|
+
* Can include {{variable}} placeholders that will be replaced
|
|
335
|
+
* with values from the tool's input arguments.
|
|
336
|
+
*/
|
|
337
|
+
approvalPrompt?: string;
|
|
338
|
+
/**
|
|
339
|
+
* Whether the tool auto-completes successfully when approved.
|
|
340
|
+
* If true (default), approval = success with feedback as output.
|
|
341
|
+
* If false, the tool's execute() is called again with hitlContext.
|
|
342
|
+
* @default true
|
|
343
|
+
*/
|
|
344
|
+
completesOnApproval?: boolean;
|
|
345
|
+
/**
|
|
346
|
+
* Whether rejection allows retry with modified arguments.
|
|
347
|
+
* If true, rejection doesn't fail the step but allows re-planning.
|
|
348
|
+
* @default true
|
|
349
|
+
*/
|
|
350
|
+
allowRetryOnReject?: boolean;
|
|
351
|
+
/**
|
|
352
|
+
* Timeout in milliseconds for user response.
|
|
353
|
+
* If exceeded, the tool fails with a timeout error.
|
|
354
|
+
* @default undefined (no timeout)
|
|
355
|
+
*/
|
|
356
|
+
timeoutMs?: number;
|
|
357
|
+
/**
|
|
358
|
+
* Category of the blocking action for UI grouping.
|
|
359
|
+
* Examples: 'destructive', 'financial', 'external', 'sensitive'
|
|
360
|
+
*/
|
|
361
|
+
category?: string;
|
|
362
|
+
/**
|
|
363
|
+
* Risk level for UI styling/warnings.
|
|
364
|
+
*/
|
|
365
|
+
riskLevel?: 'low' | 'medium' | 'high' | 'critical';
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Configuration for display tools in the ToolSchema.
|
|
369
|
+
*
|
|
370
|
+
* @remarks
|
|
371
|
+
* This is added to ToolSchema when executionMode is 'display'.
|
|
372
|
+
* Display tools render UI without producing traditional results.
|
|
373
|
+
*/
|
|
374
|
+
interface DisplayToolConfig {
|
|
375
|
+
/**
|
|
376
|
+
* The type of UI component this tool renders.
|
|
377
|
+
*/
|
|
378
|
+
componentType?: string;
|
|
379
|
+
/**
|
|
380
|
+
* Whether the display persists or is ephemeral.
|
|
381
|
+
* @default 'persistent'
|
|
382
|
+
*/
|
|
383
|
+
displayMode?: 'persistent' | 'ephemeral' | 'modal';
|
|
384
|
+
/**
|
|
385
|
+
* Whether this display supports user interaction.
|
|
386
|
+
* If true, interactions may generate new messages.
|
|
387
|
+
* @default false
|
|
388
|
+
*/
|
|
389
|
+
interactive?: boolean;
|
|
390
|
+
/**
|
|
391
|
+
* Schema for the data this display component expects.
|
|
392
|
+
*/
|
|
393
|
+
dataSchema?: Record<string, unknown>;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* HITL-specific context passed to tools via ExecutionContext.
|
|
397
|
+
*
|
|
398
|
+
* @remarks
|
|
399
|
+
* This enables blocking tools to know if they're being called
|
|
400
|
+
* for initial suspension vs. post-approval execution.
|
|
401
|
+
*/
|
|
402
|
+
interface HITLContext {
|
|
403
|
+
/**
|
|
404
|
+
* True if this execution is resuming from a previous suspension.
|
|
405
|
+
*/
|
|
406
|
+
isResuming: boolean;
|
|
407
|
+
/**
|
|
408
|
+
* True if the user approved the action.
|
|
409
|
+
* Only meaningful when isResuming is true.
|
|
410
|
+
*/
|
|
411
|
+
wasApproved?: boolean;
|
|
412
|
+
/**
|
|
413
|
+
* The user's feedback if resuming from approval.
|
|
414
|
+
*/
|
|
415
|
+
feedback?: HITLFeedback;
|
|
416
|
+
/**
|
|
417
|
+
* The original suspension ID being resumed.
|
|
418
|
+
*/
|
|
419
|
+
suspensionId?: string;
|
|
420
|
+
/**
|
|
421
|
+
* The original tool arguments that were suspended.
|
|
422
|
+
*/
|
|
423
|
+
originalArgs?: Record<string, unknown>;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Extended ToolResult for blocking tools that return 'suspended' status.
|
|
427
|
+
*
|
|
428
|
+
* @remarks
|
|
429
|
+
* When a blocking tool returns 'suspended', it should include the
|
|
430
|
+
* feedbackSchema so the UI knows what to render.
|
|
431
|
+
*/
|
|
432
|
+
interface BlockingToolSuspendedResult {
|
|
433
|
+
status: 'suspended';
|
|
434
|
+
callId: string;
|
|
435
|
+
toolName: string;
|
|
436
|
+
/**
|
|
437
|
+
* The feedback schema for the UI to render.
|
|
438
|
+
* If not provided, the framework uses the tool's schema config.
|
|
439
|
+
*/
|
|
440
|
+
feedbackSchema?: HITLFeedbackSchema;
|
|
441
|
+
/**
|
|
442
|
+
* Display content to show in the suspension UI.
|
|
443
|
+
*/
|
|
444
|
+
output?: {
|
|
445
|
+
message: string;
|
|
446
|
+
details?: Record<string, unknown>;
|
|
447
|
+
previewData?: unknown;
|
|
448
|
+
};
|
|
449
|
+
/**
|
|
450
|
+
* Metadata including the suspensionId.
|
|
451
|
+
*/
|
|
452
|
+
metadata?: {
|
|
453
|
+
suspensionId: string;
|
|
454
|
+
[key: string]: unknown;
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* The successful result created by the framework when user provides feedback.
|
|
459
|
+
*
|
|
460
|
+
* @remarks
|
|
461
|
+
* This is what the LLM sees after resumption - a normal successful tool result.
|
|
462
|
+
* The content field contains a description, and output contains the feedback.
|
|
463
|
+
*/
|
|
464
|
+
interface BlockingToolCompletedResult {
|
|
465
|
+
status: 'success';
|
|
466
|
+
callId: string;
|
|
467
|
+
toolName: string;
|
|
468
|
+
/**
|
|
469
|
+
* The user's feedback structured as the tool output.
|
|
470
|
+
*/
|
|
471
|
+
output: {
|
|
472
|
+
/**
|
|
473
|
+
* Human-readable summary of what happened.
|
|
474
|
+
*/
|
|
475
|
+
message: string;
|
|
476
|
+
/**
|
|
477
|
+
* The feedback provided by the user.
|
|
478
|
+
*/
|
|
479
|
+
feedback: HITLFeedback;
|
|
480
|
+
/**
|
|
481
|
+
* Whether the user approved the action.
|
|
482
|
+
*/
|
|
483
|
+
approved: boolean;
|
|
484
|
+
/**
|
|
485
|
+
* The actual value provided (varies by input type).
|
|
486
|
+
*/
|
|
487
|
+
value?: unknown;
|
|
488
|
+
};
|
|
489
|
+
/**
|
|
490
|
+
* Metadata about the completion.
|
|
491
|
+
*/
|
|
492
|
+
metadata?: {
|
|
493
|
+
/**
|
|
494
|
+
* The original suspension ID that was resumed.
|
|
495
|
+
*/
|
|
496
|
+
suspensionId?: string;
|
|
497
|
+
/**
|
|
498
|
+
* Timestamp of when feedback was received.
|
|
499
|
+
*/
|
|
500
|
+
completedAt: number;
|
|
501
|
+
/**
|
|
502
|
+
* Duration from suspension to completion in ms.
|
|
503
|
+
*/
|
|
504
|
+
waitDurationMs?: number;
|
|
505
|
+
[key: string]: unknown;
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Type guard to check if a ToolResult is a suspended blocking tool result.
|
|
510
|
+
*/
|
|
511
|
+
declare function isBlockingSuspendedResult(result: {
|
|
512
|
+
status: string;
|
|
513
|
+
}): result is BlockingToolSuspendedResult;
|
|
514
|
+
/**
|
|
515
|
+
* Type guard to check if feedback indicates approval.
|
|
516
|
+
*/
|
|
517
|
+
declare function isFeedbackApproved(feedback: HITLFeedback): boolean;
|
|
518
|
+
/**
|
|
519
|
+
* Creates a standardized successful result from HITL feedback.
|
|
520
|
+
*
|
|
521
|
+
* @param originalCall - The original tool call that was suspended
|
|
522
|
+
* @param feedback - The user's feedback
|
|
523
|
+
* @param suspensionId - The suspension ID being resolved
|
|
524
|
+
* @returns A properly formatted successful ToolResult
|
|
525
|
+
*/
|
|
526
|
+
declare function createHITLSuccessResult(originalCall: {
|
|
527
|
+
callId: string;
|
|
528
|
+
toolName: string;
|
|
529
|
+
arguments?: unknown;
|
|
530
|
+
}, feedback: HITLFeedback, suspensionId?: string): BlockingToolCompletedResult;
|
|
531
|
+
|
|
54
532
|
/**
|
|
55
533
|
* Entry defining an available provider adapter.
|
|
56
534
|
*
|
|
@@ -839,6 +1317,158 @@ interface ExecutionOutput {
|
|
|
839
1317
|
todoList?: TodoItem[];
|
|
840
1318
|
};
|
|
841
1319
|
}
|
|
1320
|
+
/**
|
|
1321
|
+
* Represents the type of change that occurred to a TodoItem during
|
|
1322
|
+
* dynamic plan updates.
|
|
1323
|
+
*
|
|
1324
|
+
* @enum {string}
|
|
1325
|
+
*/
|
|
1326
|
+
declare enum TodoItemChangeType {
|
|
1327
|
+
/** A new item was added to the plan during execution. */
|
|
1328
|
+
ADDED = "added",
|
|
1329
|
+
/** An existing item was modified. */
|
|
1330
|
+
MODIFIED = "modified",
|
|
1331
|
+
/** An item was removed from the plan. */
|
|
1332
|
+
REMOVED = "removed"
|
|
1333
|
+
}
|
|
1334
|
+
/**
|
|
1335
|
+
* Describes a single change to a TodoItem during dynamic plan updates.
|
|
1336
|
+
*
|
|
1337
|
+
* The presence of optional fields depends on the change type:
|
|
1338
|
+
* - ADDED: `item` is present
|
|
1339
|
+
* - MODIFIED: both `item` and `previousItem` are present
|
|
1340
|
+
* - REMOVED: only `previousItem` is present
|
|
1341
|
+
*
|
|
1342
|
+
* @interface TodoItemChange
|
|
1343
|
+
*/
|
|
1344
|
+
interface TodoItemChange {
|
|
1345
|
+
/**
|
|
1346
|
+
* The type of change that occurred.
|
|
1347
|
+
* @property {TodoItemChangeType} type
|
|
1348
|
+
*/
|
|
1349
|
+
type: TodoItemChangeType;
|
|
1350
|
+
/**
|
|
1351
|
+
* The ID of the TodoItem that changed.
|
|
1352
|
+
* @property {string} itemId
|
|
1353
|
+
*/
|
|
1354
|
+
itemId: string;
|
|
1355
|
+
/**
|
|
1356
|
+
* When this change was detected (Unix timestamp in milliseconds).
|
|
1357
|
+
* @property {number} timestamp
|
|
1358
|
+
*/
|
|
1359
|
+
timestamp: number;
|
|
1360
|
+
/**
|
|
1361
|
+
* For ADDED and MODIFIED changes: the new state of the item.
|
|
1362
|
+
* @property {TodoItem} [item]
|
|
1363
|
+
*/
|
|
1364
|
+
item?: TodoItem;
|
|
1365
|
+
/**
|
|
1366
|
+
* For MODIFIED changes: the state before modification.
|
|
1367
|
+
* For REMOVED changes: the state before removal.
|
|
1368
|
+
* @property {TodoItem} [previousItem]
|
|
1369
|
+
*/
|
|
1370
|
+
previousItem?: TodoItem;
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Describes the changes made to a todo list during dynamic plan updates.
|
|
1374
|
+
* Provides both a flat array of all changes and convenience accessors
|
|
1375
|
+
* for common filtering patterns.
|
|
1376
|
+
*
|
|
1377
|
+
* @interface TodoListChanges
|
|
1378
|
+
*/
|
|
1379
|
+
interface TodoListChanges {
|
|
1380
|
+
/**
|
|
1381
|
+
* When these changes were detected (Unix timestamp in milliseconds).
|
|
1382
|
+
* @property {number} timestamp
|
|
1383
|
+
*/
|
|
1384
|
+
timestamp: number;
|
|
1385
|
+
/**
|
|
1386
|
+
* All changes as a flat array - the single source of truth.
|
|
1387
|
+
* @property {TodoItemChange[]} changes
|
|
1388
|
+
*/
|
|
1389
|
+
changes: TodoItemChange[];
|
|
1390
|
+
/**
|
|
1391
|
+
* Convenience accessor for items that were added.
|
|
1392
|
+
* Filters the changes array to include only ADDED type changes.
|
|
1393
|
+
* @property {TodoItemChange[]} added
|
|
1394
|
+
*/
|
|
1395
|
+
added: TodoItemChange[];
|
|
1396
|
+
/**
|
|
1397
|
+
* Convenience accessor for items that were modified.
|
|
1398
|
+
* Filters the changes array to include only MODIFIED type changes.
|
|
1399
|
+
* @property {TodoItemChange[]} modified
|
|
1400
|
+
*/
|
|
1401
|
+
modified: TodoItemChange[];
|
|
1402
|
+
/**
|
|
1403
|
+
* Convenience accessor for items that were removed.
|
|
1404
|
+
* Filters the changes array to include only REMOVED type changes.
|
|
1405
|
+
* @property {TodoItemChange[]} removed
|
|
1406
|
+
*/
|
|
1407
|
+
removed: TodoItemChange[];
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
/**
|
|
1411
|
+
* @module utils/todo-diff
|
|
1412
|
+
*
|
|
1413
|
+
* Utilities for computing differences between todo lists during dynamic plan updates.
|
|
1414
|
+
* Provides efficient O(n + m) diff algorithm for tracking changes.
|
|
1415
|
+
*/
|
|
1416
|
+
|
|
1417
|
+
/**
|
|
1418
|
+
* Computes the differences between two todo lists.
|
|
1419
|
+
*
|
|
1420
|
+
* This function compares the previous and current todo lists to determine:
|
|
1421
|
+
* - Which items are new (added)
|
|
1422
|
+
* - Which items were modified
|
|
1423
|
+
* - Which items were removed
|
|
1424
|
+
*
|
|
1425
|
+
* Time Complexity: O(n + m) where n = previous length, m = current length
|
|
1426
|
+
* Space Complexity: O(n + m) for the result
|
|
1427
|
+
*
|
|
1428
|
+
* @param previous - The previous todo list state (before changes). Can be undefined or null.
|
|
1429
|
+
* @param current - The current todo list state (after changes). Can be undefined or null.
|
|
1430
|
+
* @returns A TodoListChanges object describing all detected changes.
|
|
1431
|
+
*
|
|
1432
|
+
* @example
|
|
1433
|
+
* ```ts
|
|
1434
|
+
* const previous = [
|
|
1435
|
+
* createTodoItem('1', 'Task 1'),
|
|
1436
|
+
* createTodoItem('2', 'Task 2')
|
|
1437
|
+
* ];
|
|
1438
|
+
* const current = [
|
|
1439
|
+
* createTodoItem('1', 'Task 1'),
|
|
1440
|
+
* createTodoItem('2', 'Task 2 Updated'),
|
|
1441
|
+
* createTodoItem('3', 'Task 3')
|
|
1442
|
+
* ];
|
|
1443
|
+
*
|
|
1444
|
+
* const changes = computeTodoListDiff(previous, current);
|
|
1445
|
+
* // changes.added.length === 1 (Task 3)
|
|
1446
|
+
* // changes.modified.length === 1 (Task 2)
|
|
1447
|
+
* // changes.removed.length === 0
|
|
1448
|
+
* ```
|
|
1449
|
+
*/
|
|
1450
|
+
declare function computeTodoListDiff(previous: TodoItem[] | undefined | null, current: TodoItem[] | undefined | null): TodoListChanges;
|
|
1451
|
+
/**
|
|
1452
|
+
* Creates initial TodoListChanges where all items are marked as added.
|
|
1453
|
+
*
|
|
1454
|
+
* This is used during the initial planning phase when a brand new todo list
|
|
1455
|
+
* is created. Since there was no previous state, all items are marked as
|
|
1456
|
+
* ADDED rather than MODIFIED.
|
|
1457
|
+
*
|
|
1458
|
+
* @param todoList - The initial todo list from the planning phase. Can be undefined or null.
|
|
1459
|
+
* @returns TodoListChanges with all items marked as ADDED
|
|
1460
|
+
*
|
|
1461
|
+
* @example
|
|
1462
|
+
* ```ts
|
|
1463
|
+
* // In planning phase, after LLM generates initial plan
|
|
1464
|
+
* const initialChanges = createInitialChanges(planningOutput.todoList || []);
|
|
1465
|
+
* await observationManager.record({
|
|
1466
|
+
* type: ObservationType.PLAN_UPDATE,
|
|
1467
|
+
* content: { todoList: planningOutput.todoList, changes: initialChanges }
|
|
1468
|
+
* });
|
|
1469
|
+
* ```
|
|
1470
|
+
*/
|
|
1471
|
+
declare function createInitialChanges(todoList: TodoItem[] | undefined | null): TodoListChanges;
|
|
842
1472
|
|
|
843
1473
|
/**
|
|
844
1474
|
* @module types/schemas
|
|
@@ -1675,6 +2305,7 @@ interface LLMMetadata {
|
|
|
1675
2305
|
*/
|
|
1676
2306
|
traceId?: string;
|
|
1677
2307
|
}
|
|
2308
|
+
|
|
1678
2309
|
/**
|
|
1679
2310
|
* Defines the schema for a tool, including its input parameters.
|
|
1680
2311
|
* Uses JSON Schema format for inputSchema.
|
|
@@ -1712,13 +2343,36 @@ interface ToolSchema {
|
|
|
1712
2343
|
description?: string;
|
|
1713
2344
|
}>;
|
|
1714
2345
|
/**
|
|
1715
|
-
* Defines the execution mode of the tool.
|
|
1716
|
-
*
|
|
1717
|
-
*
|
|
1718
|
-
*
|
|
1719
|
-
*
|
|
2346
|
+
* Defines the execution mode (category) of the tool.
|
|
2347
|
+
*
|
|
2348
|
+
* @remarks
|
|
2349
|
+
* Tools are categorized into three modes with different framework handling:
|
|
2350
|
+
*
|
|
2351
|
+
* - `functional` (default, also 'immediate' for backward compat): Regular tools that
|
|
2352
|
+
* execute synchronously and return results immediately.
|
|
2353
|
+
*
|
|
2354
|
+
* - `blocking`: HITL tools that require human input to complete. They return 'suspended'
|
|
2355
|
+
* status initially. When user provides feedback, the framework programmatically
|
|
2356
|
+
* completes the tool with the feedback as output - no re-execution needed.
|
|
2357
|
+
*
|
|
2358
|
+
* - `display`: Generative UI tools that render visual content. They complete immediately
|
|
2359
|
+
* but their output is meant for rendering rather than LLM consumption.
|
|
2360
|
+
*
|
|
2361
|
+
* @property {'functional' | 'immediate' | 'blocking' | 'display'} [executionMode]
|
|
2362
|
+
*/
|
|
2363
|
+
executionMode?: 'functional' | 'immediate' | 'blocking' | 'display';
|
|
2364
|
+
/**
|
|
2365
|
+
* Configuration for blocking tools (HITL).
|
|
2366
|
+
* Only applicable when executionMode is 'blocking'.
|
|
2367
|
+
* @property {import('./hitl-types').BlockingToolConfig} [blockingConfig]
|
|
2368
|
+
*/
|
|
2369
|
+
blockingConfig?: BlockingToolConfig;
|
|
2370
|
+
/**
|
|
2371
|
+
* Configuration for display tools (Generative UI).
|
|
2372
|
+
* Only applicable when executionMode is 'display'.
|
|
2373
|
+
* @property {import('./hitl-types').DisplayToolConfig} [displayConfig]
|
|
1720
2374
|
*/
|
|
1721
|
-
|
|
2375
|
+
displayConfig?: DisplayToolConfig;
|
|
1722
2376
|
}
|
|
1723
2377
|
/**
|
|
1724
2378
|
* Represents the structured result of a tool execution.
|
|
@@ -2144,6 +2798,22 @@ interface ExecutionContext {
|
|
|
2144
2798
|
* @property {string} [userId]
|
|
2145
2799
|
*/
|
|
2146
2800
|
userId?: string;
|
|
2801
|
+
/**
|
|
2802
|
+
* HITL context for blocking tools.
|
|
2803
|
+
*
|
|
2804
|
+
* @remarks
|
|
2805
|
+
* This enables blocking tools to differentiate between:
|
|
2806
|
+
* - Initial invocation (should return 'suspended' to request user input)
|
|
2807
|
+
* - Post-approval invocation (if completesOnApproval is false, tool is re-executed)
|
|
2808
|
+
*
|
|
2809
|
+
* For most blocking tools with completesOnApproval=true (default), the tool is NOT
|
|
2810
|
+
* re-executed after approval - the framework creates the success result programmatically.
|
|
2811
|
+
* This field is only populated when completesOnApproval=false and the tool needs
|
|
2812
|
+
* to perform actual work after user approval.
|
|
2813
|
+
*
|
|
2814
|
+
* @property {import('./hitl-types').HITLContext} [hitlContext]
|
|
2815
|
+
*/
|
|
2816
|
+
hitlContext?: HITLContext;
|
|
2147
2817
|
}
|
|
2148
2818
|
/**
|
|
2149
2819
|
* Options for configuring an LLM call, including streaming and context information.
|
|
@@ -6565,6 +7235,6 @@ declare const generateUUID: () => string;
|
|
|
6565
7235
|
/**
|
|
6566
7236
|
* The current version of the ART Framework package.
|
|
6567
7237
|
*/
|
|
6568
|
-
declare const VERSION = "0.4.
|
|
7238
|
+
declare const VERSION = "0.4.15";
|
|
6569
7239
|
|
|
6570
|
-
export { type A2AAgentInfo, type A2ATask, type A2ATaskEvent, type A2ATaskFilter, type A2ATaskMetadata, A2ATaskPriority, type A2ATaskResult, A2ATaskSocket, A2ATaskStatus, ARTError, AdapterInstantiationError, type AgentDiscoveryConfig, AgentDiscoveryService, AgentFactory, type AgentFinalResponse, type AgentOptions, type AgentPersona, type AgentProps, type AgentState, AnthropicAdapter, type AnthropicAdapterOptions, ApiKeyStrategy, ApiQueueTimeoutError, type ArtInstance, type ArtInstanceConfig, type ArtStandardMessage, type ArtStandardMessageRole, ArtStandardMessageSchema, type ArtStandardPrompt, ArtStandardPromptSchema, AuthManager, type AvailableProviderEntry, CalculatorTool, type CallOptions, type ConversationManager, type ConversationMessage, ConversationSocket, type CreateA2ATaskRequest, DeepSeekAdapter, type DeepSeekAdapterOptions, ErrorCode, type ExecutionConfig, type ExecutionContext, type ExecutionMetadata, type ExecutionOutput, type FilterOptions, type FormattedPrompt, GeminiAdapter, type GeminiAdapterOptions, GenericOAuthStrategy, GroqAdapter, type GroqAdapterOptions, type IA2ATaskRepository, type IAgentCore, type IAuthStrategy, type IConversationRepository, type IObservationRepository, type IProviderManager, type IStateRepository, type IToolExecutor, type ITypedSocket, InMemoryStorageAdapter, IndexedDBStorageAdapter, type JsonObjectSchema, type JsonSchema, type LLMMetadata, LLMStreamSocket, LocalInstanceBusyError, LocalProviderConflictError, LogLevel, Logger, type LoggerConfig, type ManagedAdapterAccessor, McpClientController, McpManager, type McpManagerConfig, McpProxyTool, type McpResource, type McpResourceTemplate, type McpServerConfig, type McpServerStatus, type McpToolDefinition, type MessageOptions, MessageRole, ModelCapability, type OAuthConfig, type Observation, type ObservationFilter, type ObservationManager, ObservationSocket, ObservationType, OllamaAdapter, type OllamaAdapterOptions, OpenAIAdapter, type OpenAIAdapterOptions, OpenRouterAdapter, type OpenRouterAdapterOptions, OutputParser, PESAgent, type PESAgentStateData, type PKCEOAuthConfig, PKCEOAuthStrategy, type ParsedToolCall, type PromptBlueprint, type PromptContext, type ProviderAdapter, type ProviderManagerConfig, ProviderManagerImpl, ReasoningEngine, type RuntimeProviderConfig, type StageSpecificPrompts, StateManager, type StateSavingStrategy, type StepOutputEntry, type StorageAdapter, type StreamEvent, type StreamEventTypeFilter, SupabaseStorageAdapter, type SystemPromptMergeStrategy, type SystemPromptOverride, SystemPromptResolver, type SystemPromptSpec, type SystemPromptsRegistry, type TaskDelegationConfig, TaskDelegationService, type TaskStatusResponse, type ThreadConfig, type ThreadContext, type TodoItem, TodoItemStatus, ToolRegistry, type ToolResult, type ToolSchema, type ToolSystem, TypedSocket, UISystem, UnknownProviderError, type UnsubscribeFunction, type UpdateA2ATaskRequest, VERSION, type ZyntopiaOAuthConfig, ZyntopiaOAuthStrategy, createArtInstance, generateUUID };
|
|
7240
|
+
export { type A2AAgentInfo, type A2ATask, type A2ATaskEvent, type A2ATaskFilter, type A2ATaskMetadata, A2ATaskPriority, type A2ATaskResult, A2ATaskSocket, A2ATaskStatus, ARTError, AdapterInstantiationError, type AgentDiscoveryConfig, AgentDiscoveryService, AgentFactory, type AgentFinalResponse, type AgentOptions, type AgentPersona, type AgentProps, type AgentState, AnthropicAdapter, type AnthropicAdapterOptions, ApiKeyStrategy, ApiQueueTimeoutError, type ArtInstance, type ArtInstanceConfig, type ArtStandardMessage, type ArtStandardMessageRole, ArtStandardMessageSchema, type ArtStandardPrompt, ArtStandardPromptSchema, AuthManager, type AvailableProviderEntry, type BlockingToolCompletedResult, type BlockingToolConfig, type BlockingToolSuspendedResult, CalculatorTool, type CallOptions, type ConversationManager, type ConversationMessage, ConversationSocket, type CreateA2ATaskRequest, DeepSeekAdapter, type DeepSeekAdapterOptions, type DisplayToolConfig, ErrorCode, type ExecutionConfig, type ExecutionContext, type ExecutionMetadata, type ExecutionOutput, type FilterOptions, type FormattedPrompt, GeminiAdapter, type GeminiAdapterOptions, GenericOAuthStrategy, GroqAdapter, type GroqAdapterOptions, type HITLContext, type HITLFeedback, type HITLFeedbackSchema, type HITLInputType, type HITLInputValidation, type HITLSelectOption, type IA2ATaskRepository, type IAgentCore, type IAuthStrategy, type IConversationRepository, type IObservationRepository, type IProviderManager, type IStateRepository, type IToolExecutor, type ITypedSocket, InMemoryStorageAdapter, IndexedDBStorageAdapter, type JsonObjectSchema, type JsonSchema, type LLMMetadata, LLMStreamSocket, LocalInstanceBusyError, LocalProviderConflictError, LogLevel, Logger, type LoggerConfig, type ManagedAdapterAccessor, McpClientController, McpManager, type McpManagerConfig, McpProxyTool, type McpResource, type McpResourceTemplate, type McpServerConfig, type McpServerStatus, type McpToolDefinition, type MessageOptions, MessageRole, ModelCapability, type OAuthConfig, type Observation, type ObservationFilter, type ObservationManager, ObservationSocket, ObservationType, OllamaAdapter, type OllamaAdapterOptions, OpenAIAdapter, type OpenAIAdapterOptions, OpenRouterAdapter, type OpenRouterAdapterOptions, OutputParser, PESAgent, type PESAgentStateData, type PKCEOAuthConfig, PKCEOAuthStrategy, type ParsedToolCall, type PromptBlueprint, type PromptContext, type ProviderAdapter, type ProviderManagerConfig, ProviderManagerImpl, ReasoningEngine, type RuntimeProviderConfig, type StageSpecificPrompts, StateManager, type StateSavingStrategy, type StepOutputEntry, type StorageAdapter, type StreamEvent, type StreamEventTypeFilter, SupabaseStorageAdapter, type SystemPromptMergeStrategy, type SystemPromptOverride, SystemPromptResolver, type SystemPromptSpec, type SystemPromptsRegistry, type TaskDelegationConfig, TaskDelegationService, type TaskStatusResponse, type ThreadConfig, type ThreadContext, type TodoItem, type TodoItemChange, TodoItemChangeType, TodoItemStatus, type TodoListChanges, type ToolExecutionMode, ToolRegistry, type ToolResult, type ToolSchema, type ToolSystem, TypedSocket, UISystem, UnknownProviderError, type UnsubscribeFunction, type UpdateA2ATaskRequest, VERSION, type ZyntopiaOAuthConfig, ZyntopiaOAuthStrategy, computeTodoListDiff, createArtInstance, createHITLSuccessResult, createInitialChanges, generateUUID, isBlockingSuspendedResult, isFeedbackApproved };
|