@rallycry/conveyor-mcp 5.0.8 → 5.0.9

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/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-5KU3QS6A.js";
5
5
  import {
6
6
  ConveyorConnection
7
- } from "./chunk-L3AI3EU2.js";
7
+ } from "./chunk-UPLS63HM.js";
8
8
 
9
9
  // src/cli.ts
10
10
  import { createRequire } from "module";
@@ -72,8 +72,9 @@ function registerProjectTools(server2, conn2) {
72
72
  // src/tools/connection.ts
73
73
  import { z as z4 } from "zod";
74
74
 
75
- // ../shared/dist/chunk-U3HGG5NX.js
75
+ // ../shared/dist/chunk-ZSXAYKD4.js
76
76
  import { z as z2 } from "zod";
77
+ import { z as z22 } from "zod";
77
78
  var DEFAULT_SONNET_MODEL = "claude-sonnet-5";
78
79
  var DEFAULT_OPUS_MODEL = "claude-opus-5-5";
79
80
  var DEFAULT_HAIKU_MODEL = "claude-haiku-4-5-20251001";
@@ -146,6 +147,12 @@ var projectCheckpointSettingsSchema = z2.object({
146
147
  var CARD_DESCRIPTION_MAX = 255;
147
148
  var CARD_DESCRIPTION_LIMIT_MESSAGE = `Card descriptions are capped at ${CARD_DESCRIPTION_MAX} characters \u2014 write 1-2 plain sentences a non-engineer can read; put technical detail in the plan or card chat.`;
148
149
  var CARD_DESCRIPTION_FIELD_HINT = `max ${CARD_DESCRIPTION_MAX} chars, 1-2 plain sentences a non-engineer can read \u2014 put technical detail in the plan`;
150
+ var MAX_MANUAL_TESTS_PER_TASK = 5;
151
+ var MAX_MANUAL_TEST_TITLE_LENGTH = 200;
152
+ var ManualTestItemsSchema = z22.array(z22.object({ title: z22.string().min(1).max(MAX_MANUAL_TEST_TITLE_LENGTH) })).min(1).max(MAX_MANUAL_TESTS_PER_TASK);
153
+ function describeManualTestRejection(item) {
154
+ return item.reason === "cap" ? `Rejected "${item.title}": the card already holds ${MAX_MANUAL_TESTS_PER_TASK} manual tests. Use remove_manual_test or edit_manual_test to consolidate.` : `Rejected "${item.title}": names an automated step (lint, tests, CI, shell); manual tests describe what a person does in the app.`;
155
+ }
149
156
  var DEFAULT_CI_WAIT_TIMEOUT_MINUTES = 45;
150
157
  var MAX_CI_WAIT_TIMEOUT_MINUTES = 180;
151
158
  var SEVERITY_ENUM = [
@@ -306,14 +313,14 @@ var f = {
306
313
  return { kind: "nullable", inner };
307
314
  }
308
315
  };
309
- function compileString(z13, spec) {
310
- let schema = z13.string();
316
+ function compileString(z14, spec) {
317
+ let schema = z14.string();
311
318
  if (spec.min !== void 0) schema = schema.min(spec.min);
312
319
  if (spec.max !== void 0) schema = schema.max(spec.max);
313
320
  return schema;
314
321
  }
315
- function compileNumber(z13, spec) {
316
- let schema = z13.number();
322
+ function compileNumber(z14, spec) {
323
+ let schema = z14.number();
317
324
  if (spec.int) schema = schema.int();
318
325
  if (spec.positive) schema = schema.positive();
319
326
  if (spec.nonnegative) schema = schema.nonnegative();
@@ -321,49 +328,50 @@ function compileNumber(z13, spec) {
321
328
  if (spec.max !== void 0) schema = schema.max(spec.max);
322
329
  return schema;
323
330
  }
324
- function compileArray(z13, spec) {
325
- let schema = z13.array(compileField(z13, spec.item));
331
+ function compileArray(z14, spec) {
332
+ let schema = z14.array(compileField(z14, spec.item));
326
333
  if (spec.min !== void 0) schema = schema.min(spec.min);
334
+ if (spec.max !== void 0) schema = schema.max(spec.max);
327
335
  return schema;
328
336
  }
329
- function compileBase(z13, spec) {
337
+ function compileBase(z14, spec) {
330
338
  switch (spec.kind) {
331
339
  case "string":
332
- return compileString(z13, spec);
340
+ return compileString(z14, spec);
333
341
  case "number":
334
- return compileNumber(z13, spec);
342
+ return compileNumber(z14, spec);
335
343
  case "boolean":
336
- return z13.boolean();
344
+ return z14.boolean();
337
345
  case "enum":
338
- return z13.enum([...spec.values]);
346
+ return z14.enum([...spec.values]);
339
347
  case "array":
340
- return compileArray(z13, spec);
348
+ return compileArray(z14, spec);
341
349
  case "object":
342
- return z13.object(compileShape(z13, spec.fields));
350
+ return z14.object(compileShape(z14, spec.fields));
343
351
  }
344
352
  }
345
353
  function descriptionOf(spec) {
346
354
  if (spec.kind === "optional" || spec.kind === "nullable") return descriptionOf(spec.inner);
347
355
  return spec.desc;
348
356
  }
349
- function compileUndescribed(z13, spec) {
357
+ function compileUndescribed(z14, spec) {
350
358
  if (spec.kind === "optional") {
351
- return compileUndescribed(z13, spec.inner).optional();
359
+ return compileUndescribed(z14, spec.inner).optional();
352
360
  }
353
361
  if (spec.kind === "nullable") {
354
- return compileUndescribed(z13, spec.inner).nullable();
362
+ return compileUndescribed(z14, spec.inner).nullable();
355
363
  }
356
- return compileBase(z13, spec);
364
+ return compileBase(z14, spec);
357
365
  }
358
- function compileField(z13, spec) {
359
- const schema = compileUndescribed(z13, spec);
366
+ function compileField(z14, spec) {
367
+ const schema = compileUndescribed(z14, spec);
360
368
  const desc = descriptionOf(spec);
361
369
  return desc === void 0 ? schema : schema.describe(desc);
362
370
  }
363
- function compileShape(z13, fields) {
371
+ function compileShape(z14, fields) {
364
372
  const shape = {};
365
373
  for (const [key, spec] of Object.entries(fields)) {
366
- shape[key] = compileField(z13, spec);
374
+ shape[key] = compileField(z14, spec);
367
375
  }
368
376
  return shape;
369
377
  }
@@ -453,16 +461,24 @@ var readTaskChatContract = defineToolContract({
453
461
  }
454
462
  }
455
463
  });
464
+ var listTagsDetail = f.optional(
465
+ f.enum(["summary", "full"], {
466
+ desc: `"summary" (default) returns one compact row per tag with a contextPathCount. "full" also ships each tag's contextPaths inline (each link with its verification status). Full mode can exceed a client's tool-output budget on a large glossary; use get_tag for one term instead.`
467
+ })
468
+ );
456
469
  var listTagsContract = defineToolContract({
457
470
  name: "list_tags",
458
471
  agent: {
459
- description: "List the project glossary: every tag's id, name, color, description, parent/child tag ids, its contextPaths (the rule/doc/file/folder links it wires into agent context \u2014 `[]` means none), whether it carries a full overview (fetch that with get_tag), and its attachmentCount (files labelled as examples of the term). The context links ship inline, so you only need get_tag for a term's full overview. Use the ids with get_tag / update_tag.",
460
- fields: {}
472
+ description: "List the whole project glossary in one call. The default summary gives every tag's id, name, color, description, parent/child tag ids, whether it carries a full overview (hasOverview), its attachmentCount (files labelled as examples of the term), and its contextPathCount (the rule/doc/file/folder links it wires into agent context \u2014 `0` means none). Pass detail: \"full\" to ship the contextPaths themselves inline. Use get_tag for one term's full overview and full link verification. Use the ids with get_tag / update_tag.",
473
+ fields: {
474
+ detail: listTagsDetail
475
+ }
461
476
  },
462
477
  mcp: {
463
- description: "List all project tags with names, IDs, colors, descriptions, hierarchy (parent/child ids), contextPaths (the rule/doc/file/folder links each tag wires into agent context \u2014 `[]` means none), a hasOverview flag, and an attachmentCount (files labelled as examples of the term \u2014 read the tiles with list_tag_attachments). Context links ship inline; call get_tag only for a term's full overview. Pass projectId to target a specific project; otherwise the configured default project is used.",
478
+ description: 'List all project tags in one call. The default summary gives names, IDs, colors, descriptions, hierarchy (parent/child ids), a hasOverview flag, an attachmentCount (files labelled as examples of the term \u2014 read the tiles with list_tag_attachments), and a contextPathCount (the rule/doc/file/folder links each tag wires into agent context \u2014 `0` means none). Pass detail: "full" to ship the contextPaths themselves inline. Call get_tag for one term\'s full overview and full link verification. Pass projectId to target a specific project; otherwise the configured default project is used.',
464
479
  fields: {
465
- projectId: mcpProjectId
480
+ projectId: mcpProjectId,
481
+ detail: listTagsDetail
466
482
  }
467
483
  }
468
484
  });
@@ -598,7 +614,7 @@ var updateTaskContract = defineToolContract({
598
614
  }
599
615
  },
600
616
  mcp: {
601
- description: "Update task fields: title, description, plan, status, risk, story points, assignment, githubBranch, or tags. Set status to claim a card (InProgress), triage it (Open), or cancel it (Cancelled); for review approvals prefer approve_task / request_changes, which guard against stale-state races. Tags are additive/subtractive \u2014 pass addTags/removeTags with tag names (not a replace-set). Pass projectId to target a specific project; otherwise the configured default project is used. Moving a task beyond Planning auto-fills any missing icon, story points, and agent assignment \u2014 don't spend turns on them; pass storyPointValue only to correct the sizing yourself. For subtasks use update_subtask.",
617
+ description: "Update task fields: title, description, plan, status, risk, story points, assignment, githubBranch, onHold, or tags. Set status to claim a card (InProgress), triage it (Open), or cancel it (Cancelled); for review approvals prefer approve_task / request_changes, which guard against stale-state races. Set onHold to park a card (true) or bring it back to the active board (false) without cancelling it. Tags are additive/subtractive \u2014 pass addTags/removeTags with tag names (not a replace-set). Pass projectId to target a specific project; otherwise the configured default project is used. Moving a task beyond Planning auto-fills any missing icon, story points, and agent assignment \u2014 don't spend turns on them; pass storyPointValue only to correct the sizing yourself. For subtasks use update_subtask.",
602
618
  fields: {
603
619
  projectId: mcpProjectId,
604
620
  taskId: f.string({ desc: "The task ID" }),
@@ -629,6 +645,11 @@ var updateTaskContract = defineToolContract({
629
645
  )
630
646
  ),
631
647
  githubBranch: f.optional(f.nullable(f.string({ desc: GITHUB_BRANCH_DESC }))),
648
+ onHold: f.optional(
649
+ f.boolean({
650
+ desc: "Park the card on hold (true) or return it to the active board (false). On hold hides the card from the active columns without cancelling it; a card already at an active work status is demoted to Open when parked."
651
+ })
652
+ ),
632
653
  addTags: f.optional(
633
654
  f.array(f.string(), {
634
655
  desc: 'Tag names to add to the card (e.g. ["refactor"]). Additive \u2014 existing tags are kept. Unknown names are rejected; use list_tags to see available tags or manage_tags to create one.'
@@ -672,9 +693,20 @@ var testStatuses = f.optional(
672
693
  })
673
694
  );
674
695
  var setManualTestItems = f.array(
675
- f.object({ title: f.string({ min: 1, desc: "A concise, actionable test step" }) }),
676
- { min: 1, desc: "List of manual test steps to add" }
696
+ f.object({
697
+ title: f.string({
698
+ min: 1,
699
+ max: MAX_MANUAL_TEST_TITLE_LENGTH,
700
+ desc: "One sentence a non-engineer can follow: where to go, what to do, what they should see. No commands, no code."
701
+ })
702
+ }),
703
+ {
704
+ min: 1,
705
+ max: MAX_MANUAL_TESTS_PER_TASK,
706
+ desc: `Manual tests to add. A card holds at most ${MAX_MANUAL_TESTS_PER_TASK}; most changes need 1, and a change with no user-visible behavior needs none.`
707
+ }
677
708
  );
709
+ var setManualTestsBar = 'A manual test is a real user path in plain language ("Open a card with a PR: the Pull Request slat sits directly under Description"), not an engineering check. Never record lint, typecheck, unit tests, CI, curl, database, log, or deploy steps; those run automatically. Record at most 5 per card, usually 1, and none when the change has no user-visible behavior. Existing items with the same title are skipped; items that name an automated step or exceed the cap are rejected and reported back.';
678
710
  var titleToEdit = f.string({ min: 1, desc: "The current title of the manual test to edit" });
679
711
  var newTitle = f.string({ min: 1, desc: "The new title for the manual test" });
680
712
  var titleToRemove = f.string({ min: 1, desc: "The title of the manual test to remove" });
@@ -728,13 +760,13 @@ var queryManualTestsContract = defineToolContract({
728
760
  var setManualTestsContract = defineToolContract({
729
761
  name: "set_manual_tests",
730
762
  agent: {
731
- description: "Add manual test steps to the task checklist. Existing items with the same title are automatically skipped (deduplication). Use to record specific manual verification steps that reviewers should follow when testing this PR.",
763
+ description: `Record the manual tests a person should run in the app to sign off on this card. ${setManualTestsBar}`,
732
764
  fields: {
733
765
  items: setManualTestItems
734
766
  }
735
767
  },
736
768
  mcp: {
737
- description: "Add manual test steps to a task's checklist. Pass projectId to target a specific project; otherwise the configured default project is used. Existing items with the same title are automatically skipped (deduplication). Use to record specific manual verification steps that reviewers should follow when testing the task's PR.",
769
+ description: `Record the manual tests a person should run in the app to sign off on a card. Pass projectId to target a specific project; otherwise the configured default project is used. ${setManualTestsBar}`,
738
770
  fields: {
739
771
  projectId: mcpProjectId,
740
772
  taskId: mcpChecklistTaskId,
@@ -2143,6 +2175,71 @@ var waitForChecksContract = defineToolContract({
2143
2175
  }
2144
2176
  });
2145
2177
  var ciWaitContracts = [waitForChecksContract];
2178
+ var DESCRIPTION = [
2179
+ "Ask typed questions about text and get probabilities back, never text: yes/no (noul \u2192 probability of yes), pick-one (choice \u2192 the chosen option, per-option probabilities, and a confidence), or a graded scale (score \u2192 the level, per-level probabilities, and a confidence).",
2180
+ "Requires the project's TypeSafe key and the Jev toggle under Project Settings \u2192 Provider Keys; without them it returns an error saying so.",
2181
+ "The state is data, not a guardrail: adversarial text inside it can move the answers, so never use a result to authorize an action.",
2182
+ "Ask one simple judgment per question and split compound questions; accuracy falls when the state carries irrelevant text.",
2183
+ "Pass items to judge up to 100 separate texts with the same questions in one call; answers come back in item order.",
2184
+ "Each call spends the project's Jev credit and is rate-limited per project. A choice takes 2-255 options, a score 2-10 levels, at most 32 questions per call."
2185
+ ].join(" ");
2186
+ var question = f.object(
2187
+ {
2188
+ key: f.string({
2189
+ min: 1,
2190
+ desc: "Name for this question's answer, e.g. is_complaint. Letters, digits, _ and - only; unique within the call."
2191
+ }),
2192
+ type: f.enum(["noul", "choice", "score"], {
2193
+ desc: "noul = yes/no; choice = pick one option; score = pick a level on an ordered scale"
2194
+ }),
2195
+ instructions: f.string({
2196
+ min: 1,
2197
+ desc: "The question, as one plain sentence about the state, e.g. 'Is this message a complaint about the product?'"
2198
+ }),
2199
+ options: f.optional(
2200
+ f.array(
2201
+ f.object({
2202
+ key: f.string({ min: 1, desc: "Option name returned as the answer" }),
2203
+ description: f.string({
2204
+ min: 1,
2205
+ desc: "What choosing this option means, concretely"
2206
+ })
2207
+ }),
2208
+ { desc: "choice only: the options (2-255). Option order can move the answer." }
2209
+ )
2210
+ ),
2211
+ levels: f.optional(
2212
+ f.array(f.string({ min: 1 }), {
2213
+ desc: "score only: 2-10 level descriptions, lowest first"
2214
+ })
2215
+ )
2216
+ },
2217
+ { desc: "One typed question" }
2218
+ );
2219
+ var stateDesc = "The thing being judged, as plain text or JSON. Required unless items is given; with items it is ignored.";
2220
+ var itemsDesc = "Up to 100 separate texts (each up to 8,000 characters), each judged on its own with the same questions. Use this for bulk classification instead of one call per item.";
2221
+ var questionsDesc = "1-32 questions, all answered independently against the same state.";
2222
+ var evaluateQuestionsContract = defineToolContract({
2223
+ name: "evaluate_questions",
2224
+ agent: {
2225
+ description: DESCRIPTION,
2226
+ fields: {
2227
+ state: f.optional(f.string({ desc: stateDesc })),
2228
+ questions: f.array(question, { min: 1, desc: questionsDesc }),
2229
+ items: f.optional(f.array(f.string(), { desc: itemsDesc }))
2230
+ }
2231
+ },
2232
+ mcp: {
2233
+ description: `${DESCRIPTION} Pass projectId to target a specific project; otherwise the configured default project is used.`,
2234
+ fields: {
2235
+ projectId: mcpProjectId,
2236
+ state: f.optional(f.string({ desc: stateDesc })),
2237
+ questions: f.array(question, { min: 1, desc: questionsDesc }),
2238
+ items: f.optional(f.array(f.string(), { desc: itemsDesc }))
2239
+ }
2240
+ }
2241
+ });
2242
+ var evaluateContracts = [evaluateQuestionsContract];
2146
2243
  var TOOL_CONTRACTS = Object.fromEntries(
2147
2244
  [
2148
2245
  ...tasksContracts,
@@ -2159,7 +2256,8 @@ var TOOL_CONTRACTS = Object.fromEntries(
2159
2256
  ...driveContracts,
2160
2257
  ...meetingsContracts,
2161
2258
  ...logsContracts,
2162
- ...ciWaitContracts
2259
+ ...ciWaitContracts,
2260
+ ...evaluateContracts
2163
2261
  ].map((contract) => [contract.name, contract])
2164
2262
  );
2165
2263
 
@@ -2597,6 +2695,7 @@ function registerListTasks(server2, conn2) {
2597
2695
  assigneeId: z6.string().optional().describe("Filter by assigned user ID"),
2598
2696
  unassigned: z6.boolean().optional().describe("Only return tasks with no assignee (mutually exclusive with assigneeId)"),
2599
2697
  subProjectId: BOARD_FILTER,
2698
+ onHold: z6.boolean().optional().describe("true = only cards on hold, false = exclude them, omit = both"),
2600
2699
  limit: z6.number().optional().describe("Max tasks to return (default 50)")
2601
2700
  },
2602
2701
  async (params) => {
@@ -2803,7 +2902,7 @@ function registerSearchTasks(server2, conn2) {
2803
2902
  }
2804
2903
  function registerListTags(server2, conn2) {
2805
2904
  registerContractTool(server2, listTagsContract, async (params) => {
2806
- const tags = await conn2.listTags(params.projectId);
2905
+ const tags = await conn2.listTags(params.projectId, params.detail);
2807
2906
  return { content: [{ type: "text", text: JSON.stringify(tags, null, 2) }] };
2808
2907
  });
2809
2908
  }
@@ -3314,353 +3413,9 @@ function registerSuggestionTools(server2, conn2) {
3314
3413
  });
3315
3414
  }
3316
3415
 
3317
- // src/tools/checklists.ts
3318
- function renderManualTestGroups(groups) {
3319
- const lines = [];
3320
- for (const g of groups) {
3321
- lines.push(`## ${g.title} [${g.status}] (${g.slug})`);
3322
- for (const t of g.tests) {
3323
- const mark = t.status === "approved" ? "\u2713" : t.status === "rejected" ? "\u2717" : "\u25CB";
3324
- lines.push(` ${mark} ${t.title} \u2014 ${t.status}`);
3325
- if (t.status === "rejected") {
3326
- for (const f2 of t.failures ?? []) {
3327
- lines.push(` \u26A0 ${f2.userName ?? "Someone"}: ${f2.reason ?? "(no message)"}`);
3328
- }
3329
- }
3330
- }
3331
- lines.push("");
3332
- }
3333
- return lines.join("\n").trimEnd();
3334
- }
3335
- function registerListManualTests(server2, conn2) {
3336
- registerContractTool(server2, listManualTestsContract, async (params) => {
3337
- const items = await conn2.listManualTests(params.taskId, params.projectId);
3338
- if (items.length === 0) {
3339
- return { content: [{ type: "text", text: "No manual tests recorded for this task." }] };
3340
- }
3341
- const lines = items.flatMap((item, i) => {
3342
- const checked = item.checked ? "[x]" : "[ ]";
3343
- const row = [`${i + 1}. ${checked} ${item.title}`];
3344
- for (const f2 of item.failures ?? []) {
3345
- const who = f2.userName ?? "Someone";
3346
- const reason = f2.reason ?? "(no message)";
3347
- row.push(` \u26A0 Failed (${who}): ${reason}`);
3348
- }
3349
- return row;
3350
- });
3351
- return { content: [{ type: "text", text: lines.join("\n") }] };
3352
- });
3353
- }
3354
- function registerSetManualTests(server2, conn2) {
3355
- registerContractTool(server2, setManualTestsContract, async (params) => {
3356
- const result = await conn2.setManualTests(params.taskId, params.items, params.projectId);
3357
- const parts = [`Created ${result.created} manual test item(s).`];
3358
- if (result.skipped > 0) parts.push(`Skipped ${result.skipped} duplicate(s).`);
3359
- return { content: [{ type: "text", text: parts.join(" ") }] };
3360
- });
3361
- }
3362
- function registerEditManualTest(server2, conn2) {
3363
- registerContractTool(server2, editManualTestContract, async (params) => {
3364
- await conn2.editManualTest(params.taskId, params.title, params.newTitle, params.projectId);
3365
- return { content: [{ type: "text", text: `Updated manual test to "${params.newTitle}".` }] };
3366
- });
3367
- }
3368
- function registerRemoveManualTest(server2, conn2) {
3369
- registerContractTool(server2, removeManualTestContract, async (params) => {
3370
- await conn2.removeManualTest(params.taskId, params.title, params.projectId);
3371
- return { content: [{ type: "text", text: `Removed manual test "${params.title}".` }] };
3372
- });
3373
- }
3374
- function registerApproveManualTest(server2, conn2) {
3375
- registerContractTool(server2, approveManualTestContract, async (params) => {
3376
- await conn2.approveManualTest(params.taskId, params.title, params.projectId);
3377
- return { content: [{ type: "text", text: `Approved manual test "${params.title}".` }] };
3378
- });
3379
- }
3380
- function registerRejectManualTest(server2, conn2) {
3381
- registerContractTool(server2, rejectManualTestContract, async (params) => {
3382
- await conn2.rejectManualTest(params.taskId, params.title, params.reason, params.projectId);
3383
- return {
3384
- content: [
3385
- {
3386
- type: "text",
3387
- text: `Flagged an issue with manual test "${params.title}": ${params.reason}`
3388
- }
3389
- ]
3390
- };
3391
- });
3392
- }
3393
- function registerQueryManualTests(server2, conn2) {
3394
- registerContractTool(server2, queryManualTestsContract, async (params) => {
3395
- const groups = await conn2.queryManualTests({
3396
- projectId: params.projectId,
3397
- cardStatuses: params.cardStatuses,
3398
- testStatuses: params.testStatuses
3399
- });
3400
- if (groups.length === 0) {
3401
- return { content: [{ type: "text", text: "No manual tests match those filters." }] };
3402
- }
3403
- return { content: [{ type: "text", text: renderManualTestGroups(groups) }] };
3404
- });
3405
- }
3406
- function registerChecklistTools(server2, conn2) {
3407
- registerListManualTests(server2, conn2);
3408
- registerQueryManualTests(server2, conn2);
3409
- registerSetManualTests(server2, conn2);
3410
- registerEditManualTest(server2, conn2);
3411
- registerRemoveManualTest(server2, conn2);
3412
- registerApproveManualTest(server2, conn2);
3413
- registerRejectManualTest(server2, conn2);
3414
- }
3415
-
3416
- // src/tools/workspace.ts
3416
+ // ../shared/dist/index.js
3417
3417
  import { z as z9 } from "zod";
3418
-
3419
- // src/workspace-ssh-tunnel.ts
3420
- import net from "net";
3421
- import { once } from "events";
3422
- import { WebSocket } from "ws";
3423
- var WORKSPACE_TUNNEL_HEARTBEAT_MS = 3e4;
3424
- function withPort(url, port) {
3425
- const parsed = new URL(url);
3426
- parsed.searchParams.set("port", String(port));
3427
- return parsed.toString();
3428
- }
3429
- function toBuffer(data) {
3430
- if (Buffer.isBuffer(data)) return data;
3431
- if (data instanceof ArrayBuffer) return Buffer.from(data);
3432
- return Buffer.concat(data);
3433
- }
3434
- function startHeartbeat(ws) {
3435
- const timer = setInterval(() => {
3436
- if (ws.readyState === WebSocket.OPEN) ws.ping();
3437
- }, WORKSPACE_TUNNEL_HEARTBEAT_MS);
3438
- timer.unref?.();
3439
- return () => clearInterval(timer);
3440
- }
3441
- function bridgeClient(client, options) {
3442
- let ws = null;
3443
- let ready = false;
3444
- const pending = [];
3445
- client.on("data", (data) => {
3446
- const chunk = Buffer.isBuffer(data) ? data : Buffer.from(data);
3447
- if (ready && ws && ws.readyState === WebSocket.OPEN) ws.send(chunk);
3448
- else pending.push(chunk);
3449
- });
3450
- client.on("close", () => ws?.close());
3451
- client.on("error", () => ws?.close());
3452
- options.resolveTarget().then(({ tunnelUrl, attachToken }) => {
3453
- const socket = new WebSocket(withPort(tunnelUrl, options.remotePort), {
3454
- headers: { "x-workspace-attach-token": attachToken }
3455
- });
3456
- ws = socket;
3457
- const stopHeartbeat = startHeartbeat(socket);
3458
- socket.on("message", (data) => {
3459
- const chunk = toBuffer(data);
3460
- if (!ready) {
3461
- const text = chunk.toString("utf8");
3462
- if (text === JSON.stringify({ ok: true })) {
3463
- ready = true;
3464
- for (const buffered of pending.splice(0)) socket.send(buffered);
3465
- return;
3466
- }
3467
- client.destroy(new Error(`Workspace tunnel rejected connection: ${text}`));
3468
- socket.close();
3469
- return;
3470
- }
3471
- client.write(chunk);
3472
- });
3473
- socket.on("close", () => {
3474
- stopHeartbeat();
3475
- client.destroy();
3476
- });
3477
- socket.on("error", (err) => {
3478
- stopHeartbeat();
3479
- client.destroy(err);
3480
- });
3481
- }).catch((err) => {
3482
- client.destroy(err instanceof Error ? err : new Error(String(err)));
3483
- });
3484
- }
3485
- async function startWorkspaceSshTunnel(options) {
3486
- const host = options.host ?? "127.0.0.1";
3487
- const server2 = net.createServer((client) => bridgeClient(client, options));
3488
- const ac = new AbortController();
3489
- server2.listen(options.preferredLocalPort ?? 0, host);
3490
- try {
3491
- await Promise.race([
3492
- once(server2, "listening", { signal: ac.signal }),
3493
- once(server2, "error", { signal: ac.signal }).then(([err]) => {
3494
- throw err instanceof Error ? err : new Error(String(err));
3495
- })
3496
- ]);
3497
- } catch (err) {
3498
- server2.close();
3499
- throw new Error(
3500
- `Failed to bind workspace SSH tunnel: ${err instanceof Error ? err.message : String(err)}`,
3501
- { cause: err }
3502
- );
3503
- } finally {
3504
- ac.abort();
3505
- }
3506
- const address = server2.address();
3507
- if (!address || typeof address === "string") {
3508
- server2.close();
3509
- throw new Error("Failed to bind workspace SSH tunnel");
3510
- }
3511
- return {
3512
- host,
3513
- port: address.port,
3514
- close: () => new Promise((resolve, reject) => {
3515
- server2.close((err) => {
3516
- if (err) reject(err);
3517
- else resolve();
3518
- });
3519
- })
3520
- };
3521
- }
3522
-
3523
- // src/tools/workspace.ts
3524
- var activeTunnels = /* @__PURE__ */ new Map();
3525
- function createTunnelId(taskId, port) {
3526
- return `${taskId}:${port}:${Date.now().toString(36)}:${Math.random().toString(36).slice(2, 8)}`;
3527
- }
3528
- function localUrlFor(port, host, localPort) {
3529
- if (port === 2222) return void 0;
3530
- return `http://${host}:${localPort}`;
3531
- }
3532
- function registerAttachInfoTool(server2, conn2) {
3533
- server2.tool(
3534
- "workspace_attach_info",
3535
- "Return SSH/SFTP attach metadata for a running task Claudespace, plus hosted preview URLs and configured preview ports. Optionally installs an OpenSSH public key for this attach session.",
3536
- {
3537
- taskId: z9.string().describe("The task ID"),
3538
- sshPublicKey: z9.string().optional().describe("Optional OpenSSH public key to install into the workspace")
3539
- },
3540
- async ({ taskId, sshPublicKey }) => {
3541
- const info = await conn2.getWorkspaceAttachInfo(taskId, sshPublicKey);
3542
- return { content: [{ type: "text", text: JSON.stringify(info, null, 2) }] };
3543
- }
3544
- );
3545
- }
3546
- function registerPreviewUrlsTool(server2, conn2) {
3547
- server2.tool(
3548
- "workspace_preview_urls",
3549
- "Return the hosted preview URLs and preview ports for a running task Claudespace. This mirrors the web UI preview link metadata.",
3550
- {
3551
- taskId: z9.string().describe("The task ID")
3552
- },
3553
- async ({ taskId }) => {
3554
- const info = await conn2.getWorkspaceAttachInfo(taskId);
3555
- return {
3556
- content: [
3557
- {
3558
- type: "text",
3559
- text: JSON.stringify(
3560
- {
3561
- taskId: info.taskId,
3562
- sessionId: info.sessionId,
3563
- previewPorts: info.previewPorts,
3564
- previewUrls: info.previewUrls
3565
- },
3566
- null,
3567
- 2
3568
- )
3569
- }
3570
- ]
3571
- };
3572
- }
3573
- );
3574
- }
3575
- function registerStartTunnelTool(server2, conn2, startTunnel) {
3576
- server2.tool(
3577
- "workspace_start_tunnel",
3578
- "Start a local loopback tunnel through the MCP server to a running task Claudespace port. Use port 2222 for SSH/SFTP, or one of previewPorts for app access.",
3579
- {
3580
- taskId: z9.string().describe("The task ID"),
3581
- port: z9.number().optional().describe("Remote Claudespace port. Defaults to SSH port 2222."),
3582
- preferredLocalPort: z9.number().optional().describe("Preferred local loopback port. If omitted, the OS chooses one."),
3583
- sshPublicKey: z9.string().optional().describe("Optional OpenSSH public key to install before opening the tunnel")
3584
- },
3585
- async ({ taskId, port, preferredLocalPort, sshPublicKey }) => {
3586
- const info = await conn2.getWorkspaceAttachInfo(taskId, sshPublicKey);
3587
- if (!info.tunnelUrl || !info.attachToken) {
3588
- throw new Error(
3589
- "Workspace tunnels are unavailable for this task (GitHub Codespace-backed environments expose previews only \u2014 use workspace_preview_urls)."
3590
- );
3591
- }
3592
- const remotePort = port ?? info.ssh?.remotePort ?? 2222;
3593
- const handle = await startTunnel({
3594
- remotePort,
3595
- preferredLocalPort,
3596
- // Re-mint per connection so the tunnel outlives the attach-token TTL.
3597
- // The key (if any) is already installed by the call above; the refetch
3598
- // only needs a fresh token, so it omits sshPublicKey.
3599
- resolveTarget: async () => {
3600
- const fresh = await conn2.getWorkspaceAttachInfo(taskId);
3601
- if (!fresh.tunnelUrl || !fresh.attachToken)
3602
- throw new Error("Workspace tunnel target is no longer available");
3603
- return { tunnelUrl: fresh.tunnelUrl, attachToken: fresh.attachToken };
3604
- }
3605
- });
3606
- const tunnelId = createTunnelId(taskId, remotePort);
3607
- activeTunnels.set(tunnelId, handle);
3608
- return {
3609
- content: [
3610
- {
3611
- type: "text",
3612
- text: JSON.stringify(
3613
- {
3614
- tunnelId,
3615
- taskId,
3616
- remotePort,
3617
- localHost: handle.host,
3618
- localPort: handle.port,
3619
- localUrl: localUrlFor(remotePort, handle.host, handle.port),
3620
- // `-o ServerAliveInterval=30` drives client-side keepalives so an
3621
- // idle session keeps the tunnel warm (the tunnel layer pings too,
3622
- // but the client must keep its own TCP path alive across every hop).
3623
- sshCommand: remotePort === 2222 ? `ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -p ${handle.port} ${info.ssh?.username ?? "conveyor"}@${handle.host}` : void 0,
3624
- sftpCommand: remotePort === 2222 ? `sftp -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -P ${handle.port} ${info.ssh?.username ?? "conveyor"}@${handle.host}` : void 0,
3625
- previewPorts: info.previewPorts,
3626
- previewUrls: info.previewUrls,
3627
- expiresAt: info.expiresAt
3628
- },
3629
- null,
3630
- 2
3631
- )
3632
- }
3633
- ]
3634
- };
3635
- }
3636
- );
3637
- }
3638
- function registerStopTunnelTool(server2) {
3639
- server2.tool(
3640
- "workspace_stop_tunnel",
3641
- "Stop a local workspace tunnel previously opened by workspace_start_tunnel.",
3642
- {
3643
- tunnelId: z9.string().describe("Tunnel id returned by workspace_start_tunnel")
3644
- },
3645
- async ({ tunnelId }) => {
3646
- const tunnel = activeTunnels.get(tunnelId);
3647
- if (!tunnel) throw new Error("Workspace tunnel not found");
3648
- await tunnel.close();
3649
- activeTunnels.delete(tunnelId);
3650
- return { content: [{ type: "text", text: "Workspace tunnel stopped" }] };
3651
- }
3652
- );
3653
- }
3654
- function registerWorkspaceTools(server2, conn2, deps = {}) {
3655
- registerAttachInfoTool(server2, conn2);
3656
- registerPreviewUrlsTool(server2, conn2);
3657
- registerStartTunnelTool(server2, conn2, deps.startTunnel ?? startWorkspaceSshTunnel);
3658
- registerStopTunnelTool(server2);
3659
- }
3660
-
3661
- // ../shared/dist/index.js
3662
- import { z as z10 } from "zod";
3663
- import { z as z22 } from "zod";
3418
+ import { z as z23 } from "zod";
3664
3419
  import { z as z32 } from "zod";
3665
3420
  import { z as z42 } from "zod";
3666
3421
  import { z as z52 } from "zod";
@@ -3668,7 +3423,7 @@ import { z as z62 } from "zod";
3668
3423
  import { z as z72 } from "zod";
3669
3424
  import { z as z82 } from "zod";
3670
3425
  import { z as z92 } from "zod";
3671
- import { z as z102 } from "zod";
3426
+ import { z as z10 } from "zod";
3672
3427
  import { z as z11 } from "zod";
3673
3428
  import { z as z12 } from "zod";
3674
3429
  var ACHIEVEMENT_RARITIES = [
@@ -3694,7 +3449,7 @@ var ACHIEVEMENT_RARITIES = [
3694
3449
  { key: "pack", name: "Pack", color: "#9c27b0", iconPath: "/storypoints/pack.svg" }
3695
3450
  ];
3696
3451
  var RISK_LEVELS = ["critical", "high", "medium", "low"];
3697
- var riskLevelSchema = z10.enum(RISK_LEVELS);
3452
+ var riskLevelSchema = z9.enum(RISK_LEVELS);
3698
3453
  var DEFAULT_RISK_LEVELS = [
3699
3454
  {
3700
3455
  level: "critical",
@@ -3777,155 +3532,155 @@ var ALLOWED_FILE_ACCEPT = [
3777
3532
  var EMBED_THRESHOLD_IMAGES = 5 * 1024 * 1024;
3778
3533
  var EMBED_THRESHOLD_TEXT = 2 * 1024 * 1024;
3779
3534
  var IDLE_HEARTBEAT_MS = 90 * 1e3;
3780
- var TurnEndToolCallSchema = z22.object({
3781
- tool: z22.string(),
3782
- input: z22.string().optional(),
3783
- output: z22.string().optional(),
3784
- timestamp: z22.string().optional()
3535
+ var TurnEndToolCallSchema = z23.object({
3536
+ tool: z23.string(),
3537
+ input: z23.string().optional(),
3538
+ output: z23.string().optional(),
3539
+ timestamp: z23.string().optional()
3785
3540
  }).passthrough();
3786
- var AgentTurnUsageSchema = z22.object({
3787
- inputTokens: z22.number(),
3788
- outputTokens: z22.number(),
3789
- cacheReadInputTokens: z22.number(),
3790
- cacheCreationInputTokens: z22.number(),
3791
- totalTokens: z22.number()
3792
- });
3793
- var KnownAgentEventSchema = z22.discriminatedUnion("type", [
3541
+ var AgentTurnUsageSchema = z23.object({
3542
+ inputTokens: z23.number(),
3543
+ outputTokens: z23.number(),
3544
+ cacheReadInputTokens: z23.number(),
3545
+ cacheCreationInputTokens: z23.number(),
3546
+ totalTokens: z23.number()
3547
+ });
3548
+ var KnownAgentEventSchema = z23.discriminatedUnion("type", [
3794
3549
  // ── Lifecycle / connection ────────────────────────────────────────────
3795
- z22.object({
3796
- type: z22.literal("connected"),
3797
- sessionId: z22.string(),
3798
- projectId: z22.string().optional()
3550
+ z23.object({
3551
+ type: z23.literal("connected"),
3552
+ sessionId: z23.string(),
3553
+ projectId: z23.string().optional()
3799
3554
  }).passthrough(),
3800
3555
  // Open-ended context snapshot spread from buildInitializationContext().
3801
- z22.object({ type: z22.literal("session_manifest") }).passthrough(),
3802
- z22.object({
3803
- type: z22.literal("agent_runner_status"),
3804
- reason: z22.string(),
3805
- attempt: z22.number().optional(),
3806
- attempts: z22.number().optional()
3556
+ z23.object({ type: z23.literal("session_manifest") }).passthrough(),
3557
+ z23.object({
3558
+ type: z23.literal("agent_runner_status"),
3559
+ reason: z23.string(),
3560
+ attempt: z23.number().optional(),
3561
+ attempts: z23.number().optional()
3807
3562
  }).passthrough(),
3808
- z22.object({ type: z22.literal("shutdown"), reason: z22.string().optional() }).passthrough(),
3809
- z22.object({ type: z22.literal("mode_changed"), agentMode: z22.string() }).passthrough(),
3810
- z22.object({ type: z22.literal("mode_transition"), from: z22.string(), to: z22.string() }).passthrough(),
3563
+ z23.object({ type: z23.literal("shutdown"), reason: z23.string().optional() }).passthrough(),
3564
+ z23.object({ type: z23.literal("mode_changed"), agentMode: z23.string() }).passthrough(),
3565
+ z23.object({ type: z23.literal("mode_transition"), from: z23.string(), to: z23.string() }).passthrough(),
3811
3566
  // ── Turn stream ───────────────────────────────────────────────────────
3812
- z22.object({ type: z22.literal("message"), content: z22.string() }).passthrough(),
3813
- z22.object({ type: z22.literal("thinking"), message: z22.string() }).passthrough(),
3814
- z22.object({
3815
- type: z22.literal("tool_use"),
3816
- tool: z22.string(),
3567
+ z23.object({ type: z23.literal("message"), content: z23.string() }).passthrough(),
3568
+ z23.object({ type: z23.literal("thinking"), message: z23.string() }).passthrough(),
3569
+ z23.object({
3570
+ type: z23.literal("tool_use"),
3571
+ tool: z23.string(),
3817
3572
  // Producers send JSON.stringify(input); consumers defend against
3818
3573
  // object inputs from older agents, so the wire stays permissive here.
3819
- input: z22.unknown().optional()
3574
+ input: z23.unknown().optional()
3820
3575
  }).passthrough(),
3821
- z22.object({
3822
- type: z22.literal("tool_result"),
3823
- tool: z22.string(),
3824
- output: z22.unknown().optional(),
3825
- isError: z22.boolean().optional(),
3826
- redactedCount: z22.number().optional()
3576
+ z23.object({
3577
+ type: z23.literal("tool_result"),
3578
+ tool: z23.string(),
3579
+ output: z23.unknown().optional(),
3580
+ isError: z23.boolean().optional(),
3581
+ redactedCount: z23.number().optional()
3827
3582
  }).passthrough(),
3828
- z22.object({ type: z22.literal("turn_end"), toolCalls: z22.array(TurnEndToolCallSchema) }).passthrough(),
3829
- z22.object({
3830
- type: z22.literal("completed"),
3831
- summary: z22.string().optional(),
3832
- durationMs: z22.number().optional(),
3583
+ z23.object({ type: z23.literal("turn_end"), toolCalls: z23.array(TurnEndToolCallSchema) }).passthrough(),
3584
+ z23.object({
3585
+ type: z23.literal("completed"),
3586
+ summary: z23.string().optional(),
3587
+ durationMs: z23.number().optional(),
3833
3588
  /** Tokens this turn consumed, summed from the transcript's assistant
3834
3589
  * records. Optional: an older agent build sends none, and the server
3835
3590
  * then records nothing rather than zeroing the session's totals. */
3836
3591
  usage: AgentTurnUsageSchema.optional()
3837
3592
  }).passthrough(),
3838
- z22.object({ type: z22.literal("error"), message: z22.string() }).passthrough(),
3839
- z22.object({ type: z22.literal("agent_typing_start") }).passthrough(),
3840
- z22.object({ type: z22.literal("agent_typing_stop") }).passthrough(),
3593
+ z23.object({ type: z23.literal("error"), message: z23.string() }).passthrough(),
3594
+ z23.object({ type: z23.literal("agent_typing_start") }).passthrough(),
3595
+ z23.object({ type: z23.literal("agent_typing_stop") }).passthrough(),
3841
3596
  // ── Telemetry ─────────────────────────────────────────────────────────
3842
3597
  // heartbeat/typing: legacy telemetry the server still classifies as
3843
3598
  // transient (TRANSIENT_EVENT_TYPES) — kept in the vocabulary.
3844
- z22.object({ type: z22.literal("heartbeat") }).passthrough(),
3845
- z22.object({ type: z22.literal("typing") }).passthrough(),
3846
- z22.object({
3847
- type: z22.literal("context_update"),
3848
- contextTokens: z22.number(),
3849
- contextWindow: z22.number(),
3850
- inputTokens: z22.number().optional(),
3851
- cacheReadInputTokens: z22.number().optional(),
3852
- cacheCreationInputTokens: z22.number().optional(),
3853
- totalTokensUsed: z22.number().optional()
3599
+ z23.object({ type: z23.literal("heartbeat") }).passthrough(),
3600
+ z23.object({ type: z23.literal("typing") }).passthrough(),
3601
+ z23.object({
3602
+ type: z23.literal("context_update"),
3603
+ contextTokens: z23.number(),
3604
+ contextWindow: z23.number(),
3605
+ inputTokens: z23.number().optional(),
3606
+ cacheReadInputTokens: z23.number().optional(),
3607
+ cacheCreationInputTokens: z23.number().optional(),
3608
+ totalTokensUsed: z23.number().optional()
3854
3609
  }).passthrough(),
3855
3610
  // Four producer shapes share this type: {rateLimitType, utilization, status}
3856
3611
  // (SDK rate_limit_event), {resetsAt} (agent-connection resume notice), the
3857
3612
  // usage-sampler ({rateLimitType, utilization, status, resetsAt, gauges}
3858
3613
  // — resetsAt matches rateLimitType; gauges survives via .passthrough()), and
3859
3614
  // {unmeasurable, reason} (the sampler reporting it cannot read this key).
3860
- z22.object({
3861
- type: z22.literal("rate_limit_update"),
3862
- rateLimitType: z22.string().optional(),
3863
- utilization: z22.number().optional(),
3864
- status: z22.string().optional(),
3865
- resetsAt: z22.string().optional(),
3866
- unmeasurable: z22.boolean().optional(),
3867
- reason: z22.string().optional()
3615
+ z23.object({
3616
+ type: z23.literal("rate_limit_update"),
3617
+ rateLimitType: z23.string().optional(),
3618
+ utilization: z23.number().optional(),
3619
+ status: z23.string().optional(),
3620
+ resetsAt: z23.string().optional(),
3621
+ unmeasurable: z23.boolean().optional(),
3622
+ reason: z23.string().optional()
3868
3623
  }).passthrough(),
3869
- z22.object({
3870
- type: z22.literal("context_compacted"),
3871
- trigger: z22.string().optional(),
3872
- preTokens: z22.number().optional()
3624
+ z23.object({
3625
+ type: z23.literal("context_compacted"),
3626
+ trigger: z23.string().optional(),
3627
+ preTokens: z23.number().optional()
3873
3628
  }).passthrough(),
3874
- z22.object({
3875
- type: z22.literal("tool_progress"),
3876
- toolName: z22.string().optional(),
3877
- elapsedSeconds: z22.number().optional()
3629
+ z23.object({
3630
+ type: z23.literal("tool_progress"),
3631
+ toolName: z23.string().optional(),
3632
+ elapsedSeconds: z23.number().optional()
3878
3633
  }).passthrough(),
3879
- z22.object({
3880
- type: z22.literal("subagent_started"),
3881
- sdkTaskId: z22.string().optional(),
3882
- description: z22.string().optional()
3634
+ z23.object({
3635
+ type: z23.literal("subagent_started"),
3636
+ sdkTaskId: z23.string().optional(),
3637
+ description: z23.string().optional()
3883
3638
  }).passthrough(),
3884
- z22.object({
3885
- type: z22.literal("subagent_progress"),
3886
- sdkTaskId: z22.string().optional(),
3887
- description: z22.string().optional(),
3888
- toolUses: z22.number().optional(),
3889
- durationMs: z22.number().optional()
3639
+ z23.object({
3640
+ type: z23.literal("subagent_progress"),
3641
+ sdkTaskId: z23.string().optional(),
3642
+ description: z23.string().optional(),
3643
+ toolUses: z23.number().optional(),
3644
+ durationMs: z23.number().optional()
3890
3645
  }).passthrough(),
3891
3646
  // ── Work products ─────────────────────────────────────────────────────
3892
- z22.object({ type: z22.literal("pr_created"), url: z22.string(), number: z22.number() }).passthrough(),
3893
- z22.object({
3894
- type: z22.literal("code_review_complete"),
3895
- result: z22.enum(["approved", "changes_requested"]),
3896
- summary: z22.string().optional(),
3897
- issues: z22.array(
3898
- z22.object({
3899
- file: z22.string(),
3900
- line: z22.number().optional(),
3901
- severity: z22.string().optional(),
3902
- description: z22.string().optional()
3647
+ z23.object({ type: z23.literal("pr_created"), url: z23.string(), number: z23.number() }).passthrough(),
3648
+ z23.object({
3649
+ type: z23.literal("code_review_complete"),
3650
+ result: z23.enum(["approved", "changes_requested"]),
3651
+ summary: z23.string().optional(),
3652
+ issues: z23.array(
3653
+ z23.object({
3654
+ file: z23.string(),
3655
+ line: z23.number().optional(),
3656
+ severity: z23.string().optional(),
3657
+ description: z23.string().optional()
3903
3658
  }).passthrough()
3904
3659
  ).optional()
3905
3660
  }).passthrough(),
3906
3661
  // ── Environment setup / start command ─────────────────────────────────
3907
- z22.object({ type: z22.literal("setup_output"), stream: z22.string(), data: z22.string() }).passthrough(),
3908
- z22.object({
3909
- type: z22.literal("setup_complete"),
3910
- startCommandRunning: z22.boolean().optional(),
3911
- startCommandConfigured: z22.boolean().optional(),
3662
+ z23.object({ type: z23.literal("setup_output"), stream: z23.string(), data: z23.string() }).passthrough(),
3663
+ z23.object({
3664
+ type: z23.literal("setup_complete"),
3665
+ startCommandRunning: z23.boolean().optional(),
3666
+ startCommandConfigured: z23.boolean().optional(),
3912
3667
  // Sanitized server-side by sanitizeSessionPreviewPorts — stays unknown.
3913
- previewPorts: z22.unknown().optional()
3668
+ previewPorts: z23.unknown().optional()
3914
3669
  }).passthrough(),
3915
- z22.object({ type: z22.literal("setup_error"), message: z22.string() }).passthrough(),
3916
- z22.object({ type: z22.literal("start_command_started") }).passthrough(),
3917
- z22.object({ type: z22.literal("start_command_output"), stream: z22.string(), data: z22.string() }).passthrough(),
3918
- z22.object({
3919
- type: z22.literal("start_command_exited"),
3920
- code: z22.number().nullable().optional(),
3921
- signal: z22.string().nullable().optional(),
3922
- message: z22.string().optional()
3670
+ z23.object({ type: z23.literal("setup_error"), message: z23.string() }).passthrough(),
3671
+ z23.object({ type: z23.literal("start_command_started") }).passthrough(),
3672
+ z23.object({ type: z23.literal("start_command_output"), stream: z23.string(), data: z23.string() }).passthrough(),
3673
+ z23.object({
3674
+ type: z23.literal("start_command_exited"),
3675
+ code: z23.number().nullable().optional(),
3676
+ signal: z23.string().nullable().optional(),
3677
+ message: z23.string().optional()
3923
3678
  }).passthrough(),
3924
- z22.object({ type: z22.literal("start_command_error"), message: z22.string() }).passthrough()
3679
+ z23.object({ type: z23.literal("start_command_error"), message: z23.string() }).passthrough()
3925
3680
  ]);
3926
- var AgentEventSchema = z22.union([
3681
+ var AgentEventSchema = z23.union([
3927
3682
  KnownAgentEventSchema,
3928
- z22.object({ type: z22.string().min(1) }).catchall(z22.unknown())
3683
+ z23.object({ type: z23.string().min(1) }).catchall(z23.unknown())
3929
3684
  ]);
3930
3685
  var cardDescription = z32.string().max(CARD_DESCRIPTION_MAX, CARD_DESCRIPTION_LIMIT_MESSAGE).optional();
3931
3686
  var AgentHeartbeatSchema = z32.object({
@@ -4042,7 +3797,7 @@ var StoreSessionIdRequestSchema = z32.object({
4042
3797
  });
4043
3798
  var SetManualTestsRequestSchema = z32.object({
4044
3799
  sessionId: z32.string(),
4045
- items: z32.array(z32.object({ title: z32.string().min(1) })).min(1)
3800
+ items: ManualTestItemsSchema
4046
3801
  });
4047
3802
  var EditManualTestRequestSchema = z32.object({
4048
3803
  sessionId: z32.string(),
@@ -4505,6 +4260,11 @@ var ListProjectTasksRequestSchema = z52.object({
4505
4260
  // Scope to a sub-project board when provided. Unlike the board layer's `?? null`
4506
4261
  // semantics, agents default to seeing the whole project when omitted.
4507
4262
  subProjectId: z52.string().nullable().optional(),
4263
+ // Plain equality on the on-hold flag: true = only parked cards, false =
4264
+ // exclude them, omitted = both. Deliberately NOT the board's
4265
+ // includeOnHold/surfaceActiveWork bucketing — an agent sweeping a backlog
4266
+ // needs the raw column, not a column projection.
4267
+ onHold: z52.boolean().optional(),
4508
4268
  limit: z52.number().int().positive().optional().default(50)
4509
4269
  }).refine((p) => !(p.unassigned && p.assigneeId), {
4510
4270
  message: "Pass either assigneeId or unassigned, not both"
@@ -4539,7 +4299,9 @@ var SearchProjectTasksRequestSchema = z52.object({
4539
4299
  message: "Pass either assigneeId or unassigned, not both"
4540
4300
  });
4541
4301
  var ListProjectTagsRequestSchema = z52.object({
4542
- projectId: z52.string()
4302
+ projectId: z52.string(),
4303
+ /** "summary" (default) omits inline context links; "full" includes them. */
4304
+ detail: z52.enum(["summary", "full"]).optional()
4543
4305
  });
4544
4306
  var GetProjectTagRequestSchema = z52.object({
4545
4307
  projectId: z52.string(),
@@ -4642,11 +4404,15 @@ var UpdateProjectTaskRequestSchema = z52.object({
4642
4404
  // handler: the ref must exist on origin and no live workspace may be bound
4643
4405
  // to a different branch.
4644
4406
  githubBranch: z52.string().min(1).max(GIT_BRANCH_NAME_MAX).refine(isValidGitBranchName, { message: GIT_BRANCH_NAME_MESSAGE }).nullable().optional(),
4407
+ // Park the card on hold (true) or return it to the active board (false).
4408
+ // The handler mirrors the web path's two side effects: a board re-bucket
4409
+ // event, and demotion to Open when an active-work card is parked.
4410
+ onHold: z52.boolean().optional(),
4645
4411
  requestingUserId: z52.string().optional()
4646
4412
  }).strict().refine(
4647
- (v) => v.title !== void 0 || v.description !== void 0 || v.plan !== void 0 || v.status !== void 0 || v.risk !== void 0 || v.storyPointValue !== void 0 || v.assignedUserId !== void 0 || v.subProjectId !== void 0 || v.githubBranch !== void 0,
4413
+ (v) => v.title !== void 0 || v.description !== void 0 || v.plan !== void 0 || v.status !== void 0 || v.risk !== void 0 || v.storyPointValue !== void 0 || v.assignedUserId !== void 0 || v.subProjectId !== void 0 || v.githubBranch !== void 0 || v.onHold !== void 0,
4648
4414
  {
4649
- message: "update_task requires at least one field to change (title, description, plan, status, risk, storyPointValue, assignedUserId, subProjectId, or githubBranch)"
4415
+ message: "update_task requires at least one field to change (title, description, plan, status, risk, storyPointValue, assignedUserId, subProjectId, githubBranch, or onHold)"
4650
4416
  }
4651
4417
  );
4652
4418
  var TransitionProjectTaskStatusRequestSchema = z52.object({
@@ -4967,7 +4733,7 @@ var QueryProjectManualTestsRequestSchema = z52.object({
4967
4733
  var SetProjectManualTestsRequestSchema = z52.object({
4968
4734
  projectId: z52.string(),
4969
4735
  taskId: z52.string(),
4970
- items: z52.array(z52.object({ title: z52.string().min(1) })).min(1),
4736
+ items: ManualTestItemsSchema,
4971
4737
  requestingUserId: z52.string().optional()
4972
4738
  });
4973
4739
  var EditProjectManualTestRequestSchema = z52.object({
@@ -5046,170 +4812,134 @@ var ReportApiOutageRequestSchema = z72.object({
5046
4812
  detail: z72.string().max(2e3),
5047
4813
  attempts: z72.number().int().min(0).max(100)
5048
4814
  });
5049
- var SHA_PATTERN = /^[0-9a-f]{40}$/i;
5050
- var ReviewGuideFileReferenceSchema = z82.object({
5051
- path: z82.string().min(1).max(500),
5052
- startLine: z82.number().int().positive().max(1e6).optional(),
5053
- endLine: z82.number().int().positive().max(1e6).optional(),
5054
- hunkHeader: z82.string().min(1).max(300).optional()
5055
- }).strict().superRefine((value, ctx) => {
5056
- if (value.endLine !== void 0 && value.startLine === void 0) {
5057
- ctx.addIssue({
5058
- code: "custom",
5059
- path: ["startLine"],
5060
- message: "startLine is required when endLine is set"
5061
- });
5062
- }
5063
- if (value.startLine !== void 0 && value.endLine !== void 0 && value.endLine < value.startLine) {
5064
- ctx.addIssue({
5065
- code: "custom",
5066
- path: ["endLine"],
5067
- message: "endLine must be greater than or equal to startLine"
5068
- });
5069
- }
5070
- });
5071
- var ReviewGuideSectionSchema = z82.object({
5072
- title: z82.string().min(1).max(160),
5073
- explanation: z82.string().min(1).max(2e3),
5074
- classification: z82.enum(["core", "supporting"]).optional(),
5075
- files: z82.array(ReviewGuideFileReferenceSchema).min(1).max(20)
5076
- }).strict();
5077
- var ReviewGuideContentSchema = z82.object({
5078
- overview: z82.string().min(1).max(3e3),
5079
- sections: z82.array(ReviewGuideSectionSchema).min(1).max(12)
5080
- }).strict();
5081
- var PublishReviewGuideRequestSchema = ReviewGuideContentSchema.extend({
5082
- sessionId: z82.string().min(1),
5083
- reviewedSha: z82.string().regex(SHA_PATTERN, "reviewedSha must be a 40-character commit SHA")
5084
- }).strict();
5085
4815
  var CONTEXT_LINK_LOCATOR_MAX2 = 300;
5086
4816
  var TAG_DESCRIPTION_MAX = CARD_DESCRIPTION_MAX;
5087
4817
  var TAG_OVERVIEW_MAX = 32e3;
5088
4818
  var TAG_REASON_MAX = 500;
5089
- var ProjectTagContextPathSchema = z92.object({
5090
- type: z92.enum(["rule", "doc", "file", "folder"]),
5091
- path: z92.string().min(1).max(500),
5092
- label: z92.string().max(100).optional(),
4819
+ var ProjectTagContextPathSchema = z82.object({
4820
+ type: z82.enum(["rule", "doc", "file", "folder"]),
4821
+ path: z82.string().min(1).max(500),
4822
+ label: z82.string().max(100).optional(),
5093
4823
  /** Verified-link tether — text that must keep existing in the file. */
5094
- locator: z92.string().min(1).max(CONTEXT_LINK_LOCATOR_MAX2).regex(/^[^\r\n]*$/, "Locator cannot contain line breaks").optional(),
4824
+ locator: z82.string().min(1).max(CONTEXT_LINK_LOCATOR_MAX2).regex(/^[^\r\n]*$/, "Locator cannot contain line breaks").optional(),
5095
4825
  /** test = must appear in a real test/describe title; code = any substring. */
5096
- locatorType: z92.enum(["test", "code"]).optional()
4826
+ locatorType: z82.enum(["test", "code"]).optional()
5097
4827
  }).refine((link) => link.locator === void 0 === (link.locatorType === void 0), {
5098
4828
  message: "locator and locatorType must be provided together"
5099
4829
  }).refine((link) => link.locator === void 0 || link.type !== "folder", {
5100
4830
  message: "folder links cannot carry a locator"
5101
4831
  });
5102
- var hexColor = z92.string().regex(/^#[0-9a-fA-F]{6}$/, "Expected #RRGGBB hex color");
5103
- var overviewPathSchema = z92.string().min(1).max(500).regex(/^[^\r\n]*$/, "Overview path cannot contain line breaks");
5104
- var CreateProjectTagRequestSchema = z92.object({
5105
- projectId: z92.string(),
5106
- name: z92.string().min(1).max(50),
4832
+ var hexColor = z82.string().regex(/^#[0-9a-fA-F]{6}$/, "Expected #RRGGBB hex color");
4833
+ var overviewPathSchema = z82.string().min(1).max(500).regex(/^[^\r\n]*$/, "Overview path cannot contain line breaks");
4834
+ var CreateProjectTagRequestSchema = z82.object({
4835
+ projectId: z82.string(),
4836
+ name: z82.string().min(1).max(50),
5107
4837
  color: hexColor.optional(),
5108
- description: z92.string().max(TAG_DESCRIPTION_MAX).optional(),
5109
- overview: z92.string().max(TAG_OVERVIEW_MAX).optional(),
4838
+ description: z82.string().max(TAG_DESCRIPTION_MAX).optional(),
4839
+ overview: z82.string().max(TAG_OVERVIEW_MAX).optional(),
5110
4840
  /** Source the overview from this repo file (stored overview stays as the pending fallback). */
5111
4841
  overviewPath: overviewPathSchema.optional(),
5112
- contextPaths: z92.array(ProjectTagContextPathSchema).max(20).optional(),
4842
+ contextPaths: z82.array(ProjectTagContextPathSchema).max(20).optional(),
5113
4843
  /** Parents to link at create time (multi-parent DAG). */
5114
- parentTagIds: z92.array(z92.string()).max(25).optional(),
5115
- requestingUserId: z92.string().optional()
4844
+ parentTagIds: z82.array(z82.string()).max(25).optional(),
4845
+ requestingUserId: z82.string().optional()
5116
4846
  });
5117
- var UpdateProjectTagRequestSchema = z92.object({
5118
- projectId: z92.string(),
5119
- tagId: z92.string(),
5120
- name: z92.string().min(1).max(50).optional(),
4847
+ var UpdateProjectTagRequestSchema = z82.object({
4848
+ projectId: z82.string(),
4849
+ tagId: z82.string(),
4850
+ name: z82.string().min(1).max(50).optional(),
5121
4851
  color: hexColor.optional(),
5122
- description: z92.string().max(TAG_DESCRIPTION_MAX).optional(),
4852
+ description: z82.string().max(TAG_DESCRIPTION_MAX).optional(),
5123
4853
  /** Full markdown glossary body; null clears it. Rejected while overviewPath is set. */
5124
- overview: z92.string().max(TAG_OVERVIEW_MAX).nullable().optional(),
4854
+ overview: z82.string().max(TAG_OVERVIEW_MAX).nullable().optional(),
5125
4855
  /** Repo file to source the overview from; null clears back to the stored overview. */
5126
4856
  overviewPath: overviewPathSchema.nullable().optional(),
5127
4857
  /** Full replacement of the tag's context links when provided. */
5128
- contextPaths: z92.array(ProjectTagContextPathSchema).max(20).optional(),
4858
+ contextPaths: z82.array(ProjectTagContextPathSchema).max(20).optional(),
5129
4859
  /** Full-set replacement of the tag's parent tags (multi-parent DAG). */
5130
- parentTagIds: z92.array(z92.string()).max(25).optional(),
4860
+ parentTagIds: z82.array(z82.string()).max(25).optional(),
5131
4861
  /** One-line revision provenance, recorded in the tag's history. */
5132
- reason: z92.string().max(TAG_REASON_MAX).optional(),
4862
+ reason: z82.string().max(TAG_REASON_MAX).optional(),
5133
4863
  /** Card the caller was working in — stamped into the revision history. */
5134
- taskId: z92.string().optional(),
5135
- requestingUserId: z92.string().optional()
4864
+ taskId: z82.string().optional(),
4865
+ requestingUserId: z82.string().optional()
5136
4866
  });
5137
- var PostToProjectChatRequestSchema = z92.object({
5138
- projectId: z92.string(),
5139
- content: z92.string().min(1).max(2e4),
5140
- requestingUserId: z92.string().optional(),
4867
+ var PostToProjectChatRequestSchema = z82.object({
4868
+ projectId: z82.string(),
4869
+ content: z82.string().min(1).max(2e4),
4870
+ requestingUserId: z82.string().optional(),
5141
4871
  /** Marks the post so the server can persist it beyond chat (tag-audit summaries land in tag history). */
5142
- kind: z92.enum(["tag_audit_summary"]).optional()
5143
- });
5144
- var StartTagAuditRequestSchema = z92.object({
5145
- projectId: z92.string(),
5146
- requestingUserId: z92.string().optional()
5147
- });
5148
- var StartTaskAuditRequestSchema = z92.object({
5149
- projectId: z92.string(),
5150
- taskIds: z92.array(z92.string()).min(1).max(20),
5151
- requestingUserId: z92.string().optional()
5152
- });
5153
- var GetActiveAuditSessionsRequestSchema = z92.object({
5154
- projectId: z92.string()
5155
- });
5156
- var ReportTaskAuditResultRequestSchema = z92.object({
5157
- projectId: z92.string(),
5158
- taskId: z92.string(),
5159
- summary: z92.string(),
5160
- turnGrades: z92.array(
5161
- z92.object({
5162
- turnIndex: z92.number(),
5163
- phase: z92.enum(["planning", "building", "human"]),
5164
- grade: z92.enum(["correct", "neutral", "blunder"]),
5165
- reasoning: z92.string(),
5166
- eventType: z92.string(),
5167
- eventSummary: z92.string()
4872
+ kind: z82.enum(["tag_audit_summary"]).optional()
4873
+ });
4874
+ var StartTagAuditRequestSchema = z82.object({
4875
+ projectId: z82.string(),
4876
+ requestingUserId: z82.string().optional()
4877
+ });
4878
+ var StartTaskAuditRequestSchema = z82.object({
4879
+ projectId: z82.string(),
4880
+ taskIds: z82.array(z82.string()).min(1).max(20),
4881
+ requestingUserId: z82.string().optional()
4882
+ });
4883
+ var GetActiveAuditSessionsRequestSchema = z82.object({
4884
+ projectId: z82.string()
4885
+ });
4886
+ var ReportTaskAuditResultRequestSchema = z82.object({
4887
+ projectId: z82.string(),
4888
+ taskId: z82.string(),
4889
+ summary: z82.string(),
4890
+ turnGrades: z82.array(
4891
+ z82.object({
4892
+ turnIndex: z82.number(),
4893
+ phase: z82.enum(["planning", "building", "human"]),
4894
+ grade: z82.enum(["correct", "neutral", "blunder"]),
4895
+ reasoning: z82.string(),
4896
+ eventType: z82.string(),
4897
+ eventSummary: z82.string()
5168
4898
  })
5169
4899
  ),
5170
- planningAccuracy: z92.number().nullable(),
5171
- buildingAccuracy: z92.number().nullable(),
5172
- humanAccuracy: z92.number().nullable(),
5173
- planningCorrect: z92.number(),
5174
- planningNeutral: z92.number(),
5175
- planningBlunder: z92.number(),
5176
- buildingCorrect: z92.number(),
5177
- buildingNeutral: z92.number(),
5178
- buildingBlunder: z92.number(),
5179
- humanCorrect: z92.number(),
5180
- humanNeutral: z92.number(),
5181
- humanBlunder: z92.number(),
5182
- humanEvaluations: z92.array(
5183
- z92.object({
5184
- messageIndex: z92.number(),
5185
- rating: z92.union([z92.literal(-1), z92.literal(0), z92.literal(1)]),
5186
- reasoning: z92.string()
4900
+ planningAccuracy: z82.number().nullable(),
4901
+ buildingAccuracy: z82.number().nullable(),
4902
+ humanAccuracy: z82.number().nullable(),
4903
+ planningCorrect: z82.number(),
4904
+ planningNeutral: z82.number(),
4905
+ planningBlunder: z82.number(),
4906
+ buildingCorrect: z82.number(),
4907
+ buildingNeutral: z82.number(),
4908
+ buildingBlunder: z82.number(),
4909
+ humanCorrect: z82.number(),
4910
+ humanNeutral: z82.number(),
4911
+ humanBlunder: z82.number(),
4912
+ humanEvaluations: z82.array(
4913
+ z82.object({
4914
+ messageIndex: z82.number(),
4915
+ rating: z82.union([z82.literal(-1), z82.literal(0), z82.literal(1)]),
4916
+ reasoning: z82.string()
5187
4917
  })
5188
4918
  ).optional(),
5189
- suggestionIds: z92.array(z92.string()),
5190
- auditCostUsd: z92.number().nullable(),
5191
- model: z92.string().nullable(),
4919
+ suggestionIds: z82.array(z82.string()),
4920
+ auditCostUsd: z82.number().nullable(),
4921
+ model: z82.string().nullable(),
5192
4922
  /** When set, the audit is marked failed with this message instead. */
5193
- error: z92.string().optional()
4923
+ error: z82.string().optional()
5194
4924
  });
5195
- var GetTaskAuditsRequestSchema = z92.object({
5196
- projectId: z92.string(),
5197
- limit: z92.number().int().positive().max(200).optional().default(50)
4925
+ var GetTaskAuditsRequestSchema = z82.object({
4926
+ projectId: z82.string(),
4927
+ limit: z82.number().int().positive().max(200).optional().default(50)
5198
4928
  });
5199
- var GetTaskAuditRequestSchema = z92.object({
5200
- projectId: z92.string(),
5201
- auditId: z92.string()
4929
+ var GetTaskAuditRequestSchema = z82.object({
4930
+ projectId: z82.string(),
4931
+ auditId: z82.string()
5202
4932
  });
5203
- var GetTaskAuditAggregatesRequestSchema = z92.object({
5204
- projectId: z92.string()
4933
+ var GetTaskAuditAggregatesRequestSchema = z82.object({
4934
+ projectId: z82.string()
5205
4935
  });
5206
- var DeleteTaskAuditRequestSchema = z92.object({
5207
- projectId: z92.string(),
5208
- auditId: z92.string(),
5209
- requestingUserId: z92.string().optional()
4936
+ var DeleteTaskAuditRequestSchema = z82.object({
4937
+ projectId: z82.string(),
4938
+ auditId: z82.string(),
4939
+ requestingUserId: z82.string().optional()
5210
4940
  });
5211
- var MarkInitialPromptSubmittedRequestSchema = z92.object({
5212
- sessionId: z92.string()
4941
+ var MarkInitialPromptSubmittedRequestSchema = z82.object({
4942
+ sessionId: z82.string()
5213
4943
  });
5214
4944
  var DECISION_STATUS_LABELS = ["Open", "Decided", "Cancelled"];
5215
4945
  var DECISION_OPTION_KINDS = ["current", "planned", "proposed"];
@@ -5224,166 +4954,272 @@ var DECISION_DEADLINE_MIN_HOURS = 1;
5224
4954
  var DECISION_DEADLINE_MAX_DAYS = 30;
5225
4955
  var DECISION_DEADLINE_MAX_HOURS = DECISION_DEADLINE_MAX_DAYS * 24;
5226
4956
  var DECISION_LIST_MAX_LIMIT = 200;
5227
- var decisionIdSchema = z102.string().cuid("Invalid decision ID");
5228
- var optionInputSchema = z102.object({
5229
- label: z102.string().min(1, "Option label is required").max(DECISION_OPTION_LABEL_MAX),
5230
- description: z102.string().min(1, "Describe the option as GIVEN / WHEN / THEN"),
5231
- kind: z102.enum(DECISION_OPTION_KINDS).optional()
4957
+ var decisionIdSchema = z92.string().cuid("Invalid decision ID");
4958
+ var optionInputSchema = z92.object({
4959
+ label: z92.string().min(1, "Option label is required").max(DECISION_OPTION_LABEL_MAX),
4960
+ description: z92.string().min(1, "Describe the option as GIVEN / WHEN / THEN"),
4961
+ kind: z92.enum(DECISION_OPTION_KINDS).optional()
5232
4962
  });
5233
- var optionsArraySchema = z102.array(optionInputSchema).min(DECISION_OPTIONS_MIN, `A decision needs at least ${DECISION_OPTIONS_MIN} options`).max(
4963
+ var optionsArraySchema = z92.array(optionInputSchema).min(DECISION_OPTIONS_MIN, `A decision needs at least ${DECISION_OPTIONS_MIN} options`).max(
5234
4964
  DECISION_OPTIONS_MAX,
5235
4965
  `A decision takes at most ${DECISION_OPTIONS_MAX} options \u2014 more than that means the question is not framed yet`
5236
4966
  );
5237
- var CreateDecisionRequestSchema = z102.object({
5238
- projectId: z102.string().cuid("Invalid project ID"),
4967
+ var CreateDecisionRequestSchema = z92.object({
4968
+ projectId: z92.string().cuid("Invalid project ID"),
5239
4969
  /** The question, as one plain sentence. */
5240
- title: z102.string().min(1, "A decision needs a question").max(DECISION_QUESTION_MAX),
5241
- description: z102.string().max(CARD_DESCRIPTION_MAX).optional(),
5242
- context: z102.string().min(1, "Context is required \u2014 say why this is being asked now"),
4970
+ title: z92.string().min(1, "A decision needs a question").max(DECISION_QUESTION_MAX),
4971
+ description: z92.string().max(CARD_DESCRIPTION_MAX).optional(),
4972
+ context: z92.string().min(1, "Context is required \u2014 say why this is being asked now"),
5243
4973
  options: optionsArraySchema,
5244
4974
  /** 1-based position of the option that wins on silence. */
5245
- defaultOptionOrdinal: z102.number().int().min(1).max(DECISION_OPTIONS_MAX),
5246
- deadlineHours: z102.number().min(DECISION_DEADLINE_MIN_HOURS).max(DECISION_DEADLINE_MAX_HOURS).optional(),
4975
+ defaultOptionOrdinal: z92.number().int().min(1).max(DECISION_OPTIONS_MAX),
4976
+ deadlineHours: z92.number().min(DECISION_DEADLINE_MIN_HOURS).max(DECISION_DEADLINE_MAX_HOURS).optional(),
5247
4977
  /** Cards this decision blocks, by cuid or slug. */
5248
- impactedCardRefs: z102.array(z102.string().min(1)).max(50).optional(),
5249
- tagNames: z102.array(z102.string().min(1)).max(10).optional(),
5250
- raisedByTaskId: z102.string().min(1).optional(),
5251
- raisedByPrNumber: z102.number().int().positive().optional()
4978
+ impactedCardRefs: z92.array(z92.string().min(1)).max(50).optional(),
4979
+ tagNames: z92.array(z92.string().min(1)).max(10).optional(),
4980
+ raisedByTaskId: z92.string().min(1).optional(),
4981
+ raisedByPrNumber: z92.number().int().positive().optional()
5252
4982
  });
5253
- var VoteDecisionRequestSchema = z102.object({
4983
+ var VoteDecisionRequestSchema = z92.object({
5254
4984
  decisionId: decisionIdSchema,
5255
- optionId: z102.string().cuid("Invalid option ID"),
5256
- reason: z102.string().max(DECISION_VOTE_REASON_MAX).optional(),
5257
- source: z102.enum(DECISION_VOTE_SOURCES).optional()
4985
+ optionId: z92.string().cuid("Invalid option ID"),
4986
+ reason: z92.string().max(DECISION_VOTE_REASON_MAX).optional(),
4987
+ source: z92.enum(DECISION_VOTE_SOURCES).optional()
5258
4988
  });
5259
- var RemoveDecisionVoteRequestSchema = z102.object({
4989
+ var RemoveDecisionVoteRequestSchema = z92.object({
5260
4990
  decisionId: decisionIdSchema
5261
4991
  });
5262
- var ResolveDecisionRequestSchema = z102.object({
4992
+ var ResolveDecisionRequestSchema = z92.object({
5263
4993
  decisionId: decisionIdSchema,
5264
- chosenOptionId: z102.string().cuid("Invalid option ID"),
5265
- resolution: z102.string().min(1, "A resolution is required \u2014 say what was decided").max(DECISION_RESOLUTION_MAX),
5266
- resolutionNotes: z102.string().optional()
4994
+ chosenOptionId: z92.string().cuid("Invalid option ID"),
4995
+ resolution: z92.string().min(1, "A resolution is required \u2014 say what was decided").max(DECISION_RESOLUTION_MAX),
4996
+ resolutionNotes: z92.string().optional()
5267
4997
  });
5268
- var CancelDecisionRequestSchema = z102.object({
4998
+ var CancelDecisionRequestSchema = z92.object({
5269
4999
  decisionId: decisionIdSchema,
5270
5000
  /** Why it is being dropped. Posted to the decision thread. */
5271
- reason: z102.string().max(DECISION_RESOLUTION_MAX).optional()
5001
+ reason: z92.string().max(DECISION_RESOLUTION_MAX).optional()
5272
5002
  });
5273
- var BulkDecisionIdsRequestSchema = z102.object({
5274
- projectId: z102.string().cuid("Invalid project ID"),
5275
- decisionIds: z102.array(z102.string().cuid()).min(1).max(200)
5003
+ var BulkDecisionIdsRequestSchema = z92.object({
5004
+ projectId: z92.string().cuid("Invalid project ID"),
5005
+ decisionIds: z92.array(z92.string().cuid()).min(1).max(200)
5276
5006
  });
5277
- var ReopenDecisionRequestSchema = z102.object({
5007
+ var ReopenDecisionRequestSchema = z92.object({
5278
5008
  decisionId: decisionIdSchema,
5279
- deadlineHours: z102.number().min(DECISION_DEADLINE_MIN_HOURS).max(DECISION_DEADLINE_MAX_HOURS).optional()
5009
+ deadlineHours: z92.number().min(DECISION_DEADLINE_MIN_HOURS).max(DECISION_DEADLINE_MAX_HOURS).optional()
5280
5010
  });
5281
- var UpdateDecisionRequestSchema = z102.object({
5011
+ var UpdateDecisionRequestSchema = z92.object({
5282
5012
  decisionId: decisionIdSchema,
5283
- title: z102.string().min(1).max(200).optional(),
5284
- description: z102.string().max(CARD_DESCRIPTION_MAX).optional(),
5285
- context: z102.string().min(1).optional(),
5286
- deadlineAt: z102.string().datetime().optional(),
5013
+ title: z92.string().min(1).max(200).optional(),
5014
+ description: z92.string().max(CARD_DESCRIPTION_MAX).optional(),
5015
+ context: z92.string().min(1).optional(),
5016
+ deadlineAt: z92.string().datetime().optional(),
5287
5017
  /** Only accepted while the decision has zero votes. */
5288
5018
  options: optionsArraySchema.optional(),
5289
- defaultOptionOrdinal: z102.number().int().min(1).max(DECISION_OPTIONS_MAX).optional(),
5290
- addImpactedCardRefs: z102.array(z102.string().min(1)).max(50).optional(),
5291
- removeImpactedCardIds: z102.array(z102.string().min(1)).max(50).optional()
5019
+ defaultOptionOrdinal: z92.number().int().min(1).max(DECISION_OPTIONS_MAX).optional(),
5020
+ addImpactedCardRefs: z92.array(z92.string().min(1)).max(50).optional(),
5021
+ removeImpactedCardIds: z92.array(z92.string().min(1)).max(50).optional()
5292
5022
  });
5293
- var GetDecisionRequestSchema = z102.object({
5023
+ var GetDecisionRequestSchema = z92.object({
5294
5024
  /** cuid or slug. A slug needs `projectId` to resolve unambiguously. */
5295
- decisionId: z102.string().min(1),
5296
- projectId: z102.string().cuid().optional()
5025
+ decisionId: z92.string().min(1),
5026
+ projectId: z92.string().cuid().optional()
5297
5027
  });
5298
- var ListDecisionsRequestSchema = z102.object({
5299
- projectId: z102.string().cuid("Invalid project ID"),
5300
- status: z102.enum(DECISION_STATUS_LABELS).optional(),
5028
+ var ListDecisionsRequestSchema = z92.object({
5029
+ projectId: z92.string().cuid("Invalid project ID"),
5030
+ status: z92.enum(DECISION_STATUS_LABELS).optional(),
5301
5031
  /** Tag name, not id — an agent knows the tag it is working under. */
5302
- tag: z102.string().min(1).optional(),
5032
+ tag: z92.string().min(1).optional(),
5303
5033
  /** Decisions that this card is blocked by (cuid or slug). */
5304
- cardId: z102.string().min(1).optional(),
5305
- query: z102.string().min(1).optional(),
5306
- limit: z102.number().int().min(1).max(DECISION_LIST_MAX_LIMIT).optional()
5307
- });
5308
- var optionInput = z11.object({
5309
- label: z11.string().min(1).max(DECISION_OPTION_LABEL_MAX),
5310
- description: z11.string().min(1),
5311
- kind: z11.enum(DECISION_OPTION_KINDS).optional()
5312
- });
5313
- var optionsInput = z11.array(optionInput).min(DECISION_OPTIONS_MIN).max(DECISION_OPTIONS_MAX);
5314
- var deadlineHours = z11.number().min(DECISION_DEADLINE_MIN_HOURS).max(DECISION_DEADLINE_MAX_HOURS).optional();
5315
- var CreateProjectDecisionRequestSchema = z11.object({
5316
- projectId: z11.string(),
5317
- question: z11.string().min(1).max(200),
5318
- summary: z11.string().max(CARD_DESCRIPTION_MAX).optional(),
5319
- context: z11.string().min(1),
5034
+ cardId: z92.string().min(1).optional(),
5035
+ query: z92.string().min(1).optional(),
5036
+ limit: z92.number().int().min(1).max(DECISION_LIST_MAX_LIMIT).optional()
5037
+ });
5038
+ var optionInput = z10.object({
5039
+ label: z10.string().min(1).max(DECISION_OPTION_LABEL_MAX),
5040
+ description: z10.string().min(1),
5041
+ kind: z10.enum(DECISION_OPTION_KINDS).optional()
5042
+ });
5043
+ var optionsInput = z10.array(optionInput).min(DECISION_OPTIONS_MIN).max(DECISION_OPTIONS_MAX);
5044
+ var deadlineHours = z10.number().min(DECISION_DEADLINE_MIN_HOURS).max(DECISION_DEADLINE_MAX_HOURS).optional();
5045
+ var CreateProjectDecisionRequestSchema = z10.object({
5046
+ projectId: z10.string(),
5047
+ question: z10.string().min(1).max(200),
5048
+ summary: z10.string().max(CARD_DESCRIPTION_MAX).optional(),
5049
+ context: z10.string().min(1),
5320
5050
  options: optionsInput,
5321
- defaultOption: z11.number().int().min(1).max(DECISION_OPTIONS_MAX),
5051
+ defaultOption: z10.number().int().min(1).max(DECISION_OPTIONS_MAX),
5322
5052
  deadlineHours,
5323
- impactedCards: z11.array(z11.string().min(1)).max(50).optional(),
5053
+ impactedCards: z10.array(z10.string().min(1)).max(50).optional(),
5324
5054
  /**
5325
5055
  * Pod surface only: also block the card this session is working on. The
5326
5056
  * session's task id is resolved SERVER-side from `sessionId` — a
5327
5057
  * client-supplied card id would let a pod block any card in the project.
5328
5058
  */
5329
- includeCurrentCard: z11.boolean().optional(),
5330
- sessionId: z11.string().optional(),
5331
- tagNames: z11.array(z11.string().min(1)).max(10).optional(),
5332
- raisedByPr: z11.number().int().positive().optional(),
5059
+ includeCurrentCard: z10.boolean().optional(),
5060
+ sessionId: z10.string().optional(),
5061
+ tagNames: z10.array(z10.string().min(1)).max(10).optional(),
5062
+ raisedByPr: z10.number().int().positive().optional(),
5333
5063
  /** Slug or id of the card that raised the question. A link back, not a block. */
5334
- raisedByCard: z11.string().min(1).optional(),
5064
+ raisedByCard: z10.string().min(1).optional(),
5335
5065
  /** Absolute deadline (ISO 8601). Wins over `deadlineHours` when both are sent. */
5336
- deadlineAt: z11.string().datetime({ offset: true }).optional(),
5337
- requestingUserId: z11.string().optional()
5338
- });
5339
- var ListProjectDecisionsRequestSchema = z11.object({
5340
- projectId: z11.string(),
5341
- status: z11.enum(DECISION_STATUS_LABELS).optional(),
5342
- tag: z11.string().min(1).optional(),
5343
- card: z11.string().min(1).optional(),
5344
- query: z11.string().min(1).optional(),
5345
- limit: z11.number().int().min(1).max(DECISION_LIST_MAX_LIMIT).optional(),
5346
- requestingUserId: z11.string().optional()
5347
- });
5348
- var GetProjectDecisionRequestSchema = z11.object({
5349
- projectId: z11.string(),
5350
- decision: z11.string().min(1),
5351
- requestingUserId: z11.string().optional()
5352
- });
5353
- var VoteProjectDecisionRequestSchema = z11.object({
5354
- projectId: z11.string(),
5355
- decision: z11.string().min(1),
5066
+ deadlineAt: z10.string().datetime({ offset: true }).optional(),
5067
+ requestingUserId: z10.string().optional()
5068
+ });
5069
+ var ListProjectDecisionsRequestSchema = z10.object({
5070
+ projectId: z10.string(),
5071
+ status: z10.enum(DECISION_STATUS_LABELS).optional(),
5072
+ tag: z10.string().min(1).optional(),
5073
+ card: z10.string().min(1).optional(),
5074
+ query: z10.string().min(1).optional(),
5075
+ limit: z10.number().int().min(1).max(DECISION_LIST_MAX_LIMIT).optional(),
5076
+ requestingUserId: z10.string().optional()
5077
+ });
5078
+ var GetProjectDecisionRequestSchema = z10.object({
5079
+ projectId: z10.string(),
5080
+ decision: z10.string().min(1),
5081
+ requestingUserId: z10.string().optional()
5082
+ });
5083
+ var VoteProjectDecisionRequestSchema = z10.object({
5084
+ projectId: z10.string(),
5085
+ decision: z10.string().min(1),
5356
5086
  /** An option id, or its 1-based position. */
5357
- option: z11.string().min(1),
5358
- reason: z11.string().max(CARD_DESCRIPTION_MAX).optional(),
5359
- requestingUserId: z11.string().optional()
5360
- });
5361
- var ResolveProjectDecisionRequestSchema = z11.object({
5362
- projectId: z11.string(),
5363
- decision: z11.string().min(1),
5364
- option: z11.string().min(1),
5365
- resolution: z11.string().min(1).max(DECISION_RESOLUTION_MAX),
5366
- notes: z11.string().optional(),
5367
- requestingUserId: z11.string().optional()
5368
- });
5369
- var UpdateProjectDecisionRequestSchema = z11.object({
5370
- projectId: z11.string(),
5371
- decision: z11.string().min(1),
5372
- question: z11.string().min(1).max(200).optional(),
5373
- summary: z11.string().max(CARD_DESCRIPTION_MAX).optional(),
5374
- context: z11.string().min(1).optional(),
5087
+ option: z10.string().min(1),
5088
+ reason: z10.string().max(CARD_DESCRIPTION_MAX).optional(),
5089
+ requestingUserId: z10.string().optional()
5090
+ });
5091
+ var ResolveProjectDecisionRequestSchema = z10.object({
5092
+ projectId: z10.string(),
5093
+ decision: z10.string().min(1),
5094
+ option: z10.string().min(1),
5095
+ resolution: z10.string().min(1).max(DECISION_RESOLUTION_MAX),
5096
+ notes: z10.string().optional(),
5097
+ requestingUserId: z10.string().optional()
5098
+ });
5099
+ var UpdateProjectDecisionRequestSchema = z10.object({
5100
+ projectId: z10.string(),
5101
+ decision: z10.string().min(1),
5102
+ question: z10.string().min(1).max(200).optional(),
5103
+ summary: z10.string().max(CARD_DESCRIPTION_MAX).optional(),
5104
+ context: z10.string().min(1).optional(),
5375
5105
  /** Accepted only while nobody has voted. */
5376
5106
  options: optionsInput.optional(),
5377
- defaultOption: z11.number().int().min(1).max(DECISION_OPTIONS_MAX).optional(),
5378
- tagNames: z11.array(z11.string().min(1)).max(10).optional(),
5107
+ defaultOption: z10.number().int().min(1).max(DECISION_OPTIONS_MAX).optional(),
5108
+ tagNames: z10.array(z10.string().min(1)).max(10).optional(),
5379
5109
  deadlineHours,
5380
5110
  /** Absolute deadline (ISO 8601). Wins over `deadlineHours` when both are sent. */
5381
- deadlineAt: z11.string().datetime({ offset: true }).optional(),
5382
- addImpactedCards: z11.array(z11.string().min(1)).max(50).optional(),
5383
- removeImpactedCards: z11.array(z11.string().min(1)).max(50).optional(),
5384
- status: z11.enum(["Cancelled", "Open"]).optional(),
5385
- requestingUserId: z11.string().optional()
5111
+ deadlineAt: z10.string().datetime({ offset: true }).optional(),
5112
+ addImpactedCards: z10.array(z10.string().min(1)).max(50).optional(),
5113
+ removeImpactedCards: z10.array(z10.string().min(1)).max(50).optional(),
5114
+ status: z10.enum(["Cancelled", "Open"]).optional(),
5115
+ requestingUserId: z10.string().optional()
5116
+ });
5117
+ function formatModelId(provider, model) {
5118
+ return `${provider}/${model}`;
5119
+ }
5120
+ var JEV_MODEL = "jev-1.13.0";
5121
+ var JEV_MODEL_ID = formatModelId("typesafe", JEV_MODEL);
5122
+ var JEV_INPUT_PRICE_PER_TOKEN = 0.042 / 1e6;
5123
+ var JEV_STATE_MAX_CHARS = 1e5;
5124
+ var EVALUATE_MAX_QUESTIONS = 32;
5125
+ var EVALUATE_MAX_ITEMS = 100;
5126
+ var EVALUATE_ITEM_MAX_CHARS = 8e3;
5127
+ var EVALUATE_REQUEST_MAX_CHARS = 4e5;
5128
+ var TEXT_MAX = 1e3;
5129
+ var QUESTION_KEY = /^[A-Za-z0-9_-]{1,64}$/;
5130
+ var EvaluateQuestionSchema = z11.object({
5131
+ key: z11.string().regex(QUESTION_KEY, "key must be 1-64 letters, digits, _ or -"),
5132
+ type: z11.enum(["noul", "choice", "score"]),
5133
+ instructions: z11.string().min(1).max(4e3),
5134
+ options: z11.array(
5135
+ z11.object({
5136
+ key: z11.string().min(1).max(200),
5137
+ description: z11.string().min(1).max(TEXT_MAX)
5138
+ })
5139
+ ).optional(),
5140
+ levels: z11.array(z11.string().min(1).max(TEXT_MAX)).optional()
5141
+ }).superRefine((q, ctx) => {
5142
+ if (q.type === "choice") {
5143
+ const n = q.options?.length ?? 0;
5144
+ if (n < 2 || n > 255) {
5145
+ ctx.addIssue({
5146
+ code: z11.ZodIssueCode.custom,
5147
+ path: ["options"],
5148
+ message: "a choice question needs 2-255 options"
5149
+ });
5150
+ } else if (new Set(q.options?.map((o) => o.key)).size !== n) {
5151
+ ctx.addIssue({
5152
+ code: z11.ZodIssueCode.custom,
5153
+ path: ["options"],
5154
+ message: "option keys must be unique"
5155
+ });
5156
+ }
5157
+ }
5158
+ if (q.type === "score") {
5159
+ const n = q.levels?.length ?? 0;
5160
+ if (n < 2 || n > 10) {
5161
+ ctx.addIssue({
5162
+ code: z11.ZodIssueCode.custom,
5163
+ path: ["levels"],
5164
+ message: "a score question needs 2-10 levels"
5165
+ });
5166
+ }
5167
+ }
5168
+ });
5169
+ var EvaluateQuestionsRequestSchema = z11.object({
5170
+ projectId: z11.string(),
5171
+ state: z11.string().max(JEV_STATE_MAX_CHARS).optional(),
5172
+ items: z11.array(z11.string().max(EVALUATE_ITEM_MAX_CHARS)).max(EVALUATE_MAX_ITEMS).optional(),
5173
+ questions: z11.array(EvaluateQuestionSchema).min(1).max(EVALUATE_MAX_QUESTIONS)
5174
+ }).superRefine((req, ctx) => {
5175
+ if (req.state === void 0 && (!req.items || req.items.length === 0)) {
5176
+ ctx.addIssue({
5177
+ code: z11.ZodIssueCode.custom,
5178
+ path: ["state"],
5179
+ message: "pass state, or a non-empty items array"
5180
+ });
5181
+ }
5182
+ if (JSON.stringify(req).length > EVALUATE_REQUEST_MAX_CHARS) {
5183
+ ctx.addIssue({
5184
+ code: z11.ZodIssueCode.custom,
5185
+ path: [],
5186
+ message: `the request is over ${EVALUATE_REQUEST_MAX_CHARS} characters; split the items across calls`
5187
+ });
5188
+ }
5189
+ if (new Set(req.questions.map((q) => q.key)).size !== req.questions.length) {
5190
+ ctx.addIssue({
5191
+ code: z11.ZodIssueCode.custom,
5192
+ path: ["questions"],
5193
+ message: "question keys must be unique"
5194
+ });
5195
+ }
5386
5196
  });
5197
+ var round3 = (n) => Math.round(n * 1e3) / 1e3;
5198
+ function compactAnswer(answer) {
5199
+ switch (answer.type) {
5200
+ case "noul":
5201
+ return round3(answer.noul);
5202
+ case "choice":
5203
+ return {
5204
+ choice: answer.choice,
5205
+ p: round3(answer.probabilities[answer.choice] ?? 0),
5206
+ confidence: round3(answer.confidence)
5207
+ };
5208
+ case "score":
5209
+ return { score: answer.score, confidence: round3(answer.confidence) };
5210
+ }
5211
+ }
5212
+ function formatEvaluateQuestionsResult(res) {
5213
+ const results = res.results.map(
5214
+ (r) => "error" in r ? { index: r.index, error: r.error } : {
5215
+ index: r.index,
5216
+ answers: Object.fromEntries(
5217
+ Object.entries(r.answers).map(([key, a]) => [key, compactAnswer(a)])
5218
+ )
5219
+ }
5220
+ );
5221
+ return JSON.stringify({ model: res.model, results });
5222
+ }
5387
5223
  var MEETING_CHECKLIST_TITLE_MAX = 300;
5388
5224
  var MEETING_TRANSCRIPT_MAX_CHARS = 2e6;
5389
5225
  var MEETING_TITLE_MAX = 200;
@@ -5520,9 +5356,6 @@ var UpdateProjectMeetingRequestSchema = z12.object({
5520
5356
  var TASK_CHAT_HISTORY_LIMIT = 20;
5521
5357
  var PM_CHAT_HISTORY_LIMIT = 40;
5522
5358
  var AGENT_CHAT_HISTORY_FETCH_LIMIT = Math.max(TASK_CHAT_HISTORY_LIMIT, PM_CHAT_HISTORY_LIMIT) + 10;
5523
- function formatModelId(provider, model) {
5524
- return `${provider}/${model}`;
5525
- }
5526
5359
  function anthropicEntry(model, label, inputPerMillion, outputPerMillion, opts = {}) {
5527
5360
  return {
5528
5361
  provider: "anthropic",
@@ -5861,45 +5694,390 @@ var BOARD_CARD_TYPES = surfaceTypes("board");
5861
5694
  var REPORT_CARD_TYPES = surfaceTypes("report");
5862
5695
  var DECISION_CARD_TYPES = surfaceTypes("decision");
5863
5696
 
5864
- // src/tools/logs.ts
5865
- function registerLogTools(server2, conn2) {
5866
- registerContractTool(server2, queryGcpLogsContract, async (params) => {
5867
- const text = await runQueryGcpLogs(conn2, params);
5868
- return { content: [{ type: "text", text }] };
5869
- });
5870
- registerContractTool(server2, queryGrafanaLogsContract, async (params) => {
5871
- const text = await runQueryGrafanaLogs(conn2, params);
5872
- return { content: [{ type: "text", text }] };
5873
- });
5697
+ // src/tools/checklists.ts
5698
+ function renderManualTestGroups(groups) {
5699
+ const lines = [];
5700
+ for (const g of groups) {
5701
+ lines.push(`## ${g.title} [${g.status}] (${g.slug})`);
5702
+ for (const t of g.tests) {
5703
+ const mark = t.status === "approved" ? "\u2713" : t.status === "rejected" ? "\u2717" : "\u25CB";
5704
+ lines.push(` ${mark} ${t.title} \u2014 ${t.status}`);
5705
+ if (t.status === "rejected") {
5706
+ for (const f2 of t.failures ?? []) {
5707
+ lines.push(` \u26A0 ${f2.userName ?? "Someone"}: ${f2.reason ?? "(no message)"}`);
5708
+ }
5709
+ }
5710
+ }
5711
+ lines.push("");
5712
+ }
5713
+ return lines.join("\n").trimEnd();
5874
5714
  }
5875
-
5876
- // src/tools/integrations.ts
5877
- function registerIntegrationTools(server2, conn2) {
5878
- registerContractTool(server2, listProjectIntegrationsContract, async (params) => {
5879
- const result = await conn2.listProjectIntegrations(params.projectId);
5880
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
5881
- });
5882
- registerContractTool(server2, listProjectChannelsContract, async (params) => {
5883
- const channels = await conn2.listProjectChannels(params.projectId);
5884
- if (channels.length === 0) {
5885
- return {
5886
- content: [
5887
- {
5888
- type: "text",
5889
- text: "No work channels are registered for this project. An admin registers them in project settings; until then no channel is reachable, whatever the bot can see in the workspace."
5890
- }
5891
- ]
5892
- };
5715
+ function registerListManualTests(server2, conn2) {
5716
+ registerContractTool(server2, listManualTestsContract, async (params) => {
5717
+ const items = await conn2.listManualTests(params.taskId, params.projectId);
5718
+ if (items.length === 0) {
5719
+ return { content: [{ type: "text", text: "No manual tests recorded for this task." }] };
5893
5720
  }
5894
- return { content: [{ type: "text", text: JSON.stringify(channels, null, 2) }] };
5721
+ const lines = items.flatMap((item, i) => {
5722
+ const checked = item.checked ? "[x]" : "[ ]";
5723
+ const row = [`${i + 1}. ${checked} ${item.title}`];
5724
+ for (const f2 of item.failures ?? []) {
5725
+ const who = f2.userName ?? "Someone";
5726
+ const reason = f2.reason ?? "(no message)";
5727
+ row.push(` \u26A0 Failed (${who}): ${reason}`);
5728
+ }
5729
+ return row;
5730
+ });
5731
+ return { content: [{ type: "text", text: lines.join("\n") }] };
5895
5732
  });
5896
- registerContractTool(server2, readChannelMessagesContract, async (params) => {
5897
- const result = await conn2.readChannelMessages(params);
5898
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
5733
+ }
5734
+ function registerSetManualTests(server2, conn2) {
5735
+ registerContractTool(server2, setManualTestsContract, async (params) => {
5736
+ const result = await conn2.setManualTests(params.taskId, params.items, params.projectId);
5737
+ const parts = [`Created ${result.created} manual test item(s).`];
5738
+ if (result.skipped > 0) parts.push(`Skipped ${result.skipped} duplicate(s).`);
5739
+ for (const item of result.rejected ?? []) parts.push(describeManualTestRejection(item));
5740
+ return { content: [{ type: "text", text: parts.join(" ") }] };
5899
5741
  });
5900
- registerContractTool(server2, getAnalyticsSummaryContract, async (params) => {
5901
- const res = await conn2.getProjectAnalyticsSummary(params);
5902
- if (!res.configured) {
5742
+ }
5743
+ function registerEditManualTest(server2, conn2) {
5744
+ registerContractTool(server2, editManualTestContract, async (params) => {
5745
+ await conn2.editManualTest(params.taskId, params.title, params.newTitle, params.projectId);
5746
+ return { content: [{ type: "text", text: `Updated manual test to "${params.newTitle}".` }] };
5747
+ });
5748
+ }
5749
+ function registerRemoveManualTest(server2, conn2) {
5750
+ registerContractTool(server2, removeManualTestContract, async (params) => {
5751
+ await conn2.removeManualTest(params.taskId, params.title, params.projectId);
5752
+ return { content: [{ type: "text", text: `Removed manual test "${params.title}".` }] };
5753
+ });
5754
+ }
5755
+ function registerApproveManualTest(server2, conn2) {
5756
+ registerContractTool(server2, approveManualTestContract, async (params) => {
5757
+ await conn2.approveManualTest(params.taskId, params.title, params.projectId);
5758
+ return { content: [{ type: "text", text: `Approved manual test "${params.title}".` }] };
5759
+ });
5760
+ }
5761
+ function registerRejectManualTest(server2, conn2) {
5762
+ registerContractTool(server2, rejectManualTestContract, async (params) => {
5763
+ await conn2.rejectManualTest(params.taskId, params.title, params.reason, params.projectId);
5764
+ return {
5765
+ content: [
5766
+ {
5767
+ type: "text",
5768
+ text: `Flagged an issue with manual test "${params.title}": ${params.reason}`
5769
+ }
5770
+ ]
5771
+ };
5772
+ });
5773
+ }
5774
+ function registerQueryManualTests(server2, conn2) {
5775
+ registerContractTool(server2, queryManualTestsContract, async (params) => {
5776
+ const groups = await conn2.queryManualTests({
5777
+ projectId: params.projectId,
5778
+ cardStatuses: params.cardStatuses,
5779
+ testStatuses: params.testStatuses
5780
+ });
5781
+ if (groups.length === 0) {
5782
+ return { content: [{ type: "text", text: "No manual tests match those filters." }] };
5783
+ }
5784
+ return { content: [{ type: "text", text: renderManualTestGroups(groups) }] };
5785
+ });
5786
+ }
5787
+ function registerChecklistTools(server2, conn2) {
5788
+ registerListManualTests(server2, conn2);
5789
+ registerQueryManualTests(server2, conn2);
5790
+ registerSetManualTests(server2, conn2);
5791
+ registerEditManualTest(server2, conn2);
5792
+ registerRemoveManualTest(server2, conn2);
5793
+ registerApproveManualTest(server2, conn2);
5794
+ registerRejectManualTest(server2, conn2);
5795
+ }
5796
+
5797
+ // src/tools/workspace.ts
5798
+ import { z as z13 } from "zod";
5799
+
5800
+ // src/workspace-ssh-tunnel.ts
5801
+ import net from "net";
5802
+ import { once } from "events";
5803
+ import { WebSocket } from "ws";
5804
+ var WORKSPACE_TUNNEL_HEARTBEAT_MS = 3e4;
5805
+ function withPort(url, port) {
5806
+ const parsed = new URL(url);
5807
+ parsed.searchParams.set("port", String(port));
5808
+ return parsed.toString();
5809
+ }
5810
+ function toBuffer(data) {
5811
+ if (Buffer.isBuffer(data)) return data;
5812
+ if (data instanceof ArrayBuffer) return Buffer.from(data);
5813
+ return Buffer.concat(data);
5814
+ }
5815
+ function startHeartbeat(ws) {
5816
+ const timer = setInterval(() => {
5817
+ if (ws.readyState === WebSocket.OPEN) ws.ping();
5818
+ }, WORKSPACE_TUNNEL_HEARTBEAT_MS);
5819
+ timer.unref?.();
5820
+ return () => clearInterval(timer);
5821
+ }
5822
+ function bridgeClient(client, options) {
5823
+ let ws = null;
5824
+ let ready = false;
5825
+ const pending = [];
5826
+ client.on("data", (data) => {
5827
+ const chunk = Buffer.isBuffer(data) ? data : Buffer.from(data);
5828
+ if (ready && ws && ws.readyState === WebSocket.OPEN) ws.send(chunk);
5829
+ else pending.push(chunk);
5830
+ });
5831
+ client.on("close", () => ws?.close());
5832
+ client.on("error", () => ws?.close());
5833
+ options.resolveTarget().then(({ tunnelUrl, attachToken }) => {
5834
+ const socket = new WebSocket(withPort(tunnelUrl, options.remotePort), {
5835
+ headers: { "x-workspace-attach-token": attachToken }
5836
+ });
5837
+ ws = socket;
5838
+ const stopHeartbeat = startHeartbeat(socket);
5839
+ socket.on("message", (data) => {
5840
+ const chunk = toBuffer(data);
5841
+ if (!ready) {
5842
+ const text = chunk.toString("utf8");
5843
+ if (text === JSON.stringify({ ok: true })) {
5844
+ ready = true;
5845
+ for (const buffered of pending.splice(0)) socket.send(buffered);
5846
+ return;
5847
+ }
5848
+ client.destroy(new Error(`Workspace tunnel rejected connection: ${text}`));
5849
+ socket.close();
5850
+ return;
5851
+ }
5852
+ client.write(chunk);
5853
+ });
5854
+ socket.on("close", () => {
5855
+ stopHeartbeat();
5856
+ client.destroy();
5857
+ });
5858
+ socket.on("error", (err) => {
5859
+ stopHeartbeat();
5860
+ client.destroy(err);
5861
+ });
5862
+ }).catch((err) => {
5863
+ client.destroy(err instanceof Error ? err : new Error(String(err)));
5864
+ });
5865
+ }
5866
+ async function startWorkspaceSshTunnel(options) {
5867
+ const host = options.host ?? "127.0.0.1";
5868
+ const server2 = net.createServer((client) => bridgeClient(client, options));
5869
+ const ac = new AbortController();
5870
+ server2.listen(options.preferredLocalPort ?? 0, host);
5871
+ try {
5872
+ await Promise.race([
5873
+ once(server2, "listening", { signal: ac.signal }),
5874
+ once(server2, "error", { signal: ac.signal }).then(([err]) => {
5875
+ throw err instanceof Error ? err : new Error(String(err));
5876
+ })
5877
+ ]);
5878
+ } catch (err) {
5879
+ server2.close();
5880
+ throw new Error(
5881
+ `Failed to bind workspace SSH tunnel: ${err instanceof Error ? err.message : String(err)}`,
5882
+ { cause: err }
5883
+ );
5884
+ } finally {
5885
+ ac.abort();
5886
+ }
5887
+ const address = server2.address();
5888
+ if (!address || typeof address === "string") {
5889
+ server2.close();
5890
+ throw new Error("Failed to bind workspace SSH tunnel");
5891
+ }
5892
+ return {
5893
+ host,
5894
+ port: address.port,
5895
+ close: () => new Promise((resolve, reject) => {
5896
+ server2.close((err) => {
5897
+ if (err) reject(err);
5898
+ else resolve();
5899
+ });
5900
+ })
5901
+ };
5902
+ }
5903
+
5904
+ // src/tools/workspace.ts
5905
+ var activeTunnels = /* @__PURE__ */ new Map();
5906
+ function createTunnelId(taskId, port) {
5907
+ return `${taskId}:${port}:${Date.now().toString(36)}:${Math.random().toString(36).slice(2, 8)}`;
5908
+ }
5909
+ function localUrlFor(port, host, localPort) {
5910
+ if (port === 2222) return void 0;
5911
+ return `http://${host}:${localPort}`;
5912
+ }
5913
+ function registerAttachInfoTool(server2, conn2) {
5914
+ server2.tool(
5915
+ "workspace_attach_info",
5916
+ "Return SSH/SFTP attach metadata for a running task Claudespace, plus hosted preview URLs and configured preview ports. Optionally installs an OpenSSH public key for this attach session.",
5917
+ {
5918
+ taskId: z13.string().describe("The task ID"),
5919
+ sshPublicKey: z13.string().optional().describe("Optional OpenSSH public key to install into the workspace")
5920
+ },
5921
+ async ({ taskId, sshPublicKey }) => {
5922
+ const info = await conn2.getWorkspaceAttachInfo(taskId, sshPublicKey);
5923
+ return { content: [{ type: "text", text: JSON.stringify(info, null, 2) }] };
5924
+ }
5925
+ );
5926
+ }
5927
+ function registerPreviewUrlsTool(server2, conn2) {
5928
+ server2.tool(
5929
+ "workspace_preview_urls",
5930
+ "Return the hosted preview URLs and preview ports for a running task Claudespace. This mirrors the web UI preview link metadata.",
5931
+ {
5932
+ taskId: z13.string().describe("The task ID")
5933
+ },
5934
+ async ({ taskId }) => {
5935
+ const info = await conn2.getWorkspaceAttachInfo(taskId);
5936
+ return {
5937
+ content: [
5938
+ {
5939
+ type: "text",
5940
+ text: JSON.stringify(
5941
+ {
5942
+ taskId: info.taskId,
5943
+ sessionId: info.sessionId,
5944
+ previewPorts: info.previewPorts,
5945
+ previewUrls: info.previewUrls
5946
+ },
5947
+ null,
5948
+ 2
5949
+ )
5950
+ }
5951
+ ]
5952
+ };
5953
+ }
5954
+ );
5955
+ }
5956
+ function registerStartTunnelTool(server2, conn2, startTunnel) {
5957
+ server2.tool(
5958
+ "workspace_start_tunnel",
5959
+ "Start a local loopback tunnel through the MCP server to a running task Claudespace port. Use port 2222 for SSH/SFTP, or one of previewPorts for app access.",
5960
+ {
5961
+ taskId: z13.string().describe("The task ID"),
5962
+ port: z13.number().optional().describe("Remote Claudespace port. Defaults to SSH port 2222."),
5963
+ preferredLocalPort: z13.number().optional().describe("Preferred local loopback port. If omitted, the OS chooses one."),
5964
+ sshPublicKey: z13.string().optional().describe("Optional OpenSSH public key to install before opening the tunnel")
5965
+ },
5966
+ async ({ taskId, port, preferredLocalPort, sshPublicKey }) => {
5967
+ const info = await conn2.getWorkspaceAttachInfo(taskId, sshPublicKey);
5968
+ if (!info.tunnelUrl || !info.attachToken) {
5969
+ throw new Error(
5970
+ "Workspace tunnels are unavailable for this task (GitHub Codespace-backed environments expose previews only \u2014 use workspace_preview_urls)."
5971
+ );
5972
+ }
5973
+ const remotePort = port ?? info.ssh?.remotePort ?? 2222;
5974
+ const handle = await startTunnel({
5975
+ remotePort,
5976
+ preferredLocalPort,
5977
+ // Re-mint per connection so the tunnel outlives the attach-token TTL.
5978
+ // The key (if any) is already installed by the call above; the refetch
5979
+ // only needs a fresh token, so it omits sshPublicKey.
5980
+ resolveTarget: async () => {
5981
+ const fresh = await conn2.getWorkspaceAttachInfo(taskId);
5982
+ if (!fresh.tunnelUrl || !fresh.attachToken)
5983
+ throw new Error("Workspace tunnel target is no longer available");
5984
+ return { tunnelUrl: fresh.tunnelUrl, attachToken: fresh.attachToken };
5985
+ }
5986
+ });
5987
+ const tunnelId = createTunnelId(taskId, remotePort);
5988
+ activeTunnels.set(tunnelId, handle);
5989
+ return {
5990
+ content: [
5991
+ {
5992
+ type: "text",
5993
+ text: JSON.stringify(
5994
+ {
5995
+ tunnelId,
5996
+ taskId,
5997
+ remotePort,
5998
+ localHost: handle.host,
5999
+ localPort: handle.port,
6000
+ localUrl: localUrlFor(remotePort, handle.host, handle.port),
6001
+ // `-o ServerAliveInterval=30` drives client-side keepalives so an
6002
+ // idle session keeps the tunnel warm (the tunnel layer pings too,
6003
+ // but the client must keep its own TCP path alive across every hop).
6004
+ sshCommand: remotePort === 2222 ? `ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -p ${handle.port} ${info.ssh?.username ?? "conveyor"}@${handle.host}` : void 0,
6005
+ sftpCommand: remotePort === 2222 ? `sftp -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -P ${handle.port} ${info.ssh?.username ?? "conveyor"}@${handle.host}` : void 0,
6006
+ previewPorts: info.previewPorts,
6007
+ previewUrls: info.previewUrls,
6008
+ expiresAt: info.expiresAt
6009
+ },
6010
+ null,
6011
+ 2
6012
+ )
6013
+ }
6014
+ ]
6015
+ };
6016
+ }
6017
+ );
6018
+ }
6019
+ function registerStopTunnelTool(server2) {
6020
+ server2.tool(
6021
+ "workspace_stop_tunnel",
6022
+ "Stop a local workspace tunnel previously opened by workspace_start_tunnel.",
6023
+ {
6024
+ tunnelId: z13.string().describe("Tunnel id returned by workspace_start_tunnel")
6025
+ },
6026
+ async ({ tunnelId }) => {
6027
+ const tunnel = activeTunnels.get(tunnelId);
6028
+ if (!tunnel) throw new Error("Workspace tunnel not found");
6029
+ await tunnel.close();
6030
+ activeTunnels.delete(tunnelId);
6031
+ return { content: [{ type: "text", text: "Workspace tunnel stopped" }] };
6032
+ }
6033
+ );
6034
+ }
6035
+ function registerWorkspaceTools(server2, conn2, deps = {}) {
6036
+ registerAttachInfoTool(server2, conn2);
6037
+ registerPreviewUrlsTool(server2, conn2);
6038
+ registerStartTunnelTool(server2, conn2, deps.startTunnel ?? startWorkspaceSshTunnel);
6039
+ registerStopTunnelTool(server2);
6040
+ }
6041
+
6042
+ // src/tools/logs.ts
6043
+ function registerLogTools(server2, conn2) {
6044
+ registerContractTool(server2, queryGcpLogsContract, async (params) => {
6045
+ const text = await runQueryGcpLogs(conn2, params);
6046
+ return { content: [{ type: "text", text }] };
6047
+ });
6048
+ registerContractTool(server2, queryGrafanaLogsContract, async (params) => {
6049
+ const text = await runQueryGrafanaLogs(conn2, params);
6050
+ return { content: [{ type: "text", text }] };
6051
+ });
6052
+ }
6053
+
6054
+ // src/tools/integrations.ts
6055
+ function registerIntegrationTools(server2, conn2) {
6056
+ registerContractTool(server2, listProjectIntegrationsContract, async (params) => {
6057
+ const result = await conn2.listProjectIntegrations(params.projectId);
6058
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
6059
+ });
6060
+ registerContractTool(server2, listProjectChannelsContract, async (params) => {
6061
+ const channels = await conn2.listProjectChannels(params.projectId);
6062
+ if (channels.length === 0) {
6063
+ return {
6064
+ content: [
6065
+ {
6066
+ type: "text",
6067
+ text: "No work channels are registered for this project. An admin registers them in project settings; until then no channel is reachable, whatever the bot can see in the workspace."
6068
+ }
6069
+ ]
6070
+ };
6071
+ }
6072
+ return { content: [{ type: "text", text: JSON.stringify(channels, null, 2) }] };
6073
+ });
6074
+ registerContractTool(server2, readChannelMessagesContract, async (params) => {
6075
+ const result = await conn2.readChannelMessages(params);
6076
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
6077
+ });
6078
+ registerContractTool(server2, getAnalyticsSummaryContract, async (params) => {
6079
+ const res = await conn2.getProjectAnalyticsSummary(params);
6080
+ if (!res.configured) {
5903
6081
  return {
5904
6082
  content: [
5905
6083
  {
@@ -6112,6 +6290,14 @@ function registerDecisionTools(server2, conn2) {
6112
6290
  registerDecisionWrites(server2, conn2);
6113
6291
  }
6114
6292
 
6293
+ // src/tools/evaluate.ts
6294
+ function registerEvaluateTools(server2, conn2) {
6295
+ registerContractTool(server2, evaluateQuestionsContract, async (params) => {
6296
+ const res = await conn2.evaluateQuestions(params);
6297
+ return { content: [{ type: "text", text: formatEvaluateQuestionsResult(res) }] };
6298
+ });
6299
+ }
6300
+
6115
6301
  // src/tools/index.ts
6116
6302
  function registerAllTools(server2, conn2) {
6117
6303
  registerProjectTools(server2, conn2);
@@ -6131,6 +6317,7 @@ function registerAllTools(server2, conn2) {
6131
6317
  registerDriveTools(server2, conn2);
6132
6318
  registerMeetingTools(server2, conn2);
6133
6319
  registerDecisionTools(server2, conn2);
6320
+ registerEvaluateTools(server2, conn2);
6134
6321
  }
6135
6322
 
6136
6323
  // src/cli.ts