@absolutejs/a2a
Advanced tools
+30
-0
@@ -285,2 +285,13 @@ // @bun | ||
| }, | ||
| cancelForOperator: async (id, labels, now) => { | ||
| const result = await client.query(`UPDATE ${ns}.tasks SET state = 'TASK_STATE_CANCELED', data = jsonb_set(jsonb_set(data, '{status,state}', '"TASK_STATE_CANCELED"'::jsonb, true), '{status,timestamp}', to_jsonb($3::text), true), updated_at = $3::timestamptz | ||
| WHERE task_id = $1 AND labels @> $2::jsonb AND state NOT IN ('TASK_STATE_COMPLETED','TASK_STATE_CANCELED','TASK_STATE_FAILED','TASK_STATE_REJECTED') RETURNING labels, data`, [id, JSON.stringify(labels), now]); | ||
| const row = result.rows[0]; | ||
| if (!row) | ||
| return; | ||
| return { | ||
| labels: labelsOf(row), | ||
| task: visibleTask(taskOf(row), 0, false) | ||
| }; | ||
| }, | ||
| get: async (id, authorizationKey) => taskOf((await client.query(`SELECT data FROM ${ns}.tasks WHERE task_id = $1 AND authorization_key = $2`, [id, authorizationKey])).rows[0]), | ||
@@ -840,2 +851,21 @@ list: async (authorizationKey, request) => { | ||
| }, | ||
| cancelForOperator: async (id, labels, now) => { | ||
| const row = rows.get(id); | ||
| if (!row || !Object.entries(labels).every(([key, value]) => row.labels[key] === value) || terminal.has(row.task.status.state)) { | ||
| return; | ||
| } | ||
| const task = { | ||
| ...row.task, | ||
| status: { state: "TASK_STATE_CANCELED", timestamp: now } | ||
| }; | ||
| rows.set(id, { | ||
| authorizationKey: row.authorizationKey, | ||
| labels: row.labels, | ||
| task: structuredClone(task) | ||
| }); | ||
| return { | ||
| labels: structuredClone(row.labels), | ||
| task: structuredClone(visibleTask2(task, 0, false)) | ||
| }; | ||
| }, | ||
| get: async (id, authorizationKey) => { | ||
@@ -842,0 +872,0 @@ const row = rows.get(id); |
+1
-0
@@ -196,2 +196,3 @@ import type { ActionRequestInput, Agency, AgentActor } from "@absolutejs/agency"; | ||
| export type A2aTaskOperatorStore = { | ||
| cancelForOperator: (id: string, labels: A2aTaskLabels, now: string) => Promise<A2aOperatorTask | undefined>; | ||
| listForOperator: (request: A2aOperatorListTasksRequest) => Promise<A2aOperatorListTasksResponse>; | ||
@@ -198,0 +199,0 @@ }; |
+1
-1
| { | ||
| "name": "@absolutejs/a2a", | ||
| "version": "0.2.3", | ||
| "version": "0.2.4", | ||
| "description": "Production A2A Protocol 1.0 client and server with streaming, durable tasks, push configuration, and Agency enforcement.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Unidentified License
LicenseSomething that seems like a license was found, but its contents could not be matched with a known license.
Unidentified License
LicenseSomething that seems like a license was found, but its contents could not be matched with a known license.
299021
0.49%7289
0.43%