@agentrq/agentrq-ws 0.9.19 → 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 +5 -2
- package/package.json +1 -1
- package/src/commands.js +75 -48
- 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) |
|
|
@@ -61,18 +62,20 @@ Node 20.6 or newer.
|
|
|
61
62
|
| `pano comment <id> <text>` | Comment on a Pano doc |
|
|
62
63
|
| `pano attach <id> --file PATH…` | Attach files to a Pano doc; they need no link |
|
|
63
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 |
|
|
64
66
|
| `event publish <name>` | Publish a named event |
|
|
65
67
|
| `ask <taskId> <message>` | Ask the human a question and wait |
|
|
66
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 |
|
|
67
69
|
| `site-tool <site> <tool>` | Show one shared website's tool in full, with its input schema |
|
|
68
70
|
| `call-site-tool <site> <tool> --task <taskId>` | Run a shared website's tool in the human's Chrome, with `--args '{…}'` |
|
|
69
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 |
|
|
70
73
|
| `call <tool> --args '{…}'` | Call any tool directly |
|
|
71
74
|
|
|
72
75
|
Every command takes `--help`, and so does every family:
|
|
73
76
|
|
|
74
77
|
```bash
|
|
75
|
-
agentrq-ws task --help # lists task get / next / create / status
|
|
78
|
+
agentrq-ws task --help # lists task get / next / create / status / help
|
|
76
79
|
agentrq-ws attachment get -h # the one command, its options and defaults
|
|
77
80
|
```
|
|
78
81
|
|
package/package.json
CHANGED
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.
|
|
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)
|
|
@@ -193,7 +193,7 @@ export const COMMANDS = [
|
|
|
193
193
|
summary: 'Show the workspace title and mission',
|
|
194
194
|
usage: 'agentrq-ws workspace',
|
|
195
195
|
async run(ctx) {
|
|
196
|
-
return ctx
|
|
196
|
+
return act(ctx, 'workspace', 'get', {}, 'getWorkspace')
|
|
197
197
|
},
|
|
198
198
|
},
|
|
199
199
|
{
|
|
@@ -206,13 +206,13 @@ export const COMMANDS = [
|
|
|
206
206
|
limit: { type: 'string', description: 'Maximum messages to return (default 5)' },
|
|
207
207
|
},
|
|
208
208
|
async run(ctx) {
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
taskId,
|
|
209
|
+
const payload = {
|
|
210
|
+
taskId: requirePositional(ctx.positionals, 0, 'taskId'),
|
|
212
211
|
includeConversation: ctx.values.conversation || undefined,
|
|
213
212
|
cursor: ctx.values.cursor ? Number(ctx.values.cursor) : undefined,
|
|
214
213
|
limit: ctx.values.limit ? Number(ctx.values.limit) : undefined,
|
|
215
|
-
}
|
|
214
|
+
}
|
|
215
|
+
return ctx.client.callAction('task', 'get', payload, ['getTask', payload])
|
|
216
216
|
},
|
|
217
217
|
},
|
|
218
218
|
{
|
|
@@ -225,9 +225,8 @@ export const COMMANDS = [
|
|
|
225
225
|
async run(ctx) {
|
|
226
226
|
// Kept as its own verb rather than a bare `task get`: this call mutates
|
|
227
227
|
// the queue, and a command that silently claims work is a bad surprise.
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
})
|
|
228
|
+
const payload = { includeConversation: ctx.values.conversation || undefined }
|
|
229
|
+
return ctx.client.callAction('task', 'get', payload, ['getTask', payload])
|
|
231
230
|
},
|
|
232
231
|
},
|
|
233
232
|
{
|
|
@@ -248,7 +247,7 @@ export const COMMANDS = [
|
|
|
248
247
|
async run(ctx) {
|
|
249
248
|
const title = requirePositional(ctx.positionals, 0, 'title')
|
|
250
249
|
const body = await resolveText(ctx.values.body, { stdin: ctx.stdin, what: 'the task body' })
|
|
251
|
-
|
|
250
|
+
const payload = {
|
|
252
251
|
title,
|
|
253
252
|
body: body ?? '',
|
|
254
253
|
assignee: ctx.values.assignee,
|
|
@@ -259,7 +258,8 @@ export const COMMANDS = [
|
|
|
259
258
|
// never expressed.
|
|
260
259
|
clearContext: ctx.values['clear-context'] || undefined,
|
|
261
260
|
attachments: collectAttachments(ctx.values),
|
|
262
|
-
}
|
|
261
|
+
}
|
|
262
|
+
return ctx.client.callAction('task', 'create', payload, ['createTask', payload])
|
|
263
263
|
},
|
|
264
264
|
},
|
|
265
265
|
{
|
|
@@ -272,7 +272,7 @@ export const COMMANDS = [
|
|
|
272
272
|
if (!TASK_STATUSES.includes(status)) {
|
|
273
273
|
throw new UserError(`unknown status "${status}" (expected one of: ${TASK_STATUSES.join(', ')})`)
|
|
274
274
|
}
|
|
275
|
-
return ctx.client.
|
|
275
|
+
return ctx.client.callAction('task', 'updateStatus', { taskId, status }, ['updateTaskStatus', { taskId, status }])
|
|
276
276
|
},
|
|
277
277
|
},
|
|
278
278
|
{
|
|
@@ -283,14 +283,19 @@ export const COMMANDS = [
|
|
|
283
283
|
attach: { type: 'string', multiple: true, description: 'File to attach (repeatable)' },
|
|
284
284
|
},
|
|
285
285
|
async run(ctx) {
|
|
286
|
-
const
|
|
286
|
+
const taskId = requirePositional(ctx.positionals, 0, 'taskId')
|
|
287
287
|
const raw = requirePositional(ctx.positionals, 1, 'text')
|
|
288
288
|
const text = await resolveText(raw, { stdin: ctx.stdin, what: 'the reply text' })
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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')
|
|
294
299
|
},
|
|
295
300
|
},
|
|
296
301
|
{
|
|
@@ -313,7 +318,7 @@ export const COMMANDS = [
|
|
|
313
318
|
summary: 'Read a workspace memory (defaults to the index)',
|
|
314
319
|
usage: 'agentrq-ws memory load [name]',
|
|
315
320
|
async run(ctx) {
|
|
316
|
-
return ctx
|
|
321
|
+
return act(ctx, 'memory', 'load', { name: ctx.positionals[0] }, 'loadMemory')
|
|
317
322
|
},
|
|
318
323
|
},
|
|
319
324
|
{
|
|
@@ -326,7 +331,7 @@ export const COMMANDS = [
|
|
|
326
331
|
async run(ctx) {
|
|
327
332
|
if (ctx.values.content === undefined) throw new UserError('--content is required (use @file or - to read from stdin)')
|
|
328
333
|
const content = await resolveText(ctx.values.content, { stdin: ctx.stdin, what: 'the memory content' })
|
|
329
|
-
return ctx
|
|
334
|
+
return act(ctx, 'memory', 'save', { name: ctx.positionals[0], content }, 'saveMemory')
|
|
330
335
|
},
|
|
331
336
|
},
|
|
332
337
|
{
|
|
@@ -334,7 +339,7 @@ export const COMMANDS = [
|
|
|
334
339
|
summary: 'Delete a workspace memory',
|
|
335
340
|
usage: 'agentrq-ws memory delete [name]',
|
|
336
341
|
async run(ctx) {
|
|
337
|
-
return ctx
|
|
342
|
+
return act(ctx, 'memory', 'delete', { name: ctx.positionals[0] }, 'deleteMemory')
|
|
338
343
|
},
|
|
339
344
|
},
|
|
340
345
|
{
|
|
@@ -348,7 +353,7 @@ export const COMMANDS = [
|
|
|
348
353
|
async run(ctx) {
|
|
349
354
|
const args = {}
|
|
350
355
|
if (ctx.positionals.length) args.q = ctx.positionals.join(' ')
|
|
351
|
-
return ctx
|
|
356
|
+
return act(ctx, 'skills', 'search', withPaging(ctx, args), 'searchSkills')
|
|
352
357
|
},
|
|
353
358
|
},
|
|
354
359
|
{
|
|
@@ -356,7 +361,7 @@ export const COMMANDS = [
|
|
|
356
361
|
summary: 'Read a skill file (skill://<name> reads its SKILL.md)',
|
|
357
362
|
usage: 'agentrq-ws skill load <uri>',
|
|
358
363
|
async run(ctx) {
|
|
359
|
-
return ctx
|
|
364
|
+
return act(ctx, 'skills', 'load', { uri: requirePositional(ctx.positionals, 0, 'uri') }, 'loadSkill')
|
|
360
365
|
},
|
|
361
366
|
},
|
|
362
367
|
{
|
|
@@ -370,7 +375,7 @@ export const COMMANDS = [
|
|
|
370
375
|
const uri = requirePositional(ctx.positionals, 0, 'uri')
|
|
371
376
|
if (ctx.values.content === undefined) throw new UserError('--content is required (use @file or - to read from stdin)')
|
|
372
377
|
const content = await resolveText(ctx.values.content, { stdin: ctx.stdin, what: 'the skill file' })
|
|
373
|
-
return ctx
|
|
378
|
+
return act(ctx, 'skills', 'save', { uri, content }, 'saveSkill')
|
|
374
379
|
},
|
|
375
380
|
},
|
|
376
381
|
{
|
|
@@ -378,7 +383,7 @@ export const COMMANDS = [
|
|
|
378
383
|
summary: 'Delete a skill (skill://<name>) or one of its files',
|
|
379
384
|
usage: 'agentrq-ws skill delete <uri>',
|
|
380
385
|
async run(ctx) {
|
|
381
|
-
return ctx
|
|
386
|
+
return act(ctx, 'skills', 'delete', { uri: requirePositional(ctx.positionals, 0, 'uri') }, 'deleteSkill')
|
|
382
387
|
},
|
|
383
388
|
},
|
|
384
389
|
{
|
|
@@ -405,8 +410,7 @@ export const COMMANDS = [
|
|
|
405
410
|
ttlDays = Number(ctx.values['ttl-days'])
|
|
406
411
|
if (!Number.isInteger(ttlDays) || ttlDays < 1) throw new UserError('--ttl-days must be a whole number, 1 or more')
|
|
407
412
|
}
|
|
408
|
-
return printPanoDoc(await ctx
|
|
409
|
-
action: 'save',
|
|
413
|
+
return printPanoDoc(await pano(ctx, 'save', {
|
|
410
414
|
id: ctx.positionals[0],
|
|
411
415
|
title: ctx.values.title,
|
|
412
416
|
markdown,
|
|
@@ -427,8 +431,7 @@ export const COMMANDS = [
|
|
|
427
431
|
},
|
|
428
432
|
async run(ctx) {
|
|
429
433
|
const id = requirePositional(ctx.positionals, 0, 'id')
|
|
430
|
-
const result = await ctx
|
|
431
|
-
action: 'read',
|
|
434
|
+
const result = await pano(ctx, 'read', {
|
|
432
435
|
id,
|
|
433
436
|
includeComments: ctx.values.comments || undefined,
|
|
434
437
|
includeAttachments: ctx.values.attachments || undefined,
|
|
@@ -445,7 +448,7 @@ export const COMMANDS = [
|
|
|
445
448
|
const id = requirePositional(ctx.positionals, 0, 'id')
|
|
446
449
|
const raw = requirePositional(ctx.positionals, 1, 'text')
|
|
447
450
|
const comment = await resolveText(raw, { stdin: ctx.stdin, what: 'the comment' })
|
|
448
|
-
return ctx
|
|
451
|
+
return pano(ctx, 'comment', { id, comment })
|
|
449
452
|
},
|
|
450
453
|
},
|
|
451
454
|
{
|
|
@@ -459,7 +462,7 @@ export const COMMANDS = [
|
|
|
459
462
|
const id = requirePositional(ctx.positionals, 0, 'id')
|
|
460
463
|
const files = panoFiles(ctx.values.file)
|
|
461
464
|
if (!files) throw new UserError('--file is required')
|
|
462
|
-
return printPanoDoc(await ctx
|
|
465
|
+
return printPanoDoc(await pano(ctx, 'attach', { id, files }), { idOnly: true })
|
|
463
466
|
},
|
|
464
467
|
},
|
|
465
468
|
{
|
|
@@ -467,7 +470,15 @@ export const COMMANDS = [
|
|
|
467
470
|
summary: 'Delete a Pano doc',
|
|
468
471
|
usage: 'agentrq-ws pano delete <id>',
|
|
469
472
|
async run(ctx) {
|
|
470
|
-
return 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')
|
|
471
482
|
},
|
|
472
483
|
},
|
|
473
484
|
{
|
|
@@ -482,12 +493,7 @@ export const COMMANDS = [
|
|
|
482
493
|
async run(ctx) {
|
|
483
494
|
const name = requirePositional(ctx.positionals, 0, 'name')
|
|
484
495
|
const payload = await resolveText(ctx.values.payload, { stdin: ctx.stdin, what: 'the payload' })
|
|
485
|
-
return ctx.
|
|
486
|
-
name,
|
|
487
|
-
payload,
|
|
488
|
-
taskId: ctx.values.task,
|
|
489
|
-
faq: parseFaq(ctx.values),
|
|
490
|
-
})
|
|
496
|
+
return act(ctx, 'workspace', 'publishEvent', { name, payload, taskId: ctx.values.task, faq: parseFaq(ctx.values) }, 'publishEvent')
|
|
491
497
|
},
|
|
492
498
|
},
|
|
493
499
|
{
|
|
@@ -520,14 +526,15 @@ export const COMMANDS = [
|
|
|
520
526
|
if (mode === 'form' && !requestedSchema) {
|
|
521
527
|
throw new UserError('mode=form needs at least one --field (or --schema)')
|
|
522
528
|
}
|
|
523
|
-
|
|
529
|
+
const payload = {
|
|
524
530
|
taskId,
|
|
525
531
|
message,
|
|
526
532
|
mode,
|
|
527
533
|
requestedSchema,
|
|
528
534
|
url: ctx.values.url,
|
|
529
535
|
timeoutSeconds: ctx.values.timeout ? Number(ctx.values.timeout) : undefined,
|
|
530
|
-
}
|
|
536
|
+
}
|
|
537
|
+
return ctx.client.callAction('task', 'elicit', payload, ['elicit', payload])
|
|
531
538
|
},
|
|
532
539
|
},
|
|
533
540
|
{
|
|
@@ -543,7 +550,7 @@ export const COMMANDS = [
|
|
|
543
550
|
const args = {}
|
|
544
551
|
if (ctx.positionals.length) args.q = ctx.positionals.join(' ')
|
|
545
552
|
if (ctx.values.pattern !== undefined) args.pattern = ctx.values.pattern
|
|
546
|
-
return ctx
|
|
553
|
+
return act(ctx, 'siteTools', 'search', withPaging(ctx, args), 'listSiteTools')
|
|
547
554
|
},
|
|
548
555
|
},
|
|
549
556
|
{
|
|
@@ -553,7 +560,7 @@ export const COMMANDS = [
|
|
|
553
560
|
async run(ctx) {
|
|
554
561
|
const site = requirePositional(ctx.positionals, 0, 'site')
|
|
555
562
|
const tool = requirePositional(ctx.positionals, 1, 'tool')
|
|
556
|
-
return ctx
|
|
563
|
+
return act(ctx, 'siteTools', 'getDefinition', { site, tool }, 'getSiteToolDefinition')
|
|
557
564
|
},
|
|
558
565
|
},
|
|
559
566
|
{
|
|
@@ -568,12 +575,16 @@ export const COMMANDS = [
|
|
|
568
575
|
const site = requirePositional(ctx.positionals, 0, 'site')
|
|
569
576
|
const tool = requirePositional(ctx.positionals, 1, 'tool')
|
|
570
577
|
if (!ctx.values.task) throw new UserError('--task <taskId> is required')
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
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] })
|
|
577
588
|
},
|
|
578
589
|
},
|
|
579
590
|
{
|
|
@@ -604,6 +615,22 @@ export const COMMANDS = [
|
|
|
604
615
|
},
|
|
605
616
|
]
|
|
606
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
|
+
|
|
607
634
|
/** --args as JSON, from inline, @file or stdin; nothing given is {}. */
|
|
608
635
|
async function readArgs(ctx) {
|
|
609
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
|
*
|