spur-board 0.125.0 → 0.126.0

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.
@@ -1,4 +1,4 @@
1
- import { _ as renderJsonError, at as errorContextSchema, c as tokenRequestStatusSchema, ct as successEnvelopeSchema, o as tokenRequestResultSchema, ot as errorEnvelopeSchema, rt as ERRORS } from "./chunk-CY5-uNaf.mjs";
1
+ import { _ as renderJsonError, at as errorContextSchema, c as tokenRequestStatusSchema, ct as successEnvelopeSchema, o as tokenRequestResultSchema, ot as errorEnvelopeSchema, rt as ERRORS } from "./chunk-CgQL6u77.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { z } from "zod";
4
4
  import { request } from "node:http";
@@ -1,5 +1,5 @@
1
- import { bt as plainHttpAllowed, d as buildCatalogSnapshot, p as OPERATIONS, vt as configSchema } from "./chunk-CY5-uNaf.mjs";
2
- import { o as CliError, t as fetchCatalogVersion } from "./chunk-DcRmoCME.mjs";
1
+ import { bt as plainHttpAllowed, d as buildCatalogSnapshot, p as OPERATIONS, vt as configSchema } from "./chunk-CgQL6u77.mjs";
2
+ import { o as CliError, t as fetchCatalogVersion } from "./chunk-2vFOidpZ.mjs";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
5
5
  import { homedir } from "node:os";
@@ -1304,6 +1304,27 @@ const ERRORS = {
1304
1304
  hint: "Read why with `board task <KEY> --why`; pick an enabled column, and unlink a merged pull request with `board unlink` first.",
1305
1305
  recovery: noRetry("Read why the task is where it is; pick an enabled column, and unlink a merged pull request first.")
1306
1306
  }),
1307
+ move_outside_todo_group: spec("move_outside_todo_group", {
1308
+ status: 409,
1309
+ exit: EXIT_CODES.refused,
1310
+ message: "Manual moves require an enabled Todo-group source and destination.",
1311
+ hint: "Pick an enabled Todo-group column; use `board move --correct` to correct a wrong column.",
1312
+ recovery: noRetry("Pick an enabled Todo-group column or correct a wrong column.")
1313
+ }),
1314
+ work_started: spec("work_started", {
1315
+ status: 409,
1316
+ exit: EXIT_CODES.refused,
1317
+ message: "Work has started on this task.",
1318
+ hint: "Read `board task <KEY> --why`; resolve the open pull request or live worker before moving idle work.",
1319
+ recovery: noRetry("Resolve the open pull request or live worker before moving idle work.")
1320
+ }),
1321
+ column_mirrored: spec("column_mirrored", {
1322
+ status: 409,
1323
+ exit: EXIT_CODES.refused,
1324
+ message: "The column is mirrored from the project tracker.",
1325
+ hint: "Change the task status in the named project tracker instead.",
1326
+ recovery: noRetry("Change the task status in the named project tracker instead.")
1327
+ }),
1307
1328
  task_archived: spec("task_archived", {
1308
1329
  status: 409,
1309
1330
  exit: EXIT_CODES.refused,
@@ -2086,6 +2107,7 @@ const EVENT_KINDS = [
2086
2107
  "task_moved",
2087
2108
  "task_shadow_moved",
2088
2109
  "task_corrected",
2110
+ "task_manually_moved",
2089
2111
  "dispatcher_mode_changed",
2090
2112
  "turn_opened",
2091
2113
  "turn_taken",
@@ -2258,6 +2280,11 @@ const eventPayloadSchemas = {
2258
2280
  gate: z.array(z.enum(GATE_REASONS)).optional(),
2259
2281
  courseCheck: z.literal(true).optional()
2260
2282
  }),
2283
+ task_manually_moved: z.looseObject({
2284
+ from: z.enum(COLUMN_IDS),
2285
+ to: z.enum(COLUMN_IDS),
2286
+ reason: S
2287
+ }),
2261
2288
  task_corrected: z.looseObject({
2262
2289
  from: z.enum(COLUMN_IDS),
2263
2290
  to: z.enum(COLUMN_IDS),
@@ -2673,6 +2700,8 @@ const MUTATION_ERRORS = ["idempotency_key_mismatch"];
2673
2700
  */
2674
2701
  function defineOperation(spec) {
2675
2702
  const mutation = spec.kind === "mutation";
2703
+ for (const mode of [...spec.explicitKeyModes ?? [], ...spec.cli.defaultMode === void 0 ? [] : [spec.cli.defaultMode]]) if (!spec.cli.modes?.some((entry) => entry.mode === mode)) throw new Error(`Unknown mode ${mode} in ${spec.id}.`);
2704
+ if (!mutation && spec.explicitKeyModes?.length) throw new Error("Only mutations require explicit keys.");
2676
2705
  const order = Object.keys(ERRORS);
2677
2706
  const errors = [.../* @__PURE__ */ new Set([
2678
2707
  ...COMMON_ERRORS,
@@ -2688,6 +2717,7 @@ function defineOperation(spec) {
2688
2717
  command: spec.cli.command,
2689
2718
  args: spec.cli.args,
2690
2719
  modes: spec.cli.modes ?? null,
2720
+ ...spec.cli.defaultMode === void 0 ? {} : { defaultMode: spec.cli.defaultMode },
2691
2721
  key: mutation ? "--key" : null
2692
2722
  },
2693
2723
  mcp: {
@@ -2842,18 +2872,20 @@ const moveViewSchema = z.strictObject({
2842
2872
  kind: z.enum([
2843
2873
  "task_moved",
2844
2874
  "task_shadow_moved",
2845
- "task_corrected"
2846
- ]).describe("task_moved moves the column, task_shadow_moved only the shadow column, task_corrected is an operator correction."),
2875
+ "task_corrected",
2876
+ "task_manually_moved"
2877
+ ]).describe("task_moved moves the column, task_shadow_moved only the shadow column, task_corrected is an operator correction, task_manually_moved is an operator Todo-group placement."),
2847
2878
  actor: actorIdSchema,
2848
2879
  from: z.enum(COLUMN_IDS).describe("Column the task left."),
2849
2880
  to: z.enum(COLUMN_IDS).describe("Column the task entered."),
2850
2881
  reason: z.enum([
2851
2882
  ...MOVE_REASONS,
2852
2883
  "returned",
2853
- "corrected"
2854
- ]).describe("Why it moved: a dispatcher reason, returned (a column executor returned it to Dev) or corrected (the operator corrected the column)."),
2884
+ "corrected",
2885
+ "manual"
2886
+ ]).describe("Why it moved: a dispatcher reason, returned (executor return), corrected (operator correction), or manual (operator Todo-group placement)."),
2855
2887
  gate: z.array(z.enum(GATE_REASONS)).describe("The failing gate reasons of a gate_broken move; empty otherwise."),
2856
- text: z.string().nullable().describe("The block a return opened, or the reason the operator gave for a correction; null otherwise.")
2888
+ text: z.string().nullable().describe("The block a return opened, or the literal reason for an operator correction or manual move; null otherwise.")
2857
2889
  }).describe("A column move of a task.");
2858
2890
  const gateConditionSchema = z.strictObject({
2859
2891
  condition: z.enum(GATE_CONDITIONS).describe("Exit condition of the column."),
@@ -2989,8 +3021,10 @@ const schemaGetOutputSchema = z.strictObject({
2989
3021
  description: z.string().describe("What the operation does."),
2990
3022
  grants: z.union([z.literal("any"), z.array(grantRuleSchema).min(1)]).describe("Who may call it: any identified caller, or the listed rules."),
2991
3023
  errors: z.array(z.string()).describe("Error codes the operation can return."),
3024
+ explicitKeyModes: z.array(z.string()).optional().describe("Modes requiring a caller-chosen idempotency key, including for operators."),
2992
3025
  cli: z.strictObject({
2993
3026
  command: z.string().describe("CLI command after `board`."),
3027
+ defaultMode: z.string().optional().describe("Input mode used when no mode flag is supplied."),
2994
3028
  args: z.array(z.string()).describe("Input fields given as positional arguments."),
2995
3029
  modes: z.array(cliModeSchema).min(1).nullable().describe("Flags that pick a branch of a union input; null for a plain input."),
2996
3030
  key: z.literal("--key").nullable().describe("Idempotency key flag; null for a query.")
@@ -3038,6 +3072,25 @@ const sourceViewSchema = z.strictObject({
3038
3072
  warmingUp: z.boolean().describe("Whether this source needs a complete poll in this daemon run."),
3039
3073
  defaultBranch: defaultBranchViewSchema.nullable().optional().describe("GitHub pull request sources only: the default-branch colour, red when the latest check run of a push-triggered workflow finished without success (failed, cancelled, timed out) or a commit status failed (scheduled and other runs ignored, branch protection not read); null until a poll reads it.")
3040
3074
  }).describe("Freshness and availability of one source.");
3075
+ // ../contracts/src/ops/move-schemas.ts
3076
+ const taskMoveInputSchema = z.discriminatedUnion("mode", [z.strictObject({
3077
+ mode: z.literal("manual").describe("Place an idle task inside the Todo group."),
3078
+ task: taskKeyInputSchema,
3079
+ column: z.enum(COLUMN_IDS).describe("Enabled Todo-group destination; a new visit places the task at its end."),
3080
+ reason: z.string().min(1).max(2e4).regex(/\S/).describe("Literal reason for the move, kept exactly in the journal; must contain non-whitespace text.")
3081
+ }), z.strictObject({
3082
+ mode: z.literal("correct").describe("Correct a wrong column by hand."),
3083
+ task: taskKeyInputSchema,
3084
+ column: z.enum(COLUMN_IDS).exclude(["done"]).describe("Enabled column to put the task in; Done is reached only from the facts."),
3085
+ reason: z.string().min(1).max(2e4).describe("Literal reason for manual placement or correction, kept in the journal.")
3086
+ })]);
3087
+ const taskMoveOutputSchema = z.strictObject({
3088
+ task: taskViewSchema,
3089
+ from: z.enum(COLUMN_IDS).describe("Column the task left; correction uses the dispatcher position."),
3090
+ to: z.enum(COLUMN_IDS).describe("Requested destination column."),
3091
+ column: z.enum(COLUMN_IDS).describe("Resulting position; correction uses the shadow position in shadow mode."),
3092
+ settled: z.array(moveViewSchema).describe("Dispatcher moves after a correction, oldest first; empty for manual placement.")
3093
+ });
3041
3094
  // ../contracts/src/ops/config-view-schema.ts
3042
3095
  const configViewSchema = z.strictObject({
3043
3096
  projects: z.array(z.strictObject({
@@ -5036,81 +5089,99 @@ const OPERATIONS = [
5036
5089
  defineOperation({
5037
5090
  id: "task.move",
5038
5091
  kind: "mutation",
5039
- description: "Correct the column of a task by hand; the gates then settle the task from that column at once.",
5092
+ description: "Move an idle task inside the Todo group, or correct its column and settle the gates.",
5040
5093
  mcp: {
5041
- whenToUse: "Put a task the board moved wrongly into the right column, Done excluded; the reply names the column it settled in.",
5094
+ whenToUse: "Place idle work at the end of an enabled Todo-group column with a literal reason and explicit key, or correct a wrong column with mode correct.",
5042
5095
  whenNotToUse: "Use task_get with why to read why the task is where it is."
5043
5096
  },
5044
- input: z.discriminatedUnion("mode", [z.strictObject({
5045
- mode: z.literal("correct").describe("Correct a wrong column by hand."),
5046
- task: taskKeyInputSchema,
5047
- column: z.enum(COLUMN_IDS).exclude(["done"]).describe("Enabled column to put the task in; Done is reached only from the facts."),
5048
- reason: text("Why the column is corrected, kept in the journal.", TEXT_MAX)
5049
- })]),
5050
- output: z.strictObject({
5051
- task: taskViewSchema,
5052
- from: z.enum(COLUMN_IDS).describe("Column the dispatcher worked from before the correction."),
5053
- to: z.enum(COLUMN_IDS).describe("Column the correction put the task in."),
5054
- column: z.enum(COLUMN_IDS).describe("Column the gates settled the task in; the shadow column while the dispatcher is in shadow mode."),
5055
- settled: z.array(moveViewSchema).describe("The dispatcher moves from the corrected column, oldest first.")
5056
- }),
5097
+ input: taskMoveInputSchema,
5098
+ output: taskMoveOutputSchema,
5099
+ explicitKeyModes: ["manual"],
5100
+ web: true,
5057
5101
  grants: operatorOnly,
5058
5102
  errors: [
5059
5103
  "wrong_id_kind",
5060
5104
  "not_found",
5061
5105
  "task_archived",
5062
- "move_not_allowed"
5106
+ "move_not_allowed",
5107
+ "move_outside_todo_group",
5108
+ "work_started",
5109
+ "column_mirrored"
5063
5110
  ],
5064
5111
  cli: {
5065
5112
  command: "move",
5066
5113
  args: ["task", "column"],
5067
5114
  modes: [{
5115
+ mode: "manual",
5116
+ flag: "--manual",
5117
+ value: null
5118
+ }, {
5068
5119
  mode: "correct",
5069
5120
  flag: "--correct",
5070
5121
  value: null
5071
- }]
5122
+ }],
5123
+ defaultMode: "manual"
5072
5124
  },
5073
5125
  slack: null,
5074
- examples: [{
5075
- summary: "Correct a task the board put in Done by mistake",
5076
- input: {
5077
- mode: "correct",
5078
- task: "PROJ-123",
5079
- column: "dev",
5080
- reason: "The linked pull request belongs to another ticket."
5081
- },
5082
- output: {
5083
- task,
5084
- from: "done",
5085
- to: "dev",
5086
- column: "dev",
5087
- settled: []
5088
- }
5089
- }, {
5090
- summary: "Correct a task into Review while its Dev gate is broken",
5091
- input: {
5092
- mode: "correct",
5093
- task: "PROJ-123",
5094
- column: "review",
5095
- reason: "The review was done outside the board."
5126
+ examples: [
5127
+ {
5128
+ summary: "Place idle work at the end of Ready for Dev",
5129
+ input: {
5130
+ mode: "manual",
5131
+ task: "PROJ-123",
5132
+ column: "ready-for-dev",
5133
+ reason: "Ready for the next worker."
5134
+ },
5135
+ output: {
5136
+ task,
5137
+ from: "todo",
5138
+ to: "ready-for-dev",
5139
+ column: "ready-for-dev",
5140
+ settled: []
5141
+ }
5096
5142
  },
5097
- output: {
5098
- task,
5099
- from: "dev",
5100
- to: "review",
5101
- column: "dev",
5102
- settled: [{
5103
- at,
5104
- kind: "task_moved",
5105
- actor: "system",
5106
- from: "review",
5143
+ {
5144
+ summary: "Correct a task the board put in Done by mistake",
5145
+ input: {
5146
+ mode: "correct",
5147
+ task: "PROJ-123",
5148
+ column: "dev",
5149
+ reason: "The linked pull request belongs to another ticket."
5150
+ },
5151
+ output: {
5152
+ task,
5153
+ from: "done",
5107
5154
  to: "dev",
5108
- reason: "gate_broken",
5109
- gate: ["external_comments"],
5110
- text: null
5111
- }]
5155
+ column: "dev",
5156
+ settled: []
5157
+ }
5158
+ },
5159
+ {
5160
+ summary: "Correct a task into Review while its Dev gate is broken",
5161
+ input: {
5162
+ mode: "correct",
5163
+ task: "PROJ-123",
5164
+ column: "review",
5165
+ reason: "The review was done outside the board."
5166
+ },
5167
+ output: {
5168
+ task,
5169
+ from: "dev",
5170
+ to: "review",
5171
+ column: "dev",
5172
+ settled: [{
5173
+ at,
5174
+ kind: "task_moved",
5175
+ actor: "system",
5176
+ from: "review",
5177
+ to: "dev",
5178
+ reason: "gate_broken",
5179
+ gate: ["external_comments"],
5180
+ text: null
5181
+ }]
5182
+ }
5112
5183
  }
5113
- }]
5184
+ ]
5114
5185
  }),
5115
5186
  defineOperation({
5116
5187
  id: "config.get",
@@ -5272,6 +5343,7 @@ function catalogSnapshotBody(operations) {
5272
5343
  grants: op.grants,
5273
5344
  preconditions: op.preconditions,
5274
5345
  errors: op.errors,
5346
+ ...op.explicitKeyModes === void 0 ? {} : { explicitKeyModes: op.explicitKeyModes },
5275
5347
  cli: op.cli,
5276
5348
  mcp: op.mcp,
5277
5349
  slack: op.slack,
@@ -5384,4 +5456,4 @@ const remoteDoctorReportSchema = z.object({
5384
5456
  function assertNever(value) {
5385
5457
  throw new Error(`Unexpected value: ${JSON.stringify(value)}`);
5386
5458
  }
5387
- export { encodeActorId as $, eventPayloadSchemas as A, VIAS as At, REVIEW_STATES as B, messageRefSchema as C, COLUMNS as Ct, sortSkillFiles as D, ITEM_KINDS as Dt, skillReloadFilesSchema as E, DISPATCHER_MODES as Et, prSourceId as F, prFactsSchema as G, SESSION_STATUSES as H, sessionTransitionSchema as I, sessionFactsSchema as J, prRefSchema as K, sourceCursorSchema as L, batchSchema as M, defaultBranchFactSchema as N, EVENT_KINDS as O, SLACK_BOT_SCOPES as Ot, entityRefSchema as P, actorIdSchema as Q, trackerSourceId as R, interactionRefSchema as S, resolveWebOrigin as St, skillReloadFileSchema as T, COLUMN_IDS as Tt, isExternalAuthor as U, SESSION_HEALTH_STATES as V, parseRingMarker as W, JIRA_PROJECT_KEY as X, ticketFactsSchema as Y, REF_NUMBER as Z, renderJsonError as _, configBindings as _t, requestHashOf as a, errorContextSchema as at, conversationRefSchema as b, plainHttpAllowed as bt, tokenRequestStatusSchema as c, successEnvelopeSchema as ct, buildCatalogSnapshot as d, DEFAULT_SLACK_APP_NAME as dt, errorCodeOf as et, roleCanUseOperation as f, DEFAULT_SLACK_COMMAND as ft, renderHttpProblem as g, columnTurnTimings as gt, turnHandedSchema as h, boardWideSpurProject as ht, TOKEN_REQUEST_LIMITS as i, err as it, AdapterError as j, isTodoGroupColumn as jt, GATE_REASONS as k, TASK_HOLDS as kt, BOARD_TICK_MS as l, DEFAULT_HTTP_PORT as lt, defaultBranchViewSchema as m, RESERVED_PROJECT as mt, doctorReportSchema as n, parseRef as nt, tokenRequestResultSchema as o, errorEnvelopeSchema as ot, OPERATIONS as p, DEFAULT_STAND_PORT_RANGE as pt, ringMarker as q, remoteDoctorReportSchema as r, ERRORS as rt, tokenRequestSchema as s, ok as st, assertNever as t, parseActorId as tt, SYSTEMD_SERVICE_SETTINGS as u, DEFAULT_LINK as ut, renderMcpError as v, configSchema as vt, userIdSchema as w, COLUMN_GROUPS as wt, inboundEventSchema as x, requiredSecretKeys as xt, SPACE_IDS as y, defaultAddressee as yt, PR_STATES as z };
5459
+ export { encodeActorId as $, eventPayloadSchemas as A, TODO_GROUP_COLUMN_IDS as At, REVIEW_STATES as B, messageRefSchema as C, COLUMNS as Ct, sortSkillFiles as D, ITEM_KINDS as Dt, skillReloadFilesSchema as E, DISPATCHER_MODES as Et, prSourceId as F, prFactsSchema as G, SESSION_STATUSES as H, sessionTransitionSchema as I, sessionFactsSchema as J, prRefSchema as K, sourceCursorSchema as L, batchSchema as M, isTodoGroupColumn as Mt, defaultBranchFactSchema as N, EVENT_KINDS as O, SLACK_BOT_SCOPES as Ot, entityRefSchema as P, actorIdSchema as Q, trackerSourceId as R, interactionRefSchema as S, resolveWebOrigin as St, skillReloadFileSchema as T, COLUMN_IDS as Tt, isExternalAuthor as U, SESSION_HEALTH_STATES as V, parseRingMarker as W, JIRA_PROJECT_KEY as X, ticketFactsSchema as Y, REF_NUMBER as Z, renderJsonError as _, configBindings as _t, requestHashOf as a, errorContextSchema as at, conversationRefSchema as b, plainHttpAllowed as bt, tokenRequestStatusSchema as c, successEnvelopeSchema as ct, buildCatalogSnapshot as d, DEFAULT_SLACK_APP_NAME as dt, errorCodeOf as et, roleCanUseOperation as f, DEFAULT_SLACK_COMMAND as ft, renderHttpProblem as g, columnTurnTimings as gt, turnHandedSchema as h, boardWideSpurProject as ht, TOKEN_REQUEST_LIMITS as i, err as it, AdapterError as j, VIAS as jt, GATE_REASONS as k, TASK_HOLDS as kt, BOARD_TICK_MS as l, DEFAULT_HTTP_PORT as lt, defaultBranchViewSchema as m, RESERVED_PROJECT as mt, doctorReportSchema as n, parseRef as nt, tokenRequestResultSchema as o, errorEnvelopeSchema as ot, OPERATIONS as p, DEFAULT_STAND_PORT_RANGE as pt, ringMarker as q, remoteDoctorReportSchema as r, ERRORS as rt, tokenRequestSchema as s, ok as st, assertNever as t, parseActorId as tt, SYSTEMD_SERVICE_SETTINGS as u, DEFAULT_LINK as ut, renderMcpError as v, configSchema as vt, userIdSchema as w, COLUMN_GROUPS as wt, inboundEventSchema as x, requiredSecretKeys as xt, SPACE_IDS as y, defaultAddressee as yt, PR_STATES as z };
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { D as sortSkillFiles, Ot as SLACK_BOT_SCOPES, Q as actorIdSchema, St as resolveWebOrigin, T as skillReloadFileSchema, a as requestHashOf, ct as successEnvelopeSchema, f as roleCanUseOperation, p as OPERATIONS, pt as DEFAULT_STAND_PORT_RANGE, r as remoteDoctorReportSchema, rt as ERRORS, u as SYSTEMD_SERVICE_SETTINGS, vt as configSchema, xt as requiredSecretKeys } from "./chunk-CY5-uNaf.mjs";
1
+ import { D as sortSkillFiles, Ot as SLACK_BOT_SCOPES, Q as actorIdSchema, St as resolveWebOrigin, T as skillReloadFileSchema, a as requestHashOf, ct as successEnvelopeSchema, f as roleCanUseOperation, p as OPERATIONS, pt as DEFAULT_STAND_PORT_RANGE, r as remoteDoctorReportSchema, rt as ERRORS, u as SYSTEMD_SERVICE_SETTINGS, vt as configSchema, xt as requiredSecretKeys } from "./chunk-CgQL6u77.mjs";
2
2
  import { t as apiBaseUrl } from "./chunk-Bzb7aI8R.mjs";
3
- import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-DcRmoCME.mjs";
4
- import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./chunk-B_idjhSg.mjs";
3
+ import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-2vFOidpZ.mjs";
4
+ import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./chunk-B9WekLbU.mjs";
5
5
  import { createHash, randomBytes, randomUUID } from "node:crypto";
6
6
  import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
7
7
  import { homedir, hostname, tmpdir, userInfo } from "node:os";
@@ -2468,7 +2468,8 @@ function buildInput(op, args, options) {
2468
2468
  if (options[flag] !== void 0) input[field] = options[flag];
2469
2469
  }
2470
2470
  const selected = op.cli.modes?.filter((mode) => options[optionField(mode.flag)] !== void 0);
2471
- if (selected && selected.length !== 1) throw new CliError("usage", void 0, void 0, `Pass exactly one of ${(op.cli.modes ?? []).map((mode) => mode.flag).join(", ")}.`);
2471
+ if (selected && (selected.length > 1 || selected.length === 0 && op.cli.defaultMode === void 0)) throw new CliError("usage", void 0, void 0, `Pass exactly one of ${(op.cli.modes ?? []).map((mode) => mode.flag).join(", ")}.`);
2472
+ if (selected?.length === 0 && op.cli.defaultMode !== void 0) input["mode"] = op.cli.defaultMode;
2472
2473
  if (selected?.[0]) {
2473
2474
  input["mode"] = selected[0].mode;
2474
2475
  if (selected[0].value) {
@@ -2615,12 +2616,13 @@ function createProgram(options = {}) {
2615
2616
  const command = commandFor(program, op.cli.command);
2616
2617
  command.description(op.description);
2617
2618
  registerOptions(command, op);
2618
- command.addHelpText("after", `\nExamples:\n${op.examples.map((example) => ` ${exampleCommand(op, example.input)} — ${example.summary}`).join("\n")}\n`);
2619
+ command.addHelpText("after", `\nExamples:\n${op.examples.map((example) => ` ${exampleCommand(op, example.input)}${op.explicitKeyModes?.includes(String(example.input["mode"])) ? ` --key ${op.mcp.name}-example-001` : ""} — ${example.summary}`).join("\n")}\n`);
2619
2620
  command.action(async (...parts) => {
2620
2621
  const invoked = parts.at(-1);
2621
2622
  const json = Boolean(invoked.opts()["json"] || program.opts()["json"]);
2622
2623
  const input = buildInput(op, parts.slice(0, -1), invoked.opts());
2623
2624
  const keyOption = invoked.opts()["key"];
2625
+ if (op.explicitKeyModes?.includes(input["mode"] ?? "") && (typeof keyOption !== "string" || keyOption.trim() === "")) throw new CliError("usage", void 0, void 0, "Pass an explicit non-blank --key for this mode.");
2624
2626
  if (keyOption !== void 0 && (typeof keyOption !== "string" || keyOption === "")) throw new CliError("usage", void 0, void 0, "Pass a nonempty --key, or omit it to have one generated.");
2625
2627
  if (keyOption !== void 0 && escapeTerminalControls(keyOption) !== keyOption) throw new CliError("usage", void 0, void 0, "The idempotency key must contain only printable characters.");
2626
2628
  const config = options.clientConfig ?? loadOperationConfig(op, input, env);
package/dist/client.mjs CHANGED
@@ -1 +1 @@
1
- export { t as fetchCatalogVersion, n as fetchTokenStatus, r as requestOperation, i as requestSkillReload, a as requestTokenEnrollment } from "./chunk-DcRmoCME.mjs";
1
+ export { t as fetchCatalogVersion, n as fetchTokenStatus, r as requestOperation, i as requestSkillReload, a as requestTokenEnrollment } from "./chunk-2vFOidpZ.mjs";
package/dist/daemon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as encodeActorId, A as eventPayloadSchemas, At as VIAS, B as REVIEW_STATES, C as messageRefSchema, Ct as COLUMNS, D as sortSkillFiles, Dt as ITEM_KINDS, E as skillReloadFilesSchema, Et as DISPATCHER_MODES, F as prSourceId, G as prFactsSchema, H as SESSION_STATUSES, I as sessionTransitionSchema, J as sessionFactsSchema, K as prRefSchema, L as sourceCursorSchema, M as batchSchema, N as defaultBranchFactSchema, O as EVENT_KINDS, Ot as SLACK_BOT_SCOPES, P as entityRefSchema, Q as actorIdSchema, R as trackerSourceId, S as interactionRefSchema, St as resolveWebOrigin, Tt as COLUMN_IDS, U as isExternalAuthor, V as SESSION_HEALTH_STATES, W as parseRingMarker, X as JIRA_PROJECT_KEY, Y as ticketFactsSchema, Z as REF_NUMBER, _t as configBindings, a as requestHashOf, b as conversationRefSchema, bt as plainHttpAllowed, c as tokenRequestStatusSchema, ct as successEnvelopeSchema, d as buildCatalogSnapshot, et as errorCodeOf, f as roleCanUseOperation, ft as DEFAULT_SLACK_COMMAND, g as renderHttpProblem, gt as columnTurnTimings, h as turnHandedSchema, ht as boardWideSpurProject, i as TOKEN_REQUEST_LIMITS, it as err, j as AdapterError, jt as isTodoGroupColumn, k as GATE_REASONS, kt as TASK_HOLDS, l as BOARD_TICK_MS, m as defaultBranchViewSchema, mt as RESERVED_PROJECT, n as doctorReportSchema, nt as parseRef$1, o as tokenRequestResultSchema, p as OPERATIONS, q as ringMarker, rt as ERRORS, s as tokenRequestSchema, st as ok, t as assertNever, tt as parseActorId, ut as DEFAULT_LINK, vt as configSchema, w as userIdSchema, wt as COLUMN_GROUPS, x as inboundEventSchema, xt as requiredSecretKeys, y as SPACE_IDS, yt as defaultAddressee, z as PR_STATES } from "./chunk-CY5-uNaf.mjs";
1
+ import { $ as encodeActorId, A as eventPayloadSchemas, At as TODO_GROUP_COLUMN_IDS, B as REVIEW_STATES, C as messageRefSchema, Ct as COLUMNS, D as sortSkillFiles, Dt as ITEM_KINDS, E as skillReloadFilesSchema, Et as DISPATCHER_MODES, F as prSourceId, G as prFactsSchema, H as SESSION_STATUSES, I as sessionTransitionSchema, J as sessionFactsSchema, K as prRefSchema, L as sourceCursorSchema, M as batchSchema, Mt as isTodoGroupColumn, N as defaultBranchFactSchema, O as EVENT_KINDS, Ot as SLACK_BOT_SCOPES, P as entityRefSchema, Q as actorIdSchema, R as trackerSourceId, S as interactionRefSchema, St as resolveWebOrigin, Tt as COLUMN_IDS, U as isExternalAuthor, V as SESSION_HEALTH_STATES, W as parseRingMarker, X as JIRA_PROJECT_KEY, Y as ticketFactsSchema, Z as REF_NUMBER, _t as configBindings, a as requestHashOf, b as conversationRefSchema, bt as plainHttpAllowed, c as tokenRequestStatusSchema, ct as successEnvelopeSchema, d as buildCatalogSnapshot, et as errorCodeOf, f as roleCanUseOperation, ft as DEFAULT_SLACK_COMMAND, g as renderHttpProblem, gt as columnTurnTimings, h as turnHandedSchema, ht as boardWideSpurProject, i as TOKEN_REQUEST_LIMITS, it as err, j as AdapterError, jt as VIAS, k as GATE_REASONS, kt as TASK_HOLDS, l as BOARD_TICK_MS, m as defaultBranchViewSchema, mt as RESERVED_PROJECT, n as doctorReportSchema, nt as parseRef$1, o as tokenRequestResultSchema, p as OPERATIONS, q as ringMarker, rt as ERRORS, s as tokenRequestSchema, st as ok, t as assertNever, tt as parseActorId, ut as DEFAULT_LINK, vt as configSchema, w as userIdSchema, wt as COLUMN_GROUPS, x as inboundEventSchema, xt as requiredSecretKeys, y as SPACE_IDS, yt as defaultAddressee, z as PR_STATES } from "./chunk-CgQL6u77.mjs";
2
2
  import { t as apiBaseUrl } from "./chunk-Bzb7aI8R.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { createHash, randomUUID } from "node:crypto";
@@ -8186,7 +8186,8 @@ function eventActor(row) {
8186
8186
  const MOVE_KINDS = [
8187
8187
  "task_moved",
8188
8188
  "task_shadow_moved",
8189
- "task_corrected"
8189
+ "task_corrected",
8190
+ "task_manually_moved"
8190
8191
  ];
8191
8192
  function moveView(row) {
8192
8193
  const base = {
@@ -8194,6 +8195,19 @@ function moveView(row) {
8194
8195
  actor: eventActor(row)
8195
8196
  };
8196
8197
  const payload = JSON.parse(row.payload);
8198
+ if (row.kind === "task_manually_moved") {
8199
+ const parsed = eventPayloadSchemas.task_manually_moved.safeParse(payload);
8200
+ if (!parsed.success) return null;
8201
+ return {
8202
+ ...base,
8203
+ kind: row.kind,
8204
+ from: parsed.data.from,
8205
+ to: parsed.data.to,
8206
+ reason: "manual",
8207
+ gate: [],
8208
+ text: parsed.data.reason
8209
+ };
8210
+ }
8197
8211
  if (row.kind === "task_corrected") {
8198
8212
  const parsed = eventPayloadSchemas.task_corrected.safeParse(payload);
8199
8213
  if (!parsed.success) return null;
@@ -8431,6 +8445,7 @@ function createApply(deps) {
8431
8445
  const entry = catalogMutation(op.id);
8432
8446
  const parsed = entry.input.safeParse(input);
8433
8447
  if (!parsed.success) throw new CommandError(errorCodeOf(parsed.error), "Fix the operation input.");
8448
+ if ("mode" in parsed.data && entry.explicitKeyModes?.includes(parsed.data.mode) && (key === void 0 || key.trim() === "")) throw new CommandError("usage", "Choose an explicit non-blank idempotency key for this mode.");
8434
8449
  if (key === "" || actor !== "operator" && key === void 0) throw new CommandError("usage", "Choose an idempotency key before sending an agent mutation.");
8435
8450
  const commandKey = key ?? randomUUID();
8436
8451
  const parsedInput = parsed.data;
@@ -14895,6 +14910,37 @@ async function syncModes(trx, config, at) {
14895
14910
  });
14896
14911
  }
14897
14912
  }
14913
+ /** Place idle work in a fresh real-column visit after synchronizing dispatcher mode. */
14914
+ async function manuallyMoveColumn(trx, input) {
14915
+ const { taskId, to, at, actor, reason, config } = input;
14916
+ await syncModes(trx, config, at);
14917
+ const task = await trx.selectFrom("task").selectAll().where("id", "=", taskId).executeTakeFirstOrThrow();
14918
+ const project = config.projects.find((entry) => entry.id === task.project);
14919
+ const enabledGroup = (id) => TODO_GROUP_COLUMN_IDS.some((column) => column === id) && project?.columns.some((column) => column.id === id && column.enabled);
14920
+ if (!enabledGroup(task.column) || !enabledGroup(to)) throw new CommandError("move_outside_todo_group", `Pick enabled Todo-group columns in project ${task.project}.`);
14921
+ if (await trx.selectFrom("link").select("id").where("task_id", "=", taskId).where("entity", "=", "pr").where("banned", "=", 0).where("pr_open", "=", 1).where(pastReopenFloor).executeTakeFirst() !== void 0 || await linkedSession(trx, taskId, "worker") !== void 0) throw new CommandError("work_started", "Resolve the open pull request or live worker before moving idle work.");
14922
+ await trx.updateTable("task").set({
14923
+ column: to,
14924
+ shadow_column: task.shadow_column === null && project?.dispatcher.mode !== "shadow" ? null : to,
14925
+ column_epoch: task.column_epoch + 1,
14926
+ last_change_at: taskChangeAt(at.toISOString())
14927
+ }).where("id", "=", taskId).execute();
14928
+ await closeTurns(trx, {
14929
+ taskId,
14930
+ reason: "moved",
14931
+ at
14932
+ });
14933
+ await emit(trx, "task_manually_moved", task.project, taskId, at.toISOString(), {
14934
+ from: task.column,
14935
+ to,
14936
+ reason
14937
+ }, actor);
14938
+ return {
14939
+ from: task.column,
14940
+ to,
14941
+ column: to
14942
+ };
14943
+ }
14898
14944
  /**
14899
14945
  * The operator's correction of a task's column to `to`, as a new visit of `to`. It first applies
14900
14946
  * a pending dispatcher mode switch, so the switch cannot overwrite the correction. In `on` mode it
@@ -15170,10 +15216,16 @@ async function settlePending(trx, row, project, input) {
15170
15216
  failure: branch == null ? "no PR found" : `no PR found for ${branch}`
15171
15217
  };
15172
15218
  }
15173
- /**
15174
- * The dispatcher input of one task, or null when a stored snapshot is missing or unreadable. It
15175
- * only reads.
15176
- */
15219
+ /** Whether a reopen still needs to override the latest explicit placement. */
15220
+ async function reopenNeedsDispatch(trx, taskId, project) {
15221
+ const placement = await trx.selectFrom("event").select(["id", "kind"]).where("task_id", "=", taskId).where("kind", "in", ["task_manually_moved", "task_corrected"]).orderBy("id", "desc").executeTakeFirst();
15222
+ if (placement?.kind !== "task_manually_moved") return true;
15223
+ return (await trx.selectFrom("event").select("payload").where("task_id", "=", taskId).where("kind", "=", "ticket_status_changed").where("id", ">", placement.id).execute()).some((row) => {
15224
+ const status = parseJson(eventPayloadSchemas.ticket_status_changed, row.payload);
15225
+ return status.from !== null && ticketDone(project, status.from) && !ticketDone(project, status.to);
15226
+ });
15227
+ }
15228
+ /** The dispatcher input, or null when a stored snapshot is missing or unreadable. Only reads. */
15177
15229
  async function readInput(trx, task, project, mode, blind, config, clock) {
15178
15230
  const readPr = async (ref) => parsePr((await trx.selectFrom("pr_snapshot").select("detail").where(sql`lower(repo) = ${ref.repo.toLowerCase()}`).where("number", "=", ref.number).executeTakeFirst())?.detail);
15179
15231
  const link = await taskPr(trx, task.id);
@@ -15262,7 +15314,7 @@ async function readInput(trx, task, project, mode, blind, config, clock) {
15262
15314
  unresolvedThreads: pr === null ? 0 : pr.reviewThreads.filter((thread) => !thread.resolved).length,
15263
15315
  marks
15264
15316
  },
15265
- reopened: mergedOpen === void 0 && (column === "done" && !done && task.reopened_at !== null || await trx.selectFrom("link").select("id").where("task_id", "=", task.id).where("reopen_hidden_at", "is not", null).executeTakeFirst() !== void 0),
15317
+ reopened: mergedOpen === void 0 && (column === "done" && !done && task.reopened_at !== null || await trx.selectFrom("link").select("id").where("task_id", "=", task.id).where("reopen_hidden_at", "is not", null).executeTakeFirst() !== void 0) && await reopenNeedsDispatch(trx, task.id, project),
15266
15318
  ticketDone: done,
15267
15319
  hasOpenLinkedPr,
15268
15320
  allGithubReposReady,
@@ -16666,7 +16718,15 @@ async function readStatusBlocks(db, projectIds) {
16666
16718
  }
16667
16719
  /** Latest real entry into each visible task's current column, ordered by journal position. */
16668
16720
  async function readStatusColumnEntries(db, projectIds) {
16669
- return await db.selectFrom("event").innerJoin((eb) => eb.selectFrom("event as entry").innerJoin("task", "task.id", "entry.task_id").select((eb) => eb.fn.max("entry.id").as("id")).where("task.membership", "!=", "archived").where("task.project", "in", [...projectIds]).where(sql`json_extract(entry.payload, '$.to') = task.column`).where(sql`(entry.kind = 'task_moved' or (entry.kind = 'task_corrected' and json_extract(entry.payload, '$.shadow') = 0))`).groupBy("entry.task_id").as("latest"), (join) => join.onRef("latest.id", "=", "event.id")).select(["event.task_id", "event.at"]).execute();
16721
+ return await db.selectFrom("event").innerJoin((eb) => eb.selectFrom("event as entry").innerJoin("task", "task.id", "entry.task_id").select((eb) => eb.fn.max("entry.id").as("id")).where("task.membership", "!=", "archived").where("task.project", "in", [...projectIds]).where(sql`(json_extract(entry.payload, '$.to') = task.column OR (
16722
+ entry.kind = 'task_added' AND entry.at = task.created_at AND json_extract(entry.payload, '$.column') = task.column AND entry.id = (
16723
+ SELECT MIN(original.id) FROM event original WHERE original.task_id = task.id AND original.kind = 'task_added'
16724
+ )
16725
+ ))`).where(sql`(entry.kind in ('task_added', 'task_moved', 'task_manually_moved') or (entry.kind = 'task_corrected' and json_extract(entry.payload, '$.shadow') = 0))`).groupBy("entry.task_id").as("latest"), (join) => join.onRef("latest.id", "=", "event.id")).select([
16726
+ "event.task_id",
16727
+ "event.at",
16728
+ "event.id"
16729
+ ]).execute();
16670
16730
  }
16671
16731
  function sourceInterval(config, source) {
16672
16732
  if (source === "spur") return config.adapters.spur.intervalMs;
@@ -16688,6 +16748,19 @@ function sessionView(fact) {
16688
16748
  }))
16689
16749
  };
16690
16750
  }
16751
+ /** Order group visits in their own slots, preserving non-group relative ordering. */
16752
+ function orderTodoGroupRows(rows, entries, projects) {
16753
+ const columnEntries = new Map(entries.map((entry) => [entry.task_id, entry.at]));
16754
+ const entryOrder = new Map(entries.map((entry) => [entry.task_id, entry.id]));
16755
+ for (const project of projects) for (const column of TODO_GROUP_COLUMN_IDS) {
16756
+ const slots = rows.flatMap((row, index) => row.project === project.id && row.column === column ? [index] : []);
16757
+ const ordered = slots.map((index) => rows[index]).filter((row) => row !== void 0).sort((left, right) => Date.parse(columnEntries.get(left.id) ?? left.created_at) - Date.parse(columnEntries.get(right.id) ?? right.created_at) || (entryOrder.get(left.id) ?? 0) - (entryOrder.get(right.id) ?? 0) || left.id - right.id);
16758
+ for (const [index, slot] of slots.entries()) {
16759
+ const row = ordered[index];
16760
+ if (row !== void 0) rows[slot] = row;
16761
+ }
16762
+ }
16763
+ }
16691
16764
  // ../core/src/app/status.ts
16692
16765
  /** End reasons in the words of the "worker ended" item (`ENDED_WORKER_LABELS`, fromYou.ts). */
16693
16766
  const END_WORDS = {
@@ -16755,6 +16828,7 @@ async function getStatus(deps, options = {}) {
16755
16828
  const returns = await readStatusReturns(store.db, projectIds);
16756
16829
  const entries = await readStatusColumnEntries(store.db, projectIds);
16757
16830
  const columnEntries = new Map(entries.map((entry) => [entry.task_id, entry.at]));
16831
+ orderTodoGroupRows(rows, entries, projects);
16758
16832
  const tasks = [];
16759
16833
  const submissions = await latestSubmissions(store.db, rows);
16760
16834
  for (const task of rows) {
@@ -17081,6 +17155,7 @@ const EVENT_SUMMARIES = {
17081
17155
  task_moved: "Task moved",
17082
17156
  task_shadow_moved: "Shadow move",
17083
17157
  task_corrected: "Column corrected by the operator",
17158
+ task_manually_moved: "Task manually moved by the operator",
17084
17159
  dispatcher_mode_changed: "Dispatcher mode changed",
17085
17160
  turn_opened: "Turn opened",
17086
17161
  turn_taken: "Turn taken",
@@ -17269,6 +17344,7 @@ const gates = (gate) => gate === void 0 || gate.length === 0 ? "" : ` (${gate.jo
17269
17344
  const optional = (prefix, value) => value === void 0 ? "" : `${prefix}${value}`;
17270
17345
  /** Summaries built from a row's payload; null falls back to the fixed text. */
17271
17346
  const SUMMARIES = {
17347
+ task_manually_moved: (p) => `Manually moved ${p.from} → ${p.to}: ${p.reason}`,
17272
17348
  session_state_changed: (p) => `Session ${p.session}: ${from(p.from, p.to)}${optional(", ended (", p.endReason === void 0 ? void 0 : `${END_WORDS[p.endReason]})`)}`,
17273
17349
  checks_changed: checksSummary,
17274
17350
  head_moved: (p) => `New head ${p.to.slice(0, 7)} on ${ref$1(p.repo, p.pr)}`,
@@ -17814,7 +17890,7 @@ async function describeProject(trx, config, project) {
17814
17890
  },
17815
17891
  movedBy: {
17816
17892
  kind: metadata.group !== null ? "manual" : "dispatcher",
17817
- text: metadata.group !== null ? column.id === "todo" ? "New and reopened tasks enter Todo; task add and operator correction place work here. Work starting leaves the whole Todo group." : "Operator correction places a task here. New and reopened tasks enter Todo; work starting leaves the whole Todo group." : "The dispatcher advances passing gates and completion shortcuts; in shadow mode it records only a shadow position. Operator corrections can also place tasks here."
17893
+ text: metadata.group !== null ? column.id === "todo" ? "New and reopened tasks enter Todo; task add and manual moves place idle work here; operator correction can also repair placement. Work starting leaves the whole Todo group." : "Manual moves place idle work here; operator correction can also repair placement. New and reopened tasks enter Todo; work starting leaves the whole Todo group." : "The dispatcher advances passing gates and completion shortcuts; in shadow mode it records only a shadow position. Operator corrections can also place tasks here."
17818
17894
  }
17819
17895
  });
17820
17896
  }
@@ -18715,6 +18791,18 @@ function createTurnMutations(deps) {
18715
18791
  const task = await trx.selectFrom("task").selectAll().where("key", "=", key).executeTakeFirst();
18716
18792
  if (task === void 0) throw new CommandError("not_found", "Check the task key.");
18717
18793
  if (task.membership === "archived") throw new CommandError("task_archived", "Add the task again before changing it.");
18794
+ if (input.mode === "manual") return {
18795
+ ...await manuallyMoveColumn(trx, {
18796
+ taskId: task.id,
18797
+ to: input.column,
18798
+ ...input,
18799
+ at: new Date(ctx.at),
18800
+ actor: ctx.actor,
18801
+ config
18802
+ }),
18803
+ task: taskView(await taskById(trx, task.id)),
18804
+ settled: []
18805
+ };
18718
18806
  const project = config.projects.find((entry) => entry.id === task.project);
18719
18807
  if (project === void 0) throw new CommandError("move_not_allowed", `Project ${task.project} is not in the config; add it before correcting its tasks.`);
18720
18808
  if (!project.columns.some((column) => column.id === input.column && column.enabled)) throw new CommandError("move_not_allowed", `Column ${input.column} is not enabled in project ${project.id}; pick one of ${project.columns.filter((column) => column.enabled && column.id !== "done").map((column) => column.id).join(", ")}.`);
@@ -18800,6 +18888,7 @@ function createOperationRegistry(deps) {
18800
18888
  ...rule.blockTypes === void 0 ? {} : { blockTypes: [...rule.blockTypes] }
18801
18889
  })),
18802
18890
  errors: [...operation.errors],
18891
+ ...operation.explicitKeyModes === void 0 ? {} : { explicitKeyModes: [...operation.explicitKeyModes] },
18803
18892
  cli: {
18804
18893
  ...operation.cli,
18805
18894
  args: [...operation.cli.args],
@@ -20086,7 +20175,7 @@ function whyLines(key, why, blocks) {
20086
20175
  const gate = move.gate.length === 0 ? "" : `: ${move.gate.join(", ")}`;
20087
20176
  const text = move.reason === "returned" && move.text !== null ? ` ${move.text}` : "";
20088
20177
  const moved = line(`${move.at}: ${move.from} to ${move.to} (${move.reason}${text}${gate})`);
20089
- return move.reason === "corrected" && move.text !== null ? [moved, quote(move.text)] : [moved];
20178
+ return (move.reason === "corrected" || move.reason === "manual") && move.text !== null ? [moved, quote(move.text)] : [moved];
20090
20179
  })
20091
20180
  ];
20092
20181
  }
package/dist/mcp.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { p as OPERATIONS, rt as ERRORS, v as renderMcpError } from "./chunk-CY5-uNaf.mjs";
2
- import { o as CliError, r as requestOperation } from "./chunk-DcRmoCME.mjs";
3
- import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-B_idjhSg.mjs";
1
+ import { p as OPERATIONS, rt as ERRORS, v as renderMcpError } from "./chunk-CgQL6u77.mjs";
2
+ import { o as CliError, r as requestOperation } from "./chunk-2vFOidpZ.mjs";
3
+ import { a as memoryVerdictCache, c as loadClientConfig, r as compareCatalogs, t as checkCatalog } from "./chunk-B9WekLbU.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { z } from "zod";
@@ -31,7 +31,7 @@ function toolInputSchema(op, agent) {
31
31
  ...schema["properties"],
32
32
  idempotencyKey: key
33
33
  },
34
- ...agent ? { required: [...schema["required"] ?? [], "idempotencyKey"] } : {}
34
+ ...agent || op.explicitKeyModes?.includes(schema["properties"]["mode"]?.["const"]) ? { required: [...schema["required"] ?? [], "idempotencyKey"] } : {}
35
35
  });
36
36
  if (Array.isArray(source["oneOf"])) return {
37
37
  ...source,
@@ -65,7 +65,7 @@ function parseArguments(op, argumentsValue, agent) {
65
65
  const { idempotencyKey, ...input } = argumentsValue;
66
66
  let key;
67
67
  if (op.kind === "mutation") {
68
- if (idempotencyKey === void 0 && !agent) key = randomUUID();
68
+ if (idempotencyKey === void 0 && !agent && !op.explicitKeyModes?.includes(input["mode"])) key = randomUUID();
69
69
  else if (typeof idempotencyKey === "string" && idempotencyKey.trim()) key = idempotencyKey;
70
70
  else throw keyError(MISSING_KEY_HINT);
71
71
  } else if (idempotencyKey !== void 0) throw keyError(QUERY_KEY_HINT);