@heyanon/sdk 2.2.4 → 2.3.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/dist/adapter/transformers/toResult.d.ts +1 -1
- package/dist/adapter/types.d.ts +5 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.js +31 -30
- package/dist/index.mjs +31 -30
- package/package.json +2 -1
- package/dist/ai/index.d.ts +0 -1
- package/dist/ai/types.d.ts +0 -12
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { FunctionReturn } from '../types';
|
|
2
|
-
export declare function toResult(data
|
|
2
|
+
export declare function toResult(data: string | Object | Array<any>, error?: boolean): FunctionReturn;
|
package/dist/adapter/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OpenAI } from 'openai';
|
|
2
2
|
import { EVM, Solana, TON, WalletType, Chain } from '../blockchain';
|
|
3
3
|
import { Hex, PublicClient, SignMessageReturnType, SignTypedDataParameters as ViemSignTypedDataParameters, SignTypedDataReturnType, Address } from 'viem';
|
|
4
4
|
import { Connection, PublicKey, Transaction as SolanaTransaction, VersionedTransaction as SolanaVersionedTransaction } from '@solana/web3.js';
|
|
@@ -54,10 +54,11 @@ export interface FunctionOptions {
|
|
|
54
54
|
}>;
|
|
55
55
|
}
|
|
56
56
|
export interface AdapterExport {
|
|
57
|
-
readonly tools: AiTool[];
|
|
58
|
-
readonly functions: Record<string, (args: any, options: FunctionOptions) => Promise<FunctionReturn>>;
|
|
59
|
-
readonly description: string;
|
|
60
57
|
readonly chains: Chain[];
|
|
61
58
|
readonly tags: AdapterTag[];
|
|
59
|
+
readonly description: string;
|
|
60
|
+
readonly functions: Record<string, (args: any, options: FunctionOptions) => Promise<FunctionReturn>>;
|
|
61
|
+
readonly executableFunctions: string[];
|
|
62
|
+
readonly tools: OpenAI.Chat.Completions.ChatCompletionTool[];
|
|
62
63
|
}
|
|
63
64
|
export {};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -10,11 +10,40 @@ var __export = (target, all) => {
|
|
|
10
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
// src/utils/retry.ts
|
|
14
|
+
function delay(ms) {
|
|
15
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
16
|
+
}
|
|
17
|
+
async function retry(fn, options) {
|
|
18
|
+
const { retries = 0, delayMs } = options ?? {};
|
|
19
|
+
try {
|
|
20
|
+
return await fn();
|
|
21
|
+
} catch (error) {
|
|
22
|
+
if (retries > 0) {
|
|
23
|
+
if (delayMs) {
|
|
24
|
+
await delay(delayMs);
|
|
25
|
+
}
|
|
26
|
+
return await retry(fn, { ...options, retries: retries - 1 });
|
|
27
|
+
} else {
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/utils/sleep.ts
|
|
34
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
35
|
+
|
|
36
|
+
// src/utils/stringify.ts
|
|
37
|
+
function stringify(value, space) {
|
|
38
|
+
return JSON.stringify(value, (_key, value2) => typeof value2 === "bigint" ? value2.toString() : value2, space);
|
|
39
|
+
}
|
|
40
|
+
|
|
13
41
|
// src/adapter/transformers/toResult.ts
|
|
14
|
-
function toResult(data
|
|
42
|
+
function toResult(data, error = false) {
|
|
43
|
+
const formatedData = typeof data === "string" ? data : stringify(data);
|
|
15
44
|
return {
|
|
16
45
|
success: !error,
|
|
17
|
-
data: error ? `ERROR: ${
|
|
46
|
+
data: error ? `ERROR: ${formatedData}` : formatedData
|
|
18
47
|
};
|
|
19
48
|
}
|
|
20
49
|
|
|
@@ -537,34 +566,6 @@ __export(ton_exports, {
|
|
|
537
566
|
// src/blockchain/ton/types.ts
|
|
538
567
|
var types_exports3 = {};
|
|
539
568
|
|
|
540
|
-
// src/utils/retry.ts
|
|
541
|
-
function delay(ms) {
|
|
542
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
543
|
-
}
|
|
544
|
-
async function retry(fn, options) {
|
|
545
|
-
const { retries = 0, delayMs } = options ?? {};
|
|
546
|
-
try {
|
|
547
|
-
return await fn();
|
|
548
|
-
} catch (error) {
|
|
549
|
-
if (retries > 0) {
|
|
550
|
-
if (delayMs) {
|
|
551
|
-
await delay(delayMs);
|
|
552
|
-
}
|
|
553
|
-
return await retry(fn, { ...options, retries: retries - 1 });
|
|
554
|
-
} else {
|
|
555
|
-
throw error;
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
// src/utils/sleep.ts
|
|
561
|
-
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
562
|
-
|
|
563
|
-
// src/utils/stringify.ts
|
|
564
|
-
function stringify(value, space) {
|
|
565
|
-
return JSON.stringify(value, (_key, value2) => typeof value2 === "bigint" ? value2.toString() : value2, space);
|
|
566
|
-
}
|
|
567
|
-
|
|
568
569
|
exports.AdapterTag = AdapterTag;
|
|
569
570
|
exports.Chain = Chain;
|
|
570
571
|
exports.EVM = evm_exports;
|
package/dist/index.mjs
CHANGED
|
@@ -8,11 +8,40 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
+
// src/utils/retry.ts
|
|
12
|
+
function delay(ms) {
|
|
13
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
14
|
+
}
|
|
15
|
+
async function retry(fn, options) {
|
|
16
|
+
const { retries = 0, delayMs } = options ?? {};
|
|
17
|
+
try {
|
|
18
|
+
return await fn();
|
|
19
|
+
} catch (error) {
|
|
20
|
+
if (retries > 0) {
|
|
21
|
+
if (delayMs) {
|
|
22
|
+
await delay(delayMs);
|
|
23
|
+
}
|
|
24
|
+
return await retry(fn, { ...options, retries: retries - 1 });
|
|
25
|
+
} else {
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/utils/sleep.ts
|
|
32
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
33
|
+
|
|
34
|
+
// src/utils/stringify.ts
|
|
35
|
+
function stringify(value, space) {
|
|
36
|
+
return JSON.stringify(value, (_key, value2) => typeof value2 === "bigint" ? value2.toString() : value2, space);
|
|
37
|
+
}
|
|
38
|
+
|
|
11
39
|
// src/adapter/transformers/toResult.ts
|
|
12
|
-
function toResult(data
|
|
40
|
+
function toResult(data, error = false) {
|
|
41
|
+
const formatedData = typeof data === "string" ? data : stringify(data);
|
|
13
42
|
return {
|
|
14
43
|
success: !error,
|
|
15
|
-
data: error ? `ERROR: ${
|
|
44
|
+
data: error ? `ERROR: ${formatedData}` : formatedData
|
|
16
45
|
};
|
|
17
46
|
}
|
|
18
47
|
|
|
@@ -535,32 +564,4 @@ __export(ton_exports, {
|
|
|
535
564
|
// src/blockchain/ton/types.ts
|
|
536
565
|
var types_exports3 = {};
|
|
537
566
|
|
|
538
|
-
// src/utils/retry.ts
|
|
539
|
-
function delay(ms) {
|
|
540
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
541
|
-
}
|
|
542
|
-
async function retry(fn, options) {
|
|
543
|
-
const { retries = 0, delayMs } = options ?? {};
|
|
544
|
-
try {
|
|
545
|
-
return await fn();
|
|
546
|
-
} catch (error) {
|
|
547
|
-
if (retries > 0) {
|
|
548
|
-
if (delayMs) {
|
|
549
|
-
await delay(delayMs);
|
|
550
|
-
}
|
|
551
|
-
return await retry(fn, { ...options, retries: retries - 1 });
|
|
552
|
-
} else {
|
|
553
|
-
throw error;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
// src/utils/sleep.ts
|
|
559
|
-
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
560
|
-
|
|
561
|
-
// src/utils/stringify.ts
|
|
562
|
-
function stringify(value, space) {
|
|
563
|
-
return JSON.stringify(value, (_key, value2) => typeof value2 === "bigint" ? value2.toString() : value2, space);
|
|
564
|
-
}
|
|
565
|
-
|
|
566
567
|
export { AdapterTag, Chain, evm_exports as EVM, solana_exports as Solana, ton_exports as TON, WalletType, allChains, allEvmChains, retry, sleep, stringify, toResult };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heyanon/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"@ton/core": "0.60.0",
|
|
49
49
|
"@ton/ton": "15.2.0",
|
|
50
50
|
"ccxt": "4.4.78",
|
|
51
|
+
"openai": "5.12.1",
|
|
51
52
|
"viem": "2.22.9",
|
|
52
53
|
"vitest": "^2.1.8"
|
|
53
54
|
}
|
package/dist/ai/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './types';
|
package/dist/ai/types.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface AiToolProps {
|
|
2
|
-
readonly name: string;
|
|
3
|
-
readonly [key: string]: unknown;
|
|
4
|
-
}
|
|
5
|
-
export interface AiTool {
|
|
6
|
-
readonly name: string;
|
|
7
|
-
readonly description: string;
|
|
8
|
-
readonly required: string[];
|
|
9
|
-
readonly props: AiToolProps[];
|
|
10
|
-
readonly strict?: boolean;
|
|
11
|
-
readonly additionalProperties?: boolean;
|
|
12
|
-
}
|