@absol-labs/agent 0.3.1 → 0.4.0

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.
@@ -0,0 +1,336 @@
1
+ import { canonicalJson, deliveryReceiptSchema, signDeliveryReceipt, } from "@absol-labs/shared";
2
+ import { getHttpProviderClaimParamsFromProof, getProviderHashRequirementsFromSpec, verifyProof, } from "@reclaimprotocol/js-sdk";
3
+ import { keccak256, stringToBytes, } from "viem";
4
+ import { z } from "zod";
5
+ import { asErrorMessage, buildDeliveryContextEnvelopeV2, defaultReclaimClientFactory, deliveryContextEnvelopeV2Schema, parseReclaimProofEnv, ResponseProofUnavailableError, ResponseProofVerificationError, toRequestSpec, } from "./reclaim.js";
6
+ /**
7
+ * T2 consumer zkTLS delivery envelope (issue #24, metrik-protocol#67 DECISION).
8
+ *
9
+ * This is the BUYER-side counterpart to `streamproof-oracle`'s T2 accrue-on-proof
10
+ * ingest (`src/delivery/proof-ingest.ts`). Given the stream identity, an
11
+ * oracle-issued nonce (`GET /delivery/nonce`), and the paid-route request spec,
12
+ * it: (1) proves the paid route via a pluggable zkTLS attestor with the nonce
13
+ * bound into the request and the Metrik v2 envelope bound into
14
+ * `claimData.context`; (2) signs a `DeliveryReceipt` (`@absol-labs/shared`)
15
+ * committing to that proof; and (3) returns the exact `POST /delivery/proof`
16
+ * request body the oracle's `deliveryProofRequestSchema` expects.
17
+ *
18
+ * The attestor is pluggable (`DeliveryProofAttestor`) specifically so this can
19
+ * be tested WITHOUT a live Reclaim App Secret (agent#22 is the human-intervention
20
+ * issue for that credential) - the default production attestor
21
+ * (`createReclaimT2AttestorFromEnv`) still requires it.
22
+ */
23
+ const bytes32Hex = /^0x[0-9a-fA-F]{64}$/;
24
+ const evmAddress = /^0x[0-9a-fA-F]{40}$/;
25
+ const hexSignature = /^0x[0-9a-fA-F]+$/;
26
+ export class PaidRouteNonceInjectionError extends Error {
27
+ constructor(message) {
28
+ super(message);
29
+ this.name = "PaidRouteNonceInjectionError";
30
+ }
31
+ }
32
+ /** Injects the oracle-issued nonce into the paid-route request (query or body only). */
33
+ function injectNonce(spec, nonce) {
34
+ if (spec.nonceInjection.in === "query") {
35
+ let url;
36
+ try {
37
+ url = new URL(spec.url);
38
+ }
39
+ catch (cause) {
40
+ throw new PaidRouteNonceInjectionError(`paid route url is not a valid absolute URL: ${asErrorMessage(cause)}`);
41
+ }
42
+ url.searchParams.set(spec.nonceInjection.name, nonce);
43
+ return { url: url.toString(), body: spec.body };
44
+ }
45
+ const placeholder = spec.nonceInjection.placeholder;
46
+ const body = spec.body ?? "";
47
+ if (!body.includes(placeholder)) {
48
+ throw new PaidRouteNonceInjectionError(`paid route body does not contain the nonce placeholder "${placeholder}"`);
49
+ }
50
+ return { url: spec.url, body: body.split(placeholder).join(nonce) };
51
+ }
52
+ const reclaimT2UrlSchema = z.string().url();
53
+ /**
54
+ * Production `DeliveryProofAttestor`: drives the real Reclaim zkFetch + proof
55
+ * verification pipeline (mirrors `ReclaimConsumerProofService` in `reclaim.ts`,
56
+ * but binds the FLAT T2 v2 envelope directly as `context` instead of the v1
57
+ * `{contextAddress, contextMessage}` wrapper).
58
+ */
59
+ export class ReclaimDeliveryProofAttestor {
60
+ client;
61
+ config;
62
+ verifyProofImpl;
63
+ constructor(config, options = {}) {
64
+ this.config = {
65
+ ...config,
66
+ logs: config.logs ?? false,
67
+ };
68
+ this.client = (options.createClient ?? defaultReclaimClientFactory)(this.config.applicationId, this.config.applicationSecret, this.config.logs ?? false);
69
+ this.verifyProofImpl = options.verifyProof ?? verifyProof;
70
+ }
71
+ async proveDeliveryResponse(input) {
72
+ reclaimT2UrlSchema.parse(input.url);
73
+ if (input.responseMatches.length === 0) {
74
+ throw new Error("at least one response match is required");
75
+ }
76
+ const context = deliveryContextEnvelopeV2Schema.parse(input.context);
77
+ const parsed = { ...input, context };
78
+ const method = parsed.method ?? "GET";
79
+ const proof = await this.client
80
+ .zkFetch(parsed.url, {
81
+ method,
82
+ ...(parsed.body === undefined ? {} : { body: parsed.body }),
83
+ ...(parsed.headers === undefined ? {} : { headers: parsed.headers }),
84
+ ...(parsed.geoLocation === undefined
85
+ ? {}
86
+ : { geoLocation: parsed.geoLocation }),
87
+ context: parsed.context,
88
+ ...(parsed.useTee === undefined ? {} : { useTee: parsed.useTee }),
89
+ ...(parsed.zkEngine === undefined
90
+ ? {}
91
+ : { zkEngine: parsed.zkEngine }),
92
+ }, {
93
+ ...(parsed.secretHeaders === undefined
94
+ ? {}
95
+ : { headers: parsed.secretHeaders }),
96
+ responseMatches: parsed.responseMatches,
97
+ ...(parsed.responseRedactions === undefined
98
+ ? {}
99
+ : { responseRedactions: parsed.responseRedactions }),
100
+ ...(parsed.cookie === undefined ? {} : { cookieStr: parsed.cookie }),
101
+ ...(parsed.secretParamValues === undefined
102
+ ? {}
103
+ : { paramValues: parsed.secretParamValues }),
104
+ })
105
+ .catch((error) => {
106
+ throw new ResponseProofUnavailableError(`failed to generate T2 zkTLS delivery proof: ${asErrorMessage(error)}`);
107
+ });
108
+ if (proof === undefined) {
109
+ throw new ResponseProofUnavailableError("reclaim returned no zkTLS delivery proof");
110
+ }
111
+ const verification = await this.verifyProofImpl(proof, {
112
+ ...getProviderHashRequirementsFromSpec({
113
+ requests: [toRequestSpec(parsed, method)],
114
+ }),
115
+ ...(parsed.useTee === true
116
+ ? { teeAttestation: { appSecret: this.config.applicationSecret } }
117
+ : {}),
118
+ });
119
+ if (!verification.isVerified) {
120
+ throw new ResponseProofVerificationError(`T2 zkTLS delivery proof verification failed: ${asErrorMessage(verification.error)}`);
121
+ }
122
+ const trusted = verification.data[0];
123
+ if (trusted === undefined) {
124
+ throw new ResponseProofVerificationError("T2 zkTLS delivery proof verification returned no trusted data");
125
+ }
126
+ const request = getHttpProviderClaimParamsFromProof(proof);
127
+ return {
128
+ proof,
129
+ request: {
130
+ url: request.url,
131
+ method: request.method,
132
+ body: request.body === "" ? null : (request.body ?? null),
133
+ responseMatches: request.responseMatches.map((match) => ({
134
+ value: match.value,
135
+ type: match.type,
136
+ invert: match.invert,
137
+ isOptional: match.isOptional,
138
+ })),
139
+ responseRedactions: request.responseRedactions.map((redaction) => ({
140
+ regex: redaction.regex,
141
+ jsonPath: redaction.jsonPath,
142
+ xPath: redaction.xPath,
143
+ hash: redaction.hash,
144
+ })),
145
+ },
146
+ verification: {
147
+ context: trusted.context,
148
+ extractedParameters: trusted.extractedParameters,
149
+ publicData: verification.publicData[0] ?? null,
150
+ isTeeAttestationVerified: verification.isTeeAttestationVerified ?? false,
151
+ isAttestorTeeAttestationVerified: verification.isAttestorTeeAttestationVerified ?? false,
152
+ },
153
+ };
154
+ }
155
+ }
156
+ /** `null` when `RECLAIM_APP_ID`/`RECLAIM_APP_SECRET` are not configured (see agent#22). */
157
+ export function createReclaimT2AttestorFromEnv(env = process.env) {
158
+ const parsed = parseReclaimProofEnv(env);
159
+ if (parsed === null)
160
+ return null;
161
+ return new ReclaimDeliveryProofAttestor(parsed);
162
+ }
163
+ const wireDeliveryReceiptSchema = z
164
+ .object({
165
+ streamId: z.union([
166
+ z.string().regex(bytes32Hex),
167
+ z.string().regex(/^\d+$/),
168
+ ]),
169
+ serviceRef: z
170
+ .string()
171
+ .regex(bytes32Hex, "must be a 32-byte hex serviceRef"),
172
+ operator: z.string().regex(evmAddress, "must be an EVM address"),
173
+ intervalIndex: z
174
+ .string()
175
+ .regex(/^\d+$/, "must be a non-negative integer string"),
176
+ nonce: z.string().regex(bytes32Hex, "must be a 32-byte hex nonce"),
177
+ reclaimProofId: z
178
+ .string()
179
+ .regex(bytes32Hex, "must be a 32-byte hex identifier"),
180
+ reclaimOwner: z.string().regex(evmAddress, "must be an EVM address"),
181
+ reclaimTimestamp: z
182
+ .string()
183
+ .regex(/^\d+$/, "must be a non-negative integer string"),
184
+ reclaimEpoch: z
185
+ .string()
186
+ .regex(/^\d+$/, "must be a non-negative integer string"),
187
+ canonicalRequestHash: z
188
+ .string()
189
+ .regex(bytes32Hex, "must be a 32-byte hex hash"),
190
+ canonicalBodyHash: z
191
+ .string()
192
+ .regex(bytes32Hex, "must be a 32-byte hex hash"),
193
+ })
194
+ .strict();
195
+ const reclaimProviderClaimDataSchema = z
196
+ .object({
197
+ provider: z.string().min(1),
198
+ parameters: z.string().min(1),
199
+ context: z.string(),
200
+ owner: z.string().regex(evmAddress, "must be an EVM address"),
201
+ timestampS: z.number().int().nonnegative(),
202
+ epoch: z.number().int().nonnegative(),
203
+ identifier: z
204
+ .string()
205
+ .regex(bytes32Hex, "must be a 32-byte hex identifier"),
206
+ })
207
+ .strict();
208
+ const reclaimProofWireSchema = z
209
+ .object({
210
+ identifier: z
211
+ .string()
212
+ .regex(bytes32Hex, "must be a 32-byte hex identifier"),
213
+ claimData: reclaimProviderClaimDataSchema,
214
+ signatures: z.array(z.string().regex(hexSignature)).min(1),
215
+ })
216
+ .strict();
217
+ /**
218
+ * `POST /delivery/proof` request body - mirrors the oracle's own
219
+ * `deliveryProofRequestSchema` (`streamproof-oracle/src/delivery/dto.ts`)
220
+ * field-for-field. Kept as a local copy (same convention the oracle itself
221
+ * uses for `@absol-labs/shared` shapes) rather than an import, since the two
222
+ * repos do not share a package for this DTO.
223
+ */
224
+ export const deliveryProofRequestBodySchema = z
225
+ .object({
226
+ receipt: wireDeliveryReceiptSchema,
227
+ signature: z.string().regex(hexSignature, "must be a hex signature"),
228
+ proof: reclaimProofWireSchema,
229
+ })
230
+ .strict();
231
+ /** Converts a bigint-typed `DeliveryReceipt` to the oracle's decimal-string wire shape. */
232
+ export function toWireDeliveryReceipt(receipt) {
233
+ return {
234
+ streamId: receipt.streamId.toString(),
235
+ serviceRef: receipt.serviceRef,
236
+ operator: receipt.operator,
237
+ intervalIndex: receipt.intervalIndex.toString(),
238
+ nonce: receipt.nonce,
239
+ reclaimProofId: receipt.reclaimProofId,
240
+ reclaimOwner: receipt.reclaimOwner,
241
+ reclaimTimestamp: receipt.reclaimTimestamp.toString(),
242
+ reclaimEpoch: receipt.reclaimEpoch.toString(),
243
+ canonicalRequestHash: receipt.canonicalRequestHash,
244
+ canonicalBodyHash: receipt.canonicalBodyHash,
245
+ };
246
+ }
247
+ /** Deterministic keccak256 over the canonical (sorted-key) JSON of `value`. */
248
+ function hashCanonical(value) {
249
+ return keccak256(stringToBytes(canonicalJson(value)));
250
+ }
251
+ export class NoDeliveryAttestorConfiguredError extends Error {
252
+ constructor() {
253
+ super("no zkTLS delivery attestor configured: set RECLAIM_APP_ID/RECLAIM_APP_SECRET " +
254
+ "(see agent#22) or pass an explicit `attestor`");
255
+ this.name = "NoDeliveryAttestorConfiguredError";
256
+ }
257
+ }
258
+ /**
259
+ * Produces a complete T2 delivery proof envelope: proves the paid route with
260
+ * the oracle-issued nonce bound into both the request and the Reclaim
261
+ * `claimData.context`, signs a `DeliveryReceipt` committing to that proof, and
262
+ * returns the exact body for `POST /delivery/proof`.
263
+ */
264
+ export async function buildT2DeliveryProofSubmission(input) {
265
+ const issuedAt = input.issuedAt ?? Math.floor(Date.now() / 1000);
266
+ if (input.intervalIndex > BigInt(Number.MAX_SAFE_INTEGER)) {
267
+ throw new RangeError("intervalIndex exceeds Number.MAX_SAFE_INTEGER");
268
+ }
269
+ const envelope = buildDeliveryContextEnvelopeV2({
270
+ streamId: input.streamId,
271
+ operator: input.operator,
272
+ serviceRef: input.serviceRef,
273
+ ...(input.mandateId === undefined ? {} : { mandateId: input.mandateId }),
274
+ nonce: input.nonce,
275
+ intervalIndex: Number(input.intervalIndex),
276
+ issuedAt,
277
+ });
278
+ const injected = injectNonce(input.request, input.nonce);
279
+ const attestor = input.attestor ?? createReclaimT2AttestorFromEnv();
280
+ if (attestor === null) {
281
+ throw new NoDeliveryAttestorConfiguredError();
282
+ }
283
+ const proved = await attestor.proveDeliveryResponse({
284
+ url: injected.url,
285
+ method: input.request.method,
286
+ body: injected.body,
287
+ headers: input.request.headers,
288
+ secretHeaders: input.request.secretHeaders,
289
+ responseMatches: input.request.responseMatches,
290
+ responseRedactions: input.request.responseRedactions,
291
+ cookie: input.request.cookie,
292
+ secretParamValues: input.request.secretParamValues,
293
+ geoLocation: input.request.geoLocation,
294
+ useTee: input.request.useTee,
295
+ zkEngine: input.request.zkEngine,
296
+ context: envelope,
297
+ });
298
+ const { proof } = proved;
299
+ // Deterministically bind BOTH the exact proven request (method/url/body, post
300
+ // nonce-injection) and the exact PROVEN (redacted/extracted) response content
301
+ // into the receipt, so the receipt is verifiable dispute evidence even though
302
+ // the oracle itself does not re-derive these hashes today.
303
+ const canonicalRequestHash = hashCanonical({
304
+ method: proved.request.method,
305
+ url: proved.request.url,
306
+ body: proved.request.body,
307
+ });
308
+ const canonicalBodyHash = hashCanonical({
309
+ extractedParameters: proved.verification.extractedParameters,
310
+ });
311
+ const receipt = deliveryReceiptSchema.parse({
312
+ streamId: BigInt(input.streamId),
313
+ serviceRef: input.serviceRef,
314
+ operator: input.operator,
315
+ intervalIndex: input.intervalIndex,
316
+ nonce: input.nonce,
317
+ reclaimProofId: proof.identifier,
318
+ reclaimOwner: proof.claimData.owner,
319
+ reclaimTimestamp: BigInt(proof.claimData.timestampS),
320
+ reclaimEpoch: BigInt(proof.claimData.epoch),
321
+ canonicalRequestHash,
322
+ canonicalBodyHash,
323
+ });
324
+ const signature = await signDeliveryReceipt(receipt, input.domain, input.buyer);
325
+ const body = deliveryProofRequestBodySchema.parse({
326
+ receipt: toWireDeliveryReceipt(receipt),
327
+ signature,
328
+ proof: {
329
+ identifier: proof.identifier,
330
+ claimData: proof.claimData,
331
+ signatures: proof.signatures,
332
+ },
333
+ });
334
+ return { body, receipt, signature, proof, envelope };
335
+ }
336
+ //# sourceMappingURL=t2-delivery-proof.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"t2-delivery-proof.js","sourceRoot":"","sources":["../../src/zktls/t2-delivery-proof.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,mBAAmB,GAGpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mCAAm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AAC,CAAC;IAE7B,MAAM,SAAS,GAAG,MAAM,mBAAmB,CACzC,OAAO,EACP,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,KAAK,CACZ,CAAC;IAEF,MAAM,IAAI,GAAG,8BAA8B,CAAC,KAAK,CAAC;QAChD,OAAO,EAAE,qBAAqB,CAAC,OAAO,CAAC;QACvC,SAAS;QACT,KAAK,EAAE;YACL,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,UAAU,EAAE,KAAK,CAAC,UAAU;SAC7B;KACuD,CAAC,CAAC;IAE5D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACvD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absol-labs/agent",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Metrik agent layer: x402 verified-streaming payments, an MCP server, framework tools, and spend mandates so AI agents can hire and pay verified services safely.",
5
5
  "license": "MIT",
6
6
  "author": "Absol Labs",
@@ -67,11 +67,8 @@
67
67
  },
68
68
  "dependencies": {
69
69
  "@absol-labs/sdk": "^0.4.0",
70
- "@absol-labs/shared": "^0.7.1",
71
- "@coinbase/agentkit": "^0.10.4",
70
+ "@absol-labs/shared": "^0.11.0",
72
71
  "@coinbase/cdp-sdk": "^1.51.2",
73
- "@elizaos/core": "^1.7.2",
74
- "@langchain/core": "^1.2.0",
75
72
  "@modelcontextprotocol/sdk": "^1.29.0",
76
73
  "@reclaimprotocol/js-sdk": "^5.6.0",
77
74
  "@reclaimprotocol/zk-fetch": "^1.0.0",
@@ -79,7 +76,26 @@
79
76
  "viem": "^2.21.0",
80
77
  "zod": "^3.24.0"
81
78
  },
79
+ "peerDependencies": {
80
+ "@coinbase/agentkit": "^0.10.4",
81
+ "@elizaos/core": "^1.7.2",
82
+ "@langchain/core": "^1.2.0"
83
+ },
84
+ "peerDependenciesMeta": {
85
+ "@coinbase/agentkit": {
86
+ "optional": true
87
+ },
88
+ "@elizaos/core": {
89
+ "optional": true
90
+ },
91
+ "@langchain/core": {
92
+ "optional": true
93
+ }
94
+ },
82
95
  "devDependencies": {
96
+ "@coinbase/agentkit": "^0.10.4",
97
+ "@elizaos/core": "^1.7.2",
98
+ "@langchain/core": "^1.2.0",
83
99
  "@swc/core": "^1.10.0",
84
100
  "@types/node": "^20.17.0",
85
101
  "prettier": "^3.4.0",
@@ -1,4 +1,4 @@
1
- import { DynamicStructuredTool } from "@langchain/core/tools";
1
+ import type { DynamicStructuredTool as DynamicStructuredToolType } from "@langchain/core/tools";
2
2
  import { isAddress, isHex } from "viem";
3
3
  import { z } from "zod/v3";
4
4
 
@@ -17,6 +17,23 @@ import {
17
17
  type VerifiedStreamAgentOpener,
18
18
  } from "../sdk/client.js";
19
19
 
20
+ // LangChain is an OPTIONAL peer dependency. The top-level "@absol-labs/agent"
21
+ // barrel never imports this module, so the core package installs and imports
22
+ // without LangChain present. Load the runtime class lazily here so importing
23
+ // THIS subpath ("@absol-labs/agent/langchain") without the peer installed fails
24
+ // with a clear, actionable message instead of a raw module-not-found error.
25
+ type LangChainToolsModule = typeof import("@langchain/core/tools");
26
+ let DynamicStructuredToolCtor: LangChainToolsModule["DynamicStructuredTool"];
27
+ try {
28
+ ({ DynamicStructuredTool: DynamicStructuredToolCtor } =
29
+ await import("@langchain/core/tools"));
30
+ } catch (error) {
31
+ throw new Error(
32
+ "@absol-labs/agent/langchain requires the optional peer dependency '@langchain/core'. Install it with `npm install @langchain/core`.",
33
+ { cause: error },
34
+ );
35
+ }
36
+
20
37
  const addressSchema = z
21
38
  .string()
22
39
  .refine((value) => isAddress(value), "must be an EVM address");
@@ -118,11 +135,11 @@ export interface LangChainVerifiedStreamToolsOptions {
118
135
  }
119
136
 
120
137
  export interface LangChainVerifiedStreamTools {
121
- readonly discover: DynamicStructuredTool<any, any, any, any, any, string>;
122
- readonly hire: DynamicStructuredTool<any, any, any, any, any, string>;
123
- readonly status: DynamicStructuredTool<any, any, any, any, any, string>;
124
- readonly reclaim: DynamicStructuredTool<any, any, any, any, any, string>;
125
- readonly close: DynamicStructuredTool<any, any, any, any, any, string>;
138
+ readonly discover: DynamicStructuredToolType<any, any, any, any, any, string>;
139
+ readonly hire: DynamicStructuredToolType<any, any, any, any, any, string>;
140
+ readonly status: DynamicStructuredToolType<any, any, any, any, any, string>;
141
+ readonly reclaim: DynamicStructuredToolType<any, any, any, any, any, string>;
142
+ readonly close: DynamicStructuredToolType<any, any, any, any, any, string>;
126
143
  }
127
144
 
128
145
  const DEFAULT_MANDATE_STATE_RESOLVER: LangChainMandateStateResolver = {
@@ -140,8 +157,8 @@ export function createLangChainVerifiedStreamTools(
140
157
  const now = options.now ?? (() => Math.floor(Date.now() / 1000));
141
158
  const discoverImpl = options.discoverServices ?? defaultDiscoverServices;
142
159
 
143
- const discover: DynamicStructuredTool<any, any, any, any, any, string> =
144
- new DynamicStructuredTool({
160
+ const discover: DynamicStructuredToolType<any, any, any, any, any, string> =
161
+ new DynamicStructuredToolCtor({
145
162
  name: "discover_services",
146
163
  description:
147
164
  "Discover verified third-party services on the Metrik marketplace. Returns operator + serviceRef + endpoint for listings whose operator signature is verified — the entry point before hire_verified_service.",
@@ -153,10 +170,10 @@ export function createLangChainVerifiedStreamTools(
153
170
  });
154
171
  return { services: listings };
155
172
  },
156
- }) as DynamicStructuredTool<any, any, any, any, any, string>;
173
+ }) as DynamicStructuredToolType<any, any, any, any, any, string>;
157
174
 
158
- const hire: DynamicStructuredTool<any, any, any, any, any, string> =
159
- new DynamicStructuredTool({
175
+ const hire: DynamicStructuredToolType<any, any, any, any, any, string> =
176
+ new DynamicStructuredToolCtor({
160
177
  name: "hire_verified_service",
161
178
  description:
162
179
  "Open a verified payment stream with a signed mandate and hard budget limits.",
@@ -207,10 +224,10 @@ export function createLangChainVerifiedStreamTools(
207
224
  handle: result.handle,
208
225
  };
209
226
  },
210
- }) as DynamicStructuredTool<any, any, any, any, any, string>;
227
+ }) as DynamicStructuredToolType<any, any, any, any, any, string>;
211
228
 
212
- const status: DynamicStructuredTool<any, any, any, any, any, string> =
213
- new DynamicStructuredTool({
229
+ const status: DynamicStructuredToolType<any, any, any, any, any, string> =
230
+ new DynamicStructuredToolCtor({
214
231
  name: "check_stream_status",
215
232
  description:
216
233
  "Read the current stream status and whether the agent should stop work.",
@@ -221,10 +238,10 @@ export function createLangChainVerifiedStreamTools(
221
238
  );
222
239
  return serializeStreamStatus(result, streamId as `0x${string}`);
223
240
  },
224
- }) as DynamicStructuredTool<any, any, any, any, any, string>;
241
+ }) as DynamicStructuredToolType<any, any, any, any, any, string>;
225
242
 
226
- const reclaim: DynamicStructuredTool<any, any, any, any, any, string> =
227
- new DynamicStructuredTool({
243
+ const reclaim: DynamicStructuredToolType<any, any, any, any, any, string> =
244
+ new DynamicStructuredToolCtor({
228
245
  name: "reclaim_unspent",
229
246
  description:
230
247
  "Close and/or reclaim an existing stream under the same signed mandate controls.",
@@ -254,10 +271,10 @@ export function createLangChainVerifiedStreamTools(
254
271
  reclaimTxHash: result.reclaimResult.txHash,
255
272
  };
256
273
  },
257
- }) as DynamicStructuredTool<any, any, any, any, any, string>;
274
+ }) as DynamicStructuredToolType<any, any, any, any, any, string>;
258
275
 
259
- const close: DynamicStructuredTool<any, any, any, any, any, string> =
260
- new DynamicStructuredTool({
276
+ const close: DynamicStructuredToolType<any, any, any, any, any, string> =
277
+ new DynamicStructuredToolCtor({
261
278
  name: "close_stream",
262
279
  description:
263
280
  "Close an existing stream, finalizing accrual and halting further payment, under the same signed mandate controls.",
@@ -281,7 +298,7 @@ export function createLangChainVerifiedStreamTools(
281
298
 
282
299
  return { closeTxHash: result.txHash };
283
300
  },
284
- }) as DynamicStructuredTool<any, any, any, any, any, string>;
301
+ }) as DynamicStructuredToolType<any, any, any, any, any, string>;
285
302
 
286
303
  return { discover, hire, status, reclaim, close };
287
304
  }
package/src/index.ts CHANGED
@@ -117,9 +117,13 @@ export {
117
117
  ReclaimConsumerProofService,
118
118
  ResponseProofUnavailableError,
119
119
  ResponseProofVerificationError,
120
+ buildDeliveryContextEnvelopeV2,
120
121
  createReclaimConsumerProofServiceFromEnv,
122
+ deliveryContextEnvelopeV2Schema,
121
123
  parseReclaimProofEnv,
122
124
  type ConsumerDeliveryProofService,
125
+ type DeliveryContextEnvelopeV2,
126
+ type DeliveryContextEnvelopeV2Input,
123
127
  type DeliveryProofBinding,
124
128
  type HttpsResponseMatch,
125
129
  type HttpsResponseRedaction,
@@ -132,6 +136,24 @@ export {
132
136
  type VerifyProofFn,
133
137
  } from "./zktls/reclaim.js";
134
138
 
139
+ export {
140
+ NoDeliveryAttestorConfiguredError,
141
+ PaidRouteNonceInjectionError,
142
+ ReclaimDeliveryProofAttestor,
143
+ buildT2DeliveryProofSubmission,
144
+ createReclaimT2AttestorFromEnv,
145
+ deliveryProofRequestBodySchema,
146
+ toWireDeliveryReceipt,
147
+ type BuildT2DeliveryProofInput,
148
+ type BuildT2DeliveryProofResult,
149
+ type DeliveryProofAttestor,
150
+ type DeliveryProofRequestBody,
151
+ type PaidRouteRequestSpec,
152
+ type ProveDeliveryResponseInput,
153
+ type T2NonceInjection,
154
+ type WireDeliveryReceipt,
155
+ } from "./zktls/t2-delivery-proof.js";
156
+
135
157
  // Framework adapters are NOT re-exported from this top-level barrel on purpose.
136
158
  // Some of them (notably the Coinbase AgentKit adapter) pull heavy optional
137
159
  // dependency graphs, so importing "@absol-labs/agent" must stay light and load