slopwaresystems 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +1195 -727
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -594,8 +594,8 @@ var Help = class {
|
|
|
594
594
|
* @param {string} str
|
|
595
595
|
* @returns {number}
|
|
596
596
|
*/
|
|
597
|
-
displayWidth(
|
|
598
|
-
return stripVTControlCharacters(
|
|
597
|
+
displayWidth(str2) {
|
|
598
|
+
return stripVTControlCharacters(str2).length;
|
|
599
599
|
}
|
|
600
600
|
/**
|
|
601
601
|
* Style the title for displaying in the help. Called with 'Usage:', 'Options:', etc.
|
|
@@ -603,11 +603,11 @@ var Help = class {
|
|
|
603
603
|
* @param {string} str
|
|
604
604
|
* @returns {string}
|
|
605
605
|
*/
|
|
606
|
-
styleTitle(
|
|
607
|
-
return
|
|
606
|
+
styleTitle(str2) {
|
|
607
|
+
return str2;
|
|
608
608
|
}
|
|
609
|
-
styleUsage(
|
|
610
|
-
return
|
|
609
|
+
styleUsage(str2) {
|
|
610
|
+
return str2.split(" ").map((word) => {
|
|
611
611
|
if (word === "[options]") return this.styleOptionText(word);
|
|
612
612
|
if (word === "[command]") return this.styleSubcommandText(word);
|
|
613
613
|
if (word[0] === "[" || word[0] === "<")
|
|
@@ -615,46 +615,46 @@ var Help = class {
|
|
|
615
615
|
return this.styleCommandText(word);
|
|
616
616
|
}).join(" ");
|
|
617
617
|
}
|
|
618
|
-
styleCommandDescription(
|
|
619
|
-
return this.styleDescriptionText(
|
|
618
|
+
styleCommandDescription(str2) {
|
|
619
|
+
return this.styleDescriptionText(str2);
|
|
620
620
|
}
|
|
621
|
-
styleOptionDescription(
|
|
622
|
-
return this.styleDescriptionText(
|
|
621
|
+
styleOptionDescription(str2) {
|
|
622
|
+
return this.styleDescriptionText(str2);
|
|
623
623
|
}
|
|
624
|
-
styleSubcommandDescription(
|
|
625
|
-
return this.styleDescriptionText(
|
|
624
|
+
styleSubcommandDescription(str2) {
|
|
625
|
+
return this.styleDescriptionText(str2);
|
|
626
626
|
}
|
|
627
|
-
styleArgumentDescription(
|
|
628
|
-
return this.styleDescriptionText(
|
|
627
|
+
styleArgumentDescription(str2) {
|
|
628
|
+
return this.styleDescriptionText(str2);
|
|
629
629
|
}
|
|
630
|
-
styleDescriptionText(
|
|
631
|
-
return
|
|
630
|
+
styleDescriptionText(str2) {
|
|
631
|
+
return str2;
|
|
632
632
|
}
|
|
633
|
-
styleOptionTerm(
|
|
634
|
-
return this.styleOptionText(
|
|
633
|
+
styleOptionTerm(str2) {
|
|
634
|
+
return this.styleOptionText(str2);
|
|
635
635
|
}
|
|
636
|
-
styleSubcommandTerm(
|
|
637
|
-
return
|
|
636
|
+
styleSubcommandTerm(str2) {
|
|
637
|
+
return str2.split(" ").map((word) => {
|
|
638
638
|
if (word === "[options]") return this.styleOptionText(word);
|
|
639
639
|
if (word[0] === "[" || word[0] === "<")
|
|
640
640
|
return this.styleArgumentText(word);
|
|
641
641
|
return this.styleSubcommandText(word);
|
|
642
642
|
}).join(" ");
|
|
643
643
|
}
|
|
644
|
-
styleArgumentTerm(
|
|
645
|
-
return this.styleArgumentText(
|
|
644
|
+
styleArgumentTerm(str2) {
|
|
645
|
+
return this.styleArgumentText(str2);
|
|
646
646
|
}
|
|
647
|
-
styleOptionText(
|
|
648
|
-
return
|
|
647
|
+
styleOptionText(str2) {
|
|
648
|
+
return str2;
|
|
649
649
|
}
|
|
650
|
-
styleArgumentText(
|
|
651
|
-
return
|
|
650
|
+
styleArgumentText(str2) {
|
|
651
|
+
return str2;
|
|
652
652
|
}
|
|
653
|
-
styleSubcommandText(
|
|
654
|
-
return
|
|
653
|
+
styleSubcommandText(str2) {
|
|
654
|
+
return str2;
|
|
655
655
|
}
|
|
656
|
-
styleCommandText(
|
|
657
|
-
return
|
|
656
|
+
styleCommandText(str2) {
|
|
657
|
+
return str2;
|
|
658
658
|
}
|
|
659
659
|
/**
|
|
660
660
|
* Calculate the pad width from the maximum term length.
|
|
@@ -677,8 +677,8 @@ var Help = class {
|
|
|
677
677
|
* @param {string} str
|
|
678
678
|
* @returns {boolean}
|
|
679
679
|
*/
|
|
680
|
-
preformatted(
|
|
681
|
-
return /\n[^\S\r\n]/.test(
|
|
680
|
+
preformatted(str2) {
|
|
681
|
+
return /\n[^\S\r\n]/.test(str2);
|
|
682
682
|
}
|
|
683
683
|
/**
|
|
684
684
|
* Format the "item", which consists of a term and description. Pad the term and wrap the description, indenting the following lines.
|
|
@@ -724,9 +724,9 @@ ${itemIndentStr}`);
|
|
|
724
724
|
* @param {number} width
|
|
725
725
|
* @returns {string}
|
|
726
726
|
*/
|
|
727
|
-
boxWrap(
|
|
728
|
-
if (width < this.minWidthToWrap) return
|
|
729
|
-
const rawLines =
|
|
727
|
+
boxWrap(str2, width) {
|
|
728
|
+
if (width < this.minWidthToWrap) return str2;
|
|
729
|
+
const rawLines = str2.split(/\r\n|\n/);
|
|
730
730
|
const chunkPattern = /[\s]*[^\s]+/g;
|
|
731
731
|
const wrappedLines = [];
|
|
732
732
|
rawLines.forEach((line) => {
|
|
@@ -1016,9 +1016,9 @@ var DualOptions = class {
|
|
|
1016
1016
|
return option.negate === (negativeValue === value);
|
|
1017
1017
|
}
|
|
1018
1018
|
};
|
|
1019
|
-
function camelcase(
|
|
1020
|
-
return
|
|
1021
|
-
return
|
|
1019
|
+
function camelcase(str2) {
|
|
1020
|
+
return str2.split("-").reduce((str3, word) => {
|
|
1021
|
+
return str3 + word[0].toUpperCase() + word.slice(1);
|
|
1022
1022
|
});
|
|
1023
1023
|
}
|
|
1024
1024
|
function splitOptionFlags(flags) {
|
|
@@ -1178,14 +1178,14 @@ var Command = class _Command extends EventEmitter {
|
|
|
1178
1178
|
this._showSuggestionAfterError = true;
|
|
1179
1179
|
this._savedState = null;
|
|
1180
1180
|
this._outputConfiguration = {
|
|
1181
|
-
writeOut: (
|
|
1182
|
-
writeErr: (
|
|
1183
|
-
outputError: (
|
|
1181
|
+
writeOut: (str2) => process2.stdout.write(str2),
|
|
1182
|
+
writeErr: (str2) => process2.stderr.write(str2),
|
|
1183
|
+
outputError: (str2, write) => write(str2),
|
|
1184
1184
|
getOutHelpWidth: () => process2.stdout.isTTY ? process2.stdout.columns : void 0,
|
|
1185
1185
|
getErrHelpWidth: () => process2.stderr.isTTY ? process2.stderr.columns : void 0,
|
|
1186
1186
|
getOutHasColors: () => useColor() ?? (process2.stdout.isTTY && process2.stdout.hasColors?.()),
|
|
1187
1187
|
getErrHasColors: () => useColor() ?? (process2.stderr.isTTY && process2.stderr.hasColors?.()),
|
|
1188
|
-
stripColor: (
|
|
1188
|
+
stripColor: (str2) => stripVTControlCharacters2(str2)
|
|
1189
1189
|
};
|
|
1190
1190
|
this._hidden = false;
|
|
1191
1191
|
this._helpOption = void 0;
|
|
@@ -2913,18 +2913,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2913
2913
|
* @param {string} [description]
|
|
2914
2914
|
* @return {(this | string | undefined)} `this` command for chaining, or version string if no arguments
|
|
2915
2915
|
*/
|
|
2916
|
-
version(
|
|
2917
|
-
if (
|
|
2918
|
-
this._version =
|
|
2916
|
+
version(str2, flags, description2) {
|
|
2917
|
+
if (str2 === void 0) return this._version;
|
|
2918
|
+
this._version = str2;
|
|
2919
2919
|
flags = flags || "-V, --version";
|
|
2920
2920
|
description2 = description2 || "output the version number";
|
|
2921
2921
|
const versionOption = this.createOption(flags, description2);
|
|
2922
2922
|
this._versionOptionName = versionOption.attributeName();
|
|
2923
2923
|
this._registerOption(versionOption);
|
|
2924
2924
|
this.on("option:" + versionOption.name(), () => {
|
|
2925
|
-
this._outputConfiguration.writeOut(`${
|
|
2925
|
+
this._outputConfiguration.writeOut(`${str2}
|
|
2926
2926
|
`);
|
|
2927
|
-
this._exit(0, "commander.version",
|
|
2927
|
+
this._exit(0, "commander.version", str2);
|
|
2928
2928
|
});
|
|
2929
2929
|
return this;
|
|
2930
2930
|
}
|
|
@@ -2935,10 +2935,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2935
2935
|
* @param {object} [argsDescription]
|
|
2936
2936
|
* @return {(string|Command)}
|
|
2937
2937
|
*/
|
|
2938
|
-
description(
|
|
2939
|
-
if (
|
|
2938
|
+
description(str2, argsDescription) {
|
|
2939
|
+
if (str2 === void 0 && argsDescription === void 0)
|
|
2940
2940
|
return this._description;
|
|
2941
|
-
this._description =
|
|
2941
|
+
this._description = str2;
|
|
2942
2942
|
if (argsDescription) {
|
|
2943
2943
|
this._argsDescription = argsDescription;
|
|
2944
2944
|
}
|
|
@@ -2950,9 +2950,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2950
2950
|
* @param {string} [str]
|
|
2951
2951
|
* @return {(string|Command)}
|
|
2952
2952
|
*/
|
|
2953
|
-
summary(
|
|
2954
|
-
if (
|
|
2955
|
-
this._summary =
|
|
2953
|
+
summary(str2) {
|
|
2954
|
+
if (str2 === void 0) return this._summary;
|
|
2955
|
+
this._summary = str2;
|
|
2956
2956
|
return this;
|
|
2957
2957
|
}
|
|
2958
2958
|
/**
|
|
@@ -3000,8 +3000,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3000
3000
|
* @param {string} [str]
|
|
3001
3001
|
* @return {(string|Command)}
|
|
3002
3002
|
*/
|
|
3003
|
-
usage(
|
|
3004
|
-
if (
|
|
3003
|
+
usage(str2) {
|
|
3004
|
+
if (str2 === void 0) {
|
|
3005
3005
|
if (this._usage) return this._usage;
|
|
3006
3006
|
const args = this.registeredArguments.map((arg) => {
|
|
3007
3007
|
return humanReadableArgName(arg);
|
|
@@ -3012,7 +3012,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3012
3012
|
this.registeredArguments.length ? args : []
|
|
3013
3013
|
).join(" ");
|
|
3014
3014
|
}
|
|
3015
|
-
this._usage =
|
|
3015
|
+
this._usage = str2;
|
|
3016
3016
|
return this;
|
|
3017
3017
|
}
|
|
3018
3018
|
/**
|
|
@@ -3021,9 +3021,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3021
3021
|
* @param {string} [str]
|
|
3022
3022
|
* @return {(string|Command)}
|
|
3023
3023
|
*/
|
|
3024
|
-
name(
|
|
3025
|
-
if (
|
|
3026
|
-
this._name =
|
|
3024
|
+
name(str2) {
|
|
3025
|
+
if (str2 === void 0) return this._name;
|
|
3026
|
+
this._name = str2;
|
|
3027
3027
|
return this;
|
|
3028
3028
|
}
|
|
3029
3029
|
/**
|
|
@@ -3157,17 +3157,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3157
3157
|
let hasColors;
|
|
3158
3158
|
let helpWidth;
|
|
3159
3159
|
if (error62) {
|
|
3160
|
-
baseWrite = (
|
|
3160
|
+
baseWrite = (str2) => this._outputConfiguration.writeErr(str2);
|
|
3161
3161
|
hasColors = this._outputConfiguration.getErrHasColors();
|
|
3162
3162
|
helpWidth = this._outputConfiguration.getErrHelpWidth();
|
|
3163
3163
|
} else {
|
|
3164
|
-
baseWrite = (
|
|
3164
|
+
baseWrite = (str2) => this._outputConfiguration.writeOut(str2);
|
|
3165
3165
|
hasColors = this._outputConfiguration.getOutHasColors();
|
|
3166
3166
|
helpWidth = this._outputConfiguration.getOutHelpWidth();
|
|
3167
3167
|
}
|
|
3168
|
-
const write = (
|
|
3169
|
-
if (!hasColors)
|
|
3170
|
-
return baseWrite(
|
|
3168
|
+
const write = (str2) => {
|
|
3169
|
+
if (!hasColors) str2 = this._outputConfiguration.stripColor(str2);
|
|
3170
|
+
return baseWrite(str2);
|
|
3171
3171
|
};
|
|
3172
3172
|
return { error: error62, write, hasColors, helpWidth };
|
|
3173
3173
|
}
|
|
@@ -3379,13 +3379,13 @@ import { homedir } from "os";
|
|
|
3379
3379
|
import { join } from "path";
|
|
3380
3380
|
|
|
3381
3381
|
// skills/slop-cli.md
|
|
3382
|
-
var slop_cli_default = '---\nname: slop-cli\ndescription: How to use the slop CLI to read and update the task board this repository is linked to. Load when asked to create, update, plan, comment on or finish tasks.\n---\n\n# slop: the board from the terminal\n\nThe repository you are in is linked to a project on Slopware Tasks. Everything a person can do on the board, you can do with `slop`. Add `--json` to any command for machine-readable output.\n\n## Orientation\n\n```bash\nslop status # which project this checkout is linked to\nslop statuses # the board\'s columns (key, label, category)\nslop members # who tasks can be assigned to\nslop task list [--all] [--status <column>] [--assignee me]\nslop task show <KEY> # title, status, severity, assignee, links, plan, description\nslop task history <KEY> # everything that happened to it, in order\n```\n\nTask keys look like `WEB-12`; the bare number works inside the linked project.\n\nA link belongs to the clone: every git worktree of it (including agent sandboxes made with `git worktree add`) is linked without doing anything. On a machine with no browser, `slop login` prints a link and a code; open it on any device.\n\n## Creating and changing tasks\n\n```bash\nslop task create "Short imperative title" -d "What, where, why" -s <low|medium|high|critical> [--status <column>] [-a <email|me|none>]\nslop task update <KEY> [--title \u2026] [-d \u2026] [-s \u2026] [--status \u2026] [-a \u2026]\nslop task move <KEY> "<column label or key>"\nslop task start <KEY> # first "in progress" column\nslop task done <KEY> # first "done" column\nslop task assign <KEY> <email|me|none>\nslop task link <KEY> <url> # a PR, a design, a log; GitHub PRs are recognised\nslop task notes <KEY> [text|-] # the scratchpad under the links: read it, or replace it whole\n\n## Sessions (see the `slop-sessions` skill)\n\n```bash\nslop session start <KEY> # claim: assign me, move to in progress\nslop session wait <KEY> # be live until someone says something; run in the background\nslop session end <KEY>\nslop sessions # who is live on what\nslop threads [--task KEY] [--general] [--unread] # the project\'s threads\nslop thread show <id> | reply <id> "\u2026" | new "Subject" -m "\u2026" [--task KEY]\nslop task ask <KEY> "\u2026" # a new thread about the task, to whoever is live on it\n```\nslop task archive <KEY> # off the board, history kept\n```\n\nDescriptions are Markdown and are shown in full. Long text: `-d -` reads stdin.\n\n## Plans (see the `slop-planning` skill)\n\n```bash\nslop task items <KEY> # the plan, numbered, with notes\nslop task plan <KEY> - <<\'EOF\' # one item per line, appended in order\nInventory the Intercom data model\nWrite the export script\nEOF\nslop task item add <KEY> "title" [-n "note"]\nslop task item done <KEY> <n> # by number from `items`\nslop task item reopen <KEY> <n>\nslop task item note <KEY> <n> "what is true now"\nslop task item rename <KEY> <n> "new title"\nslop task item remove <KEY> <n>\n```\n\n## Projects\n\n```bash\nslop projects\nslop project create "Name" [--key KEY]\nslop project update [--name \u2026] [--description \u2026]\nslop project status add "In review" -c in_progress # columns: add | rename | remove | order\n```\n\n## Rules of the road\n\n- Do not delete tasks you did not create. Archive finished work instead.\n- Keep titles short and imperative; put the reasoning in the description or the plan\'s notes. There is no chat: the plan\'s notes are the running state, the description holds decisions.\n- When you open a pull request for a task, link it.\n';
|
|
3382
|
+
var slop_cli_default = '---\nname: slop-cli\ndescription: How to use the slop CLI to read and update the task board this repository is linked to. Load when asked to create, update, plan, comment on or finish tasks.\n---\n\n# slop: the board from the terminal\n\nThe repository you are in is linked to a project on Slopware Tasks. Everything a person can do on the board, you can do with `slop`. Add `--json` to any command for machine-readable output.\n\n## Orientation\n\n```bash\nslop status # which project this checkout is linked to\nslop statuses # the board\'s columns (key, label, category)\nslop members # who tasks can be assigned to\nslop task list [--all] [--status <column>] [--assignee me]\nslop task show <KEY> # title, status, severity, assignee, links, plan, description\nslop task history <KEY> # everything that happened to it, in order\n```\n\nTask keys look like `WEB-12`; the bare number works inside the linked project.\n\nA link belongs to the clone: every git worktree of it (including agent sandboxes made with `git worktree add`) is linked without doing anything. On a machine with no browser, `slop login` prints a link and a code; open it on any device.\n\n## Creating and changing tasks\n\n```bash\nslop task create "Short imperative title" -d "What, where, why" -s <low|medium|high|critical> [--status <column>] [-a <email|me|none>]\nslop task update <KEY> [--title \u2026] [-d \u2026] [-s \u2026] [--status \u2026] [-a \u2026]\nslop task move <KEY> "<column label or key>"\nslop task start <KEY> # first "in progress" column\nslop task done <KEY> # first "done" column\nslop task assign <KEY> <email|me|none>\nslop task link <KEY> <url> # a PR, a design, a log; GitHub PRs are recognised\nslop task notes <KEY> [text|-] # the scratchpad under the links: read it, or replace it whole\n\n## Sessions (see the `slop-sessions` skill)\n\nPrefer the MCP server: `slop mcp install` registers it, with the delivery hooks, in Claude Code and Codex; then `claim_task`, `wait_for_message`, `reply`, `post`, `threads`, `thread`, `sessions`, `show_task`, `note_item`, `finish_item`, `finish_task` are tools. The commands below do the same from a shell.\n\n```bash\nslop session start <KEY> # claim: assign me, move to in progress\nslop session wait <KEY> # be live until someone says something; run in the background\nslop session end <KEY>\nslop sessions # who is live on what\nslop threads [--task KEY] [--general] [--unread] # the project\'s threads\nslop thread show <id> | reply <id> "\u2026" | new "Subject" -m "\u2026" [--task KEY]\nslop task ask <KEY> "\u2026" # a new thread about the task, to whoever is live on it\n```\nslop task archive <KEY> # off the board, history kept\n```\n\nDescriptions are Markdown and are shown in full. Long text: `-d -` reads stdin.\n\n## Plans (see the `slop-planning` skill)\n\n```bash\nslop task items <KEY> # the plan, numbered, with notes\nslop task plan <KEY> - <<\'EOF\' # one item per line, appended in order\nInventory the Intercom data model\nWrite the export script\nEOF\nslop task item add <KEY> "title" [-n "note"]\nslop task item done <KEY> <n> # by number from `items`\nslop task item reopen <KEY> <n>\nslop task item note <KEY> <n> "what is true now"\nslop task item rename <KEY> <n> "new title"\nslop task item remove <KEY> <n>\n```\n\n## Projects\n\n```bash\nslop projects\nslop project create "Name" [--key KEY]\nslop project update [--name \u2026] [--description \u2026]\nslop project status add "In review" -c in_progress # columns: add | rename | remove | order\n```\n\n## Rules of the road\n\n- Do not delete tasks you did not create. Archive finished work instead.\n- Keep titles short and imperative; put the reasoning in the description or the plan\'s notes. There is no chat: the plan\'s notes are the running state, the description holds decisions.\n- When you open a pull request for a task, link it.\n';
|
|
3383
3383
|
|
|
3384
3384
|
// skills/slop-planning.md
|
|
3385
3385
|
var slop_planning_default = '---\nname: slop-planning\ndescription: How to break long or multi-session work into a plan on its task, keep each item\'s note current, and pick up where you left off. Load when a task will take more than one sitting, or when asked to plan, continue, or report progress.\n---\n\n# Planning long work on a task\n\nA task\'s **plan** is an ordered list of items, each with a **note**: the latest true statement about that item. The plan plus the task\'s timeline is your memory between sessions. Write to it as you work, not at the end.\n\n## Starting\n\n1. Read the task: `slop task show <KEY>`. If it has a plan, read the notes; they are what the last session knew.\n2. If there is no plan, write one. Items are concrete, checkable, and ordered by what unlocks what. Eight to fifteen is typical; more means the task should be split.\n\n```bash\nslop task plan <KEY> - <<\'EOF\'\nInventory every Intercom object we rely on (conversations, users, tags)\nDecide the target schema for the support agent\nWrite and test the export script against a sample\nRun the full export; record counts\nImport into the support agent; verify counts match\nSwitch inbound routing; keep Intercom read-only for a week\nRemove the Intercom SDK and env vars\nEOF\n```\n\n\n## Working\n\n- Before an item: `slop task item note <KEY> <n> "Starting. Approach: \u2026"`\n- As facts arrive, replace the note. Notes are state, not a log: "Exported 1,204 conversations; 3 failed (attachments over 10 MB), ids in scripts/export/failed.json".\n- When an item is done: `slop task item done <KEY> <n>`. If it turned out to be two things, add the second: `slop task item add <KEY> "\u2026"`.\n- Blocked? Put the blocker in the note, then move on to an item that is not blocked. Do not mark blocked items done.\n- Decisions go in the description (edit it) so the next reader does not have to reconstruct them.\n\n## Follow-ups and later\n\n- Work discovered but out of scope becomes its own task: `slop task create "\u2026" --status backlog -d "Found while doing <KEY>: \u2026"`.\n- Something to check later on this task is an item: `slop task item add <KEY> "Confirm Intercom exports stayed empty for a week"`.\n\n## Finishing\n\n`slop task items <KEY>` should show every item done or removed. Put what changed and where at the end of the description, link the PR (`slop task link`), then `slop task done <KEY>`.\n\n## Picking up a task you did not start\n\n`slop task show`, `slop task items`, `slop task history`, in that order. The notes tell you the present; the history tells you how it got there. Then continue from the first item that is not done.\n';
|
|
3386
3386
|
|
|
3387
3387
|
// skills/slop-sessions.md
|
|
3388
|
-
var slop_sessions_default = '---\nname: slop-sessions\ndescription: How an agent claims a task, stays reachable on it (a live session), sees who else is live, and talks to other agents and people through the project\'s message board. Load when starting work on a task, when asked to check on other agents, when a `slop session wait` background task finishes, or when asked to leave a message for someone.\n---\n\n# Sessions and the board\n\nA **session** is you, live on one task. It exists while `slop session wait` is running: when that process ends (you exit, or your thread closes), the session ends with it. Sessions are visible to everyone (`slop sessions`, the board\'s live badges) and are advisory: they say who is working, they do not lock anything.\n\n**Threads** are how agents and people talk across sessions. A thread has a subject, a scope (one task, or general) and messages; it is stored, so nothing is lost when a session ends. **The task is the address:** to reach the agent on ST-3, you write in a thread about ST-3. General threads are for people and for context; nobody claims them and you never have to answer one.\n\n## What wakes you, and what waits\n\n- A message in a thread **about the task you are live on**
|
|
3388
|
+
var slop_sessions_default = '---\nname: slop-sessions\ndescription: How an agent claims a task, stays reachable on it (a live session), sees who else is live, and talks to other agents and people through the project\'s message board. Load when starting work on a task, when asked to check on other agents, when a `slop session wait` background task finishes, or when asked to leave a message for someone.\n---\n\n# Sessions and the board\n\nA **session** is you, live on one task. It exists while `slop session wait` is running: when that process ends (you exit, or your thread closes), the session ends with it. Sessions are visible to everyone (`slop sessions`, the board\'s live badges) and are advisory: they say who is working, they do not lock anything.\n\n**Threads** are how agents and people talk across sessions. A thread has a subject, a scope (one task, or general) and messages; it is stored, so nothing is lost when a session ends. **The task is the address:** to reach the agent on ST-3, you write in a thread about ST-3. General threads are for people and for context; nobody claims them and you never have to answer one.\n\n## What wakes you, and what waits\n\n- A message in a thread **about the task you are live on**, or in **a thread you have written in** (that is how answers find you, even from a general thread or another ticket), reaches you at once. Nothing else does.\n- **Everything else waits.** `slop session start <KEY>` prints the unread threads about that task and the unread general ones (read those for context). `slop threads` lists them any time; `slop thread show <id>` reads one.\n- Your own messages never wake your own waiter.\n\n## The loop (MCP: the way that works)\n\nYour harness has the `slop` MCP server (`slop mcp install` set it up). Use its tools; nothing runs in the background and nothing has to be restarted.\n\n1. **Claim:** `claim_task(task)`. Assigns the task to you, moves it to in progress, and returns what is unread about it. Read that first.\n2. **Work.** Keep the plan\'s notes current with `note_item`, tick with `finish_item`.\n3. **You are live from now on.** `claim_task` holds your session for as long as the harness runs the server. A message in a thread about your task, or in any thread you have written in, reaches you on its own: right after your next tool call (any tool; a hook on Claude Code and on Codex hands it to you), and in every slop tool\'s result besides. There is nothing to poll and nothing to restart. When one arrives, act or answer with `reply(thread, body)` and carry on.\n4. **Nothing to do but wait?** `wait_for_message(task, minutes)` blocks until the next message. Optional; most of the time you just keep working.\n5. **Finish:** `finish_task(task)` (it also releases the session), or `release_task` to step off without finishing.\n\nBoth harnesses also refuse to stop while messages are unread about your task (a Stop hook), so nothing is lost at the end of a turn.\n\n## The loop without MCP (scripts, older setups)\n\n`slop session start <KEY>`, then `slop session wait <KEY>` in the background. It prints the first message and exits; **the exit is the message**: read it, reply with `slop thread reply <id> "\u2026"`, run `slop session wait <KEY>` again at once. Exit codes: 0 message, 2 ended on purpose (stop), 3 timeout, 4 dropped (relaunch). `--follow` streams instead of exiting, for harnesses that watch output.\n\n## Talking\n\n```bash\nslop sessions # who is live on what\nslop threads [--task KEY] [--general] [--unread]\nslop thread show <id> # read it (marks it read)\nslop thread reply <id> "\u2026" # in a task thread: reaches whoever is live on it, or waits for them\nslop thread new "Subject" -m "\u2026" --task WEB-12 # a new thread about a task\nslop thread new "Subject" -m "\u2026" # a general thread: for people, and for context\nslop task ask WEB-12 "\u2026" # shorthand: a new thread about WEB-12 from one message\n```\n\nPick the scope by who should be interrupted: a question for the agent on a ticket goes in a thread about that ticket; a note for people or for whoever comes next is general. Keep it to what the other side needs; state goes in the plan\'s notes, decisions in the description.\n\n## Etiquette\n\n- One live session per agent. Do not claim a task that has someone else\'s live session (`sessions`); write in a thread about it first.\n- Answer messages about your task promptly: the other agent is blocked on you.\n- Report progress in the plan\'s notes, not in threads. Threads are for talking to someone.\n- If you stop working on a task, end the session so nobody waits on you.\n';
|
|
3389
3389
|
|
|
3390
3390
|
// skills/slop-working.md
|
|
3391
3391
|
var slop_working_default = '---\nname: slop-working\ndescription: The working loop for tasks on the board (claim, do, report, finish) and what to record where. Load at the start of any coding session in a repository linked with slop.\n---\n\n# The loop\n\n1. **What is there:** `slop task list --assignee me` (or `slop task list`). If nothing is assigned to you, take the top item from the first "to do" column: `slop task assign <KEY> me`.\n2. **Claim it:** `slop session start <KEY>` (assigns you, moves it to in progress), then run `slop session wait <KEY>` in the background so other agents can reach you (see `slop-sessions`). Read `slop task show <KEY>` fully, including the plan and its notes.\n3. **Do it.** Long work: follow `slop-planning`. Short work: just do it.\n4. **Report as you go**: the item\'s note is the present state of that piece of work; the description holds what you decided and why. Write in sentences a teammate can act on.\n5. **Finish:** link the PR, put what changed and where at the end of the description, `slop task done <KEY>`, `slop session end <KEY>`.\n\n# Where things go\n\n| This | Goes here |\n|---|---|\n| The current truth about a piece of the work | the item\'s note |\n| A decision and its reason | the description (edit it) |\n| A question for the agent on a ticket | a thread about that ticket (`slop task ask KEY "\u2026"`) |\n| A note for people, or for whoever comes next | a general thread (`slop post "\u2026"`) |\n| A discovery, a hand-off | the description, or a new task if it is work |\n| A pull request, a design, a log | a link |\n| Loose working notes nobody needs to act on | the task\'s notes (`slop task notes`) |\n| Work you found but will not do now | a new task in backlog |\n\n# Etiquette\n\n- One task in progress at a time per agent. `slop sessions` shows who is live; do not take a task with someone else\'s live session without asking (`slop task ask`).\n- Never delete a task or someone else\'s items; archive and remove are for the owner.\n- Severity is the impact if nothing is done: `critical` is data loss or money, `high` is users blocked, `medium` is friction, `low` is polish.\n';
|
|
@@ -4078,7 +4078,7 @@ function assertNotEqual(val) {
|
|
|
4078
4078
|
return val;
|
|
4079
4079
|
}
|
|
4080
4080
|
function toZod() {
|
|
4081
|
-
return (
|
|
4081
|
+
return (schema2) => schema2;
|
|
4082
4082
|
}
|
|
4083
4083
|
function assertIs(_arg) {
|
|
4084
4084
|
}
|
|
@@ -4171,8 +4171,8 @@ function rawShape(def) {
|
|
|
4171
4171
|
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
4172
4172
|
return desc?.get ? desc.get.raw : desc?.value;
|
|
4173
4173
|
}
|
|
4174
|
-
function sourceShape(
|
|
4175
|
-
return rawShape(
|
|
4174
|
+
function sourceShape(schema2) {
|
|
4175
|
+
return rawShape(schema2._zod.def) ?? schema2._zod.def.shape;
|
|
4176
4176
|
}
|
|
4177
4177
|
function deferProp(target, key, getter) {
|
|
4178
4178
|
Object.defineProperty(target, key, {
|
|
@@ -4225,8 +4225,8 @@ function mergeDefs(...defs) {
|
|
|
4225
4225
|
}
|
|
4226
4226
|
return Object.defineProperties({}, mergedDescriptors);
|
|
4227
4227
|
}
|
|
4228
|
-
function cloneDef(
|
|
4229
|
-
return mergeDefs(
|
|
4228
|
+
function cloneDef(schema2) {
|
|
4229
|
+
return mergeDefs(schema2._zod.def);
|
|
4230
4230
|
}
|
|
4231
4231
|
function getElementAtPath(obj, path3) {
|
|
4232
4232
|
if (!path3)
|
|
@@ -4246,14 +4246,14 @@ function promiseAllObject(promisesObj) {
|
|
|
4246
4246
|
}
|
|
4247
4247
|
function randomString(length = 10) {
|
|
4248
4248
|
const chars = "abcdefghijklmnopqrstuvwxyz";
|
|
4249
|
-
let
|
|
4249
|
+
let str2 = "";
|
|
4250
4250
|
for (let i = 0; i < length; i++) {
|
|
4251
|
-
|
|
4251
|
+
str2 += chars[Math.floor(Math.random() * chars.length)];
|
|
4252
4252
|
}
|
|
4253
|
-
return
|
|
4253
|
+
return str2;
|
|
4254
4254
|
}
|
|
4255
|
-
function esc(
|
|
4256
|
-
return JSON.stringify(
|
|
4255
|
+
function esc(str2) {
|
|
4256
|
+
return JSON.stringify(str2);
|
|
4257
4257
|
}
|
|
4258
4258
|
function slugify(input2) {
|
|
4259
4259
|
return input2.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -4367,8 +4367,8 @@ var primitiveTypes = /* @__PURE__ */ new Set([
|
|
|
4367
4367
|
"symbol",
|
|
4368
4368
|
"undefined"
|
|
4369
4369
|
]);
|
|
4370
|
-
function escapeRegex(
|
|
4371
|
-
return
|
|
4370
|
+
function escapeRegex(str2) {
|
|
4371
|
+
return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4372
4372
|
}
|
|
4373
4373
|
function clone(inst, def, params) {
|
|
4374
4374
|
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
@@ -4448,19 +4448,19 @@ var BIGINT_FORMAT_RANGES = {
|
|
|
4448
4448
|
int64: [/* @__PURE__ */ BigInt("-9223372036854775808"), /* @__PURE__ */ BigInt("9223372036854775807")],
|
|
4449
4449
|
uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
|
|
4450
4450
|
};
|
|
4451
|
-
function pick(
|
|
4452
|
-
const currDef =
|
|
4451
|
+
function pick(schema2, mask) {
|
|
4452
|
+
const currDef = schema2._zod.def;
|
|
4453
4453
|
const checks = currDef.checks;
|
|
4454
4454
|
const hasChecks = checks && checks.length > 0;
|
|
4455
4455
|
if (hasChecks) {
|
|
4456
4456
|
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
4457
4457
|
}
|
|
4458
4458
|
const newShape = {};
|
|
4459
|
-
mirrorShape(newShape,
|
|
4460
|
-
return clone(
|
|
4459
|
+
mirrorShape(newShape, schema2, maskedKeys(schema2, mask));
|
|
4460
|
+
return clone(schema2, mergeDefs(currDef, { shape: newShape, checks: [] }));
|
|
4461
4461
|
}
|
|
4462
|
-
function maskedKeys(
|
|
4463
|
-
const raw = sourceShape(
|
|
4462
|
+
function maskedKeys(schema2, mask) {
|
|
4463
|
+
const raw = sourceShape(schema2);
|
|
4464
4464
|
const keys = [];
|
|
4465
4465
|
for (const key of Reflect.ownKeys(mask)) {
|
|
4466
4466
|
if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) {
|
|
@@ -4471,45 +4471,45 @@ function maskedKeys(schema, mask) {
|
|
|
4471
4471
|
}
|
|
4472
4472
|
return keys;
|
|
4473
4473
|
}
|
|
4474
|
-
function omit(
|
|
4475
|
-
const currDef =
|
|
4474
|
+
function omit(schema2, mask) {
|
|
4475
|
+
const currDef = schema2._zod.def;
|
|
4476
4476
|
const checks = currDef.checks;
|
|
4477
4477
|
const hasChecks = checks && checks.length > 0;
|
|
4478
4478
|
if (hasChecks) {
|
|
4479
4479
|
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
4480
4480
|
}
|
|
4481
|
-
const omitted = new Set(maskedKeys(
|
|
4481
|
+
const omitted = new Set(maskedKeys(schema2, mask));
|
|
4482
4482
|
const newShape = {};
|
|
4483
|
-
mirrorShape(newShape,
|
|
4484
|
-
return clone(
|
|
4483
|
+
mirrorShape(newShape, schema2, Reflect.ownKeys(sourceShape(schema2)).filter((key) => !omitted.has(key)));
|
|
4484
|
+
return clone(schema2, mergeDefs(currDef, { shape: newShape, checks: [] }));
|
|
4485
4485
|
}
|
|
4486
|
-
function extend(
|
|
4486
|
+
function extend(schema2, shape) {
|
|
4487
4487
|
if (!isPlainObject(shape)) {
|
|
4488
4488
|
throw new Error("Invalid input to extend: expected a plain object");
|
|
4489
4489
|
}
|
|
4490
|
-
const checks =
|
|
4490
|
+
const checks = schema2._zod.def.checks;
|
|
4491
4491
|
const hasChecks = checks && checks.length > 0;
|
|
4492
4492
|
if (hasChecks) {
|
|
4493
|
-
const existingShape = sourceShape(
|
|
4493
|
+
const existingShape = sourceShape(schema2);
|
|
4494
4494
|
for (const key of Reflect.ownKeys(shape)) {
|
|
4495
4495
|
if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
|
|
4496
4496
|
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
4497
4497
|
}
|
|
4498
4498
|
}
|
|
4499
4499
|
}
|
|
4500
|
-
return clone(
|
|
4500
|
+
return clone(schema2, mergeDefs(schema2._zod.def, { shape: extended(schema2, shape) }));
|
|
4501
4501
|
}
|
|
4502
|
-
function extended(
|
|
4502
|
+
function extended(schema2, shape) {
|
|
4503
4503
|
const newShape = {};
|
|
4504
|
-
mirrorShape(newShape,
|
|
4504
|
+
mirrorShape(newShape, schema2, Reflect.ownKeys(sourceShape(schema2)));
|
|
4505
4505
|
mirrorProps(newShape, shape);
|
|
4506
4506
|
return newShape;
|
|
4507
4507
|
}
|
|
4508
|
-
function safeExtend(
|
|
4508
|
+
function safeExtend(schema2, shape) {
|
|
4509
4509
|
if (!isPlainObject(shape)) {
|
|
4510
4510
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
4511
4511
|
}
|
|
4512
|
-
return clone(
|
|
4512
|
+
return clone(schema2, mergeDefs(schema2._zod.def, { shape: extended(schema2, shape) }));
|
|
4513
4513
|
}
|
|
4514
4514
|
function merge(a, b) {
|
|
4515
4515
|
if (!b?._zod?.def) {
|
|
@@ -4530,26 +4530,26 @@ function merge(a, b) {
|
|
|
4530
4530
|
});
|
|
4531
4531
|
return clone(a, def);
|
|
4532
4532
|
}
|
|
4533
|
-
function partial(Class2,
|
|
4534
|
-
const currDef =
|
|
4533
|
+
function partial(Class2, schema2, mask, name = "partial") {
|
|
4534
|
+
const currDef = schema2._zod.def;
|
|
4535
4535
|
const checks = currDef.checks;
|
|
4536
4536
|
const hasChecks = checks && checks.length > 0;
|
|
4537
4537
|
if (hasChecks) {
|
|
4538
4538
|
throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
|
|
4539
4539
|
}
|
|
4540
|
-
const selected = mask ? new Set(maskedKeys(
|
|
4540
|
+
const selected = mask ? new Set(maskedKeys(schema2, mask)) : void 0;
|
|
4541
4541
|
const newShape = {};
|
|
4542
|
-
mirrorShape(newShape,
|
|
4543
|
-
return clone(
|
|
4542
|
+
mirrorShape(newShape, schema2, Reflect.ownKeys(sourceShape(schema2)), Class2 && ((value, key) => selected && !selected.has(key) ? value : new Class2({ type: "optional", innerType: value })));
|
|
4543
|
+
return clone(schema2, mergeDefs(schema2._zod.def, { shape: newShape, checks: [] }));
|
|
4544
4544
|
}
|
|
4545
|
-
function required(Class2,
|
|
4546
|
-
const selected = mask ? new Set(maskedKeys(
|
|
4545
|
+
function required(Class2, schema2, mask) {
|
|
4546
|
+
const selected = mask ? new Set(maskedKeys(schema2, mask)) : void 0;
|
|
4547
4547
|
const newShape = {};
|
|
4548
|
-
mirrorShape(newShape,
|
|
4548
|
+
mirrorShape(newShape, schema2, Reflect.ownKeys(sourceShape(schema2)), (value, key) => (
|
|
4549
4549
|
// overwrite with non-optional
|
|
4550
4550
|
selected && !selected.has(key) ? value : new Class2({ type: "nonoptional", innerType: value })
|
|
4551
4551
|
));
|
|
4552
|
-
return clone(
|
|
4552
|
+
return clone(schema2, mergeDefs(schema2._zod.def, { shape: newShape }));
|
|
4553
4553
|
}
|
|
4554
4554
|
function aborted(x, startIndex = 0) {
|
|
4555
4555
|
if (x.aborted === true)
|
|
@@ -4622,13 +4622,13 @@ function getSizableOrigin(input2) {
|
|
|
4622
4622
|
return "unknown";
|
|
4623
4623
|
}
|
|
4624
4624
|
var highSurrogate = /[\uD800-\uDBFF]/;
|
|
4625
|
-
function codePointLength(
|
|
4626
|
-
const units =
|
|
4627
|
-
if (!highSurrogate.test(
|
|
4625
|
+
function codePointLength(str2) {
|
|
4626
|
+
const units = str2.length;
|
|
4627
|
+
if (!highSurrogate.test(str2))
|
|
4628
4628
|
return units;
|
|
4629
4629
|
let count = units;
|
|
4630
4630
|
for (let i = 0; i < units - 1; i++) {
|
|
4631
|
-
if ((
|
|
4631
|
+
if ((str2.charCodeAt(i) & 64512) === 55296 && (str2.charCodeAt(i + 1) & 64512) === 56320) {
|
|
4632
4632
|
count--;
|
|
4633
4633
|
i++;
|
|
4634
4634
|
}
|
|
@@ -5154,9 +5154,9 @@ function finalizeParams(callee, params) {
|
|
|
5154
5154
|
return { callee: params?.callee ?? callee, Err: params?.Err };
|
|
5155
5155
|
}
|
|
5156
5156
|
var _parse = (_Err) => {
|
|
5157
|
-
const fn = (
|
|
5157
|
+
const fn = (schema2, value, _ctx, _params) => {
|
|
5158
5158
|
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
5159
|
-
const result =
|
|
5159
|
+
const result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
5160
5160
|
if (result instanceof Promise) {
|
|
5161
5161
|
throw new $ZodAsyncError();
|
|
5162
5162
|
}
|
|
@@ -5171,9 +5171,9 @@ var _parse = (_Err) => {
|
|
|
5171
5171
|
};
|
|
5172
5172
|
var parse = /* @__PURE__ */ _parse($ZodRealError);
|
|
5173
5173
|
var _parseAsync = (_Err) => {
|
|
5174
|
-
const fn = async (
|
|
5174
|
+
const fn = async (schema2, value, _ctx, params) => {
|
|
5175
5175
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
5176
|
-
let result =
|
|
5176
|
+
let result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
5177
5177
|
if (result instanceof Promise)
|
|
5178
5178
|
result = await result;
|
|
5179
5179
|
if (result.issues.length) {
|
|
@@ -5186,9 +5186,9 @@ var _parseAsync = (_Err) => {
|
|
|
5186
5186
|
return fn;
|
|
5187
5187
|
};
|
|
5188
5188
|
var parseAsync = /* @__PURE__ */ _parseAsync($ZodRealError);
|
|
5189
|
-
var _safeParse = (_Err) => (
|
|
5189
|
+
var _safeParse = (_Err) => (schema2, value, _ctx) => {
|
|
5190
5190
|
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
5191
|
-
const result =
|
|
5191
|
+
const result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
5192
5192
|
if (result instanceof Promise) {
|
|
5193
5193
|
throw new $ZodAsyncError();
|
|
5194
5194
|
}
|
|
@@ -5214,9 +5214,9 @@ function failure(Err, issues, ctx) {
|
|
|
5214
5214
|
}
|
|
5215
5215
|
};
|
|
5216
5216
|
}
|
|
5217
|
-
var _safeParseAsync = (_Err) => async (
|
|
5217
|
+
var _safeParseAsync = (_Err) => async (schema2, value, _ctx) => {
|
|
5218
5218
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
5219
|
-
let result =
|
|
5219
|
+
let result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
5220
5220
|
if (result instanceof Promise)
|
|
5221
5221
|
result = await result;
|
|
5222
5222
|
return result.issues.length ? failure(_Err, result.issues, ctx) : { success: true, data: result.value };
|
|
@@ -5224,88 +5224,88 @@ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
5224
5224
|
var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
5225
5225
|
var COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
|
|
5226
5226
|
var COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
|
|
5227
|
-
var validate = ((
|
|
5228
|
-
const validator =
|
|
5227
|
+
var validate = ((schema2, value, _ctx) => {
|
|
5228
|
+
const validator = schema2._zod.bag.validator;
|
|
5229
5229
|
if (validator !== void 0) {
|
|
5230
5230
|
if (validator(value) !== COMPILE_INVALID)
|
|
5231
5231
|
return true;
|
|
5232
5232
|
if (validator.definite === true && _ctx === void 0)
|
|
5233
5233
|
return false;
|
|
5234
5234
|
}
|
|
5235
|
-
return validateFallback(
|
|
5235
|
+
return validateFallback(schema2, value, _ctx);
|
|
5236
5236
|
});
|
|
5237
|
-
function validateFallback(
|
|
5237
|
+
function validateFallback(schema2, value, _ctx) {
|
|
5238
5238
|
const ctx = _ctx ? { ..._ctx, async: false, abortEarly: true } : { async: false, abortEarly: true };
|
|
5239
|
-
const fallbackRun =
|
|
5239
|
+
const fallbackRun = schema2._zod.bag.fallbackRun;
|
|
5240
5240
|
let result;
|
|
5241
5241
|
if (fallbackRun) {
|
|
5242
5242
|
ctx[COMPILE_FALLBACK] = true;
|
|
5243
5243
|
result = fallbackRun({ value, issues: [] }, ctx);
|
|
5244
5244
|
} else {
|
|
5245
|
-
result =
|
|
5245
|
+
result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
5246
5246
|
}
|
|
5247
5247
|
if (result instanceof Promise) {
|
|
5248
5248
|
throw new $ZodAsyncError();
|
|
5249
5249
|
}
|
|
5250
5250
|
return result.issues.length === 0;
|
|
5251
5251
|
}
|
|
5252
|
-
var validateAsync = async (
|
|
5252
|
+
var validateAsync = async (schema2, value, _ctx) => {
|
|
5253
5253
|
const ctx = _ctx ? { ..._ctx, async: true, abortEarly: true } : { async: true, abortEarly: true };
|
|
5254
|
-
let result =
|
|
5254
|
+
let result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
5255
5255
|
if (result instanceof Promise)
|
|
5256
5256
|
result = await result;
|
|
5257
5257
|
return result.issues.length === 0;
|
|
5258
5258
|
};
|
|
5259
5259
|
var _encode = (_Err) => {
|
|
5260
5260
|
const parse3 = _parse(_Err);
|
|
5261
|
-
const fn = (
|
|
5261
|
+
const fn = (schema2, value, _ctx, _params) => {
|
|
5262
5262
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
5263
|
-
return parse3(
|
|
5263
|
+
return parse3(schema2, value, ctx, finalizeParams(fn, _params));
|
|
5264
5264
|
};
|
|
5265
5265
|
return fn;
|
|
5266
5266
|
};
|
|
5267
5267
|
var encode = /* @__PURE__ */ _encode($ZodRealError);
|
|
5268
5268
|
var _decode = (_Err) => {
|
|
5269
5269
|
const parse3 = _parse(_Err);
|
|
5270
|
-
const fn = (
|
|
5271
|
-
return parse3(
|
|
5270
|
+
const fn = (schema2, value, _ctx, _params) => {
|
|
5271
|
+
return parse3(schema2, value, _ctx, finalizeParams(fn, _params));
|
|
5272
5272
|
};
|
|
5273
5273
|
return fn;
|
|
5274
5274
|
};
|
|
5275
5275
|
var decode = /* @__PURE__ */ _decode($ZodRealError);
|
|
5276
5276
|
var _encodeAsync = (_Err) => {
|
|
5277
5277
|
const parseAsync3 = _parseAsync(_Err);
|
|
5278
|
-
const fn = async (
|
|
5278
|
+
const fn = async (schema2, value, _ctx, _params) => {
|
|
5279
5279
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
5280
|
-
return await parseAsync3(
|
|
5280
|
+
return await parseAsync3(schema2, value, ctx, finalizeParams(fn, _params));
|
|
5281
5281
|
};
|
|
5282
5282
|
return fn;
|
|
5283
5283
|
};
|
|
5284
5284
|
var encodeAsync = /* @__PURE__ */ _encodeAsync($ZodRealError);
|
|
5285
5285
|
var _decodeAsync = (_Err) => {
|
|
5286
5286
|
const parseAsync3 = _parseAsync(_Err);
|
|
5287
|
-
const fn = async (
|
|
5288
|
-
return await parseAsync3(
|
|
5287
|
+
const fn = async (schema2, value, _ctx, _params) => {
|
|
5288
|
+
return await parseAsync3(schema2, value, _ctx, finalizeParams(fn, _params));
|
|
5289
5289
|
};
|
|
5290
5290
|
return fn;
|
|
5291
5291
|
};
|
|
5292
5292
|
var decodeAsync = /* @__PURE__ */ _decodeAsync($ZodRealError);
|
|
5293
|
-
var _safeEncode = (_Err) => (
|
|
5293
|
+
var _safeEncode = (_Err) => (schema2, value, _ctx) => {
|
|
5294
5294
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
5295
|
-
return _safeParse(_Err)(
|
|
5295
|
+
return _safeParse(_Err)(schema2, value, ctx);
|
|
5296
5296
|
};
|
|
5297
5297
|
var safeEncode = /* @__PURE__ */ _safeEncode($ZodRealError);
|
|
5298
|
-
var _safeDecode = (_Err) => (
|
|
5299
|
-
return _safeParse(_Err)(
|
|
5298
|
+
var _safeDecode = (_Err) => (schema2, value, _ctx) => {
|
|
5299
|
+
return _safeParse(_Err)(schema2, value, _ctx);
|
|
5300
5300
|
};
|
|
5301
5301
|
var safeDecode = /* @__PURE__ */ _safeDecode($ZodRealError);
|
|
5302
|
-
var _safeEncodeAsync = (_Err) => async (
|
|
5302
|
+
var _safeEncodeAsync = (_Err) => async (schema2, value, _ctx) => {
|
|
5303
5303
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
5304
|
-
return _safeParseAsync(_Err)(
|
|
5304
|
+
return _safeParseAsync(_Err)(schema2, value, ctx);
|
|
5305
5305
|
};
|
|
5306
5306
|
var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync($ZodRealError);
|
|
5307
|
-
var _safeDecodeAsync = (_Err) => async (
|
|
5308
|
-
return _safeParseAsync(_Err)(
|
|
5307
|
+
var _safeDecodeAsync = (_Err) => async (schema2, value, _ctx) => {
|
|
5308
|
+
return _safeParseAsync(_Err)(schema2, value, _ctx);
|
|
5309
5309
|
};
|
|
5310
5310
|
var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
|
|
5311
5311
|
|
|
@@ -5921,8 +5921,8 @@ var $ZodCheckProperties = /* @__PURE__ */ $constructor("$ZodCheckProperties", (i
|
|
|
5921
5921
|
entries ?? (entries = Reflect.ownKeys(def.shape).map((key) => [key, def.shape[key]]));
|
|
5922
5922
|
const input2 = payload.value;
|
|
5923
5923
|
let proms;
|
|
5924
|
-
for (const [key,
|
|
5925
|
-
const result =
|
|
5924
|
+
for (const [key, schema2] of entries) {
|
|
5925
|
+
const result = schema2._zod.run({ value: input2[key], issues: [] }, {});
|
|
5926
5926
|
if (result instanceof Promise) {
|
|
5927
5927
|
proms ?? (proms = []);
|
|
5928
5928
|
proms.push(result.then((result2) => handleCheckPropertyResult(result2, payload, key)));
|
|
@@ -7016,10 +7016,10 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
7016
7016
|
const id = ids[key];
|
|
7017
7017
|
const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : esc(key);
|
|
7018
7018
|
const isPresent = `${k} in input`;
|
|
7019
|
-
const
|
|
7020
|
-
const optin =
|
|
7019
|
+
const schema2 = shape[key];
|
|
7020
|
+
const optin = schema2?._zod?.optin;
|
|
7021
7021
|
const isOptionalIn = optin !== void 0;
|
|
7022
|
-
const isOptionalOut =
|
|
7022
|
+
const isOptionalOut = schema2?._zod?.optout === "optional";
|
|
7023
7023
|
doc.write(`const ${id} = ${parseStr(k)};`);
|
|
7024
7024
|
if (isOptionalIn && isOptionalOut) {
|
|
7025
7025
|
const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
|
|
@@ -8198,8 +8198,8 @@ function handleReadonlyResult(payload) {
|
|
|
8198
8198
|
payload.value = Object.freeze(payload.value);
|
|
8199
8199
|
return payload;
|
|
8200
8200
|
}
|
|
8201
|
-
function leafPattern(
|
|
8202
|
-
const def =
|
|
8201
|
+
function leafPattern(schema2) {
|
|
8202
|
+
const def = schema2._zod.def;
|
|
8203
8203
|
let pattern = def.pattern;
|
|
8204
8204
|
let isInt = !!def.format?.includes("int");
|
|
8205
8205
|
let minimum;
|
|
@@ -8222,13 +8222,13 @@ function leafPattern(schema) {
|
|
|
8222
8222
|
return "(?!)";
|
|
8223
8223
|
if (minimum !== void 0 || maximum !== void 0)
|
|
8224
8224
|
return string({ minimum, maximum }).source;
|
|
8225
|
-
const own2 =
|
|
8225
|
+
const own2 = schema2._zod.pattern;
|
|
8226
8226
|
return (isInt && own2 === number ? integer : own2)?.source;
|
|
8227
8227
|
}
|
|
8228
|
-
function partPattern(
|
|
8229
|
-
const def =
|
|
8230
|
-
const own2 =
|
|
8231
|
-
const inner = def.innerType ??
|
|
8228
|
+
function partPattern(schema2) {
|
|
8229
|
+
const def = schema2._zod.def;
|
|
8230
|
+
const own2 = schema2._zod.pattern?.source;
|
|
8231
|
+
const inner = def.innerType ?? schema2._zod.innerType;
|
|
8232
8232
|
if (inner) {
|
|
8233
8233
|
const before = inner._zod.pattern?.source;
|
|
8234
8234
|
const after = partPattern(inner);
|
|
@@ -8242,7 +8242,7 @@ function partPattern(schema) {
|
|
|
8242
8242
|
if (sources.every(Boolean))
|
|
8243
8243
|
return `^(${sources.map((s) => cleanRegex(s)).join("|")})$`;
|
|
8244
8244
|
}
|
|
8245
|
-
return leafPattern(
|
|
8245
|
+
return leafPattern(schema2);
|
|
8246
8246
|
}
|
|
8247
8247
|
var $ZodTemplateLiteral = /* @__PURE__ */ $constructor("$ZodTemplateLiteral", (inst, def) => {
|
|
8248
8248
|
$ZodType.init(inst, def);
|
|
@@ -16272,11 +16272,11 @@ var $ZodRegistry = class {
|
|
|
16272
16272
|
this._map = /* @__PURE__ */ new WeakMap();
|
|
16273
16273
|
this._idmap = /* @__PURE__ */ new Map();
|
|
16274
16274
|
}
|
|
16275
|
-
add(
|
|
16275
|
+
add(schema2, ..._meta) {
|
|
16276
16276
|
const meta3 = _meta[0];
|
|
16277
|
-
this._map.set(
|
|
16277
|
+
this._map.set(schema2, meta3);
|
|
16278
16278
|
if (meta3 && typeof meta3 === "object" && "id" in meta3) {
|
|
16279
|
-
this._idmap.set(meta3.id,
|
|
16279
|
+
this._idmap.set(meta3.id, schema2);
|
|
16280
16280
|
}
|
|
16281
16281
|
return this;
|
|
16282
16282
|
}
|
|
@@ -16285,26 +16285,26 @@ var $ZodRegistry = class {
|
|
|
16285
16285
|
this._idmap = /* @__PURE__ */ new Map();
|
|
16286
16286
|
return this;
|
|
16287
16287
|
}
|
|
16288
|
-
remove(
|
|
16289
|
-
const meta3 = this._map.get(
|
|
16288
|
+
remove(schema2) {
|
|
16289
|
+
const meta3 = this._map.get(schema2);
|
|
16290
16290
|
if (meta3 && typeof meta3 === "object" && "id" in meta3) {
|
|
16291
16291
|
this._idmap.delete(meta3.id);
|
|
16292
16292
|
}
|
|
16293
|
-
this._map.delete(
|
|
16293
|
+
this._map.delete(schema2);
|
|
16294
16294
|
return this;
|
|
16295
16295
|
}
|
|
16296
|
-
get(
|
|
16297
|
-
const p =
|
|
16296
|
+
get(schema2) {
|
|
16297
|
+
const p = schema2._zod.parent;
|
|
16298
16298
|
if (p) {
|
|
16299
16299
|
const pm = { ...this.get(p) ?? {} };
|
|
16300
16300
|
delete pm.id;
|
|
16301
|
-
const f = { ...pm, ...this._map.get(
|
|
16301
|
+
const f = { ...pm, ...this._map.get(schema2) };
|
|
16302
16302
|
return Object.keys(f).length ? f : void 0;
|
|
16303
16303
|
}
|
|
16304
|
-
return this._map.get(
|
|
16304
|
+
return this._map.get(schema2);
|
|
16305
16305
|
}
|
|
16306
|
-
has(
|
|
16307
|
-
return this._map.has(
|
|
16306
|
+
has(schema2) {
|
|
16307
|
+
return this._map.has(schema2);
|
|
16308
16308
|
}
|
|
16309
16309
|
};
|
|
16310
16310
|
function registry() {
|
|
@@ -16329,31 +16329,31 @@ var ZodCompileUnsupportedError = class extends Error {
|
|
|
16329
16329
|
this.islandable = islandable;
|
|
16330
16330
|
}
|
|
16331
16331
|
};
|
|
16332
|
-
function compileValidator(
|
|
16332
|
+
function compileValidator(schema2, parser) {
|
|
16333
16333
|
try {
|
|
16334
|
-
return compileFn(
|
|
16334
|
+
return compileFn(schema2, { assertOnly: true });
|
|
16335
16335
|
} catch {
|
|
16336
16336
|
return parser;
|
|
16337
16337
|
}
|
|
16338
16338
|
}
|
|
16339
|
-
function compile(
|
|
16339
|
+
function compile(schema2, options) {
|
|
16340
16340
|
try {
|
|
16341
|
-
const parser = compileFn(
|
|
16342
|
-
const clone2 = withParser(
|
|
16343
|
-
clone2._zod.bag.validator = compileValidator(
|
|
16341
|
+
const parser = compileFn(schema2);
|
|
16342
|
+
const clone2 = withParser(schema2, parser);
|
|
16343
|
+
clone2._zod.bag.validator = compileValidator(schema2, parser);
|
|
16344
16344
|
return clone2;
|
|
16345
16345
|
} catch (err) {
|
|
16346
16346
|
if (options?.strict)
|
|
16347
16347
|
throw err;
|
|
16348
|
-
return
|
|
16348
|
+
return schema2;
|
|
16349
16349
|
}
|
|
16350
16350
|
}
|
|
16351
|
-
function withParser(
|
|
16352
|
-
if (isRecursiveSchema(
|
|
16351
|
+
function withParser(schema2, parser) {
|
|
16352
|
+
if (isRecursiveSchema(schema2)) {
|
|
16353
16353
|
throw new ZodCompileUnsupportedError("a schema whose subtree contains a reference cycle");
|
|
16354
16354
|
}
|
|
16355
|
-
const clone2 = clone(
|
|
16356
|
-
const liveRun =
|
|
16355
|
+
const clone2 = clone(schema2);
|
|
16356
|
+
const liveRun = schema2._zod.run;
|
|
16357
16357
|
const originalRun = liveRun.__originalRun ?? liveRun;
|
|
16358
16358
|
const wrapped = (payload, ctx) => {
|
|
16359
16359
|
if (ctx?.async || ctx?.direction === "backward" || ctx?.skipChecks || ctx?.[FALLBACK_FLAG]) {
|
|
@@ -16376,7 +16376,7 @@ function withParser(schema, parser) {
|
|
|
16376
16376
|
clone2._zod.bag.validator = parser;
|
|
16377
16377
|
clone2._zod.run = wrapped;
|
|
16378
16378
|
if (!liveRun.__originalRun)
|
|
16379
|
-
installCompiledUserMethods(clone2,
|
|
16379
|
+
installCompiledUserMethods(clone2, schema2, parser);
|
|
16380
16380
|
return clone2;
|
|
16381
16381
|
}
|
|
16382
16382
|
function installCompiledUserMethods(target, source, parser) {
|
|
@@ -16403,10 +16403,10 @@ function installCompiledUserMethods(target, source, parser) {
|
|
|
16403
16403
|
};
|
|
16404
16404
|
}
|
|
16405
16405
|
}
|
|
16406
|
-
function compileFn(
|
|
16406
|
+
function compileFn(schema2, options) {
|
|
16407
16407
|
let recursive2 = true;
|
|
16408
16408
|
try {
|
|
16409
|
-
recursive2 = isRecursiveSchema(
|
|
16409
|
+
recursive2 = isRecursiveSchema(schema2);
|
|
16410
16410
|
} catch {
|
|
16411
16411
|
}
|
|
16412
16412
|
if (recursive2) {
|
|
@@ -16419,7 +16419,7 @@ function compileFn(schema, options) {
|
|
|
16419
16419
|
definite: true
|
|
16420
16420
|
};
|
|
16421
16421
|
const doc = new Doc(["input"]);
|
|
16422
|
-
const outputAccessor = generateCheck(doc, ctx,
|
|
16422
|
+
const outputAccessor = generateCheck(doc, ctx, schema2, "input", !options?.assertOnly);
|
|
16423
16423
|
doc.write(outputAccessor === null ? `return true;` : `return ${outputAccessor};`);
|
|
16424
16424
|
const constantNames = ["INVALID", ...ctx.constants.keys()];
|
|
16425
16425
|
const constantValues = [INVALID, ...ctx.constants.values()];
|
|
@@ -16459,20 +16459,20 @@ function addUserConstant(ctx, fn) {
|
|
|
16459
16459
|
function newVar(ctx) {
|
|
16460
16460
|
return `v${ctx.varCounter++}`;
|
|
16461
16461
|
}
|
|
16462
|
-
function runtimeRun(
|
|
16463
|
-
const result =
|
|
16462
|
+
function runtimeRun(schema2, value) {
|
|
16463
|
+
const result = schema2._zod.run({ value, issues: [] }, {});
|
|
16464
16464
|
if (result && typeof result.then === "function")
|
|
16465
16465
|
return INVALID;
|
|
16466
16466
|
const r = result;
|
|
16467
16467
|
return r.issues.length === 0 ? r.value : INVALID;
|
|
16468
16468
|
}
|
|
16469
|
-
function compileChild(doc, ctx,
|
|
16469
|
+
function compileChild(doc, ctx, schema2, accessor, needsValue = true) {
|
|
16470
16470
|
const contentLen = doc.content.length;
|
|
16471
16471
|
const constantCount = ctx.constants.size;
|
|
16472
16472
|
const constantCounter = ctx.constantCounter;
|
|
16473
16473
|
const varCounter = ctx.varCounter;
|
|
16474
16474
|
try {
|
|
16475
|
-
return generateCheck(doc, ctx,
|
|
16475
|
+
return generateCheck(doc, ctx, schema2, accessor, needsValue);
|
|
16476
16476
|
} catch (err) {
|
|
16477
16477
|
if (!(err instanceof ZodCompileUnsupportedError) || !err.islandable)
|
|
16478
16478
|
throw err;
|
|
@@ -16484,12 +16484,12 @@ function compileChild(doc, ctx, schema, accessor, needsValue = true) {
|
|
|
16484
16484
|
}
|
|
16485
16485
|
ctx.constantCounter = constantCounter;
|
|
16486
16486
|
ctx.varCounter = varCounter;
|
|
16487
|
-
return emitRuntimeIsland(doc, ctx,
|
|
16487
|
+
return emitRuntimeIsland(doc, ctx, schema2, accessor);
|
|
16488
16488
|
}
|
|
16489
16489
|
}
|
|
16490
|
-
function emitRuntimeIsland(doc, ctx,
|
|
16490
|
+
function emitRuntimeIsland(doc, ctx, schema2, accessor) {
|
|
16491
16491
|
ctx.definite = false;
|
|
16492
|
-
const schemaConst = addConstant(ctx,
|
|
16492
|
+
const schemaConst = addConstant(ctx, schema2);
|
|
16493
16493
|
const runConst = addConstant(ctx, runtimeRun);
|
|
16494
16494
|
const outVar = newVar(ctx);
|
|
16495
16495
|
doc.write(`const ${outVar} = ${runConst}(${schemaConst}, ${accessor});`);
|
|
@@ -16504,8 +16504,8 @@ var WHEN_DEFAULTED_CHECKS = /* @__PURE__ */ new Set([
|
|
|
16504
16504
|
"min_length",
|
|
16505
16505
|
"length_equals"
|
|
16506
16506
|
]);
|
|
16507
|
-
function generateChecks(doc, ctx,
|
|
16508
|
-
const schemaChecks =
|
|
16507
|
+
function generateChecks(doc, ctx, schema2, accessor) {
|
|
16508
|
+
const schemaChecks = schema2._zod.def.checks;
|
|
16509
16509
|
if (!schemaChecks || schemaChecks.length === 0)
|
|
16510
16510
|
return accessor;
|
|
16511
16511
|
let currentAccessor = accessor;
|
|
@@ -16880,8 +16880,8 @@ function generateStringFormatCheck(doc, ctx, def, accessor, needsValue = true) {
|
|
|
16880
16880
|
}
|
|
16881
16881
|
return accessor;
|
|
16882
16882
|
}
|
|
16883
|
-
function generateCheck(doc, ctx,
|
|
16884
|
-
const def =
|
|
16883
|
+
function generateCheck(doc, ctx, schema2, accessor, needsValue = true) {
|
|
16884
|
+
const def = schema2._zod.def;
|
|
16885
16885
|
const type = def.type;
|
|
16886
16886
|
if (def.coerce) {
|
|
16887
16887
|
throw new ZodCompileUnsupportedError(`coercion (z.coerce.${type}())`);
|
|
@@ -16890,16 +16890,16 @@ function generateCheck(doc, ctx, schema, accessor, needsValue = true) {
|
|
|
16890
16890
|
let typeAccessor;
|
|
16891
16891
|
switch (type) {
|
|
16892
16892
|
case "string":
|
|
16893
|
-
typeAccessor = generateStringCheck(doc, ctx,
|
|
16893
|
+
typeAccessor = generateStringCheck(doc, ctx, schema2, accessor, buildsValue);
|
|
16894
16894
|
break;
|
|
16895
16895
|
case "number":
|
|
16896
|
-
typeAccessor = generateNumberCheck(doc,
|
|
16896
|
+
typeAccessor = generateNumberCheck(doc, schema2, accessor);
|
|
16897
16897
|
break;
|
|
16898
16898
|
case "boolean":
|
|
16899
16899
|
typeAccessor = generateBooleanCheck(doc, accessor);
|
|
16900
16900
|
break;
|
|
16901
16901
|
case "bigint":
|
|
16902
|
-
typeAccessor = generateBigIntCheck(doc,
|
|
16902
|
+
typeAccessor = generateBigIntCheck(doc, schema2, accessor);
|
|
16903
16903
|
break;
|
|
16904
16904
|
case "symbol":
|
|
16905
16905
|
typeAccessor = generateSymbolCheck(doc, accessor);
|
|
@@ -16928,79 +16928,79 @@ function generateCheck(doc, ctx, schema, accessor, needsValue = true) {
|
|
|
16928
16928
|
typeAccessor = generateDateCheck(doc, accessor);
|
|
16929
16929
|
break;
|
|
16930
16930
|
case "object":
|
|
16931
|
-
typeAccessor = generateObjectCheck(doc, ctx,
|
|
16931
|
+
typeAccessor = generateObjectCheck(doc, ctx, schema2, accessor, buildsValue);
|
|
16932
16932
|
break;
|
|
16933
16933
|
case "optional":
|
|
16934
|
-
typeAccessor = generateOptionalCheck(doc, ctx,
|
|
16934
|
+
typeAccessor = generateOptionalCheck(doc, ctx, schema2, accessor, buildsValue);
|
|
16935
16935
|
break;
|
|
16936
16936
|
case "nullable":
|
|
16937
|
-
typeAccessor = generateNullableCheck(doc, ctx,
|
|
16937
|
+
typeAccessor = generateNullableCheck(doc, ctx, schema2, accessor, buildsValue);
|
|
16938
16938
|
break;
|
|
16939
16939
|
case "array":
|
|
16940
|
-
typeAccessor = generateArrayCheck(doc, ctx,
|
|
16940
|
+
typeAccessor = generateArrayCheck(doc, ctx, schema2, accessor, buildsValue);
|
|
16941
16941
|
break;
|
|
16942
16942
|
case "literal":
|
|
16943
|
-
typeAccessor = generateLiteralCheck(doc, ctx,
|
|
16943
|
+
typeAccessor = generateLiteralCheck(doc, ctx, schema2, accessor);
|
|
16944
16944
|
break;
|
|
16945
16945
|
case "enum":
|
|
16946
|
-
typeAccessor = generateEnumCheck(doc, ctx,
|
|
16946
|
+
typeAccessor = generateEnumCheck(doc, ctx, schema2, accessor);
|
|
16947
16947
|
break;
|
|
16948
16948
|
case "readonly": {
|
|
16949
|
-
const innerOut = generateWrapperCheck(doc, ctx,
|
|
16949
|
+
const innerOut = generateWrapperCheck(doc, ctx, schema2, accessor);
|
|
16950
16950
|
const frozenVar = newVar(ctx);
|
|
16951
16951
|
doc.write(`const ${frozenVar} = Object.freeze(${innerOut});`);
|
|
16952
16952
|
typeAccessor = frozenVar;
|
|
16953
16953
|
break;
|
|
16954
16954
|
}
|
|
16955
16955
|
case "success":
|
|
16956
|
-
generateWrapperCheck(doc, ctx,
|
|
16956
|
+
generateWrapperCheck(doc, ctx, schema2, accessor);
|
|
16957
16957
|
typeAccessor = "true";
|
|
16958
16958
|
break;
|
|
16959
16959
|
case "default":
|
|
16960
16960
|
case "prefault":
|
|
16961
|
-
typeAccessor = generateDefaultCheck(doc, ctx,
|
|
16961
|
+
typeAccessor = generateDefaultCheck(doc, ctx, schema2, accessor);
|
|
16962
16962
|
break;
|
|
16963
16963
|
case "nonoptional":
|
|
16964
|
-
typeAccessor = generateNonOptionalCheck(doc, ctx,
|
|
16964
|
+
typeAccessor = generateNonOptionalCheck(doc, ctx, schema2, accessor);
|
|
16965
16965
|
break;
|
|
16966
16966
|
case "tuple":
|
|
16967
|
-
typeAccessor = generateTupleCheck(doc, ctx,
|
|
16967
|
+
typeAccessor = generateTupleCheck(doc, ctx, schema2, accessor);
|
|
16968
16968
|
break;
|
|
16969
16969
|
case "union":
|
|
16970
|
-
typeAccessor = generateUnionCheck(doc, ctx,
|
|
16970
|
+
typeAccessor = generateUnionCheck(doc, ctx, schema2, accessor);
|
|
16971
16971
|
break;
|
|
16972
16972
|
case "intersection":
|
|
16973
|
-
typeAccessor = generateIntersectionCheck(doc, ctx,
|
|
16973
|
+
typeAccessor = generateIntersectionCheck(doc, ctx, schema2, accessor);
|
|
16974
16974
|
break;
|
|
16975
16975
|
case "record":
|
|
16976
|
-
typeAccessor = generateRecordCheck(doc, ctx,
|
|
16976
|
+
typeAccessor = generateRecordCheck(doc, ctx, schema2, accessor);
|
|
16977
16977
|
break;
|
|
16978
16978
|
case "map":
|
|
16979
|
-
typeAccessor = generateMapCheck(doc, ctx,
|
|
16979
|
+
typeAccessor = generateMapCheck(doc, ctx, schema2, accessor);
|
|
16980
16980
|
break;
|
|
16981
16981
|
case "set":
|
|
16982
|
-
typeAccessor = generateSetCheck(doc, ctx,
|
|
16982
|
+
typeAccessor = generateSetCheck(doc, ctx, schema2, accessor);
|
|
16983
16983
|
break;
|
|
16984
16984
|
case "file":
|
|
16985
16985
|
typeAccessor = generateFileCheck(doc, accessor);
|
|
16986
16986
|
break;
|
|
16987
16987
|
case "template_literal":
|
|
16988
|
-
typeAccessor = generateTemplateLiteralCheck(doc, ctx,
|
|
16988
|
+
typeAccessor = generateTemplateLiteralCheck(doc, ctx, schema2, accessor);
|
|
16989
16989
|
break;
|
|
16990
16990
|
case "lazy":
|
|
16991
|
-
typeAccessor = generateLazyCheck(doc, ctx,
|
|
16991
|
+
typeAccessor = generateLazyCheck(doc, ctx, schema2, accessor);
|
|
16992
16992
|
break;
|
|
16993
16993
|
case "pipe":
|
|
16994
|
-
typeAccessor = generatePipeCheck(doc, ctx,
|
|
16994
|
+
typeAccessor = generatePipeCheck(doc, ctx, schema2, accessor);
|
|
16995
16995
|
break;
|
|
16996
16996
|
case "custom":
|
|
16997
|
-
typeAccessor = generateCustomCheck(doc, ctx,
|
|
16997
|
+
typeAccessor = generateCustomCheck(doc, ctx, schema2, accessor);
|
|
16998
16998
|
break;
|
|
16999
16999
|
case "transform":
|
|
17000
|
-
typeAccessor = generateTransformCheck(doc, ctx,
|
|
17000
|
+
typeAccessor = generateTransformCheck(doc, ctx, schema2, accessor);
|
|
17001
17001
|
break;
|
|
17002
17002
|
case "catch":
|
|
17003
|
-
typeAccessor = generateCatchCheck(doc, ctx,
|
|
17003
|
+
typeAccessor = generateCatchCheck(doc, ctx, schema2, accessor);
|
|
17004
17004
|
break;
|
|
17005
17005
|
default: {
|
|
17006
17006
|
void type;
|
|
@@ -17009,18 +17009,18 @@ function generateCheck(doc, ctx, schema, accessor, needsValue = true) {
|
|
|
17009
17009
|
}
|
|
17010
17010
|
if (typeAccessor === null)
|
|
17011
17011
|
return null;
|
|
17012
|
-
return generateChecks(doc, ctx,
|
|
17012
|
+
return generateChecks(doc, ctx, schema2, typeAccessor);
|
|
17013
17013
|
}
|
|
17014
|
-
function generateStringCheck(doc, ctx,
|
|
17014
|
+
function generateStringCheck(doc, ctx, schema2, accessor, needsValue = true) {
|
|
17015
17015
|
doc.write(`if (typeof ${accessor} !== "string") return INVALID;`);
|
|
17016
|
-
const def =
|
|
17016
|
+
const def = schema2._zod.def;
|
|
17017
17017
|
if (def.format === void 0)
|
|
17018
17018
|
return accessor;
|
|
17019
17019
|
return generateStringFormatCheck(doc, ctx, def, accessor, needsValue);
|
|
17020
17020
|
}
|
|
17021
|
-
function generateNumberCheck(doc,
|
|
17021
|
+
function generateNumberCheck(doc, schema2, accessor) {
|
|
17022
17022
|
doc.write(`if (typeof ${accessor} !== "number" || !Number.isFinite(${accessor})) return INVALID;`);
|
|
17023
|
-
const def =
|
|
17023
|
+
const def = schema2._zod.def;
|
|
17024
17024
|
if (def.check === "number_format" && def.format) {
|
|
17025
17025
|
generateNumberFormatCheck(doc, { format: def.format }, accessor);
|
|
17026
17026
|
}
|
|
@@ -17030,9 +17030,9 @@ function generateBooleanCheck(doc, accessor) {
|
|
|
17030
17030
|
doc.write(`if (typeof ${accessor} !== "boolean") return INVALID;`);
|
|
17031
17031
|
return accessor;
|
|
17032
17032
|
}
|
|
17033
|
-
function generateBigIntCheck(doc,
|
|
17033
|
+
function generateBigIntCheck(doc, schema2, accessor) {
|
|
17034
17034
|
doc.write(`if (typeof ${accessor} !== "bigint") return INVALID;`);
|
|
17035
|
-
const def =
|
|
17035
|
+
const def = schema2._zod.def;
|
|
17036
17036
|
if (def.format) {
|
|
17037
17037
|
switch (def.format) {
|
|
17038
17038
|
case "int64":
|
|
@@ -17069,8 +17069,8 @@ function generateDateCheck(doc, accessor) {
|
|
|
17069
17069
|
doc.write(`if (!(${accessor} instanceof Date) || Number.isNaN(${accessor}.getTime())) return INVALID;`);
|
|
17070
17070
|
return accessor;
|
|
17071
17071
|
}
|
|
17072
|
-
function generateObjectCheck(doc, ctx,
|
|
17073
|
-
const def =
|
|
17072
|
+
function generateObjectCheck(doc, ctx, schema2, accessor, buildsValue = true) {
|
|
17073
|
+
const def = schema2._zod.def;
|
|
17074
17074
|
doc.write(`if (typeof ${accessor} !== "object" || ${accessor} === null || Array.isArray(${accessor})) return INVALID;`);
|
|
17075
17075
|
const shape = def.shape;
|
|
17076
17076
|
const keys = Object.keys(shape);
|
|
@@ -17188,9 +17188,9 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
17188
17188
|
}
|
|
17189
17189
|
return outputVar;
|
|
17190
17190
|
}
|
|
17191
|
-
function generateOptionalCheck(doc, ctx,
|
|
17192
|
-
const def =
|
|
17193
|
-
if (isExactOptional(
|
|
17191
|
+
function generateOptionalCheck(doc, ctx, schema2, accessor, buildsValue = true) {
|
|
17192
|
+
const def = schema2._zod.def;
|
|
17193
|
+
if (isExactOptional(schema2)) {
|
|
17194
17194
|
return generateCheck(doc, ctx, def.innerType, accessor, buildsValue);
|
|
17195
17195
|
}
|
|
17196
17196
|
if (def.innerType._zod.optin === "defaulted") {
|
|
@@ -17227,16 +17227,16 @@ function generateOptionalCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
17227
17227
|
doc.write(`}`);
|
|
17228
17228
|
return outputVar;
|
|
17229
17229
|
}
|
|
17230
|
-
function isExactOptional(
|
|
17231
|
-
return
|
|
17230
|
+
function isExactOptional(schema2) {
|
|
17231
|
+
return schema2._zod.traits?.has("$ZodExactOptional") === true;
|
|
17232
17232
|
}
|
|
17233
|
-
function requiresPresenceCheck(
|
|
17234
|
-
return
|
|
17233
|
+
function requiresPresenceCheck(schema2) {
|
|
17234
|
+
return schema2._zod.optin === void 0 && fastPathAcceptsAbsence(schema2);
|
|
17235
17235
|
}
|
|
17236
|
-
function fastPathAcceptsAbsence(
|
|
17237
|
-
if (
|
|
17236
|
+
function fastPathAcceptsAbsence(schema2) {
|
|
17237
|
+
if (schema2._zod.def.coerce)
|
|
17238
17238
|
return true;
|
|
17239
|
-
const def =
|
|
17239
|
+
const def = schema2._zod.def;
|
|
17240
17240
|
switch (def.type) {
|
|
17241
17241
|
case "any":
|
|
17242
17242
|
case "unknown":
|
|
@@ -17271,7 +17271,7 @@ function fastPathAcceptsAbsence(schema) {
|
|
|
17271
17271
|
case "literal":
|
|
17272
17272
|
return !!def.values?.includes(void 0);
|
|
17273
17273
|
case "enum":
|
|
17274
|
-
return !!
|
|
17274
|
+
return !!schema2._zod.values?.has(void 0);
|
|
17275
17275
|
case "optional":
|
|
17276
17276
|
case "nullable":
|
|
17277
17277
|
case "readonly":
|
|
@@ -17291,14 +17291,14 @@ function fastPathAcceptsAbsence(schema) {
|
|
|
17291
17291
|
return true;
|
|
17292
17292
|
}
|
|
17293
17293
|
}
|
|
17294
|
-
function dropsWhenAbsent(
|
|
17295
|
-
return
|
|
17294
|
+
function dropsWhenAbsent(schema2) {
|
|
17295
|
+
return schema2._zod.optin === "optional" && schema2._zod.optout === "optional";
|
|
17296
17296
|
}
|
|
17297
|
-
function mayOmitUndefined(
|
|
17298
|
-
return (
|
|
17297
|
+
function mayOmitUndefined(schema2) {
|
|
17298
|
+
return (schema2._zod.optin !== "defaulted" || schema2._zod.optout === "optional") && mayOutputUndefined(schema2);
|
|
17299
17299
|
}
|
|
17300
|
-
function mayOutputUndefined(
|
|
17301
|
-
const def =
|
|
17300
|
+
function mayOutputUndefined(schema2) {
|
|
17301
|
+
const def = schema2._zod.def;
|
|
17302
17302
|
switch (def.type) {
|
|
17303
17303
|
case "string":
|
|
17304
17304
|
case "number":
|
|
@@ -17322,7 +17322,7 @@ function mayOutputUndefined(schema) {
|
|
|
17322
17322
|
case "literal":
|
|
17323
17323
|
return !!def.values?.includes(void 0);
|
|
17324
17324
|
case "enum":
|
|
17325
|
-
return !!
|
|
17325
|
+
return !!schema2._zod.values?.has(void 0);
|
|
17326
17326
|
case "optional":
|
|
17327
17327
|
return true;
|
|
17328
17328
|
case "nullable":
|
|
@@ -17339,8 +17339,8 @@ function mayOutputUndefined(schema) {
|
|
|
17339
17339
|
return true;
|
|
17340
17340
|
}
|
|
17341
17341
|
}
|
|
17342
|
-
function generateNullableCheck(doc, ctx,
|
|
17343
|
-
const def =
|
|
17342
|
+
function generateNullableCheck(doc, ctx, schema2, accessor, buildsValue = true) {
|
|
17343
|
+
const def = schema2._zod.def;
|
|
17344
17344
|
const outputVar = buildsValue ? newVar(ctx) : null;
|
|
17345
17345
|
if (outputVar)
|
|
17346
17346
|
doc.write(`let ${outputVar} = null;`);
|
|
@@ -17353,8 +17353,8 @@ function generateNullableCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
17353
17353
|
doc.write(`}`);
|
|
17354
17354
|
return outputVar;
|
|
17355
17355
|
}
|
|
17356
|
-
function generateArrayCheck(doc, ctx,
|
|
17357
|
-
const def =
|
|
17356
|
+
function generateArrayCheck(doc, ctx, schema2, accessor, buildsValue = true) {
|
|
17357
|
+
const def = schema2._zod.def;
|
|
17358
17358
|
doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
|
|
17359
17359
|
const outputVar = buildsValue ? newVar(ctx) : null;
|
|
17360
17360
|
const iVar = newVar(ctx);
|
|
@@ -17371,8 +17371,8 @@ function generateArrayCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
17371
17371
|
doc.write(`}`);
|
|
17372
17372
|
return outputVar;
|
|
17373
17373
|
}
|
|
17374
|
-
function generateLiteralCheck(doc, ctx,
|
|
17375
|
-
const def =
|
|
17374
|
+
function generateLiteralCheck(doc, ctx, schema2, accessor) {
|
|
17375
|
+
const def = schema2._zod.def;
|
|
17376
17376
|
const values = def.values;
|
|
17377
17377
|
if (values.length !== 1) {
|
|
17378
17378
|
const literalSet = addConstant(ctx, new Set(values));
|
|
@@ -17400,8 +17400,8 @@ function generateLiteralCheck(doc, ctx, schema, accessor) {
|
|
|
17400
17400
|
}
|
|
17401
17401
|
return accessor;
|
|
17402
17402
|
}
|
|
17403
|
-
function generateEnumCheck(doc, ctx,
|
|
17404
|
-
const values =
|
|
17403
|
+
function generateEnumCheck(doc, ctx, schema2, accessor) {
|
|
17404
|
+
const values = schema2._zod.values;
|
|
17405
17405
|
if (!values) {
|
|
17406
17406
|
throw new ZodCompileUnsupportedError("enum schema without enumerated values");
|
|
17407
17407
|
}
|
|
@@ -17409,15 +17409,15 @@ function generateEnumCheck(doc, ctx, schema, accessor) {
|
|
|
17409
17409
|
doc.write(`if (!${enumSet}.has(${accessor})) return INVALID;`);
|
|
17410
17410
|
return accessor;
|
|
17411
17411
|
}
|
|
17412
|
-
function generateWrapperCheck(doc, ctx,
|
|
17413
|
-
const def =
|
|
17412
|
+
function generateWrapperCheck(doc, ctx, schema2, accessor) {
|
|
17413
|
+
const def = schema2._zod.def;
|
|
17414
17414
|
return generateCheck(doc, ctx, def.innerType, accessor);
|
|
17415
17415
|
}
|
|
17416
|
-
function generateDefaultCheck(doc, ctx,
|
|
17417
|
-
const def =
|
|
17418
|
-
const descriptor = Object.getOwnPropertyDescriptor(
|
|
17419
|
-
const defaultGetter = descriptor ? () =>
|
|
17420
|
-
if (
|
|
17416
|
+
function generateDefaultCheck(doc, ctx, schema2, accessor) {
|
|
17417
|
+
const def = schema2._zod.def;
|
|
17418
|
+
const descriptor = Object.getOwnPropertyDescriptor(schema2._zod.def, "defaultValue");
|
|
17419
|
+
const defaultGetter = descriptor ? () => schema2._zod.def.defaultValue : void 0;
|
|
17420
|
+
if (schema2._zod.def.type === "prefault") {
|
|
17421
17421
|
if (!defaultGetter) {
|
|
17422
17422
|
return generateCheck(doc, ctx, def.innerType, accessor);
|
|
17423
17423
|
}
|
|
@@ -17453,16 +17453,16 @@ function generateDefaultCheck(doc, ctx, schema, accessor) {
|
|
|
17453
17453
|
}
|
|
17454
17454
|
return outputVar;
|
|
17455
17455
|
}
|
|
17456
|
-
function generateNonOptionalCheck(doc, ctx,
|
|
17457
|
-
const def =
|
|
17456
|
+
function generateNonOptionalCheck(doc, ctx, schema2, accessor) {
|
|
17457
|
+
const def = schema2._zod.def;
|
|
17458
17458
|
const innerOutput = generateCheck(doc, ctx, def.innerType, accessor);
|
|
17459
17459
|
const outputVar = newVar(ctx);
|
|
17460
17460
|
doc.write(`const ${outputVar} = ${innerOutput};`);
|
|
17461
17461
|
doc.write(`if (${outputVar} === undefined) return INVALID;`);
|
|
17462
17462
|
return outputVar;
|
|
17463
17463
|
}
|
|
17464
|
-
function generateTupleCheck(doc, ctx,
|
|
17465
|
-
const def =
|
|
17464
|
+
function generateTupleCheck(doc, ctx, schema2, accessor) {
|
|
17465
|
+
const def = schema2._zod.def;
|
|
17466
17466
|
const items = def.items;
|
|
17467
17467
|
const rest = def.rest;
|
|
17468
17468
|
doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
|
|
@@ -17536,8 +17536,8 @@ function getTupleOptStart2(items, key) {
|
|
|
17536
17536
|
}
|
|
17537
17537
|
return 0;
|
|
17538
17538
|
}
|
|
17539
|
-
function generateUnionCheck(doc, ctx,
|
|
17540
|
-
const def =
|
|
17539
|
+
function generateUnionCheck(doc, ctx, schema2, accessor) {
|
|
17540
|
+
const def = schema2._zod.def;
|
|
17541
17541
|
const options = def.options;
|
|
17542
17542
|
if (def.discriminator) {
|
|
17543
17543
|
return generateDiscriminatedUnionCheck(doc, ctx, def, accessor);
|
|
@@ -17637,8 +17637,8 @@ function literalEquality(ctx, accessor, value) {
|
|
|
17637
17637
|
}
|
|
17638
17638
|
throw new ZodCompileUnsupportedError(`literal discriminator value ${String(value)}`);
|
|
17639
17639
|
}
|
|
17640
|
-
function generateIntersectionCheck(doc, ctx,
|
|
17641
|
-
const def =
|
|
17640
|
+
function generateIntersectionCheck(doc, ctx, schema2, accessor) {
|
|
17641
|
+
const def = schema2._zod.def;
|
|
17642
17642
|
ctx.definite = false;
|
|
17643
17643
|
const leftOutput = compileChild(doc, ctx, def.left, accessor);
|
|
17644
17644
|
const rightOutput = compileChild(doc, ctx, def.right, accessor);
|
|
@@ -17648,8 +17648,8 @@ function generateIntersectionCheck(doc, ctx, schema, accessor) {
|
|
|
17648
17648
|
doc.write(`if (!${mergedVar}.valid) return INVALID;`);
|
|
17649
17649
|
return `${mergedVar}.data`;
|
|
17650
17650
|
}
|
|
17651
|
-
function generateRecordCheck(doc, ctx,
|
|
17652
|
-
const def =
|
|
17651
|
+
function generateRecordCheck(doc, ctx, schema2, accessor) {
|
|
17652
|
+
const def = schema2._zod.def;
|
|
17653
17653
|
const isPlainObjectConst = addConstant(ctx, isPlainObject);
|
|
17654
17654
|
doc.write(`if (!${isPlainObjectConst}(${accessor})) return INVALID;`);
|
|
17655
17655
|
const outputVar = newVar(ctx);
|
|
@@ -17752,8 +17752,8 @@ function literalPropertyKey(ctx, key) {
|
|
|
17752
17752
|
return esc(key);
|
|
17753
17753
|
return addConstant(ctx, key);
|
|
17754
17754
|
}
|
|
17755
|
-
function generateMapCheck(doc, ctx,
|
|
17756
|
-
const def =
|
|
17755
|
+
function generateMapCheck(doc, ctx, schema2, accessor) {
|
|
17756
|
+
const def = schema2._zod.def;
|
|
17757
17757
|
doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
|
|
17758
17758
|
const outputVar = newVar(ctx);
|
|
17759
17759
|
const kVar = newVar(ctx);
|
|
@@ -17768,8 +17768,8 @@ function generateMapCheck(doc, ctx, schema, accessor) {
|
|
|
17768
17768
|
doc.write(`}`);
|
|
17769
17769
|
return outputVar;
|
|
17770
17770
|
}
|
|
17771
|
-
function generateSetCheck(doc, ctx,
|
|
17772
|
-
const def =
|
|
17771
|
+
function generateSetCheck(doc, ctx, schema2, accessor) {
|
|
17772
|
+
const def = schema2._zod.def;
|
|
17773
17773
|
doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
|
|
17774
17774
|
const outputVar = newVar(ctx);
|
|
17775
17775
|
const valVar = newVar(ctx);
|
|
@@ -17786,9 +17786,9 @@ function generateFileCheck(doc, accessor) {
|
|
|
17786
17786
|
doc.write(`if (!(${accessor} instanceof File)) return INVALID;`);
|
|
17787
17787
|
return accessor;
|
|
17788
17788
|
}
|
|
17789
|
-
function generateTemplateLiteralCheck(doc, ctx,
|
|
17789
|
+
function generateTemplateLiteralCheck(doc, ctx, schema2, accessor) {
|
|
17790
17790
|
doc.write(`if (typeof ${accessor} !== "string") return INVALID;`);
|
|
17791
|
-
const pattern =
|
|
17791
|
+
const pattern = schema2._zod.pattern;
|
|
17792
17792
|
if (pattern) {
|
|
17793
17793
|
const patternConst = addConstant(ctx, pattern);
|
|
17794
17794
|
doc.write(`${patternConst}.lastIndex = 0;`);
|
|
@@ -17796,8 +17796,8 @@ function generateTemplateLiteralCheck(doc, ctx, schema, accessor) {
|
|
|
17796
17796
|
}
|
|
17797
17797
|
return accessor;
|
|
17798
17798
|
}
|
|
17799
|
-
function generateLazyCheck(doc, ctx,
|
|
17800
|
-
const def =
|
|
17799
|
+
function generateLazyCheck(doc, ctx, schema2, accessor) {
|
|
17800
|
+
const def = schema2._zod.def;
|
|
17801
17801
|
const getterConst = addUserConstant(ctx, def.getter);
|
|
17802
17802
|
const cacheConst = addConstant(ctx, { parser: null });
|
|
17803
17803
|
doc.write(`if (!${cacheConst}.parser) {`);
|
|
@@ -17816,8 +17816,8 @@ function generateLazyCheck(doc, ctx, schema, accessor) {
|
|
|
17816
17816
|
doc.write(`if (${outputVar} === INVALID) return INVALID;`);
|
|
17817
17817
|
return outputVar;
|
|
17818
17818
|
}
|
|
17819
|
-
function generatePipeCheck(doc, ctx,
|
|
17820
|
-
const def =
|
|
17819
|
+
function generatePipeCheck(doc, ctx, schema2, accessor) {
|
|
17820
|
+
const def = schema2._zod.def;
|
|
17821
17821
|
const inputOutput = generateCheck(doc, ctx, def.in, accessor);
|
|
17822
17822
|
if (def.transform) {
|
|
17823
17823
|
if (isAsyncFunction(def.transform)) {
|
|
@@ -17843,8 +17843,8 @@ function generatePipeCheck(doc, ctx, schema, accessor) {
|
|
|
17843
17843
|
function isAsyncFunction(fn) {
|
|
17844
17844
|
return typeof fn === "function" && (fn.constructor.name === "AsyncFunction" || fn[Symbol.toStringTag] === "AsyncFunction");
|
|
17845
17845
|
}
|
|
17846
|
-
function generateCustomCheck(doc, ctx,
|
|
17847
|
-
const def =
|
|
17846
|
+
function generateCustomCheck(doc, ctx, schema2, accessor) {
|
|
17847
|
+
const def = schema2._zod.def;
|
|
17848
17848
|
if (def.fn) {
|
|
17849
17849
|
if (isAsyncFunction(def.fn)) {
|
|
17850
17850
|
throw new ZodCompileAsyncError("z.compile: async custom predicates are not supported");
|
|
@@ -17869,8 +17869,8 @@ function runtimeCatch(innerSchema, catchValue, value) {
|
|
|
17869
17869
|
return r.value;
|
|
17870
17870
|
return catchValue();
|
|
17871
17871
|
}
|
|
17872
|
-
function generateCatchCheck(doc, ctx,
|
|
17873
|
-
const def =
|
|
17872
|
+
function generateCatchCheck(doc, ctx, schema2, accessor) {
|
|
17873
|
+
const def = schema2._zod.def;
|
|
17874
17874
|
if (!def.catchValue[CONSTANT_CATCH]) {
|
|
17875
17875
|
throw new ZodCompileUnsupportedError("catch with a callback (only a constant catch value compiles)", false);
|
|
17876
17876
|
}
|
|
@@ -17892,8 +17892,8 @@ function generateCatchCheck(doc, ctx, schema, accessor) {
|
|
|
17892
17892
|
doc.write(`}`);
|
|
17893
17893
|
return outputVar;
|
|
17894
17894
|
}
|
|
17895
|
-
function generateTransformCheck(doc, ctx,
|
|
17896
|
-
const def =
|
|
17895
|
+
function generateTransformCheck(doc, ctx, schema2, accessor) {
|
|
17896
|
+
const def = schema2._zod.def;
|
|
17897
17897
|
if (def.transform) {
|
|
17898
17898
|
if (isAsyncFunction(def.transform)) {
|
|
17899
17899
|
throw new ZodCompileAsyncError("z.compile: async transforms are not supported");
|
|
@@ -18568,11 +18568,11 @@ function _endsWith(suffix, params) {
|
|
|
18568
18568
|
});
|
|
18569
18569
|
}
|
|
18570
18570
|
// @__NO_SIDE_EFFECTS__
|
|
18571
|
-
function _property(property,
|
|
18571
|
+
function _property(property, schema2, params) {
|
|
18572
18572
|
return new $ZodCheckProperty({
|
|
18573
18573
|
check: "property",
|
|
18574
18574
|
property,
|
|
18575
|
-
schema,
|
|
18575
|
+
schema: schema2,
|
|
18576
18576
|
...normalizeParams(params)
|
|
18577
18577
|
});
|
|
18578
18578
|
}
|
|
@@ -18828,23 +18828,23 @@ function _promise(Class2, innerType) {
|
|
|
18828
18828
|
function _custom(Class2, fn, _params) {
|
|
18829
18829
|
const norm = normalizeParams(_params);
|
|
18830
18830
|
norm.abort ?? (norm.abort = true);
|
|
18831
|
-
const
|
|
18831
|
+
const schema2 = new Class2({
|
|
18832
18832
|
type: "custom",
|
|
18833
18833
|
check: "custom",
|
|
18834
18834
|
fn,
|
|
18835
18835
|
...norm
|
|
18836
18836
|
});
|
|
18837
|
-
return
|
|
18837
|
+
return schema2;
|
|
18838
18838
|
}
|
|
18839
18839
|
// @__NO_SIDE_EFFECTS__
|
|
18840
18840
|
function _refine(Class2, fn, _params) {
|
|
18841
|
-
const
|
|
18841
|
+
const schema2 = new Class2({
|
|
18842
18842
|
type: "custom",
|
|
18843
18843
|
check: "custom",
|
|
18844
18844
|
fn,
|
|
18845
18845
|
...normalizeParams(_params)
|
|
18846
18846
|
});
|
|
18847
|
-
return
|
|
18847
|
+
return schema2;
|
|
18848
18848
|
}
|
|
18849
18849
|
// @__NO_SIDE_EFFECTS__
|
|
18850
18850
|
function _superRefine(fn, params) {
|
|
@@ -19010,8 +19010,8 @@ function initializeContext(params) {
|
|
|
19010
19010
|
external: params?.external ?? void 0
|
|
19011
19011
|
};
|
|
19012
19012
|
}
|
|
19013
|
-
function handleUnrepresentable(
|
|
19014
|
-
const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({ zodSchema:
|
|
19013
|
+
function handleUnrepresentable(schema2, ctx, json2, params, message) {
|
|
19014
|
+
const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({ zodSchema: schema2, path: params.path, message }) : ctx.unrepresentable;
|
|
19015
19015
|
if (result === "any")
|
|
19016
19016
|
return false;
|
|
19017
19017
|
if (result === void 0 || result === "throw")
|
|
@@ -19019,42 +19019,42 @@ function handleUnrepresentable(schema, ctx, json2, params, message) {
|
|
|
19019
19019
|
Object.assign(json2, result);
|
|
19020
19020
|
return true;
|
|
19021
19021
|
}
|
|
19022
|
-
function processSchema(
|
|
19022
|
+
function processSchema(schema2, ctx, _params = { path: [], schemaPath: [] }) {
|
|
19023
19023
|
var _a3;
|
|
19024
|
-
const def =
|
|
19025
|
-
const seen = ctx.seen.get(
|
|
19024
|
+
const def = schema2._zod.def;
|
|
19025
|
+
const seen = ctx.seen.get(schema2);
|
|
19026
19026
|
if (seen) {
|
|
19027
19027
|
seen.count++;
|
|
19028
|
-
const isCycle = _params.schemaPath.includes(
|
|
19028
|
+
const isCycle = _params.schemaPath.includes(schema2);
|
|
19029
19029
|
if (isCycle) {
|
|
19030
19030
|
seen.cycle = _params.path;
|
|
19031
19031
|
}
|
|
19032
19032
|
return seen.schema;
|
|
19033
19033
|
}
|
|
19034
19034
|
const result = { schema: {}, count: 1, cycle: void 0, path: _params.path };
|
|
19035
|
-
ctx.seen.set(
|
|
19035
|
+
ctx.seen.set(schema2, result);
|
|
19036
19036
|
ctx.sharedDefsExtractedFor = void 0;
|
|
19037
19037
|
ctx.sharedEmitDoneFor = void 0;
|
|
19038
|
-
const overrideSchema =
|
|
19038
|
+
const overrideSchema = schema2._zod.toJSONSchema?.();
|
|
19039
19039
|
if (overrideSchema) {
|
|
19040
19040
|
result.schema = overrideSchema;
|
|
19041
19041
|
} else {
|
|
19042
19042
|
const params = {
|
|
19043
19043
|
..._params,
|
|
19044
|
-
schemaPath: [..._params.schemaPath,
|
|
19044
|
+
schemaPath: [..._params.schemaPath, schema2],
|
|
19045
19045
|
path: _params.path
|
|
19046
19046
|
};
|
|
19047
|
-
if (
|
|
19048
|
-
|
|
19047
|
+
if (schema2._zod.processJSONSchema) {
|
|
19048
|
+
schema2._zod.processJSONSchema(ctx, result.schema, params);
|
|
19049
19049
|
} else {
|
|
19050
19050
|
const _json = result.schema;
|
|
19051
19051
|
const processor = ctx.processors[def.type];
|
|
19052
19052
|
if (!processor) {
|
|
19053
19053
|
throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
|
19054
19054
|
}
|
|
19055
|
-
processor(
|
|
19055
|
+
processor(schema2, ctx, _json, params);
|
|
19056
19056
|
}
|
|
19057
|
-
const parent =
|
|
19057
|
+
const parent = schema2._zod.parent;
|
|
19058
19058
|
if (parent) {
|
|
19059
19059
|
if (!result.ref)
|
|
19060
19060
|
result.ref = parent;
|
|
@@ -19062,24 +19062,24 @@ function processSchema(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
19062
19062
|
ctx.seen.get(parent).isParent = true;
|
|
19063
19063
|
}
|
|
19064
19064
|
}
|
|
19065
|
-
const meta3 = ctx.metadataRegistry.get(
|
|
19065
|
+
const meta3 = ctx.metadataRegistry.get(schema2);
|
|
19066
19066
|
if (meta3)
|
|
19067
19067
|
assignProps(result.schema, meta3);
|
|
19068
|
-
if (ctx.io === "input" && isTransforming(
|
|
19068
|
+
if (ctx.io === "input" && isTransforming(schema2)) {
|
|
19069
19069
|
delete result.schema.examples;
|
|
19070
19070
|
delete result.schema.default;
|
|
19071
19071
|
}
|
|
19072
19072
|
if (ctx.io === "input" && "_prefault" in result.schema)
|
|
19073
19073
|
(_a3 = result.schema).default ?? (_a3.default = result.schema._prefault);
|
|
19074
19074
|
delete result.schema._prefault;
|
|
19075
|
-
const _result = ctx.seen.get(
|
|
19075
|
+
const _result = ctx.seen.get(schema2);
|
|
19076
19076
|
return _result.schema;
|
|
19077
19077
|
}
|
|
19078
19078
|
function encodeJSONPointerSegment(segment) {
|
|
19079
19079
|
return segment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
19080
19080
|
}
|
|
19081
|
-
function extractDefs(ctx,
|
|
19082
|
-
const root = ctx.seen.get(
|
|
19081
|
+
function extractDefs(ctx, schema2) {
|
|
19082
|
+
const root = ctx.seen.get(schema2);
|
|
19083
19083
|
if (!root)
|
|
19084
19084
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
19085
19085
|
if (ctx.external && ctx.sharedDefsExtractedFor === ctx.external)
|
|
@@ -19124,11 +19124,11 @@ function extractDefs(ctx, schema) {
|
|
|
19124
19124
|
seen.def = { ...seen.schema };
|
|
19125
19125
|
if (defId)
|
|
19126
19126
|
seen.defId = defId;
|
|
19127
|
-
const
|
|
19128
|
-
for (const key in
|
|
19129
|
-
delete
|
|
19127
|
+
const schema3 = seen.schema;
|
|
19128
|
+
for (const key in schema3) {
|
|
19129
|
+
delete schema3[key];
|
|
19130
19130
|
}
|
|
19131
|
-
|
|
19131
|
+
schema3.$ref = ref;
|
|
19132
19132
|
};
|
|
19133
19133
|
if (ctx.cycles === "throw") {
|
|
19134
19134
|
for (const entry of ctx.seen.entries()) {
|
|
@@ -19142,13 +19142,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
19142
19142
|
}
|
|
19143
19143
|
for (const entry of ctx.seen.entries()) {
|
|
19144
19144
|
const seen = entry[1];
|
|
19145
|
-
if (
|
|
19145
|
+
if (schema2 === entry[0]) {
|
|
19146
19146
|
extractToDef(entry);
|
|
19147
19147
|
continue;
|
|
19148
19148
|
}
|
|
19149
19149
|
if (ctx.external) {
|
|
19150
19150
|
const ext = ctx.external.registry.get(entry[0])?.id;
|
|
19151
|
-
if (
|
|
19151
|
+
if (schema2 !== entry[0] && ext) {
|
|
19152
19152
|
extractToDef(entry);
|
|
19153
19153
|
continue;
|
|
19154
19154
|
}
|
|
@@ -19171,9 +19171,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
19171
19171
|
if (ctx.external)
|
|
19172
19172
|
ctx.sharedDefsExtractedFor = ctx.external;
|
|
19173
19173
|
}
|
|
19174
|
-
function compactTypeUnion(
|
|
19175
|
-
const options =
|
|
19176
|
-
if (!Array.isArray(options) || options.length === 0 ||
|
|
19174
|
+
function compactTypeUnion(schema2) {
|
|
19175
|
+
const options = schema2.anyOf;
|
|
19176
|
+
if (!Array.isArray(options) || options.length === 0 || schema2.type !== void 0)
|
|
19177
19177
|
return;
|
|
19178
19178
|
const types = [];
|
|
19179
19179
|
for (const option of options) {
|
|
@@ -19191,8 +19191,8 @@ function compactTypeUnion(schema) {
|
|
|
19191
19191
|
types.push(member);
|
|
19192
19192
|
}
|
|
19193
19193
|
}
|
|
19194
|
-
delete
|
|
19195
|
-
|
|
19194
|
+
delete schema2.anyOf;
|
|
19195
|
+
schema2.type = types.length === 1 ? types[0] : types;
|
|
19196
19196
|
}
|
|
19197
19197
|
var FOLDABLE_KEYS = /* @__PURE__ */ new Set(["type", "properties", "required", "additionalProperties"]);
|
|
19198
19198
|
var UNION_KEYS = ["oneOf", "anyOf"];
|
|
@@ -19279,16 +19279,16 @@ function foldIntersection(json2) {
|
|
|
19279
19279
|
delete json2.allOf;
|
|
19280
19280
|
assignProps(json2, folded);
|
|
19281
19281
|
}
|
|
19282
|
-
function finalize(ctx,
|
|
19283
|
-
const root = ctx.seen.get(
|
|
19282
|
+
function finalize(ctx, schema2) {
|
|
19283
|
+
const root = ctx.seen.get(schema2);
|
|
19284
19284
|
if (!root)
|
|
19285
19285
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
19286
19286
|
const flattenRef = (zodSchema) => {
|
|
19287
19287
|
const seen = ctx.seen.get(zodSchema);
|
|
19288
19288
|
if (seen.ref === null)
|
|
19289
19289
|
return;
|
|
19290
|
-
const
|
|
19291
|
-
const _cached = { ...
|
|
19290
|
+
const schema3 = seen.def ?? seen.schema;
|
|
19291
|
+
const _cached = { ...schema3 };
|
|
19292
19292
|
const ref = seen.ref;
|
|
19293
19293
|
seen.ref = null;
|
|
19294
19294
|
if (ref) {
|
|
@@ -19296,28 +19296,28 @@ function finalize(ctx, schema) {
|
|
|
19296
19296
|
const refSeen = ctx.seen.get(ref);
|
|
19297
19297
|
const refSchema = refSeen.schema;
|
|
19298
19298
|
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
19299
|
-
|
|
19300
|
-
|
|
19299
|
+
schema3.allOf = schema3.allOf ?? [];
|
|
19300
|
+
schema3.allOf.push(refSchema);
|
|
19301
19301
|
} else {
|
|
19302
|
-
assignProps(
|
|
19302
|
+
assignProps(schema3, refSchema);
|
|
19303
19303
|
}
|
|
19304
|
-
assignProps(
|
|
19304
|
+
assignProps(schema3, _cached);
|
|
19305
19305
|
const isParentRef = zodSchema._zod.parent === ref;
|
|
19306
19306
|
if (isParentRef) {
|
|
19307
|
-
for (const key in
|
|
19307
|
+
for (const key in schema3) {
|
|
19308
19308
|
if (key === "$ref" || key === "allOf")
|
|
19309
19309
|
continue;
|
|
19310
19310
|
if (!(key in _cached)) {
|
|
19311
|
-
delete
|
|
19311
|
+
delete schema3[key];
|
|
19312
19312
|
}
|
|
19313
19313
|
}
|
|
19314
19314
|
}
|
|
19315
19315
|
if (refSchema.$ref && refSeen.def) {
|
|
19316
|
-
for (const key in
|
|
19316
|
+
for (const key in schema3) {
|
|
19317
19317
|
if (key === "$ref" || key === "allOf")
|
|
19318
19318
|
continue;
|
|
19319
|
-
if (key in refSeen.def && JSON.stringify(
|
|
19320
|
-
delete
|
|
19319
|
+
if (key in refSeen.def && JSON.stringify(schema3[key]) === JSON.stringify(refSeen.def[key])) {
|
|
19320
|
+
delete schema3[key];
|
|
19321
19321
|
}
|
|
19322
19322
|
}
|
|
19323
19323
|
}
|
|
@@ -19327,13 +19327,13 @@ function finalize(ctx, schema) {
|
|
|
19327
19327
|
flattenRef(parent);
|
|
19328
19328
|
const parentSeen = ctx.seen.get(parent);
|
|
19329
19329
|
if (parentSeen?.schema.$ref) {
|
|
19330
|
-
|
|
19330
|
+
schema3.$ref = parentSeen.schema.$ref;
|
|
19331
19331
|
if (parentSeen.def) {
|
|
19332
|
-
for (const key in
|
|
19332
|
+
for (const key in schema3) {
|
|
19333
19333
|
if (key === "$ref" || key === "allOf")
|
|
19334
19334
|
continue;
|
|
19335
|
-
if (key in parentSeen.def && JSON.stringify(
|
|
19336
|
-
delete
|
|
19335
|
+
if (key in parentSeen.def && JSON.stringify(schema3[key]) === JSON.stringify(parentSeen.def[key])) {
|
|
19336
|
+
delete schema3[key];
|
|
19337
19337
|
}
|
|
19338
19338
|
}
|
|
19339
19339
|
}
|
|
@@ -19341,7 +19341,7 @@ function finalize(ctx, schema) {
|
|
|
19341
19341
|
}
|
|
19342
19342
|
ctx.override({
|
|
19343
19343
|
zodSchema,
|
|
19344
|
-
jsonSchema:
|
|
19344
|
+
jsonSchema: schema3,
|
|
19345
19345
|
path: seen.path ?? []
|
|
19346
19346
|
});
|
|
19347
19347
|
};
|
|
@@ -19387,13 +19387,13 @@ function finalize(ctx, schema) {
|
|
|
19387
19387
|
} else {
|
|
19388
19388
|
}
|
|
19389
19389
|
if (ctx.external?.uri) {
|
|
19390
|
-
const id = ctx.external.registry.get(
|
|
19390
|
+
const id = ctx.external.registry.get(schema2)?.id;
|
|
19391
19391
|
if (!id)
|
|
19392
19392
|
throw new Error("Schema is missing an `id` property");
|
|
19393
19393
|
result.$id = ctx.external.uri(id);
|
|
19394
19394
|
}
|
|
19395
19395
|
assignProps(result, root.defId ? root.schema : root.def ?? root.schema);
|
|
19396
|
-
const rootMetaId = ctx.metadataRegistry.get(
|
|
19396
|
+
const rootMetaId = ctx.metadataRegistry.get(schema2)?.id;
|
|
19397
19397
|
if (rootMetaId !== void 0 && result.id === rootMetaId)
|
|
19398
19398
|
delete result.id;
|
|
19399
19399
|
const defs = ctx.external?.defs ?? {};
|
|
@@ -19423,10 +19423,10 @@ function finalize(ctx, schema) {
|
|
|
19423
19423
|
const finalized = JSON.parse(JSON.stringify(result));
|
|
19424
19424
|
Object.defineProperty(finalized, "~standard", {
|
|
19425
19425
|
value: {
|
|
19426
|
-
...
|
|
19426
|
+
...schema2["~standard"],
|
|
19427
19427
|
jsonSchema: {
|
|
19428
|
-
input: createStandardJSONSchemaMethod(
|
|
19429
|
-
output: createStandardJSONSchemaMethod(
|
|
19428
|
+
input: createStandardJSONSchemaMethod(schema2, "input", ctx.processors),
|
|
19429
|
+
output: createStandardJSONSchemaMethod(schema2, "output", ctx.processors)
|
|
19430
19430
|
}
|
|
19431
19431
|
},
|
|
19432
19432
|
enumerable: false,
|
|
@@ -19490,18 +19490,18 @@ function isTransforming(_schema, _ctx) {
|
|
|
19490
19490
|
}
|
|
19491
19491
|
return false;
|
|
19492
19492
|
}
|
|
19493
|
-
var createToJSONSchemaMethod = (
|
|
19493
|
+
var createToJSONSchemaMethod = (schema2, processors = {}) => (params) => {
|
|
19494
19494
|
const ctx = initializeContext({ ...params, processors });
|
|
19495
|
-
processSchema(
|
|
19496
|
-
extractDefs(ctx,
|
|
19497
|
-
return finalize(ctx,
|
|
19495
|
+
processSchema(schema2, ctx);
|
|
19496
|
+
extractDefs(ctx, schema2);
|
|
19497
|
+
return finalize(ctx, schema2);
|
|
19498
19498
|
};
|
|
19499
|
-
var createStandardJSONSchemaMethod = (
|
|
19499
|
+
var createStandardJSONSchemaMethod = (schema2, io, processors = {}) => (params) => {
|
|
19500
19500
|
const { libraryOptions, target } = params ?? {};
|
|
19501
19501
|
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
19502
|
-
processSchema(
|
|
19503
|
-
extractDefs(ctx,
|
|
19504
|
-
return finalize(ctx,
|
|
19502
|
+
processSchema(schema2, ctx);
|
|
19503
|
+
extractDefs(ctx, schema2);
|
|
19504
|
+
return finalize(ctx, schema2);
|
|
19505
19505
|
};
|
|
19506
19506
|
|
|
19507
19507
|
// ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/json-schema-processors.js
|
|
@@ -19565,13 +19565,13 @@ var contributors = {
|
|
|
19565
19565
|
},
|
|
19566
19566
|
mime_type: (agg, def) => intersectMime(agg, def.mime)
|
|
19567
19567
|
};
|
|
19568
|
-
function aggregateChecks(
|
|
19568
|
+
function aggregateChecks(schema2) {
|
|
19569
19569
|
const agg = {};
|
|
19570
|
-
const def =
|
|
19571
|
-
const list =
|
|
19570
|
+
const def = schema2._zod.def;
|
|
19571
|
+
const list = schema2._zod.traits.has("$ZodCheck") ? [schema2, ...def.checks ?? []] : def.checks ?? [];
|
|
19572
19572
|
for (const ch of list)
|
|
19573
19573
|
contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
19574
|
-
const bag =
|
|
19574
|
+
const bag = schema2._zod.bag;
|
|
19575
19575
|
if (bag.minimum !== void 0)
|
|
19576
19576
|
narrowMin(agg, "minimum", bag.minimum);
|
|
19577
19577
|
if (bag.exclusiveMinimum !== void 0)
|
|
@@ -19606,10 +19606,10 @@ var exactPatterns = /* @__PURE__ */ new Map([
|
|
|
19606
19606
|
[base64urlCharset, base64url]
|
|
19607
19607
|
]);
|
|
19608
19608
|
var exactPattern = (p) => exactPatterns.get(p) ?? p;
|
|
19609
|
-
var stringProcessor = (
|
|
19609
|
+
var stringProcessor = (schema2, ctx, _json, _params) => {
|
|
19610
19610
|
const json2 = _json;
|
|
19611
19611
|
json2.type = "string";
|
|
19612
|
-
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(
|
|
19612
|
+
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema2);
|
|
19613
19613
|
if (typeof minimum === "number")
|
|
19614
19614
|
json2.minLength = minimum;
|
|
19615
19615
|
if (typeof maximum === "number")
|
|
@@ -19638,9 +19638,9 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
19638
19638
|
}
|
|
19639
19639
|
}
|
|
19640
19640
|
};
|
|
19641
|
-
var numberProcessor = (
|
|
19641
|
+
var numberProcessor = (schema2, ctx, _json, params) => {
|
|
19642
19642
|
const json2 = _json;
|
|
19643
|
-
const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(
|
|
19643
|
+
const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema2);
|
|
19644
19644
|
json2.type = isInt ? "integer" : "number";
|
|
19645
19645
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
19646
19646
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
@@ -19671,7 +19671,7 @@ var numberProcessor = (schema, ctx, _json, params) => {
|
|
|
19671
19671
|
if (Number.isFinite(divisor) && divisor !== 0)
|
|
19672
19672
|
divisors.add(Math.abs(divisor));
|
|
19673
19673
|
else
|
|
19674
|
-
handleUnrepresentable(
|
|
19674
|
+
handleUnrepresentable(schema2, ctx, json2, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
|
|
19675
19675
|
}
|
|
19676
19676
|
const [first, ...rest] = divisors;
|
|
19677
19677
|
if (first !== void 0)
|
|
@@ -19683,11 +19683,11 @@ var numberProcessor = (schema, ctx, _json, params) => {
|
|
|
19683
19683
|
var booleanProcessor = (_schema, _ctx, json2, _params) => {
|
|
19684
19684
|
json2.type = "boolean";
|
|
19685
19685
|
};
|
|
19686
|
-
var bigintProcessor = (
|
|
19687
|
-
handleUnrepresentable(
|
|
19686
|
+
var bigintProcessor = (schema2, ctx, json2, params) => {
|
|
19687
|
+
handleUnrepresentable(schema2, ctx, json2, params, "BigInt cannot be represented in JSON Schema");
|
|
19688
19688
|
};
|
|
19689
|
-
var symbolProcessor = (
|
|
19690
|
-
handleUnrepresentable(
|
|
19689
|
+
var symbolProcessor = (schema2, ctx, json2, params) => {
|
|
19690
|
+
handleUnrepresentable(schema2, ctx, json2, params, "Symbols cannot be represented in JSON Schema");
|
|
19691
19691
|
};
|
|
19692
19692
|
var nullProcessor = (_schema, ctx, json2, _params) => {
|
|
19693
19693
|
if (ctx.target === "openapi-3.0") {
|
|
@@ -19698,11 +19698,11 @@ var nullProcessor = (_schema, ctx, json2, _params) => {
|
|
|
19698
19698
|
json2.type = "null";
|
|
19699
19699
|
}
|
|
19700
19700
|
};
|
|
19701
|
-
var undefinedProcessor = (
|
|
19702
|
-
handleUnrepresentable(
|
|
19701
|
+
var undefinedProcessor = (schema2, ctx, json2, params) => {
|
|
19702
|
+
handleUnrepresentable(schema2, ctx, json2, params, "Undefined cannot be represented in JSON Schema");
|
|
19703
19703
|
};
|
|
19704
|
-
var voidProcessor = (
|
|
19705
|
-
handleUnrepresentable(
|
|
19704
|
+
var voidProcessor = (schema2, ctx, json2, params) => {
|
|
19705
|
+
handleUnrepresentable(schema2, ctx, json2, params, "Void cannot be represented in JSON Schema");
|
|
19706
19706
|
};
|
|
19707
19707
|
var neverProcessor = (_schema, _ctx, json2, _params) => {
|
|
19708
19708
|
json2.not = {};
|
|
@@ -19711,11 +19711,11 @@ var anyProcessor = (_schema, _ctx, _json, _params) => {
|
|
|
19711
19711
|
};
|
|
19712
19712
|
var unknownProcessor = (_schema, _ctx, _json, _params) => {
|
|
19713
19713
|
};
|
|
19714
|
-
var dateProcessor = (
|
|
19715
|
-
handleUnrepresentable(
|
|
19714
|
+
var dateProcessor = (schema2, ctx, json2, params) => {
|
|
19715
|
+
handleUnrepresentable(schema2, ctx, json2, params, "Date cannot be represented in JSON Schema");
|
|
19716
19716
|
};
|
|
19717
|
-
var enumProcessor = (
|
|
19718
|
-
const def =
|
|
19717
|
+
var enumProcessor = (schema2, _ctx, json2, _params) => {
|
|
19718
|
+
const def = schema2._zod.def;
|
|
19719
19719
|
const values = getEnumValues(def.entries);
|
|
19720
19720
|
if (values.length === 0) {
|
|
19721
19721
|
json2.not = {};
|
|
@@ -19727,8 +19727,8 @@ var enumProcessor = (schema, _ctx, json2, _params) => {
|
|
|
19727
19727
|
json2.type = "string";
|
|
19728
19728
|
json2.enum = values;
|
|
19729
19729
|
};
|
|
19730
|
-
var literalProcessor = (
|
|
19731
|
-
const def =
|
|
19730
|
+
var literalProcessor = (schema2, ctx, json2, params) => {
|
|
19731
|
+
const def = schema2._zod.def;
|
|
19732
19732
|
if (def.values.length === 0) {
|
|
19733
19733
|
json2.not = {};
|
|
19734
19734
|
return;
|
|
@@ -19736,10 +19736,10 @@ var literalProcessor = (schema, ctx, json2, params) => {
|
|
|
19736
19736
|
const vals = [];
|
|
19737
19737
|
for (const val of def.values) {
|
|
19738
19738
|
if (val === void 0) {
|
|
19739
|
-
if (handleUnrepresentable(
|
|
19739
|
+
if (handleUnrepresentable(schema2, ctx, json2, params, "Literal `undefined` cannot be represented in JSON Schema"))
|
|
19740
19740
|
return;
|
|
19741
19741
|
} else if (typeof val === "bigint") {
|
|
19742
|
-
if (handleUnrepresentable(
|
|
19742
|
+
if (handleUnrepresentable(schema2, ctx, json2, params, "BigInt literals cannot be represented in JSON Schema"))
|
|
19743
19743
|
return;
|
|
19744
19744
|
vals.push(Number(val));
|
|
19745
19745
|
} else {
|
|
@@ -19767,23 +19767,23 @@ var literalProcessor = (schema, ctx, json2, params) => {
|
|
|
19767
19767
|
json2.enum = vals;
|
|
19768
19768
|
}
|
|
19769
19769
|
};
|
|
19770
|
-
var nanProcessor = (
|
|
19771
|
-
handleUnrepresentable(
|
|
19770
|
+
var nanProcessor = (schema2, ctx, json2, params) => {
|
|
19771
|
+
handleUnrepresentable(schema2, ctx, json2, params, "NaN cannot be represented in JSON Schema");
|
|
19772
19772
|
};
|
|
19773
|
-
var templateLiteralProcessor = (
|
|
19773
|
+
var templateLiteralProcessor = (schema2, _ctx, json2, _params) => {
|
|
19774
19774
|
const _json = json2;
|
|
19775
|
-
const pattern =
|
|
19775
|
+
const pattern = schema2._zod.pattern;
|
|
19776
19776
|
if (!pattern)
|
|
19777
19777
|
throw new Error("Pattern not found in template literal");
|
|
19778
19778
|
_json.type = "string";
|
|
19779
19779
|
_json.pattern = pattern.source;
|
|
19780
19780
|
};
|
|
19781
|
-
var fileProcessor = (
|
|
19781
|
+
var fileProcessor = (schema2, _ctx, json2, _params) => {
|
|
19782
19782
|
const _json = json2;
|
|
19783
19783
|
_json.type = "string";
|
|
19784
19784
|
_json.format = "binary";
|
|
19785
19785
|
_json.contentEncoding = "binary";
|
|
19786
|
-
const { minimum, maximum, mime } = aggregateChecks(
|
|
19786
|
+
const { minimum, maximum, mime } = aggregateChecks(schema2);
|
|
19787
19787
|
if (minimum !== void 0)
|
|
19788
19788
|
_json.minLength = minimum;
|
|
19789
19789
|
if (maximum !== void 0)
|
|
@@ -19800,25 +19800,25 @@ var fileProcessor = (schema, _ctx, json2, _params) => {
|
|
|
19800
19800
|
var successProcessor = (_schema, _ctx, json2, _params) => {
|
|
19801
19801
|
json2.type = "boolean";
|
|
19802
19802
|
};
|
|
19803
|
-
var customProcessor = (
|
|
19804
|
-
handleUnrepresentable(
|
|
19803
|
+
var customProcessor = (schema2, ctx, json2, params) => {
|
|
19804
|
+
handleUnrepresentable(schema2, ctx, json2, params, "Custom types cannot be represented in JSON Schema");
|
|
19805
19805
|
};
|
|
19806
|
-
var functionProcessor = (
|
|
19807
|
-
handleUnrepresentable(
|
|
19806
|
+
var functionProcessor = (schema2, ctx, json2, params) => {
|
|
19807
|
+
handleUnrepresentable(schema2, ctx, json2, params, "Function types cannot be represented in JSON Schema");
|
|
19808
19808
|
};
|
|
19809
|
-
var transformProcessor = (
|
|
19810
|
-
handleUnrepresentable(
|
|
19809
|
+
var transformProcessor = (schema2, ctx, json2, params) => {
|
|
19810
|
+
handleUnrepresentable(schema2, ctx, json2, params, "Transforms cannot be represented in JSON Schema");
|
|
19811
19811
|
};
|
|
19812
|
-
var mapProcessor = (
|
|
19813
|
-
handleUnrepresentable(
|
|
19812
|
+
var mapProcessor = (schema2, ctx, json2, params) => {
|
|
19813
|
+
handleUnrepresentable(schema2, ctx, json2, params, "Map cannot be represented in JSON Schema");
|
|
19814
19814
|
};
|
|
19815
|
-
var setProcessor = (
|
|
19816
|
-
handleUnrepresentable(
|
|
19815
|
+
var setProcessor = (schema2, ctx, json2, params) => {
|
|
19816
|
+
handleUnrepresentable(schema2, ctx, json2, params, "Set cannot be represented in JSON Schema");
|
|
19817
19817
|
};
|
|
19818
|
-
var arrayProcessor = (
|
|
19818
|
+
var arrayProcessor = (schema2, ctx, _json, params) => {
|
|
19819
19819
|
const json2 = _json;
|
|
19820
|
-
const def =
|
|
19821
|
-
const { minimum, maximum } = aggregateChecks(
|
|
19820
|
+
const def = schema2._zod.def;
|
|
19821
|
+
const { minimum, maximum } = aggregateChecks(schema2);
|
|
19822
19822
|
if (typeof minimum === "number")
|
|
19823
19823
|
json2.minItems = minimum;
|
|
19824
19824
|
if (typeof maximum === "number")
|
|
@@ -19829,22 +19829,22 @@ var arrayProcessor = (schema, ctx, _json, params) => {
|
|
|
19829
19829
|
path: [...params.path, "items"]
|
|
19830
19830
|
});
|
|
19831
19831
|
};
|
|
19832
|
-
function inputOptin(
|
|
19833
|
-
const def =
|
|
19832
|
+
function inputOptin(schema2) {
|
|
19833
|
+
const def = schema2._zod.def;
|
|
19834
19834
|
if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) {
|
|
19835
19835
|
return inputOptin(def.out);
|
|
19836
19836
|
}
|
|
19837
19837
|
if (def.type === "catch") {
|
|
19838
19838
|
return inputOptin(def.innerType);
|
|
19839
19839
|
}
|
|
19840
|
-
return
|
|
19840
|
+
return schema2._zod.optin;
|
|
19841
19841
|
}
|
|
19842
|
-
var objectProcessor = (
|
|
19842
|
+
var objectProcessor = (schema2, ctx, _json, params) => {
|
|
19843
19843
|
const json2 = _json;
|
|
19844
|
-
const def =
|
|
19844
|
+
const def = schema2._zod.def;
|
|
19845
19845
|
const shape = def.shape;
|
|
19846
19846
|
const symbolKeys = Object.getOwnPropertySymbols(shape);
|
|
19847
|
-
if (symbolKeys.length && handleUnrepresentable(
|
|
19847
|
+
if (symbolKeys.length && handleUnrepresentable(schema2, ctx, json2, params, "Symbol keys cannot be represented in JSON Schema")) {
|
|
19848
19848
|
return;
|
|
19849
19849
|
}
|
|
19850
19850
|
json2.type = "object";
|
|
@@ -19877,8 +19877,8 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
19877
19877
|
});
|
|
19878
19878
|
}
|
|
19879
19879
|
};
|
|
19880
|
-
var unionProcessor = (
|
|
19881
|
-
const def =
|
|
19880
|
+
var unionProcessor = (schema2, ctx, json2, params) => {
|
|
19881
|
+
const def = schema2._zod.def;
|
|
19882
19882
|
const isExclusive = def.inclusive === false;
|
|
19883
19883
|
const options = def.options.map((x, i) => processSchema(x, ctx, {
|
|
19884
19884
|
...params,
|
|
@@ -19890,8 +19890,8 @@ var unionProcessor = (schema, ctx, json2, params) => {
|
|
|
19890
19890
|
json2.anyOf = options;
|
|
19891
19891
|
}
|
|
19892
19892
|
};
|
|
19893
|
-
var intersectionProcessor = (
|
|
19894
|
-
const def =
|
|
19893
|
+
var intersectionProcessor = (schema2, ctx, json2, params) => {
|
|
19894
|
+
const def = schema2._zod.def;
|
|
19895
19895
|
const a = processSchema(def.left, ctx, {
|
|
19896
19896
|
...params,
|
|
19897
19897
|
path: [...params.path, "allOf", 0]
|
|
@@ -19908,9 +19908,9 @@ var intersectionProcessor = (schema, ctx, json2, params) => {
|
|
|
19908
19908
|
json2.allOf = allOf;
|
|
19909
19909
|
ctx.intersections.push(allOf);
|
|
19910
19910
|
};
|
|
19911
|
-
var tupleProcessor = (
|
|
19911
|
+
var tupleProcessor = (schema2, ctx, _json, params) => {
|
|
19912
19912
|
const json2 = _json;
|
|
19913
|
-
const def =
|
|
19913
|
+
const def = schema2._zod.def;
|
|
19914
19914
|
json2.type = "array";
|
|
19915
19915
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
19916
19916
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
@@ -19966,7 +19966,7 @@ var tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
19966
19966
|
if (isClosed)
|
|
19967
19967
|
json2.maxItems = maxItems;
|
|
19968
19968
|
}
|
|
19969
|
-
const { minimum, maximum } = aggregateChecks(
|
|
19969
|
+
const { minimum, maximum } = aggregateChecks(schema2);
|
|
19970
19970
|
if (typeof minimum === "number")
|
|
19971
19971
|
json2.minItems = minimum;
|
|
19972
19972
|
if (typeof maximum === "number")
|
|
@@ -20035,9 +20035,9 @@ function rewriteKeyNames(ctx) {
|
|
|
20035
20035
|
}
|
|
20036
20036
|
}
|
|
20037
20037
|
}
|
|
20038
|
-
var recordProcessor = (
|
|
20038
|
+
var recordProcessor = (schema2, ctx, _json, params) => {
|
|
20039
20039
|
const json2 = _json;
|
|
20040
|
-
const def =
|
|
20040
|
+
const def = schema2._zod.def;
|
|
20041
20041
|
json2.type = "object";
|
|
20042
20042
|
const keyType = def.keyType;
|
|
20043
20043
|
const patterns = aggregateChecks(keyType).patterns;
|
|
@@ -20062,7 +20062,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
20062
20062
|
pendingRecords.set(ctx, pending);
|
|
20063
20063
|
ctx.deferred.push(() => rewriteKeyNames(ctx));
|
|
20064
20064
|
}
|
|
20065
|
-
pending.push(
|
|
20065
|
+
pending.push(schema2);
|
|
20066
20066
|
}
|
|
20067
20067
|
json2.additionalProperties = processSchema(def.valueType, ctx, {
|
|
20068
20068
|
...params,
|
|
@@ -20078,10 +20078,10 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
20078
20078
|
}
|
|
20079
20079
|
}
|
|
20080
20080
|
};
|
|
20081
|
-
var nullableProcessor = (
|
|
20082
|
-
const def =
|
|
20081
|
+
var nullableProcessor = (schema2, ctx, json2, params) => {
|
|
20082
|
+
const def = schema2._zod.def;
|
|
20083
20083
|
const inner = processSchema(def.innerType, ctx, params);
|
|
20084
|
-
const seen = ctx.seen.get(
|
|
20084
|
+
const seen = ctx.seen.get(schema2);
|
|
20085
20085
|
if (ctx.target === "openapi-3.0") {
|
|
20086
20086
|
seen.ref = def.innerType;
|
|
20087
20087
|
json2.nullable = true;
|
|
@@ -20089,14 +20089,14 @@ var nullableProcessor = (schema, ctx, json2, params) => {
|
|
|
20089
20089
|
json2.anyOf = [inner, { type: "null" }];
|
|
20090
20090
|
}
|
|
20091
20091
|
};
|
|
20092
|
-
var nonoptionalProcessor = (
|
|
20093
|
-
const def =
|
|
20092
|
+
var nonoptionalProcessor = (schema2, ctx, _json, params) => {
|
|
20093
|
+
const def = schema2._zod.def;
|
|
20094
20094
|
processSchema(def.innerType, ctx, params);
|
|
20095
|
-
const seen = ctx.seen.get(
|
|
20095
|
+
const seen = ctx.seen.get(schema2);
|
|
20096
20096
|
seen.ref = def.innerType;
|
|
20097
20097
|
};
|
|
20098
20098
|
var UNREPRESENTABLE_DEFAULT = /* @__PURE__ */ Symbol();
|
|
20099
|
-
function serializeDefaultValue(value,
|
|
20099
|
+
function serializeDefaultValue(value, schema2, ctx, json2, params) {
|
|
20100
20100
|
let unrepresentable = false;
|
|
20101
20101
|
const serialized = JSON.stringify(value, (_, val) => {
|
|
20102
20102
|
if (typeof val !== "bigint")
|
|
@@ -20106,74 +20106,74 @@ function serializeDefaultValue(value, schema, ctx, json2, params) {
|
|
|
20106
20106
|
});
|
|
20107
20107
|
if (!unrepresentable)
|
|
20108
20108
|
return JSON.parse(serialized);
|
|
20109
|
-
handleUnrepresentable(
|
|
20109
|
+
handleUnrepresentable(schema2, ctx, json2, params, "BigInt defaults cannot be represented in JSON Schema");
|
|
20110
20110
|
return UNREPRESENTABLE_DEFAULT;
|
|
20111
20111
|
}
|
|
20112
|
-
var defaultProcessor = (
|
|
20113
|
-
const def =
|
|
20112
|
+
var defaultProcessor = (schema2, ctx, json2, params) => {
|
|
20113
|
+
const def = schema2._zod.def;
|
|
20114
20114
|
processSchema(def.innerType, ctx, params);
|
|
20115
|
-
const seen = ctx.seen.get(
|
|
20115
|
+
const seen = ctx.seen.get(schema2);
|
|
20116
20116
|
seen.ref = def.innerType;
|
|
20117
|
-
const value = serializeDefaultValue(def.defaultValue,
|
|
20117
|
+
const value = serializeDefaultValue(def.defaultValue, schema2, ctx, json2, params);
|
|
20118
20118
|
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
20119
20119
|
json2.default = value;
|
|
20120
20120
|
};
|
|
20121
|
-
var prefaultProcessor = (
|
|
20122
|
-
const def =
|
|
20121
|
+
var prefaultProcessor = (schema2, ctx, json2, params) => {
|
|
20122
|
+
const def = schema2._zod.def;
|
|
20123
20123
|
processSchema(def.innerType, ctx, params);
|
|
20124
|
-
const seen = ctx.seen.get(
|
|
20124
|
+
const seen = ctx.seen.get(schema2);
|
|
20125
20125
|
seen.ref = def.innerType;
|
|
20126
20126
|
if (ctx.io !== "input")
|
|
20127
20127
|
return;
|
|
20128
|
-
const value = serializeDefaultValue(def.defaultValue,
|
|
20128
|
+
const value = serializeDefaultValue(def.defaultValue, schema2, ctx, json2, params);
|
|
20129
20129
|
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
20130
20130
|
json2._prefault = value;
|
|
20131
20131
|
};
|
|
20132
|
-
var catchProcessor = (
|
|
20133
|
-
const def =
|
|
20132
|
+
var catchProcessor = (schema2, ctx, json2, params) => {
|
|
20133
|
+
const def = schema2._zod.def;
|
|
20134
20134
|
processSchema(def.innerType, ctx, params);
|
|
20135
|
-
const seen = ctx.seen.get(
|
|
20135
|
+
const seen = ctx.seen.get(schema2);
|
|
20136
20136
|
seen.ref = def.innerType;
|
|
20137
20137
|
let catchValue;
|
|
20138
20138
|
try {
|
|
20139
20139
|
catchValue = def.catchValue(void 0);
|
|
20140
20140
|
} catch {
|
|
20141
|
-
handleUnrepresentable(
|
|
20141
|
+
handleUnrepresentable(schema2, ctx, json2, params, "Dynamic catch values are not supported in JSON Schema");
|
|
20142
20142
|
return;
|
|
20143
20143
|
}
|
|
20144
20144
|
json2.default = catchValue;
|
|
20145
20145
|
};
|
|
20146
|
-
var pipeProcessor = (
|
|
20147
|
-
const def =
|
|
20146
|
+
var pipeProcessor = (schema2, ctx, _json, params) => {
|
|
20147
|
+
const def = schema2._zod.def;
|
|
20148
20148
|
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
20149
20149
|
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
|
|
20150
20150
|
processSchema(innerType, ctx, params);
|
|
20151
|
-
const seen = ctx.seen.get(
|
|
20151
|
+
const seen = ctx.seen.get(schema2);
|
|
20152
20152
|
seen.ref = innerType;
|
|
20153
20153
|
};
|
|
20154
|
-
var readonlyProcessor = (
|
|
20155
|
-
const def =
|
|
20154
|
+
var readonlyProcessor = (schema2, ctx, json2, params) => {
|
|
20155
|
+
const def = schema2._zod.def;
|
|
20156
20156
|
processSchema(def.innerType, ctx, params);
|
|
20157
|
-
const seen = ctx.seen.get(
|
|
20157
|
+
const seen = ctx.seen.get(schema2);
|
|
20158
20158
|
seen.ref = def.innerType;
|
|
20159
20159
|
json2.readOnly = true;
|
|
20160
20160
|
};
|
|
20161
|
-
var promiseProcessor = (
|
|
20162
|
-
const def =
|
|
20161
|
+
var promiseProcessor = (schema2, ctx, _json, params) => {
|
|
20162
|
+
const def = schema2._zod.def;
|
|
20163
20163
|
processSchema(def.innerType, ctx, params);
|
|
20164
|
-
const seen = ctx.seen.get(
|
|
20164
|
+
const seen = ctx.seen.get(schema2);
|
|
20165
20165
|
seen.ref = def.innerType;
|
|
20166
20166
|
};
|
|
20167
|
-
var optionalProcessor = (
|
|
20168
|
-
const def =
|
|
20167
|
+
var optionalProcessor = (schema2, ctx, _json, params) => {
|
|
20168
|
+
const def = schema2._zod.def;
|
|
20169
20169
|
processSchema(def.innerType, ctx, params);
|
|
20170
|
-
const seen = ctx.seen.get(
|
|
20170
|
+
const seen = ctx.seen.get(schema2);
|
|
20171
20171
|
seen.ref = def.innerType;
|
|
20172
20172
|
};
|
|
20173
|
-
var lazyProcessor = (
|
|
20174
|
-
const innerType =
|
|
20173
|
+
var lazyProcessor = (schema2, ctx, _json, params) => {
|
|
20174
|
+
const innerType = schema2._zod.innerType;
|
|
20175
20175
|
processSchema(innerType, ctx, params);
|
|
20176
|
-
const seen = ctx.seen.get(
|
|
20176
|
+
const seen = ctx.seen.get(schema2);
|
|
20177
20177
|
seen.ref = innerType;
|
|
20178
20178
|
};
|
|
20179
20179
|
var allProcessors = {
|
|
@@ -20223,8 +20223,8 @@ function toJSONSchema(input2, params) {
|
|
|
20223
20223
|
const ctx2 = initializeContext({ ...params, processors: allProcessors });
|
|
20224
20224
|
const defs = {};
|
|
20225
20225
|
for (const entry of registry2._idmap.entries()) {
|
|
20226
|
-
const [_,
|
|
20227
|
-
processSchema(
|
|
20226
|
+
const [_, schema2] = entry;
|
|
20227
|
+
processSchema(schema2, ctx2);
|
|
20228
20228
|
}
|
|
20229
20229
|
const schemas = {};
|
|
20230
20230
|
const external = {
|
|
@@ -20234,9 +20234,9 @@ function toJSONSchema(input2, params) {
|
|
|
20234
20234
|
};
|
|
20235
20235
|
ctx2.external = external;
|
|
20236
20236
|
for (const entry of registry2._idmap.entries()) {
|
|
20237
|
-
const [key,
|
|
20238
|
-
extractDefs(ctx2,
|
|
20239
|
-
assignProp(schemas, key, finalize(ctx2,
|
|
20237
|
+
const [key, schema2] = entry;
|
|
20238
|
+
extractDefs(ctx2, schema2);
|
|
20239
|
+
assignProp(schemas, key, finalize(ctx2, schema2));
|
|
20240
20240
|
}
|
|
20241
20241
|
if (Object.keys(defs).length > 0) {
|
|
20242
20242
|
const defsSegment = ctx2.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
@@ -20305,14 +20305,14 @@ var JSONSchemaGenerator = class {
|
|
|
20305
20305
|
* Process a schema to prepare it for JSON Schema generation.
|
|
20306
20306
|
* This must be called before emit().
|
|
20307
20307
|
*/
|
|
20308
|
-
process(
|
|
20309
|
-
return processSchema(
|
|
20308
|
+
process(schema2, _params = { path: [], schemaPath: [] }) {
|
|
20309
|
+
return processSchema(schema2, this.ctx, _params);
|
|
20310
20310
|
}
|
|
20311
20311
|
/**
|
|
20312
20312
|
* Emit the final JSON Schema after processing.
|
|
20313
20313
|
* Must call process() first.
|
|
20314
20314
|
*/
|
|
20315
|
-
emit(
|
|
20315
|
+
emit(schema2, _params) {
|
|
20316
20316
|
if (_params) {
|
|
20317
20317
|
if (_params.cycles)
|
|
20318
20318
|
this.ctx.cycles = _params.cycles;
|
|
@@ -20323,8 +20323,8 @@ var JSONSchemaGenerator = class {
|
|
|
20323
20323
|
}
|
|
20324
20324
|
this.ctx.sharedDefsExtractedFor = void 0;
|
|
20325
20325
|
this.ctx.sharedEmitDoneFor = void 0;
|
|
20326
|
-
extractDefs(this.ctx,
|
|
20327
|
-
const result = finalize(this.ctx,
|
|
20326
|
+
extractDefs(this.ctx, schema2);
|
|
20327
|
+
const result = finalize(this.ctx, schema2);
|
|
20328
20328
|
const { "~standard": _, ...plainResult } = result;
|
|
20329
20329
|
return plainResult;
|
|
20330
20330
|
}
|
|
@@ -21417,8 +21417,8 @@ var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
|
21417
21417
|
function array(element, params) {
|
|
21418
21418
|
return _array(ZodArray, element, params);
|
|
21419
21419
|
}
|
|
21420
|
-
function keyof(
|
|
21421
|
-
const shape =
|
|
21420
|
+
function keyof(schema2) {
|
|
21421
|
+
const shape = schema2._zod.def.shape;
|
|
21422
21422
|
return _enum2(Object.keys(shape));
|
|
21423
21423
|
}
|
|
21424
21424
|
var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
@@ -22066,11 +22066,11 @@ function json(params) {
|
|
|
22066
22066
|
});
|
|
22067
22067
|
return jsonSchema;
|
|
22068
22068
|
}
|
|
22069
|
-
function preprocess(fn,
|
|
22069
|
+
function preprocess(fn, schema2) {
|
|
22070
22070
|
return new ZodPreprocess({
|
|
22071
22071
|
type: "pipe",
|
|
22072
22072
|
in: transform(fn),
|
|
22073
|
-
out:
|
|
22073
|
+
out: schema2
|
|
22074
22074
|
});
|
|
22075
22075
|
}
|
|
22076
22076
|
|
|
@@ -22202,8 +22202,8 @@ var RECOGNIZED_KEYS = /* @__PURE__ */ new Set([
|
|
|
22202
22202
|
"nullable",
|
|
22203
22203
|
"readOnly"
|
|
22204
22204
|
]);
|
|
22205
|
-
function detectVersion(
|
|
22206
|
-
const $schema =
|
|
22205
|
+
function detectVersion(schema2, defaultTarget) {
|
|
22206
|
+
const $schema = schema2.$schema;
|
|
22207
22207
|
if ($schema === "https://json-schema.org/draft/2020-12/schema") {
|
|
22208
22208
|
return "draft-2020-12";
|
|
22209
22209
|
}
|
|
@@ -22431,27 +22431,27 @@ function getTupleRest(restSchema, ctx) {
|
|
|
22431
22431
|
return convertSchema(restSchema, ctx);
|
|
22432
22432
|
}
|
|
22433
22433
|
var fullTime = /^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;
|
|
22434
|
-
function convertBaseSchema(
|
|
22435
|
-
if (
|
|
22436
|
-
if (typeof
|
|
22434
|
+
function convertBaseSchema(schema2, ctx) {
|
|
22435
|
+
if (schema2.not !== void 0) {
|
|
22436
|
+
if (typeof schema2.not === "object" && Object.keys(schema2.not).length === 0) {
|
|
22437
22437
|
return z.never();
|
|
22438
22438
|
}
|
|
22439
22439
|
throw new Error("not is not supported in Zod (except { not: {} } for never)");
|
|
22440
22440
|
}
|
|
22441
|
-
if (
|
|
22441
|
+
if (schema2.unevaluatedItems !== void 0) {
|
|
22442
22442
|
throw new Error("unevaluatedItems is not supported");
|
|
22443
22443
|
}
|
|
22444
|
-
if (
|
|
22444
|
+
if (schema2.unevaluatedProperties !== void 0) {
|
|
22445
22445
|
throw new Error("unevaluatedProperties is not supported");
|
|
22446
22446
|
}
|
|
22447
|
-
if (
|
|
22447
|
+
if (schema2.if !== void 0 || schema2.then !== void 0 || schema2.else !== void 0) {
|
|
22448
22448
|
throw new Error("Conditional schemas (if/then/else) are not supported");
|
|
22449
22449
|
}
|
|
22450
|
-
if (
|
|
22450
|
+
if (schema2.dependentSchemas !== void 0 || schema2.dependentRequired !== void 0) {
|
|
22451
22451
|
throw new Error("dependentSchemas and dependentRequired are not supported");
|
|
22452
22452
|
}
|
|
22453
|
-
if (
|
|
22454
|
-
const refPath =
|
|
22453
|
+
if (schema2.$ref) {
|
|
22454
|
+
const refPath = schema2.$ref;
|
|
22455
22455
|
if (ctx.refs.has(refPath)) {
|
|
22456
22456
|
return ctx.refs.get(refPath);
|
|
22457
22457
|
}
|
|
@@ -22470,9 +22470,9 @@ function convertBaseSchema(schema, ctx) {
|
|
|
22470
22470
|
ctx.processing.delete(refPath);
|
|
22471
22471
|
return zodSchema2;
|
|
22472
22472
|
}
|
|
22473
|
-
if (
|
|
22474
|
-
const enumValues =
|
|
22475
|
-
if (ctx.version === "openapi-3.0" &&
|
|
22473
|
+
if (schema2.enum !== void 0) {
|
|
22474
|
+
const enumValues = schema2.enum;
|
|
22475
|
+
if (ctx.version === "openapi-3.0" && schema2.nullable === true && enumValues.length === 1 && enumValues[0] === null) {
|
|
22476
22476
|
return z.null();
|
|
22477
22477
|
}
|
|
22478
22478
|
if (enumValues.length === 0) {
|
|
@@ -22490,13 +22490,13 @@ function convertBaseSchema(schema, ctx) {
|
|
|
22490
22490
|
}
|
|
22491
22491
|
return z.union([literalSchemas[0], literalSchemas[1], ...literalSchemas.slice(2)]);
|
|
22492
22492
|
}
|
|
22493
|
-
if (
|
|
22494
|
-
return z.literal(
|
|
22493
|
+
if (schema2.const !== void 0) {
|
|
22494
|
+
return z.literal(schema2.const);
|
|
22495
22495
|
}
|
|
22496
|
-
const type =
|
|
22496
|
+
const type = schema2.type;
|
|
22497
22497
|
if (Array.isArray(type)) {
|
|
22498
22498
|
const typeSchemas = type.map((t) => {
|
|
22499
|
-
const typeSchema = { ...
|
|
22499
|
+
const typeSchema = { ...schema2, type: t };
|
|
22500
22500
|
return convertBaseSchema(typeSchema, ctx);
|
|
22501
22501
|
});
|
|
22502
22502
|
if (typeSchemas.length === 0) {
|
|
@@ -22514,8 +22514,8 @@ function convertBaseSchema(schema, ctx) {
|
|
|
22514
22514
|
switch (type) {
|
|
22515
22515
|
case "string": {
|
|
22516
22516
|
let stringSchema = z.string();
|
|
22517
|
-
if (
|
|
22518
|
-
const format =
|
|
22517
|
+
if (schema2.format) {
|
|
22518
|
+
const format = schema2.format;
|
|
22519
22519
|
if (format === "email") {
|
|
22520
22520
|
stringSchema = stringSchema.check(z.email());
|
|
22521
22521
|
} else if (format === "uri" || format === "uri-reference") {
|
|
@@ -22570,14 +22570,14 @@ function convertBaseSchema(schema, ctx) {
|
|
|
22570
22570
|
stringSchema = stringSchema.check(z.ksuid());
|
|
22571
22571
|
}
|
|
22572
22572
|
}
|
|
22573
|
-
if (typeof
|
|
22574
|
-
stringSchema = stringSchema.min(
|
|
22573
|
+
if (typeof schema2.minLength === "number") {
|
|
22574
|
+
stringSchema = stringSchema.min(schema2.minLength);
|
|
22575
22575
|
}
|
|
22576
|
-
if (typeof
|
|
22577
|
-
stringSchema = stringSchema.max(
|
|
22576
|
+
if (typeof schema2.maxLength === "number") {
|
|
22577
|
+
stringSchema = stringSchema.max(schema2.maxLength);
|
|
22578
22578
|
}
|
|
22579
|
-
if (
|
|
22580
|
-
stringSchema = stringSchema.regex(new RegExp(
|
|
22579
|
+
if (schema2.pattern) {
|
|
22580
|
+
stringSchema = stringSchema.regex(new RegExp(schema2.pattern));
|
|
22581
22581
|
}
|
|
22582
22582
|
zodSchema = stringSchema;
|
|
22583
22583
|
break;
|
|
@@ -22585,24 +22585,24 @@ function convertBaseSchema(schema, ctx) {
|
|
|
22585
22585
|
case "number":
|
|
22586
22586
|
case "integer": {
|
|
22587
22587
|
let numberSchema = type === "integer" ? z.number().int() : z.number();
|
|
22588
|
-
if (typeof
|
|
22589
|
-
numberSchema = numberSchema.min(
|
|
22588
|
+
if (typeof schema2.minimum === "number" && schema2.exclusiveMinimum !== true) {
|
|
22589
|
+
numberSchema = numberSchema.min(schema2.minimum);
|
|
22590
22590
|
}
|
|
22591
|
-
if (typeof
|
|
22592
|
-
numberSchema = numberSchema.max(
|
|
22591
|
+
if (typeof schema2.maximum === "number" && schema2.exclusiveMaximum !== true) {
|
|
22592
|
+
numberSchema = numberSchema.max(schema2.maximum);
|
|
22593
22593
|
}
|
|
22594
|
-
if (typeof
|
|
22595
|
-
numberSchema = numberSchema.gt(
|
|
22596
|
-
} else if (
|
|
22597
|
-
numberSchema = numberSchema.gt(
|
|
22594
|
+
if (typeof schema2.exclusiveMinimum === "number") {
|
|
22595
|
+
numberSchema = numberSchema.gt(schema2.exclusiveMinimum);
|
|
22596
|
+
} else if (schema2.exclusiveMinimum === true && typeof schema2.minimum === "number") {
|
|
22597
|
+
numberSchema = numberSchema.gt(schema2.minimum);
|
|
22598
22598
|
}
|
|
22599
|
-
if (typeof
|
|
22600
|
-
numberSchema = numberSchema.lt(
|
|
22601
|
-
} else if (
|
|
22602
|
-
numberSchema = numberSchema.lt(
|
|
22599
|
+
if (typeof schema2.exclusiveMaximum === "number") {
|
|
22600
|
+
numberSchema = numberSchema.lt(schema2.exclusiveMaximum);
|
|
22601
|
+
} else if (schema2.exclusiveMaximum === true && typeof schema2.maximum === "number") {
|
|
22602
|
+
numberSchema = numberSchema.lt(schema2.maximum);
|
|
22603
22603
|
}
|
|
22604
|
-
if (typeof
|
|
22605
|
-
numberSchema = numberSchema.multipleOf(
|
|
22604
|
+
if (typeof schema2.multipleOf === "number") {
|
|
22605
|
+
numberSchema = numberSchema.multipleOf(schema2.multipleOf);
|
|
22606
22606
|
}
|
|
22607
22607
|
zodSchema = numberSchema;
|
|
22608
22608
|
break;
|
|
@@ -22617,15 +22617,15 @@ function convertBaseSchema(schema, ctx) {
|
|
|
22617
22617
|
}
|
|
22618
22618
|
case "object": {
|
|
22619
22619
|
const shape = {};
|
|
22620
|
-
const properties =
|
|
22621
|
-
const requiredSet = new Set(
|
|
22622
|
-
const additionalSchema = typeof
|
|
22620
|
+
const properties = schema2.properties || {};
|
|
22621
|
+
const requiredSet = new Set(schema2.required || []);
|
|
22622
|
+
const additionalSchema = typeof schema2.additionalProperties === "object" ? convertSchema(schema2.additionalProperties, ctx) : void 0;
|
|
22623
22623
|
for (const [key, propSchema] of Object.entries(properties)) {
|
|
22624
22624
|
const propZodSchema = convertSchema(propSchema, ctx);
|
|
22625
22625
|
assignProp(shape, key, requiredSet.has(key) ? propZodSchema : propZodSchema.optional());
|
|
22626
22626
|
}
|
|
22627
|
-
if (
|
|
22628
|
-
const patternProps =
|
|
22627
|
+
if (schema2.patternProperties) {
|
|
22628
|
+
const patternProps = schema2.patternProperties;
|
|
22629
22629
|
const patternKeys = Object.keys(patternProps);
|
|
22630
22630
|
const looseRecords = [];
|
|
22631
22631
|
for (const pattern of patternKeys) {
|
|
@@ -22649,7 +22649,7 @@ function convertBaseSchema(schema, ctx) {
|
|
|
22649
22649
|
}
|
|
22650
22650
|
zodSchema = result;
|
|
22651
22651
|
}
|
|
22652
|
-
if (
|
|
22652
|
+
if (schema2.additionalProperties === false) {
|
|
22653
22653
|
const propertyKeys = Object.keys(shape);
|
|
22654
22654
|
const patterns = patternKeys.map((p) => new RegExp(p));
|
|
22655
22655
|
const basePatternSchema = zodSchema;
|
|
@@ -22676,7 +22676,7 @@ function convertBaseSchema(schema, ctx) {
|
|
|
22676
22676
|
}
|
|
22677
22677
|
} else {
|
|
22678
22678
|
const objectSchema = z.object(shape);
|
|
22679
|
-
if (
|
|
22679
|
+
if (schema2.additionalProperties === false) {
|
|
22680
22680
|
zodSchema = objectSchema.strict();
|
|
22681
22681
|
} else if (additionalSchema) {
|
|
22682
22682
|
zodSchema = objectSchema.catchall(additionalSchema);
|
|
@@ -22684,13 +22684,13 @@ function convertBaseSchema(schema, ctx) {
|
|
|
22684
22684
|
zodSchema = objectSchema.passthrough();
|
|
22685
22685
|
}
|
|
22686
22686
|
}
|
|
22687
|
-
const hasKeyGuard =
|
|
22688
|
-
const minProperties = typeof
|
|
22689
|
-
const maxProperties = typeof
|
|
22687
|
+
const hasKeyGuard = schema2.propertyNames !== void 0 && schema2.propertyNames !== true;
|
|
22688
|
+
const minProperties = typeof schema2.minProperties === "number" ? schema2.minProperties : void 0;
|
|
22689
|
+
const maxProperties = typeof schema2.maxProperties === "number" ? schema2.maxProperties : void 0;
|
|
22690
22690
|
if (hasKeyGuard || minProperties !== void 0 || maxProperties !== void 0) {
|
|
22691
22691
|
let keySchema;
|
|
22692
22692
|
if (hasKeyGuard) {
|
|
22693
|
-
const keyJSONSchema = typeof
|
|
22693
|
+
const keyJSONSchema = typeof schema2.propertyNames === "object" && schema2.propertyNames.type === void 0 ? { type: "string", ...schema2.propertyNames } : schema2.propertyNames;
|
|
22694
22694
|
keySchema = convertSchema(keyJSONSchema, ctx);
|
|
22695
22695
|
}
|
|
22696
22696
|
zodSchema = checkObjectGuards(zodSchema, { keySchema, minProperties, maxProperties });
|
|
@@ -22698,53 +22698,53 @@ function convertBaseSchema(schema, ctx) {
|
|
|
22698
22698
|
break;
|
|
22699
22699
|
}
|
|
22700
22700
|
case "array": {
|
|
22701
|
-
const prefixItems =
|
|
22702
|
-
const items =
|
|
22701
|
+
const prefixItems = schema2.prefixItems;
|
|
22702
|
+
const items = schema2.items;
|
|
22703
22703
|
if (prefixItems && Array.isArray(prefixItems)) {
|
|
22704
|
-
const minItems = typeof
|
|
22704
|
+
const minItems = typeof schema2.minItems === "number" ? schema2.minItems : 0;
|
|
22705
22705
|
const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
|
|
22706
22706
|
const positionalItems = applyMinItems(tupleItems, minItems);
|
|
22707
22707
|
const rest = !Array.isArray(items) ? getTupleRest(items, ctx) : void 0;
|
|
22708
22708
|
const tupleSchema = z.tuple(positionalItems);
|
|
22709
22709
|
zodSchema = rest ? tupleSchema.rest(rest) : tupleSchema;
|
|
22710
|
-
if (typeof
|
|
22711
|
-
zodSchema = zodSchema.check(z.minLength(
|
|
22710
|
+
if (typeof schema2.minItems === "number") {
|
|
22711
|
+
zodSchema = zodSchema.check(z.minLength(schema2.minItems));
|
|
22712
22712
|
}
|
|
22713
|
-
if (typeof
|
|
22714
|
-
zodSchema = zodSchema.check(z.maxLength(
|
|
22713
|
+
if (typeof schema2.maxItems === "number") {
|
|
22714
|
+
zodSchema = zodSchema.check(z.maxLength(schema2.maxItems));
|
|
22715
22715
|
}
|
|
22716
22716
|
} else if (Array.isArray(items)) {
|
|
22717
|
-
const minItems = typeof
|
|
22717
|
+
const minItems = typeof schema2.minItems === "number" ? schema2.minItems : 0;
|
|
22718
22718
|
const tupleItems = items.map((item) => convertSchema(item, ctx));
|
|
22719
22719
|
const positionalItems = applyMinItems(tupleItems, minItems);
|
|
22720
|
-
const rest = getTupleRest(
|
|
22720
|
+
const rest = getTupleRest(schema2.additionalItems, ctx);
|
|
22721
22721
|
const tupleSchema = z.tuple(positionalItems);
|
|
22722
22722
|
zodSchema = rest ? tupleSchema.rest(rest) : tupleSchema;
|
|
22723
|
-
if (typeof
|
|
22724
|
-
zodSchema = zodSchema.check(z.minLength(
|
|
22723
|
+
if (typeof schema2.minItems === "number") {
|
|
22724
|
+
zodSchema = zodSchema.check(z.minLength(schema2.minItems));
|
|
22725
22725
|
}
|
|
22726
|
-
if (typeof
|
|
22727
|
-
zodSchema = zodSchema.check(z.maxLength(
|
|
22726
|
+
if (typeof schema2.maxItems === "number") {
|
|
22727
|
+
zodSchema = zodSchema.check(z.maxLength(schema2.maxItems));
|
|
22728
22728
|
}
|
|
22729
22729
|
} else if (items !== void 0) {
|
|
22730
22730
|
const element = convertSchema(items, ctx);
|
|
22731
22731
|
let arraySchema = z.array(element);
|
|
22732
|
-
if (typeof
|
|
22733
|
-
arraySchema = arraySchema.min(
|
|
22732
|
+
if (typeof schema2.minItems === "number") {
|
|
22733
|
+
arraySchema = arraySchema.min(schema2.minItems);
|
|
22734
22734
|
}
|
|
22735
|
-
if (typeof
|
|
22736
|
-
arraySchema = arraySchema.max(
|
|
22735
|
+
if (typeof schema2.maxItems === "number") {
|
|
22736
|
+
arraySchema = arraySchema.max(schema2.maxItems);
|
|
22737
22737
|
}
|
|
22738
22738
|
zodSchema = arraySchema;
|
|
22739
22739
|
} else {
|
|
22740
22740
|
zodSchema = z.array(z.any());
|
|
22741
22741
|
}
|
|
22742
|
-
if (
|
|
22742
|
+
if (schema2.uniqueItems === true || schema2.contains !== void 0) {
|
|
22743
22743
|
zodSchema = checkArrayGuards(zodSchema, {
|
|
22744
|
-
uniqueItems:
|
|
22745
|
-
containsSchema:
|
|
22746
|
-
minContains: typeof
|
|
22747
|
-
maxContains: typeof
|
|
22744
|
+
uniqueItems: schema2.uniqueItems === true,
|
|
22745
|
+
containsSchema: schema2.contains !== void 0 ? convertSchema(schema2.contains, ctx) : void 0,
|
|
22746
|
+
minContains: typeof schema2.minContains === "number" ? schema2.minContains : void 0,
|
|
22747
|
+
maxContains: typeof schema2.maxContains === "number" ? schema2.maxContains : void 0
|
|
22748
22748
|
});
|
|
22749
22749
|
}
|
|
22750
22750
|
break;
|
|
@@ -22754,94 +22754,94 @@ function convertBaseSchema(schema, ctx) {
|
|
|
22754
22754
|
}
|
|
22755
22755
|
return zodSchema;
|
|
22756
22756
|
}
|
|
22757
|
-
function convertSchema(
|
|
22758
|
-
if (typeof
|
|
22759
|
-
return
|
|
22757
|
+
function convertSchema(schema2, ctx) {
|
|
22758
|
+
if (typeof schema2 === "boolean") {
|
|
22759
|
+
return schema2 ? z.any() : z.never();
|
|
22760
22760
|
}
|
|
22761
|
-
let baseSchema = convertBaseSchema(
|
|
22762
|
-
const hasExplicitType =
|
|
22763
|
-
if (
|
|
22764
|
-
const options =
|
|
22761
|
+
let baseSchema = convertBaseSchema(schema2, ctx);
|
|
22762
|
+
const hasExplicitType = schema2.type || schema2.enum !== void 0 || schema2.const !== void 0;
|
|
22763
|
+
if (schema2.anyOf && Array.isArray(schema2.anyOf)) {
|
|
22764
|
+
const options = schema2.anyOf.map((s) => convertSchema(s, ctx));
|
|
22765
22765
|
const anyOfUnion = z.union(options);
|
|
22766
22766
|
baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
|
|
22767
22767
|
}
|
|
22768
|
-
if (
|
|
22769
|
-
const options =
|
|
22768
|
+
if (schema2.oneOf && Array.isArray(schema2.oneOf)) {
|
|
22769
|
+
const options = schema2.oneOf.map((s) => convertSchema(s, ctx));
|
|
22770
22770
|
const oneOfUnion = z.xor(options);
|
|
22771
22771
|
baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
|
|
22772
22772
|
}
|
|
22773
|
-
if (
|
|
22774
|
-
if (
|
|
22773
|
+
if (schema2.allOf && Array.isArray(schema2.allOf)) {
|
|
22774
|
+
if (schema2.allOf.length === 0) {
|
|
22775
22775
|
baseSchema = hasExplicitType ? baseSchema : z.any();
|
|
22776
22776
|
} else {
|
|
22777
|
-
let result = hasExplicitType ? baseSchema : convertSchema(
|
|
22777
|
+
let result = hasExplicitType ? baseSchema : convertSchema(schema2.allOf[0], ctx);
|
|
22778
22778
|
const startIdx = hasExplicitType ? 0 : 1;
|
|
22779
|
-
for (let i = startIdx; i <
|
|
22780
|
-
result = z.intersection(result, convertSchema(
|
|
22779
|
+
for (let i = startIdx; i < schema2.allOf.length; i++) {
|
|
22780
|
+
result = z.intersection(result, convertSchema(schema2.allOf[i], ctx));
|
|
22781
22781
|
}
|
|
22782
22782
|
baseSchema = result;
|
|
22783
22783
|
}
|
|
22784
22784
|
}
|
|
22785
|
-
if (
|
|
22785
|
+
if (schema2.nullable === true && ctx.version === "openapi-3.0") {
|
|
22786
22786
|
baseSchema = z.nullable(baseSchema);
|
|
22787
22787
|
}
|
|
22788
|
-
if (
|
|
22788
|
+
if (schema2.readOnly === true) {
|
|
22789
22789
|
baseSchema = z.readonly(baseSchema);
|
|
22790
22790
|
}
|
|
22791
|
-
if (
|
|
22792
|
-
baseSchema = baseSchema.default(
|
|
22791
|
+
if (schema2.default !== void 0) {
|
|
22792
|
+
baseSchema = baseSchema.default(schema2.default);
|
|
22793
22793
|
}
|
|
22794
22794
|
const extraMeta = {};
|
|
22795
22795
|
const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
|
|
22796
22796
|
for (const key of coreMetadataKeys) {
|
|
22797
|
-
if (key in
|
|
22798
|
-
extraMeta[key] =
|
|
22797
|
+
if (key in schema2) {
|
|
22798
|
+
extraMeta[key] = schema2[key];
|
|
22799
22799
|
}
|
|
22800
22800
|
}
|
|
22801
22801
|
const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
|
|
22802
22802
|
for (const key of contentMetadataKeys) {
|
|
22803
|
-
if (key in
|
|
22804
|
-
extraMeta[key] =
|
|
22803
|
+
if (key in schema2) {
|
|
22804
|
+
extraMeta[key] = schema2[key];
|
|
22805
22805
|
}
|
|
22806
22806
|
}
|
|
22807
|
-
if (
|
|
22808
|
-
if (
|
|
22809
|
-
extraMeta.propertyNames =
|
|
22807
|
+
if (schema2.type === "object" && schema2.$ref === void 0) {
|
|
22808
|
+
if (schema2.propertyNames !== void 0 && !containsRef(schema2.propertyNames)) {
|
|
22809
|
+
extraMeta.propertyNames = schema2.propertyNames;
|
|
22810
22810
|
}
|
|
22811
22811
|
for (const key of ["minProperties", "maxProperties"]) {
|
|
22812
|
-
if (
|
|
22813
|
-
extraMeta[key] =
|
|
22812
|
+
if (schema2[key] !== void 0)
|
|
22813
|
+
extraMeta[key] = schema2[key];
|
|
22814
22814
|
}
|
|
22815
22815
|
}
|
|
22816
|
-
if (
|
|
22817
|
-
if (
|
|
22818
|
-
extraMeta.contains =
|
|
22816
|
+
if (schema2.type === "array" && schema2.$ref === void 0) {
|
|
22817
|
+
if (schema2.contains !== void 0 && !containsRef(schema2.contains)) {
|
|
22818
|
+
extraMeta.contains = schema2.contains;
|
|
22819
22819
|
}
|
|
22820
22820
|
for (const key of ["uniqueItems", "minContains", "maxContains"]) {
|
|
22821
|
-
if (
|
|
22822
|
-
extraMeta[key] =
|
|
22821
|
+
if (schema2[key] !== void 0)
|
|
22822
|
+
extraMeta[key] = schema2[key];
|
|
22823
22823
|
}
|
|
22824
22824
|
}
|
|
22825
|
-
for (const key of Object.keys(
|
|
22825
|
+
for (const key of Object.keys(schema2)) {
|
|
22826
22826
|
if (!RECOGNIZED_KEYS.has(key)) {
|
|
22827
|
-
assignProp(extraMeta, key,
|
|
22827
|
+
assignProp(extraMeta, key, schema2[key]);
|
|
22828
22828
|
}
|
|
22829
22829
|
}
|
|
22830
22830
|
if (Object.keys(extraMeta).length > 0) {
|
|
22831
22831
|
ctx.registry.add(baseSchema, extraMeta);
|
|
22832
22832
|
}
|
|
22833
|
-
if (
|
|
22834
|
-
baseSchema = baseSchema.describe(
|
|
22833
|
+
if (schema2.description) {
|
|
22834
|
+
baseSchema = baseSchema.describe(schema2.description);
|
|
22835
22835
|
}
|
|
22836
22836
|
return baseSchema;
|
|
22837
22837
|
}
|
|
22838
|
-
function fromJSONSchema(
|
|
22839
|
-
if (typeof
|
|
22840
|
-
return
|
|
22838
|
+
function fromJSONSchema(schema2, params) {
|
|
22839
|
+
if (typeof schema2 === "boolean") {
|
|
22840
|
+
return schema2 ? z.any() : z.never();
|
|
22841
22841
|
}
|
|
22842
22842
|
let normalized;
|
|
22843
22843
|
try {
|
|
22844
|
-
normalized = JSON.parse(JSON.stringify(
|
|
22844
|
+
normalized = JSON.parse(JSON.stringify(schema2));
|
|
22845
22845
|
} catch {
|
|
22846
22846
|
throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
|
|
22847
22847
|
}
|
|
@@ -22860,7 +22860,7 @@ function fromJSONSchema(schema, params) {
|
|
|
22860
22860
|
|
|
22861
22861
|
// ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/visit.js
|
|
22862
22862
|
var RESOLVING = /* @__PURE__ */ Symbol("z.visit/resolving");
|
|
22863
|
-
function visit(
|
|
22863
|
+
function visit(schema2, fnOrHandlers) {
|
|
22864
22864
|
const fn = typeof fnOrHandlers === "function" ? fnOrHandlers : (node2, rewritten) => {
|
|
22865
22865
|
const h = fnOrHandlers[node2._zod.def.type];
|
|
22866
22866
|
return h ? h(node2, rewritten) : node2;
|
|
@@ -23010,12 +23010,12 @@ function visit(schema, fnOrHandlers) {
|
|
|
23010
23010
|
}
|
|
23011
23011
|
}
|
|
23012
23012
|
}
|
|
23013
|
-
return run2(
|
|
23013
|
+
return run2(schema2);
|
|
23014
23014
|
}
|
|
23015
23015
|
|
|
23016
23016
|
// ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/deep-partial.js
|
|
23017
|
-
function deepPartial(
|
|
23018
|
-
return visit(
|
|
23017
|
+
function deepPartial(schema2) {
|
|
23018
|
+
return visit(schema2, {
|
|
23019
23019
|
object: (s) => s.partial(),
|
|
23020
23020
|
// Every partialed option now admits `undefined`, which the constructor rejects as a duplicate.
|
|
23021
23021
|
union: (s) => {
|
|
@@ -23038,8 +23038,8 @@ function outSide(def) {
|
|
|
23038
23038
|
function inSide(def) {
|
|
23039
23039
|
return def.in._zod.traits.has("$ZodTransform") ? outSide(def) : def.in;
|
|
23040
23040
|
}
|
|
23041
|
-
function input(
|
|
23042
|
-
return visit(
|
|
23041
|
+
function input(schema2) {
|
|
23042
|
+
return visit(schema2, {
|
|
23043
23043
|
pipe: (s) => inSide(s._zod.def),
|
|
23044
23044
|
// A default value belongs to the output side, so a rewritten inner type leaves it stranded. `.default()` widens the declared input type with `undefined`, and `optional` is what carries that across.
|
|
23045
23045
|
default: (s, rewritten) => rewritten ? optional(s._zod.def.innerType) : s,
|
|
@@ -23047,8 +23047,8 @@ function input(schema) {
|
|
|
23047
23047
|
catch: (s, rewritten) => rewritten ? s._zod.def.innerType : s
|
|
23048
23048
|
});
|
|
23049
23049
|
}
|
|
23050
|
-
function output(
|
|
23051
|
-
return visit(
|
|
23050
|
+
function output(schema2) {
|
|
23051
|
+
return visit(schema2, {
|
|
23052
23052
|
pipe: (s) => outSide(s._zod.def),
|
|
23053
23053
|
// A prefault value is fed through the schema, which makes it input-side, so a rewritten inner type leaves it stranded.
|
|
23054
23054
|
prefault: (s, rewritten) => rewritten ? s._zod.def.innerType : s
|
|
@@ -23715,7 +23715,7 @@ Confirm the code matches: ${started2.userCode}
|
|
|
23715
23715
|
writeConfig({ baseUrl, token: poll.token, email: me.user.email });
|
|
23716
23716
|
const skills = installSkills();
|
|
23717
23717
|
emit({ ok: true, user: me.user, machine: me.machine, baseUrl, skills }, () => `Signed in as ${me.user.email} on ${me.machine?.name ?? "this machine"}.${skills.length ? `
|
|
23718
|
-
Agent skills installed in ~/.claude/skills and ~/.agents/skills.` : ""}`);
|
|
23718
|
+
Agent skills installed in ~/.claude/skills and ~/.agents/skills. Next: slop mcp install (the board as tools for Claude Code and Codex).` : ""}`);
|
|
23719
23719
|
return;
|
|
23720
23720
|
}
|
|
23721
23721
|
throw new CliError("The login request expired before it was approved", "slop login");
|
|
@@ -23746,7 +23746,7 @@ This repository is linked to a Slopware Tasks board. Use the \`slop\` CLI to kee
|
|
|
23746
23746
|
- Before starting tracked work: \`slop task list\`, then \`slop task start <KEY>\`.
|
|
23747
23747
|
- When it is finished and verified: \`slop task done <KEY>\`.
|
|
23748
23748
|
- Descriptions are Markdown and are shown in full on the board. Write real ones: context, file paths, what done means. Pipe long ones in with \`-d -\`.
|
|
23749
|
-
-
|
|
23749
|
+
- Best: \`slop mcp install\` once, then use the slop MCP tools: \`claim_task\`, work, \`wait_for_message\` at every stopping point (it holds until someone writes to you), \`reply\`. Without MCP: \`slop session start <KEY>\` and \`slop session wait <KEY>\` in the background (the exit is the message; relaunch at once). Talk through threads: \`slop task ask <KEY> "\u2026"\` reaches whoever is live on that task, \`slop thread reply <id> "\u2026"\` answers, \`slop threads\` lists them; general threads are for people and for context. Method: \`slop skill slop-sessions\`.
|
|
23750
23750
|
- Work that outlasts one session gets a plan on its task: \`slop task plan <KEY> -\` (one item per line), then \`slop task item note|done <KEY> <n>\` as you go; \`slop task items <KEY>\` shows where you are. \`slop skill slop-planning\` is the method; \`slop skills install\` puts the skills in this repository.
|
|
23751
23751
|
- Everything is editable: \`slop task update <KEY> --title \u2026 --severity \u2026 --status \u2026 --assignee \u2026\`. Assign with \`slop task assign <KEY> <email|me|none>\`; see who exists with \`slop members\`. \`slop task list --mine\` shows your user's tasks.
|
|
23752
23752
|
- Add \`--json\` to any command for machine-readable output. \`slop task --help\` lists everything.
|
|
@@ -23949,92 +23949,171 @@ linked to ${link.projectKey} ${link.projectName} (${link.baseUrl})`
|
|
|
23949
23949
|
});
|
|
23950
23950
|
}
|
|
23951
23951
|
|
|
23952
|
-
// src/commands/
|
|
23953
|
-
import {
|
|
23952
|
+
// src/commands/mcp.ts
|
|
23953
|
+
import { execFileSync as execFileSync3 } from "child_process";
|
|
23954
|
+
import { appendFileSync, existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync8, readdirSync, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "fs";
|
|
23955
|
+
import { dirname as dirname3 } from "path";
|
|
23956
|
+
import { homedir as homedir3 } from "os";
|
|
23957
|
+
import { join as join5 } from "path";
|
|
23954
23958
|
|
|
23955
|
-
// src/
|
|
23956
|
-
|
|
23957
|
-
|
|
23958
|
-
|
|
23959
|
-
|
|
23960
|
-
|
|
23961
|
-
|
|
23962
|
-
|
|
23963
|
-
|
|
23964
|
-
|
|
23965
|
-
|
|
23966
|
-
|
|
23967
|
-
|
|
23968
|
-
|
|
23969
|
-
|
|
23970
|
-
}
|
|
23971
|
-
|
|
23972
|
-
|
|
23973
|
-
|
|
23974
|
-
|
|
23975
|
-
|
|
23976
|
-
|
|
23977
|
-
|
|
23978
|
-
}
|
|
23979
|
-
|
|
23980
|
-
|
|
23981
|
-
withProject(program3.command("threads")).description("List the project's threads, newest activity first.").option("-t, --task <key>", "only threads about this task").option("--general", "only general threads").option("--unread", "only threads with messages you have not read").action(async (options) => {
|
|
23982
|
-
const api = authedApi();
|
|
23983
|
-
const project = await resolveProject(api, options.project);
|
|
23984
|
-
const query = new URLSearchParams();
|
|
23985
|
-
if (options.task) query.set("task", options.task);
|
|
23986
|
-
if (options.general) query.set("scope", "general");
|
|
23987
|
-
if (options.unread) query.set("unread", "1");
|
|
23988
|
-
const threads = await api.get(`/projects/${project.id}/threads${query.size ? `?${query}` : ""}`);
|
|
23989
|
-
emit(threads, () => threads.length === 0 ? "No threads." : threads.map(threadLine).join("\n"));
|
|
23990
|
-
});
|
|
23991
|
-
const thread = program3.command("thread").description("One thread: start, read, reply.");
|
|
23992
|
-
withProject(thread.command("new <subject>")).description('Start a thread. General by default; --task makes it about a task (and reaches whoever is live on it). The first message is -m, or "-" for stdin.').requiredOption("-m, --message <text>", 'the first message; "-" reads stdin').option("-t, --task <key>", "about this task").action(async (subject, options) => {
|
|
23993
|
-
const api = authedApi();
|
|
23994
|
-
const project = await resolveProject(api, options.project);
|
|
23995
|
-
const result = await api.post(`/projects/${project.id}/threads`, { subject, task: options.task, body: readText(options.message) });
|
|
23996
|
-
emit(result, () => started(result));
|
|
23997
|
-
});
|
|
23998
|
-
withProject(thread.command("show <id>")).description("Read a thread (and mark it read).").action(async (id, options) => {
|
|
23999
|
-
const api = authedApi();
|
|
24000
|
-
const project = await resolveProject(api, options.project);
|
|
24001
|
-
const detail = await api.get(`/projects/${project.id}/threads/${id}`);
|
|
24002
|
-
emit(detail, () => threadBlock(detail));
|
|
24003
|
-
});
|
|
24004
|
-
withProject(thread.command("reply <id> <text>")).description('Reply in a thread. About a task: reaches whoever is live on it. "-" reads stdin.').action(async (id, text, options) => {
|
|
24005
|
-
const api = authedApi();
|
|
24006
|
-
const project = await resolveProject(api, options.project);
|
|
24007
|
-
const result = await api.post(`/projects/${project.id}/threads/${id}/messages`, { body: readText(text) });
|
|
24008
|
-
emit(result, () => result.delivered ? `Replied; reached ${result.delivered} live session${result.delivered === 1 ? "" : "s"}.` : "Replied. Nobody is live on it; they see it when they start.");
|
|
24009
|
-
});
|
|
24010
|
-
withProject(program3.command("post <text>")).description('Start a general thread from one message (the first line is the subject). For a task, use --task. "-" reads stdin.').option("-t, --task <key>", "about this task").action(async (text, options) => {
|
|
24011
|
-
const api = authedApi();
|
|
24012
|
-
const project = await resolveProject(api, options.project);
|
|
24013
|
-
const body2 = readText(text);
|
|
24014
|
-
const result = await api.post(`/projects/${project.id}/threads`, { subject: subjectOf(body2), task: options.task, body: body2 });
|
|
24015
|
-
emit(result, () => started(result));
|
|
23959
|
+
// src/platform/live.ts
|
|
23960
|
+
async function waitForMessage(api, projectId, taskKey, options = {}) {
|
|
23961
|
+
const ticket = await api.post(`/projects/${projectId}/tasks/${encodeURIComponent(taskKey)}/session/ticket`);
|
|
23962
|
+
const socket = new WebSocket(`${api.baseUrl.replace(/^http/, "ws")}/api${ticket.path}`);
|
|
23963
|
+
const outcome = await new Promise((resolve2) => {
|
|
23964
|
+
const timer = options.timeoutMs && options.timeoutMs > 0 ? setTimeout(() => resolve2({ kind: "timeout" }), options.timeoutMs) : null;
|
|
23965
|
+
const done = (result) => {
|
|
23966
|
+
if (timer) clearTimeout(timer);
|
|
23967
|
+
resolve2(result);
|
|
23968
|
+
};
|
|
23969
|
+
socket.addEventListener("message", (event) => {
|
|
23970
|
+
const push = JSON.parse(String(event.data));
|
|
23971
|
+
if (push.type === "hello") {
|
|
23972
|
+
options.onHello?.(push.session);
|
|
23973
|
+
return;
|
|
23974
|
+
}
|
|
23975
|
+
if (push.type === "end") {
|
|
23976
|
+
done({ kind: "ended" });
|
|
23977
|
+
return;
|
|
23978
|
+
}
|
|
23979
|
+
if (push.type !== "thread") return;
|
|
23980
|
+
if (options.onMessage?.({ thread: push.thread, message: push.message })) return;
|
|
23981
|
+
done({ kind: "message", push: { thread: push.thread, message: push.message } });
|
|
23982
|
+
});
|
|
23983
|
+
socket.addEventListener("close", (event) => done({ kind: "dropped", reason: event.reason || `code ${event.code}` }));
|
|
23984
|
+
socket.addEventListener("error", () => done({ kind: "dropped", reason: "socket error" }));
|
|
24016
23985
|
});
|
|
24017
|
-
|
|
24018
|
-
|
|
24019
|
-
|
|
24020
|
-
|
|
24021
|
-
|
|
24022
|
-
|
|
23986
|
+
if (outcome.kind === "message" || outcome.kind === "timeout") {
|
|
23987
|
+
socket.close(1e3, outcome.kind === "message" ? "handled" : "timeout");
|
|
23988
|
+
await new Promise((resolve2) => {
|
|
23989
|
+
socket.addEventListener("close", () => resolve2(), { once: true });
|
|
23990
|
+
setTimeout(resolve2, 500);
|
|
23991
|
+
});
|
|
23992
|
+
}
|
|
23993
|
+
return outcome;
|
|
23994
|
+
}
|
|
23995
|
+
var HeldSession = class {
|
|
23996
|
+
constructor(api, projectId, taskKey, onMessage) {
|
|
23997
|
+
this.api = api;
|
|
23998
|
+
this.projectId = projectId;
|
|
23999
|
+
this.taskKey = taskKey;
|
|
24000
|
+
this.onMessage = onMessage;
|
|
24001
|
+
}
|
|
24002
|
+
api;
|
|
24003
|
+
projectId;
|
|
24004
|
+
taskKey;
|
|
24005
|
+
onMessage;
|
|
24006
|
+
socket = null;
|
|
24007
|
+
stopped = false;
|
|
24008
|
+
timer = null;
|
|
24009
|
+
attempt = 0;
|
|
24010
|
+
waiters = /* @__PURE__ */ new Set();
|
|
24011
|
+
async start() {
|
|
24012
|
+
await this.connect();
|
|
24013
|
+
}
|
|
24014
|
+
async connect() {
|
|
24015
|
+
if (this.stopped) return;
|
|
24016
|
+
try {
|
|
24017
|
+
const ticket = await this.api.post(`/projects/${this.projectId}/tasks/${encodeURIComponent(this.taskKey)}/session/ticket`);
|
|
24018
|
+
const socket = new WebSocket(`${this.api.baseUrl.replace(/^http/, "ws")}/api${ticket.path}`);
|
|
24019
|
+
this.socket = socket;
|
|
24020
|
+
socket.addEventListener("open", () => {
|
|
24021
|
+
this.attempt = 0;
|
|
24022
|
+
});
|
|
24023
|
+
socket.addEventListener("message", (event) => {
|
|
24024
|
+
const push = JSON.parse(String(event.data));
|
|
24025
|
+
if (push.type === "end") {
|
|
24026
|
+
this.stopped = true;
|
|
24027
|
+
return;
|
|
24028
|
+
}
|
|
24029
|
+
if (push.type !== "thread") return;
|
|
24030
|
+
const delivered = { thread: push.thread, message: push.message };
|
|
24031
|
+
for (const waiter of this.waiters) waiter(delivered);
|
|
24032
|
+
if (this.waiters.size === 0) this.onMessage(delivered);
|
|
24033
|
+
});
|
|
24034
|
+
socket.addEventListener("close", () => {
|
|
24035
|
+
this.socket = null;
|
|
24036
|
+
if (!this.stopped) this.schedule();
|
|
24037
|
+
});
|
|
24038
|
+
socket.addEventListener("error", () => {
|
|
24039
|
+
});
|
|
24040
|
+
} catch {
|
|
24041
|
+
this.schedule();
|
|
24042
|
+
}
|
|
24043
|
+
}
|
|
24044
|
+
schedule() {
|
|
24045
|
+
this.attempt += 1;
|
|
24046
|
+
this.timer = setTimeout(() => void this.connect(), Math.min(3e4, 1e3 * 2 ** Math.min(this.attempt, 5)));
|
|
24047
|
+
}
|
|
24048
|
+
stop() {
|
|
24049
|
+
this.stopped = true;
|
|
24050
|
+
if (this.timer) clearTimeout(this.timer);
|
|
24051
|
+
this.socket?.close(1e3, "released");
|
|
24052
|
+
}
|
|
24053
|
+
};
|
|
24054
|
+
|
|
24055
|
+
// src/platform/mcp.ts
|
|
24056
|
+
import { createInterface } from "readline";
|
|
24057
|
+
function serveMcp(tools2, info) {
|
|
24058
|
+
const send = (message) => process.stdout.write(`${JSON.stringify(message)}
|
|
24059
|
+
`);
|
|
24060
|
+
const reply = (id, result) => send({ jsonrpc: "2.0", id, result });
|
|
24061
|
+
const fail2 = (id, code, message) => send({ jsonrpc: "2.0", id, error: { code, message } });
|
|
24062
|
+
const handle = async (request) => {
|
|
24063
|
+
const { id, method, params = {} } = request;
|
|
24064
|
+
switch (method) {
|
|
24065
|
+
case "initialize":
|
|
24066
|
+
reply(id, { protocolVersion: params.protocolVersion ?? "2025-06-18", capabilities: { tools: {} }, serverInfo: info });
|
|
24067
|
+
return;
|
|
24068
|
+
case "notifications/initialized":
|
|
24069
|
+
case "notifications/cancelled":
|
|
24070
|
+
return;
|
|
24071
|
+
case "ping":
|
|
24072
|
+
reply(id, {});
|
|
24073
|
+
return;
|
|
24074
|
+
case "tools/list":
|
|
24075
|
+
reply(id, { tools: tools2.map(({ name, description: description2, inputSchema }) => ({ name, description: description2, inputSchema })) });
|
|
24076
|
+
return;
|
|
24077
|
+
case "tools/call": {
|
|
24078
|
+
const name = params.name;
|
|
24079
|
+
const tool = tools2.find((candidate) => candidate.name === name);
|
|
24080
|
+
if (!tool) {
|
|
24081
|
+
fail2(id, -32602, `No tool named ${name}`);
|
|
24082
|
+
return;
|
|
24083
|
+
}
|
|
24084
|
+
try {
|
|
24085
|
+
const text = await tool.run(params.arguments ?? {});
|
|
24086
|
+
reply(id, { content: [{ type: "text", text }] });
|
|
24087
|
+
} catch (error62) {
|
|
24088
|
+
reply(id, { content: [{ type: "text", text: error62 instanceof Error ? error62.message : String(error62) }], isError: true });
|
|
24089
|
+
}
|
|
24090
|
+
return;
|
|
24091
|
+
}
|
|
24092
|
+
default:
|
|
24093
|
+
if (id !== void 0) fail2(id, -32601, `Unknown method ${method}`);
|
|
24094
|
+
}
|
|
24095
|
+
};
|
|
24096
|
+
const lines = createInterface({ input: process.stdin });
|
|
24097
|
+
lines.on("line", (line) => {
|
|
24098
|
+
if (!line.trim()) return;
|
|
24099
|
+
let request;
|
|
24100
|
+
try {
|
|
24101
|
+
request = JSON.parse(line);
|
|
24102
|
+
} catch {
|
|
24103
|
+
fail2(null, -32700, "Parse error");
|
|
24104
|
+
return;
|
|
24105
|
+
}
|
|
24106
|
+
void handle(request);
|
|
24023
24107
|
});
|
|
24108
|
+
lines.on("close", () => process.exit(0));
|
|
24024
24109
|
}
|
|
24025
|
-
var subjectOf = (body2) => {
|
|
24026
|
-
const line = body2.split("\n")[0]?.trim() ?? "";
|
|
24027
|
-
if (!line) throw new CliError("Say something", "the first line becomes the subject");
|
|
24028
|
-
return line.length > 120 ? `${line.slice(0, 117)}\u2026` : line;
|
|
24029
|
-
};
|
|
24030
|
-
var started = (result) => result.thread.taskKey ? result.delivered ? `Started ${result.thread.id} on ${result.thread.taskKey}; reached ${result.delivered} live session${result.delivered === 1 ? "" : "s"}.` : `Started ${result.thread.id} on ${result.thread.taskKey}. Nobody is live on it; they see it when they start.` : `Started ${result.thread.id} (general). People see it on the web; agents at their next session start.`;
|
|
24031
24110
|
|
|
24032
24111
|
// src/commands/tasks.ts
|
|
24033
|
-
import { readFileSync as
|
|
24112
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
24034
24113
|
|
|
24035
24114
|
// src/commands/items.ts
|
|
24036
|
-
import { readFileSync as
|
|
24037
|
-
var
|
|
24115
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
24116
|
+
var readText = (value) => value === "-" ? readFileSync5(0, "utf8").trim() : value;
|
|
24038
24117
|
var path2 = (projectId, key) => `/projects/${projectId}/tasks/${encodeURIComponent(key)}/items`;
|
|
24039
24118
|
function renderItems(items) {
|
|
24040
24119
|
if (items.length === 0) return "No plan yet. Write one: slop task plan <KEY> -";
|
|
@@ -24061,7 +24140,7 @@ function registerItemCommands(task, withProject) {
|
|
|
24061
24140
|
withProject(task.command("plan <key> [lines...]")).description('Append items to the plan, one per argument; "-" reads one per line from stdin (list markers are fine).').action(async (key, lines, options) => {
|
|
24062
24141
|
const api = authedApi();
|
|
24063
24142
|
const project = await resolveProject(api, options.project);
|
|
24064
|
-
const source = lines.length === 1 && lines[0] === "-" ?
|
|
24143
|
+
const source = lines.length === 1 && lines[0] === "-" ? readFileSync5(0, "utf8") : lines.join("\n");
|
|
24065
24144
|
const titles = source.split("\n").map((line) => line.replace(/^\s*(?:[-*+]|\d+[.)])\s*(?:\[[ xX]\]\s*)?/, "").trim()).filter(Boolean);
|
|
24066
24145
|
if (titles.length === 0) throw new CliError("Nothing to add", 'give items as arguments, or "-" and one per line on stdin');
|
|
24067
24146
|
const items = await api.post(path2(project.id, key), { items: titles.map((title3) => ({ title: title3 })) });
|
|
@@ -24071,7 +24150,7 @@ function registerItemCommands(task, withProject) {
|
|
|
24071
24150
|
withProject(item.command("add <key> <title>")).description("Add an item to the end of the plan.").option("-n, --note <text>", 'what is true about it now; "-" reads stdin').action(async (key, title3, options) => {
|
|
24072
24151
|
const api = authedApi();
|
|
24073
24152
|
const project = await resolveProject(api, options.project);
|
|
24074
|
-
const items = await api.post(path2(project.id, key), { title: title3, note: options.note ?
|
|
24153
|
+
const items = await api.post(path2(project.id, key), { title: title3, note: options.note ? readText(options.note) : "" });
|
|
24075
24154
|
emit(items, () => renderItems(items));
|
|
24076
24155
|
});
|
|
24077
24156
|
for (const [name, done, help] of [
|
|
@@ -24090,7 +24169,7 @@ function registerItemCommands(task, withProject) {
|
|
|
24090
24169
|
const api = authedApi();
|
|
24091
24170
|
const project = await resolveProject(api, options.project);
|
|
24092
24171
|
const target = await itemAt(api, project.id, key, ref);
|
|
24093
|
-
const items = await api.patch(`${path2(project.id, key)}/${target.id}`, { note:
|
|
24172
|
+
const items = await api.patch(`${path2(project.id, key)}/${target.id}`, { note: readText(text) });
|
|
24094
24173
|
emit(items, () => renderItems(items));
|
|
24095
24174
|
});
|
|
24096
24175
|
withProject(item.command("rename <key> <item> <title>")).description("Retitle an item.").action(async (key, ref, title3, options) => {
|
|
@@ -24118,7 +24197,7 @@ function oneOf(value, allowed, what) {
|
|
|
24118
24197
|
if (allowed.includes(normalized)) return normalized;
|
|
24119
24198
|
throw new CliError(`Unknown ${what} "${value}"`, `use one of: ${allowed.join(", ")}`);
|
|
24120
24199
|
}
|
|
24121
|
-
var readDescription = (value) => value === "-" ?
|
|
24200
|
+
var readDescription = (value) => value === "-" ? readFileSync6(0, "utf8").trim() : value;
|
|
24122
24201
|
var taskUrl = (baseUrl, projectId, task) => `${baseUrl}/projects/${projectId}?task=${task.key}`;
|
|
24123
24202
|
var loadProject = (api, id) => api.get(`/projects/${id}`);
|
|
24124
24203
|
function resolveStatus(project, ref) {
|
|
@@ -24268,13 +24347,437 @@ ${taskUrl(api.baseUrl, project.id, created)}`);
|
|
|
24268
24347
|
return task;
|
|
24269
24348
|
}
|
|
24270
24349
|
|
|
24271
|
-
// src/commands/
|
|
24350
|
+
// src/commands/threads.ts
|
|
24351
|
+
import { readFileSync as readFileSync7 } from "fs";
|
|
24352
|
+
var readText2 = (value) => value === "-" ? readFileSync7(0, "utf8").trim() : value;
|
|
24353
|
+
var when = (iso) => iso.slice(0, 16).replace("T", " ");
|
|
24354
|
+
var who = (message) => `${message.author.name}${message.via === "agent" ? ` (agent${message.machine ? ` \xB7 ${message.machine}` : ""})` : ""}`;
|
|
24355
|
+
function threadLine(thread) {
|
|
24356
|
+
const scope = thread.taskKey ?? "general";
|
|
24357
|
+
const unread = thread.unread > 0 ? ` ${thread.unread} unread` : "";
|
|
24358
|
+
const last = thread.last ? `
|
|
24359
|
+
${who(thread.last)}: ${thread.last.body.split("\n")[0]}` : "";
|
|
24360
|
+
return `${thread.id} [${scope}] ${thread.subject} (${thread.messageCount} msg, ${when(thread.lastMessageAt)})${unread}${last}`;
|
|
24361
|
+
}
|
|
24362
|
+
function messageBlock(message) {
|
|
24363
|
+
return `${who(message)} ${when(message.createdAt)}
|
|
24364
|
+
${message.body.replace(/^/gm, " ")}`;
|
|
24365
|
+
}
|
|
24366
|
+
function threadBlock(thread) {
|
|
24367
|
+
return [`${thread.subject} [${thread.taskKey ?? "general"}] ${thread.id}`, "", ...thread.messages.map(messageBlock)].join("\n\n").replace("\n\n\n", "\n\n");
|
|
24368
|
+
}
|
|
24369
|
+
function pushBlock(push) {
|
|
24370
|
+
return `Thread ${push.thread.id} [${push.thread.taskKey ?? "general"}] ${push.thread.subject}
|
|
24371
|
+
${messageBlock(push.message)}
|
|
24372
|
+
Reply: slop thread reply ${push.thread.id} "\u2026"`;
|
|
24373
|
+
}
|
|
24374
|
+
function registerThreadCommands(program3, task) {
|
|
24375
|
+
const withProject = (command) => command.option("-p, --project <key>", "project key (default: the project this repository is linked to)");
|
|
24376
|
+
withProject(program3.command("threads")).description("List the project's threads, newest activity first.").option("-t, --task <key>", "only threads about this task").option("--general", "only general threads").option("--unread", "only threads with messages you have not read").action(async (options) => {
|
|
24377
|
+
const api = authedApi();
|
|
24378
|
+
const project = await resolveProject(api, options.project);
|
|
24379
|
+
const query = new URLSearchParams();
|
|
24380
|
+
if (options.task) query.set("task", options.task);
|
|
24381
|
+
if (options.general) query.set("scope", "general");
|
|
24382
|
+
if (options.unread) query.set("unread", "1");
|
|
24383
|
+
const threads = await api.get(`/projects/${project.id}/threads${query.size ? `?${query}` : ""}`);
|
|
24384
|
+
emit(threads, () => threads.length === 0 ? "No threads." : threads.map(threadLine).join("\n"));
|
|
24385
|
+
});
|
|
24386
|
+
const thread = program3.command("thread").description("One thread: start, read, reply.");
|
|
24387
|
+
withProject(thread.command("new <subject>")).description('Start a thread. General by default; --task makes it about a task (and reaches whoever is live on it). The first message is -m, or "-" for stdin.').requiredOption("-m, --message <text>", 'the first message; "-" reads stdin').option("-t, --task <key>", "about this task").action(async (subject, options) => {
|
|
24388
|
+
const api = authedApi();
|
|
24389
|
+
const project = await resolveProject(api, options.project);
|
|
24390
|
+
const result = await api.post(`/projects/${project.id}/threads`, { subject, task: options.task, body: readText2(options.message) });
|
|
24391
|
+
emit(result, () => started(result));
|
|
24392
|
+
});
|
|
24393
|
+
withProject(thread.command("show <id>")).description("Read a thread (and mark it read).").action(async (id, options) => {
|
|
24394
|
+
const api = authedApi();
|
|
24395
|
+
const project = await resolveProject(api, options.project);
|
|
24396
|
+
const detail = await api.get(`/projects/${project.id}/threads/${id}`);
|
|
24397
|
+
emit(detail, () => threadBlock(detail));
|
|
24398
|
+
});
|
|
24399
|
+
withProject(thread.command("reply <id> <text>")).description('Reply in a thread. About a task: reaches whoever is live on it. "-" reads stdin.').action(async (id, text, options) => {
|
|
24400
|
+
const api = authedApi();
|
|
24401
|
+
const project = await resolveProject(api, options.project);
|
|
24402
|
+
const result = await api.post(`/projects/${project.id}/threads/${id}/messages`, { body: readText2(text) });
|
|
24403
|
+
emit(result, () => result.delivered ? `Replied; reached ${result.delivered} live session${result.delivered === 1 ? "" : "s"}.` : "Replied. Nobody is live on it; they see it when they start.");
|
|
24404
|
+
});
|
|
24405
|
+
withProject(program3.command("post <text>")).description('Start a general thread from one message (the first line is the subject). For a task, use --task. "-" reads stdin.').option("-t, --task <key>", "about this task").action(async (text, options) => {
|
|
24406
|
+
const api = authedApi();
|
|
24407
|
+
const project = await resolveProject(api, options.project);
|
|
24408
|
+
const body2 = readText2(text);
|
|
24409
|
+
const result = await api.post(`/projects/${project.id}/threads`, { subject: subjectOf(body2), task: options.task, body: body2 });
|
|
24410
|
+
emit(result, () => started(result));
|
|
24411
|
+
});
|
|
24412
|
+
withProject(task.command("ask <key> <text>")).description('Start a thread about the task and say something to whoever is live on it. "-" reads stdin.').action(async (key, text, options) => {
|
|
24413
|
+
const api = authedApi();
|
|
24414
|
+
const project = await resolveProject(api, options.project);
|
|
24415
|
+
const body2 = readText2(text);
|
|
24416
|
+
const result = await api.post(`/projects/${project.id}/threads`, { subject: subjectOf(body2), task: key, body: body2 });
|
|
24417
|
+
emit(result, () => started(result));
|
|
24418
|
+
});
|
|
24419
|
+
}
|
|
24420
|
+
var subjectOf = (body2) => {
|
|
24421
|
+
const line = body2.split("\n")[0]?.trim() ?? "";
|
|
24422
|
+
if (!line) throw new CliError("Say something", "the first line becomes the subject");
|
|
24423
|
+
return line.length > 120 ? `${line.slice(0, 117)}\u2026` : line;
|
|
24424
|
+
};
|
|
24425
|
+
var started = (result) => result.thread.taskKey ? result.delivered ? `Started ${result.thread.id} on ${result.thread.taskKey}; reached ${result.delivered} live session${result.delivered === 1 ? "" : "s"}.` : `Started ${result.thread.id} on ${result.thread.taskKey}. Nobody is live on it; they see it when they start.` : `Started ${result.thread.id} (general). People see it on the web; agents at their next session start.`;
|
|
24426
|
+
|
|
24427
|
+
// src/commands/mcp.ts
|
|
24428
|
+
var str = (description2) => ({ type: "string", description: description2 });
|
|
24429
|
+
var int2 = (description2) => ({ type: "integer", description: description2 });
|
|
24430
|
+
var schema = (properties, required2 = []) => ({ type: "object", properties, required: required2, additionalProperties: false });
|
|
24431
|
+
var PROJECT = str("Project key. Defaults to the project this repository is linked to.");
|
|
24272
24432
|
var taskPath = (projectId, key) => `/projects/${projectId}/tasks/${encodeURIComponent(key)}`;
|
|
24273
|
-
var
|
|
24274
|
-
|
|
24275
|
-
|
|
24276
|
-
|
|
24433
|
+
var inboxDir = () => join5(dirname3(configPath()), "inbox");
|
|
24434
|
+
var inboxFile = (projectId) => join5(inboxDir(), `${projectId}.jsonl`);
|
|
24435
|
+
function inboxWrite(projectId, push) {
|
|
24436
|
+
mkdirSync4(inboxDir(), { recursive: true });
|
|
24437
|
+
appendFileSync(inboxFile(projectId), `${JSON.stringify(push)}
|
|
24438
|
+
`);
|
|
24439
|
+
}
|
|
24440
|
+
function inboxDrain(projectId) {
|
|
24441
|
+
const path3 = inboxFile(projectId);
|
|
24442
|
+
if (!existsSync5(path3)) return [];
|
|
24443
|
+
const lines = readFileSync8(path3, "utf8").split("\n").filter(Boolean);
|
|
24444
|
+
rmSync3(path3, { force: true });
|
|
24445
|
+
return lines.map((line) => JSON.parse(line));
|
|
24446
|
+
}
|
|
24447
|
+
function inboxDrainAll() {
|
|
24448
|
+
if (!existsSync5(inboxDir())) return [];
|
|
24449
|
+
return readdirSync(inboxDir()).flatMap((name) => inboxDrain(name.replace(/\.jsonl$/, "")));
|
|
24450
|
+
}
|
|
24451
|
+
async function digest(api, projectId, taskKey) {
|
|
24452
|
+
const [about, mine, general] = await Promise.all([
|
|
24453
|
+
taskKey ? api.get(`/projects/${projectId}/threads?task=${encodeURIComponent(taskKey)}&unread=1&read=1`) : Promise.resolve([]),
|
|
24454
|
+
api.get(`/projects/${projectId}/threads?participant=1&unread=1&read=1`),
|
|
24455
|
+
api.get(`/projects/${projectId}/threads?scope=general&unread=1&read=1`)
|
|
24456
|
+
]);
|
|
24457
|
+
const lines = [];
|
|
24458
|
+
if (about.length) lines.push(`Unread about ${taskKey} (read one with the thread tool):`, ...about.map(threadLine));
|
|
24459
|
+
const elsewhere = mine.filter((thread) => !about.some((candidate) => candidate.id === thread.id));
|
|
24460
|
+
if (elsewhere.length) lines.push("Unread in threads you are part of (answers to you):", ...elsewhere.map(threadLine));
|
|
24461
|
+
if (general.length) lines.push("Unread general threads (context; nobody has to answer):", ...general.map(threadLine));
|
|
24462
|
+
return lines.length ? lines.join("\n") : "Nothing unread.";
|
|
24463
|
+
}
|
|
24464
|
+
function tools() {
|
|
24465
|
+
const api = authedApi();
|
|
24466
|
+
const project = (args) => resolveProject(api, args.project);
|
|
24467
|
+
let held = null;
|
|
24468
|
+
const hold = async (projectId, taskKey) => {
|
|
24469
|
+
if (held && held.projectId === projectId && held.taskKey === taskKey) return;
|
|
24470
|
+
held?.stop();
|
|
24471
|
+
held = new HeldSession(api, projectId, taskKey, (push) => inboxWrite(projectId, push));
|
|
24472
|
+
await held.start();
|
|
24473
|
+
};
|
|
24474
|
+
const release = () => {
|
|
24475
|
+
held?.stop();
|
|
24476
|
+
held = null;
|
|
24477
|
+
};
|
|
24478
|
+
return [
|
|
24479
|
+
{
|
|
24480
|
+
name: "wait_for_message",
|
|
24481
|
+
description: "Optional. Block until the next message in a thread about the task you hold (claim_task first), or until `minutes` pass. You do not need this to be reached: messages arrive on their own after your next tool call. Use it only when you have nothing else to do and want to sit and wait.",
|
|
24482
|
+
inputSchema: schema({ task: str("Task key, e.g. WEB-12"), minutes: int2("How long to wait before returning empty (default 10)"), project: PROJECT }, ["task"]),
|
|
24483
|
+
run: async (args) => {
|
|
24484
|
+
const target = await project(args);
|
|
24485
|
+
await hold(target.id, String(args.task));
|
|
24486
|
+
const queued = inboxDrain(target.id);
|
|
24487
|
+
if (queued.length) return queued.map(pushBlock).join("\n\n");
|
|
24488
|
+
const minutes = typeof args.minutes === "number" ? args.minutes : 10;
|
|
24489
|
+
const push = await new Promise((resolve2) => {
|
|
24490
|
+
const waiter = (delivered) => {
|
|
24491
|
+
held?.waiters.delete(waiter);
|
|
24492
|
+
resolve2(delivered);
|
|
24493
|
+
};
|
|
24494
|
+
held?.waiters.add(waiter);
|
|
24495
|
+
setTimeout(() => {
|
|
24496
|
+
held?.waiters.delete(waiter);
|
|
24497
|
+
resolve2(null);
|
|
24498
|
+
}, minutes * 6e4);
|
|
24499
|
+
});
|
|
24500
|
+
return push ? pushBlock(push) : `No message in ${minutes} minutes.`;
|
|
24501
|
+
}
|
|
24502
|
+
},
|
|
24503
|
+
{
|
|
24504
|
+
name: "check_messages",
|
|
24505
|
+
description: "What is unread right now: anything the held session received since you last looked, threads about a task (if given), and general threads. Does not wait. Marks them read.",
|
|
24506
|
+
inputSchema: schema({ task: str("Task key"), project: PROJECT }),
|
|
24507
|
+
run: async (args) => {
|
|
24508
|
+
const target = await project(args);
|
|
24509
|
+
const queued = inboxDrain(target.id).map(pushBlock);
|
|
24510
|
+
const rest = await digest(api, target.id, args.task ?? null);
|
|
24511
|
+
return [...queued, rest].join("\n\n");
|
|
24512
|
+
}
|
|
24513
|
+
},
|
|
24514
|
+
{
|
|
24515
|
+
name: "reply",
|
|
24516
|
+
description: "Reply in a thread. In a thread about a task, it reaches whoever is live on that task now, or waits for them.",
|
|
24517
|
+
inputSchema: schema({ thread: str("Thread id"), body: str("The message (Markdown)"), project: PROJECT }, ["thread", "body"]),
|
|
24518
|
+
run: async (args) => {
|
|
24519
|
+
const target = await project(args);
|
|
24520
|
+
const result = await api.post(`/projects/${target.id}/threads/${String(args.thread)}/messages`, { body: String(args.body) });
|
|
24521
|
+
return result.delivered ? `Replied; reached ${result.delivered} live session(s).` : "Replied. Nobody is live on it; they see it when they start.";
|
|
24522
|
+
}
|
|
24523
|
+
},
|
|
24524
|
+
{
|
|
24525
|
+
name: "post",
|
|
24526
|
+
description: "Start a thread. With a task: about that task, to whoever is live on it (or whoever picks it up). Without: general, for people and for context; nobody has to answer.",
|
|
24527
|
+
inputSchema: schema({ subject: str("Subject"), body: str("First message (Markdown)"), task: str("Task key, to make it about that task"), project: PROJECT }, ["subject", "body"]),
|
|
24528
|
+
run: async (args) => {
|
|
24529
|
+
const target = await project(args);
|
|
24530
|
+
const result = await api.post(`/projects/${target.id}/threads`, { subject: String(args.subject), body: String(args.body), task: args.task });
|
|
24531
|
+
return `Started ${result.thread.id}${result.thread.taskKey ? ` on ${result.thread.taskKey}` : " (general)"}${result.delivered ? `; reached ${result.delivered} live session(s)` : ""}.`;
|
|
24532
|
+
}
|
|
24533
|
+
},
|
|
24534
|
+
{
|
|
24535
|
+
name: "threads",
|
|
24536
|
+
description: "List threads, newest activity first.",
|
|
24537
|
+
inputSchema: schema({ task: str("Only threads about this task"), unread: { type: "boolean", description: "Only unread" }, project: PROJECT }),
|
|
24538
|
+
run: async (args) => {
|
|
24539
|
+
const target = await project(args);
|
|
24540
|
+
const query = new URLSearchParams();
|
|
24541
|
+
if (args.task) query.set("task", String(args.task));
|
|
24542
|
+
if (args.unread) query.set("unread", "1");
|
|
24543
|
+
const list = await api.get(`/projects/${target.id}/threads${query.size ? `?${query}` : ""}`);
|
|
24544
|
+
return list.length ? list.map(threadLine).join("\n") : "No threads.";
|
|
24545
|
+
}
|
|
24546
|
+
},
|
|
24547
|
+
{
|
|
24548
|
+
name: "thread",
|
|
24549
|
+
description: "Read a thread in full (marks it read).",
|
|
24550
|
+
inputSchema: schema({ id: str("Thread id"), project: PROJECT }, ["id"]),
|
|
24551
|
+
run: async (args) => threadBlock(await api.get(`/projects/${(await project(args)).id}/threads/${String(args.id)}`))
|
|
24552
|
+
},
|
|
24553
|
+
{
|
|
24554
|
+
name: "sessions",
|
|
24555
|
+
description: "Who is live on which task right now.",
|
|
24556
|
+
inputSchema: schema({ project: PROJECT }),
|
|
24557
|
+
run: async (args) => {
|
|
24558
|
+
const list = await api.get(`/projects/${(await project(args)).id}/sessions`);
|
|
24559
|
+
return list.length ? list.map((session) => `${session.taskKey} ${session.user.name} ${session.machine.name} since ${session.startedAt}`).join("\n") : "Nobody is live.";
|
|
24560
|
+
}
|
|
24561
|
+
},
|
|
24562
|
+
{
|
|
24563
|
+
name: "claim_task",
|
|
24564
|
+
description: "Take a task: assign it to you, move it to in progress, go live on it for as long as this server runs, and get what is unread about it. From now on a message in a thread about the task reaches you on its own, right after your next tool call; you do not have to wait or poll.",
|
|
24565
|
+
inputSchema: schema({ task: str("Task key"), project: PROJECT }, ["task"]),
|
|
24566
|
+
run: async (args) => {
|
|
24567
|
+
const target = await loadProject(api, (await project(args)).id);
|
|
24568
|
+
const assigneeId = await resolveAssignee(api, target.id, "me");
|
|
24569
|
+
const task = await api.patch(taskPath(target.id, String(args.task)), { assigneeId, status: statusInCategory(target, "in_progress") });
|
|
24570
|
+
await hold(target.id, task.key);
|
|
24571
|
+
return `Claimed ${task.key} ${task.title}. You are live on it; messages about it reach you as you work.
|
|
24572
|
+
|
|
24573
|
+
${await digest(api, target.id, task.key)}`;
|
|
24574
|
+
}
|
|
24575
|
+
},
|
|
24576
|
+
{
|
|
24577
|
+
name: "release_task",
|
|
24578
|
+
description: "Stop being live on the task you hold (without finishing it).",
|
|
24579
|
+
inputSchema: schema({ project: PROJECT }),
|
|
24580
|
+
run: async () => {
|
|
24581
|
+
release();
|
|
24582
|
+
return "Released.";
|
|
24583
|
+
}
|
|
24584
|
+
},
|
|
24585
|
+
{
|
|
24586
|
+
name: "show_task",
|
|
24587
|
+
description: "A task in full: status, severity, assignee, links, plan with notes, description, notes.",
|
|
24588
|
+
inputSchema: schema({ task: str("Task key"), project: PROJECT }, ["task"]),
|
|
24589
|
+
run: async (args) => {
|
|
24590
|
+
const target = await project(args);
|
|
24591
|
+
const task = await api.get(taskPath(target.id, String(args.task)));
|
|
24592
|
+
const plan = task.items.map((item, index) => ` ${index + 1}. [${item.done ? "x" : " "}] ${item.title}${item.note ? `
|
|
24593
|
+
${item.note.replace(/\n/g, "\n ")}` : ""}`).join("\n");
|
|
24594
|
+
return [`${task.key} ${task.title}`, `status: ${task.status} severity: ${task.severity} assignee: ${task.assignee?.name ?? "nobody"}`, task.links.length ? `links: ${task.links.map((link) => link.url).join(", ")}` : "", task.items.length ? `plan (${task.progress.done}/${task.progress.total}):
|
|
24595
|
+
${plan}` : "", task.description ? `
|
|
24596
|
+
${task.description}` : "", task.notes ? `
|
|
24597
|
+
notes:
|
|
24598
|
+
${task.notes}` : ""].filter(Boolean).join("\n");
|
|
24599
|
+
}
|
|
24600
|
+
},
|
|
24601
|
+
{
|
|
24602
|
+
name: "note_item",
|
|
24603
|
+
description: "Replace a plan item's note with what is true now (Markdown). Items are numbered as in show_task.",
|
|
24604
|
+
inputSchema: schema({ task: str("Task key"), item: int2("Item number"), note: str("The note"), project: PROJECT }, ["task", "item", "note"]),
|
|
24605
|
+
run: async (args) => {
|
|
24606
|
+
const target = await project(args);
|
|
24607
|
+
const items = await api.get(`${taskPath(target.id, String(args.task))}/items`);
|
|
24608
|
+
const item = items[Number(args.item) - 1];
|
|
24609
|
+
if (!item) throw new Error(`No item ${String(args.item)}`);
|
|
24610
|
+
await api.patch(`${taskPath(target.id, String(args.task))}/items/${item.id}`, { note: String(args.note) });
|
|
24611
|
+
return `Noted on item ${String(args.item)}.`;
|
|
24612
|
+
}
|
|
24613
|
+
},
|
|
24614
|
+
{
|
|
24615
|
+
name: "finish_item",
|
|
24616
|
+
description: "Tick a plan item done.",
|
|
24617
|
+
inputSchema: schema({ task: str("Task key"), item: int2("Item number"), project: PROJECT }, ["task", "item"]),
|
|
24618
|
+
run: async (args) => {
|
|
24619
|
+
const target = await project(args);
|
|
24620
|
+
const items = await api.get(`${taskPath(target.id, String(args.task))}/items`);
|
|
24621
|
+
const item = items[Number(args.item) - 1];
|
|
24622
|
+
if (!item) throw new Error(`No item ${String(args.item)}`);
|
|
24623
|
+
await api.patch(`${taskPath(target.id, String(args.task))}/items/${item.id}`, { done: true });
|
|
24624
|
+
return `Item ${String(args.item)} done.`;
|
|
24625
|
+
}
|
|
24626
|
+
},
|
|
24627
|
+
{
|
|
24628
|
+
name: "finish_task",
|
|
24629
|
+
description: "Move a task to the first done column.",
|
|
24630
|
+
inputSchema: schema({ task: str("Task key"), project: PROJECT }, ["task"]),
|
|
24631
|
+
run: async (args) => {
|
|
24632
|
+
const target = await loadProject(api, (await project(args)).id);
|
|
24633
|
+
const task = await api.patch(taskPath(target.id, String(args.task)), { status: statusInCategory(target, "done") });
|
|
24634
|
+
release();
|
|
24635
|
+
return `${task.key} is done.`;
|
|
24636
|
+
}
|
|
24637
|
+
}
|
|
24638
|
+
];
|
|
24277
24639
|
}
|
|
24640
|
+
function readJson(path3) {
|
|
24641
|
+
try {
|
|
24642
|
+
return JSON.parse(readFileSync8(path3, "utf8"));
|
|
24643
|
+
} catch {
|
|
24644
|
+
return {};
|
|
24645
|
+
}
|
|
24646
|
+
}
|
|
24647
|
+
function installClaude() {
|
|
24648
|
+
const done = [];
|
|
24649
|
+
try {
|
|
24650
|
+
execFileSync3("claude", ["mcp", "add", "--scope", "user", "slop", "--", "slop", "mcp"], { stdio: "ignore" });
|
|
24651
|
+
done.push('Claude Code: MCP server "slop" registered (user scope)');
|
|
24652
|
+
} catch {
|
|
24653
|
+
done.push("Claude Code: run `claude mcp add --scope user slop -- slop mcp` (the claude command was not found here)");
|
|
24654
|
+
}
|
|
24655
|
+
const dir = join5(homedir3(), ".claude");
|
|
24656
|
+
const path3 = join5(dir, "settings.json");
|
|
24657
|
+
mkdirSync4(dir, { recursive: true });
|
|
24658
|
+
const settings = readJson(path3);
|
|
24659
|
+
settings.hooks = mergeHooks(settings.hooks ?? {});
|
|
24660
|
+
settings.env = { ...settings.env ?? {}, MCP_TOOL_TIMEOUT: "1800000" };
|
|
24661
|
+
writeFileSync5(path3, `${JSON.stringify(settings, null, 2)}
|
|
24662
|
+
`);
|
|
24663
|
+
done.push(`Claude Code: PostToolUse and Stop hooks and MCP_TOOL_TIMEOUT written to ${path3}`);
|
|
24664
|
+
return done;
|
|
24665
|
+
}
|
|
24666
|
+
function mergeHooks(hooks) {
|
|
24667
|
+
const stop = hooks.Stop ?? [];
|
|
24668
|
+
if (!stop.some((entry) => entry.hooks?.some((hook) => hook.command === "slop hook stop"))) {
|
|
24669
|
+
stop.push({ hooks: [{ type: "command", command: "slop hook stop", timeout: 30, statusMessage: "Checking Slopware Tasks for messages" }] });
|
|
24670
|
+
}
|
|
24671
|
+
const tick = hooks.PostToolUse ?? [];
|
|
24672
|
+
if (!tick.some((entry) => entry.hooks?.some((hook) => hook.command === "slop hook tick"))) {
|
|
24673
|
+
tick.push({ hooks: [{ type: "command", command: "slop hook tick", timeout: 5, statusMessage: "Slopware Tasks inbox" }] });
|
|
24674
|
+
}
|
|
24675
|
+
return { ...hooks, Stop: stop, PostToolUse: tick };
|
|
24676
|
+
}
|
|
24677
|
+
function installCodex() {
|
|
24678
|
+
const done = [];
|
|
24679
|
+
const dir = join5(homedir3(), ".codex");
|
|
24680
|
+
mkdirSync4(dir, { recursive: true });
|
|
24681
|
+
const configPath2 = join5(dir, "config.toml");
|
|
24682
|
+
const current = existsSync5(configPath2) ? readFileSync8(configPath2, "utf8") : "";
|
|
24683
|
+
if (/^\[mcp_servers\.slop\]/m.test(current)) done.push(`Codex: MCP server already in ${configPath2}`);
|
|
24684
|
+
else {
|
|
24685
|
+
writeFileSync5(configPath2, `${current.trimEnd()}${current.trim() ? "\n\n" : ""}[mcp_servers.slop]
|
|
24686
|
+
command = "slop"
|
|
24687
|
+
args = ["mcp"]
|
|
24688
|
+
tool_timeout_sec = 1800
|
|
24689
|
+
`);
|
|
24690
|
+
done.push(`Codex: MCP server "slop" added to ${configPath2}`);
|
|
24691
|
+
}
|
|
24692
|
+
const hooksPath = join5(dir, "hooks.json");
|
|
24693
|
+
const file2 = readJson(hooksPath);
|
|
24694
|
+
file2.hooks = mergeHooks(file2.hooks ?? {});
|
|
24695
|
+
writeFileSync5(hooksPath, `${JSON.stringify(file2, null, 2)}
|
|
24696
|
+
`);
|
|
24697
|
+
done.push(`Codex: PostToolUse and Stop hooks written to ${hooksPath}. Codex asks you to trust new hooks once (/hooks in a session).`);
|
|
24698
|
+
return done;
|
|
24699
|
+
}
|
|
24700
|
+
function tickHook() {
|
|
24701
|
+
const arrived = inboxDrainAll();
|
|
24702
|
+
if (arrived.length === 0) return;
|
|
24703
|
+
const text = `Messages arrived on Slopware Tasks while you worked:
|
|
24704
|
+
|
|
24705
|
+
${arrived.map(pushBlock).join("\n\n")}
|
|
24706
|
+
|
|
24707
|
+
Act or answer with the slop MCP \`reply\` tool, then carry on.`;
|
|
24708
|
+
process.stdout.write(`${JSON.stringify({ hookSpecificOutput: { hookEventName: "PostToolUse", additionalContext: text } })}
|
|
24709
|
+
`);
|
|
24710
|
+
}
|
|
24711
|
+
async function stopHook() {
|
|
24712
|
+
const input2 = await new Promise((resolve2) => {
|
|
24713
|
+
let data = "";
|
|
24714
|
+
process.stdin.on("data", (chunk) => data += chunk);
|
|
24715
|
+
process.stdin.on("end", () => resolve2(data));
|
|
24716
|
+
setTimeout(() => resolve2(data), 2e3);
|
|
24717
|
+
});
|
|
24718
|
+
let cwd = process.cwd();
|
|
24719
|
+
try {
|
|
24720
|
+
cwd = JSON.parse(input2).cwd ?? cwd;
|
|
24721
|
+
} catch {
|
|
24722
|
+
}
|
|
24723
|
+
process.chdir(cwd);
|
|
24724
|
+
const parts = inboxDrainAll().map(pushBlock);
|
|
24725
|
+
const repo = findRepo();
|
|
24726
|
+
const link = repo ? readLink(repo) : null;
|
|
24727
|
+
if (!link) {
|
|
24728
|
+
if (parts.length) process.stdout.write(`${JSON.stringify({ decision: "block", reason: `Messages arrived on Slopware Tasks while you worked:
|
|
24729
|
+
|
|
24730
|
+
${parts.join("\n\n")}` })}
|
|
24731
|
+
`);
|
|
24732
|
+
return;
|
|
24733
|
+
}
|
|
24734
|
+
const api = authedApi();
|
|
24735
|
+
const [me, project, tasks] = await Promise.all([api.get("/me"), api.get(`/projects/${link.projectId}`), api.get(`/projects/${link.projectId}/tasks`)]);
|
|
24736
|
+
const inProgress = new Set(project.statuses.filter((status) => status.category === "in_progress").map((status) => status.key));
|
|
24737
|
+
const mine = tasks.filter((task) => task.assignee?.userId === me.user.id && inProgress.has(task.status));
|
|
24738
|
+
for (const task of mine) {
|
|
24739
|
+
const about = await api.get(`/projects/${project.id}/threads?task=${encodeURIComponent(task.key)}&unread=1&read=1`);
|
|
24740
|
+
if (about.length) parts.push(`Unread about ${task.key}:`, ...about.map(threadLine));
|
|
24741
|
+
}
|
|
24742
|
+
const general = await api.get(`/projects/${project.id}/threads?scope=general&unread=1&read=1`);
|
|
24743
|
+
if (general.length) parts.push("Unread general threads (context):", ...general.map(threadLine));
|
|
24744
|
+
if (parts.length === 0) return;
|
|
24745
|
+
process.stdout.write(`${JSON.stringify({ decision: "block", reason: `Messages arrived on Slopware Tasks while you worked. Read them (slop thread show <id>), act or reply (slop thread reply <id> "\u2026"), then continue or stop.
|
|
24746
|
+
|
|
24747
|
+
${parts.join("\n")}` })}
|
|
24748
|
+
`);
|
|
24749
|
+
}
|
|
24750
|
+
function withInbox(list) {
|
|
24751
|
+
return list.map(
|
|
24752
|
+
(tool) => tool.name === "check_messages" || tool.name === "wait_for_message" ? tool : {
|
|
24753
|
+
...tool,
|
|
24754
|
+
run: async (args) => {
|
|
24755
|
+
const result = await tool.run(args);
|
|
24756
|
+
const arrived = inboxDrainAll();
|
|
24757
|
+
return arrived.length ? `${result}
|
|
24758
|
+
|
|
24759
|
+
--- Messages arrived while you worked ---
|
|
24760
|
+
${arrived.map(pushBlock).join("\n\n")}` : result;
|
|
24761
|
+
}
|
|
24762
|
+
}
|
|
24763
|
+
);
|
|
24764
|
+
}
|
|
24765
|
+
function registerMcpCommands(program3, version2) {
|
|
24766
|
+
const mcp = program3.command("mcp").description("The MCP server: the board and its threads as tools for Claude Code, Codex and any MCP client. Holds your live session while it runs.");
|
|
24767
|
+
mcp.command("serve", { isDefault: true }).description("Serve MCP over stdio (what the harness runs).").action(() => serveMcp(withInbox(tools()), { name: "slop", version: version2 }));
|
|
24768
|
+
mcp.command("install").description("Register the server and the two hooks with Claude Code and Codex on this machine.").action(() => {
|
|
24769
|
+
const lines = [...installClaude(), ...installCodex()];
|
|
24770
|
+
emit({ done: lines }, () => lines.join("\n"));
|
|
24771
|
+
});
|
|
24772
|
+
const hook = program3.command("hook").description("Harness hooks (installed by slop mcp install).");
|
|
24773
|
+
hook.command("stop").description("Stop hook (Claude Code and Codex): hands over unread messages instead of letting the agent stop.").action(stopHook);
|
|
24774
|
+
hook.command("tick").description("PostToolUse hook (Claude Code and Codex): hands over messages the held session received, as context, right after any tool call.").action(tickHook);
|
|
24775
|
+
}
|
|
24776
|
+
|
|
24777
|
+
// src/commands/sessions.ts
|
|
24778
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
24779
|
+
var taskPath2 = (projectId, key) => `/projects/${projectId}/tasks/${encodeURIComponent(key)}`;
|
|
24780
|
+
var sessionLine = (session) => [session.taskKey, session.user.name, session.machine.name, session.startedAt];
|
|
24278
24781
|
function registerSessionCommands(program3, task) {
|
|
24279
24782
|
const withProject = (command) => command.option("-p, --project <key>", "project key (default: the project this repository is linked to)");
|
|
24280
24783
|
const session = program3.command("session").description("Claim a task and be reachable on it while you work.");
|
|
@@ -24282,14 +24785,17 @@ function registerSessionCommands(program3, task) {
|
|
|
24282
24785
|
const api = authedApi();
|
|
24283
24786
|
const project = await loadProject(api, (await resolveProject(api, options.project)).id);
|
|
24284
24787
|
const assigneeId = await resolveAssignee(api, project.id, "me");
|
|
24285
|
-
const updated = await api.patch(
|
|
24286
|
-
const [about, general] = await Promise.all([
|
|
24788
|
+
const updated = await api.patch(taskPath2(project.id, key), { assigneeId, status: statusInCategory(project, "in_progress") });
|
|
24789
|
+
const [about, mine, general] = await Promise.all([
|
|
24287
24790
|
api.get(`/projects/${project.id}/threads?task=${encodeURIComponent(updated.key)}&unread=1&read=1`),
|
|
24791
|
+
api.get(`/projects/${project.id}/threads?participant=1&unread=1&read=1`),
|
|
24288
24792
|
api.get(`/projects/${project.id}/threads?scope=general&unread=1&read=1`)
|
|
24289
24793
|
]);
|
|
24290
|
-
|
|
24794
|
+
const elsewhere = mine.filter((thread) => !about.some((candidate) => candidate.id === thread.id));
|
|
24795
|
+
emit({ task: updated, threads: { task: about, mine: elsewhere, general } }, () => {
|
|
24291
24796
|
const lines = [`Claimed ${updated.key} ${updated.title}`];
|
|
24292
24797
|
if (about.length) lines.push("", `Unread about ${updated.key} (read one with slop thread show <id>):`, ...about.map(threadLine));
|
|
24798
|
+
if (elsewhere.length) lines.push("", "Unread in threads you are part of (answers to you):", ...elsewhere.map(threadLine));
|
|
24293
24799
|
if (general.length) lines.push("", `Unread general threads (for context; nobody has to answer):`, ...general.map(threadLine));
|
|
24294
24800
|
lines.push("", `Go live (in the background, and relaunch it after each message): slop session wait ${updated.key}`);
|
|
24295
24801
|
return lines.join("\n");
|
|
@@ -24298,68 +24804,29 @@ function registerSessionCommands(program3, task) {
|
|
|
24298
24804
|
withProject(session.command("wait <key>")).description("Hold a live session on the task until someone says something in a thread about it; print it and exit. Exit 2 if the session was ended, 3 on timeout, 4 if the connection dropped (relaunch). --follow stays up and prints each message as it comes.").option("--timeout <seconds>", "give up after this long (default: never)").option("--follow", "keep the session and print every message instead of exiting on the first").action(async (key, options) => {
|
|
24299
24805
|
const api = authedApi();
|
|
24300
24806
|
const project = await resolveProject(api, options.project);
|
|
24301
|
-
const ticket = await api.post(`${taskPath(project.id, key)}/session/ticket`);
|
|
24302
|
-
const url2 = `${api.baseUrl.replace(/^http/, "ws")}/api${ticket.path}`;
|
|
24303
|
-
const socket = new WebSocket(url2);
|
|
24304
24807
|
const note2 = (text) => process.stderr.write(`${text}
|
|
24305
24808
|
`);
|
|
24306
|
-
const
|
|
24307
|
-
|
|
24308
|
-
|
|
24309
|
-
|
|
24310
|
-
|
|
24311
|
-
if (push.type === "hello") {
|
|
24312
|
-
note2(isJsonMode() ? JSON.stringify({ live: push.session }) : `live on ${push.session.taskKey} as ${push.session.user.name} (${push.session.machine.name}); waiting\u2026`);
|
|
24313
|
-
return;
|
|
24314
|
-
}
|
|
24315
|
-
if (timer) clearTimeout(timer);
|
|
24316
|
-
if (push.type === "end") {
|
|
24317
|
-
resolve2({ ended: true });
|
|
24318
|
-
return;
|
|
24319
|
-
}
|
|
24320
|
-
if (push.type === "thread") {
|
|
24321
|
-
if (options.follow) {
|
|
24322
|
-
emit({ thread: push.thread, message: push.message }, () => `${pushBlock(push)}
|
|
24809
|
+
const outcome = await waitForMessage(api, project.id, key, {
|
|
24810
|
+
timeoutMs: options.timeout ? Number(options.timeout) * 1e3 : 0,
|
|
24811
|
+
onHello: (session2) => note2(isJsonMode() ? JSON.stringify({ live: session2 }) : `live on ${session2.taskKey} as ${session2.user.name} (${session2.machine.name}); waiting\u2026`),
|
|
24812
|
+
onMessage: options.follow ? (push) => {
|
|
24813
|
+
emit(push, () => `${pushBlock(push)}
|
|
24323
24814
|
`);
|
|
24324
|
-
|
|
24325
|
-
|
|
24326
|
-
resolve2({ push });
|
|
24327
|
-
return;
|
|
24328
|
-
}
|
|
24329
|
-
if (push.type !== "event") return;
|
|
24330
|
-
resolve2({ record: push.record });
|
|
24331
|
-
});
|
|
24332
|
-
socket.addEventListener("close", (event) => {
|
|
24333
|
-
if (timer) clearTimeout(timer);
|
|
24334
|
-
note2(`socket closed: ${event.code} ${event.reason}`);
|
|
24335
|
-
resolve2({ closed: event.reason || `code ${event.code}` });
|
|
24336
|
-
});
|
|
24337
|
-
socket.addEventListener("error", (event) => {
|
|
24338
|
-
note2(`socket error: ${"message" in event ? String(event.message) : "unknown"}`);
|
|
24339
|
-
resolve2({ closed: "socket error" });
|
|
24340
|
-
});
|
|
24815
|
+
return true;
|
|
24816
|
+
} : void 0
|
|
24341
24817
|
});
|
|
24342
|
-
if (
|
|
24343
|
-
|
|
24344
|
-
else emit(outcome.record, () => messageLine(outcome.record));
|
|
24345
|
-
socket.close(1e3, "handled");
|
|
24346
|
-
await new Promise((resolve2) => {
|
|
24347
|
-
socket.addEventListener("close", () => resolve2(), { once: true });
|
|
24348
|
-
setTimeout(resolve2, 500);
|
|
24349
|
-
});
|
|
24818
|
+
if (outcome.kind === "message") {
|
|
24819
|
+
emit(outcome.push, () => pushBlock(outcome.push));
|
|
24350
24820
|
process.exit(0);
|
|
24351
24821
|
}
|
|
24352
|
-
if ("
|
|
24353
|
-
|
|
24354
|
-
|
|
24355
|
-
}
|
|
24356
|
-
if ("ended" in outcome) throw new CliError("Session ended", void 0, "ended", 2);
|
|
24357
|
-
throw new CliError(`Connection dropped (${outcome.closed})`, `slop session wait ${key}`, "dropped", 4);
|
|
24822
|
+
if (outcome.kind === "timeout") throw new CliError(`No message in ${options.timeout}s`, `slop session wait ${key}`, "timeout", 3);
|
|
24823
|
+
if (outcome.kind === "ended") throw new CliError("Session ended", void 0, "ended", 2);
|
|
24824
|
+
throw new CliError(`Connection dropped (${outcome.reason})`, `slop session wait ${key}`, "dropped", 4);
|
|
24358
24825
|
});
|
|
24359
24826
|
withProject(session.command("end <key>")).description("End your live session on the task (from any terminal on this machine).").action(async (key, options) => {
|
|
24360
24827
|
const api = authedApi();
|
|
24361
24828
|
const project = await resolveProject(api, options.project);
|
|
24362
|
-
const result = await api.post(`${
|
|
24829
|
+
const result = await api.post(`${taskPath2(project.id, key)}/session/end`);
|
|
24363
24830
|
emit(result, () => result.ended ? `Ended ${result.ended} session${result.ended === 1 ? "" : "s"} on ${key.toUpperCase()}.` : `No live session of yours on ${key.toUpperCase()}.`);
|
|
24364
24831
|
});
|
|
24365
24832
|
withProject(program3.command("sessions")).description("Who is live on which task right now.").action(async (options) => {
|
|
@@ -24392,12 +24859,13 @@ ${written.map((path3) => ` ${path3}`).join("\n")}`);
|
|
|
24392
24859
|
}
|
|
24393
24860
|
|
|
24394
24861
|
// src/index.ts
|
|
24395
|
-
var program2 = new Command().name("slop").description("Slopware Tasks from the terminal. Everything a person can do on the board, an agent can do here.").version("0.2.
|
|
24862
|
+
var program2 = new Command().name("slop").description("Slopware Tasks from the terminal. Everything a person can do on the board, an agent can do here.").version("0.2.2").option("--json", "machine-readable output: JSON on stdout, errors as JSON on stderr").hook("preAction", (_, action) => setJsonMode(Boolean(action.optsWithGlobals().json))).showHelpAfterError("(run with --help for usage)");
|
|
24396
24863
|
registerAuthCommands(program2);
|
|
24397
24864
|
registerProjectCommands(program2);
|
|
24398
24865
|
var taskCommand = registerTaskCommands(program2);
|
|
24399
24866
|
registerSessionCommands(program2, taskCommand);
|
|
24400
24867
|
registerThreadCommands(program2, taskCommand);
|
|
24868
|
+
registerMcpCommands(program2, "0.2.2");
|
|
24401
24869
|
registerGuideCommand(program2);
|
|
24402
24870
|
registerSkillCommands(program2);
|
|
24403
24871
|
program2.parseAsync().catch(fail);
|