torque-actions 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Torque
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # torque-actions
2
+
3
+ Parse Assistant **`functionResults`** and call Torque **`POST /api/v1/execute/**`** routes with a Connect delegated JWT or smart wallet JWT.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ yarn add torque-actions @torquefi/types
9
+ ```
10
+
11
+ ```ts
12
+ import { createTorqueActions, parseFunctionResults } from 'torque-actions'
13
+
14
+ const parsed = parseFunctionResults(chat.functionResults)
15
+ const actions = createTorqueActions({
16
+ accessToken: delegatedJwt,
17
+ baseUrl: 'https://app.torque.fi',
18
+ })
19
+
20
+ for (const item of parsed) {
21
+ if (item.kind === 'swap') {
22
+ await actions.buildEvmSwap(item.payload, 'retry-key-1')
23
+ }
24
+ }
25
+ ```
26
+
27
+ Unsigned responses must be signed by your wallet client (same contract as in-app `AssistantTransactionHandler`).
@@ -0,0 +1,53 @@
1
+ import type { AssistantChatFunctionResult } from '@torquefi/types/assistant';
2
+ import type { TorquePlatformClientConfig } from '@torquefi/types/platform';
3
+ export type TorqueActionsOptions = TorquePlatformClientConfig & {
4
+ /** Delegated Connect JWT or in-app smart wallet JWT. */
5
+ accessToken: string;
6
+ timeout?: number;
7
+ };
8
+ export type ParsedSignableAction = {
9
+ kind: 'swap';
10
+ payload: Record<string, unknown>;
11
+ } | {
12
+ kind: 'transfer';
13
+ payload: Record<string, unknown>;
14
+ } | {
15
+ kind: 'lend';
16
+ payload: Record<string, unknown>;
17
+ } | {
18
+ kind: 'borrow';
19
+ payload: Record<string, unknown>;
20
+ } | {
21
+ kind: 'bridge';
22
+ payload: Record<string, unknown>;
23
+ } | {
24
+ kind: 'advisory';
25
+ toolName: string;
26
+ payload: Record<string, unknown>;
27
+ };
28
+ /** Parse Assistant functionResults into signable vs advisory payloads. */
29
+ export declare function parseFunctionResults(results: AssistantChatFunctionResult[] | undefined): ParsedSignableAction[];
30
+ export declare class TorqueActionsError extends Error {
31
+ code: string;
32
+ statusCode: number;
33
+ constructor(message: string, code: string, statusCode?: number);
34
+ }
35
+ export declare class TorqueActions {
36
+ private readonly config;
37
+ constructor(config: TorqueActionsOptions);
38
+ private post;
39
+ buildEvmSwap(body: Record<string, unknown>, idempotencyKey?: string): Promise<unknown>;
40
+ buildEvmTransfer(body: Record<string, unknown>, idempotencyKey?: string): Promise<unknown>;
41
+ buildEvmLend(body: Record<string, unknown>, idempotencyKey?: string): Promise<unknown>;
42
+ buildEvmBorrow(body: Record<string, unknown>, idempotencyKey?: string): Promise<unknown>;
43
+ /** Refresh delegated Connect JWT via partner BFF (requires business API key on server). */
44
+ refreshDelegatedToken(params: {
45
+ apiKey: string;
46
+ refreshToken: string;
47
+ }): Promise<{
48
+ accessToken: string;
49
+ expiresIn: number;
50
+ scopes: string[];
51
+ }>;
52
+ }
53
+ export declare function createTorqueActions(config: TorqueActionsOptions): TorqueActions;
@@ -0,0 +1,122 @@
1
+ const SIGNABLE_TOOLS = new Set([
2
+ 'swap_tokens',
3
+ 'getEnsoRoute',
4
+ 'executeEnsoRoute',
5
+ 'transfer_tokens',
6
+ 'pay_invoice',
7
+ 'lend_tokens',
8
+ 'borrow_tokens',
9
+ 'redeem_tokens',
10
+ 'repay_tokens',
11
+ 'bridge_tokens',
12
+ 'swap_tokens_solana',
13
+ 'transfer_tokens_solana',
14
+ ]);
15
+ function resolveKind(toolName, result) {
16
+ const action = typeof result.action === 'string' ? result.action : '';
17
+ if (action === 'swap' || toolName.includes('swap') || toolName.includes('enso'))
18
+ return 'swap';
19
+ if (action === 'transfer' || toolName.includes('transfer') || toolName === 'pay_invoice')
20
+ return 'transfer';
21
+ if (action === 'lend' || toolName.includes('lend') || toolName === 'redeem_tokens')
22
+ return 'lend';
23
+ if (action === 'borrow' || toolName.includes('borrow') || toolName === 'repay_tokens')
24
+ return 'borrow';
25
+ if (action === 'bridge' || toolName === 'bridge_tokens')
26
+ return 'bridge';
27
+ return 'advisory';
28
+ }
29
+ /** Parse Assistant functionResults into signable vs advisory payloads. */
30
+ function parseFunctionResults(results) {
31
+ if (!results?.length)
32
+ return [];
33
+ return results.map((fr) => {
34
+ const toolName = fr.toolName ?? '';
35
+ const payload = (fr.result ?? fr);
36
+ const requiresConfirmation = payload.requiresConfirmation === true;
37
+ const signable = SIGNABLE_TOOLS.has(toolName) && payload.success === true && requiresConfirmation;
38
+ if (!signable) {
39
+ return { kind: 'advisory', toolName, payload };
40
+ }
41
+ return { kind: resolveKind(toolName, payload), payload };
42
+ });
43
+ }
44
+ class TorqueActionsError extends Error {
45
+ constructor(message, code, statusCode = 400) {
46
+ super(message);
47
+ this.name = 'TorqueActionsError';
48
+ this.code = code;
49
+ this.statusCode = statusCode;
50
+ }
51
+ }
52
+ class TorqueActions {
53
+ constructor(config) {
54
+ this.config = config;
55
+ if (!config.accessToken?.trim()) {
56
+ throw new TorqueActionsError('accessToken is required', 'INVALID_CONFIG');
57
+ }
58
+ }
59
+ async post(path, body, idempotencyKey) {
60
+ const baseUrl = (this.config.baseUrl || 'https://app.torque.fi').replace(/\/$/, '');
61
+ const headers = {
62
+ Accept: 'application/json',
63
+ 'Content-Type': 'application/json',
64
+ Authorization: `Bearer ${this.config.accessToken}`,
65
+ };
66
+ if (idempotencyKey?.trim())
67
+ headers['Idempotency-Key'] = idempotencyKey.trim();
68
+ const res = await fetch(`${baseUrl}${path}`, {
69
+ method: 'POST',
70
+ headers,
71
+ body: JSON.stringify(body),
72
+ });
73
+ const data = await res.json().catch(() => ({}));
74
+ if (!res.ok) {
75
+ throw new TorqueActionsError(data?.error?.message ?? `HTTP ${res.status}`, data?.error?.code ?? 'EXECUTE_ERROR', res.status);
76
+ }
77
+ return data;
78
+ }
79
+ buildEvmSwap(body, idempotencyKey) {
80
+ return this.post('/api/v1/execute/trades', body, idempotencyKey);
81
+ }
82
+ buildEvmTransfer(body, idempotencyKey) {
83
+ return this.post('/api/v1/execute/transfers/evm', body, idempotencyKey);
84
+ }
85
+ buildEvmLend(body, idempotencyKey) {
86
+ return this.post('/api/v1/execute/lends/evm', body, idempotencyKey);
87
+ }
88
+ buildEvmBorrow(body, idempotencyKey) {
89
+ return this.post('/api/v1/execute/borrows/evm', body, idempotencyKey);
90
+ }
91
+ /** Refresh delegated Connect JWT via partner BFF (requires business API key on server). */
92
+ async refreshDelegatedToken(params) {
93
+ const baseUrl = (this.config.baseUrl || 'https://app.torque.fi').replace(/\/$/, '');
94
+ const res = await fetch(`${baseUrl}/api/v1/connect/token`, {
95
+ method: 'POST',
96
+ headers: {
97
+ Accept: 'application/json',
98
+ 'Content-Type': 'application/json',
99
+ Authorization: `Bearer ${params.apiKey}`,
100
+ },
101
+ body: JSON.stringify({
102
+ grant_type: 'refresh_token',
103
+ refresh_token: params.refreshToken,
104
+ }),
105
+ });
106
+ const data = (await res.json().catch(() => ({})));
107
+ if (!res.ok || !data.accessToken) {
108
+ throw new TorqueActionsError(data.error?.message ?? `HTTP ${res.status}`, data.error?.code ?? 'REFRESH_ERROR', res.status);
109
+ }
110
+ return {
111
+ accessToken: data.accessToken,
112
+ expiresIn: data.expiresIn ?? 3600,
113
+ scopes: data.scopes ?? [],
114
+ };
115
+ }
116
+ }
117
+ function createTorqueActions(config) {
118
+ return new TorqueActions(config);
119
+ }
120
+
121
+ export { TorqueActions, TorqueActionsError, createTorqueActions, parseFunctionResults };
122
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../src/index.ts"],"sourcesContent":["import type { AssistantChatFunctionResult } from '@torquefi/types/assistant'\nimport type { TorquePlatformClientConfig } from '@torquefi/types/platform'\n\nexport type TorqueActionsOptions = TorquePlatformClientConfig & {\n /** Delegated Connect JWT or in-app smart wallet JWT. */\n accessToken: string\n timeout?: number\n}\n\nexport type ParsedSignableAction =\n | { kind: 'swap'; payload: Record<string, unknown> }\n | { kind: 'transfer'; payload: Record<string, unknown> }\n | { kind: 'lend'; payload: Record<string, unknown> }\n | { kind: 'borrow'; payload: Record<string, unknown> }\n | { kind: 'bridge'; payload: Record<string, unknown> }\n | { kind: 'advisory'; toolName: string; payload: Record<string, unknown> }\n\nconst SIGNABLE_TOOLS = new Set([\n 'swap_tokens',\n 'getEnsoRoute',\n 'executeEnsoRoute',\n 'transfer_tokens',\n 'pay_invoice',\n 'lend_tokens',\n 'borrow_tokens',\n 'redeem_tokens',\n 'repay_tokens',\n 'bridge_tokens',\n 'swap_tokens_solana',\n 'transfer_tokens_solana',\n])\n\nfunction resolveKind(toolName: string, result: Record<string, unknown>): ParsedSignableAction['kind'] {\n const action = typeof result.action === 'string' ? result.action : ''\n if (action === 'swap' || toolName.includes('swap') || toolName.includes('enso')) return 'swap'\n if (action === 'transfer' || toolName.includes('transfer') || toolName === 'pay_invoice') return 'transfer'\n if (action === 'lend' || toolName.includes('lend') || toolName === 'redeem_tokens') return 'lend'\n if (action === 'borrow' || toolName.includes('borrow') || toolName === 'repay_tokens') return 'borrow'\n if (action === 'bridge' || toolName === 'bridge_tokens') return 'bridge'\n return 'advisory'\n}\n\n/** Parse Assistant functionResults into signable vs advisory payloads. */\nexport function parseFunctionResults(\n results: AssistantChatFunctionResult[] | undefined,\n): ParsedSignableAction[] {\n if (!results?.length) return []\n\n return results.map((fr) => {\n const toolName = fr.toolName ?? ''\n const payload = (fr.result ?? fr) as Record<string, unknown>\n const requiresConfirmation = payload.requiresConfirmation === true\n const signable = SIGNABLE_TOOLS.has(toolName) && payload.success === true && requiresConfirmation\n\n if (!signable) {\n return { kind: 'advisory', toolName, payload }\n }\n\n return { kind: resolveKind(toolName, payload), payload }\n })\n}\n\nexport class TorqueActionsError extends Error {\n code: string\n statusCode: number\n\n constructor(message: string, code: string, statusCode = 400) {\n super(message)\n this.name = 'TorqueActionsError'\n this.code = code\n this.statusCode = statusCode\n }\n}\n\nexport class TorqueActions {\n constructor(private readonly config: TorqueActionsOptions) {\n if (!config.accessToken?.trim()) {\n throw new TorqueActionsError('accessToken is required', 'INVALID_CONFIG')\n }\n }\n\n private async post(path: string, body: unknown, idempotencyKey?: string): Promise<unknown> {\n const baseUrl = (this.config.baseUrl || 'https://app.torque.fi').replace(/\\/$/, '')\n const headers: Record<string, string> = {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.config.accessToken}`,\n }\n if (idempotencyKey?.trim()) headers['Idempotency-Key'] = idempotencyKey.trim()\n\n const res = await fetch(`${baseUrl}${path}`, {\n method: 'POST',\n headers,\n body: JSON.stringify(body),\n })\n const data = await res.json().catch(() => ({}))\n if (!res.ok) {\n throw new TorqueActionsError(\n (data as { error?: { message?: string } })?.error?.message ?? `HTTP ${res.status}`,\n (data as { error?: { code?: string } })?.error?.code ?? 'EXECUTE_ERROR',\n res.status,\n )\n }\n return data\n }\n\n buildEvmSwap(body: Record<string, unknown>, idempotencyKey?: string) {\n return this.post('/api/v1/execute/trades', body, idempotencyKey)\n }\n\n buildEvmTransfer(body: Record<string, unknown>, idempotencyKey?: string) {\n return this.post('/api/v1/execute/transfers/evm', body, idempotencyKey)\n }\n\n buildEvmLend(body: Record<string, unknown>, idempotencyKey?: string) {\n return this.post('/api/v1/execute/lends/evm', body, idempotencyKey)\n }\n\n buildEvmBorrow(body: Record<string, unknown>, idempotencyKey?: string) {\n return this.post('/api/v1/execute/borrows/evm', body, idempotencyKey)\n }\n\n /** Refresh delegated Connect JWT via partner BFF (requires business API key on server). */\n async refreshDelegatedToken(params: {\n apiKey: string\n refreshToken: string\n }): Promise<{ accessToken: string; expiresIn: number; scopes: string[] }> {\n const baseUrl = (this.config.baseUrl || 'https://app.torque.fi').replace(/\\/$/, '')\n const res = await fetch(`${baseUrl}/api/v1/connect/token`, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${params.apiKey}`,\n },\n body: JSON.stringify({\n grant_type: 'refresh_token',\n refresh_token: params.refreshToken,\n }),\n })\n const data = (await res.json().catch(() => ({}))) as {\n accessToken?: string\n expiresIn?: number\n scopes?: string[]\n error?: { message?: string; code?: string }\n }\n if (!res.ok || !data.accessToken) {\n throw new TorqueActionsError(\n data.error?.message ?? `HTTP ${res.status}`,\n data.error?.code ?? 'REFRESH_ERROR',\n res.status,\n )\n }\n return {\n accessToken: data.accessToken,\n expiresIn: data.expiresIn ?? 3600,\n scopes: data.scopes ?? [],\n }\n }\n}\n\nexport function createTorqueActions(config: TorqueActionsOptions): TorqueActions {\n return new TorqueActions(config)\n}\n"],"names":[],"mappings":"AAiBA,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,aAAa;IACb,cAAc;IACd,kBAAkB;IAClB,iBAAiB;IACjB,aAAa;IACb,aAAa;IACb,eAAe;IACf,eAAe;IACf,c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@@ -0,0 +1,127 @@
1
+ 'use strict';
2
+
3
+ const SIGNABLE_TOOLS = new Set([
4
+ 'swap_tokens',
5
+ 'getEnsoRoute',
6
+ 'executeEnsoRoute',
7
+ 'transfer_tokens',
8
+ 'pay_invoice',
9
+ 'lend_tokens',
10
+ 'borrow_tokens',
11
+ 'redeem_tokens',
12
+ 'repay_tokens',
13
+ 'bridge_tokens',
14
+ 'swap_tokens_solana',
15
+ 'transfer_tokens_solana',
16
+ ]);
17
+ function resolveKind(toolName, result) {
18
+ const action = typeof result.action === 'string' ? result.action : '';
19
+ if (action === 'swap' || toolName.includes('swap') || toolName.includes('enso'))
20
+ return 'swap';
21
+ if (action === 'transfer' || toolName.includes('transfer') || toolName === 'pay_invoice')
22
+ return 'transfer';
23
+ if (action === 'lend' || toolName.includes('lend') || toolName === 'redeem_tokens')
24
+ return 'lend';
25
+ if (action === 'borrow' || toolName.includes('borrow') || toolName === 'repay_tokens')
26
+ return 'borrow';
27
+ if (action === 'bridge' || toolName === 'bridge_tokens')
28
+ return 'bridge';
29
+ return 'advisory';
30
+ }
31
+ /** Parse Assistant functionResults into signable vs advisory payloads. */
32
+ function parseFunctionResults(results) {
33
+ if (!results?.length)
34
+ return [];
35
+ return results.map((fr) => {
36
+ const toolName = fr.toolName ?? '';
37
+ const payload = (fr.result ?? fr);
38
+ const requiresConfirmation = payload.requiresConfirmation === true;
39
+ const signable = SIGNABLE_TOOLS.has(toolName) && payload.success === true && requiresConfirmation;
40
+ if (!signable) {
41
+ return { kind: 'advisory', toolName, payload };
42
+ }
43
+ return { kind: resolveKind(toolName, payload), payload };
44
+ });
45
+ }
46
+ class TorqueActionsError extends Error {
47
+ constructor(message, code, statusCode = 400) {
48
+ super(message);
49
+ this.name = 'TorqueActionsError';
50
+ this.code = code;
51
+ this.statusCode = statusCode;
52
+ }
53
+ }
54
+ class TorqueActions {
55
+ constructor(config) {
56
+ this.config = config;
57
+ if (!config.accessToken?.trim()) {
58
+ throw new TorqueActionsError('accessToken is required', 'INVALID_CONFIG');
59
+ }
60
+ }
61
+ async post(path, body, idempotencyKey) {
62
+ const baseUrl = (this.config.baseUrl || 'https://app.torque.fi').replace(/\/$/, '');
63
+ const headers = {
64
+ Accept: 'application/json',
65
+ 'Content-Type': 'application/json',
66
+ Authorization: `Bearer ${this.config.accessToken}`,
67
+ };
68
+ if (idempotencyKey?.trim())
69
+ headers['Idempotency-Key'] = idempotencyKey.trim();
70
+ const res = await fetch(`${baseUrl}${path}`, {
71
+ method: 'POST',
72
+ headers,
73
+ body: JSON.stringify(body),
74
+ });
75
+ const data = await res.json().catch(() => ({}));
76
+ if (!res.ok) {
77
+ throw new TorqueActionsError(data?.error?.message ?? `HTTP ${res.status}`, data?.error?.code ?? 'EXECUTE_ERROR', res.status);
78
+ }
79
+ return data;
80
+ }
81
+ buildEvmSwap(body, idempotencyKey) {
82
+ return this.post('/api/v1/execute/trades', body, idempotencyKey);
83
+ }
84
+ buildEvmTransfer(body, idempotencyKey) {
85
+ return this.post('/api/v1/execute/transfers/evm', body, idempotencyKey);
86
+ }
87
+ buildEvmLend(body, idempotencyKey) {
88
+ return this.post('/api/v1/execute/lends/evm', body, idempotencyKey);
89
+ }
90
+ buildEvmBorrow(body, idempotencyKey) {
91
+ return this.post('/api/v1/execute/borrows/evm', body, idempotencyKey);
92
+ }
93
+ /** Refresh delegated Connect JWT via partner BFF (requires business API key on server). */
94
+ async refreshDelegatedToken(params) {
95
+ const baseUrl = (this.config.baseUrl || 'https://app.torque.fi').replace(/\/$/, '');
96
+ const res = await fetch(`${baseUrl}/api/v1/connect/token`, {
97
+ method: 'POST',
98
+ headers: {
99
+ Accept: 'application/json',
100
+ 'Content-Type': 'application/json',
101
+ Authorization: `Bearer ${params.apiKey}`,
102
+ },
103
+ body: JSON.stringify({
104
+ grant_type: 'refresh_token',
105
+ refresh_token: params.refreshToken,
106
+ }),
107
+ });
108
+ const data = (await res.json().catch(() => ({})));
109
+ if (!res.ok || !data.accessToken) {
110
+ throw new TorqueActionsError(data.error?.message ?? `HTTP ${res.status}`, data.error?.code ?? 'REFRESH_ERROR', res.status);
111
+ }
112
+ return {
113
+ accessToken: data.accessToken,
114
+ expiresIn: data.expiresIn ?? 3600,
115
+ scopes: data.scopes ?? [],
116
+ };
117
+ }
118
+ }
119
+ function createTorqueActions(config) {
120
+ return new TorqueActions(config);
121
+ }
122
+
123
+ exports.TorqueActions = TorqueActions;
124
+ exports.TorqueActionsError = TorqueActionsError;
125
+ exports.createTorqueActions = createTorqueActions;
126
+ exports.parseFunctionResults = parseFunctionResults;
127
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { AssistantChatFunctionResult } from '@torquefi/types/assistant'\nimport type { TorquePlatformClientConfig } from '@torquefi/types/platform'\n\nexport type TorqueActionsOptions = TorquePlatformClientConfig & {\n /** Delegated Connect JWT or in-app smart wallet JWT. */\n accessToken: string\n timeout?: number\n}\n\nexport type ParsedSignableAction =\n | { kind: 'swap'; payload: Record<string, unknown> }\n | { kind: 'transfer'; payload: Record<string, unknown> }\n | { kind: 'lend'; payload: Record<string, unknown> }\n | { kind: 'borrow'; payload: Record<string, unknown> }\n | { kind: 'bridge'; payload: Record<string, unknown> }\n | { kind: 'advisory'; toolName: string; payload: Record<string, unknown> }\n\nconst SIGNABLE_TOOLS = new Set([\n 'swap_tokens',\n 'getEnsoRoute',\n 'executeEnsoRoute',\n 'transfer_tokens',\n 'pay_invoice',\n 'lend_tokens',\n 'borrow_tokens',\n 'redeem_tokens',\n 'repay_tokens',\n 'bridge_tokens',\n 'swap_tokens_solana',\n 'transfer_tokens_solana',\n])\n\nfunction resolveKind(toolName: string, result: Record<string, unknown>): ParsedSignableAction['kind'] {\n const action = typeof result.action === 'string' ? result.action : ''\n if (action === 'swap' || toolName.includes('swap') || toolName.includes('enso')) return 'swap'\n if (action === 'transfer' || toolName.includes('transfer') || toolName === 'pay_invoice') return 'transfer'\n if (action === 'lend' || toolName.includes('lend') || toolName === 'redeem_tokens') return 'lend'\n if (action === 'borrow' || toolName.includes('borrow') || toolName === 'repay_tokens') return 'borrow'\n if (action === 'bridge' || toolName === 'bridge_tokens') return 'bridge'\n return 'advisory'\n}\n\n/** Parse Assistant functionResults into signable vs advisory payloads. */\nexport function parseFunctionResults(\n results: AssistantChatFunctionResult[] | undefined,\n): ParsedSignableAction[] {\n if (!results?.length) return []\n\n return results.map((fr) => {\n const toolName = fr.toolName ?? ''\n const payload = (fr.result ?? fr) as Record<string, unknown>\n const requiresConfirmation = payload.requiresConfirmation === true\n const signable = SIGNABLE_TOOLS.has(toolName) && payload.success === true && requiresConfirmation\n\n if (!signable) {\n return { kind: 'advisory', toolName, payload }\n }\n\n return { kind: resolveKind(toolName, payload), payload }\n })\n}\n\nexport class TorqueActionsError extends Error {\n code: string\n statusCode: number\n\n constructor(message: string, code: string, statusCode = 400) {\n super(message)\n this.name = 'TorqueActionsError'\n this.code = code\n this.statusCode = statusCode\n }\n}\n\nexport class TorqueActions {\n constructor(private readonly config: TorqueActionsOptions) {\n if (!config.accessToken?.trim()) {\n throw new TorqueActionsError('accessToken is required', 'INVALID_CONFIG')\n }\n }\n\n private async post(path: string, body: unknown, idempotencyKey?: string): Promise<unknown> {\n const baseUrl = (this.config.baseUrl || 'https://app.torque.fi').replace(/\\/$/, '')\n const headers: Record<string, string> = {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.config.accessToken}`,\n }\n if (idempotencyKey?.trim()) headers['Idempotency-Key'] = idempotencyKey.trim()\n\n const res = await fetch(`${baseUrl}${path}`, {\n method: 'POST',\n headers,\n body: JSON.stringify(body),\n })\n const data = await res.json().catch(() => ({}))\n if (!res.ok) {\n throw new TorqueActionsError(\n (data as { error?: { message?: string } })?.error?.message ?? `HTTP ${res.status}`,\n (data as { error?: { code?: string } })?.error?.code ?? 'EXECUTE_ERROR',\n res.status,\n )\n }\n return data\n }\n\n buildEvmSwap(body: Record<string, unknown>, idempotencyKey?: string) {\n return this.post('/api/v1/execute/trades', body, idempotencyKey)\n }\n\n buildEvmTransfer(body: Record<string, unknown>, idempotencyKey?: string) {\n return this.post('/api/v1/execute/transfers/evm', body, idempotencyKey)\n }\n\n buildEvmLend(body: Record<string, unknown>, idempotencyKey?: string) {\n return this.post('/api/v1/execute/lends/evm', body, idempotencyKey)\n }\n\n buildEvmBorrow(body: Record<string, unknown>, idempotencyKey?: string) {\n return this.post('/api/v1/execute/borrows/evm', body, idempotencyKey)\n }\n\n /** Refresh delegated Connect JWT via partner BFF (requires business API key on server). */\n async refreshDelegatedToken(params: {\n apiKey: string\n refreshToken: string\n }): Promise<{ accessToken: string; expiresIn: number; scopes: string[] }> {\n const baseUrl = (this.config.baseUrl || 'https://app.torque.fi').replace(/\\/$/, '')\n const res = await fetch(`${baseUrl}/api/v1/connect/token`, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${params.apiKey}`,\n },\n body: JSON.stringify({\n grant_type: 'refresh_token',\n refresh_token: params.refreshToken,\n }),\n })\n const data = (await res.json().catch(() => ({}))) as {\n accessToken?: string\n expiresIn?: number\n scopes?: string[]\n error?: { message?: string; code?: string }\n }\n if (!res.ok || !data.accessToken) {\n throw new TorqueActionsError(\n data.error?.message ?? `HTTP ${res.status}`,\n data.error?.code ?? 'REFRESH_ERROR',\n res.status,\n )\n }\n return {\n accessToken: data.accessToken,\n expiresIn: data.expiresIn ?? 3600,\n scopes: data.scopes ?? [],\n }\n }\n}\n\nexport function createTorqueActions(config: TorqueActionsOptions): TorqueActions {\n return new TorqueActions(config)\n}\n"],"names":[],"mappings":";;AAiBA,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,aAAa;IACb,cAAc;IACd,kBAAkB;IAClB,iBAAiB;IACjB,aAAa;IACb,aAAa;IACb,eAAe;IACf,eAAe;IACf,cAAc;IACd,eAAe;IACf,oBAAoB;IACpB,wBAAwB;A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3
+ "version": "0.1.0",
4
+ "description": "Torque Platform execute helpers — parse Assistant functionResults and call v1 execute routes",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "main": "dist/index.js",
9
+ "module": "dist/index.esm.js",
10
+ "types": "dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.esm.js",
14
+ "require": "./dist/index.js",
15
+ "types": "./dist/index.d.ts"
16
+ },
17
+ "./package.json": "./package.json"
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "README.md",
22
+ "LICENSE"
23
+ ],
24
+ "scripts": {
25
+ "build": "rollup -c",
26
+ "clean": "rimraf dist",
27
+ "prepublishOnly": "yarn clean && yarn build"
28
+ },
29
+ "keywords": [
30
+ "torque",
31
+ "actions",
32
+ "execute",
33
+ "integrator",
34
+ "sdk"
35
+ ],
36
+ "author": "Torque <hello@torque.fi>",
37
+ "license": "MIT",
38
+ "dependencies": {
39
+ "@torquefi/types": "file:../torque-types"
40
+ },
41
+ "devDependencies": {
42
+ "@rollup/plugin-typescript": "^12.1.4",
43
+ "@types/node": "^20.0.0",
44
+ "rimraf": "^5.0.0",
45
+ "rollup": "^4.0.0",
46
+ "typescript": "^5.0.0"
47
+ },
48
+ "engines": {
49
+ "node": ">=16.0.0"
50
+ }
51
+ }