flavor-code 1.2.5 → 1.2.7
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 +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/{app-3DXEGSS7.js → app-R3SDG2OH.js} +1 -1
- package/dist/{chunk-3TYRDK34.js → chunk-5RHJ3PQN.js} +84 -13
- package/dist/{chunk-Z3BW52MK.js → chunk-WN2EZV3Y.js} +1 -1
- package/dist/cli.js +3 -3
- package/dist/desktop/main.js +86 -16
- package/dist/desktop-renderer/assets/{index-C66pDvHs.js → index-CLrVaR9H.js} +1 -1
- package/dist/desktop-renderer/index.html +1 -1
- package/dist/memory/store.d.ts +9 -0
- package/dist/sdk/index.js +2 -2
- package/dist/ui/commands.d.ts +1 -1
- package/dist/ui/session.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -147,7 +147,7 @@ Common commands:
|
|
|
147
147
|
| `/compact` | Manually compact long session context |
|
|
148
148
|
| `/checkpoint`, `/tree` | Save state, view the session tree |
|
|
149
149
|
| `/rewind`, `/unrevert`, `/fork` | Resume or fork sessions |
|
|
150
|
-
| `/memory`, `/remember`, `/forget` | Manage long-term memory |
|
|
150
|
+
| `/memory`, `/remember`, `/forget`, `/forget-cold` | Manage long-term memory; `/forget-cold` purges cold entries and their files |
|
|
151
151
|
| `/mcp` | View and manage MCP servers |
|
|
152
152
|
| `/loop <goal>` | Run an autonomous loop with verification |
|
|
153
153
|
| `/goal <objective>` | Run the plan, execute, adversarial-review workflow |
|
package/README.zh-CN.md
CHANGED
|
@@ -147,7 +147,7 @@ OAuth PKCE 的运行时行为与配置约定见 [PKCE 规范](./docs/specs/pkce-
|
|
|
147
147
|
| `/compact` | 手动压缩长会话上下文 |
|
|
148
148
|
| `/checkpoint`、`/tree` | 保存现场、查看会话树 |
|
|
149
149
|
| `/rewind`、`/unrevert`、`/fork` | 恢复或分叉会话 |
|
|
150
|
-
| `/memory`、`/remember`、`/forget` |
|
|
150
|
+
| `/memory`、`/remember`、`/forget`、`/forget-cold` | 管理长期记忆;`/forget-cold` 清空 cold 记忆及其文件 |
|
|
151
151
|
| `/mcp` | 查看和管理 MCP 服务 |
|
|
152
152
|
| `/loop <goal>` | 运行带验证的自治循环 |
|
|
153
153
|
| `/goal <objective>` | 运行规划、执行、对抗审查流程 |
|
|
@@ -2328,6 +2328,7 @@ var MVP_COMMANDS = [
|
|
|
2328
2328
|
"memory",
|
|
2329
2329
|
"remember",
|
|
2330
2330
|
"forget",
|
|
2331
|
+
"forget-cold",
|
|
2331
2332
|
"checkpoint",
|
|
2332
2333
|
"tree",
|
|
2333
2334
|
"rewind",
|
|
@@ -2358,6 +2359,7 @@ var COMMAND_DESCRIPTIONS = {
|
|
|
2358
2359
|
memory: "Show long-term project memory",
|
|
2359
2360
|
remember: "Add a long-term memory",
|
|
2360
2361
|
forget: "Remove matching long-term memories",
|
|
2362
|
+
"forget-cold": "Remove all cold long-term memories and their files",
|
|
2361
2363
|
checkpoint: "Create a workspace and context checkpoint",
|
|
2362
2364
|
tree: "Show the session history tree",
|
|
2363
2365
|
rewind: "Restore a prior session node",
|
|
@@ -2504,7 +2506,7 @@ var HELP = [
|
|
|
2504
2506
|
"/permissions <default|acceptEdits|plan|bypassPermissions|auto|bubble>",
|
|
2505
2507
|
"/login authenticate via OAuth PKCE",
|
|
2506
2508
|
"/init /config /skills /plugins /hooks /tasks",
|
|
2507
|
-
"/memory /remember [type] <text> /forget <text-or-id> /finish",
|
|
2509
|
+
"/memory /remember [type] <text> /forget <text-or-id> /forget-cold /finish",
|
|
2508
2510
|
"/checkpoint [label] /tree /rewind <node> /unrevert /fork <node>",
|
|
2509
2511
|
"/compact /clear /help /exit",
|
|
2510
2512
|
"/loop <goal> run a verified autonomous loop",
|
|
@@ -2700,6 +2702,8 @@ var FlavorSession = class {
|
|
|
2700
2702
|
this.#notice(await this.#services.remember(command.type, command.text));
|
|
2701
2703
|
} else if (command.name === "forget") {
|
|
2702
2704
|
this.#notice(await this.#services.forget(command.query));
|
|
2705
|
+
} else if (command.name === "forget-cold") {
|
|
2706
|
+
this.#notice(await this.#services.forgetCold());
|
|
2703
2707
|
} else if (command.name === "finish") {
|
|
2704
2708
|
this.#notice(await this.#services.finishTask());
|
|
2705
2709
|
} else if (command.name === "checkpoint") {
|
|
@@ -12835,7 +12839,7 @@ ${total}`;
|
|
|
12835
12839
|
|
|
12836
12840
|
// src/memory/store.ts
|
|
12837
12841
|
import { createHash as createHash7 } from "crypto";
|
|
12838
|
-
import { readFile as readFile14 } from "fs/promises";
|
|
12842
|
+
import { readFile as readFile14, rm as rm7 } from "fs/promises";
|
|
12839
12843
|
import { resolve as resolve19, join as join15, relative as relative16, sep as sep15 } from "path";
|
|
12840
12844
|
|
|
12841
12845
|
// src/memory/similarity.ts
|
|
@@ -13062,6 +13066,50 @@ var MemoryStore = class {
|
|
|
13062
13066
|
}) }));
|
|
13063
13067
|
return removed;
|
|
13064
13068
|
}
|
|
13069
|
+
/**
|
|
13070
|
+
* Removes every cold memory entry and its backing content. A task file is
|
|
13071
|
+
* deleted only when all of its entries were cold; otherwise only the cold
|
|
13072
|
+
* entries are dropped from the shared file.
|
|
13073
|
+
*/
|
|
13074
|
+
async forgetCold(now = /* @__PURE__ */ new Date()) {
|
|
13075
|
+
let removedReferences = [];
|
|
13076
|
+
await this.#updateIndex((index) => {
|
|
13077
|
+
removedReferences = index.references.filter((reference) => classifyMemoryHeat(reference, now) === "cold");
|
|
13078
|
+
const removedIds = new Set(removedReferences.map((reference) => reference.id));
|
|
13079
|
+
return { ...index, references: index.references.filter((reference) => !removedIds.has(reference.id)) };
|
|
13080
|
+
});
|
|
13081
|
+
if (removedReferences.length === 0) return { removed: 0, filesRemoved: 0 };
|
|
13082
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
13083
|
+
for (const reference of removedReferences) {
|
|
13084
|
+
const group = byPath.get(reference.contentPath) ?? [];
|
|
13085
|
+
group.push(reference);
|
|
13086
|
+
byPath.set(reference.contentPath, group);
|
|
13087
|
+
}
|
|
13088
|
+
let filesRemoved = 0;
|
|
13089
|
+
for (const [contentPath, references] of byPath) {
|
|
13090
|
+
const removedIds = new Set(references.map((reference) => reference.id));
|
|
13091
|
+
const path = this.#resolveContentPath(contentPath);
|
|
13092
|
+
const recovered = await readRecoverableFile(path, decodeTask);
|
|
13093
|
+
if (recovered === void 0) continue;
|
|
13094
|
+
const remaining = recovered.value.items.filter((item) => !removedIds.has(item.id));
|
|
13095
|
+
if (remaining.length === 0) {
|
|
13096
|
+
await rm7(path, { force: true });
|
|
13097
|
+
await rm7(`${path}.bak`, { force: true });
|
|
13098
|
+
filesRemoved += 1;
|
|
13099
|
+
} else {
|
|
13100
|
+
await updateProtectedFile({
|
|
13101
|
+
path,
|
|
13102
|
+
decode: decodeTask,
|
|
13103
|
+
encode: encodeTask,
|
|
13104
|
+
update: (current) => {
|
|
13105
|
+
const document = current ?? recovered.value;
|
|
13106
|
+
return { ...document, items: document.items.filter((item) => !removedIds.has(item.id)) };
|
|
13107
|
+
}
|
|
13108
|
+
});
|
|
13109
|
+
}
|
|
13110
|
+
}
|
|
13111
|
+
return { removed: removedReferences.length, filesRemoved };
|
|
13112
|
+
}
|
|
13065
13113
|
async recall(query, options) {
|
|
13066
13114
|
assertTaskId(options.taskId);
|
|
13067
13115
|
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
@@ -13870,9 +13918,17 @@ async function createProductionRuntime(options) {
|
|
|
13870
13918
|
const home = resolve21(options.home ?? homedir());
|
|
13871
13919
|
const environment = options.environment ?? process.env;
|
|
13872
13920
|
const ide = new FlavorIdeClient({ workspace, home, environment });
|
|
13921
|
+
const ideReady = ide.initialize();
|
|
13922
|
+
const gitRepository = detectGitRepository(workspace);
|
|
13873
13923
|
const loaded = await loadConfig({ cwd: workspace, home, environment });
|
|
13874
|
-
await ide.initialize();
|
|
13875
13924
|
const config = loaded.config;
|
|
13925
|
+
const mcpReady = connectMcpServers({
|
|
13926
|
+
servers: config.mcpServers,
|
|
13927
|
+
workspace,
|
|
13928
|
+
clientFactory: options.mcpClientFactory ?? connectSdkMcpClient
|
|
13929
|
+
});
|
|
13930
|
+
mcpReady.catch(() => void 0);
|
|
13931
|
+
let mcpDiscarded = false;
|
|
13876
13932
|
const sessionStore = new SessionStore({ workspace, maxSessions: config.maxSessions });
|
|
13877
13933
|
const memoryStore = config.memory.enabled ? new MemoryStore({
|
|
13878
13934
|
workspace,
|
|
@@ -14100,12 +14156,6 @@ async function createProductionRuntime(options) {
|
|
|
14100
14156
|
await pluginHost.loadAll();
|
|
14101
14157
|
let sleepScheduler;
|
|
14102
14158
|
try {
|
|
14103
|
-
mcpManager = await connectMcpServers({
|
|
14104
|
-
servers: config.mcpServers,
|
|
14105
|
-
workspace,
|
|
14106
|
-
clientFactory: options.mcpClientFactory ?? connectSdkMcpClient
|
|
14107
|
-
});
|
|
14108
|
-
diagnostics.push(...mcpManager.diagnostics);
|
|
14109
14159
|
const syncMcpTools = () => {
|
|
14110
14160
|
for (const tool of mcpTools) remove(tools, tool);
|
|
14111
14161
|
mcpTools.length = 0;
|
|
@@ -14120,14 +14170,25 @@ async function createProductionRuntime(options) {
|
|
|
14120
14170
|
}
|
|
14121
14171
|
if (harnessCreated) harness.replaceMainTools(tools);
|
|
14122
14172
|
};
|
|
14123
|
-
|
|
14173
|
+
void mcpReady.then((manager) => {
|
|
14174
|
+
if (mcpDiscarded) {
|
|
14175
|
+
void manager.close().catch(() => void 0);
|
|
14176
|
+
return;
|
|
14177
|
+
}
|
|
14178
|
+
mcpManager = manager;
|
|
14179
|
+
diagnostics.push(...manager.diagnostics);
|
|
14180
|
+
syncMcpTools();
|
|
14181
|
+
}, (error) => {
|
|
14182
|
+
diagnostics.push(`MCP servers could not start: ${message(error)}`);
|
|
14183
|
+
});
|
|
14124
14184
|
const skills = new SkillRegistry({
|
|
14125
14185
|
globalRoots: [join17(home, ".flavor-code", "skills")],
|
|
14126
14186
|
projectRoots: [join17(workspace, ".flavor", "skills"), ...pluginSkillRoots],
|
|
14127
14187
|
authorizeResource: async () => true,
|
|
14128
14188
|
disabledNames: config.skills.disabled
|
|
14129
14189
|
});
|
|
14130
|
-
|
|
14190
|
+
const skillsReady = skills.discover();
|
|
14191
|
+
skillsReady.catch(() => void 0);
|
|
14131
14192
|
tools.push(createSkillResourceTool(skills));
|
|
14132
14193
|
const flavor = await optionalText2(join17(workspace, "FLAVOR.md"));
|
|
14133
14194
|
let memoryContext;
|
|
@@ -14155,6 +14216,7 @@ async function createProductionRuntime(options) {
|
|
|
14155
14216
|
let sessionId = recovered?.sessionId ?? `session-${(/* @__PURE__ */ new Date()).toISOString().replace(/[^0-9]/g, "").slice(0, 17)}-${randomUUID10().slice(0, 8)}`;
|
|
14156
14217
|
setUsageSession(sessionId);
|
|
14157
14218
|
ideSessionId = sessionId;
|
|
14219
|
+
await ideReady;
|
|
14158
14220
|
await ide.startSession(sessionId);
|
|
14159
14221
|
let createdAt = recovered?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
14160
14222
|
let memoryLifecycle = recovered?.memory ?? { status: "active", taskId: createMemoryTaskId(), messageStart: 0 };
|
|
@@ -14284,7 +14346,7 @@ async function createProductionRuntime(options) {
|
|
|
14284
14346
|
platform: process.platform,
|
|
14285
14347
|
osVersion: `${osVersion()} ${osRelease()}`,
|
|
14286
14348
|
shell: environment.ComSpec ?? environment.SHELL ?? "unknown",
|
|
14287
|
-
isGitRepository: await
|
|
14349
|
+
isGitRepository: await gitRepository
|
|
14288
14350
|
});
|
|
14289
14351
|
const createContext = (agent, agentTools, contextModelId, parentContext) => {
|
|
14290
14352
|
const taskState = serializedTaskState();
|
|
@@ -14344,6 +14406,7 @@ async function createProductionRuntime(options) {
|
|
|
14344
14406
|
showWarnings: config.hallucination.showWarnings,
|
|
14345
14407
|
evaluationTimeoutMs: config.hallucination.evaluationTimeoutMs
|
|
14346
14408
|
});
|
|
14409
|
+
await skillsReady;
|
|
14347
14410
|
harness = new LocalHarness({
|
|
14348
14411
|
registry,
|
|
14349
14412
|
hooks,
|
|
@@ -14771,7 +14834,7 @@ async function createProductionRuntime(options) {
|
|
|
14771
14834
|
runGoal: (goal, signal) => persistEach(runGoalSession(goalOrchestrator, goal, signal), persist),
|
|
14772
14835
|
mcp: async (command, signal) => {
|
|
14773
14836
|
signal.throwIfAborted();
|
|
14774
|
-
const manager =
|
|
14837
|
+
const manager = await mcpReady;
|
|
14775
14838
|
if (command.action === "status") return redactSecrets(formatMcpStatus(manager), secrets);
|
|
14776
14839
|
if (command.action === "tools") return redactSecrets(formatMcpTools(manager, command.target), secrets);
|
|
14777
14840
|
if (command.action === "reconnect") {
|
|
@@ -14962,6 +15025,12 @@ ${renderMemoryDocument(entries)}`;
|
|
|
14962
15025
|
if (removed > 0) await refreshMemoryState();
|
|
14963
15026
|
return removed === 0 ? "No matching memory found." : `Forgot ${removed} memory ${removed === 1 ? "entry" : "entries"}.`;
|
|
14964
15027
|
},
|
|
15028
|
+
forgetCold: async () => {
|
|
15029
|
+
if (memoryStore === void 0) return "Long-term memory is disabled.";
|
|
15030
|
+
const { removed, filesRemoved } = await memoryStore.forgetCold();
|
|
15031
|
+
if (removed > 0) await refreshMemoryState();
|
|
15032
|
+
return removed === 0 ? "No cold long-term memories to remove." : `Forgot ${removed} cold memory ${removed === 1 ? "entry" : "entries"} and removed ${filesRemoved} task ${filesRemoved === 1 ? "file" : "files"}.`;
|
|
15033
|
+
},
|
|
14965
15034
|
finishTask: () => finalizeMemoryTask(true),
|
|
14966
15035
|
pluginCommands: () => [...pluginCommands.keys()].sort(),
|
|
14967
15036
|
runPluginCommand: async (name, args, signal) => {
|
|
@@ -15074,6 +15143,7 @@ ${renderMemoryDocument(entries)}`;
|
|
|
15074
15143
|
async dispose() {
|
|
15075
15144
|
if (disposed) return;
|
|
15076
15145
|
disposed = true;
|
|
15146
|
+
mcpDiscarded = true;
|
|
15077
15147
|
await sleepScheduler?.dispose();
|
|
15078
15148
|
await memoryCoordinator?.flush();
|
|
15079
15149
|
await persist();
|
|
@@ -15086,6 +15156,7 @@ ${renderMemoryDocument(entries)}`;
|
|
|
15086
15156
|
}
|
|
15087
15157
|
};
|
|
15088
15158
|
} catch (primaryError) {
|
|
15159
|
+
mcpDiscarded = true;
|
|
15089
15160
|
memoryReviews.dispose();
|
|
15090
15161
|
try {
|
|
15091
15162
|
if (ideSessionId !== void 0) await ide.endSession(ideSessionId);
|
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createRequire } from "node:module"; const require = createRequire(impor
|
|
|
3
3
|
import {
|
|
4
4
|
FlavorRpcServer,
|
|
5
5
|
TraceRecorder
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WN2EZV3Y.js";
|
|
7
7
|
import {
|
|
8
8
|
staticTaskLines
|
|
9
9
|
} from "./chunk-KKIBYDJI.js";
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
message,
|
|
21
21
|
packageVersion,
|
|
22
22
|
redactErrorText
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-5RHJ3PQN.js";
|
|
24
24
|
import {
|
|
25
25
|
McpServerConfigSchema,
|
|
26
26
|
McpServerNameSchema,
|
|
@@ -771,7 +771,7 @@ function createProgram() {
|
|
|
771
771
|
const [{ render, AlternateScreen }, { createElement }, { App }] = await Promise.all([
|
|
772
772
|
import("./claude-ink-WPWPEL5A.js"),
|
|
773
773
|
import("react"),
|
|
774
|
-
import("./app-
|
|
774
|
+
import("./app-R3SDG2OH.js")
|
|
775
775
|
]);
|
|
776
776
|
const instance = await render(createElement(
|
|
777
777
|
AlternateScreen,
|
package/dist/desktop/main.js
CHANGED
|
@@ -12573,6 +12573,7 @@ var MVP_COMMANDS = [
|
|
|
12573
12573
|
"memory",
|
|
12574
12574
|
"remember",
|
|
12575
12575
|
"forget",
|
|
12576
|
+
"forget-cold",
|
|
12576
12577
|
"checkpoint",
|
|
12577
12578
|
"tree",
|
|
12578
12579
|
"rewind",
|
|
@@ -12719,7 +12720,7 @@ var HELP = [
|
|
|
12719
12720
|
"/permissions <default|acceptEdits|plan|bypassPermissions|auto|bubble>",
|
|
12720
12721
|
"/login authenticate via OAuth PKCE",
|
|
12721
12722
|
"/init /config /skills /plugins /hooks /tasks",
|
|
12722
|
-
"/memory /remember [type] <text> /forget <text-or-id> /finish",
|
|
12723
|
+
"/memory /remember [type] <text> /forget <text-or-id> /forget-cold /finish",
|
|
12723
12724
|
"/checkpoint [label] /tree /rewind <node> /unrevert /fork <node>",
|
|
12724
12725
|
"/compact /clear /help /exit",
|
|
12725
12726
|
"/loop <goal> run a verified autonomous loop",
|
|
@@ -12915,6 +12916,8 @@ var FlavorSession = class {
|
|
|
12915
12916
|
this.#notice(await this.#services.remember(command.type, command.text));
|
|
12916
12917
|
} else if (command.name === "forget") {
|
|
12917
12918
|
this.#notice(await this.#services.forget(command.query));
|
|
12919
|
+
} else if (command.name === "forget-cold") {
|
|
12920
|
+
this.#notice(await this.#services.forgetCold());
|
|
12918
12921
|
} else if (command.name === "finish") {
|
|
12919
12922
|
this.#notice(await this.#services.finishTask());
|
|
12920
12923
|
} else if (command.name === "checkpoint") {
|
|
@@ -13738,7 +13741,7 @@ ${total}`;
|
|
|
13738
13741
|
|
|
13739
13742
|
// src/memory/store.ts
|
|
13740
13743
|
import { createHash as createHash8 } from "crypto";
|
|
13741
|
-
import { readFile as readFile17 } from "fs/promises";
|
|
13744
|
+
import { readFile as readFile17, rm as rm9 } from "fs/promises";
|
|
13742
13745
|
import { resolve as resolve20, join as join19, relative as relative15, sep as sep14 } from "path";
|
|
13743
13746
|
|
|
13744
13747
|
// src/memory/similarity.ts
|
|
@@ -13965,6 +13968,50 @@ var MemoryStore = class {
|
|
|
13965
13968
|
}) }));
|
|
13966
13969
|
return removed;
|
|
13967
13970
|
}
|
|
13971
|
+
/**
|
|
13972
|
+
* Removes every cold memory entry and its backing content. A task file is
|
|
13973
|
+
* deleted only when all of its entries were cold; otherwise only the cold
|
|
13974
|
+
* entries are dropped from the shared file.
|
|
13975
|
+
*/
|
|
13976
|
+
async forgetCold(now = /* @__PURE__ */ new Date()) {
|
|
13977
|
+
let removedReferences = [];
|
|
13978
|
+
await this.#updateIndex((index) => {
|
|
13979
|
+
removedReferences = index.references.filter((reference) => classifyMemoryHeat(reference, now) === "cold");
|
|
13980
|
+
const removedIds = new Set(removedReferences.map((reference) => reference.id));
|
|
13981
|
+
return { ...index, references: index.references.filter((reference) => !removedIds.has(reference.id)) };
|
|
13982
|
+
});
|
|
13983
|
+
if (removedReferences.length === 0) return { removed: 0, filesRemoved: 0 };
|
|
13984
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
13985
|
+
for (const reference of removedReferences) {
|
|
13986
|
+
const group = byPath.get(reference.contentPath) ?? [];
|
|
13987
|
+
group.push(reference);
|
|
13988
|
+
byPath.set(reference.contentPath, group);
|
|
13989
|
+
}
|
|
13990
|
+
let filesRemoved = 0;
|
|
13991
|
+
for (const [contentPath, references] of byPath) {
|
|
13992
|
+
const removedIds = new Set(references.map((reference) => reference.id));
|
|
13993
|
+
const path = this.#resolveContentPath(contentPath);
|
|
13994
|
+
const recovered = await readRecoverableFile(path, decodeTask);
|
|
13995
|
+
if (recovered === void 0) continue;
|
|
13996
|
+
const remaining = recovered.value.items.filter((item) => !removedIds.has(item.id));
|
|
13997
|
+
if (remaining.length === 0) {
|
|
13998
|
+
await rm9(path, { force: true });
|
|
13999
|
+
await rm9(`${path}.bak`, { force: true });
|
|
14000
|
+
filesRemoved += 1;
|
|
14001
|
+
} else {
|
|
14002
|
+
await updateProtectedFile({
|
|
14003
|
+
path,
|
|
14004
|
+
decode: decodeTask,
|
|
14005
|
+
encode: encodeTask,
|
|
14006
|
+
update: (current) => {
|
|
14007
|
+
const document = current ?? recovered.value;
|
|
14008
|
+
return { ...document, items: document.items.filter((item) => !removedIds.has(item.id)) };
|
|
14009
|
+
}
|
|
14010
|
+
});
|
|
14011
|
+
}
|
|
14012
|
+
}
|
|
14013
|
+
return { removed: removedReferences.length, filesRemoved };
|
|
14014
|
+
}
|
|
13968
14015
|
async recall(query, options) {
|
|
13969
14016
|
assertTaskId(options.taskId);
|
|
13970
14017
|
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
@@ -14867,9 +14914,17 @@ async function createProductionRuntime(options) {
|
|
|
14867
14914
|
const home = resolve23(options.home ?? homedir());
|
|
14868
14915
|
const environment = options.environment ?? process.env;
|
|
14869
14916
|
const ide = new FlavorIdeClient({ workspace, home, environment });
|
|
14917
|
+
const ideReady = ide.initialize();
|
|
14918
|
+
const gitRepository = detectGitRepository(workspace);
|
|
14870
14919
|
const loaded = await loadConfig({ cwd: workspace, home, environment });
|
|
14871
|
-
await ide.initialize();
|
|
14872
14920
|
const config = loaded.config;
|
|
14921
|
+
const mcpReady = connectMcpServers({
|
|
14922
|
+
servers: config.mcpServers,
|
|
14923
|
+
workspace,
|
|
14924
|
+
clientFactory: options.mcpClientFactory ?? connectSdkMcpClient
|
|
14925
|
+
});
|
|
14926
|
+
mcpReady.catch(() => void 0);
|
|
14927
|
+
let mcpDiscarded = false;
|
|
14873
14928
|
const sessionStore = new SessionStore({ workspace, maxSessions: config.maxSessions });
|
|
14874
14929
|
const memoryStore = config.memory.enabled ? new MemoryStore({
|
|
14875
14930
|
workspace,
|
|
@@ -15097,12 +15152,6 @@ async function createProductionRuntime(options) {
|
|
|
15097
15152
|
await pluginHost.loadAll();
|
|
15098
15153
|
let sleepScheduler;
|
|
15099
15154
|
try {
|
|
15100
|
-
mcpManager = await connectMcpServers({
|
|
15101
|
-
servers: config.mcpServers,
|
|
15102
|
-
workspace,
|
|
15103
|
-
clientFactory: options.mcpClientFactory ?? connectSdkMcpClient
|
|
15104
|
-
});
|
|
15105
|
-
diagnostics.push(...mcpManager.diagnostics);
|
|
15106
15155
|
const syncMcpTools = () => {
|
|
15107
15156
|
for (const tool of mcpTools) remove(tools, tool);
|
|
15108
15157
|
mcpTools.length = 0;
|
|
@@ -15117,14 +15166,25 @@ async function createProductionRuntime(options) {
|
|
|
15117
15166
|
}
|
|
15118
15167
|
if (harnessCreated) harness.replaceMainTools(tools);
|
|
15119
15168
|
};
|
|
15120
|
-
|
|
15169
|
+
void mcpReady.then((manager) => {
|
|
15170
|
+
if (mcpDiscarded) {
|
|
15171
|
+
void manager.close().catch(() => void 0);
|
|
15172
|
+
return;
|
|
15173
|
+
}
|
|
15174
|
+
mcpManager = manager;
|
|
15175
|
+
diagnostics.push(...manager.diagnostics);
|
|
15176
|
+
syncMcpTools();
|
|
15177
|
+
}, (error) => {
|
|
15178
|
+
diagnostics.push(`MCP servers could not start: ${message(error)}`);
|
|
15179
|
+
});
|
|
15121
15180
|
const skills = new SkillRegistry({
|
|
15122
15181
|
globalRoots: [join21(home, ".flavor-code", "skills")],
|
|
15123
15182
|
projectRoots: [join21(workspace, ".flavor", "skills"), ...pluginSkillRoots],
|
|
15124
15183
|
authorizeResource: async () => true,
|
|
15125
15184
|
disabledNames: config.skills.disabled
|
|
15126
15185
|
});
|
|
15127
|
-
|
|
15186
|
+
const skillsReady = skills.discover();
|
|
15187
|
+
skillsReady.catch(() => void 0);
|
|
15128
15188
|
tools.push(createSkillResourceTool(skills));
|
|
15129
15189
|
const flavor = await optionalText2(join21(workspace, "FLAVOR.md"));
|
|
15130
15190
|
let memoryContext;
|
|
@@ -15152,6 +15212,7 @@ async function createProductionRuntime(options) {
|
|
|
15152
15212
|
let sessionId = recovered?.sessionId ?? `session-${(/* @__PURE__ */ new Date()).toISOString().replace(/[^0-9]/g, "").slice(0, 17)}-${randomUUID12().slice(0, 8)}`;
|
|
15153
15213
|
setUsageSession(sessionId);
|
|
15154
15214
|
ideSessionId = sessionId;
|
|
15215
|
+
await ideReady;
|
|
15155
15216
|
await ide.startSession(sessionId);
|
|
15156
15217
|
let createdAt = recovered?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
15157
15218
|
let memoryLifecycle = recovered?.memory ?? { status: "active", taskId: createMemoryTaskId(), messageStart: 0 };
|
|
@@ -15281,7 +15342,7 @@ async function createProductionRuntime(options) {
|
|
|
15281
15342
|
platform: process.platform,
|
|
15282
15343
|
osVersion: `${osVersion()} ${osRelease()}`,
|
|
15283
15344
|
shell: environment.ComSpec ?? environment.SHELL ?? "unknown",
|
|
15284
|
-
isGitRepository: await
|
|
15345
|
+
isGitRepository: await gitRepository
|
|
15285
15346
|
});
|
|
15286
15347
|
const createContext = (agent, agentTools, contextModelId, parentContext) => {
|
|
15287
15348
|
const taskState = serializedTaskState();
|
|
@@ -15341,6 +15402,7 @@ async function createProductionRuntime(options) {
|
|
|
15341
15402
|
showWarnings: config.hallucination.showWarnings,
|
|
15342
15403
|
evaluationTimeoutMs: config.hallucination.evaluationTimeoutMs
|
|
15343
15404
|
});
|
|
15405
|
+
await skillsReady;
|
|
15344
15406
|
harness = new LocalHarness({
|
|
15345
15407
|
registry,
|
|
15346
15408
|
hooks,
|
|
@@ -15768,7 +15830,7 @@ async function createProductionRuntime(options) {
|
|
|
15768
15830
|
runGoal: (goal, signal) => persistEach(runGoalSession(goalOrchestrator, goal, signal), persist),
|
|
15769
15831
|
mcp: async (command, signal) => {
|
|
15770
15832
|
signal.throwIfAborted();
|
|
15771
|
-
const manager =
|
|
15833
|
+
const manager = await mcpReady;
|
|
15772
15834
|
if (command.action === "status") return redactSecrets(formatMcpStatus(manager), secrets);
|
|
15773
15835
|
if (command.action === "tools") return redactSecrets(formatMcpTools(manager, command.target), secrets);
|
|
15774
15836
|
if (command.action === "reconnect") {
|
|
@@ -15959,6 +16021,12 @@ ${renderMemoryDocument(entries)}`;
|
|
|
15959
16021
|
if (removed > 0) await refreshMemoryState();
|
|
15960
16022
|
return removed === 0 ? "No matching memory found." : `Forgot ${removed} memory ${removed === 1 ? "entry" : "entries"}.`;
|
|
15961
16023
|
},
|
|
16024
|
+
forgetCold: async () => {
|
|
16025
|
+
if (memoryStore === void 0) return "Long-term memory is disabled.";
|
|
16026
|
+
const { removed, filesRemoved } = await memoryStore.forgetCold();
|
|
16027
|
+
if (removed > 0) await refreshMemoryState();
|
|
16028
|
+
return removed === 0 ? "No cold long-term memories to remove." : `Forgot ${removed} cold memory ${removed === 1 ? "entry" : "entries"} and removed ${filesRemoved} task ${filesRemoved === 1 ? "file" : "files"}.`;
|
|
16029
|
+
},
|
|
15962
16030
|
finishTask: () => finalizeMemoryTask(true),
|
|
15963
16031
|
pluginCommands: () => [...pluginCommands.keys()].sort(),
|
|
15964
16032
|
runPluginCommand: async (name, args, signal) => {
|
|
@@ -16071,6 +16139,7 @@ ${renderMemoryDocument(entries)}`;
|
|
|
16071
16139
|
async dispose() {
|
|
16072
16140
|
if (disposed) return;
|
|
16073
16141
|
disposed = true;
|
|
16142
|
+
mcpDiscarded = true;
|
|
16074
16143
|
await sleepScheduler?.dispose();
|
|
16075
16144
|
await memoryCoordinator?.flush();
|
|
16076
16145
|
await persist();
|
|
@@ -16083,6 +16152,7 @@ ${renderMemoryDocument(entries)}`;
|
|
|
16083
16152
|
}
|
|
16084
16153
|
};
|
|
16085
16154
|
} catch (primaryError) {
|
|
16155
|
+
mcpDiscarded = true;
|
|
16086
16156
|
memoryReviews.dispose();
|
|
16087
16157
|
try {
|
|
16088
16158
|
if (ideSessionId !== void 0) await ide.endSession(ideSessionId);
|
|
@@ -16759,7 +16829,7 @@ function createMemoryTaskId() {
|
|
|
16759
16829
|
}
|
|
16760
16830
|
|
|
16761
16831
|
// src/skills/manager.ts
|
|
16762
|
-
import { lstat as lstat10, mkdir as mkdir18, readFile as readFile20, readdir as readdir10, realpath as realpath8, rm as
|
|
16832
|
+
import { lstat as lstat10, mkdir as mkdir18, readFile as readFile20, readdir as readdir10, realpath as realpath8, rm as rm10, writeFile as writeFile9 } from "fs/promises";
|
|
16763
16833
|
import { homedir as homedir2 } from "os";
|
|
16764
16834
|
import { isAbsolute as isAbsolute10, join as join22, relative as relative19, resolve as resolve24, sep as sep18 } from "path";
|
|
16765
16835
|
import { stringify } from "yaml";
|
|
@@ -16797,7 +16867,7 @@ var SkillManager = class {
|
|
|
16797
16867
|
await this.#persistEnabled(value.name, true);
|
|
16798
16868
|
return this.get(value.name);
|
|
16799
16869
|
} catch (error) {
|
|
16800
|
-
await
|
|
16870
|
+
await rm10(directory, { recursive: true, force: true }).catch(() => void 0);
|
|
16801
16871
|
throw error;
|
|
16802
16872
|
}
|
|
16803
16873
|
}
|
|
@@ -16825,7 +16895,7 @@ var SkillManager = class {
|
|
|
16825
16895
|
throw error;
|
|
16826
16896
|
});
|
|
16827
16897
|
if (!info.isDirectory() || info.isSymbolicLink()) throw new Error(`Project skill path is not a real directory: ${validName}`);
|
|
16828
|
-
await
|
|
16898
|
+
await rm10(directory, { recursive: true });
|
|
16829
16899
|
await this.#persistEnabled(validName, true);
|
|
16830
16900
|
}
|
|
16831
16901
|
async setEnabled(name, enabled) {
|
|
@@ -131,7 +131,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
131
131
|
|
|
132
132
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Fn,s=!xn.jitless,c=s&&In.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?ea([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function ra(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=>!Zn(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=>tr(e,r,Sn())))}),t)}var ia=P(`$ZodUnion`,(e,t)=>{yi.init(e,t),F(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),F(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),F(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),F(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=>Dn(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=>ra(t,r,e,i)):ra(o,r,e,i)}}),aa=P(`$ZodIntersection`,(e,t)=>{yi.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])=>sa(e,t,n)):sa(e,i,a)}});function oa(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ln(e)&&Ln(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=oa(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=oa(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 sa(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}),Zn(e))return e;let o=oa(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var ca=P(`$ZodRecord`,(e,t)=>{yi.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Ln(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>tr(e,r,Sn())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...$n(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...$n(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Xr.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>tr(e,r,Sn())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...$n(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...$n(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),la=P(`$ZodEnum`,(e,t)=>{yi.init(e,t);let n=Cn(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>zn.has(typeof e)).map(e=>typeof e==`string`?Bn(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}}),ua=P(`$ZodLiteral`,(e,t)=>{if(yi.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`?Bn(e):e?Bn(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}}),da=P(`$ZodTransform`,(e,t)=>{yi.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new bn(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 yn;return n.value=i,n.fallback=!0,n}});function fa(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var pa=P(`$ZodOptional`,(e,t)=>{yi.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,F(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),F(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Dn(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=>fa(e,r)):fa(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),ma=P(`$ZodExactOptional`,(e,t)=>{pa.init(e,t),F(e._zod,`values`,()=>t.innerType._zod.values),F(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ha=P(`$ZodNullable`,(e,t)=>{yi.init(e,t),F(e._zod,`optin`,()=>t.innerType._zod.optin),F(e._zod,`optout`,()=>t.innerType._zod.optout),F(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Dn(e.source)}|null)$`):void 0}),F(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)}),ga=P(`$ZodDefault`,(e,t)=>{yi.init(e,t),e._zod.optin=`optional`,F(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=>_a(e,t)):_a(r,t)}});function _a(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var va=P(`$ZodPrefault`,(e,t)=>{yi.init(e,t),e._zod.optin=`optional`,F(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))}),ya=P(`$ZodNonOptional`,(e,t)=>{yi.init(e,t),F(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=>ba(t,e)):ba(i,e)}});function ba(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 xa=P(`$ZodCatch`,(e,t)=>{yi.init(e,t),e._zod.optin=`optional`,F(e._zod,`optout`,()=>t.innerType._zod.optout),F(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=>tr(e,n,Sn()))},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=>tr(e,n,Sn()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Sa=P(`$ZodPipe`,(e,t)=>{yi.init(e,t),F(e._zod,`values`,()=>t.in._zod.values),F(e._zod,`optin`,()=>t.in._zod.optin),F(e._zod,`optout`,()=>t.out._zod.optout),F(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=>Ca(e,t.in,n)):Ca(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ca(e,t.out,n)):Ca(r,t.out,n)}});function Ca(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 wa=P(`$ZodPreprocess`,(e,t)=>{Sa.init(e,t)}),Ta=P(`$ZodReadonly`,(e,t)=>{yi.init(e,t),F(e._zod,`propValues`,()=>t.innerType._zod.propValues),F(e._zod,`values`,()=>t.innerType._zod.values),F(e._zod,`optin`,()=>t.innerType?._zod?.optin),F(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(Ea):Ea(r)}});function Ea(e){return e.value=Object.freeze(e.value),e}var Da=P(`$ZodCustom`,(e,t)=>{ei.init(e,t),yi.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=>Oa(t,n,r,e));Oa(i,n,r,e)}});function Oa(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(rr(e))}}var ka,Aa=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 ja(){return new Aa}(ka=globalThis).__zod_globalRegistry??(ka.__zod_globalRegistry=ja());var Ma=globalThis.__zod_globalRegistry;function Na(e,t){return new e({type:`string`,...I(t)})}function Pa(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...I(t)})}function Fa(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...I(t)})}function Ia(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...I(t)})}function La(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...I(t)})}function Ra(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...I(t)})}function za(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...I(t)})}function Ba(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...I(t)})}function Va(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...I(t)})}function Ha(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...I(t)})}function Ua(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...I(t)})}function Wa(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...I(t)})}function Ga(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...I(t)})}function Ka(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...I(t)})}function qa(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...I(t)})}function Ja(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...I(t)})}function Ya(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...I(t)})}function Xa(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...I(t)})}function Za(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...I(t)})}function Qa(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...I(t)})}function $a(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...I(t)})}function eo(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...I(t)})}function to(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...I(t)})}function no(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...I(t)})}function ro(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...I(t)})}function io(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...I(t)})}function ao(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...I(t)})}function oo(e,t){return new e({type:`number`,checks:[],...I(t)})}function so(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...I(t)})}function co(e,t){return new e({type:`boolean`,...I(t)})}function lo(e){return new e({type:`unknown`})}function uo(e,t){return new e({type:`never`,...I(t)})}function fo(e,t){return new ni({check:`less_than`,...I(t),value:e,inclusive:!1})}function po(e,t){return new ni({check:`less_than`,...I(t),value:e,inclusive:!0})}function B(e,t){return new ri({check:`greater_than`,...I(t),value:e,inclusive:!1})}function V(e,t){return new ri({check:`greater_than`,...I(t),value:e,inclusive:!0})}function mo(e,t){return new ii({check:`multiple_of`,...I(t),value:e})}function ho(e,t){return new oi({check:`max_length`,...I(t),maximum:e})}function go(e,t){return new si({check:`min_length`,...I(t),minimum:e})}function _o(e,t){return new ci({check:`length_equals`,...I(t),length:e})}function vo(e,t){return new ui({check:`string_format`,format:`regex`,...I(t),pattern:e})}function yo(e){return new di({check:`string_format`,format:`lowercase`,...I(e)})}function bo(e){return new fi({check:`string_format`,format:`uppercase`,...I(e)})}function xo(e,t){return new pi({check:`string_format`,format:`includes`,...I(t),includes:e})}function So(e,t){return new mi({check:`string_format`,format:`starts_with`,...I(t),prefix:e})}function Co(e,t){return new hi({check:`string_format`,format:`ends_with`,...I(t),suffix:e})}function wo(e){return new gi({check:`overwrite`,tx:e})}function To(e){return wo(t=>t.normalize(e))}function Eo(){return wo(e=>e.trim())}function Do(){return wo(e=>e.toLowerCase())}function Oo(){return wo(e=>e.toUpperCase())}function ko(){return wo(e=>Nn(e))}function Ao(e,t,n){return new e({type:`array`,element:t,...I(n)})}function jo(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...I(n)})}function Mo(e,t){let n=No(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(rr(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(rr(r))}},e(t.value,t)),t);return n}function No(e,t){let n=new ei({check:`custom`,...I(t)});return n._zod.check=e,n}function Po(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??Ma,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 Fo(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,Fo(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`&&Ro(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 Io(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>
|
|
133
133
|
|
|
134
|
-
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 Lo(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:Bo(t,`input`,e.processors),output:Bo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ro(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 Ro(r.element,n);if(r.type===`set`)return Ro(r.valueType,n);if(r.type===`lazy`)return Ro(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 Ro(r.innerType,n);if(r.type===`intersection`)return Ro(r.left,n)||Ro(r.right,n);if(r.type===`record`||r.type===`map`)return Ro(r.keyType,n)||Ro(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ro(r.in,n)||Ro(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ro(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ro(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ro(e,n))return!0;return!!(r.rest&&Ro(r.rest,n))}return!1}var zo=(e,t={})=>n=>{let r=Po({...n,processors:t});return Fo(e,r),Io(r,e),Lo(r,e)},Bo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Po({...i??{},target:a,io:t,processors:n});return Fo(e,o),Io(o,e),Lo(o,e)},Vo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ho=(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=Vo[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}))])}},Uo=(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)},Wo=(e,t,n,r)=>{n.type=`boolean`},Go=(e,t,n,r)=>{n.not={}},Ko=(e,t,n,r)=>{let i=e._zod.def,a=Cn(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},qo=(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},Jo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Yo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Xo=(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=Fo(a.element,t,{...r,path:[...r.path,`items`]})},Zo=(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]=Fo(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=Fo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Qo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Fo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},$o=(e,t,n,r)=>{let i=e._zod.def,a=Fo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Fo(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]]},es=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Fo(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Fo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Fo(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},ts=(e,t,n,r)=>{let i=e._zod.def,a=Fo(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`}]},ns=(e,t,n,r)=>{let i=e._zod.def;Fo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},rs=(e,t,n,r)=>{let i=e._zod.def;Fo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},is=(e,t,n,r)=>{let i=e._zod.def;Fo(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)))},as=(e,t,n,r)=>{let i=e._zod.def;Fo(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},os=(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;Fo(o,t,r);let s=t.seen.get(e);s.ref=o},ss=(e,t,n,r)=>{let i=e._zod.def;Fo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},cs=(e,t,n,r)=>{let i=e._zod.def;Fo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ls=P(`ZodISODateTime`,(e,t)=>{Mi.init(e,t),U.init(e,t)});function us(e){return no(ls,e)}var ds=P(`ZodISODate`,(e,t)=>{Ni.init(e,t),U.init(e,t)});function fs(e){return ro(ds,e)}var ps=P(`ZodISOTime`,(e,t)=>{Pi.init(e,t),U.init(e,t)});function ms(e){return io(ps,e)}var hs=P(`ZodISODuration`,(e,t)=>{R.init(e,t),U.init(e,t)});function gs(e){return ao(hs,e)}var _s=P(`ZodError`,(e,t)=>{ar.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>cr(e,t)},flatten:{value:t=>sr(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,wn,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,wn,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),vs=lr(_s),ys=ur(_s),bs=dr(_s),xs=pr(_s),Ss=hr(_s),Cs=gr(_s),ws=_r(_s),Ts=vr(_s),Es=yr(_s),Ds=br(_s),Os=xr(_s),ks=Sr(_s),As=new WeakMap;function js(e,t,n){let r=Object.getPrototypeOf(e),i=As.get(r);if(i||(i=new Set,As.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 Ms=P(`ZodType`,(e,t)=>(yi.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Bo(e,`input`),output:Bo(e,`output`)}}),e.toJSONSchema=zo(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>vs(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>bs(e,t,n),e.parseAsync=async(t,n)=>ys(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>xs(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ss(e,t,n),e.decode=(t,n)=>Cs(e,t,n),e.encodeAsync=async(t,n)=>ws(e,t,n),e.decodeAsync=async(t,n)=>Ts(e,t,n),e.safeEncode=(t,n)=>Es(e,t,n),e.safeDecode=(t,n)=>Ds(e,t,n),e.safeEncodeAsync=async(t,n)=>Os(e,t,n),e.safeDecodeAsync=async(t,n)=>ks(e,t,n),js(e,`ZodType`,{check(...e){let t=this.def;return this.clone(jn(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 Vn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Wc(e,t))},superRefine(e,t){return this.check(Gc(e,t))},overwrite(e){return this.check(wo(e))},optional(){return Ec(this)},exactOptional(){return Oc(this)},nullable(){return Ac(this)},nullish(){return Ec(Ac(this))},nonoptional(e){return Ic(this,e)},array(){return uc(this)},or(e){return mc([this,e])},and(e){return gc(this,e)},transform(e){return zc(this,wc(e))},default(e){return Mc(this,e)},prefault(e){return Pc(this,e)},catch(e){return Lc(this,e)},pipe(e){return zc(this,e)},readonly(){return Hc(this)},describe(e){let t=this.clone();return Ma.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ma.get(this);let t=this.clone();return Ma.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 Ma.get(e)?.description},configurable:!0}),e)),Ns=P(`_ZodString`,(e,t)=>{bi.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ho(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,js(e,`_ZodString`,{regex(...e){return this.check(vo(...e))},includes(...e){return this.check(xo(...e))},startsWith(...e){return this.check(So(...e))},endsWith(...e){return this.check(Co(...e))},min(...e){return this.check(go(...e))},max(...e){return this.check(ho(...e))},length(...e){return this.check(_o(...e))},nonempty(...e){return this.check(go(1,...e))},lowercase(e){return this.check(yo(e))},uppercase(e){return this.check(bo(e))},trim(){return this.check(Eo())},normalize(...e){return this.check(To(...e))},toLowerCase(){return this.check(Do())},toUpperCase(){return this.check(Oo())},slugify(){return this.check(ko())}})}),Ps=P(`ZodString`,(e,t)=>{bi.init(e,t),Ns.init(e,t),e.email=t=>e.check(Pa(Fs,t)),e.url=t=>e.check(Ba(Rs,t)),e.jwt=t=>e.check(to($s,t)),e.emoji=t=>e.check(Va(zs,t)),e.guid=t=>e.check(Fa(Is,t)),e.uuid=t=>e.check(Ia(Ls,t)),e.uuidv4=t=>e.check(La(Ls,t)),e.uuidv6=t=>e.check(Ra(Ls,t)),e.uuidv7=t=>e.check(za(Ls,t)),e.nanoid=t=>e.check(Ha(Bs,t)),e.guid=t=>e.check(Fa(Is,t)),e.cuid=t=>e.check(Ua(Vs,t)),e.cuid2=t=>e.check(Wa(Hs,t)),e.ulid=t=>e.check(Ga(Us,t)),e.base64=t=>e.check(Qa(Xs,t)),e.base64url=t=>e.check($a(Zs,t)),e.xid=t=>e.check(Ka(Ws,t)),e.ksuid=t=>e.check(qa(Gs,t)),e.ipv4=t=>e.check(Ja(Ks,t)),e.ipv6=t=>e.check(Ya(qs,t)),e.cidrv4=t=>e.check(Xa(Js,t)),e.cidrv6=t=>e.check(Za(Ys,t)),e.e164=t=>e.check(eo(Qs,t)),e.datetime=t=>e.check(us(t)),e.date=t=>e.check(fs(t)),e.time=t=>e.check(ms(t)),e.duration=t=>e.check(gs(t))});function H(e){return Na(Ps,e)}var U=P(`ZodStringFormat`,(e,t)=>{L.init(e,t),Ns.init(e,t)}),Fs=P(`ZodEmail`,(e,t)=>{Ci.init(e,t),U.init(e,t)}),Is=P(`ZodGUID`,(e,t)=>{xi.init(e,t),U.init(e,t)}),Ls=P(`ZodUUID`,(e,t)=>{Si.init(e,t),U.init(e,t)}),Rs=P(`ZodURL`,(e,t)=>{wi.init(e,t),U.init(e,t)}),zs=P(`ZodEmoji`,(e,t)=>{Ti.init(e,t),U.init(e,t)}),Bs=P(`ZodNanoID`,(e,t)=>{Ei.init(e,t),U.init(e,t)}),Vs=P(`ZodCUID`,(e,t)=>{Di.init(e,t),U.init(e,t)}),Hs=P(`ZodCUID2`,(e,t)=>{Oi.init(e,t),U.init(e,t)}),Us=P(`ZodULID`,(e,t)=>{ki.init(e,t),U.init(e,t)}),Ws=P(`ZodXID`,(e,t)=>{Ai.init(e,t),U.init(e,t)}),Gs=P(`ZodKSUID`,(e,t)=>{ji.init(e,t),U.init(e,t)}),Ks=P(`ZodIPv4`,(e,t)=>{z.init(e,t),U.init(e,t)}),qs=P(`ZodIPv6`,(e,t)=>{Fi.init(e,t),U.init(e,t)}),Js=P(`ZodCIDRv4`,(e,t)=>{Ii.init(e,t),U.init(e,t)}),Ys=P(`ZodCIDRv6`,(e,t)=>{Li.init(e,t),U.init(e,t)}),Xs=P(`ZodBase64`,(e,t)=>{zi.init(e,t),U.init(e,t)}),Zs=P(`ZodBase64URL`,(e,t)=>{Vi.init(e,t),U.init(e,t)}),Qs=P(`ZodE164`,(e,t)=>{Hi.init(e,t),U.init(e,t)}),$s=P(`ZodJWT`,(e,t)=>{Wi.init(e,t),U.init(e,t)}),ec=P(`ZodNumber`,(e,t)=>{Gi.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uo(e,t,n,r),js(e,`ZodNumber`,{gt(e,t){return this.check(B(e,t))},gte(e,t){return this.check(V(e,t))},min(e,t){return this.check(V(e,t))},lt(e,t){return this.check(fo(e,t))},lte(e,t){return this.check(po(e,t))},max(e,t){return this.check(po(e,t))},int(e){return this.check(nc(e))},safe(e){return this.check(nc(e))},positive(e){return this.check(B(0,e))},nonnegative(e){return this.check(V(0,e))},negative(e){return this.check(fo(0,e))},nonpositive(e){return this.check(po(0,e))},multipleOf(e,t){return this.check(mo(e,t))},step(e,t){return this.check(mo(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 W(e){return oo(ec,e)}var tc=P(`ZodNumberFormat`,(e,t)=>{Ki.init(e,t),ec.init(e,t)});function nc(e){return so(tc,e)}var rc=P(`ZodBoolean`,(e,t)=>{qi.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wo(e,t,n,r)});function ic(e){return co(rc,e)}var ac=P(`ZodUnknown`,(e,t)=>{Ji.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function oc(){return lo(ac)}var sc=P(`ZodNever`,(e,t)=>{Yi.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Go(e,t,n,r)});function cc(e){return uo(sc,e)}var lc=P(`ZodArray`,(e,t)=>{Zi.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r),e.element=t.element,js(e,`ZodArray`,{min(e,t){return this.check(go(e,t))},nonempty(e){return this.check(go(1,e))},max(e,t){return this.check(ho(e,t))},length(e,t){return this.check(_o(e,t))},unwrap(){return this.element}})});function uc(e,t){return Ao(lc,e,t)}var dc=P(`ZodObject`,(e,t)=>{na.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r),F(e,`shape`,()=>t.shape),js(e,`ZodObject`,{keyof(){return bc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:oc()})},loose(){return this.clone({...this._zod.def,catchall:oc()})},strict(){return this.clone({...this._zod.def,catchall:cc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Kn(this,e)},safeExtend(e){return qn(this,e)},merge(e){return Jn(this,e)},pick(e){return Wn(this,e)},omit(e){return Gn(this,e)},partial(...e){return Yn(Tc,this,e[0])},required(...e){return Xn(Fc,this,e[0])}})});function fc(e,t){return new dc({type:`object`,shape:e??{},...I(t)})}var pc=P(`ZodUnion`,(e,t)=>{ia.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qo(e,t,n,r),e.options=t.options});function mc(e,t){return new pc({type:`union`,options:e,...I(t)})}var hc=P(`ZodIntersection`,(e,t)=>{aa.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(e,t,n,r)});function gc(e,t){return new hc({type:`intersection`,left:e,right:t})}var _c=P(`ZodRecord`,(e,t)=>{ca.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>es(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function vc(e,t,n){return!t||!t._zod?new _c({type:`record`,keyType:H(),valueType:e,...I(t)}):new _c({type:`record`,keyType:e,valueType:t,...I(n)})}var yc=P(`ZodEnum`,(e,t)=>{la.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ko(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 yc({...t,checks:[],...I(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 yc({...t,checks:[],...I(r),entries:i})}});function bc(e,t){return new yc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...I(t)})}var xc=P(`ZodLiteral`,(e,t)=>{ua.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(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 Sc(e,t){return new xc({type:`literal`,values:Array.isArray(e)?e:[e],...I(t)})}var Cc=P(`ZodTransform`,(e,t)=>{da.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new bn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(rr(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(rr(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 wc(e){return new Cc({type:`transform`,transform:e})}var Tc=P(`ZodOptional`,(e,t)=>{pa.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ec(e){return new Tc({type:`optional`,innerType:e})}var Dc=P(`ZodExactOptional`,(e,t)=>{ma.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Oc(e){return new Dc({type:`optional`,innerType:e})}var kc=P(`ZodNullable`,(e,t)=>{ha.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ac(e){return new kc({type:`nullable`,innerType:e})}var jc=P(`ZodDefault`,(e,t)=>{ga.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Mc(e,t){return new jc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Rn(t)}})}var Nc=P(`ZodPrefault`,(e,t)=>{va.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pc(e,t){return new Nc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Rn(t)}})}var Fc=P(`ZodNonOptional`,(e,t)=>{ya.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ic(e,t){return new Fc({type:`nonoptional`,innerType:e,...I(t)})}var G=P(`ZodCatch`,(e,t)=>{xa.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Lc(e,t){return new G({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Rc=P(`ZodPipe`,(e,t)=>{Sa.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r),e.in=t.in,e.out=t.out});function zc(e,t){return new Rc({type:`pipe`,in:e,out:t})}var Bc=P(`ZodPreprocess`,(e,t)=>{Rc.init(e,t),wa.init(e,t)}),Vc=P(`ZodReadonly`,(e,t)=>{Ta.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hc(e){return new Vc({type:`readonly`,innerType:e})}var Uc=P(`ZodCustom`,(e,t)=>{Da.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jo(e,t,n,r)});function Wc(e,t={}){return jo(Uc,e,t)}function Gc(e,t){return Mo(e,t)}function Kc(e,t){return new Bc({type:`pipe`,in:wc(e),out:t})}var qc=[`default`,`acceptEdits`,`plan`,`bypassPermissions`,`auto`,`bubble`];function Jc(e){return e===`safe`||e===`workspace`?`default`:e===`full`?`bypassPermissions`:e}var Yc=Kc(Jc,bc(qc).default(`default`)),Xc=fc({type:H(),baseURL:H().url().optional(),apiKey:H().optional(),defaultModel:H().min(1).optional(),cheapModel:H().min(1).optional(),models:uc(H().min(1)).max(100).optional(),maxOutputTokens:W().int().positive().optional(),apiType:bc([`openai`,`anthropic`]).optional(),authorizationUrl:H().url().optional(),tokenUrl:H().url().optional(),clientId:H().min(1).optional(),scope:H().optional()}),Zc={disabled:ic().default(!1),timeoutMs:W().int().min(100).max(30*6e4).default(6e4)},Qc=mc([fc({command:H().min(1),args:uc(H()).default([]),env:vc(H(),H()).default({}),cwd:H().min(1).optional(),...Zc}).strict(),fc({url:H().url().refine(e=>{let t=new URL(e).protocol;return t===`http:`||t===`https:`},`MCP HTTP URLs must use http or https`),headers:vc(H(),H()).default({}),...Zc}).strict()]),$c=H().min(1).max(32).regex(/^[A-Za-z0-9_-]+$/,`MCP server names may contain only letters, digits, underscores, and hyphens`),el=H().min(1).max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,`Skill names must use lowercase letters, digits, and single hyphens`);fc({sleep:ic().default(!1),providers:vc(H(),Xc).default({}),mcpServers:vc($c,Qc).default({}),skills:fc({disabled:uc(el).max(1e3).default([])}).prefault({}),agents:fc({main:fc({model:H()}).optional(),subagent:fc({model:H()}).optional()}).optional(),maxSubagents:W().int().min(1).max(16).default(3),maxSessions:W().int().min(1).max(1e3).default(50),memory:fc({enabled:ic().default(!0),autoExtract:ic().default(!0),autoExtractMinChars:W().int().min(200).max(1e5).default(200),scoreThreshold:W().int().min(0).max(12).default(9),autoStoreThreshold:W().int().min(0).max(12).default(11),ignoreStreakLimit:W().int().min(2).max(100).default(5),reviewAutoDismissSeconds:W().int().min(0).max(300).default(5),maxCandidatesPerTask:W().int().min(1).max(10).default(1),retrievalTopK:W().int().min(1).max(20).default(5),maxEntries:W().int().min(1).max(1e4).default(200),maxEntryChars:W().int().min(32).max(2e4).default(1e3),maxPromptChars:W().int().min(256).max(2e5).default(12e3)}).prefault({}),permissionMode:Yc,execution:fc({mode:bc([`local`,`docker`]).default(`local`),image:H().trim().min(1).default(`node:24-bookworm-slim`),network:ic().default(!1),memory:H().regex(/^[1-9][0-9]*(?:[kKmMgG])?$/).default(`2g`),cpus:W().positive().max(64).default(2)}).prefault({}),language:H().regex(/^[a-z]{2}(-[A-Z]{2})?$/,`language must be a BCP47 tag like zh-CN or en-US`).optional(),hallucination:fc({showWarnings:ic().default(!1),evaluationTimeoutMs:W().int().min(100).max(3e4).default(2e3)}).prefault({}),maxIterations:fc({main:W().int().min(10).max(500).default(80),subagent:W().int().min(10).max(200).default(40),softLimitFactor:W().min(.5).max(1).default(.8),extendBy:W().int().min(5).max(100).default(20)}).prefault({}),loop:fc({maxCycles:W().int().positive().max(1e4).default(20),maxTokens:W().int().positive().max(2**53-1).default(5e5),isolation:Sc(`auto`).default(`auto`)}).prefault({}),context:fc({windowTokens:W().int().positive().default(2e5),reservedOutputTokens:W().int().nonnegative().default(2e4),autoCompactBufferTokens:W().int().nonnegative().default(13e3),warningBufferTokens:W().int().nonnegative().default(2e4),blockingBufferTokens:W().int().nonnegative().default(3e3),microcompactKeepRecentToolResults:W().int().nonnegative().default(5),recentTokens:W().int().nonnegative().default(1e4),recentTextMessages:W().int().nonnegative().default(5),maxRecentTokens:W().int().nonnegative().default(4e4),compactAtChars:W().int().positive().optional(),toolOutputChars:W().int().positive().default(3e4)}).superRefine((e,t)=>{e.reservedOutputTokens>=e.windowTokens&&t.addIssue({code:`custom`,path:[`reservedOutputTokens`],message:`reservedOutputTokens must be below windowTokens`}),e.maxRecentTokens<e.recentTokens&&t.addIssue({code:`custom`,path:[`maxRecentTokens`],message:`maxRecentTokens must be at least recentTokens`})}).prefault({}),incidents:fc({enabled:ic().default(!1),webhookUrl:H().url().optional()}).prefault({})});var tl=[`user`,`feedback`,`project`,`reference`],nl=`model.init.config.login.permissions.skills.plugins.hooks.tasks.finish.compact.clear.help.exit.audit.usage.loop.goal.mcp.ide.memory.remember.forget.checkpoint.tree.rewind.unrevert.fork`.split(`.`),rl={model:`Switch the active model`,init:`Initialize Flavor project files`,config:`Show the resolved configuration`,login:`Authenticate via OAuth PKCE`,permissions:`Change the tool permission mode`,skills:`List discovered skills`,plugins:`List loaded plugins`,hooks:`Show plugin hook status`,tasks:`Show task planning status`,finish:`Complete this task and evaluate long-term memory`,compact:`Compact the conversation context`,clear:`Clear the transcript`,help:`Show available commands`,exit:`Exit Flavor`,audit:`Query tool failure audit log`,usage:`Show cache hit statistics for this session`,loop:`Run a verified autonomous loop toward a goal`,goal:`Run a goal pipeline with adversarial verification`,mcp:`Manage MCP servers`,ide:`Show the connected IDE and editor context`,memory:`Show long-term project memory`,remember:`Add a long-term memory`,forget:`Remove matching long-term memories`,checkpoint:`Create a workspace and context checkpoint`,tree:`Show the session history tree`,rewind:`Restore a prior session node`,unrevert:`Undo the most recent rewind`,fork:`Continue context from a prior session node`},il={name:``,description:``,body:`# Instructions
|
|
134
|
+
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 Lo(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:Bo(t,`input`,e.processors),output:Bo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ro(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 Ro(r.element,n);if(r.type===`set`)return Ro(r.valueType,n);if(r.type===`lazy`)return Ro(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 Ro(r.innerType,n);if(r.type===`intersection`)return Ro(r.left,n)||Ro(r.right,n);if(r.type===`record`||r.type===`map`)return Ro(r.keyType,n)||Ro(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ro(r.in,n)||Ro(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ro(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ro(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ro(e,n))return!0;return!!(r.rest&&Ro(r.rest,n))}return!1}var zo=(e,t={})=>n=>{let r=Po({...n,processors:t});return Fo(e,r),Io(r,e),Lo(r,e)},Bo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Po({...i??{},target:a,io:t,processors:n});return Fo(e,o),Io(o,e),Lo(o,e)},Vo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ho=(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=Vo[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}))])}},Uo=(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)},Wo=(e,t,n,r)=>{n.type=`boolean`},Go=(e,t,n,r)=>{n.not={}},Ko=(e,t,n,r)=>{let i=e._zod.def,a=Cn(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},qo=(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},Jo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Yo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Xo=(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=Fo(a.element,t,{...r,path:[...r.path,`items`]})},Zo=(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]=Fo(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=Fo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Qo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Fo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},$o=(e,t,n,r)=>{let i=e._zod.def,a=Fo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Fo(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]]},es=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Fo(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Fo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Fo(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},ts=(e,t,n,r)=>{let i=e._zod.def,a=Fo(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`}]},ns=(e,t,n,r)=>{let i=e._zod.def;Fo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},rs=(e,t,n,r)=>{let i=e._zod.def;Fo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},is=(e,t,n,r)=>{let i=e._zod.def;Fo(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)))},as=(e,t,n,r)=>{let i=e._zod.def;Fo(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},os=(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;Fo(o,t,r);let s=t.seen.get(e);s.ref=o},ss=(e,t,n,r)=>{let i=e._zod.def;Fo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},cs=(e,t,n,r)=>{let i=e._zod.def;Fo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ls=P(`ZodISODateTime`,(e,t)=>{Mi.init(e,t),U.init(e,t)});function us(e){return no(ls,e)}var ds=P(`ZodISODate`,(e,t)=>{Ni.init(e,t),U.init(e,t)});function fs(e){return ro(ds,e)}var ps=P(`ZodISOTime`,(e,t)=>{Pi.init(e,t),U.init(e,t)});function ms(e){return io(ps,e)}var hs=P(`ZodISODuration`,(e,t)=>{R.init(e,t),U.init(e,t)});function gs(e){return ao(hs,e)}var _s=P(`ZodError`,(e,t)=>{ar.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>cr(e,t)},flatten:{value:t=>sr(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,wn,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,wn,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),vs=lr(_s),ys=ur(_s),bs=dr(_s),xs=pr(_s),Ss=hr(_s),Cs=gr(_s),ws=_r(_s),Ts=vr(_s),Es=yr(_s),Ds=br(_s),Os=xr(_s),ks=Sr(_s),As=new WeakMap;function js(e,t,n){let r=Object.getPrototypeOf(e),i=As.get(r);if(i||(i=new Set,As.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 Ms=P(`ZodType`,(e,t)=>(yi.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Bo(e,`input`),output:Bo(e,`output`)}}),e.toJSONSchema=zo(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>vs(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>bs(e,t,n),e.parseAsync=async(t,n)=>ys(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>xs(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ss(e,t,n),e.decode=(t,n)=>Cs(e,t,n),e.encodeAsync=async(t,n)=>ws(e,t,n),e.decodeAsync=async(t,n)=>Ts(e,t,n),e.safeEncode=(t,n)=>Es(e,t,n),e.safeDecode=(t,n)=>Ds(e,t,n),e.safeEncodeAsync=async(t,n)=>Os(e,t,n),e.safeDecodeAsync=async(t,n)=>ks(e,t,n),js(e,`ZodType`,{check(...e){let t=this.def;return this.clone(jn(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 Vn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Wc(e,t))},superRefine(e,t){return this.check(Gc(e,t))},overwrite(e){return this.check(wo(e))},optional(){return Ec(this)},exactOptional(){return Oc(this)},nullable(){return Ac(this)},nullish(){return Ec(Ac(this))},nonoptional(e){return Ic(this,e)},array(){return uc(this)},or(e){return mc([this,e])},and(e){return gc(this,e)},transform(e){return zc(this,wc(e))},default(e){return Mc(this,e)},prefault(e){return Pc(this,e)},catch(e){return Lc(this,e)},pipe(e){return zc(this,e)},readonly(){return Hc(this)},describe(e){let t=this.clone();return Ma.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ma.get(this);let t=this.clone();return Ma.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 Ma.get(e)?.description},configurable:!0}),e)),Ns=P(`_ZodString`,(e,t)=>{bi.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ho(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,js(e,`_ZodString`,{regex(...e){return this.check(vo(...e))},includes(...e){return this.check(xo(...e))},startsWith(...e){return this.check(So(...e))},endsWith(...e){return this.check(Co(...e))},min(...e){return this.check(go(...e))},max(...e){return this.check(ho(...e))},length(...e){return this.check(_o(...e))},nonempty(...e){return this.check(go(1,...e))},lowercase(e){return this.check(yo(e))},uppercase(e){return this.check(bo(e))},trim(){return this.check(Eo())},normalize(...e){return this.check(To(...e))},toLowerCase(){return this.check(Do())},toUpperCase(){return this.check(Oo())},slugify(){return this.check(ko())}})}),Ps=P(`ZodString`,(e,t)=>{bi.init(e,t),Ns.init(e,t),e.email=t=>e.check(Pa(Fs,t)),e.url=t=>e.check(Ba(Rs,t)),e.jwt=t=>e.check(to($s,t)),e.emoji=t=>e.check(Va(zs,t)),e.guid=t=>e.check(Fa(Is,t)),e.uuid=t=>e.check(Ia(Ls,t)),e.uuidv4=t=>e.check(La(Ls,t)),e.uuidv6=t=>e.check(Ra(Ls,t)),e.uuidv7=t=>e.check(za(Ls,t)),e.nanoid=t=>e.check(Ha(Bs,t)),e.guid=t=>e.check(Fa(Is,t)),e.cuid=t=>e.check(Ua(Vs,t)),e.cuid2=t=>e.check(Wa(Hs,t)),e.ulid=t=>e.check(Ga(Us,t)),e.base64=t=>e.check(Qa(Xs,t)),e.base64url=t=>e.check($a(Zs,t)),e.xid=t=>e.check(Ka(Ws,t)),e.ksuid=t=>e.check(qa(Gs,t)),e.ipv4=t=>e.check(Ja(Ks,t)),e.ipv6=t=>e.check(Ya(qs,t)),e.cidrv4=t=>e.check(Xa(Js,t)),e.cidrv6=t=>e.check(Za(Ys,t)),e.e164=t=>e.check(eo(Qs,t)),e.datetime=t=>e.check(us(t)),e.date=t=>e.check(fs(t)),e.time=t=>e.check(ms(t)),e.duration=t=>e.check(gs(t))});function H(e){return Na(Ps,e)}var U=P(`ZodStringFormat`,(e,t)=>{L.init(e,t),Ns.init(e,t)}),Fs=P(`ZodEmail`,(e,t)=>{Ci.init(e,t),U.init(e,t)}),Is=P(`ZodGUID`,(e,t)=>{xi.init(e,t),U.init(e,t)}),Ls=P(`ZodUUID`,(e,t)=>{Si.init(e,t),U.init(e,t)}),Rs=P(`ZodURL`,(e,t)=>{wi.init(e,t),U.init(e,t)}),zs=P(`ZodEmoji`,(e,t)=>{Ti.init(e,t),U.init(e,t)}),Bs=P(`ZodNanoID`,(e,t)=>{Ei.init(e,t),U.init(e,t)}),Vs=P(`ZodCUID`,(e,t)=>{Di.init(e,t),U.init(e,t)}),Hs=P(`ZodCUID2`,(e,t)=>{Oi.init(e,t),U.init(e,t)}),Us=P(`ZodULID`,(e,t)=>{ki.init(e,t),U.init(e,t)}),Ws=P(`ZodXID`,(e,t)=>{Ai.init(e,t),U.init(e,t)}),Gs=P(`ZodKSUID`,(e,t)=>{ji.init(e,t),U.init(e,t)}),Ks=P(`ZodIPv4`,(e,t)=>{z.init(e,t),U.init(e,t)}),qs=P(`ZodIPv6`,(e,t)=>{Fi.init(e,t),U.init(e,t)}),Js=P(`ZodCIDRv4`,(e,t)=>{Ii.init(e,t),U.init(e,t)}),Ys=P(`ZodCIDRv6`,(e,t)=>{Li.init(e,t),U.init(e,t)}),Xs=P(`ZodBase64`,(e,t)=>{zi.init(e,t),U.init(e,t)}),Zs=P(`ZodBase64URL`,(e,t)=>{Vi.init(e,t),U.init(e,t)}),Qs=P(`ZodE164`,(e,t)=>{Hi.init(e,t),U.init(e,t)}),$s=P(`ZodJWT`,(e,t)=>{Wi.init(e,t),U.init(e,t)}),ec=P(`ZodNumber`,(e,t)=>{Gi.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uo(e,t,n,r),js(e,`ZodNumber`,{gt(e,t){return this.check(B(e,t))},gte(e,t){return this.check(V(e,t))},min(e,t){return this.check(V(e,t))},lt(e,t){return this.check(fo(e,t))},lte(e,t){return this.check(po(e,t))},max(e,t){return this.check(po(e,t))},int(e){return this.check(nc(e))},safe(e){return this.check(nc(e))},positive(e){return this.check(B(0,e))},nonnegative(e){return this.check(V(0,e))},negative(e){return this.check(fo(0,e))},nonpositive(e){return this.check(po(0,e))},multipleOf(e,t){return this.check(mo(e,t))},step(e,t){return this.check(mo(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 W(e){return oo(ec,e)}var tc=P(`ZodNumberFormat`,(e,t)=>{Ki.init(e,t),ec.init(e,t)});function nc(e){return so(tc,e)}var rc=P(`ZodBoolean`,(e,t)=>{qi.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wo(e,t,n,r)});function ic(e){return co(rc,e)}var ac=P(`ZodUnknown`,(e,t)=>{Ji.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function oc(){return lo(ac)}var sc=P(`ZodNever`,(e,t)=>{Yi.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Go(e,t,n,r)});function cc(e){return uo(sc,e)}var lc=P(`ZodArray`,(e,t)=>{Zi.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xo(e,t,n,r),e.element=t.element,js(e,`ZodArray`,{min(e,t){return this.check(go(e,t))},nonempty(e){return this.check(go(1,e))},max(e,t){return this.check(ho(e,t))},length(e,t){return this.check(_o(e,t))},unwrap(){return this.element}})});function uc(e,t){return Ao(lc,e,t)}var dc=P(`ZodObject`,(e,t)=>{na.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zo(e,t,n,r),F(e,`shape`,()=>t.shape),js(e,`ZodObject`,{keyof(){return bc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:oc()})},loose(){return this.clone({...this._zod.def,catchall:oc()})},strict(){return this.clone({...this._zod.def,catchall:cc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Kn(this,e)},safeExtend(e){return qn(this,e)},merge(e){return Jn(this,e)},pick(e){return Wn(this,e)},omit(e){return Gn(this,e)},partial(...e){return Yn(Tc,this,e[0])},required(...e){return Xn(Fc,this,e[0])}})});function fc(e,t){return new dc({type:`object`,shape:e??{},...I(t)})}var pc=P(`ZodUnion`,(e,t)=>{ia.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qo(e,t,n,r),e.options=t.options});function mc(e,t){return new pc({type:`union`,options:e,...I(t)})}var hc=P(`ZodIntersection`,(e,t)=>{aa.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$o(e,t,n,r)});function gc(e,t){return new hc({type:`intersection`,left:e,right:t})}var _c=P(`ZodRecord`,(e,t)=>{ca.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>es(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function vc(e,t,n){return!t||!t._zod?new _c({type:`record`,keyType:H(),valueType:e,...I(t)}):new _c({type:`record`,keyType:e,valueType:t,...I(n)})}var yc=P(`ZodEnum`,(e,t)=>{la.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ko(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 yc({...t,checks:[],...I(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 yc({...t,checks:[],...I(r),entries:i})}});function bc(e,t){return new yc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...I(t)})}var xc=P(`ZodLiteral`,(e,t)=>{ua.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qo(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 Sc(e,t){return new xc({type:`literal`,values:Array.isArray(e)?e:[e],...I(t)})}var Cc=P(`ZodTransform`,(e,t)=>{da.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new bn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(rr(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(rr(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 wc(e){return new Cc({type:`transform`,transform:e})}var Tc=P(`ZodOptional`,(e,t)=>{pa.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ec(e){return new Tc({type:`optional`,innerType:e})}var Dc=P(`ZodExactOptional`,(e,t)=>{ma.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Oc(e){return new Dc({type:`optional`,innerType:e})}var kc=P(`ZodNullable`,(e,t)=>{ha.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ac(e){return new kc({type:`nullable`,innerType:e})}var jc=P(`ZodDefault`,(e,t)=>{ga.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Mc(e,t){return new jc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Rn(t)}})}var Nc=P(`ZodPrefault`,(e,t)=>{va.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pc(e,t){return new Nc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Rn(t)}})}var Fc=P(`ZodNonOptional`,(e,t)=>{ya.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ic(e,t){return new Fc({type:`nonoptional`,innerType:e,...I(t)})}var G=P(`ZodCatch`,(e,t)=>{xa.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Lc(e,t){return new G({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Rc=P(`ZodPipe`,(e,t)=>{Sa.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r),e.in=t.in,e.out=t.out});function zc(e,t){return new Rc({type:`pipe`,in:e,out:t})}var Bc=P(`ZodPreprocess`,(e,t)=>{Rc.init(e,t),wa.init(e,t)}),Vc=P(`ZodReadonly`,(e,t)=>{Ta.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hc(e){return new Vc({type:`readonly`,innerType:e})}var Uc=P(`ZodCustom`,(e,t)=>{Da.init(e,t),Ms.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jo(e,t,n,r)});function Wc(e,t={}){return jo(Uc,e,t)}function Gc(e,t){return Mo(e,t)}function Kc(e,t){return new Bc({type:`pipe`,in:wc(e),out:t})}var qc=[`default`,`acceptEdits`,`plan`,`bypassPermissions`,`auto`,`bubble`];function Jc(e){return e===`safe`||e===`workspace`?`default`:e===`full`?`bypassPermissions`:e}var Yc=Kc(Jc,bc(qc).default(`default`)),Xc=fc({type:H(),baseURL:H().url().optional(),apiKey:H().optional(),defaultModel:H().min(1).optional(),cheapModel:H().min(1).optional(),models:uc(H().min(1)).max(100).optional(),maxOutputTokens:W().int().positive().optional(),apiType:bc([`openai`,`anthropic`]).optional(),authorizationUrl:H().url().optional(),tokenUrl:H().url().optional(),clientId:H().min(1).optional(),scope:H().optional()}),Zc={disabled:ic().default(!1),timeoutMs:W().int().min(100).max(30*6e4).default(6e4)},Qc=mc([fc({command:H().min(1),args:uc(H()).default([]),env:vc(H(),H()).default({}),cwd:H().min(1).optional(),...Zc}).strict(),fc({url:H().url().refine(e=>{let t=new URL(e).protocol;return t===`http:`||t===`https:`},`MCP HTTP URLs must use http or https`),headers:vc(H(),H()).default({}),...Zc}).strict()]),$c=H().min(1).max(32).regex(/^[A-Za-z0-9_-]+$/,`MCP server names may contain only letters, digits, underscores, and hyphens`),el=H().min(1).max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,`Skill names must use lowercase letters, digits, and single hyphens`);fc({sleep:ic().default(!1),providers:vc(H(),Xc).default({}),mcpServers:vc($c,Qc).default({}),skills:fc({disabled:uc(el).max(1e3).default([])}).prefault({}),agents:fc({main:fc({model:H()}).optional(),subagent:fc({model:H()}).optional()}).optional(),maxSubagents:W().int().min(1).max(16).default(3),maxSessions:W().int().min(1).max(1e3).default(50),memory:fc({enabled:ic().default(!0),autoExtract:ic().default(!0),autoExtractMinChars:W().int().min(200).max(1e5).default(200),scoreThreshold:W().int().min(0).max(12).default(9),autoStoreThreshold:W().int().min(0).max(12).default(11),ignoreStreakLimit:W().int().min(2).max(100).default(5),reviewAutoDismissSeconds:W().int().min(0).max(300).default(5),maxCandidatesPerTask:W().int().min(1).max(10).default(1),retrievalTopK:W().int().min(1).max(20).default(5),maxEntries:W().int().min(1).max(1e4).default(200),maxEntryChars:W().int().min(32).max(2e4).default(1e3),maxPromptChars:W().int().min(256).max(2e5).default(12e3)}).prefault({}),permissionMode:Yc,execution:fc({mode:bc([`local`,`docker`]).default(`local`),image:H().trim().min(1).default(`node:24-bookworm-slim`),network:ic().default(!1),memory:H().regex(/^[1-9][0-9]*(?:[kKmMgG])?$/).default(`2g`),cpus:W().positive().max(64).default(2)}).prefault({}),language:H().regex(/^[a-z]{2}(-[A-Z]{2})?$/,`language must be a BCP47 tag like zh-CN or en-US`).optional(),hallucination:fc({showWarnings:ic().default(!1),evaluationTimeoutMs:W().int().min(100).max(3e4).default(2e3)}).prefault({}),maxIterations:fc({main:W().int().min(10).max(500).default(80),subagent:W().int().min(10).max(200).default(40),softLimitFactor:W().min(.5).max(1).default(.8),extendBy:W().int().min(5).max(100).default(20)}).prefault({}),loop:fc({maxCycles:W().int().positive().max(1e4).default(20),maxTokens:W().int().positive().max(2**53-1).default(5e5),isolation:Sc(`auto`).default(`auto`)}).prefault({}),context:fc({windowTokens:W().int().positive().default(2e5),reservedOutputTokens:W().int().nonnegative().default(2e4),autoCompactBufferTokens:W().int().nonnegative().default(13e3),warningBufferTokens:W().int().nonnegative().default(2e4),blockingBufferTokens:W().int().nonnegative().default(3e3),microcompactKeepRecentToolResults:W().int().nonnegative().default(5),recentTokens:W().int().nonnegative().default(1e4),recentTextMessages:W().int().nonnegative().default(5),maxRecentTokens:W().int().nonnegative().default(4e4),compactAtChars:W().int().positive().optional(),toolOutputChars:W().int().positive().default(3e4)}).superRefine((e,t)=>{e.reservedOutputTokens>=e.windowTokens&&t.addIssue({code:`custom`,path:[`reservedOutputTokens`],message:`reservedOutputTokens must be below windowTokens`}),e.maxRecentTokens<e.recentTokens&&t.addIssue({code:`custom`,path:[`maxRecentTokens`],message:`maxRecentTokens must be at least recentTokens`})}).prefault({}),incidents:fc({enabled:ic().default(!1),webhookUrl:H().url().optional()}).prefault({})});var tl=[`user`,`feedback`,`project`,`reference`],nl=`model.init.config.login.permissions.skills.plugins.hooks.tasks.finish.compact.clear.help.exit.audit.usage.loop.goal.mcp.ide.memory.remember.forget.forget-cold.checkpoint.tree.rewind.unrevert.fork`.split(`.`),rl={model:`Switch the active model`,init:`Initialize Flavor project files`,config:`Show the resolved configuration`,login:`Authenticate via OAuth PKCE`,permissions:`Change the tool permission mode`,skills:`List discovered skills`,plugins:`List loaded plugins`,hooks:`Show plugin hook status`,tasks:`Show task planning status`,finish:`Complete this task and evaluate long-term memory`,compact:`Compact the conversation context`,clear:`Clear the transcript`,help:`Show available commands`,exit:`Exit Flavor`,audit:`Query tool failure audit log`,usage:`Show cache hit statistics for this session`,loop:`Run a verified autonomous loop toward a goal`,goal:`Run a goal pipeline with adversarial verification`,mcp:`Manage MCP servers`,ide:`Show the connected IDE and editor context`,memory:`Show long-term project memory`,remember:`Add a long-term memory`,forget:`Remove matching long-term memories`,"forget-cold":`Remove all cold long-term memories and their files`,checkpoint:`Create a workspace and context checkpoint`,tree:`Show the session history tree`,rewind:`Restore a prior session node`,unrevert:`Undo the most recent rewind`,fork:`Continue context from a prior session node`},il={name:``,description:``,body:`# Instructions
|
|
135
135
|
|
|
136
136
|
Describe when and how the agent should use this skill.`,disableModelInvocation:!1};function al({onClose:e,onError:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(il),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(!1),y=(0,_.useMemo)(()=>{let e=m.trim().toLowerCase();return e.length===0?n:n.filter(t=>t.name.includes(e)||t.description.toLowerCase().includes(e))},[m,n]),b=n.filter(e=>e.enabled).length,x=c?o.name.trim().length>0||o.description.trim().length>0||o.body!==il.body:i!==void 0&&(o.description!==i.description||o.body!==i.body||!!o.disableModelInvocation!==i.disableModelInvocation),S=e=>t(e instanceof Error?e.message:String(e)),C=async e=>{let t=await window.flavorDesktop.listSkills();r(t);let n=e??i?.name??t[0]?.name;n!==void 0&&t.some(e=>e.name===n)?await w(n):c||(a(void 0),s(il))},w=async e=>{try{let t=await window.flavorDesktop.getSkill(e);a(t),s({name:t.name,description:t.description,body:t.body,disableModelInvocation:t.disableModelInvocation}),l(!1),v(!1)}catch(e){S(e)}};(0,_.useEffect)(()=>{let e=!0;return window.flavorDesktop.listSkills().then(async t=>{e&&(r(t),t[0]!==void 0&&await w(t[0].name))}).catch(S).finally(()=>{e&&d(!1)}),()=>{e=!1}},[]);let ee=()=>{l(!0),a(void 0),s(il),v(!1)},T=async()=>{if(!f){p(!0);try{let e=c?await window.flavorDesktop.createSkill(o):await window.flavorDesktop.updateSkill(i.name,o);l(!1),a(e),s({name:e.name,description:e.description,body:e.body,disableModelInvocation:e.disableModelInvocation}),await C(e.name)}catch(e){S(e)}finally{p(!1)}}},te=async(e,t)=>{r(n=>n.map(n=>n.name===e.name?{...n,enabled:t}:n)),i?.name===e.name&&a({...i,enabled:t});try{await window.flavorDesktop.setSkillEnabled(e.name,t)}catch(n){r(n=>n.map(n=>n.name===e.name?{...n,enabled:!t}:n)),i?.name===e.name&&a({...i,enabled:!t}),S(n)}},E=async()=>{if(!(i===void 0||f)){p(!0);try{await window.flavorDesktop.deleteSkill(i.name),v(!1),a(void 0),s(il);let e=await window.flavorDesktop.listSkills();r(e),e[0]!==void 0&&await w(e[0].name)}catch(e){S(e)}finally{p(!1)}}};return(0,N.jsxs)(`section`,{className:`skill-workbench`,"aria-label":`技能管理`,children:[(0,N.jsxs)(`header`,{className:`skill-workbench-header`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`button`,{className:`skill-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{children:`项目能力`}),(0,N.jsx)(`h1`,{children:`技能管理`})]})]}),(0,N.jsxs)(`div`,{className:`skill-health`,children:[(0,N.jsx)(`i`,{}),(0,N.jsxs)(`span`,{children:[(0,N.jsx)(`strong`,{children:b}),` / `,n.length,` 已开启`]})]})]}),(0,N.jsxs)(`div`,{className:`skill-workbench-body`,children:[(0,N.jsxs)(`aside`,{className:`skill-catalog`,children:[(0,N.jsxs)(`div`,{className:`skill-catalog-tools`,children:[(0,N.jsxs)(`label`,{children:[(0,N.jsx)(`span`,{children:`⌕`}),(0,N.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`搜索技能`})]}),(0,N.jsxs)(`button`,{className:`skill-create`,onClick:ee,children:[(0,N.jsx)(`span`,{children:`+`}),` 新建技能`]})]}),(0,N.jsxs)(`div`,{className:`skill-list`,"aria-busy":u,children:[u&&(0,N.jsx)(`p`,{className:`skill-list-empty`,children:`正在读取技能…`}),!u&&y.length===0&&(0,N.jsxs)(`div`,{className:`skill-list-empty`,children:[(0,N.jsx)(`strong`,{children:`没有匹配的技能`}),(0,N.jsx)(`span`,{children:`创建一个项目技能,或调整搜索词。`})]}),y.map(e=>(0,N.jsxs)(`article`,{className:`skill-list-item`,"data-selected":!c&&i?.name===e.name,"data-enabled":e.enabled,children:[(0,N.jsxs)(`button`,{className:`skill-select`,onClick:()=>void w(e.name),children:[(0,N.jsx)(`span`,{className:`skill-glyph`,children:e.name.slice(0,1).toUpperCase()}),(0,N.jsxs)(`span`,{children:[(0,N.jsx)(`strong`,{children:e.name}),(0,N.jsx)(`small`,{children:e.description})]})]}),(0,N.jsxs)(`label`,{className:`skill-toggle`,title:e.enabled?`关闭后 Agent 无法读取`:`开启后 Agent 可以读取`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:t=>void te(e,t.target.checked)}),(0,N.jsx)(`span`,{})]})]},e.name))]}),(0,N.jsxs)(`p`,{className:`skill-catalog-note`,children:[`启停状态保存在 `,(0,N.jsx)(`code`,{children:`.flavor/flavor.json`})]})]}),(0,N.jsx)(`main`,{className:`skill-editor`,children:i===void 0&&!c?(0,N.jsxs)(`div`,{className:`skill-editor-empty`,children:[(0,N.jsx)(`span`,{children:`◇`}),(0,N.jsx)(`h2`,{children:`选择或创建一个技能`}),(0,N.jsx)(`p`,{children:`技能会在任务匹配时为 Agent 注入专门的工作说明。`})]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`skill-editor-heading`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{children:c?`新建项目技能`:i?.editable?`项目技能`:i?.source===`global`?`全局技能`:`插件技能`}),(0,N.jsx)(`h2`,{children:c?`定义一项新能力`:i?.name})]}),!c&&i!==void 0&&(0,N.jsxs)(`span`,{className:`skill-status`,"data-enabled":i.enabled,children:[(0,N.jsx)(`i`,{}),i.enabled?`Agent 可读取`:`已隔离`]})]}),!c&&i?.editable===!1&&(0,N.jsx)(`div`,{className:`skill-readonly-note`,children:`此技能由全局目录或插件提供,在此项目中只读。你仍可以为当前项目开启或关闭它。`}),(0,N.jsxs)(`div`,{className:`skill-form`,children:[(0,N.jsxs)(`label`,{children:[(0,N.jsxs)(`span`,{children:[`名称 `,(0,N.jsx)(`small`,{children:`小写字母、数字和连字符`})]}),(0,N.jsx)(`input`,{value:o.name,disabled:!c,onChange:e=>s({...o,name:e.target.value}),placeholder:`code-review`})]}),(0,N.jsxs)(`label`,{children:[(0,N.jsxs)(`span`,{children:[`描述 `,(0,N.jsx)(`small`,{children:`帮助 Agent 判断何时使用`})]}),(0,N.jsx)(`textarea`,{rows:3,value:o.description,disabled:!c&&!i?.editable,onChange:e=>s({...o,description:e.target.value}),placeholder:`在提交代码前检查正确性、安全性与可维护性`})]}),(0,N.jsxs)(`label`,{className:`skill-instructions`,children:[(0,N.jsxs)(`span`,{children:[`SKILL.md 指令 `,(0,N.jsx)(`small`,{children:`支持 Markdown`})]}),(0,N.jsx)(`textarea`,{value:o.body,disabled:!c&&!i?.editable,onChange:e=>s({...o,body:e.target.value}),spellCheck:!1})]}),(0,N.jsxs)(`label`,{className:`manual-invocation`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:!!o.disableModelInvocation,disabled:!c&&!i?.editable,onChange:e=>s({...o,disableModelInvocation:e.target.checked})}),(0,N.jsxs)(`span`,{children:[(0,N.jsx)(`strong`,{children:`仅允许手动调用`}),(0,N.jsxs)(`small`,{children:[`开启技能,但不让 Agent 自动匹配;仍可通过 /`,o.name||`skill-name`,` 调用。`]})]})]})]}),(0,N.jsxs)(`footer`,{className:`skill-editor-actions`,children:[!c&&i?.editable&&(0,N.jsx)(`button`,{className:`skill-delete`,onClick:()=>v(!0),children:`删除技能`}),c&&(0,N.jsx)(`button`,{onClick:()=>{l(!1),C()},children:`取消`}),(c||i?.editable)&&(0,N.jsx)(`button`,{className:`skill-save`,disabled:!x||f||!o.name.trim()||!o.description.trim()||!o.body.trim(),onClick:()=>void T(),children:f?`正在保存…`:c?`创建技能`:`保存更改`})]})]})})]}),g&&i!==void 0&&(0,N.jsx)(`div`,{className:`skill-delete-layer`,children:(0,N.jsxs)(`div`,{className:`skill-delete-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`skill-delete-title`,children:[(0,N.jsx)(`span`,{children:`!`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{children:`删除项目技能`}),(0,N.jsxs)(`h2`,{id:`skill-delete-title`,children:[`删除“`,i.name,`”?`]}),(0,N.jsx)(`small`,{children:`技能目录及其中的资源会被永久删除,此操作无法撤销。`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`button`,{onClick:()=>v(!1),children:`取消`}),(0,N.jsx)(`button`,{className:`danger`,disabled:f,onClick:()=>void E(),children:f?`正在删除…`:`删除技能`})]})]})]})})]})}var ol={user:{label:`用户偏好`,hint:`长期稳定的角色、表达和工作偏好`},feedback:{label:`行为反馈`,hint:`希望 Agent 以后持续遵守的纠正`},project:{label:`项目约定`,hint:`不能只靠代码推导出的规则和决策`},reference:{label:`外部引用`,hint:`以后仍会用到的文档或系统入口`}},sl={enabled:!0,path:``,entries:[]},cl={type:`project`,content:``};function ll({onClose:e,onError:t}){let[n,r]=(0,_.useState)(sl),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(cl),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(`all`),[y,b]=(0,_.useState)(!1),x=e=>t(e instanceof Error?e.message:String(e)),S=(0,_.useMemo)(()=>{let e=m.trim().toLocaleLowerCase();return n.entries.filter(t=>(g===`all`||t.type===g)&&(e.length===0||t.content.toLocaleLowerCase().includes(e)||t.id.includes(e)))},[g,m,n.entries]),C=c?o.content.trim().length>0:i!==void 0&&(o.type!==i.type||o.content!==i.content),w=(e,t)=>{let n=e.entries.find(e=>e.id===t)??e.entries.find(e=>e.id===i?.id)??e.entries[0];a(n),s(n===void 0?cl:{type:n.type,content:n.content})},ee=async e=>{let t=await window.flavorDesktop.listMemory();return r(t),w(t,e),t};(0,_.useEffect)(()=>{let e=!0;return window.flavorDesktop.listMemory().then(t=>{e&&(r(t),w(t))}).catch(x).finally(()=>{e&&d(!1)}),()=>{e=!1}},[]);let T=()=>{l(!0),a(void 0),s(cl),b(!1)},te=e=>{l(!1),a(e),s({type:e.type,content:e.content}),b(!1)},E=async()=>{if(!(f||o.content.trim().length===0)){p(!0);try{let e=c?await window.flavorDesktop.createMemory(o):await window.flavorDesktop.updateMemory(i.id,o);l(!1),await ee(e.id)}catch(e){x(e)}finally{p(!1)}}},ne=async()=>{if(!(i===void 0||f)){p(!0);try{if(!await window.flavorDesktop.deleteMemory(i.id))throw Error(`这条记忆已不存在,请重新载入后再试。`);b(!1),a(void 0),s(cl),await ee()}catch(e){x(e)}finally{p(!1)}}};return(0,N.jsxs)(`section`,{className:`memory-workbench`,"aria-label":`长期记忆管理`,children:[(0,N.jsxs)(`header`,{className:`memory-workbench-header`,children:[(0,N.jsxs)(`div`,{className:`memory-heading`,children:[(0,N.jsx)(`button`,{className:`memory-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{children:`项目上下文`}),(0,N.jsx)(`h1`,{children:`长期记忆`})]})]}),(0,N.jsxs)(`div`,{className:`memory-ledger-status`,"data-enabled":n.enabled,children:[(0,N.jsx)(`i`,{}),(0,N.jsxs)(`span`,{children:[(0,N.jsx)(`strong`,{children:n.entries.length}),` 条已保存`]})]})]}),(0,N.jsxs)(`div`,{className:`memory-workbench-body`,children:[(0,N.jsxs)(`aside`,{className:`memory-catalog`,children:[(0,N.jsxs)(`div`,{className:`memory-catalog-tools`,children:[(0,N.jsxs)(`label`,{children:[(0,N.jsx)(`span`,{children:`⌕`}),(0,N.jsx)(`input`,{"aria-label":`搜索记忆`,value:m,onChange:e=>h(e.target.value),placeholder:`搜索记忆`})]}),(0,N.jsxs)(`button`,{className:`memory-create`,onClick:T,disabled:!n.enabled,children:[(0,N.jsx)(`span`,{children:`+`}),` 新建记忆`]})]}),(0,N.jsxs)(`div`,{className:`memory-index`,"aria-label":`按类型筛选`,children:[(0,N.jsxs)(`button`,{"data-active":g===`all`,onClick:()=>v(`all`),children:[(0,N.jsx)(`span`,{children:`全部`}),(0,N.jsx)(`b`,{children:n.entries.length})]}),tl.map(e=>(0,N.jsxs)(`button`,{"data-type":e,"data-active":g===e,onClick:()=>v(e),children:[(0,N.jsx)(`span`,{children:ol[e].label}),(0,N.jsx)(`b`,{children:n.entries.filter(t=>t.type===e).length})]},e))]}),(0,N.jsxs)(`div`,{className:`memory-list`,"aria-busy":u,children:[u&&(0,N.jsx)(`p`,{className:`memory-list-empty`,children:`正在读取记忆…`}),!u&&!n.enabled&&(0,N.jsxs)(`div`,{className:`memory-list-empty`,children:[(0,N.jsx)(`strong`,{children:`长期记忆已关闭`}),(0,N.jsx)(`span`,{children:`在项目配置中将 memory.enabled 设为 true 后可维护。`})]}),!u&&n.enabled&&S.length===0&&(0,N.jsxs)(`div`,{className:`memory-list-empty`,children:[(0,N.jsx)(`strong`,{children:n.entries.length===0?`还没有长期记忆`:`没有匹配项`}),(0,N.jsx)(`span`,{children:n.entries.length===0?`新建一条明确、稳定、以后仍有用的信息。`:`尝试其他关键词或类型。`})]}),S.map(e=>(0,N.jsxs)(`button`,{className:`memory-card`,"data-selected":!c&&i?.id===e.id,"data-type":e.type,onClick:()=>te(e),children:[(0,N.jsx)(`span`,{className:`memory-card-tab`,children:ol[e.type].label}),(0,N.jsx)(`strong`,{children:e.content}),(0,N.jsx)(`code`,{children:e.id})]},e.id))]}),(0,N.jsxs)(`p`,{className:`memory-catalog-note`,children:[`存储于 `,(0,N.jsx)(`code`,{children:n.path||`.flavor/memory/MEMORY.md`})]})]}),(0,N.jsx)(`main`,{className:`memory-editor`,children:n.enabled?i===void 0&&!c?(0,N.jsxs)(`div`,{className:`memory-editor-empty`,children:[(0,N.jsx)(`span`,{children:`⌁`}),(0,N.jsx)(`h2`,{children:`建立项目的共同记忆`}),(0,N.jsx)(`p`,{children:`保存少量稳定事实。当前指令和仓库内容始终优先。`}),(0,N.jsx)(`button`,{onClick:T,children:`新建第一条记忆`})]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`memory-editor-heading`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{children:c?`新记忆`:`记忆 ${i?.id}`}),(0,N.jsx)(`h2`,{children:c?`记录一件以后仍有用的事`:ol[o.type].label})]}),(0,N.jsx)(`span`,{className:`memory-type-seal`,"data-type":o.type,children:o.type})]}),(0,N.jsxs)(`div`,{className:`memory-priority-note`,children:[(0,N.jsx)(`span`,{children:`i`}),(0,N.jsx)(`p`,{children:`记忆是历史背景,不是强制指令。新建或修改后,从下一次模型请求开始生效。`})]}),(0,N.jsxs)(`div`,{className:`memory-form`,children:[(0,N.jsxs)(`fieldset`,{children:[(0,N.jsx)(`legend`,{children:`记忆类型`}),(0,N.jsx)(`div`,{className:`memory-type-options`,children:tl.map(e=>(0,N.jsxs)(`label`,{"data-type":e,"data-selected":o.type===e,children:[(0,N.jsx)(`input`,{type:`radio`,name:`memory-type`,value:e,checked:o.type===e,onChange:()=>s({...o,type:e})}),(0,N.jsxs)(`span`,{children:[(0,N.jsx)(`strong`,{children:ol[e].label}),(0,N.jsx)(`small`,{children:ol[e].hint})]})]},e))})]}),(0,N.jsxs)(`label`,{className:`memory-content-field`,children:[(0,N.jsxs)(`span`,{children:[`内容 `,(0,N.jsx)(`small`,{children:`只写一件事,避免密码、Token 和临时任务状态`})]}),(0,N.jsx)(`textarea`,{autoFocus:!0,value:o.content,maxLength:2e4,onChange:e=>s({...o,content:e.target.value}),placeholder:`例如:不要在未明确要求时创建 Git 提交。`}),(0,N.jsxs)(`em`,{children:[o.content.length,` 字符`]})]})]}),(0,N.jsxs)(`footer`,{className:`memory-editor-actions`,children:[!c&&(0,N.jsx)(`button`,{className:`memory-delete`,onClick:()=>b(!0),children:`删除记忆`}),c&&(0,N.jsx)(`button`,{onClick:()=>{l(!1),ee()},children:`取消`}),(0,N.jsx)(`button`,{className:`memory-save`,disabled:!C||f||o.content.trim().length===0,onClick:()=>void E(),children:f?`正在保存…`:c?`保存记忆`:`保存更改`})]})]}):(0,N.jsxs)(`div`,{className:`memory-editor-empty`,children:[(0,N.jsx)(`span`,{children:`⊘`}),(0,N.jsx)(`h2`,{children:`长期记忆没有启用`}),(0,N.jsx)(`p`,{children:`启用后才能读取和修改项目记忆。`})]})})]}),y&&i!==void 0&&(0,N.jsx)(`div`,{className:`memory-delete-layer`,children:(0,N.jsxs)(`div`,{className:`memory-delete-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`memory-delete-title`,children:[(0,N.jsx)(`span`,{children:`!`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{children:`删除长期记忆`}),(0,N.jsxs)(`h2`,{id:`memory-delete-title`,children:[`删除这条`,ol[i.type].label,`?`]}),(0,N.jsx)(`small`,{children:i.content}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`button`,{onClick:()=>b(!1),children:`取消`}),(0,N.jsx)(`button`,{className:`danger`,disabled:f,onClick:()=>void ne(),children:f?`正在删除…`:`删除记忆`})]})]})]})})]})}var ul={name:``,transport:`stdio`,enabled:!0,command:``,args:``,env:``,cwd:``,url:``,headers:``,timeoutMs:`60000`};function dl({onClose:e,onError:t}){let[n,r]=(0,_.useState)([]),[i,a]=(0,_.useState)(),[o,s]=(0,_.useState)(ul),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(),y=(0,_.useMemo)(()=>{let e=m.trim().toLowerCase();return e===``?n:n.filter(t=>t.name.toLowerCase().includes(e)||t.transport.includes(e))},[m,n]),b=async e=>{let t=await window.flavorDesktop.listMcpServers();r(t);let n=t.find(t=>t.name===e)??t.find(e=>e.name===i)??t[0];n===void 0?t.length===0&&a(void 0):(a(n.name),s(fl(n)))};(0,_.useEffect)(()=>{let e=!1;return window.flavorDesktop.listMcpServers().then(t=>{if(e)return;r(t);let n=t[0];n!==void 0&&(a(n.name),s(fl(n)))}).catch(n=>{e||t(yl(n))}).finally(()=>{e||d(!1)}),()=>{e=!0}},[]);let x=e=>{l(!1),a(e.name),s(fl(e))},S=()=>{l(!0),a(void 0),s(ul)},C=async()=>{p(!0);try{let e=await window.flavorDesktop.saveMcpServer(c?void 0:i,pl(o));l(!1),a(e.name),await b(e.name)}catch(e){t(yl(e))}finally{p(!1)}},w=async(e,n)=>{try{let t=await window.flavorDesktop.setMcpServerEnabled(e.name,n);r(e=>e.map(e=>e.name===t.name?t:e)),i===t.name&&s(fl(t))}catch(e){t(yl(e))}},ee=async()=>{let e=g;if(e!==void 0){p(!0);try{await window.flavorDesktop.deleteMcpServer(e.name),v(void 0),l(!1),a(void 0),s(ul),await b()}catch(e){t(yl(e))}finally{p(!1)}}},T=n.find(e=>e.name===i);return(0,N.jsxs)(`section`,{className:`mcp-workbench`,"aria-label":`MCP 服务管理`,children:[(0,N.jsxs)(`header`,{className:`mcp-workbench-header`,children:[(0,N.jsxs)(`div`,{className:`mcp-heading`,children:[(0,N.jsx)(`button`,{className:`mcp-back`,onClick:e,"aria-label":`返回对话`,children:`‹`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{children:`PROJECT CONNECTIONS`}),(0,N.jsx)(`h1`,{children:`MCP 服务`})]})]}),(0,N.jsxs)(`div`,{className:`mcp-health`,children:[(0,N.jsx)(`i`,{}),`项目配置 `,(0,N.jsx)(`strong`,{children:n.filter(e=>e.enabled).length}),` 已开启`]})]}),(0,N.jsxs)(`div`,{className:`mcp-workbench-body`,children:[(0,N.jsxs)(`aside`,{className:`mcp-catalog`,children:[(0,N.jsxs)(`div`,{className:`mcp-catalog-tools`,children:[(0,N.jsxs)(`label`,{children:[(0,N.jsx)(`span`,{children:`⌕`}),(0,N.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`搜索服务`,"aria-label":`搜索服务`})]}),(0,N.jsxs)(`button`,{className:`mcp-create`,onClick:S,children:[(0,N.jsx)(`span`,{children:`+`}),`添加服务`]})]}),(0,N.jsx)(`div`,{className:`mcp-list`,children:u?(0,N.jsxs)(`div`,{className:`mcp-list-empty`,children:[(0,N.jsx)(`strong`,{children:`正在读取项目配置`}),(0,N.jsx)(`span`,{children:`.flavor/flavor.json`})]}):y.length===0?(0,N.jsxs)(`div`,{className:`mcp-list-empty`,children:[(0,N.jsx)(`strong`,{children:m?`没有匹配的服务`:`还没有项目 MCP 服务`}),(0,N.jsx)(`span`,{children:m?`尝试其他名称或传输类型`:`添加 stdio 或 Streamable HTTP 服务`})]}):y.map(e=>(0,N.jsxs)(`div`,{className:`mcp-list-item`,"data-selected":!c&&i===e.name,"data-transport":e.transport,"data-enabled":e.enabled,children:[(0,N.jsxs)(`button`,{className:`mcp-select`,onClick:()=>x(e),children:[(0,N.jsx)(`span`,{className:`mcp-transport-glyph`,children:e.transport===`stdio`?`>_`:`↗`}),(0,N.jsxs)(`span`,{children:[(0,N.jsx)(`strong`,{children:e.name}),(0,N.jsx)(`small`,{children:e.transport===`stdio`?_l(e.config):vl(e.config)})]})]}),(0,N.jsxs)(`label`,{className:`mcp-toggle`,title:e.enabled?`关闭服务`:`开启服务`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:t=>void w(e,t.target.checked),"aria-label":`${e.enabled?`关闭`:`开启`} ${e.name}`}),(0,N.jsx)(`span`,{})]})]},e.name))}),(0,N.jsxs)(`p`,{className:`mcp-catalog-note`,children:[`仅管理项目配置 `,(0,N.jsx)(`code`,{children:`.flavor/flavor.json`})]})]}),(0,N.jsx)(`article`,{className:`mcp-editor`,children:c||T!==void 0?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`mcp-editor-heading`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{children:c?`NEW CONNECTION`:`SERVICE CONFIGURATION`}),(0,N.jsx)(`h2`,{children:c?`添加 MCP 服务`:i})]}),(0,N.jsx)(`span`,{className:`mcp-transport-seal`,"data-transport":o.transport,children:o.transport})]}),(0,N.jsxs)(`div`,{className:`mcp-lifecycle-note`,children:[(0,N.jsx)(`span`,{children:`↻`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`strong`,{children:`从下一个任务开始生效`}),(0,N.jsx)(`small`,{children:`现有对话不会因配置更改而中断。`})]})]}),(0,N.jsxs)(`form`,{className:`mcp-form`,onSubmit:e=>{e.preventDefault(),C()},children:[(0,N.jsxs)(`div`,{className:`mcp-form-grid`,children:[(0,N.jsxs)(`label`,{children:[(0,N.jsxs)(`span`,{children:[`服务名称 `,(0,N.jsx)(`small`,{children:`字母、数字、_ 或 -`})]}),(0,N.jsx)(`input`,{value:o.name,onChange:e=>s({...o,name:e.target.value}),required:!0,pattern:`[A-Za-z0-9_-]+`})]}),(0,N.jsxs)(`label`,{children:[(0,N.jsx)(`span`,{children:`传输方式`}),(0,N.jsxs)(`select`,{value:o.transport,onChange:e=>s({...o,transport:e.target.value}),children:[(0,N.jsx)(`option`,{value:`stdio`,children:`stdio · 本地进程`}),(0,N.jsx)(`option`,{value:`http`,children:`HTTP · 远程服务`})]})]})]}),o.transport===`stdio`?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`label`,{children:[(0,N.jsx)(`span`,{children:`启动命令`}),(0,N.jsx)(`input`,{value:o.command,onChange:e=>s({...o,command:e.target.value}),placeholder:`npx`,required:!0})]}),(0,N.jsxs)(`label`,{children:[(0,N.jsxs)(`span`,{children:[`参数 `,(0,N.jsx)(`small`,{children:`每行一个参数`})]}),(0,N.jsx)(`textarea`,{rows:4,value:o.args,onChange:e=>s({...o,args:e.target.value}),placeholder:`-y
|
|
137
137
|
@modelcontextprotocol/server-filesystem
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="color-scheme" content="light" />
|
|
7
7
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self' http://127.0.0.1:* ws://127.0.0.1:*" />
|
|
8
8
|
<title>Flavor Code</title>
|
|
9
|
-
<script type="module" crossorigin src="./assets/index-
|
|
9
|
+
<script type="module" crossorigin src="./assets/index-CLrVaR9H.js"></script>
|
|
10
10
|
<link rel="stylesheet" crossorigin href="./assets/index-Cm_ktmXm.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
package/dist/memory/store.d.ts
CHANGED
|
@@ -39,6 +39,15 @@ export declare class MemoryStore {
|
|
|
39
39
|
update(id: string, candidate: MemoryCandidate): Promise<MemoryEntry>;
|
|
40
40
|
delete(id: string): Promise<boolean>;
|
|
41
41
|
forget(query: string): Promise<number>;
|
|
42
|
+
/**
|
|
43
|
+
* Removes every cold memory entry and its backing content. A task file is
|
|
44
|
+
* deleted only when all of its entries were cold; otherwise only the cold
|
|
45
|
+
* entries are dropped from the shared file.
|
|
46
|
+
*/
|
|
47
|
+
forgetCold(now?: Date): Promise<{
|
|
48
|
+
removed: number;
|
|
49
|
+
filesRemoved: number;
|
|
50
|
+
}>;
|
|
42
51
|
recall(query: string, options: {
|
|
43
52
|
taskId: string;
|
|
44
53
|
topK: number;
|
package/dist/sdk/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
FlavorRpcServer,
|
|
5
5
|
TraceRecordSchema,
|
|
6
6
|
TraceRecorder
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-WN2EZV3Y.js";
|
|
8
8
|
import {
|
|
9
9
|
AgentMessageQueue,
|
|
10
10
|
DockerExecutionEnvironment,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
WorkspaceCheckpointStore,
|
|
14
14
|
buildDockerInvocation,
|
|
15
15
|
createProductionRuntime
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-5RHJ3PQN.js";
|
|
17
17
|
import "../chunk-HFR2WS6T.js";
|
|
18
18
|
import "../chunk-N2S7USST.js";
|
|
19
19
|
import "../chunk-S32JRDZK.js";
|
package/dist/ui/commands.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const MVP_COMMANDS: readonly ["model", "init", "config", "login", "permissions", "skills", "plugins", "hooks", "tasks", "finish", "compact", "clear", "help", "exit", "audit", "usage", "loop", "goal", "mcp", "ide", "memory", "remember", "forget", "checkpoint", "tree", "rewind", "unrevert", "fork"];
|
|
1
|
+
export declare const MVP_COMMANDS: readonly ["model", "init", "config", "login", "permissions", "skills", "plugins", "hooks", "tasks", "finish", "compact", "clear", "help", "exit", "audit", "usage", "loop", "goal", "mcp", "ide", "memory", "remember", "forget", "forget-cold", "checkpoint", "tree", "rewind", "unrevert", "fork"];
|
|
2
2
|
export declare const COMMAND_DESCRIPTIONS: Record<(typeof MVP_COMMANDS)[number], string>;
|
|
3
3
|
export type PermissionCommandMode = PermissionMode;
|
|
4
4
|
export type ModelRole = "main" | "subagent";
|
package/dist/ui/session.d.ts
CHANGED
|
@@ -98,6 +98,7 @@ export interface SessionServices {
|
|
|
98
98
|
refreshMemory?(): Promise<void>;
|
|
99
99
|
remember(type: MemoryType, text: string): Promise<string>;
|
|
100
100
|
forget(query: string): Promise<string>;
|
|
101
|
+
forgetCold(): Promise<string>;
|
|
101
102
|
finishTask(): Promise<string>;
|
|
102
103
|
pluginCommands(): readonly string[];
|
|
103
104
|
runPluginCommand(name: string, args: readonly string[], signal: AbortSignal): Promise<unknown>;
|