@lombard.finance/sdk-agent 0.1.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.
- package/LICENSE +21 -0
- package/README.md +183 -0
- package/dist/assets.d.ts +61 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/chains.d.ts +11 -0
- package/dist/chains.d.ts.map +1 -0
- package/dist/index.cjs +78 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +164 -0
- package/dist/langchain.cjs +1 -0
- package/dist/langchain.d.ts +4 -0
- package/dist/langchain.d.ts.map +1 -0
- package/dist/langchain.js +17 -0
- package/dist/morpho.d.ts +106 -0
- package/dist/morpho.d.ts.map +1 -0
- package/dist/prompt.d.ts +2 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/schemas.d.ts +266 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/tools.cjs +39 -0
- package/dist/tools.d.ts +311 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +1641 -0
- package/dist/validation.d.ts +85 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/vercel.cjs +1 -0
- package/dist/vercel.d.ts +12 -0
- package/dist/vercel.d.ts.map +1 -0
- package/dist/vercel.js +17 -0
- package/package.json +84 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared validation helpers for prepare_* tools.
|
|
3
|
+
*
|
|
4
|
+
* The agent must validate inputs against SDK constraints (minimums, address
|
|
5
|
+
* formats, required fields) BEFORE constructing a transaction. Tools return
|
|
6
|
+
* a structured ValidationFailure when checks fail so the LLM can surface
|
|
7
|
+
* the missing or invalid fields to the user and ask, instead of producing
|
|
8
|
+
* an executable card with bad data.
|
|
9
|
+
*/
|
|
10
|
+
import { Env } from "@lombard.finance/sdk";
|
|
11
|
+
/**
|
|
12
|
+
* Verifies that a string looks like a Bitcoin address for the network
|
|
13
|
+
* implied by the EVM chain the user is on. Format check only; does NOT
|
|
14
|
+
* validate the base58/bech32 checksum.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isBitcoinAddress(addr: string, evmChainId: number): boolean;
|
|
17
|
+
/** Verifies a string parses as a positive numeric amount. */
|
|
18
|
+
export declare function isPositiveAmount(amount: unknown): amount is string;
|
|
19
|
+
/**
|
|
20
|
+
* Structured validation failure surfaced to the LLM as a tool result.
|
|
21
|
+
* `missing` lists field names the LLM should re-prompt the user for.
|
|
22
|
+
* `errors` lists field-level problems (invalid format, below minimum, etc).
|
|
23
|
+
* `note` is a single-sentence instruction for the LLM (what to do next).
|
|
24
|
+
*/
|
|
25
|
+
export interface ValidationFailure {
|
|
26
|
+
valid: false;
|
|
27
|
+
missing: string[];
|
|
28
|
+
errors: string[];
|
|
29
|
+
note: string;
|
|
30
|
+
}
|
|
31
|
+
/** Tags a successful validation; spread alongside tool-specific output. */
|
|
32
|
+
export interface ValidationSuccess {
|
|
33
|
+
valid: true;
|
|
34
|
+
}
|
|
35
|
+
export type ValidationResult = ValidationFailure | ValidationSuccess;
|
|
36
|
+
/**
|
|
37
|
+
* Validates the inputs to prepare_unstake. Asks for a Bitcoin recipient
|
|
38
|
+
* when outputAsset is "BTC" and checks the format against the network.
|
|
39
|
+
*/
|
|
40
|
+
export declare function validateUnstakeInputs(params: {
|
|
41
|
+
amount: unknown;
|
|
42
|
+
outputAsset: unknown;
|
|
43
|
+
recipient?: unknown;
|
|
44
|
+
chainId: number;
|
|
45
|
+
}): ValidationResult;
|
|
46
|
+
/** Validates the inputs to prepare_stake (BTC.b → LBTC). */
|
|
47
|
+
export declare function validateStakeInputs(params: {
|
|
48
|
+
amount: unknown;
|
|
49
|
+
}): ValidationResult;
|
|
50
|
+
/**
|
|
51
|
+
* Validates the inputs to prepare_redeem_btcb (BTC.b -> native BTC).
|
|
52
|
+
* BTC.b has its own minimum-redeem floor today (same MIN_REDEEM_AMOUNT_BTC
|
|
53
|
+
* as LBTC); kept here so the agent can advertise it without an extra
|
|
54
|
+
* round trip.
|
|
55
|
+
*/
|
|
56
|
+
export declare function validateRedeemBtcbInputs(params: {
|
|
57
|
+
amount: unknown;
|
|
58
|
+
recipient: unknown;
|
|
59
|
+
chainId: number;
|
|
60
|
+
}): ValidationResult;
|
|
61
|
+
/** Validates the inputs to prepare_deploy_to_vault / prepare_vault_withdrawal. */
|
|
62
|
+
export declare function validateAmountInputs(params: {
|
|
63
|
+
amount: unknown;
|
|
64
|
+
}): ValidationResult;
|
|
65
|
+
/**
|
|
66
|
+
* Resolves the partner ID used for BTC deposit address generation.
|
|
67
|
+
*
|
|
68
|
+
* Testnet and mainnet have separate partner registries on the BFF, so the
|
|
69
|
+
* same partner string is rarely registered on both — `okx` on testnet
|
|
70
|
+
* returns "partner not found", `test1` on prod returns the same.
|
|
71
|
+
*
|
|
72
|
+
* Defaults are non-revenue test partners so accidental traffic from the
|
|
73
|
+
* chatbot example never routes through a real partner (which would incur
|
|
74
|
+
* fee payouts):
|
|
75
|
+
* - testnet: `test1` (overridable via LOMBARD_TESTNET_PARTNER_ID)
|
|
76
|
+
* - mainnet: `lombardtest1` (overridable via LOMBARD_PARTNER_ID)
|
|
77
|
+
*
|
|
78
|
+
* To actually run through a real partner like `okx` or `lombard`, set
|
|
79
|
+
* LOMBARD_PARTNER_ID explicitly.
|
|
80
|
+
*/
|
|
81
|
+
export declare function resolvePartnerId(env: Env, configured?: {
|
|
82
|
+
mainnet?: string;
|
|
83
|
+
testnet?: string;
|
|
84
|
+
}): string;
|
|
85
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,GAAG,EAGJ,MAAM,sBAAsB,CAAC;AAgB9B;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,C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ercel.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("ai"),l=require("./tools.cjs");function e(o){const t=r.tool;return t({name:o.name,description:o.description,parameters:o.schema,execute:o.execute})}const n=Object.fromEntries(l.allTools.map(o=>[o.name,e(o)]));exports.lombardTools=n;exports.toAiTool=e;
|
package/dist/vercel.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ToolDefinition } from "./tools";
|
|
2
|
+
/**
|
|
3
|
+
* Converts a framework-agnostic ToolDefinition into a Vercel AI SDK tool.
|
|
4
|
+
* Uses Zod schemas directly — Vercel AI SDK accepts Zod natively.
|
|
5
|
+
*/
|
|
6
|
+
declare function toAiTool(def: ToolDefinition<any, any>): any;
|
|
7
|
+
/**
|
|
8
|
+
* All Lombard tools formatted for the Vercel AI SDK's `tools` parameter.
|
|
9
|
+
*/
|
|
10
|
+
export declare const lombardTools: Record<string, any>;
|
|
11
|
+
export { toAiTool };
|
|
12
|
+
//# sourceMappingURL=vercel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vercel.d.ts","sourceRoot":"","sources":["../src/vercel.ts"],"names":[],"mappings":"AAaA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAExD;;;GAGG;AAEH,iBAAS,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,GAAG,CAapD;AAED;;GAEG;AAEH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAE5C,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/vercel.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { tool as e } from "ai";
|
|
2
|
+
import { K as t } from "./tools.js";
|
|
3
|
+
function r(o) {
|
|
4
|
+
return e({
|
|
5
|
+
name: o.name,
|
|
6
|
+
description: o.description,
|
|
7
|
+
parameters: o.schema,
|
|
8
|
+
execute: o.execute
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
const n = Object.fromEntries(
|
|
12
|
+
t.map((o) => [o.name, r(o)])
|
|
13
|
+
);
|
|
14
|
+
export {
|
|
15
|
+
n as lombardTools,
|
|
16
|
+
r as toAiTool
|
|
17
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lombard.finance/sdk-agent",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Framework-agnostic AI agent tool definitions for the Lombard protocol",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"import": "./dist/index.js",
|
|
9
|
+
"require": "./dist/index.cjs"
|
|
10
|
+
},
|
|
11
|
+
"./vercel": {
|
|
12
|
+
"types": "./dist/vercel.d.ts",
|
|
13
|
+
"import": "./dist/vercel.js",
|
|
14
|
+
"require": "./dist/vercel.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./langchain": {
|
|
17
|
+
"types": "./dist/langchain.d.ts",
|
|
18
|
+
"import": "./dist/langchain.js",
|
|
19
|
+
"require": "./dist/langchain.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">= 18.0.0"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"types": "tsc --noEmit",
|
|
34
|
+
"build": "yarn types && vite build && tsc -p tsconfig.build.json",
|
|
35
|
+
"lint": "eslint . --ext .js,.jsx,.ts,.tsx --max-warnings=0",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"test:watch": "vitest watch"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/lombard-finance/sdk.git",
|
|
42
|
+
"directory": "packages/sdk-agent"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://docs.lombard.finance",
|
|
45
|
+
"keywords": [
|
|
46
|
+
"lombard",
|
|
47
|
+
"sdk",
|
|
48
|
+
"ai",
|
|
49
|
+
"agent",
|
|
50
|
+
"tools",
|
|
51
|
+
"bitcoin",
|
|
52
|
+
"lbtc"
|
|
53
|
+
],
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"@langchain/core": "^0.3.0",
|
|
59
|
+
"ai": "^4.0.0",
|
|
60
|
+
"viem": "^2.21.0"
|
|
61
|
+
},
|
|
62
|
+
"peerDependenciesMeta": {
|
|
63
|
+
"@langchain/core": {
|
|
64
|
+
"optional": true
|
|
65
|
+
},
|
|
66
|
+
"ai": {
|
|
67
|
+
"optional": true
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"@lombard.finance/sdk": "5.0.4",
|
|
72
|
+
"@lombard.finance/sdk-common": "4.0.0",
|
|
73
|
+
"zod": "^3.25.28",
|
|
74
|
+
"zod-to-json-schema": "^3.25.2"
|
|
75
|
+
},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"@langchain/core": "^0.3.0",
|
|
78
|
+
"ai": "^4.0.0",
|
|
79
|
+
"typescript": "^5.4.5",
|
|
80
|
+
"viem": "^2.21.0",
|
|
81
|
+
"vite": "^6.3.5",
|
|
82
|
+
"vitest": "^3.2.4"
|
|
83
|
+
}
|
|
84
|
+
}
|