@paca-ai/paca-mcp 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/build/api/doc-client.d.ts +3 -3
  2. package/build/api/doc-client.d.ts.map +1 -1
  3. package/build/api/doc-client.js +5 -2
  4. package/build/api/doc-client.js.map +1 -1
  5. package/build/api/index.d.ts +1 -0
  6. package/build/api/index.d.ts.map +1 -1
  7. package/build/api/index.js +1 -0
  8. package/build/api/index.js.map +1 -1
  9. package/build/api/workflow-client.d.ts +31 -0
  10. package/build/api/workflow-client.d.ts.map +1 -0
  11. package/build/api/workflow-client.js +120 -0
  12. package/build/api/workflow-client.js.map +1 -0
  13. package/build/index.js +7 -1
  14. package/build/index.js.map +1 -1
  15. package/build/package.json +1 -1
  16. package/build/permissions.d.ts.map +1 -1
  17. package/build/permissions.js +303 -57
  18. package/build/permissions.js.map +1 -1
  19. package/build/server.d.ts.map +1 -1
  20. package/build/server.js +8 -3
  21. package/build/server.js.map +1 -1
  22. package/build/tools/doc-activity-tools.d.ts +17 -0
  23. package/build/tools/doc-activity-tools.d.ts.map +1 -0
  24. package/build/tools/doc-activity-tools.js +169 -0
  25. package/build/tools/doc-activity-tools.js.map +1 -0
  26. package/build/tools/filesystem-doc-tools.d.ts.map +1 -1
  27. package/build/tools/filesystem-doc-tools.js +8 -2
  28. package/build/tools/filesystem-doc-tools.js.map +1 -1
  29. package/build/tools/index.d.ts +2 -1
  30. package/build/tools/index.d.ts.map +1 -1
  31. package/build/tools/index.js +21 -3
  32. package/build/tools/index.js.map +1 -1
  33. package/build/tools/task-link-tools.d.ts.map +1 -1
  34. package/build/tools/task-link-tools.js +4 -1
  35. package/build/tools/task-link-tools.js.map +1 -1
  36. package/build/tools/task-tools.d.ts.map +1 -1
  37. package/build/tools/task-tools.js +8 -2
  38. package/build/tools/task-tools.js.map +1 -1
  39. package/build/tools/view-tools.d.ts.map +1 -1
  40. package/build/tools/view-tools.js.map +1 -1
  41. package/build/tools/workflow-orchestration.d.ts +101 -0
  42. package/build/tools/workflow-orchestration.d.ts.map +1 -0
  43. package/build/tools/workflow-orchestration.js +399 -0
  44. package/build/tools/workflow-orchestration.js.map +1 -0
  45. package/build/tools/workflow-tools.d.ts +11 -0
  46. package/build/tools/workflow-tools.d.ts.map +1 -0
  47. package/build/tools/workflow-tools.js +607 -0
  48. package/build/tools/workflow-tools.js.map +1 -0
  49. package/build/types/index.d.ts +79 -9
  50. package/build/types/index.d.ts.map +1 -1
  51. package/build/utils/formatters.d.ts +10 -0
  52. package/build/utils/formatters.d.ts.map +1 -1
  53. package/build/utils/formatters.js +25 -0
  54. package/build/utils/formatters.js.map +1 -1
  55. package/package.json +1 -1
@@ -0,0 +1,101 @@
1
+ import type { PacaAPIWorkflowClient } from "../api/index.js";
2
+ import type { WorkflowGraph } from "../types/index.js";
3
+ /**
4
+ * Shared apply-logic for `create_workflow`/`update_workflow`: both accept a
5
+ * full graph (nodes/status rules/status transitions/edges) addressed by
6
+ * taskId/statusId/task-pairs rather than internal node/rule/transition/edge
7
+ * UUIDs, and both need to translate that into the granular REST calls the
8
+ * backend actually exposes. This module is that translation layer.
9
+ */
10
+ export interface NodeSetInput {
11
+ taskId: string;
12
+ posX: number;
13
+ posY: number;
14
+ }
15
+ export interface StatusRuleSetInput {
16
+ statusId: string;
17
+ assigneeMemberId: string;
18
+ }
19
+ export interface StatusTransitionSetInput {
20
+ statusId: string;
21
+ nextStatusId?: string | null;
22
+ }
23
+ export interface EdgeRefInput {
24
+ sourceTaskId: string;
25
+ targetTaskId: string;
26
+ }
27
+ export type ItemOutcome = "created" | "updated" | "removed" | "skipped" | "failed";
28
+ export interface ItemResult {
29
+ key: string;
30
+ outcome: ItemOutcome;
31
+ detail?: string;
32
+ }
33
+ export interface CategoryResult {
34
+ items: ItemResult[];
35
+ hasFailure: boolean;
36
+ }
37
+ export declare function anyHasFailure(...results: Array<CategoryResult | undefined>): boolean;
38
+ /**
39
+ * Renders one category's results as a text block, or null if the category
40
+ * wasn't touched at all (so callers can skip it from the final summary).
41
+ */
42
+ export declare function formatCategoryResult(label: string, result: CategoryResult | undefined): string | null;
43
+ export interface GraphIndexes {
44
+ taskToNode: Map<string, string>;
45
+ statusToRule: Map<string, string>;
46
+ statusToTransition: Map<string, string>;
47
+ nodePairToEdge: Map<string, string>;
48
+ }
49
+ /** Builds the natural-key -> internal-id lookup maps from a fetched graph. */
50
+ export declare function buildGraphIndexes(graph: WorkflowGraph): GraphIndexes;
51
+ /** Empty indexes for contexts with no prior graph (e.g. a brand-new workflow). */
52
+ export declare function emptyGraphIndexes(): GraphIndexes;
53
+ /** Keeps only the last entry per key — "last write wins" for a request array. */
54
+ export declare function dedupeByKey<T>(items: T[], keyFn: (item: T) => string): T[];
55
+ /**
56
+ * Pulls the human-readable `error` field out of the JSON body embedded in
57
+ * the Error thrown by PacaAPIWorkflowClient's request() helper (formatted as
58
+ * `API request failed: <status> <statusText> - <jsonBody>`), falling back to
59
+ * the raw message if the body isn't parseable JSON with that shape.
60
+ */
61
+ export declare function extractApiErrorMessage(err: unknown): string;
62
+ export interface OrchestrationContext {
63
+ client: PacaAPIWorkflowClient;
64
+ projectId: string;
65
+ workflowId: string;
66
+ }
67
+ export declare const RECOMMENDED_NODE_GAP_X = 300;
68
+ export declare const RECOMMENDED_NODE_GAP_Y = 200;
69
+ export interface PositionedNode {
70
+ taskId: string;
71
+ posX: number;
72
+ posY: number;
73
+ }
74
+ /**
75
+ * Warns (without changing anything) when any two of `positions` are closer
76
+ * than the recommended gap on BOTH axes at once — i.e. they'd read as
77
+ * crowded/overlapping on the canvas rather than as clearly separate nodes.
78
+ * Purely advisory: prose-only spacing guidance in the tool description was
79
+ * not enough on its own (agents kept picking small, evenly-spaced values
80
+ * like 200px regardless of the stated minimum), so this gives concrete,
81
+ * per-call feedback the agent can act on — but it never moves a node itself;
82
+ * position is still entirely the agent's call (see NodeSetInput).
83
+ */
84
+ export declare function checkNodeSpacing(positions: PositionedNode[]): string | null;
85
+ export declare function applyNodes(ctx: OrchestrationContext, set: NodeSetInput[] | undefined, remove: string[] | undefined, indexes: GraphIndexes): Promise<{
86
+ removed: CategoryResult;
87
+ set: CategoryResult;
88
+ }>;
89
+ export declare function applyStatusRules(ctx: OrchestrationContext, set: StatusRuleSetInput[] | undefined, remove: string[] | undefined, indexes: GraphIndexes): Promise<{
90
+ removed: CategoryResult;
91
+ set: CategoryResult;
92
+ }>;
93
+ export declare function applyStatusTransitions(ctx: OrchestrationContext, set: StatusTransitionSetInput[] | undefined, remove: string[] | undefined, indexes: GraphIndexes): Promise<{
94
+ removed: CategoryResult;
95
+ set: CategoryResult;
96
+ }>;
97
+ export declare function applyEdges(ctx: OrchestrationContext, add: EdgeRefInput[] | undefined, remove: EdgeRefInput[] | undefined, indexes: GraphIndexes): Promise<{
98
+ removed: CategoryResult;
99
+ added: CategoryResult;
100
+ }>;
101
+ //# sourceMappingURL=workflow-orchestration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-orchestration.d.ts","sourceRoot":"","sources":["../../src/tools/workflow-orchestration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;;;GAMG;AAIH,MAAM,WAAW,YAAY;IAC5B,MAAM,EAAE,MAAM,CAAC;IAIf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,kBAAkB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,wBAAwB;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC5B,YAAY,EAAE,MAAM,CA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,oBAAoB,EACzB,GAAG,EAAE,YAAY,EAAE,GAAG,SAAS,EAC/B,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS,EAClC,OAAO,EAAE,YAAY,GACnB,OAAO,CAAC;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAE,CAAC,CAgF7D"}
@@ -0,0 +1,399 @@
1
+ function emptyCategoryResult() {
2
+ return { items: [], hasFailure: false };
3
+ }
4
+ function pushResult(result, item) {
5
+ result.items.push(item);
6
+ if (item.outcome === "failed") {
7
+ result.hasFailure = true;
8
+ }
9
+ }
10
+ export function anyHasFailure(...results) {
11
+ return results.some((r) => r?.hasFailure);
12
+ }
13
+ /**
14
+ * Renders one category's results as a text block, or null if the category
15
+ * wasn't touched at all (so callers can skip it from the final summary).
16
+ */
17
+ export function formatCategoryResult(label, result) {
18
+ if (!result || result.items.length === 0) {
19
+ return null;
20
+ }
21
+ const counts = {
22
+ created: 0,
23
+ updated: 0,
24
+ removed: 0,
25
+ skipped: 0,
26
+ failed: 0,
27
+ };
28
+ for (const item of result.items) {
29
+ counts[item.outcome]++;
30
+ }
31
+ const parts = [];
32
+ if (counts.created)
33
+ parts.push(`${counts.created} created`);
34
+ if (counts.updated)
35
+ parts.push(`${counts.updated} updated`);
36
+ if (counts.removed)
37
+ parts.push(`${counts.removed} removed`);
38
+ if (counts.skipped)
39
+ parts.push(`${counts.skipped} skipped`);
40
+ if (counts.failed)
41
+ parts.push(`${counts.failed} failed`);
42
+ const lines = [`${label}: ${parts.join(", ")}`];
43
+ for (const item of result.items) {
44
+ if (item.outcome === "failed" || item.outcome === "skipped") {
45
+ lines.push(` - ${item.outcome} (${item.key}): ${item.detail}`);
46
+ }
47
+ }
48
+ return lines.join("\n");
49
+ }
50
+ function nodePairKey(sourceNodeId, targetNodeId) {
51
+ return `${sourceNodeId}|${targetNodeId}`;
52
+ }
53
+ /** Builds the natural-key -> internal-id lookup maps from a fetched graph. */
54
+ export function buildGraphIndexes(graph) {
55
+ const taskToNode = new Map();
56
+ for (const n of graph.nodes) {
57
+ taskToNode.set(n.task_id, n.id);
58
+ }
59
+ const statusToRule = new Map();
60
+ for (const r of graph.status_rules) {
61
+ statusToRule.set(r.status_id, r.id);
62
+ }
63
+ const statusToTransition = new Map();
64
+ for (const t of graph.status_transitions) {
65
+ statusToTransition.set(t.status_id, t.id);
66
+ }
67
+ const nodePairToEdge = new Map();
68
+ for (const e of graph.edges) {
69
+ nodePairToEdge.set(nodePairKey(e.source_node_id, e.target_node_id), e.id);
70
+ }
71
+ return { taskToNode, statusToRule, statusToTransition, nodePairToEdge };
72
+ }
73
+ /** Empty indexes for contexts with no prior graph (e.g. a brand-new workflow). */
74
+ export function emptyGraphIndexes() {
75
+ return {
76
+ taskToNode: new Map(),
77
+ statusToRule: new Map(),
78
+ statusToTransition: new Map(),
79
+ nodePairToEdge: new Map(),
80
+ };
81
+ }
82
+ /** Keeps only the last entry per key — "last write wins" for a request array. */
83
+ export function dedupeByKey(items, keyFn) {
84
+ const map = new Map();
85
+ for (const item of items) {
86
+ map.set(keyFn(item), item);
87
+ }
88
+ return [...map.values()];
89
+ }
90
+ /**
91
+ * Pulls the human-readable `error` field out of the JSON body embedded in
92
+ * the Error thrown by PacaAPIWorkflowClient's request() helper (formatted as
93
+ * `API request failed: <status> <statusText> - <jsonBody>`), falling back to
94
+ * the raw message if the body isn't parseable JSON with that shape.
95
+ */
96
+ export function extractApiErrorMessage(err) {
97
+ const message = err instanceof Error ? err.message : String(err);
98
+ const jsonStart = message.indexOf("{");
99
+ if (jsonStart === -1) {
100
+ return message;
101
+ }
102
+ try {
103
+ const parsed = JSON.parse(message.slice(jsonStart));
104
+ if (parsed && typeof parsed.error === "string") {
105
+ return parsed.error;
106
+ }
107
+ }
108
+ catch {
109
+ // Not JSON (or not the expected shape) — fall through to raw message.
110
+ }
111
+ return message;
112
+ }
113
+ // --- Nodes ---------------------------------------------------------------------
114
+ // Minimum canvas spacing the agent is asked to use between any two nodes.
115
+ // Defined once here and interpolated into both the tool-description text
116
+ // (workflow-tools.ts) and checkNodeSpacing below, so the two can never drift
117
+ // out of sync — X in particular has been adjusted several times based on
118
+ // live feedback (400 -> 600 -> 900 -> 1800 -> back down to 400 as too-wide,
119
+ // halved to 200 with Y, then back up to 300); centralizing it means each
120
+ // adjustment is one constant, not a hunt across strings. Canvas cards are a
121
+ // fixed 256px wide (see apps/web's `w-64` TaskNode in workflow-canvas.tsx).
122
+ export const RECOMMENDED_NODE_GAP_X = 300;
123
+ export const RECOMMENDED_NODE_GAP_Y = 200;
124
+ /**
125
+ * Warns (without changing anything) when any two of `positions` are closer
126
+ * than the recommended gap on BOTH axes at once — i.e. they'd read as
127
+ * crowded/overlapping on the canvas rather than as clearly separate nodes.
128
+ * Purely advisory: prose-only spacing guidance in the tool description was
129
+ * not enough on its own (agents kept picking small, evenly-spaced values
130
+ * like 200px regardless of the stated minimum), so this gives concrete,
131
+ * per-call feedback the agent can act on — but it never moves a node itself;
132
+ * position is still entirely the agent's call (see NodeSetInput).
133
+ */
134
+ export function checkNodeSpacing(positions) {
135
+ const violations = [];
136
+ for (let i = 0; i < positions.length; i++) {
137
+ for (let j = i + 1; j < positions.length; j++) {
138
+ const a = positions[i];
139
+ const b = positions[j];
140
+ const dx = Math.abs(a.posX - b.posX);
141
+ const dy = Math.abs(a.posY - b.posY);
142
+ if (dx < RECOMMENDED_NODE_GAP_X && dy < RECOMMENDED_NODE_GAP_Y) {
143
+ violations.push({ a, b, dx, dy });
144
+ }
145
+ }
146
+ }
147
+ if (violations.length === 0) {
148
+ return null;
149
+ }
150
+ violations.sort((v1, v2) => v1.dx + v1.dy - (v2.dx + v2.dy));
151
+ const examples = violations
152
+ .slice(0, 3)
153
+ .map((v) => ` - ${v.a.taskId} (${v.a.posX}, ${v.a.posY}) and ${v.b.taskId} (${v.b.posX}, ${v.b.posY}) — ${v.dx}px apart horizontally, ${v.dy}px apart vertically`);
154
+ const more = violations.length > 3
155
+ ? `\n ...and ${violations.length - 3} more pair(s) this close.`
156
+ : "";
157
+ return (`Warning: ${violations.length} pair(s) of these nodes are close enough to visually crowd or overlap on the canvas (need at least ${RECOMMENDED_NODE_GAP_X}px apart horizontally OR ${RECOMMENDED_NODE_GAP_Y}px apart vertically — not both less):\n` +
158
+ `${examples.join("\n")}${more}\n` +
159
+ "These positions were still applied as requested — spread them out further yourself (e.g. call update_workflow again with larger posX/posY differences) if this isn't what you intended.");
160
+ }
161
+ export async function applyNodes(ctx, set, remove, indexes) {
162
+ const { client, projectId, workflowId } = ctx;
163
+ // Each item below targets a distinct taskId (remove is de-duplicated via
164
+ // Set, set via dedupeByKey), so every call reads/writes a different
165
+ // indexes.taskToNode entry — safe to fire concurrently instead of
166
+ // paying for each REST round-trip sequentially.
167
+ const removedResult = emptyCategoryResult();
168
+ await Promise.all([...new Set(remove ?? [])].map(async (taskId) => {
169
+ const nodeId = indexes.taskToNode.get(taskId);
170
+ if (!nodeId) {
171
+ pushResult(removedResult, {
172
+ key: taskId,
173
+ outcome: "skipped",
174
+ detail: "no node exists for this taskId in the workflow",
175
+ });
176
+ return;
177
+ }
178
+ try {
179
+ await client.removeWorkflowNode(projectId, workflowId, nodeId);
180
+ indexes.taskToNode.delete(taskId);
181
+ pushResult(removedResult, { key: taskId, outcome: "removed" });
182
+ }
183
+ catch (err) {
184
+ pushResult(removedResult, {
185
+ key: taskId,
186
+ outcome: "failed",
187
+ detail: extractApiErrorMessage(err),
188
+ });
189
+ }
190
+ }));
191
+ const setResult = emptyCategoryResult();
192
+ await Promise.all(dedupeByKey(set ?? [], (i) => i.taskId).map(async (item) => {
193
+ const existingNodeId = indexes.taskToNode.get(item.taskId);
194
+ try {
195
+ if (existingNodeId) {
196
+ await client.updateWorkflowNode(projectId, workflowId, existingNodeId, { pos_x: item.posX, pos_y: item.posY });
197
+ pushResult(setResult, { key: item.taskId, outcome: "updated" });
198
+ }
199
+ else {
200
+ const node = await client.addWorkflowNode(projectId, workflowId, {
201
+ task_id: item.taskId,
202
+ pos_x: item.posX,
203
+ pos_y: item.posY,
204
+ });
205
+ indexes.taskToNode.set(item.taskId, node.id);
206
+ pushResult(setResult, { key: item.taskId, outcome: "created" });
207
+ }
208
+ }
209
+ catch (err) {
210
+ pushResult(setResult, {
211
+ key: item.taskId,
212
+ outcome: "failed",
213
+ detail: extractApiErrorMessage(err),
214
+ });
215
+ }
216
+ }));
217
+ return { removed: removedResult, set: setResult };
218
+ }
219
+ // --- Status rules ----------------------------------------------------------------
220
+ export async function applyStatusRules(ctx, set, remove, indexes) {
221
+ const { client, projectId, workflowId } = ctx;
222
+ // See applyNodes: each item targets a distinct statusId, so these run
223
+ // concurrently instead of one REST round-trip at a time.
224
+ const removedResult = emptyCategoryResult();
225
+ await Promise.all([...new Set(remove ?? [])].map(async (statusId) => {
226
+ const ruleId = indexes.statusToRule.get(statusId);
227
+ if (!ruleId) {
228
+ pushResult(removedResult, {
229
+ key: statusId,
230
+ outcome: "skipped",
231
+ detail: "no status rule exists for this statusId in the workflow",
232
+ });
233
+ return;
234
+ }
235
+ try {
236
+ await client.removeWorkflowStatusRule(projectId, workflowId, ruleId);
237
+ indexes.statusToRule.delete(statusId);
238
+ pushResult(removedResult, { key: statusId, outcome: "removed" });
239
+ }
240
+ catch (err) {
241
+ pushResult(removedResult, {
242
+ key: statusId,
243
+ outcome: "failed",
244
+ detail: extractApiErrorMessage(err),
245
+ });
246
+ }
247
+ }));
248
+ const setResult = emptyCategoryResult();
249
+ await Promise.all(dedupeByKey(set ?? [], (i) => i.statusId).map(async (item) => {
250
+ const existed = indexes.statusToRule.has(item.statusId);
251
+ try {
252
+ const rule = await client.setWorkflowStatusRule(projectId, workflowId, {
253
+ status_id: item.statusId,
254
+ assignee_member_id: item.assigneeMemberId,
255
+ });
256
+ indexes.statusToRule.set(item.statusId, rule.id);
257
+ pushResult(setResult, {
258
+ key: item.statusId,
259
+ outcome: existed ? "updated" : "created",
260
+ });
261
+ }
262
+ catch (err) {
263
+ pushResult(setResult, {
264
+ key: item.statusId,
265
+ outcome: "failed",
266
+ detail: extractApiErrorMessage(err),
267
+ });
268
+ }
269
+ }));
270
+ return { removed: removedResult, set: setResult };
271
+ }
272
+ // --- Status transitions ------------------------------------------------------------
273
+ export async function applyStatusTransitions(ctx, set, remove, indexes) {
274
+ const { client, projectId, workflowId } = ctx;
275
+ // See applyNodes: each item targets a distinct statusId, so these run
276
+ // concurrently instead of one REST round-trip at a time.
277
+ const removedResult = emptyCategoryResult();
278
+ await Promise.all([...new Set(remove ?? [])].map(async (statusId) => {
279
+ const transitionId = indexes.statusToTransition.get(statusId);
280
+ if (!transitionId) {
281
+ pushResult(removedResult, {
282
+ key: statusId,
283
+ outcome: "skipped",
284
+ detail: "no status transition exists for this statusId in the workflow",
285
+ });
286
+ return;
287
+ }
288
+ try {
289
+ await client.removeWorkflowStatusTransition(projectId, workflowId, transitionId);
290
+ indexes.statusToTransition.delete(statusId);
291
+ pushResult(removedResult, { key: statusId, outcome: "removed" });
292
+ }
293
+ catch (err) {
294
+ pushResult(removedResult, {
295
+ key: statusId,
296
+ outcome: "failed",
297
+ detail: extractApiErrorMessage(err),
298
+ });
299
+ }
300
+ }));
301
+ const setResult = emptyCategoryResult();
302
+ await Promise.all(dedupeByKey(set ?? [], (i) => i.statusId).map(async (item) => {
303
+ const existed = indexes.statusToTransition.has(item.statusId);
304
+ try {
305
+ const transition = await client.setWorkflowStatusTransition(projectId, workflowId, {
306
+ status_id: item.statusId,
307
+ next_status_id: item.nextStatusId ?? null,
308
+ });
309
+ indexes.statusToTransition.set(item.statusId, transition.id);
310
+ pushResult(setResult, {
311
+ key: item.statusId,
312
+ outcome: existed ? "updated" : "created",
313
+ });
314
+ }
315
+ catch (err) {
316
+ pushResult(setResult, {
317
+ key: item.statusId,
318
+ outcome: "failed",
319
+ detail: extractApiErrorMessage(err),
320
+ });
321
+ }
322
+ }));
323
+ return { removed: removedResult, set: setResult };
324
+ }
325
+ // --- Edges -----------------------------------------------------------------------
326
+ function edgeLabel(ref) {
327
+ return `${ref.sourceTaskId} -> ${ref.targetTaskId}`;
328
+ }
329
+ export async function applyEdges(ctx, add, remove, indexes) {
330
+ const { client, projectId, workflowId } = ctx;
331
+ // See applyNodes: each item targets a distinct node pair (both add and
332
+ // remove are de-duplicated via dedupeByKey), so these run concurrently
333
+ // instead of one REST round-trip at a time.
334
+ const removedResult = emptyCategoryResult();
335
+ await Promise.all(dedupeByKey(remove ?? [], edgeLabel).map(async (ref) => {
336
+ const sourceNodeId = indexes.taskToNode.get(ref.sourceTaskId);
337
+ const targetNodeId = indexes.taskToNode.get(ref.targetTaskId);
338
+ if (!sourceNodeId || !targetNodeId) {
339
+ pushResult(removedResult, {
340
+ key: edgeLabel(ref),
341
+ outcome: "skipped",
342
+ detail: "one or both tasks have no node in this workflow — edge is already effectively gone",
343
+ });
344
+ return;
345
+ }
346
+ const edgeId = indexes.nodePairToEdge.get(nodePairKey(sourceNodeId, targetNodeId));
347
+ if (!edgeId) {
348
+ pushResult(removedResult, {
349
+ key: edgeLabel(ref),
350
+ outcome: "skipped",
351
+ detail: "no edge exists between these tasks",
352
+ });
353
+ return;
354
+ }
355
+ try {
356
+ await client.removeWorkflowEdge(projectId, workflowId, edgeId);
357
+ indexes.nodePairToEdge.delete(nodePairKey(sourceNodeId, targetNodeId));
358
+ pushResult(removedResult, { key: edgeLabel(ref), outcome: "removed" });
359
+ }
360
+ catch (err) {
361
+ pushResult(removedResult, {
362
+ key: edgeLabel(ref),
363
+ outcome: "failed",
364
+ detail: extractApiErrorMessage(err),
365
+ });
366
+ }
367
+ }));
368
+ const addedResult = emptyCategoryResult();
369
+ await Promise.all(dedupeByKey(add ?? [], edgeLabel).map(async (ref) => {
370
+ const sourceNodeId = indexes.taskToNode.get(ref.sourceTaskId);
371
+ const targetNodeId = indexes.taskToNode.get(ref.targetTaskId);
372
+ if (!sourceNodeId || !targetNodeId) {
373
+ const missing = !sourceNodeId ? ref.sourceTaskId : ref.targetTaskId;
374
+ pushResult(addedResult, {
375
+ key: edgeLabel(ref),
376
+ outcome: "failed",
377
+ detail: `taskId ${missing} has no node in this workflow — add it via nodes first`,
378
+ });
379
+ return;
380
+ }
381
+ try {
382
+ const edge = await client.addWorkflowEdge(projectId, workflowId, {
383
+ source_node_id: sourceNodeId,
384
+ target_node_id: targetNodeId,
385
+ });
386
+ indexes.nodePairToEdge.set(nodePairKey(sourceNodeId, targetNodeId), edge.id);
387
+ pushResult(addedResult, { key: edgeLabel(ref), outcome: "created" });
388
+ }
389
+ catch (err) {
390
+ pushResult(addedResult, {
391
+ key: edgeLabel(ref),
392
+ outcome: "failed",
393
+ detail: extractApiErrorMessage(err),
394
+ });
395
+ }
396
+ }));
397
+ return { removed: removedResult, added: addedResult };
398
+ }
399
+ //# sourceMappingURL=workflow-orchestration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-orchestration.js","sourceRoot":"","sources":["../../src/tools/workflow-orchestration.ts"],"names":[],"mappings":"AAyDA,SAAS,mBAAmB;IAC3B,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AACzC,CAAC;AAED,SAAS,UAAU,CAAC,MAAsB,EAAE,IAAgB;IAC3D,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxB,IAAI,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC/B,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;IAC1B,CAAC;AACF,CAAC;AAED,MAAM,UAAU,aAAa,CAC5B,GAAG,OAA0C;IAE7C,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CACnC,KAAa,EACb,MAAkC;IAElC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAA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type { Tool } from "@modelcontextprotocol/sdk/types.js";
2
+ import type { PacaAPIWorkflowClient } from "../api/index.js";
3
+ /**
4
+ * Returns all automation-workflow MCP tools.
5
+ */
6
+ export declare function getWorkflowTools(): Tool[];
7
+ /**
8
+ * Handles automation-workflow tool calls.
9
+ */
10
+ export declare function handleWorkflowTool(toolName: string, args: any, workflowClient: PacaAPIWorkflowClient): Promise<any>;
11
+ //# sourceMappingURL=workflow-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-tools.d.ts","sourceRoot":"","sources":["../../src/tools/workflow-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAyL7D;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,EAAE,CAyLzC;AA0ED;;GAEG;AACH,wBAAsB,kBAAkB,CACvC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,GAAG,EACT,cAAc,EAAE,qBAAqB,GACnC,OAAO,CAAC,GAAG,CAAC,CAiBd"}