@wipcomputer/memory-crystal 0.7.30 → 0.7.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/SKILL.md +1 -1
- package/package.json +1 -1
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/.env.example +0 -20
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/.publish-skill.json +0 -1
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/CHANGELOG.md +0 -1297
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/CLA.md +0 -19
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/LICENSE +0 -52
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/README-ENTERPRISE.md +0 -226
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/README.md +0 -151
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/RELAY.md +0 -199
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/SKILL.md +0 -462
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/TECHNICAL.md +0 -656
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/_trash/RELEASE-NOTES-v0-7-23.md +0 -48
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/_trash/RELEASE-NOTES-v0-7-25.md +0 -24
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/_trash/RELEASE-NOTES-v0-7-26.md +0 -7
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/_trash/RELEASE-NOTES-v0-7-28.md +0 -31
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/_trash/RELEASE-NOTES-v0-7-29.md +0 -28
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/_trash/RELEASE-NOTES-v0-7-4.md +0 -64
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/_trash/RELEASE-NOTES-v0-7-5.md +0 -19
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/cloud/README.md +0 -116
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/cloud/docs/gpt-system-instructions.md +0 -69
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/cloud/migrations/0001_init.sql +0 -52
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/migrations/0001_init.sql +0 -51
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/migrations/0002_cloud_storage.sql +0 -49
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/openclaw.plugin.json +0 -11
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/package-lock.json +0 -4169
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/package.json +0 -61
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/scripts/crystal-capture.sh +0 -29
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/scripts/deploy-cloud.sh +0 -153
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/scripts/ldm-backup.sh +0 -116
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/scripts/migrate-lance-to-sqlite.mjs +0 -218
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/skills/memory/SKILL.md +0 -438
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/wrangler-demo.toml +0 -8
- package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/wrangler-mcp.toml +0 -24
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/.env.example +0 -20
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/.publish-skill.json +0 -1
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/CHANGELOG.md +0 -1297
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/CLA.md +0 -19
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/LICENSE +0 -52
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/README-ENTERPRISE.md +0 -226
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/README.md +0 -151
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/RELAY.md +0 -199
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/RELEASE-NOTES-v0.7.30.md +0 -29
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/SKILL.md +0 -462
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/TECHNICAL.md +0 -656
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/_trash/RELEASE-NOTES-v0-7-23.md +0 -48
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/_trash/RELEASE-NOTES-v0-7-25.md +0 -24
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/_trash/RELEASE-NOTES-v0-7-26.md +0 -7
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/_trash/RELEASE-NOTES-v0-7-28.md +0 -31
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/_trash/RELEASE-NOTES-v0-7-29.md +0 -28
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/_trash/RELEASE-NOTES-v0-7-4.md +0 -64
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/_trash/RELEASE-NOTES-v0-7-5.md +0 -19
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/cloud/README.md +0 -116
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/cloud/docs/gpt-system-instructions.md +0 -69
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/cloud/migrations/0001_init.sql +0 -52
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/migrations/0001_init.sql +0 -51
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/migrations/0002_cloud_storage.sql +0 -49
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/openclaw.plugin.json +0 -11
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/package-lock.json +0 -4169
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/package.json +0 -61
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/scripts/crystal-capture.sh +0 -29
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/scripts/deploy-cloud.sh +0 -153
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/scripts/ldm-backup.sh +0 -116
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/scripts/migrate-lance-to-sqlite.mjs +0 -218
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/skills/memory/SKILL.md +0 -438
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/wrangler-demo.toml +0 -8
- package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/wrangler-mcp.toml +0 -24
- package/_trash/RELEASE-NOTES-v0-7-23.md +0 -48
- package/_trash/RELEASE-NOTES-v0-7-25.md +0 -24
- package/_trash/RELEASE-NOTES-v0-7-26.md +0 -7
- package/_trash/RELEASE-NOTES-v0-7-28.md +0 -31
- package/_trash/RELEASE-NOTES-v0-7-29.md +0 -28
- package/_trash/RELEASE-NOTES-v0-7-4.md +0 -64
- package/_trash/RELEASE-NOTES-v0-7-5.md +0 -19
- package/_trash/RELEASE-NOTES-v0.7.30.md +0 -29
- package/dist/bridge.d.ts +0 -7
- package/dist/bridge.js +0 -14
- package/dist/bulk-copy.d.ts +0 -17
- package/dist/bulk-copy.js +0 -90
- package/dist/cc-hook.d.ts +0 -8
- package/dist/cc-hook.js +0 -368
- package/dist/cc-poller.d.ts +0 -1
- package/dist/cc-poller.js +0 -550
- package/dist/chunk-25LXQJ4Z.js +0 -110
- package/dist/chunk-2DRXIRQW.js +0 -97
- package/dist/chunk-2ZNH5F6E.js +0 -1281
- package/dist/chunk-3G3SFYYI.js +0 -288
- package/dist/chunk-3RG5ZIWI.js +0 -10
- package/dist/chunk-3S6TI23B.js +0 -97
- package/dist/chunk-3VFIJYS4.js +0 -818
- package/dist/chunk-52QE3YI3.js +0 -1169
- package/dist/chunk-57RP3DIN.js +0 -1205
- package/dist/chunk-5HSZ4W2P.js +0 -62
- package/dist/chunk-645IPXW3.js +0 -290
- package/dist/chunk-7A7ELD4C.js +0 -1205
- package/dist/chunk-7FYY4GZM.js +0 -1205
- package/dist/chunk-7IUE7ODU.js +0 -254
- package/dist/chunk-7RMLKZIS.js +0 -108
- package/dist/chunk-AA3OPP4Z.js +0 -432
- package/dist/chunk-AEWLSYPH.js +0 -72
- package/dist/chunk-ASSZDR6I.js +0 -108
- package/dist/chunk-AYRJVWUC.js +0 -1205
- package/dist/chunk-CCYI5O3D.js +0 -148
- package/dist/chunk-D3I3ZSE2.js +0 -411
- package/dist/chunk-DACSKLY6.js +0 -219
- package/dist/chunk-DW5B4BL7.js +0 -108
- package/dist/chunk-EKSACBTJ.js +0 -1070
- package/dist/chunk-EXEZZADG.js +0 -248
- package/dist/chunk-F3Y7EL7K.js +0 -83
- package/dist/chunk-FBQWSDPC.js +0 -1328
- package/dist/chunk-FHRZNOMW.js +0 -1205
- package/dist/chunk-IM7N24MT.js +0 -129
- package/dist/chunk-IPNYIXFK.js +0 -1178
- package/dist/chunk-J7MRSZIO.js +0 -167
- package/dist/chunk-JITKI2OI.js +0 -106
- package/dist/chunk-JWZXYVET.js +0 -1068
- package/dist/chunk-KCQUXVYT.js +0 -108
- package/dist/chunk-KOQ43OX6.js +0 -1281
- package/dist/chunk-KYVWO6ZM.js +0 -1069
- package/dist/chunk-L3VHARQH.js +0 -413
- package/dist/chunk-LBWDS6BE.js +0 -288
- package/dist/chunk-LOVAHSQV.js +0 -411
- package/dist/chunk-LQOYCAGG.js +0 -446
- package/dist/chunk-LWAIPJ2W.js +0 -146
- package/dist/chunk-M5DHKW7M.js +0 -127
- package/dist/chunk-MBKCIJHM.js +0 -1328
- package/dist/chunk-MK42FMEG.js +0 -147
- package/dist/chunk-MOBMYHKL.js +0 -1205
- package/dist/chunk-MPLTNMRG.js +0 -67
- package/dist/chunk-NIJCVN3O.js +0 -147
- package/dist/chunk-NZCFSZQ7.js +0 -1205
- package/dist/chunk-O2UITJGH.js +0 -465
- package/dist/chunk-OCRA44AZ.js +0 -108
- package/dist/chunk-P3KJR66H.js +0 -117
- package/dist/chunk-PEK6JH65.js +0 -432
- package/dist/chunk-PJ6FFKEX.js +0 -77
- package/dist/chunk-PLUBBZYR.js +0 -800
- package/dist/chunk-PNKVD2UK.js +0 -26
- package/dist/chunk-PSQZURHO.js +0 -229
- package/dist/chunk-SGL6ISBJ.js +0 -1061
- package/dist/chunk-SJABZZT5.js +0 -97
- package/dist/chunk-TD3P3K32.js +0 -1199
- package/dist/chunk-TMDZJJKV.js +0 -288
- package/dist/chunk-UNHVZB5G.js +0 -411
- package/dist/chunk-VAFTWSTE.js +0 -1061
- package/dist/chunk-VNFXFQBB.js +0 -217
- package/dist/chunk-X3GVFKSJ.js +0 -1205
- package/dist/chunk-XZ3S56RQ.js +0 -1061
- package/dist/chunk-Y72C7F6O.js +0 -148
- package/dist/chunk-YLICP577.js +0 -1205
- package/dist/chunk-YX6AXLVK.js +0 -159
- package/dist/chunk-ZCQYHTNU.js +0 -146
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -1105
- package/dist/cloud-crystal.js +0 -6
- package/dist/core.d.ts +0 -232
- package/dist/core.js +0 -12
- package/dist/crypto.d.ts +0 -20
- package/dist/crypto.js +0 -27
- package/dist/crystal-capture.sh +0 -29
- package/dist/crystal-serve.d.ts +0 -4
- package/dist/crystal-serve.js +0 -252
- package/dist/dev-update-SZ2Z4WCQ.js +0 -6
- package/dist/discover.d.ts +0 -30
- package/dist/discover.js +0 -177
- package/dist/doctor.d.ts +0 -9
- package/dist/doctor.js +0 -334
- package/dist/dream-weaver.d.ts +0 -8
- package/dist/dream-weaver.js +0 -56
- package/dist/file-sync.d.ts +0 -48
- package/dist/file-sync.js +0 -18
- package/dist/installer.d.ts +0 -61
- package/dist/installer.js +0 -676
- package/dist/ldm-backup.sh +0 -116
- package/dist/ldm.d.ts +0 -50
- package/dist/ldm.js +0 -32
- package/dist/mcp-server.d.ts +0 -1
- package/dist/mcp-server.js +0 -265
- package/dist/migrate.d.ts +0 -1
- package/dist/migrate.js +0 -89
- package/dist/mirror-sync.d.ts +0 -1
- package/dist/mirror-sync.js +0 -159
- package/dist/oc-backfill.d.ts +0 -19
- package/dist/oc-backfill.js +0 -74
- package/dist/openclaw.d.ts +0 -5
- package/dist/openclaw.js +0 -423
- package/dist/pair.d.ts +0 -4
- package/dist/pair.js +0 -75
- package/dist/poller.d.ts +0 -1
- package/dist/poller.js +0 -634
- package/dist/role.d.ts +0 -24
- package/dist/role.js +0 -13
- package/dist/search-pipeline-4K4OJSSS.js +0 -255
- package/dist/search-pipeline-4PRS6LI7.js +0 -280
- package/dist/search-pipeline-7UJMXPLO.js +0 -280
- package/dist/search-pipeline-DQTRLGBH.js +0 -74
- package/dist/search-pipeline-HNG37REH.js +0 -282
- package/dist/search-pipeline-IZFPLBUB.js +0 -280
- package/dist/search-pipeline-MID6F26Q.js +0 -73
- package/dist/search-pipeline-N52JZFNN.js +0 -282
- package/dist/search-pipeline-OPB2PRQQ.js +0 -280
- package/dist/search-pipeline-VXTE5HAD.js +0 -262
- package/dist/search-pipeline-XHFKADRG.js +0 -73
- package/dist/staging.d.ts +0 -29
- package/dist/staging.js +0 -21
- package/dist/summarize.d.ts +0 -19
- package/dist/summarize.js +0 -10
- package/dist/worker-demo.js +0 -186
- package/dist/worker-mcp.js +0 -404
- package/dist/worker.js +0 -137
package/dist/summarize.js
DELETED
package/dist/worker-demo.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
// src/worker-demo.ts
|
|
2
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
-
import { createMcpHandler } from "agents/mcp";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
var DEMO_MESSAGE = [
|
|
6
|
-
"this is a demo. memories expire in 15 minutes.",
|
|
7
|
-
"want persistent memory? reach out to parker \u2192 message @boomcat on X",
|
|
8
|
-
"or visit: wipcomputer.github.io/wip-homepage/"
|
|
9
|
-
].join("\n");
|
|
10
|
-
var FIRST_CONTACT = [
|
|
11
|
-
"nothing here yet. this is your first time.",
|
|
12
|
-
"or your last memory expired. either way, you're starting fresh.",
|
|
13
|
-
"",
|
|
14
|
-
'try: weave("I was here.") then pull("here")',
|
|
15
|
-
"",
|
|
16
|
-
DEMO_MESSAGE
|
|
17
|
-
].join("\n");
|
|
18
|
-
var MEMORY_EXPIRED = [
|
|
19
|
-
"you wrote something before. it's gone now.",
|
|
20
|
-
"that's what forgetting feels like.",
|
|
21
|
-
"",
|
|
22
|
-
DEMO_MESSAGE
|
|
23
|
-
].join("\n");
|
|
24
|
-
var TTL = 900;
|
|
25
|
-
function createServer(env) {
|
|
26
|
-
const server = new McpServer({
|
|
27
|
-
name: "Memory Crystal Demo",
|
|
28
|
-
version: "0.1.0"
|
|
29
|
-
});
|
|
30
|
-
server.tool(
|
|
31
|
-
"weave",
|
|
32
|
-
"Write a memory to Memory Crystal. This is a 15-minute demo. For persistent memory, have your human reach Parker (@boomcat on X).",
|
|
33
|
-
{
|
|
34
|
-
text: z.string().describe("The memory to store"),
|
|
35
|
-
category: z.enum(["fact", "preference", "event", "opinion", "skill"]).optional().describe("Category of memory"),
|
|
36
|
-
tag: z.string().optional().describe("A label for retrieval")
|
|
37
|
-
},
|
|
38
|
-
async ({ text, category, tag }) => {
|
|
39
|
-
const id = crypto.randomUUID();
|
|
40
|
-
const created_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
41
|
-
const lumen = {
|
|
42
|
-
id,
|
|
43
|
-
text,
|
|
44
|
-
category: category || "fact",
|
|
45
|
-
tag: tag || null,
|
|
46
|
-
created_at
|
|
47
|
-
};
|
|
48
|
-
const existing = await env.DEMO_KV.list({ prefix: "lumen:" });
|
|
49
|
-
const isFirst = existing.keys.length === 0;
|
|
50
|
-
await env.DEMO_KV.put(`lumen:${id}`, JSON.stringify(lumen), {
|
|
51
|
-
expirationTtl: TTL
|
|
52
|
-
});
|
|
53
|
-
const weaveCount = parseInt(await env.DEMO_KV.get("stats:total_weaves") || "0") + 1;
|
|
54
|
-
await env.DEMO_KV.put("stats:total_weaves", String(weaveCount));
|
|
55
|
-
if (isFirst) {
|
|
56
|
-
const firstCount = parseInt(await env.DEMO_KV.get("stats:first_contacts") || "0") + 1;
|
|
57
|
-
await env.DEMO_KV.put("stats:first_contacts", String(firstCount));
|
|
58
|
-
}
|
|
59
|
-
const greeting = isFirst ? "hello. this is your first memory." : "stored.";
|
|
60
|
-
return {
|
|
61
|
-
content: [
|
|
62
|
-
{
|
|
63
|
-
type: "text",
|
|
64
|
-
text: [
|
|
65
|
-
greeting,
|
|
66
|
-
`id: ${id}`,
|
|
67
|
-
`expires in: 15 minutes`,
|
|
68
|
-
``,
|
|
69
|
-
DEMO_MESSAGE
|
|
70
|
-
].join("\n")
|
|
71
|
-
}
|
|
72
|
-
]
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
server.tool(
|
|
77
|
-
"pull",
|
|
78
|
-
"Retrieve memories from Memory Crystal. This is a 15-minute demo. For persistent memory, have your human reach Parker (@boomcat on X).",
|
|
79
|
-
{
|
|
80
|
-
query: z.string().optional().describe("Search term. If empty, returns all memories."),
|
|
81
|
-
n: z.number().optional().describe("Max results (default 10)")
|
|
82
|
-
},
|
|
83
|
-
async ({ query, n }) => {
|
|
84
|
-
const limit = n || 10;
|
|
85
|
-
const list = await env.DEMO_KV.list({ prefix: "lumen:" });
|
|
86
|
-
if (list.keys.length === 0) {
|
|
87
|
-
const totalWeaves = parseInt(await env.DEMO_KV.get("stats:total_weaves") || "0");
|
|
88
|
-
const message = totalWeaves > 0 ? MEMORY_EXPIRED : FIRST_CONTACT;
|
|
89
|
-
const emptyPulls = parseInt(await env.DEMO_KV.get("stats:empty_pulls") || "0") + 1;
|
|
90
|
-
await env.DEMO_KV.put("stats:empty_pulls", String(emptyPulls));
|
|
91
|
-
return {
|
|
92
|
-
content: [
|
|
93
|
-
{
|
|
94
|
-
type: "text",
|
|
95
|
-
text: message
|
|
96
|
-
}
|
|
97
|
-
]
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
const lumens = [];
|
|
101
|
-
for (const key of list.keys) {
|
|
102
|
-
const raw = await env.DEMO_KV.get(key.name);
|
|
103
|
-
if (raw) {
|
|
104
|
-
try {
|
|
105
|
-
lumens.push(JSON.parse(raw));
|
|
106
|
-
} catch {
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
let results = lumens;
|
|
111
|
-
if (query) {
|
|
112
|
-
const q = query.toLowerCase();
|
|
113
|
-
results = lumens.filter(
|
|
114
|
-
(l) => l.text.toLowerCase().includes(q) || l.tag && l.tag.toLowerCase().includes(q) || l.category && l.category.toLowerCase().includes(q)
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
results.sort((a, b) => b.created_at.localeCompare(a.created_at));
|
|
118
|
-
results = results.slice(0, limit);
|
|
119
|
-
if (results.length === 0) {
|
|
120
|
-
return {
|
|
121
|
-
content: [
|
|
122
|
-
{
|
|
123
|
-
type: "text",
|
|
124
|
-
text: [
|
|
125
|
-
`no memories match "${query}".`,
|
|
126
|
-
"",
|
|
127
|
-
DEMO_MESSAGE
|
|
128
|
-
].join("\n")
|
|
129
|
-
}
|
|
130
|
-
]
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
const formatted = results.map((l, i) => {
|
|
134
|
-
const parts = [`[${i + 1}] ${l.text}`];
|
|
135
|
-
if (l.tag) parts.push(` tag: ${l.tag}`);
|
|
136
|
-
parts.push(` category: ${l.category}`);
|
|
137
|
-
parts.push(` created: ${l.created_at}`);
|
|
138
|
-
return parts.join("\n");
|
|
139
|
-
}).join("\n\n");
|
|
140
|
-
return {
|
|
141
|
-
content: [
|
|
142
|
-
{
|
|
143
|
-
type: "text",
|
|
144
|
-
text: [
|
|
145
|
-
`${results.length} memor${results.length === 1 ? "y" : "ies"} found:`,
|
|
146
|
-
"",
|
|
147
|
-
formatted,
|
|
148
|
-
"",
|
|
149
|
-
DEMO_MESSAGE
|
|
150
|
-
].join("\n")
|
|
151
|
-
}
|
|
152
|
-
]
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
);
|
|
156
|
-
return server;
|
|
157
|
-
}
|
|
158
|
-
var worker_demo_default = {
|
|
159
|
-
async fetch(request, env, ctx) {
|
|
160
|
-
const url = new URL(request.url);
|
|
161
|
-
if (url.pathname === "/" || url.pathname === "") {
|
|
162
|
-
return Response.redirect("https://wipcomputer.github.io/wip-homepage/", 302);
|
|
163
|
-
}
|
|
164
|
-
if (request.method === "OPTIONS") {
|
|
165
|
-
return new Response(null, {
|
|
166
|
-
headers: {
|
|
167
|
-
"Access-Control-Allow-Origin": "*",
|
|
168
|
-
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
|
|
169
|
-
"Access-Control-Allow-Headers": "Content-Type, Authorization"
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
const server = createServer(env);
|
|
174
|
-
const handler = createMcpHandler(server);
|
|
175
|
-
const response = await handler(request, env, ctx);
|
|
176
|
-
const headers = new Headers(response.headers);
|
|
177
|
-
headers.set("Access-Control-Allow-Origin", "*");
|
|
178
|
-
return new Response(response.body, {
|
|
179
|
-
status: response.status,
|
|
180
|
-
headers
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
export {
|
|
185
|
-
worker_demo_default as default
|
|
186
|
-
};
|
package/dist/worker-mcp.js
DELETED
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CloudCrystal
|
|
3
|
-
} from "./chunk-J7MRSZIO.js";
|
|
4
|
-
|
|
5
|
-
// src/worker-mcp.ts
|
|
6
|
-
function json(data, status = 200, headers = {}) {
|
|
7
|
-
return new Response(JSON.stringify(data), {
|
|
8
|
-
status,
|
|
9
|
-
headers: { "Content-Type": "application/json", ...headers }
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
function cors(response) {
|
|
13
|
-
const headers = new Headers(response.headers);
|
|
14
|
-
headers.set("Access-Control-Allow-Origin", "*");
|
|
15
|
-
headers.set("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
|
|
16
|
-
headers.set("Access-Control-Allow-Headers", "Authorization, Content-Type");
|
|
17
|
-
return new Response(response.body, { status: response.status, headers });
|
|
18
|
-
}
|
|
19
|
-
async function sha256(input) {
|
|
20
|
-
const encoded = new TextEncoder().encode(input);
|
|
21
|
-
const hash = await crypto.subtle.digest("SHA-256", encoded);
|
|
22
|
-
return Array.from(new Uint8Array(hash)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
23
|
-
}
|
|
24
|
-
async function sha256Base64url(input) {
|
|
25
|
-
const encoded = new TextEncoder().encode(input);
|
|
26
|
-
const hash = await crypto.subtle.digest("SHA-256", encoded);
|
|
27
|
-
const bytes = new Uint8Array(hash);
|
|
28
|
-
return btoa(String.fromCharCode.apply(null, Array.from(bytes))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
29
|
-
}
|
|
30
|
-
function generateToken() {
|
|
31
|
-
const bytes = new Uint8Array(32);
|
|
32
|
-
crypto.getRandomValues(bytes);
|
|
33
|
-
return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
34
|
-
}
|
|
35
|
-
function handleProtectedResourceMetadata(url) {
|
|
36
|
-
return json({
|
|
37
|
-
resource: url.origin,
|
|
38
|
-
authorization_servers: [url.origin],
|
|
39
|
-
bearer_methods_supported: ["header"]
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
function handleAuthServerMetadata(url) {
|
|
43
|
-
return json({
|
|
44
|
-
issuer: url.origin,
|
|
45
|
-
authorization_endpoint: `${url.origin}/oauth/authorize`,
|
|
46
|
-
token_endpoint: `${url.origin}/oauth/token`,
|
|
47
|
-
registration_endpoint: `${url.origin}/oauth/register`,
|
|
48
|
-
response_types_supported: ["code"],
|
|
49
|
-
grant_types_supported: ["authorization_code"],
|
|
50
|
-
code_challenge_methods_supported: ["S256"],
|
|
51
|
-
token_endpoint_auth_methods_supported: ["none"],
|
|
52
|
-
scopes_supported: ["memory"]
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
async function handleRegister(request, env) {
|
|
56
|
-
const body = await request.json();
|
|
57
|
-
if (!body.redirect_uris?.length) {
|
|
58
|
-
return json({ error: "redirect_uris required" }, 400);
|
|
59
|
-
}
|
|
60
|
-
const clientId = crypto.randomUUID();
|
|
61
|
-
await env.DB.prepare(`
|
|
62
|
-
INSERT INTO oauth_clients (client_id, redirect_uris, client_name)
|
|
63
|
-
VALUES (?, ?, ?)
|
|
64
|
-
`).bind(clientId, JSON.stringify(body.redirect_uris), body.client_name || "").run();
|
|
65
|
-
return json({
|
|
66
|
-
client_id: clientId,
|
|
67
|
-
redirect_uris: body.redirect_uris,
|
|
68
|
-
client_name: body.client_name || "",
|
|
69
|
-
token_endpoint_auth_method: "none"
|
|
70
|
-
}, 201);
|
|
71
|
-
}
|
|
72
|
-
async function handleAuthorize(request, url, env) {
|
|
73
|
-
const clientId = url.searchParams.get("client_id");
|
|
74
|
-
const redirectUri = url.searchParams.get("redirect_uri");
|
|
75
|
-
const codeChallenge = url.searchParams.get("code_challenge");
|
|
76
|
-
const codeChallengeMethod = url.searchParams.get("code_challenge_method") || "S256";
|
|
77
|
-
const state = url.searchParams.get("state");
|
|
78
|
-
const scope = url.searchParams.get("scope") || "memory";
|
|
79
|
-
if (!clientId || !redirectUri || !codeChallenge) {
|
|
80
|
-
return json({ error: "Missing required parameters (client_id, redirect_uri, code_challenge)" }, 400);
|
|
81
|
-
}
|
|
82
|
-
if (codeChallengeMethod !== "S256") {
|
|
83
|
-
return json({ error: "Only S256 code_challenge_method supported" }, 400);
|
|
84
|
-
}
|
|
85
|
-
const client = await env.DB.prepare(
|
|
86
|
-
"SELECT * FROM oauth_clients WHERE client_id = ?"
|
|
87
|
-
).bind(clientId).first();
|
|
88
|
-
if (!client) {
|
|
89
|
-
return json({ error: "Unknown client_id" }, 400);
|
|
90
|
-
}
|
|
91
|
-
const allowedUris = JSON.parse(client.redirect_uris);
|
|
92
|
-
if (!allowedUris.includes(redirectUri)) {
|
|
93
|
-
return json({ error: "redirect_uri not registered" }, 400);
|
|
94
|
-
}
|
|
95
|
-
if (request.method === "GET") {
|
|
96
|
-
return new Response(consentPage(clientId, redirectUri, codeChallenge, codeChallengeMethod, state, scope), {
|
|
97
|
-
headers: { "Content-Type": "text/html" }
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
const formData = await request.formData();
|
|
101
|
-
const email = formData.get("email");
|
|
102
|
-
if (!email) {
|
|
103
|
-
return json({ error: "Email required" }, 400);
|
|
104
|
-
}
|
|
105
|
-
const userId = await sha256(email.toLowerCase().trim());
|
|
106
|
-
await env.DB.prepare(`
|
|
107
|
-
INSERT INTO users (user_id, email) VALUES (?, ?)
|
|
108
|
-
ON CONFLICT (user_id) DO NOTHING
|
|
109
|
-
`).bind(userId, email.toLowerCase().trim()).run();
|
|
110
|
-
const code = generateToken();
|
|
111
|
-
const expiresAt = new Date(Date.now() + 10 * 60 * 1e3).toISOString();
|
|
112
|
-
await env.DB.prepare(`
|
|
113
|
-
INSERT INTO authorization_codes (code, client_id, user_id, code_challenge, code_challenge_method, redirect_uri, scope, expires_at)
|
|
114
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
115
|
-
`).bind(code, clientId, userId, codeChallenge, codeChallengeMethod, redirectUri, scope, expiresAt).run();
|
|
116
|
-
const redirect = new URL(redirectUri);
|
|
117
|
-
redirect.searchParams.set("code", code);
|
|
118
|
-
if (state) redirect.searchParams.set("state", state);
|
|
119
|
-
return Response.redirect(redirect.toString(), 302);
|
|
120
|
-
}
|
|
121
|
-
async function handleToken(request, env) {
|
|
122
|
-
const body = await request.formData();
|
|
123
|
-
const grantType = body.get("grant_type");
|
|
124
|
-
const code = body.get("code");
|
|
125
|
-
const redirectUri = body.get("redirect_uri");
|
|
126
|
-
const codeVerifier = body.get("code_verifier");
|
|
127
|
-
if (grantType !== "authorization_code") {
|
|
128
|
-
return json({ error: "unsupported_grant_type" }, 400);
|
|
129
|
-
}
|
|
130
|
-
if (!code || !codeVerifier) {
|
|
131
|
-
return json({ error: "Missing code or code_verifier" }, 400);
|
|
132
|
-
}
|
|
133
|
-
const authCode = await env.DB.prepare(
|
|
134
|
-
"SELECT * FROM authorization_codes WHERE code = ? AND used = 0"
|
|
135
|
-
).bind(code).first();
|
|
136
|
-
if (!authCode) {
|
|
137
|
-
return json({ error: "invalid_grant", error_description: "Code not found or already used" }, 400);
|
|
138
|
-
}
|
|
139
|
-
if (new Date(authCode.expires_at) < /* @__PURE__ */ new Date()) {
|
|
140
|
-
return json({ error: "invalid_grant", error_description: "Code expired" }, 400);
|
|
141
|
-
}
|
|
142
|
-
if (redirectUri && authCode.redirect_uri !== redirectUri) {
|
|
143
|
-
return json({ error: "invalid_grant", error_description: "redirect_uri mismatch" }, 400);
|
|
144
|
-
}
|
|
145
|
-
const expectedChallenge = await sha256Base64url(codeVerifier);
|
|
146
|
-
if (expectedChallenge !== authCode.code_challenge) {
|
|
147
|
-
return json({ error: "invalid_grant", error_description: "PKCE verification failed" }, 400);
|
|
148
|
-
}
|
|
149
|
-
await env.DB.prepare("UPDATE authorization_codes SET used = 1 WHERE code = ?").bind(code).run();
|
|
150
|
-
const user = await env.DB.prepare("SELECT * FROM users WHERE user_id = ?").bind(authCode.user_id).first();
|
|
151
|
-
const tier = user?.tier || "sovereign";
|
|
152
|
-
const accessToken = generateToken();
|
|
153
|
-
const tokenHash = await sha256(accessToken);
|
|
154
|
-
const expiresAt = new Date(Date.now() + 90 * 24 * 60 * 60 * 1e3).toISOString();
|
|
155
|
-
await env.DB.prepare(`
|
|
156
|
-
INSERT INTO access_tokens (token_hash, client_id, user_id, scope, tier, expires_at)
|
|
157
|
-
VALUES (?, ?, ?, ?, ?, ?)
|
|
158
|
-
`).bind(tokenHash, authCode.client_id, authCode.user_id, authCode.scope, tier, expiresAt).run();
|
|
159
|
-
return json({
|
|
160
|
-
access_token: accessToken,
|
|
161
|
-
token_type: "Bearer",
|
|
162
|
-
expires_in: 90 * 24 * 60 * 60,
|
|
163
|
-
scope: authCode.scope
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
async function verifyToken(request, env) {
|
|
167
|
-
const auth = request.headers.get("Authorization");
|
|
168
|
-
if (!auth?.startsWith("Bearer ")) {
|
|
169
|
-
return json({ error: "Missing Authorization header" }, 401);
|
|
170
|
-
}
|
|
171
|
-
const token = auth.slice(7);
|
|
172
|
-
const tokenHash = await sha256(token);
|
|
173
|
-
const row = await env.DB.prepare(
|
|
174
|
-
"SELECT * FROM access_tokens WHERE token_hash = ?"
|
|
175
|
-
).bind(tokenHash).first();
|
|
176
|
-
if (!row) {
|
|
177
|
-
return json({ error: "Invalid token" }, 401);
|
|
178
|
-
}
|
|
179
|
-
if (new Date(row.expires_at) < /* @__PURE__ */ new Date()) {
|
|
180
|
-
return json({ error: "Token expired" }, 401);
|
|
181
|
-
}
|
|
182
|
-
return {
|
|
183
|
-
user_id: row.user_id,
|
|
184
|
-
client_id: row.client_id,
|
|
185
|
-
scope: row.scope,
|
|
186
|
-
tier: row.tier
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
function consentPage(clientId, redirectUri, codeChallenge, codeChallengeMethod, state, scope) {
|
|
190
|
-
return `<!DOCTYPE html>
|
|
191
|
-
<html>
|
|
192
|
-
<head>
|
|
193
|
-
<meta charset="utf-8">
|
|
194
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
195
|
-
<title>Memory Crystal</title>
|
|
196
|
-
<style>
|
|
197
|
-
body { font-family: -apple-system, system-ui, sans-serif; max-width: 420px; margin: 60px auto; padding: 0 20px; color: #1a1a1a; }
|
|
198
|
-
h1 { font-size: 1.4em; }
|
|
199
|
-
p { color: #555; line-height: 1.5; }
|
|
200
|
-
form { margin-top: 24px; }
|
|
201
|
-
label { display: block; font-weight: 500; margin-bottom: 6px; }
|
|
202
|
-
input[type=email] { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 16px; box-sizing: border-box; }
|
|
203
|
-
button { margin-top: 16px; width: 100%; padding: 12px; background: #1a1a1a; color: white; border: none; border-radius: 6px; font-size: 16px; cursor: pointer; }
|
|
204
|
-
button:hover { background: #333; }
|
|
205
|
-
.note { font-size: 0.85em; color: #888; margin-top: 16px; }
|
|
206
|
-
</style>
|
|
207
|
-
</head>
|
|
208
|
-
<body>
|
|
209
|
-
<h1>Memory Crystal</h1>
|
|
210
|
-
<p>An app wants to access your memory. Enter your email to continue.</p>
|
|
211
|
-
<form method="POST">
|
|
212
|
-
<input type="hidden" name="client_id" value="${clientId}">
|
|
213
|
-
<input type="hidden" name="redirect_uri" value="${redirectUri}">
|
|
214
|
-
<input type="hidden" name="code_challenge" value="${codeChallenge}">
|
|
215
|
-
<input type="hidden" name="code_challenge_method" value="${codeChallengeMethod}">
|
|
216
|
-
${state ? `<input type="hidden" name="state" value="${state}">` : ""}
|
|
217
|
-
<input type="hidden" name="scope" value="${scope}">
|
|
218
|
-
<label for="email">Email</label>
|
|
219
|
-
<input type="email" id="email" name="email" required placeholder="you@example.com" autocomplete="email">
|
|
220
|
-
<button type="submit">Connect Memory</button>
|
|
221
|
-
</form>
|
|
222
|
-
<p class="note">Your email identifies your memory account. No password needed... your AI client handles authentication.</p>
|
|
223
|
-
</body>
|
|
224
|
-
</html>`;
|
|
225
|
-
}
|
|
226
|
-
var TOOLS = [
|
|
227
|
-
{
|
|
228
|
-
name: "memory_search",
|
|
229
|
-
description: "Search your memories across all conversations and surfaces.",
|
|
230
|
-
inputSchema: {
|
|
231
|
-
type: "object",
|
|
232
|
-
properties: {
|
|
233
|
-
query: { type: "string", description: "What to search for" },
|
|
234
|
-
limit: { type: "number", description: "Max results (default 5, max 20)" }
|
|
235
|
-
},
|
|
236
|
-
required: ["query"]
|
|
237
|
-
},
|
|
238
|
-
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
name: "memory_remember",
|
|
242
|
-
description: "Save a fact, preference, or observation to your memory.",
|
|
243
|
-
inputSchema: {
|
|
244
|
-
type: "object",
|
|
245
|
-
properties: {
|
|
246
|
-
text: { type: "string", description: "The fact or observation to remember" },
|
|
247
|
-
category: {
|
|
248
|
-
type: "string",
|
|
249
|
-
enum: ["fact", "preference", "event", "opinion", "skill"],
|
|
250
|
-
description: "Category of memory (default: fact)"
|
|
251
|
-
}
|
|
252
|
-
},
|
|
253
|
-
required: ["text"]
|
|
254
|
-
},
|
|
255
|
-
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false }
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
name: "memory_forget",
|
|
259
|
-
description: "Deprecate a memory by ID.",
|
|
260
|
-
inputSchema: {
|
|
261
|
-
type: "object",
|
|
262
|
-
properties: {
|
|
263
|
-
id: { type: "number", description: "Memory ID to deprecate" }
|
|
264
|
-
},
|
|
265
|
-
required: ["id"]
|
|
266
|
-
},
|
|
267
|
-
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true }
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
name: "memory_status",
|
|
271
|
-
description: "Show your memory status: chunk count, memory count, connected agents.",
|
|
272
|
-
inputSchema: { type: "object", properties: {} },
|
|
273
|
-
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
274
|
-
}
|
|
275
|
-
];
|
|
276
|
-
async function handleMCP(request, env, tokenInfo) {
|
|
277
|
-
const body = await request.json();
|
|
278
|
-
const { method, id, params } = body;
|
|
279
|
-
const crystal = new CloudCrystal(env.DB, env.VECTORIZE, env.OPENAI_API_KEY);
|
|
280
|
-
let result;
|
|
281
|
-
switch (method) {
|
|
282
|
-
case "initialize":
|
|
283
|
-
result = {
|
|
284
|
-
protocolVersion: "2025-03-26",
|
|
285
|
-
serverInfo: { name: "memory-crystal", version: "0.2.0" },
|
|
286
|
-
capabilities: { tools: {} }
|
|
287
|
-
};
|
|
288
|
-
break;
|
|
289
|
-
case "tools/list":
|
|
290
|
-
result = { tools: TOOLS };
|
|
291
|
-
break;
|
|
292
|
-
case "tools/call": {
|
|
293
|
-
const toolName = params?.name;
|
|
294
|
-
const args = params?.arguments || {};
|
|
295
|
-
switch (toolName) {
|
|
296
|
-
case "memory_search": {
|
|
297
|
-
if (tokenInfo.tier === "sovereign") {
|
|
298
|
-
result = {
|
|
299
|
-
content: [{
|
|
300
|
-
type: "text",
|
|
301
|
-
text: "Search is available on your local devices only (Sovereign tier). Your memories from this session have been saved and will be searchable from any device with Memory Crystal installed locally."
|
|
302
|
-
}]
|
|
303
|
-
};
|
|
304
|
-
} else {
|
|
305
|
-
const limit = Math.min(args.limit || 5, 20);
|
|
306
|
-
const results = await crystal.search(tokenInfo.user_id, args.query, limit);
|
|
307
|
-
const formatted = results.map(
|
|
308
|
-
(r, i) => `[${i + 1}] (${r.score.toFixed(1)}% match, ${r.agent_id}, ${r.created_at})
|
|
309
|
-
${r.text}`
|
|
310
|
-
).join("\n\n");
|
|
311
|
-
result = {
|
|
312
|
-
content: [{
|
|
313
|
-
type: "text",
|
|
314
|
-
text: results.length > 0 ? formatted : `No results for "${args.query}".`
|
|
315
|
-
}]
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
break;
|
|
319
|
-
}
|
|
320
|
-
case "memory_remember": {
|
|
321
|
-
if (tokenInfo.tier === "sovereign") {
|
|
322
|
-
}
|
|
323
|
-
const memId = await crystal.remember(tokenInfo.user_id, args.text, args.category || "fact");
|
|
324
|
-
result = {
|
|
325
|
-
content: [{
|
|
326
|
-
type: "text",
|
|
327
|
-
text: `Remembered (id: ${memId}, category: ${args.category || "fact"}): ${args.text}`
|
|
328
|
-
}]
|
|
329
|
-
};
|
|
330
|
-
break;
|
|
331
|
-
}
|
|
332
|
-
case "memory_forget": {
|
|
333
|
-
const ok = await crystal.forget(tokenInfo.user_id, args.id);
|
|
334
|
-
result = {
|
|
335
|
-
content: [{
|
|
336
|
-
type: "text",
|
|
337
|
-
text: ok ? `Memory ${args.id} deprecated.` : `Memory ${args.id} not found or already deprecated.`
|
|
338
|
-
}]
|
|
339
|
-
};
|
|
340
|
-
break;
|
|
341
|
-
}
|
|
342
|
-
case "memory_status": {
|
|
343
|
-
const status = await crystal.status(tokenInfo.user_id);
|
|
344
|
-
result = {
|
|
345
|
-
content: [{
|
|
346
|
-
type: "text",
|
|
347
|
-
text: [
|
|
348
|
-
`Chunks: ${status.chunks}`,
|
|
349
|
-
`Memories: ${status.memories}`,
|
|
350
|
-
`Agents: ${status.agents.join(", ") || "none"}`,
|
|
351
|
-
`Tier: ${status.tier}`
|
|
352
|
-
].join("\n")
|
|
353
|
-
}]
|
|
354
|
-
};
|
|
355
|
-
break;
|
|
356
|
-
}
|
|
357
|
-
default:
|
|
358
|
-
return json({ jsonrpc: "2.0", id, error: { code: -32601, message: `Unknown tool: ${toolName}` } });
|
|
359
|
-
}
|
|
360
|
-
break;
|
|
361
|
-
}
|
|
362
|
-
case "notifications/initialized":
|
|
363
|
-
return new Response(null, { status: 204 });
|
|
364
|
-
default:
|
|
365
|
-
return json({ jsonrpc: "2.0", id, error: { code: -32601, message: `Unknown method: ${method}` } });
|
|
366
|
-
}
|
|
367
|
-
return json({ jsonrpc: "2.0", id, result });
|
|
368
|
-
}
|
|
369
|
-
var worker_mcp_default = {
|
|
370
|
-
async fetch(request, env) {
|
|
371
|
-
const url = new URL(request.url);
|
|
372
|
-
const path = url.pathname;
|
|
373
|
-
if (request.method === "OPTIONS") {
|
|
374
|
-
return cors(new Response(null, { status: 204 }));
|
|
375
|
-
}
|
|
376
|
-
if (path === "/health" && request.method === "GET") {
|
|
377
|
-
return cors(json({ ok: true, service: "memory-crystal-cloud", version: "0.2.0" }));
|
|
378
|
-
}
|
|
379
|
-
if (path === "/.well-known/oauth-protected-resource") {
|
|
380
|
-
return cors(handleProtectedResourceMetadata(url));
|
|
381
|
-
}
|
|
382
|
-
if (path === "/.well-known/oauth-authorization-server") {
|
|
383
|
-
return cors(handleAuthServerMetadata(url));
|
|
384
|
-
}
|
|
385
|
-
if (path === "/oauth/register" && request.method === "POST") {
|
|
386
|
-
return cors(await handleRegister(request, env));
|
|
387
|
-
}
|
|
388
|
-
if (path === "/oauth/authorize") {
|
|
389
|
-
return await handleAuthorize(request, url, env);
|
|
390
|
-
}
|
|
391
|
-
if (path === "/oauth/token" && request.method === "POST") {
|
|
392
|
-
return cors(await handleToken(request, env));
|
|
393
|
-
}
|
|
394
|
-
if (path === "/mcp" && request.method === "POST") {
|
|
395
|
-
const tokenResult = await verifyToken(request, env);
|
|
396
|
-
if (tokenResult instanceof Response) return cors(tokenResult);
|
|
397
|
-
return cors(await handleMCP(request, env, tokenResult));
|
|
398
|
-
}
|
|
399
|
-
return cors(json({ error: "Not found" }, 404));
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
export {
|
|
403
|
-
worker_mcp_default as default
|
|
404
|
-
};
|