@agenticprimitives/a2a 0.0.0-alpha.1 → 0.0.0-alpha.10

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.
@@ -1,14 +1,16 @@
1
1
  import type { Hex } from '@agenticprimitives/types';
2
2
  import type { TaskRecord } from './types.js';
3
- export interface TaskStore {
3
+ import type { MessageIdReservation, MessageIdReserver } from './auth.js';
4
+ export interface TaskStore extends MessageIdReserver {
4
5
  /** Persist (insert or replace) a task record. */
5
6
  put(record: TaskRecord): Promise<void>;
6
7
  /** Load a task record, or null if unknown. */
7
8
  get(taskId: Hex): Promise<TaskRecord | null>;
8
9
  /** Task ids in a non-terminal state that are due for processing (drives the alarm loop). */
9
10
  listDue(now: number): Promise<Hex[]>;
10
- /** Single-use message-id reservation (FR-4.3 inbound replay guard). Returns false if already seen. */
11
- reserveMessageId(messageId: Hex, ttlSec: number): Promise<boolean>;
11
+ /** Single-use message-id reservation (FR-4.3 inbound replay guard); two-phase per spec 290 §3.
12
+ * Returns `null` if already in-flight/consumed, else a reservation to commit (durable) / release. */
13
+ reserveMessageId(messageId: Hex, ttlSec: number): Promise<MessageIdReservation | null>;
12
14
  }
13
15
  /** Reference in-memory TaskStore — used by the test harness + non-Worker consumers. NOT for production
14
16
  * (no cross-isolate durability); the Cloudflare DO adapter is the durable implementation. */
@@ -1 +1 @@
1
- {"version":3,"file":"task-store.d.ts","sourceRoot":"","sources":["../src/task-store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,SAAS;IACxB,iDAAiD;IACjD,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,8CAA8C;IAC9C,GAAG,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAC7C,4FAA4F;IAC5F,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACrC,sGAAsG;IACtG,gBAAgB,CAAC,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACpE;AAED;8FAC8F;AAC9F,wBAAgB,uBAAuB,IAAI,SAAS,CA2BnD"}
1
+ {"version":3,"file":"task-store.d.ts","sourceRoot":"","sources":["../src/task-store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEzE,MAAM,WAAW,SAAU,SAAQ,iBAAiB;IAClD,iDAAiD;IACjD,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,8CAA8C;IAC9C,GAAG,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAC7C,4FAA4F;IAC5F,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACrC;0GACsG;IACtG,gBAAgB,CAAC,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;CACxF;AAED;8FAC8F;AAC9F,wBAAgB,uBAAuB,IAAI,SAAS,CA6BnD"}
@@ -21,13 +21,15 @@ export function createInMemoryTaskStore() {
21
21
  },
22
22
  async reserveMessageId(messageId, ttlSec) {
23
23
  const key = messageId.toLowerCase();
24
- const exp = seen.get(key);
25
- // `now` is injected by callers in tests; here we approximate with a monotonic-free check: a present
26
- // entry means used. (The durable adapter uses KV TTL.)
27
- if (exp !== undefined)
28
- return false;
24
+ // A present entry means in-flight OR consumed — either way a replay (deny). Otherwise mark in-flight.
25
+ // (`now`/TTL is approximate in-memory; the durable adapter uses real storage. Two-phase per §290.3:)
26
+ if (seen.has(key))
27
+ return null;
29
28
  seen.set(key, ttlSec);
30
- return true;
29
+ return {
30
+ async commit() { seen.set(key, ttlSec); }, // stays present → permanently consumed
31
+ async release() { seen.delete(key); }, // free the in-flight slot so a legit retry can re-reserve
32
+ };
31
33
  },
32
34
  };
33
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"task-store.js","sourceRoot":"","sources":["../src/task-store.ts"],"names":[],"mappings":"AAiBA;8FAC8F;AAC9F,MAAM,UAAU,uBAAuB;IACrC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC5C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAC,CAAC,4BAA4B;IACpE,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,OAAO;QACL,KAAK,CAAC,GAAG,CAAC,MAAM;YACd,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,MAAM,CAAC,CAAC;YACpD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YAC7C,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS;gBAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;;gBAClF,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,MAAM;YACd,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,IAAI,CAAC;QACjD,CAAC;QACD,KAAK,CAAC,OAAO;YACX,OAAO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C,IAAI,IAAI,CAAC;QACjD,CAAC;QACD,KAAK,CAAC,OAAO;YACX,OAAO,CAAC,GAAG,GAAG,CAAU,CAAC;QAC3B,CAAC;QACD,KAAK,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM;YACtC,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;YACpC,sGAAsG;YACtG,qGAAqG;YACrG,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,OAAO,IAAI,CAAC;YAC/B,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACtB,OAAO;gBACL,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,uCAAuC;gBAClF,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAM,0DAA0D;aACtG,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticprimitives/a2a",
3
- "version": "0.0.0-alpha.1",
3
+ "version": "0.0.0-alpha.10",
4
4
  "description": "Async, delegation-authorized Agent-to-Agent (A2A) task transport: Task/Message/Artifact runtime over a TaskStore port, JSON-RPC method handlers, SkillHandler dispatch, the A2aWireAdapter client, and scoped-grant caveat builders. Transport-agnostic core (spec 269 / ADR-0034); the Cloudflare TaskStoreDO ships as the ./cloudflare adapter subpath.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -32,21 +32,10 @@
32
32
  "README.md",
33
33
  "CLAUDE.md"
34
34
  ],
35
- "scripts": {
36
- "build": "tsc -p tsconfig.build.json",
37
- "typecheck": "tsc -p tsconfig.json --noEmit",
38
- "test": "vitest run",
39
- "test:unit": "vitest run --passWithNoTests",
40
- "test:watch": "vitest",
41
- "clean": "rm -rf dist"
42
- },
43
35
  "publishConfig": {
44
36
  "access": "public"
45
37
  },
46
38
  "peerDependencies": {
47
- "@agenticprimitives/types": "workspace:*",
48
- "@agenticprimitives/fulfillment": "workspace:*",
49
- "@agenticprimitives/delegation": "workspace:*",
50
39
  "viem": "^2.52.2"
51
40
  },
52
41
  "devDependencies": {
@@ -61,5 +50,18 @@
61
50
  "delegation",
62
51
  "jsonrpc",
63
52
  "agentic"
64
- ]
65
- }
53
+ ],
54
+ "dependencies": {
55
+ "@agenticprimitives/delegation": "1.0.0-alpha.14",
56
+ "@agenticprimitives/fulfillment": "0.0.0-alpha.11",
57
+ "@agenticprimitives/types": "1.0.0-alpha.14"
58
+ },
59
+ "scripts": {
60
+ "build": "tsc -p tsconfig.build.json",
61
+ "typecheck": "tsc -p tsconfig.json --noEmit",
62
+ "test": "vitest run",
63
+ "test:unit": "vitest run --passWithNoTests",
64
+ "test:watch": "vitest",
65
+ "clean": "rm -rf dist"
66
+ }
67
+ }