@agentrq/agentrq-ws 0.9.18 → 0.9.19

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 eighteen tools are underneath this
23
+ answer is tokens the agent pays for. The same nineteen 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
@@ -56,6 +56,11 @@ Node 20.6 or newer.
56
56
  | `skill load <uri>` | Read a skill file (`skill://<name>` reads its `SKILL.md`) |
57
57
  | `skill save <uri> --content …` | Replace a file of one of this workspace's skills |
58
58
  | `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 |
61
+ | `pano comment <id> <text>` | Comment on a Pano doc |
62
+ | `pano attach <id> --file PATH…` | Attach files to a Pano doc; they need no link |
63
+ | `pano delete <id>` | Delete a Pano doc |
59
64
  | `event publish <name>` | Publish a named event |
60
65
  | `ask <taskId> <message>` | Ask the human a question and wait |
61
66
  | `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 |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentrq/agentrq-ws",
3
- "version": "0.9.18",
3
+ "version": "0.9.19",
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/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'
@@ -136,6 +137,56 @@ 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'],
@@ -330,6 +381,95 @@ export const COMMANDS = [
330
381
  return ctx.client.callTool('deleteSkill', { uri: requirePositional(ctx.positionals, 0, 'uri') })
331
382
  },
332
383
  },
384
+ {
385
+ 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]',
388
+ options: {
389
+ title: { type: 'string', short: 'T', description: "The doc's title (required)" },
390
+ markdown: { type: 'string', short: 'M', description: "The doc's full markdown (@file or - for stdin; required)" },
391
+ file: { type: 'string', multiple: true, description: 'A linked file, linked from the markdown by its file name (repeatable)' },
392
+ 'ttl-days': { type: 'string', description: 'Days the doc lives after this save (default: 30, or its own)' },
393
+ color: { type: 'string', description: `Its post-it's color: ${PANO_COLORS.join(', ')}` },
394
+ },
395
+ async run(ctx) {
396
+ if (ctx.values.title === undefined) throw new UserError('--title is required')
397
+ if (ctx.values.markdown === undefined) throw new UserError('--markdown is required (use @file or - to read from stdin)')
398
+ const markdown = await resolveText(ctx.values.markdown, { stdin: ctx.stdin, what: 'the markdown' })
399
+ const color = ctx.values.color
400
+ if (color !== undefined && !PANO_COLORS.includes(color)) {
401
+ throw new UserError(`unknown color "${color}" (expected one of: ${PANO_COLORS.join(', ')})`)
402
+ }
403
+ let ttlDays
404
+ if (ctx.values['ttl-days'] !== undefined) {
405
+ ttlDays = Number(ctx.values['ttl-days'])
406
+ if (!Number.isInteger(ttlDays) || ttlDays < 1) throw new UserError('--ttl-days must be a whole number, 1 or more')
407
+ }
408
+ return printPanoDoc(await ctx.client.callTool('pano', {
409
+ action: 'save',
410
+ id: ctx.positionals[0],
411
+ title: ctx.values.title,
412
+ markdown,
413
+ ttlDays,
414
+ color,
415
+ files: panoFiles(ctx.values.file),
416
+ }), { idOnly: true })
417
+ },
418
+ },
419
+ {
420
+ path: ['pano', 'read'],
421
+ summary: 'Read a Pano doc, or download it with its files to a directory',
422
+ usage: 'agentrq-ws pano read <id> [--comments] [--attachments] [--out DIR]',
423
+ options: {
424
+ comments: { type: 'boolean', short: 'c', description: "Include the doc's comments" },
425
+ attachments: { type: 'boolean', short: 'a', description: "Include the doc's attachments" },
426
+ out: { type: 'string', short: 'o', description: 'Write the markdown and download every file here; prints only their paths' },
427
+ },
428
+ async run(ctx) {
429
+ const id = requirePositional(ctx.positionals, 0, 'id')
430
+ const result = await ctx.client.callTool('pano', {
431
+ action: 'read',
432
+ id,
433
+ includeComments: ctx.values.comments || undefined,
434
+ includeAttachments: ctx.values.attachments || undefined,
435
+ })
436
+ if (!ctx.values.out) return result
437
+ return downloadPanoDoc(ctx, printPanoDoc(result).data, ctx.values.out)
438
+ },
439
+ },
440
+ {
441
+ path: ['pano', 'comment'],
442
+ summary: 'Comment on a Pano doc',
443
+ usage: 'agentrq-ws pano comment <id> <text|@file|->',
444
+ async run(ctx) {
445
+ const id = requirePositional(ctx.positionals, 0, 'id')
446
+ const raw = requirePositional(ctx.positionals, 1, 'text')
447
+ const comment = await resolveText(raw, { stdin: ctx.stdin, what: 'the comment' })
448
+ return ctx.client.callTool('pano', { action: 'comment', id, comment })
449
+ },
450
+ },
451
+ {
452
+ path: ['pano', 'attach'],
453
+ summary: 'Attach files to a Pano doc; they need no link',
454
+ usage: 'agentrq-ws pano attach <id> --file PATH...',
455
+ options: {
456
+ file: { type: 'string', multiple: true, description: 'A file to attach (repeatable)' },
457
+ },
458
+ async run(ctx) {
459
+ const id = requirePositional(ctx.positionals, 0, 'id')
460
+ const files = panoFiles(ctx.values.file)
461
+ if (!files) throw new UserError('--file is required')
462
+ return printPanoDoc(await ctx.client.callTool('pano', { action: 'attach', id, files }), { idOnly: true })
463
+ },
464
+ },
465
+ {
466
+ path: ['pano', 'delete'],
467
+ summary: 'Delete a Pano doc',
468
+ usage: 'agentrq-ws pano delete <id>',
469
+ async run(ctx) {
470
+ return ctx.client.callTool('pano', { action: 'delete', id: requirePositional(ctx.positionals, 0, 'id') })
471
+ },
472
+ },
333
473
  {
334
474
  path: ['event', 'publish'],
335
475
  summary: 'Publish a named event',