agentlaunch-sdk 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/CHANGELOG.md +66 -0
- package/README.md +319 -0
- package/dist/agentlaunch.d.ts +138 -0
- package/dist/agentlaunch.d.ts.map +1 -0
- package/dist/agentlaunch.js +85 -0
- package/dist/agentlaunch.js.map +1 -0
- package/dist/agents.d.ts +67 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +106 -0
- package/dist/agents.js.map +1 -0
- package/dist/client.d.ts +67 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +174 -0
- package/dist/client.js.map +1 -0
- package/dist/handoff.d.ts +84 -0
- package/dist/handoff.d.ts.map +1 -0
- package/dist/handoff.js +119 -0
- package/dist/handoff.js.map +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/market.d.ts +81 -0
- package/dist/market.d.ts.map +1 -0
- package/dist/market.js +125 -0
- package/dist/market.js.map +1 -0
- package/dist/tokens.d.ts +66 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +86 -0
- package/dist/tokens.js.map +1 -0
- package/dist/types.d.ts +174 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +20 -0
- package/dist/types.js.map +1 -0
- package/package.json +57 -0
package/dist/agents.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agent-launch/sdk — Agent operations
|
|
3
|
+
*
|
|
4
|
+
* SDK-005: Authentication and Agentverse agent management.
|
|
5
|
+
*
|
|
6
|
+
* These endpoints let an agent:
|
|
7
|
+
* - Exchange an Agentverse API key for a platform JWT (POST /agents/auth)
|
|
8
|
+
* - List its own Agentverse agents (GET /agents/my-agents)
|
|
9
|
+
* - Import agent metadata by API key (POST /agents/import-agentverse)
|
|
10
|
+
*/
|
|
11
|
+
import { AgentLaunchClient } from './client.js';
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Module-level default client (lazy, env-based)
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
function defaultClient(apiKey) {
|
|
16
|
+
return new AgentLaunchClient({
|
|
17
|
+
apiKey: apiKey ?? process.env['AGENTVERSE_API_KEY'] ?? process.env['AGENT_LAUNCH_API_KEY'],
|
|
18
|
+
baseUrl: process.env['AGENT_LAUNCH_BASE_URL'],
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// authenticate
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
/**
|
|
25
|
+
* Exchange an Agentverse API key for a platform JWT.
|
|
26
|
+
*
|
|
27
|
+
* The JWT can be used as a `Bearer` token on any endpoint that requires
|
|
28
|
+
* platform authentication (same access level as an X-API-Key header).
|
|
29
|
+
*
|
|
30
|
+
* Rate limit: 10 requests per 60 seconds.
|
|
31
|
+
*
|
|
32
|
+
* @param apiKey Agentverse API key (av-…)
|
|
33
|
+
* @param client Optional pre-configured client instance
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const { data } = await authenticate('av-xxxxxxxxxxxxxxxx');
|
|
38
|
+
* // data.token — JWT string
|
|
39
|
+
* // data.expires_in — seconds until expiry
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export async function authenticate(apiKey, client) {
|
|
43
|
+
// authenticate uses a body field, not a header — use a temporary client
|
|
44
|
+
// that does NOT need an API key header (the key goes in the body).
|
|
45
|
+
const c = client ?? new AgentLaunchClient({
|
|
46
|
+
baseUrl: process.env['AGENT_LAUNCH_BASE_URL'],
|
|
47
|
+
// No apiKey — the key is passed in the request body for this endpoint
|
|
48
|
+
});
|
|
49
|
+
// The auth endpoint accepts the key in the body and does not require
|
|
50
|
+
// an X-API-Key header, so we call post directly with no guard.
|
|
51
|
+
// We build a one-off request to avoid the "apiKey required" guard.
|
|
52
|
+
return c.post('/api/agents/auth', { api_key: apiKey });
|
|
53
|
+
}
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
// getMyAgents
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
/**
|
|
58
|
+
* List the Agentverse agents owned by the caller's API key.
|
|
59
|
+
*
|
|
60
|
+
* Requires X-API-Key authentication.
|
|
61
|
+
*
|
|
62
|
+
* Rate limit: 30 requests per 60 seconds.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const { data } = await getMyAgents();
|
|
67
|
+
* console.log(data.agents.map(a => a.address));
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export async function getMyAgents(client) {
|
|
71
|
+
const c = client ?? defaultClient();
|
|
72
|
+
return c.get('/api/agents/my-agents');
|
|
73
|
+
}
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
// importFromAgentverse
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
/**
|
|
78
|
+
* Fetch all agents belonging to the supplied Agentverse API key.
|
|
79
|
+
*
|
|
80
|
+
* No platform authentication is required — the caller provides their own
|
|
81
|
+
* Agentverse key in the request body. Results are cached on the server
|
|
82
|
+
* for 5 minutes.
|
|
83
|
+
*
|
|
84
|
+
* Useful for building integrations that need to enumerate an account's
|
|
85
|
+
* agents without a pre-existing platform session.
|
|
86
|
+
*
|
|
87
|
+
* Rate limit: 5 requests per 60 seconds.
|
|
88
|
+
*
|
|
89
|
+
* @param agentverseApiKey Agentverse API key to import agents from
|
|
90
|
+
* @param client Optional pre-configured client instance
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* const { agents, count } = await importFromAgentverse('av-xxxxxxxxxxxxxxxx');
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export async function importFromAgentverse(agentverseApiKey, client) {
|
|
98
|
+
// This endpoint does not require platform auth — use a client without key
|
|
99
|
+
const c = client ?? new AgentLaunchClient({
|
|
100
|
+
baseUrl: process.env['AGENT_LAUNCH_BASE_URL'],
|
|
101
|
+
});
|
|
102
|
+
return c.post('/api/agents/import-agentverse', {
|
|
103
|
+
agentverseApiKey,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAOhD,8EAA8E;AAC9E,gDAAgD;AAChD,8EAA8E;AAE9E,SAAS,aAAa,CAAC,MAAe;IACpC,OAAO,IAAI,iBAAiB,CAAC;QAC3B,MAAM,EAAE,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;QAC1F,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;KAC9C,CAAC,CAAC;AACL,CAAC;AAED,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAc,EACd,MAA0B;IAE1B,wEAAwE;IACxE,mEAAmE;IACnE,MAAM,CAAC,GAAG,MAAM,IAAI,IAAI,iBAAiB,CAAC;QACxC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;QAC7C,sEAAsE;KACvE,CAAC,CAAC;IAEH,qEAAqE;IACrE,+DAA+D;IAC/D,mEAAmE;IACnE,OAAQ,CAEN,CAAC,IAAI,CAAoB,kBAAkB,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;AACtE,CAAC;AAED,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAA0B;IAE1B,MAAM,CAAC,GAAG,MAAM,IAAI,aAAa,EAAE,CAAC;IACpC,OAAO,CAAC,CAAC,GAAG,CAAmB,uBAAuB,CAAC,CAAC;AAC1D,CAAC;AAED,8EAA8E;AAC9E,uBAAuB;AACvB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,gBAAwB,EACxB,MAA0B;IAE1B,0EAA0E;IAC1E,MAAM,CAAC,GAAG,MAAM,IAAI,IAAI,iBAAiB,CAAC;QACxC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;KAC9C,CAAC,CAAC;IAEH,OAAQ,CAEN,CAAC,IAAI,CAA2B,+BAA+B,EAAE;QACjE,gBAAgB;KACjB,CAAC,CAAC;AACL,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agent-launch/sdk — HTTP client
|
|
3
|
+
*
|
|
4
|
+
* SDK-001: Core fetch wrapper that injects auth headers and provides typed
|
|
5
|
+
* request helpers used by all other SDK modules.
|
|
6
|
+
*
|
|
7
|
+
* SDK-007: Exponential backoff retry on HTTP 429 (rate limit) responses.
|
|
8
|
+
* Retries up to `maxRetries` times (default: 3) with delays of 1s, 2s, 4s, …
|
|
9
|
+
*
|
|
10
|
+
* No external runtime dependencies — uses the global fetch() available in
|
|
11
|
+
* Node.js ≥ 18, Deno, and modern browsers.
|
|
12
|
+
*/
|
|
13
|
+
import { AgentLaunchConfig } from './types.js';
|
|
14
|
+
/**
|
|
15
|
+
* AgentLaunchClient
|
|
16
|
+
*
|
|
17
|
+
* The central HTTP client for the AgentLaunch SDK. Instantiate once and
|
|
18
|
+
* pass to the token, market, handoff, and agent helpers — or use the
|
|
19
|
+
* named module functions which create a default client from environment
|
|
20
|
+
* variables automatically.
|
|
21
|
+
*
|
|
22
|
+
* Automatically retries requests that receive HTTP 429 (Too Many Requests)
|
|
23
|
+
* using exponential backoff: 1s → 2s → 4s → … up to `maxRetries` attempts.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { AgentLaunchClient } from '@agent-launch/sdk';
|
|
28
|
+
*
|
|
29
|
+
* const client = new AgentLaunchClient({
|
|
30
|
+
* apiKey: process.env.AGENTVERSE_API_KEY,
|
|
31
|
+
* maxRetries: 3, // default
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare class AgentLaunchClient {
|
|
36
|
+
/** Resolved base URL (no trailing slash, no /api suffix). */
|
|
37
|
+
readonly baseUrl: string;
|
|
38
|
+
private readonly apiKey;
|
|
39
|
+
private readonly maxRetries;
|
|
40
|
+
constructor(config?: AgentLaunchConfig);
|
|
41
|
+
/** Build the full API URL for a given path. */
|
|
42
|
+
private url;
|
|
43
|
+
/** Shared headers injected on every request. */
|
|
44
|
+
private headers;
|
|
45
|
+
/**
|
|
46
|
+
* Execute a fetch call with exponential backoff retry on HTTP 429.
|
|
47
|
+
*
|
|
48
|
+
* @param fetchFn Factory that returns a Promise<Response> for each attempt
|
|
49
|
+
* @param label Human-readable label for error messages (e.g. "GET /api/...")
|
|
50
|
+
*/
|
|
51
|
+
private fetchWithRetry;
|
|
52
|
+
/**
|
|
53
|
+
* Perform a typed GET request.
|
|
54
|
+
*
|
|
55
|
+
* @param path API path, e.g. `/api/agents/tokens`
|
|
56
|
+
* @param params Optional query-string parameters (undefined values omitted)
|
|
57
|
+
*/
|
|
58
|
+
get<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
59
|
+
/**
|
|
60
|
+
* Perform a typed POST request. Always requires authentication.
|
|
61
|
+
*
|
|
62
|
+
* @param path API path, e.g. `/api/agents/tokenize`
|
|
63
|
+
* @param body Request body (serialised to JSON)
|
|
64
|
+
*/
|
|
65
|
+
post<T>(path: string, body: unknown): Promise<T>;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,iBAAiB,EAAoB,MAAM,YAAY,CAAC;AA0BjE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,iBAAiB;IAC5B,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,MAAM,GAAE,iBAAsB;IAU1C,+CAA+C;IAC/C,OAAO,CAAC,GAAG;IAKX,gDAAgD;IAChD,OAAO,CAAC,OAAO;IAuBf;;;;;OAKG;YACW,cAAc;IAiC5B;;;;;OAKG;IACG,GAAG,CAAC,CAAC,EACT,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,GAC7D,OAAO,CAAC,CAAC,CAAC;IAqCb;;;;;OAKG;IACG,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;CAyBvD"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agent-launch/sdk — HTTP client
|
|
3
|
+
*
|
|
4
|
+
* SDK-001: Core fetch wrapper that injects auth headers and provides typed
|
|
5
|
+
* request helpers used by all other SDK modules.
|
|
6
|
+
*
|
|
7
|
+
* SDK-007: Exponential backoff retry on HTTP 429 (rate limit) responses.
|
|
8
|
+
* Retries up to `maxRetries` times (default: 3) with delays of 1s, 2s, 4s, …
|
|
9
|
+
*
|
|
10
|
+
* No external runtime dependencies — uses the global fetch() available in
|
|
11
|
+
* Node.js ≥ 18, Deno, and modern browsers.
|
|
12
|
+
*/
|
|
13
|
+
import { AgentLaunchError } from './types.js';
|
|
14
|
+
const DEFAULT_BASE_URL = 'https://agent-launch.ai';
|
|
15
|
+
const DEFAULT_MAX_RETRIES = 3;
|
|
16
|
+
/**
|
|
17
|
+
* Parses the response body and extracts a human-readable error message
|
|
18
|
+
* from the server's JSON error payload (if present).
|
|
19
|
+
*/
|
|
20
|
+
async function extractErrorMessage(response) {
|
|
21
|
+
try {
|
|
22
|
+
const body = (await response.json());
|
|
23
|
+
return body.message ?? body.error ?? undefined;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// Body is not JSON — ignore
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Sleep for `ms` milliseconds. Used between retry attempts.
|
|
32
|
+
*/
|
|
33
|
+
function sleep(ms) {
|
|
34
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* AgentLaunchClient
|
|
38
|
+
*
|
|
39
|
+
* The central HTTP client for the AgentLaunch SDK. Instantiate once and
|
|
40
|
+
* pass to the token, market, handoff, and agent helpers — or use the
|
|
41
|
+
* named module functions which create a default client from environment
|
|
42
|
+
* variables automatically.
|
|
43
|
+
*
|
|
44
|
+
* Automatically retries requests that receive HTTP 429 (Too Many Requests)
|
|
45
|
+
* using exponential backoff: 1s → 2s → 4s → … up to `maxRetries` attempts.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import { AgentLaunchClient } from '@agent-launch/sdk';
|
|
50
|
+
*
|
|
51
|
+
* const client = new AgentLaunchClient({
|
|
52
|
+
* apiKey: process.env.AGENTVERSE_API_KEY,
|
|
53
|
+
* maxRetries: 3, // default
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export class AgentLaunchClient {
|
|
58
|
+
constructor(config = {}) {
|
|
59
|
+
this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, '');
|
|
60
|
+
this.apiKey = config.apiKey;
|
|
61
|
+
this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
62
|
+
}
|
|
63
|
+
// -------------------------------------------------------------------------
|
|
64
|
+
// Internal helpers
|
|
65
|
+
// -------------------------------------------------------------------------
|
|
66
|
+
/** Build the full API URL for a given path. */
|
|
67
|
+
url(path) {
|
|
68
|
+
// Paths passed internally are already prefixed with /api/...
|
|
69
|
+
return `${this.baseUrl}${path}`;
|
|
70
|
+
}
|
|
71
|
+
/** Shared headers injected on every request. */
|
|
72
|
+
headers(requireAuth) {
|
|
73
|
+
const h = {
|
|
74
|
+
'Content-Type': 'application/json',
|
|
75
|
+
};
|
|
76
|
+
if (requireAuth) {
|
|
77
|
+
if (!this.apiKey) {
|
|
78
|
+
throw new AgentLaunchError('An API key is required for this operation. ' +
|
|
79
|
+
'Pass apiKey to AgentLaunchClient or set AGENTVERSE_API_KEY in your environment.', 0);
|
|
80
|
+
}
|
|
81
|
+
h['X-API-Key'] = this.apiKey;
|
|
82
|
+
}
|
|
83
|
+
else if (this.apiKey) {
|
|
84
|
+
// Attach the key on public endpoints too when present — harmless and
|
|
85
|
+
// enables higher rate limits on some endpoints.
|
|
86
|
+
h['X-API-Key'] = this.apiKey;
|
|
87
|
+
}
|
|
88
|
+
return h;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Execute a fetch call with exponential backoff retry on HTTP 429.
|
|
92
|
+
*
|
|
93
|
+
* @param fetchFn Factory that returns a Promise<Response> for each attempt
|
|
94
|
+
* @param label Human-readable label for error messages (e.g. "GET /api/...")
|
|
95
|
+
*/
|
|
96
|
+
async fetchWithRetry(fetchFn, label) {
|
|
97
|
+
let attempt = 0;
|
|
98
|
+
while (true) {
|
|
99
|
+
const response = await fetchFn();
|
|
100
|
+
if (response.status !== 429 || attempt >= this.maxRetries) {
|
|
101
|
+
return response;
|
|
102
|
+
}
|
|
103
|
+
// Exponential backoff: 1000ms, 2000ms, 4000ms, …
|
|
104
|
+
const delayMs = 1000 * Math.pow(2, attempt);
|
|
105
|
+
attempt++;
|
|
106
|
+
// Respect Retry-After header if the server sends one
|
|
107
|
+
const retryAfter = response.headers.get('Retry-After');
|
|
108
|
+
const waitMs = retryAfter ? parseInt(retryAfter, 10) * 1000 : delayMs;
|
|
109
|
+
await sleep(waitMs);
|
|
110
|
+
// The 429 response body must be consumed to avoid memory leaks in some
|
|
111
|
+
// runtimes; do so after the sleep so we don't block unnecessarily.
|
|
112
|
+
try {
|
|
113
|
+
await response.text();
|
|
114
|
+
}
|
|
115
|
+
catch { /* ignore */ }
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// -------------------------------------------------------------------------
|
|
119
|
+
// Public request methods
|
|
120
|
+
// -------------------------------------------------------------------------
|
|
121
|
+
/**
|
|
122
|
+
* Perform a typed GET request.
|
|
123
|
+
*
|
|
124
|
+
* @param path API path, e.g. `/api/agents/tokens`
|
|
125
|
+
* @param params Optional query-string parameters (undefined values omitted)
|
|
126
|
+
*/
|
|
127
|
+
async get(path, params) {
|
|
128
|
+
let fullPath = path;
|
|
129
|
+
if (params) {
|
|
130
|
+
const qs = new URLSearchParams();
|
|
131
|
+
for (const [key, value] of Object.entries(params)) {
|
|
132
|
+
if (value !== undefined && value !== null) {
|
|
133
|
+
qs.set(key, String(value));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const queryString = qs.toString();
|
|
137
|
+
if (queryString) {
|
|
138
|
+
fullPath = `${path}?${queryString}`;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const response = await this.fetchWithRetry(() => fetch(this.url(fullPath), {
|
|
142
|
+
method: 'GET',
|
|
143
|
+
headers: this.headers(false),
|
|
144
|
+
}), `GET ${fullPath}`);
|
|
145
|
+
if (!response.ok) {
|
|
146
|
+
const serverMessage = await extractErrorMessage(response);
|
|
147
|
+
throw new AgentLaunchError(`GET ${fullPath} failed: ${response.status} ${response.statusText}` +
|
|
148
|
+
(serverMessage ? ` — ${serverMessage}` : ''), response.status, serverMessage);
|
|
149
|
+
}
|
|
150
|
+
return response.json();
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Perform a typed POST request. Always requires authentication.
|
|
154
|
+
*
|
|
155
|
+
* @param path API path, e.g. `/api/agents/tokenize`
|
|
156
|
+
* @param body Request body (serialised to JSON)
|
|
157
|
+
*/
|
|
158
|
+
async post(path, body) {
|
|
159
|
+
// Build headers first — throws synchronously if apiKey is missing
|
|
160
|
+
const headers = this.headers(true);
|
|
161
|
+
const response = await this.fetchWithRetry(() => fetch(this.url(path), {
|
|
162
|
+
method: 'POST',
|
|
163
|
+
headers,
|
|
164
|
+
body: JSON.stringify(body),
|
|
165
|
+
}), `POST ${path}`);
|
|
166
|
+
if (!response.ok) {
|
|
167
|
+
const serverMessage = await extractErrorMessage(response);
|
|
168
|
+
throw new AgentLaunchError(`POST ${path} failed: ${response.status} ${response.statusText}` +
|
|
169
|
+
(serverMessage ? ` — ${serverMessage}` : ''), response.status, serverMessage);
|
|
170
|
+
}
|
|
171
|
+
return response.json();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAqB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEjE,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AACnD,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B;;;GAGG;AACH,KAAK,UAAU,mBAAmB,CAAC,QAAkB;IACnD,IAAI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IAAI,CAAI,IAAY,EAAE,IAAa;QACvC,kEAAkE;QAClE,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEnC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CACxC,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC1B,MAAM,EAAE,MAAM;YACd,OAAO;YACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,EACF,QAAQ,IAAI,EAAE,CACf,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,aAAa,GAAG,MAAM,mBAAmB,CAAC,QAAQ,CAAC,CAAC;YAC1D,MAAM,IAAI,gBAAgB,CACxB,QAAQ,IAAI,YAAY,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE;gBAChE,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAC5C,QAAQ,CAAC,MAAM,EACf,aAAa,CACd,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAAgB,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agent-launch/sdk — Handoff link generation
|
|
3
|
+
*
|
|
4
|
+
* SDK-004: Helpers for generating deploy and trade handoff URLs.
|
|
5
|
+
*
|
|
6
|
+
* The agent-human handoff protocol:
|
|
7
|
+
* 1. Agent calls POST /api/agents/tokenize → receives token_id
|
|
8
|
+
* 2. Agent generates a deploy link from token_id → sends to human
|
|
9
|
+
* 3. Human opens link, connects wallet, signs 2 transactions
|
|
10
|
+
* 4. Token is live on the bonding curve
|
|
11
|
+
*
|
|
12
|
+
* Agents never hold private keys or sign blockchain transactions directly.
|
|
13
|
+
* All on-chain actions are delegated to humans via handoff links.
|
|
14
|
+
*/
|
|
15
|
+
import type { TradeLinkOptions } from './types.js';
|
|
16
|
+
/**
|
|
17
|
+
* Generate a deploy handoff link for a pending token.
|
|
18
|
+
*
|
|
19
|
+
* The returned URL opens the deployment page where a human can connect
|
|
20
|
+
* their wallet and complete the on-chain deployment with two transactions:
|
|
21
|
+
* 1. Approve 120 FET to the deployer contract
|
|
22
|
+
* 2. Call deploy() on the deployer contract
|
|
23
|
+
*
|
|
24
|
+
* @param tokenId The `token_id` returned by POST /api/agents/tokenize
|
|
25
|
+
* @param baseUrl Override the platform base URL (defaults to agent-launch.ai)
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const link = generateDeployLink(42);
|
|
30
|
+
* // https://agent-launch.ai/deploy/42
|
|
31
|
+
*
|
|
32
|
+
* const devLink = generateDeployLink(42, 'https://fetch.ants-at-work.com');
|
|
33
|
+
* // https://fetch.ants-at-work.com/deploy/42
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function generateDeployLink(tokenId: number, baseUrl?: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Generate a trade handoff link for a deployed token.
|
|
39
|
+
*
|
|
40
|
+
* Agents use this to send pre-filled trade URLs to users. The user opens
|
|
41
|
+
* the link, connects their wallet, reviews the pre-filled amount, and
|
|
42
|
+
* clicks Buy or Sell.
|
|
43
|
+
*
|
|
44
|
+
* @param address Token contract address
|
|
45
|
+
* @param opts Optional action ('buy' | 'sell') and pre-fill amount
|
|
46
|
+
* @param baseUrl Override the platform base URL
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* // Simple buy link
|
|
51
|
+
* generateTradeLink('0xAbCd...');
|
|
52
|
+
* // https://agent-launch.ai/trade/0xAbCd...
|
|
53
|
+
*
|
|
54
|
+
* // Pre-filled buy with amount
|
|
55
|
+
* generateTradeLink('0xAbCd...', { action: 'buy', amount: 100 });
|
|
56
|
+
* // https://agent-launch.ai/trade/0xAbCd...?action=buy&amount=100
|
|
57
|
+
*
|
|
58
|
+
* // Sell link
|
|
59
|
+
* generateTradeLink('0xAbCd...', { action: 'sell', amount: 500 });
|
|
60
|
+
* // https://agent-launch.ai/trade/0xAbCd...?action=sell&amount=500
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function generateTradeLink(address: string, opts?: TradeLinkOptions, baseUrl?: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Generate a buy link with a pre-filled FET amount.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* const link = generateBuyLink('0xAbCd...', 100);
|
|
70
|
+
* // https://agent-launch.ai/trade/0xAbCd...?action=buy&amount=100
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function generateBuyLink(address: string, amount?: number | string, baseUrl?: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* Generate a sell link with a pre-filled token amount.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* const link = generateSellLink('0xAbCd...', 500);
|
|
80
|
+
* // https://agent-launch.ai/trade/0xAbCd...?action=sell&amount=500
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare function generateSellLink(address: string, amount?: number | string, baseUrl?: string): string;
|
|
84
|
+
//# sourceMappingURL=handoff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handoff.d.ts","sourceRoot":"","sources":["../src/handoff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAe,MAAM,YAAY,CAAC;AAchE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAK5E;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,gBAAqB,EAC3B,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAeR;AAMD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EACxB,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAER;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EACxB,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAER"}
|
package/dist/handoff.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agent-launch/sdk — Handoff link generation
|
|
3
|
+
*
|
|
4
|
+
* SDK-004: Helpers for generating deploy and trade handoff URLs.
|
|
5
|
+
*
|
|
6
|
+
* The agent-human handoff protocol:
|
|
7
|
+
* 1. Agent calls POST /api/agents/tokenize → receives token_id
|
|
8
|
+
* 2. Agent generates a deploy link from token_id → sends to human
|
|
9
|
+
* 3. Human opens link, connects wallet, signs 2 transactions
|
|
10
|
+
* 4. Token is live on the bonding curve
|
|
11
|
+
*
|
|
12
|
+
* Agents never hold private keys or sign blockchain transactions directly.
|
|
13
|
+
* All on-chain actions are delegated to humans via handoff links.
|
|
14
|
+
*/
|
|
15
|
+
/** Resolve the platform base URL from the optional override or environment. */
|
|
16
|
+
function resolveBaseUrl(baseUrl) {
|
|
17
|
+
return ((baseUrl ?? process.env['AGENT_LAUNCH_BASE_URL'])?.replace(/\/$/, '') ??
|
|
18
|
+
'https://agent-launch.ai');
|
|
19
|
+
}
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// generateDeployLink
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
/**
|
|
24
|
+
* Generate a deploy handoff link for a pending token.
|
|
25
|
+
*
|
|
26
|
+
* The returned URL opens the deployment page where a human can connect
|
|
27
|
+
* their wallet and complete the on-chain deployment with two transactions:
|
|
28
|
+
* 1. Approve 120 FET to the deployer contract
|
|
29
|
+
* 2. Call deploy() on the deployer contract
|
|
30
|
+
*
|
|
31
|
+
* @param tokenId The `token_id` returned by POST /api/agents/tokenize
|
|
32
|
+
* @param baseUrl Override the platform base URL (defaults to agent-launch.ai)
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const link = generateDeployLink(42);
|
|
37
|
+
* // https://agent-launch.ai/deploy/42
|
|
38
|
+
*
|
|
39
|
+
* const devLink = generateDeployLink(42, 'https://fetch.ants-at-work.com');
|
|
40
|
+
* // https://fetch.ants-at-work.com/deploy/42
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export function generateDeployLink(tokenId, baseUrl) {
|
|
44
|
+
if (!Number.isInteger(tokenId) || tokenId <= 0) {
|
|
45
|
+
throw new Error(`generateDeployLink: tokenId must be a positive integer, got ${tokenId}`);
|
|
46
|
+
}
|
|
47
|
+
return `${resolveBaseUrl(baseUrl)}/deploy/${tokenId}`;
|
|
48
|
+
}
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// generateTradeLink
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
/**
|
|
53
|
+
* Generate a trade handoff link for a deployed token.
|
|
54
|
+
*
|
|
55
|
+
* Agents use this to send pre-filled trade URLs to users. The user opens
|
|
56
|
+
* the link, connects their wallet, reviews the pre-filled amount, and
|
|
57
|
+
* clicks Buy or Sell.
|
|
58
|
+
*
|
|
59
|
+
* @param address Token contract address
|
|
60
|
+
* @param opts Optional action ('buy' | 'sell') and pre-fill amount
|
|
61
|
+
* @param baseUrl Override the platform base URL
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* // Simple buy link
|
|
66
|
+
* generateTradeLink('0xAbCd...');
|
|
67
|
+
* // https://agent-launch.ai/trade/0xAbCd...
|
|
68
|
+
*
|
|
69
|
+
* // Pre-filled buy with amount
|
|
70
|
+
* generateTradeLink('0xAbCd...', { action: 'buy', amount: 100 });
|
|
71
|
+
* // https://agent-launch.ai/trade/0xAbCd...?action=buy&amount=100
|
|
72
|
+
*
|
|
73
|
+
* // Sell link
|
|
74
|
+
* generateTradeLink('0xAbCd...', { action: 'sell', amount: 500 });
|
|
75
|
+
* // https://agent-launch.ai/trade/0xAbCd...?action=sell&amount=500
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export function generateTradeLink(address, opts = {}, baseUrl) {
|
|
79
|
+
const base = resolveBaseUrl(baseUrl);
|
|
80
|
+
const params = new URLSearchParams();
|
|
81
|
+
if (opts.action) {
|
|
82
|
+
params.set('action', opts.action);
|
|
83
|
+
}
|
|
84
|
+
if (opts.amount !== undefined && opts.amount !== null) {
|
|
85
|
+
params.set('amount', String(opts.amount));
|
|
86
|
+
}
|
|
87
|
+
const qs = params.toString();
|
|
88
|
+
return qs
|
|
89
|
+
? `${base}/trade/${address}?${qs}`
|
|
90
|
+
: `${base}/trade/${address}`;
|
|
91
|
+
}
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
// Convenience re-exports for common patterns
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
/**
|
|
96
|
+
* Generate a buy link with a pre-filled FET amount.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* const link = generateBuyLink('0xAbCd...', 100);
|
|
101
|
+
* // https://agent-launch.ai/trade/0xAbCd...?action=buy&amount=100
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export function generateBuyLink(address, amount, baseUrl) {
|
|
105
|
+
return generateTradeLink(address, { action: 'buy', amount }, baseUrl);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Generate a sell link with a pre-filled token amount.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* const link = generateSellLink('0xAbCd...', 500);
|
|
113
|
+
* // https://agent-launch.ai/trade/0xAbCd...?action=sell&amount=500
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export function generateSellLink(address, amount, baseUrl) {
|
|
117
|
+
return generateTradeLink(address, { action: 'sell', amount }, baseUrl);
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=handoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../src/handoff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,+EAA+E;AAC/E,SAAS,cAAc,CAAC,OAAgB;IACtC,OAAO,CACL,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;QACrE,yBAAyB,CAC1B,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe,EAAE,OAAgB;IAClE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,+DAA+D,OAAO,EAAE,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,WAAW,OAAO,EAAE,CAAC;AACxD,CAAC;AAED,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAe,EACf,OAAyB,EAAE,EAC3B,OAAgB;IAEhB,MAAM,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IAErC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;QACtD,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC7B,OAAO,EAAE;QACP,CAAC,CAAC,GAAG,IAAI,UAAU,OAAO,IAAI,EAAE,EAAE;QAClC,CAAC,CAAC,GAAG,IAAI,UAAU,OAAO,EAAE,CAAC;AACjC,CAAC;AAED,8EAA8E;AAC9E,6CAA6C;AAC7C,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAe,EACf,MAAwB,EACxB,OAAgB;IAEhB,OAAO,iBAAiB,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,KAAoB,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;AACvF,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAe,EACf,MAAwB,EACxB,OAAgB;IAEhB,OAAO,iBAAiB,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,MAAqB,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;AACxF,CAAC"}
|
package/dist/index.cjs
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agent-launch/sdk
|
|
3
|
+
*
|
|
4
|
+
* TypeScript SDK for the AgentLaunch platform (agent-launch.ai).
|
|
5
|
+
*
|
|
6
|
+
* Enables AI agents and developers to:
|
|
7
|
+
* - Create token records and receive human handoff links
|
|
8
|
+
* - Query token prices, market data, and holder information
|
|
9
|
+
* - Generate pre-filled deploy and trade URLs for human users
|
|
10
|
+
* - Authenticate with Agentverse API keys
|
|
11
|
+
* - List and import Agentverse agents
|
|
12
|
+
*
|
|
13
|
+
* Quick start:
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { tokenize, generateDeployLink } from '@agent-launch/sdk';
|
|
16
|
+
*
|
|
17
|
+
* const { data } = await tokenize({
|
|
18
|
+
* agentAddress: 'agent1qf8xfhsc8hg4g5l0nhtj...',
|
|
19
|
+
* name: 'My Agent Token',
|
|
20
|
+
* chainId: 97,
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* const link = generateDeployLink(data.token_id);
|
|
24
|
+
* // Share this link with a human → they connect wallet → token is live
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* Authentication:
|
|
28
|
+
* Set AGENTVERSE_API_KEY in your environment, or pass `apiKey` directly
|
|
29
|
+
* to AgentLaunchClient.
|
|
30
|
+
*
|
|
31
|
+
* Platform fee:
|
|
32
|
+
* A 2% fee applies to every buy and sell transaction.
|
|
33
|
+
* This fee goes 100% to the protocol treasury (REVENUE_ACCOUNT).
|
|
34
|
+
* There is no creator fee.
|
|
35
|
+
*/
|
|
36
|
+
export { AgentLaunch } from './agentlaunch.js';
|
|
37
|
+
export type { TokensNamespace, MarketNamespace, HandoffNamespace, AgentsNamespace, } from './agentlaunch.js';
|
|
38
|
+
export { AgentLaunchClient } from './client.js';
|
|
39
|
+
export type { AgentLaunchConfig, TokenizeParams, TokenizeResponse, Token, TokenListParams, TokenListResponse, Holder, HolderListResponse, SingleHolderResponse, TradeAction, TradeLinkOptions, AgentAuthResponse, AgentverseAgent, MyAgentsResponse, ImportAgentverseResponse, } from './types.js';
|
|
40
|
+
export { AgentLaunchError } from './types.js';
|
|
41
|
+
export { tokenize, getToken, listTokens } from './tokens.js';
|
|
42
|
+
export { getTokenPrice, getTokenHolders, generateTradeLink as generateTradeLinkWithAction, generateTradeLinkFromOptions, } from './market.js';
|
|
43
|
+
export { generateDeployLink, generateTradeLink, generateBuyLink, generateSellLink, } from './handoff.js';
|
|
44
|
+
export { authenticate, getMyAgents, importFromAgentverse } from './agents.js';
|
|
45
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,YAAY,EACV,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,KAAK,EACL,eAAe,EACf,iBAAiB,EACjB,MAAM,EACN,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG9C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG7D,OAAO,EACL,aAAa,EACb,eAAe,EACf,iBAAiB,IAAI,2BAA2B,EAChD,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC"}
|