@agentrq/agentrq-ws 0.9.18 → 0.10.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 +10 -2
- package/package.json +1 -1
- package/src/commands.js +208 -41
- package/src/mcp.js +20 -0
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ npx -y @agentrq/agentrq-ws@latest workspace
|
|
|
20
20
|
|
|
21
21
|
An agent talks to its workspace over MCP, which is the right shape for an agent
|
|
22
22
|
and the wrong shape for a person: every call is a JSON envelope, and every
|
|
23
|
-
answer is tokens the agent pays for. The same
|
|
23
|
+
answer is tokens the agent pays for. The same seven tools are underneath this
|
|
24
24
|
CLI, but a command is a line of shell and the answer is plain text.
|
|
25
25
|
|
|
26
26
|
It is also the difference between reading an attachment and *handling* one — see
|
|
@@ -47,6 +47,7 @@ Node 20.6 or newer.
|
|
|
47
47
|
| `task next` | Take the next not-started task — **this dequeues the queue** |
|
|
48
48
|
| `task create <title>` | Create a task, with `--clear-context` to send `/clear` to the agent first |
|
|
49
49
|
| `task status <taskId> <status>` | Set a task's status |
|
|
50
|
+
| `task help [action]` | The server's help for its `task` tool: every action, or one action's payload |
|
|
50
51
|
| `reply <taskId> <text>` | Send a message to a task |
|
|
51
52
|
| `attachment get <id> --task <taskId>` | Download an attachment to a file |
|
|
52
53
|
| `memory load [name]` | Read a workspace memory (defaults to the index) |
|
|
@@ -56,18 +57,25 @@ Node 20.6 or newer.
|
|
|
56
57
|
| `skill load <uri>` | Read a skill file (`skill://<name>` reads its `SKILL.md`) |
|
|
57
58
|
| `skill save <uri> --content …` | Replace a file of one of this workspace's skills |
|
|
58
59
|
| `skill delete <uri>` | Take a skill out of this workspace (`skill://<name>`), deleting it when no other workspace uses it, or delete one of its files |
|
|
60
|
+
| `pano save [id] --title … --markdown …` | Create a Pano doc, or replace one, and print its id; `--file` sends a file the markdown links, `--ttl-days` and `--color` set its life and post-it |
|
|
61
|
+
| `pano read <id>` | Read a Pano doc, `--comments`/`--attachments` adding those; `--out DIR` writes its markdown and downloads its files instead, printing only their paths |
|
|
62
|
+
| `pano comment <id> <text>` | Comment on a Pano doc |
|
|
63
|
+
| `pano attach <id> --file PATH…` | Attach files to a Pano doc; they need no link |
|
|
64
|
+
| `pano delete <id>` | Delete a Pano doc |
|
|
65
|
+
| `pano help [action]` | The server's help for its `pano` tool: every action, or one action's payload |
|
|
59
66
|
| `event publish <name>` | Publish a named event |
|
|
60
67
|
| `ask <taskId> <message>` | Ask the human a question and wait |
|
|
61
68
|
| `site-tools [q]` | List the websites shared with this workspace from the Chrome extension, and their tools' names and descriptions; `q` ranks the tools, `--pattern` filters them by a regular expression, `--limit`/`--offset` page |
|
|
62
69
|
| `site-tool <site> <tool>` | Show one shared website's tool in full, with its input schema |
|
|
63
70
|
| `call-site-tool <site> <tool> --task <taskId>` | Run a shared website's tool in the human's Chrome, with `--args '{…}'` |
|
|
64
71
|
| `tools` | List the tools this workspace server offers |
|
|
72
|
+
| `tools help [tool\|tool.action]` | The server's help: every tool, one tool's actions, or one action's payload with an example |
|
|
65
73
|
| `call <tool> --args '{…}'` | Call any tool directly |
|
|
66
74
|
|
|
67
75
|
Every command takes `--help`, and so does every family:
|
|
68
76
|
|
|
69
77
|
```bash
|
|
70
|
-
agentrq-ws task --help # lists task get / next / create / status
|
|
78
|
+
agentrq-ws task --help # lists task get / next / create / status / help
|
|
71
79
|
agentrq-ws attachment get -h # the one command, its options and defaults
|
|
72
80
|
```
|
|
73
81
|
|
package/package.json
CHANGED
package/src/commands.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// This notice may not be modified or removed.
|
|
3
3
|
|
|
4
4
|
import { readFileSync } from 'node:fs'
|
|
5
|
+
import { basename, join } from 'node:path'
|
|
5
6
|
|
|
6
7
|
import { readAttachment, resolveOutputPath, writeAttachment } from './attachments.js'
|
|
7
8
|
import { UserError } from './errors.js'
|
|
@@ -109,7 +110,7 @@ function withPaging(ctx, args) {
|
|
|
109
110
|
* content as base64. A link is fetched, so the file arrives either way.
|
|
110
111
|
*/
|
|
111
112
|
async function downloadAttachment(ctx, attachmentId, taskId, out) {
|
|
112
|
-
const { text } = await ctx.client.
|
|
113
|
+
const { text } = await ctx.client.callAction('task', 'getAttachment', { attachmentId, taskId }, ['getAttachment', { attachmentId, taskId }])
|
|
113
114
|
let attachment
|
|
114
115
|
try {
|
|
115
116
|
attachment = JSON.parse(text)
|
|
@@ -136,13 +137,63 @@ async function fetchAttachment(ctx, url) {
|
|
|
136
137
|
return Buffer.from(await response.arrayBuffer())
|
|
137
138
|
}
|
|
138
139
|
|
|
140
|
+
/** The Pano's post-it colors, mirrored from the backend. */
|
|
141
|
+
export const PANO_COLORS = ['yellow', 'pink', 'green', 'blue', 'orange', 'purple', 'amber']
|
|
142
|
+
|
|
143
|
+
/** Files for the pano tool from repeated --file flags: an attachment without its id. */
|
|
144
|
+
function panoFiles(paths) {
|
|
145
|
+
const list = asArray(paths)
|
|
146
|
+
if (list.length === 0) return undefined
|
|
147
|
+
return list.map((path) => {
|
|
148
|
+
const { filename, mimeType, data } = readAttachment(path)
|
|
149
|
+
return { filename, mimeType, data }
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The pano tool answers with the doc as JSON, or with a refusal's text. With
|
|
155
|
+
* idOnly a doc prints as its id, which is all a write needs to hand on.
|
|
156
|
+
*/
|
|
157
|
+
function printPanoDoc(result, { idOnly = false } = {}) {
|
|
158
|
+
let doc
|
|
159
|
+
try {
|
|
160
|
+
doc = JSON.parse(result.text)
|
|
161
|
+
} catch {
|
|
162
|
+
return result
|
|
163
|
+
}
|
|
164
|
+
return { text: idOnly ? doc.id : result.text, data: doc }
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Writes a doc's markdown to <out>/<id>/<id>.md and downloads its linked files
|
|
169
|
+
* beside it, so the markdown's links resolve on disk, and its attachments to
|
|
170
|
+
* <out>/<id>/attachments/. Comments go to comments.json. Prints the paths only.
|
|
171
|
+
*/
|
|
172
|
+
async function downloadPanoDoc(ctx, doc, out) {
|
|
173
|
+
if (!doc?.id) throw new UserError('unexpected answer from the pano tool')
|
|
174
|
+
const dir = resolveOutputPath(doc.id, out.endsWith('/') ? out : `${out}/`, { cwd: ctx.cwd })
|
|
175
|
+
const paths = [writeAttachment(join(dir, `${doc.id}.md`), Buffer.from(doc.markdown || '')).path]
|
|
176
|
+
const downloads = [
|
|
177
|
+
...(doc.files || []).map((f) => [f, dir]),
|
|
178
|
+
...(doc.attachments || []).map((f) => [f, join(dir, 'attachments')]),
|
|
179
|
+
]
|
|
180
|
+
for (const [file, into] of downloads) {
|
|
181
|
+
if (!file.url) continue
|
|
182
|
+
paths.push(writeAttachment(join(into, basename(file.filename)), await fetchAttachment(ctx, file.url)).path)
|
|
183
|
+
}
|
|
184
|
+
if (doc.comments) {
|
|
185
|
+
paths.push(writeAttachment(join(dir, 'comments.json'), Buffer.from(JSON.stringify(doc.comments, null, 2))).path)
|
|
186
|
+
}
|
|
187
|
+
return { text: paths.join('\n'), data: { ...doc, paths } }
|
|
188
|
+
}
|
|
189
|
+
|
|
139
190
|
export const COMMANDS = [
|
|
140
191
|
{
|
|
141
192
|
path: ['workspace'],
|
|
142
193
|
summary: 'Show the workspace title and mission',
|
|
143
194
|
usage: 'agentrq-ws workspace',
|
|
144
195
|
async run(ctx) {
|
|
145
|
-
return ctx
|
|
196
|
+
return act(ctx, 'workspace', 'get', {}, 'getWorkspace')
|
|
146
197
|
},
|
|
147
198
|
},
|
|
148
199
|
{
|
|
@@ -155,13 +206,13 @@ export const COMMANDS = [
|
|
|
155
206
|
limit: { type: 'string', description: 'Maximum messages to return (default 5)' },
|
|
156
207
|
},
|
|
157
208
|
async run(ctx) {
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
taskId,
|
|
209
|
+
const payload = {
|
|
210
|
+
taskId: requirePositional(ctx.positionals, 0, 'taskId'),
|
|
161
211
|
includeConversation: ctx.values.conversation || undefined,
|
|
162
212
|
cursor: ctx.values.cursor ? Number(ctx.values.cursor) : undefined,
|
|
163
213
|
limit: ctx.values.limit ? Number(ctx.values.limit) : undefined,
|
|
164
|
-
}
|
|
214
|
+
}
|
|
215
|
+
return ctx.client.callAction('task', 'get', payload, ['getTask', payload])
|
|
165
216
|
},
|
|
166
217
|
},
|
|
167
218
|
{
|
|
@@ -174,9 +225,8 @@ export const COMMANDS = [
|
|
|
174
225
|
async run(ctx) {
|
|
175
226
|
// Kept as its own verb rather than a bare `task get`: this call mutates
|
|
176
227
|
// the queue, and a command that silently claims work is a bad surprise.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
})
|
|
228
|
+
const payload = { includeConversation: ctx.values.conversation || undefined }
|
|
229
|
+
return ctx.client.callAction('task', 'get', payload, ['getTask', payload])
|
|
180
230
|
},
|
|
181
231
|
},
|
|
182
232
|
{
|
|
@@ -197,7 +247,7 @@ export const COMMANDS = [
|
|
|
197
247
|
async run(ctx) {
|
|
198
248
|
const title = requirePositional(ctx.positionals, 0, 'title')
|
|
199
249
|
const body = await resolveText(ctx.values.body, { stdin: ctx.stdin, what: 'the task body' })
|
|
200
|
-
|
|
250
|
+
const payload = {
|
|
201
251
|
title,
|
|
202
252
|
body: body ?? '',
|
|
203
253
|
assignee: ctx.values.assignee,
|
|
@@ -208,7 +258,8 @@ export const COMMANDS = [
|
|
|
208
258
|
// never expressed.
|
|
209
259
|
clearContext: ctx.values['clear-context'] || undefined,
|
|
210
260
|
attachments: collectAttachments(ctx.values),
|
|
211
|
-
}
|
|
261
|
+
}
|
|
262
|
+
return ctx.client.callAction('task', 'create', payload, ['createTask', payload])
|
|
212
263
|
},
|
|
213
264
|
},
|
|
214
265
|
{
|
|
@@ -221,7 +272,7 @@ export const COMMANDS = [
|
|
|
221
272
|
if (!TASK_STATUSES.includes(status)) {
|
|
222
273
|
throw new UserError(`unknown status "${status}" (expected one of: ${TASK_STATUSES.join(', ')})`)
|
|
223
274
|
}
|
|
224
|
-
return ctx.client.
|
|
275
|
+
return ctx.client.callAction('task', 'updateStatus', { taskId, status }, ['updateTaskStatus', { taskId, status }])
|
|
225
276
|
},
|
|
226
277
|
},
|
|
227
278
|
{
|
|
@@ -232,14 +283,19 @@ export const COMMANDS = [
|
|
|
232
283
|
attach: { type: 'string', multiple: true, description: 'File to attach (repeatable)' },
|
|
233
284
|
},
|
|
234
285
|
async run(ctx) {
|
|
235
|
-
const
|
|
286
|
+
const taskId = requirePositional(ctx.positionals, 0, 'taskId')
|
|
236
287
|
const raw = requirePositional(ctx.positionals, 1, 'text')
|
|
237
288
|
const text = await resolveText(raw, { stdin: ctx.stdin, what: 'the reply text' })
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
289
|
+
const attachments = collectAttachments(ctx.values)
|
|
290
|
+
return ctx.client.callAction('task', 'reply', { taskId, text, attachments }, ['reply', { chatId: taskId, text, attachments }])
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
path: ['task', 'help'],
|
|
295
|
+
summary: "Show the task tool's actions, or one action's payload",
|
|
296
|
+
usage: 'agentrq-ws task help [action]',
|
|
297
|
+
async run(ctx) {
|
|
298
|
+
return actionHelp(ctx, 'task')
|
|
243
299
|
},
|
|
244
300
|
},
|
|
245
301
|
{
|
|
@@ -262,7 +318,7 @@ export const COMMANDS = [
|
|
|
262
318
|
summary: 'Read a workspace memory (defaults to the index)',
|
|
263
319
|
usage: 'agentrq-ws memory load [name]',
|
|
264
320
|
async run(ctx) {
|
|
265
|
-
return ctx
|
|
321
|
+
return act(ctx, 'memory', 'load', { name: ctx.positionals[0] }, 'loadMemory')
|
|
266
322
|
},
|
|
267
323
|
},
|
|
268
324
|
{
|
|
@@ -275,7 +331,7 @@ export const COMMANDS = [
|
|
|
275
331
|
async run(ctx) {
|
|
276
332
|
if (ctx.values.content === undefined) throw new UserError('--content is required (use @file or - to read from stdin)')
|
|
277
333
|
const content = await resolveText(ctx.values.content, { stdin: ctx.stdin, what: 'the memory content' })
|
|
278
|
-
return ctx
|
|
334
|
+
return act(ctx, 'memory', 'save', { name: ctx.positionals[0], content }, 'saveMemory')
|
|
279
335
|
},
|
|
280
336
|
},
|
|
281
337
|
{
|
|
@@ -283,7 +339,7 @@ export const COMMANDS = [
|
|
|
283
339
|
summary: 'Delete a workspace memory',
|
|
284
340
|
usage: 'agentrq-ws memory delete [name]',
|
|
285
341
|
async run(ctx) {
|
|
286
|
-
return ctx
|
|
342
|
+
return act(ctx, 'memory', 'delete', { name: ctx.positionals[0] }, 'deleteMemory')
|
|
287
343
|
},
|
|
288
344
|
},
|
|
289
345
|
{
|
|
@@ -297,7 +353,7 @@ export const COMMANDS = [
|
|
|
297
353
|
async run(ctx) {
|
|
298
354
|
const args = {}
|
|
299
355
|
if (ctx.positionals.length) args.q = ctx.positionals.join(' ')
|
|
300
|
-
return ctx
|
|
356
|
+
return act(ctx, 'skills', 'search', withPaging(ctx, args), 'searchSkills')
|
|
301
357
|
},
|
|
302
358
|
},
|
|
303
359
|
{
|
|
@@ -305,7 +361,7 @@ export const COMMANDS = [
|
|
|
305
361
|
summary: 'Read a skill file (skill://<name> reads its SKILL.md)',
|
|
306
362
|
usage: 'agentrq-ws skill load <uri>',
|
|
307
363
|
async run(ctx) {
|
|
308
|
-
return ctx
|
|
364
|
+
return act(ctx, 'skills', 'load', { uri: requirePositional(ctx.positionals, 0, 'uri') }, 'loadSkill')
|
|
309
365
|
},
|
|
310
366
|
},
|
|
311
367
|
{
|
|
@@ -319,7 +375,7 @@ export const COMMANDS = [
|
|
|
319
375
|
const uri = requirePositional(ctx.positionals, 0, 'uri')
|
|
320
376
|
if (ctx.values.content === undefined) throw new UserError('--content is required (use @file or - to read from stdin)')
|
|
321
377
|
const content = await resolveText(ctx.values.content, { stdin: ctx.stdin, what: 'the skill file' })
|
|
322
|
-
return ctx
|
|
378
|
+
return act(ctx, 'skills', 'save', { uri, content }, 'saveSkill')
|
|
323
379
|
},
|
|
324
380
|
},
|
|
325
381
|
{
|
|
@@ -327,7 +383,102 @@ export const COMMANDS = [
|
|
|
327
383
|
summary: 'Delete a skill (skill://<name>) or one of its files',
|
|
328
384
|
usage: 'agentrq-ws skill delete <uri>',
|
|
329
385
|
async run(ctx) {
|
|
330
|
-
return ctx
|
|
386
|
+
return act(ctx, 'skills', 'delete', { uri: requirePositional(ctx.positionals, 0, 'uri') }, 'deleteSkill')
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
path: ['pano', 'save'],
|
|
391
|
+
summary: 'Create a Pano doc, or replace one; prints its id',
|
|
392
|
+
usage: 'agentrq-ws pano save [id] --title TEXT --markdown TEXT|@file|- [--file PATH]... [--ttl-days N] [--color NAME]',
|
|
393
|
+
options: {
|
|
394
|
+
title: { type: 'string', short: 'T', description: "The doc's title (required)" },
|
|
395
|
+
markdown: { type: 'string', short: 'M', description: "The doc's full markdown (@file or - for stdin; required)" },
|
|
396
|
+
file: { type: 'string', multiple: true, description: 'A linked file, linked from the markdown by its file name (repeatable)' },
|
|
397
|
+
'ttl-days': { type: 'string', description: 'Days the doc lives after this save (default: 30, or its own)' },
|
|
398
|
+
color: { type: 'string', description: `Its post-it's color: ${PANO_COLORS.join(', ')}` },
|
|
399
|
+
},
|
|
400
|
+
async run(ctx) {
|
|
401
|
+
if (ctx.values.title === undefined) throw new UserError('--title is required')
|
|
402
|
+
if (ctx.values.markdown === undefined) throw new UserError('--markdown is required (use @file or - to read from stdin)')
|
|
403
|
+
const markdown = await resolveText(ctx.values.markdown, { stdin: ctx.stdin, what: 'the markdown' })
|
|
404
|
+
const color = ctx.values.color
|
|
405
|
+
if (color !== undefined && !PANO_COLORS.includes(color)) {
|
|
406
|
+
throw new UserError(`unknown color "${color}" (expected one of: ${PANO_COLORS.join(', ')})`)
|
|
407
|
+
}
|
|
408
|
+
let ttlDays
|
|
409
|
+
if (ctx.values['ttl-days'] !== undefined) {
|
|
410
|
+
ttlDays = Number(ctx.values['ttl-days'])
|
|
411
|
+
if (!Number.isInteger(ttlDays) || ttlDays < 1) throw new UserError('--ttl-days must be a whole number, 1 or more')
|
|
412
|
+
}
|
|
413
|
+
return printPanoDoc(await pano(ctx, 'save', {
|
|
414
|
+
id: ctx.positionals[0],
|
|
415
|
+
title: ctx.values.title,
|
|
416
|
+
markdown,
|
|
417
|
+
ttlDays,
|
|
418
|
+
color,
|
|
419
|
+
files: panoFiles(ctx.values.file),
|
|
420
|
+
}), { idOnly: true })
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
path: ['pano', 'read'],
|
|
425
|
+
summary: 'Read a Pano doc, or download it with its files to a directory',
|
|
426
|
+
usage: 'agentrq-ws pano read <id> [--comments] [--attachments] [--out DIR]',
|
|
427
|
+
options: {
|
|
428
|
+
comments: { type: 'boolean', short: 'c', description: "Include the doc's comments" },
|
|
429
|
+
attachments: { type: 'boolean', short: 'a', description: "Include the doc's attachments" },
|
|
430
|
+
out: { type: 'string', short: 'o', description: 'Write the markdown and download every file here; prints only their paths' },
|
|
431
|
+
},
|
|
432
|
+
async run(ctx) {
|
|
433
|
+
const id = requirePositional(ctx.positionals, 0, 'id')
|
|
434
|
+
const result = await pano(ctx, 'read', {
|
|
435
|
+
id,
|
|
436
|
+
includeComments: ctx.values.comments || undefined,
|
|
437
|
+
includeAttachments: ctx.values.attachments || undefined,
|
|
438
|
+
})
|
|
439
|
+
if (!ctx.values.out) return result
|
|
440
|
+
return downloadPanoDoc(ctx, printPanoDoc(result).data, ctx.values.out)
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
path: ['pano', 'comment'],
|
|
445
|
+
summary: 'Comment on a Pano doc',
|
|
446
|
+
usage: 'agentrq-ws pano comment <id> <text|@file|->',
|
|
447
|
+
async run(ctx) {
|
|
448
|
+
const id = requirePositional(ctx.positionals, 0, 'id')
|
|
449
|
+
const raw = requirePositional(ctx.positionals, 1, 'text')
|
|
450
|
+
const comment = await resolveText(raw, { stdin: ctx.stdin, what: 'the comment' })
|
|
451
|
+
return pano(ctx, 'comment', { id, comment })
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
path: ['pano', 'attach'],
|
|
456
|
+
summary: 'Attach files to a Pano doc; they need no link',
|
|
457
|
+
usage: 'agentrq-ws pano attach <id> --file PATH...',
|
|
458
|
+
options: {
|
|
459
|
+
file: { type: 'string', multiple: true, description: 'A file to attach (repeatable)' },
|
|
460
|
+
},
|
|
461
|
+
async run(ctx) {
|
|
462
|
+
const id = requirePositional(ctx.positionals, 0, 'id')
|
|
463
|
+
const files = panoFiles(ctx.values.file)
|
|
464
|
+
if (!files) throw new UserError('--file is required')
|
|
465
|
+
return printPanoDoc(await pano(ctx, 'attach', { id, files }), { idOnly: true })
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
path: ['pano', 'delete'],
|
|
470
|
+
summary: 'Delete a Pano doc',
|
|
471
|
+
usage: 'agentrq-ws pano delete <id>',
|
|
472
|
+
async run(ctx) {
|
|
473
|
+
return pano(ctx, 'delete', { id: requirePositional(ctx.positionals, 0, 'id') })
|
|
474
|
+
},
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
path: ['pano', 'help'],
|
|
478
|
+
summary: "Show the pano tool's actions, or one action's payload",
|
|
479
|
+
usage: 'agentrq-ws pano help [action]',
|
|
480
|
+
async run(ctx) {
|
|
481
|
+
return actionHelp(ctx, 'pano')
|
|
331
482
|
},
|
|
332
483
|
},
|
|
333
484
|
{
|
|
@@ -342,12 +493,7 @@ export const COMMANDS = [
|
|
|
342
493
|
async run(ctx) {
|
|
343
494
|
const name = requirePositional(ctx.positionals, 0, 'name')
|
|
344
495
|
const payload = await resolveText(ctx.values.payload, { stdin: ctx.stdin, what: 'the payload' })
|
|
345
|
-
return ctx.
|
|
346
|
-
name,
|
|
347
|
-
payload,
|
|
348
|
-
taskId: ctx.values.task,
|
|
349
|
-
faq: parseFaq(ctx.values),
|
|
350
|
-
})
|
|
496
|
+
return act(ctx, 'workspace', 'publishEvent', { name, payload, taskId: ctx.values.task, faq: parseFaq(ctx.values) }, 'publishEvent')
|
|
351
497
|
},
|
|
352
498
|
},
|
|
353
499
|
{
|
|
@@ -380,14 +526,15 @@ export const COMMANDS = [
|
|
|
380
526
|
if (mode === 'form' && !requestedSchema) {
|
|
381
527
|
throw new UserError('mode=form needs at least one --field (or --schema)')
|
|
382
528
|
}
|
|
383
|
-
|
|
529
|
+
const payload = {
|
|
384
530
|
taskId,
|
|
385
531
|
message,
|
|
386
532
|
mode,
|
|
387
533
|
requestedSchema,
|
|
388
534
|
url: ctx.values.url,
|
|
389
535
|
timeoutSeconds: ctx.values.timeout ? Number(ctx.values.timeout) : undefined,
|
|
390
|
-
}
|
|
536
|
+
}
|
|
537
|
+
return ctx.client.callAction('task', 'elicit', payload, ['elicit', payload])
|
|
391
538
|
},
|
|
392
539
|
},
|
|
393
540
|
{
|
|
@@ -403,7 +550,7 @@ export const COMMANDS = [
|
|
|
403
550
|
const args = {}
|
|
404
551
|
if (ctx.positionals.length) args.q = ctx.positionals.join(' ')
|
|
405
552
|
if (ctx.values.pattern !== undefined) args.pattern = ctx.values.pattern
|
|
406
|
-
return ctx
|
|
553
|
+
return act(ctx, 'siteTools', 'search', withPaging(ctx, args), 'listSiteTools')
|
|
407
554
|
},
|
|
408
555
|
},
|
|
409
556
|
{
|
|
@@ -413,7 +560,7 @@ export const COMMANDS = [
|
|
|
413
560
|
async run(ctx) {
|
|
414
561
|
const site = requirePositional(ctx.positionals, 0, 'site')
|
|
415
562
|
const tool = requirePositional(ctx.positionals, 1, 'tool')
|
|
416
|
-
return ctx
|
|
563
|
+
return act(ctx, 'siteTools', 'getDefinition', { site, tool }, 'getSiteToolDefinition')
|
|
417
564
|
},
|
|
418
565
|
},
|
|
419
566
|
{
|
|
@@ -428,12 +575,16 @@ export const COMMANDS = [
|
|
|
428
575
|
const site = requirePositional(ctx.positionals, 0, 'site')
|
|
429
576
|
const tool = requirePositional(ctx.positionals, 1, 'tool')
|
|
430
577
|
if (!ctx.values.task) throw new UserError('--task <taskId> is required')
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
578
|
+
const payload = { taskId: ctx.values.task, site, tool, arguments: await readArgs(ctx) }
|
|
579
|
+
return act(ctx, 'siteTools', 'call', payload, 'callSiteTool')
|
|
580
|
+
},
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
path: ['tools', 'help'],
|
|
584
|
+
summary: "The server's help: every tool, one tool's actions, or one action's payload with an example",
|
|
585
|
+
usage: 'agentrq-ws tools help [tool|tool.action]',
|
|
586
|
+
async run(ctx) {
|
|
587
|
+
return ctx.client.callTool('help', { action: ctx.positionals[0] })
|
|
437
588
|
},
|
|
438
589
|
},
|
|
439
590
|
{
|
|
@@ -464,6 +615,22 @@ export const COMMANDS = [
|
|
|
464
615
|
},
|
|
465
616
|
]
|
|
466
617
|
|
|
618
|
+
/** One action of a tool; an older server gets the tool it had for it, `legacy`. */
|
|
619
|
+
function act(ctx, tool, action, payload, legacy) {
|
|
620
|
+
return ctx.client.callAction(tool, action, payload, [legacy, payload])
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/** The server's own help for an action tool, for one action when named. */
|
|
624
|
+
function actionHelp(ctx, tool) {
|
|
625
|
+
const topic = ctx.positionals[0]
|
|
626
|
+
return ctx.client.callTool(tool, { action: 'help', payload: topic ? { topic } : undefined })
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/** One pano call; a server from before payloads takes its fields beside action. */
|
|
630
|
+
function pano(ctx, action, payload) {
|
|
631
|
+
return ctx.client.callAction('pano', action, payload, ['pano', { action, ...payload }])
|
|
632
|
+
}
|
|
633
|
+
|
|
467
634
|
/** --args as JSON, from inline, @file or stdin; nothing given is {}. */
|
|
468
635
|
async function readArgs(ctx) {
|
|
469
636
|
const raw = await resolveText(ctx.values.args, { stdin: ctx.stdin, what: 'the arguments' })
|
package/src/mcp.js
CHANGED
|
@@ -203,6 +203,26 @@ export class McpClient {
|
|
|
203
203
|
return (result && result.tools) || []
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Call one action of an action tool — `task`, `pano` — which takes two
|
|
208
|
+
* inputs, the action and its payload. A server from before those tools took
|
|
209
|
+
* them gets the call it knows instead: `legacy` is the tool and arguments it
|
|
210
|
+
* had for this, `[name, args]`.
|
|
211
|
+
*/
|
|
212
|
+
async callAction(tool, action, payload, legacy) {
|
|
213
|
+
if (!(await this.takesPayload(tool))) return this.callTool(...legacy)
|
|
214
|
+
return this.callTool(tool, { action, payload: pruneUndefined(payload) })
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** Whether the server's `tool` takes a payload: asked once per client. */
|
|
218
|
+
async takesPayload(tool) {
|
|
219
|
+
if (!this.actionTools) {
|
|
220
|
+
const tools = await this.listTools()
|
|
221
|
+
this.actionTools = new Set(tools.filter((t) => t.inputSchema?.properties?.payload).map((t) => t.name))
|
|
222
|
+
}
|
|
223
|
+
return this.actionTools.has(tool)
|
|
224
|
+
}
|
|
225
|
+
|
|
206
226
|
/**
|
|
207
227
|
* Call a tool and return its text.
|
|
208
228
|
*
|