@wiro-ai/wiro-mcp 1.4.1 → 1.5.1
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 +38 -15
- package/dist/client.d.ts +19 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +44 -27
- package/dist/client.js.map +1 -1
- package/dist/instructions.d.ts.map +1 -1
- package/dist/instructions.js +7 -4
- package/dist/instructions.js.map +1 -1
- package/dist/playbooks.d.ts.map +1 -1
- package/dist/playbooks.js +46 -35
- package/dist/playbooks.js.map +1 -1
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +3 -2
- package/dist/prompts.js.map +1 -1
- package/dist/tools/apply-agent-skills.d.ts.map +1 -1
- package/dist/tools/apply-agent-skills.js +458 -109
- package/dist/tools/apply-agent-skills.js.map +1 -1
- package/dist/tools/bind-agent-project.d.ts +4 -0
- package/dist/tools/bind-agent-project.d.ts.map +1 -0
- package/dist/tools/bind-agent-project.js +405 -0
- package/dist/tools/bind-agent-project.js.map +1 -0
- package/dist/tools/cancel-agent-message.d.ts.map +1 -1
- package/dist/tools/cancel-agent-message.js +6 -3
- package/dist/tools/cancel-agent-message.js.map +1 -1
- package/dist/tools/cancel-task.js +3 -3
- package/dist/tools/cancel-task.js.map +1 -1
- package/dist/tools/clone-workflow.d.ts.map +1 -1
- package/dist/tools/clone-workflow.js +5 -4
- package/dist/tools/clone-workflow.js.map +1 -1
- package/dist/tools/connect-agent-oauth.d.ts.map +1 -1
- package/dist/tools/connect-agent-oauth.js +161 -40
- package/dist/tools/connect-agent-oauth.js.map +1 -1
- package/dist/tools/control-agent.d.ts.map +1 -1
- package/dist/tools/control-agent.js +109 -36
- package/dist/tools/control-agent.js.map +1 -1
- package/dist/tools/create-workflow.d.ts +3 -0
- package/dist/tools/create-workflow.d.ts.map +1 -1
- package/dist/tools/create-workflow.js +12 -11
- package/dist/tools/create-workflow.js.map +1 -1
- package/dist/tools/delete-agent-session.d.ts.map +1 -1
- package/dist/tools/delete-agent-session.js +18 -12
- package/dist/tools/delete-agent-session.js.map +1 -1
- package/dist/tools/delete-agent.d.ts.map +1 -1
- package/dist/tools/delete-agent.js +12 -9
- package/dist/tools/delete-agent.js.map +1 -1
- package/dist/tools/delete-workflow.d.ts.map +1 -1
- package/dist/tools/delete-workflow.js +5 -4
- package/dist/tools/delete-workflow.js.map +1 -1
- package/dist/tools/deploy-agent.d.ts.map +1 -1
- package/dist/tools/deploy-agent.js +239 -46
- package/dist/tools/deploy-agent.js.map +1 -1
- package/dist/tools/disconnect-agent-oauth.d.ts.map +1 -1
- package/dist/tools/disconnect-agent-oauth.js +32 -12
- package/dist/tools/disconnect-agent-oauth.js.map +1 -1
- package/dist/tools/get-account.d.ts.map +1 -1
- package/dist/tools/get-account.js +148 -42
- package/dist/tools/get-account.js.map +1 -1
- package/dist/tools/get-agent-activity.d.ts.map +1 -1
- package/dist/tools/get-agent-activity.js +185 -35
- package/dist/tools/get-agent-activity.js.map +1 -1
- package/dist/tools/get-agent-conversation.d.ts.map +1 -1
- package/dist/tools/get-agent-conversation.js +57 -35
- package/dist/tools/get-agent-conversation.js.map +1 -1
- package/dist/tools/get-agent-message.d.ts.map +1 -1
- package/dist/tools/get-agent-message.js +6 -4
- package/dist/tools/get-agent-message.js.map +1 -1
- package/dist/tools/get-agent-template.d.ts.map +1 -1
- package/dist/tools/get-agent-template.js +13 -17
- package/dist/tools/get-agent-template.js.map +1 -1
- package/dist/tools/get-model-schema.js +3 -3
- package/dist/tools/get-model-schema.js.map +1 -1
- package/dist/tools/get-my-agent.d.ts.map +1 -1
- package/dist/tools/get-my-agent.js +13 -8
- package/dist/tools/get-my-agent.js.map +1 -1
- package/dist/tools/get-playbook.d.ts.map +1 -1
- package/dist/tools/get-playbook.js +3 -2
- package/dist/tools/get-playbook.js.map +1 -1
- package/dist/tools/get-task-price.js +3 -3
- package/dist/tools/get-task-price.js.map +1 -1
- package/dist/tools/get-task.js +3 -3
- package/dist/tools/get-task.js.map +1 -1
- package/dist/tools/get-workflow.d.ts.map +1 -1
- package/dist/tools/get-workflow.js +38 -19
- package/dist/tools/get-workflow.js.map +1 -1
- package/dist/tools/index.d.ts +3 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +6 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/kill-task.js +3 -3
- package/dist/tools/kill-task.js.map +1 -1
- package/dist/tools/list-agent-skills.d.ts.map +1 -1
- package/dist/tools/list-agent-skills.js +11 -8
- package/dist/tools/list-agent-skills.js.map +1 -1
- package/dist/tools/list-agent-templates.js +4 -4
- package/dist/tools/list-agent-templates.js.map +1 -1
- package/dist/tools/list-my-agents.d.ts.map +1 -1
- package/dist/tools/list-my-agents.js +11 -8
- package/dist/tools/list-my-agents.js.map +1 -1
- package/dist/tools/list-projects.d.ts +4 -0
- package/dist/tools/list-projects.d.ts.map +1 -0
- package/dist/tools/list-projects.js +141 -0
- package/dist/tools/list-projects.js.map +1 -0
- package/dist/tools/list-studio-results.js +3 -3
- package/dist/tools/list-studio-results.js.map +1 -1
- package/dist/tools/list-tasks.js +3 -3
- package/dist/tools/list-tasks.js.map +1 -1
- package/dist/tools/list-workflow-runs.d.ts.map +1 -1
- package/dist/tools/list-workflow-runs.js +6 -4
- package/dist/tools/list-workflow-runs.js.map +1 -1
- package/dist/tools/list-workflows.d.ts.map +1 -1
- package/dist/tools/list-workflows.js +7 -6
- package/dist/tools/list-workflows.js.map +1 -1
- package/dist/tools/manage-agent-billing.d.ts.map +1 -1
- package/dist/tools/manage-agent-billing.js +207 -59
- package/dist/tools/manage-agent-billing.js.map +1 -1
- package/dist/tools/manage-agent-custom-skill.d.ts.map +1 -1
- package/dist/tools/manage-agent-custom-skill.js +119 -15
- package/dist/tools/manage-agent-custom-skill.js.map +1 -1
- package/dist/tools/recommend-model.js +3 -3
- package/dist/tools/recommend-model.js.map +1 -1
- package/dist/tools/resume-workflow-run.d.ts.map +1 -1
- package/dist/tools/resume-workflow-run.js +3 -2
- package/dist/tools/resume-workflow-run.js.map +1 -1
- package/dist/tools/run-model.js +3 -3
- package/dist/tools/run-model.js.map +1 -1
- package/dist/tools/run-workflow.d.ts.map +1 -1
- package/dist/tools/run-workflow.js +3 -2
- package/dist/tools/run-workflow.js.map +1 -1
- package/dist/tools/save-workflow-from-agent.d.ts.map +1 -1
- package/dist/tools/save-workflow-from-agent.js +17 -12
- package/dist/tools/save-workflow-from-agent.js.map +1 -1
- package/dist/tools/schemas.d.ts +32 -26
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +67 -0
- package/dist/tools/schemas.js.map +1 -1
- package/dist/tools/search-docs.js +3 -3
- package/dist/tools/search-docs.js.map +1 -1
- package/dist/tools/search-models.js +3 -3
- package/dist/tools/search-models.js.map +1 -1
- package/dist/tools/send-agent-message.d.ts.map +1 -1
- package/dist/tools/send-agent-message.js +30 -9
- package/dist/tools/send-agent-message.js.map +1 -1
- package/dist/tools/set-agent-credentials.d.ts.map +1 -1
- package/dist/tools/set-agent-credentials.js +55 -61
- package/dist/tools/set-agent-credentials.js.map +1 -1
- package/dist/tools/update-agent.d.ts.map +1 -1
- package/dist/tools/update-agent.js +59 -20
- package/dist/tools/update-agent.js.map +1 -1
- package/dist/tools/update-workflow.d.ts +199 -0
- package/dist/tools/update-workflow.d.ts.map +1 -1
- package/dist/tools/update-workflow.js +20 -7
- package/dist/tools/update-workflow.js.map +1 -1
- package/dist/tools/upload-file.js +3 -3
- package/dist/tools/upload-file.js.map +1 -1
- package/dist/tools/wait-for-task.js +3 -3
- package/dist/tools/wait-for-task.js.map +1 -1
- package/dist/tools/wait-for-workflow-run.d.ts +3 -3
- package/dist/tools/wait-for-workflow-run.d.ts.map +1 -1
- package/dist/tools/wait-for-workflow-run.js +7 -6
- package/dist/tools/wait-for-workflow-run.js.map +1 -1
- package/dist/utils/agent-catalog.d.ts +59 -0
- package/dist/utils/agent-catalog.d.ts.map +1 -1
- package/dist/utils/agent-catalog.js +28 -7
- package/dist/utils/agent-catalog.js.map +1 -1
- package/dist/utils/agent-config.d.ts +172 -9
- package/dist/utils/agent-config.d.ts.map +1 -1
- package/dist/utils/agent-config.js +416 -60
- package/dist/utils/agent-config.js.map +1 -1
- package/dist/utils/agent-message.d.ts +36 -14
- package/dist/utils/agent-message.d.ts.map +1 -1
- package/dist/utils/agent-message.js +92 -26
- package/dist/utils/agent-message.js.map +1 -1
- package/dist/utils/agent-targets.d.ts +7 -3
- package/dist/utils/agent-targets.d.ts.map +1 -1
- package/dist/utils/agent-targets.js +35 -23
- package/dist/utils/agent-targets.js.map +1 -1
- package/dist/utils/agent-turns.d.ts +19 -12
- package/dist/utils/agent-turns.d.ts.map +1 -1
- package/dist/utils/agent-turns.js +97 -15
- package/dist/utils/agent-turns.js.map +1 -1
- package/dist/utils/api.d.ts +6 -0
- package/dist/utils/api.d.ts.map +1 -1
- package/dist/utils/api.js +22 -1
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +7 -13
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/json-schema-dialect.d.ts.map +1 -1
- package/dist/utils/json-schema-dialect.js +4 -0
- package/dist/utils/json-schema-dialect.js.map +1 -1
- package/dist/utils/media.d.ts +8 -0
- package/dist/utils/media.d.ts.map +1 -1
- package/dist/utils/media.js +29 -0
- package/dist/utils/media.js.map +1 -1
- package/dist/utils/poll.d.ts +5 -2
- package/dist/utils/poll.d.ts.map +1 -1
- package/dist/utils/poll.js +10 -9
- package/dist/utils/poll.js.map +1 -1
- package/dist/utils/quoted-text.d.ts +28 -0
- package/dist/utils/quoted-text.d.ts.map +1 -0
- package/dist/utils/quoted-text.js +64 -0
- package/dist/utils/quoted-text.js.map +1 -0
- package/dist/utils/studio-runs.d.ts.map +1 -1
- package/dist/utils/studio-runs.js +7 -4
- package/dist/utils/studio-runs.js.map +1 -1
- package/dist/utils/user-agent.d.ts +197 -29
- package/dist/utils/user-agent.d.ts.map +1 -1
- package/dist/utils/user-agent.js +314 -48
- package/dist/utils/user-agent.js.map +1 -1
- package/dist/utils/wiro-project.d.ts +45 -0
- package/dist/utils/wiro-project.d.ts.map +1 -0
- package/dist/utils/wiro-project.js +66 -0
- package/dist/utils/wiro-project.js.map +1 -0
- package/dist/utils/workflow-save.d.ts +22 -1
- package/dist/utils/workflow-save.d.ts.map +1 -1
- package/dist/utils/workflow-save.js +122 -24
- package/dist/utils/workflow-save.js.map +1 -1
- package/dist/utils/workflow.d.ts +26 -13
- package/dist/utils/workflow.d.ts.map +1 -1
- package/dist/utils/workflow.js +51 -20
- package/dist/utils/workflow.js.map +1 -1
- package/dist/utils/workspace.d.ts +30 -4
- package/dist/utils/workspace.d.ts.map +1 -1
- package/dist/utils/workspace.js +95 -12
- package/dist/utils/workspace.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,8 @@ import { z } from 'zod';
|
|
|
2
2
|
import { apiErrorMessage, errorResult } from '../utils/api.js';
|
|
3
3
|
import { agentMessageSchema, formatAgentMessage, messageStateSchema, } from '../utils/agent-message.js';
|
|
4
4
|
import { AGENT_INPUT_DESCRIPTION, agentRequestBody, callAgent, readAgentMessage, resolveAgentTarget, resolveReadSession, } from '../utils/agent-targets.js';
|
|
5
|
-
import { notFoundMessage, projectAgentMessage } from '../utils/agent-turns.js';
|
|
5
|
+
import { costPendingNote, isCostPending, notFoundMessage, projectAgentMessage } from '../utils/agent-turns.js';
|
|
6
|
+
import { strictInput } from './schemas.js';
|
|
6
7
|
// The cancel is written at once, but a turn that is already finishing can still
|
|
7
8
|
// end normally, so the result is read back after a short pause.
|
|
8
9
|
const READ_BACK_DELAY_MS = 1_500;
|
|
@@ -33,12 +34,12 @@ export function registerCancelAgentMessage(server, client) {
|
|
|
33
34
|
+ 'can still finish normally if it was already completing, so the final status is read back and '
|
|
34
35
|
+ 'returned. Usage up to the cancel stays billed. For Studio, model runs the turn already started keep '
|
|
35
36
|
+ 'running and cannot be stopped from here; list_studio_results shows them.',
|
|
36
|
-
inputSchema: {
|
|
37
|
+
inputSchema: strictInput({
|
|
37
38
|
agent: z.string().min(1).describe(AGENT_INPUT_DESCRIPTION),
|
|
38
39
|
message_id: z.string().min(1).describe('The message id from send_agent_message.'),
|
|
39
40
|
session: z.string().optional().describe('The session the message was sent in. Required for Studio and '
|
|
40
41
|
+ 'the Workflow Agent unless it was "default".'),
|
|
41
|
-
},
|
|
42
|
+
}),
|
|
42
43
|
outputSchema: {
|
|
43
44
|
agent: z.string(),
|
|
44
45
|
agentKind: z.enum(['studio', 'workflow-agent', 'deployed']),
|
|
@@ -88,6 +89,8 @@ export function registerCancelAgentMessage(server, client) {
|
|
|
88
89
|
await delay(READ_BACK_DELAY_MS, extra.signal);
|
|
89
90
|
const row = await readAgentMessage(client, target, message_id, readSession, extra.signal);
|
|
90
91
|
message = projectAgentMessage(target, row, false).message;
|
|
92
|
+
if (isCostPending(row, true))
|
|
93
|
+
notes.push(costPendingNote(target, row.status));
|
|
91
94
|
}
|
|
92
95
|
catch (error) {
|
|
93
96
|
if (extra.signal.aborted)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancel-agent-message.js","sourceRoot":"","sources":["../../src/tools/cancel-agent-message.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GAEnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"cancel-agent-message.js","sourceRoot":"","sources":["../../src/tools/cancel-agent-message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AK,QAAQ,EAAE,CAAC;gBAC7B,KAAK,CAAC,IAAI,CAAC,oFAAoF;sBAC3F,iCAAiC,CAAC,CAAC;YACzC,CAAC;YAED,MAAM,KAAK,GAAG,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC;YAC1C,IAAI,OAAO;gBAAE,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;YACrE,KAAK,MAAM,IAAI,IAAI,KAAK;gBAAE,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;YAClD,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC5D,iBAAiB,EAAE;oBACjB,GAAG,IAAI;oBACP,cAAc,EAAE,IAAI;oBACpB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBACvF,KAAK;iBACN;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { taskActionOutputSchema } from './schemas.js';
|
|
2
|
+
import { strictInput, taskActionOutputSchema } from './schemas.js';
|
|
3
3
|
export function registerCancelTask(server, client) {
|
|
4
4
|
server.registerTool('cancel_task', {
|
|
5
5
|
title: 'Cancel a queued Wiro task',
|
|
6
6
|
description: 'Cancel a model task that is still queued. It is refused once '
|
|
7
7
|
+ 'the task has started; `kill_task` stops a task in either state. A '
|
|
8
8
|
+ 'task cancelled while queued is never charged.',
|
|
9
|
-
inputSchema: {
|
|
9
|
+
inputSchema: strictInput({
|
|
10
10
|
tasktoken: z.string().optional().describe('The task token returned from run_model.'),
|
|
11
11
|
taskid: z.string().optional().describe('The task ID (alternative to tasktoken).'),
|
|
12
|
-
},
|
|
12
|
+
}),
|
|
13
13
|
outputSchema: taskActionOutputSchema,
|
|
14
14
|
annotations: {
|
|
15
15
|
readOnlyHint: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancel-task.js","sourceRoot":"","sources":["../../src/tools/cancel-task.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"cancel-task.js","sourceRoot":"","sources":["../../src/tools/cancel-task.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEnE,MAAM,UAAU,kBAAkB,CAAC,MAAiB,EAAE,MAAkB;IACtE,MAAM,CAAC,YAAY,CACjB,aAAa,EACb;QACE,KAAK,EAAE,2BAA2B;QAClC,WAAW,EAAE,+DAA+D;cACxE,oEAAoE;cACpE,+CAA+C;QACnD,WAAW,EAAE,WAAW,CAAC;YACvB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yCAAyC,CAAC;YACpF,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yCAAyC,CAAC;SAClF,CAAC;QACF,YAAY,EAAE,sBAAsB;QACpC,WAAW,EAAE;YACX,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,IAAI;YACrB,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,IAAI;SACpB;KACF,EACD,KAAK,EAAE,EAAE,SA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KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,eAAe,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;gBACnH,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clone-workflow.d.ts","sourceRoot":"","sources":["../../src/tools/clone-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"clone-workflow.d.ts","sourceRoot":"","sources":["../../src/tools/clone-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAU/C,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAmFjF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ApiResultError, asString, errorResult, requireApiSuccess, toInteger } from '../utils/api.js';
|
|
3
|
+
import { quotedSpan } from '../utils/quoted-text.js';
|
|
3
4
|
import { fullSlugOf, parseWorkflowSlug, workflowUrl } from '../utils/workflow.js';
|
|
4
|
-
import { nextActionSchema } from './schemas.js';
|
|
5
|
+
import { nextActionSchema, strictInput } from './schemas.js';
|
|
5
6
|
export function registerCloneWorkflow(server, client) {
|
|
6
7
|
server.registerTool('clone_workflow', {
|
|
7
8
|
title: 'Clone a public Wiro workflow',
|
|
@@ -10,10 +11,10 @@ export function registerCloneWorkflow(server, client) {
|
|
|
10
11
|
+ 'just to run a public workflow; clone it to keep it or to edit it. A copy of a '
|
|
11
12
|
+ 'protected workflow keeps its steps hidden: you can run it and change its title, '
|
|
12
13
|
+ 'description and tags, but not its steps.',
|
|
13
|
-
inputSchema: {
|
|
14
|
+
inputSchema: strictInput({
|
|
14
15
|
slug: z.string().min(1)
|
|
15
16
|
.describe('The full slug or page URL of a published workflow from list_workflows scope "public".'),
|
|
16
|
-
},
|
|
17
|
+
}),
|
|
17
18
|
outputSchema: {
|
|
18
19
|
fullSlug: z.string(),
|
|
19
20
|
url: z.string(),
|
|
@@ -39,7 +40,7 @@ export function registerCloneWorkflow(server, client) {
|
|
|
39
40
|
return {
|
|
40
41
|
content: [{
|
|
41
42
|
type: 'text',
|
|
42
|
-
text: `## Workflow cloned\n\n**Title:** ${title}\n**Slug:** \`${fullSlug}\`\n**Page:** ${workflowUrl(fullSlug)}`
|
|
43
|
+
text: `## Workflow cloned\n\n**Title:** ${quotedSpan(title)}\n**Slug:** \`${fullSlug}\`\n**Page:** ${workflowUrl(fullSlug)}`
|
|
43
44
|
+ (isProtected ? '\n\nThe original is protected, so the copy\'s steps stay hidden. You can still run it.' : ''),
|
|
44
45
|
}],
|
|
45
46
|
structuredContent: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clone-workflow.js","sourceRoot":"","sources":["../../src/tools/clone-workflow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,SAAS,EAAoB,MAAM,iBAAiB,CAAC;AACxH,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"clone-workflow.js","sourceRoot":"","sources":["../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AI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;oBAC7D,OAAO,WAAW,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,CAAC,OAAO,wDAAwD;0BACjG,uBAAuB,SAAS,sDAAsD,CAAC,CAAC,CAAC;gBAC/F,CAAC;gBACD,kFAAkF;gBAClF,kFAAkF;gBAClF,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;oBAC5C,OAAO,WAAW,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,CAAC,OAAO,oEAAoE;0BAC7G,sGAAsG;0BACtG,2CAA2C,SAAS,4CAA4C;0BAChG,4CAA4C,CAAC,CAAC,CAAC;gBACrD,CAAC;YACH,CAAC;YACD,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect-agent-oauth.d.ts","sourceRoot":"","sources":["../../src/tools/connect-agent-oauth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"connect-agent-oauth.d.ts","sourceRoot":"","sources":["../../src/tools/connect-agent-oauth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAkqB/C,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CA2FrF"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { asString, errorResult, errorText, isPlainObject, requireApiSuccess, } from '../utils/api.js';
|
|
3
|
-
import { OAUTH_LINK_TTL_SECONDS, buildChainedSelections, buildPickerAccounts, chooseConnectionMode, connectionModeRequirements, connectionState, credentialGroup, dashboardAgentUrl, isAllowedRedirectUrl, loadCredentialMeta, ownAppRedirectUri, parseDiscoveredGroups, readOAuthStatus, readUserAgent, toAccountRefs, } from '../utils/agent-config.js';
|
|
2
|
+
import { apiErrorMessage, asString, errorResult, errorText, isPlainObject, requireApiSuccess, } from '../utils/api.js';
|
|
3
|
+
import { CONNECTION_NOT_CLEARED, OAUTH_LINK_TTL_SECONDS, accountLabel, agentStatusOf, buildChainedSelections, buildPickerAccounts, chooseConnectionMode, connectionModeRequirements, connectionRefusalText, connectionState, credentialGroup, customSkillEntries, dashboardAgentUrl, entriesTurnedOnBy, isAgentRunning, isAllowedRedirectUrl, isFilledValue, loadCredentialMeta, loadSkillRegistry, ownAppRedirectUri, parseDiscoveredGroups, pausedSkillTitles, readOAuthStatus, readUserAgent, skillTitles, toAccountRefs, turnOnSkillText, unusedCredential, unusedCredentialNote, writeOnlyModesNote, } from '../utils/agent-config.js';
|
|
4
4
|
import { DEFAULT_WAIT_SECONDS, MAX_WAIT_SECONDS, pollUntil, reportProgress, } from '../utils/poll.js';
|
|
5
|
-
import {
|
|
5
|
+
import { jsonSpan } from '../utils/quoted-text.js';
|
|
6
|
+
import { readStatusAdvice, skillOffTasksNote, startNeedsPlan, taskLabel, taskNamedByWiro, toAgentDetail, waitingTaskSentence, WIRO_PROJECT_CREDENTIAL } from '../utils/user-agent.js';
|
|
7
|
+
import { nextActionSchema, strictInput } from './schemas.js';
|
|
6
8
|
const accountSchema = z.object({ id: z.string(), name: z.string() });
|
|
7
9
|
const outputSchema = {
|
|
8
10
|
action: z.enum(['connect', 'status', 'select_accounts']),
|
|
@@ -43,7 +45,7 @@ const outputSchema = {
|
|
|
43
45
|
mode: z.string(),
|
|
44
46
|
available: z.boolean(),
|
|
45
47
|
needsBrowser: z.boolean(),
|
|
46
|
-
fields: z.array(z.object({ field: z.string(), label: z.string(), isSet: z.boolean() })),
|
|
48
|
+
fields: z.array(z.object({ field: z.string(), label: z.string(), isSet: z.boolean(), writeOnly: z.boolean().optional() })),
|
|
47
49
|
note: z.string(),
|
|
48
50
|
})).optional(),
|
|
49
51
|
ownAppRedirectUri: z.string().optional(),
|
|
@@ -52,9 +54,6 @@ const outputSchema = {
|
|
|
52
54
|
};
|
|
53
55
|
const DONE_STATES = new Set(['connected', 'pick_accounts', 'pick_child_items']);
|
|
54
56
|
function oauthHint(message, meta) {
|
|
55
|
-
if (/not found or unauthorized/i.test(message)) {
|
|
56
|
-
return 'Integrations can only be connected with a project created by the person who deployed the agent: connect this server with such a project, by its API key or a browser sign-in.';
|
|
57
|
-
}
|
|
58
57
|
if (/credentials not configured/i.test(message)) {
|
|
59
58
|
return `Save your own ${meta.title} app keys with set_agent_credentials first (call it with credential "${meta.key}" to see the fields).`;
|
|
60
59
|
}
|
|
@@ -93,7 +92,7 @@ function childStepOf(picker, groups, configured) {
|
|
|
93
92
|
};
|
|
94
93
|
}
|
|
95
94
|
function accountsLine(accounts) {
|
|
96
|
-
return accounts.map(
|
|
95
|
+
return accounts.map(accountLabel).join(', ');
|
|
97
96
|
}
|
|
98
97
|
function result(action, context, state, message, extra = {}, textExtra = []) {
|
|
99
98
|
const lines = [
|
|
@@ -103,7 +102,7 @@ function result(action, context, state, message, extra = {}, textExtra = []) {
|
|
|
103
102
|
...textExtra,
|
|
104
103
|
];
|
|
105
104
|
if (isPlainObject(extra.nextAction)) {
|
|
106
|
-
lines.push('', `Next: call ${String(extra.nextAction.tool)} with ${
|
|
105
|
+
lines.push('', `Next: call ${String(extra.nextAction.tool)} with ${jsonSpan(extra.nextAction.arguments)}.`);
|
|
107
106
|
}
|
|
108
107
|
return {
|
|
109
108
|
content: [{ type: 'text', text: lines.join('\n') }],
|
|
@@ -121,13 +120,52 @@ function result(action, context, state, message, extra = {}, textExtra = []) {
|
|
|
121
120
|
function modeLines(modes) {
|
|
122
121
|
return [
|
|
123
122
|
'',
|
|
124
|
-
...modes.filter(mode => mode.available).map(mode => `- **${mode.mode}**: ${mode.note}${mode.fields.length > 0 ? ` Fields: ${mode.fields.map(field => `${field.field}${field.isSet ? ' (set)' : ' (missing)'}`).join(', ')}.` : ''}`),
|
|
123
|
+
...modes.filter(mode => mode.available).map(mode => `- **${mode.mode}**: ${mode.note}${mode.fields.length > 0 ? ` Fields: ${mode.fields.map(field => `${field.field}${field.isSet ? ' (set)' : field.writeOnly ? '' : ' (missing)'}`).join(', ')}.` : ''}`),
|
|
125
124
|
];
|
|
126
125
|
}
|
|
126
|
+
/** The answer to a connect that the rule on unused credentials refuses, or null when it may go ahead. */
|
|
127
|
+
function unusedCredentialRefusal(row, context, registry) {
|
|
128
|
+
const { credential, meta } = context;
|
|
129
|
+
const unused = unusedCredential(row, credential, registry);
|
|
130
|
+
if (!unused)
|
|
131
|
+
return null;
|
|
132
|
+
return [
|
|
133
|
+
`${meta.title} is not used by any of this agent's active skills, custom skills or scheduled tasks, so nothing was started.`,
|
|
134
|
+
unused.services.length > 0
|
|
135
|
+
? `Services its skills connect with this tool: ${unused.services.join(', ')}.`
|
|
136
|
+
: 'None of its skills connect a service with this tool.',
|
|
137
|
+
turnOnSkillText(meta.title, credential, unused.skills),
|
|
138
|
+
credentialGroup(row, credential)?._connected === true ? `${meta.title} is still connected from before; disconnect_agent_oauth removes that connection.` : '',
|
|
139
|
+
].filter(Boolean).join(' ');
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* What a finished sign-in does to the entries that need the service (entriesTurnedOnBy): the ones it turns on,
|
|
143
|
+
* the ones it turns on that stay paused for skills that are off, the tasks already on that start running, and
|
|
144
|
+
* those that still wait for skills. Each task is named as people see it, and each skill by its title. A task
|
|
145
|
+
* that is on runs only while the agent runs, so on an agent that is not running it would run once it starts.
|
|
146
|
+
*/
|
|
147
|
+
function turnsOnNote({ on, paused, starts, waiting }, { meta }, titles, running) {
|
|
148
|
+
if (on.length === 0 && paused.length === 0 && starts.length === 0 && waiting.length === 0)
|
|
149
|
+
return '';
|
|
150
|
+
const names = (entries) => entries.map(entry => taskLabel(entry.key, taskNamedByWiro(entry))).join(', ');
|
|
151
|
+
const startRunning = running
|
|
152
|
+
? `${starts.length > 1 ? 'start' : 'starts'} running once ${meta.title} is connected`
|
|
153
|
+
: `would run once ${meta.title} is connected and the agent starts`;
|
|
154
|
+
const sentence = (on.length > 0 ? ` ${names(on)} ${on.length > 1 ? 'turn' : 'turns'} on once ${meta.title} is connected.` : '')
|
|
155
|
+
+ paused.map(task => waitingTaskSentence(task.key, task.groups, titles, 'turns on but stays paused')).join('')
|
|
156
|
+
+ (starts.length > 0 ? ` ${names(starts)} ${startRunning}.` : '')
|
|
157
|
+
+ waiting.map(task => waitingTaskSentence(task.key, task.groups, titles, 'stays paused')).join('');
|
|
158
|
+
return [...on, ...starts].some(entry => entry.kind === 'scheduled_task') || paused.length > 0
|
|
159
|
+
? `${sentence} Every run of a scheduled task uses credits; turn off any you do not want with manage_agent_custom_skill.`
|
|
160
|
+
: sentence;
|
|
161
|
+
}
|
|
127
162
|
async function connect(context, input) {
|
|
128
163
|
const { client, agentGuid, credential, meta, signal } = context;
|
|
129
164
|
const oauth = meta.oauth;
|
|
130
165
|
const row = await readUserAgent(client, agentGuid, signal);
|
|
166
|
+
const refusal = unusedCredentialRefusal(row, context, await loadSkillRegistry(client, signal));
|
|
167
|
+
if (refusal)
|
|
168
|
+
return errorResult(new Error(refusal));
|
|
131
169
|
const group = credentialGroup(row, credential);
|
|
132
170
|
const modes = connectionModeRequirements(meta, group);
|
|
133
171
|
const redirectUri = meta.connectionModes.includes('own') ? ownAppRedirectUri(meta) : undefined;
|
|
@@ -143,7 +181,8 @@ async function connect(context, input) {
|
|
|
143
181
|
const mode = input.mode ?? chooseConnectionMode(meta, modes);
|
|
144
182
|
const requirement = modes.find(candidate => candidate.mode === mode);
|
|
145
183
|
if (!mode || !requirement) {
|
|
146
|
-
|
|
184
|
+
const savedKeysNote = writeOnlyModesNote(modes);
|
|
185
|
+
return result('connect', context, 'setup_needed', `Choose how to connect ${meta.title}: it needs your own app keys or a token saved first.${savedKeysNote ? ` ${savedKeysNote}` : ''}`, { ...setupExtra, nextAction: describeAction }, modeLines(modes));
|
|
147
186
|
}
|
|
148
187
|
if (!requirement.available) {
|
|
149
188
|
return result('connect', context, 'setup_needed', `${requirement.note}`, { ...setupExtra, mode, nextAction: describeAction }, modeLines(modes));
|
|
@@ -151,13 +190,27 @@ async function connect(context, input) {
|
|
|
151
190
|
if (mode === 'api_key' && !oauth.directProbe) {
|
|
152
191
|
return result('connect', context, 'setup_needed', requirement.note, { ...setupExtra, mode, nextAction: describeAction }, modeLines(modes));
|
|
153
192
|
}
|
|
154
|
-
|
|
193
|
+
// App keys read as empty even once saved, so for those the sign-in route below decides.
|
|
194
|
+
const missing = requirement.fields.filter(field => !field.isSet && !field.writeOnly);
|
|
155
195
|
if (missing.length > 0) {
|
|
156
196
|
return result('connect', context, 'setup_needed', `Mode ${mode} needs these saved first with set_agent_credentials: ${missing.map(field => `${field.label} (${field.field})`).join(', ')}. ${requirement.note}`, { ...setupExtra, mode, nextAction: describeAction });
|
|
157
197
|
}
|
|
158
198
|
const connectedBefore = group?._connected === true;
|
|
159
|
-
|
|
160
|
-
|
|
199
|
+
// A sign-in removes what is saved for the modes it leaves.
|
|
200
|
+
const removed = mode === oauth.directProbe?.mode
|
|
201
|
+
? []
|
|
202
|
+
: meta.fields.filter(field => !field.oauthManaged
|
|
203
|
+
&& field.onlyInModes?.length
|
|
204
|
+
&& !field.onlyInModes.includes(mode)
|
|
205
|
+
&& isFilledValue(group?.[field.key]));
|
|
206
|
+
const appKeys = requirement.fields.filter(field => field.writeOnly);
|
|
207
|
+
if ((connectedBefore || removed.length > 0) && !input.confirm) {
|
|
208
|
+
const saveKeysFirst = removed.length > 0 && appKeys.length > 0
|
|
209
|
+
? ' Save the app keys first if they are not saved yet, so the sign-in can start.'
|
|
210
|
+
: '';
|
|
211
|
+
return result('connect', context, 'confirm_needed', `${connectedBefore
|
|
212
|
+
? `${meta.title} is already connected. Connecting again replaces that connection and its selected accounts; if the new sign-in or check fails, the agent is left without it.`
|
|
213
|
+
: `Connecting ${meta.title} with mode ${mode} removes the saved ${removed.map(field => field.label).join(', ')}.`}${saveKeysFirst}`, {
|
|
161
214
|
mode,
|
|
162
215
|
nextAction: {
|
|
163
216
|
tool: 'connect_agent_oauth',
|
|
@@ -175,7 +228,8 @@ async function connect(context, input) {
|
|
|
175
228
|
}
|
|
176
229
|
if (oauth.directProbe && mode === oauth.directProbe.mode) {
|
|
177
230
|
// The check reads the mode from the saved credential, so it is saved first.
|
|
178
|
-
|
|
231
|
+
const modeSaved = asString(group?.authmethod) !== mode;
|
|
232
|
+
if (modeSaved) {
|
|
179
233
|
requireApiSuccess(await client.post('/UserAgent/CredentialUpsert', {
|
|
180
234
|
useragentguid: agentGuid,
|
|
181
235
|
fields: [{ credentialkey: credential, fieldname: 'authmethod', fieldvalue: mode }],
|
|
@@ -190,6 +244,8 @@ async function connect(context, input) {
|
|
|
190
244
|
const code = asString(body.errorcode);
|
|
191
245
|
const message = (body.errors ?? []).map(error => error?.message?.trim()).filter(Boolean).join(' ')
|
|
192
246
|
|| `${meta.title} could not be checked.`;
|
|
247
|
+
if (message === CONNECTION_NOT_CLEARED)
|
|
248
|
+
return errorResult(new Error(message));
|
|
193
249
|
const parts = [code ? `${message} (${code})` : message];
|
|
194
250
|
if (code === 'direct_token_missing') {
|
|
195
251
|
parts.push(`Save ${requirement.fields.map(field => field.field).join(', ')} with set_agent_credentials first.`);
|
|
@@ -197,6 +253,12 @@ async function connect(context, input) {
|
|
|
197
253
|
else if (connectedBefore) {
|
|
198
254
|
parts.push('Connect again to restore the connection.');
|
|
199
255
|
}
|
|
256
|
+
// An error result reads as nothing done, so it says what the check still did.
|
|
257
|
+
if (modeSaved)
|
|
258
|
+
parts.push(`The mode is saved as ${mode}.`);
|
|
259
|
+
if ((modeSaved || code) && isAgentRunning(agentStatusOf(row))) {
|
|
260
|
+
parts.push('The running agent restarts, which takes about a minute.');
|
|
261
|
+
}
|
|
200
262
|
return errorResult(new Error(parts.join(' ')));
|
|
201
263
|
}
|
|
202
264
|
const candidates = toAccountRefs(body.accounts, oauth.picker);
|
|
@@ -212,7 +274,7 @@ async function connect(context, input) {
|
|
|
212
274
|
? 'Save the only available account.'
|
|
213
275
|
: 'Ask the user which accounts to use, then save only those.',
|
|
214
276
|
},
|
|
215
|
-
}, ['', ...candidates.map(account => `- ${
|
|
277
|
+
}, ['', ...candidates.map(account => `- ${accountLabel(account)}`)]);
|
|
216
278
|
}
|
|
217
279
|
return result('connect', context, 'connected', `${meta.title} is connected. A running agent restarts to use it.`, { mode });
|
|
218
280
|
}
|
|
@@ -227,12 +289,23 @@ async function connect(context, input) {
|
|
|
227
289
|
catch {
|
|
228
290
|
since = '';
|
|
229
291
|
}
|
|
230
|
-
const
|
|
292
|
+
const answer = await client.post('/UserAgentOAuth/OAuthConnect', {
|
|
231
293
|
useragentguid: agentGuid,
|
|
232
294
|
credentialkey: credential,
|
|
233
295
|
authmethod: mode,
|
|
234
296
|
redirecturl: redirectUrl,
|
|
235
|
-
}, signal)
|
|
297
|
+
}, signal);
|
|
298
|
+
if (answer.result !== true && appKeys.length > 0 && /credentials not configured/i.test(apiErrorMessage(answer, ''))) {
|
|
299
|
+
// What the sign-in removes may be gone already, so this answer goes by a fresh read.
|
|
300
|
+
const fresh = removed.length > 0 ? await readUserAgent(client, agentGuid, signal).catch(() => null) : null;
|
|
301
|
+
const groupNow = fresh ? credentialGroup(fresh, credential) : group;
|
|
302
|
+
const gone = removed.filter(field => !isFilledValue(groupNow?.[field.key]));
|
|
303
|
+
const goneText = gone.length > 0
|
|
304
|
+
? ` The sign-in did not start, and this call removed the saved ${gone.map(field => field.label).join(', ')}${connectedBefore && groupNow?._connected !== true ? `, so ${meta.title} is no longer connected` : ''}. To go back to it, save it again with set_agent_credentials.`
|
|
305
|
+
: '';
|
|
306
|
+
return result('connect', context, 'setup_needed', `Mode ${mode} needs these saved first with set_agent_credentials: ${appKeys.map(field => `${field.label} (${field.field})`).join(', ')}. ${requirement.note}${goneText}`, { ...setupExtra, connectionModes: connectionModeRequirements(meta, groupNow), mode, nextAction: describeAction });
|
|
307
|
+
}
|
|
308
|
+
const body = requireApiSuccess(answer, `Could not start the ${meta.title} sign-in.`);
|
|
236
309
|
const authorizeUrl = asString(body.authorizeUrl);
|
|
237
310
|
if (!authorizeUrl)
|
|
238
311
|
throw new Error(`Wiro did not return a sign-in link for ${meta.title}.`);
|
|
@@ -240,7 +313,9 @@ async function connect(context, input) {
|
|
|
240
313
|
const after = usesDashboard
|
|
241
314
|
? `After approving, the browser returns to the agent's page in the Wiro dashboard${oauth.picker ? ', which asks which accounts the agent should use' : ''}. Use a browser where the user is signed in to wiro.ai as the agent's owner.`
|
|
242
315
|
: `After approving, the browser goes to ${redirectUrl}.`;
|
|
243
|
-
|
|
316
|
+
const turnsOn = entriesTurnedOnBy(row, credential);
|
|
317
|
+
const titles = await skillTitles(client, [...turnsOn.paused, ...turnsOn.waiting].flatMap(task => task.groups.flat()), signal);
|
|
318
|
+
return result('connect', context, 'authorize_in_browser', `The user must open this link in their own browser and approve access. It works for ${OAUTH_LINK_TTL_SECONDS / 60} minutes. ${after}${turnsOnNote(turnsOn, context, titles, isAgentRunning(agentStatusOf(row)))} Give the link to the user and check the status once they say they are done.`, {
|
|
244
319
|
mode,
|
|
245
320
|
authorizeUrl,
|
|
246
321
|
expiresInSeconds: OAUTH_LINK_TTL_SECONDS,
|
|
@@ -258,7 +333,24 @@ async function connect(context, input) {
|
|
|
258
333
|
},
|
|
259
334
|
}, ['', authorizeUrl]);
|
|
260
335
|
}
|
|
261
|
-
|
|
336
|
+
/**
|
|
337
|
+
* What to do about access that reads as expired. A start is offered only when one can
|
|
338
|
+
* happen. Without the agent's row the offer stays: control_agent reads the agent again
|
|
339
|
+
* and says what comes first.
|
|
340
|
+
*/
|
|
341
|
+
function expiredAdvice(row) {
|
|
342
|
+
const startOrConnect = 'Start the agent with control_agent, or connect again.';
|
|
343
|
+
if (!row)
|
|
344
|
+
return startOrConnect;
|
|
345
|
+
const agent = toAgentDetail(row);
|
|
346
|
+
if ((agent.status === 0 || agent.status === 5) && !startNeedsPlan(agent))
|
|
347
|
+
return startOrConnect;
|
|
348
|
+
return agent.status === 3 || agent.status === 4
|
|
349
|
+
? 'If the agent cannot use it, connect again.'
|
|
350
|
+
: `Connect again if the agent needs it. ${readStatusAdvice(agent)}`;
|
|
351
|
+
}
|
|
352
|
+
function statusMessage(state, meta, snapshot, unusedNote, row) {
|
|
353
|
+
const saved = row !== null && credentialGroup(row, meta.key)?._connected === true;
|
|
262
354
|
const next = meta.oauth?.picker?.next;
|
|
263
355
|
switch (state) {
|
|
264
356
|
case 'connected': {
|
|
@@ -274,9 +366,11 @@ function statusMessage(state, meta, snapshot) {
|
|
|
274
366
|
case 'waiting_for_user':
|
|
275
367
|
return `The ${meta.title} sign-in has not finished yet. The link from connect works for ${OAUTH_LINK_TTL_SECONDS / 60} minutes; after that, connect again.`;
|
|
276
368
|
case 'token_expired':
|
|
277
|
-
return `The saved ${meta.title} access has expired
|
|
369
|
+
return `The saved ${meta.title} access has expired.${saved ? ` The connection is still saved, so get_my_agent lists ${meta.title} as connected.` : ''} ${unusedNote ?? expiredAdvice(row)}`;
|
|
278
370
|
default:
|
|
279
|
-
return
|
|
371
|
+
return saved
|
|
372
|
+
? `This check found no current ${meta.title} sign-in, but a ${meta.title} connection is saved on this agent, so get_my_agent lists it as connected. ${unusedNote ?? 'If the agent cannot use it, connect again: that replaces the saved connection and asks for confirm: true.'}`
|
|
373
|
+
: `${meta.title} is not connected. ${unusedNote ?? 'Start with action connect.'}`;
|
|
280
374
|
}
|
|
281
375
|
}
|
|
282
376
|
async function status(context, input, extra) {
|
|
@@ -296,6 +390,8 @@ async function status(context, input, extra) {
|
|
|
296
390
|
throw new Error(`Could not read the ${meta.title} connection status.`);
|
|
297
391
|
const state = stateOf(snapshot);
|
|
298
392
|
let nextAction;
|
|
393
|
+
let unusedNote = null;
|
|
394
|
+
let row = null;
|
|
299
395
|
if (state === 'waiting_for_user') {
|
|
300
396
|
nextAction = {
|
|
301
397
|
tool: 'connect_agent_oauth',
|
|
@@ -317,16 +413,33 @@ async function status(context, input, extra) {
|
|
|
317
413
|
};
|
|
318
414
|
}
|
|
319
415
|
else if (state === 'not_connected' || state === 'token_expired') {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
416
|
+
// Only these states offer connect, so only they read the skills. A status is
|
|
417
|
+
// still answered when that read fails: connect goes by the rule anyway.
|
|
418
|
+
row = await readUserAgent(client, agentGuid, signal).catch(() => null);
|
|
419
|
+
unusedNote = row ? await unusedCredentialNote(client, row, credential, meta.title, signal) : null;
|
|
420
|
+
if (!unusedNote) {
|
|
421
|
+
nextAction = {
|
|
422
|
+
tool: 'connect_agent_oauth',
|
|
423
|
+
arguments: { action: 'connect', agent_guid: agentGuid, credential },
|
|
424
|
+
reason: `Connect ${meta.title}.`,
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
// Once connected, the scheduled tasks that need this service and still wait for a skill are named, with the
|
|
429
|
+
// skills they wait for. A status is still answered when the agent cannot be read.
|
|
430
|
+
let pausedNote = '';
|
|
431
|
+
if (state === 'connected') {
|
|
432
|
+
row = await readUserAgent(client, agentGuid, signal).catch(() => null);
|
|
433
|
+
const paused = row
|
|
434
|
+
? customSkillEntries(row).filter(entry => entry.kind === 'scheduled_task' && entry.skillOff
|
|
435
|
+
&& (entry.requiresCredentials.includes(credential) || (entry.usableCredentials ?? []).includes(credential)))
|
|
436
|
+
: [];
|
|
437
|
+
pausedNote = skillOffTasksNote(paused, await pausedSkillTitles(client, paused, signal));
|
|
325
438
|
}
|
|
326
439
|
const childStep = snapshot.childStep
|
|
327
440
|
? { ...snapshot.childStep, label: picker?.next?.label ?? snapshot.childStep.picker }
|
|
328
441
|
: undefined;
|
|
329
|
-
return result('status', context, state, statusMessage(state, meta, snapshot
|
|
442
|
+
return result('status', context, state, `${statusMessage(state, meta, snapshot, unusedNote, row)}${pausedNote}`, {
|
|
330
443
|
...(snapshot.connectedAt ? { connectedAt: snapshot.connectedAt } : {}),
|
|
331
444
|
...(snapshot.tokenExpiresAt ? { tokenExpiresAt: snapshot.tokenExpiresAt } : {}),
|
|
332
445
|
accounts: snapshot.accounts,
|
|
@@ -368,8 +481,8 @@ async function selectAccounts(context, input) {
|
|
|
368
481
|
reason: 'Ask the user which ones to keep; this preselects all of them.',
|
|
369
482
|
},
|
|
370
483
|
}, ['', ...groups.flatMap(group => [
|
|
371
|
-
`- ${
|
|
372
|
-
...group.items.map(item => ` - ${
|
|
484
|
+
`- ${accountLabel(group.parent)}${group.errorCode ? `: could not be read (${group.errorCode})` : ''}`,
|
|
485
|
+
...group.items.map(item => ` - ${accountLabel(item)}`),
|
|
373
486
|
])]);
|
|
374
487
|
}
|
|
375
488
|
const built = buildChainedSelections(next, groups, input.selections);
|
|
@@ -438,13 +551,16 @@ export function registerConnectAgentOauth(server, client) {
|
|
|
438
551
|
+ 'save. action status: whether the sign-in finished (wait_seconds waits for '
|
|
439
552
|
+ 'the user). action select_accounts: saves which accounts the agent uses ({id, name} from '
|
|
440
553
|
+ 'connect), and with picker runs the extra step some providers have (Meta Ads pages, '
|
|
441
|
-
+ 'Google Business locations). Connecting again replaces an existing connection and
|
|
442
|
-
+ 'confirm: true. A running agent restarts when a connection or selection is saved. '
|
|
443
|
-
+ '
|
|
444
|
-
+ '
|
|
554
|
+
+ 'Google Business locations). Connecting again replaces an existing connection, and a sign-in removes a token saved for another mode; both need '
|
|
555
|
+
+ 'confirm: true. A running agent restarts when a connection or selection is saved. Connecting a service '
|
|
556
|
+
+ 'turns on the scheduled tasks that need it, and the result names any that stay paused until a skill they need is on; '
|
|
557
|
+
+ 'turn off any you do not want. '
|
|
558
|
+
+ 'Remove a connection with disconnect_agent_oauth. A credential that none of the agent\'s active '
|
|
559
|
+
+ 'skills use, that no custom skill or scheduled task of the agent requires, and that its setup does not wait for, is refused before any link is made (get_my_agent '
|
|
560
|
+
+ 'lists the skills; apply_agent_skills turns one on). Only the person who deployed the agent can connect, so the '
|
|
445
561
|
+ 'connected project must be one that person created. The agents playbook (get_playbook) has the '
|
|
446
562
|
+ 'full setup walkthrough.',
|
|
447
|
-
inputSchema: {
|
|
563
|
+
inputSchema: strictInput({
|
|
448
564
|
action: z.enum(['connect', 'status', 'select_accounts']).default('connect')
|
|
449
565
|
.describe('connect (default) starts a connection, status checks it, select_accounts saves the accounts to use.'),
|
|
450
566
|
agent_guid: z.string().min(1).describe('The deployed agent\'s guid, from list_my_agents.'),
|
|
@@ -468,12 +584,12 @@ export function registerConnectAgentOauth(server, client) {
|
|
|
468
584
|
})).optional()
|
|
469
585
|
.describe('select_accounts with picker: what to use under each account. Accounts left out get nothing.'),
|
|
470
586
|
confirm: z.boolean().default(false)
|
|
471
|
-
.describe('connect: true to replace an existing connection after the user agreed.'),
|
|
472
|
-
},
|
|
587
|
+
.describe('connect: true to replace an existing connection or a token saved for another mode, after the user agreed.'),
|
|
588
|
+
}),
|
|
473
589
|
outputSchema,
|
|
474
590
|
annotations: {
|
|
475
591
|
readOnlyHint: false,
|
|
476
|
-
destructiveHint:
|
|
592
|
+
destructiveHint: true,
|
|
477
593
|
idempotentHint: false,
|
|
478
594
|
openWorldHint: true,
|
|
479
595
|
},
|
|
@@ -485,7 +601,9 @@ export function registerConnectAgentOauth(server, client) {
|
|
|
485
601
|
if (!meta)
|
|
486
602
|
return errorResult(new Error(`Unknown credential "${credential}".`));
|
|
487
603
|
if (!meta.oauth) {
|
|
488
|
-
return errorResult(new Error(
|
|
604
|
+
return errorResult(new Error(credential === WIRO_PROJECT_CREDENTIAL
|
|
605
|
+
? `${meta.title} is not a sign-in connection. Connect a Wiro project with bind_agent_project, with no key to paste.`
|
|
606
|
+
: `${meta.title} is not a sign-in connection. Save its fields with set_agent_credentials (call it with credential "${credential}" to see them).`));
|
|
489
607
|
}
|
|
490
608
|
const context = { client, agentGuid: args.agent_guid, credential, meta, signal: extra.signal };
|
|
491
609
|
if (args.action === 'status') {
|
|
@@ -501,7 +619,10 @@ export function registerConnectAgentOauth(server, client) {
|
|
|
501
619
|
return await connect(context, { mode: args.mode, redirectUrl: args.redirect_url, confirm: args.confirm });
|
|
502
620
|
}
|
|
503
621
|
catch (error) {
|
|
504
|
-
|
|
622
|
+
const message = errorText(error);
|
|
623
|
+
return errorResult(/not found or unauthorized/i.test(message)
|
|
624
|
+
? new Error(await connectionRefusalText(client, args.agent_guid, message, 'connected', extra.signal))
|
|
625
|
+
: withHint(error, meta ?? undefined));
|
|
505
626
|
}
|
|
506
627
|
});
|
|
507
628
|
}
|