wikimemory 0.2.0 → 0.2.2
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 +11 -11
- package/dist/npm-cli/scripts/cli.js +1 -1
- package/dist/npm-cli/scripts/dev.js +2 -1
- package/dist/npm-cli/scripts/setup.js +115 -30
- package/dist/npm-cli/scripts/upgrade.js +3 -2
- package/dist/npm-cli/src/version.js +1 -1
- package/dist/web/assets/{index-buhGyrxi.js → index-CGTHUs4b.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/release-manifest.json +1 -1
- package/skills/wikimemory-install/SKILL.md +8 -8
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ or password manager. No Google Cloud project or OAuth application is required.
|
|
|
18
18
|
|
|
19
19
|
```sh
|
|
20
20
|
npx wrangler login
|
|
21
|
-
npx wikimemory install
|
|
21
|
+
npx --yes wikimemory install
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
The installer previews the exact Cloudflare account, Worker, D1 database, and KV
|
|
@@ -26,12 +26,12 @@ namespace before creating anything. Open its one-time URL to register the owner
|
|
|
26
26
|
passkey, then connect a client and install its memory skills:
|
|
27
27
|
|
|
28
28
|
```sh
|
|
29
|
-
npx wikimemory connect codex
|
|
30
|
-
npx wikimemory skills install codex
|
|
29
|
+
npx --yes wikimemory connect codex
|
|
30
|
+
npx --yes wikimemory skills install codex
|
|
31
31
|
|
|
32
32
|
# or
|
|
33
|
-
npx wikimemory connect claude
|
|
34
|
-
npx wikimemory skills install claude
|
|
33
|
+
npx --yes wikimemory connect claude
|
|
34
|
+
npx --yes wikimemory skills install claude
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
Use the same remote MCP from Claude web or mobile by adding the printed HTTPS `/mcp`
|
|
@@ -41,7 +41,7 @@ for recovery, passkey management, upgrades, and safe uninstall.
|
|
|
41
41
|
## Local development without a checkout
|
|
42
42
|
|
|
43
43
|
```sh
|
|
44
|
-
npx wikimemory dev
|
|
44
|
+
npx --yes wikimemory dev
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
This starts the packaged Worker, React app, D1, and KV through local Wrangler
|
|
@@ -52,11 +52,11 @@ and MCP transport remain real.
|
|
|
52
52
|
## Lifecycle commands
|
|
53
53
|
|
|
54
54
|
```sh
|
|
55
|
-
npx wikimemory status
|
|
56
|
-
npx wikimemory upgrade
|
|
57
|
-
npx wikimemory recover
|
|
58
|
-
npx wikimemory passkeys list
|
|
59
|
-
npx wikimemory uninstall # preview only
|
|
55
|
+
npx --yes wikimemory status
|
|
56
|
+
npx --yes wikimemory upgrade
|
|
57
|
+
npx --yes wikimemory recover
|
|
58
|
+
npx --yes wikimemory passkeys list
|
|
59
|
+
npx --yes wikimemory uninstall # preview only
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
Parallel installations use `--deployment NAME`. Non-secret lifecycle state lives
|
|
@@ -7,7 +7,7 @@ import { deploymentPaths } from "./deployment-record.js";
|
|
|
7
7
|
import { packageRoot } from "./package-root.js";
|
|
8
8
|
const [command, ...args] = process.argv.slice(2);
|
|
9
9
|
function usage() {
|
|
10
|
-
return `Wikimemory ${WIKIMEMORY_VERSION}\n\nUsage:\n wikimemory install [--deployment NAME] [installer options]\n wikimemory recover [--deployment NAME]\n wikimemory dev [wrangler dev options]\n wikimemory status [--deployment NAME]\n wikimemory upgrade [--deployment NAME] [--yes]\n wikimemory passkeys [--deployment NAME] list|add|revoke\n wikimemory connect [--deployment NAME] codex|claude\n wikimemory skills install codex|claude\n wikimemory uninstall [--deployment NAME] [--apply]\n wikimemory --version
|
|
10
|
+
return `Wikimemory ${WIKIMEMORY_VERSION}\nPersonal, passkey-protected memory for Claude, Codex, and other MCP clients.\n\nUsage: wikimemory COMMAND [OPTIONS]\n\nStart a personal Cloudflare-hosted instance:\n npx --yes wikimemory install\n\nTry it locally without a Cloudflare deployment:\n npx --yes wikimemory dev\n\nCommands:\n wikimemory install [--deployment NAME] [installer options]\n wikimemory recover [--deployment NAME]\n wikimemory dev [wrangler dev options]\n wikimemory status [--deployment NAME]\n wikimemory upgrade [--deployment NAME] [--yes]\n wikimemory passkeys [--deployment NAME] list|add|revoke\n wikimemory connect [--deployment NAME] codex|claude\n wikimemory skills install codex|claude\n wikimemory uninstall [--deployment NAME] [--apply]\n wikimemory --version\n\nUse \`wikimemory COMMAND --help\` for command-specific options.`;
|
|
11
11
|
}
|
|
12
12
|
async function main() {
|
|
13
13
|
if (command === undefined || command === "--help" || command === "help") {
|
|
@@ -11,7 +11,8 @@ export function localConfig(packageRoot) {
|
|
|
11
11
|
assets: {
|
|
12
12
|
directory: join(packageRoot, "dist", "web"),
|
|
13
13
|
binding: "ASSETS",
|
|
14
|
-
not_found_handling: "single-page-application"
|
|
14
|
+
not_found_handling: "single-page-application",
|
|
15
|
+
run_worker_first: true
|
|
15
16
|
},
|
|
16
17
|
vars: { APP_ENV: "local" },
|
|
17
18
|
d1_databases: [
|
|
@@ -32,6 +32,59 @@ const STATE_SCHEMA = z.object({
|
|
|
32
32
|
kvName: z.string()
|
|
33
33
|
});
|
|
34
34
|
const D1_QUERY_SCHEMA = z.array(z.object({ results: z.array(z.object({ name: z.string() })) }));
|
|
35
|
+
function cloudflareOperation(args) {
|
|
36
|
+
const command = args[1] ?? "command";
|
|
37
|
+
const subcommand = args[2];
|
|
38
|
+
if (command === "whoami")
|
|
39
|
+
return "Cloudflare authentication check";
|
|
40
|
+
if (command === "deployments")
|
|
41
|
+
return "Worker lookup";
|
|
42
|
+
if (command === "deploy")
|
|
43
|
+
return "Worker deployment";
|
|
44
|
+
if (command === "secret")
|
|
45
|
+
return "Owner setup credential upload";
|
|
46
|
+
if (command === "d1" && subcommand === "list")
|
|
47
|
+
return "D1 database lookup";
|
|
48
|
+
if (command === "d1" && subcommand === "create")
|
|
49
|
+
return "D1 database creation";
|
|
50
|
+
if (command === "d1" && subcommand === "execute")
|
|
51
|
+
return "D1 database migration";
|
|
52
|
+
if (command === "kv" && args[3] === "namespace" && args[4] === "list")
|
|
53
|
+
return "KV namespace lookup";
|
|
54
|
+
if (command === "kv" && args[3] === "namespace" && args[4] === "create")
|
|
55
|
+
return "KV namespace creation";
|
|
56
|
+
return `Cloudflare ${command}`;
|
|
57
|
+
}
|
|
58
|
+
function conciseDiagnostic(result) {
|
|
59
|
+
const raw = result.stderr.trim() || result.stdout.trim();
|
|
60
|
+
const plain = raw.replaceAll("\u001b", "").replaceAll(/\s+/gu, " ").trim();
|
|
61
|
+
if (plain === "")
|
|
62
|
+
return `process exited with status ${result.exitCode}`;
|
|
63
|
+
return plain.length > 600 ? `${plain.slice(0, 597)}...` : plain;
|
|
64
|
+
}
|
|
65
|
+
export function commandFailureMessage(operation, result) {
|
|
66
|
+
return `${operation} failed: ${conciseDiagnostic(result)}`;
|
|
67
|
+
}
|
|
68
|
+
async function sleep(milliseconds) {
|
|
69
|
+
await new Promise((resolve) => {
|
|
70
|
+
setTimeout(resolve, milliseconds);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export async function retryOperation(operation, execute, sleeper = sleep, attempts = 3) {
|
|
74
|
+
let finalError;
|
|
75
|
+
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
76
|
+
try {
|
|
77
|
+
return await execute();
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
finalError = error;
|
|
81
|
+
if (attempt + 1 < attempts)
|
|
82
|
+
await sleeper(250 * 2 ** attempt);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const detail = finalError instanceof Error ? finalError.message : "Unknown failure";
|
|
86
|
+
throw new Error(`${operation} failed after ${attempts} attempts: ${detail}`);
|
|
87
|
+
}
|
|
35
88
|
export function parseOptions(args) {
|
|
36
89
|
let recover = false;
|
|
37
90
|
let resume = false;
|
|
@@ -81,7 +134,7 @@ export function parseOptions(args) {
|
|
|
81
134
|
return { recover, resume, yes, help, workerName, databaseName, kvName, accountId };
|
|
82
135
|
}
|
|
83
136
|
function usage() {
|
|
84
|
-
return `
|
|
137
|
+
return `Deploy a personal Wikimemory instance to your Cloudflare account.\nThe installer previews every Worker, D1, and KV resource before creating it.\n\nUsage: ${setupRuntime.executable} [--account-id ID] [--yes] [--worker-name NAME] [--database-name NAME] [--kv-name NAME]\n ${setupRuntime.executable} --resume [--yes]\n ${setupRuntime.executable} --recover [--yes]`;
|
|
85
138
|
}
|
|
86
139
|
async function exists(path) {
|
|
87
140
|
try {
|
|
@@ -93,7 +146,6 @@ async function exists(path) {
|
|
|
93
146
|
}
|
|
94
147
|
}
|
|
95
148
|
async function run(command, args, input, allowFailure = false) {
|
|
96
|
-
console.log(`\n> ${command} ${args.join(" ")}`);
|
|
97
149
|
const result = await new Promise((resolve, reject) => {
|
|
98
150
|
const child = spawn(command, args, { stdio: ["pipe", "pipe", "pipe"] });
|
|
99
151
|
let stdout = "";
|
|
@@ -102,11 +154,9 @@ async function run(command, args, input, allowFailure = false) {
|
|
|
102
154
|
child.stderr.setEncoding("utf8");
|
|
103
155
|
child.stdout.on("data", (chunk) => {
|
|
104
156
|
stdout += chunk;
|
|
105
|
-
process.stdout.write(chunk);
|
|
106
157
|
});
|
|
107
158
|
child.stderr.on("data", (chunk) => {
|
|
108
159
|
stderr += chunk;
|
|
109
|
-
process.stderr.write(chunk);
|
|
110
160
|
});
|
|
111
161
|
child.on("error", (error) => {
|
|
112
162
|
reject(error);
|
|
@@ -117,7 +167,7 @@ async function run(command, args, input, allowFailure = false) {
|
|
|
117
167
|
child.stdin.end(input === undefined ? undefined : `${input}\n`);
|
|
118
168
|
});
|
|
119
169
|
if (result.exitCode !== 0 && !allowFailure)
|
|
120
|
-
throw new Error(
|
|
170
|
+
throw new Error(commandFailureMessage(cloudflareOperation(args), result));
|
|
121
171
|
return result;
|
|
122
172
|
}
|
|
123
173
|
async function runInteractive(command, args) {
|
|
@@ -146,19 +196,31 @@ export function initialConfig(options, account) {
|
|
|
146
196
|
assets: {
|
|
147
197
|
directory: join(PACKAGE_ROOT, "dist", "web"),
|
|
148
198
|
binding: "ASSETS",
|
|
149
|
-
not_found_handling: "single-page-application"
|
|
199
|
+
not_found_handling: "single-page-application",
|
|
200
|
+
run_worker_first: true
|
|
150
201
|
},
|
|
151
202
|
vars: { APP_ENV: "production", APP_BASE_URL: BOOTSTRAP_ORIGIN }
|
|
152
203
|
}, null, 2)}\n`;
|
|
153
204
|
}
|
|
154
205
|
export function withWebAssets(config) {
|
|
155
|
-
const parsed = z
|
|
206
|
+
const parsed = z
|
|
207
|
+
.looseObject({
|
|
208
|
+
d1_databases: z.array(z.looseObject({ binding: z.string() })).optional()
|
|
209
|
+
})
|
|
210
|
+
.parse(JSON.parse(config));
|
|
211
|
+
const databases = parsed.d1_databases?.map((database) => database.binding === "DB"
|
|
212
|
+
? { ...database, migrations_dir: join(PACKAGE_ROOT, "migrations") }
|
|
213
|
+
: database);
|
|
156
214
|
return `${JSON.stringify({
|
|
157
215
|
...parsed,
|
|
216
|
+
$schema: join(PACKAGE_ROOT, "node_modules", "wrangler", "config-schema.json"),
|
|
217
|
+
main: join(PACKAGE_ROOT, "src", "index.ts"),
|
|
218
|
+
...(databases === undefined ? {} : { d1_databases: databases }),
|
|
158
219
|
assets: {
|
|
159
220
|
directory: join(PACKAGE_ROOT, "dist", "web"),
|
|
160
221
|
binding: "ASSETS",
|
|
161
|
-
not_found_handling: "single-page-application"
|
|
222
|
+
not_found_handling: "single-page-application",
|
|
223
|
+
run_worker_first: true
|
|
162
224
|
}
|
|
163
225
|
}, null, 2)}\n`;
|
|
164
226
|
}
|
|
@@ -292,19 +354,38 @@ function bootstrapSecret() {
|
|
|
292
354
|
const hash = createHash("sha256").update(raw, "utf8").digest("hex");
|
|
293
355
|
return { raw, hash };
|
|
294
356
|
}
|
|
295
|
-
async function verifyEndpoint(origin, path, expectedStatus) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
357
|
+
export async function verifyEndpoint(origin, path, expectedStatus, fetcher = fetch, sleeper = sleep, attempts = 6) {
|
|
358
|
+
let finalDetail = "no response";
|
|
359
|
+
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
360
|
+
try {
|
|
361
|
+
const response = await fetcher(`${origin}${path}`, { redirect: "error" });
|
|
362
|
+
const body = await response.text();
|
|
363
|
+
if (response.ok) {
|
|
364
|
+
const decoded = z
|
|
365
|
+
.object({
|
|
366
|
+
status: z.literal(expectedStatus),
|
|
367
|
+
service: z.literal("wikimemory"),
|
|
368
|
+
version: z.literal(WIKIMEMORY_VERSION)
|
|
369
|
+
})
|
|
370
|
+
.safeParse(JSON.parse(body));
|
|
371
|
+
if (decoded.success)
|
|
372
|
+
return;
|
|
373
|
+
finalDetail = `HTTP ${response.status}: unexpected response ${body.slice(0, 300)}`;
|
|
374
|
+
}
|
|
375
|
+
else
|
|
376
|
+
finalDetail = `HTTP ${response.status}: ${body.slice(0, 300) || response.statusText}`;
|
|
377
|
+
}
|
|
378
|
+
catch (error) {
|
|
379
|
+
finalDetail = error instanceof Error ? error.message : "Unknown request failure";
|
|
380
|
+
}
|
|
381
|
+
if (attempt + 1 < attempts)
|
|
382
|
+
await sleeper(250 * 2 ** attempt);
|
|
383
|
+
}
|
|
384
|
+
throw new Error(`Deployment ${path} check failed after ${attempts} attempts: ${finalDetail}`);
|
|
304
385
|
}
|
|
305
|
-
export function handoff(origin, rawToken) {
|
|
386
|
+
export function handoff(origin, rawToken, deploymentName) {
|
|
306
387
|
const endpoint = `${origin}/mcp`;
|
|
307
|
-
return `Wikimemory is ready for owner setup.\n\nOpen this one-time URL on a device that can create a passkey:\n${origin}/setup#${encodeURIComponent(rawToken)}\n\nAfter setup, connect clients with:\n
|
|
388
|
+
return `Wikimemory is ready for owner setup.\n\nOpen this one-time URL on a device that can create a passkey:\n${origin}/setup#${encodeURIComponent(rawToken)}\n\nAfter setup, connect clients with:\n npx --yes wikimemory connect --deployment ${deploymentName} codex\n npx --yes wikimemory connect --deployment ${deploymentName} claude\n\nMCP endpoint: ${endpoint}\nThe setup token was not written to disk. This is the only time it will be printed.`;
|
|
308
389
|
}
|
|
309
390
|
async function remoteWorkerExists(workerName) {
|
|
310
391
|
const result = await run("npx", ["wrangler", "deployments", "list", "--name", workerName, "--json", "--config", CONFIG_PATH], undefined, true);
|
|
@@ -328,10 +409,8 @@ export function workersDevRegistrationRequired(result) {
|
|
|
328
409
|
diagnostic.includes("workers/onboarding"));
|
|
329
410
|
}
|
|
330
411
|
async function existingResourceNames() {
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
run("npx", ["wrangler", "kv", "namespace", "list", "--config", CONFIG_PATH])
|
|
334
|
-
]);
|
|
412
|
+
const d1 = await retryOperation("D1 database lookup", async () => run("npx", ["wrangler", "d1", "list", "--json", "--config", CONFIG_PATH]));
|
|
413
|
+
const kv = await retryOperation("KV namespace lookup", async () => run("npx", ["wrangler", "kv", "namespace", "list", "--config", CONFIG_PATH]));
|
|
335
414
|
const databases = z.array(z.looseObject({ name: z.string() })).parse(JSON.parse(d1.stdout));
|
|
336
415
|
const namespaces = z.array(z.looseObject({ title: z.string() })).parse(JSON.parse(kv.stdout));
|
|
337
416
|
return {
|
|
@@ -342,6 +421,7 @@ async function existingResourceNames() {
|
|
|
342
421
|
async function ensureResources(options) {
|
|
343
422
|
let config = await readFile(CONFIG_PATH, "utf8");
|
|
344
423
|
if (!hasBinding(config, "DB")) {
|
|
424
|
+
console.log(" Creating D1 database…");
|
|
345
425
|
await run("npx", [
|
|
346
426
|
"wrangler",
|
|
347
427
|
"d1",
|
|
@@ -356,6 +436,7 @@ async function ensureResources(options) {
|
|
|
356
436
|
config = await readFile(CONFIG_PATH, "utf8");
|
|
357
437
|
}
|
|
358
438
|
if (!hasBinding(config, "OAUTH_KV")) {
|
|
439
|
+
console.log(" Creating OAuth state namespace…");
|
|
359
440
|
await run("npx", [
|
|
360
441
|
"wrangler",
|
|
361
442
|
"kv",
|
|
@@ -382,6 +463,7 @@ async function finalizeDeployment(options) {
|
|
|
382
463
|
if (origin === null)
|
|
383
464
|
throw new Error(`${CONFIG_PATH} has no valid APP_BASE_URL.`);
|
|
384
465
|
if (origin === BOOTSTRAP_ORIGIN) {
|
|
466
|
+
console.log(" Creating Worker address…");
|
|
385
467
|
const deployArgs = ["wrangler", "deploy", "--strict", "--config", CONFIG_PATH];
|
|
386
468
|
let firstDeploy = await run("npx", deployArgs, undefined, true);
|
|
387
469
|
if (firstDeploy.exitCode !== 0 && workersDevRegistrationRequired(firstDeploy)) {
|
|
@@ -393,7 +475,7 @@ async function finalizeDeployment(options) {
|
|
|
393
475
|
firstDeploy = await run("npx", deployArgs, undefined, true);
|
|
394
476
|
}
|
|
395
477
|
if (firstDeploy.exitCode !== 0) {
|
|
396
|
-
throw new Error(
|
|
478
|
+
throw new Error(commandFailureMessage("Worker deployment", firstDeploy));
|
|
397
479
|
}
|
|
398
480
|
origin = deployedOrigin(`${firstDeploy.stdout}\n${firstDeploy.stderr}`);
|
|
399
481
|
if (origin === null)
|
|
@@ -408,10 +490,14 @@ async function finalizeDeployment(options) {
|
|
|
408
490
|
const boundDatabaseName = bindingProperty(config, "DB", "database_name");
|
|
409
491
|
if (boundDatabaseName === null)
|
|
410
492
|
throw new Error(`${CONFIG_PATH} has a DB binding without a database_name.`);
|
|
493
|
+
console.log(" Applying database migrations…");
|
|
411
494
|
await applyRemoteMigrations(boundDatabaseName);
|
|
412
495
|
const secret = bootstrapSecret();
|
|
496
|
+
console.log(" Deploying Wikimemory…");
|
|
413
497
|
await run("npx", ["wrangler", "deploy", "--strict", "--config", CONFIG_PATH]);
|
|
498
|
+
console.log(" Creating one-time owner setup…");
|
|
414
499
|
await run("npx", ["wrangler", "secret", "put", "SETUP_TOKEN_HASH", "--config", CONFIG_PATH], secret.hash);
|
|
500
|
+
console.log(" Waiting for deployment readiness…");
|
|
415
501
|
await verifyEndpoint(origin, "/health", "ok");
|
|
416
502
|
await verifyEndpoint(origin, "/ready", "ready");
|
|
417
503
|
const finalConfig = await readFile(CONFIG_PATH, "utf8");
|
|
@@ -419,7 +505,7 @@ async function finalizeDeployment(options) {
|
|
|
419
505
|
const recordPath = installedRecordPath(options.workerName);
|
|
420
506
|
await writeDeploymentRecord(deploymentRecord, recordPath);
|
|
421
507
|
console.log(`\nSaved deployment record: ${recordPath}`);
|
|
422
|
-
console.log(`\n${handoff(origin, secret.raw)}`);
|
|
508
|
+
console.log(`\n${handoff(origin, secret.raw, options.workerName)}`);
|
|
423
509
|
}
|
|
424
510
|
async function freshDeployment(options) {
|
|
425
511
|
if (await exists(CONFIG_PATH))
|
|
@@ -434,10 +520,9 @@ async function freshDeployment(options) {
|
|
|
434
520
|
let workerExists;
|
|
435
521
|
let resources;
|
|
436
522
|
try {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
]);
|
|
523
|
+
console.log("\nChecking that Cloudflare resource names are available…");
|
|
524
|
+
workerExists = await retryOperation("Worker lookup", async () => remoteWorkerExists(options.workerName));
|
|
525
|
+
resources = await existingResourceNames();
|
|
441
526
|
}
|
|
442
527
|
catch (error) {
|
|
443
528
|
await unlink(CONFIG_PATH);
|
|
@@ -499,7 +584,7 @@ async function recover(options) {
|
|
|
499
584
|
await run("npx", ["wrangler", "secret", "put", "SETUP_TOKEN_HASH", "--config", CONFIG_PATH], secret.hash);
|
|
500
585
|
await verifyEndpoint(origin, "/health", "ok");
|
|
501
586
|
await verifyEndpoint(origin, "/ready", "ready");
|
|
502
|
-
console.log(`\n${handoff(origin, secret.raw)}`);
|
|
587
|
+
console.log(`\n${handoff(origin, secret.raw, options.workerName)}`);
|
|
503
588
|
}
|
|
504
589
|
export async function runSetup(args) {
|
|
505
590
|
const options = parseOptions(args);
|
|
@@ -90,7 +90,8 @@ export function productionUpgradeConfig(record, packageRoot) {
|
|
|
90
90
|
assets: {
|
|
91
91
|
directory: join(packageRoot, "dist", "web"),
|
|
92
92
|
binding: "ASSETS",
|
|
93
|
-
not_found_handling: "single-page-application"
|
|
93
|
+
not_found_handling: "single-page-application",
|
|
94
|
+
run_worker_first: true
|
|
94
95
|
},
|
|
95
96
|
vars: { APP_ENV: "production", APP_BASE_URL: record.origin },
|
|
96
97
|
d1_databases: [
|
|
@@ -108,7 +109,7 @@ const PRODUCTION_UPGRADE_CONFIG_SCHEMA = z.object({
|
|
|
108
109
|
name: z.string(),
|
|
109
110
|
account_id: z.string(),
|
|
110
111
|
main: z.string(),
|
|
111
|
-
assets: z.object({ directory: z.string() }),
|
|
112
|
+
assets: z.object({ directory: z.string(), run_worker_first: z.literal(true) }),
|
|
112
113
|
vars: z.object({ APP_BASE_URL: z.string() }),
|
|
113
114
|
d1_databases: z.array(z.object({ database_id: z.string() })),
|
|
114
115
|
kv_namespaces: z.array(z.object({ id: z.string() }))
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const WIKIMEMORY_VERSION = "0.2.
|
|
1
|
+
export const WIKIMEMORY_VERSION = "0.2.2";
|
|
2
2
|
export const LATEST_SCHEMA_VERSION = "0004_credential_bound_registration_tokens.sql";
|
|
@@ -69,4 +69,4 @@ Error generating stack: `+e.message+`
|
|
|
69
69
|
|
|
70
70
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=ge,s=!ae.jitless,c=s&&_e.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Ln([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Bn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Me(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Ie(e,r,oe())))}),t)}var Vn=C(`$ZodUnion`,(e,t)=>{A.init(e,t),D(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),D(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),D(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),D(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>T(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Bn(t,r,e,i)):Bn(o,r,e,i)}}),Hn=C(`$ZodIntersection`,(e,t)=>{A.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Wn(e,t,n)):Wn(e,i,a)}});function Un(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ve(e)&&ve(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Un(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Un(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Wn(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Me(e))return e;let o=Un(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Gn=C(`$ZodEnum`,(e,t)=>{A.init(e,t);let n=se(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>be.has(typeof e)).map(e=>typeof e==`string`?xe(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Kn=C(`$ZodLiteral`,(e,t)=>{if(A.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?xe(e):e?xe(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),qn=C(`$ZodTransform`,(e,t)=>{A.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ie(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new w;return n.value=i,n.fallback=!0,n}});function Jn(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Yn=C(`$ZodOptional`,(e,t)=>{A.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,D(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),D(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${T(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Jn(e,r)):Jn(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Xn=C(`$ZodExactOptional`,(e,t)=>{Yn.init(e,t),D(e._zod,`values`,()=>t.innerType._zod.values),D(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Zn=C(`$ZodNullable`,(e,t)=>{A.init(e,t),D(e._zod,`optin`,()=>t.innerType._zod.optin),D(e._zod,`optout`,()=>t.innerType._zod.optout),D(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${T(e.source)}|null)$`):void 0}),D(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Qn=C(`$ZodDefault`,(e,t)=>{A.init(e,t),e._zod.optin=`optional`,D(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>$n(e,t)):$n(r,t)}});function $n(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var er=C(`$ZodPrefault`,(e,t)=>{A.init(e,t),e._zod.optin=`optional`,D(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),tr=C(`$ZodNonOptional`,(e,t)=>{A.init(e,t),D(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>nr(t,e)):nr(i,e)}});function nr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var rr=C(`$ZodCatch`,(e,t)=>{A.init(e,t),e._zod.optin=`optional`,D(e._zod,`optout`,()=>t.innerType._zod.optout),D(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Ie(e,n,oe()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Ie(e,n,oe()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),ir=C(`$ZodPipe`,(e,t)=>{A.init(e,t),D(e._zod,`values`,()=>t.in._zod.values),D(e._zod,`optin`,()=>t.in._zod.optin),D(e._zod,`optout`,()=>t.out._zod.optout),D(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>ar(e,t.in,n)):ar(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ar(e,t.out,n)):ar(r,t.out,n)}});function ar(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var or=C(`$ZodReadonly`,(e,t)=>{A.init(e,t),D(e._zod,`propValues`,()=>t.innerType._zod.propValues),D(e._zod,`values`,()=>t.innerType._zod.values),D(e._zod,`optin`,()=>t.innerType?._zod?.optin),D(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(sr):sr(r)}});function sr(e){return e.value=Object.freeze(e.value),e}var cr=C(`$ZodCustom`,(e,t)=>{Ft.init(e,t),A.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>lr(t,n,r,e));lr(i,n,r,e)}});function lr(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Re(e))}}var ur,dr=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function fr(){return new dr}(ur=globalThis).__zod_globalRegistry??(ur.__zod_globalRegistry=fr());var pr=globalThis.__zod_globalRegistry;function mr(e,t){return new e({type:`string`,...k(t)})}function hr(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...k(t)})}function gr(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...k(t)})}function _r(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...k(t)})}function vr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...k(t)})}function yr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...k(t)})}function br(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...k(t)})}function xr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...k(t)})}function Sr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...k(t)})}function Cr(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...k(t)})}function wr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...k(t)})}function Tr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...k(t)})}function Er(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...k(t)})}function Dr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...k(t)})}function Or(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...k(t)})}function kr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...k(t)})}function Ar(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...k(t)})}function jr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...k(t)})}function Mr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...k(t)})}function Nr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...k(t)})}function Pr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...k(t)})}function Fr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...k(t)})}function Ir(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...k(t)})}function Lr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...k(t)})}function Rr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...k(t)})}function zr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...k(t)})}function Br(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...k(t)})}function Vr(e,t){return new e({type:`number`,checks:[],...k(t)})}function Hr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...k(t)})}function Ur(e,t){return new e({type:`boolean`,...k(t)})}function Wr(e){return new e({type:`unknown`})}function Gr(e,t){return new e({type:`never`,...k(t)})}function Kr(e,t){return new Lt({check:`less_than`,...k(t),value:e,inclusive:!1})}function qr(e,t){return new Lt({check:`less_than`,...k(t),value:e,inclusive:!0})}function Jr(e,t){return new Rt({check:`greater_than`,...k(t),value:e,inclusive:!1})}function Yr(e,t){return new Rt({check:`greater_than`,...k(t),value:e,inclusive:!0})}function Xr(e,t){return new zt({check:`multiple_of`,...k(t),value:e})}function Zr(e,t){return new Vt({check:`max_length`,...k(t),maximum:e})}function Qr(e,t){return new Ht({check:`min_length`,...k(t),minimum:e})}function $r(e,t){return new Ut({check:`length_equals`,...k(t),length:e})}function ei(e,t){return new Gt({check:`string_format`,format:`regex`,...k(t),pattern:e})}function ti(e){return new Kt({check:`string_format`,format:`lowercase`,...k(e)})}function ni(e){return new qt({check:`string_format`,format:`uppercase`,...k(e)})}function ri(e,t){return new Jt({check:`string_format`,format:`includes`,...k(t),includes:e})}function ii(e,t){return new Yt({check:`string_format`,format:`starts_with`,...k(t),prefix:e})}function ai(e,t){return new Xt({check:`string_format`,format:`ends_with`,...k(t),suffix:e})}function oi(e){return new Zt({check:`overwrite`,tx:e})}function si(e){return oi(t=>t.normalize(e))}function ci(){return oi(e=>e.trim())}function li(){return oi(e=>e.toLowerCase())}function ui(){return oi(e=>e.toUpperCase())}function di(){return oi(e=>O(e))}function fi(e,t,n){return new e({type:`array`,element:t,...k(n)})}function pi(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...k(n)})}function mi(e,t){let n=hi(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Re(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Re(r))}},e(t.value,t)),t);return n}function hi(e,t){let n=new Ft({check:`custom`,...k(t)});return n._zod.check=e,n}function gi(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??pr,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function M(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,M(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&yi(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function _i(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
71
71
|
|
|
72
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function vi(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:xi(t,`input`,e.processors),output:xi(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function yi(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return yi(r.element,n);if(r.type===`set`)return yi(r.valueType,n);if(r.type===`lazy`)return yi(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return yi(r.innerType,n);if(r.type===`intersection`)return yi(r.left,n)||yi(r.right,n);if(r.type===`record`||r.type===`map`)return yi(r.keyType,n)||yi(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:yi(r.in,n)||yi(r.out,n);if(r.type===`object`){for(let e in r.shape)if(yi(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(yi(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(yi(e,n))return!0;return!!(r.rest&&yi(r.rest,n))}return!1}var bi=(e,t={})=>n=>{let r=gi({...n,processors:t});return M(e,r),_i(r,e),vi(r,e)},xi=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=gi({...i??{},target:a,io:t,processors:n});return M(e,o),_i(o,e),vi(o,e)},Si={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ci=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Si[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},wi=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Ti=(e,t,n,r)=>{n.type=`boolean`},Ei=(e,t,n,r)=>{n.not={}},Di=(e,t,n,r)=>{let i=e._zod.def,a=se(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Oi=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},ki=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Ai=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ji=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=M(a.element,t,{...r,path:[...r.path,`items`]})},Mi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=M(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=M(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ni=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>M(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Pi=(e,t,n,r)=>{let i=e._zod.def,a=M(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=M(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Fi=(e,t,n,r)=>{let i=e._zod.def,a=M(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ii=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Li=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ri=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},zi=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},N=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;M(o,t,r);let s=t.seen.get(e);s.ref=o},P=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Bi=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Vi=C(`ZodISODateTime`,(e,t)=>{pn.init(e,t),L.init(e,t)});function Hi(e){return Lr(Vi,e)}var Ui=C(`ZodISODate`,(e,t)=>{mn.init(e,t),L.init(e,t)});function Wi(e){return Rr(Ui,e)}var Gi=C(`ZodISOTime`,(e,t)=>{hn.init(e,t),L.init(e,t)});function Ki(e){return zr(Gi,e)}var qi=C(`ZodISODuration`,(e,t)=>{gn.init(e,t),L.init(e,t)});function Ji(e){return Br(qi,e)}var Yi=C(`ZodError`,(e,t)=>{Be.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Ue(e,t)},flatten:{value:t=>He(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ce,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ce,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Xi=We(Yi),Zi=Ge(Yi),Qi=Ke(Yi),$i=Je(Yi),ea=Xe(Yi),ta=Ze(Yi),na=Qe(Yi),ra=$e(Yi),ia=et(Yi),aa=tt(Yi),oa=nt(Yi),sa=rt(Yi),ca=new WeakMap;function la(e,t,n){let r=Object.getPrototypeOf(e),i=ca.get(r);if(i||(i=new Set,ca.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var F=C(`ZodType`,(e,t)=>(A.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:xi(e,`input`),output:xi(e,`output`)}}),e.toJSONSchema=bi(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Xi(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Qi(e,t,n),e.parseAsync=async(t,n)=>Zi(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>$i(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ea(e,t,n),e.decode=(t,n)=>ta(e,t,n),e.encodeAsync=async(t,n)=>na(e,t,n),e.decodeAsync=async(t,n)=>ra(e,t,n),e.safeEncode=(t,n)=>ia(e,t,n),e.safeDecode=(t,n)=>aa(e,t,n),e.safeEncodeAsync=async(t,n)=>oa(e,t,n),e.safeDecodeAsync=async(t,n)=>sa(e,t,n),la(e,`ZodType`,{check(...e){let t=this.def;return this.clone(pe(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Se(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(_o(e,t))},superRefine(e,t){return this.check(vo(e,t))},overwrite(e){return this.check(oi(e))},optional(){return to(this)},exactOptional(){return ro(this)},nullable(){return ao(this)},nullish(){return to(ao(this))},nonoptional(e){return z(this,e)},array(){return Ha(this)},or(e){return Ga([this,e])},and(e){return qa(this,e)},transform(e){return V(this,$a(e))},default(e){return so(this,e)},prefault(e){return lo(this,e)},catch(e){return po(this,e)},pipe(e){return V(this,e)},readonly(){return ho(this)},describe(e){let t=this.clone();return pr.add(t,{description:e}),t},meta(...e){if(e.length===0)return pr.get(this);let t=this.clone();return pr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return pr.get(e)?.description},configurable:!0}),e)),ua=C(`_ZodString`,(e,t)=>{en.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ci(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,la(e,`_ZodString`,{regex(...e){return this.check(ei(...e))},includes(...e){return this.check(ri(...e))},startsWith(...e){return this.check(ii(...e))},endsWith(...e){return this.check(ai(...e))},min(...e){return this.check(Qr(...e))},max(...e){return this.check(Zr(...e))},length(...e){return this.check($r(...e))},nonempty(...e){return this.check(Qr(1,...e))},lowercase(e){return this.check(ti(e))},uppercase(e){return this.check(ni(e))},trim(){return this.check(ci())},normalize(...e){return this.check(si(...e))},toLowerCase(){return this.check(li())},toUpperCase(){return this.check(ui())},slugify(){return this.check(di())}})}),da=C(`ZodString`,(e,t)=>{en.init(e,t),ua.init(e,t),e.email=t=>e.check(hr(fa,t)),e.url=t=>e.check(xr(ha,t)),e.jwt=t=>e.check(Ir(Aa,t)),e.emoji=t=>e.check(Sr(ga,t)),e.guid=t=>e.check(gr(pa,t)),e.uuid=t=>e.check(_r(ma,t)),e.uuidv4=t=>e.check(vr(ma,t)),e.uuidv6=t=>e.check(yr(ma,t)),e.uuidv7=t=>e.check(br(ma,t)),e.nanoid=t=>e.check(Cr(_a,t)),e.guid=t=>e.check(gr(pa,t)),e.cuid=t=>e.check(wr(va,t)),e.cuid2=t=>e.check(Tr(ya,t)),e.ulid=t=>e.check(Er(ba,t)),e.base64=t=>e.check(Nr(Da,t)),e.base64url=t=>e.check(Pr(Oa,t)),e.xid=t=>e.check(Dr(xa,t)),e.ksuid=t=>e.check(Or(Sa,t)),e.ipv4=t=>e.check(kr(Ca,t)),e.ipv6=t=>e.check(Ar(wa,t)),e.cidrv4=t=>e.check(jr(Ta,t)),e.cidrv6=t=>e.check(Mr(Ea,t)),e.e164=t=>e.check(Fr(ka,t)),e.datetime=t=>e.check(Hi(t)),e.date=t=>e.check(Wi(t)),e.time=t=>e.check(Ki(t)),e.duration=t=>e.check(Ji(t))});function I(e){return mr(da,e)}var L=C(`ZodStringFormat`,(e,t)=>{j.init(e,t),ua.init(e,t)}),fa=C(`ZodEmail`,(e,t)=>{rn.init(e,t),L.init(e,t)}),pa=C(`ZodGUID`,(e,t)=>{tn.init(e,t),L.init(e,t)}),ma=C(`ZodUUID`,(e,t)=>{nn.init(e,t),L.init(e,t)}),ha=C(`ZodURL`,(e,t)=>{an.init(e,t),L.init(e,t)}),ga=C(`ZodEmoji`,(e,t)=>{on.init(e,t),L.init(e,t)}),_a=C(`ZodNanoID`,(e,t)=>{sn.init(e,t),L.init(e,t)}),va=C(`ZodCUID`,(e,t)=>{cn.init(e,t),L.init(e,t)}),ya=C(`ZodCUID2`,(e,t)=>{ln.init(e,t),L.init(e,t)}),ba=C(`ZodULID`,(e,t)=>{un.init(e,t),L.init(e,t)}),xa=C(`ZodXID`,(e,t)=>{dn.init(e,t),L.init(e,t)}),Sa=C(`ZodKSUID`,(e,t)=>{fn.init(e,t),L.init(e,t)}),Ca=C(`ZodIPv4`,(e,t)=>{_n.init(e,t),L.init(e,t)}),wa=C(`ZodIPv6`,(e,t)=>{vn.init(e,t),L.init(e,t)}),Ta=C(`ZodCIDRv4`,(e,t)=>{yn.init(e,t),L.init(e,t)}),Ea=C(`ZodCIDRv6`,(e,t)=>{bn.init(e,t),L.init(e,t)}),Da=C(`ZodBase64`,(e,t)=>{Sn.init(e,t),L.init(e,t)}),Oa=C(`ZodBase64URL`,(e,t)=>{wn.init(e,t),L.init(e,t)}),ka=C(`ZodE164`,(e,t)=>{Tn.init(e,t),L.init(e,t)}),Aa=C(`ZodJWT`,(e,t)=>{Dn.init(e,t),L.init(e,t)}),ja=C(`ZodNumber`,(e,t)=>{On.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wi(e,t,n,r),la(e,`ZodNumber`,{gt(e,t){return this.check(Jr(e,t))},gte(e,t){return this.check(Yr(e,t))},min(e,t){return this.check(Yr(e,t))},lt(e,t){return this.check(Kr(e,t))},lte(e,t){return this.check(qr(e,t))},max(e,t){return this.check(qr(e,t))},int(e){return this.check(Pa(e))},safe(e){return this.check(Pa(e))},positive(e){return this.check(Jr(0,e))},nonnegative(e){return this.check(Yr(0,e))},negative(e){return this.check(Kr(0,e))},nonpositive(e){return this.check(qr(0,e))},multipleOf(e,t){return this.check(Xr(e,t))},step(e,t){return this.check(Xr(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Ma(e){return Vr(ja,e)}var Na=C(`ZodNumberFormat`,(e,t)=>{kn.init(e,t),ja.init(e,t)});function Pa(e){return Hr(Na,e)}var Fa=C(`ZodBoolean`,(e,t)=>{An.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ti(e,t,n,r)});function Ia(e){return Ur(Fa,e)}var La=C(`ZodUnknown`,(e,t)=>{jn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ra(){return Wr(La)}var za=C(`ZodNever`,(e,t)=>{Mn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ei(e,t,n,r)});function Ba(e){return Gr(za,e)}var Va=C(`ZodArray`,(e,t)=>{Pn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ji(e,t,n,r),e.element=t.element,la(e,`ZodArray`,{min(e,t){return this.check(Qr(e,t))},nonempty(e){return this.check(Qr(1,e))},max(e,t){return this.check(Zr(e,t))},length(e,t){return this.check($r(e,t))},unwrap(){return this.element}})});function Ha(e,t){return fi(Va,e,t)}var Ua=C(`ZodObject`,(e,t)=>{zn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mi(e,t,n,r),D(e,`shape`,()=>t.shape),la(e,`ZodObject`,{keyof(){return Ya(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Ra()})},loose(){return this.clone({...this._zod.def,catchall:Ra()})},strict(){return this.clone({...this._zod.def,catchall:Ba()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return De(this,e)},safeExtend(e){return Oe(this,e)},merge(e){return ke(this,e)},pick(e){return Te(this,e)},omit(e){return Ee(this,e)},partial(...e){return Ae(eo,this,e[0])},required(...e){return je(uo,this,e[0])}})});function R(e,t){return new Ua({type:`object`,shape:e??{},...k(t)})}var Wa=C(`ZodUnion`,(e,t)=>{Vn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ni(e,t,n,r),e.options=t.options});function Ga(e,t){return new Wa({type:`union`,options:e,...k(t)})}var Ka=C(`ZodIntersection`,(e,t)=>{Hn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pi(e,t,n,r)});function qa(e,t){return new Ka({type:`intersection`,left:e,right:t})}var Ja=C(`ZodEnum`,(e,t)=>{Gn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Di(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ja({...t,checks:[],...k(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ja({...t,checks:[],...k(r),entries:i})}});function Ya(e,t){return new Ja({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...k(t)})}var Xa=C(`ZodLiteral`,(e,t)=>{Kn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oi(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Za(e,t){return new Xa({type:`literal`,values:Array.isArray(e)?e:[e],...k(t)})}var Qa=C(`ZodTransform`,(e,t)=>{qn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ai(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ie(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Re(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Re(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function $a(e){return new Qa({type:`transform`,transform:e})}var eo=C(`ZodOptional`,(e,t)=>{Yn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function to(e){return new eo({type:`optional`,innerType:e})}var no=C(`ZodExactOptional`,(e,t)=>{Xn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ro(e){return new no({type:`optional`,innerType:e})}var io=C(`ZodNullable`,(e,t)=>{Zn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ao(e){return new io({type:`nullable`,innerType:e})}var oo=C(`ZodDefault`,(e,t)=>{Qn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Li(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function so(e,t){return new oo({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ye(t)}})}var co=C(`ZodPrefault`,(e,t)=>{er.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ri(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lo(e,t){return new co({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ye(t)}})}var uo=C(`ZodNonOptional`,(e,t)=>{tr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ii(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function z(e,t){return new uo({type:`nonoptional`,innerType:e,...k(t)})}var fo=C(`ZodCatch`,(e,t)=>{rr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function po(e,t){return new fo({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var B=C(`ZodPipe`,(e,t)=>{ir.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>N(e,t,n,r),e.in=t.in,e.out=t.out});function V(e,t){return new B({type:`pipe`,in:e,out:t})}var mo=C(`ZodReadonly`,(e,t)=>{or.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>P(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ho(e){return new mo({type:`readonly`,innerType:e})}var go=C(`ZodCustom`,(e,t)=>{cr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ki(e,t,n,r)});function _o(e,t={}){return pi(go,e,t)}function vo(e,t){return mi(e,t)}var H=y(),yo=ne(),bo=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),U=e(((e,t)=>{t.exports=bo()}))(),xo=R({slug:I(),type:I(),title:I(),summary:I().nullable(),status:I().nullable().optional()}),So=R({authenticated:Ia(),environment:Ya([`local`,`production`]),loginUrl:I().optional()}),Co=R({items:Ha(xo)}),wo=R({hits:Ha(xo.extend({snippet:I()}))}),To=R({revisions:Ha(R({slug:I(),revision_id:I(),revision_number:Ma(),created_at:I(),reason:I()}))}),Eo=R({passkeys:Ha(R({credentialRef:I(),label:I(),deviceType:Ya([`singleDevice`,`multiDevice`]),backedUp:Ia(),createdAt:I(),lastUsedAt:I().nullable()})),clients:Ha(R({id:I(),clientName:I(),scope:Ha(I()),createdAt:I()})),sessions:Ha(R({sessionRef:I(),authenticatedAt:I(),createdAt:I(),current:Ia()}))}),Do=R({revoked:I(),sessionCleanupComplete:Ia()}),Oo=R({document:R({revisionId:I(),revisionNumber:Ma(),slug:I(),type:I(),title:I(),summary:I().nullable(),body:I(),createdAt:I(),metadata:Ha(R({key:I(),value:I()}))}),current:R({revisionId:I()}).nullable(),history:Ha(R({revisionId:I(),revisionNumber:Ma(),createdAt:I(),reason:I()}))}),ko=R({flowId:I(),options:Ra(),label:I().optional()}),Ao=R({flowId:I(),kind:Ya([`mcp`,`web`]),options:Ra(),clientName:I().optional(),requestedScopes:Ha(I()).optional()}),jo=R({clientName:I(),requestedScopes:Ha(I())});function Mo(e){return typeof e==`object`&&!!e}function No(e){return Mo(e)&&typeof e.challenge==`string`&&Mo(e.user)&&typeof e.user.id==`string`&&Array.isArray(e.pubKeyCredParams)}function Po(e){return Mo(e)&&typeof e.challenge==`string`}async function Fo(e){let t=await e.json();if(!e.ok){let n=Mo(t)&&typeof t.message==`string`?t.message:Mo(t)&&typeof t.error==`string`?t.error:`HTTP ${e.status}`;throw Error(n)}return t}async function Io(e,t){let n=new Headers(t?.headers);return n.set(`content-type`,`application/json`),await Fo(await fetch(e,{...t,headers:n}))}function Lo(e,t=``){let[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(null),[o,s]=(0,H.useState)(0),c=(0,H.useCallback)(()=>{s(e=>e+1)},[]),l=(0,H.useEffectEvent)(e);return(0,H.useEffect)(()=>{let e=!0;return l().then(t=>{e&&r(t)}).catch(t=>{e&&a(t instanceof Error?t.message:`Request failed`)}),()=>{e=!1}},[t,o]),{value:n,error:i,reload:c}}function Ro({children:e}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`a`,{className:`brand`,href:`/app`,children:[(0,U.jsx)(`span`,{children:`W`}),`Wikimemory`]}),(0,U.jsx)(`a`,{href:`/app`,children:`Browse`}),(0,U.jsx)(`a`,{href:`/app/search`,children:`Search`}),(0,U.jsx)(`a`,{href:`/app/history`,children:`Recent`}),(0,U.jsx)(`a`,{href:`/app/manage`,children:`Manage`})]}),(0,U.jsx)(`main`,{children:e})]})}function zo({items:e}){return e.length===0?(0,U.jsx)(`p`,{className:`muted`,children:`No documents found.`}):(0,U.jsx)(`div`,{className:`grid`,children:e.map(e=>(0,U.jsxs)(`article`,{className:`card`,children:[(0,U.jsxs)(`div`,{className:`meta`,children:[(0,U.jsx)(`span`,{children:e.type}),e.status?(0,U.jsx)(`span`,{children:e.status}):null]}),(0,U.jsx)(`h2`,{children:(0,U.jsx)(`a`,{href:`/app/docs/${encodeURIComponent(e.slug)}`,children:e.title})}),(0,U.jsx)(`small`,{children:e.slug}),(0,U.jsx)(`p`,{children:e.summary??`No summary`})]},e.slug))})}function Bo(){let e=new URLSearchParams(location.search).get(`flowId`),t=Lo(async()=>Ao.parse(await Io(`/api/auth/options?flowId=${encodeURIComponent(e??``)}`)),e??``),[n,r]=(0,H.useState)(`Waiting for authorization details…`);async function i(){if(!(t.value===null||!Po(t.value.options))){r(`Waiting for your passkey…`);try{let e=await _({optionsJSON:t.value.options}),n=R({redirectTo:I()}).parse(await Io(`/auth/passkey/verify`,{method:`POST`,body:JSON.stringify({flowId:t.value.flowId,response:e})}));location.assign(n.redirectTo)}catch(e){r(e instanceof Error?e.message:`Authentication failed`)}}}return(0,U.jsx)(`main`,{className:`center`,children:(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h1`,{children:`Wikimemory`}),t.value?.kind===`mcp`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`p`,{children:[(0,U.jsx)(`strong`,{children:t.value.clientName??`An MCP client`}),` is requesting access.`]}),(0,U.jsx)(`ul`,{children:t.value.requestedScopes?.map(e=>(0,U.jsx)(`li`,{children:e},e))})]}):(0,U.jsx)(`p`,{children:`Sign in to browse your memory.`}),(0,U.jsx)(`button`,{disabled:t.value===null,onClick:()=>void i(),children:`Continue with passkey`}),(0,U.jsx)(`p`,{className:`muted`,children:t.error??n})]})})}function Vo(){let e=location.search,t=Lo(async()=>jo.parse(await Io(`/api/local-authorize/options${e}`)),e),[n,r]=(0,H.useState)(`Review this local test authorization.`);async function i(){r(`Authorizing local test owner…`);try{let t=R({redirectTo:I()}).parse(await Io(`/api/local-authorize/approve${e}`,{method:`POST`,body:`{}`}));location.assign(t.redirectTo)}catch(e){r(e instanceof Error?e.message:`Authorization failed`)}}return(0,U.jsx)(`main`,{className:`center`,children:(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h1`,{children:`Authorize local Wikimemory`}),(0,U.jsxs)(`p`,{children:[(0,U.jsx)(`strong`,{children:t.value?.clientName??`An MCP client`}),` is requesting access to the explicit local test owner.`]}),(0,U.jsx)(`ul`,{children:t.value?.requestedScopes.map(e=>(0,U.jsx)(`li`,{children:e},e))}),(0,U.jsx)(`button`,{disabled:t.value===null,onClick:()=>void i(),children:`Continue as local test owner`}),(0,U.jsx)(`p`,{className:`muted`,children:t.error??n})]})})}function Ho({recovery:e}){let[t]=(0,H.useState)(()=>decodeURIComponent(location.hash.slice(1))),[n,r]=(0,H.useState)(e?`Primary passkey`:`Backup passkey`),[i,a]=(0,H.useState)(``);(0,H.useEffect)(()=>{history.replaceState(null,``,location.pathname)},[]);async function o(){a(`Waiting for your passkey…`);try{let r=e?`/setup`:`/passkeys/add`,i=e?{token:t,label:n}:{token:t},o=ko.parse(await Io(`${r}/options`,{method:`POST`,body:JSON.stringify(i)}));if(!No(o.options))throw Error(`Server returned invalid passkey options`);let s=await f({optionsJSON:o.options}),c=R({ok:Za(!0),mode:I().optional(),label:I().optional()}).parse(await Io(`${r}/verify`,{method:`POST`,body:JSON.stringify({flowId:o.flowId,response:s})}));a(c.mode===`recovery`?`Account recovered. Previous credentials and sessions were revoked.`:`Saved ${c.label??n}.`)}catch(e){a(e instanceof Error?e.message:`Registration failed`)}}return(0,U.jsx)(`main`,{className:`center`,children:(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h1`,{children:e?`Set up Wikimemory`:`Add a passkey`}),(0,U.jsx)(`p`,{children:e?`Initial setup creates the owner credential; recovery replaces every existing credential.`:`This adds another owner credential without removing existing passkeys.`}),e?(0,U.jsxs)(`label`,{children:[`Passkey name`,(0,U.jsx)(`input`,{value:n,maxLength:80,onChange:e=>{r(e.target.value)}})]}):null,(0,U.jsx)(`button`,{disabled:t===``,onClick:()=>void o(),children:`Create passkey`}),(0,U.jsx)(`p`,{className:`muted`,children:t===``?`The one-time token is missing.`:i})]})})}function Uo(){let e=Lo(async()=>Co.parse(await Io(`/api/app/documents`)));return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h1`,{children:`Browse memory`}),(0,U.jsx)(`p`,{className:`lede`,children:`The current pages in your durable store.`}),e.error?(0,U.jsx)(`p`,{children:e.error}):e.value===null?(0,U.jsx)(`p`,{children:`Loading…`}):(0,U.jsx)(zo,{items:e.value.items})]})}function Wo(){let e=new URLSearchParams(location.search).get(`q`)??``,[t,n]=(0,H.useState)(e),[r,i]=(0,H.useState)(e),a=Lo(async()=>r===``?{hits:[]}:wo.parse(await Io(`/api/app/search?q=${encodeURIComponent(r)}`)),r);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h1`,{children:`Search`}),(0,U.jsxs)(`form`,{className:`search`,onSubmit:e=>{e.preventDefault(),i(t.trim())},children:[(0,U.jsx)(`input`,{value:t,onChange:e=>{n(e.target.value)},placeholder:`Search durable memory…`}),(0,U.jsx)(`button`,{children:`Search`})]}),a.value?(0,U.jsx)(zo,{items:a.value.hits}):null]})}function Go(){let e=Lo(async()=>To.parse(await Io(`/api/app/recent`)));return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h1`,{children:`Recent revisions`}),(0,U.jsx)(`ol`,{className:`list`,children:e.value?.revisions.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsxs)(`a`,{href:`/app/docs/${encodeURIComponent(e.slug)}?revision=${encodeURIComponent(e.revision_id)}`,children:[e.slug,` revision `,e.revision_number]}),(0,U.jsxs)(`small`,{children:[e.created_at,` · `,e.reason]})]},e.revision_id))})]})}function Ko({slug:e}){let t=new URLSearchParams(location.search).get(`revision`),n=`/api/app/docs/${encodeURIComponent(e)}${t===null?``:`?revision=${encodeURIComponent(t)}`}`,r=Lo(async()=>Oo.parse(await Io(n)),n),[i,a]=(0,H.useState)(``);if(r.error!==null)return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h1`,{children:`Document unavailable`}),(0,U.jsx)(`p`,{children:r.error})]});if(r.value===null)return(0,U.jsx)(`p`,{children:`Loading…`});let{document:o,current:s,history:c}=r.value,l=s!==null&&s.revisionId!==o.revisionId;async function u(){s!==null&&(await Io(`/api/app/docs/${encodeURIComponent(e)}/restore`,{method:`POST`,body:JSON.stringify({targetRevisionId:o.revisionId,expectedRevisionId:s.revisionId})}),a(`Restored as a new revision.`),location.assign(`/app/docs/${encodeURIComponent(e)}`))}return(0,U.jsxs)(`article`,{children:[(0,U.jsxs)(`div`,{className:`meta`,children:[(0,U.jsx)(`span`,{children:o.type}),(0,U.jsxs)(`span`,{children:[`revision `,o.revisionNumber]})]}),(0,U.jsx)(`h1`,{children:o.title}),(0,U.jsx)(`p`,{className:`lede`,children:o.summary??o.slug}),i===``?null:(0,U.jsx)(`p`,{className:`notice`,children:i}),l?(0,U.jsx)(`button`,{onClick:()=>void u(),children:`Restore this revision`}):null,o.metadata.length===0?null:(0,U.jsx)(`dl`,{className:`metadata`,children:o.metadata.map(e=>(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:e.key}),(0,U.jsx)(`dd`,{children:e.value})]},`${e.key}:${e.value}`))}),(0,U.jsx)(`pre`,{className:`document-body`,children:o.body}),(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h2`,{children:`History`}),(0,U.jsx)(`ol`,{className:`list`,children:c.map(t=>(0,U.jsxs)(`li`,{children:[(0,U.jsxs)(`a`,{href:`/app/docs/${encodeURIComponent(e)}?revision=${encodeURIComponent(t.revisionId)}`,children:[`Revision `,t.revisionNumber]}),(0,U.jsxs)(`small`,{children:[t.createdAt,` · `,t.reason]})]},t.revisionId))})]})]})}function qo({passkeysEnabled:e}){let t=Lo(async()=>Eo.parse(await Io(`/api/app/manage`))),[n,r]=(0,H.useState)(``),[i,a]=(0,H.useState)(``);async function o(e,n,r){let i=await Io(n,{method:e,body:JSON.stringify(r)});return t.reload(),i}return t.value===null?(0,U.jsx)(`p`,{children:t.error??`Loading…`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h1`,{children:`Manage Wikimemory`}),i?(0,U.jsx)(`p`,{className:`notice`,children:i}):null,e?(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h2`,{children:`Passkeys`}),(0,U.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),o(`POST`,`/api/app/passkeys`,{label:n}).then(e=>{let t=R({registrationUrl:I()}).parse(e);location.assign(t.registrationUrl)})},children:[(0,U.jsxs)(`label`,{children:[`New passkey name`,(0,U.jsx)(`input`,{required:!0,maxLength:80,value:n,onChange:e=>{r(e.target.value)}})]}),(0,U.jsx)(`button`,{children:`Add passkey`})]}),(0,U.jsx)(`ol`,{className:`list`,children:t.value.passkeys.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`strong`,{children:e.label}),(0,U.jsxs)(`small`,{children:[e.deviceType,` · `,e.backedUp?`backed up`:`not backed up`,` · created `,e.createdAt,e.lastUsedAt?` · last used ${e.lastUsedAt}`:``]}),(0,U.jsx)(`button`,{className:`danger`,disabled:t.value?.passkeys.length===1,onClick:()=>void o(`DELETE`,`/api/app/passkeys`,{credentialRef:e.credentialRef}).then(e=>{let t=Do.parse(e);a(t.sessionCleanupComplete?`Passkey and its browser sessions were revoked.`:`Passkey revoked. Browser-session cleanup could not be confirmed; those sessions are blocked because the passkey no longer exists.`)}),children:`Revoke`})]},e.credentialRef))})]}):(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h2`,{children:`Passkeys`}),(0,U.jsx)(`p`,{className:`muted`,children:`Passkey management is disabled for the fake local owner.`})]}),(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h2`,{children:`Authorized MCP clients`}),(0,U.jsx)(`ol`,{className:`list`,children:t.value.clients.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`strong`,{children:e.clientName}),(0,U.jsxs)(`small`,{children:[e.scope.join(` `),` · `,e.createdAt]}),(0,U.jsx)(`button`,{className:`danger`,onClick:()=>void o(`DELETE`,`/api/app/grants`,{grantId:e.id}),children:`Revoke`})]},e.id))})]}),(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h2`,{children:`Browser sessions`}),(0,U.jsx)(`ol`,{className:`list`,children:t.value.sessions.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`strong`,{children:e.current?`Current browser`:`Browser session`}),(0,U.jsx)(`small`,{children:e.createdAt}),(0,U.jsx)(`button`,{className:`danger`,onClick:()=>void o(`DELETE`,`/api/app/sessions`,{sessionRef:e.sessionRef}),children:`Revoke`})]},e.sessionRef))})]}),(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h2`,{children:`Export`}),(0,U.jsx)(`a`,{href:`/api/app/export.jsonl`,children:`Download JSONL history`}),` ·`,` `,(0,U.jsx)(`a`,{href:`/api/app/export.md`,children:`Download current Markdown`})]})]})}function Jo(){let e=Lo(async()=>So.parse(await Io(`/api/app/session`))),[t,n]=(0,H.useState)(``);if(e.error)return(0,U.jsx)(`main`,{className:`center`,children:(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h1`,{children:`Wikimemory`}),(0,U.jsx)(`p`,{children:e.error})]})});if(e.value===null)return(0,U.jsx)(`p`,{children:`Loading…`});if(!e.value.authenticated){async function r(){try{await Io(`/api/app/login`,{method:`POST`,body:`{}`}),e.reload()}catch(e){n(e instanceof Error?e.message:`Sign-in failed`)}}return(0,U.jsx)(`main`,{className:`center`,children:(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h1`,{children:`Wikimemory`}),(0,U.jsx)(`p`,{children:e.value.environment===`local`?`Use the explicit local test owner. No production passkey is involved.`:`Use an owner passkey to browse your memory.`}),e.value.environment===`local`?(0,U.jsx)(`button`,{onClick:()=>void r(),children:`Continue as local test owner`}):(0,U.jsx)(`a`,{className:`button`,href:e.value.loginUrl??`/app/login`,children:`Continue with passkey`}),t===``?null:(0,U.jsx)(`p`,{children:t})]})})}let r=location.pathname;return(0,U.jsx)(Ro,{children:r===`/app/search`?(0,U.jsx)(Wo,{}):r===`/app/history`?(0,U.jsx)(Go,{}):r===`/app/manage`?(0,U.jsx)(qo,{passkeysEnabled:e.value.environment===`production`}):r.startsWith(`/app/docs/`)?(0,U.jsx)(Ko,{slug:decodeURIComponent(r.slice(10))}):(0,U.jsx)(Uo,{})})}function Yo(){return location.pathname===`/login`?(0,U.jsx)(Bo,{}):location.pathname===`/local-authorize`?(0,U.jsx)(Vo,{}):location.pathname===`/setup`?(0,U.jsx)(Ho,{recovery:!0}):location.pathname===`/passkeys/add`?(0,U.jsx)(Ho,{recovery:!1}):(0,U.jsx)(Jo,{})}var Xo=document.getElementById(`root`);Xo!==null&&(0,yo.createRoot)(Xo).render((0,U.jsx)(H.StrictMode,{children:(0,U.jsx)(Yo,{})}));
|
|
72
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function vi(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:xi(t,`input`,e.processors),output:xi(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function yi(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return yi(r.element,n);if(r.type===`set`)return yi(r.valueType,n);if(r.type===`lazy`)return yi(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return yi(r.innerType,n);if(r.type===`intersection`)return yi(r.left,n)||yi(r.right,n);if(r.type===`record`||r.type===`map`)return yi(r.keyType,n)||yi(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:yi(r.in,n)||yi(r.out,n);if(r.type===`object`){for(let e in r.shape)if(yi(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(yi(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(yi(e,n))return!0;return!!(r.rest&&yi(r.rest,n))}return!1}var bi=(e,t={})=>n=>{let r=gi({...n,processors:t});return M(e,r),_i(r,e),vi(r,e)},xi=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=gi({...i??{},target:a,io:t,processors:n});return M(e,o),_i(o,e),vi(o,e)},Si={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ci=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Si[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},wi=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Ti=(e,t,n,r)=>{n.type=`boolean`},Ei=(e,t,n,r)=>{n.not={}},Di=(e,t,n,r)=>{let i=e._zod.def,a=se(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Oi=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},ki=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Ai=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ji=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=M(a.element,t,{...r,path:[...r.path,`items`]})},Mi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=M(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=M(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ni=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>M(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Pi=(e,t,n,r)=>{let i=e._zod.def,a=M(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=M(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Fi=(e,t,n,r)=>{let i=e._zod.def,a=M(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ii=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Li=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ri=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},zi=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},N=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;M(o,t,r);let s=t.seen.get(e);s.ref=o},P=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Bi=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Vi=C(`ZodISODateTime`,(e,t)=>{pn.init(e,t),L.init(e,t)});function Hi(e){return Lr(Vi,e)}var Ui=C(`ZodISODate`,(e,t)=>{mn.init(e,t),L.init(e,t)});function Wi(e){return Rr(Ui,e)}var Gi=C(`ZodISOTime`,(e,t)=>{hn.init(e,t),L.init(e,t)});function Ki(e){return zr(Gi,e)}var qi=C(`ZodISODuration`,(e,t)=>{gn.init(e,t),L.init(e,t)});function Ji(e){return Br(qi,e)}var Yi=C(`ZodError`,(e,t)=>{Be.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Ue(e,t)},flatten:{value:t=>He(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ce,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ce,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Xi=We(Yi),Zi=Ge(Yi),Qi=Ke(Yi),$i=Je(Yi),ea=Xe(Yi),ta=Ze(Yi),na=Qe(Yi),ra=$e(Yi),ia=et(Yi),aa=tt(Yi),oa=nt(Yi),sa=rt(Yi),ca=new WeakMap;function la(e,t,n){let r=Object.getPrototypeOf(e),i=ca.get(r);if(i||(i=new Set,ca.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var F=C(`ZodType`,(e,t)=>(A.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:xi(e,`input`),output:xi(e,`output`)}}),e.toJSONSchema=bi(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Xi(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Qi(e,t,n),e.parseAsync=async(t,n)=>Zi(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>$i(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ea(e,t,n),e.decode=(t,n)=>ta(e,t,n),e.encodeAsync=async(t,n)=>na(e,t,n),e.decodeAsync=async(t,n)=>ra(e,t,n),e.safeEncode=(t,n)=>ia(e,t,n),e.safeDecode=(t,n)=>aa(e,t,n),e.safeEncodeAsync=async(t,n)=>oa(e,t,n),e.safeDecodeAsync=async(t,n)=>sa(e,t,n),la(e,`ZodType`,{check(...e){let t=this.def;return this.clone(pe(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Se(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(_o(e,t))},superRefine(e,t){return this.check(vo(e,t))},overwrite(e){return this.check(oi(e))},optional(){return to(this)},exactOptional(){return ro(this)},nullable(){return ao(this)},nullish(){return to(ao(this))},nonoptional(e){return z(this,e)},array(){return Ha(this)},or(e){return Ga([this,e])},and(e){return qa(this,e)},transform(e){return V(this,$a(e))},default(e){return so(this,e)},prefault(e){return lo(this,e)},catch(e){return po(this,e)},pipe(e){return V(this,e)},readonly(){return ho(this)},describe(e){let t=this.clone();return pr.add(t,{description:e}),t},meta(...e){if(e.length===0)return pr.get(this);let t=this.clone();return pr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return pr.get(e)?.description},configurable:!0}),e)),ua=C(`_ZodString`,(e,t)=>{en.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ci(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,la(e,`_ZodString`,{regex(...e){return this.check(ei(...e))},includes(...e){return this.check(ri(...e))},startsWith(...e){return this.check(ii(...e))},endsWith(...e){return this.check(ai(...e))},min(...e){return this.check(Qr(...e))},max(...e){return this.check(Zr(...e))},length(...e){return this.check($r(...e))},nonempty(...e){return this.check(Qr(1,...e))},lowercase(e){return this.check(ti(e))},uppercase(e){return this.check(ni(e))},trim(){return this.check(ci())},normalize(...e){return this.check(si(...e))},toLowerCase(){return this.check(li())},toUpperCase(){return this.check(ui())},slugify(){return this.check(di())}})}),da=C(`ZodString`,(e,t)=>{en.init(e,t),ua.init(e,t),e.email=t=>e.check(hr(fa,t)),e.url=t=>e.check(xr(ha,t)),e.jwt=t=>e.check(Ir(Aa,t)),e.emoji=t=>e.check(Sr(ga,t)),e.guid=t=>e.check(gr(pa,t)),e.uuid=t=>e.check(_r(ma,t)),e.uuidv4=t=>e.check(vr(ma,t)),e.uuidv6=t=>e.check(yr(ma,t)),e.uuidv7=t=>e.check(br(ma,t)),e.nanoid=t=>e.check(Cr(_a,t)),e.guid=t=>e.check(gr(pa,t)),e.cuid=t=>e.check(wr(va,t)),e.cuid2=t=>e.check(Tr(ya,t)),e.ulid=t=>e.check(Er(ba,t)),e.base64=t=>e.check(Nr(Da,t)),e.base64url=t=>e.check(Pr(Oa,t)),e.xid=t=>e.check(Dr(xa,t)),e.ksuid=t=>e.check(Or(Sa,t)),e.ipv4=t=>e.check(kr(Ca,t)),e.ipv6=t=>e.check(Ar(wa,t)),e.cidrv4=t=>e.check(jr(Ta,t)),e.cidrv6=t=>e.check(Mr(Ea,t)),e.e164=t=>e.check(Fr(ka,t)),e.datetime=t=>e.check(Hi(t)),e.date=t=>e.check(Wi(t)),e.time=t=>e.check(Ki(t)),e.duration=t=>e.check(Ji(t))});function I(e){return mr(da,e)}var L=C(`ZodStringFormat`,(e,t)=>{j.init(e,t),ua.init(e,t)}),fa=C(`ZodEmail`,(e,t)=>{rn.init(e,t),L.init(e,t)}),pa=C(`ZodGUID`,(e,t)=>{tn.init(e,t),L.init(e,t)}),ma=C(`ZodUUID`,(e,t)=>{nn.init(e,t),L.init(e,t)}),ha=C(`ZodURL`,(e,t)=>{an.init(e,t),L.init(e,t)}),ga=C(`ZodEmoji`,(e,t)=>{on.init(e,t),L.init(e,t)}),_a=C(`ZodNanoID`,(e,t)=>{sn.init(e,t),L.init(e,t)}),va=C(`ZodCUID`,(e,t)=>{cn.init(e,t),L.init(e,t)}),ya=C(`ZodCUID2`,(e,t)=>{ln.init(e,t),L.init(e,t)}),ba=C(`ZodULID`,(e,t)=>{un.init(e,t),L.init(e,t)}),xa=C(`ZodXID`,(e,t)=>{dn.init(e,t),L.init(e,t)}),Sa=C(`ZodKSUID`,(e,t)=>{fn.init(e,t),L.init(e,t)}),Ca=C(`ZodIPv4`,(e,t)=>{_n.init(e,t),L.init(e,t)}),wa=C(`ZodIPv6`,(e,t)=>{vn.init(e,t),L.init(e,t)}),Ta=C(`ZodCIDRv4`,(e,t)=>{yn.init(e,t),L.init(e,t)}),Ea=C(`ZodCIDRv6`,(e,t)=>{bn.init(e,t),L.init(e,t)}),Da=C(`ZodBase64`,(e,t)=>{Sn.init(e,t),L.init(e,t)}),Oa=C(`ZodBase64URL`,(e,t)=>{wn.init(e,t),L.init(e,t)}),ka=C(`ZodE164`,(e,t)=>{Tn.init(e,t),L.init(e,t)}),Aa=C(`ZodJWT`,(e,t)=>{Dn.init(e,t),L.init(e,t)}),ja=C(`ZodNumber`,(e,t)=>{On.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wi(e,t,n,r),la(e,`ZodNumber`,{gt(e,t){return this.check(Jr(e,t))},gte(e,t){return this.check(Yr(e,t))},min(e,t){return this.check(Yr(e,t))},lt(e,t){return this.check(Kr(e,t))},lte(e,t){return this.check(qr(e,t))},max(e,t){return this.check(qr(e,t))},int(e){return this.check(Pa(e))},safe(e){return this.check(Pa(e))},positive(e){return this.check(Jr(0,e))},nonnegative(e){return this.check(Yr(0,e))},negative(e){return this.check(Kr(0,e))},nonpositive(e){return this.check(qr(0,e))},multipleOf(e,t){return this.check(Xr(e,t))},step(e,t){return this.check(Xr(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Ma(e){return Vr(ja,e)}var Na=C(`ZodNumberFormat`,(e,t)=>{kn.init(e,t),ja.init(e,t)});function Pa(e){return Hr(Na,e)}var Fa=C(`ZodBoolean`,(e,t)=>{An.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ti(e,t,n,r)});function Ia(e){return Ur(Fa,e)}var La=C(`ZodUnknown`,(e,t)=>{jn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ra(){return Wr(La)}var za=C(`ZodNever`,(e,t)=>{Mn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ei(e,t,n,r)});function Ba(e){return Gr(za,e)}var Va=C(`ZodArray`,(e,t)=>{Pn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ji(e,t,n,r),e.element=t.element,la(e,`ZodArray`,{min(e,t){return this.check(Qr(e,t))},nonempty(e){return this.check(Qr(1,e))},max(e,t){return this.check(Zr(e,t))},length(e,t){return this.check($r(e,t))},unwrap(){return this.element}})});function Ha(e,t){return fi(Va,e,t)}var Ua=C(`ZodObject`,(e,t)=>{zn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mi(e,t,n,r),D(e,`shape`,()=>t.shape),la(e,`ZodObject`,{keyof(){return Ya(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Ra()})},loose(){return this.clone({...this._zod.def,catchall:Ra()})},strict(){return this.clone({...this._zod.def,catchall:Ba()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return De(this,e)},safeExtend(e){return Oe(this,e)},merge(e){return ke(this,e)},pick(e){return Te(this,e)},omit(e){return Ee(this,e)},partial(...e){return Ae(eo,this,e[0])},required(...e){return je(uo,this,e[0])}})});function R(e,t){return new Ua({type:`object`,shape:e??{},...k(t)})}var Wa=C(`ZodUnion`,(e,t)=>{Vn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ni(e,t,n,r),e.options=t.options});function Ga(e,t){return new Wa({type:`union`,options:e,...k(t)})}var Ka=C(`ZodIntersection`,(e,t)=>{Hn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pi(e,t,n,r)});function qa(e,t){return new Ka({type:`intersection`,left:e,right:t})}var Ja=C(`ZodEnum`,(e,t)=>{Gn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Di(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ja({...t,checks:[],...k(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ja({...t,checks:[],...k(r),entries:i})}});function Ya(e,t){return new Ja({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...k(t)})}var Xa=C(`ZodLiteral`,(e,t)=>{Kn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oi(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Za(e,t){return new Xa({type:`literal`,values:Array.isArray(e)?e:[e],...k(t)})}var Qa=C(`ZodTransform`,(e,t)=>{qn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ai(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ie(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Re(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Re(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function $a(e){return new Qa({type:`transform`,transform:e})}var eo=C(`ZodOptional`,(e,t)=>{Yn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function to(e){return new eo({type:`optional`,innerType:e})}var no=C(`ZodExactOptional`,(e,t)=>{Xn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ro(e){return new no({type:`optional`,innerType:e})}var io=C(`ZodNullable`,(e,t)=>{Zn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ao(e){return new io({type:`nullable`,innerType:e})}var oo=C(`ZodDefault`,(e,t)=>{Qn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Li(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function so(e,t){return new oo({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ye(t)}})}var co=C(`ZodPrefault`,(e,t)=>{er.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ri(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lo(e,t){return new co({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ye(t)}})}var uo=C(`ZodNonOptional`,(e,t)=>{tr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ii(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function z(e,t){return new uo({type:`nonoptional`,innerType:e,...k(t)})}var fo=C(`ZodCatch`,(e,t)=>{rr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function po(e,t){return new fo({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var B=C(`ZodPipe`,(e,t)=>{ir.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>N(e,t,n,r),e.in=t.in,e.out=t.out});function V(e,t){return new B({type:`pipe`,in:e,out:t})}var mo=C(`ZodReadonly`,(e,t)=>{or.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>P(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ho(e){return new mo({type:`readonly`,innerType:e})}var go=C(`ZodCustom`,(e,t)=>{cr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ki(e,t,n,r)});function _o(e,t={}){return pi(go,e,t)}function vo(e,t){return mi(e,t)}var H=y(),yo=ne(),bo=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),U=e(((e,t)=>{t.exports=bo()}))(),xo=R({slug:I(),type:I(),title:I(),summary:I().nullable(),status:I().nullable().optional()}),So=R({authenticated:Ia(),environment:Ya([`local`,`production`]),loginUrl:I().optional()}),Co=R({items:Ha(xo)}),wo=R({hits:Ha(xo.extend({snippet:I()}))}),To=R({revisions:Ha(R({slug:I(),revision_id:I(),revision_number:Ma(),created_at:I(),reason:I()}))}),Eo=R({passkeys:Ha(R({credentialRef:I(),label:I(),deviceType:Ya([`singleDevice`,`multiDevice`]),backedUp:Ia(),createdAt:I(),lastUsedAt:I().nullable()})),clients:Ha(R({id:I(),clientName:I(),scope:Ha(I()),createdAt:I()})),sessions:Ha(R({sessionRef:I(),authenticatedAt:I(),createdAt:I(),current:Ia()}))}),Do=R({revoked:I(),sessionCleanupComplete:Ia()}),Oo=R({document:R({revisionId:I(),revisionNumber:Ma(),slug:I(),type:I(),title:I(),summary:I().nullable(),body:I(),createdAt:I(),metadata:Ha(R({key:I(),value:I()}))}),current:R({revisionId:I()}).nullable(),history:Ha(R({revisionId:I(),revisionNumber:Ma(),createdAt:I(),reason:I()}))}),ko=R({flowId:I(),options:Ra(),label:I().optional()}),Ao=R({flowId:I(),kind:Ya([`mcp`,`web`]),options:Ra(),clientName:I().optional(),requestedScopes:Ha(I()).optional()}),jo=R({clientName:I(),requestedScopes:Ha(I())});function Mo(e){return typeof e==`object`&&!!e}function No(e){return Mo(e)&&typeof e.challenge==`string`&&Mo(e.user)&&typeof e.user.id==`string`&&Array.isArray(e.pubKeyCredParams)}function Po(e){return Mo(e)&&typeof e.challenge==`string`}async function Fo(e){let t=await e.json();if(!e.ok){let n=Mo(t)&&typeof t.message==`string`?t.message:Mo(t)&&typeof t.error==`string`?t.error:`HTTP ${e.status}`;throw Error(n)}return t}async function Io(e,t){let n=new Headers(t?.headers);return n.set(`content-type`,`application/json`),await Fo(await fetch(e,{...t,headers:n}))}function Lo(e,t=``){let[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(null),[o,s]=(0,H.useState)(0),c=(0,H.useCallback)(()=>{s(e=>e+1)},[]),l=(0,H.useEffectEvent)(e);return(0,H.useEffect)(()=>{let e=!0;return l().then(t=>{e&&r(t)}).catch(t=>{e&&a(t instanceof Error?t.message:`Request failed`)}),()=>{e=!1}},[t,o]),{value:n,error:i,reload:c}}function Ro({children:e}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`a`,{className:`brand`,href:`/app`,children:[(0,U.jsx)(`span`,{children:`W`}),`Wikimemory`]}),(0,U.jsx)(`a`,{href:`/app`,children:`Browse`}),(0,U.jsx)(`a`,{href:`/app/search`,children:`Search`}),(0,U.jsx)(`a`,{href:`/app/history`,children:`Recent`}),(0,U.jsx)(`a`,{href:`/app/manage`,children:`Manage`})]}),(0,U.jsx)(`main`,{children:e})]})}function zo({items:e}){return e.length===0?(0,U.jsx)(`p`,{className:`muted`,children:`No documents found.`}):(0,U.jsx)(`div`,{className:`grid`,children:e.map(e=>(0,U.jsxs)(`article`,{className:`card`,children:[(0,U.jsxs)(`div`,{className:`meta`,children:[(0,U.jsx)(`span`,{children:e.type}),e.status?(0,U.jsx)(`span`,{children:e.status}):null]}),(0,U.jsx)(`h2`,{children:(0,U.jsx)(`a`,{href:`/app/docs/${encodeURIComponent(e.slug)}`,children:e.title})}),(0,U.jsx)(`small`,{children:e.slug}),(0,U.jsx)(`p`,{children:e.summary??`No summary`})]},e.slug))})}function Bo(){let e=new URLSearchParams(location.search).get(`flowId`),t=Lo(async()=>Ao.parse(await Io(`/api/auth/options?flowId=${encodeURIComponent(e??``)}`)),e??``),[n,r]=(0,H.useState)(`Waiting for authorization details…`);async function i(){if(!(t.value===null||!Po(t.value.options))){r(`Waiting for your passkey…`);try{let e=await _({optionsJSON:t.value.options}),n=R({redirectTo:I()}).parse(await Io(`/auth/passkey/verify`,{method:`POST`,body:JSON.stringify({flowId:t.value.flowId,response:e})}));location.assign(n.redirectTo)}catch(e){r(e instanceof Error?e.message:`Authentication failed`)}}}return(0,U.jsx)(`main`,{className:`center`,children:(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h1`,{children:`Wikimemory`}),t.value?.kind===`mcp`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`p`,{children:[(0,U.jsx)(`strong`,{children:t.value.clientName??`An MCP client`}),` is requesting access.`]}),(0,U.jsx)(`ul`,{children:t.value.requestedScopes?.map(e=>(0,U.jsx)(`li`,{children:e},e))})]}):(0,U.jsx)(`p`,{children:`Sign in to browse your memory.`}),(0,U.jsx)(`button`,{disabled:t.value===null,onClick:()=>void i(),children:`Continue with passkey`}),(0,U.jsx)(`p`,{className:`muted`,children:t.error??n})]})})}function Vo(){let e=location.search,t=Lo(async()=>jo.parse(await Io(`/api/local-authorize/options${e}`)),e),[n,r]=(0,H.useState)(`Review this local test authorization.`);async function i(){r(`Authorizing local test owner…`);try{let t=R({redirectTo:I()}).parse(await Io(`/api/local-authorize/approve${e}`,{method:`POST`,body:`{}`}));location.assign(t.redirectTo)}catch(e){r(e instanceof Error?e.message:`Authorization failed`)}}return(0,U.jsx)(`main`,{className:`center`,children:(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h1`,{children:`Authorize local Wikimemory`}),(0,U.jsxs)(`p`,{children:[(0,U.jsx)(`strong`,{children:t.value?.clientName??`An MCP client`}),` is requesting access to the explicit local test owner.`]}),(0,U.jsx)(`ul`,{children:t.value?.requestedScopes.map(e=>(0,U.jsx)(`li`,{children:e},e))}),(0,U.jsx)(`button`,{disabled:t.value===null,onClick:()=>void i(),children:`Continue as local test owner`}),(0,U.jsx)(`p`,{className:`muted`,children:t.error??n})]})})}function Ho({recovery:e}){let[t]=(0,H.useState)(()=>decodeURIComponent(location.hash.slice(1))),[n,r]=(0,H.useState)(e?`Primary passkey`:`Backup passkey`),[i,a]=(0,H.useState)(``),[o,s]=(0,H.useState)(null);(0,H.useEffect)(()=>{history.replaceState(null,``,location.pathname)},[]);async function c(){a(`Waiting for your passkey…`);try{let r=e?`/setup`:`/passkeys/add`,i=e?{token:t,label:n}:{token:t},a=ko.parse(await Io(`${r}/options`,{method:`POST`,body:JSON.stringify(i)}));if(!No(a.options))throw Error(`Server returned invalid passkey options`);let o=await f({optionsJSON:a.options}),c=R({ok:Za(!0),mode:I().optional(),label:I().optional()}).parse(await Io(`${r}/verify`,{method:`POST`,body:JSON.stringify({flowId:a.flowId,response:o})}));s({label:c.label??n,message:c.mode===`recovery`?`Previous credentials and sessions were revoked.`:`Your existing credentials remain active.`})}catch(e){a(e instanceof Error?e.message:`Registration failed`)}}return o===null?(0,U.jsx)(`main`,{className:`center`,children:(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h1`,{children:e?`Set up Wikimemory`:`Add a passkey`}),(0,U.jsx)(`p`,{children:e?`Initial setup creates the owner credential; recovery replaces every existing credential.`:`This adds another owner credential without removing existing passkeys.`}),e?(0,U.jsxs)(`label`,{children:[`Passkey name`,(0,U.jsx)(`input`,{value:n,maxLength:80,onChange:e=>{r(e.target.value)}})]}):null,(0,U.jsx)(`button`,{disabled:t===``,onClick:()=>void c(),children:`Create passkey`}),(0,U.jsx)(`p`,{className:`muted`,children:t===``?`The one-time token is missing.`:i})]})}):(0,U.jsx)(`main`,{className:`center`,children:(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h1`,{children:`Passkey created`}),(0,U.jsxs)(`p`,{children:[(0,U.jsx)(`strong`,{children:o.label}),` is ready.`]}),(0,U.jsx)(`p`,{children:o.message}),(0,U.jsx)(`a`,{className:`button`,href:e?`/app/login`:`/app/manage`,children:e?`Continue to Wikimemory`:`Return to passkey management`})]})})}function Uo(){let e=Lo(async()=>Co.parse(await Io(`/api/app/documents`)));return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h1`,{children:`Browse memory`}),(0,U.jsx)(`p`,{className:`lede`,children:`The current pages in your durable store.`}),e.error?(0,U.jsx)(`p`,{children:e.error}):e.value===null?(0,U.jsx)(`p`,{children:`Loading…`}):(0,U.jsx)(zo,{items:e.value.items})]})}function Wo(){let e=new URLSearchParams(location.search).get(`q`)??``,[t,n]=(0,H.useState)(e),[r,i]=(0,H.useState)(e),a=Lo(async()=>r===``?{hits:[]}:wo.parse(await Io(`/api/app/search?q=${encodeURIComponent(r)}`)),r);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h1`,{children:`Search`}),(0,U.jsxs)(`form`,{className:`search`,onSubmit:e=>{e.preventDefault(),i(t.trim())},children:[(0,U.jsx)(`input`,{value:t,onChange:e=>{n(e.target.value)},placeholder:`Search durable memory…`}),(0,U.jsx)(`button`,{children:`Search`})]}),a.value?(0,U.jsx)(zo,{items:a.value.hits}):null]})}function Go(){let e=Lo(async()=>To.parse(await Io(`/api/app/recent`)));return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h1`,{children:`Recent revisions`}),(0,U.jsx)(`ol`,{className:`list`,children:e.value?.revisions.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsxs)(`a`,{href:`/app/docs/${encodeURIComponent(e.slug)}?revision=${encodeURIComponent(e.revision_id)}`,children:[e.slug,` revision `,e.revision_number]}),(0,U.jsxs)(`small`,{children:[e.created_at,` · `,e.reason]})]},e.revision_id))})]})}function Ko({slug:e}){let t=new URLSearchParams(location.search).get(`revision`),n=`/api/app/docs/${encodeURIComponent(e)}${t===null?``:`?revision=${encodeURIComponent(t)}`}`,r=Lo(async()=>Oo.parse(await Io(n)),n),[i,a]=(0,H.useState)(``);if(r.error!==null)return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h1`,{children:`Document unavailable`}),(0,U.jsx)(`p`,{children:r.error})]});if(r.value===null)return(0,U.jsx)(`p`,{children:`Loading…`});let{document:o,current:s,history:c}=r.value,l=s!==null&&s.revisionId!==o.revisionId;async function u(){s!==null&&(await Io(`/api/app/docs/${encodeURIComponent(e)}/restore`,{method:`POST`,body:JSON.stringify({targetRevisionId:o.revisionId,expectedRevisionId:s.revisionId})}),a(`Restored as a new revision.`),location.assign(`/app/docs/${encodeURIComponent(e)}`))}return(0,U.jsxs)(`article`,{children:[(0,U.jsxs)(`div`,{className:`meta`,children:[(0,U.jsx)(`span`,{children:o.type}),(0,U.jsxs)(`span`,{children:[`revision `,o.revisionNumber]})]}),(0,U.jsx)(`h1`,{children:o.title}),(0,U.jsx)(`p`,{className:`lede`,children:o.summary??o.slug}),i===``?null:(0,U.jsx)(`p`,{className:`notice`,children:i}),l?(0,U.jsx)(`button`,{onClick:()=>void u(),children:`Restore this revision`}):null,o.metadata.length===0?null:(0,U.jsx)(`dl`,{className:`metadata`,children:o.metadata.map(e=>(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:e.key}),(0,U.jsx)(`dd`,{children:e.value})]},`${e.key}:${e.value}`))}),(0,U.jsx)(`pre`,{className:`document-body`,children:o.body}),(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h2`,{children:`History`}),(0,U.jsx)(`ol`,{className:`list`,children:c.map(t=>(0,U.jsxs)(`li`,{children:[(0,U.jsxs)(`a`,{href:`/app/docs/${encodeURIComponent(e)}?revision=${encodeURIComponent(t.revisionId)}`,children:[`Revision `,t.revisionNumber]}),(0,U.jsxs)(`small`,{children:[t.createdAt,` · `,t.reason]})]},t.revisionId))})]})]})}function qo({passkeysEnabled:e}){let t=Lo(async()=>Eo.parse(await Io(`/api/app/manage`))),[n,r]=(0,H.useState)(``),[i,a]=(0,H.useState)(``);async function o(e,n,r){let i=await Io(n,{method:e,body:JSON.stringify(r)});return t.reload(),i}return t.value===null?(0,U.jsx)(`p`,{children:t.error??`Loading…`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h1`,{children:`Manage Wikimemory`}),i?(0,U.jsx)(`p`,{className:`notice`,children:i}):null,e?(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h2`,{children:`Passkeys`}),(0,U.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),o(`POST`,`/api/app/passkeys`,{label:n}).then(e=>{let t=R({registrationUrl:I()}).parse(e);location.assign(t.registrationUrl)})},children:[(0,U.jsxs)(`label`,{children:[`New passkey name`,(0,U.jsx)(`input`,{required:!0,maxLength:80,value:n,onChange:e=>{r(e.target.value)}})]}),(0,U.jsx)(`button`,{children:`Add passkey`})]}),(0,U.jsx)(`ol`,{className:`list`,children:t.value.passkeys.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`strong`,{children:e.label}),(0,U.jsxs)(`small`,{children:[e.deviceType,` · `,e.backedUp?`backed up`:`not backed up`,` · created `,e.createdAt,e.lastUsedAt?` · last used ${e.lastUsedAt}`:``]}),(0,U.jsx)(`button`,{className:`danger`,disabled:t.value?.passkeys.length===1,onClick:()=>void o(`DELETE`,`/api/app/passkeys`,{credentialRef:e.credentialRef}).then(e=>{let t=Do.parse(e);a(t.sessionCleanupComplete?`Passkey and its browser sessions were revoked.`:`Passkey revoked. Browser-session cleanup could not be confirmed; those sessions are blocked because the passkey no longer exists.`)}),children:`Revoke`})]},e.credentialRef))})]}):(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h2`,{children:`Passkeys`}),(0,U.jsx)(`p`,{className:`muted`,children:`Passkey management is disabled for the fake local owner.`})]}),(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h2`,{children:`Authorized MCP clients`}),(0,U.jsx)(`ol`,{className:`list`,children:t.value.clients.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`strong`,{children:e.clientName}),(0,U.jsxs)(`small`,{children:[e.scope.join(` `),` · `,e.createdAt]}),(0,U.jsx)(`button`,{className:`danger`,onClick:()=>void o(`DELETE`,`/api/app/grants`,{grantId:e.id}),children:`Revoke`})]},e.id))})]}),(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h2`,{children:`Browser sessions`}),(0,U.jsx)(`ol`,{className:`list`,children:t.value.sessions.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`strong`,{children:e.current?`Current browser`:`Browser session`}),(0,U.jsx)(`small`,{children:e.createdAt}),(0,U.jsx)(`button`,{className:`danger`,onClick:()=>void o(`DELETE`,`/api/app/sessions`,{sessionRef:e.sessionRef}),children:`Revoke`})]},e.sessionRef))})]}),(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h2`,{children:`Export`}),(0,U.jsx)(`a`,{href:`/api/app/export.jsonl`,children:`Download JSONL history`}),` ·`,` `,(0,U.jsx)(`a`,{href:`/api/app/export.md`,children:`Download current Markdown`})]})]})}function Jo(){let e=Lo(async()=>So.parse(await Io(`/api/app/session`))),[t,n]=(0,H.useState)(``);if(e.error)return(0,U.jsx)(`main`,{className:`center`,children:(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h1`,{children:`Wikimemory`}),(0,U.jsx)(`p`,{children:e.error})]})});if(e.value===null)return(0,U.jsx)(`p`,{children:`Loading…`});if(!e.value.authenticated){async function r(){try{await Io(`/api/app/login`,{method:`POST`,body:`{}`}),e.reload()}catch(e){n(e instanceof Error?e.message:`Sign-in failed`)}}return(0,U.jsx)(`main`,{className:`center`,children:(0,U.jsxs)(`section`,{className:`panel`,children:[(0,U.jsx)(`h1`,{children:`Wikimemory`}),(0,U.jsx)(`p`,{children:e.value.environment===`local`?`Use the explicit local test owner. No production passkey is involved.`:`Use an owner passkey to browse your memory.`}),e.value.environment===`local`?(0,U.jsx)(`button`,{onClick:()=>void r(),children:`Continue as local test owner`}):(0,U.jsx)(`a`,{className:`button`,href:e.value.loginUrl??`/app/login`,children:`Continue with passkey`}),t===``?null:(0,U.jsx)(`p`,{children:t})]})})}let r=location.pathname;return(0,U.jsx)(Ro,{children:r===`/app/search`?(0,U.jsx)(Wo,{}):r===`/app/history`?(0,U.jsx)(Go,{}):r===`/app/manage`?(0,U.jsx)(qo,{passkeysEnabled:e.value.environment===`production`}):r.startsWith(`/app/docs/`)?(0,U.jsx)(Ko,{slug:decodeURIComponent(r.slice(10))}):(0,U.jsx)(Uo,{})})}function Yo(){return location.pathname===`/login`?(0,U.jsx)(Bo,{}):location.pathname===`/local-authorize`?(0,U.jsx)(Vo,{}):location.pathname===`/setup`?(0,U.jsx)(Ho,{recovery:!0}):location.pathname===`/passkeys/add`?(0,U.jsx)(Ho,{recovery:!1}):(0,U.jsx)(Jo,{})}var Xo=document.getElementById(`root`);Xo!==null&&(0,yo.createRoot)(Xo).render((0,U.jsx)(H.StrictMode,{children:(0,U.jsx)(Yo,{})}));
|
package/dist/web/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<meta name="referrer" content="no-referrer" />
|
|
7
7
|
<title>Wikimemory</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-CGTHUs4b.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-CjnFBnXp.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/package.json
CHANGED
package/release-manifest.json
CHANGED
|
@@ -26,7 +26,7 @@ For Claude on phone, configure the same HTTPS endpoint as a custom connector in
|
|
|
26
26
|
## Deploy a new instance
|
|
27
27
|
|
|
28
28
|
1. Confirm the user controls a Cloudflare account. Deployment changes external state, so show the exact target account, Worker name, D1 database name, and KV namespace before applying it.
|
|
29
|
-
2. Run `npx wikimemory install`, or the repository's guided TypeScript workflow for
|
|
29
|
+
2. Run `npx --yes wikimemory install`, or the repository's guided TypeScript workflow for
|
|
30
30
|
maintainer testing. Use `--deployment NAME` for a
|
|
31
31
|
non-default installation. Do not reimplement provisioning steps ad hoc.
|
|
32
32
|
3. Stop after the installer prints the one-time URL. The human must open it and create the owner passkey; never open, copy, or retain that URL for them.
|
|
@@ -37,7 +37,7 @@ If a provisioning step fails after the config is created, rerun the documented
|
|
|
37
37
|
`--resume` workflow. It must require the installer's successful-preflight state.
|
|
38
38
|
Never work around a remote resource name collision by deploying over it.
|
|
39
39
|
|
|
40
|
-
For lost-passkey recovery, use `npx wikimemory recover` or the documented repository
|
|
40
|
+
For lost-passkey recovery, use `npx --yes wikimemory recover` or the documented repository
|
|
41
41
|
fallback.
|
|
42
42
|
It rotates the bootstrap hash and prints a one-use registration URL. Existing
|
|
43
43
|
credentials remain active until the replacement verifies; successful recovery then
|
|
@@ -53,7 +53,7 @@ If production deployment is marked incomplete in the installation guide, stop af
|
|
|
53
53
|
|
|
54
54
|
## Update an existing instance
|
|
55
55
|
|
|
56
|
-
1. Run `npx wikimemory status` first, then use `npx wikimemory upgrade` or
|
|
56
|
+
1. Run `npx --yes wikimemory status` first, then use `npx --yes wikimemory upgrade` or
|
|
57
57
|
`npm run upgrade` for maintainer testing from this repository.
|
|
58
58
|
2. Let the CLI load the non-secret deployment record written by setup and show the
|
|
59
59
|
exact account, Worker, D1 database, KV namespace, origin, version transition, and
|
|
@@ -70,12 +70,12 @@ An ordinary update must not run `setup -- --resume` or `setup -- --recover`, rot
|
|
|
70
70
|
|
|
71
71
|
## Manage an installed instance
|
|
72
72
|
|
|
73
|
-
- Run `npx wikimemory dev` for package-owned local D1/KV/Worker testing; state is
|
|
73
|
+
- Run `npx --yes wikimemory dev` for package-owned local D1/KV/Worker testing; state is
|
|
74
74
|
retained under the current directory's `.wikimemory/dev`.
|
|
75
|
-
- Run `npx wikimemory passkeys list|add|revoke` for owner credential management.
|
|
76
|
-
- Run `npx wikimemory connect codex|claude` only when the user explicitly asks to
|
|
75
|
+
- Run `npx --yes wikimemory passkeys list|add|revoke` for owner credential management.
|
|
76
|
+
- Run `npx --yes wikimemory connect codex|claude` only when the user explicitly asks to
|
|
77
77
|
change that client's MCP configuration.
|
|
78
|
-
- Run `npx wikimemory skills install codex|claude` to install version-matched skills.
|
|
79
|
-
- Preview with `npx wikimemory uninstall`; apply only after exact-target review and
|
|
78
|
+
- Run `npx --yes wikimemory skills install codex|claude` to install version-matched skills.
|
|
79
|
+
- Preview with `npx --yes wikimemory uninstall`; apply only after exact-target review and
|
|
80
80
|
explicit destructive confirmation. Remind the user to remove client-owned MCP
|
|
81
81
|
registrations separately.
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const WIKIMEMORY_VERSION = "0.2.
|
|
1
|
+
export const WIKIMEMORY_VERSION = "0.2.2";
|
|
2
2
|
export const LATEST_SCHEMA_VERSION = "0004_credential_bound_registration_tokens.sql";
|