@taiga-ai/mcp-server 0.30.0-dev.640 → 0.30.0-dev.641

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.
Files changed (2) hide show
  1. package/dist/index.js +101 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -22449,6 +22449,10 @@ var TaigaClient = class {
22449
22449
  async listQueue(productId) {
22450
22450
  return this.request("GET", `/products/${seg(productId)}/queue`);
22451
22451
  }
22452
+ /** Start now: plan and build a queued entry's initiative without waiting for its turn (it leaves the queue). */
22453
+ async startQueueEntryNow(entryId) {
22454
+ return this.request("POST", `/queue/${seg(entryId)}/start-now`);
22455
+ }
22452
22456
  async getActivePlan(itemId) {
22453
22457
  return this.request("GET", `/backlog/${seg(itemId)}/plans/active`);
22454
22458
  }
@@ -28612,20 +28616,26 @@ const autoBuildInput = boolean().nullable().describe("false stops the line at th
28612
28616
  function registerQueue(server, client) {
28613
28617
  server.registerTool("taiga_queue_initiative", {
28614
28618
  title: "Queue initiative",
28615
- description: "Start work on an initiative: put it on the product's line, where the agent plans it, builds it and opens a pull request, one initiative at a time. autoBuild: false makes the plan wait for a person before it is built. Returns its place on the line.",
28619
+ description: "Start work on an initiative: put it on the product's line, where the agent plans it, builds it and opens a pull request, one initiative at a time. autoBuild: false makes the plan wait for a person before it is built. Returns its place on the line. startNow: true is Start now: it is planned at once, against main as it is now, and built alongside the initiative already in build instead of waiting for its turn; parallel builds in one repository can conflict, so say that when you ask. The rest of the queue keeps its order.",
28616
28620
  inputSchema: object({
28617
28621
  initiativeId,
28618
- afterId: idInput("initiative", "taiga_list_initiatives gives it").nullable().optional().describe("The queued initiative to follow; null for the head of the queue; omit to append a new entry or leave a queued one where it is"),
28619
- autoBuild: autoBuildInput.optional().describe("Set the initiative's review gate before queueing: false to read the plan first, true to build it at once, null to follow the product; omit to leave the gate as it is")
28622
+ afterId: idInput("initiative", "taiga_list_initiatives gives it").nullable().optional().describe("The queued initiative to follow; null for the head of the queue; omit to append a new entry or leave a queued one where it is. Not with startNow, which takes it out of the queue"),
28623
+ autoBuild: autoBuildInput.optional().describe("Set the initiative's review gate before queueing: false to read the plan first, true to build it at once, null to follow the product; omit to leave the gate as it is"),
28624
+ startNow: boolean().optional().describe("true starts it now, alongside the current work, rather than at its turn (the web's Start now); omit to wait in the queue")
28625
+ }).refine((input) => !(input.startNow && input.afterId !== void 0), {
28626
+ path: ["afterId"],
28627
+ message: "startNow takes it out of the queue, so it takes no afterId: leave afterId out."
28620
28628
  }),
28621
28629
  annotations: OPERATE
28622
28630
  }, (params) => runTool(async () => {
28623
- const { initiativeId: id, autoBuild, ...placement } = params;
28631
+ const { initiativeId: id, autoBuild, startNow, ...placement } = params;
28632
+ if (startNow && !client.hasCapability("products:read")) return toolError("FORBIDDEN", "startNow reads the queue to find its entry, which needs products:read, and this key lacks it. Queue it without startNow, or use a key that can read products.");
28624
28633
  if (autoBuild !== void 0) await client.setAutoBuild(id, autoBuild);
28625
28634
  const item = (await client.transitionInitiative(id, {
28626
28635
  state: "queue",
28627
28636
  ...placement
28628
28637
  })).data;
28638
+ if (startNow) return startedNow(client, item);
28629
28639
  const [gate, queue] = await Promise.all([reviewGate(client, item), placeInQueue(client, item)]);
28630
28640
  return toolResult({
28631
28641
  ...outcomeOf(item),
@@ -28635,6 +28645,93 @@ function registerQueue(server, client) {
28635
28645
  });
28636
28646
  }));
28637
28647
  }
28648
+ /** What the API said, or what failed on the way to it. */
28649
+ const failureSaid = (error) => (error instanceof TaigaApiError ? error.apiMessage : void 0) ?? (isNetworkFailure(error) ? networkFailureDetail(error) : error instanceof Error ? error.message : String(error));
28650
+ /**
28651
+ * Start now, the web's button on a queued initiative (PRO-3391): its queue
28652
+ * entry is started out of turn. Queueing it first is what gives it an entry,
28653
+ * so every outcome after that move says it is queued or started, never only
28654
+ * that something failed: an error would read as nothing having happened.
28655
+ * With a free line the queue may take it up first, before the listing or
28656
+ * between it and Start now; that is the outcome the caller asked for, so it
28657
+ * is said rather than refused.
28658
+ */
28659
+ async function startedNow(client, queued) {
28660
+ const entryOf = async () => (await client.listQueue(queued.productId)).data.find((row) => row.backlogItemId === queued.id && row.state !== "settled");
28661
+ let entry;
28662
+ try {
28663
+ entry = await entryOf();
28664
+ } catch (error) {
28665
+ if (!isApiFailure$2(error)) throw error;
28666
+ return stillQueued(client, queued, `its queue could not be read (${failureSaid(error)})`);
28667
+ }
28668
+ if (entry?.state === "active") return startOutcome(client, queued, null);
28669
+ if (!entry) return stillQueued(client, queued, "it has no live queue entry after queueing");
28670
+ if (entry.state === "halted") return stillQueued(client, queued, "its queue entry is halted; taiga_get_line says why and what lifts it");
28671
+ let started;
28672
+ try {
28673
+ started = (await client.startQueueEntryNow(entry.id)).data;
28674
+ } catch (error) {
28675
+ const refused = error instanceof TaigaApiError && error.status < 500;
28676
+ const now = await entryOf().then((row) => ({ row }), (readError) => {
28677
+ if (!isApiFailure$2(readError)) throw readError;
28678
+ return null;
28679
+ });
28680
+ if (now?.row?.state === "active") return startOutcome(client, queued, null);
28681
+ if (refused && now?.row) return stillQueued(client, queued, failureSaid(error));
28682
+ return toolResult({
28683
+ ...outcomeOf(await freshItem(client, queued) ?? unconfirmed(queued)),
28684
+ startedNow: null,
28685
+ note: `Whether Start now took effect is unknown: ${failureSaid(error).replace(/\.$/, "")}. Read taiga_get_line before trying again: repeating it blind can start the work twice.`
28686
+ });
28687
+ }
28688
+ return startOutcome(client, queued, started);
28689
+ }
28690
+ /** Queued and not started now, with its place in the queue and why. */
28691
+ async function stillQueued(client, queued, why) {
28692
+ return toolResult({
28693
+ ...outcomeOf(queued),
28694
+ startedNow: false,
28695
+ queue: await placeInQueue(client, queued),
28696
+ note: `It is queued, but it did not start now: ${why.replace(/\.$/, "")}. It starts at its turn unless you take it off the line (taiga_move_initiative).`
28697
+ });
28698
+ }
28699
+ /** The initiative as it now stands, for a key that may read the backlog; null otherwise or when the read fails. */
28700
+ async function freshItem(client, queued) {
28701
+ if (!client.hasCapability("backlog:read")) return null;
28702
+ return client.getBacklogItem(queued.id).then((read) => read.data, (error) => {
28703
+ if (!isApiFailure$2(error)) throw error;
28704
+ return null;
28705
+ });
28706
+ }
28707
+ /**
28708
+ * The queued row with what nothing confirmed taken out: no column unless
28709
+ * Start now answered with one, and no lifecycle, whose situation would still
28710
+ * say queued (situationOf says nothing without one).
28711
+ */
28712
+ const unconfirmed = (queued, started) => ({
28713
+ ...queued,
28714
+ state: null,
28715
+ ...started,
28716
+ lifecycle: null
28717
+ });
28718
+ /**
28719
+ * The initiative once it is running: Start now's (`started`, its answer) or
28720
+ * the queue's own at its turn (null). A key that can read the backlog gets it
28721
+ * as it now stands; one that cannot (queueing needs no backlog read) gets the
28722
+ * column Start now answered with, or none.
28723
+ */
28724
+ async function startOutcome(client, queued, started) {
28725
+ const item = await freshItem(client, queued) ?? unconfirmed(queued, started ?? void 0);
28726
+ const gate = await reviewGate(client, item);
28727
+ const said = started ? "Started now: it is planned against main as it is now and built alongside the current work." : "Nothing held the line, so the queue started it at its turn: it is the active entry.";
28728
+ return toolResult({
28729
+ ...outcomeOf(item),
28730
+ startedNow: started !== null,
28731
+ reviewGate: gate,
28732
+ note: gate ? said : `${said} The product's default review gate could not be read; taiga_get_product says it.`
28733
+ });
28734
+ }
28638
28735
  function registerReviewGate(server, client) {
28639
28736
  server.registerTool("taiga_set_auto_build", {
28640
28737
  title: "Set an initiative's review gate",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taiga-ai/mcp-server",
3
- "version": "0.30.0-dev.640",
3
+ "version": "0.30.0-dev.641",
4
4
  "description": "Taiga for AI coding assistants: read products, policies, initiatives and runs, and operate the line, over MCP",
5
5
  "mcpName": "ga.tai/mcp-server",
6
6
  "license": "UNLICENSED",