@ferrfleet/mcp 10.16.0 → 10.17.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.
- package/dist/tools/__tests__/workflows.test.js +121 -3
- package/dist/tools/__tests__/writes.test.js +48 -0
- package/dist/tools/connectors.d.ts.map +1 -1
- package/dist/tools/connectors.js +26 -1
- package/dist/tools/workflows.d.ts.map +1 -1
- package/dist/tools/workflows.js +71 -9
- package/package.json +1 -1
|
@@ -27,6 +27,29 @@ function lastCall() {
|
|
|
27
27
|
body: init.body ? JSON.parse(init.body) : undefined,
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
+
function callAt(index) {
|
|
31
|
+
const [url, init] = mockFetch.mock.calls[index];
|
|
32
|
+
return {
|
|
33
|
+
url: String(url),
|
|
34
|
+
method: init.method ?? 'GET',
|
|
35
|
+
body: init.body ? JSON.parse(init.body) : undefined,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const cronEntry = {
|
|
39
|
+
id: 'nightly',
|
|
40
|
+
kind: 'cron',
|
|
41
|
+
cron: '0 6 * * *',
|
|
42
|
+
starts: ['review'],
|
|
43
|
+
position: { x: 0, y: 0 },
|
|
44
|
+
};
|
|
45
|
+
const issueOutput = {
|
|
46
|
+
id: 'file-issue',
|
|
47
|
+
from: 'review',
|
|
48
|
+
kind: 'github_issue',
|
|
49
|
+
connector_id: 'conn-1',
|
|
50
|
+
repo: 'FerrLabs/FerrFleet',
|
|
51
|
+
position: { x: 5, y: 5 },
|
|
52
|
+
};
|
|
30
53
|
const FLEET = 'https://api.ferrfleet.com';
|
|
31
54
|
const ID = '3f0c6a52-8d1e-4b7a-9c2f-5e6d7a8b9c01';
|
|
32
55
|
const OTHER_ID = '7a1d9e34-2b5c-4f80-8e6a-1c3b5d7f9a02';
|
|
@@ -77,12 +100,103 @@ describe('workflow and event rule tools', () => {
|
|
|
77
100
|
body: { name: 'Review', enabled: false, steps: [fullStep] },
|
|
78
101
|
});
|
|
79
102
|
});
|
|
80
|
-
it('
|
|
103
|
+
it('create_workflow posts entries and outputs', async () => {
|
|
104
|
+
await handlers.get('create_workflow')({
|
|
105
|
+
name: 'Review',
|
|
106
|
+
steps: [step],
|
|
107
|
+
entries: [cronEntry],
|
|
108
|
+
outputs: [issueOutput],
|
|
109
|
+
});
|
|
110
|
+
expect(lastCall().body).toEqual({
|
|
111
|
+
name: 'Review',
|
|
112
|
+
steps: [step],
|
|
113
|
+
entries: [cronEntry],
|
|
114
|
+
outputs: [issueOutput],
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
it('update_workflow keeps stored entries, outputs and enabled when omitted', async () => {
|
|
118
|
+
mockFetch.mockResolvedValueOnce(respond(200, {
|
|
119
|
+
id: ID,
|
|
120
|
+
enabled: false,
|
|
121
|
+
entries: [{ ...cronEntry, next_run_at: '2026-11-12T06:00:00Z' }],
|
|
122
|
+
outputs: [issueOutput],
|
|
123
|
+
}));
|
|
81
124
|
await handlers.get('update_workflow')({ workflow_id: ID, name: 'Review', steps: [step] });
|
|
82
|
-
expect(
|
|
125
|
+
expect(callAt(0)).toMatchObject({ url: `${FLEET}/workflows/${ID}`, method: 'GET' });
|
|
126
|
+
expect(callAt(1)).toEqual({
|
|
83
127
|
url: `${FLEET}/workflows/${ID}`,
|
|
84
128
|
method: 'PUT',
|
|
85
|
-
body: {
|
|
129
|
+
body: {
|
|
130
|
+
name: 'Review',
|
|
131
|
+
steps: [step],
|
|
132
|
+
enabled: false,
|
|
133
|
+
entries: [{ ...cronEntry, next_run_at: '2026-11-12T06:00:00Z' }],
|
|
134
|
+
outputs: [issueOutput],
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
it('update_workflow clears entries and outputs only when given empty arrays', async () => {
|
|
139
|
+
mockFetch.mockResolvedValueOnce(respond(200, { id: ID, enabled: true, entries: [cronEntry], outputs: [issueOutput] }));
|
|
140
|
+
await handlers.get('update_workflow')({
|
|
141
|
+
workflow_id: ID,
|
|
142
|
+
name: 'Review',
|
|
143
|
+
steps: [step],
|
|
144
|
+
entries: [],
|
|
145
|
+
outputs: [],
|
|
146
|
+
});
|
|
147
|
+
expect(callAt(1).body).toMatchObject({ entries: [], outputs: [], enabled: true });
|
|
148
|
+
});
|
|
149
|
+
it('update_workflow sends the given entries and outputs over the stored ones', async () => {
|
|
150
|
+
mockFetch.mockResolvedValueOnce(respond(200, { id: ID, enabled: true, entries: [], outputs: [issueOutput] }));
|
|
151
|
+
await handlers.get('update_workflow')({
|
|
152
|
+
workflow_id: ID,
|
|
153
|
+
name: 'Review',
|
|
154
|
+
steps: [step],
|
|
155
|
+
entries: [cronEntry],
|
|
156
|
+
});
|
|
157
|
+
expect(callAt(1).body).toMatchObject({ entries: [cronEntry], outputs: [issueOutput] });
|
|
158
|
+
});
|
|
159
|
+
it('update_workflow skips the read when everything is given', async () => {
|
|
160
|
+
await handlers.get('update_workflow')({
|
|
161
|
+
workflow_id: ID,
|
|
162
|
+
name: 'Review',
|
|
163
|
+
steps: [step],
|
|
164
|
+
enabled: true,
|
|
165
|
+
entries: [cronEntry],
|
|
166
|
+
outputs: [issueOutput],
|
|
167
|
+
});
|
|
168
|
+
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
169
|
+
expect(lastCall()).toMatchObject({ method: 'PUT' });
|
|
170
|
+
});
|
|
171
|
+
it('update_workflow does not write when the stored workflow cannot be read', async () => {
|
|
172
|
+
mockFetch.mockResolvedValueOnce(respond(404, { error: 'not_found' }));
|
|
173
|
+
await expect(handlers.get('update_workflow')({ workflow_id: ID, name: 'Review', steps: [step] })).rejects.toThrow('not_found');
|
|
174
|
+
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
175
|
+
});
|
|
176
|
+
describe('entries and outputs schemas', () => {
|
|
177
|
+
it('accepts cron and manual entries and a github_issue output', () => {
|
|
178
|
+
expect(accepts('create_workflow', 'entries', [cronEntry])).toBe(true);
|
|
179
|
+
expect(accepts('create_workflow', 'entries', [
|
|
180
|
+
{ id: 'go', kind: 'manual', starts: ['review'], position: { x: 0, y: 0 } },
|
|
181
|
+
])).toBe(true);
|
|
182
|
+
expect(accepts('update_workflow', 'outputs', [issueOutput])).toBe(true);
|
|
183
|
+
});
|
|
184
|
+
it('rejects unknown kinds and keys', () => {
|
|
185
|
+
expect(accepts('create_workflow', 'entries', [{ ...cronEntry, kind: 'weekly' }])).toBe(false);
|
|
186
|
+
expect(accepts('create_workflow', 'entries', [{ ...cronEntry, extra: 1 }])).toBe(false);
|
|
187
|
+
expect(accepts('create_workflow', 'outputs', [{ ...issueOutput, kind: 'sms' }])).toBe(false);
|
|
188
|
+
});
|
|
189
|
+
it('requires starts on an entry and from on an output', () => {
|
|
190
|
+
const { starts: _starts, ...noStarts } = cronEntry;
|
|
191
|
+
const { from: _from, ...noFrom } = issueOutput;
|
|
192
|
+
expect(accepts('create_workflow', 'entries', [noStarts])).toBe(false);
|
|
193
|
+
expect(accepts('create_workflow', 'outputs', [noFrom])).toBe(false);
|
|
194
|
+
});
|
|
195
|
+
it('caps entries and outputs at 10', () => {
|
|
196
|
+
const entries = Array.from({ length: 11 }, (_, i) => ({ ...cronEntry, id: `e${i}` }));
|
|
197
|
+
const outputs = Array.from({ length: 11 }, (_, i) => ({ ...issueOutput, id: `o${i}` }));
|
|
198
|
+
expect(accepts('create_workflow', 'entries', entries)).toBe(false);
|
|
199
|
+
expect(accepts('create_workflow', 'outputs', outputs)).toBe(false);
|
|
86
200
|
});
|
|
87
201
|
});
|
|
88
202
|
it('delete_workflow sends DELETE and reports the id on 204', async () => {
|
|
@@ -99,6 +213,10 @@ describe('workflow and event rule tools', () => {
|
|
|
99
213
|
body: { pr: 4 },
|
|
100
214
|
});
|
|
101
215
|
});
|
|
216
|
+
it('run_workflow starts a workflow that has a cron entry without naming an entry', async () => {
|
|
217
|
+
await handlers.get('run_workflow')({ workflow_id: ID });
|
|
218
|
+
expect(lastCall().url).toBe(`${FLEET}/workflows/${ID}/runs`);
|
|
219
|
+
});
|
|
102
220
|
it('run_workflow sends an empty object when no input is given', async () => {
|
|
103
221
|
await handlers.get('run_workflow')({ workflow_id: ID });
|
|
104
222
|
expect(lastCall().body).toEqual({});
|
|
@@ -354,6 +354,54 @@ describe('ferrfleet tools', () => {
|
|
|
354
354
|
expect(name.safeParse('-github').success).toBe(false);
|
|
355
355
|
expect(name.safeParse('a/b').success).toBe(false);
|
|
356
356
|
});
|
|
357
|
+
it('create_connector posts a custom http connector with its secret', async () => {
|
|
358
|
+
const config = {
|
|
359
|
+
url: 'https://mcp.example.com',
|
|
360
|
+
headers: { 'x-team': 'a' },
|
|
361
|
+
secret_header: 'authorization',
|
|
362
|
+
};
|
|
363
|
+
await handlers.get('create_connector')({
|
|
364
|
+
type: 'custom',
|
|
365
|
+
name: 'Docs',
|
|
366
|
+
config,
|
|
367
|
+
secret: 'hunter2',
|
|
368
|
+
});
|
|
369
|
+
const call = lastCall();
|
|
370
|
+
expect(call.url).toBe(`${FLEET}/connectors`);
|
|
371
|
+
expect(call.method).toBe('POST');
|
|
372
|
+
expect(call.body).toEqual({ type: 'custom', name: 'Docs', config, secret: 'hunter2' });
|
|
373
|
+
});
|
|
374
|
+
it('create_connector sends no secret or config key when they are omitted', async () => {
|
|
375
|
+
await handlers.get('create_connector')({ type: 'custom', name: 'Docs' });
|
|
376
|
+
expect(lastCall().body).toEqual({ type: 'custom', name: 'Docs' });
|
|
377
|
+
});
|
|
378
|
+
it('create_connector does not echo the secret in the result', async () => {
|
|
379
|
+
mockFetch.mockResolvedValue(ok({ id: 'conn-1', type: 'custom', name: 'Docs', has_secret: true }));
|
|
380
|
+
const result = await handlers.get('create_connector')({
|
|
381
|
+
type: 'custom',
|
|
382
|
+
name: 'Docs',
|
|
383
|
+
secret: 'hunter2',
|
|
384
|
+
});
|
|
385
|
+
const text = result.content[0].text;
|
|
386
|
+
expect(text).not.toContain('hunter2');
|
|
387
|
+
expect(JSON.parse(text)).toMatchObject({ has_secret: true });
|
|
388
|
+
});
|
|
389
|
+
it('create_connector surfaces API validation errors', async () => {
|
|
390
|
+
mockFetch.mockResolvedValue({
|
|
391
|
+
ok: false,
|
|
392
|
+
status: 400,
|
|
393
|
+
text: () => Promise.resolve('bad config'),
|
|
394
|
+
json: () => Promise.resolve({}),
|
|
395
|
+
});
|
|
396
|
+
await expect(handlers.get('create_connector')({ type: 'custom', name: 'Docs', secret: 'hunter2' })).rejects.toThrow(/400(?!.*hunter2)/s);
|
|
397
|
+
});
|
|
398
|
+
it('create_connector only accepts names the API accepts and an object config', () => {
|
|
399
|
+
const { name, config, secret } = schemas.get('create_connector');
|
|
400
|
+
expect(name.safeParse('Docs 1').success).toBe(true);
|
|
401
|
+
expect(name.safeParse('-docs').success).toBe(false);
|
|
402
|
+
expect(config.safeParse('x').success).toBe(false);
|
|
403
|
+
expect(secret.safeParse('').success).toBe(false);
|
|
404
|
+
});
|
|
357
405
|
it('list_github_installations reads the installations collection', async () => {
|
|
358
406
|
mockFetch.mockResolvedValue(ok([]));
|
|
359
407
|
await handlers.get('list_github_installations')({});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectors.d.ts","sourceRoot":"","sources":["../../src/tools/connectors.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAc,MAAM,oBAAoB,CAAC;AAK1E,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"connectors.d.ts","sourceRoot":"","sources":["../../src/tools/connectors.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAc,MAAM,oBAAoB,CAAC;AAK1E,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,QAgHvD"}
|
package/dist/tools/connectors.js
CHANGED
|
@@ -10,6 +10,31 @@ export function registerConnectorTools(server) {
|
|
|
10
10
|
content: [{ type: 'text', text: toToolText(connectors) }],
|
|
11
11
|
};
|
|
12
12
|
});
|
|
13
|
+
server.tool('create_connector', 'Create a connector of any type the API accepts (github, custom, ferrtrack, ferrvault, ferrgrowth, playwright, gitlab, forgejo, jira, linear). The config shape depends on the type; for custom it is the http transport: url, headers, secret_header. The secret is optional and can be set later in the UI; it is never returned, only has_secret.', {
|
|
14
|
+
type: z.string().min(1).describe('Connector type, for example custom'),
|
|
15
|
+
name: z
|
|
16
|
+
.string()
|
|
17
|
+
.regex(CONNECTOR_NAME_PATTERN)
|
|
18
|
+
.describe('Display name: letters, digits, spaces, underscores and hyphens, up to 63 chars'),
|
|
19
|
+
config: z.record(z.string(), z.unknown()).optional().describe('Type specific config object'),
|
|
20
|
+
secret: z
|
|
21
|
+
.string()
|
|
22
|
+
.min(1)
|
|
23
|
+
.optional()
|
|
24
|
+
.describe('Secret such as an API token; omit it to set it later in the UI'),
|
|
25
|
+
org_id: orgIdSchema,
|
|
26
|
+
}, async ({ type, name, config, secret, org_id }) => {
|
|
27
|
+
const token = await getToken();
|
|
28
|
+
const connector = await fleetRequest('/connectors', {
|
|
29
|
+
method: 'POST',
|
|
30
|
+
body: { type, name, config, secret },
|
|
31
|
+
token,
|
|
32
|
+
orgId: org_id,
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
content: [{ type: 'text', text: toToolText(connector) }],
|
|
36
|
+
};
|
|
37
|
+
});
|
|
13
38
|
server.tool('set_agent_connectors', "Set the connectors attached to an agent. This REPLACES the agent's whole connector list: connectors not in connector_ids are detached, and an empty list detaches all of them. Every id must be a connector of the organization (see list_connectors).", {
|
|
14
39
|
agent_id: z.string().min(1).describe('Agent id'),
|
|
15
40
|
org_id: orgIdSchema,
|
|
@@ -33,7 +58,7 @@ export function registerConnectorTools(server) {
|
|
|
33
58
|
],
|
|
34
59
|
};
|
|
35
60
|
});
|
|
36
|
-
server.tool('update_connector', "Update a FerrFleet connector's name or config. Only the fields you pass change; at least one is required. config REPLACES the whole config object, it is not merged with the existing one. Secrets cannot be
|
|
61
|
+
server.tool('update_connector', "Update a FerrFleet connector's name or config. Only the fields you pass change; at least one is required. config REPLACES the whole config object, it is not merged with the existing one. Secrets cannot be changed through this server.", {
|
|
37
62
|
connector_id: z.string().min(1).describe('Connector id'),
|
|
38
63
|
org_id: orgIdSchema,
|
|
39
64
|
name: z
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/tools/workflows.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/tools/workflows.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAmH9D,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,QAqItD"}
|
package/dist/tools/workflows.js
CHANGED
|
@@ -3,6 +3,14 @@ import { getToken } from '@ferrlabs/mcp-core';
|
|
|
3
3
|
import { fleetRequest, orgIdSchema } from '../api-base.js';
|
|
4
4
|
import { reply } from './reply.js';
|
|
5
5
|
const JOIN_CONDITIONS = ['all_completed', 'all_finished', 'any_completed'];
|
|
6
|
+
const ENTRY_KINDS = ['event', 'cron', 'manual'];
|
|
7
|
+
const OUTPUT_KINDS = [
|
|
8
|
+
'github_comment',
|
|
9
|
+
'github_review',
|
|
10
|
+
'github_issue',
|
|
11
|
+
'ferrtrack_ticket',
|
|
12
|
+
'webhook',
|
|
13
|
+
];
|
|
6
14
|
const STEP_ID_PATTERN = /^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
7
15
|
const stepSchema = z.strictObject({
|
|
8
16
|
id: z
|
|
@@ -31,6 +39,38 @@ const stepSchema = z.strictObject({
|
|
|
31
39
|
.strictObject({ x: z.number(), y: z.number() })
|
|
32
40
|
.describe('Canvas position of the step in the editor'),
|
|
33
41
|
});
|
|
42
|
+
const positionSchema = z
|
|
43
|
+
.strictObject({ x: z.number(), y: z.number() })
|
|
44
|
+
.describe('Canvas position in the editor');
|
|
45
|
+
const entrySchema = z.strictObject({
|
|
46
|
+
id: z
|
|
47
|
+
.string()
|
|
48
|
+
.min(1)
|
|
49
|
+
.describe('Entry id, unique among the steps, entries and outputs of the workflow'),
|
|
50
|
+
kind: z.enum(ENTRY_KINDS).describe('event, cron or manual'),
|
|
51
|
+
cron: z
|
|
52
|
+
.string()
|
|
53
|
+
.optional()
|
|
54
|
+
.describe('Required for cron, refused otherwise: 5 field cron expression, evaluated in UTC'),
|
|
55
|
+
starts: z.array(z.string().min(1)).describe('Ids of the root steps this entry starts'),
|
|
56
|
+
position: positionSchema,
|
|
57
|
+
});
|
|
58
|
+
const outputSchema = z.strictObject({
|
|
59
|
+
id: z
|
|
60
|
+
.string()
|
|
61
|
+
.min(1)
|
|
62
|
+
.describe('Output id, unique among the steps, entries and outputs of the workflow'),
|
|
63
|
+
from: z.string().min(1).describe('Id of the step whose result is delivered'),
|
|
64
|
+
kind: z.enum(OUTPUT_KINDS).describe('Where the result goes'),
|
|
65
|
+
connector_id: z
|
|
66
|
+
.string()
|
|
67
|
+
.optional()
|
|
68
|
+
.describe('Connector of the matching type, from list_connectors (github_*, ferrtrack_ticket)'),
|
|
69
|
+
url: z.string().optional().describe('Target url for a webhook output'),
|
|
70
|
+
project: z.string().optional().describe('Project slug for a ferrtrack_ticket output'),
|
|
71
|
+
repo: z.string().optional().describe('owner/name repository for a github output'),
|
|
72
|
+
position: positionSchema,
|
|
73
|
+
});
|
|
34
74
|
const workflowFields = {
|
|
35
75
|
name: z.string().trim().min(1).max(100).describe('Workflow name'),
|
|
36
76
|
enabled: z.boolean().optional().describe('Whether the workflow can run; defaults to true'),
|
|
@@ -40,28 +80,50 @@ const workflowFields = {
|
|
|
40
80
|
.max(20)
|
|
41
81
|
.describe('One to 20 steps forming an acyclic graph with at least one root. Two steps on the same agent must be ordered with needs'),
|
|
42
82
|
};
|
|
83
|
+
const entriesField = z
|
|
84
|
+
.array(entrySchema)
|
|
85
|
+
.max(10)
|
|
86
|
+
.describe('What starts the workflow: cron schedules, event or manual entries');
|
|
87
|
+
const outputsField = z
|
|
88
|
+
.array(outputSchema)
|
|
89
|
+
.max(10)
|
|
90
|
+
.describe('Where step results are delivered, for example a github_issue');
|
|
91
|
+
const entryAndOutputFields = { entries: entriesField.optional(), outputs: outputsField.optional() };
|
|
43
92
|
const workflowIdSchema = z.guid().describe('Workflow id from list_workflows');
|
|
44
93
|
export function registerWorkflowTools(server) {
|
|
45
94
|
server.tool('list_workflows', "List the organization's workflows.", { org_id: orgIdSchema }, async ({ org_id }) => {
|
|
46
95
|
const token = await getToken();
|
|
47
96
|
return reply(await fleetRequest('/workflows', { token, orgId: org_id }));
|
|
48
97
|
});
|
|
49
|
-
server.tool('get_workflow', 'Get a workflow with its steps.', { workflow_id: workflowIdSchema, org_id: orgIdSchema }, async ({ workflow_id, org_id }) => {
|
|
98
|
+
server.tool('get_workflow', 'Get a workflow with its entries, steps and outputs.', { workflow_id: workflowIdSchema, org_id: orgIdSchema }, async ({ workflow_id, org_id }) => {
|
|
50
99
|
const token = await getToken();
|
|
51
100
|
return reply(await fleetRequest(`/workflows/${workflow_id}`, { token, orgId: org_id }));
|
|
52
101
|
});
|
|
53
|
-
server.tool('create_workflow', 'Create a workflow: a graph of agent steps. The API refuses cycles, unknown needs or agents,
|
|
102
|
+
server.tool('create_workflow', 'Create a workflow: a graph of agent steps, with optional entries (cron, event, manual) and outputs (github_issue and others). The API refuses cycles, unknown needs or agents, two steps on the same agent that could run at the same time, and invalid entries or outputs.', { ...workflowFields, ...entryAndOutputFields, org_id: orgIdSchema }, async ({ org_id, ...body }) => {
|
|
54
103
|
const token = await getToken();
|
|
55
104
|
return reply(await fleetRequest('/workflows', { token, orgId: org_id, method: 'POST', body }));
|
|
56
105
|
});
|
|
57
|
-
server.tool('update_workflow', 'Replace a workflow. Send the whole workflow, not a patch: steps you leave out are removed.
|
|
106
|
+
server.tool('update_workflow', 'Replace a workflow. Send the whole workflow, not a patch: steps you leave out are removed. entries, outputs and enabled keep their current values when omitted; pass entries: [] or outputs: [] to clear them.', {
|
|
107
|
+
workflow_id: workflowIdSchema,
|
|
108
|
+
...workflowFields,
|
|
109
|
+
...entryAndOutputFields,
|
|
110
|
+
org_id: orgIdSchema,
|
|
111
|
+
}, async ({ workflow_id, org_id, ...fields }) => {
|
|
58
112
|
const token = await getToken();
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
113
|
+
const path = `/workflows/${workflow_id}`;
|
|
114
|
+
const needsCurrent = fields.entries === undefined ||
|
|
115
|
+
fields.outputs === undefined ||
|
|
116
|
+
fields.enabled === undefined;
|
|
117
|
+
const current = needsCurrent
|
|
118
|
+
? await fleetRequest(path, { token, orgId: org_id })
|
|
119
|
+
: undefined;
|
|
120
|
+
const body = {
|
|
121
|
+
...fields,
|
|
122
|
+
enabled: fields.enabled ?? current?.enabled,
|
|
123
|
+
entries: fields.entries ?? current?.entries,
|
|
124
|
+
outputs: fields.outputs ?? current?.outputs,
|
|
125
|
+
};
|
|
126
|
+
return reply(await fleetRequest(path, { token, orgId: org_id, method: 'PUT', body }));
|
|
65
127
|
});
|
|
66
128
|
server.tool('delete_workflow', 'Delete a workflow. Fails with workflow_in_use while an event rule names it; change or delete the rule first.', { workflow_id: workflowIdSchema, org_id: orgIdSchema }, async ({ workflow_id, org_id }) => {
|
|
67
129
|
const token = await getToken();
|