@absol-labs/agent 0.3.1 → 0.3.2
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,4 +1,4 @@
|
|
|
1
|
-
import { DynamicStructuredTool } from "@langchain/core/tools";
|
|
1
|
+
import type { DynamicStructuredTool as DynamicStructuredToolType } from "@langchain/core/tools";
|
|
2
2
|
import { type DiscoverServicesOptions, type ServiceListing } from "../discovery/registry.js";
|
|
3
3
|
import { type MandateAuthorizedStreamActionInput, type ReclaimAuthorizedStreamInput, type ReclaimVerifiedStreamResult, type StreamProofTransactionResult, type StreamStatusView, type VerifiedStreamAgentOpener } from "../sdk/client.js";
|
|
4
4
|
export interface LangChainMandateStateResolver {
|
|
@@ -21,11 +21,11 @@ export interface LangChainVerifiedStreamToolsOptions {
|
|
|
21
21
|
readonly discoverServices?: (opts?: DiscoverServicesOptions) => Promise<ServiceListing[]>;
|
|
22
22
|
}
|
|
23
23
|
export interface LangChainVerifiedStreamTools {
|
|
24
|
-
readonly discover:
|
|
25
|
-
readonly hire:
|
|
26
|
-
readonly status:
|
|
27
|
-
readonly reclaim:
|
|
28
|
-
readonly close:
|
|
24
|
+
readonly discover: DynamicStructuredToolType<any, any, any, any, any, string>;
|
|
25
|
+
readonly hire: DynamicStructuredToolType<any, any, any, any, any, string>;
|
|
26
|
+
readonly status: DynamicStructuredToolType<any, any, any, any, any, string>;
|
|
27
|
+
readonly reclaim: DynamicStructuredToolType<any, any, any, any, any, string>;
|
|
28
|
+
readonly close: DynamicStructuredToolType<any, any, any, any, any, string>;
|
|
29
29
|
}
|
|
30
30
|
export declare function createLangChainVerifiedStreamTools(options: LangChainVerifiedStreamToolsOptions): LangChainVerifiedStreamTools;
|
|
31
31
|
//# sourceMappingURL=langchain.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langchain.d.ts","sourceRoot":"","sources":["../../src/frameworks/langchain.ts"],"names":[],"mappings":"AAAA,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gBAAgB,CAAC,EAAE,CAC1B,IAAI,CAAC,EAAE,uBAAuB,KAC3B,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAC9E,QAAQ,CAAC,IAAI,EAAE,yBAAyB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAC1E,QAAQ,CAAC,MAAM,EAAE,yBAAyB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAC5E,QAAQ,CAAC,OAAO,EAAE,yBAAyB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAC7E,QAAQ,CAAC,KAAK,EAAE,yBAAyB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;CAC5E;AAOD,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,mCAAmC,GAC3C,4BAA4B,CAwJ9B"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { DynamicStructuredTool } from "@langchain/core/tools";
|
|
2
1
|
import { isAddress, isHex } from "viem";
|
|
3
2
|
import { z } from "zod/v3";
|
|
4
3
|
import { discoverServices as defaultDiscoverServices, } from "../discovery/registry.js";
|
|
5
4
|
import { checkMandate } from "../mandates/mandate.js";
|
|
5
|
+
let DynamicStructuredToolCtor;
|
|
6
|
+
try {
|
|
7
|
+
({ DynamicStructuredTool: DynamicStructuredToolCtor } =
|
|
8
|
+
await import("@langchain/core/tools"));
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
throw new Error("@absol-labs/agent/langchain requires the optional peer dependency '@langchain/core'. Install it with `npm install @langchain/core`.", { cause: error });
|
|
12
|
+
}
|
|
6
13
|
const addressSchema = z
|
|
7
14
|
.string()
|
|
8
15
|
.refine((value) => isAddress(value), "must be an EVM address");
|
|
@@ -65,7 +72,7 @@ export function createLangChainVerifiedStreamTools(options) {
|
|
|
65
72
|
};
|
|
66
73
|
const now = options.now ?? (() => Math.floor(Date.now() / 1000));
|
|
67
74
|
const discoverImpl = options.discoverServices ?? defaultDiscoverServices;
|
|
68
|
-
const discover = new
|
|
75
|
+
const discover = new DynamicStructuredToolCtor({
|
|
69
76
|
name: "discover_services",
|
|
70
77
|
description: "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.",
|
|
71
78
|
schema: discoverToolSchema,
|
|
@@ -77,7 +84,7 @@ export function createLangChainVerifiedStreamTools(options) {
|
|
|
77
84
|
return { services: listings };
|
|
78
85
|
},
|
|
79
86
|
});
|
|
80
|
-
const hire = new
|
|
87
|
+
const hire = new DynamicStructuredToolCtor({
|
|
81
88
|
name: "hire_verified_service",
|
|
82
89
|
description: "Open a verified payment stream with a signed mandate and hard budget limits.",
|
|
83
90
|
schema: hireToolSchema,
|
|
@@ -117,7 +124,7 @@ export function createLangChainVerifiedStreamTools(options) {
|
|
|
117
124
|
};
|
|
118
125
|
},
|
|
119
126
|
});
|
|
120
|
-
const status = new
|
|
127
|
+
const status = new DynamicStructuredToolCtor({
|
|
121
128
|
name: "check_stream_status",
|
|
122
129
|
description: "Read the current stream status and whether the agent should stop work.",
|
|
123
130
|
schema: streamStatusToolSchema,
|
|
@@ -126,7 +133,7 @@ export function createLangChainVerifiedStreamTools(options) {
|
|
|
126
133
|
return serializeStreamStatus(result, streamId);
|
|
127
134
|
},
|
|
128
135
|
});
|
|
129
|
-
const reclaim = new
|
|
136
|
+
const reclaim = new DynamicStructuredToolCtor({
|
|
130
137
|
name: "reclaim_unspent",
|
|
131
138
|
description: "Close and/or reclaim an existing stream under the same signed mandate controls.",
|
|
132
139
|
schema: reclaimToolSchema,
|
|
@@ -151,7 +158,7 @@ export function createLangChainVerifiedStreamTools(options) {
|
|
|
151
158
|
};
|
|
152
159
|
},
|
|
153
160
|
});
|
|
154
|
-
const close = new
|
|
161
|
+
const close = new DynamicStructuredToolCtor({
|
|
155
162
|
name: "close_stream",
|
|
156
163
|
description: "Close an existing stream, finalizing accrual and halting further payment, under the same signed mandate controls.",
|
|
157
164
|
schema: closeToolSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langchain.js","sourceRoot":"","sources":["../../src/frameworks/langchain.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"langchain.js","sourceRoot":"","sources":["../../src/frameworks/langchain.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EACL,gBAAgB,IAAI,uBAAuB,GAG5C,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAA2B,MAAM,wBAAwB,CAAC;AAgB/E,IAAI,yBAAwE,CAAC;AAC7E,IAAI,CAAC;IACH,CAAC,EAAE,qBAAqB,EAAE,yBAAyB,EAAE;QACnD,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC;AAC3C,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,MAAM,IAAI,KAAK,CACb,qIAAqI,EACrI,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;AACJ,CAAC;AAED,MAAM,aAAa,GAAG,CAAC;KACpB,MAAM,EAAE;KACR,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,wBAAwB,CAAC,CAAC;AACjE,MAAM,aAAa,GAAG,CAAC;KACpB,MAAM,EAAE;KACR,M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;YACzD,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC;YACjD,oBAAoB,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC;SAClE;KACF,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAC5B,MAAwB,EACxB,QAAuB;IAEvB,OAAO;QACL,QAAQ;QACR,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,QAAQ;QAC7C,MAAM,EAAE;YACN,GAAG,MAAM,CAAC,MAAM;YAChB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE;YACzC,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE;YACrD,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE;YACzC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE;YACzC,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE;SACpD;QACD,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE;QACtC,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE;KAC3C,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absol-labs/agent",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
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",
|
|
@@ -68,10 +68,7 @@
|
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@absol-labs/sdk": "^0.4.0",
|
|
70
70
|
"@absol-labs/shared": "^0.7.1",
|
|
71
|
-
"@coinbase/agentkit": "^0.10.4",
|
|
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:
|
|
122
|
-
readonly hire:
|
|
123
|
-
readonly status:
|
|
124
|
-
readonly reclaim:
|
|
125
|
-
readonly close:
|
|
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:
|
|
144
|
-
new
|
|
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
|
|
173
|
+
}) as DynamicStructuredToolType<any, any, any, any, any, string>;
|
|
157
174
|
|
|
158
|
-
const hire:
|
|
159
|
-
new
|
|
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
|
|
227
|
+
}) as DynamicStructuredToolType<any, any, any, any, any, string>;
|
|
211
228
|
|
|
212
|
-
const status:
|
|
213
|
-
new
|
|
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
|
|
241
|
+
}) as DynamicStructuredToolType<any, any, any, any, any, string>;
|
|
225
242
|
|
|
226
|
-
const reclaim:
|
|
227
|
-
new
|
|
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
|
|
274
|
+
}) as DynamicStructuredToolType<any, any, any, any, any, string>;
|
|
258
275
|
|
|
259
|
-
const close:
|
|
260
|
-
new
|
|
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
|
|
301
|
+
}) as DynamicStructuredToolType<any, any, any, any, any, string>;
|
|
285
302
|
|
|
286
303
|
return { discover, hire, status, reclaim, close };
|
|
287
304
|
}
|