@wiro-ai/wiro-mcp 1.3.3 → 1.4.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/README.md +173 -16
- package/dist/client.d.ts +10 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +39 -20
- package/dist/client.js.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/instructions.d.ts +2 -0
- package/dist/instructions.d.ts.map +1 -0
- package/dist/instructions.js +25 -0
- package/dist/instructions.js.map +1 -0
- package/dist/playbooks.d.ts +8 -0
- package/dist/playbooks.d.ts.map +1 -0
- package/dist/playbooks.js +665 -0
- package/dist/playbooks.js.map +1 -0
- package/dist/prompts.d.ts +4 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +133 -0
- package/dist/prompts.js.map +1 -0
- package/dist/server.d.ts +9 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +9 -3
- package/dist/server.js.map +1 -1
- package/dist/tools/apply-agent-skills.d.ts +4 -0
- package/dist/tools/apply-agent-skills.d.ts.map +1 -0
- package/dist/tools/apply-agent-skills.js +545 -0
- package/dist/tools/apply-agent-skills.js.map +1 -0
- package/dist/tools/cancel-agent-message.d.ts +4 -0
- package/dist/tools/cancel-agent-message.d.ts.map +1 -0
- package/dist/tools/cancel-agent-message.js +126 -0
- package/dist/tools/cancel-agent-message.js.map +1 -0
- package/dist/tools/cancel-task.js +3 -3
- package/dist/tools/cancel-task.js.map +1 -1
- package/dist/tools/clone-workflow.d.ts +4 -0
- package/dist/tools/clone-workflow.d.ts.map +1 -0
- package/dist/tools/clone-workflow.js +83 -0
- package/dist/tools/clone-workflow.js.map +1 -0
- package/dist/tools/connect-agent-oauth.d.ts +4 -0
- package/dist/tools/connect-agent-oauth.d.ts.map +1 -0
- package/dist/tools/connect-agent-oauth.js +508 -0
- package/dist/tools/connect-agent-oauth.js.map +1 -0
- package/dist/tools/control-agent.d.ts +4 -0
- package/dist/tools/control-agent.d.ts.map +1 -0
- package/dist/tools/control-agent.js +274 -0
- package/dist/tools/control-agent.js.map +1 -0
- package/dist/tools/create-workflow.d.ts +100 -0
- package/dist/tools/create-workflow.d.ts.map +1 -0
- package/dist/tools/create-workflow.js +103 -0
- package/dist/tools/create-workflow.js.map +1 -0
- package/dist/tools/delete-agent-session.d.ts +6 -0
- package/dist/tools/delete-agent-session.d.ts.map +1 -0
- package/dist/tools/delete-agent-session.js +134 -0
- package/dist/tools/delete-agent-session.js.map +1 -0
- package/dist/tools/delete-agent.d.ts +4 -0
- package/dist/tools/delete-agent.d.ts.map +1 -0
- package/dist/tools/delete-agent.js +144 -0
- package/dist/tools/delete-agent.js.map +1 -0
- package/dist/tools/delete-workflow.d.ts +4 -0
- package/dist/tools/delete-workflow.d.ts.map +1 -0
- package/dist/tools/delete-workflow.js +77 -0
- package/dist/tools/delete-workflow.js.map +1 -0
- package/dist/tools/deploy-agent.d.ts +4 -0
- package/dist/tools/deploy-agent.d.ts.map +1 -0
- package/dist/tools/deploy-agent.js +455 -0
- package/dist/tools/deploy-agent.js.map +1 -0
- package/dist/tools/disconnect-agent-oauth.d.ts +4 -0
- package/dist/tools/disconnect-agent-oauth.d.ts.map +1 -0
- package/dist/tools/disconnect-agent-oauth.js +118 -0
- package/dist/tools/disconnect-agent-oauth.js.map +1 -0
- package/dist/tools/get-account.d.ts +4 -0
- package/dist/tools/get-account.d.ts.map +1 -0
- package/dist/tools/get-account.js +110 -0
- package/dist/tools/get-account.js.map +1 -0
- package/dist/tools/get-agent-activity.d.ts +4 -0
- package/dist/tools/get-agent-activity.d.ts.map +1 -0
- package/dist/tools/get-agent-activity.js +383 -0
- package/dist/tools/get-agent-activity.js.map +1 -0
- package/dist/tools/get-agent-conversation.d.ts +4 -0
- package/dist/tools/get-agent-conversation.d.ts.map +1 -0
- package/dist/tools/get-agent-conversation.js +224 -0
- package/dist/tools/get-agent-conversation.js.map +1 -0
- package/dist/tools/get-agent-message.d.ts +4 -0
- package/dist/tools/get-agent-message.d.ts.map +1 -0
- package/dist/tools/get-agent-message.js +68 -0
- package/dist/tools/get-agent-message.js.map +1 -0
- package/dist/tools/get-agent-template.d.ts +4 -0
- package/dist/tools/get-agent-template.d.ts.map +1 -0
- package/dist/tools/get-agent-template.js +107 -0
- package/dist/tools/get-agent-template.js.map +1 -0
- package/dist/tools/get-model-schema.d.ts +5 -1
- package/dist/tools/get-model-schema.d.ts.map +1 -1
- package/dist/tools/get-model-schema.js +136 -8
- package/dist/tools/get-model-schema.js.map +1 -1
- package/dist/tools/get-my-agent.d.ts +4 -0
- package/dist/tools/get-my-agent.d.ts.map +1 -0
- package/dist/tools/get-my-agent.js +78 -0
- package/dist/tools/get-my-agent.js.map +1 -0
- package/dist/tools/get-playbook.d.ts +3 -0
- package/dist/tools/get-playbook.d.ts.map +1 -0
- package/dist/tools/get-playbook.js +50 -0
- package/dist/tools/get-playbook.js.map +1 -0
- package/dist/tools/get-task-price.d.ts.map +1 -1
- package/dist/tools/get-task-price.js +42 -15
- package/dist/tools/get-task-price.js.map +1 -1
- package/dist/tools/get-task.d.ts.map +1 -1
- package/dist/tools/get-task.js +4 -3
- package/dist/tools/get-task.js.map +1 -1
- package/dist/tools/get-workflow.d.ts +9 -0
- package/dist/tools/get-workflow.d.ts.map +1 -0
- package/dist/tools/get-workflow.js +99 -0
- package/dist/tools/get-workflow.js.map +1 -0
- package/dist/tools/index.d.ts +62 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +127 -14
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/kill-task.d.ts.map +1 -1
- package/dist/tools/kill-task.js +10 -6
- package/dist/tools/kill-task.js.map +1 -1
- package/dist/tools/list-agent-skills.d.ts +4 -0
- package/dist/tools/list-agent-skills.d.ts.map +1 -0
- package/dist/tools/list-agent-skills.js +242 -0
- package/dist/tools/list-agent-skills.js.map +1 -0
- package/dist/tools/list-agent-templates.d.ts +4 -0
- package/dist/tools/list-agent-templates.d.ts.map +1 -0
- package/dist/tools/list-agent-templates.js +110 -0
- package/dist/tools/list-agent-templates.js.map +1 -0
- package/dist/tools/list-my-agents.d.ts +4 -0
- package/dist/tools/list-my-agents.d.ts.map +1 -0
- package/dist/tools/list-my-agents.js +90 -0
- package/dist/tools/list-my-agents.js.map +1 -0
- package/dist/tools/list-studio-results.d.ts +4 -0
- package/dist/tools/list-studio-results.d.ts.map +1 -0
- package/dist/tools/list-studio-results.js +95 -0
- package/dist/tools/list-studio-results.js.map +1 -0
- package/dist/tools/list-tasks.d.ts.map +1 -1
- package/dist/tools/list-tasks.js +7 -5
- package/dist/tools/list-tasks.js.map +1 -1
- package/dist/tools/list-workflow-runs.d.ts +4 -0
- package/dist/tools/list-workflow-runs.d.ts.map +1 -0
- package/dist/tools/list-workflow-runs.js +110 -0
- package/dist/tools/list-workflow-runs.js.map +1 -0
- package/dist/tools/list-workflows.d.ts +4 -0
- package/dist/tools/list-workflows.d.ts.map +1 -0
- package/dist/tools/list-workflows.js +143 -0
- package/dist/tools/list-workflows.js.map +1 -0
- package/dist/tools/manage-agent-billing.d.ts +4 -0
- package/dist/tools/manage-agent-billing.d.ts.map +1 -0
- package/dist/tools/manage-agent-billing.js +764 -0
- package/dist/tools/manage-agent-billing.js.map +1 -0
- package/dist/tools/manage-agent-custom-skill.d.ts +4 -0
- package/dist/tools/manage-agent-custom-skill.d.ts.map +1 -0
- package/dist/tools/manage-agent-custom-skill.js +537 -0
- package/dist/tools/manage-agent-custom-skill.js.map +1 -0
- package/dist/tools/recommend-model.d.ts.map +1 -1
- package/dist/tools/recommend-model.js +6 -5
- package/dist/tools/recommend-model.js.map +1 -1
- package/dist/tools/resume-workflow-run.d.ts +4 -0
- package/dist/tools/resume-workflow-run.d.ts.map +1 -0
- package/dist/tools/resume-workflow-run.js +69 -0
- package/dist/tools/resume-workflow-run.js.map +1 -0
- package/dist/tools/run-model.d.ts.map +1 -1
- package/dist/tools/run-model.js +39 -3
- package/dist/tools/run-model.js.map +1 -1
- package/dist/tools/run-workflow.d.ts +6 -0
- package/dist/tools/run-workflow.d.ts.map +1 -0
- package/dist/tools/run-workflow.js +132 -0
- package/dist/tools/run-workflow.js.map +1 -0
- package/dist/tools/save-workflow-from-agent.d.ts +4 -0
- package/dist/tools/save-workflow-from-agent.d.ts.map +1 -0
- package/dist/tools/save-workflow-from-agent.js +283 -0
- package/dist/tools/save-workflow-from-agent.js.map +1 -0
- package/dist/tools/schemas.d.ts +62 -12
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +17 -3
- package/dist/tools/schemas.js.map +1 -1
- package/dist/tools/search-models.js +6 -6
- package/dist/tools/search-models.js.map +1 -1
- package/dist/tools/send-agent-message.d.ts +4 -0
- package/dist/tools/send-agent-message.d.ts.map +1 -0
- package/dist/tools/send-agent-message.js +156 -0
- package/dist/tools/send-agent-message.js.map +1 -0
- package/dist/tools/set-agent-credentials.d.ts +4 -0
- package/dist/tools/set-agent-credentials.d.ts.map +1 -0
- package/dist/tools/set-agent-credentials.js +529 -0
- package/dist/tools/set-agent-credentials.js.map +1 -0
- package/dist/tools/update-agent.d.ts +4 -0
- package/dist/tools/update-agent.d.ts.map +1 -0
- package/dist/tools/update-agent.js +178 -0
- package/dist/tools/update-agent.js.map +1 -0
- package/dist/tools/update-workflow.d.ts +201 -0
- package/dist/tools/update-workflow.d.ts.map +1 -0
- package/dist/tools/update-workflow.js +168 -0
- package/dist/tools/update-workflow.js.map +1 -0
- package/dist/tools/upload-file.d.ts.map +1 -1
- package/dist/tools/upload-file.js +4 -3
- package/dist/tools/upload-file.js.map +1 -1
- package/dist/tools/wait-for-workflow-run.d.ts +259 -0
- package/dist/tools/wait-for-workflow-run.d.ts.map +1 -0
- package/dist/tools/wait-for-workflow-run.js +190 -0
- package/dist/tools/wait-for-workflow-run.js.map +1 -0
- package/dist/types.d.ts +22 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/agent-catalog.d.ts +1256 -0
- package/dist/utils/agent-catalog.d.ts.map +1 -0
- package/dist/utils/agent-catalog.js +388 -0
- package/dist/utils/agent-catalog.js.map +1 -0
- package/dist/utils/agent-config.d.ts +441 -0
- package/dist/utils/agent-config.d.ts.map +1 -0
- package/dist/utils/agent-config.js +1667 -0
- package/dist/utils/agent-config.js.map +1 -0
- package/dist/utils/agent-message.d.ts +115 -0
- package/dist/utils/agent-message.d.ts.map +1 -0
- package/dist/utils/agent-message.js +246 -0
- package/dist/utils/agent-message.js.map +1 -0
- package/dist/utils/agent-targets.d.ts +76 -0
- package/dist/utils/agent-targets.d.ts.map +1 -0
- package/dist/utils/agent-targets.js +408 -0
- package/dist/utils/agent-targets.js.map +1 -0
- package/dist/utils/agent-turns.d.ts +354 -0
- package/dist/utils/agent-turns.d.ts.map +1 -0
- package/dist/utils/agent-turns.js +623 -0
- package/dist/utils/agent-turns.js.map +1 -0
- package/dist/utils/api.d.ts +40 -0
- package/dist/utils/api.d.ts.map +1 -0
- package/dist/utils/api.js +111 -0
- package/dist/utils/api.js.map +1 -0
- package/dist/utils/format.d.ts +42 -1
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +173 -14
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/media.d.ts +28 -0
- package/dist/utils/media.d.ts.map +1 -0
- package/dist/utils/media.js +65 -0
- package/dist/utils/media.js.map +1 -0
- package/dist/utils/poll.d.ts +39 -0
- package/dist/utils/poll.d.ts.map +1 -0
- package/dist/utils/poll.js +111 -0
- package/dist/utils/poll.js.map +1 -0
- package/dist/utils/remote-file.js +2 -2
- package/dist/utils/remote-file.js.map +1 -1
- package/dist/utils/structured.d.ts +2 -0
- package/dist/utils/structured.d.ts.map +1 -1
- package/dist/utils/structured.js +10 -10
- package/dist/utils/structured.js.map +1 -1
- package/dist/utils/studio-runs.d.ts +87 -0
- package/dist/utils/studio-runs.d.ts.map +1 -0
- package/dist/utils/studio-runs.js +167 -0
- package/dist/utils/studio-runs.js.map +1 -0
- package/dist/utils/user-agent.d.ts +1140 -0
- package/dist/utils/user-agent.d.ts.map +1 -0
- package/dist/utils/user-agent.js +802 -0
- package/dist/utils/user-agent.js.map +1 -0
- package/dist/utils/workflow-agent.d.ts +151 -0
- package/dist/utils/workflow-agent.d.ts.map +1 -0
- package/dist/utils/workflow-agent.js +292 -0
- package/dist/utils/workflow-agent.js.map +1 -0
- package/dist/utils/workflow-artifacts.d.ts +160 -0
- package/dist/utils/workflow-artifacts.d.ts.map +1 -0
- package/dist/utils/workflow-artifacts.js +801 -0
- package/dist/utils/workflow-artifacts.js.map +1 -0
- package/dist/utils/workflow-save.d.ts +123 -0
- package/dist/utils/workflow-save.d.ts.map +1 -0
- package/dist/utils/workflow-save.js +734 -0
- package/dist/utils/workflow-save.js.map +1 -0
- package/dist/utils/workflow.d.ts +559 -0
- package/dist/utils/workflow.d.ts.map +1 -0
- package/dist/utils/workflow.js +613 -0
- package/dist/utils/workflow.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ApiResultError, errorResult, requireApiSuccess } from '../utils/api.js';
|
|
3
|
+
import { DEFAULT_WAIT_SECONDS, MAX_WAIT_SECONDS } from '../utils/poll.js';
|
|
4
|
+
import { agentStatusLabel, agentStatusLabelSchema, agentSummarySchema, describeAgentStatus, isTransitionalStatus, missingCredentialStep, nextStepForAgent, readAgentDetail, readAgentStatus, settledStatusAdvice, toAgentDetail, toAgentSummary, waitForAgentToSettle, } from '../utils/user-agent.js';
|
|
5
|
+
import { nextActionSchema } from './schemas.js';
|
|
6
|
+
const PLAN_KEEPS_RUNNING = 'Stopping does not pause the plan: a wallet plan still renews every 30 days and '
|
|
7
|
+
+ 'starts the agent again. Cancel it with manage_agent_billing to stop paying.';
|
|
8
|
+
function waitAction(guid) {
|
|
9
|
+
return {
|
|
10
|
+
tool: 'get_my_agent',
|
|
11
|
+
arguments: { agent_guid: guid, wait_seconds: DEFAULT_WAIT_SECONDS },
|
|
12
|
+
reason: 'Wait until the agent has settled. Do not repeat the action that started it.',
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function setupRefusal(agent) {
|
|
16
|
+
if (agent.subscription?.status !== 'active') {
|
|
17
|
+
return {
|
|
18
|
+
outcome: 'refused',
|
|
19
|
+
message: 'The agent has no paid plan, so it cannot start. manage_agent_billing with action subscribe '
|
|
20
|
+
+ 'pays for it and starts it.',
|
|
21
|
+
nextAction: {
|
|
22
|
+
tool: 'manage_agent_billing',
|
|
23
|
+
arguments: { agent_guid: agent.guid, action: 'subscribe' },
|
|
24
|
+
reason: 'This returns the price first; nothing is charged without confirm: true.',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const missing = agent.missingCredentials;
|
|
29
|
+
return {
|
|
30
|
+
outcome: 'refused',
|
|
31
|
+
message: `The agent cannot start until its setup is finished${missing.length > 0 ? `: missing ${missing.map(item => item.title).join(', ')}` : ''}. `
|
|
32
|
+
+ 'After the credentials are set, call update_agent with only agent_guid to finish setup, then start it.',
|
|
33
|
+
nextAction: missingCredentialStep(agent) ?? {
|
|
34
|
+
tool: 'update_agent',
|
|
35
|
+
arguments: { agent_guid: agent.guid },
|
|
36
|
+
reason: 'Re-check the setup so the agent can be started.',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Turns the known refusals of Start and Stop into advice. Anything else stays an error. */
|
|
41
|
+
function interpretRefusal(message, agent) {
|
|
42
|
+
if (/subscription required/i.test(message)) {
|
|
43
|
+
const renewable = agent.subscription?.status === 'expired' && agent.subscription.billing === 'wallet';
|
|
44
|
+
return {
|
|
45
|
+
outcome: 'refused',
|
|
46
|
+
message: 'Wiro refused the start: the agent has no active plan and no extra credits left. '
|
|
47
|
+
+ (renewable
|
|
48
|
+
? 'Its wallet plan has expired; manage_agent_billing with action renew restarts it.'
|
|
49
|
+
: 'manage_agent_billing with action subscribe pays for a plan and starts the agent.'),
|
|
50
|
+
nextAction: {
|
|
51
|
+
tool: 'manage_agent_billing',
|
|
52
|
+
arguments: { agent_guid: agent.guid, action: renewable ? 'renew' : 'subscribe' },
|
|
53
|
+
reason: 'This returns the price first; nothing is charged without confirm: true.',
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (/no credits available/i.test(message)) {
|
|
58
|
+
const pro = agent.tier === 'pro';
|
|
59
|
+
return {
|
|
60
|
+
outcome: 'refused',
|
|
61
|
+
message: 'Wiro refused the start: the agent has used all of its credits for this period. '
|
|
62
|
+
+ (pro
|
|
63
|
+
? 'Buy an extra credit pack, or wait for the plan to renew.'
|
|
64
|
+
: 'Upgrade to Pro for a larger monthly pool (Pro can also buy extra packs), or wait for the plan to renew.'),
|
|
65
|
+
nextAction: {
|
|
66
|
+
tool: 'manage_agent_billing',
|
|
67
|
+
arguments: pro
|
|
68
|
+
? { agent_guid: agent.guid, action: 'buy_credits', pack: 'small' }
|
|
69
|
+
: { agent_guid: agent.guid, action: 'upgrade_to_pro' },
|
|
70
|
+
reason: 'This returns the price first; nothing is charged without confirm: true.',
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (/setup is not complete/i.test(message))
|
|
75
|
+
return setupRefusal(agent);
|
|
76
|
+
if (/already (queued|running)/i.test(message)) {
|
|
77
|
+
return { outcome: 'not_needed', message: 'The agent is already queued or running.' };
|
|
78
|
+
}
|
|
79
|
+
if (/already stopped/i.test(message)) {
|
|
80
|
+
return { outcome: 'not_needed', message: 'The agent is already stopped.' };
|
|
81
|
+
}
|
|
82
|
+
if (/currently stopping/i.test(message)) {
|
|
83
|
+
return {
|
|
84
|
+
outcome: 'refused',
|
|
85
|
+
message: 'The agent is still stopping. Wait until it has stopped, then start it.',
|
|
86
|
+
nextAction: waitAction(agent.guid),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
if (/error state/i.test(message)) {
|
|
90
|
+
return {
|
|
91
|
+
outcome: 'not_needed',
|
|
92
|
+
message: 'The agent is in the error state and nothing is running. control_agent with action start retries it.',
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
export function registerControlAgent(server, client) {
|
|
98
|
+
server.registerTool('control_agent', {
|
|
99
|
+
title: 'Start, stop or restart a Wiro agent',
|
|
100
|
+
description: 'Start, stop or restart a deployed agent. Starting needs an active plan or credits left '
|
|
101
|
+
+ 'and charges nothing by itself. Stopping does not pause the plan: a wallet plan still renews every '
|
|
102
|
+
+ '30 days and starts the agent again, so cancel the plan with manage_agent_billing to stop paying. '
|
|
103
|
+
+ 'A restart reloads the agent with its current settings. The change finishes in the background: pass '
|
|
104
|
+
+ 'wait_seconds, or follow the returned nextAction, to see the result. When a start is refused, the '
|
|
105
|
+
+ 'result says what to do next (subscribe, renew, buy credits or finish setup).',
|
|
106
|
+
inputSchema: {
|
|
107
|
+
agent_guid: z.string().min(1).max(100)
|
|
108
|
+
.describe('The deployed agent\'s guid, from list_my_agents or deploy_agent.'),
|
|
109
|
+
action: z.enum(['start', 'stop', 'restart'])
|
|
110
|
+
.describe('start queues a stopped or failed agent, stop shuts it down, restart reloads a running agent.'),
|
|
111
|
+
wait_seconds: z.number().int().min(0).max(MAX_WAIT_SECONDS).default(0)
|
|
112
|
+
.describe('Wait up to this many seconds for the agent to finish starting or stopping (0 to 600, default 0). 45 or less is safe for clients with a 60 second tool timeout; follow nextAction to keep waiting.'),
|
|
113
|
+
},
|
|
114
|
+
outputSchema: {
|
|
115
|
+
action: z.enum(['start', 'stop', 'restart']),
|
|
116
|
+
outcome: z.enum(['requested', 'not_needed', 'refused']),
|
|
117
|
+
previousStatus: z.number().int().nullable(),
|
|
118
|
+
previousStatusLabel: agentStatusLabelSchema,
|
|
119
|
+
status: z.number().int().nullable(),
|
|
120
|
+
statusLabel: agentStatusLabelSchema,
|
|
121
|
+
settled: z.boolean(),
|
|
122
|
+
waitedSeconds: z.number().nonnegative().optional(),
|
|
123
|
+
message: z.string(),
|
|
124
|
+
agent: agentSummarySchema,
|
|
125
|
+
nextAction: nextActionSchema.optional(),
|
|
126
|
+
},
|
|
127
|
+
annotations: {
|
|
128
|
+
readOnlyHint: false,
|
|
129
|
+
destructiveHint: false,
|
|
130
|
+
idempotentHint: false,
|
|
131
|
+
openWorldHint: true,
|
|
132
|
+
},
|
|
133
|
+
}, async ({ agent_guid, action, wait_seconds }, extra) => {
|
|
134
|
+
try {
|
|
135
|
+
const guid = agent_guid.trim();
|
|
136
|
+
const before = await readAgentDetail(client, guid, extra.signal);
|
|
137
|
+
const previous = readAgentStatus(before);
|
|
138
|
+
const current = toAgentDetail(before);
|
|
139
|
+
let call = null;
|
|
140
|
+
let decision = null;
|
|
141
|
+
const stillStopping = {
|
|
142
|
+
outcome: 'refused',
|
|
143
|
+
message: 'The agent is still stopping. If a restart was requested it starts again by itself; otherwise start it once it has stopped.',
|
|
144
|
+
nextAction: waitAction(guid),
|
|
145
|
+
};
|
|
146
|
+
const start = { path: '/UserAgent/Start', fallback: 'The agent could not be started.' };
|
|
147
|
+
if (action === 'start') {
|
|
148
|
+
if (previous === 2 || previous === 3 || previous === 4) {
|
|
149
|
+
decision = { outcome: 'not_needed', message: `The agent is already ${describeAgentStatus(previous).toLowerCase()}.` };
|
|
150
|
+
}
|
|
151
|
+
else if (previous === 1) {
|
|
152
|
+
decision = stillStopping;
|
|
153
|
+
}
|
|
154
|
+
else if (previous === 6) {
|
|
155
|
+
decision = setupRefusal(current);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
call = start;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else if (action === 'stop') {
|
|
162
|
+
if (previous === 0) {
|
|
163
|
+
decision = { outcome: 'not_needed', message: 'The agent is already stopped.' };
|
|
164
|
+
}
|
|
165
|
+
else if (previous === 6) {
|
|
166
|
+
decision = { outcome: 'not_needed', message: 'The agent has never started, so there is nothing to stop.' };
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
call = { path: '/UserAgent/Stop', fallback: 'The agent could not be stopped.' };
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else if (previous === 3 || previous === 4) {
|
|
173
|
+
// A restart is an update: updating a starting or running agent stops
|
|
174
|
+
// it and queues it again. Only `result` is read; the rest of the
|
|
175
|
+
// response is the full agent row, which is not passed on.
|
|
176
|
+
call = { path: '/UserAgent/Update', fallback: 'The agent could not be restarted.' };
|
|
177
|
+
}
|
|
178
|
+
else if (previous === 0 || previous === 5) {
|
|
179
|
+
call = start;
|
|
180
|
+
}
|
|
181
|
+
else if (previous === 2) {
|
|
182
|
+
decision = { outcome: 'not_needed', message: 'The agent is already queued to start.' };
|
|
183
|
+
}
|
|
184
|
+
else if (previous === 1) {
|
|
185
|
+
decision = stillStopping;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
decision = setupRefusal(current);
|
|
189
|
+
}
|
|
190
|
+
if (call) {
|
|
191
|
+
try {
|
|
192
|
+
requireApiSuccess(await client.post(call.path, { guid }, extra.signal), call.fallback);
|
|
193
|
+
const label = call.path === '/UserAgent/Start'
|
|
194
|
+
? 'Start requested. The agent is queued and starts on its own; this can take a while.'
|
|
195
|
+
: call.path === '/UserAgent/Stop'
|
|
196
|
+
? `Stop requested. ${PLAN_KEEPS_RUNNING}`
|
|
197
|
+
: 'Restart requested. The agent stops and starts again with its current settings.';
|
|
198
|
+
const missing = current.missingCredentials;
|
|
199
|
+
decision = {
|
|
200
|
+
outcome: 'requested',
|
|
201
|
+
message: label + (call.path !== '/UserAgent/Stop' && missing.length > 0
|
|
202
|
+
? ` Missing credentials: ${missing.map(item => item.title).join(', ')}. Skills that need them fail until they are set.`
|
|
203
|
+
: ''),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
const refusal = error instanceof ApiResultError ? interpretRefusal(error.message, current) : null;
|
|
208
|
+
if (!refusal)
|
|
209
|
+
throw error;
|
|
210
|
+
decision = refusal;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const result = decision ?? { outcome: 'not_needed', message: 'Nothing to do.' };
|
|
214
|
+
let after = before;
|
|
215
|
+
let settled = !isTransitionalStatus(previous);
|
|
216
|
+
let waitedSeconds;
|
|
217
|
+
let readFailed = false;
|
|
218
|
+
if (result.outcome === 'requested' || (wait_seconds > 0 && !settled)) {
|
|
219
|
+
try {
|
|
220
|
+
const waited = await waitForAgentToSettle(client, guid, wait_seconds, extra, before);
|
|
221
|
+
after = waited.row;
|
|
222
|
+
settled = waited.settled;
|
|
223
|
+
if (wait_seconds > 0)
|
|
224
|
+
waitedSeconds = Math.round(waited.elapsedMs / 1000);
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
if (extra.signal.aborted)
|
|
228
|
+
throw error;
|
|
229
|
+
// The action itself went through; only the follow-up read failed.
|
|
230
|
+
readFailed = true;
|
|
231
|
+
settled = false;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
const afterView = toAgentDetail(after);
|
|
235
|
+
const status = readAgentStatus(after);
|
|
236
|
+
let message = result.message + (readFailed ? ' The new status could not be read; get_my_agent shows it.' : '');
|
|
237
|
+
let nextAction = result.nextAction;
|
|
238
|
+
if (result.outcome === 'requested' || result.outcome === 'not_needed') {
|
|
239
|
+
if (!settled) {
|
|
240
|
+
nextAction = waitAction(guid);
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
if (waitedSeconds !== undefined)
|
|
244
|
+
message += ` ${settledStatusAdvice(status)}`;
|
|
245
|
+
nextAction = action === 'stop' ? undefined : nextAction ?? nextStepForAgent(afterView, DEFAULT_WAIT_SECONDS);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
content: [{
|
|
250
|
+
type: 'text',
|
|
251
|
+
text: `## ${action[0].toUpperCase()}${action.slice(1)}: ${result.outcome.replace('_', ' ')}\n\n${message}\n\n`
|
|
252
|
+
+ `**Status:** ${describeAgentStatus(previous)} before, ${describeAgentStatus(status)} now.`,
|
|
253
|
+
}],
|
|
254
|
+
structuredContent: {
|
|
255
|
+
action,
|
|
256
|
+
outcome: result.outcome,
|
|
257
|
+
previousStatus: previous,
|
|
258
|
+
previousStatusLabel: agentStatusLabel(previous),
|
|
259
|
+
status,
|
|
260
|
+
statusLabel: agentStatusLabel(status),
|
|
261
|
+
settled,
|
|
262
|
+
...(waitedSeconds !== undefined ? { waitedSeconds } : {}),
|
|
263
|
+
message,
|
|
264
|
+
agent: toAgentSummary(after),
|
|
265
|
+
...(nextAction ? { nextAction } : {}),
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
return errorResult(error);
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=control-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-agent.js","sourceRoot":"","sources":["../../src/tools/control-agent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,oBAAoB,GAGrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAUhD,MAAM,kBAAkB,GAAG,iFAAiF;MACxG,6EAA6E,CAAC;AAElF,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO;QACL,IAAI,EAAE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C,OAAO;qBAC/F,CAAC;gBACF,iBAAiB,EAAE;oBACjB,MAAM;oBACN,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,cAAc,EAAE,QAAQ;oBACxB,mBAAmB,EAAE,gBAAgB,CAAC,QAAQ,CAAC;oBAC/C,MAAM;oBACN,WAAW,EAAE,gBAAgB,CAAC,MAAM,CAAC;oBACrC,OAAO;oBACP,GAAG,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBACzD,OAAO;oBACP,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC;oBAC5B,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACtC;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { WiroClient } from '../client.js';
|
|
4
|
+
export declare const prepareIssueSchema: z.ZodObject<{
|
|
5
|
+
code: z.ZodOptional<z.ZodString>;
|
|
6
|
+
message: z.ZodString;
|
|
7
|
+
nodeId: z.ZodOptional<z.ZodString>;
|
|
8
|
+
input: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
message: string;
|
|
11
|
+
input?: string | undefined;
|
|
12
|
+
code?: string | undefined;
|
|
13
|
+
nodeId?: string | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
message: string;
|
|
16
|
+
input?: string | undefined;
|
|
17
|
+
code?: string | undefined;
|
|
18
|
+
nodeId?: string | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const savedWorkflowSchema: {
|
|
21
|
+
fullSlug: z.ZodString;
|
|
22
|
+
url: z.ZodString;
|
|
23
|
+
title: z.ZodString;
|
|
24
|
+
renamed: z.ZodBoolean;
|
|
25
|
+
state: z.ZodOptional<z.ZodEnum<["private", "pending_review", "published", "rejected"]>>;
|
|
26
|
+
updatetime: z.ZodOptional<z.ZodString>;
|
|
27
|
+
inputs: z.ZodArray<z.ZodObject<{
|
|
28
|
+
key: z.ZodString;
|
|
29
|
+
label: z.ZodString;
|
|
30
|
+
type: z.ZodString;
|
|
31
|
+
field: z.ZodOptional<z.ZodString>;
|
|
32
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
33
|
+
value: z.ZodString;
|
|
34
|
+
text: z.ZodString;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
text: string;
|
|
37
|
+
value: string;
|
|
38
|
+
}, {
|
|
39
|
+
text: string;
|
|
40
|
+
value: string;
|
|
41
|
+
}>, "many">>;
|
|
42
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
43
|
+
savedValue: z.ZodOptional<z.ZodUnknown>;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
type: string;
|
|
46
|
+
label: string;
|
|
47
|
+
key: string;
|
|
48
|
+
default?: unknown;
|
|
49
|
+
options?: {
|
|
50
|
+
text: string;
|
|
51
|
+
value: string;
|
|
52
|
+
}[] | undefined;
|
|
53
|
+
field?: string | undefined;
|
|
54
|
+
savedValue?: unknown;
|
|
55
|
+
}, {
|
|
56
|
+
type: string;
|
|
57
|
+
label: string;
|
|
58
|
+
key: string;
|
|
59
|
+
default?: unknown;
|
|
60
|
+
options?: {
|
|
61
|
+
text: string;
|
|
62
|
+
value: string;
|
|
63
|
+
}[] | undefined;
|
|
64
|
+
field?: string | undefined;
|
|
65
|
+
savedValue?: unknown;
|
|
66
|
+
}>, "many">;
|
|
67
|
+
outputs: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
68
|
+
warnings: z.ZodArray<z.ZodObject<{
|
|
69
|
+
code: z.ZodOptional<z.ZodString>;
|
|
70
|
+
message: z.ZodString;
|
|
71
|
+
nodeId: z.ZodOptional<z.ZodString>;
|
|
72
|
+
input: z.ZodOptional<z.ZodString>;
|
|
73
|
+
}, "strip", z.ZodTypeAny, {
|
|
74
|
+
message: string;
|
|
75
|
+
input?: string | undefined;
|
|
76
|
+
code?: string | undefined;
|
|
77
|
+
nodeId?: string | undefined;
|
|
78
|
+
}, {
|
|
79
|
+
message: string;
|
|
80
|
+
input?: string | undefined;
|
|
81
|
+
code?: string | undefined;
|
|
82
|
+
nodeId?: string | undefined;
|
|
83
|
+
}>, "many">;
|
|
84
|
+
nextAction: z.ZodOptional<z.ZodObject<{
|
|
85
|
+
tool: z.ZodString;
|
|
86
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
87
|
+
reason: z.ZodString;
|
|
88
|
+
}, "strip", z.ZodTypeAny, {
|
|
89
|
+
arguments: Record<string, unknown>;
|
|
90
|
+
tool: string;
|
|
91
|
+
reason: string;
|
|
92
|
+
}, {
|
|
93
|
+
arguments: Record<string, unknown>;
|
|
94
|
+
tool: string;
|
|
95
|
+
reason: string;
|
|
96
|
+
}>>;
|
|
97
|
+
};
|
|
98
|
+
export declare const workflowContentsInputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
99
|
+
export declare function registerCreateWorkflow(server: McpServer, client: WiroClient): void;
|
|
100
|
+
//# sourceMappingURL=create-workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-workflow.d.ts","sourceRoot":"","sources":["../../src/tools/create-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAY/C,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;EAK7B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAW/B,CAAC;AAEF,eAAO,MAAM,2BAA2B,wCAEwC,CAAC;AAEjF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CA+ElF"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { errorResult, isPlainObject } from '../utils/api.js';
|
|
3
|
+
import { formatWorkflowInputs, workflowInputSchema } from '../utils/workflow.js';
|
|
4
|
+
import { createWorkflow, findHiddenValues, prepareIssuesText, tagProblem, WorkflowPrepareError, } from '../utils/workflow-save.js';
|
|
5
|
+
import { nextActionSchema } from './schemas.js';
|
|
6
|
+
export const prepareIssueSchema = z.object({
|
|
7
|
+
code: z.string().optional(),
|
|
8
|
+
message: z.string(),
|
|
9
|
+
nodeId: z.string().optional(),
|
|
10
|
+
input: z.string().optional(),
|
|
11
|
+
});
|
|
12
|
+
export const savedWorkflowSchema = {
|
|
13
|
+
fullSlug: z.string(),
|
|
14
|
+
url: z.string(),
|
|
15
|
+
title: z.string(),
|
|
16
|
+
renamed: z.boolean(),
|
|
17
|
+
state: z.enum(['private', 'pending_review', 'published', 'rejected']).optional(),
|
|
18
|
+
updatetime: z.string().optional(),
|
|
19
|
+
inputs: z.array(workflowInputSchema),
|
|
20
|
+
outputs: z.record(z.string(), z.unknown()),
|
|
21
|
+
warnings: z.array(prepareIssueSchema),
|
|
22
|
+
nextAction: nextActionSchema.optional(),
|
|
23
|
+
};
|
|
24
|
+
export const workflowContentsInputSchema = z.record(z.string(), z.unknown())
|
|
25
|
+
.describe('The workflow graph (version "1"): {version, nodes, output, schema, metadata}. '
|
|
26
|
+
+ 'Read get_playbook topic "workflow-graph" for the format and an example.');
|
|
27
|
+
export function registerCreateWorkflow(server, client) {
|
|
28
|
+
server.registerTool('create_workflow', {
|
|
29
|
+
title: 'Create a Wiro workflow',
|
|
30
|
+
description: 'Save a new private workflow in the API key\'s workspace from a step graph. '
|
|
31
|
+
+ 'Read get_playbook topic "workflow-graph" first: it has the graph format, the reference '
|
|
32
|
+
+ 'syntax and examples. Check every model\'s parameter ids and values with get_model_schema: '
|
|
33
|
+
+ 'a model step\'s values, such as a duration, a size or an option, are checked when that '
|
|
34
|
+
+ 'step runs. Wiro checks the graph against the live model catalog, fills catalog defaults '
|
|
35
|
+
+ 'and lays the steps out before saving; every problem it finds comes back together, so fix '
|
|
36
|
+
+ 'them all and call again. Set every model input you care about: a left-out one gets the model\'s '
|
|
37
|
+
+ 'default, which for some models is the sample prompt or sample images from its page '
|
|
38
|
+
+ '(the Notes in the result list what was filled). The graph can be at most 40 KB of JSON '
|
|
39
|
+
+ 'with those defaults. Free. Each call creates another workflow. The result gives the '
|
|
40
|
+
+ 'full slug, the page link and the input keys, so no get_workflow call is needed to run it.',
|
|
41
|
+
inputSchema: {
|
|
42
|
+
title: z.string().trim().min(1).max(160).describe('Workflow title (1-160 characters).'),
|
|
43
|
+
contents: workflowContentsInputSchema,
|
|
44
|
+
description: z.string().max(1000).optional().describe('What the workflow does (up to 1000 characters).'),
|
|
45
|
+
tags: z.array(z.string()).max(20).optional().describe('Up to 20 tags.'),
|
|
46
|
+
},
|
|
47
|
+
outputSchema: savedWorkflowSchema,
|
|
48
|
+
annotations: {
|
|
49
|
+
readOnlyHint: false,
|
|
50
|
+
destructiveHint: false,
|
|
51
|
+
idempotentHint: false,
|
|
52
|
+
openWorldHint: true,
|
|
53
|
+
},
|
|
54
|
+
}, async ({ title, contents, description, tags }, extra) => {
|
|
55
|
+
try {
|
|
56
|
+
const problem = tags ? tagProblem(tags) : null;
|
|
57
|
+
if (problem)
|
|
58
|
+
throw new Error(problem);
|
|
59
|
+
if (!isPlainObject(contents.nodes) || !isPlainObject(contents.nodes.output)) {
|
|
60
|
+
throw new Error('contents.nodes must include the End node "output". See get_playbook topic "workflow-graph".');
|
|
61
|
+
}
|
|
62
|
+
const hidden = findHiddenValues(contents);
|
|
63
|
+
if (hidden.length > 0) {
|
|
64
|
+
throw new Error(`Some values are placeholders for hidden secrets (${hidden.join(', ')}). `
|
|
65
|
+
+ 'Remove those values and keep the Start fields and steps they belong to. Never put a key, token or password there; '
|
|
66
|
+
+ 'set a real value only when it is not secret.');
|
|
67
|
+
}
|
|
68
|
+
const saved = await createWorkflow(client, { title, contents, description, tags }, extra.signal);
|
|
69
|
+
const lines = ['## Workflow created', ''];
|
|
70
|
+
lines.push(`**Title:** ${saved.title}${saved.renamed ? ' (renamed because the title was already used)' : ''}`);
|
|
71
|
+
lines.push(`**Slug:** \`${saved.fullSlug}\``);
|
|
72
|
+
lines.push(`**Page:** ${saved.url}`);
|
|
73
|
+
lines.push('', '### Inputs', '', ...formatWorkflowInputs(saved.inputs));
|
|
74
|
+
if (saved.warnings.length > 0) {
|
|
75
|
+
lines.push('', '### Notes', '', ...saved.warnings.map(warning => `- ${warning.nodeId ? `\`${warning.nodeId}\`: ` : ''}${warning.message}`));
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
content: [{ type: 'text', text: lines.join('\n') }],
|
|
79
|
+
structuredContent: {
|
|
80
|
+
...saved,
|
|
81
|
+
nextAction: {
|
|
82
|
+
tool: 'run_workflow',
|
|
83
|
+
arguments: { slug: saved.fullSlug },
|
|
84
|
+
reason: 'Run it only if the user asked for a run, after telling them the estimate; otherwise ask the user first (each model step is charged). Pass input values'
|
|
85
|
+
+ (saved.inputs.length > 0
|
|
86
|
+
? ` for: ${saved.inputs.map(input => input.key).join(', ')}. A key you leave out uses its saved value or default.`
|
|
87
|
+
: '. It has no inputs.'),
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
if (error instanceof WorkflowPrepareError) {
|
|
94
|
+
return {
|
|
95
|
+
content: [{ type: 'text', text: prepareIssuesText(error) }],
|
|
96
|
+
isError: true,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return errorResult(error);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=create-workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-workflow.js","sourceRoot":"","sources":["../../src/tools/create-workflow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,oBAAoB,GACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,g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C,IAAI,CAAC,IAAI,CAAC,wDAAwD;gCAClH,CAAC,CAAC,qBAAqB,CAAC;qBAC7B;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,oBAAoB,EAAE,CAAC;gBAC1C,OAAO;oBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;oBACpE,OAAO,EAAE,IAAI;iBACd,CAAC;YACJ,CAAC;YACD,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { WiroClient } from '../client.js';
|
|
3
|
+
/** Pause before the second look at a session list that did not show the session. */
|
|
4
|
+
export declare const SESSION_RECHECK_MS = 2000;
|
|
5
|
+
export declare function registerDeleteAgentSession(server: McpServer, client: WiroClient): void;
|
|
6
|
+
//# sourceMappingURL=delete-agent-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-agent-session.d.ts","sourceRoot":"","sources":["../../src/tools/delete-agent-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAuC/C,oFAAoF;AACpF,eAAO,MAAM,kBAAkB,OAAQ,CAAC;AAqBxC,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAyGtF"}
|