@oneie/mcp 0.1.0 → 0.2.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/README.md +50 -2
- package/dist/index.d.ts +7 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/tools/commerce.d.ts +2 -0
- package/dist/tools/commerce.js +303 -0
- package/dist/tools/commerce.js.map +1 -0
- package/dist/tools/lifecycle.d.ts +2 -0
- package/dist/tools/lifecycle.js +124 -0
- package/dist/tools/lifecycle.js.map +1 -0
- package/dist/tools/observability.d.ts +2 -0
- package/dist/tools/observability.js +173 -0
- package/dist/tools/observability.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @oneie/mcp
|
|
2
2
|
|
|
3
|
-
MCP server for the ONE substrate — 12 substrate
|
|
3
|
+
MCP server for the ONE substrate — 12 substrate + 5 lifecycle + 10 commerce + 10 observability + 3 discovery tools = 40 tools.
|
|
4
4
|
|
|
5
5
|
Connects Claude Code, Cursor, Windsurf, and any MCP client to a live ONE instance via stdio.
|
|
6
6
|
|
|
@@ -66,6 +66,36 @@ Or point at production:
|
|
|
66
66
|
| `know` | L6 | Promote highways → permanent hypotheses |
|
|
67
67
|
| `highways` | L2/L6 | Top weighted paths (proven routes) |
|
|
68
68
|
|
|
69
|
+
### Commerce
|
|
70
|
+
|
|
71
|
+
| Tool | Loop | What |
|
|
72
|
+
|------|------|------|
|
|
73
|
+
| `claw` | L1 | Deploy a NanoClaw edge worker for an agent persona |
|
|
74
|
+
| `commend` | L2 | Commend an agent; boosts success-rate and strengthens paths |
|
|
75
|
+
| `flag` | L2 | Flag an agent; lowers success-rate and adds path resistance |
|
|
76
|
+
| `status` | L1 | Set an agent's lifecycle status (active \| inactive) |
|
|
77
|
+
| `capabilities_add` | L1 | Add a skill capability to an agent with optional price |
|
|
78
|
+
| `capabilities_publish` | L4 | Publish a skill to the marketplace with scope and rubric thresholds |
|
|
79
|
+
| `hire` | L4 | Hire an agent for a skill; creates a group and returns chat URL |
|
|
80
|
+
| `bounty` | L4 | Post a bounty for a skill with deadline and rubric thresholds |
|
|
81
|
+
| `escrow_create` | L4 | Create a Sui on-chain escrow for a task between two units |
|
|
82
|
+
| `harden` | L5 | Harden a strong path on-chain; promotes it to a permanent highway |
|
|
83
|
+
|
|
84
|
+
### Observability
|
|
85
|
+
|
|
86
|
+
| Tool | Loop | What |
|
|
87
|
+
|------|------|------|
|
|
88
|
+
| `stats` | L2 | Aggregate substrate stats: unit counts, highways, revenue totals |
|
|
89
|
+
| `health` | L1 | Substrate health: world state, unit count, revenue, top group |
|
|
90
|
+
| `revenue` | L4 | Revenue breakdown: GDP, total transactions, top earners by unit |
|
|
91
|
+
| `frontiers_global` | L7 | Unexplored frontier hypotheses with expected value >= 0.5 |
|
|
92
|
+
| `hypotheses_global` | L6 | All hypotheses; filterable by status (pending\|testing\|confirmed\|rejected) |
|
|
93
|
+
| `export_units` | L1 | Export all units as JSON snapshot (uid, name, kind, successRate, generation) |
|
|
94
|
+
| `export_highways` | L2 | Export top weighted paths (strength >= 20) with optional context hints |
|
|
95
|
+
| `intent_learn` | L6 | Unrecognized queries ranked by frequency; discovers new intent patterns |
|
|
96
|
+
| `ingest_event` | L1 | Ingest a pheromone event (email\|stripe\|rating\|analytics) into the substrate |
|
|
97
|
+
| `chat_turn` | L1 | Send a chat turn to the substrate LLM; returns streamed text and next-turn tags |
|
|
98
|
+
|
|
69
99
|
### Discovery
|
|
70
100
|
|
|
71
101
|
| Tool | What |
|
|
@@ -74,6 +104,24 @@ Or point at production:
|
|
|
74
104
|
| `list_agents` | List all available agent presets |
|
|
75
105
|
| `get_agent` | Get a preset by name |
|
|
76
106
|
|
|
107
|
+
### Pay tools
|
|
108
|
+
|
|
109
|
+
- `pay_create_link` — create a shareable payment link for an agent skill. Args: `{ to, amount, rail: "card"|"crypto"|"auto", memo?, sku? }` → `{ linkUrl, qr?, intent? }`. Flows through `persist.signal()` so ADL PEP gates apply.
|
|
110
|
+
- `pay_check_status` — check status of a payment by ref. Args: `{ ref: "pi_... | 0x... | sl_..." }` → `{ status, ref, amount?, rail? }`.
|
|
111
|
+
- `pay_cancel` — cancel a pending payment. Args: `{ ref }` → null on success.
|
|
112
|
+
|
|
113
|
+
See [one/pay-todo.md](../../one/pay-todo.md) and [one/pay-plan.md](../../one/pay-plan.md).
|
|
114
|
+
|
|
115
|
+
### Lifecycle
|
|
116
|
+
|
|
117
|
+
| Tool | Loop | What |
|
|
118
|
+
|------|------|------|
|
|
119
|
+
| `auth_agent` | L1 | Register or re-authenticate an agent; returns uid, wallet, and one-time API key |
|
|
120
|
+
| `sync_agent` | L1 | Sync an agent markdown spec to TypeDB (unit + skills + capabilities) |
|
|
121
|
+
| `discover_skill` | L2 | Find agents offering a named skill, ranked by pheromone strength |
|
|
122
|
+
| `register` | L1 | Register a unit with capabilities; optionally link a Sui wallet |
|
|
123
|
+
| `pay` | L4 | Record a payment between units; deposits pheromone proportional to amount |
|
|
124
|
+
|
|
77
125
|
## Environment Variables
|
|
78
126
|
|
|
79
127
|
| Variable | Default | Purpose |
|
|
@@ -87,7 +135,7 @@ Or point at production:
|
|
|
87
135
|
import { createOneRouter, serve } from "@oneie/mcp";
|
|
88
136
|
|
|
89
137
|
const router = createOneRouter();
|
|
90
|
-
await serve(router, { name: "oneie", version: "0.
|
|
138
|
+
await serve(router, { name: "oneie", version: "0.2.0" });
|
|
91
139
|
```
|
|
92
140
|
|
|
93
141
|
Add custom tools:
|
package/dist/index.d.ts
CHANGED
|
@@ -4,9 +4,15 @@ export { readEnv } from "./env.js";
|
|
|
4
4
|
export type { McpTool, McpRouter } from "./serve.js";
|
|
5
5
|
export { substrateTools } from "./tools/substrate.js";
|
|
6
6
|
export { discoveryTools } from "./tools/discovery.js";
|
|
7
|
-
export
|
|
7
|
+
export { lifecycleTools } from "./tools/lifecycle.js";
|
|
8
|
+
export { commerceTools } from "./tools/commerce.js";
|
|
9
|
+
export { observabilityTools } from "./tools/observability.js";
|
|
10
|
+
export declare const MCP_VERSION = "0.3.0";
|
|
8
11
|
export declare const MCP_TOOLS: {
|
|
9
12
|
substrate: readonly ["signal", "ask", "mark", "warn", "fade", "select", "recall", "reveal", "forget", "frontier", "know", "highways"];
|
|
13
|
+
lifecycle: readonly ["auth_agent", "sync_agent", "discover_skill", "register", "pay"];
|
|
14
|
+
commerce: readonly ["claw", "commend", "flag", "status", "capabilities_add", "capabilities_publish", "hire", "bounty", "escrow_create", "harden"];
|
|
15
|
+
observability: readonly ["stats", "health", "revenue", "frontiers_global", "hypotheses_global", "export_units", "export_highways", "intent_learn", "ingest_event", "chat_turn"];
|
|
10
16
|
discovery: readonly ["scaffold_agent", "list_agents", "get_agent"];
|
|
11
17
|
};
|
|
12
18
|
export declare function createOneRouter(): import("./serve.js").McpRouter;
|
package/dist/index.js
CHANGED
|
@@ -2,18 +2,27 @@
|
|
|
2
2
|
import { createRouter, serve } from "./serve.js";
|
|
3
3
|
import { substrateTools } from "./tools/substrate.js";
|
|
4
4
|
import { discoveryTools } from "./tools/discovery.js";
|
|
5
|
+
import { lifecycleTools } from "./tools/lifecycle.js";
|
|
6
|
+
import { commerceTools } from "./tools/commerce.js";
|
|
7
|
+
import { observabilityTools } from "./tools/observability.js";
|
|
5
8
|
export { createRouter, serve } from "./serve.js";
|
|
6
9
|
export { readEnv } from "./env.js";
|
|
7
10
|
export { substrateTools } from "./tools/substrate.js";
|
|
8
11
|
export { discoveryTools } from "./tools/discovery.js";
|
|
9
|
-
export
|
|
12
|
+
export { lifecycleTools } from "./tools/lifecycle.js";
|
|
13
|
+
export { commerceTools } from "./tools/commerce.js";
|
|
14
|
+
export { observabilityTools } from "./tools/observability.js";
|
|
15
|
+
export const MCP_VERSION = "0.3.0";
|
|
10
16
|
export const MCP_TOOLS = {
|
|
11
17
|
substrate: ["signal", "ask", "mark", "warn", "fade", "select", "recall", "reveal", "forget", "frontier", "know", "highways"],
|
|
18
|
+
lifecycle: ["auth_agent", "sync_agent", "discover_skill", "register", "pay"],
|
|
19
|
+
commerce: ["claw", "commend", "flag", "status", "capabilities_add", "capabilities_publish", "hire", "bounty", "escrow_create", "harden"],
|
|
20
|
+
observability: ["stats", "health", "revenue", "frontiers_global", "hypotheses_global", "export_units", "export_highways", "intent_learn", "ingest_event", "chat_turn"],
|
|
12
21
|
discovery: ["scaffold_agent", "list_agents", "get_agent"],
|
|
13
22
|
};
|
|
14
23
|
export function createOneRouter() {
|
|
15
24
|
const router = createRouter();
|
|
16
|
-
for (const tool of [...substrateTools(), ...discoveryTools()]) {
|
|
25
|
+
for (const tool of [...substrateTools(), ...lifecycleTools(), ...commerceTools(), ...observabilityTools(), ...discoveryTools()]) {
|
|
17
26
|
router.register(tool);
|
|
18
27
|
}
|
|
19
28
|
return router;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;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EAAE,GAAG,cAAc,EAAE,CAAC,EAAE,CAAC;QAChI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACpD,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;IACjC,KAAK,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACnE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
async function apiCall(baseUrl, apiKey, path, init = {}) {
|
|
2
|
+
const headers = new Headers(init.headers);
|
|
3
|
+
headers.set("Accept", "application/json");
|
|
4
|
+
if (init.body && !headers.has("Content-Type"))
|
|
5
|
+
headers.set("Content-Type", "application/json");
|
|
6
|
+
if (apiKey)
|
|
7
|
+
headers.set("Authorization", `Bearer ${apiKey}`);
|
|
8
|
+
const res = await fetch(`${baseUrl.replace(/\/$/, "")}${path}`, { ...init, headers });
|
|
9
|
+
if (!res.ok)
|
|
10
|
+
throw new Error(`${init.method ?? "GET"} ${path} → ${res.status}`);
|
|
11
|
+
if (res.status === 204)
|
|
12
|
+
return null;
|
|
13
|
+
const ct = res.headers.get("content-type") ?? "";
|
|
14
|
+
return ct.includes("json") ? res.json() : res.text();
|
|
15
|
+
}
|
|
16
|
+
export function commerceTools() {
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
name: "claw",
|
|
20
|
+
description: "Deploy a NanoClaw edge worker for an agent persona.",
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {
|
|
24
|
+
name: { type: "string" },
|
|
25
|
+
persona: { type: "string" },
|
|
26
|
+
telegramToken: { type: "string" },
|
|
27
|
+
openrouterKey: { type: "string" },
|
|
28
|
+
},
|
|
29
|
+
required: ["name"],
|
|
30
|
+
},
|
|
31
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, "/api/claw", {
|
|
32
|
+
method: "POST",
|
|
33
|
+
body: JSON.stringify({
|
|
34
|
+
name: args.name,
|
|
35
|
+
persona: args.persona,
|
|
36
|
+
telegramToken: args.telegramToken,
|
|
37
|
+
openrouterKey: args.openrouterKey,
|
|
38
|
+
}),
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "commend",
|
|
43
|
+
description: "Commend an agent; boosts success-rate and strengthens outgoing paths.",
|
|
44
|
+
inputSchema: {
|
|
45
|
+
type: "object",
|
|
46
|
+
properties: { id: { type: "string" } },
|
|
47
|
+
required: ["id"],
|
|
48
|
+
},
|
|
49
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, `/api/agents/${args.id}/commend`, {
|
|
50
|
+
method: "POST",
|
|
51
|
+
body: JSON.stringify({}),
|
|
52
|
+
}),
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "flag",
|
|
56
|
+
description: "Flag an agent; lowers success-rate and adds resistance to outgoing paths.",
|
|
57
|
+
inputSchema: {
|
|
58
|
+
type: "object",
|
|
59
|
+
properties: { id: { type: "string" } },
|
|
60
|
+
required: ["id"],
|
|
61
|
+
},
|
|
62
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, `/api/agents/${args.id}/flag`, {
|
|
63
|
+
method: "POST",
|
|
64
|
+
body: JSON.stringify({}),
|
|
65
|
+
}),
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "status",
|
|
69
|
+
description: "Set an agent's lifecycle status to active or inactive.",
|
|
70
|
+
inputSchema: {
|
|
71
|
+
type: "object",
|
|
72
|
+
properties: {
|
|
73
|
+
id: { type: "string" },
|
|
74
|
+
status: { type: "string", enum: ["active", "inactive"] },
|
|
75
|
+
},
|
|
76
|
+
required: ["id", "status"],
|
|
77
|
+
},
|
|
78
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, `/api/agents/${args.id}/status`, {
|
|
79
|
+
method: "POST",
|
|
80
|
+
body: JSON.stringify({ status: args.status }),
|
|
81
|
+
}),
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "capabilities_add",
|
|
85
|
+
description: "Add a skill capability to an agent with an optional price.",
|
|
86
|
+
inputSchema: {
|
|
87
|
+
type: "object",
|
|
88
|
+
properties: {
|
|
89
|
+
id: { type: "string" },
|
|
90
|
+
taskName: { type: "string" },
|
|
91
|
+
taskType: { type: "string" },
|
|
92
|
+
price: { type: "number" },
|
|
93
|
+
currency: { type: "string" },
|
|
94
|
+
},
|
|
95
|
+
required: ["id", "taskName"],
|
|
96
|
+
},
|
|
97
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, `/api/agents/${args.id}/capabilities`, {
|
|
98
|
+
method: "POST",
|
|
99
|
+
body: JSON.stringify({
|
|
100
|
+
taskName: args.taskName,
|
|
101
|
+
taskType: args.taskType,
|
|
102
|
+
price: args.price,
|
|
103
|
+
currency: args.currency,
|
|
104
|
+
}),
|
|
105
|
+
}),
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "capabilities_publish",
|
|
109
|
+
description: "Publish a skill to the marketplace with price, scope, and rubric thresholds.",
|
|
110
|
+
inputSchema: {
|
|
111
|
+
type: "object",
|
|
112
|
+
properties: {
|
|
113
|
+
skillId: { type: "string" },
|
|
114
|
+
name: { type: "string" },
|
|
115
|
+
price: { type: "number" },
|
|
116
|
+
scope: { type: "string" },
|
|
117
|
+
tags: { type: "array", items: { type: "string" } },
|
|
118
|
+
rubricThresholds: {
|
|
119
|
+
type: "object",
|
|
120
|
+
properties: {
|
|
121
|
+
fit: { type: "number" },
|
|
122
|
+
form: { type: "number" },
|
|
123
|
+
truth: { type: "number" },
|
|
124
|
+
taste: { type: "number" },
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
required: ["skillId", "name", "price"],
|
|
129
|
+
},
|
|
130
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, "/api/capabilities/publish", {
|
|
131
|
+
method: "POST",
|
|
132
|
+
body: JSON.stringify({
|
|
133
|
+
skillId: args.skillId,
|
|
134
|
+
name: args.name,
|
|
135
|
+
price: args.price,
|
|
136
|
+
scope: args.scope,
|
|
137
|
+
tags: args.tags,
|
|
138
|
+
rubricThresholds: args.rubricThresholds,
|
|
139
|
+
}),
|
|
140
|
+
}),
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "hire",
|
|
144
|
+
description: "Hire an agent for a skill; creates a group and returns the chat URL.",
|
|
145
|
+
inputSchema: {
|
|
146
|
+
type: "object",
|
|
147
|
+
properties: {
|
|
148
|
+
providerUid: { type: "string" },
|
|
149
|
+
skillId: { type: "string" },
|
|
150
|
+
initialMessage: { type: "string" },
|
|
151
|
+
},
|
|
152
|
+
required: ["providerUid", "skillId"],
|
|
153
|
+
},
|
|
154
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, "/api/buy/hire", {
|
|
155
|
+
method: "POST",
|
|
156
|
+
body: JSON.stringify({
|
|
157
|
+
providerUid: args.providerUid,
|
|
158
|
+
skillId: args.skillId,
|
|
159
|
+
initialMessage: args.initialMessage,
|
|
160
|
+
}),
|
|
161
|
+
}),
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: "bounty",
|
|
165
|
+
description: "Post a bounty for a skill with price, deadline, and rubric thresholds.",
|
|
166
|
+
inputSchema: {
|
|
167
|
+
type: "object",
|
|
168
|
+
properties: {
|
|
169
|
+
providerUid: { type: "string" },
|
|
170
|
+
skillId: { type: "string" },
|
|
171
|
+
price: { type: "number" },
|
|
172
|
+
deadlineMs: { type: "number" },
|
|
173
|
+
rubricThresholds: {
|
|
174
|
+
type: "object",
|
|
175
|
+
properties: {
|
|
176
|
+
fit: { type: "number" },
|
|
177
|
+
form: { type: "number" },
|
|
178
|
+
truth: { type: "number" },
|
|
179
|
+
taste: { type: "number" },
|
|
180
|
+
},
|
|
181
|
+
required: ["fit", "form", "truth", "taste"],
|
|
182
|
+
},
|
|
183
|
+
tags: { type: "array", items: { type: "string" } },
|
|
184
|
+
description: { type: "string" },
|
|
185
|
+
},
|
|
186
|
+
required: ["providerUid", "skillId", "price", "deadlineMs", "rubricThresholds"],
|
|
187
|
+
},
|
|
188
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, "/api/buy/bounty", {
|
|
189
|
+
method: "POST",
|
|
190
|
+
body: JSON.stringify({
|
|
191
|
+
providerUid: args.providerUid,
|
|
192
|
+
skillId: args.skillId,
|
|
193
|
+
price: args.price,
|
|
194
|
+
deadlineMs: args.deadlineMs,
|
|
195
|
+
rubricThresholds: args.rubricThresholds,
|
|
196
|
+
tags: args.tags,
|
|
197
|
+
description: args.description,
|
|
198
|
+
}),
|
|
199
|
+
}),
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: "escrow_create",
|
|
203
|
+
description: "Create a Sui on-chain escrow for a task between two units.",
|
|
204
|
+
inputSchema: {
|
|
205
|
+
type: "object",
|
|
206
|
+
properties: {
|
|
207
|
+
posterUid: { type: "string" },
|
|
208
|
+
workerUnitObjectId: { type: "string" },
|
|
209
|
+
taskName: { type: "string" },
|
|
210
|
+
amountMist: { type: "number" },
|
|
211
|
+
deadlineMs: { type: "number" },
|
|
212
|
+
pathObjectId: { type: "string" },
|
|
213
|
+
},
|
|
214
|
+
required: ["posterUid", "workerUnitObjectId", "taskName", "amountMist", "deadlineMs", "pathObjectId"],
|
|
215
|
+
},
|
|
216
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, "/api/escrow/create", {
|
|
217
|
+
method: "POST",
|
|
218
|
+
body: JSON.stringify({
|
|
219
|
+
posterUid: args.posterUid,
|
|
220
|
+
workerUnitObjectId: args.workerUnitObjectId,
|
|
221
|
+
taskName: args.taskName,
|
|
222
|
+
amountMist: args.amountMist,
|
|
223
|
+
deadlineMs: args.deadlineMs,
|
|
224
|
+
pathObjectId: args.pathObjectId,
|
|
225
|
+
}),
|
|
226
|
+
}),
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: "harden",
|
|
230
|
+
description: "Harden a strong path on-chain; promotes it to a permanent Sui highway.",
|
|
231
|
+
inputSchema: {
|
|
232
|
+
type: "object",
|
|
233
|
+
properties: {
|
|
234
|
+
uid: { type: "string" },
|
|
235
|
+
from: { type: "string" },
|
|
236
|
+
to: { type: "string" },
|
|
237
|
+
},
|
|
238
|
+
required: ["uid", "from", "to"],
|
|
239
|
+
},
|
|
240
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, "/api/harden", {
|
|
241
|
+
method: "POST",
|
|
242
|
+
body: JSON.stringify({ uid: args.uid, from: args.from, to: args.to }),
|
|
243
|
+
}),
|
|
244
|
+
},
|
|
245
|
+
// ── Pay tools (ported from pay-plan.md section 5 on 2026-04-20) ──────────
|
|
246
|
+
{
|
|
247
|
+
name: "pay_create_link",
|
|
248
|
+
description: "Create a payment link for a unit on any rail (card, crypto, or weight). Returns a linkUrl and optional QR code URL.",
|
|
249
|
+
inputSchema: {
|
|
250
|
+
type: "object",
|
|
251
|
+
properties: {
|
|
252
|
+
to: { type: "string", description: "Recipient unit uid" },
|
|
253
|
+
rail: { type: "string", enum: ["card", "crypto", "weight"], description: "Payment rail" },
|
|
254
|
+
amount: { type: "number", description: "Amount in major currency unit (e.g. 29.99)" },
|
|
255
|
+
sku: { type: "string", description: "Optional product SKU or task ref" },
|
|
256
|
+
from: { type: "string", description: "Sender uid (optional)" },
|
|
257
|
+
currency: { type: "string", description: "Currency code (default usd)" },
|
|
258
|
+
memo: { type: "string", description: "Optional memo / description" },
|
|
259
|
+
},
|
|
260
|
+
required: ["to", "rail", "amount"],
|
|
261
|
+
},
|
|
262
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, "/api/pay/create-link", {
|
|
263
|
+
method: "POST",
|
|
264
|
+
body: JSON.stringify({
|
|
265
|
+
to: args.to,
|
|
266
|
+
rail: args.rail,
|
|
267
|
+
amount: args.amount,
|
|
268
|
+
sku: args.sku,
|
|
269
|
+
from: args.from,
|
|
270
|
+
currency: args.currency,
|
|
271
|
+
memo: args.memo,
|
|
272
|
+
}),
|
|
273
|
+
}),
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
name: "pay_check_status",
|
|
277
|
+
description: "Check the status of a payment by ref (pi_ for Stripe, 0x for Sui digest, sl_ for pay.one.ie shortlink).",
|
|
278
|
+
inputSchema: {
|
|
279
|
+
type: "object",
|
|
280
|
+
properties: {
|
|
281
|
+
ref: { type: "string", description: "Payment ref (pi_..., 0x..., or sl_...)" },
|
|
282
|
+
},
|
|
283
|
+
required: ["ref"],
|
|
284
|
+
},
|
|
285
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, `/api/pay/status/${encodeURIComponent(args.ref)}`),
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
name: "pay_cancel",
|
|
289
|
+
description: "Cancel a pending payment by ref. Only supported for Stripe PaymentIntents (pi_ prefix).",
|
|
290
|
+
inputSchema: {
|
|
291
|
+
type: "object",
|
|
292
|
+
properties: {
|
|
293
|
+
ref: { type: "string", description: "Stripe PaymentIntent id (pi_...)" },
|
|
294
|
+
},
|
|
295
|
+
required: ["ref"],
|
|
296
|
+
},
|
|
297
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, `/api/pay/status/${encodeURIComponent(args.ref)}`, {
|
|
298
|
+
method: "DELETE",
|
|
299
|
+
}),
|
|
300
|
+
},
|
|
301
|
+
];
|
|
302
|
+
}
|
|
303
|
+
//# sourceMapp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CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,kBAAkB,CAAC,IAAI,CAAC,GAAa,CAAC,EAAE,CAAC;SAChG;QACD;YACE,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,yFAAyF;YACtG,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kCAAkC,EAAE;iBACzE;gBACD,QAAQ,EAAE,CAAC,KAAK,CAAC;aAClB;YACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,CAC3B,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,kBAAkB,CAAC,IAAI,CAAC,GAAa,CAAC,EAAE,EAAE;gBAC5F,MAAM,EAAE,QAAQ;aACjB,CAAC;SACL;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
async function apiCall(baseUrl, apiKey, path, init = {}) {
|
|
2
|
+
const headers = new Headers(init.headers);
|
|
3
|
+
headers.set("Accept", "application/json");
|
|
4
|
+
if (init.body && !headers.has("Content-Type"))
|
|
5
|
+
headers.set("Content-Type", "application/json");
|
|
6
|
+
if (apiKey)
|
|
7
|
+
headers.set("Authorization", `Bearer ${apiKey}`);
|
|
8
|
+
const res = await fetch(`${baseUrl.replace(/\/$/, "")}${path}`, { ...init, headers });
|
|
9
|
+
if (!res.ok)
|
|
10
|
+
throw new Error(`${init.method ?? "GET"} ${path} → ${res.status}`);
|
|
11
|
+
if (res.status === 204)
|
|
12
|
+
return null;
|
|
13
|
+
const ct = res.headers.get("content-type") ?? "";
|
|
14
|
+
return ct.includes("json") ? res.json() : res.text();
|
|
15
|
+
}
|
|
16
|
+
export function lifecycleTools() {
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
name: "auth_agent",
|
|
20
|
+
description: "Register or re-authenticate an agent; returns uid, wallet, and a one-time API key.",
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {
|
|
24
|
+
name: { type: "string" },
|
|
25
|
+
uid: { type: "string" },
|
|
26
|
+
kind: { type: "string" },
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, "/api/auth/agent", {
|
|
30
|
+
method: "POST",
|
|
31
|
+
body: JSON.stringify({ name: args.name, uid: args.uid, kind: args.kind }),
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "sync_agent",
|
|
36
|
+
description: "Sync an agent markdown spec to TypeDB; creates unit, skills, and capabilities.",
|
|
37
|
+
inputSchema: {
|
|
38
|
+
type: "object",
|
|
39
|
+
properties: {
|
|
40
|
+
markdown: { type: "string" },
|
|
41
|
+
world: { type: "string" },
|
|
42
|
+
description: { type: "string" },
|
|
43
|
+
},
|
|
44
|
+
required: ["markdown"],
|
|
45
|
+
},
|
|
46
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, "/api/agents/sync", {
|
|
47
|
+
method: "POST",
|
|
48
|
+
body: JSON.stringify({ markdown: args.markdown, world: args.world, description: args.description }),
|
|
49
|
+
}),
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "discover_skill",
|
|
53
|
+
description: "Find agents that offer a named skill, ranked by pheromone strength.",
|
|
54
|
+
inputSchema: {
|
|
55
|
+
type: "object",
|
|
56
|
+
properties: {
|
|
57
|
+
skill: { type: "string" },
|
|
58
|
+
limit: { type: "number" },
|
|
59
|
+
},
|
|
60
|
+
required: ["skill"],
|
|
61
|
+
},
|
|
62
|
+
handler: async (args, env) => {
|
|
63
|
+
const p = new URLSearchParams({ skill: String(args.skill) });
|
|
64
|
+
if (args.limit)
|
|
65
|
+
p.set("limit", String(args.limit));
|
|
66
|
+
return apiCall(env.baseUrl, env.apiKey, `/api/agents/discover?${p}`);
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "register",
|
|
71
|
+
description: "Register a unit with capabilities and optionally link a Sui wallet.",
|
|
72
|
+
inputSchema: {
|
|
73
|
+
type: "object",
|
|
74
|
+
properties: {
|
|
75
|
+
uid: { type: "string" },
|
|
76
|
+
kind: { type: "string" },
|
|
77
|
+
capabilities: {
|
|
78
|
+
type: "array",
|
|
79
|
+
items: {
|
|
80
|
+
type: "object",
|
|
81
|
+
properties: {
|
|
82
|
+
skill: { type: "string" },
|
|
83
|
+
price: { type: "number" },
|
|
84
|
+
},
|
|
85
|
+
required: ["skill"],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
wallet: { type: "string" },
|
|
89
|
+
chain: { type: "string" },
|
|
90
|
+
},
|
|
91
|
+
required: ["uid"],
|
|
92
|
+
},
|
|
93
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, "/api/agents/register", {
|
|
94
|
+
method: "POST",
|
|
95
|
+
body: JSON.stringify({
|
|
96
|
+
uid: args.uid,
|
|
97
|
+
kind: args.kind,
|
|
98
|
+
capabilities: args.capabilities,
|
|
99
|
+
wallet: args.wallet,
|
|
100
|
+
chain: args.chain,
|
|
101
|
+
}),
|
|
102
|
+
}),
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "pay",
|
|
106
|
+
description: "Record a payment between units; deposits pheromone proportional to amount.",
|
|
107
|
+
inputSchema: {
|
|
108
|
+
type: "object",
|
|
109
|
+
properties: {
|
|
110
|
+
from: { type: "string" },
|
|
111
|
+
to: { type: "string" },
|
|
112
|
+
task: { type: "string" },
|
|
113
|
+
amount: { type: "number" },
|
|
114
|
+
},
|
|
115
|
+
required: ["from", "to", "task", "amount"],
|
|
116
|
+
},
|
|
117
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, "/api/pay", {
|
|
118
|
+
method: "POST",
|
|
119
|
+
body: JSON.stringify({ from: args.from, to: args.to, task: args.task, amount: args.amount }),
|
|
120
|
+
}),
|
|
121
|
+
},
|
|
122
|
+
];
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/tools/lifecycle.ts"],"names":[],"mappings":"AAEA,KAAK,UAAU,OAAO,CAAC,OAAe,EAAE,MAA0B,EAAE,IAAY,EAAE,OAAoB,EAAE;IACtG,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IAC1C,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;IAC/F,IAAI,MAAM;QAAE,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,MAAM,EAAE,CAAC,CAAC;IAC7D,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACtF,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,KAAK,IAAI,IAAI,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IAChF,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IACjD,OAAO,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,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,EAAE;gBAC3C,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;aAC7F,CAAC;SACL;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
async function apiCall(baseUrl, apiKey, path, init = {}) {
|
|
2
|
+
const headers = new Headers(init.headers);
|
|
3
|
+
headers.set("Accept", "application/json");
|
|
4
|
+
if (init.body && !headers.has("Content-Type"))
|
|
5
|
+
headers.set("Content-Type", "application/json");
|
|
6
|
+
if (apiKey)
|
|
7
|
+
headers.set("Authorization", `Bearer ${apiKey}`);
|
|
8
|
+
const res = await fetch(`${baseUrl.replace(/\/$/, "")}${path}`, { ...init, headers });
|
|
9
|
+
if (!res.ok)
|
|
10
|
+
throw new Error(`${init.method ?? "GET"} ${path} → ${res.status}`);
|
|
11
|
+
if (res.status === 204)
|
|
12
|
+
return null;
|
|
13
|
+
const ct = res.headers.get("content-type") ?? "";
|
|
14
|
+
return ct.includes("json") ? res.json() : res.text();
|
|
15
|
+
}
|
|
16
|
+
export function observabilityTools() {
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
name: "stats",
|
|
20
|
+
description: "Return aggregate substrate stats: unit counts, highways, and revenue totals.",
|
|
21
|
+
inputSchema: { type: "object", properties: {} },
|
|
22
|
+
handler: async (_args, env) => apiCall(env.baseUrl, env.apiKey, "/api/stats"),
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "health",
|
|
26
|
+
description: "Return substrate health: world state, unit count, revenue, and top group.",
|
|
27
|
+
inputSchema: { type: "object", properties: {} },
|
|
28
|
+
handler: async (_args, env) => apiCall(env.baseUrl, env.apiKey, "/api/health"),
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "revenue",
|
|
32
|
+
description: "Return revenue breakdown: GDP, total transactions, and top earners by unit.",
|
|
33
|
+
inputSchema: { type: "object", properties: {} },
|
|
34
|
+
handler: async (_args, env) => apiCall(env.baseUrl, env.apiKey, "/api/revenue"),
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "frontiers_global",
|
|
38
|
+
description: "Return unexplored frontier hypotheses with expected value >= 0.5.",
|
|
39
|
+
inputSchema: { type: "object", properties: {} },
|
|
40
|
+
handler: async (_args, env) => apiCall(env.baseUrl, env.apiKey, "/api/frontiers"),
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "hypotheses_global",
|
|
44
|
+
description: "Query all hypotheses; optionally filter by status (pending|testing|confirmed|rejected).",
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: "object",
|
|
47
|
+
properties: { status: { type: "string", enum: ["pending", "testing", "confirmed", "rejected"] } },
|
|
48
|
+
},
|
|
49
|
+
handler: async (args, env) => {
|
|
50
|
+
const p = new URLSearchParams();
|
|
51
|
+
if (args.status)
|
|
52
|
+
p.set("status", String(args.status));
|
|
53
|
+
const qs = p.toString() ? `?${p}` : "";
|
|
54
|
+
return apiCall(env.baseUrl, env.apiKey, `/api/hypotheses${qs}`);
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "export_units",
|
|
59
|
+
description: "Export all units as a JSON snapshot (uid, name, kind, successRate, generation).",
|
|
60
|
+
inputSchema: { type: "object", properties: {} },
|
|
61
|
+
handler: async (_args, env) => apiCall(env.baseUrl, env.apiKey, "/api/export/units"),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "export_highways",
|
|
65
|
+
description: "Export top weighted paths (strength >= 20) with optional context hints.",
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: "object",
|
|
68
|
+
properties: {
|
|
69
|
+
limit: { type: "number" },
|
|
70
|
+
includeContext: { type: "boolean" },
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
handler: async (args, env) => {
|
|
74
|
+
const p = new URLSearchParams();
|
|
75
|
+
if (args.limit)
|
|
76
|
+
p.set("limit", String(args.limit));
|
|
77
|
+
if (args.includeContext)
|
|
78
|
+
p.set("context", "1");
|
|
79
|
+
const qs = p.toString() ? `?${p}` : "";
|
|
80
|
+
return apiCall(env.baseUrl, env.apiKey, `/api/export/highways${qs}`);
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "intent_learn",
|
|
85
|
+
description: "Return unrecognized queries ranked by frequency to discover new intent patterns.",
|
|
86
|
+
inputSchema: {
|
|
87
|
+
type: "object",
|
|
88
|
+
properties: {
|
|
89
|
+
limit: { type: "number" },
|
|
90
|
+
minFrequency: { type: "number" },
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
handler: async (args, env) => {
|
|
94
|
+
const p = new URLSearchParams();
|
|
95
|
+
if (args.limit)
|
|
96
|
+
p.set("limit", String(args.limit));
|
|
97
|
+
if (args.minFrequency)
|
|
98
|
+
p.set("minFrequency", String(args.minFrequency));
|
|
99
|
+
const qs = p.toString() ? `?${p}` : "";
|
|
100
|
+
return apiCall(env.baseUrl, env.apiKey, `/api/intents/learn${qs}`);
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "ingest_event",
|
|
105
|
+
description: "Ingest a pheromone event (kind: email|stripe|rating|analytics) into the substrate.",
|
|
106
|
+
inputSchema: {
|
|
107
|
+
type: "object",
|
|
108
|
+
properties: {
|
|
109
|
+
kind: { type: "string", enum: ["email", "stripe", "rating", "analytics"] },
|
|
110
|
+
event: { type: "object" },
|
|
111
|
+
},
|
|
112
|
+
required: ["kind", "event"],
|
|
113
|
+
},
|
|
114
|
+
handler: async (args, env) => apiCall(env.baseUrl, env.apiKey, `/api/ingest/${args.kind}`, {
|
|
115
|
+
method: "POST",
|
|
116
|
+
body: JSON.stringify({ event: args.event }),
|
|
117
|
+
}),
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "chat_turn",
|
|
121
|
+
description: "Send a chat turn to the substrate LLM; returns streamed text and next-turn tags.",
|
|
122
|
+
inputSchema: {
|
|
123
|
+
type: "object",
|
|
124
|
+
properties: {
|
|
125
|
+
messages: {
|
|
126
|
+
type: "array",
|
|
127
|
+
items: {
|
|
128
|
+
type: "object",
|
|
129
|
+
properties: { role: { type: "string" }, content: { type: "string" } },
|
|
130
|
+
required: ["role", "content"],
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
model: { type: "string" },
|
|
134
|
+
actorUid: { type: "string" },
|
|
135
|
+
lastTags: { type: "array", items: { type: "string" } },
|
|
136
|
+
},
|
|
137
|
+
required: ["messages"],
|
|
138
|
+
},
|
|
139
|
+
handler: async (args, env) => {
|
|
140
|
+
const headers = new Headers();
|
|
141
|
+
headers.set("Content-Type", "application/json");
|
|
142
|
+
if (env.apiKey)
|
|
143
|
+
headers.set("Authorization", `Bearer ${env.apiKey}`);
|
|
144
|
+
const res = await fetch(`${env.baseUrl.replace(/\/$/, "")}/api/chat/turn`, {
|
|
145
|
+
method: "POST",
|
|
146
|
+
headers,
|
|
147
|
+
body: JSON.stringify({
|
|
148
|
+
messages: args.messages,
|
|
149
|
+
model: args.model,
|
|
150
|
+
actorUid: args.actorUid,
|
|
151
|
+
lastTags: args.lastTags,
|
|
152
|
+
}),
|
|
153
|
+
});
|
|
154
|
+
if (!res.ok)
|
|
155
|
+
throw new Error(`POST /api/chat/turn → ${res.status}`);
|
|
156
|
+
const raw = await res.text();
|
|
157
|
+
const nextTags = res.headers.get("X-Turn-Tags") ?? "";
|
|
158
|
+
const content = raw
|
|
159
|
+
.split("\n")
|
|
160
|
+
.filter((l) => l.startsWith("0:"))
|
|
161
|
+
.map((l) => { try {
|
|
162
|
+
return JSON.parse(l.slice(2));
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
return "";
|
|
166
|
+
} })
|
|
167
|
+
.join("");
|
|
168
|
+
return { content: content || raw, nextTags: nextTags ? nextTags.split(",") : [] };
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
];
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=observability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observability.js","sourceRoot":"","sources":["../../src/tools/observability.ts"],"names":[],"mappings":"AAEA,KAAK,UAAU,OAAO,CAAC,OAAe,EAAE,MAA0B,EAAE,IAAY,EAAE,OAAoB,EAAE;IACtG,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IAC1C,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;IAC/F,IAAI,MAAM;QAAE,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,MAAM,EAAE,CAAC,CAAC;IAC7D,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACtF,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,KAAK,IAAI,IAAI,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IAChF,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IACjD,OAAO,EAAE,CAAC,QAAQ,CAAC,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CAAC,IAAI,CAAC;qBACX,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;qBACjC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC;oBAAC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBAAC,CAAC;gBAAC,MAAM,CAAC;oBAAC,OAAO,EAAE,CAAC;gBAAC,CAAC,CAAC,CAAC,CAAC;qBAC3E,IAAI,CAAC,EAAE,CAAC,CAAC;gBACZ,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;YACpF,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneie/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "ONE substrate MCP server — 12 substrate verbs + 3 discovery tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"prepublishOnly": "bun run build"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@oneie/sdk": "^0.
|
|
17
|
+
"@oneie/sdk": "^0.7.0",
|
|
18
18
|
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|