@agentrq/agentrq-ws 0.9.19 → 0.10.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 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 nineteen tools are underneath this
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,23 +57,26 @@ 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 |
59
- | `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 |
60
- | `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 |
60
+ | `pano save [id --version N] --title … --markdown …` | Create a Pano doc, or replace one, and print its id and version; replacing needs the `--version` you read and is refused if the doc changed since; `--file` sends a file the markdown links, `--ttl-days` and `--color` set its life and post-it |
61
+ | `pano edit <id> --version N …` | Change part of a doc without resending it: `--replace TEXT --with TEXT` (the text must occur once), `--append TEXT`, or `--ops` as a JSON array; the ops apply all or none. Prints the id and new version |
62
+ | `pano read <id>` | Read a Pano doc (its `version` included), `--comments`/`--attachments` adding those; `--out DIR` writes its markdown and downloads its files instead, printing its version and their paths |
61
63
  | `pano comment <id> <text>` | Comment on a Pano doc |
62
64
  | `pano attach <id> --file PATH…` | Attach files to a Pano doc; they need no link |
63
65
  | `pano delete <id>` | Delete a Pano doc |
66
+ | `pano help [action]` | The server's help for its `pano` tool: every action, or one action's payload |
64
67
  | `event publish <name>` | Publish a named event |
65
68
  | `ask <taskId> <message>` | Ask the human a question and wait |
66
69
  | `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 |
67
70
  | `site-tool <site> <tool>` | Show one shared website's tool in full, with its input schema |
68
71
  | `call-site-tool <site> <tool> --task <taskId>` | Run a shared website's tool in the human's Chrome, with `--args '{…}'` |
69
72
  | `tools` | List the tools this workspace server offers |
73
+ | `tools help [tool\|tool.action]` | The server's help: every tool, one tool's actions, or one action's payload with an example |
70
74
  | `call <tool> --args '{…}'` | Call any tool directly |
71
75
 
72
76
  Every command takes `--help`, and so does every family:
73
77
 
74
78
  ```bash
75
- agentrq-ws task --help # lists task get / next / create / status
79
+ agentrq-ws task --help # lists task get / next / create / status / help
76
80
  agentrq-ws attachment get -h # the one command, its options and defaults
77
81
  ```
78
82
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentrq/agentrq-ws",
3
- "version": "0.9.19",
3
+ "version": "0.10.1",
4
4
  "description": "AgentRQ workspace client \u2014 drive an AgentRQ workspace from the command line, using the workspace's own .mcp.json",
5
5
  "keywords": [
6
6
  "agentrq",
package/src/cli.js CHANGED
@@ -38,6 +38,12 @@ export async function run({
38
38
  const write = (stream, text) => stream.write(`${text}\n`)
39
39
 
40
40
  try {
41
+ // `--help "memory load"` reads as `help memory load`: a leading help flag
42
+ // asks for the help of whatever follows, rather than being an unknown command.
43
+ // A quoted "memory load" is one argument, so split it into words.
44
+ if (argv[0] === '--help' || argv[0] === '-h') {
45
+ argv = ['help', ...argv.slice(1).flatMap((arg) => arg.split(/\s+/).filter(Boolean))]
46
+ }
41
47
  if (argv.length === 0 || argv[0] === 'help') {
42
48
  const target = argv.slice(1)
43
49
  if (target.length > 0) {
package/src/commands.js CHANGED
@@ -110,7 +110,7 @@ function withPaging(ctx, args) {
110
110
  * content as base64. A link is fetched, so the file arrives either way.
111
111
  */
112
112
  async function downloadAttachment(ctx, attachmentId, taskId, out) {
113
- const { text } = await ctx.client.callTool('getAttachment', { attachmentId, taskId })
113
+ const { text } = await ctx.client.callAction('task', 'getAttachment', { attachmentId, taskId }, ['getAttachment', { attachmentId, taskId }])
114
114
  let attachment
115
115
  try {
116
116
  attachment = JSON.parse(text)
@@ -152,7 +152,8 @@ function panoFiles(paths) {
152
152
 
153
153
  /**
154
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.
155
+ * idOnly a doc prints as its id and version, which is all a write needs to
156
+ * hand on: the next update must send that version.
156
157
  */
157
158
  function printPanoDoc(result, { idOnly = false } = {}) {
158
159
  let doc
@@ -161,7 +162,41 @@ function printPanoDoc(result, { idOnly = false } = {}) {
161
162
  } catch {
162
163
  return result
163
164
  }
164
- return { text: idOnly ? doc.id : result.text, data: doc }
165
+ return { text: idOnly ? [doc.id, doc.version].filter((x) => x !== undefined).join(' ') : result.text, data: doc }
166
+ }
167
+
168
+ /** The ops of pano edit: --ops (a JSON array, as the tool takes it), then --replace/--with, then --append. */
169
+ async function panoEditOps(ctx) {
170
+ const { ops, replace, with: newString, append } = ctx.values
171
+ const out = []
172
+ if (ops !== undefined) {
173
+ let parsed
174
+ try {
175
+ parsed = JSON.parse(await resolveText(ops, { stdin: ctx.stdin, what: 'the ops' }))
176
+ } catch (err) {
177
+ if (err instanceof UserError) throw err
178
+ throw new UserError(`--ops is not JSON: ${err.message}`)
179
+ }
180
+ if (!Array.isArray(parsed)) throw new UserError('--ops must be a JSON array of {op, ...}')
181
+ out.push(...parsed)
182
+ }
183
+ if (replace !== undefined) {
184
+ if (newString === undefined) throw new UserError('--replace needs --with, the text it becomes')
185
+ out.push({ op: 'replace', oldString: replace, newString })
186
+ } else if (newString !== undefined) {
187
+ throw new UserError('--with needs --replace, the text to replace')
188
+ }
189
+ if (append !== undefined) out.push({ op: 'append', text: await resolveText(append, { stdin: ctx.stdin, what: 'the text to append' }) })
190
+ if (out.length === 0) throw new UserError('nothing to do: give --ops, --replace and --with, or --append')
191
+ return out
192
+ }
193
+
194
+ /** The doc's version, as a flag: required to change a doc that exists. */
195
+ function panoVersion(value) {
196
+ if (value === undefined) throw new UserError('--version is required to change a doc: the version you read (pano read prints it)')
197
+ const version = Number(value)
198
+ if (!Number.isInteger(version) || version < 1) throw new UserError('--version must be a whole number, 1 or more')
199
+ return version
165
200
  }
166
201
 
167
202
  /**
@@ -184,7 +219,8 @@ async function downloadPanoDoc(ctx, doc, out) {
184
219
  if (doc.comments) {
185
220
  paths.push(writeAttachment(join(dir, 'comments.json'), Buffer.from(JSON.stringify(doc.comments, null, 2))).path)
186
221
  }
187
- return { text: paths.join('\n'), data: { ...doc, paths } }
222
+ const version = doc.version === undefined ? [] : [`version ${doc.version}`]
223
+ return { text: [...version, ...paths].join('\n'), data: { ...doc, paths } }
188
224
  }
189
225
 
190
226
  export const COMMANDS = [
@@ -193,7 +229,7 @@ export const COMMANDS = [
193
229
  summary: 'Show the workspace title and mission',
194
230
  usage: 'agentrq-ws workspace',
195
231
  async run(ctx) {
196
- return ctx.client.callTool('getWorkspace', {})
232
+ return act(ctx, 'workspace', 'get', {}, 'getWorkspace')
197
233
  },
198
234
  },
199
235
  {
@@ -206,13 +242,13 @@ export const COMMANDS = [
206
242
  limit: { type: 'string', description: 'Maximum messages to return (default 5)' },
207
243
  },
208
244
  async run(ctx) {
209
- const taskId = requirePositional(ctx.positionals, 0, 'taskId')
210
- return ctx.client.callTool('getTask', {
211
- taskId,
245
+ const payload = {
246
+ taskId: requirePositional(ctx.positionals, 0, 'taskId'),
212
247
  includeConversation: ctx.values.conversation || undefined,
213
248
  cursor: ctx.values.cursor ? Number(ctx.values.cursor) : undefined,
214
249
  limit: ctx.values.limit ? Number(ctx.values.limit) : undefined,
215
- })
250
+ }
251
+ return ctx.client.callAction('task', 'get', payload, ['getTask', payload])
216
252
  },
217
253
  },
218
254
  {
@@ -225,9 +261,8 @@ export const COMMANDS = [
225
261
  async run(ctx) {
226
262
  // Kept as its own verb rather than a bare `task get`: this call mutates
227
263
  // the queue, and a command that silently claims work is a bad surprise.
228
- return ctx.client.callTool('getTask', {
229
- includeConversation: ctx.values.conversation || undefined,
230
- })
264
+ const payload = { includeConversation: ctx.values.conversation || undefined }
265
+ return ctx.client.callAction('task', 'get', payload, ['getTask', payload])
231
266
  },
232
267
  },
233
268
  {
@@ -248,7 +283,7 @@ export const COMMANDS = [
248
283
  async run(ctx) {
249
284
  const title = requirePositional(ctx.positionals, 0, 'title')
250
285
  const body = await resolveText(ctx.values.body, { stdin: ctx.stdin, what: 'the task body' })
251
- return ctx.client.callTool('createTask', {
286
+ const payload = {
252
287
  title,
253
288
  body: body ?? '',
254
289
  assignee: ctx.values.assignee,
@@ -259,7 +294,8 @@ export const COMMANDS = [
259
294
  // never expressed.
260
295
  clearContext: ctx.values['clear-context'] || undefined,
261
296
  attachments: collectAttachments(ctx.values),
262
- })
297
+ }
298
+ return ctx.client.callAction('task', 'create', payload, ['createTask', payload])
263
299
  },
264
300
  },
265
301
  {
@@ -272,7 +308,7 @@ export const COMMANDS = [
272
308
  if (!TASK_STATUSES.includes(status)) {
273
309
  throw new UserError(`unknown status "${status}" (expected one of: ${TASK_STATUSES.join(', ')})`)
274
310
  }
275
- return ctx.client.callTool('updateTaskStatus', { taskId, status })
311
+ return ctx.client.callAction('task', 'updateStatus', { taskId, status }, ['updateTaskStatus', { taskId, status }])
276
312
  },
277
313
  },
278
314
  {
@@ -283,14 +319,19 @@ export const COMMANDS = [
283
319
  attach: { type: 'string', multiple: true, description: 'File to attach (repeatable)' },
284
320
  },
285
321
  async run(ctx) {
286
- const chatId = requirePositional(ctx.positionals, 0, 'taskId')
322
+ const taskId = requirePositional(ctx.positionals, 0, 'taskId')
287
323
  const raw = requirePositional(ctx.positionals, 1, 'text')
288
324
  const text = await resolveText(raw, { stdin: ctx.stdin, what: 'the reply text' })
289
- return ctx.client.callTool('reply', {
290
- chatId,
291
- text,
292
- attachments: collectAttachments(ctx.values),
293
- })
325
+ const attachments = collectAttachments(ctx.values)
326
+ return ctx.client.callAction('task', 'reply', { taskId, text, attachments }, ['reply', { chatId: taskId, text, attachments }])
327
+ },
328
+ },
329
+ {
330
+ path: ['task', 'help'],
331
+ summary: "Show the task tool's actions, or one action's payload",
332
+ usage: 'agentrq-ws task help [action]',
333
+ async run(ctx) {
334
+ return actionHelp(ctx, 'task')
294
335
  },
295
336
  },
296
337
  {
@@ -313,7 +354,7 @@ export const COMMANDS = [
313
354
  summary: 'Read a workspace memory (defaults to the index)',
314
355
  usage: 'agentrq-ws memory load [name]',
315
356
  async run(ctx) {
316
- return ctx.client.callTool('loadMemory', { name: ctx.positionals[0] })
357
+ return act(ctx, 'memory', 'load', { name: ctx.positionals[0] }, 'loadMemory')
317
358
  },
318
359
  },
319
360
  {
@@ -326,7 +367,7 @@ export const COMMANDS = [
326
367
  async run(ctx) {
327
368
  if (ctx.values.content === undefined) throw new UserError('--content is required (use @file or - to read from stdin)')
328
369
  const content = await resolveText(ctx.values.content, { stdin: ctx.stdin, what: 'the memory content' })
329
- return ctx.client.callTool('saveMemory', { name: ctx.positionals[0], content })
370
+ return act(ctx, 'memory', 'save', { name: ctx.positionals[0], content }, 'saveMemory')
330
371
  },
331
372
  },
332
373
  {
@@ -334,7 +375,7 @@ export const COMMANDS = [
334
375
  summary: 'Delete a workspace memory',
335
376
  usage: 'agentrq-ws memory delete [name]',
336
377
  async run(ctx) {
337
- return ctx.client.callTool('deleteMemory', { name: ctx.positionals[0] })
378
+ return act(ctx, 'memory', 'delete', { name: ctx.positionals[0] }, 'deleteMemory')
338
379
  },
339
380
  },
340
381
  {
@@ -348,7 +389,7 @@ export const COMMANDS = [
348
389
  async run(ctx) {
349
390
  const args = {}
350
391
  if (ctx.positionals.length) args.q = ctx.positionals.join(' ')
351
- return ctx.client.callTool('searchSkills', withPaging(ctx, args))
392
+ return act(ctx, 'skills', 'search', withPaging(ctx, args), 'searchSkills')
352
393
  },
353
394
  },
354
395
  {
@@ -356,7 +397,7 @@ export const COMMANDS = [
356
397
  summary: 'Read a skill file (skill://<name> reads its SKILL.md)',
357
398
  usage: 'agentrq-ws skill load <uri>',
358
399
  async run(ctx) {
359
- return ctx.client.callTool('loadSkill', { uri: requirePositional(ctx.positionals, 0, 'uri') })
400
+ return act(ctx, 'skills', 'load', { uri: requirePositional(ctx.positionals, 0, 'uri') }, 'loadSkill')
360
401
  },
361
402
  },
362
403
  {
@@ -370,7 +411,7 @@ export const COMMANDS = [
370
411
  const uri = requirePositional(ctx.positionals, 0, 'uri')
371
412
  if (ctx.values.content === undefined) throw new UserError('--content is required (use @file or - to read from stdin)')
372
413
  const content = await resolveText(ctx.values.content, { stdin: ctx.stdin, what: 'the skill file' })
373
- return ctx.client.callTool('saveSkill', { uri, content })
414
+ return act(ctx, 'skills', 'save', { uri, content }, 'saveSkill')
374
415
  },
375
416
  },
376
417
  {
@@ -378,14 +419,15 @@ export const COMMANDS = [
378
419
  summary: 'Delete a skill (skill://<name>) or one of its files',
379
420
  usage: 'agentrq-ws skill delete <uri>',
380
421
  async run(ctx) {
381
- return ctx.client.callTool('deleteSkill', { uri: requirePositional(ctx.positionals, 0, 'uri') })
422
+ return act(ctx, 'skills', 'delete', { uri: requirePositional(ctx.positionals, 0, 'uri') }, 'deleteSkill')
382
423
  },
383
424
  },
384
425
  {
385
426
  path: ['pano', 'save'],
386
- summary: 'Create a Pano doc, or replace one; prints its id',
387
- usage: 'agentrq-ws pano save [id] --title TEXT --markdown TEXT|@file|- [--file PATH]... [--ttl-days N] [--color NAME]',
427
+ summary: 'Create a Pano doc, or replace one; prints its id and version',
428
+ usage: 'agentrq-ws pano save [id --version N] --title TEXT --markdown TEXT|@file|- [--file PATH]... [--ttl-days N] [--color NAME]',
388
429
  options: {
430
+ version: { type: 'string', short: 'v', description: 'The version you read; required with an id, refused if the doc changed since' },
389
431
  title: { type: 'string', short: 'T', description: "The doc's title (required)" },
390
432
  markdown: { type: 'string', short: 'M', description: "The doc's full markdown (@file or - for stdin; required)" },
391
433
  file: { type: 'string', multiple: true, description: 'A linked file, linked from the markdown by its file name (repeatable)' },
@@ -405,9 +447,10 @@ export const COMMANDS = [
405
447
  ttlDays = Number(ctx.values['ttl-days'])
406
448
  if (!Number.isInteger(ttlDays) || ttlDays < 1) throw new UserError('--ttl-days must be a whole number, 1 or more')
407
449
  }
408
- return printPanoDoc(await ctx.client.callTool('pano', {
409
- action: 'save',
410
- id: ctx.positionals[0],
450
+ const id = ctx.positionals[0]
451
+ return printPanoDoc(await pano(ctx, 'save', {
452
+ id,
453
+ version: id === undefined ? undefined : panoVersion(ctx.values.version),
411
454
  title: ctx.values.title,
412
455
  markdown,
413
456
  ttlDays,
@@ -416,6 +459,23 @@ export const COMMANDS = [
416
459
  }), { idOnly: true })
417
460
  },
418
461
  },
462
+ {
463
+ path: ['pano', 'edit'],
464
+ summary: 'Change part of a Pano doc without sending it whole; prints its id and new version',
465
+ usage: 'agentrq-ws pano edit <id> --version N [--ops JSON|@file|-] [--replace TEXT --with TEXT] [--append TEXT|@file|-]',
466
+ options: {
467
+ version: { type: 'string', short: 'v', description: 'The version you read (required); refused if the doc changed since' },
468
+ ops: { type: 'string', description: 'A JSON array of {op: "append", text} and {op: "replace", oldString, newString}' },
469
+ replace: { type: 'string', description: 'Text to replace; it must occur exactly once in the markdown' },
470
+ with: { type: 'string', description: 'What --replace becomes' },
471
+ append: { type: 'string', description: 'Text added at the end, as is (@file or - for stdin)' },
472
+ },
473
+ async run(ctx) {
474
+ const id = requirePositional(ctx.positionals, 0, 'id')
475
+ const version = panoVersion(ctx.values.version)
476
+ return printPanoDoc(await pano(ctx, 'edit', { id, version, ops: await panoEditOps(ctx) }), { idOnly: true })
477
+ },
478
+ },
419
479
  {
420
480
  path: ['pano', 'read'],
421
481
  summary: 'Read a Pano doc, or download it with its files to a directory',
@@ -427,8 +487,7 @@ export const COMMANDS = [
427
487
  },
428
488
  async run(ctx) {
429
489
  const id = requirePositional(ctx.positionals, 0, 'id')
430
- const result = await ctx.client.callTool('pano', {
431
- action: 'read',
490
+ const result = await pano(ctx, 'read', {
432
491
  id,
433
492
  includeComments: ctx.values.comments || undefined,
434
493
  includeAttachments: ctx.values.attachments || undefined,
@@ -445,7 +504,7 @@ export const COMMANDS = [
445
504
  const id = requirePositional(ctx.positionals, 0, 'id')
446
505
  const raw = requirePositional(ctx.positionals, 1, 'text')
447
506
  const comment = await resolveText(raw, { stdin: ctx.stdin, what: 'the comment' })
448
- return ctx.client.callTool('pano', { action: 'comment', id, comment })
507
+ return pano(ctx, 'comment', { id, comment })
449
508
  },
450
509
  },
451
510
  {
@@ -459,7 +518,7 @@ export const COMMANDS = [
459
518
  const id = requirePositional(ctx.positionals, 0, 'id')
460
519
  const files = panoFiles(ctx.values.file)
461
520
  if (!files) throw new UserError('--file is required')
462
- return printPanoDoc(await ctx.client.callTool('pano', { action: 'attach', id, files }), { idOnly: true })
521
+ return printPanoDoc(await pano(ctx, 'attach', { id, files }), { idOnly: true })
463
522
  },
464
523
  },
465
524
  {
@@ -467,7 +526,15 @@ export const COMMANDS = [
467
526
  summary: 'Delete a Pano doc',
468
527
  usage: 'agentrq-ws pano delete <id>',
469
528
  async run(ctx) {
470
- return ctx.client.callTool('pano', { action: 'delete', id: requirePositional(ctx.positionals, 0, 'id') })
529
+ return pano(ctx, 'delete', { id: requirePositional(ctx.positionals, 0, 'id') })
530
+ },
531
+ },
532
+ {
533
+ path: ['pano', 'help'],
534
+ summary: "Show the pano tool's actions, or one action's payload",
535
+ usage: 'agentrq-ws pano help [action]',
536
+ async run(ctx) {
537
+ return actionHelp(ctx, 'pano')
471
538
  },
472
539
  },
473
540
  {
@@ -482,12 +549,7 @@ export const COMMANDS = [
482
549
  async run(ctx) {
483
550
  const name = requirePositional(ctx.positionals, 0, 'name')
484
551
  const payload = await resolveText(ctx.values.payload, { stdin: ctx.stdin, what: 'the payload' })
485
- return ctx.client.callTool('publishEvent', {
486
- name,
487
- payload,
488
- taskId: ctx.values.task,
489
- faq: parseFaq(ctx.values),
490
- })
552
+ return act(ctx, 'workspace', 'publishEvent', { name, payload, taskId: ctx.values.task, faq: parseFaq(ctx.values) }, 'publishEvent')
491
553
  },
492
554
  },
493
555
  {
@@ -520,14 +582,15 @@ export const COMMANDS = [
520
582
  if (mode === 'form' && !requestedSchema) {
521
583
  throw new UserError('mode=form needs at least one --field (or --schema)')
522
584
  }
523
- return ctx.client.callTool('elicit', {
585
+ const payload = {
524
586
  taskId,
525
587
  message,
526
588
  mode,
527
589
  requestedSchema,
528
590
  url: ctx.values.url,
529
591
  timeoutSeconds: ctx.values.timeout ? Number(ctx.values.timeout) : undefined,
530
- })
592
+ }
593
+ return ctx.client.callAction('task', 'elicit', payload, ['elicit', payload])
531
594
  },
532
595
  },
533
596
  {
@@ -543,7 +606,7 @@ export const COMMANDS = [
543
606
  const args = {}
544
607
  if (ctx.positionals.length) args.q = ctx.positionals.join(' ')
545
608
  if (ctx.values.pattern !== undefined) args.pattern = ctx.values.pattern
546
- return ctx.client.callTool('listSiteTools', withPaging(ctx, args))
609
+ return act(ctx, 'siteTools', 'search', withPaging(ctx, args), 'listSiteTools')
547
610
  },
548
611
  },
549
612
  {
@@ -553,7 +616,7 @@ export const COMMANDS = [
553
616
  async run(ctx) {
554
617
  const site = requirePositional(ctx.positionals, 0, 'site')
555
618
  const tool = requirePositional(ctx.positionals, 1, 'tool')
556
- return ctx.client.callTool('getSiteToolDefinition', { site, tool })
619
+ return act(ctx, 'siteTools', 'getDefinition', { site, tool }, 'getSiteToolDefinition')
557
620
  },
558
621
  },
559
622
  {
@@ -568,12 +631,16 @@ export const COMMANDS = [
568
631
  const site = requirePositional(ctx.positionals, 0, 'site')
569
632
  const tool = requirePositional(ctx.positionals, 1, 'tool')
570
633
  if (!ctx.values.task) throw new UserError('--task <taskId> is required')
571
- return ctx.client.callTool('callSiteTool', {
572
- taskId: ctx.values.task,
573
- site,
574
- tool,
575
- arguments: await readArgs(ctx),
576
- })
634
+ const payload = { taskId: ctx.values.task, site, tool, arguments: await readArgs(ctx) }
635
+ return act(ctx, 'siteTools', 'call', payload, 'callSiteTool')
636
+ },
637
+ },
638
+ {
639
+ path: ['tools', 'help'],
640
+ summary: "The server's help: every tool, one tool's actions, or one action's payload with an example",
641
+ usage: 'agentrq-ws tools help [tool|tool.action]',
642
+ async run(ctx) {
643
+ return ctx.client.callTool('help', { action: ctx.positionals[0] })
577
644
  },
578
645
  },
579
646
  {
@@ -604,6 +671,22 @@ export const COMMANDS = [
604
671
  },
605
672
  ]
606
673
 
674
+ /** One action of a tool; an older server gets the tool it had for it, `legacy`. */
675
+ function act(ctx, tool, action, payload, legacy) {
676
+ return ctx.client.callAction(tool, action, payload, [legacy, payload])
677
+ }
678
+
679
+ /** The server's own help for an action tool, for one action when named. */
680
+ function actionHelp(ctx, tool) {
681
+ const topic = ctx.positionals[0]
682
+ return ctx.client.callTool(tool, { action: 'help', payload: topic ? { topic } : undefined })
683
+ }
684
+
685
+ /** One pano call; a server from before payloads takes its fields beside action. */
686
+ function pano(ctx, action, payload) {
687
+ return ctx.client.callAction('pano', action, payload, ['pano', { action, ...payload }])
688
+ }
689
+
607
690
  /** --args as JSON, from inline, @file or stdin; nothing given is {}. */
608
691
  async function readArgs(ctx) {
609
692
  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
  *