runcastle 1.0.9 → 1.0.10
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/bin/runcastle.js
CHANGED
|
@@ -106,7 +106,8 @@ var init_config = __esm(() => {
|
|
|
106
106
|
sandboxImage: z.string().optional(),
|
|
107
107
|
burnConcurrency: z.number().int().min(1).max(8).default(3),
|
|
108
108
|
burnMaxIterations: z.number().int().min(1).max(10).default(3),
|
|
109
|
-
setupCommand: z.string().optional()
|
|
109
|
+
setupCommand: z.string().optional(),
|
|
110
|
+
burnWorkspace: z.enum(["auto", "mounted", "isolated"]).default("auto")
|
|
110
111
|
}));
|
|
111
112
|
});
|
|
112
113
|
|
|
@@ -147,6 +148,8 @@ function loadConfig(env = process.env) {
|
|
|
147
148
|
}
|
|
148
149
|
if (env.RUNCASTLE_SETUP_COMMAND)
|
|
149
150
|
overrides.setupCommand = env.RUNCASTLE_SETUP_COMMAND;
|
|
151
|
+
if (env.RUNCASTLE_BURN_WORKSPACE)
|
|
152
|
+
overrides.burnWorkspace = env.RUNCASTLE_BURN_WORKSPACE;
|
|
150
153
|
const base = typeof fileConfig === "object" && fileConfig !== null ? fileConfig : {};
|
|
151
154
|
return RuncastleConfig.parse({ ...base, ...overrides });
|
|
152
155
|
}
|
|
@@ -2689,7 +2692,40 @@ function resolveSetupCommand(tc, override) {
|
|
|
2689
2692
|
}
|
|
2690
2693
|
}
|
|
2691
2694
|
function cacheMountFor(pm, hostPath) {
|
|
2692
|
-
|
|
2695
|
+
const sandboxPath = PM_CACHE_SANDBOX_PATHS[pm];
|
|
2696
|
+
return sandboxPath ? { hostPath, sandboxPath } : undefined;
|
|
2697
|
+
}
|
|
2698
|
+
function resolveBurnWorkspaceMode(config2, platform = process.platform) {
|
|
2699
|
+
if (config2.sandbox === "noSandbox")
|
|
2700
|
+
return "mounted";
|
|
2701
|
+
if (config2.burnWorkspace === "auto")
|
|
2702
|
+
return platform === "linux" ? "mounted" : "isolated";
|
|
2703
|
+
return config2.burnWorkspace;
|
|
2704
|
+
}
|
|
2705
|
+
function buildIsolatedSetupCommand(tempBranch, setupCommand) {
|
|
2706
|
+
const hookFile = `${ISOLATED_REPO_PATH}/.git/hooks/post-commit`;
|
|
2707
|
+
const parts = [
|
|
2708
|
+
`git -C ${SANDBOX_WORKSPACE_PATH} config receive.denyCurrentBranch updateInstead`,
|
|
2709
|
+
`git clone ${SANDBOX_WORKSPACE_PATH} ${ISOLATED_REPO_PATH}`,
|
|
2710
|
+
`printf '#!/bin/sh\\nexec git push --quiet origin HEAD:%s\\n' '${tempBranch}' > ${hookFile}`,
|
|
2711
|
+
`chmod +x ${hookFile}`
|
|
2712
|
+
];
|
|
2713
|
+
if (setupCommand)
|
|
2714
|
+
parts.push(`cd ${ISOLATED_REPO_PATH} && ${setupCommand}`);
|
|
2715
|
+
return parts.join(" && ");
|
|
2716
|
+
}
|
|
2717
|
+
function buildWorkspaceNotes(mode) {
|
|
2718
|
+
if (mode === "mounted") {
|
|
2719
|
+
return "Work in the current directory \u2014 it is the repo checkout on your branch.";
|
|
2720
|
+
}
|
|
2721
|
+
return [
|
|
2722
|
+
`Your working repository is \`${ISOLATED_REPO_PATH}\` \u2014 a clone on the container's fast native filesystem, with dependencies already installed. Do ALL work there: \`cd ${ISOLATED_REPO_PATH}\` first; every file you read, edit, test, and commit lives under it.`,
|
|
2723
|
+
"",
|
|
2724
|
+
`The directory you start in (\`${SANDBOX_WORKSPACE_PATH}\`) is a slow mounted mirror used only to collect your commits \u2014 never edit files, install, or run tests there. Your commits sync back automatically (a post-commit hook pushes them); just commit as normal.`,
|
|
2725
|
+
"",
|
|
2726
|
+
`If you are blocked and write \`BLOCKED.md\`, write it at \`${ISOLATED_REPO_PATH}/BLOCKED.md\` AND copy it to \`${SANDBOX_WORKSPACE_PATH}/BLOCKED.md\` so the orchestrator can see it.`
|
|
2727
|
+
].join(`
|
|
2728
|
+
`);
|
|
2693
2729
|
}
|
|
2694
2730
|
function readRepoToolchain(repoPath) {
|
|
2695
2731
|
const pkgPath = join8(repoPath, "package.json");
|
|
@@ -2981,26 +3017,31 @@ function selectSandbox(config2, mounts = []) {
|
|
|
2981
3017
|
async function realExecuteTicketRun(ctx, ticket, config2, token, model, land) {
|
|
2982
3018
|
const { project, feature } = ctx;
|
|
2983
3019
|
const tempBranch = ticketBranchName(feature.slug, ticket.seq, newId("b").slice(2, 10));
|
|
3020
|
+
const workspaceMode = resolveBurnWorkspaceMode(config2);
|
|
2984
3021
|
const template = readFileSync4(burnerTemplatePath(), "utf8");
|
|
2985
3022
|
const prompt = renderTicketPrompt(template, {
|
|
2986
3023
|
TICKET_JSON: buildTicketJson(ticket),
|
|
2987
3024
|
FEATURE_BRIEF: buildFeatureBrief(feature),
|
|
2988
3025
|
DOCS_DIGEST: readDocsDigestFromDisk(project.id, feature.slug),
|
|
2989
|
-
COMMIT_CONVENTION: `ticket(${ticket.seq}): <summary
|
|
3026
|
+
COMMIT_CONVENTION: `ticket(${ticket.seq}): <summary>`,
|
|
3027
|
+
WORKSPACE_NOTES: buildWorkspaceNotes(workspaceMode)
|
|
2990
3028
|
});
|
|
2991
3029
|
const toolchain = readRepoToolchain(project.repoPath);
|
|
2992
3030
|
const pm = detectPackageManager(toolchain);
|
|
2993
3031
|
const setupCommand = resolveSetupCommand(toolchain, config2.setupCommand);
|
|
2994
3032
|
const mounts = [];
|
|
2995
3033
|
if (config2.sandbox !== "noSandbox" && pm) {
|
|
2996
|
-
const
|
|
2997
|
-
|
|
2998
|
-
|
|
3034
|
+
const mount = cacheMountFor(pm, burnCacheDir(pm));
|
|
3035
|
+
if (mount) {
|
|
3036
|
+
mkdirSync4(mount.hostPath, { recursive: true });
|
|
3037
|
+
mounts.push(mount);
|
|
3038
|
+
}
|
|
2999
3039
|
}
|
|
3000
|
-
|
|
3040
|
+
const hookCommand = workspaceMode === "isolated" ? buildIsolatedSetupCommand(tempBranch, setupCommand) : setupCommand;
|
|
3041
|
+
if (hookCommand) {
|
|
3001
3042
|
ctx.emitEvent({
|
|
3002
3043
|
type: "burn.setup",
|
|
3003
|
-
message: `installing deps before agent start: ${setupCommand}`,
|
|
3044
|
+
message: workspaceMode === "isolated" ? `preparing isolated workspace (native-FS clone)${setupCommand ? ` + deps install: ${setupCommand}` : ""}` : `installing deps before agent start: ${setupCommand}`,
|
|
3004
3045
|
ticketId: ticket.id
|
|
3005
3046
|
});
|
|
3006
3047
|
}
|
|
@@ -3029,10 +3070,10 @@ async function realExecuteTicketRun(ctx, ticket, config2, token, model, land) {
|
|
|
3029
3070
|
signal: ctx.signal,
|
|
3030
3071
|
name: `ticket-${ticket.seq}`,
|
|
3031
3072
|
maxIterations: config2.burnMaxIterations,
|
|
3032
|
-
...
|
|
3073
|
+
...hookCommand ? {
|
|
3033
3074
|
hooks: {
|
|
3034
3075
|
sandbox: {
|
|
3035
|
-
onSandboxReady: [{ command:
|
|
3076
|
+
onSandboxReady: [{ command: hookCommand, timeoutMs: SETUP_HOOK_TIMEOUT_MS }]
|
|
3036
3077
|
}
|
|
3037
3078
|
}
|
|
3038
3079
|
} : {},
|
|
@@ -3109,7 +3150,7 @@ function readTokenFromEnvFile(path) {
|
|
|
3109
3150
|
const token = fromFile && fromFile.length > 0 ? fromFile : process.env.CLAUDE_CODE_OAUTH_TOKEN;
|
|
3110
3151
|
return token && token.length > 0 ? token : undefined;
|
|
3111
3152
|
}
|
|
3112
|
-
var AUTH_MISSING_EVENT = "auth.missing", AUTH_MISSING_MESSAGE = "run `claude setup-token` and put CLAUDE_CODE_OAUTH_TOKEN in ~/.runcastle/.env", PLACEHOLDERS, PACKAGE_MANAGERS, PM_CACHE_SANDBOX_PATHS, SETUP_HOOK_TIMEOUT_MS, ticketBurner;
|
|
3153
|
+
var AUTH_MISSING_EVENT = "auth.missing", AUTH_MISSING_MESSAGE = "run `claude setup-token` and put CLAUDE_CODE_OAUTH_TOKEN in ~/.runcastle/.env", PLACEHOLDERS, PACKAGE_MANAGERS, PM_CACHE_SANDBOX_PATHS, SANDBOX_WORKSPACE_PATH = "/home/agent/workspace", ISOLATED_REPO_PATH = "/home/agent/repo", SETUP_HOOK_TIMEOUT_MS, ticketBurner;
|
|
3113
3154
|
var init_ticket_burner = __esm(() => {
|
|
3114
3155
|
init_src();
|
|
3115
3156
|
init_config_load();
|
|
@@ -3117,11 +3158,16 @@ var init_ticket_burner = __esm(() => {
|
|
|
3117
3158
|
init_skills_root();
|
|
3118
3159
|
init_agent_stream();
|
|
3119
3160
|
init_git();
|
|
3120
|
-
PLACEHOLDERS = [
|
|
3161
|
+
PLACEHOLDERS = [
|
|
3162
|
+
"TICKET_JSON",
|
|
3163
|
+
"FEATURE_BRIEF",
|
|
3164
|
+
"DOCS_DIGEST",
|
|
3165
|
+
"COMMIT_CONVENTION",
|
|
3166
|
+
"WORKSPACE_NOTES"
|
|
3167
|
+
];
|
|
3121
3168
|
PACKAGE_MANAGERS = ["bun", "pnpm", "yarn", "npm"];
|
|
3122
3169
|
PM_CACHE_SANDBOX_PATHS = {
|
|
3123
3170
|
bun: "~/.bun/install/cache",
|
|
3124
|
-
pnpm: "~/.local/share/pnpm/store",
|
|
3125
3171
|
yarn: "~/.cache/yarn",
|
|
3126
3172
|
npm: "~/.npm"
|
|
3127
3173
|
};
|
|
@@ -4902,6 +4948,17 @@ import { eq as eq9, isNull } from "drizzle-orm";
|
|
|
4902
4948
|
function listProjects(ctx) {
|
|
4903
4949
|
return ctx.db.select().from(projects).where(isNull(projects.closedAt)).all().map(rowToProject);
|
|
4904
4950
|
}
|
|
4951
|
+
function isTranslatedWindowsMount(repoPath, platform = process.platform) {
|
|
4952
|
+
return platform === "linux" && /^\/mnt\/[a-z](\/|$)/i.test(repoPath);
|
|
4953
|
+
}
|
|
4954
|
+
function warnIfTranslatedMount(ctx, projectId, repoPath) {
|
|
4955
|
+
if (!isTranslatedWindowsMount(repoPath))
|
|
4956
|
+
return;
|
|
4957
|
+
emitProject(ctx, projectId, {
|
|
4958
|
+
type: "project.slow-path",
|
|
4959
|
+
message: `${repoPath} is a Windows drive mounted into Linux (/mnt) \u2014 git and burns pay a per-file translation tax here; clone the repo into the Linux filesystem (e.g. ~/projects) for native speed`
|
|
4960
|
+
});
|
|
4961
|
+
}
|
|
4905
4962
|
async function openProject(ctx, repoPath) {
|
|
4906
4963
|
await assertRepoTolerant(ctx, repoPath);
|
|
4907
4964
|
const mainBranch = await detectMainBranchTolerant(ctx, repoPath);
|
|
@@ -4914,6 +4971,7 @@ async function openProject(ctx, repoPath) {
|
|
|
4914
4971
|
type: "project.opened",
|
|
4915
4972
|
message: `project ${existing.name} re-opened at ${repoPath} (${mainBranch})`
|
|
4916
4973
|
});
|
|
4974
|
+
warnIfTranslatedMount(ctx, existing.id, repoPath);
|
|
4917
4975
|
return reopened;
|
|
4918
4976
|
}
|
|
4919
4977
|
const row = {
|
|
@@ -4930,6 +4988,7 @@ async function openProject(ctx, repoPath) {
|
|
|
4930
4988
|
type: "project.opened",
|
|
4931
4989
|
message: `project ${name} at ${repoPath} (${mainBranch})`
|
|
4932
4990
|
});
|
|
4991
|
+
warnIfTranslatedMount(ctx, project.id, repoPath);
|
|
4933
4992
|
return project;
|
|
4934
4993
|
}
|
|
4935
4994
|
function closeProject(ctx, projectId) {
|
package/index.js
CHANGED
|
@@ -105,7 +105,8 @@ var init_config = __esm(() => {
|
|
|
105
105
|
sandboxImage: z.string().optional(),
|
|
106
106
|
burnConcurrency: z.number().int().min(1).max(8).default(3),
|
|
107
107
|
burnMaxIterations: z.number().int().min(1).max(10).default(3),
|
|
108
|
-
setupCommand: z.string().optional()
|
|
108
|
+
setupCommand: z.string().optional(),
|
|
109
|
+
burnWorkspace: z.enum(["auto", "mounted", "isolated"]).default("auto")
|
|
109
110
|
}));
|
|
110
111
|
});
|
|
111
112
|
|
|
@@ -146,6 +147,8 @@ function loadConfig(env = process.env) {
|
|
|
146
147
|
}
|
|
147
148
|
if (env.RUNCASTLE_SETUP_COMMAND)
|
|
148
149
|
overrides.setupCommand = env.RUNCASTLE_SETUP_COMMAND;
|
|
150
|
+
if (env.RUNCASTLE_BURN_WORKSPACE)
|
|
151
|
+
overrides.burnWorkspace = env.RUNCASTLE_BURN_WORKSPACE;
|
|
149
152
|
const base = typeof fileConfig === "object" && fileConfig !== null ? fileConfig : {};
|
|
150
153
|
return RuncastleConfig.parse({ ...base, ...overrides });
|
|
151
154
|
}
|
|
@@ -2688,7 +2691,40 @@ function resolveSetupCommand(tc, override) {
|
|
|
2688
2691
|
}
|
|
2689
2692
|
}
|
|
2690
2693
|
function cacheMountFor(pm, hostPath) {
|
|
2691
|
-
|
|
2694
|
+
const sandboxPath = PM_CACHE_SANDBOX_PATHS[pm];
|
|
2695
|
+
return sandboxPath ? { hostPath, sandboxPath } : undefined;
|
|
2696
|
+
}
|
|
2697
|
+
function resolveBurnWorkspaceMode(config2, platform = process.platform) {
|
|
2698
|
+
if (config2.sandbox === "noSandbox")
|
|
2699
|
+
return "mounted";
|
|
2700
|
+
if (config2.burnWorkspace === "auto")
|
|
2701
|
+
return platform === "linux" ? "mounted" : "isolated";
|
|
2702
|
+
return config2.burnWorkspace;
|
|
2703
|
+
}
|
|
2704
|
+
function buildIsolatedSetupCommand(tempBranch, setupCommand) {
|
|
2705
|
+
const hookFile = `${ISOLATED_REPO_PATH}/.git/hooks/post-commit`;
|
|
2706
|
+
const parts = [
|
|
2707
|
+
`git -C ${SANDBOX_WORKSPACE_PATH} config receive.denyCurrentBranch updateInstead`,
|
|
2708
|
+
`git clone ${SANDBOX_WORKSPACE_PATH} ${ISOLATED_REPO_PATH}`,
|
|
2709
|
+
`printf '#!/bin/sh\\nexec git push --quiet origin HEAD:%s\\n' '${tempBranch}' > ${hookFile}`,
|
|
2710
|
+
`chmod +x ${hookFile}`
|
|
2711
|
+
];
|
|
2712
|
+
if (setupCommand)
|
|
2713
|
+
parts.push(`cd ${ISOLATED_REPO_PATH} && ${setupCommand}`);
|
|
2714
|
+
return parts.join(" && ");
|
|
2715
|
+
}
|
|
2716
|
+
function buildWorkspaceNotes(mode) {
|
|
2717
|
+
if (mode === "mounted") {
|
|
2718
|
+
return "Work in the current directory \u2014 it is the repo checkout on your branch.";
|
|
2719
|
+
}
|
|
2720
|
+
return [
|
|
2721
|
+
`Your working repository is \`${ISOLATED_REPO_PATH}\` \u2014 a clone on the container's fast native filesystem, with dependencies already installed. Do ALL work there: \`cd ${ISOLATED_REPO_PATH}\` first; every file you read, edit, test, and commit lives under it.`,
|
|
2722
|
+
"",
|
|
2723
|
+
`The directory you start in (\`${SANDBOX_WORKSPACE_PATH}\`) is a slow mounted mirror used only to collect your commits \u2014 never edit files, install, or run tests there. Your commits sync back automatically (a post-commit hook pushes them); just commit as normal.`,
|
|
2724
|
+
"",
|
|
2725
|
+
`If you are blocked and write \`BLOCKED.md\`, write it at \`${ISOLATED_REPO_PATH}/BLOCKED.md\` AND copy it to \`${SANDBOX_WORKSPACE_PATH}/BLOCKED.md\` so the orchestrator can see it.`
|
|
2726
|
+
].join(`
|
|
2727
|
+
`);
|
|
2692
2728
|
}
|
|
2693
2729
|
function readRepoToolchain(repoPath) {
|
|
2694
2730
|
const pkgPath = join8(repoPath, "package.json");
|
|
@@ -2980,26 +3016,31 @@ function selectSandbox(config2, mounts = []) {
|
|
|
2980
3016
|
async function realExecuteTicketRun(ctx, ticket, config2, token, model, land) {
|
|
2981
3017
|
const { project, feature } = ctx;
|
|
2982
3018
|
const tempBranch = ticketBranchName(feature.slug, ticket.seq, newId("b").slice(2, 10));
|
|
3019
|
+
const workspaceMode = resolveBurnWorkspaceMode(config2);
|
|
2983
3020
|
const template = readFileSync4(burnerTemplatePath(), "utf8");
|
|
2984
3021
|
const prompt = renderTicketPrompt(template, {
|
|
2985
3022
|
TICKET_JSON: buildTicketJson(ticket),
|
|
2986
3023
|
FEATURE_BRIEF: buildFeatureBrief(feature),
|
|
2987
3024
|
DOCS_DIGEST: readDocsDigestFromDisk(project.id, feature.slug),
|
|
2988
|
-
COMMIT_CONVENTION: `ticket(${ticket.seq}): <summary
|
|
3025
|
+
COMMIT_CONVENTION: `ticket(${ticket.seq}): <summary>`,
|
|
3026
|
+
WORKSPACE_NOTES: buildWorkspaceNotes(workspaceMode)
|
|
2989
3027
|
});
|
|
2990
3028
|
const toolchain = readRepoToolchain(project.repoPath);
|
|
2991
3029
|
const pm = detectPackageManager(toolchain);
|
|
2992
3030
|
const setupCommand = resolveSetupCommand(toolchain, config2.setupCommand);
|
|
2993
3031
|
const mounts = [];
|
|
2994
3032
|
if (config2.sandbox !== "noSandbox" && pm) {
|
|
2995
|
-
const
|
|
2996
|
-
|
|
2997
|
-
|
|
3033
|
+
const mount = cacheMountFor(pm, burnCacheDir(pm));
|
|
3034
|
+
if (mount) {
|
|
3035
|
+
mkdirSync4(mount.hostPath, { recursive: true });
|
|
3036
|
+
mounts.push(mount);
|
|
3037
|
+
}
|
|
2998
3038
|
}
|
|
2999
|
-
|
|
3039
|
+
const hookCommand = workspaceMode === "isolated" ? buildIsolatedSetupCommand(tempBranch, setupCommand) : setupCommand;
|
|
3040
|
+
if (hookCommand) {
|
|
3000
3041
|
ctx.emitEvent({
|
|
3001
3042
|
type: "burn.setup",
|
|
3002
|
-
message: `installing deps before agent start: ${setupCommand}`,
|
|
3043
|
+
message: workspaceMode === "isolated" ? `preparing isolated workspace (native-FS clone)${setupCommand ? ` + deps install: ${setupCommand}` : ""}` : `installing deps before agent start: ${setupCommand}`,
|
|
3003
3044
|
ticketId: ticket.id
|
|
3004
3045
|
});
|
|
3005
3046
|
}
|
|
@@ -3028,10 +3069,10 @@ async function realExecuteTicketRun(ctx, ticket, config2, token, model, land) {
|
|
|
3028
3069
|
signal: ctx.signal,
|
|
3029
3070
|
name: `ticket-${ticket.seq}`,
|
|
3030
3071
|
maxIterations: config2.burnMaxIterations,
|
|
3031
|
-
...
|
|
3072
|
+
...hookCommand ? {
|
|
3032
3073
|
hooks: {
|
|
3033
3074
|
sandbox: {
|
|
3034
|
-
onSandboxReady: [{ command:
|
|
3075
|
+
onSandboxReady: [{ command: hookCommand, timeoutMs: SETUP_HOOK_TIMEOUT_MS }]
|
|
3035
3076
|
}
|
|
3036
3077
|
}
|
|
3037
3078
|
} : {},
|
|
@@ -3108,7 +3149,7 @@ function readTokenFromEnvFile(path) {
|
|
|
3108
3149
|
const token = fromFile && fromFile.length > 0 ? fromFile : process.env.CLAUDE_CODE_OAUTH_TOKEN;
|
|
3109
3150
|
return token && token.length > 0 ? token : undefined;
|
|
3110
3151
|
}
|
|
3111
|
-
var AUTH_MISSING_EVENT = "auth.missing", AUTH_MISSING_MESSAGE = "run `claude setup-token` and put CLAUDE_CODE_OAUTH_TOKEN in ~/.runcastle/.env", PLACEHOLDERS, PACKAGE_MANAGERS, PM_CACHE_SANDBOX_PATHS, SETUP_HOOK_TIMEOUT_MS, ticketBurner;
|
|
3152
|
+
var AUTH_MISSING_EVENT = "auth.missing", AUTH_MISSING_MESSAGE = "run `claude setup-token` and put CLAUDE_CODE_OAUTH_TOKEN in ~/.runcastle/.env", PLACEHOLDERS, PACKAGE_MANAGERS, PM_CACHE_SANDBOX_PATHS, SANDBOX_WORKSPACE_PATH = "/home/agent/workspace", ISOLATED_REPO_PATH = "/home/agent/repo", SETUP_HOOK_TIMEOUT_MS, ticketBurner;
|
|
3112
3153
|
var init_ticket_burner = __esm(() => {
|
|
3113
3154
|
init_src();
|
|
3114
3155
|
init_config_load();
|
|
@@ -3116,11 +3157,16 @@ var init_ticket_burner = __esm(() => {
|
|
|
3116
3157
|
init_skills_root();
|
|
3117
3158
|
init_agent_stream();
|
|
3118
3159
|
init_git();
|
|
3119
|
-
PLACEHOLDERS = [
|
|
3160
|
+
PLACEHOLDERS = [
|
|
3161
|
+
"TICKET_JSON",
|
|
3162
|
+
"FEATURE_BRIEF",
|
|
3163
|
+
"DOCS_DIGEST",
|
|
3164
|
+
"COMMIT_CONVENTION",
|
|
3165
|
+
"WORKSPACE_NOTES"
|
|
3166
|
+
];
|
|
3120
3167
|
PACKAGE_MANAGERS = ["bun", "pnpm", "yarn", "npm"];
|
|
3121
3168
|
PM_CACHE_SANDBOX_PATHS = {
|
|
3122
3169
|
bun: "~/.bun/install/cache",
|
|
3123
|
-
pnpm: "~/.local/share/pnpm/store",
|
|
3124
3170
|
yarn: "~/.cache/yarn",
|
|
3125
3171
|
npm: "~/.npm"
|
|
3126
3172
|
};
|
|
@@ -4901,6 +4947,17 @@ import { eq as eq9, isNull } from "drizzle-orm";
|
|
|
4901
4947
|
function listProjects(ctx) {
|
|
4902
4948
|
return ctx.db.select().from(projects).where(isNull(projects.closedAt)).all().map(rowToProject);
|
|
4903
4949
|
}
|
|
4950
|
+
function isTranslatedWindowsMount(repoPath, platform = process.platform) {
|
|
4951
|
+
return platform === "linux" && /^\/mnt\/[a-z](\/|$)/i.test(repoPath);
|
|
4952
|
+
}
|
|
4953
|
+
function warnIfTranslatedMount(ctx, projectId, repoPath) {
|
|
4954
|
+
if (!isTranslatedWindowsMount(repoPath))
|
|
4955
|
+
return;
|
|
4956
|
+
emitProject(ctx, projectId, {
|
|
4957
|
+
type: "project.slow-path",
|
|
4958
|
+
message: `${repoPath} is a Windows drive mounted into Linux (/mnt) \u2014 git and burns pay a per-file translation tax here; clone the repo into the Linux filesystem (e.g. ~/projects) for native speed`
|
|
4959
|
+
});
|
|
4960
|
+
}
|
|
4904
4961
|
async function openProject(ctx, repoPath) {
|
|
4905
4962
|
await assertRepoTolerant(ctx, repoPath);
|
|
4906
4963
|
const mainBranch = await detectMainBranchTolerant(ctx, repoPath);
|
|
@@ -4913,6 +4970,7 @@ async function openProject(ctx, repoPath) {
|
|
|
4913
4970
|
type: "project.opened",
|
|
4914
4971
|
message: `project ${existing.name} re-opened at ${repoPath} (${mainBranch})`
|
|
4915
4972
|
});
|
|
4973
|
+
warnIfTranslatedMount(ctx, existing.id, repoPath);
|
|
4916
4974
|
return reopened;
|
|
4917
4975
|
}
|
|
4918
4976
|
const row = {
|
|
@@ -4929,6 +4987,7 @@ async function openProject(ctx, repoPath) {
|
|
|
4929
4987
|
type: "project.opened",
|
|
4930
4988
|
message: `project ${name} at ${repoPath} (${mainBranch})`
|
|
4931
4989
|
});
|
|
4990
|
+
warnIfTranslatedMount(ctx, project.id, repoPath);
|
|
4932
4991
|
return project;
|
|
4933
4992
|
}
|
|
4934
4993
|
function closeProject(ctx, projectId) {
|
package/package.json
CHANGED
|
@@ -12,6 +12,10 @@ You run **non-interactively** (`claude --print`), for up to a few fresh iteratio
|
|
|
12
12
|
- **You may not be the first iteration.** A previous iteration may have left commits or uncommitted work on this branch. Check `git status` and `git log` before starting; continue the work, don't redo it.
|
|
13
13
|
- **Signal completion.** When the ticket is fully done — every acceptance criterion verified, self-review finished, all work committed — print exactly `<promise>COMPLETE</promise>` as the last line of your final message. Do the same after writing `BLOCKED.md` (see hard rules). Without the signal, the harness assumes you were cut off and spends another iteration.
|
|
14
14
|
|
|
15
|
+
## Where to work
|
|
16
|
+
|
|
17
|
+
{{WORKSPACE_NOTES}}
|
|
18
|
+
|
|
15
19
|
## The ticket
|
|
16
20
|
|
|
17
21
|
```json
|
|
@@ -38,6 +42,8 @@ You run **non-interactively** (`claude --print`), for up to a few fresh iteratio
|
|
|
38
42
|
|
|
39
43
|
`{{COMMIT_CONVENTION}}`
|
|
40
44
|
|
|
45
|
+
Run any full suite **once**, capturing output to a file (`<test command> > /tmp/test-run.log 2>&1`; check the exit code), then grep the file for failures and details — never re-run the whole suite just to re-read or filter its output.
|
|
46
|
+
|
|
41
47
|
5. **Self-review before you finish (forked code-review — two axes).** When all acceptance criteria pass, review your own diff along both axes, then fix what you find and re-run typecheck + tests:
|
|
42
48
|
- **Standards** — does the diff follow the conventions of the surrounding code? Watch for the smells: duplicated logic (extract it), mysterious names (rename), primitive obsession (give the concept a type), speculative generality (delete anything the ticket did not ask for), feature envy, data clumps.
|
|
43
49
|
- **Spec = this ticket** — is every acceptance criterion actually met, and is there **nothing in the diff the ticket did not ask for**? Missing and extra both count.
|
|
@@ -69,7 +69,7 @@ Error generating stack: `+e.message+`
|
|
|
69
69
|
|
|
70
70
|
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Gi,s=!Mi.jitless,c=s&&Ki.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?hs([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function vs(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=>!sa(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=>da(e,r,Ni())))}),t)}var ys=N(`$ZodUnion`,(e,t)=>{Ao.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=>Ri(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=>vs(t,r,e,i)):vs(o,r,e,i)}}),bs=N(`$ZodIntersection`,(e,t)=>{Ao.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])=>Ss(e,t,n)):Ss(e,i,a)}});function xs(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(qi(e)&&qi(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=xs(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=xs(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 Ss(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}),sa(e))return e;let o=xs(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Cs=N(`$ZodRecord`,(e,t)=>{Ao.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!qi(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=>da(e,r,Ni())),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(...la(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...la(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`&&oo.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=>da(e,r,Ni())),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(...la(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...la(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),ws=N(`$ZodEnum`,(e,t)=>{Ao.init(e,t);let n=Pi(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Yi.has(typeof e)).map(e=>typeof e==`string`?Xi(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}}),Ts=N(`$ZodTransform`,(e,t)=>{Ao.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ji(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 Ai;return n.value=i,n.fallback=!0,n}});function Es(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Ds=N(`$ZodOptional`,(e,t)=>{Ao.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(`^(${Ri(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=>Es(e,r)):Es(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Os=N(`$ZodExactOptional`,(e,t)=>{Ds.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)}),ks=N(`$ZodNullable`,(e,t)=>{Ao.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(`^(${Ri(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)}),As=N(`$ZodDefault`,(e,t)=>{Ao.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=>js(e,t)):js(r,t)}});function js(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ms=N(`$ZodPrefault`,(e,t)=>{Ao.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))}),Ns=N(`$ZodNonOptional`,(e,t)=>{Ao.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=>Ps(t,e)):Ps(i,e)}});function Ps(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 Fs=N(`$ZodCatch`,(e,t)=>{Ao.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=>da(e,n,Ni()))},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=>da(e,n,Ni()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Is=N(`$ZodPipe`,(e,t)=>{Ao.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=>Ls(e,t.in,n)):Ls(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ls(e,t.out,n)):Ls(r,t.out,n)}});function Ls(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 Rs=N(`$ZodPreprocess`,(e,t)=>{Is.init(e,t)}),zs=N(`$ZodReadonly`,(e,t)=>{Ao.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(Bs):Bs(r)}});function Bs(e){return e.value=Object.freeze(e.value),e}var Vs=N(`$ZodCustom`,(e,t)=>{fo.init(e,t),Ao.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=>Hs(t,n,r,e));Hs(i,n,r,e)}});function Hs(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(pa(e))}}var Us,Ws=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 Gs(){return new Ws}(Us=globalThis).__zod_globalRegistry??(Us.__zod_globalRegistry=Gs());var Ks=globalThis.__zod_globalRegistry;function qs(e,t){return new e({type:`string`,...I(t)})}function Js(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...I(t)})}function Ys(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...I(t)})}function Xs(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...I(t)})}function Zs(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...I(t)})}function Qs(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...I(t)})}function $s(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...I(t)})}function ec(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...I(t)})}function tc(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...I(t)})}function nc(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...I(t)})}function rc(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...I(t)})}function ic(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...I(t)})}function ac(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...I(t)})}function oc(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...I(t)})}function sc(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...I(t)})}function cc(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...I(t)})}function lc(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...I(t)})}function uc(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...I(t)})}function dc(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...I(t)})}function fc(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...I(t)})}function pc(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...I(t)})}function mc(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...I(t)})}function hc(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...I(t)})}function gc(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...I(t)})}function _c(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...I(t)})}function vc(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...I(t)})}function yc(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...I(t)})}function bc(e,t){return new e({type:`number`,checks:[],...I(t)})}function xc(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...I(t)})}function Sc(e,t){return new e({type:`boolean`,...I(t)})}function Cc(e,t){return new e({type:`null`,...I(t)})}function wc(e){return new e({type:`unknown`})}function Tc(e,t){return new e({type:`never`,...I(t)})}function Ec(e,t){return new mo({check:`less_than`,...I(t),value:e,inclusive:!1})}function Dc(e,t){return new mo({check:`less_than`,...I(t),value:e,inclusive:!0})}function Oc(e,t){return new ho({check:`greater_than`,...I(t),value:e,inclusive:!1})}function kc(e,t){return new ho({check:`greater_than`,...I(t),value:e,inclusive:!0})}function Ac(e,t){return new go({check:`multiple_of`,...I(t),value:e})}function jc(e,t){return new _o({check:`max_length`,...I(t),maximum:e})}function Mc(e,t){return new vo({check:`min_length`,...I(t),minimum:e})}function Nc(e,t){return new yo({check:`length_equals`,...I(t),length:e})}function Pc(e,t){return new xo({check:`string_format`,format:`regex`,...I(t),pattern:e})}function Fc(e){return new So({check:`string_format`,format:`lowercase`,...I(e)})}function Ic(e){return new Co({check:`string_format`,format:`uppercase`,...I(e)})}function Lc(e,t){return new wo({check:`string_format`,format:`includes`,...I(t),includes:e})}function Rc(e,t){return new To({check:`string_format`,format:`starts_with`,...I(t),prefix:e})}function zc(e,t){return new Eo({check:`string_format`,format:`ends_with`,...I(t),suffix:e})}function Bc(e){return new Do({check:`overwrite`,tx:e})}function Vc(e){return Bc(t=>t.normalize(e))}function Hc(){return Bc(e=>e.trim())}function Uc(){return Bc(e=>e.toLowerCase())}function Wc(){return Bc(e=>e.toUpperCase())}function Gc(){return Bc(e=>Ui(e))}function Kc(e,t,n){return new e({type:`array`,element:t,...I(n)})}function qc(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...I(n)})}function Jc(e,t){let n=Yc(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(pa(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(pa(r))}},e(t.value,t)),t);return n}function Yc(e,t){let n=new fo({check:`custom`,...I(t)});return n._zod.check=e,n}function Xc(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??Ks,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 Zc(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,Zc(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`&&el(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 Qc(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
71
71
|
|
|
72
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function $c(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:nl(t,`input`,e.processors),output:nl(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function el(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 el(r.element,n);if(r.type===`set`)return el(r.valueType,n);if(r.type===`lazy`)return el(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 el(r.innerType,n);if(r.type===`intersection`)return el(r.left,n)||el(r.right,n);if(r.type===`record`||r.type===`map`)return el(r.keyType,n)||el(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:el(r.in,n)||el(r.out,n);if(r.type===`object`){for(let e in r.shape)if(el(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(el(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(el(e,n))return!0;return!!(r.rest&&el(r.rest,n))}return!1}var tl=(e,t={})=>n=>{let r=Xc({...n,processors:t});return Zc(e,r),Qc(r,e),$c(r,e)},nl=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Xc({...i??{},target:a,io:t,processors:n});return Zc(e,o),Qc(o,e),$c(o,e)},rl={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},il=(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=rl[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}))])}},al=(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)},ol=(e,t,n,r)=>{n.type=`boolean`},sl=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},cl=(e,t,n,r)=>{n.not={}},ll=(e,t,n,r)=>{let i=e._zod.def,a=Pi(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},ul=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},dl=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},fl=(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=Zc(a.element,t,{...r,path:[...r.path,`items`]})},pl=(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]=Zc(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=Zc(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ml=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Zc(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},hl=(e,t,n,r)=>{let i=e._zod.def,a=Zc(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Zc(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]]},gl=(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=Zc(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=Zc(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Zc(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)}},_l=(e,t,n,r)=>{let i=e._zod.def,a=Zc(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`}]},vl=(e,t,n,r)=>{let i=e._zod.def;Zc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},yl=(e,t,n,r)=>{let i=e._zod.def;Zc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},bl=(e,t,n,r)=>{let i=e._zod.def;Zc(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)))},xl=(e,t,n,r)=>{let i=e._zod.def;Zc(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},Sl=(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;Zc(o,t,r);let s=t.seen.get(e);s.ref=o},Cl=(e,t,n,r)=>{let i=e._zod.def;Zc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},wl=(e,t,n,r)=>{let i=e._zod.def;Zc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Tl=N(`ZodISODateTime`,(e,t)=>{Wo.init(e,t),U.init(e,t)});function El(e){return gc(Tl,e)}var Dl=N(`ZodISODate`,(e,t)=>{Go.init(e,t),U.init(e,t)});function Ol(e){return _c(Dl,e)}var kl=N(`ZodISOTime`,(e,t)=>{Ko.init(e,t),U.init(e,t)});function Al(e){return vc(kl,e)}var jl=N(`ZodISODuration`,(e,t)=>{qo.init(e,t),U.init(e,t)});function Ml(e){return yc(jl,e)}var Nl=N(`ZodError`,(e,t)=>{ha.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>va(e,t)},flatten:{value:t=>_a(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Fi,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Fi,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Pl=ya(Nl),Fl=ba(Nl),Il=xa(Nl),Ll=Ca(Nl),Rl=Ta(Nl),zl=Ea(Nl),Bl=Da(Nl),Vl=Oa(Nl),Hl=ka(Nl),Ul=Aa(Nl),Wl=ja(Nl),Gl=Ma(Nl),Kl=new WeakMap;function R(e,t,n){let r=Object.getPrototypeOf(e),i=Kl.get(r);if(i||(i=new Set,Kl.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 z=N(`ZodType`,(e,t)=>(Ao.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:nl(e,`input`),output:nl(e,`output`)}}),e.toJSONSchema=tl(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Pl(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Il(e,t,n),e.parseAsync=async(t,n)=>Fl(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ll(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Rl(e,t,n),e.decode=(t,n)=>zl(e,t,n),e.encodeAsync=async(t,n)=>Bl(e,t,n),e.decodeAsync=async(t,n)=>Vl(e,t,n),e.safeEncode=(t,n)=>Hl(e,t,n),e.safeDecode=(t,n)=>Ul(e,t,n),e.safeEncodeAsync=async(t,n)=>Wl(e,t,n),e.safeDecodeAsync=async(t,n)=>Gl(e,t,n),R(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Vi(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 Zi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(id(e,t))},superRefine(e,t){return this.check(ad(e,t))},overwrite(e){return this.check(Bc(e))},optional(){return zu(this)},exactOptional(){return Vu(this)},nullable(){return Uu(this)},nullish(){return zu(Uu(this))},nonoptional(e){return Yu(this,e)},array(){return Tu(this)},or(e){return ku([this,e])},and(e){return ju(this,e)},transform(e){return $u(this,Lu(e))},default(e){return Gu(this,e)},prefault(e){return qu(this,e)},catch(e){return Zu(this,e)},pipe(e){return $u(this,e)},readonly(){return nd(this)},describe(e){let t=this.clone();return Ks.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ks.get(this);let t=this.clone();return Ks.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 Ks.get(e)?.description},configurable:!0}),e)),B=N(`_ZodString`,(e,t)=>{jo.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>il(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,R(e,`_ZodString`,{regex(...e){return this.check(Pc(...e))},includes(...e){return this.check(Lc(...e))},startsWith(...e){return this.check(Rc(...e))},endsWith(...e){return this.check(zc(...e))},min(...e){return this.check(Mc(...e))},max(...e){return this.check(jc(...e))},length(...e){return this.check(Nc(...e))},nonempty(...e){return this.check(Mc(1,...e))},lowercase(e){return this.check(Fc(e))},uppercase(e){return this.check(Ic(e))},trim(){return this.check(Hc())},normalize(...e){return this.check(Vc(...e))},toLowerCase(){return this.check(Uc())},toUpperCase(){return this.check(Wc())},slugify(){return this.check(Gc())}})}),V=N(`ZodString`,(e,t)=>{jo.init(e,t),B.init(e,t),e.email=t=>e.check(Js(ql,t)),e.url=t=>e.check(ec(Xl,t)),e.jwt=t=>e.check(hc(du,t)),e.emoji=t=>e.check(tc(Zl,t)),e.guid=t=>e.check(Ys(Jl,t)),e.uuid=t=>e.check(Xs(Yl,t)),e.uuidv4=t=>e.check(Zs(Yl,t)),e.uuidv6=t=>e.check(Qs(Yl,t)),e.uuidv7=t=>e.check($s(Yl,t)),e.nanoid=t=>e.check(nc(Ql,t)),e.guid=t=>e.check(Ys(Jl,t)),e.cuid=t=>e.check(rc($l,t)),e.cuid2=t=>e.check(ic(eu,t)),e.ulid=t=>e.check(ac(tu,t)),e.base64=t=>e.check(fc(cu,t)),e.base64url=t=>e.check(pc(lu,t)),e.xid=t=>e.check(oc(nu,t)),e.ksuid=t=>e.check(sc(ru,t)),e.ipv4=t=>e.check(cc(iu,t)),e.ipv6=t=>e.check(lc(au,t)),e.cidrv4=t=>e.check(uc(ou,t)),e.cidrv6=t=>e.check(dc(su,t)),e.e164=t=>e.check(mc(uu,t)),e.datetime=t=>e.check(El(t)),e.date=t=>e.check(Ol(t)),e.time=t=>e.check(Al(t)),e.duration=t=>e.check(Ml(t))});function H(e){return qs(V,e)}var U=N(`ZodStringFormat`,(e,t)=>{Mo.init(e,t),B.init(e,t)}),ql=N(`ZodEmail`,(e,t)=>{Fo.init(e,t),U.init(e,t)}),Jl=N(`ZodGUID`,(e,t)=>{No.init(e,t),U.init(e,t)}),Yl=N(`ZodUUID`,(e,t)=>{Po.init(e,t),U.init(e,t)}),Xl=N(`ZodURL`,(e,t)=>{Io.init(e,t),U.init(e,t)}),Zl=N(`ZodEmoji`,(e,t)=>{Lo.init(e,t),U.init(e,t)}),Ql=N(`ZodNanoID`,(e,t)=>{Ro.init(e,t),U.init(e,t)}),$l=N(`ZodCUID`,(e,t)=>{zo.init(e,t),U.init(e,t)}),eu=N(`ZodCUID2`,(e,t)=>{Bo.init(e,t),U.init(e,t)}),tu=N(`ZodULID`,(e,t)=>{Vo.init(e,t),U.init(e,t)}),nu=N(`ZodXID`,(e,t)=>{Ho.init(e,t),U.init(e,t)}),ru=N(`ZodKSUID`,(e,t)=>{Uo.init(e,t),U.init(e,t)}),iu=N(`ZodIPv4`,(e,t)=>{Jo.init(e,t),U.init(e,t)}),au=N(`ZodIPv6`,(e,t)=>{Yo.init(e,t),U.init(e,t)}),ou=N(`ZodCIDRv4`,(e,t)=>{Xo.init(e,t),U.init(e,t)}),su=N(`ZodCIDRv6`,(e,t)=>{Zo.init(e,t),U.init(e,t)}),cu=N(`ZodBase64`,(e,t)=>{$o.init(e,t),U.init(e,t)}),lu=N(`ZodBase64URL`,(e,t)=>{ts.init(e,t),U.init(e,t)}),uu=N(`ZodE164`,(e,t)=>{ns.init(e,t),U.init(e,t)}),du=N(`ZodJWT`,(e,t)=>{is.init(e,t),U.init(e,t)}),fu=N(`ZodNumber`,(e,t)=>{as.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>al(e,t,n,r),R(e,`ZodNumber`,{gt(e,t){return this.check(Oc(e,t))},gte(e,t){return this.check(kc(e,t))},min(e,t){return this.check(kc(e,t))},lt(e,t){return this.check(Ec(e,t))},lte(e,t){return this.check(Dc(e,t))},max(e,t){return this.check(Dc(e,t))},int(e){return this.check(hu(e))},safe(e){return this.check(hu(e))},positive(e){return this.check(Oc(0,e))},nonnegative(e){return this.check(kc(0,e))},negative(e){return this.check(Ec(0,e))},nonpositive(e){return this.check(Dc(0,e))},multipleOf(e,t){return this.check(Ac(e,t))},step(e,t){return this.check(Ac(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 pu(e){return bc(fu,e)}var mu=N(`ZodNumberFormat`,(e,t)=>{os.init(e,t),fu.init(e,t)});function hu(e){return xc(mu,e)}var gu=N(`ZodBoolean`,(e,t)=>{ss.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ol(e,t,n,r)});function _u(e){return Sc(gu,e)}var vu=N(`ZodNull`,(e,t)=>{cs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sl(e,t,n,r)});function yu(e){return Cc(vu,e)}var bu=N(`ZodUnknown`,(e,t)=>{ls.init(e,t),z.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function xu(){return wc(bu)}var Su=N(`ZodNever`,(e,t)=>{us.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cl(e,t,n,r)});function Cu(e){return Tc(Su,e)}var wu=N(`ZodArray`,(e,t)=>{fs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fl(e,t,n,r),e.element=t.element,R(e,`ZodArray`,{min(e,t){return this.check(Mc(e,t))},nonempty(e){return this.check(Mc(1,e))},max(e,t){return this.check(jc(e,t))},length(e,t){return this.check(Nc(e,t))},unwrap(){return this.element}})});function Tu(e,t){return Kc(wu,e,t)}var Eu=N(`ZodObject`,(e,t)=>{_s.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pl(e,t,n,r),F(e,`shape`,()=>t.shape),R(e,`ZodObject`,{keyof(){return Fu(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:xu()})},loose(){return this.clone({...this._zod.def,catchall:xu()})},strict(){return this.clone({...this._zod.def,catchall:Cu()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return na(this,e)},safeExtend(e){return ra(this,e)},merge(e){return ia(this,e)},pick(e){return ea(this,e)},omit(e){return ta(this,e)},partial(...e){return aa(Ru,this,e[0])},required(...e){return oa(Ju,this,e[0])}})});function Du(e,t){return new Eu({type:`object`,shape:e??{},...I(t)})}var Ou=N(`ZodUnion`,(e,t)=>{ys.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ml(e,t,n,r),e.options=t.options});function ku(e,t){return new Ou({type:`union`,options:e,...I(t)})}var Au=N(`ZodIntersection`,(e,t)=>{bs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hl(e,t,n,r)});function ju(e,t){return new Au({type:`intersection`,left:e,right:t})}var Mu=N(`ZodRecord`,(e,t)=>{Cs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gl(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Nu(e,t,n){let r=Zi(e);return r._zod.values=void 0,new Mu({type:`record`,keyType:r,valueType:t,...I(n)})}var Pu=N(`ZodEnum`,(e,t)=>{ws.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ll(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 Pu({...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 Pu({...t,checks:[],...I(r),entries:i})}});function Fu(e,t){return new Pu({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...I(t)})}var Iu=N(`ZodTransform`,(e,t)=>{Ts.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dl(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ji(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(pa(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(pa(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 Lu(e){return new Iu({type:`transform`,transform:e})}var Ru=N(`ZodOptional`,(e,t)=>{Ds.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zu(e){return new Ru({type:`optional`,innerType:e})}var Bu=N(`ZodExactOptional`,(e,t)=>{Os.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vu(e){return new Bu({type:`optional`,innerType:e})}var Hu=N(`ZodNullable`,(e,t)=>{ks.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_l(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uu(e){return new Hu({type:`nullable`,innerType:e})}var Wu=N(`ZodDefault`,(e,t)=>{As.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Gu(e,t){return new Wu({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ji(t)}})}var Ku=N(`ZodPrefault`,(e,t)=>{Ms.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qu(e,t){return new Ku({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ji(t)}})}var Ju=N(`ZodNonOptional`,(e,t)=>{Ns.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yu(e,t){return new Ju({type:`nonoptional`,innerType:e,...I(t)})}var Xu=N(`ZodCatch`,(e,t)=>{Fs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Zu(e,t){return new Xu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Qu=N(`ZodPipe`,(e,t)=>{Is.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sl(e,t,n,r),e.in=t.in,e.out=t.out});function $u(e,t){return new Qu({type:`pipe`,in:e,out:t})}var ed=N(`ZodPreprocess`,(e,t)=>{Qu.init(e,t),Rs.init(e,t)}),td=N(`ZodReadonly`,(e,t)=>{zs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nd(e){return new td({type:`readonly`,innerType:e})}var rd=N(`ZodCustom`,(e,t)=>{Vs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ul(e,t,n,r)});function id(e,t={}){return qc(rd,e,t)}function ad(e,t){return Jc(e,t)}function od(e,t){return new ed({type:`pipe`,in:Lu(e),out:t})}var sd=Fu([`ideation`,`spec`,`tickets`,`implementation`,`review`,`shipped`]),cd=Fu([`full`,`collapsed`]),ld=Fu([`pending`,`burning`,`done`,`failed`,`cancelled`]),ud=Fu([`ideation`,`qa`,`waypoint`,`converge`,`revisit`]),dd=Fu([`running`,`succeeded`,`failed`,`cancelled`]),fd=Fu([`active`,`shipped`]),pd=Fu([`launching`,`live`,`ended`]);Du({title:H(),goal:H(),context:H(),acceptanceCriteria:Tu(H()),seams:Tu(H()),blockedBy:Tu(pu())}).extend({id:H(),featureId:H(),seq:pu(),status:ld,commits:Tu(H()),error:H().optional()});var md=Fu([`grilling`,`research`,`prototype`,`task`]),hd=Fu([`open`,`claimed`,`resolved`,`dropped`]);Fu([`resolved`,`dropped`]),Du({title:H(),type:md,question:H(),blockedBy:Tu(ku([pu(),H()])),originWaypointId:H().optional()}).extend({id:H(),featureId:H(),seq:pu(),blockedBy:Tu(pu()),status:hd,claimedBy:H().optional(),lastSessionId:H().optional(),summary:H().optional()}),Du({id:H(),name:H(),repoPath:H(),mainBranch:H(),devCommand:H().optional(),model:H().optional()}),Du({id:H(),projectId:H(),slug:H(),title:H(),oneLiner:H(),size:cd,mapped:_u(),phase:sd,branch:H(),baseBranch:H().optional(),status:fd,createdAt:pu()}),Du({id:H(),featureId:H(),kind:ud,ccSessionId:H().optional(),transcriptPath:H().optional(),status:pd,worktreePath:H()}),Du({id:H(),featureId:H(),workflow:H(),status:dd,startedAt:pu(),endedAt:pu().optional(),summary:H().optional()});var gd=Fu([`env`,`project`,`file`,`default`]),_d=Fu([`global`,`project`]),vd=Du({key:H(),value:xu(),source:gd,editable:_u(),restartRequired:_u(),scope:_d});Du({projectId:H().optional(),fields:Tu(vd)}),Du({projectId:H().optional(),key:H(),value:ku([H(),pu(),_u(),yu()])}),Du({id:pu(),projectId:H(),featureId:H().optional(),runId:H().optional(),ticketId:H().optional(),ts:pu(),type:H(),message:H(),data:xu().optional()});var yd=[{phase:`ideation`},{phase:`spec`,gateToEnter:{id:`G1`,description:`Decisions captured before writing a spec`,check:`decisions-file-exists`}},{phase:`tickets`,gateToEnter:{id:`G2`,description:`Spec written before breaking into tickets (auto-satisfied for collapsed features)`,check:`spec-file-exists`}},{phase:`implementation`,gateToEnter:{id:`G3`,description:`Tickets approved by a human (the Burn click)`,check:`tickets-approved`}},{phase:`review`,gateToEnter:{id:`G4`,description:`Every ticket reached a terminal state`,check:`all-tickets-terminal`}},{phase:`shipped`,gateToEnter:{id:`G5`,description:`Human merged the feature branch (the Merge click)`,check:`human-merge`}}].map(e=>e.phase);function bd(e){let t=yd.indexOf(e.phase);if(t<0||t>=yd.length-1)return null;let n=yd[t+1];return e.size===`collapsed`&&n===`spec`?yd[t+2]??null:n}var W=Symbol.for(`drizzle:entityKind`);function xd(e,t){if(!e||typeof e!=`object`)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,W))throw Error(`Class "${t.name??`<unknown>`}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let n=Object.getPrototypeOf(e).constructor;if(n)for(;n;){if(W in n&&n[W]===t[W])return!0;n=Object.getPrototypeOf(n)}return!1}var Sd=class{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}static[W]=`Column`;name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!==`byDefault`}},Cd=class{static[W]=`ColumnBuilder`;config;constructor(e,t,n){this.config={name:e,keyAsName:e===``,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:n,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){this.config.name===``&&(this.config.name=e)}},wd=Symbol.for(`drizzle:Name`),Td=Symbol.for(`drizzle:isPgEnum`);function Ed(e){return!!e&&typeof e==`function`&&Td in e&&e[Td]===!0}var G=class{static[W]=`Subquery`;constructor(e,t,n,r=!1,i=[]){this._={brand:`Subquery`,sql:e,selectedFields:t,alias:n,isWith:r,usedTables:i}}},Dd={startActiveSpan(e,t){return t()}},Od=Symbol.for(`drizzle:ViewBaseConfig`),kd=Symbol.for(`drizzle:Schema`),Ad=Symbol.for(`drizzle:Columns`),jd=Symbol.for(`drizzle:ExtraConfigColumns`),Md=Symbol.for(`drizzle:OriginalName`),Nd=Symbol.for(`drizzle:BaseName`),Pd=Symbol.for(`drizzle:IsAlias`),Fd=Symbol.for(`drizzle:ExtraConfigBuilder`),Id=Symbol.for(`drizzle:IsDrizzleTable`),Ld=class{static[W]=`Table`;static Symbol={Name:wd,Schema:kd,OriginalName:Md,Columns:Ad,ExtraConfigColumns:jd,BaseName:Nd,IsAlias:Pd,ExtraConfigBuilder:Fd};[wd];[Md];[kd];[Ad];[jd];[Nd];[Pd]=!1;[Id]=!0;[Fd]=void 0;constructor(e,t,n){this[wd]=this[Md]=e,this[kd]=t,this[Nd]=n}};function Rd(e){return e!=null&&typeof e.getSQL==`function`}function zd(e){let t={sql:``,params:[]};for(let n of e)t.sql+=n.sql,t.params.push(...n.params),n.typings?.length&&(t.typings||=[],t.typings.push(...n.typings));return t}var K=class{static[W]=`StringChunk`;value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new Bd([this])}},Bd=class e{constructor(e){this.queryChunks=e;for(let t of e)if(xd(t,Ld)){let e=t[Ld.Symbol.Schema];this.usedTables.push(e===void 0?t[Ld.Symbol.Name]:e+`.`+t[Ld.Symbol.Name])}}static[W]=`SQL`;decoder=Hd;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return Dd.startActiveSpan(`drizzle.buildSQL`,t=>{let n=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(t,n){let r=Object.assign({},n,{inlineParams:n.inlineParams||this.shouldInlineParams,paramStartIndex:n.paramStartIndex||{value:0}}),{casing:i,escapeName:a,escapeParam:o,prepareTyping:s,inlineParams:c,paramStartIndex:l}=r;return zd(t.map(t=>{if(xd(t,K))return{sql:t.value.join(``),params:[]};if(xd(t,Vd))return{sql:a(t.value),params:[]};if(t===void 0)return{sql:``,params:[]};if(Array.isArray(t)){let e=[new K(`(`)];for(let[n,r]of t.entries())e.push(r),n<t.length-1&&e.push(new K(`, `));return e.push(new K(`)`)),this.buildQueryFromSourceParams(e,r)}if(xd(t,e))return this.buildQueryFromSourceParams(t.queryChunks,{...r,inlineParams:c||t.shouldInlineParams});if(xd(t,Ld)){let e=t[Ld.Symbol.Schema],n=t[Ld.Symbol.Name];return{sql:e===void 0||t[Pd]?a(n):a(e)+`.`+a(n),params:[]}}if(xd(t,Sd)){let e=i.getColumnCasing(t);if(n.invokeSource===`indexes`)return{sql:a(e),params:[]};let r=t.table[Ld.Symbol.Schema];return{sql:t.table[Pd]||r===void 0?a(t.table[Ld.Symbol.Name])+`.`+a(e):a(r)+`.`+a(t.table[Ld.Symbol.Name])+`.`+a(e),params:[]}}if(xd(t,Jd)){let e=t[Od].schema,n=t[Od].name;return{sql:e===void 0||t[Od].isAlias?a(n):a(e)+`.`+a(n),params:[]}}if(xd(t,Wd)){if(xd(t.value,Kd))return{sql:o(l.value++,t),params:[t],typings:[`none`]};let n=t.value===null?null:t.encoder.mapToDriverValue(t.value);if(xd(n,e))return this.buildQueryFromSourceParams([n],r);if(c)return{sql:this.mapInlineParam(n,r),params:[]};let i=[`none`];return s&&(i=[s(t.encoder)]),{sql:o(l.value++,n),params:[n],typings:i}}return xd(t,Kd)?{sql:o(l.value++,t),params:[t],typings:[`none`]}:xd(t,e.Aliased)&&t.fieldAlias!==void 0?{sql:a(t.fieldAlias),params:[]}:xd(t,G)?t._.isWith?{sql:a(t._.alias),params:[]}:this.buildQueryFromSourceParams([new K(`(`),t._.sql,new K(`) `),new Vd(t._.alias)],r):Ed(t)?t.schema?{sql:a(t.schema)+`.`+a(t.enumName),params:[]}:{sql:a(t.enumName),params:[]}:Rd(t)?t.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([t.getSQL()],r):this.buildQueryFromSourceParams([new K(`(`),t.getSQL(),new K(`)`)],r):c?{sql:this.mapInlineParam(t,r),params:[]}:{sql:o(l.value++,t),params:[t],typings:[`none`]}}))}mapInlineParam(e,{escapeString:t}){if(e===null)return`null`;if(typeof e==`number`||typeof e==`boolean`)return e.toString();if(typeof e==`string`)return t(e);if(typeof e==`object`){let n=e.toString();return t(n===`[object Object]`?JSON.stringify(e):n)}throw Error(`Unexpected param value: `+e)}getSQL(){return this}as(t){return t===void 0?this:new e.Aliased(this,t)}mapWith(e){return this.decoder=typeof e==`function`?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}},Vd=class{constructor(e){this.value=e}static[W]=`Name`;brand;getSQL(){return new Bd([this])}},Hd={mapFromDriverValue:e=>e},Ud={mapToDriverValue:e=>e};({...Hd,...Ud});var Wd=class{constructor(e,t=Ud){this.value=e,this.encoder=t}static[W]=`Param`;brand;getSQL(){return new Bd([this])}};function Gd(e,...t){let n=[];(t.length>0||e.length>0&&e[0]!==``)&&n.push(new K(e[0]));for(let[r,i]of t.entries())n.push(i,new K(e[r+1]));return new Bd(n)}(e=>{function t(){return new Bd([])}e.empty=t;function n(e){return new Bd(e)}e.fromList=n;function r(e){return new Bd([new K(e)])}e.raw=r;function i(e,t){let n=[];for(let[r,i]of e.entries())r>0&&t!==void 0&&n.push(t),n.push(i);return new Bd(n)}e.join=i;function a(e){return new Vd(e)}e.identifier=a;function o(e){return new Kd(e)}e.placeholder=o;function s(e,t){return new Wd(e,t)}e.param=s})(Gd||={}),(e=>{class t{constructor(e,t){this.sql=e,this.fieldAlias=t}static[W]=`SQL.Aliased`;isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(Bd||={});var Kd=class{constructor(e){this.name=e}static[W]=`Placeholder`;getSQL(){return new Bd([this])}},qd=Symbol.for(`drizzle:IsDrizzleView`),Jd=class{static[W]=`View`;[Od];[qd]=!0;constructor({name:e,schema:t,selectedFields:n,query:r}){this[Od]={name:e,originalName:e,schema:t,selectedFields:n,query:r,isExisting:!r,isAlias:!1}}getSQL(){return new Bd([this])}};Sd.prototype.getSQL=function(){return new Bd([this])},Ld.prototype.getSQL=function(){return new Bd([this])},G.prototype.getSQL=function(){return new Bd([this])};function Yd(e,t){return{name:typeof e==`string`&&e.length>0?e:``,config:typeof e==`object`?e:t}}var Xd=typeof TextDecoder>`u`?null:new TextDecoder,Zd=class{static[W]=`SQLiteForeignKeyBuilder`;reference;_onUpdate;_onDelete;constructor(e,t){this.reference=()=>{let{name:t,columns:n,foreignColumns:r}=e();return{name:t,columns:n,foreignTable:r[0].table,foreignColumns:r}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete)}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new Qd(e,this)}},Qd=class{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[W]=`SQLiteForeignKey`;reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),r=t.map(e=>e.name),i=n.map(e=>e.name),a=[this.table[wd],...r,n[0].table[wd],...i];return e??`${a.join(`_`)}_fk`}};function $d(e,t){return`${e[wd]}_${t.join(`_`)}_unique`}var ef=class extends Cd{static[W]=`SQLiteColumnBuilder`;foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:`always`,mode:t?.mode??`virtual`},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:r})=>((n,r)=>{let i=new Zd(()=>{let t=n();return{columns:[e],foreignColumns:[t]}});return r.onUpdate&&i.onUpdate(r.onUpdate),r.onDelete&&i.onDelete(r.onDelete),i.build(t)})(n,r))}},tf=class extends Sd{constructor(e,t){t.uniqueName||=$d(e,[t.name]),super(e,t),this.table=e}static[W]=`SQLiteColumn`},nf=class extends ef{static[W]=`SQLiteBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteBigInt`)}build(e){return new rf(e,this.config)}},rf=class extends tf{static[W]=`SQLiteBigInt`;getSQLType(){return`blob`}mapFromDriverValue(e){if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString(`utf8`))}return BigInt(Xd.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}},af=class extends ef{static[W]=`SQLiteBlobJsonBuilder`;constructor(e){super(e,`json`,`SQLiteBlobJson`)}build(e){return new of(e,this.config)}},of=class extends tf{static[W]=`SQLiteBlobJson`;getSQLType(){return`blob`}mapFromDriverValue(e){if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString(`utf8`))}return JSON.parse(Xd.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}},sf=class extends ef{static[W]=`SQLiteBlobBufferBuilder`;constructor(e){super(e,`buffer`,`SQLiteBlobBuffer`)}build(e){return new cf(e,this.config)}},cf=class extends tf{static[W]=`SQLiteBlobBuffer`;mapFromDriverValue(e){return Buffer.isBuffer(e)?e:Buffer.from(e)}getSQLType(){return`blob`}};function lf(e,t){let{name:n,config:r}=Yd(e,t);return r?.mode===`json`?new af(n):r?.mode===`bigint`?new nf(n):new sf(n)}var uf=class extends ef{static[W]=`SQLiteCustomColumnBuilder`;constructor(e,t,n){super(e,`custom`,`SQLiteCustomColumn`),this.config.fieldConfig=t,this.config.customTypeParams=n}build(e){return new df(e,this.config)}},df=class extends tf{static[W]=`SQLiteCustomColumn`;sqlName;mapTo;mapFrom;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom==`function`?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo==`function`?this.mapTo(e):e}};function ff(e){return(t,n)=>{let{name:r,config:i}=Yd(t,n);return new uf(r,i,e)}}var pf=class extends ef{static[W]=`SQLiteBaseIntegerBuilder`;constructor(e,t,n){super(e,t,n),this.config.autoIncrement=!1}primaryKey(e){return e?.autoIncrement&&(this.config.autoIncrement=!0),this.config.hasDefault=!0,super.primaryKey()}},mf=class extends tf{static[W]=`SQLiteBaseInteger`;autoIncrement=this.config.autoIncrement;getSQLType(){return`integer`}},hf=class extends pf{static[W]=`SQLiteIntegerBuilder`;constructor(e){super(e,`number`,`SQLiteInteger`)}build(e){return new gf(e,this.config)}},gf=class extends mf{static[W]=`SQLiteInteger`},_f=class extends pf{static[W]=`SQLiteTimestampBuilder`;constructor(e,t){super(e,`date`,`SQLiteTimestamp`),this.config.mode=t}defaultNow(){return this.default(Gd`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new vf(e,this.config)}},vf=class extends mf{static[W]=`SQLiteTimestamp`;mode=this.config.mode;mapFromDriverValue(e){return this.config.mode===`timestamp`?new Date(e*1e3):new Date(e)}mapToDriverValue(e){let t=e.getTime();return this.config.mode===`timestamp`?Math.floor(t/1e3):t}},yf=class extends pf{static[W]=`SQLiteBooleanBuilder`;constructor(e,t){super(e,`boolean`,`SQLiteBoolean`),this.config.mode=t}build(e){return new bf(e,this.config)}},bf=class extends mf{static[W]=`SQLiteBoolean`;mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return+!!e}};function xf(e,t){let{name:n,config:r}=Yd(e,t);return r?.mode===`timestamp`||r?.mode===`timestamp_ms`?new _f(n,r.mode):r?.mode===`boolean`?new yf(n,r.mode):new hf(n)}var Sf=class extends ef{static[W]=`SQLiteNumericBuilder`;constructor(e){super(e,`string`,`SQLiteNumeric`)}build(e){return new Cf(e,this.config)}},Cf=class extends tf{static[W]=`SQLiteNumeric`;mapFromDriverValue(e){return typeof e==`string`?e:String(e)}getSQLType(){return`numeric`}},wf=class extends ef{static[W]=`SQLiteNumericNumberBuilder`;constructor(e){super(e,`number`,`SQLiteNumericNumber`)}build(e){return new Tf(e,this.config)}},Tf=class extends tf{static[W]=`SQLiteNumericNumber`;mapFromDriverValue(e){return typeof e==`number`?e:Number(e)}mapToDriverValue=String;getSQLType(){return`numeric`}},Ef=class extends ef{static[W]=`SQLiteNumericBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteNumericBigInt`)}build(e){return new Df(e,this.config)}},Df=class extends tf{static[W]=`SQLiteNumericBigInt`;mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return`numeric`}};function Of(e,t){let{name:n,config:r}=Yd(e,t),i=r?.mode;return i===`number`?new wf(n):i===`bigint`?new Ef(n):new Sf(n)}var kf=class extends ef{static[W]=`SQLiteRealBuilder`;constructor(e){super(e,`number`,`SQLiteReal`)}build(e){return new Af(e,this.config)}},Af=class extends tf{static[W]=`SQLiteReal`;getSQLType(){return`real`}};function jf(e){return new kf(e??``)}var Mf=class extends ef{static[W]=`SQLiteTextBuilder`;constructor(e,t){super(e,`string`,`SQLiteText`),this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new Nf(e,this.config)}},Nf=class extends tf{static[W]=`SQLiteText`;enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:``}`}},Pf=class extends ef{static[W]=`SQLiteTextJsonBuilder`;constructor(e){super(e,`json`,`SQLiteTextJson`)}build(e){return new Ff(e,this.config)}},Ff=class extends tf{static[W]=`SQLiteTextJson`;getSQLType(){return`text`}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}};function q(e,t={}){let{name:n,config:r}=Yd(e,t);return r.mode===`json`?new Pf(n):new Mf(n,r)}function If(){return{blob:lf,customType:ff,integer:xf,numeric:Of,real:jf,text:q}}var Lf=Symbol.for(`drizzle:SQLiteInlineForeignKeys`),Rf=class extends Ld{static[W]=`SQLiteTable`;static Symbol=Object.assign({},Ld.Symbol,{InlineForeignKeys:Lf});[Ld.Symbol.Columns];[Lf]=[];[Ld.Symbol.ExtraConfigBuilder]=void 0};function zf(e,t,n,r,i=e){let a=new Rf(e,r,i),o=typeof t==`function`?t(If()):t,s=Object.fromEntries(Object.entries(o).map(([e,t])=>{let n=t;n.setName(e);let r=n.build(a);return a[Lf].push(...n.buildForeignKeys(r,a)),[e,r]})),c=Object.assign(a,s);return c[Ld.Symbol.Columns]=s,c[Ld.Symbol.ExtraConfigColumns]=s,n&&(c[Rf.Symbol.ExtraConfigBuilder]=n),c}var Bf=(e,t,n)=>zf(e,t,n);Bf(`projects`,{id:q(`id`).primaryKey(),name:q(`name`).notNull(),repoPath:q(`repo_path`).notNull(),mainBranch:q(`main_branch`).notNull(),devCommand:q(`dev_command`),model:q(`model`),sandbox:q(`sandbox`),closedAt:xf(`closed_at`)}),Bf(`features`,{id:q(`id`).primaryKey(),projectId:q(`project_id`).notNull(),slug:q(`slug`).notNull(),title:q(`title`).notNull(),oneLiner:q(`one_liner`).notNull(),size:q(`size`).notNull().$type(),mapped:xf(`mapped`,{mode:`boolean`}).notNull().default(!1),phase:q(`phase`).notNull().$type(),branch:q(`branch`).notNull(),baseBranch:q(`base_branch`),status:q(`status`).notNull().$type(),createdAt:xf(`created_at`).notNull()}),Bf(`sessions`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),kind:q(`kind`).notNull().$type(),ccSessionId:q(`cc_session_id`),transcriptPath:q(`transcript_path`),status:q(`status`).notNull().$type(),worktreePath:q(`worktree_path`).notNull()}),Bf(`tickets`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),seq:xf(`seq`).notNull(),title:q(`title`).notNull(),goal:q(`goal`).notNull(),context:q(`context`).notNull(),acceptanceCriteria:q(`acceptance_criteria`,{mode:`json`}).notNull().$type(),seams:q(`seams`,{mode:`json`}).notNull().$type(),blockedBy:q(`blocked_by`,{mode:`json`}).notNull().$type(),status:q(`status`).notNull().$type(),commits:q(`commits`,{mode:`json`}).notNull().$type(),error:q(`error`)}),Bf(`waypoints`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),seq:xf(`seq`).notNull(),title:q(`title`).notNull(),type:q(`type`).notNull().$type(),question:q(`question`).notNull(),blockedBy:q(`blocked_by`,{mode:`json`}).notNull().$type(),originWaypointId:q(`origin_waypoint_id`),status:q(`status`).notNull().$type(),claimedBy:q(`claimed_by`),lastSessionId:q(`last_session_id`),summary:q(`summary`)}),Bf(`runs`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),workflow:q(`workflow`).notNull(),status:q(`status`).notNull().$type(),startedAt:xf(`started_at`).notNull(),endedAt:xf(`ended_at`),summary:q(`summary`)}),Bf(`events`,{id:xf(`id`).primaryKey({autoIncrement:!0}),projectId:q(`project_id`).notNull(),featureId:q(`feature_id`),runId:q(`run_id`),ticketId:q(`ticket_id`),ts:xf(`ts`).notNull(),type:q(`type`).notNull(),message:q(`message`).notNull(),data:q(`data`,{mode:`json`})}),Bf(`gate_overrides`,{id:xf(`id`).primaryKey({autoIncrement:!0}),featureId:q(`feature_id`).notNull(),gate:q(`gate`).notNull(),reason:q(`reason`).notNull(),ts:xf(`ts`).notNull()});var Vf=[`ideation`,`qa`,`waypoint`,`converge`,`revisit`,`research`,`implement`,`smoke`],Hf=Fu(Vf),Uf=[{id:`claude-opus-4-8`,label:`Opus 4.8`},{id:`claude-sonnet-5`,label:`Sonnet 5`},{id:`claude-haiku-4-5-20251001`,label:`Haiku 4.5`},{id:`claude-fable-5`,label:`Fable 5`}];od(e=>{if(typeof e!=`object`||!e||Array.isArray(e))return e;let t={...e},n=t.smokeModel;if(typeof n==`string`&&n.length>0){let e=typeof t.stepModels==`object`&&t.stepModels!==null&&!Array.isArray(t.stepModels)?t.stepModels:{};e.smoke===void 0&&(t.stepModels={...e,smoke:n})}return delete t.smokeModel,t},Du({serverPort:pu().default(4512),model:H().default(`claude-opus-4-8`),stepModels:Nu(Hf,H()).default({smoke:`claude-haiku-4-5-20251001`}),sandbox:Fu([`docker`,`podman`,`noSandbox`]).default(`docker`),mainBranch:H().default(`main`),sandboxImage:H().optional(),burnConcurrency:pu().int().min(1).max(8).default(3),burnMaxIterations:pu().int().min(1).max(10).default(3),setupCommand:H().optional()}));var Wf=[`ideation`,`spec`,`tickets`,`implementation`,`review`,`shipped`];function Gf(e){switch(e){case`ideation`:return`◉`;case`spec`:return`◐`;case`tickets`:return`▤`;case`implementation`:return`⚙`;case`review`:return`◆`;case`shipped`:return`✓`}}function Kf(e){return e.status===`shipped`||e.activeRun?null:e.ticketCounts.failed>0?{kind:`attention`,label:`run failed — needs attention`}:e.phase===`ideation`?{kind:`grill`,label:`needs grilling`}:e.phase===`tickets`&&e.ticketCounts.total>0?{kind:`burn`,label:`review & burn tickets`}:e.phase===`review`?{kind:`ship`,label:`test & merge`}:null}function qf(e){if(e.length!==0)return[...e].sort((e,t)=>t.startedAt-e.startedAt)[0]}var Jf={ideation:`ideation`,spec:`spec`,tickets:`tickets`,implementation:`build`,review:`review`,shipped:`shipped`},Yf={ideation:`Shape the idea in a grill session`,spec:`Write it up as a spec`,tickets:`Break the work into atomic tickets`,implementation:`Burn the tickets into commits`,review:`Test-drive the branch, then merge`,shipped:`Merged to the main branch`};function Xf(e){return Wf.indexOf(e)}function Zf(e){return e.size===`collapsed`}function Qf(e){return e.status===`shipped`?`shipped`:e.activeRun?`agentWorking`:Kf(e)?`needsYou`:`inProgress`}function $f(e){let t={needsYou:[],agentWorking:[],inProgress:[],shipped:[]};for(let n of e)t[Qf(n)].push(n);return[{key:`needsYou`,label:`Needs you`},{key:`agentWorking`,label:`Agent working`},{key:`inProgress`,label:`In progress`},{key:`shipped`,label:`Shipped`}].map(({key:e,label:n})=>({key:e,label:n,features:t[e]})).filter(e=>e.features.length>0)}function ep(e,t){if(Zf(e)&&t===`spec`)return`skipped`;let n=Xf(e.phase),r=Xf(t);return r<n?`done`:r===n?`current`:`upcoming`}function tp(e){return Wf.map(t=>({phase:t,state:ep(e,t)}))}function np(e,t){return t??e.phase}function rp(e,t){return Xf(t)<Xf(e.phase)}function ip(e,t){return Wf.map(n=>{let r=ep(e,n);return{phase:n,label:Jf[n],state:r,isViewed:n===t,clickable:r===`done`||r===`current`,tip:Yf[n]}})}function ap(e,t){let{feature:n,tickets:r,sessions:i,runs:a,gate:o}=e,s=i.find(e=>e.status===`live`),c=r.length,l=r.filter(e=>e.status===`done`).length,u=r.filter(e=>e.status===`failed`).length,d=qf(a),f=d?.status===`running`,p=bd(n),m=!!o.next&&o.satisfied&&o.next.id!==`G3`&&o.next.id!==`G5`,h=p?`Promote to ${Jf[p]}`:`Promote`;switch(n.phase){case`ideation`:return n.mapped?{kick:`MAP`,title:o.satisfied?`Converge the map`:`Work the frontier`,desc:o.satisfied?`Every waypoint is resolved — converge to draft the spec and tickets.`:o.reason??`Resolve the open waypoints; converge once the frontier clears.`,primary:s?{label:`Jump to grill`,kind:`openGrill`}:void 0,secondary:[],busy:!1}:m?{kick:`NEXT STEP`,title:`Promote the idea`,desc:`Decisions are captured — promote the idea when it feels concrete.`,primary:{label:h,kind:`advance`},secondary:s?[{label:`Back to grill`,kind:`openGrill`}]:[],busy:!1}:s?{kick:`GRILL LIVE`,title:`Grill session in progress`,desc:`Shape the idea with Claude — decisions accumulate in Knowledge.`,primary:{label:`Jump to grill`,kind:`openGrill`},secondary:[],busy:!1}:{kick:`NEXT STEP`,title:`Shape the idea with Claude`,desc:`Launch a grill session to shape the idea before any code is written.`,primary:{label:`Start grill session`,kind:`startGrill`},secondary:[],busy:!1};case`spec`:return m?{kick:`NEXT STEP`,title:`Approve the spec`,desc:`The spec is written — approve it to move into tickets.`,primary:{label:`Approve spec → tickets`,kind:`advance`},secondary:s?[{label:`Back to grill`,kind:`openGrill`}]:[],busy:!1}:s?{kick:`GRILL LIVE`,title:`Writing the spec`,desc:`The spec takes shape beside the conversation.`,primary:{label:`Jump to grill`,kind:`openGrill`},secondary:[],busy:!1}:{kick:`NEXT STEP`,title:`Write the spec`,desc:`No spec yet — resume the grill to draft it.`,primary:{label:`Resume grill`,kind:`startGrill`},secondary:[],busy:!1};case`tickets`:return c>0?{kick:`NEXT STEP`,title:`Review & burn the tickets`,desc:`Each ticket is one atomic task Claude will implement. Review them, then burn.`,primary:{label:`Burn ${c} ticket${c===1?``:`s`}`,kind:`burn`},secondary:s?[{label:`Back to grill`,kind:`openGrill`}]:[{label:`Revisit`,kind:`revisit`}],busy:!1}:{kick:`WAITING`,title:`Waiting for tickets`,desc:`No tickets yet — a grill session emits them. Open a session to shape the work.`,primary:s?{label:`Jump to grill`,kind:`openGrill`}:{label:`Open grill to emit tickets`,kind:`startGrill`},secondary:[],busy:!1};case`implementation`:return f?{kick:`IN PROGRESS`,title:`Burning tickets`,desc:`Burning ${c} ticket${c===1?``:`s`} — ${l} done${u?`, ${u} failed`:``}.`,primary:{label:`Cancel run`,kind:`cancelRun`,danger:!0},secondary:[],busy:!0}:{kick:`NEXT STEP`,title:`Resume the burn`,desc:d?.status===`failed`?`The run failed — resume the burn to retry.`:d?.status===`cancelled`?`The run was cancelled — resume the burn to continue.`:`The burn has not started — resume to run the tickets.`,primary:{label:`Resume burn`,kind:`burn`},secondary:s?[]:[{label:`Revisit`,kind:`revisit`}],busy:!1};case`review`:{let e=t.driving?`Test-driving the branch — merge when it looks right.`:u>0?`Run finished with ${u} failed ticket${u===1?``:`s`} — review, then ship.`:`Checks are in. Test-drive the branch, then merge to ship.`;return{kick:`NEXT STEP`,title:t.driving?`Merge when it looks right`:`Test drive, then ship`,desc:e,primary:{label:`Merge & ship`,kind:`merge`},secondary:t.driving?[{label:`Stop test drive`,kind:`testDriveStop`}]:[{label:`Start test drive`,kind:`testDriveStart`}],busy:!1}}case`shipped`:return{kick:`SHIPPED`,title:`Shipped to main`,desc:`The branch is merged and the pipeline is complete. Ask a question anytime.`,primary:void 0,secondary:[{label:`Ask a question`,kind:`askQuestions`}],busy:!1}}}function op({projectId:e,selectedFeatureId:t,onSelect:n,onNewFeature:r}){let i=j.feature.list.useQuery({projectId:e},{refetchInterval:1500}),a=$f(i.data??[]);return(0,O.jsxs)(`nav`,{className:`sidebar`,children:[(0,O.jsxs)(`div`,{className:`sidebar-head`,children:[(0,O.jsx)(`span`,{className:`pane-title`,children:`Features`}),(0,O.jsx)(`button`,{className:`new-btn`,onClick:r,children:`+ New`})]}),(0,O.jsxs)(`div`,{className:`sidebar-list`,children:[i.isLoading&&(0,O.jsx)(`div`,{style:{padding:`10px 8px`},children:(0,O.jsx)(M,{children:`loading features…`})}),i.data&&i.data.length===0&&(0,O.jsx)(`div`,{style:{padding:`10px 8px`},children:(0,O.jsx)(M,{children:`no features yet — + New to begin`})}),a.map(e=>(0,O.jsxs)(`div`,{className:`triage-group triage-${e.key}`,children:[(0,O.jsxs)(`div`,{className:`triage-label`,children:[(0,O.jsx)(`span`,{className:`triage-name`,children:e.label}),(0,O.jsx)(`span`,{className:`triage-count`,children:e.features.length})]}),e.features.map(e=>(0,O.jsx)(sp,{f:e,active:e.id===t,onSelect:n},e.id))]},e.key))]}),(0,O.jsx)(`div`,{className:`sidebar-foot`,children:`Every feature moves through the same six-phase pipeline. Amber means it's waiting on you.`})]})}function sp({f:e,active:t,onSelect:n}){let r=Kf(e),i=tp(e);return(0,O.jsxs)(`button`,{className:`feature-row${t?` is-active`:``}${e.status===`shipped`?` is-shipped`:``}`,onClick:()=>n(e.id),title:e.title,children:[(0,O.jsx)(`span`,{className:`feature-glyph phase-fg-${e.phase}`,children:Gf(e.phase)}),(0,O.jsx)(`span`,{className:`feature-slug mono`,children:e.slug}),(0,O.jsx)(`span`,{className:`feature-flag`,children:e.activeRun?(0,O.jsx)(`span`,{className:`spin-ring`,title:`agent working`}):e.status===`shipped`?(0,O.jsx)(`span`,{className:`mini-check`,children:`✓`}):(0,O.jsxs)(O.Fragment,{children:[r&&(0,O.jsx)(`span`,{className:`needs-dot needs-${r.kind}`,title:r.label}),(0,O.jsx)(`span`,{className:`mini-map`,children:i.map((e,t)=>(0,O.jsx)(`span`,{className:`mini-seg is-${e.state}`},t))})]})})]})}var cp=(0,D.createContext)(null);function lp({children:e}){let[t,n]=(0,D.useState)([]),r=(0,D.useCallback)((e,t=`error`)=>{let r=Date.now()+Math.random();n(n=>[...n,{id:r,kind:t,message:e}]),setTimeout(()=>n(e=>e.filter(e=>e.id!==r)),6e3)},[]);return(0,O.jsxs)(cp.Provider,{value:{push:r},children:[e,(0,O.jsx)(`div`,{className:`toasts`,children:t.map(e=>(0,O.jsx)(`div`,{className:`toast toast-${e.kind}`,onClick:()=>n(t=>t.filter(t=>t.id!==e.id)),children:e.message},e.id))})]})}function up(){let e=(0,D.useContext)(cp);if(!e)throw Error(`useToast used outside ToastProvider`);return e}function dp(e){let[t,n]=(0,D.useState)([]),r=t.length?t[t.length-1].id:void 0,i=j.events.list.useQuery({featureId:e,afterId:r},{refetchInterval:1500});return(0,D.useEffect)(()=>{let e=i.data;!e||e.length===0||n(t=>{let n=new Set(t.map(e=>e.id)),r=e.filter(e=>!n.has(e.id));return r.length===0?t:[...t,...r].sort((e,t)=>e.id-t.id)})},[i.data]),t}function fp(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function pp(e){return e.slice(0,7)}function mp(e,t=Date.now()){let n=Math.max(0,Math.floor((t-e)/1e3));if(n<5)return`now`;if(n<60)return`${n}s`;let r=Math.floor(n/60);if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function hp(e,t){let n=Math.max(0,Math.floor((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60;return r>0?`${r}h ${String(i).padStart(2,`0`)}m`:i>0?`${i}m ${String(a).padStart(2,`0`)}s`:`${a}s`}function gp({featureId:e,relPath:t,title:n,onClose:r}){let i=j.docs.read.useQuery({featureId:e,relPath:t});return(0,D.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,O.jsx)(`div`,{className:`peek-backdrop`,onClick:r,children:(0,O.jsxs)(`div`,{className:`peek`,onClick:e=>e.stopPropagation(),children:[(0,O.jsxs)(`div`,{className:`peek-head`,children:[(0,O.jsx)(`span`,{className:`mono peek-path`,children:t}),(0,O.jsx)(`button`,{className:`peek-close`,onClick:r,"aria-label":`Close (Esc)`,children:`✕`})]}),(0,O.jsxs)(`div`,{className:`peek-body mono`,children:[i.isLoading&&(0,O.jsxs)(M,{children:[`loading `,n,`…`]}),i.error&&(0,O.jsxs)(M,{children:[`could not read `,t,`: `,i.error.message]}),i.data&&(0,O.jsx)(`pre`,{className:`peek-pre`,children:i.data.content})]})]})})}function _p({featureId:e}){let t=j.feature.get.useQuery({id:e},{refetchInterval:1500});return t.isLoading?(0,O.jsx)(`aside`,{className:`inspector`,children:(0,O.jsx)(M,{children:`loading…`})}):t.data?(0,O.jsxs)(`aside`,{className:`inspector`,children:[(0,O.jsx)(bp,{featureId:e,gate:t.data.gate}),(0,O.jsx)(Cp,{featureId:e,docs:t.data.docs}),(0,O.jsx)(wp,{featureId:e})]}):(0,O.jsx)(`aside`,{className:`inspector`,children:(0,O.jsx)(M,{children:t.error?.message??`could not load inspector`})})}var vp={G1:`Decisions captured`,G2:`Spec written`,G3:`Tickets approved`,G4:`Run clean`,G5:`Merged`};function yp(e){return e.check===`all-waypoints-terminal`?`Waypoints resolved`:vp[e.id]??e.id}function bp({featureId:e,gate:t}){let n=up(),r=j.useUtils(),[i,a]=(0,D.useState)(!1),[o,s]=(0,D.useState)(``),c=j.feature.overrideGate.useMutation({onSuccess:()=>{s(``),a(!1),r.feature.get.invalidate({id:e}),r.feature.list.invalidate()},onError:e=>n.push(e.message)});return(0,O.jsxs)(`section`,{className:`insp-section`,children:[(0,O.jsx)(`div`,{className:`insp-cap`,children:`Current gate`}),t.next===null?(0,O.jsx)(`div`,{className:`gate-empty`,children:`No gate — this feature is shipped.`}):(0,O.jsx)(xp,{gateId:t.next.id,name:yp(t.next),description:t.next.description,satisfied:t.satisfied,reason:t.reason,open:i,reasonValue:o,pending:c.isPending,onOpen:()=>a(!0),onCancel:()=>{a(!1),s(``)},onReasonChange:s,onApply:()=>c.mutate({featureId:e,gate:t.next.id,reason:o.trim()})})]})}function xp({gateId:e,name:t,description:n,satisfied:r,reason:i,open:a,reasonValue:o,pending:s,onOpen:c,onCancel:l,onReasonChange:u,onApply:d}){return(0,O.jsxs)(`div`,{className:`gate-card`,children:[(0,O.jsxs)(`div`,{className:`gate-idrow`,children:[(0,O.jsx)(`span`,{className:`gate-id`,children:e}),(0,O.jsx)(`span`,{className:`gate-name`,children:t})]}),(0,O.jsx)(`div`,{className:`gate-req`,children:n}),(0,O.jsxs)(`div`,{className:`gate-state ${r?`is-ok`:`is-block`}`,children:[(0,O.jsx)(`span`,{className:`gate-state-dot`}),(0,O.jsx)(`span`,{children:r?`ready to advance`:i??`blocked`})]}),a?(0,O.jsxs)(`div`,{className:`override-form`,children:[(0,O.jsx)(`input`,{className:`override-input`,placeholder:`reason for override`,value:o,autoFocus:!0,onChange:e=>u(e.target.value)}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(Ci,{variant:`solid`,className:`btn-xs`,disabled:!o.trim()||s,onClick:d,children:`Apply`}),(0,O.jsx)(Ci,{variant:`ghost`,className:`btn-xs`,onClick:l,children:`Cancel`})]})]}):(0,O.jsx)(Ci,{variant:`ghost`,className:`btn-xs`,onClick:c,children:`Override with reason…`}),(0,O.jsx)(`div`,{className:`gate-hint`,children:`The highlighted action in the workspace advances this gate.`})]})}function Sp(e){return e.split(/[\\/]/).pop()??e}function Cp({featureId:e,docs:t}){let[n,r]=(0,D.useState)(null);return(0,O.jsxs)(`section`,{className:`insp-section`,children:[(0,O.jsx)(`div`,{className:`insp-cap`,children:`Knowledge`}),t.length===0?(0,O.jsx)(M,{children:`no docs yet`}):(0,O.jsx)(`ul`,{className:`doc-list`,children:t.map(e=>(0,O.jsx)(`li`,{children:(0,O.jsxs)(`button`,{className:`doc-link`,onClick:()=>r({relPath:e.relPath,title:e.title}),children:[(0,O.jsx)(`span`,{className:`doc-title`,children:e.title}),(0,O.jsx)(`span`,{className:`doc-meta`,children:Sp(e.relPath)})]})},e.relPath))}),n&&(0,O.jsx)(gp,{featureId:e,relPath:n.relPath,title:n.title,onClose:()=>r(null)})]})}function wp({featureId:e}){let t=dp(e).slice(-12).reverse();return(0,O.jsxs)(`section`,{className:`insp-section`,children:[(0,O.jsx)(`div`,{className:`insp-cap`,children:`Activity`}),t.length===0?(0,O.jsx)(M,{children:`no activity yet`}):(0,O.jsx)(`div`,{className:`activity-log`,children:t.map(e=>(0,O.jsxs)(`div`,{className:`act-line`,children:[(0,O.jsx)(`span`,{className:`act-time`,children:mp(e.ts)}),(0,O.jsxs)(`div`,{className:`act-body`,children:[(0,O.jsx)(`div`,{className:`act-type`,children:e.type}),(0,O.jsx)(`div`,{className:`act-msg`,children:e.message})]})]},e.id))})]})}var Tp=`docker`,Ep=4512;function Dp({projectId:e,activeFeatureId:t,driving:n,onDriveChange:r}){let i=up(),a=j.useUtils(),o=j.feature.list.useQuery({projectId:e},{refetchInterval:1500}),s=!o.isError&&o.data!==void 0,c=o.data?.find(e=>e.id===t),l=o.data?.filter(e=>e.activeRun).length??0,u=j.feature.testDrive.useMutation({onSuccess:()=>{r(null),n&&a.feature.get.invalidate({id:n.featureId}),a.feature.list.invalidate()},onError:e=>i.push(e.message)});return(0,O.jsxs)(`footer`,{className:`statusbar`,children:[c&&(0,O.jsxs)(`button`,{className:`sb-branch`,onClick:()=>{c&&navigator.clipboard.writeText(c.branch).then(()=>i.push(`copied ${c.branch}`,`info`),()=>i.push(`copy failed`))},title:`copy branch`,children:[`⎇ `,c.branch]}),(0,O.jsxs)(`span`,{className:`sb-item`,children:[`sandbox · `,Tp]}),n&&(0,O.jsxs)(`span`,{className:`sb-driving`,children:[(0,O.jsx)(`span`,{className:`sb-driving-dot`}),`driving `,(0,O.jsx)(`span`,{className:`mono`,children:n.branch}),(0,O.jsx)(`button`,{className:`sb-stop`,disabled:u.isPending,onClick:()=>u.mutate({featureId:n.featureId,action:`stop`}),children:`stop`})]}),(0,O.jsx)(`span`,{className:`sb-spacer`}),(0,O.jsxs)(`span`,{className:`sb-item`,children:[l,` run`,l===1?``:`s`]}),(0,O.jsxs)(`span`,{className:`sb-item sb-health ${s?`is-ok`:`is-down`}`,children:[(0,O.jsx)(`span`,{className:`health-dot`}),`:`,Ep,` `,s?`ok`:`down`]})]})}function Op({featureId:e,sessionId:t}){let n=j.useUtils(),r=up(),i=j.feature.endSession.useMutation({onSuccess:()=>{n.feature.get.invalidate({id:e}),n.feature.list.invalidate(),r.push(`session ended`,`info`)},onError:e=>r.push(e.message)});return(0,O.jsx)(`button`,{type:`button`,className:`btn btn-xs btn-ghost sess-end`,disabled:i.isPending,title:`end this session — recoverable, you can relaunch it`,onClick:()=>i.mutate({sessionId:t}),children:i.isPending?`Ending…`:`End session`})}var kp=class extends D.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[runcastle] boundary caught`,e,t)}render(){return this.state.error?(0,O.jsx)(`div`,{className:`boundary-fallback`,children:(0,O.jsxs)(`span`,{className:`dim-line mono`,children:[this.props.label??`component`,` failed: `,this.state.error.message]})}):this.props.children}},Ap=2,jp=1,Mp=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(Ap,Math.floor(u/e.css.cell.width)),rows:Math.max(jp,Math.floor(l/e.css.cell.height))}}},Np=Object.defineProperty,Pp=Object.getOwnPropertyDescriptor,Fp=(e,t)=>{for(var n in t)Np(e,n,{get:t[n],enumerable:!0})},Ip=(e,t,n,r)=>{for(var i=r>1?void 0:r?Pp(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Np(t,n,i),i},J=(e,t)=>(n,r)=>t(n,r,e),Lp=`Terminal input`,Rp={get:()=>Lp,set:e=>Lp=e},zp=`Too much output to announce, navigate to rows manually to read`,Bp={get:()=>zp,set:e=>zp=e};function Vp(e){return e.replace(/\r?\n/g,`\r`)}function Hp(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function Up(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function Wp(e,t,n,r){e.stopPropagation(),e.clipboardData&&Gp(e.clipboardData.getData(`text/plain`),t,n,r)}function Gp(e,t,n,r){e=Vp(e),e=Hp(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function Kp(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function qp(e,t,n,r,i){Kp(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Jp(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Yp(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var Xp=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},Zp=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},Qp=``,$p=` `,em=class e{constructor(){this.fg=0,this.bg=0,this.extended=new tm}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},tm=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},nm=class e extends em{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new tm,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Jp(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},rm=`di$target`,im=`di$dependencies`,am=new Map;function om(e){return e[im]||[]}function sm(e){if(am.has(e))return am.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);cm(t,e,r)};return t._id=e,am.set(e,t),t}function cm(e,t,n){t[rm]===t?t[im].push({id:e,index:n}):(t[im]=[{id:e,index:n}],t[rm]=t)}var lm=sm(`BufferService`),um=sm(`CoreMouseService`),dm=sm(`CoreService`),fm=sm(`CharsetService`),pm=sm(`InstantiationService`),mm=sm(`LogService`),hm=sm(`OptionsService`),gm=sm(`OscLinkService`),_m=sm(`UnicodeService`),vm=sm(`DecorationService`),ym=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new nm,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):bm(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};ym=Ip([J(0,lm),J(1,hm),J(2,gm)],ym);function bm(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
72
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function $c(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:nl(t,`input`,e.processors),output:nl(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function el(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 el(r.element,n);if(r.type===`set`)return el(r.valueType,n);if(r.type===`lazy`)return el(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 el(r.innerType,n);if(r.type===`intersection`)return el(r.left,n)||el(r.right,n);if(r.type===`record`||r.type===`map`)return el(r.keyType,n)||el(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:el(r.in,n)||el(r.out,n);if(r.type===`object`){for(let e in r.shape)if(el(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(el(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(el(e,n))return!0;return!!(r.rest&&el(r.rest,n))}return!1}var tl=(e,t={})=>n=>{let r=Xc({...n,processors:t});return Zc(e,r),Qc(r,e),$c(r,e)},nl=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Xc({...i??{},target:a,io:t,processors:n});return Zc(e,o),Qc(o,e),$c(o,e)},rl={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},il=(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=rl[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}))])}},al=(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)},ol=(e,t,n,r)=>{n.type=`boolean`},sl=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},cl=(e,t,n,r)=>{n.not={}},ll=(e,t,n,r)=>{let i=e._zod.def,a=Pi(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},ul=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},dl=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},fl=(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=Zc(a.element,t,{...r,path:[...r.path,`items`]})},pl=(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]=Zc(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=Zc(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ml=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Zc(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},hl=(e,t,n,r)=>{let i=e._zod.def,a=Zc(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Zc(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]]},gl=(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=Zc(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=Zc(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Zc(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)}},_l=(e,t,n,r)=>{let i=e._zod.def,a=Zc(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`}]},vl=(e,t,n,r)=>{let i=e._zod.def;Zc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},yl=(e,t,n,r)=>{let i=e._zod.def;Zc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},bl=(e,t,n,r)=>{let i=e._zod.def;Zc(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)))},xl=(e,t,n,r)=>{let i=e._zod.def;Zc(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},Sl=(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;Zc(o,t,r);let s=t.seen.get(e);s.ref=o},Cl=(e,t,n,r)=>{let i=e._zod.def;Zc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},wl=(e,t,n,r)=>{let i=e._zod.def;Zc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Tl=N(`ZodISODateTime`,(e,t)=>{Wo.init(e,t),U.init(e,t)});function El(e){return gc(Tl,e)}var Dl=N(`ZodISODate`,(e,t)=>{Go.init(e,t),U.init(e,t)});function Ol(e){return _c(Dl,e)}var kl=N(`ZodISOTime`,(e,t)=>{Ko.init(e,t),U.init(e,t)});function Al(e){return vc(kl,e)}var jl=N(`ZodISODuration`,(e,t)=>{qo.init(e,t),U.init(e,t)});function Ml(e){return yc(jl,e)}var Nl=N(`ZodError`,(e,t)=>{ha.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>va(e,t)},flatten:{value:t=>_a(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Fi,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Fi,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Pl=ya(Nl),Fl=ba(Nl),Il=xa(Nl),Ll=Ca(Nl),Rl=Ta(Nl),zl=Ea(Nl),Bl=Da(Nl),Vl=Oa(Nl),Hl=ka(Nl),Ul=Aa(Nl),Wl=ja(Nl),Gl=Ma(Nl),Kl=new WeakMap;function R(e,t,n){let r=Object.getPrototypeOf(e),i=Kl.get(r);if(i||(i=new Set,Kl.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 z=N(`ZodType`,(e,t)=>(Ao.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:nl(e,`input`),output:nl(e,`output`)}}),e.toJSONSchema=tl(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Pl(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Il(e,t,n),e.parseAsync=async(t,n)=>Fl(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ll(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Rl(e,t,n),e.decode=(t,n)=>zl(e,t,n),e.encodeAsync=async(t,n)=>Bl(e,t,n),e.decodeAsync=async(t,n)=>Vl(e,t,n),e.safeEncode=(t,n)=>Hl(e,t,n),e.safeDecode=(t,n)=>Ul(e,t,n),e.safeEncodeAsync=async(t,n)=>Wl(e,t,n),e.safeDecodeAsync=async(t,n)=>Gl(e,t,n),R(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Vi(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 Zi(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(id(e,t))},superRefine(e,t){return this.check(ad(e,t))},overwrite(e){return this.check(Bc(e))},optional(){return zu(this)},exactOptional(){return Vu(this)},nullable(){return Uu(this)},nullish(){return zu(Uu(this))},nonoptional(e){return Yu(this,e)},array(){return Tu(this)},or(e){return ku([this,e])},and(e){return ju(this,e)},transform(e){return $u(this,Lu(e))},default(e){return Gu(this,e)},prefault(e){return qu(this,e)},catch(e){return Zu(this,e)},pipe(e){return $u(this,e)},readonly(){return nd(this)},describe(e){let t=this.clone();return Ks.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ks.get(this);let t=this.clone();return Ks.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 Ks.get(e)?.description},configurable:!0}),e)),B=N(`_ZodString`,(e,t)=>{jo.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>il(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,R(e,`_ZodString`,{regex(...e){return this.check(Pc(...e))},includes(...e){return this.check(Lc(...e))},startsWith(...e){return this.check(Rc(...e))},endsWith(...e){return this.check(zc(...e))},min(...e){return this.check(Mc(...e))},max(...e){return this.check(jc(...e))},length(...e){return this.check(Nc(...e))},nonempty(...e){return this.check(Mc(1,...e))},lowercase(e){return this.check(Fc(e))},uppercase(e){return this.check(Ic(e))},trim(){return this.check(Hc())},normalize(...e){return this.check(Vc(...e))},toLowerCase(){return this.check(Uc())},toUpperCase(){return this.check(Wc())},slugify(){return this.check(Gc())}})}),V=N(`ZodString`,(e,t)=>{jo.init(e,t),B.init(e,t),e.email=t=>e.check(Js(ql,t)),e.url=t=>e.check(ec(Xl,t)),e.jwt=t=>e.check(hc(du,t)),e.emoji=t=>e.check(tc(Zl,t)),e.guid=t=>e.check(Ys(Jl,t)),e.uuid=t=>e.check(Xs(Yl,t)),e.uuidv4=t=>e.check(Zs(Yl,t)),e.uuidv6=t=>e.check(Qs(Yl,t)),e.uuidv7=t=>e.check($s(Yl,t)),e.nanoid=t=>e.check(nc(Ql,t)),e.guid=t=>e.check(Ys(Jl,t)),e.cuid=t=>e.check(rc($l,t)),e.cuid2=t=>e.check(ic(eu,t)),e.ulid=t=>e.check(ac(tu,t)),e.base64=t=>e.check(fc(cu,t)),e.base64url=t=>e.check(pc(lu,t)),e.xid=t=>e.check(oc(nu,t)),e.ksuid=t=>e.check(sc(ru,t)),e.ipv4=t=>e.check(cc(iu,t)),e.ipv6=t=>e.check(lc(au,t)),e.cidrv4=t=>e.check(uc(ou,t)),e.cidrv6=t=>e.check(dc(su,t)),e.e164=t=>e.check(mc(uu,t)),e.datetime=t=>e.check(El(t)),e.date=t=>e.check(Ol(t)),e.time=t=>e.check(Al(t)),e.duration=t=>e.check(Ml(t))});function H(e){return qs(V,e)}var U=N(`ZodStringFormat`,(e,t)=>{Mo.init(e,t),B.init(e,t)}),ql=N(`ZodEmail`,(e,t)=>{Fo.init(e,t),U.init(e,t)}),Jl=N(`ZodGUID`,(e,t)=>{No.init(e,t),U.init(e,t)}),Yl=N(`ZodUUID`,(e,t)=>{Po.init(e,t),U.init(e,t)}),Xl=N(`ZodURL`,(e,t)=>{Io.init(e,t),U.init(e,t)}),Zl=N(`ZodEmoji`,(e,t)=>{Lo.init(e,t),U.init(e,t)}),Ql=N(`ZodNanoID`,(e,t)=>{Ro.init(e,t),U.init(e,t)}),$l=N(`ZodCUID`,(e,t)=>{zo.init(e,t),U.init(e,t)}),eu=N(`ZodCUID2`,(e,t)=>{Bo.init(e,t),U.init(e,t)}),tu=N(`ZodULID`,(e,t)=>{Vo.init(e,t),U.init(e,t)}),nu=N(`ZodXID`,(e,t)=>{Ho.init(e,t),U.init(e,t)}),ru=N(`ZodKSUID`,(e,t)=>{Uo.init(e,t),U.init(e,t)}),iu=N(`ZodIPv4`,(e,t)=>{Jo.init(e,t),U.init(e,t)}),au=N(`ZodIPv6`,(e,t)=>{Yo.init(e,t),U.init(e,t)}),ou=N(`ZodCIDRv4`,(e,t)=>{Xo.init(e,t),U.init(e,t)}),su=N(`ZodCIDRv6`,(e,t)=>{Zo.init(e,t),U.init(e,t)}),cu=N(`ZodBase64`,(e,t)=>{$o.init(e,t),U.init(e,t)}),lu=N(`ZodBase64URL`,(e,t)=>{ts.init(e,t),U.init(e,t)}),uu=N(`ZodE164`,(e,t)=>{ns.init(e,t),U.init(e,t)}),du=N(`ZodJWT`,(e,t)=>{is.init(e,t),U.init(e,t)}),fu=N(`ZodNumber`,(e,t)=>{as.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>al(e,t,n,r),R(e,`ZodNumber`,{gt(e,t){return this.check(Oc(e,t))},gte(e,t){return this.check(kc(e,t))},min(e,t){return this.check(kc(e,t))},lt(e,t){return this.check(Ec(e,t))},lte(e,t){return this.check(Dc(e,t))},max(e,t){return this.check(Dc(e,t))},int(e){return this.check(hu(e))},safe(e){return this.check(hu(e))},positive(e){return this.check(Oc(0,e))},nonnegative(e){return this.check(kc(0,e))},negative(e){return this.check(Ec(0,e))},nonpositive(e){return this.check(Dc(0,e))},multipleOf(e,t){return this.check(Ac(e,t))},step(e,t){return this.check(Ac(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 pu(e){return bc(fu,e)}var mu=N(`ZodNumberFormat`,(e,t)=>{os.init(e,t),fu.init(e,t)});function hu(e){return xc(mu,e)}var gu=N(`ZodBoolean`,(e,t)=>{ss.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ol(e,t,n,r)});function _u(e){return Sc(gu,e)}var vu=N(`ZodNull`,(e,t)=>{cs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sl(e,t,n,r)});function yu(e){return Cc(vu,e)}var bu=N(`ZodUnknown`,(e,t)=>{ls.init(e,t),z.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function xu(){return wc(bu)}var Su=N(`ZodNever`,(e,t)=>{us.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cl(e,t,n,r)});function Cu(e){return Tc(Su,e)}var wu=N(`ZodArray`,(e,t)=>{fs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fl(e,t,n,r),e.element=t.element,R(e,`ZodArray`,{min(e,t){return this.check(Mc(e,t))},nonempty(e){return this.check(Mc(1,e))},max(e,t){return this.check(jc(e,t))},length(e,t){return this.check(Nc(e,t))},unwrap(){return this.element}})});function Tu(e,t){return Kc(wu,e,t)}var Eu=N(`ZodObject`,(e,t)=>{_s.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pl(e,t,n,r),F(e,`shape`,()=>t.shape),R(e,`ZodObject`,{keyof(){return Fu(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:xu()})},loose(){return this.clone({...this._zod.def,catchall:xu()})},strict(){return this.clone({...this._zod.def,catchall:Cu()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return na(this,e)},safeExtend(e){return ra(this,e)},merge(e){return ia(this,e)},pick(e){return ea(this,e)},omit(e){return ta(this,e)},partial(...e){return aa(Ru,this,e[0])},required(...e){return oa(Ju,this,e[0])}})});function Du(e,t){return new Eu({type:`object`,shape:e??{},...I(t)})}var Ou=N(`ZodUnion`,(e,t)=>{ys.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ml(e,t,n,r),e.options=t.options});function ku(e,t){return new Ou({type:`union`,options:e,...I(t)})}var Au=N(`ZodIntersection`,(e,t)=>{bs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hl(e,t,n,r)});function ju(e,t){return new Au({type:`intersection`,left:e,right:t})}var Mu=N(`ZodRecord`,(e,t)=>{Cs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gl(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Nu(e,t,n){let r=Zi(e);return r._zod.values=void 0,new Mu({type:`record`,keyType:r,valueType:t,...I(n)})}var Pu=N(`ZodEnum`,(e,t)=>{ws.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ll(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 Pu({...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 Pu({...t,checks:[],...I(r),entries:i})}});function Fu(e,t){return new Pu({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...I(t)})}var Iu=N(`ZodTransform`,(e,t)=>{Ts.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dl(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ji(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(pa(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(pa(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 Lu(e){return new Iu({type:`transform`,transform:e})}var Ru=N(`ZodOptional`,(e,t)=>{Ds.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zu(e){return new Ru({type:`optional`,innerType:e})}var Bu=N(`ZodExactOptional`,(e,t)=>{Os.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vu(e){return new Bu({type:`optional`,innerType:e})}var Hu=N(`ZodNullable`,(e,t)=>{ks.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_l(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uu(e){return new Hu({type:`nullable`,innerType:e})}var Wu=N(`ZodDefault`,(e,t)=>{As.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Gu(e,t){return new Wu({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ji(t)}})}var Ku=N(`ZodPrefault`,(e,t)=>{Ms.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function qu(e,t){return new Ku({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ji(t)}})}var Ju=N(`ZodNonOptional`,(e,t)=>{Ns.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yu(e,t){return new Ju({type:`nonoptional`,innerType:e,...I(t)})}var Xu=N(`ZodCatch`,(e,t)=>{Fs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Zu(e,t){return new Xu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Qu=N(`ZodPipe`,(e,t)=>{Is.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sl(e,t,n,r),e.in=t.in,e.out=t.out});function $u(e,t){return new Qu({type:`pipe`,in:e,out:t})}var ed=N(`ZodPreprocess`,(e,t)=>{Qu.init(e,t),Rs.init(e,t)}),td=N(`ZodReadonly`,(e,t)=>{zs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nd(e){return new td({type:`readonly`,innerType:e})}var rd=N(`ZodCustom`,(e,t)=>{Vs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ul(e,t,n,r)});function id(e,t={}){return qc(rd,e,t)}function ad(e,t){return Jc(e,t)}function od(e,t){return new ed({type:`pipe`,in:Lu(e),out:t})}var sd=Fu([`ideation`,`spec`,`tickets`,`implementation`,`review`,`shipped`]),cd=Fu([`full`,`collapsed`]),ld=Fu([`pending`,`burning`,`done`,`failed`,`cancelled`]),ud=Fu([`ideation`,`qa`,`waypoint`,`converge`,`revisit`]),dd=Fu([`running`,`succeeded`,`failed`,`cancelled`]),fd=Fu([`active`,`shipped`]),pd=Fu([`launching`,`live`,`ended`]);Du({title:H(),goal:H(),context:H(),acceptanceCriteria:Tu(H()),seams:Tu(H()),blockedBy:Tu(pu())}).extend({id:H(),featureId:H(),seq:pu(),status:ld,commits:Tu(H()),error:H().optional()});var md=Fu([`grilling`,`research`,`prototype`,`task`]),hd=Fu([`open`,`claimed`,`resolved`,`dropped`]);Fu([`resolved`,`dropped`]),Du({title:H(),type:md,question:H(),blockedBy:Tu(ku([pu(),H()])),originWaypointId:H().optional()}).extend({id:H(),featureId:H(),seq:pu(),blockedBy:Tu(pu()),status:hd,claimedBy:H().optional(),lastSessionId:H().optional(),summary:H().optional()}),Du({id:H(),name:H(),repoPath:H(),mainBranch:H(),devCommand:H().optional(),model:H().optional()}),Du({id:H(),projectId:H(),slug:H(),title:H(),oneLiner:H(),size:cd,mapped:_u(),phase:sd,branch:H(),baseBranch:H().optional(),status:fd,createdAt:pu()}),Du({id:H(),featureId:H(),kind:ud,ccSessionId:H().optional(),transcriptPath:H().optional(),status:pd,worktreePath:H()}),Du({id:H(),featureId:H(),workflow:H(),status:dd,startedAt:pu(),endedAt:pu().optional(),summary:H().optional()});var gd=Fu([`env`,`project`,`file`,`default`]),_d=Fu([`global`,`project`]),vd=Du({key:H(),value:xu(),source:gd,editable:_u(),restartRequired:_u(),scope:_d});Du({projectId:H().optional(),fields:Tu(vd)}),Du({projectId:H().optional(),key:H(),value:ku([H(),pu(),_u(),yu()])}),Du({id:pu(),projectId:H(),featureId:H().optional(),runId:H().optional(),ticketId:H().optional(),ts:pu(),type:H(),message:H(),data:xu().optional()});var yd=[{phase:`ideation`},{phase:`spec`,gateToEnter:{id:`G1`,description:`Decisions captured before writing a spec`,check:`decisions-file-exists`}},{phase:`tickets`,gateToEnter:{id:`G2`,description:`Spec written before breaking into tickets (auto-satisfied for collapsed features)`,check:`spec-file-exists`}},{phase:`implementation`,gateToEnter:{id:`G3`,description:`Tickets approved by a human (the Burn click)`,check:`tickets-approved`}},{phase:`review`,gateToEnter:{id:`G4`,description:`Every ticket reached a terminal state`,check:`all-tickets-terminal`}},{phase:`shipped`,gateToEnter:{id:`G5`,description:`Human merged the feature branch (the Merge click)`,check:`human-merge`}}].map(e=>e.phase);function bd(e){let t=yd.indexOf(e.phase);if(t<0||t>=yd.length-1)return null;let n=yd[t+1];return e.size===`collapsed`&&n===`spec`?yd[t+2]??null:n}var W=Symbol.for(`drizzle:entityKind`);function xd(e,t){if(!e||typeof e!=`object`)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,W))throw Error(`Class "${t.name??`<unknown>`}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let n=Object.getPrototypeOf(e).constructor;if(n)for(;n;){if(W in n&&n[W]===t[W])return!0;n=Object.getPrototypeOf(n)}return!1}var Sd=class{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}static[W]=`Column`;name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!==`byDefault`}},Cd=class{static[W]=`ColumnBuilder`;config;constructor(e,t,n){this.config={name:e,keyAsName:e===``,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:n,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){this.config.name===``&&(this.config.name=e)}},wd=Symbol.for(`drizzle:Name`),Td=Symbol.for(`drizzle:isPgEnum`);function Ed(e){return!!e&&typeof e==`function`&&Td in e&&e[Td]===!0}var G=class{static[W]=`Subquery`;constructor(e,t,n,r=!1,i=[]){this._={brand:`Subquery`,sql:e,selectedFields:t,alias:n,isWith:r,usedTables:i}}},Dd={startActiveSpan(e,t){return t()}},Od=Symbol.for(`drizzle:ViewBaseConfig`),kd=Symbol.for(`drizzle:Schema`),Ad=Symbol.for(`drizzle:Columns`),jd=Symbol.for(`drizzle:ExtraConfigColumns`),Md=Symbol.for(`drizzle:OriginalName`),Nd=Symbol.for(`drizzle:BaseName`),Pd=Symbol.for(`drizzle:IsAlias`),Fd=Symbol.for(`drizzle:ExtraConfigBuilder`),Id=Symbol.for(`drizzle:IsDrizzleTable`),Ld=class{static[W]=`Table`;static Symbol={Name:wd,Schema:kd,OriginalName:Md,Columns:Ad,ExtraConfigColumns:jd,BaseName:Nd,IsAlias:Pd,ExtraConfigBuilder:Fd};[wd];[Md];[kd];[Ad];[jd];[Nd];[Pd]=!1;[Id]=!0;[Fd]=void 0;constructor(e,t,n){this[wd]=this[Md]=e,this[kd]=t,this[Nd]=n}};function Rd(e){return e!=null&&typeof e.getSQL==`function`}function zd(e){let t={sql:``,params:[]};for(let n of e)t.sql+=n.sql,t.params.push(...n.params),n.typings?.length&&(t.typings||=[],t.typings.push(...n.typings));return t}var K=class{static[W]=`StringChunk`;value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new Bd([this])}},Bd=class e{constructor(e){this.queryChunks=e;for(let t of e)if(xd(t,Ld)){let e=t[Ld.Symbol.Schema];this.usedTables.push(e===void 0?t[Ld.Symbol.Name]:e+`.`+t[Ld.Symbol.Name])}}static[W]=`SQL`;decoder=Hd;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return Dd.startActiveSpan(`drizzle.buildSQL`,t=>{let n=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(t,n){let r=Object.assign({},n,{inlineParams:n.inlineParams||this.shouldInlineParams,paramStartIndex:n.paramStartIndex||{value:0}}),{casing:i,escapeName:a,escapeParam:o,prepareTyping:s,inlineParams:c,paramStartIndex:l}=r;return zd(t.map(t=>{if(xd(t,K))return{sql:t.value.join(``),params:[]};if(xd(t,Vd))return{sql:a(t.value),params:[]};if(t===void 0)return{sql:``,params:[]};if(Array.isArray(t)){let e=[new K(`(`)];for(let[n,r]of t.entries())e.push(r),n<t.length-1&&e.push(new K(`, `));return e.push(new K(`)`)),this.buildQueryFromSourceParams(e,r)}if(xd(t,e))return this.buildQueryFromSourceParams(t.queryChunks,{...r,inlineParams:c||t.shouldInlineParams});if(xd(t,Ld)){let e=t[Ld.Symbol.Schema],n=t[Ld.Symbol.Name];return{sql:e===void 0||t[Pd]?a(n):a(e)+`.`+a(n),params:[]}}if(xd(t,Sd)){let e=i.getColumnCasing(t);if(n.invokeSource===`indexes`)return{sql:a(e),params:[]};let r=t.table[Ld.Symbol.Schema];return{sql:t.table[Pd]||r===void 0?a(t.table[Ld.Symbol.Name])+`.`+a(e):a(r)+`.`+a(t.table[Ld.Symbol.Name])+`.`+a(e),params:[]}}if(xd(t,Jd)){let e=t[Od].schema,n=t[Od].name;return{sql:e===void 0||t[Od].isAlias?a(n):a(e)+`.`+a(n),params:[]}}if(xd(t,Wd)){if(xd(t.value,Kd))return{sql:o(l.value++,t),params:[t],typings:[`none`]};let n=t.value===null?null:t.encoder.mapToDriverValue(t.value);if(xd(n,e))return this.buildQueryFromSourceParams([n],r);if(c)return{sql:this.mapInlineParam(n,r),params:[]};let i=[`none`];return s&&(i=[s(t.encoder)]),{sql:o(l.value++,n),params:[n],typings:i}}return xd(t,Kd)?{sql:o(l.value++,t),params:[t],typings:[`none`]}:xd(t,e.Aliased)&&t.fieldAlias!==void 0?{sql:a(t.fieldAlias),params:[]}:xd(t,G)?t._.isWith?{sql:a(t._.alias),params:[]}:this.buildQueryFromSourceParams([new K(`(`),t._.sql,new K(`) `),new Vd(t._.alias)],r):Ed(t)?t.schema?{sql:a(t.schema)+`.`+a(t.enumName),params:[]}:{sql:a(t.enumName),params:[]}:Rd(t)?t.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([t.getSQL()],r):this.buildQueryFromSourceParams([new K(`(`),t.getSQL(),new K(`)`)],r):c?{sql:this.mapInlineParam(t,r),params:[]}:{sql:o(l.value++,t),params:[t],typings:[`none`]}}))}mapInlineParam(e,{escapeString:t}){if(e===null)return`null`;if(typeof e==`number`||typeof e==`boolean`)return e.toString();if(typeof e==`string`)return t(e);if(typeof e==`object`){let n=e.toString();return t(n===`[object Object]`?JSON.stringify(e):n)}throw Error(`Unexpected param value: `+e)}getSQL(){return this}as(t){return t===void 0?this:new e.Aliased(this,t)}mapWith(e){return this.decoder=typeof e==`function`?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}},Vd=class{constructor(e){this.value=e}static[W]=`Name`;brand;getSQL(){return new Bd([this])}},Hd={mapFromDriverValue:e=>e},Ud={mapToDriverValue:e=>e};({...Hd,...Ud});var Wd=class{constructor(e,t=Ud){this.value=e,this.encoder=t}static[W]=`Param`;brand;getSQL(){return new Bd([this])}};function Gd(e,...t){let n=[];(t.length>0||e.length>0&&e[0]!==``)&&n.push(new K(e[0]));for(let[r,i]of t.entries())n.push(i,new K(e[r+1]));return new Bd(n)}(e=>{function t(){return new Bd([])}e.empty=t;function n(e){return new Bd(e)}e.fromList=n;function r(e){return new Bd([new K(e)])}e.raw=r;function i(e,t){let n=[];for(let[r,i]of e.entries())r>0&&t!==void 0&&n.push(t),n.push(i);return new Bd(n)}e.join=i;function a(e){return new Vd(e)}e.identifier=a;function o(e){return new Kd(e)}e.placeholder=o;function s(e,t){return new Wd(e,t)}e.param=s})(Gd||={}),(e=>{class t{constructor(e,t){this.sql=e,this.fieldAlias=t}static[W]=`SQL.Aliased`;isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(Bd||={});var Kd=class{constructor(e){this.name=e}static[W]=`Placeholder`;getSQL(){return new Bd([this])}},qd=Symbol.for(`drizzle:IsDrizzleView`),Jd=class{static[W]=`View`;[Od];[qd]=!0;constructor({name:e,schema:t,selectedFields:n,query:r}){this[Od]={name:e,originalName:e,schema:t,selectedFields:n,query:r,isExisting:!r,isAlias:!1}}getSQL(){return new Bd([this])}};Sd.prototype.getSQL=function(){return new Bd([this])},Ld.prototype.getSQL=function(){return new Bd([this])},G.prototype.getSQL=function(){return new Bd([this])};function Yd(e,t){return{name:typeof e==`string`&&e.length>0?e:``,config:typeof e==`object`?e:t}}var Xd=typeof TextDecoder>`u`?null:new TextDecoder,Zd=class{static[W]=`SQLiteForeignKeyBuilder`;reference;_onUpdate;_onDelete;constructor(e,t){this.reference=()=>{let{name:t,columns:n,foreignColumns:r}=e();return{name:t,columns:n,foreignTable:r[0].table,foreignColumns:r}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete)}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new Qd(e,this)}},Qd=class{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[W]=`SQLiteForeignKey`;reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),r=t.map(e=>e.name),i=n.map(e=>e.name),a=[this.table[wd],...r,n[0].table[wd],...i];return e??`${a.join(`_`)}_fk`}};function $d(e,t){return`${e[wd]}_${t.join(`_`)}_unique`}var ef=class extends Cd{static[W]=`SQLiteColumnBuilder`;foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:`always`,mode:t?.mode??`virtual`},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:r})=>((n,r)=>{let i=new Zd(()=>{let t=n();return{columns:[e],foreignColumns:[t]}});return r.onUpdate&&i.onUpdate(r.onUpdate),r.onDelete&&i.onDelete(r.onDelete),i.build(t)})(n,r))}},tf=class extends Sd{constructor(e,t){t.uniqueName||=$d(e,[t.name]),super(e,t),this.table=e}static[W]=`SQLiteColumn`},nf=class extends ef{static[W]=`SQLiteBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteBigInt`)}build(e){return new rf(e,this.config)}},rf=class extends tf{static[W]=`SQLiteBigInt`;getSQLType(){return`blob`}mapFromDriverValue(e){if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString(`utf8`))}return BigInt(Xd.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}},af=class extends ef{static[W]=`SQLiteBlobJsonBuilder`;constructor(e){super(e,`json`,`SQLiteBlobJson`)}build(e){return new of(e,this.config)}},of=class extends tf{static[W]=`SQLiteBlobJson`;getSQLType(){return`blob`}mapFromDriverValue(e){if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString(`utf8`))}return JSON.parse(Xd.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}},sf=class extends ef{static[W]=`SQLiteBlobBufferBuilder`;constructor(e){super(e,`buffer`,`SQLiteBlobBuffer`)}build(e){return new cf(e,this.config)}},cf=class extends tf{static[W]=`SQLiteBlobBuffer`;mapFromDriverValue(e){return Buffer.isBuffer(e)?e:Buffer.from(e)}getSQLType(){return`blob`}};function lf(e,t){let{name:n,config:r}=Yd(e,t);return r?.mode===`json`?new af(n):r?.mode===`bigint`?new nf(n):new sf(n)}var uf=class extends ef{static[W]=`SQLiteCustomColumnBuilder`;constructor(e,t,n){super(e,`custom`,`SQLiteCustomColumn`),this.config.fieldConfig=t,this.config.customTypeParams=n}build(e){return new df(e,this.config)}},df=class extends tf{static[W]=`SQLiteCustomColumn`;sqlName;mapTo;mapFrom;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom==`function`?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo==`function`?this.mapTo(e):e}};function ff(e){return(t,n)=>{let{name:r,config:i}=Yd(t,n);return new uf(r,i,e)}}var pf=class extends ef{static[W]=`SQLiteBaseIntegerBuilder`;constructor(e,t,n){super(e,t,n),this.config.autoIncrement=!1}primaryKey(e){return e?.autoIncrement&&(this.config.autoIncrement=!0),this.config.hasDefault=!0,super.primaryKey()}},mf=class extends tf{static[W]=`SQLiteBaseInteger`;autoIncrement=this.config.autoIncrement;getSQLType(){return`integer`}},hf=class extends pf{static[W]=`SQLiteIntegerBuilder`;constructor(e){super(e,`number`,`SQLiteInteger`)}build(e){return new gf(e,this.config)}},gf=class extends mf{static[W]=`SQLiteInteger`},_f=class extends pf{static[W]=`SQLiteTimestampBuilder`;constructor(e,t){super(e,`date`,`SQLiteTimestamp`),this.config.mode=t}defaultNow(){return this.default(Gd`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new vf(e,this.config)}},vf=class extends mf{static[W]=`SQLiteTimestamp`;mode=this.config.mode;mapFromDriverValue(e){return this.config.mode===`timestamp`?new Date(e*1e3):new Date(e)}mapToDriverValue(e){let t=e.getTime();return this.config.mode===`timestamp`?Math.floor(t/1e3):t}},yf=class extends pf{static[W]=`SQLiteBooleanBuilder`;constructor(e,t){super(e,`boolean`,`SQLiteBoolean`),this.config.mode=t}build(e){return new bf(e,this.config)}},bf=class extends mf{static[W]=`SQLiteBoolean`;mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return+!!e}};function xf(e,t){let{name:n,config:r}=Yd(e,t);return r?.mode===`timestamp`||r?.mode===`timestamp_ms`?new _f(n,r.mode):r?.mode===`boolean`?new yf(n,r.mode):new hf(n)}var Sf=class extends ef{static[W]=`SQLiteNumericBuilder`;constructor(e){super(e,`string`,`SQLiteNumeric`)}build(e){return new Cf(e,this.config)}},Cf=class extends tf{static[W]=`SQLiteNumeric`;mapFromDriverValue(e){return typeof e==`string`?e:String(e)}getSQLType(){return`numeric`}},wf=class extends ef{static[W]=`SQLiteNumericNumberBuilder`;constructor(e){super(e,`number`,`SQLiteNumericNumber`)}build(e){return new Tf(e,this.config)}},Tf=class extends tf{static[W]=`SQLiteNumericNumber`;mapFromDriverValue(e){return typeof e==`number`?e:Number(e)}mapToDriverValue=String;getSQLType(){return`numeric`}},Ef=class extends ef{static[W]=`SQLiteNumericBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteNumericBigInt`)}build(e){return new Df(e,this.config)}},Df=class extends tf{static[W]=`SQLiteNumericBigInt`;mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return`numeric`}};function Of(e,t){let{name:n,config:r}=Yd(e,t),i=r?.mode;return i===`number`?new wf(n):i===`bigint`?new Ef(n):new Sf(n)}var kf=class extends ef{static[W]=`SQLiteRealBuilder`;constructor(e){super(e,`number`,`SQLiteReal`)}build(e){return new Af(e,this.config)}},Af=class extends tf{static[W]=`SQLiteReal`;getSQLType(){return`real`}};function jf(e){return new kf(e??``)}var Mf=class extends ef{static[W]=`SQLiteTextBuilder`;constructor(e,t){super(e,`string`,`SQLiteText`),this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new Nf(e,this.config)}},Nf=class extends tf{static[W]=`SQLiteText`;enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:``}`}},Pf=class extends ef{static[W]=`SQLiteTextJsonBuilder`;constructor(e){super(e,`json`,`SQLiteTextJson`)}build(e){return new Ff(e,this.config)}},Ff=class extends tf{static[W]=`SQLiteTextJson`;getSQLType(){return`text`}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}};function q(e,t={}){let{name:n,config:r}=Yd(e,t);return r.mode===`json`?new Pf(n):new Mf(n,r)}function If(){return{blob:lf,customType:ff,integer:xf,numeric:Of,real:jf,text:q}}var Lf=Symbol.for(`drizzle:SQLiteInlineForeignKeys`),Rf=class extends Ld{static[W]=`SQLiteTable`;static Symbol=Object.assign({},Ld.Symbol,{InlineForeignKeys:Lf});[Ld.Symbol.Columns];[Lf]=[];[Ld.Symbol.ExtraConfigBuilder]=void 0};function zf(e,t,n,r,i=e){let a=new Rf(e,r,i),o=typeof t==`function`?t(If()):t,s=Object.fromEntries(Object.entries(o).map(([e,t])=>{let n=t;n.setName(e);let r=n.build(a);return a[Lf].push(...n.buildForeignKeys(r,a)),[e,r]})),c=Object.assign(a,s);return c[Ld.Symbol.Columns]=s,c[Ld.Symbol.ExtraConfigColumns]=s,n&&(c[Rf.Symbol.ExtraConfigBuilder]=n),c}var Bf=(e,t,n)=>zf(e,t,n);Bf(`projects`,{id:q(`id`).primaryKey(),name:q(`name`).notNull(),repoPath:q(`repo_path`).notNull(),mainBranch:q(`main_branch`).notNull(),devCommand:q(`dev_command`),model:q(`model`),sandbox:q(`sandbox`),closedAt:xf(`closed_at`)}),Bf(`features`,{id:q(`id`).primaryKey(),projectId:q(`project_id`).notNull(),slug:q(`slug`).notNull(),title:q(`title`).notNull(),oneLiner:q(`one_liner`).notNull(),size:q(`size`).notNull().$type(),mapped:xf(`mapped`,{mode:`boolean`}).notNull().default(!1),phase:q(`phase`).notNull().$type(),branch:q(`branch`).notNull(),baseBranch:q(`base_branch`),status:q(`status`).notNull().$type(),createdAt:xf(`created_at`).notNull()}),Bf(`sessions`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),kind:q(`kind`).notNull().$type(),ccSessionId:q(`cc_session_id`),transcriptPath:q(`transcript_path`),status:q(`status`).notNull().$type(),worktreePath:q(`worktree_path`).notNull()}),Bf(`tickets`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),seq:xf(`seq`).notNull(),title:q(`title`).notNull(),goal:q(`goal`).notNull(),context:q(`context`).notNull(),acceptanceCriteria:q(`acceptance_criteria`,{mode:`json`}).notNull().$type(),seams:q(`seams`,{mode:`json`}).notNull().$type(),blockedBy:q(`blocked_by`,{mode:`json`}).notNull().$type(),status:q(`status`).notNull().$type(),commits:q(`commits`,{mode:`json`}).notNull().$type(),error:q(`error`)}),Bf(`waypoints`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),seq:xf(`seq`).notNull(),title:q(`title`).notNull(),type:q(`type`).notNull().$type(),question:q(`question`).notNull(),blockedBy:q(`blocked_by`,{mode:`json`}).notNull().$type(),originWaypointId:q(`origin_waypoint_id`),status:q(`status`).notNull().$type(),claimedBy:q(`claimed_by`),lastSessionId:q(`last_session_id`),summary:q(`summary`)}),Bf(`runs`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),workflow:q(`workflow`).notNull(),status:q(`status`).notNull().$type(),startedAt:xf(`started_at`).notNull(),endedAt:xf(`ended_at`),summary:q(`summary`)}),Bf(`events`,{id:xf(`id`).primaryKey({autoIncrement:!0}),projectId:q(`project_id`).notNull(),featureId:q(`feature_id`),runId:q(`run_id`),ticketId:q(`ticket_id`),ts:xf(`ts`).notNull(),type:q(`type`).notNull(),message:q(`message`).notNull(),data:q(`data`,{mode:`json`})}),Bf(`gate_overrides`,{id:xf(`id`).primaryKey({autoIncrement:!0}),featureId:q(`feature_id`).notNull(),gate:q(`gate`).notNull(),reason:q(`reason`).notNull(),ts:xf(`ts`).notNull()});var Vf=[`ideation`,`qa`,`waypoint`,`converge`,`revisit`,`research`,`implement`,`smoke`],Hf=Fu(Vf),Uf=[{id:`claude-opus-4-8`,label:`Opus 4.8`},{id:`claude-sonnet-5`,label:`Sonnet 5`},{id:`claude-haiku-4-5-20251001`,label:`Haiku 4.5`},{id:`claude-fable-5`,label:`Fable 5`}];od(e=>{if(typeof e!=`object`||!e||Array.isArray(e))return e;let t={...e},n=t.smokeModel;if(typeof n==`string`&&n.length>0){let e=typeof t.stepModels==`object`&&t.stepModels!==null&&!Array.isArray(t.stepModels)?t.stepModels:{};e.smoke===void 0&&(t.stepModels={...e,smoke:n})}return delete t.smokeModel,t},Du({serverPort:pu().default(4512),model:H().default(`claude-opus-4-8`),stepModels:Nu(Hf,H()).default({smoke:`claude-haiku-4-5-20251001`}),sandbox:Fu([`docker`,`podman`,`noSandbox`]).default(`docker`),mainBranch:H().default(`main`),sandboxImage:H().optional(),burnConcurrency:pu().int().min(1).max(8).default(3),burnMaxIterations:pu().int().min(1).max(10).default(3),setupCommand:H().optional(),burnWorkspace:Fu([`auto`,`mounted`,`isolated`]).default(`auto`)}));var Wf=[`ideation`,`spec`,`tickets`,`implementation`,`review`,`shipped`];function Gf(e){switch(e){case`ideation`:return`◉`;case`spec`:return`◐`;case`tickets`:return`▤`;case`implementation`:return`⚙`;case`review`:return`◆`;case`shipped`:return`✓`}}function Kf(e){return e.status===`shipped`||e.activeRun?null:e.ticketCounts.failed>0?{kind:`attention`,label:`run failed — needs attention`}:e.phase===`ideation`?{kind:`grill`,label:`needs grilling`}:e.phase===`tickets`&&e.ticketCounts.total>0?{kind:`burn`,label:`review & burn tickets`}:e.phase===`review`?{kind:`ship`,label:`test & merge`}:null}function qf(e){if(e.length!==0)return[...e].sort((e,t)=>t.startedAt-e.startedAt)[0]}var Jf={ideation:`ideation`,spec:`spec`,tickets:`tickets`,implementation:`build`,review:`review`,shipped:`shipped`},Yf={ideation:`Shape the idea in a grill session`,spec:`Write it up as a spec`,tickets:`Break the work into atomic tickets`,implementation:`Burn the tickets into commits`,review:`Test-drive the branch, then merge`,shipped:`Merged to the main branch`};function Xf(e){return Wf.indexOf(e)}function Zf(e){return e.size===`collapsed`}function Qf(e){return e.status===`shipped`?`shipped`:e.activeRun?`agentWorking`:Kf(e)?`needsYou`:`inProgress`}function $f(e){let t={needsYou:[],agentWorking:[],inProgress:[],shipped:[]};for(let n of e)t[Qf(n)].push(n);return[{key:`needsYou`,label:`Needs you`},{key:`agentWorking`,label:`Agent working`},{key:`inProgress`,label:`In progress`},{key:`shipped`,label:`Shipped`}].map(({key:e,label:n})=>({key:e,label:n,features:t[e]})).filter(e=>e.features.length>0)}function ep(e,t){if(Zf(e)&&t===`spec`)return`skipped`;let n=Xf(e.phase),r=Xf(t);return r<n?`done`:r===n?`current`:`upcoming`}function tp(e){return Wf.map(t=>({phase:t,state:ep(e,t)}))}function np(e,t){return t??e.phase}function rp(e,t){return Xf(t)<Xf(e.phase)}function ip(e,t){return Wf.map(n=>{let r=ep(e,n);return{phase:n,label:Jf[n],state:r,isViewed:n===t,clickable:r===`done`||r===`current`,tip:Yf[n]}})}function ap(e,t){let{feature:n,tickets:r,sessions:i,runs:a,gate:o}=e,s=i.find(e=>e.status===`live`),c=r.length,l=r.filter(e=>e.status===`done`).length,u=r.filter(e=>e.status===`failed`).length,d=qf(a),f=d?.status===`running`,p=bd(n),m=!!o.next&&o.satisfied&&o.next.id!==`G3`&&o.next.id!==`G5`,h=p?`Promote to ${Jf[p]}`:`Promote`;switch(n.phase){case`ideation`:return n.mapped?{kick:`MAP`,title:o.satisfied?`Converge the map`:`Work the frontier`,desc:o.satisfied?`Every waypoint is resolved — converge to draft the spec and tickets.`:o.reason??`Resolve the open waypoints; converge once the frontier clears.`,primary:s?{label:`Jump to grill`,kind:`openGrill`}:void 0,secondary:[],busy:!1}:m?{kick:`NEXT STEP`,title:`Promote the idea`,desc:`Decisions are captured — promote the idea when it feels concrete.`,primary:{label:h,kind:`advance`},secondary:s?[{label:`Back to grill`,kind:`openGrill`}]:[],busy:!1}:s?{kick:`GRILL LIVE`,title:`Grill session in progress`,desc:`Shape the idea with Claude — decisions accumulate in Knowledge.`,primary:{label:`Jump to grill`,kind:`openGrill`},secondary:[],busy:!1}:{kick:`NEXT STEP`,title:`Shape the idea with Claude`,desc:`Launch a grill session to shape the idea before any code is written.`,primary:{label:`Start grill session`,kind:`startGrill`},secondary:[],busy:!1};case`spec`:return m?{kick:`NEXT STEP`,title:`Approve the spec`,desc:`The spec is written — approve it to move into tickets.`,primary:{label:`Approve spec → tickets`,kind:`advance`},secondary:s?[{label:`Back to grill`,kind:`openGrill`}]:[],busy:!1}:s?{kick:`GRILL LIVE`,title:`Writing the spec`,desc:`The spec takes shape beside the conversation.`,primary:{label:`Jump to grill`,kind:`openGrill`},secondary:[],busy:!1}:{kick:`NEXT STEP`,title:`Write the spec`,desc:`No spec yet — resume the grill to draft it.`,primary:{label:`Resume grill`,kind:`startGrill`},secondary:[],busy:!1};case`tickets`:return c>0?{kick:`NEXT STEP`,title:`Review & burn the tickets`,desc:`Each ticket is one atomic task Claude will implement. Review them, then burn.`,primary:{label:`Burn ${c} ticket${c===1?``:`s`}`,kind:`burn`},secondary:s?[{label:`Back to grill`,kind:`openGrill`}]:[{label:`Revisit`,kind:`revisit`}],busy:!1}:{kick:`WAITING`,title:`Waiting for tickets`,desc:`No tickets yet — a grill session emits them. Open a session to shape the work.`,primary:s?{label:`Jump to grill`,kind:`openGrill`}:{label:`Open grill to emit tickets`,kind:`startGrill`},secondary:[],busy:!1};case`implementation`:return f?{kick:`IN PROGRESS`,title:`Burning tickets`,desc:`Burning ${c} ticket${c===1?``:`s`} — ${l} done${u?`, ${u} failed`:``}.`,primary:{label:`Cancel run`,kind:`cancelRun`,danger:!0},secondary:[],busy:!0}:{kick:`NEXT STEP`,title:`Resume the burn`,desc:d?.status===`failed`?`The run failed — resume the burn to retry.`:d?.status===`cancelled`?`The run was cancelled — resume the burn to continue.`:`The burn has not started — resume to run the tickets.`,primary:{label:`Resume burn`,kind:`burn`},secondary:s?[]:[{label:`Revisit`,kind:`revisit`}],busy:!1};case`review`:{let e=t.driving?`Test-driving the branch — merge when it looks right.`:u>0?`Run finished with ${u} failed ticket${u===1?``:`s`} — review, then ship.`:`Checks are in. Test-drive the branch, then merge to ship.`;return{kick:`NEXT STEP`,title:t.driving?`Merge when it looks right`:`Test drive, then ship`,desc:e,primary:{label:`Merge & ship`,kind:`merge`},secondary:t.driving?[{label:`Stop test drive`,kind:`testDriveStop`}]:[{label:`Start test drive`,kind:`testDriveStart`}],busy:!1}}case`shipped`:return{kick:`SHIPPED`,title:`Shipped to main`,desc:`The branch is merged and the pipeline is complete. Ask a question anytime.`,primary:void 0,secondary:[{label:`Ask a question`,kind:`askQuestions`}],busy:!1}}}function op({projectId:e,selectedFeatureId:t,onSelect:n,onNewFeature:r}){let i=j.feature.list.useQuery({projectId:e},{refetchInterval:1500}),a=$f(i.data??[]);return(0,O.jsxs)(`nav`,{className:`sidebar`,children:[(0,O.jsxs)(`div`,{className:`sidebar-head`,children:[(0,O.jsx)(`span`,{className:`pane-title`,children:`Features`}),(0,O.jsx)(`button`,{className:`new-btn`,onClick:r,children:`+ New`})]}),(0,O.jsxs)(`div`,{className:`sidebar-list`,children:[i.isLoading&&(0,O.jsx)(`div`,{style:{padding:`10px 8px`},children:(0,O.jsx)(M,{children:`loading features…`})}),i.data&&i.data.length===0&&(0,O.jsx)(`div`,{style:{padding:`10px 8px`},children:(0,O.jsx)(M,{children:`no features yet — + New to begin`})}),a.map(e=>(0,O.jsxs)(`div`,{className:`triage-group triage-${e.key}`,children:[(0,O.jsxs)(`div`,{className:`triage-label`,children:[(0,O.jsx)(`span`,{className:`triage-name`,children:e.label}),(0,O.jsx)(`span`,{className:`triage-count`,children:e.features.length})]}),e.features.map(e=>(0,O.jsx)(sp,{f:e,active:e.id===t,onSelect:n},e.id))]},e.key))]}),(0,O.jsx)(`div`,{className:`sidebar-foot`,children:`Every feature moves through the same six-phase pipeline. Amber means it's waiting on you.`})]})}function sp({f:e,active:t,onSelect:n}){let r=Kf(e),i=tp(e);return(0,O.jsxs)(`button`,{className:`feature-row${t?` is-active`:``}${e.status===`shipped`?` is-shipped`:``}`,onClick:()=>n(e.id),title:e.title,children:[(0,O.jsx)(`span`,{className:`feature-glyph phase-fg-${e.phase}`,children:Gf(e.phase)}),(0,O.jsx)(`span`,{className:`feature-slug mono`,children:e.slug}),(0,O.jsx)(`span`,{className:`feature-flag`,children:e.activeRun?(0,O.jsx)(`span`,{className:`spin-ring`,title:`agent working`}):e.status===`shipped`?(0,O.jsx)(`span`,{className:`mini-check`,children:`✓`}):(0,O.jsxs)(O.Fragment,{children:[r&&(0,O.jsx)(`span`,{className:`needs-dot needs-${r.kind}`,title:r.label}),(0,O.jsx)(`span`,{className:`mini-map`,children:i.map((e,t)=>(0,O.jsx)(`span`,{className:`mini-seg is-${e.state}`},t))})]})})]})}var cp=(0,D.createContext)(null);function lp({children:e}){let[t,n]=(0,D.useState)([]),r=(0,D.useCallback)((e,t=`error`)=>{let r=Date.now()+Math.random();n(n=>[...n,{id:r,kind:t,message:e}]),setTimeout(()=>n(e=>e.filter(e=>e.id!==r)),6e3)},[]);return(0,O.jsxs)(cp.Provider,{value:{push:r},children:[e,(0,O.jsx)(`div`,{className:`toasts`,children:t.map(e=>(0,O.jsx)(`div`,{className:`toast toast-${e.kind}`,onClick:()=>n(t=>t.filter(t=>t.id!==e.id)),children:e.message},e.id))})]})}function up(){let e=(0,D.useContext)(cp);if(!e)throw Error(`useToast used outside ToastProvider`);return e}function dp(e){let[t,n]=(0,D.useState)([]),r=t.length?t[t.length-1].id:void 0,i=j.events.list.useQuery({featureId:e,afterId:r},{refetchInterval:1500});return(0,D.useEffect)(()=>{let e=i.data;!e||e.length===0||n(t=>{let n=new Set(t.map(e=>e.id)),r=e.filter(e=>!n.has(e.id));return r.length===0?t:[...t,...r].sort((e,t)=>e.id-t.id)})},[i.data]),t}function fp(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function pp(e){return e.slice(0,7)}function mp(e,t=Date.now()){let n=Math.max(0,Math.floor((t-e)/1e3));if(n<5)return`now`;if(n<60)return`${n}s`;let r=Math.floor(n/60);if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function hp(e,t){let n=Math.max(0,Math.floor((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60;return r>0?`${r}h ${String(i).padStart(2,`0`)}m`:i>0?`${i}m ${String(a).padStart(2,`0`)}s`:`${a}s`}function gp({featureId:e,relPath:t,title:n,onClose:r}){let i=j.docs.read.useQuery({featureId:e,relPath:t});return(0,D.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,O.jsx)(`div`,{className:`peek-backdrop`,onClick:r,children:(0,O.jsxs)(`div`,{className:`peek`,onClick:e=>e.stopPropagation(),children:[(0,O.jsxs)(`div`,{className:`peek-head`,children:[(0,O.jsx)(`span`,{className:`mono peek-path`,children:t}),(0,O.jsx)(`button`,{className:`peek-close`,onClick:r,"aria-label":`Close (Esc)`,children:`✕`})]}),(0,O.jsxs)(`div`,{className:`peek-body mono`,children:[i.isLoading&&(0,O.jsxs)(M,{children:[`loading `,n,`…`]}),i.error&&(0,O.jsxs)(M,{children:[`could not read `,t,`: `,i.error.message]}),i.data&&(0,O.jsx)(`pre`,{className:`peek-pre`,children:i.data.content})]})]})})}function _p({featureId:e}){let t=j.feature.get.useQuery({id:e},{refetchInterval:1500});return t.isLoading?(0,O.jsx)(`aside`,{className:`inspector`,children:(0,O.jsx)(M,{children:`loading…`})}):t.data?(0,O.jsxs)(`aside`,{className:`inspector`,children:[(0,O.jsx)(bp,{featureId:e,gate:t.data.gate}),(0,O.jsx)(Cp,{featureId:e,docs:t.data.docs}),(0,O.jsx)(wp,{featureId:e})]}):(0,O.jsx)(`aside`,{className:`inspector`,children:(0,O.jsx)(M,{children:t.error?.message??`could not load inspector`})})}var vp={G1:`Decisions captured`,G2:`Spec written`,G3:`Tickets approved`,G4:`Run clean`,G5:`Merged`};function yp(e){return e.check===`all-waypoints-terminal`?`Waypoints resolved`:vp[e.id]??e.id}function bp({featureId:e,gate:t}){let n=up(),r=j.useUtils(),[i,a]=(0,D.useState)(!1),[o,s]=(0,D.useState)(``),c=j.feature.overrideGate.useMutation({onSuccess:()=>{s(``),a(!1),r.feature.get.invalidate({id:e}),r.feature.list.invalidate()},onError:e=>n.push(e.message)});return(0,O.jsxs)(`section`,{className:`insp-section`,children:[(0,O.jsx)(`div`,{className:`insp-cap`,children:`Current gate`}),t.next===null?(0,O.jsx)(`div`,{className:`gate-empty`,children:`No gate — this feature is shipped.`}):(0,O.jsx)(xp,{gateId:t.next.id,name:yp(t.next),description:t.next.description,satisfied:t.satisfied,reason:t.reason,open:i,reasonValue:o,pending:c.isPending,onOpen:()=>a(!0),onCancel:()=>{a(!1),s(``)},onReasonChange:s,onApply:()=>c.mutate({featureId:e,gate:t.next.id,reason:o.trim()})})]})}function xp({gateId:e,name:t,description:n,satisfied:r,reason:i,open:a,reasonValue:o,pending:s,onOpen:c,onCancel:l,onReasonChange:u,onApply:d}){return(0,O.jsxs)(`div`,{className:`gate-card`,children:[(0,O.jsxs)(`div`,{className:`gate-idrow`,children:[(0,O.jsx)(`span`,{className:`gate-id`,children:e}),(0,O.jsx)(`span`,{className:`gate-name`,children:t})]}),(0,O.jsx)(`div`,{className:`gate-req`,children:n}),(0,O.jsxs)(`div`,{className:`gate-state ${r?`is-ok`:`is-block`}`,children:[(0,O.jsx)(`span`,{className:`gate-state-dot`}),(0,O.jsx)(`span`,{children:r?`ready to advance`:i??`blocked`})]}),a?(0,O.jsxs)(`div`,{className:`override-form`,children:[(0,O.jsx)(`input`,{className:`override-input`,placeholder:`reason for override`,value:o,autoFocus:!0,onChange:e=>u(e.target.value)}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(Ci,{variant:`solid`,className:`btn-xs`,disabled:!o.trim()||s,onClick:d,children:`Apply`}),(0,O.jsx)(Ci,{variant:`ghost`,className:`btn-xs`,onClick:l,children:`Cancel`})]})]}):(0,O.jsx)(Ci,{variant:`ghost`,className:`btn-xs`,onClick:c,children:`Override with reason…`}),(0,O.jsx)(`div`,{className:`gate-hint`,children:`The highlighted action in the workspace advances this gate.`})]})}function Sp(e){return e.split(/[\\/]/).pop()??e}function Cp({featureId:e,docs:t}){let[n,r]=(0,D.useState)(null);return(0,O.jsxs)(`section`,{className:`insp-section`,children:[(0,O.jsx)(`div`,{className:`insp-cap`,children:`Knowledge`}),t.length===0?(0,O.jsx)(M,{children:`no docs yet`}):(0,O.jsx)(`ul`,{className:`doc-list`,children:t.map(e=>(0,O.jsx)(`li`,{children:(0,O.jsxs)(`button`,{className:`doc-link`,onClick:()=>r({relPath:e.relPath,title:e.title}),children:[(0,O.jsx)(`span`,{className:`doc-title`,children:e.title}),(0,O.jsx)(`span`,{className:`doc-meta`,children:Sp(e.relPath)})]})},e.relPath))}),n&&(0,O.jsx)(gp,{featureId:e,relPath:n.relPath,title:n.title,onClose:()=>r(null)})]})}function wp({featureId:e}){let t=dp(e).slice(-12).reverse();return(0,O.jsxs)(`section`,{className:`insp-section`,children:[(0,O.jsx)(`div`,{className:`insp-cap`,children:`Activity`}),t.length===0?(0,O.jsx)(M,{children:`no activity yet`}):(0,O.jsx)(`div`,{className:`activity-log`,children:t.map(e=>(0,O.jsxs)(`div`,{className:`act-line`,children:[(0,O.jsx)(`span`,{className:`act-time`,children:mp(e.ts)}),(0,O.jsxs)(`div`,{className:`act-body`,children:[(0,O.jsx)(`div`,{className:`act-type`,children:e.type}),(0,O.jsx)(`div`,{className:`act-msg`,children:e.message})]})]},e.id))})]})}var Tp=`docker`,Ep=4512;function Dp({projectId:e,activeFeatureId:t,driving:n,onDriveChange:r}){let i=up(),a=j.useUtils(),o=j.feature.list.useQuery({projectId:e},{refetchInterval:1500}),s=!o.isError&&o.data!==void 0,c=o.data?.find(e=>e.id===t),l=o.data?.filter(e=>e.activeRun).length??0,u=j.feature.testDrive.useMutation({onSuccess:()=>{r(null),n&&a.feature.get.invalidate({id:n.featureId}),a.feature.list.invalidate()},onError:e=>i.push(e.message)});return(0,O.jsxs)(`footer`,{className:`statusbar`,children:[c&&(0,O.jsxs)(`button`,{className:`sb-branch`,onClick:()=>{c&&navigator.clipboard.writeText(c.branch).then(()=>i.push(`copied ${c.branch}`,`info`),()=>i.push(`copy failed`))},title:`copy branch`,children:[`⎇ `,c.branch]}),(0,O.jsxs)(`span`,{className:`sb-item`,children:[`sandbox · `,Tp]}),n&&(0,O.jsxs)(`span`,{className:`sb-driving`,children:[(0,O.jsx)(`span`,{className:`sb-driving-dot`}),`driving `,(0,O.jsx)(`span`,{className:`mono`,children:n.branch}),(0,O.jsx)(`button`,{className:`sb-stop`,disabled:u.isPending,onClick:()=>u.mutate({featureId:n.featureId,action:`stop`}),children:`stop`})]}),(0,O.jsx)(`span`,{className:`sb-spacer`}),(0,O.jsxs)(`span`,{className:`sb-item`,children:[l,` run`,l===1?``:`s`]}),(0,O.jsxs)(`span`,{className:`sb-item sb-health ${s?`is-ok`:`is-down`}`,children:[(0,O.jsx)(`span`,{className:`health-dot`}),`:`,Ep,` `,s?`ok`:`down`]})]})}function Op({featureId:e,sessionId:t}){let n=j.useUtils(),r=up(),i=j.feature.endSession.useMutation({onSuccess:()=>{n.feature.get.invalidate({id:e}),n.feature.list.invalidate(),r.push(`session ended`,`info`)},onError:e=>r.push(e.message)});return(0,O.jsx)(`button`,{type:`button`,className:`btn btn-xs btn-ghost sess-end`,disabled:i.isPending,title:`end this session — recoverable, you can relaunch it`,onClick:()=>i.mutate({sessionId:t}),children:i.isPending?`Ending…`:`End session`})}var kp=class extends D.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[runcastle] boundary caught`,e,t)}render(){return this.state.error?(0,O.jsx)(`div`,{className:`boundary-fallback`,children:(0,O.jsxs)(`span`,{className:`dim-line mono`,children:[this.props.label??`component`,` failed: `,this.state.error.message]})}):this.props.children}},Ap=2,jp=1,Mp=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(Ap,Math.floor(u/e.css.cell.width)),rows:Math.max(jp,Math.floor(l/e.css.cell.height))}}},Np=Object.defineProperty,Pp=Object.getOwnPropertyDescriptor,Fp=(e,t)=>{for(var n in t)Np(e,n,{get:t[n],enumerable:!0})},Ip=(e,t,n,r)=>{for(var i=r>1?void 0:r?Pp(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Np(t,n,i),i},J=(e,t)=>(n,r)=>t(n,r,e),Lp=`Terminal input`,Rp={get:()=>Lp,set:e=>Lp=e},zp=`Too much output to announce, navigate to rows manually to read`,Bp={get:()=>zp,set:e=>zp=e};function Vp(e){return e.replace(/\r?\n/g,`\r`)}function Hp(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function Up(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function Wp(e,t,n,r){e.stopPropagation(),e.clipboardData&&Gp(e.clipboardData.getData(`text/plain`),t,n,r)}function Gp(e,t,n,r){e=Vp(e),e=Hp(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function Kp(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function qp(e,t,n,r,i){Kp(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Jp(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Yp(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var Xp=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},Zp=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},Qp=``,$p=` `,em=class e{constructor(){this.fg=0,this.bg=0,this.extended=new tm}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},tm=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},nm=class e extends em{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new tm,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Jp(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},rm=`di$target`,im=`di$dependencies`,am=new Map;function om(e){return e[im]||[]}function sm(e){if(am.has(e))return am.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);cm(t,e,r)};return t._id=e,am.set(e,t),t}function cm(e,t,n){t[rm]===t?t[im].push({id:e,index:n}):(t[im]=[{id:e,index:n}],t[rm]=t)}var lm=sm(`BufferService`),um=sm(`CoreMouseService`),dm=sm(`CoreService`),fm=sm(`CharsetService`),pm=sm(`InstantiationService`),mm=sm(`LogService`),hm=sm(`OptionsService`),gm=sm(`OscLinkService`),_m=sm(`UnicodeService`),vm=sm(`DecorationService`),ym=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new nm,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):bm(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};ym=Ip([J(0,lm),J(1,hm),J(2,gm)],ym);function bm(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
73
73
|
|
|
74
74
|
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var xm=sm(`CharSizeService`),Sm=sm(`CoreBrowserService`),Cm=sm(`MouseService`),wm=sm(`RenderService`),Tm=sm(`SelectionService`),Em=sm(`CharacterJoinerService`),Dm=sm(`ThemeService`),Om=sm(`LinkProviderService`),km=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Fm.isErrorNoTelemetry(e)?new Fm(e.message+`
|
|
75
75
|
|
package/web/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>runcastle</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-B0l9lJT5.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-JQYIwCj3.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|