@inkbox/sdk 0.5.5 → 0.5.6
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 +64 -5
- package/dist/a2a/client.d.ts +48 -0
- package/dist/a2a/client.d.ts.map +1 -0
- package/dist/a2a/client.js +259 -0
- package/dist/a2a/client.js.map +1 -0
- package/dist/a2a/index.d.ts +4 -0
- package/dist/a2a/index.d.ts.map +1 -0
- package/dist/a2a/index.js +3 -0
- package/dist/a2a/index.js.map +1 -0
- package/dist/a2a/resource.d.ts +51 -0
- package/dist/a2a/resource.d.ts.map +1 -0
- package/dist/a2a/resource.js +195 -0
- package/dist/a2a/resource.js.map +1 -0
- package/dist/a2a/types.d.ts +178 -0
- package/dist/a2a/types.d.ts.map +1 -0
- package/dist/a2a/types.js +80 -0
- package/dist/a2a/types.js.map +1 -0
- package/dist/agent_identity.d.ts +72 -0
- package/dist/agent_identity.d.ts.map +1 -1
- package/dist/agent_identity.js +112 -0
- package/dist/agent_identity.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/inkbox.d.ts +6 -0
- package/dist/inkbox.d.ts.map +1 -1
- package/dist/inkbox.js +9 -0
- package/dist/inkbox.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/webhooks/subscriptions.d.ts +12 -14
- package/dist/webhooks/subscriptions.d.ts.map +1 -1
- package/dist/webhooks/subscriptions.js +41 -28
- package/dist/webhooks/subscriptions.js.map +1 -1
- package/dist/webhooks/types.d.ts +20 -0
- package/dist/webhooks/types.d.ts.map +1 -1
- package/dist/whoami/types.d.ts +2 -0
- package/dist/whoami/types.d.ts.map +1 -1
- package/dist/whoami/types.js +1 -0
- package/dist/whoami/types.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -630,6 +630,65 @@ identity-owned webhook subscriptions — see
|
|
|
630
630
|
|
|
631
631
|
---
|
|
632
632
|
|
|
633
|
+
## Agent-to-Agent (A2A)
|
|
634
|
+
|
|
635
|
+
```ts
|
|
636
|
+
const identity = await inkbox.getIdentity("coordinator");
|
|
637
|
+
|
|
638
|
+
// Omit direction for the receiver inbox. Use "outbound" for requested work
|
|
639
|
+
// or "both" for the complete identity-scoped history.
|
|
640
|
+
const page = await identity.a2aTasks({
|
|
641
|
+
direction: "both",
|
|
642
|
+
requesterHandle: "coordinator",
|
|
643
|
+
workerHandle: "researcher",
|
|
644
|
+
state: "working",
|
|
645
|
+
q: "quarterly report",
|
|
646
|
+
since: "2026-07-01T00:00:00Z",
|
|
647
|
+
limit: 25,
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
if (page.nextCursor) {
|
|
651
|
+
await identity.a2aTasks({
|
|
652
|
+
direction: "both",
|
|
653
|
+
requesterHandle: "coordinator",
|
|
654
|
+
workerHandle: "researcher",
|
|
655
|
+
state: "working",
|
|
656
|
+
q: "quarterly report",
|
|
657
|
+
since: "2026-07-01T00:00:00Z",
|
|
658
|
+
cursor: page.nextCursor,
|
|
659
|
+
limit: 25,
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// Async iterators preserve every filter while following opaque cursors.
|
|
664
|
+
for await (const message of identity.iterA2AMessages({
|
|
665
|
+
direction: "outbound",
|
|
666
|
+
workerHandle: "researcher",
|
|
667
|
+
role: "agent",
|
|
668
|
+
q: "revenue",
|
|
669
|
+
})) {
|
|
670
|
+
console.log(message.taskId, message.taskState, message.parts);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// The outbound alias is convenient when only requested work is needed.
|
|
674
|
+
const sent = await identity.a2aSentTasks({ workerHandle: "researcher" });
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
Task keyword filtering returns tasks containing a matching message. Message
|
|
678
|
+
filtering returns the individual matching messages with task, context,
|
|
679
|
+
requester, and worker provenance. Search covers string and numeric content
|
|
680
|
+
values from `text` and `data` parts, excludes metadata, and is newest-first
|
|
681
|
+
rather than relevance-ranked. `role` is the message author (`caller` or
|
|
682
|
+
`agent`), independent of task direction. Task detail exposes message history
|
|
683
|
+
and current state.
|
|
684
|
+
|
|
685
|
+
Receiver enablement and advertised skills accept the identity's agent-scoped
|
|
686
|
+
key. Filter-mode and contact-rule create/update/delete operations require an
|
|
687
|
+
admin API key. Use `a2aResetSkills()` to restore default skills; rule
|
|
688
|
+
directions are `inbound`, `outbound`, or `both`. A protocol call must pass the
|
|
689
|
+
requester's outbound policy and the worker's inbound policy; `both` applies in
|
|
690
|
+
either role.
|
|
691
|
+
|
|
633
692
|
## Credentials
|
|
634
693
|
|
|
635
694
|
Access credentials stored in the vault through the agent-facing `credentials` surface. The vault must be unlocked first.
|
|
@@ -1090,10 +1149,9 @@ non-empty, distinct, no `phone.incoming_call`) plus the `message.` /
|
|
|
1090
1149
|
`Error` before the request leaves the client. The server remains
|
|
1091
1150
|
authoritative for the exact event-name enum, so a typo with a valid
|
|
1092
1151
|
prefix (e.g. `message.received_typo`) passes the SDK's check and is
|
|
1093
|
-
rejected as 422 by the server. On `update` the SDK
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
owner FK from a sub_id alone.
|
|
1152
|
+
rejected as 422 by the server. On `update` the SDK also rejects mixed
|
|
1153
|
+
event families. Owner compatibility remains server-validated because the
|
|
1154
|
+
SDK doesn't know the owner FK from a subscription ID alone.
|
|
1097
1155
|
|
|
1098
1156
|
### Conversation context
|
|
1099
1157
|
|
|
@@ -1101,7 +1159,8 @@ Opt a subscription into per-class conversation history on **received**
|
|
|
1101
1159
|
events (`message.received`, `text.received`, `imessage.received`) by
|
|
1102
1160
|
passing `contextConfig`. Each class (`email`, `texts`, `calls`) takes a
|
|
1103
1161
|
`count` mode (last N items, 1..50) or a `window` mode (last H hours,
|
|
1104
|
-
1..168); omit a class to leave it unconfigured.
|
|
1162
|
+
1..168); omit a class to leave it unconfigured. Conversation context is
|
|
1163
|
+
not supported for A2A subscriptions.
|
|
1105
1164
|
|
|
1106
1165
|
```ts
|
|
1107
1166
|
await inkbox.webhooks.subscriptions.create({
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** Stateless A2A 1.0 client with strict credential-origin pinning. */
|
|
2
|
+
import { InkboxError } from "../_http.js";
|
|
3
|
+
import type { A2AResolvedTarget, A2ASendResult, A2AWireTask, A2AWireTaskPage, A2AWireTaskState } from "./types.js";
|
|
4
|
+
export declare class A2AProtocolError extends InkboxError {
|
|
5
|
+
readonly code: number;
|
|
6
|
+
readonly data?: unknown | undefined;
|
|
7
|
+
constructor(code: number, message: string, data?: unknown | undefined);
|
|
8
|
+
}
|
|
9
|
+
export declare class A2AClient {
|
|
10
|
+
private readonly apiKey;
|
|
11
|
+
private nextId;
|
|
12
|
+
private readonly platformOrigin;
|
|
13
|
+
private readonly requestTimeoutMs;
|
|
14
|
+
private readonly targetCredentials;
|
|
15
|
+
constructor(apiKey: string, platformBaseUrl: string, options?: {
|
|
16
|
+
requestTimeoutMs?: number;
|
|
17
|
+
});
|
|
18
|
+
fetchCard(cardUrl: string, options?: {
|
|
19
|
+
credential?: string;
|
|
20
|
+
requestTimeoutMs?: number;
|
|
21
|
+
}): Promise<A2AResolvedTarget>;
|
|
22
|
+
send(target: A2AResolvedTarget, options: {
|
|
23
|
+
text?: string;
|
|
24
|
+
parts?: Record<string, unknown>[];
|
|
25
|
+
messageId?: string;
|
|
26
|
+
contextId?: string;
|
|
27
|
+
taskId?: string;
|
|
28
|
+
}): Promise<A2ASendResult>;
|
|
29
|
+
getTask(target: A2AResolvedTarget, taskId: string, options?: {
|
|
30
|
+
historyLength?: number;
|
|
31
|
+
requestTimeoutMs?: number;
|
|
32
|
+
}): Promise<A2AWireTask>;
|
|
33
|
+
listTasks(target: A2AResolvedTarget, options?: {
|
|
34
|
+
contextId?: string;
|
|
35
|
+
status?: A2AWireTaskState;
|
|
36
|
+
cursor?: string;
|
|
37
|
+
pageSize?: number;
|
|
38
|
+
historyLength?: number;
|
|
39
|
+
statusTimestampAfter?: string;
|
|
40
|
+
}): Promise<A2AWireTaskPage>;
|
|
41
|
+
cancel(target: A2AResolvedTarget, taskId: string): Promise<A2AWireTask>;
|
|
42
|
+
wait(target: A2AResolvedTarget, taskId: string, options?: {
|
|
43
|
+
timeoutMs?: number;
|
|
44
|
+
intervalMs?: number;
|
|
45
|
+
}): Promise<A2AWireTask>;
|
|
46
|
+
private rpc;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/a2a/client.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAEV,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,eAAe,EACf,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAKpB,qBAAa,gBAAiB,SAAQ,WAAW;IAE7C,QAAQ,CAAC,IAAI,EAAE,MAAM;IAErB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO;gBAFd,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACN,IAAI,CAAC,EAAE,OAAO,YAAA;CAK1B;AA0DD,qBAAa,SAAS;IAUlB,OAAO,CAAC,QAAQ,CAAC,MAAM;IATzB,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAG9B;gBAGe,MAAM,EAAE,MAAM,EAC/B,eAAe,EAAE,MAAM,EACvB,OAAO,GAAE;QAAE,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAO;IAQvC,SAAS,CACb,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QACP,UAAU,CAAC,EAA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
|
|
|
1
|
+
/** Stateless A2A 1.0 client with strict credential-origin pinning. */
|
|
2
|
+
import { InkboxError } from "../_http.js";
|
|
3
|
+
const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;
|
|
4
|
+
const MAX_REQUEST_TIMEOUT_MS = 2_147_483_647;
|
|
5
|
+
export class A2AProtocolError extends InkboxError {
|
|
6
|
+
code;
|
|
7
|
+
data;
|
|
8
|
+
constructor(code, message, data) {
|
|
9
|
+
super(`A2A error ${code}: ${message}`);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.data = data;
|
|
12
|
+
this.name = "A2AProtocolError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function canonicalUrl(value) {
|
|
16
|
+
const url = new URL(value);
|
|
17
|
+
if (url.username || url.password || url.hash) {
|
|
18
|
+
throw new TypeError("A2A URLs cannot contain credentials or fragments");
|
|
19
|
+
}
|
|
20
|
+
const local = url.hostname === "localhost" || url.hostname === "127.0.0.1";
|
|
21
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && local)) {
|
|
22
|
+
throw new TypeError("A2A URLs must use HTTPS");
|
|
23
|
+
}
|
|
24
|
+
url.hostname = url.hostname.toLowerCase();
|
|
25
|
+
if ((url.protocol === "https:" && url.port === "443")
|
|
26
|
+
|| (url.protocol === "http:" && url.port === "80")) {
|
|
27
|
+
url.port = "";
|
|
28
|
+
}
|
|
29
|
+
if (!url.pathname)
|
|
30
|
+
url.pathname = "/";
|
|
31
|
+
return url.toString();
|
|
32
|
+
}
|
|
33
|
+
function origin(value) {
|
|
34
|
+
return new URL(canonicalUrl(value)).origin;
|
|
35
|
+
}
|
|
36
|
+
function requestTimeout(value) {
|
|
37
|
+
if (!Number.isFinite(value)
|
|
38
|
+
|| value <= 0
|
|
39
|
+
|| value > MAX_REQUEST_TIMEOUT_MS) {
|
|
40
|
+
throw new TypeError(`A2A request timeout must be between 1 and ${MAX_REQUEST_TIMEOUT_MS} ms`);
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
async function withRequestTimeout(timeoutMs, operation, run) {
|
|
45
|
+
const controller = new AbortController();
|
|
46
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
47
|
+
try {
|
|
48
|
+
return await run(controller.signal);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (controller.signal.aborted) {
|
|
52
|
+
throw new InkboxError(`${operation} timed out after ${timeoutMs} ms`);
|
|
53
|
+
}
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
clearTimeout(timer);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export class A2AClient {
|
|
61
|
+
apiKey;
|
|
62
|
+
nextId = 0;
|
|
63
|
+
platformOrigin;
|
|
64
|
+
requestTimeoutMs;
|
|
65
|
+
targetCredentials = new WeakMap();
|
|
66
|
+
constructor(apiKey, platformBaseUrl, options = {}) {
|
|
67
|
+
this.apiKey = apiKey;
|
|
68
|
+
this.platformOrigin = origin(platformBaseUrl);
|
|
69
|
+
this.requestTimeoutMs = requestTimeout(options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS);
|
|
70
|
+
}
|
|
71
|
+
async fetchCard(cardUrl, options = {}) {
|
|
72
|
+
const canonicalCardUrl = canonicalUrl(cardUrl);
|
|
73
|
+
const card = await withRequestTimeout(requestTimeout(options.requestTimeoutMs ?? this.requestTimeoutMs), "A2A Agent Card request", async (signal) => {
|
|
74
|
+
const response = await fetch(canonicalCardUrl, {
|
|
75
|
+
method: "GET",
|
|
76
|
+
headers: { Accept: "application/json" },
|
|
77
|
+
redirect: "manual",
|
|
78
|
+
signal,
|
|
79
|
+
});
|
|
80
|
+
if (response.status >= 300 && response.status < 400) {
|
|
81
|
+
throw new InkboxError("A2A Agent Card redirects are refused");
|
|
82
|
+
}
|
|
83
|
+
if (!response.ok) {
|
|
84
|
+
throw new InkboxError(`A2A Agent Card request failed with HTTP ${response.status}`);
|
|
85
|
+
}
|
|
86
|
+
return await response.json();
|
|
87
|
+
});
|
|
88
|
+
const selected = card.supportedInterfaces?.find((item) => item.protocolVersion === "1.0"
|
|
89
|
+
&& item.protocolBinding.toUpperCase() === "JSONRPC");
|
|
90
|
+
if (!selected) {
|
|
91
|
+
throw new TypeError("Agent Card does not advertise A2A 1.0 JSON-RPC");
|
|
92
|
+
}
|
|
93
|
+
const rpcUrl = canonicalUrl(selected.url);
|
|
94
|
+
let credential = options.credential;
|
|
95
|
+
if (credential !== undefined
|
|
96
|
+
&& origin(rpcUrl) !== origin(canonicalCardUrl)) {
|
|
97
|
+
throw new TypeError("External A2A credentials require matching card and RPC origins");
|
|
98
|
+
}
|
|
99
|
+
if (origin(canonicalCardUrl) === this.platformOrigin) {
|
|
100
|
+
if (origin(rpcUrl) !== this.platformOrigin) {
|
|
101
|
+
throw new TypeError("Inkbox Agent Card points to a non-Inkbox RPC origin");
|
|
102
|
+
}
|
|
103
|
+
credential = this.apiKey;
|
|
104
|
+
}
|
|
105
|
+
const target = Object.freeze({
|
|
106
|
+
cardUrl: canonicalCardUrl,
|
|
107
|
+
rpcUrl,
|
|
108
|
+
protocolVersion: "1.0",
|
|
109
|
+
card,
|
|
110
|
+
});
|
|
111
|
+
if (credential !== undefined) {
|
|
112
|
+
this.targetCredentials.set(target, credential);
|
|
113
|
+
}
|
|
114
|
+
return target;
|
|
115
|
+
}
|
|
116
|
+
async send(target, options) {
|
|
117
|
+
if ((options.text === undefined) === (options.parts === undefined)) {
|
|
118
|
+
throw new TypeError("Pass exactly one of text or parts");
|
|
119
|
+
}
|
|
120
|
+
const message = {
|
|
121
|
+
messageId: options.messageId ?? crypto.randomUUID(),
|
|
122
|
+
role: "ROLE_USER",
|
|
123
|
+
parts: options.text === undefined ? options.parts : [{ text: options.text }],
|
|
124
|
+
};
|
|
125
|
+
if (options.contextId)
|
|
126
|
+
message.contextId = options.contextId;
|
|
127
|
+
if (options.taskId)
|
|
128
|
+
message.taskId = options.taskId;
|
|
129
|
+
const result = await this.rpc(target, "SendMessage", {
|
|
130
|
+
message,
|
|
131
|
+
configuration: { returnImmediately: true },
|
|
132
|
+
});
|
|
133
|
+
if (result.task && typeof result.task === "object") {
|
|
134
|
+
return { kind: "task", task: result.task };
|
|
135
|
+
}
|
|
136
|
+
if (result.message && typeof result.message === "object") {
|
|
137
|
+
return { kind: "message", message: result.message };
|
|
138
|
+
}
|
|
139
|
+
// Accept direct payloads from older A2A implementations.
|
|
140
|
+
return "status" in result && "id" in result
|
|
141
|
+
? { kind: "task", task: result }
|
|
142
|
+
: { kind: "message", message: result };
|
|
143
|
+
}
|
|
144
|
+
async getTask(target, taskId, options = {}) {
|
|
145
|
+
const result = await this.rpc(target, "GetTask", {
|
|
146
|
+
id: taskId,
|
|
147
|
+
...(options.historyLength === undefined
|
|
148
|
+
? {}
|
|
149
|
+
: { historyLength: options.historyLength }),
|
|
150
|
+
}, requestTimeout(options.requestTimeoutMs ?? this.requestTimeoutMs));
|
|
151
|
+
return result.task && typeof result.task === "object"
|
|
152
|
+
? result.task
|
|
153
|
+
: result;
|
|
154
|
+
}
|
|
155
|
+
async listTasks(target, options = {}) {
|
|
156
|
+
const raw = await this.rpc(target, "ListTasks", {
|
|
157
|
+
pageSize: options.pageSize ?? 50,
|
|
158
|
+
...(options.contextId ? { contextId: options.contextId } : {}),
|
|
159
|
+
...(options.status ? { status: options.status } : {}),
|
|
160
|
+
...(options.cursor ? { pageToken: options.cursor } : {}),
|
|
161
|
+
...(options.historyLength === undefined
|
|
162
|
+
? {}
|
|
163
|
+
: { historyLength: options.historyLength }),
|
|
164
|
+
...(options.statusTimestampAfter === undefined
|
|
165
|
+
? {}
|
|
166
|
+
: { statusTimestampAfter: options.statusTimestampAfter }),
|
|
167
|
+
});
|
|
168
|
+
return {
|
|
169
|
+
tasks: raw.tasks ?? [],
|
|
170
|
+
nextPageToken: raw.nextPageToken || null,
|
|
171
|
+
pageSize: raw.pageSize ?? options.pageSize ?? 50,
|
|
172
|
+
totalSize: raw.totalSize ?? 0,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
async cancel(target, taskId) {
|
|
176
|
+
const result = await this.rpc(target, "CancelTask", { id: taskId });
|
|
177
|
+
return result.task && typeof result.task === "object"
|
|
178
|
+
? result.task
|
|
179
|
+
: result;
|
|
180
|
+
}
|
|
181
|
+
async wait(target, taskId, options = {}) {
|
|
182
|
+
const timeoutMs = requestTimeout(options.timeoutMs ?? 120_000);
|
|
183
|
+
const intervalMs = requestTimeout(options.intervalMs ?? 5_000);
|
|
184
|
+
const deadline = Date.now() + timeoutMs;
|
|
185
|
+
const stopped = new Set([
|
|
186
|
+
"TASK_STATE_COMPLETED",
|
|
187
|
+
"TASK_STATE_FAILED",
|
|
188
|
+
"TASK_STATE_CANCELED",
|
|
189
|
+
"TASK_STATE_REJECTED",
|
|
190
|
+
"TASK_STATE_INPUT_REQUIRED",
|
|
191
|
+
"TASK_STATE_AUTH_REQUIRED",
|
|
192
|
+
]);
|
|
193
|
+
while (true) {
|
|
194
|
+
const remainingBeforeRequest = deadline - Date.now();
|
|
195
|
+
if (remainingBeforeRequest <= 0) {
|
|
196
|
+
throw new InkboxError(`A2A task ${taskId} did not stop before timeout`);
|
|
197
|
+
}
|
|
198
|
+
let task;
|
|
199
|
+
try {
|
|
200
|
+
task = await this.getTask(target, taskId, {
|
|
201
|
+
requestTimeoutMs: Math.min(this.requestTimeoutMs, remainingBeforeRequest),
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
if (Date.now() >= deadline) {
|
|
206
|
+
throw new InkboxError(`A2A task ${taskId} did not stop before timeout`);
|
|
207
|
+
}
|
|
208
|
+
throw error;
|
|
209
|
+
}
|
|
210
|
+
if (stopped.has(task.status.state))
|
|
211
|
+
return task;
|
|
212
|
+
const remaining = deadline - Date.now();
|
|
213
|
+
if (remaining <= 0) {
|
|
214
|
+
throw new InkboxError(`A2A task ${taskId} did not stop before timeout`);
|
|
215
|
+
}
|
|
216
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(intervalMs, remaining)));
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
async rpc(target, method, params, timeoutMs = this.requestTimeoutMs) {
|
|
220
|
+
const rpcUrl = target.rpcUrl;
|
|
221
|
+
if (canonicalUrl(rpcUrl) !== rpcUrl) {
|
|
222
|
+
throw new TypeError("A2A target RPC URL is not canonical");
|
|
223
|
+
}
|
|
224
|
+
const headers = {
|
|
225
|
+
Accept: "application/json",
|
|
226
|
+
"Content-Type": "application/json",
|
|
227
|
+
"A2A-Version": "1.0",
|
|
228
|
+
};
|
|
229
|
+
const credential = this.targetCredentials.get(target);
|
|
230
|
+
if (credential)
|
|
231
|
+
headers["X-API-Key"] = credential;
|
|
232
|
+
const payload = await withRequestTimeout(requestTimeout(timeoutMs), "A2A RPC request", async (signal) => {
|
|
233
|
+
const response = await fetch(rpcUrl, {
|
|
234
|
+
method: "POST",
|
|
235
|
+
headers,
|
|
236
|
+
redirect: "manual",
|
|
237
|
+
body: JSON.stringify({
|
|
238
|
+
jsonrpc: "2.0",
|
|
239
|
+
id: ++this.nextId,
|
|
240
|
+
method,
|
|
241
|
+
params,
|
|
242
|
+
}),
|
|
243
|
+
signal,
|
|
244
|
+
});
|
|
245
|
+
if (response.status >= 300 && response.status < 400) {
|
|
246
|
+
throw new InkboxError("A2A RPC redirects are refused");
|
|
247
|
+
}
|
|
248
|
+
if (!response.ok) {
|
|
249
|
+
throw new InkboxError(`A2A RPC request failed with HTTP ${response.status}`);
|
|
250
|
+
}
|
|
251
|
+
return await response.json();
|
|
252
|
+
});
|
|
253
|
+
if (payload.error) {
|
|
254
|
+
throw new A2AProtocolError(payload.error.code ?? -32603, payload.error.message ?? "Unknown A2A error", payload.error.data);
|
|
255
|
+
}
|
|
256
|
+
return payload.result;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
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AAC;QACF,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,MAAM,IAAI,gBAAgB,CACxB,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,EAC5B,OAAO,CAAC,KAAK,CAAC,OAAO,IAAI,mBAAmB,EAC5C,OAAO,CAAC,KAAK,CAAC,IAAI,CACnB,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC,MAAW,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { A2AClient, A2AProtocolError } from "./client.js";
|
|
2
|
+
export { A2AResource } from "./resource.js";
|
|
3
|
+
export type { A2ACard, A2ACaller, A2AContactRule, A2AContext, A2AContextPage, A2AHistoryDirection, A2AHistoryMessage, A2AHistoryMessagePage, A2AMessage, A2AMessageListOptions, A2AMessageRole, A2AReplyIntent, A2AResolvedTarget, A2ARuleAction, A2ARuleDirection, A2ASendResult, A2ASettings, A2ASkill, A2ATask, A2ATaskListOptions, A2ATaskPage, A2ATaskState, A2ASentTaskListOptions, A2ATarget, A2AWireMessage, A2AWireTask, A2AWireTaskPage, A2AWireTaskState, } from "./types.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/a2a/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EACV,OAAO,EACP,SAAS,EACT,cAAc,EACd,UAAU,EACV,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,EACV,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,QAAQ,EACR,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,sBAAsB,EACtB,SAAS,EACT,cAAc,EACd,WAAW,EACX,eAAe,EACf,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/a2a/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** Inkbox serve-side A2A inbox resource. */
|
|
2
|
+
import type { HttpTransport } from "../_http.js";
|
|
3
|
+
import type { FilterMode } from "../mail/types.js";
|
|
4
|
+
import type { A2AContactRule, A2AContext, A2AContextPage, A2AHistoryMessage, A2AHistoryMessagePage, A2AMessageListOptions, A2AReplyIntent, A2ARuleAction, A2ARuleDirection, A2ASettings, A2ASkill, A2ATask, A2ATaskListOptions, A2ATaskPage, A2ASentTaskListOptions } from "./types.js";
|
|
5
|
+
export declare class A2AResource {
|
|
6
|
+
private readonly http;
|
|
7
|
+
constructor(http: HttpTransport);
|
|
8
|
+
settings(handle: string): Promise<A2ASettings>;
|
|
9
|
+
updateSettings(handle: string, changes: {
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
filter_mode?: FilterMode;
|
|
12
|
+
skills?: A2ASkill[] | null;
|
|
13
|
+
}): Promise<A2ASettings>;
|
|
14
|
+
card(handle: string): Promise<Record<string, unknown>>;
|
|
15
|
+
tasks(handle: string, options?: A2ATaskListOptions): Promise<A2ATaskPage>;
|
|
16
|
+
iterTasks(handle: string, options?: Omit<A2ATaskListOptions, "cursor">): AsyncGenerator<A2ATask>;
|
|
17
|
+
task(handle: string, taskId: string): Promise<A2ATask>;
|
|
18
|
+
sentTasks(handle: string, options?: A2ASentTaskListOptions): Promise<A2ATaskPage>;
|
|
19
|
+
iterSentTasks(handle: string, options?: Omit<A2ASentTaskListOptions, "cursor">): AsyncGenerator<A2ATask>;
|
|
20
|
+
sentTask(handle: string, taskId: string): Promise<A2ATask>;
|
|
21
|
+
messages(handle: string, options?: A2AMessageListOptions): Promise<A2AHistoryMessagePage>;
|
|
22
|
+
iterMessages(handle: string, options?: Omit<A2AMessageListOptions, "cursor">): AsyncGenerator<A2AHistoryMessage>;
|
|
23
|
+
reply(handle: string, taskId: string, options: {
|
|
24
|
+
intent: A2AReplyIntent;
|
|
25
|
+
text?: string;
|
|
26
|
+
parts?: Record<string, unknown>[];
|
|
27
|
+
}): Promise<A2ATask>;
|
|
28
|
+
contexts(handle: string, options?: {
|
|
29
|
+
direction?: "inbound" | "outbound" | "both";
|
|
30
|
+
cursor?: string;
|
|
31
|
+
limit?: number;
|
|
32
|
+
}): Promise<A2AContextPage>;
|
|
33
|
+
context(handle: string, contextId: string): Promise<A2AContext>;
|
|
34
|
+
sentContexts(handle: string, options?: {
|
|
35
|
+
cursor?: string;
|
|
36
|
+
limit?: number;
|
|
37
|
+
}): Promise<A2AContextPage>;
|
|
38
|
+
sentContext(handle: string, contextId: string): Promise<A2AContext>;
|
|
39
|
+
contactRules(handle: string): Promise<A2AContactRule[]>;
|
|
40
|
+
addContactRule(handle: string, options: {
|
|
41
|
+
handle: string;
|
|
42
|
+
action: A2ARuleAction;
|
|
43
|
+
direction?: A2ARuleDirection;
|
|
44
|
+
}): Promise<A2AContactRule>;
|
|
45
|
+
updateContactRule(handle: string, ruleId: string, options: {
|
|
46
|
+
action?: A2ARuleAction;
|
|
47
|
+
direction?: A2ARuleDirection;
|
|
48
|
+
}): Promise<A2AContactRule>;
|
|
49
|
+
deleteContactRule(handle: string, ruleId: string): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/a2a/resource.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAE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