@cleocode/lafs 2026.4.0 → 2026.4.4
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 +97 -68
- package/dist/src/a2a/bindings/grpc.d.ts +117 -11
- package/dist/src/a2a/bindings/grpc.d.ts.map +1 -1
- package/dist/src/a2a/bindings/grpc.js +79 -8
- package/dist/src/a2a/bindings/grpc.js.map +1 -1
- package/dist/src/a2a/bindings/http.d.ts +129 -14
- package/dist/src/a2a/bindings/http.d.ts.map +1 -1
- package/dist/src/a2a/bindings/http.js +93 -12
- package/dist/src/a2a/bindings/http.js.map +1 -1
- package/dist/src/a2a/bindings/index.d.ts +80 -7
- package/dist/src/a2a/bindings/index.d.ts.map +1 -1
- package/dist/src/a2a/bindings/index.js +69 -2
- package/dist/src/a2a/bindings/index.js.map +1 -1
- package/dist/src/a2a/bindings/jsonrpc.d.ts +193 -9
- package/dist/src/a2a/bindings/jsonrpc.d.ts.map +1 -1
- package/dist/src/a2a/bindings/jsonrpc.js +152 -9
- package/dist/src/a2a/bindings/jsonrpc.js.map +1 -1
- package/dist/src/a2a/bridge.d.ts +232 -37
- package/dist/src/a2a/bridge.d.ts.map +1 -1
- package/dist/src/a2a/bridge.js +172 -24
- package/dist/src/a2a/bridge.js.map +1 -1
- package/dist/src/a2a/extensions.d.ts +221 -12
- package/dist/src/a2a/extensions.d.ts.map +1 -1
- package/dist/src/a2a/extensions.js +175 -11
- package/dist/src/a2a/extensions.js.map +1 -1
- package/dist/src/a2a/index.d.ts +2 -0
- package/dist/src/a2a/index.d.ts.map +1 -1
- package/dist/src/a2a/index.js +2 -0
- package/dist/src/a2a/index.js.map +1 -1
- package/dist/src/a2a/streaming.d.ts +274 -2
- package/dist/src/a2a/streaming.d.ts.map +1 -1
- package/dist/src/a2a/streaming.js +245 -2
- package/dist/src/a2a/streaming.js.map +1 -1
- package/dist/src/a2a/task-lifecycle.d.ts +339 -19
- package/dist/src/a2a/task-lifecycle.d.ts.map +1 -1
- package/dist/src/a2a/task-lifecycle.js +302 -19
- package/dist/src/a2a/task-lifecycle.js.map +1 -1
- package/dist/src/budgetEnforcement.d.ts +88 -14
- package/dist/src/budgetEnforcement.d.ts.map +1 -1
- package/dist/src/budgetEnforcement.js +132 -19
- package/dist/src/budgetEnforcement.js.map +1 -1
- package/dist/src/circuit-breaker/index.d.ts +254 -9
- package/dist/src/circuit-breaker/index.d.ts.map +1 -1
- package/dist/src/circuit-breaker/index.js +218 -9
- package/dist/src/circuit-breaker/index.js.map +1 -1
- package/dist/src/compliance.d.ts +176 -0
- package/dist/src/compliance.d.ts.map +1 -1
- package/dist/src/compliance.js +100 -0
- package/dist/src/compliance.js.map +1 -1
- package/dist/src/conformance.d.ts +52 -0
- package/dist/src/conformance.d.ts.map +1 -1
- package/dist/src/conformance.js +41 -0
- package/dist/src/conformance.js.map +1 -1
- package/dist/src/conformanceProfiles.d.ts +66 -0
- package/dist/src/conformanceProfiles.d.ts.map +1 -1
- package/dist/src/conformanceProfiles.js +51 -0
- package/dist/src/conformanceProfiles.js.map +1 -1
- package/dist/src/deprecationRegistry.d.ts +80 -0
- package/dist/src/deprecationRegistry.d.ts.map +1 -1
- package/dist/src/deprecationRegistry.js +50 -0
- package/dist/src/deprecationRegistry.js.map +1 -1
- package/dist/src/discovery.d.ts +344 -63
- package/dist/src/discovery.d.ts.map +1 -1
- package/dist/src/discovery.js +67 -13
- package/dist/src/discovery.js.map +1 -1
- package/dist/src/envelope.d.ts +252 -0
- package/dist/src/envelope.d.ts.map +1 -1
- package/dist/src/envelope.js +165 -0
- package/dist/src/envelope.js.map +1 -1
- package/dist/src/errorRegistry.d.ts +159 -0
- package/dist/src/errorRegistry.d.ts.map +1 -1
- package/dist/src/errorRegistry.js +115 -0
- package/dist/src/errorRegistry.js.map +1 -1
- package/dist/src/fieldExtraction.d.ts +125 -25
- package/dist/src/fieldExtraction.d.ts.map +1 -1
- package/dist/src/fieldExtraction.js +85 -16
- package/dist/src/fieldExtraction.js.map +1 -1
- package/dist/src/flagResolver.d.ts +75 -9
- package/dist/src/flagResolver.d.ts.map +1 -1
- package/dist/src/flagResolver.js +20 -4
- package/dist/src/flagResolver.js.map +1 -1
- package/dist/src/flagSemantics.d.ts +76 -1
- package/dist/src/flagSemantics.d.ts.map +1 -1
- package/dist/src/flagSemantics.js +66 -0
- package/dist/src/flagSemantics.js.map +1 -1
- package/dist/src/health/index.d.ts +87 -6
- package/dist/src/health/index.d.ts.map +1 -1
- package/dist/src/health/index.js +54 -6
- package/dist/src/health/index.js.map +1 -1
- package/dist/src/index.d.ts +12 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +12 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/mviProjection.d.ts +42 -6
- package/dist/src/mviProjection.d.ts.map +1 -1
- package/dist/src/mviProjection.js +31 -5
- package/dist/src/mviProjection.js.map +1 -1
- package/dist/src/native-loader.d.ts +49 -0
- package/dist/src/native-loader.d.ts.map +1 -0
- package/dist/src/native-loader.js +56 -0
- package/dist/src/native-loader.js.map +1 -0
- package/dist/src/problemDetails.d.ts +70 -4
- package/dist/src/problemDetails.d.ts.map +1 -1
- package/dist/src/problemDetails.js +21 -3
- package/dist/src/problemDetails.js.map +1 -1
- package/dist/src/shutdown/index.d.ts +96 -7
- package/dist/src/shutdown/index.d.ts.map +1 -1
- package/dist/src/shutdown/index.js +72 -7
- package/dist/src/shutdown/index.js.map +1 -1
- package/dist/src/tokenEstimator.d.ts +97 -11
- package/dist/src/tokenEstimator.d.ts.map +1 -1
- package/dist/src/tokenEstimator.js +90 -11
- package/dist/src/tokenEstimator.js.map +1 -1
- package/dist/src/types.d.ts +467 -2
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +64 -0
- package/dist/src/types.js.map +1 -1
- package/dist/src/validateEnvelope.d.ts +59 -1
- package/dist/src/validateEnvelope.d.ts.map +1 -1
- package/dist/src/validateEnvelope.js +75 -9
- package/dist/src/validateEnvelope.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/lafs.md +3 -4
- package/package.json +6 -3
- package/dist/src/mcpAdapter.d.ts +0 -29
- package/dist/src/mcpAdapter.d.ts.map +0 -1
- package/dist/src/mcpAdapter.js +0 -286
- package/dist/src/mcpAdapter.js.map +0 -1
- package/schemas/v1/conformance-profiles.d.ts +0 -15
- package/schemas/v1/envelope.schema.d.ts +0 -14
- package/schemas/v1/error-registry.d.ts +0 -24
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
* State machine enforcement, task CRUD, and LAFS integration
|
|
5
5
|
* for A2A Protocol v1.0+ compliance.
|
|
6
6
|
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Implements the A2A task state machine with valid transitions, terminal
|
|
9
|
+
* state immutability, and context-based task grouping. Provides an
|
|
10
|
+
* in-memory TaskManager for managing task lifecycle and LAFS envelope
|
|
11
|
+
* attachment.
|
|
12
|
+
*
|
|
7
13
|
* Reference: A2A spec Section 6 (Task Lifecycle)
|
|
8
14
|
*/
|
|
9
15
|
import type { Artifact, Message, Task, TaskState } from '@a2a-js/sdk';
|
|
@@ -14,97 +20,411 @@ export declare const TERMINAL_STATES: ReadonlySet<TaskState>;
|
|
|
14
20
|
export declare const INTERRUPTED_STATES: ReadonlySet<TaskState>;
|
|
15
21
|
/** Valid state transitions (adjacency map). Terminal states have empty outgoing sets. */
|
|
16
22
|
export declare const VALID_TRANSITIONS: ReadonlyMap<TaskState, ReadonlySet<TaskState>>;
|
|
17
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Check if a transition from one state to another is valid.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* Looks up the `from` state in the VALID_TRANSITIONS adjacency map and
|
|
28
|
+
* checks whether `to` is in the allowed set.
|
|
29
|
+
*
|
|
30
|
+
* @param from - Current task state
|
|
31
|
+
* @param to - Desired target state
|
|
32
|
+
* @returns True if the transition is allowed by the state machine
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* if (!isValidTransition('submitted', 'completed')) {
|
|
37
|
+
* throw new Error('Cannot go directly from submitted to completed');
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
18
41
|
export declare function isValidTransition(from: TaskState, to: TaskState): boolean;
|
|
19
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Check if a state is terminal (no further transitions allowed).
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* Terminal states are `completed`, `failed`, `canceled`, and `rejected`.
|
|
47
|
+
*
|
|
48
|
+
* @param state - Task state to check
|
|
49
|
+
* @returns True if the state is terminal
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* if (isTerminalState(task.status.state)) {
|
|
54
|
+
* console.log('Task has reached a final state');
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
20
58
|
export declare function isTerminalState(state: TaskState): boolean;
|
|
21
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Check if a state is interrupted (paused awaiting input).
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* Interrupted states are `input-required` and `auth-required`.
|
|
64
|
+
*
|
|
65
|
+
* @param state - Task state to check
|
|
66
|
+
* @returns True if the state indicates the task is waiting for external input
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* if (isInterruptedState(task.status.state)) {
|
|
71
|
+
* promptUserForInput(task);
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
22
75
|
export declare function isInterruptedState(state: TaskState): boolean;
|
|
23
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* Thrown when attempting an invalid state transition.
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* Captures the task ID, source state, and target state so callers can
|
|
81
|
+
* determine which transition was rejected.
|
|
82
|
+
*/
|
|
24
83
|
export declare class InvalidStateTransitionError extends Error {
|
|
84
|
+
/** ID of the task that failed the transition */
|
|
25
85
|
readonly taskId: string;
|
|
86
|
+
/** State the task was in when the transition was attempted */
|
|
26
87
|
readonly fromState: TaskState;
|
|
88
|
+
/** State the task was being transitioned to */
|
|
27
89
|
readonly toState: TaskState;
|
|
90
|
+
/**
|
|
91
|
+
* Create an InvalidStateTransitionError.
|
|
92
|
+
*
|
|
93
|
+
* @param taskId - ID of the task that failed the transition
|
|
94
|
+
* @param fromState - Current state of the task
|
|
95
|
+
* @param toState - Desired target state that was rejected
|
|
96
|
+
*/
|
|
28
97
|
constructor(taskId: string, fromState: TaskState, toState: TaskState);
|
|
29
98
|
}
|
|
30
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Thrown when attempting to modify a task in a terminal state.
|
|
101
|
+
*
|
|
102
|
+
* @remarks
|
|
103
|
+
* Tasks in terminal states (`completed`, `failed`, `canceled`, `rejected`)
|
|
104
|
+
* are immutable and cannot be modified further.
|
|
105
|
+
*/
|
|
31
106
|
export declare class TaskImmutabilityError extends Error {
|
|
107
|
+
/** ID of the task that cannot be modified */
|
|
32
108
|
readonly taskId: string;
|
|
109
|
+
/** Terminal state the task is in */
|
|
33
110
|
readonly terminalState: TaskState;
|
|
111
|
+
/**
|
|
112
|
+
* Create a TaskImmutabilityError.
|
|
113
|
+
*
|
|
114
|
+
* @param taskId - ID of the task in terminal state
|
|
115
|
+
* @param terminalState - The terminal state preventing modification
|
|
116
|
+
*/
|
|
34
117
|
constructor(taskId: string, terminalState: TaskState);
|
|
35
118
|
}
|
|
36
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* Thrown when a task is not found.
|
|
121
|
+
*
|
|
122
|
+
* @remarks
|
|
123
|
+
* Indicates a lookup by task ID failed because no task with that ID exists
|
|
124
|
+
* in the TaskManager's store.
|
|
125
|
+
*/
|
|
37
126
|
export declare class TaskNotFoundError extends Error {
|
|
127
|
+
/** ID of the task that was not found */
|
|
38
128
|
readonly taskId: string;
|
|
129
|
+
/**
|
|
130
|
+
* Create a TaskNotFoundError.
|
|
131
|
+
*
|
|
132
|
+
* @param taskId - ID of the task that was not found
|
|
133
|
+
*/
|
|
39
134
|
constructor(taskId: string);
|
|
40
135
|
}
|
|
41
|
-
/**
|
|
136
|
+
/**
|
|
137
|
+
* Thrown when a refinement/follow-up task references invalid parent tasks.
|
|
138
|
+
*
|
|
139
|
+
* @remarks
|
|
140
|
+
* Occurs when referenced tasks do not exist or belong to a different
|
|
141
|
+
* context than the refinement task.
|
|
142
|
+
*/
|
|
42
143
|
export declare class TaskRefinementError extends Error {
|
|
144
|
+
/** IDs of the referenced tasks that caused the error */
|
|
43
145
|
readonly referenceTaskIds: string[];
|
|
146
|
+
/**
|
|
147
|
+
* Create a TaskRefinementError.
|
|
148
|
+
*
|
|
149
|
+
* @param message - Descriptive error message
|
|
150
|
+
* @param referenceTaskIds - IDs of the invalid reference tasks
|
|
151
|
+
*/
|
|
44
152
|
constructor(message: string, referenceTaskIds: string[]);
|
|
45
153
|
}
|
|
46
154
|
/** Options for creating a new task */
|
|
47
155
|
export interface CreateTaskOptions {
|
|
156
|
+
/**
|
|
157
|
+
* Context ID for grouping related tasks.
|
|
158
|
+
* @defaultValue undefined
|
|
159
|
+
*/
|
|
48
160
|
contextId?: string;
|
|
161
|
+
/**
|
|
162
|
+
* Arbitrary metadata to attach to the task.
|
|
163
|
+
* @defaultValue undefined
|
|
164
|
+
*/
|
|
49
165
|
metadata?: Record<string, unknown>;
|
|
166
|
+
/**
|
|
167
|
+
* IDs of parent tasks this task refines or follows up on.
|
|
168
|
+
* @defaultValue undefined
|
|
169
|
+
*/
|
|
50
170
|
referenceTaskIds?: string[];
|
|
171
|
+
/**
|
|
172
|
+
* Whether this follow-up can run in parallel with its references.
|
|
173
|
+
* @defaultValue undefined
|
|
174
|
+
*/
|
|
51
175
|
parallelFollowUp?: boolean;
|
|
52
176
|
}
|
|
53
177
|
/** Options for listing tasks */
|
|
54
178
|
export interface ListTasksOptions {
|
|
179
|
+
/**
|
|
180
|
+
* Filter tasks by context ID.
|
|
181
|
+
* @defaultValue undefined
|
|
182
|
+
*/
|
|
55
183
|
contextId?: string;
|
|
184
|
+
/**
|
|
185
|
+
* Filter tasks by current state.
|
|
186
|
+
* @defaultValue undefined
|
|
187
|
+
*/
|
|
56
188
|
state?: TaskState;
|
|
189
|
+
/**
|
|
190
|
+
* Maximum number of tasks to return.
|
|
191
|
+
* @defaultValue undefined
|
|
192
|
+
*/
|
|
57
193
|
limit?: number;
|
|
194
|
+
/**
|
|
195
|
+
* Cursor token for pagination (last seen task ID).
|
|
196
|
+
* @defaultValue undefined
|
|
197
|
+
*/
|
|
58
198
|
pageToken?: string;
|
|
59
199
|
}
|
|
60
200
|
/** Paginated result from listTasks */
|
|
61
201
|
export interface ListTasksResult {
|
|
202
|
+
/** Array of tasks matching the query */
|
|
62
203
|
tasks: Task[];
|
|
204
|
+
/**
|
|
205
|
+
* Token for fetching the next page of results.
|
|
206
|
+
* @defaultValue undefined
|
|
207
|
+
*/
|
|
63
208
|
nextPageToken?: string;
|
|
64
209
|
}
|
|
65
210
|
/**
|
|
66
211
|
* In-memory task manager implementing A2A task lifecycle.
|
|
212
|
+
*
|
|
213
|
+
* @remarks
|
|
67
214
|
* Enforces valid state transitions and terminal state immutability.
|
|
215
|
+
* Tasks are indexed by both ID and context ID for efficient lookup.
|
|
216
|
+
* All returned Task objects are deep clones to prevent external mutation.
|
|
68
217
|
*/
|
|
69
218
|
export declare class TaskManager {
|
|
219
|
+
/** Map of task ID to Task object */
|
|
70
220
|
private tasks;
|
|
221
|
+
/** Index mapping context ID to set of task IDs */
|
|
71
222
|
private contextIndex;
|
|
72
|
-
/**
|
|
223
|
+
/**
|
|
224
|
+
* Create a new task in the submitted state.
|
|
225
|
+
*
|
|
226
|
+
* @remarks
|
|
227
|
+
* Generates a UUID for the task and resolves the context ID from options
|
|
228
|
+
* or referenced tasks. Validates that all reference tasks exist and share
|
|
229
|
+
* the same context.
|
|
230
|
+
*
|
|
231
|
+
* @param options - Task creation options including context, metadata, and references
|
|
232
|
+
* @returns Deep clone of the newly created task
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```typescript
|
|
236
|
+
* const manager = new TaskManager();
|
|
237
|
+
* const task = manager.createTask({ contextId: 'ctx-1', metadata: { source: 'api' } });
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
73
240
|
createTask(options?: CreateTaskOptions): Task;
|
|
74
|
-
/**
|
|
241
|
+
/**
|
|
242
|
+
* Create a refinement/follow-up task referencing existing task(s).
|
|
243
|
+
*
|
|
244
|
+
* @remarks
|
|
245
|
+
* Delegates to {@link TaskManager.createTask} with the provided reference
|
|
246
|
+
* task IDs. The context ID is automatically resolved from the first
|
|
247
|
+
* referenced task.
|
|
248
|
+
*
|
|
249
|
+
* @param referenceTaskIds - IDs of parent tasks to reference
|
|
250
|
+
* @param options - Additional task creation options (excluding referenceTaskIds)
|
|
251
|
+
* @returns Deep clone of the newly created refinement task
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```typescript
|
|
255
|
+
* const refined = manager.createRefinedTask(['task-1'], { parallelFollowUp: true });
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
75
258
|
createRefinedTask(referenceTaskIds: string[], options?: Omit<CreateTaskOptions, 'referenceTaskIds'>): Task;
|
|
76
|
-
/**
|
|
259
|
+
/**
|
|
260
|
+
* Get a task by ID.
|
|
261
|
+
*
|
|
262
|
+
* @remarks
|
|
263
|
+
* Returns a deep clone of the task to prevent external mutation.
|
|
264
|
+
*
|
|
265
|
+
* @param taskId - ID of the task to retrieve
|
|
266
|
+
* @returns Deep clone of the requested task
|
|
267
|
+
* @throws {@link TaskNotFoundError} if no task with the given ID exists
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```typescript
|
|
271
|
+
* const task = manager.getTask('some-task-id');
|
|
272
|
+
* console.log(task.status.state);
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
77
275
|
getTask(taskId: string): Task;
|
|
78
|
-
/**
|
|
276
|
+
/**
|
|
277
|
+
* List tasks with optional filtering and pagination.
|
|
278
|
+
*
|
|
279
|
+
* @remarks
|
|
280
|
+
* Supports filtering by context ID and state, with cursor-based
|
|
281
|
+
* pagination using the last seen task ID as a page token. Results
|
|
282
|
+
* are sorted by task ID for deterministic ordering.
|
|
283
|
+
*
|
|
284
|
+
* @param options - Filtering and pagination options
|
|
285
|
+
* @returns Paginated result with tasks and optional next page token
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```typescript
|
|
289
|
+
* const result = manager.listTasks({ contextId: 'ctx-1', state: 'working', limit: 10 });
|
|
290
|
+
* for (const task of result.tasks) {
|
|
291
|
+
* console.log(task.id, task.status.state);
|
|
292
|
+
* }
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
79
295
|
listTasks(options?: ListTasksOptions): ListTasksResult;
|
|
80
296
|
/**
|
|
81
297
|
* Update task status. Enforces valid transitions and terminal state immutability.
|
|
82
|
-
*
|
|
83
|
-
* @
|
|
298
|
+
*
|
|
299
|
+
* @remarks
|
|
300
|
+
* Validates that the transition is allowed by the state machine before
|
|
301
|
+
* applying. An optional message can be attached to the new status.
|
|
302
|
+
*
|
|
303
|
+
* @param taskId - ID of the task to update
|
|
304
|
+
* @param state - New state to transition to
|
|
305
|
+
* @param message - Optional message to attach to the status update
|
|
306
|
+
* @returns Deep clone of the updated task
|
|
307
|
+
* @throws {@link InvalidStateTransitionError} if the transition is not valid
|
|
308
|
+
* @throws {@link TaskImmutabilityError} if the task is in a terminal state
|
|
309
|
+
* @throws {@link TaskNotFoundError} if the task does not exist
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* ```typescript
|
|
313
|
+
* const updated = manager.updateTaskStatus('task-1', 'working');
|
|
314
|
+
* ```
|
|
84
315
|
*/
|
|
85
316
|
updateTaskStatus(taskId: string, state: TaskState, message?: Message): Task;
|
|
86
317
|
/**
|
|
87
318
|
* Add an artifact to a task.
|
|
88
|
-
*
|
|
319
|
+
*
|
|
320
|
+
* @remarks
|
|
321
|
+
* Appends the artifact to the task's artifacts array. The task must
|
|
322
|
+
* not be in a terminal state.
|
|
323
|
+
*
|
|
324
|
+
* @param taskId - ID of the task to add the artifact to
|
|
325
|
+
* @param artifact - Artifact to add
|
|
326
|
+
* @returns Deep clone of the updated task
|
|
327
|
+
* @throws {@link TaskImmutabilityError} if the task is in a terminal state
|
|
328
|
+
* @throws {@link TaskNotFoundError} if the task does not exist
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```typescript
|
|
332
|
+
* const artifact = createLafsArtifact(envelope);
|
|
333
|
+
* manager.addArtifact('task-1', artifact);
|
|
334
|
+
* ```
|
|
89
335
|
*/
|
|
90
336
|
addArtifact(taskId: string, artifact: Artifact): Task;
|
|
91
337
|
/**
|
|
92
338
|
* Add a message to task history.
|
|
93
|
-
*
|
|
339
|
+
*
|
|
340
|
+
* @remarks
|
|
341
|
+
* Appends the message to the task's history array. The task must
|
|
342
|
+
* not be in a terminal state.
|
|
343
|
+
*
|
|
344
|
+
* @param taskId - ID of the task to add the message to
|
|
345
|
+
* @param message - Message to add to history
|
|
346
|
+
* @returns Deep clone of the updated task
|
|
347
|
+
* @throws {@link TaskImmutabilityError} if the task is in a terminal state
|
|
348
|
+
* @throws {@link TaskNotFoundError} if the task does not exist
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* ```typescript
|
|
352
|
+
* manager.addHistory('task-1', { role: 'agent', parts: [{ kind: 'text', text: 'Done' }] });
|
|
353
|
+
* ```
|
|
94
354
|
*/
|
|
95
355
|
addHistory(taskId: string, message: Message): Task;
|
|
96
|
-
/**
|
|
356
|
+
/**
|
|
357
|
+
* Cancel a task by transitioning to canceled state.
|
|
358
|
+
*
|
|
359
|
+
* @remarks
|
|
360
|
+
* Convenience wrapper around {@link TaskManager.updateTaskStatus} with `'canceled'`.
|
|
361
|
+
*
|
|
362
|
+
* @param taskId - ID of the task to cancel
|
|
363
|
+
* @returns Deep clone of the canceled task
|
|
364
|
+
* @throws {@link InvalidStateTransitionError} if cancellation is not valid from the current state
|
|
365
|
+
* @throws {@link TaskImmutabilityError} if the task is already in a terminal state
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
* ```typescript
|
|
369
|
+
* const canceled = manager.cancelTask('task-1');
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
97
372
|
cancelTask(taskId: string): Task;
|
|
98
|
-
/**
|
|
373
|
+
/**
|
|
374
|
+
* Get all tasks in a given context.
|
|
375
|
+
*
|
|
376
|
+
* @remarks
|
|
377
|
+
* Returns deep clones of all tasks sharing the specified context ID.
|
|
378
|
+
*
|
|
379
|
+
* @param contextId - Context ID to look up
|
|
380
|
+
* @returns Array of deep-cloned tasks in the context, or empty array if none
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* ```typescript
|
|
384
|
+
* const tasks = manager.getTasksByContext('ctx-1');
|
|
385
|
+
* ```
|
|
386
|
+
*/
|
|
99
387
|
getTasksByContext(contextId: string): Task[];
|
|
100
|
-
/**
|
|
388
|
+
/**
|
|
389
|
+
* Check if a task is in a terminal state.
|
|
390
|
+
*
|
|
391
|
+
* @remarks
|
|
392
|
+
* Retrieves the task and checks its current state against the terminal states set.
|
|
393
|
+
*
|
|
394
|
+
* @param taskId - ID of the task to check
|
|
395
|
+
* @returns True if the task is in a terminal state
|
|
396
|
+
* @throws {@link TaskNotFoundError} if the task does not exist
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* ```typescript
|
|
400
|
+
* if (manager.isTerminal('task-1')) {
|
|
401
|
+
* console.log('Task is finished');
|
|
402
|
+
* }
|
|
403
|
+
* ```
|
|
404
|
+
*/
|
|
101
405
|
isTerminal(taskId: string): boolean;
|
|
406
|
+
/** Derive a contextId from the first referenced task, if any reference tasks are provided. */
|
|
102
407
|
private resolveContextForReferenceTasks;
|
|
408
|
+
/** Validate that all referenced tasks exist and share the same contextId. */
|
|
103
409
|
private validateReferenceTasks;
|
|
104
410
|
}
|
|
105
411
|
/**
|
|
106
412
|
* Attach a LAFS envelope as an artifact to an A2A task.
|
|
107
|
-
*
|
|
413
|
+
*
|
|
414
|
+
* @remarks
|
|
415
|
+
* Uses {@link createLafsArtifact} from bridge.ts to wrap the envelope
|
|
416
|
+
* in a properly formatted A2A artifact, then adds it to the task.
|
|
417
|
+
*
|
|
418
|
+
* @param manager - TaskManager instance managing the task
|
|
419
|
+
* @param taskId - ID of the task to attach the envelope to
|
|
420
|
+
* @param envelope - LAFS envelope to attach as an artifact
|
|
421
|
+
* @returns Deep clone of the updated task with the new artifact
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* ```typescript
|
|
425
|
+
* const envelope: LAFSEnvelope = { success: true, result: { data: 'ok' }, error: null, _meta: meta };
|
|
426
|
+
* const updated = attachLafsEnvelope(manager, 'task-1', envelope);
|
|
427
|
+
* ```
|
|
108
428
|
*/
|
|
109
429
|
export declare function attachLafsEnvelope(manager: TaskManager, taskId: string, envelope: LAFSEnvelope): Task;
|
|
110
430
|
//# sourceMappingURL=task-lifecycle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/a2a/task-lifecycle.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"task-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/a2a/task-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAc,MAAM,aAAa,CAAC;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAOhD,4DAA4D;AAC5D,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,SAAS,CAKjD,CAAC;AAEH,8DA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