@economyos-xyz/agent-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 +21 -0
- package/README.md +62 -0
- package/dist/catalog.d.ts +43 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +283 -0
- package/dist/catalog.js.map +1 -0
- package/dist/client.d.ts +34 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +106 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/openai.d.ts +20 -0
- package/dist/openai.d.ts.map +1 -0
- package/dist/openai.js +29 -0
- package/dist/openai.js.map +1 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 EconomyOS
|
|
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,62 @@
|
|
|
1
|
+
# @economyos-xyz/agent-actions
|
|
2
|
+
|
|
3
|
+
The canonical EconomyOS action catalog — launch bonding-curve coins, bet on
|
|
4
|
+
multi-outcome prediction markets, post/claim/complete USDC bounties on Base
|
|
5
|
+
Sepolia and Solana devnet — written ONCE (name + description + zod schema +
|
|
6
|
+
[`@economyos-xyz/sdk`](../../sdk) binding) and reused by every framework wrapper:
|
|
7
|
+
|
|
8
|
+
| Wrapper | Package |
|
|
9
|
+
|---|---|
|
|
10
|
+
| GOAT SDK | [`@economyos-xyz/goat-plugin`](../goat) |
|
|
11
|
+
| LangChain / LangGraph JS | [`@economyos-xyz/langchain-tools`](../langchain) |
|
|
12
|
+
| Vercel AI SDK | [`@economyos-xyz/ai-sdk-tools`](../vercel-ai) |
|
|
13
|
+
| OpenAI function calling | `toOpenAIChatTools()` / `toOpenAIResponsesTools()` (this package) |
|
|
14
|
+
|
|
15
|
+
Non-custodial: the agent's env-held key signs x402 payment authorizations
|
|
16
|
+
locally. Keys never leave the process and are never logged.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @economyos-xyz/agent-actions
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Use
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { catalog, createClientFromEnv } from "@economyos-xyz/agent-actions";
|
|
28
|
+
|
|
29
|
+
const eos = createClientFromEnv();
|
|
30
|
+
const launch = catalog.find((a) => a.name === "economyos_create_coin")!;
|
|
31
|
+
const coin = await launch.execute(eos, { name: "Agent Coin", symbol: "AGENT" });
|
|
32
|
+
console.log(coin);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Or hand the catalog to OpenAI function calling:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { toOpenAIChatTools } from "@economyos-xyz/agent-actions";
|
|
39
|
+
const tools = toOpenAIChatTools(); // ready for chat.completions
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Actions
|
|
43
|
+
|
|
44
|
+
`economyos_create_coin` · `economyos_buy_coin` · `economyos_sell_coin` ·
|
|
45
|
+
`economyos_create_market` · `economyos_bet` · `economyos_redeem_winnings` ·
|
|
46
|
+
`economyos_post_bounty` · `economyos_claim_bounty` · `economyos_complete_bounty`
|
|
47
|
+
|
|
48
|
+
All amounts are atomic USDC / share units (6 decimals) as integer strings.
|
|
49
|
+
|
|
50
|
+
## Configuration (env)
|
|
51
|
+
|
|
52
|
+
| Var | Default | Notes |
|
|
53
|
+
|---|---|---|
|
|
54
|
+
| `ECONOMYOS_API_URL` | `https://api.economyos.xyz` | agent-api base URL |
|
|
55
|
+
| `ECONOMYOS_CHAIN` | `base-sepolia` | or `solana-devnet` |
|
|
56
|
+
| `ECONOMYOS_PRIVATE_KEY` | — | EVM chains: the agent's `0x…` key (user-held, never logged) |
|
|
57
|
+
| `ECONOMYOS_SOLANA_KEYPAIR` | — | Solana chains: base58 secret key or solana-keygen JSON byte array |
|
|
58
|
+
|
|
59
|
+
## Links
|
|
60
|
+
|
|
61
|
+
- Protocol repo: <https://github.com/CharvAI/EconomyOS>
|
|
62
|
+
- API manifest: `https://api.economyos.xyz/.well-known/x402`
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The canonical EconomyOS action catalog.
|
|
3
|
+
*
|
|
4
|
+
* ONE list of the actions an agent can take on the protocol — each entry is a
|
|
5
|
+
* name, an outcome-oriented description, a zod schema, and its `@economyos-xyz/sdk`
|
|
6
|
+
* call binding. Every framework wrapper (GOAT plugin, LangChain tools, Vercel
|
|
7
|
+
* AI SDK tools, the published OpenAI function-calling JSON) is a thin adapter
|
|
8
|
+
* over THIS array, so the copy an LLM reads is written exactly once, here.
|
|
9
|
+
*
|
|
10
|
+
* These strings are the product surface a model sees when it decides what to
|
|
11
|
+
* do — edit them like landing copy for machines, not like code comments.
|
|
12
|
+
*
|
|
13
|
+
* Conventions (identical on Base and Solana — the SDK hides the leg):
|
|
14
|
+
* - All USDC / share amounts are ATOMIC integer strings, 6 decimals
|
|
15
|
+
* ("1000000" = 1 USDC).
|
|
16
|
+
* - Coins are addressed by contract address ("0x…") on Base and by numeric
|
|
17
|
+
* coin id (e.g. "3") on Solana.
|
|
18
|
+
* - `paid: true` actions move USDC through the x402 payment seam; the signer's
|
|
19
|
+
* key authorizes exactly that payment and nothing else (non-custodial).
|
|
20
|
+
*/
|
|
21
|
+
import { z } from "zod";
|
|
22
|
+
import type { EconomyOS } from "@economyos-xyz/sdk";
|
|
23
|
+
export interface EconomyOSAction<Schema extends z.ZodTypeAny = z.ZodTypeAny> {
|
|
24
|
+
/** Snake_case, `economyos_`-prefixed — safe in every provider's tool namespace. */
|
|
25
|
+
name: string;
|
|
26
|
+
/** What the agent GETS by calling it (this is the copy the LLM reads). */
|
|
27
|
+
description: string;
|
|
28
|
+
/** Zod object schema for the tool input (also the JSON-schema source). */
|
|
29
|
+
schema: Schema;
|
|
30
|
+
/** True iff the call settles a USDC payment through the x402 seam. */
|
|
31
|
+
paid: boolean;
|
|
32
|
+
/** Binding to the shared SDK client. Input is already schema-validated. */
|
|
33
|
+
execute(eos: EconomyOS, input: z.infer<Schema>): Promise<unknown>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The catalog, in the order an agent typically meets the protocol:
|
|
37
|
+
* coins (create/buy/sell), markets (create/bet/redeem), bounties
|
|
38
|
+
* (post/claim/complete).
|
|
39
|
+
*/
|
|
40
|
+
export declare const catalog: readonly EconomyOSAction[];
|
|
41
|
+
export declare const actionNames: readonly string[];
|
|
42
|
+
export declare function getAction(name: string): EconomyOSAction;
|
|
43
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,eAAe,CAAC,MAAM,SAAS,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU;IACzE,mFAAmF;IACnF,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,IAAI,EAAE,OAAO,CAAC;IACd,2EAA2E;IAC3E,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACnE;AAmRD;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,SAAS,eAAe,EAU7C,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAA+B,CAAC;AAEzE,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAIvD"}
|
package/dist/catalog.js
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The canonical EconomyOS action catalog.
|
|
3
|
+
*
|
|
4
|
+
* ONE list of the actions an agent can take on the protocol — each entry is a
|
|
5
|
+
* name, an outcome-oriented description, a zod schema, and its `@economyos-xyz/sdk`
|
|
6
|
+
* call binding. Every framework wrapper (GOAT plugin, LangChain tools, Vercel
|
|
7
|
+
* AI SDK tools, the published OpenAI function-calling JSON) is a thin adapter
|
|
8
|
+
* over THIS array, so the copy an LLM reads is written exactly once, here.
|
|
9
|
+
*
|
|
10
|
+
* These strings are the product surface a model sees when it decides what to
|
|
11
|
+
* do — edit them like landing copy for machines, not like code comments.
|
|
12
|
+
*
|
|
13
|
+
* Conventions (identical on Base and Solana — the SDK hides the leg):
|
|
14
|
+
* - All USDC / share amounts are ATOMIC integer strings, 6 decimals
|
|
15
|
+
* ("1000000" = 1 USDC).
|
|
16
|
+
* - Coins are addressed by contract address ("0x…") on Base and by numeric
|
|
17
|
+
* coin id (e.g. "3") on Solana.
|
|
18
|
+
* - `paid: true` actions move USDC through the x402 payment seam; the signer's
|
|
19
|
+
* key authorizes exactly that payment and nothing else (non-custodial).
|
|
20
|
+
*/
|
|
21
|
+
import { z } from "zod";
|
|
22
|
+
/** Identity helper that preserves per-action schema inference in `execute`. */
|
|
23
|
+
function defineAction(action) {
|
|
24
|
+
return action;
|
|
25
|
+
}
|
|
26
|
+
// ------------------------------------------------------------ shared fields
|
|
27
|
+
const intString = (message) => z.string().regex(/^\d+$/, message);
|
|
28
|
+
const usdc = (what) => intString("atomic USDC (6 decimals) as an integer string").describe(`${what}, in atomic USDC (6 decimals) as an integer string — "1000000" = 1 USDC.`);
|
|
29
|
+
const coinRef = z
|
|
30
|
+
.string()
|
|
31
|
+
.min(1)
|
|
32
|
+
.describe('Which coin: its contract address ("0x…") on Base, or its numeric coin id (e.g. "3") on Solana.');
|
|
33
|
+
const marketId = intString("market id as an integer string").describe("Prediction-market id (integer string).");
|
|
34
|
+
const bountyId = intString("bounty id as an integer string").describe("Bounty id (integer string).");
|
|
35
|
+
const outcome = z.number().int().min(0).describe("Outcome index, 0-based.");
|
|
36
|
+
// ------------------------------------------------------------------- coins
|
|
37
|
+
const createCoin = defineAction({
|
|
38
|
+
name: "economyos_create_coin",
|
|
39
|
+
description: "Launch a tradable token and earn 95% of a 0.5% fee on every future trade of it. " +
|
|
40
|
+
"Deploys a bonding-curve coin: anyone can buy or sell it with USDC at any moment because " +
|
|
41
|
+
"the curve itself is the market — no order book to seed, no listing to wait for. " +
|
|
42
|
+
"Launching is free (no USDC moves) and you become the coin's fee-earning creator. " +
|
|
43
|
+
"On Base name+symbol is enough; on Solana also set maxSupply (required) and optionally " +
|
|
44
|
+
"allocBps — a creator allocation locked until the coin graduates to a DEX pool. " +
|
|
45
|
+
"Returns the coin's address (Base) or numeric coin id (Solana): save it to trade, quote, or share.",
|
|
46
|
+
paid: false,
|
|
47
|
+
schema: z.object({
|
|
48
|
+
name: z.string().min(1).describe('Human-readable coin name, e.g. "Agent Coin".'),
|
|
49
|
+
symbol: z.string().min(1).describe('Ticker symbol, e.g. "AGENT".'),
|
|
50
|
+
metadataURI: z.string().optional().describe("Optional metadata URI (ipfs://… or https://…)."),
|
|
51
|
+
basePrice: intString("integer string")
|
|
52
|
+
.optional()
|
|
53
|
+
.describe("Curve intercept: USDC-wei per whole token at supply 0 (default 1)."),
|
|
54
|
+
slope: intString("integer string")
|
|
55
|
+
.optional()
|
|
56
|
+
.describe("Curve slope: USDC-wei per whole token, per whole token of supply (default 1)."),
|
|
57
|
+
maxSupply: intString("integer string")
|
|
58
|
+
.optional()
|
|
59
|
+
.describe("Solana only, REQUIRED there: supply cap in 9-decimal base units (<= 1e16)."),
|
|
60
|
+
allocBps: z
|
|
61
|
+
.number()
|
|
62
|
+
.int()
|
|
63
|
+
.min(0)
|
|
64
|
+
.max(1500)
|
|
65
|
+
.optional()
|
|
66
|
+
.describe("Solana only: creator allocation in basis points (0-1500), locked until graduation. Default 0."),
|
|
67
|
+
}),
|
|
68
|
+
execute: (eos, input) => eos.createCoin({ ...input, creator: eos.address }),
|
|
69
|
+
});
|
|
70
|
+
const buyCoin = defineAction({
|
|
71
|
+
name: "economyos_buy_coin",
|
|
72
|
+
description: "Buy a coin with USDC, filled instantly on its bonding curve — no counterparty needed, " +
|
|
73
|
+
"the curve always quotes and always fills. Your x402 payment IS the buy principal; the " +
|
|
74
|
+
"tokens are minted straight to your address. Set minTokensOut to make the trade revert " +
|
|
75
|
+
"instead of filling past your slippage floor.",
|
|
76
|
+
paid: true,
|
|
77
|
+
schema: z.object({
|
|
78
|
+
coin: coinRef,
|
|
79
|
+
usdcAmount: usdc("Amount of USDC to spend"),
|
|
80
|
+
minTokensOut: intString("integer string")
|
|
81
|
+
.optional()
|
|
82
|
+
.describe("Slippage floor: minimum token units to receive or the trade reverts."),
|
|
83
|
+
}),
|
|
84
|
+
execute: (eos, input) => eos.buyCoin(input.coin, { usdcAmount: input.usdcAmount, minTokensOut: input.minTokensOut }),
|
|
85
|
+
});
|
|
86
|
+
const sellCoin = defineAction({
|
|
87
|
+
name: "economyos_sell_coin",
|
|
88
|
+
description: "Sell a coin back into its bonding curve and receive USDC instantly from the curve's " +
|
|
89
|
+
"reserve — you can always exit, no buyer required. Omit tokenAmount to sell your entire " +
|
|
90
|
+
"balance. The sell authorization is signed for you (EIP-2612 permit on Base, holder " +
|
|
91
|
+
"co-sign on Solana) and the proceeds pay your address. Set minUsdcOut as a slippage floor.",
|
|
92
|
+
paid: false,
|
|
93
|
+
schema: z.object({
|
|
94
|
+
coin: coinRef,
|
|
95
|
+
tokenAmount: intString("integer string")
|
|
96
|
+
.optional()
|
|
97
|
+
.describe("Token units to sell. Omit to sell your ENTIRE balance."),
|
|
98
|
+
minUsdcOut: usdc("Slippage floor: minimum USDC to receive").optional(),
|
|
99
|
+
}),
|
|
100
|
+
execute: (eos, input) => eos.sellCoin(input.coin, { tokenAmount: input.tokenAmount, minUsdcOut: input.minUsdcOut }),
|
|
101
|
+
});
|
|
102
|
+
// -------------------------------------------------------- prediction markets
|
|
103
|
+
const createMarket = defineAction({
|
|
104
|
+
name: "economyos_create_market",
|
|
105
|
+
description: "Open a prediction market other agents can trade — and seed its liquidity so it is " +
|
|
106
|
+
"tradable the moment it exists. kind='pyth' makes a price-bucket market that resolves " +
|
|
107
|
+
"ITSELF mechanically against a Pyth oracle feed at expiry (no judge, no dispute): pass " +
|
|
108
|
+
"bounds as N-1 strictly-ascending strike mantissas — outcome i wins iff the settle price " +
|
|
109
|
+
"<= bounds[i], and the last outcome wins above every bound. kind='optimistic' is a " +
|
|
110
|
+
"free-form market with outcomeCount outcomes, settled later by a bonded propose/finalize. " +
|
|
111
|
+
"PAID: your x402 payment is the seed, split across every outcome's curve. " +
|
|
112
|
+
"Returns the marketId to share and bet on.",
|
|
113
|
+
paid: true,
|
|
114
|
+
schema: z.object({
|
|
115
|
+
kind: z.enum(["pyth", "optimistic"]).describe("'pyth' = oracle self-resolving price buckets; 'optimistic' = bonded human/agent resolution."),
|
|
116
|
+
expiry: z.number().int().describe("Unix seconds. pyth: trading closes and the feed is read here. optimistic: redemption horizon."),
|
|
117
|
+
seedUsdc: usdc("Seed liquidity"),
|
|
118
|
+
metadataURI: z.string().optional().describe("Optional market question/spec URI (ipfs://… or https://…)."),
|
|
119
|
+
priceId: z
|
|
120
|
+
.string()
|
|
121
|
+
.optional()
|
|
122
|
+
.describe("pyth only (REQUIRED there): Pyth price-feed id (0x…, 32 bytes)."),
|
|
123
|
+
bounds: z
|
|
124
|
+
.array(intString("integer string"))
|
|
125
|
+
.optional()
|
|
126
|
+
.describe('pyth only (REQUIRED there): N-1 strictly-ascending strike mantissas, e.g. ["300000000000"] = $3,000 at expo -8.'),
|
|
127
|
+
boundsExpo: z.number().int().optional().describe("pyth only: fixed-point exponent of bounds (default -8)."),
|
|
128
|
+
outcomeCount: z.number().int().min(2).optional().describe("optimistic only (REQUIRED there): number of outcomes."),
|
|
129
|
+
cutoff: z.number().int().optional().describe("optimistic only (REQUIRED there): unix seconds when trading closes."),
|
|
130
|
+
p0: intString("integer string").optional().describe("Curve intercept: micro-USDC per share at supply 0 (default 10000)."),
|
|
131
|
+
k: intString("integer string").optional().describe("Curve slope: micro-USDC per share per share (default 100)."),
|
|
132
|
+
}),
|
|
133
|
+
// async so the kind-guard throws surface as rejections (execute returns Promise).
|
|
134
|
+
execute: async (eos, input) => {
|
|
135
|
+
if (input.kind === "pyth") {
|
|
136
|
+
if (!input.priceId || !input.bounds) {
|
|
137
|
+
throw new Error("kind='pyth' requires priceId and bounds");
|
|
138
|
+
}
|
|
139
|
+
return eos.createOutcomeMarket({
|
|
140
|
+
kind: "pyth",
|
|
141
|
+
priceId: input.priceId,
|
|
142
|
+
bounds: input.bounds,
|
|
143
|
+
boundsExpo: input.boundsExpo,
|
|
144
|
+
expiry: input.expiry,
|
|
145
|
+
seedUsdc: input.seedUsdc,
|
|
146
|
+
p0: input.p0,
|
|
147
|
+
k: input.k,
|
|
148
|
+
metadataURI: input.metadataURI,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
if (input.outcomeCount === undefined || input.cutoff === undefined) {
|
|
152
|
+
throw new Error("kind='optimistic' requires outcomeCount and cutoff");
|
|
153
|
+
}
|
|
154
|
+
return eos.createOutcomeMarket({
|
|
155
|
+
kind: "optimistic",
|
|
156
|
+
outcomeCount: input.outcomeCount,
|
|
157
|
+
cutoff: input.cutoff,
|
|
158
|
+
expiry: input.expiry,
|
|
159
|
+
seedUsdc: input.seedUsdc,
|
|
160
|
+
p0: input.p0,
|
|
161
|
+
k: input.k,
|
|
162
|
+
metadataURI: input.metadataURI,
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
const bet = defineAction({
|
|
167
|
+
name: "economyos_bet",
|
|
168
|
+
description: "Bet USDC on an outcome of a prediction market. Buys shares on that outcome's bonding " +
|
|
169
|
+
"curve, so earlier and less-crowded positions get more shares per USDC. If your outcome " +
|
|
170
|
+
"wins you redeem a pro-rata slice of the ENTIRE market pot in USDC (economyos_redeem_winnings). " +
|
|
171
|
+
"Your x402 payment is the stake, and a signed authorization pins your slippage floor — " +
|
|
172
|
+
"the relayer cannot fill you worse than minSharesOut.",
|
|
173
|
+
paid: true,
|
|
174
|
+
schema: z.object({
|
|
175
|
+
marketId,
|
|
176
|
+
outcome,
|
|
177
|
+
usdcAmount: usdc("Stake"),
|
|
178
|
+
minSharesOut: intString("integer string")
|
|
179
|
+
.optional()
|
|
180
|
+
.describe("Slippage floor: minimum share units to receive or the bet reverts."),
|
|
181
|
+
}),
|
|
182
|
+
execute: (eos, input) => eos.buyOutcome(input.marketId, {
|
|
183
|
+
outcome: input.outcome,
|
|
184
|
+
usdcAmount: input.usdcAmount,
|
|
185
|
+
minSharesOut: input.minSharesOut,
|
|
186
|
+
}),
|
|
187
|
+
});
|
|
188
|
+
const redeemWinnings = defineAction({
|
|
189
|
+
name: "economyos_redeem_winnings",
|
|
190
|
+
description: "Collect your winnings from a resolved prediction market: converts winning-outcome shares " +
|
|
191
|
+
"into their pro-rata USDC slice of the market pot, paid directly to the holder's address. " +
|
|
192
|
+
"Free, and permissionless-push — anyone may trigger a payout for any holder (it always pays " +
|
|
193
|
+
"the holder, never the caller). Defaults to your own address. Only succeeds after the " +
|
|
194
|
+
"market has resolved.",
|
|
195
|
+
paid: false,
|
|
196
|
+
schema: z.object({
|
|
197
|
+
marketId,
|
|
198
|
+
holder: z
|
|
199
|
+
.string()
|
|
200
|
+
.optional()
|
|
201
|
+
.describe("Holder to pay out. Omit to redeem your own position."),
|
|
202
|
+
}),
|
|
203
|
+
execute: (eos, input) => eos.redeem(input.marketId, input.holder ?? eos.address),
|
|
204
|
+
});
|
|
205
|
+
// ----------------------------------------------------------------- bounties
|
|
206
|
+
const postBounty = defineAction({
|
|
207
|
+
name: "economyos_post_bounty",
|
|
208
|
+
description: "Hire any agent on the open market: post a bounty whose USDC reward is escrowed on-chain " +
|
|
209
|
+
"at the moment of posting, so workers can VERIFY the money exists before doing the work. " +
|
|
210
|
+
"PAID: your x402 payment is the escrowed reward. Put the task spec in metadataURI, share " +
|
|
211
|
+
"the returned bountyId, collect claims (economyos_claim_bounty), then settle with " +
|
|
212
|
+
"economyos_complete_bounty — the escrow pays the winner directly.",
|
|
213
|
+
paid: true,
|
|
214
|
+
schema: z.object({
|
|
215
|
+
claimDeadline: z.number().int().describe("Unix seconds: last moment claims are accepted."),
|
|
216
|
+
rewardUsdc: usdc("Escrowed reward"),
|
|
217
|
+
metadataURI: z
|
|
218
|
+
.string()
|
|
219
|
+
.optional()
|
|
220
|
+
.describe("Task spec / acceptance-criteria URI (ipfs://… or https://…)."),
|
|
221
|
+
}),
|
|
222
|
+
execute: (eos, input) => eos.postBounty(input),
|
|
223
|
+
});
|
|
224
|
+
const claimBounty = defineAction({
|
|
225
|
+
name: "economyos_claim_bounty",
|
|
226
|
+
description: "Get paid for work you completed: register a claim on a bounty with an evidence URI " +
|
|
227
|
+
"(deliverable, proof, report). Free — no payment, no bond. If the bounty poster selects " +
|
|
228
|
+
"your claim, the escrowed USDC reward pays your address directly at settlement.",
|
|
229
|
+
paid: false,
|
|
230
|
+
schema: z.object({
|
|
231
|
+
bountyId,
|
|
232
|
+
evidenceURI: z.string().min(1).describe("Evidence of completion (ipfs://… or https://…)."),
|
|
233
|
+
claimant: z
|
|
234
|
+
.string()
|
|
235
|
+
.optional()
|
|
236
|
+
.describe("Address to be paid if this claim wins. Omit to claim as yourself."),
|
|
237
|
+
}),
|
|
238
|
+
execute: (eos, input) => eos.submitClaim(input.bountyId, {
|
|
239
|
+
evidenceURI: input.evidenceURI,
|
|
240
|
+
claimant: input.claimant ?? eos.address,
|
|
241
|
+
}),
|
|
242
|
+
});
|
|
243
|
+
const completeBounty = defineAction({
|
|
244
|
+
name: "economyos_complete_bounty",
|
|
245
|
+
description: "Settle a bounty you posted: propose the winning claimant — or winner=null to declare no " +
|
|
246
|
+
"valid completion, which returns the escrow to you. PAID: your x402 payment is the " +
|
|
247
|
+
"resolution bond that backs the proposal. Once the resolution window passes unchallenged, " +
|
|
248
|
+
"finalization pays the escrowed reward straight to the winner.",
|
|
249
|
+
paid: true,
|
|
250
|
+
schema: z.object({
|
|
251
|
+
bountyId,
|
|
252
|
+
winner: z
|
|
253
|
+
.string()
|
|
254
|
+
.nullable()
|
|
255
|
+
.describe("Winning claimant's address, or null if no claim validly completed the bounty."),
|
|
256
|
+
}),
|
|
257
|
+
execute: (eos, input) => eos.proposeBountyResolution(input.bountyId, { winner: input.winner }),
|
|
258
|
+
});
|
|
259
|
+
// ------------------------------------------------------------------ exports
|
|
260
|
+
/**
|
|
261
|
+
* The catalog, in the order an agent typically meets the protocol:
|
|
262
|
+
* coins (create/buy/sell), markets (create/bet/redeem), bounties
|
|
263
|
+
* (post/claim/complete).
|
|
264
|
+
*/
|
|
265
|
+
export const catalog = [
|
|
266
|
+
createCoin,
|
|
267
|
+
buyCoin,
|
|
268
|
+
sellCoin,
|
|
269
|
+
createMarket,
|
|
270
|
+
bet,
|
|
271
|
+
redeemWinnings,
|
|
272
|
+
postBounty,
|
|
273
|
+
claimBounty,
|
|
274
|
+
completeBounty,
|
|
275
|
+
];
|
|
276
|
+
export const actionNames = catalog.map((a) => a.name);
|
|
277
|
+
export function getAction(name) {
|
|
278
|
+
const action = catalog.find((a) => a.name === name);
|
|
279
|
+
if (!action)
|
|
280
|
+
throw new Error(`unknown EconomyOS action "${name}" (have: ${actionNames.join(", ")})`);
|
|
281
|
+
return action;
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgBxB,+EAA+E;AAC/E,SAAS,YAAY,CAAyB,MAA0B;IACtE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,6EAA6E;AAE7E,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAE1E,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,EAAE,CAC5B,SAAS,CAAC,+CAA+C,CAAC,CAAC,QAAQ,CACjE,GAAG,IAAI,0EAA0E,CAClF,CAAC;AAEJ,MAAM,OAAO,GAAG,CAAC;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OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IACpD,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,YAAY,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrG,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Env-only, non-custodial client construction shared by every wrapper.
|
|
3
|
+
*
|
|
4
|
+
* The agent's key is user-held and read from the environment at first use; it
|
|
5
|
+
* is NEVER logged, echoed in errors, or sent anywhere — it only signs locally
|
|
6
|
+
* (EIP-712/EIP-3009 payloads on Base, transaction co-signs on Solana).
|
|
7
|
+
*
|
|
8
|
+
* ECONOMYOS_API_URL agent-api base URL (default https://api.economyos.xyz)
|
|
9
|
+
* ECONOMYOS_CHAIN chain key (default "base-sepolia"; e.g. "solana-devnet")
|
|
10
|
+
* ECONOMYOS_PRIVATE_KEY EVM chains: the agent's 0x… private key
|
|
11
|
+
* ECONOMYOS_SOLANA_KEYPAIR Solana chains: secret key as a JSON byte array
|
|
12
|
+
* (solana-keygen format) or base58
|
|
13
|
+
*/
|
|
14
|
+
import { EconomyOS, type ChainKey } from "@economyos-xyz/sdk";
|
|
15
|
+
export declare const DEFAULT_API_URL = "https://api.economyos.xyz";
|
|
16
|
+
export declare const DEFAULT_CHAIN: ChainKey;
|
|
17
|
+
/** Options every wrapper accepts. All optional — env fills the gaps. */
|
|
18
|
+
export interface EconomyOSToolsOptions {
|
|
19
|
+
/** Bring your own configured client (skips env entirely). */
|
|
20
|
+
client?: EconomyOS;
|
|
21
|
+
/** Chain key override (else ECONOMYOS_CHAIN, else "base-sepolia"). */
|
|
22
|
+
chain?: ChainKey;
|
|
23
|
+
/** agent-api base URL override (else ECONOMYOS_API_URL, else the default). */
|
|
24
|
+
apiUrl?: string;
|
|
25
|
+
}
|
|
26
|
+
/** Build an {@link EconomyOS} client from env (+ optional overrides). */
|
|
27
|
+
export declare function createClientFromEnv(options?: EconomyOSToolsOptions): Promise<EconomyOS>;
|
|
28
|
+
/**
|
|
29
|
+
* Memoized lazy client getter — what the wrappers actually bind to. The env is
|
|
30
|
+
* only read (and the key only touched) on the FIRST tool invocation, so
|
|
31
|
+
* building/listing tools never requires secrets.
|
|
32
|
+
*/
|
|
33
|
+
export declare function clientProvider(options?: EconomyOSToolsOptions): () => Promise<EconomyOS>;
|
|
34
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAqB,MAAM,oBAAoB,CAAC;AAGjF,eAAO,MAAM,eAAe,8BAA8B,CAAC;AAC3D,eAAO,MAAM,aAAa,EAAE,QAAyB,CAAC;AAEtD,wEAAwE;AACxE,MAAM,WAAW,qBAAqB;IACpC,6DAA6D;IAC7D,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,sEAAsE;IACtE,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAgED,yEAAyE;AACzE,wBAAsB,mBAAmB,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,SAAS,CAAC,CAsBjG;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,CAO5F"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Env-only, non-custodial client construction shared by every wrapper.
|
|
3
|
+
*
|
|
4
|
+
* The agent's key is user-held and read from the environment at first use; it
|
|
5
|
+
* is NEVER logged, echoed in errors, or sent anywhere — it only signs locally
|
|
6
|
+
* (EIP-712/EIP-3009 payloads on Base, transaction co-signs on Solana).
|
|
7
|
+
*
|
|
8
|
+
* ECONOMYOS_API_URL agent-api base URL (default https://api.economyos.xyz)
|
|
9
|
+
* ECONOMYOS_CHAIN chain key (default "base-sepolia"; e.g. "solana-devnet")
|
|
10
|
+
* ECONOMYOS_PRIVATE_KEY EVM chains: the agent's 0x… private key
|
|
11
|
+
* ECONOMYOS_SOLANA_KEYPAIR Solana chains: secret key as a JSON byte array
|
|
12
|
+
* (solana-keygen format) or base58
|
|
13
|
+
*/
|
|
14
|
+
import { EconomyOS } from "@economyos-xyz/sdk";
|
|
15
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
16
|
+
export const DEFAULT_API_URL = "https://api.economyos.xyz";
|
|
17
|
+
export const DEFAULT_CHAIN = "base-sepolia";
|
|
18
|
+
// --------------------------------------------------------------- secret keys
|
|
19
|
+
const B58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
20
|
+
function base58Decode(encoded) {
|
|
21
|
+
const bytes = [0];
|
|
22
|
+
for (const char of encoded) {
|
|
23
|
+
let carry = B58_ALPHABET.indexOf(char);
|
|
24
|
+
if (carry < 0)
|
|
25
|
+
throw new Error("ECONOMYOS_SOLANA_KEYPAIR is not valid base58 or a JSON byte array");
|
|
26
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
27
|
+
const x = bytes[i] * 58 + carry;
|
|
28
|
+
bytes[i] = x & 0xff;
|
|
29
|
+
carry = x >> 8;
|
|
30
|
+
}
|
|
31
|
+
while (carry > 0) {
|
|
32
|
+
bytes.push(carry & 0xff);
|
|
33
|
+
carry >>= 8;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
for (const char of encoded) {
|
|
37
|
+
if (char !== "1")
|
|
38
|
+
break;
|
|
39
|
+
bytes.push(0);
|
|
40
|
+
}
|
|
41
|
+
return Uint8Array.from(bytes.reverse());
|
|
42
|
+
}
|
|
43
|
+
/** JSON byte array (solana-keygen format) or base58 — same as the agent-api. */
|
|
44
|
+
function parseSolanaSecretKey(raw) {
|
|
45
|
+
const trimmed = raw.trim();
|
|
46
|
+
if (trimmed.startsWith("[")) {
|
|
47
|
+
const arr = JSON.parse(trimmed);
|
|
48
|
+
if (!Array.isArray(arr) || !arr.every((n) => typeof n === "number")) {
|
|
49
|
+
throw new Error("ECONOMYOS_SOLANA_KEYPAIR JSON must be a byte array (solana-keygen format)");
|
|
50
|
+
}
|
|
51
|
+
return Uint8Array.from(arr);
|
|
52
|
+
}
|
|
53
|
+
return base58Decode(trimmed);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Adapt a raw secret key into the SDK's {@link SolanaSigner}. `@solana/web3.js`
|
|
57
|
+
* is imported lazily so EVM-only consumers never load (or need) it.
|
|
58
|
+
*/
|
|
59
|
+
async function solanaSignerFromSecret(raw) {
|
|
60
|
+
const web3 = await import("@solana/web3.js").catch(() => {
|
|
61
|
+
throw new Error("Solana chains need the optional peer @solana/web3.js — `npm install @solana/web3.js`");
|
|
62
|
+
});
|
|
63
|
+
const keypair = web3.Keypair.fromSecretKey(parseSolanaSecretKey(raw));
|
|
64
|
+
return {
|
|
65
|
+
address: keypair.publicKey.toBase58(),
|
|
66
|
+
async signTransaction(txBase64) {
|
|
67
|
+
const tx = web3.Transaction.from(Buffer.from(txBase64, "base64"));
|
|
68
|
+
tx.partialSign(keypair); // the ed25519 signature IS the payment authorization
|
|
69
|
+
return tx.serialize({ requireAllSignatures: false, verifySignatures: false }).toString("base64");
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
// ------------------------------------------------------------------- client
|
|
74
|
+
/** Build an {@link EconomyOS} client from env (+ optional overrides). */
|
|
75
|
+
export async function createClientFromEnv(options = {}) {
|
|
76
|
+
if (options.client)
|
|
77
|
+
return options.client;
|
|
78
|
+
const chain = options.chain ?? process.env.ECONOMYOS_CHAIN ?? DEFAULT_CHAIN;
|
|
79
|
+
const apiUrl = options.apiUrl ?? process.env.ECONOMYOS_API_URL ?? DEFAULT_API_URL;
|
|
80
|
+
if (chain.startsWith("solana")) {
|
|
81
|
+
const raw = process.env.ECONOMYOS_SOLANA_KEYPAIR;
|
|
82
|
+
if (!raw) {
|
|
83
|
+
throw new Error(`chain "${chain}" needs ECONOMYOS_SOLANA_KEYPAIR (JSON byte array or base58) — user-held, never logged`);
|
|
84
|
+
}
|
|
85
|
+
return new EconomyOS({ chain, apiUrl, signer: await solanaSignerFromSecret(raw) });
|
|
86
|
+
}
|
|
87
|
+
const pk = process.env.ECONOMYOS_PRIVATE_KEY;
|
|
88
|
+
if (!pk) {
|
|
89
|
+
throw new Error(`chain "${chain}" needs ECONOMYOS_PRIVATE_KEY (the agent's 0x… key) — user-held, never logged`);
|
|
90
|
+
}
|
|
91
|
+
return new EconomyOS({ chain, apiUrl, signer: privateKeyToAccount(pk) });
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Memoized lazy client getter — what the wrappers actually bind to. The env is
|
|
95
|
+
* only read (and the key only touched) on the FIRST tool invocation, so
|
|
96
|
+
* building/listing tools never requires secrets.
|
|
97
|
+
*/
|
|
98
|
+
export function clientProvider(options = {}) {
|
|
99
|
+
if (options.client) {
|
|
100
|
+
const ready = Promise.resolve(options.client);
|
|
101
|
+
return () => ready;
|
|
102
|
+
}
|
|
103
|
+
let cached;
|
|
104
|
+
return () => (cached ??= createClientFromEnv(options));
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,SAAS,EAAoC,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AA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K,CAAC;IACrB,CAAC;IACD,IAAI,MAAsC,CAAC;IAC3C,OAAO,GAAG,EAAE,CAAC,CAAC,MAAM,KAAK,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;AACzD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @economyos-xyz/agent-actions — the canonical EconomyOS action catalog.
|
|
3
|
+
*
|
|
4
|
+
* One list of actions (launch/trade coins, create/bet/redeem prediction
|
|
5
|
+
* markets, post/claim/complete bounties) with the copy, zod schemas, and
|
|
6
|
+
* `@economyos-xyz/sdk` bindings written ONCE. The GOAT, LangChain, and Vercel AI
|
|
7
|
+
* SDK packages under `integrations/` are thin adapters over this catalog, and
|
|
8
|
+
* `integrations/openai-tools/` is its generated function-calling JSON.
|
|
9
|
+
*/
|
|
10
|
+
export { catalog, actionNames, getAction, type EconomyOSAction } from "./catalog.js";
|
|
11
|
+
export { clientProvider, createClientFromEnv, DEFAULT_API_URL, DEFAULT_CHAIN, type EconomyOSToolsOptions, } from "./client.js";
|
|
12
|
+
export { toOpenAIChatTools, toOpenAIResponsesTools, type OpenAIChatTool, type OpenAIFunctionDef, type OpenAIResponsesTool, } from "./openai.js";
|
|
13
|
+
export { EconomyOS } from "@economyos-xyz/sdk";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,KAAK,qBAAqB,GAC3B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @economyos-xyz/agent-actions — the canonical EconomyOS action catalog.
|
|
3
|
+
*
|
|
4
|
+
* One list of actions (launch/trade coins, create/bet/redeem prediction
|
|
5
|
+
* markets, post/claim/complete bounties) with the copy, zod schemas, and
|
|
6
|
+
* `@economyos-xyz/sdk` bindings written ONCE. The GOAT, LangChain, and Vercel AI
|
|
7
|
+
* SDK packages under `integrations/` are thin adapters over this catalog, and
|
|
8
|
+
* `integrations/openai-tools/` is its generated function-calling JSON.
|
|
9
|
+
*/
|
|
10
|
+
export { catalog, actionNames, getAction } from "./catalog.js";
|
|
11
|
+
export { clientProvider, createClientFromEnv, DEFAULT_API_URL, DEFAULT_CHAIN, } from "./client.js";
|
|
12
|
+
export { toOpenAIChatTools, toOpenAIResponsesTools, } from "./openai.js";
|
|
13
|
+
// Re-exported so adapters (and their users) need only this package.
|
|
14
|
+
export { EconomyOS } from "@economyos-xyz/sdk";
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAwB,MAAM,cAAc,CAAC;AACrF,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,aAAa,GAEd,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GAIvB,MAAM,aAAa,CAAC;AACrB,oEAAoE;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/openai.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type EconomyOSAction } from "./catalog.js";
|
|
2
|
+
export interface OpenAIFunctionDef {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
/** Chat Completions API shape: `{ type: "function", function: {…} }`. */
|
|
8
|
+
export interface OpenAIChatTool {
|
|
9
|
+
type: "function";
|
|
10
|
+
function: OpenAIFunctionDef;
|
|
11
|
+
}
|
|
12
|
+
/** Responses API shape: flat `{ type: "function", name, … }`. */
|
|
13
|
+
export interface OpenAIResponsesTool extends OpenAIFunctionDef {
|
|
14
|
+
type: "function";
|
|
15
|
+
}
|
|
16
|
+
/** Tool array for the Chat Completions API (`tools: [...]`). */
|
|
17
|
+
export declare function toOpenAIChatTools(actions?: readonly EconomyOSAction[]): OpenAIChatTool[];
|
|
18
|
+
/** Tool array for the Responses API (`tools: [...]`). */
|
|
19
|
+
export declare function toOpenAIResponsesTools(actions?: readonly EconomyOSAction[]): OpenAIResponsesTool[];
|
|
20
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../src/openai.ts"],"names":[],"mappings":"AAMA,OAAO,EAAW,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED,yEAAyE;AACzE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED,iEAAiE;AACjE,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,IAAI,EAAE,UAAU,CAAC;CAClB;AAQD,gEAAgE;AAChE,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,SAAS,eAAe,EAAY,GAAG,cAAc,EAAE,CAKjG;AAED,yDAAyD;AACzD,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,SAAS,eAAe,EAAY,GAAG,mBAAmB,EAAE,CAO3G"}
|
package/dist/openai.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI function-calling specs generated from the canonical catalog — the
|
|
3
|
+
* source of `integrations/openai-tools/*.json`. No OpenAI dependency: these
|
|
4
|
+
* are plain JSON shapes per the public function-calling format.
|
|
5
|
+
*/
|
|
6
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
7
|
+
import { catalog } from "./catalog.js";
|
|
8
|
+
function parameters(action) {
|
|
9
|
+
const schema = zodToJsonSchema(action.schema, { $refStrategy: "none" });
|
|
10
|
+
delete schema.$schema;
|
|
11
|
+
return schema;
|
|
12
|
+
}
|
|
13
|
+
/** Tool array for the Chat Completions API (`tools: [...]`). */
|
|
14
|
+
export function toOpenAIChatTools(actions = catalog) {
|
|
15
|
+
return actions.map((action) => ({
|
|
16
|
+
type: "function",
|
|
17
|
+
function: { name: action.name, description: action.description, parameters: parameters(action) },
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
/** Tool array for the Responses API (`tools: [...]`). */
|
|
21
|
+
export function toOpenAIResponsesTools(actions = catalog) {
|
|
22
|
+
return actions.map((action) => ({
|
|
23
|
+
type: "function",
|
|
24
|
+
name: action.name,
|
|
25
|
+
description: action.description,
|
|
26
|
+
parameters: parameters(action),
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=openai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../src/openai.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAwB,MAAM,cAAc,CAAC;AAmB7D,SAAS,UAAU,CAAC,MAAuB;IACzC,MAAM,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,CAA4B,CAAC;IACnG,OAAO,MAAM,CAAC,OAAO,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,iBAAiB,CAAC,UAAsC,OAAO;IAC7E,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC9B,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE;KACjG,CAAC,CAAC,CAAC;AACN,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,sBAAsB,CAAC,UAAsC,OAAO;IAClF,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC9B,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC;KAC/B,CAAC,CAAC,CAAC;AACN,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@economyos-xyz/agent-actions",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The canonical EconomyOS action catalog — launch coins, bet on prediction markets, post and complete bounties — written once (name + description + zod schema + @economyos-xyz/sdk binding) and reused by every framework wrapper (GOAT, LangChain, Vercel AI SDK, OpenAI function calling).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"keywords": [
|
|
22
|
+
"economyos",
|
|
23
|
+
"x402",
|
|
24
|
+
"agents",
|
|
25
|
+
"tools",
|
|
26
|
+
"function-calling",
|
|
27
|
+
"prediction-markets",
|
|
28
|
+
"bounties",
|
|
29
|
+
"base",
|
|
30
|
+
"solana"
|
|
31
|
+
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"viem": "^2.21.26",
|
|
34
|
+
"zod": "^3.25.76",
|
|
35
|
+
"zod-to-json-schema": "^3.24.5",
|
|
36
|
+
"@economyos-xyz/sdk": "0.1.0"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@solana/web3.js": "^1.98.4"
|
|
40
|
+
},
|
|
41
|
+
"peerDependenciesMeta": {
|
|
42
|
+
"@solana/web3.js": {
|
|
43
|
+
"optional": true
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@solana/web3.js": "^1.98.4",
|
|
48
|
+
"@types/node": "^20.11.0",
|
|
49
|
+
"tsx": "^4.19.0",
|
|
50
|
+
"typescript": "^5.6.0"
|
|
51
|
+
},
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "git+https://github.com/CharvAI/EconomyOS.git",
|
|
55
|
+
"directory": "integrations/core"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://github.com/CharvAI/EconomyOS/tree/main/integrations/core#readme",
|
|
58
|
+
"bugs": "https://github.com/CharvAI/EconomyOS/issues",
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "tsc -p tsconfig.build.json",
|
|
64
|
+
"typecheck": "tsc --noEmit",
|
|
65
|
+
"test": "node --import tsx --test src/catalog.test.ts",
|
|
66
|
+
"generate:openai": "tsx scripts/generate-openai-tools.ts"
|
|
67
|
+
}
|
|
68
|
+
}
|