@toon-protocol/views 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/dist/a2ui/A2UIRenderer.d.ts +47 -0
- package/dist/a2ui/A2UIRenderer.d.ts.map +1 -0
- package/dist/a2ui/A2UIRenderer.js +106 -0
- package/dist/a2ui/A2UIRenderer.js.map +1 -0
- package/dist/a2ui/binding.d.ts +46 -0
- package/dist/a2ui/binding.d.ts.map +1 -0
- package/dist/a2ui/binding.js +111 -0
- package/dist/a2ui/binding.js.map +1 -0
- package/dist/a2ui/index.d.ts +17 -0
- package/dist/a2ui/index.d.ts.map +1 -0
- package/dist/a2ui/index.js +17 -0
- package/dist/a2ui/index.js.map +1 -0
- package/dist/a2ui/types.d.ts +101 -0
- package/dist/a2ui/types.d.ts.map +1 -0
- package/dist/a2ui/types.js +64 -0
- package/dist/a2ui/types.js.map +1 -0
- package/dist/a2ui/validate.d.ts +55 -0
- package/dist/a2ui/validate.d.ts.map +1 -0
- package/dist/a2ui/validate.js +117 -0
- package/dist/a2ui/validate.js.map +1 -0
- package/dist/app/index.html +246 -0
- package/dist/app-bridge/ext-apps-bridge.d.ts +16 -0
- package/dist/app-bridge/ext-apps-bridge.d.ts.map +1 -0
- package/dist/app-bridge/ext-apps-bridge.js +66 -0
- package/dist/app-bridge/ext-apps-bridge.js.map +1 -0
- package/dist/app-bridge/types.d.ts +41 -0
- package/dist/app-bridge/types.d.ts.map +1 -0
- package/dist/app-bridge/types.js +10 -0
- package/dist/app-bridge/types.js.map +1 -0
- package/dist/app-entry.d.ts +13 -0
- package/dist/app-entry.d.ts.map +1 -0
- package/dist/app-entry.js +45 -0
- package/dist/app-entry.js.map +1 -0
- package/dist/atoms/defi.d.ts +3 -0
- package/dist/atoms/defi.d.ts.map +1 -0
- package/dist/atoms/defi.js +80 -0
- package/dist/atoms/defi.js.map +1 -0
- package/dist/atoms/fallback.d.ts +4 -0
- package/dist/atoms/fallback.d.ts.map +1 -0
- package/dist/atoms/fallback.js +15 -0
- package/dist/atoms/fallback.js.map +1 -0
- package/dist/atoms/forge.d.ts +3 -0
- package/dist/atoms/forge.d.ts.map +1 -0
- package/dist/atoms/forge.js +50 -0
- package/dist/atoms/forge.js.map +1 -0
- package/dist/atoms/interactive.d.ts +3 -0
- package/dist/atoms/interactive.d.ts.map +1 -0
- package/dist/atoms/interactive.js +99 -0
- package/dist/atoms/interactive.js.map +1 -0
- package/dist/atoms/layout.d.ts +3 -0
- package/dist/atoms/layout.d.ts.map +1 -0
- package/dist/atoms/layout.js +22 -0
- package/dist/atoms/layout.js.map +1 -0
- package/dist/atoms/media.d.ts +3 -0
- package/dist/atoms/media.d.ts.map +1 -0
- package/dist/atoms/media.js +92 -0
- package/dist/atoms/media.js.map +1 -0
- package/dist/atoms/onboard.d.ts +3 -0
- package/dist/atoms/onboard.d.ts.map +1 -0
- package/dist/atoms/onboard.js +26 -0
- package/dist/atoms/onboard.js.map +1 -0
- package/dist/atoms/registry.d.ts +35 -0
- package/dist/atoms/registry.d.ts.map +1 -0
- package/dist/atoms/registry.js +77 -0
- package/dist/atoms/registry.js.map +1 -0
- package/dist/atoms/social.d.ts +3 -0
- package/dist/atoms/social.d.ts.map +1 -0
- package/dist/atoms/social.js +52 -0
- package/dist/atoms/social.js.map +1 -0
- package/dist/atoms/types.d.ts +72 -0
- package/dist/atoms/types.d.ts.map +1 -0
- package/dist/atoms/types.js +11 -0
- package/dist/atoms/types.js.map +1 -0
- package/dist/catalog.d.ts +27 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +121 -0
- package/dist/catalog.js.map +1 -0
- package/dist/components/mono-id.d.ts +16 -0
- package/dist/components/mono-id.d.ts.map +1 -0
- package/dist/components/mono-id.js +18 -0
- package/dist/components/mono-id.js.map +1 -0
- package/dist/components/ui/avatar.d.ts +12 -0
- package/dist/components/ui/avatar.d.ts.map +1 -0
- package/dist/components/ui/avatar.js +25 -0
- package/dist/components/ui/avatar.js.map +1 -0
- package/dist/components/ui/badge.d.ts +10 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/badge.js +26 -0
- package/dist/components/ui/badge.js.map +1 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +37 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/input.d.ts +4 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +8 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/separator.d.ts +5 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/separator.js +9 -0
- package/dist/components/ui/separator.js.map +1 -0
- package/dist/components/ui/textarea.d.ts +4 -0
- package/dist/components/ui/textarea.d.ts.map +1 -0
- package/dist/components/ui/textarea.js +8 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/examples.d.ts +39 -0
- package/dist/examples.d.ts.map +1 -0
- package/dist/examples.js +168 -0
- package/dist/examples.js.map +1 -0
- package/dist/filters.d.ts +40 -0
- package/dist/filters.d.ts.map +1 -0
- package/dist/filters.js +84 -0
- package/dist/filters.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/cn.d.ts +4 -0
- package/dist/lib/cn.d.ts.map +1 -0
- package/dist/lib/cn.js +7 -0
- package/dist/lib/cn.js.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +6 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +7 -0
- package/dist/main.js.map +1 -0
- package/dist/mcp-ui/ConsentPrompt.d.ts +41 -0
- package/dist/mcp-ui/ConsentPrompt.d.ts.map +1 -0
- package/dist/mcp-ui/ConsentPrompt.js +45 -0
- package/dist/mcp-ui/ConsentPrompt.js.map +1 -0
- package/dist/mcp-ui/SandboxedAppRenderer.d.ts +54 -0
- package/dist/mcp-ui/SandboxedAppRenderer.d.ts.map +1 -0
- package/dist/mcp-ui/SandboxedAppRenderer.js +74 -0
- package/dist/mcp-ui/SandboxedAppRenderer.js.map +1 -0
- package/dist/mcp-ui/index.d.ts +18 -0
- package/dist/mcp-ui/index.d.ts.map +1 -0
- package/dist/mcp-ui/index.js +18 -0
- package/dist/mcp-ui/index.js.map +1 -0
- package/dist/mcp-ui/sandbox.d.ts +62 -0
- package/dist/mcp-ui/sandbox.d.ts.map +1 -0
- package/dist/mcp-ui/sandbox.js +78 -0
- package/dist/mcp-ui/sandbox.js.map +1 -0
- package/dist/parsers/media.d.ts +68 -0
- package/dist/parsers/media.d.ts.map +1 -0
- package/dist/parsers/media.js +124 -0
- package/dist/parsers/media.js.map +1 -0
- package/dist/parsers/nip34.d.ts +75 -0
- package/dist/parsers/nip34.d.ts.map +1 -0
- package/dist/parsers/nip34.js +142 -0
- package/dist/parsers/nip34.js.map +1 -0
- package/dist/parsers/social.d.ts +89 -0
- package/dist/parsers/social.d.ts.map +1 -0
- package/dist/parsers/social.js +136 -0
- package/dist/parsers/social.js.map +1 -0
- package/dist/render/node-shims/node-builtins.d.ts +30 -0
- package/dist/render/node-shims/node-builtins.d.ts.map +1 -0
- package/dist/render/node-shims/node-builtins.js +38 -0
- package/dist/render/node-shims/node-builtins.js.map +1 -0
- package/dist/render/resolve.d.ts +72 -0
- package/dist/render/resolve.d.ts.map +1 -0
- package/dist/render/resolve.js +115 -0
- package/dist/render/resolve.js.map +1 -0
- package/dist/runtime.d.ts +17 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +218 -0
- package/dist/runtime.js.map +1 -0
- package/dist/server/apps-server.d.ts +32 -0
- package/dist/server/apps-server.d.ts.map +1 -0
- package/dist/server/apps-server.js +163 -0
- package/dist/server/apps-server.js.map +1 -0
- package/dist/server/backend.d.ts +148 -0
- package/dist/server/backend.d.ts.map +1 -0
- package/dist/server/backend.js +11 -0
- package/dist/server/backend.js.map +1 -0
- package/dist/server/daemon-backend.d.ts +113 -0
- package/dist/server/daemon-backend.d.ts.map +1 -0
- package/dist/server/daemon-backend.js +79 -0
- package/dist/server/daemon-backend.js.map +1 -0
- package/dist/server/daemon-main.d.ts +25 -0
- package/dist/server/daemon-main.d.ts.map +1 -0
- package/dist/server/daemon-main.js +165 -0
- package/dist/server/daemon-main.js.map +1 -0
- package/dist/server/fake-backend.d.ts +53 -0
- package/dist/server/fake-backend.d.ts.map +1 -0
- package/dist/server/fake-backend.js +157 -0
- package/dist/server/fake-backend.js.map +1 -0
- package/dist/server/fake-main.d.ts +15 -0
- package/dist/server/fake-main.d.ts.map +1 -0
- package/dist/server/fake-main.js +39 -0
- package/dist/server/fake-main.js.map +1 -0
- package/dist/spec.d.ts +67 -0
- package/dist/spec.d.ts.map +1 -0
- package/dist/spec.js +221 -0
- package/dist/spec.js.map +1 -0
- package/dist/tool-names.d.ts +27 -0
- package/dist/tool-names.d.ts.map +1 -0
- package/dist/tool-names.js +32 -0
- package/dist/tool-names.js.map +1 -0
- package/dist/types.d.ts +39 -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 +71 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers the TOON apps surface on an MCP server: the single `ui://toon/app`
|
|
3
|
+
* UI resource plus the tools the agent uses to drive a generative user journey.
|
|
4
|
+
*
|
|
5
|
+
* The journey loop:
|
|
6
|
+
* 1. agent → `toon_atoms` (discover the atom vocabulary)
|
|
7
|
+
* 2. agent → `toon_render(spec)` (compose a ViewSpec; rides back as the tool
|
|
8
|
+
* result, and the tool's `_meta.ui.resourceUri` makes the host render the
|
|
9
|
+
* app bundle with it)
|
|
10
|
+
* 3. iframe → `toon_query(filter)` (free reads, fed into atoms)
|
|
11
|
+
* 4. iframe → `toon_publish_unsigned` / `toon_upload_media` (writes)
|
|
12
|
+
* 5. iframe → updateModelContext → agent composes the next ViewSpec
|
|
13
|
+
*
|
|
14
|
+
* ViewSpecs are model-authored → validated here (server side) before they are
|
|
15
|
+
* echoed back, in addition to the iframe runtime's own validation.
|
|
16
|
+
*/
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
import { registerAppResource, registerAppTool, RESOURCE_MIME_TYPE, } from '@modelcontextprotocol/ext-apps/server';
|
|
19
|
+
import { ATOM_CATALOG, CATALOG_ATOM_IDS } from '../catalog.js';
|
|
20
|
+
import { EXAMPLE_VIEWSPECS } from '../examples.js';
|
|
21
|
+
import { validateViewSpec } from '../spec.js';
|
|
22
|
+
import {} from '../types.js';
|
|
23
|
+
import { APP_RESOURCE_URI, ATOMS_TOOL, OPEN_CHANNEL_TOOL, PUBLISH_TOOL, QUERY_TOOL, RENDER_TOOL, STATUS_TOOL, SWAP_TOOL, UPLOAD_TOOL, WRITE_TOOLS, } from '../tool-names.js';
|
|
24
|
+
import {} from './backend.js';
|
|
25
|
+
function result(text, structuredContent) {
|
|
26
|
+
return {
|
|
27
|
+
content: [{ type: 'text', text }],
|
|
28
|
+
...(structuredContent ? { structuredContent } : {}),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function errorResult(text) {
|
|
32
|
+
return { content: [{ type: 'text', text }], isError: true };
|
|
33
|
+
}
|
|
34
|
+
/** Register the `ui://toon/app` resource + the generative-UI tools. */
|
|
35
|
+
export function registerToonApps(server, opts) {
|
|
36
|
+
const connect = opts.cspDomains?.connect ?? ['https://arweave.net'];
|
|
37
|
+
const resource = opts.cspDomains?.resource ?? ['https://arweave.net'];
|
|
38
|
+
registerAppResource(server, 'TOON', APP_RESOURCE_URI, {
|
|
39
|
+
mimeType: RESOURCE_MIME_TYPE,
|
|
40
|
+
_meta: { ui: { csp: { connectDomains: connect, resourceDomains: resource } } },
|
|
41
|
+
}, (uri) => ({
|
|
42
|
+
contents: [{ uri: uri.href, mimeType: RESOURCE_MIME_TYPE, text: opts.appHtml }],
|
|
43
|
+
}));
|
|
44
|
+
// toon_atoms — the vocabulary the agent composes with.
|
|
45
|
+
server.registerTool(ATOMS_TOOL, {
|
|
46
|
+
description: 'List the atom vocabulary (ids, kinds rendered, props, write actions) plus ' +
|
|
47
|
+
'example ViewSpecs, for composing a view to pass to ' + RENDER_TOOL + '.',
|
|
48
|
+
inputSchema: {},
|
|
49
|
+
}, () => {
|
|
50
|
+
const atomsPayload = { atoms: ATOM_CATALOG, examples: EXAMPLE_VIEWSPECS };
|
|
51
|
+
return result(JSON.stringify(atomsPayload, null, 2), atomsPayload);
|
|
52
|
+
});
|
|
53
|
+
// toon_render — agent composes a ViewSpec; it rides back as the tool result and
|
|
54
|
+
// the host renders the app bundle (via _meta.ui.resourceUri) with it.
|
|
55
|
+
registerAppTool(server, RENDER_TOOL, {
|
|
56
|
+
description: 'Render an agent-authored ViewSpec (a tree of atoms with data binds and ' +
|
|
57
|
+
'write actions) as the in-host UI. Use ' + ATOMS_TOOL + ' to learn the vocabulary.',
|
|
58
|
+
inputSchema: { spec: z.unknown() },
|
|
59
|
+
_meta: { ui: { resourceUri: APP_RESOURCE_URI } },
|
|
60
|
+
}, (args) => {
|
|
61
|
+
const check = validateViewSpec(args.spec, {
|
|
62
|
+
allowedAtoms: CATALOG_ATOM_IDS,
|
|
63
|
+
allowedTools: WRITE_TOOLS,
|
|
64
|
+
});
|
|
65
|
+
if (!check.ok) {
|
|
66
|
+
return errorResult(`Invalid ViewSpec:\n- ${check.errors.join('\n- ')}`);
|
|
67
|
+
}
|
|
68
|
+
return result(`Rendering view${check.spec.title ? `: ${check.spec.title}` : ''}.`, {
|
|
69
|
+
viewSpec: check.spec,
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
// toon_query — free reads resolved from the backend.
|
|
73
|
+
server.registerTool(QUERY_TOOL, {
|
|
74
|
+
description: 'Free read: resolve a NIP-01 filter to matching events.',
|
|
75
|
+
inputSchema: { filter: z.record(z.unknown()) },
|
|
76
|
+
}, async (args) => {
|
|
77
|
+
const events = await opts.backend.query(args.filter);
|
|
78
|
+
return result(`${events.length} event(s).`, { events });
|
|
79
|
+
});
|
|
80
|
+
// toon_status — free read: the current pay-to-write fee + settlement chain.
|
|
81
|
+
// The confirm UX pulls the fee from here (never hardcoded); when the real
|
|
82
|
+
// daemon backend (#16) is wired, the same UI shows the live fee/chain.
|
|
83
|
+
server.registerTool(STATUS_TOOL, {
|
|
84
|
+
description: 'Free read: report the current pay-to-write fee (feePerEvent) and ' +
|
|
85
|
+
'settlement chain. Used by the confirm UX to show the fee being paid.',
|
|
86
|
+
inputSchema: {},
|
|
87
|
+
}, async () => {
|
|
88
|
+
const status = await opts.backend.status();
|
|
89
|
+
return result(`Fee ${status.feePerEvent}${status.asset ? ` ${status.asset}` : ''} per event on ${status.settlementChain}.`, { ...status });
|
|
90
|
+
});
|
|
91
|
+
// toon_publish_unsigned — write (the daemon/back-end signs; the UI never does).
|
|
92
|
+
server.registerTool(PUBLISH_TOOL, {
|
|
93
|
+
description: 'Pay-to-write: supply only { kind, content, tags } — the backend signs ' +
|
|
94
|
+
'with the held key and publishes. UI actions target this tool.',
|
|
95
|
+
inputSchema: {
|
|
96
|
+
kind: z.number(),
|
|
97
|
+
content: z.string().optional(),
|
|
98
|
+
tags: z.array(z.array(z.string())).optional(),
|
|
99
|
+
},
|
|
100
|
+
}, async (args) => {
|
|
101
|
+
const res = await opts.backend.publish(args);
|
|
102
|
+
return result(`Published event ${res.eventId}.`, { ...res });
|
|
103
|
+
});
|
|
104
|
+
// toon_upload_media — spendy two-step write (upload → publish referencing it).
|
|
105
|
+
server.registerTool(UPLOAD_TOOL, {
|
|
106
|
+
description: 'Spendy: upload base64 media to Arweave then publish a referencing event ' +
|
|
107
|
+
'(default kind:1063; 20 picture, 21/22 video, 1 note w/ imeta).',
|
|
108
|
+
inputSchema: {
|
|
109
|
+
dataBase64: z.string(),
|
|
110
|
+
mime: z.string().optional(),
|
|
111
|
+
kind: z.number().optional(),
|
|
112
|
+
caption: z.string().optional(),
|
|
113
|
+
tags: z.array(z.array(z.string())).optional(),
|
|
114
|
+
},
|
|
115
|
+
}, async (args) => {
|
|
116
|
+
const res = await opts.backend.uploadMedia(args);
|
|
117
|
+
return result(`Uploaded + published media at ${res.url}.`, { ...res });
|
|
118
|
+
});
|
|
119
|
+
// toon_open_channel — pre-open a payment channel (daemon signs/settles).
|
|
120
|
+
server.registerTool(OPEN_CHANNEL_TOOL, {
|
|
121
|
+
description: 'Pre-open a payment channel (optionally toward a specific destination). ' +
|
|
122
|
+
'The backend signs/settles; the UI never holds keys. Returns { channelId }.',
|
|
123
|
+
inputSchema: { destination: z.string().optional() },
|
|
124
|
+
}, async (args) => {
|
|
125
|
+
const res = await opts.backend.openChannel(args);
|
|
126
|
+
return result(`Opened channel ${res.channelId}.`, { ...res });
|
|
127
|
+
});
|
|
128
|
+
// toon_swap — spendy cross-asset swap (daemon signs the source claim,
|
|
129
|
+
// returns the signed target-chain claim + settlement metadata).
|
|
130
|
+
server.registerTool(SWAP_TOOL, {
|
|
131
|
+
description: 'Spendy: run a cross-asset swap via a mill peer. The backend signs the ' +
|
|
132
|
+
'source-asset claim against the open channel and returns the signed ' +
|
|
133
|
+
'target-chain claim(s) + settlement metadata. UI actions target this tool.',
|
|
134
|
+
inputSchema: {
|
|
135
|
+
destination: z.string(),
|
|
136
|
+
amount: z.string(),
|
|
137
|
+
millPubkey: z.string(),
|
|
138
|
+
pair: z.object({
|
|
139
|
+
from: z.object({
|
|
140
|
+
assetCode: z.string(),
|
|
141
|
+
assetScale: z.number(),
|
|
142
|
+
chain: z.string(),
|
|
143
|
+
}),
|
|
144
|
+
to: z.object({
|
|
145
|
+
assetCode: z.string(),
|
|
146
|
+
assetScale: z.number(),
|
|
147
|
+
chain: z.string(),
|
|
148
|
+
}),
|
|
149
|
+
rate: z.string(),
|
|
150
|
+
minAmount: z.string().optional(),
|
|
151
|
+
maxAmount: z.string().optional(),
|
|
152
|
+
}),
|
|
153
|
+
chainRecipient: z.string(),
|
|
154
|
+
packetCount: z.number().optional(),
|
|
155
|
+
},
|
|
156
|
+
}, async (args) => {
|
|
157
|
+
const res = await opts.backend.swap(args);
|
|
158
|
+
return result(res.accepted
|
|
159
|
+
? `Swap ${res.state}: ${res.cumulativeSource} → ${res.cumulativeTarget} (${res.packetsAccepted} packet(s)).`
|
|
160
|
+
: `Swap ${res.state}${res.message ? `: ${res.message}` : ''}.`, { ...res });
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=apps-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apps-server.js","sourceRoot":"","sources":["../../src/server/apps-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,kBAAkB,GACnB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAoB,MAAM,aAAa,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,WAAW,EACX,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAqC,MAAM,cAAc,CAAC;AAWjE,SAAS,MAAM,CAAC,IAAY,EAAE,iBAA2C;IACvE,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACjC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,iBAAiB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CAAC,EAAE,GAAG,EAChE,EAAE,GAAG,GAAG,EAAE,CACX,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable read/write backends for the TOON apps MCP server.
|
|
3
|
+
*
|
|
4
|
+
* The apps server (atoms + ViewSpec rendering) depends only on these
|
|
5
|
+
* interfaces. The {@link ./fake-backend FakeBackend} satisfies them with a
|
|
6
|
+
* seeded relay + in-memory writes (good enough while core/sdk are in flux); the
|
|
7
|
+
* real `@toon-protocol/client-mcp` daemon will satisfy them with live BTP writes
|
|
8
|
+
* and relay reads.
|
|
9
|
+
*/
|
|
10
|
+
import { type NostrEvent, type NostrFilter } from '../types.js';
|
|
11
|
+
/** Free-read side: resolve a NIP-01 filter to matching events. */
|
|
12
|
+
export interface AppReadBackend {
|
|
13
|
+
query(filter: NostrFilter): Promise<NostrEvent[]>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Read-only pay-to-write status. The confirm UX shows the live fee + settlement
|
|
17
|
+
* chain pulled from here (never hardcoded). A structural subset of the daemon's
|
|
18
|
+
* `StatusResponse` — only the fields the UI needs. The `FakeBackend` returns a
|
|
19
|
+
* deterministic stub; the real `DaemonAppBackend` (#16) maps the live daemon
|
|
20
|
+
* `feePerEvent` / `settlementChain`, with no atom/ViewSpec change.
|
|
21
|
+
*/
|
|
22
|
+
export interface AppStatus {
|
|
23
|
+
/** Per-event fee in base (micro) units, as a decimal string. */
|
|
24
|
+
feePerEvent: string;
|
|
25
|
+
/** The chain family a paid write settles on (e.g. `'base'`, `'evm'`). */
|
|
26
|
+
settlementChain: string;
|
|
27
|
+
/** Optional human-readable asset code for the fee (e.g. `'USDC'`). */
|
|
28
|
+
asset?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Read-only status side: report the current fee + settlement chain. */
|
|
31
|
+
export interface AppStatusBackend {
|
|
32
|
+
status(): Promise<AppStatus>;
|
|
33
|
+
}
|
|
34
|
+
export interface PublishResult {
|
|
35
|
+
eventId: string;
|
|
36
|
+
channelId?: string;
|
|
37
|
+
nonce?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface UploadResult extends PublishResult {
|
|
40
|
+
url: string;
|
|
41
|
+
txId: string;
|
|
42
|
+
}
|
|
43
|
+
/** Pay-to-write side: sign+publish an event shell; upload+publish media. */
|
|
44
|
+
export interface AppWriteBackend {
|
|
45
|
+
publish(req: {
|
|
46
|
+
kind: number;
|
|
47
|
+
content?: string;
|
|
48
|
+
tags?: string[][];
|
|
49
|
+
}): Promise<PublishResult>;
|
|
50
|
+
uploadMedia(req: {
|
|
51
|
+
dataBase64: string;
|
|
52
|
+
mime?: string;
|
|
53
|
+
kind?: number;
|
|
54
|
+
caption?: string;
|
|
55
|
+
tags?: string[][];
|
|
56
|
+
}): Promise<UploadResult>;
|
|
57
|
+
}
|
|
58
|
+
/** Swap pair (source → target asset), mirroring `@toon-protocol/core`'s `SwapPair`. */
|
|
59
|
+
export interface SwapPair {
|
|
60
|
+
/** Source asset. */
|
|
61
|
+
from: {
|
|
62
|
+
assetCode: string;
|
|
63
|
+
assetScale: number;
|
|
64
|
+
chain: string;
|
|
65
|
+
};
|
|
66
|
+
/** Target asset. */
|
|
67
|
+
to: {
|
|
68
|
+
assetCode: string;
|
|
69
|
+
assetScale: number;
|
|
70
|
+
chain: string;
|
|
71
|
+
};
|
|
72
|
+
/** Exchange rate as a decimal string (target units per source unit). */
|
|
73
|
+
rate: string;
|
|
74
|
+
/** Minimum swap amount per packet in source micro-units. */
|
|
75
|
+
minAmount?: string;
|
|
76
|
+
/** Maximum swap amount per packet in source micro-units. */
|
|
77
|
+
maxAmount?: string;
|
|
78
|
+
}
|
|
79
|
+
/** Parameters for a cross-asset swap (subset of the daemon's `SwapRequest`). */
|
|
80
|
+
export interface SwapRequest {
|
|
81
|
+
/** Mill peer ILP destination (e.g. `g.townhouse.mill`). */
|
|
82
|
+
destination: string;
|
|
83
|
+
/** Total source-asset amount to swap, in source micro-units (decimal string). */
|
|
84
|
+
amount: string;
|
|
85
|
+
/** Mill's 64-char lowercase hex Nostr pubkey (NIP-59 gift-wrap recipient). */
|
|
86
|
+
millPubkey: string;
|
|
87
|
+
/** The swap pair to execute. */
|
|
88
|
+
pair: SwapPair;
|
|
89
|
+
/** Sender's payout address on `pair.to.chain`. */
|
|
90
|
+
chainRecipient: string;
|
|
91
|
+
/** Split the swap into N equal packets (default 1). */
|
|
92
|
+
packetCount?: number;
|
|
93
|
+
}
|
|
94
|
+
/** One accumulated, decrypted claim harvested from a single swap packet. */
|
|
95
|
+
export interface SwapClaim {
|
|
96
|
+
/** Source-asset amount sent for this packet (micro-units, decimal). */
|
|
97
|
+
sourceAmount: string;
|
|
98
|
+
/** Target-asset amount claimed (micro-units, decimal). */
|
|
99
|
+
targetAmount: string;
|
|
100
|
+
/** Decrypted signed target-chain claim bytes, base64. */
|
|
101
|
+
claim: string;
|
|
102
|
+
/** Target-chain channel id (real on-chain id, or a dev placeholder). */
|
|
103
|
+
channelId?: string;
|
|
104
|
+
/** Sender's payout address echoed by the mill. */
|
|
105
|
+
recipient?: string;
|
|
106
|
+
/** Mill's on-chain signer address. */
|
|
107
|
+
millSignerAddress?: string;
|
|
108
|
+
/** Mill-side claim id. */
|
|
109
|
+
claimId?: string;
|
|
110
|
+
/** Balance-proof nonce on the target channel (decimal). */
|
|
111
|
+
nonce?: string;
|
|
112
|
+
/** Cumulative transferred on the target channel (micro-units, decimal). */
|
|
113
|
+
cumulativeAmount?: string;
|
|
114
|
+
}
|
|
115
|
+
/** Result of a swap (subset of the daemon's `SwapResponse`). */
|
|
116
|
+
export interface SwapResponse {
|
|
117
|
+
/** True when at least one packet FULFILLed with a usable claim. */
|
|
118
|
+
accepted: boolean;
|
|
119
|
+
/** Number of packets the mill FULFILLed. */
|
|
120
|
+
packetsAccepted: number;
|
|
121
|
+
/** Per-packet accumulated claims (settlement metadata + signed claim). */
|
|
122
|
+
claims: SwapClaim[];
|
|
123
|
+
/** Total source sent across accepted packets (micro-units, decimal). */
|
|
124
|
+
cumulativeSource: string;
|
|
125
|
+
/** Total target received across accepted packets (micro-units, decimal). */
|
|
126
|
+
cumulativeTarget: string;
|
|
127
|
+
/** Final stream state. */
|
|
128
|
+
state: 'completed' | 'failed' | 'stopped';
|
|
129
|
+
/** First rejection code from the mill, if any (e.g. `F99`). */
|
|
130
|
+
code?: string;
|
|
131
|
+
/** First rejection message, if any. */
|
|
132
|
+
message?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* DeFi side: pre-open a payment channel and run a swap. The UI only *calls*
|
|
136
|
+
* these tools — all signing/settlement happens daemon-side.
|
|
137
|
+
*/
|
|
138
|
+
export interface AppDefiBackend {
|
|
139
|
+
openChannel(req: {
|
|
140
|
+
destination?: string;
|
|
141
|
+
}): Promise<{
|
|
142
|
+
channelId: string;
|
|
143
|
+
}>;
|
|
144
|
+
swap(req: SwapRequest): Promise<SwapResponse>;
|
|
145
|
+
}
|
|
146
|
+
export interface AppBackend extends AppReadBackend, AppWriteBackend, AppDefiBackend, AppStatusBackend {
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../src/server/backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAEhE,kEAAkE;AAClE,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;CACnD;AAED;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAC;IACpB,yEAAyE;IACzE,eAAe,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,KAAK,CAAC,E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C1C,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,GAAG,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3E,IAAI,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,UACf,SAAQ,cAAc,EACpB,eAAe,EACf,cAAc,EACd,gBAAgB;CAAG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable read/write backends for the TOON apps MCP server.
|
|
3
|
+
*
|
|
4
|
+
* The apps server (atoms + ViewSpec rendering) depends only on these
|
|
5
|
+
* interfaces. The {@link ./fake-backend FakeBackend} satisfies them with a
|
|
6
|
+
* seeded relay + in-memory writes (good enough while core/sdk are in flux); the
|
|
7
|
+
* real `@toon-protocol/client-mcp` daemon will satisfy them with live BTP writes
|
|
8
|
+
* and relay reads.
|
|
9
|
+
*/
|
|
10
|
+
import {} from '../types.js';
|
|
11
|
+
//# sourceMappingURL=backend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../../src/server/backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAqC,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Real, daemon-backed {@link AppBackend} for the TOON apps surface.
|
|
3
|
+
*
|
|
4
|
+
* Reads resolve over the free Nostr relay side (`query`); writes go through the
|
|
5
|
+
* `toon-clientd` control plane (`publish-unsigned` / `upload-media`), where the
|
|
6
|
+
* daemon holds the chain key and signs + pays. **No key material ever reaches
|
|
7
|
+
* the iframe** — the UI only supplies an unsigned event shell or raw bytes.
|
|
8
|
+
*
|
|
9
|
+
* To avoid a dependency cycle (`@toon-protocol/client-mcp` imports
|
|
10
|
+
* `@toon-protocol/views`), this file does NOT import client-mcp. Instead it
|
|
11
|
+
* depends on a minimal structural control port, {@link DaemonControl}, which the
|
|
12
|
+
* client-mcp `ControlClient` satisfies structurally.
|
|
13
|
+
*/
|
|
14
|
+
import { type NostrEvent, type NostrFilter } from '../types.js';
|
|
15
|
+
import { type AppBackend, type AppStatus, type PublishResult, type SwapRequest, type SwapResponse, type UploadResult } from './backend.js';
|
|
16
|
+
/** One-shot free read: subscribe the filter(s), wait briefly, return matches. */
|
|
17
|
+
export interface DaemonQueryRequest {
|
|
18
|
+
filters: NostrFilter | NostrFilter[];
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface DaemonQueryResponse {
|
|
22
|
+
events: NostrEvent[];
|
|
23
|
+
}
|
|
24
|
+
/** Build, sign (daemon-held key), and pay-to-write an event from a shell. */
|
|
25
|
+
export interface DaemonPublishUnsignedRequest {
|
|
26
|
+
kind: number;
|
|
27
|
+
content?: string;
|
|
28
|
+
tags?: string[][];
|
|
29
|
+
}
|
|
30
|
+
export interface DaemonPublishResponse {
|
|
31
|
+
eventId: string;
|
|
32
|
+
channelId: string;
|
|
33
|
+
nonce: number;
|
|
34
|
+
}
|
|
35
|
+
/** Upload bytes to Arweave (blob DVM), then sign+publish a referencing event. */
|
|
36
|
+
export interface DaemonUploadMediaRequest {
|
|
37
|
+
dataBase64: string;
|
|
38
|
+
mime?: string;
|
|
39
|
+
kind?: number;
|
|
40
|
+
caption?: string;
|
|
41
|
+
tags?: string[][];
|
|
42
|
+
}
|
|
43
|
+
export interface DaemonUploadMediaResponse extends DaemonPublishResponse {
|
|
44
|
+
url: string;
|
|
45
|
+
txId: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Read-only pay-to-write status from the daemon. A structural subset of the
|
|
49
|
+
* client-mcp `StatusResponse` — only the fields the confirm UX needs. The
|
|
50
|
+
* fetch-based control in {@link ./daemon-main daemon-main.ts} maps the daemon's
|
|
51
|
+
* `/status` response onto this shape.
|
|
52
|
+
*/
|
|
53
|
+
export interface DaemonStatusResponse {
|
|
54
|
+
feePerEvent: string;
|
|
55
|
+
settlementChain: string;
|
|
56
|
+
asset?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Minimal structural control-plane port the {@link DaemonAppBackend} needs.
|
|
60
|
+
*
|
|
61
|
+
* Intentionally a structural subset of the client-mcp `ControlClient`: that
|
|
62
|
+
* class satisfies this interface without `views` importing client-mcp (which
|
|
63
|
+
* would form a cycle). Extra response fields (e.g. `data` on a publish) are
|
|
64
|
+
* tolerated — only the fields mapped below are read.
|
|
65
|
+
*/
|
|
66
|
+
export interface DaemonControl {
|
|
67
|
+
status(): Promise<DaemonStatusResponse>;
|
|
68
|
+
query(body: DaemonQueryRequest): Promise<DaemonQueryResponse>;
|
|
69
|
+
publishUnsigned(body: DaemonPublishUnsignedRequest): Promise<DaemonPublishResponse>;
|
|
70
|
+
uploadMedia(body: DaemonUploadMediaRequest): Promise<DaemonUploadMediaResponse>;
|
|
71
|
+
openChannel(body: {
|
|
72
|
+
destination?: string;
|
|
73
|
+
}): Promise<{
|
|
74
|
+
channelId: string;
|
|
75
|
+
}>;
|
|
76
|
+
swap(body: SwapRequest): Promise<SwapResponse>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* `AppBackend` implemented over the live daemon control plane. Construct it with
|
|
80
|
+
* a `DaemonControl` (the client-mcp `ControlClient` fits) and hand it to
|
|
81
|
+
* {@link ../apps-server.registerToonApps registerToonApps}.
|
|
82
|
+
*/
|
|
83
|
+
export declare class DaemonAppBackend implements AppBackend {
|
|
84
|
+
private readonly control;
|
|
85
|
+
constructor(control: DaemonControl);
|
|
86
|
+
/** Read-only fee/chain — no payment. Maps the daemon status onto `AppStatus`. */
|
|
87
|
+
status(): Promise<AppStatus>;
|
|
88
|
+
/** Free read — no payment. Maps `QueryResponse.events` → `NostrEvent[]`. */
|
|
89
|
+
query(filter: NostrFilter): Promise<NostrEvent[]>;
|
|
90
|
+
/** Pay-to-write. The daemon signs with the held key; the iframe holds none. */
|
|
91
|
+
publish(req: {
|
|
92
|
+
kind: number;
|
|
93
|
+
content?: string;
|
|
94
|
+
tags?: string[][];
|
|
95
|
+
}): Promise<PublishResult>;
|
|
96
|
+
/** Two-step spendy write: Arweave upload (DVM) then sign+publish reference. */
|
|
97
|
+
uploadMedia(req: {
|
|
98
|
+
dataBase64: string;
|
|
99
|
+
mime?: string;
|
|
100
|
+
kind?: number;
|
|
101
|
+
caption?: string;
|
|
102
|
+
tags?: string[][];
|
|
103
|
+
}): Promise<UploadResult>;
|
|
104
|
+
/** Pre-open a payment channel. Daemon-side; no key material in the iframe. */
|
|
105
|
+
openChannel(req: {
|
|
106
|
+
destination?: string;
|
|
107
|
+
}): Promise<{
|
|
108
|
+
channelId: string;
|
|
109
|
+
}>;
|
|
110
|
+
/** Run a cross-asset swap. All signing/settlement happens daemon-side. */
|
|
111
|
+
swap(req: SwapRequest): Promise<SwapResponse>;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=daemon-backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon-backend.d.ts","sourceRoot":"","sources":["../../src/server/daemon-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAEtB,iFAAiF;AACjF,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,WAAW,GAAG,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the TOON apps surface.
|
|
3
|
+
*
|
|
4
|
+
* Reads resolve over the free Nostr relay side (`query`); writes go through the
|
|
5
|
+
* `toon-clientd` control plane (`publish-unsigned` / `upload-media`), where the
|
|
6
|
+
* daemon holds the chain key and signs + pays. **No key material ever reaches
|
|
7
|
+
* the iframe** — the UI only supplies an unsigned event shell or raw bytes.
|
|
8
|
+
*
|
|
9
|
+
* To avoid a dependency cycle (`@toon-protocol/client-mcp` imports
|
|
10
|
+
* `@toon-protocol/views`), this file does NOT import client-mcp. Instead it
|
|
11
|
+
* depends on a minimal structural control port, {@link DaemonControl}, which the
|
|
12
|
+
* client-mcp `ControlClient` satisfies structurally.
|
|
13
|
+
*/
|
|
14
|
+
import {} from '../types.js';
|
|
15
|
+
import {} from './backend.js';
|
|
16
|
+
/**
|
|
17
|
+
* `AppBackend` implemented over the live daemon control plane. Construct it with
|
|
18
|
+
* a `DaemonControl` (the client-mcp `ControlClient` fits) and hand it to
|
|
19
|
+
* {@link ../apps-server.registerToonApps registerToonApps}.
|
|
20
|
+
*/
|
|
21
|
+
export class DaemonAppBackend {
|
|
22
|
+
control;
|
|
23
|
+
constructor(control) {
|
|
24
|
+
this.control = control;
|
|
25
|
+
}
|
|
26
|
+
/** Read-only fee/chain — no payment. Maps the daemon status onto `AppStatus`. */
|
|
27
|
+
async status() {
|
|
28
|
+
const res = await this.control.status();
|
|
29
|
+
return {
|
|
30
|
+
feePerEvent: res.feePerEvent,
|
|
31
|
+
settlementChain: res.settlementChain,
|
|
32
|
+
...(res.asset ? { asset: res.asset } : {}),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Free read — no payment. Maps `QueryResponse.events` → `NostrEvent[]`. */
|
|
36
|
+
async query(filter) {
|
|
37
|
+
const res = await this.control.query({ filters: filter });
|
|
38
|
+
return res.events;
|
|
39
|
+
}
|
|
40
|
+
/** Pay-to-write. The daemon signs with the held key; the iframe holds none. */
|
|
41
|
+
async publish(req) {
|
|
42
|
+
const res = await this.control.publishUnsigned({
|
|
43
|
+
kind: req.kind,
|
|
44
|
+
content: req.content,
|
|
45
|
+
tags: req.tags,
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
eventId: res.eventId,
|
|
49
|
+
channelId: res.channelId,
|
|
50
|
+
nonce: res.nonce,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Two-step spendy write: Arweave upload (DVM) then sign+publish reference. */
|
|
54
|
+
async uploadMedia(req) {
|
|
55
|
+
const res = await this.control.uploadMedia({
|
|
56
|
+
dataBase64: req.dataBase64,
|
|
57
|
+
mime: req.mime,
|
|
58
|
+
kind: req.kind,
|
|
59
|
+
caption: req.caption,
|
|
60
|
+
tags: req.tags,
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
eventId: res.eventId,
|
|
64
|
+
channelId: res.channelId,
|
|
65
|
+
nonce: res.nonce,
|
|
66
|
+
url: res.url,
|
|
67
|
+
txId: res.txId,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/** Pre-open a payment channel. Daemon-side; no key material in the iframe. */
|
|
71
|
+
async openChannel(req) {
|
|
72
|
+
return this.control.openChannel(req);
|
|
73
|
+
}
|
|
74
|
+
/** Run a cross-asset swap. All signing/settlement happens daemon-side. */
|
|
75
|
+
async swap(req) {
|
|
76
|
+
return this.control.swap(req);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=daemon-backend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon-backend.js","sourceRoot":"","sources":["../../src/server/daemon-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAqC,MAAM,aAAa,CAAC;AAChE,OAAO,EAON,MAAM,cAAc,CAAC;AAwEtB;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IACE;IAA7B,YAA6B,OAAsB;QAAtB,YAAO,GAAP,OAAO,CAAe;IAAG,CAAC;IAEvD,iFAAiF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CAAC;QACH,OAAO;YACL,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,GAAG,EAAE,GAAG,CAAC,GAAG;YACZ,IAAI,EAAE,GAAG,CAAC,IAAI;SACf,CAAC;IACJ,CAAC;IAED,8EAA8E;IAC9E,KAAK,CAAC,WAAW,CAAC,GAA6B;QAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;IAED,0EAA0E;IAC1E,KAAK,CAAC,IAAI,CAAC,GAAgB;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Real TOON apps MCP server (stdio) — the daemon-backed counterpart to
|
|
4
|
+
* {@link ./fake-main fake-main.ts}.
|
|
5
|
+
*
|
|
6
|
+
* Reads resolve over the free Nostr relay side and writes go through the
|
|
7
|
+
* always-on `toon-clientd` control plane: this entrypoint wires a
|
|
8
|
+
* {@link DaemonAppBackend} (over a tiny fetch-based {@link DaemonControl}) into
|
|
9
|
+
* {@link ./apps-server.registerToonApps registerToonApps}. No chain keys ever
|
|
10
|
+
* live in this process or the iframe — the daemon holds the key and signs+pays.
|
|
11
|
+
*
|
|
12
|
+
* pnpm --filter @toon-protocol/views build
|
|
13
|
+
* node packages/views/dist/server/daemon-main.js # toon-clientd must be up
|
|
14
|
+
*
|
|
15
|
+
* Then connect it as an MCP server (e.g. `claude mcp add toon -- node …/daemon-main.js`).
|
|
16
|
+
*
|
|
17
|
+
* The daemon URL is resolved the same way `client-mcp/src/mcp.ts` does — from
|
|
18
|
+
* `TOON_CLIENT_HTTP_PORT` or the config file's `httpPort`, default 8787. To keep
|
|
19
|
+
* `@toon-protocol/views` free of a dependency cycle on `@toon-protocol/client-mcp`
|
|
20
|
+
* (which imports views), this entrypoint speaks the control plane over `fetch`
|
|
21
|
+
* directly rather than importing the client-mcp `ControlClient` — the structural
|
|
22
|
+
* `DaemonControl` port is all `DaemonAppBackend` needs.
|
|
23
|
+
*/
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=daemon-main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon-main.d.ts","sourceRoot":"","sources":["../../src/server/daemon-main.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;GAqBG"}
|