flavor-code 1.2.4 → 1.2.6
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 +369 -367
- package/README.zh-CN.md +369 -0
- package/dist/{app-N3655H2E.js → app-WRTEXGA6.js} +10 -3
- package/dist/{chunk-L5A2NDMT.js → chunk-CXSXBPD6.js} +1 -1
- package/dist/{chunk-MRISY6KK.js → chunk-RYDCJHXW.js} +89 -30
- package/dist/cli.js +3 -3
- package/dist/desktop/main.js +91 -33
- 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 +2 -1
package/dist/desktop/main.js
CHANGED
|
@@ -2953,10 +2953,12 @@ function getToolCategory(name) {
|
|
|
2953
2953
|
return isNetworkTool(name) ? "network" : CATEGORY_MAP[name] ?? "unknown";
|
|
2954
2954
|
}
|
|
2955
2955
|
var PermissionEngine = class {
|
|
2956
|
+
#lexicalWorkspace;
|
|
2956
2957
|
#workspace;
|
|
2957
2958
|
#mode;
|
|
2958
2959
|
constructor(options) {
|
|
2959
2960
|
const root = resolve2(options.workspace);
|
|
2961
|
+
this.#lexicalWorkspace = root;
|
|
2960
2962
|
this.#workspace = existsSync(root) ? realpathSync.native(root) : root;
|
|
2961
2963
|
this.#mode = canonicalMode(options.mode ?? "default");
|
|
2962
2964
|
}
|
|
@@ -2977,13 +2979,13 @@ var PermissionEngine = class {
|
|
|
2977
2979
|
return { decision: "deny", reason: `${request.tool} requires source and destination paths` };
|
|
2978
2980
|
}
|
|
2979
2981
|
for (const path of paths) {
|
|
2980
|
-
const classification = classifyPath(this.#workspace, path);
|
|
2982
|
+
const classification = classifyPath(this.#lexicalWorkspace, this.#workspace, path);
|
|
2981
2983
|
if (classification.escape) return { decision: "deny", reason: classification.reason ?? "Path escapes the workspace" };
|
|
2982
2984
|
if (request.agent === "subagent" && !classification.inside) {
|
|
2983
2985
|
return { decision: "deny", reason: "Subagents are restricted to the workspace" };
|
|
2984
2986
|
}
|
|
2985
2987
|
}
|
|
2986
|
-
const inside = paths.every((path) => classifyPath(this.#workspace, path).inside);
|
|
2988
|
+
const inside = paths.every((path) => classifyPath(this.#lexicalWorkspace, this.#workspace, path).inside);
|
|
2987
2989
|
if (this.#mode === "plan") {
|
|
2988
2990
|
return READ_TOOLS.has(request.tool) ? { decision: "allow" } : { decision: "deny", reason: "Plan mode is read-only" };
|
|
2989
2991
|
}
|
|
@@ -3010,11 +3012,11 @@ var PermissionEngine = class {
|
|
|
3010
3012
|
const analysis = request.args === void 0 ? analyzeCommand(request.command ?? "") : analyzeArgumentCommand(request.command ?? "", request.args);
|
|
3011
3013
|
if (request.agent === "subagent") {
|
|
3012
3014
|
if (request.cwd === void 0) return { decision: "ask", reason: "Subagent shell commands require an explicit workspace cwd" };
|
|
3013
|
-
const cwd = classifyPath(this.#workspace, request.cwd);
|
|
3015
|
+
const cwd = classifyPath(this.#lexicalWorkspace, this.#workspace, request.cwd);
|
|
3014
3016
|
if (cwd.escape || !cwd.inside) return { decision: "deny", reason: "Subagent shell cwd must remain in the workspace" };
|
|
3015
3017
|
if (analysis.destructive) return { decision: "deny", reason: "Destructive commands are forbidden for subagents" };
|
|
3016
3018
|
if (analysis.wrapped || analysis.opaque || !isRoutineCommand(analysis.command)) return { decision: "ask", reason: "Subagent shell command requires main-Agent approval" };
|
|
3017
|
-
const argumentDecision = assessRoutineArguments(analysis.command, request.cwd, this.#workspace);
|
|
3019
|
+
const argumentDecision = assessRoutineArguments(analysis.command, request.cwd, this.#lexicalWorkspace, this.#workspace);
|
|
3018
3020
|
if (argumentDecision !== "allow") {
|
|
3019
3021
|
return argumentDecision === "deny" ? { decision: "deny", reason: "Subagent command arguments escape the workspace" } : { decision: "ask", reason: "Ambiguous subagent command arguments require main-Agent approval" };
|
|
3020
3022
|
}
|
|
@@ -3026,12 +3028,12 @@ var PermissionEngine = class {
|
|
|
3026
3028
|
if (analysis.wrapped || analysis.opaque) return ask(this.#mode, "Shell wrapper requires approval");
|
|
3027
3029
|
if (this.#mode === "bypassPermissions") return { decision: "allow" };
|
|
3028
3030
|
if ((this.#mode === "acceptEdits" || this.#mode === "auto") && isRoutineCommand(analysis.command)) {
|
|
3029
|
-
const cwd = request.cwd ?? this.#
|
|
3030
|
-
const cwdClassification = classifyPath(this.#workspace, cwd);
|
|
3031
|
+
const cwd = request.cwd ?? this.#lexicalWorkspace;
|
|
3032
|
+
const cwdClassification = classifyPath(this.#lexicalWorkspace, this.#workspace, cwd);
|
|
3031
3033
|
if (cwdClassification.escape || !cwdClassification.inside) {
|
|
3032
3034
|
return { decision: "deny", reason: "Routine command cwd must remain in the workspace" };
|
|
3033
3035
|
}
|
|
3034
|
-
const argumentDecision = assessRoutineArguments(analysis.command, cwd, this.#workspace);
|
|
3036
|
+
const argumentDecision = assessRoutineArguments(analysis.command, cwd, this.#lexicalWorkspace, this.#workspace);
|
|
3035
3037
|
if (argumentDecision === "deny") return { decision: "deny", reason: "Routine command arguments escape the workspace" };
|
|
3036
3038
|
if (argumentDecision === "ask") return ask(this.#mode, "Ambiguous routine command arguments require approval");
|
|
3037
3039
|
return { decision: "allow" };
|
|
@@ -3068,16 +3070,16 @@ function analyzeArgumentCommand(executable, args) {
|
|
|
3068
3070
|
}
|
|
3069
3071
|
return { command, destructive: isForbiddenCommand(command), opaque: false, wrapped: false };
|
|
3070
3072
|
}
|
|
3071
|
-
function classifyPath(
|
|
3072
|
-
const candidate = resolve2(
|
|
3073
|
-
const lexicalInside = isWithin(
|
|
3073
|
+
function classifyPath(lexicalWorkspace, physicalWorkspace, input) {
|
|
3074
|
+
const candidate = resolve2(lexicalWorkspace, input);
|
|
3075
|
+
const lexicalInside = isWithin(lexicalWorkspace, candidate);
|
|
3074
3076
|
const traversal = input.split(/[\\/]+/).includes("..");
|
|
3075
|
-
const startsInWorkspace = pathStartsWith(
|
|
3077
|
+
const startsInWorkspace = pathStartsWith(lexicalWorkspace, input);
|
|
3076
3078
|
if ((!isAbsolute(input) || startsInWorkspace) && traversal && !lexicalInside) {
|
|
3077
3079
|
return { inside: false, escape: true, reason: "Path traversal escapes the workspace" };
|
|
3078
3080
|
}
|
|
3079
3081
|
const physical = resolvePhysical(candidate);
|
|
3080
|
-
const physicalInside = isWithin(
|
|
3082
|
+
const physicalInside = isWithin(physicalWorkspace, physical);
|
|
3081
3083
|
if (lexicalInside && !physicalInside) return { inside: false, escape: true, reason: "Symlink escapes the workspace" };
|
|
3082
3084
|
return { inside: physicalInside, escape: false };
|
|
3083
3085
|
}
|
|
@@ -3167,7 +3169,7 @@ function isRoutineCommand(command) {
|
|
|
3167
3169
|
if (command.executable === "go") return first === "test";
|
|
3168
3170
|
return ["pytest", "vitest", "jest", "eslint", "tsc"].includes(command.executable);
|
|
3169
3171
|
}
|
|
3170
|
-
function assessRoutineArguments(command, cwd,
|
|
3172
|
+
function assessRoutineArguments(command, cwd, lexicalWorkspace, physicalWorkspace) {
|
|
3171
3173
|
const args = routineArguments(command);
|
|
3172
3174
|
if (args === void 0) return "ask";
|
|
3173
3175
|
const pathOptions = /* @__PURE__ */ new Set([
|
|
@@ -3192,7 +3194,7 @@ function assessRoutineArguments(command, cwd, workspace) {
|
|
|
3192
3194
|
const option2 = equals[1]?.toLowerCase() ?? "";
|
|
3193
3195
|
const value = equals[2] ?? "";
|
|
3194
3196
|
if (!pathOptions.has(option2)) return "ask";
|
|
3195
|
-
const decision = assessArgumentPath(value, cwd,
|
|
3197
|
+
const decision = assessArgumentPath(value, cwd, lexicalWorkspace, physicalWorkspace);
|
|
3196
3198
|
if (decision !== "allow") return decision;
|
|
3197
3199
|
continue;
|
|
3198
3200
|
}
|
|
@@ -3200,14 +3202,14 @@ function assessRoutineArguments(command, cwd, workspace) {
|
|
|
3200
3202
|
if (option !== void 0 && pathOptions.has(option)) {
|
|
3201
3203
|
const value = args[index + 1];
|
|
3202
3204
|
if (value === void 0 || value.startsWith("-")) return "ask";
|
|
3203
|
-
const decision = assessArgumentPath(value, cwd,
|
|
3205
|
+
const decision = assessArgumentPath(value, cwd, lexicalWorkspace, physicalWorkspace);
|
|
3204
3206
|
if (decision !== "allow") return decision;
|
|
3205
3207
|
index += 1;
|
|
3206
3208
|
continue;
|
|
3207
3209
|
}
|
|
3208
3210
|
if (arg.startsWith("-")) continue;
|
|
3209
3211
|
if (looksLikePath(arg)) {
|
|
3210
|
-
const decision = assessArgumentPath(arg, cwd,
|
|
3212
|
+
const decision = assessArgumentPath(arg, cwd, lexicalWorkspace, physicalWorkspace);
|
|
3211
3213
|
if (decision !== "allow") return decision;
|
|
3212
3214
|
continue;
|
|
3213
3215
|
}
|
|
@@ -3225,10 +3227,10 @@ function routineArguments(command) {
|
|
|
3225
3227
|
if (["pytest", "vitest", "jest", "eslint", "tsc"].includes(command.executable)) return command.args;
|
|
3226
3228
|
return void 0;
|
|
3227
3229
|
}
|
|
3228
|
-
function assessArgumentPath(value, cwd,
|
|
3230
|
+
function assessArgumentPath(value, cwd, lexicalWorkspace, physicalWorkspace) {
|
|
3229
3231
|
if (value.length === 0) return "ask";
|
|
3230
3232
|
const resolved = resolve2(cwd, value);
|
|
3231
|
-
const classification = classifyPath(
|
|
3233
|
+
const classification = classifyPath(lexicalWorkspace, physicalWorkspace, resolved);
|
|
3232
3234
|
return classification.escape || !classification.inside ? "deny" : "allow";
|
|
3233
3235
|
}
|
|
3234
3236
|
function looksLikePath(value) {
|
|
@@ -3477,7 +3479,8 @@ var ToolRuntime = class {
|
|
|
3477
3479
|
} catch {
|
|
3478
3480
|
}
|
|
3479
3481
|
}
|
|
3480
|
-
|
|
3482
|
+
const sessionAllowed = this.#alwaysAllowed.has(getToolCategory(tool.name));
|
|
3483
|
+
if (!sessionAllowed && (pre.decision === "ask" || permission.decision === "ask")) {
|
|
3481
3484
|
const reason = [pre.reason, permission.reason].filter((value) => value !== void 0).join("\n") || "Approval required";
|
|
3482
3485
|
const requestDecision = await this.#hooks.emit({
|
|
3483
3486
|
version: 1,
|
|
@@ -3502,8 +3505,7 @@ var ToolRuntime = class {
|
|
|
3502
3505
|
throw signal.reason;
|
|
3503
3506
|
} else {
|
|
3504
3507
|
const category = getToolCategory(tool.name);
|
|
3505
|
-
if (this.#
|
|
3506
|
-
} else if (this.#approve === void 0) {
|
|
3508
|
+
if (this.#approve === void 0) {
|
|
3507
3509
|
return this.#fail(tool.name, input, context.agent, "permission_denied", reason);
|
|
3508
3510
|
} else {
|
|
3509
3511
|
const decision = await this.#approve({ ...request, reason }, signal);
|
|
@@ -8251,9 +8253,11 @@ var SkillRegistry = class {
|
|
|
8251
8253
|
for (const configuredRoot of roots) {
|
|
8252
8254
|
const root = resolve11(configuredRoot);
|
|
8253
8255
|
let entries;
|
|
8256
|
+
let physicalRoot = root;
|
|
8254
8257
|
try {
|
|
8255
8258
|
const rootInfo = await lstat5(root);
|
|
8256
8259
|
if (rootInfo.isSymbolicLink() || !rootInfo.isDirectory()) throw new Error("Skill root must be a real directory");
|
|
8260
|
+
physicalRoot = await realpath4(root);
|
|
8257
8261
|
entries = await readdir4(root, { withFileTypes: true });
|
|
8258
8262
|
} catch (error) {
|
|
8259
8263
|
if (isMissing(error)) continue;
|
|
@@ -8266,12 +8270,12 @@ var SkillRegistry = class {
|
|
|
8266
8270
|
try {
|
|
8267
8271
|
if (entry2.isSymbolicLink()) throw new Error("Symlinked skill directories are not allowed");
|
|
8268
8272
|
if (!entry2.isDirectory()) continue;
|
|
8269
|
-
const
|
|
8270
|
-
if (!isWithin3(
|
|
8273
|
+
const physicalSkillRoot = await realpath4(skillRoot);
|
|
8274
|
+
if (!isWithin3(physicalRoot, physicalSkillRoot)) throw new Error("Skill directory escapes its registry root");
|
|
8271
8275
|
const skillFile = resolve11(skillRoot, "SKILL.md");
|
|
8272
8276
|
const parsed = await readFrontmatterFile(
|
|
8273
8277
|
skillFile,
|
|
8274
|
-
|
|
8278
|
+
physicalSkillRoot,
|
|
8275
8279
|
this.#options.maxMetadataBytes,
|
|
8276
8280
|
this.#options.openFile
|
|
8277
8281
|
);
|
|
@@ -8282,7 +8286,7 @@ var SkillRegistry = class {
|
|
|
8282
8286
|
name: parsed.name,
|
|
8283
8287
|
description: parsed.description,
|
|
8284
8288
|
source,
|
|
8285
|
-
root:
|
|
8289
|
+
root: physicalSkillRoot,
|
|
8286
8290
|
disableModelInvocation: parsed.disableModelInvocation
|
|
8287
8291
|
}),
|
|
8288
8292
|
skillFile
|
|
@@ -10513,6 +10517,7 @@ function createEditTool(workspace, options = {}) {
|
|
|
10513
10517
|
paths: (input) => [guard.lexical(input.path)],
|
|
10514
10518
|
execute: async (input, signal) => {
|
|
10515
10519
|
abortIfNeeded(signal);
|
|
10520
|
+
const displayPath = guard.lexical(input.path);
|
|
10516
10521
|
const path = await guard.existing(input.path);
|
|
10517
10522
|
const contents = await readText(path);
|
|
10518
10523
|
const hasCRLF = contents.includes("\r\n");
|
|
@@ -10528,11 +10533,11 @@ function createEditTool(workspace, options = {}) {
|
|
|
10528
10533
|
}
|
|
10529
10534
|
const updatedLF = contentsLF.slice(0, first) + newTextLF + contentsLF.slice(first + oldTextLF.length);
|
|
10530
10535
|
const updated = hasCRLF ? updatedLF.replace(/\n/g, "\r\n") : updatedLF;
|
|
10531
|
-
await options.beforeCommit?.({ path, before: contents, after: updated, kind: "update" }, signal);
|
|
10536
|
+
await options.beforeCommit?.({ path: displayPath, before: contents, after: updated, kind: "update" }, signal);
|
|
10532
10537
|
await atomicWrite(path, updated, signal);
|
|
10533
10538
|
return withToolPresentation(
|
|
10534
|
-
{ path, replacements: 1 },
|
|
10535
|
-
buildFileChangePresentation(
|
|
10539
|
+
{ path: displayPath, replacements: 1 },
|
|
10540
|
+
buildFileChangePresentation(displayPath, contents, updated, "update")
|
|
10536
10541
|
);
|
|
10537
10542
|
}
|
|
10538
10543
|
};
|
|
@@ -12568,6 +12573,7 @@ var MVP_COMMANDS = [
|
|
|
12568
12573
|
"memory",
|
|
12569
12574
|
"remember",
|
|
12570
12575
|
"forget",
|
|
12576
|
+
"forget-cold",
|
|
12571
12577
|
"checkpoint",
|
|
12572
12578
|
"tree",
|
|
12573
12579
|
"rewind",
|
|
@@ -12714,7 +12720,7 @@ var HELP = [
|
|
|
12714
12720
|
"/permissions <default|acceptEdits|plan|bypassPermissions|auto|bubble>",
|
|
12715
12721
|
"/login authenticate via OAuth PKCE",
|
|
12716
12722
|
"/init /config /skills /plugins /hooks /tasks",
|
|
12717
|
-
"/memory /remember [type] <text> /forget <text-or-id> /finish",
|
|
12723
|
+
"/memory /remember [type] <text> /forget <text-or-id> /forget-cold /finish",
|
|
12718
12724
|
"/checkpoint [label] /tree /rewind <node> /unrevert /fork <node>",
|
|
12719
12725
|
"/compact /clear /help /exit",
|
|
12720
12726
|
"/loop <goal> run a verified autonomous loop",
|
|
@@ -12910,6 +12916,8 @@ var FlavorSession = class {
|
|
|
12910
12916
|
this.#notice(await this.#services.remember(command.type, command.text));
|
|
12911
12917
|
} else if (command.name === "forget") {
|
|
12912
12918
|
this.#notice(await this.#services.forget(command.query));
|
|
12919
|
+
} else if (command.name === "forget-cold") {
|
|
12920
|
+
this.#notice(await this.#services.forgetCold());
|
|
12913
12921
|
} else if (command.name === "finish") {
|
|
12914
12922
|
this.#notice(await this.#services.finishTask());
|
|
12915
12923
|
} else if (command.name === "checkpoint") {
|
|
@@ -13733,7 +13741,7 @@ ${total}`;
|
|
|
13733
13741
|
|
|
13734
13742
|
// src/memory/store.ts
|
|
13735
13743
|
import { createHash as createHash8 } from "crypto";
|
|
13736
|
-
import { readFile as readFile17 } from "fs/promises";
|
|
13744
|
+
import { readFile as readFile17, rm as rm9 } from "fs/promises";
|
|
13737
13745
|
import { resolve as resolve20, join as join19, relative as relative15, sep as sep14 } from "path";
|
|
13738
13746
|
|
|
13739
13747
|
// src/memory/similarity.ts
|
|
@@ -13960,6 +13968,50 @@ var MemoryStore = class {
|
|
|
13960
13968
|
}) }));
|
|
13961
13969
|
return removed;
|
|
13962
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
|
+
}
|
|
13963
14015
|
async recall(query, options) {
|
|
13964
14016
|
assertTaskId(options.taskId);
|
|
13965
14017
|
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
@@ -15954,6 +16006,12 @@ ${renderMemoryDocument(entries)}`;
|
|
|
15954
16006
|
if (removed > 0) await refreshMemoryState();
|
|
15955
16007
|
return removed === 0 ? "No matching memory found." : `Forgot ${removed} memory ${removed === 1 ? "entry" : "entries"}.`;
|
|
15956
16008
|
},
|
|
16009
|
+
forgetCold: async () => {
|
|
16010
|
+
if (memoryStore === void 0) return "Long-term memory is disabled.";
|
|
16011
|
+
const { removed, filesRemoved } = await memoryStore.forgetCold();
|
|
16012
|
+
if (removed > 0) await refreshMemoryState();
|
|
16013
|
+
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"}.`;
|
|
16014
|
+
},
|
|
15957
16015
|
finishTask: () => finalizeMemoryTask(true),
|
|
15958
16016
|
pluginCommands: () => [...pluginCommands.keys()].sort(),
|
|
15959
16017
|
runPluginCommand: async (name, args, signal) => {
|
|
@@ -16754,7 +16812,7 @@ function createMemoryTaskId() {
|
|
|
16754
16812
|
}
|
|
16755
16813
|
|
|
16756
16814
|
// src/skills/manager.ts
|
|
16757
|
-
import { lstat as lstat10, mkdir as mkdir18, readFile as readFile20, readdir as readdir10, realpath as realpath8, rm as
|
|
16815
|
+
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";
|
|
16758
16816
|
import { homedir as homedir2 } from "os";
|
|
16759
16817
|
import { isAbsolute as isAbsolute10, join as join22, relative as relative19, resolve as resolve24, sep as sep18 } from "path";
|
|
16760
16818
|
import { stringify } from "yaml";
|
|
@@ -16792,7 +16850,7 @@ var SkillManager = class {
|
|
|
16792
16850
|
await this.#persistEnabled(value.name, true);
|
|
16793
16851
|
return this.get(value.name);
|
|
16794
16852
|
} catch (error) {
|
|
16795
|
-
await
|
|
16853
|
+
await rm10(directory, { recursive: true, force: true }).catch(() => void 0);
|
|
16796
16854
|
throw error;
|
|
16797
16855
|
}
|
|
16798
16856
|
}
|
|
@@ -16820,7 +16878,7 @@ var SkillManager = class {
|
|
|
16820
16878
|
throw error;
|
|
16821
16879
|
});
|
|
16822
16880
|
if (!info.isDirectory() || info.isSymbolicLink()) throw new Error(`Project skill path is not a real directory: ${validName}`);
|
|
16823
|
-
await
|
|
16881
|
+
await rm10(directory, { recursive: true });
|
|
16824
16882
|
await this.#persistEnabled(validName, true);
|
|
16825
16883
|
}
|
|
16826
16884
|
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-CXSXBPD6.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-RYDCJHXW.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>;
|