shapewall 0.3.1 → 0.3.3
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/CHANGELOG.md +142 -0
- package/NOTICE +7 -0
- package/README.md +4 -2
- package/THIRD_PARTY.md +39 -0
- package/dist/agent/package-lock.json +2 -2
- package/dist/client/assets/BoardChat-DxehB761.js +27 -0
- package/dist/client/assets/BuzzDialog-Ix9qJvim.js +1 -0
- package/dist/client/assets/ChecksPanel-pA_ueIaJ.js +1 -0
- package/dist/client/assets/History-C9N32kCv.js +1 -0
- package/dist/client/assets/LocalSettings-DawtKnvi.js +1 -0
- package/dist/client/assets/{Management-BFcKFdbp.js → Management-NVFDtSZB.js} +1 -1
- package/dist/client/assets/QuickConnect-DO1TjS1t.js +1 -0
- package/dist/client/assets/ShareDialog-By0ETg6n.js +2 -0
- package/dist/client/assets/app-update-dialog-RGIw24iZ.js +1 -0
- package/dist/client/assets/{circle-x-PRxj7kPi.js → circle-x-B6KfScOE.js} +1 -1
- package/dist/client/assets/index-CsqLdqGx.css +2 -0
- package/dist/client/assets/index-DnZarJ3U.js +37 -0
- package/dist/client/assets/{refresh-cw-aeOBDuGQ.js → refresh-cw-vkgvCCfR.js} +1 -1
- package/dist/client/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/dist/client/assets/{shield-check-DuPBJ6H_.js → shield-check-QzwGhz0t.js} +1 -1
- package/dist/client/assets/ui-DI-FGWWK.js +41 -0
- package/dist/client/build-info.json +1 -1
- package/dist/client/index.html +4 -3
- package/dist/client/sw.js +2 -2
- package/dist/console/assets/{LocalAccountsApp-lJjkhUcH.js → LocalAccountsApp-VOCZg8dg.js} +1 -1
- package/dist/console/assets/{LocalConsole-BZHqYKnt.js → LocalConsole-CMwAW-mF.js} +1 -1
- package/dist/console/assets/{app-update-dialog-DCM9sYE3.js → app-update-dialog-Cw6UDqNP.js} +1 -1
- package/dist/console/assets/console-DgfWmUEx.js +55 -0
- package/dist/console/assets/console-Lis0vvdL.css +2 -0
- package/dist/console/build-info.json +1 -1
- package/dist/console/console.html +2 -2
- package/docs/agent-workflow.md +19 -3
- package/docs/agents.md +62 -2
- package/docs/config.md +3 -3
- package/docs/deployment.md +2 -0
- package/docs/design-system.md +20 -15
- package/docs/hosted.md +19 -0
- package/docs/pull-requests.md +4 -1
- package/docs/where-to-run.md +88 -0
- package/package.json +2 -1
- package/src/agent/agent-logos.js +81 -0
- package/src/agent/composer.js +9 -5
- package/src/agent/config.js +27 -2
- package/src/agent/context.js +3 -1
- package/src/agent/icon-store.js +100 -0
- package/src/agent/identity.js +77 -0
- package/src/agent/owner-mcp.js +19 -3
- package/src/agent/routes.js +82 -21
- package/src/agent/run.js +3 -1
- package/src/agent/settings-routes.js +233 -14
- package/src/agent/test-timing.js +14 -0
- package/src/agent/tools.js +6 -3
- package/src/agent/user-settings.js +51 -3
- package/src/capture/capture.js +3 -1
- package/src/capture/element-map.js +73 -11
- package/src/ci/settings.js +3 -3
- package/src/ci/start.js +16 -0
- package/src/ci/summary.js +8 -1
- package/src/cli/args.js +1 -0
- package/src/cli/ci.js +2 -2
- package/src/cli/comments.js +5 -4
- package/src/cli/help.js +3 -1
- package/src/cli/init.js +2 -2
- package/src/comment-fields.js +45 -0
- package/src/comments-cli.js +100 -21
- package/src/discover.js +34 -1
- package/src/doctor.js +26 -1
- package/src/event-log.js +5 -2
- package/src/feedback.js +5 -2
- package/src/github.js +4 -2
- package/src/hosted/agent-presence.js +40 -0
- package/src/hosted/app.js +6 -0
- package/src/hosted/board-routes.js +9 -1
- package/src/hosted/comments.js +11 -11
- package/src/hosted/console-routes.js +47 -1
- package/src/hosted/events.js +6 -4
- package/src/hosted/import.js +7 -4
- package/src/hosted/presence.js +1 -1
- package/src/hosted/projects.js +32 -1
- package/src/hosted/token-api.js +5 -1
- package/src/hosted/token-events.js +5 -2
- package/src/hosted/tokens.js +3 -2
- package/src/mcp.js +10 -2
- package/src/notify/messages.js +6 -4
- package/src/store.js +19 -11
- package/dist/client/assets/BoardChat-V1BCXdDB.js +0 -27
- package/dist/client/assets/BuzzDialog-Ds7Thpfe.js +0 -1
- package/dist/client/assets/ChecksPanel-Cm22bCdQ.js +0 -1
- package/dist/client/assets/History-U0bD1BjA.js +0 -1
- package/dist/client/assets/LocalSettings-DOSuW7VC.js +0 -1
- package/dist/client/assets/QuickConnect-DyfPSWbV.js +0 -1
- package/dist/client/assets/ShareDialog-BouvNraR.js +0 -2
- package/dist/client/assets/app-update-dialog-DH2Mgby8.js +0 -1
- package/dist/client/assets/index-C9S7HL_o.js +0 -37
- package/dist/client/assets/index-CXtuJi1K.css +0 -2
- package/dist/client/assets/ui-Cg4TTrec.js +0 -41
- package/dist/console/assets/console-C2LsvEco.js +0 -55
- package/dist/console/assets/console-Fp4k9iyx.css +0 -2
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Where to run Shapewall
|
|
2
|
+
|
|
3
|
+
Shapewall has two shapes. Pick by who needs the board and when, not by how big the site is.
|
|
4
|
+
|
|
5
|
+
| You are | Run | Who can open it | Always on? |
|
|
6
|
+
| ----------------------------------------------- | ------------------------------------------------------------ | ------------------------------------ | -------------------------- |
|
|
7
|
+
| One person, reviewing your own project | `npx shapewall serve` in the project, next to its dev server | You, on this machine | No: start it when you work |
|
|
8
|
+
| One person, also on your phone or second laptop | `npx shapewall serve --tailscale` | Your own devices on your tailnet | No |
|
|
9
|
+
| A team, or you and your agents around the clock | `shapewall hosted --tailscale` on a machine that stays on | Everyone you invite, on your tailnet | Yes |
|
|
10
|
+
| A team with people outside your tailnet | `shapewall hosted` behind your own domain | Everyone you invite, from anywhere | Yes |
|
|
11
|
+
|
|
12
|
+
The first two are the same local board. The last two are the same hosted server, reached two ways. Nothing about a project changes
|
|
13
|
+
when you move between them: the config, the captures and the comments are the same files.
|
|
14
|
+
|
|
15
|
+
## The local board
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npx shapewall doctor --install-browser
|
|
19
|
+
npx shapewall init --base-url http://localhost:3000
|
|
20
|
+
npx shapewall capture
|
|
21
|
+
npx shapewall serve --open
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
It lives in the project folder, runs while you work and stops when you close it, like a dev server. Captures, comments and agent fixes
|
|
25
|
+
all happen on this machine. There is no account and nothing to host. Details: [Running and sharing a board](deployment.md).
|
|
26
|
+
|
|
27
|
+
To use the same board from your phone, add `--tailscale`: Shapewall asks Tailscale to serve it at this machine's private HTTPS name,
|
|
28
|
+
and your other devices pair once. See [Your own other devices](deployment.md#your-own-other-devices-local-mode).
|
|
29
|
+
|
|
30
|
+
Working on several projects? Each one has its own board on its own port, and the site dropdown switches between the ones that are
|
|
31
|
+
running. See [Several local projects](deployment.md#several-local-projects).
|
|
32
|
+
|
|
33
|
+
## The hosted server
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
shapewall hosted --data ./hosted-data --tailscale
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
One server for all your projects: passkey accounts, workspaces, invites, roles, share links and live presence. It runs on any machine
|
|
40
|
+
that stays on: a spare computer at home, a server in the office, a small cloud machine. It needs Node 22.13 or newer and little else:
|
|
41
|
+
it stores and serves boards, and runs no browser and no agent. The full guide is [the hosted operator guide](hosted.md).
|
|
42
|
+
|
|
43
|
+
**Tailscale is the recommended way to reach it.** With `--tailscale` the server gets a private HTTPS address on the machine's tailnet
|
|
44
|
+
name, with a real certificate and nothing open to the internet. Add `--funnel` to make only guest share links public while the console
|
|
45
|
+
and sign-in stay private. When people outside your tailnet need accounts, put the server behind your own domain instead:
|
|
46
|
+
`shapewall hosted --setup --domain app.example.com` writes a Docker Compose and Caddy folder for that
|
|
47
|
+
([Own domain deployment](hosted.md#own-domain-deployment-mode-2)).
|
|
48
|
+
|
|
49
|
+
### Where the work happens
|
|
50
|
+
|
|
51
|
+
The hosted server never captures a page and never edits code. Those happen on a machine that has the project:
|
|
52
|
+
|
|
53
|
+
```text
|
|
54
|
+
machine with the code hosted server
|
|
55
|
+
--------------------- -------------
|
|
56
|
+
shapewall capture -> shapewall push -> stores the board, shows it to everyone
|
|
57
|
+
agent fixes the code <- shapewall watch <- a comment someone left
|
|
58
|
+
recapture, push, reply -> the thread shows the fix
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
1. **Sign the machine in once.** `shapewall login --remote https://your-server` shows a code; approve it in the console and choose the
|
|
62
|
+
project. Tick **Take agent work** if this machine should pick up comments.
|
|
63
|
+
2. **Push the board.** `shapewall capture`, then `shapewall push --remote https://your-server`. Push again after every capture, or
|
|
64
|
+
from CI.
|
|
65
|
+
3. **Let an agent pick up comments (optional).** `shapewall watch --remote https://your-server --exec "<your agent command>"` runs
|
|
66
|
+
your command once per new comment, with the comment's JSON on stdin (`{ "board": ..., "comment": ... }`). The command edits the
|
|
67
|
+
code; a wrapper around it recaptures, pushes and replies. [Agent recipes](agent-recipes.md) has commands for Claude Code, Codex and
|
|
68
|
+
goose.
|
|
69
|
+
|
|
70
|
+
While the watching machine is off, comments still save on the server and wait. Nothing is lost; nothing is fixed until it is back.
|
|
71
|
+
|
|
72
|
+
### One machine, several projects
|
|
73
|
+
|
|
74
|
+
`shapewall login` remembers one project for each server. For a second project on the same server, make a token on that project's page
|
|
75
|
+
in the console, keep it in a file only you can read, and pass it: `--token-file ~/.config/shapewall/other-project.token` (or
|
|
76
|
+
`SHAPEWALL_TOKEN`). A watcher that runs as a service should use a token file of its own, so a later `login` cannot change what it
|
|
77
|
+
talks to.
|
|
78
|
+
|
|
79
|
+
## Which one should I start with?
|
|
80
|
+
|
|
81
|
+
Start local. It takes four commands and nothing to maintain. Move to the hosted server when one of these is true:
|
|
82
|
+
|
|
83
|
+
- someone else needs to comment, and a share link or a screenshot is not enough;
|
|
84
|
+
- you want to leave comments from anywhere and have an agent on another machine act on them;
|
|
85
|
+
- the board should be there when your laptop is closed.
|
|
86
|
+
|
|
87
|
+
`shapewall share --remote https://your-server` moves a local project's captures, history and comments to a hosted project in one go
|
|
88
|
+
([Move a local project to your team](hosted.md#move-a-local-project-to-your-team)).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shapewall",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Every page of your site on one zoomable wall: desktop and phone captures, sandboxed live HTML, and element-anchored comments your coding agent can read.",
|
|
5
5
|
"license": "Apache-2.0 AND FSL-1.1-ALv2",
|
|
6
6
|
"author": "Dan Baruch",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"docs/performance.md",
|
|
51
51
|
"docs/starter-agent.md",
|
|
52
52
|
"docs/updates.md",
|
|
53
|
+
"docs/where-to-run.md",
|
|
53
54
|
"docs/images"
|
|
54
55
|
],
|
|
55
56
|
"engines": {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// The product marks of the agents Shapewall knows how to run: the default
|
|
2
|
+
// icon of a connected Claude Code, Codex, goose or Gemini CLI, until its owner
|
|
3
|
+
// picks an avatar or uploads a picture (identity.js). Data only, one entry per mark,
|
|
4
|
+
// so adding or removing one is one line here (and its row in THIRD_PARTY.md).
|
|
5
|
+
//
|
|
6
|
+
// Each mark is another company's trademark, shown only to identify the agent
|
|
7
|
+
// the owner connected, with no endorsement implied (NOTICE). They are used
|
|
8
|
+
// exactly as sourced: one path, one colour, never redrawn, recoloured into
|
|
9
|
+
// Shapewall's accent or combined with another shape. The board draws them in
|
|
10
|
+
// the text colour on a neutral tile (client/src/chat/agentIcons.jsx).
|
|
11
|
+
//
|
|
12
|
+
// Source: the Simple Icons project (https://simpleicons.org), npm package
|
|
13
|
+
// simple-icons, released under CC0 1.0. Simple Icons carries no separate
|
|
14
|
+
// licence entry for these marks; its disclaimer says a brand may still have
|
|
15
|
+
// its own terms, and CC0 waives no trademark rights. Claude and Google
|
|
16
|
+
// Gemini are from 16.37.0. OpenAI is from 15.22.0, the last release that has
|
|
17
|
+
// it: Simple Icons removed the icon in 16.0.0 (pull request 13944, "assuming
|
|
18
|
+
// no permissions are sought/obtained"), so it is here by the owner's
|
|
19
|
+
// decision, with that provenance said plainly in THIRD_PARTY.md.
|
|
20
|
+
//
|
|
21
|
+
// The goose mark is the project's own file, from its official repository
|
|
22
|
+
// (github.com/aaif-goose/goose, where github.com/block/goose now redirects;
|
|
23
|
+
// Apache 2.0). goose is a project of LF Projects, LLC, whose trademark policy
|
|
24
|
+
// (https://lfprojects.org/policies/trademark-policy/) covers its name and logo.
|
|
25
|
+
//
|
|
26
|
+
// A mark is only added from a source that may be redistributed, never drawn
|
|
27
|
+
// to look like one or copied from an unofficial site.
|
|
28
|
+
//
|
|
29
|
+
// No Node imports: the board and the demo share this file.
|
|
30
|
+
|
|
31
|
+
const SIMPLE_ICONS = 'Simple Icons 16.37.0 (https://simpleicons.org), CC0 1.0'
|
|
32
|
+
// The last release with the OpenAI icon (removed in 16.0.0).
|
|
33
|
+
const SIMPLE_ICONS_15 = 'Simple Icons 15.22.0 (https://simpleicons.org), CC0 1.0'
|
|
34
|
+
|
|
35
|
+
export const AGENT_LOGOS = [
|
|
36
|
+
{
|
|
37
|
+
id: 'claude',
|
|
38
|
+
name: 'Claude',
|
|
39
|
+
owner: 'Anthropic, PBC',
|
|
40
|
+
// The known agents (acp/detect.js KNOWN_AGENTS ids) it is the default icon of.
|
|
41
|
+
agents: ['claude'],
|
|
42
|
+
viewBox: '0 0 24 24',
|
|
43
|
+
path: 'm4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z',
|
|
44
|
+
source: `${SIMPLE_ICONS}, icons/claude.svg`,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'openai',
|
|
48
|
+
name: 'OpenAI',
|
|
49
|
+
owner: 'OpenAI',
|
|
50
|
+
agents: ['codex'],
|
|
51
|
+
viewBox: '0 0 24 24',
|
|
52
|
+
path: 'M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z',
|
|
53
|
+
source: `${SIMPLE_ICONS_15}, icons/openai.svg`,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 'goose',
|
|
57
|
+
name: 'goose',
|
|
58
|
+
owner: 'LF Projects, LLC',
|
|
59
|
+
agents: ['goose'],
|
|
60
|
+
viewBox: '0 0 45 45',
|
|
61
|
+
path: 'M43.2098 39.2492L39.8118 36.4522C37.9646 34.9318 36.3923 33.1051 35.1631 31.0529C33.4647 28.2172 31.1178 25.8243 28.3164 24.071L26.9482 23.2744C26.4794 22.9485 26.1525 22.4405 26.106 21.8675C26.0762 21.4981 26.1647 21.1678 26.3712 20.8771C27.0837 19.873 30.9617 15.6995 31.6365 15.1411C32.5056 14.4228 33.4739 13.8253 34.3724 13.1412C34.5001 13.0438 34.6283 12.9469 34.7545 12.8481C34.7589 12.8437 34.7653 12.8403 34.7692 12.8363C35.0574 12.6088 35.3295 12.3671 35.5458 12.0803C36.5993 10.8604 36.5783 9.82938 36.5783 9.82938C36.5783 9.82938 36.5793 9.8284 36.5798 9.82791C36.4677 9.5534 36.0645 8.69902 35.2449 8.29825C35.9696 8.28406 36.7872 8.55564 37.1582 8.91873C37.6039 8.21947 37.8922 7.76585 38.3404 7.00347C38.4471 6.82241 38.5038 6.48771 38.2998 6.30029C38.2998 6.30029 38.2988 6.30029 38.2978 6.30029C38.2978 6.30029 38.2978 6.29931 38.2978 6.29833C38.2939 6.29442 38.289 6.29148 38.2851 6.28757C38.2812 6.28365 38.2787 6.27925 38.2743 6.27485C38.2743 6.27485 38.2734 6.27485 38.2724 6.27485C38.2724 6.27485 38.2724 6.27387 38.2724 6.27289C38.2641 6.26457 38.2548 6.25821 38.246 6.25038C38.2406 6.245 38.2362 6.23864 38.2313 6.23276C38.2254 6.22787 38.219 6.22347 38.2137 6.21808C38.2053 6.20977 38.2 6.19949 38.1911 6.19166C38.1911 6.19166 38.1897 6.19117 38.1892 6.19166C38.1892 6.19166 38.1892 6.19068 38.1892 6.1897C38.1853 6.18579 38.1804 6.18285 38.1765 6.17894C38.1726 6.17502 38.1696 6.17013 38.1657 6.16621C38.1657 6.16621 38.1642 6.16572 38.1637 6.16621C38.1637 6.16621 38.1637 6.16524 38.1637 6.16426C37.9763 5.9602 37.6416 6.01697 37.4606 6.12364C36.4692 6.70693 35.5047 7.33475 34.6351 7.88525C34.6351 7.88525 33.6046 7.86372 32.3842 8.91775C32.097 9.13452 31.8552 9.4066 31.6282 9.69433C31.6238 9.69873 31.6199 9.7046 31.6164 9.70901C31.5171 9.83476 31.4202 9.96297 31.3233 10.0912C30.6387 10.9901 30.0417 11.958 29.3234 12.8271C28.7656 13.5023 24.5915 17.3798 23.5874 18.0923C23.2967 18.2988 22.9669 18.3879 22.597 18.3575C22.0245 18.3115 21.5161 17.9842 21.1902 17.5154L20.3935 16.1472C18.6402 13.3448 16.2474 10.9989 13.4117 9.30041C11.3594 8.0712 9.5332 6.49847 8.01234 4.65172L5.2153 1.25377C5.0773 1.08642 4.81306 1.11382 4.71422 1.30662C4.39615 1.92612 3.78888 3.23411 3.32353 4.99327C3.31227 5.03487 3.32206 5.07891 3.34946 5.11218C3.92786 5.81095 5.26717 7.35089 6.8624 8.65351C6.97348 8.74403 6.88246 8.92313 6.74447 8.88496C5.36846 8.51013 4.03062 7.90825 3.02944 7.39542C2.94772 7.35383 2.84887 7.4057 2.83713 7.49672C2.68152 8.74354 2.64139 10.1127 2.80581 11.5562C2.8107 11.6032 2.84055 11.6438 2.8841 11.6629C4.02572 12.1596 5.85143 12.8804 7.76816 13.3389C7.90713 13.3722 7.90273 13.5723 7.76229 13.5992C6.26982 13.8801 4.70688 13.9427 3.43656 13.9261C3.3475 13.9251 3.28193 14.0093 3.30591 14.0949C3.56085 14.9958 3.90632 15.9118 4.3619 16.8342C4.55029 17.2487 4.75532 17.6553 4.97504 18.0532C5.01271 18.1212 5.08562 18.1618 5.16343 18.1584C6.21207 18.107 7.47946 17.9964 8.75369 17.7713C8.97095 17.7331 9.08741 18.0189 8.90391 18.1417C8.03877 18.7201 7.11588 19.2183 6.25758 19.6283C6.14259 19.6836 6.1054 19.8304 6.18125 19.9327C6.69114 20.6236 7.25191 21.2774 7.86114 21.8866C7.86114 21.8866 10.8608 24.9763 10.9425 25.2185C12.6928 23.4261 15.5701 21.4394 18.7474 19.7047C14.4921 23.1672 12.1198 25.7235 10.9258 27.1758L10.0935 28.3439C9.66091 28.9507 9.2856 29.5951 8.97193 30.2709C7.92231 32.5292 6.19201 37.0966 6.19201 37.0966C6.0594 37.4543 6.16755 37.8072 6.39753 38.0371C6.40292 38.0425 6.4083 38.0479 6.41417 38.0528C6.41955 38.0582 6.42445 38.0641 6.42983 38.0694C6.66031 38.2999 7.01263 38.4076 7.37033 38.275C7.37033 38.275 11.9368 36.5447 14.1961 35.495C14.8719 35.1814 15.5168 34.8056 16.1231 34.3735L17.4095 33.457C18.0907 32.9715 19.0234 33.0489 19.615 33.6405L22.5804 36.6058C23.1896 37.2151 23.8433 37.7758 24.5343 38.2857C24.637 38.3611 24.7833 38.3244 24.8386 38.2094C25.2492 37.3516 25.7473 36.4277 26.3252 35.5631C26.4481 35.3796 26.7343 35.4965 26.6957 35.7133C26.4701 36.988 26.3605 38.2554 26.3086 39.3035C26.3047 39.3809 26.3458 39.4543 26.4138 39.4919C26.8112 39.7121 27.2178 39.9172 27.6327 40.1051C28.5551 40.5606 29.4717 40.9066 30.3721 41.1611C30.4577 41.185 30.5419 41.1195 30.5409 41.0304C30.5237 39.7596 30.5864 38.1967 30.8677 36.7047C30.8942 36.5638 31.0943 36.5593 31.1281 36.6988C31.5861 38.616 32.3069 40.4417 32.8041 41.5829C32.8231 41.6264 32.8633 41.6558 32.9107 41.6612C34.3543 41.8256 35.7234 41.7855 36.9703 41.6298C37.0618 41.6186 37.1136 41.5197 37.0715 41.4375C36.5587 40.4364 35.9568 39.0975 35.582 37.7225C35.5443 37.584 35.7229 37.4935 35.8135 37.6046C37.1161 39.1998 38.656 40.5391 39.3548 41.1175C39.3881 41.1449 39.4326 41.1542 39.4737 41.1434C41.2333 40.6786 42.5413 40.0713 43.1604 39.7528C43.3532 39.6539 43.3806 39.3897 43.2132 39.2517L43.2098 39.2492Z',
|
|
62
|
+
source:
|
|
63
|
+
'github.com/aaif-goose/goose at 0c5b5e2f2e7933fca4de5377d239645dcbe4cbb3, documentation/static/img/goose.svg (Apache 2.0; LF Projects trademark policy)',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'gemini',
|
|
67
|
+
name: 'Google Gemini',
|
|
68
|
+
owner: 'Google LLC',
|
|
69
|
+
agents: ['gemini'],
|
|
70
|
+
viewBox: '0 0 24 24',
|
|
71
|
+
path: 'M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81',
|
|
72
|
+
source: `${SIMPLE_ICONS}, icons/googlegemini.svg`,
|
|
73
|
+
},
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
// The mark by its id, or null.
|
|
77
|
+
export const agentLogo = (id) => AGENT_LOGOS.find((logo) => logo.id === id) || null
|
|
78
|
+
|
|
79
|
+
// The id of the mark a known agent shows by default, or null (an agent
|
|
80
|
+
// Shapewall does not know, one without a redistributable mark, an endpoint).
|
|
81
|
+
export const logoForAgent = (agentId) => AGENT_LOGOS.find((logo) => logo.agents.includes(agentId))?.id || null
|
package/src/agent/composer.js
CHANGED
|
@@ -13,6 +13,7 @@ import { MENTION_HANDLE_RE, commentMentions, handleFor } from '../mentions.js'
|
|
|
13
13
|
import { quoteData } from './context.js'
|
|
14
14
|
import { AgentError } from './errors.js'
|
|
15
15
|
import { commentForModel } from './tools.js'
|
|
16
|
+
import { commentText } from '../comment-fields.js'
|
|
16
17
|
|
|
17
18
|
export const MENTIONS_MAX = 8
|
|
18
19
|
export const FILES_MAX = 3
|
|
@@ -68,7 +69,7 @@ export function validateMentions(config, board, raw) {
|
|
|
68
69
|
const id = Number(item.id)
|
|
69
70
|
const found = Number.isSafeInteger(id) && id > 0 ? comment(id) : null
|
|
70
71
|
if (found && (kind === 'comment' || found.anchor)) {
|
|
71
|
-
const text = kind === 'element' ? found.anchor?.text || found.anchor?.selector || 'element' : found
|
|
72
|
+
const text = kind === 'element' ? found.anchor?.text || found.anchor?.selector || 'element' : commentText(found)
|
|
72
73
|
entry = { kind, id: found.id, label: cut(`#${found.id} ${text}`, LABEL_MAX) }
|
|
73
74
|
}
|
|
74
75
|
} else if (kind === 'journey') {
|
|
@@ -135,7 +136,7 @@ export function mentionContext(config, board, mention, find = commentById(config
|
|
|
135
136
|
element: { selector: comment.anchor?.selector || null, text: comment.anchor?.text || null },
|
|
136
137
|
page: page ? { id: page.id, title: page.title, path: page.path } : { id: comment.pageId },
|
|
137
138
|
viewport: comment.viewport,
|
|
138
|
-
comment: { id: comment.id, body: cut(comment
|
|
139
|
+
comment: { id: comment.id, body: cut(commentText(comment), BODY_MAX), status: comment.status },
|
|
139
140
|
},
|
|
140
141
|
)
|
|
141
142
|
}
|
|
@@ -170,9 +171,12 @@ export function mentionContext(config, board, mention, find = commentById(config
|
|
|
170
171
|
{ ...attrs, person: handle },
|
|
171
172
|
{
|
|
172
173
|
person: `@${handle}`,
|
|
173
|
-
openComments: theirs
|
|
174
|
-
.
|
|
175
|
-
|
|
174
|
+
openComments: theirs.slice(0, PERSON_COMMENTS_MAX).map((comment) => ({
|
|
175
|
+
id: comment.id,
|
|
176
|
+
page: comment.pageId,
|
|
177
|
+
author: comment.author || null,
|
|
178
|
+
body: cut(commentText(comment), 300),
|
|
179
|
+
})),
|
|
176
180
|
more: Math.max(0, theirs.length - PERSON_COMMENTS_MAX) || undefined,
|
|
177
181
|
},
|
|
178
182
|
)
|
package/src/agent/config.js
CHANGED
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
// thread or an API response.
|
|
11
11
|
|
|
12
12
|
import { ACP_COMMAND_VAR, ACP_FLAG, SETTINGS_SOURCE, acpCommand, extraVarNames } from './acp/command.js'
|
|
13
|
-
import { implicitDefault, userAgentEntry } from './user-settings.js'
|
|
13
|
+
import { implicitDefault, profileForDefault, userAgentEntry } from './user-settings.js'
|
|
14
|
+
import { identityOf } from './identity.js'
|
|
15
|
+
import { logoForAgent } from './agent-logos.js'
|
|
16
|
+
import { KNOWN_AGENTS } from './acp/detect.js'
|
|
14
17
|
import { validateBranchConfig } from './branch-mode.js'
|
|
15
18
|
import { validateBatchConfig } from './batch-fixes.js'
|
|
16
19
|
|
|
@@ -186,6 +189,7 @@ export function agentSettings(config, env = process.env, { acp = null, profileId
|
|
|
186
189
|
{
|
|
187
190
|
...acpSettings(command, env),
|
|
188
191
|
label: profile.label,
|
|
192
|
+
...identityOf(profile),
|
|
189
193
|
profileId,
|
|
190
194
|
settingsFile: saved.file,
|
|
191
195
|
sources: { backend: 'settings', acpCommand: 'settings' },
|
|
@@ -213,7 +217,14 @@ export function agentSettings(config, env = process.env, { acp = null, profileId
|
|
|
213
217
|
backend: backendSource,
|
|
214
218
|
acpCommand: command ? (command.source === SETTINGS_SOURCE ? 'settings' : backendSource) : null,
|
|
215
219
|
}
|
|
216
|
-
|
|
220
|
+
// What the owner called it (identity.js): the connected agent that runs
|
|
221
|
+
// this command, or, for a command a flag or the environment fixes, the
|
|
222
|
+
// name and icon saved for that (`fixedAgent`). Display only.
|
|
223
|
+
// A saved command that is no connected agent's takes the form's name field.
|
|
224
|
+
const typed = user.label ? { label: user.label } : null
|
|
225
|
+
const named = !command ? null : command.source === SETTINGS_SOURCE ? profileForDefault(user) || typed : user.fixedAgent || null
|
|
226
|
+
const identity = named ? { ...(named.label ? { label: named.label } : {}), ...identityOf(named) } : identityOf(null)
|
|
227
|
+
return withProblem({ ...acpSettings(command, env), ...identity, vision: base.vision !== false, ...extra, sources }, saved.problem)
|
|
217
228
|
}
|
|
218
229
|
const baseUrl = String(env.SHAPEWALL_AGENT_BASE_URL || base.baseUrl || '')
|
|
219
230
|
.trim()
|
|
@@ -240,6 +251,8 @@ export function agentSettings(config, env = process.env, { acp = null, profileId
|
|
|
240
251
|
baseUrl: baseUrl || null,
|
|
241
252
|
model: model || null,
|
|
242
253
|
label: base.label || model || null,
|
|
254
|
+
// The endpoint's icon and tint (identity.js), saved beside its label.
|
|
255
|
+
...identityOf(user),
|
|
243
256
|
keyVar,
|
|
244
257
|
hasKey,
|
|
245
258
|
// A key variable named on purpose (settings or config), not the default:
|
|
@@ -287,6 +300,11 @@ function acpSettings(command, env) {
|
|
|
287
300
|
baseUrl: null,
|
|
288
301
|
model: null,
|
|
289
302
|
label: command?.label || 'ACP agent',
|
|
303
|
+
// The name the command itself gives it, which an emptied name goes back to.
|
|
304
|
+
builtInLabel: command?.label || null,
|
|
305
|
+
// The product mark of a known agent (agent-logos.js), told from the
|
|
306
|
+
// command as its built-in name is: its default icon. null: initials.
|
|
307
|
+
logo: logoForAgent(KNOWN_AGENTS.find((agent) => agent.label === command?.label)?.id),
|
|
290
308
|
keyVar: null,
|
|
291
309
|
hasKey: false,
|
|
292
310
|
host: null,
|
|
@@ -332,6 +350,13 @@ export function publicAgentInfo(settings) {
|
|
|
332
350
|
configured: settings.configured,
|
|
333
351
|
backend: settings.backend,
|
|
334
352
|
label: settings.configured ? settings.label : null,
|
|
353
|
+
// How its owner made it look (identity.js): a built-in icon's id or
|
|
354
|
+
// "upload:<hash>" (served by GET /api/agent/icons/<hash>), and a tint.
|
|
355
|
+
icon: settings.configured ? settings.icon || null : null,
|
|
356
|
+
tint: settings.configured ? settings.tint || null : null,
|
|
357
|
+
// The default icon while `icon` is null: a known agent's product mark
|
|
358
|
+
// (agent-logos.js), or null for initials.
|
|
359
|
+
logo: settings.configured ? settings.logo || null : null,
|
|
335
360
|
model: settings.configured ? settings.model : null,
|
|
336
361
|
host: settings.host,
|
|
337
362
|
// An ACP agent: a process on the server's machine, not an endpoint.
|
package/src/agent/context.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
// system prompt. The payload is JSON with <, > and & escaped, so no text can
|
|
7
7
|
// close the element early or forge another one.
|
|
8
8
|
|
|
9
|
+
import { commentText } from '../comment-fields.js'
|
|
10
|
+
|
|
9
11
|
// How to point at the board: the panel turns these into links to the board
|
|
10
12
|
// (client/src/chat/refs.js), and only for ids the board has.
|
|
11
13
|
export const REFS_RULE =
|
|
@@ -143,7 +145,7 @@ export function openCommentsContext({ board, comments, skip = null, max = COMMEN
|
|
|
143
145
|
for (const comment of open) {
|
|
144
146
|
if (blocks.length >= max) break
|
|
145
147
|
const page = pages.get(comment.pageId)
|
|
146
|
-
const body =
|
|
148
|
+
const body = commentText(comment)
|
|
147
149
|
const block = quoteData(
|
|
148
150
|
'comment',
|
|
149
151
|
{
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Uploaded agent icons, stored next to the agent settings file
|
|
2
|
+
// (user-settings.js): <settings folder>/agent-icons/<32 hex>.png, private
|
|
3
|
+
// like the settings (folder 0700, files 0600), named by the hash of their
|
|
4
|
+
// bytes. A settings entry refers to one as "upload:<hash>" (identity.js).
|
|
5
|
+
//
|
|
6
|
+
// The image goes through the profile photo pipeline (src/accounts/avatar.js
|
|
7
|
+
// cleanAvatar): the board crops the chosen PNG, JPEG or WebP to a square and
|
|
8
|
+
// sends a 256 by 256 PNG; the server checks its signature, size, chunks and
|
|
9
|
+
// CRCs, decodes it and writes the pixels out again, so nothing but pixels is
|
|
10
|
+
// stored (no metadata, no trailing data, never an SVG) and what is served is
|
|
11
|
+
// always a PNG this server encoded.
|
|
12
|
+
|
|
13
|
+
import crypto from 'node:crypto'
|
|
14
|
+
import fs from 'node:fs'
|
|
15
|
+
import path from 'node:path'
|
|
16
|
+
import { cleanAvatar } from '../accounts/avatar.js'
|
|
17
|
+
import { uploadHashes } from './identity.js'
|
|
18
|
+
import { readUserSettings, userSettingsFile } from './user-settings.js'
|
|
19
|
+
|
|
20
|
+
const HASH_RE = /^[0-9a-f]{32}$/
|
|
21
|
+
|
|
22
|
+
export class IconError extends Error {
|
|
23
|
+
constructor(status, code, message) {
|
|
24
|
+
super(message)
|
|
25
|
+
this.status = status
|
|
26
|
+
this.code = code
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// The folder the icons live in, or null when there is no settings file.
|
|
31
|
+
export function iconDir(env = process.env) {
|
|
32
|
+
const file = userSettingsFile(env)
|
|
33
|
+
return file ? path.join(path.dirname(file), 'agent-icons') : null
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const iconFile = (dir, hash) => path.join(dir, `${hash}.png`)
|
|
37
|
+
|
|
38
|
+
// Checks and re-encodes an upload ({ png: base64 }), stores it and returns
|
|
39
|
+
// its hash. The same picture twice is one file.
|
|
40
|
+
export function saveIcon(png, env = process.env) {
|
|
41
|
+
const dir = iconDir(env)
|
|
42
|
+
if (!dir) throw new IconError(500, 'no_settings_file', 'There is no home folder to save agent settings in (set XDG_CONFIG_HOME or HOME).')
|
|
43
|
+
let clean
|
|
44
|
+
try {
|
|
45
|
+
clean = cleanAvatar(png)
|
|
46
|
+
} catch (error) {
|
|
47
|
+
// cleanAvatar speaks of profile images: say what this upload needs.
|
|
48
|
+
if (error.code === 'avatar_too_large') throw new IconError(413, 'icon_too_large', 'The icon is too large. Choose a smaller image.')
|
|
49
|
+
throw new IconError(400, 'invalid_icon', 'The icon must be a PNG, JPEG or WebP image, cropped to a square by the board.')
|
|
50
|
+
}
|
|
51
|
+
const hash = crypto.createHash('sha256').update(clean).digest('hex').slice(0, 32)
|
|
52
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 })
|
|
53
|
+
const file = iconFile(dir, hash)
|
|
54
|
+
if (!fs.existsSync(file)) {
|
|
55
|
+
const temp = `${file}.${process.pid}.${crypto.randomBytes(4).toString('hex')}.tmp`
|
|
56
|
+
try {
|
|
57
|
+
fs.writeFileSync(temp, clean, { mode: 0o600, flag: 'wx' })
|
|
58
|
+
fs.renameSync(temp, file)
|
|
59
|
+
} catch (error) {
|
|
60
|
+
fs.rmSync(temp, { force: true })
|
|
61
|
+
throw error
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return hash
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// The stored PNG, or null. Only a hash is ever joined to the folder.
|
|
68
|
+
export function readIcon(hash, env = process.env) {
|
|
69
|
+
const dir = iconDir(env)
|
|
70
|
+
if (!dir || !HASH_RE.test(String(hash))) return null
|
|
71
|
+
try {
|
|
72
|
+
const file = iconFile(dir, hash)
|
|
73
|
+
// A link planted in the folder is not followed.
|
|
74
|
+
if (!fs.lstatSync(file).isFile()) return null
|
|
75
|
+
return fs.readFileSync(file)
|
|
76
|
+
} catch {
|
|
77
|
+
return null
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Removes the icons no project's settings refer to any more (after an icon
|
|
82
|
+
// was replaced or removed). Best effort: a file left behind is only a few
|
|
83
|
+
// kilobytes in a private folder.
|
|
84
|
+
export function pruneIcons(env = process.env) {
|
|
85
|
+
const dir = iconDir(env)
|
|
86
|
+
const { data } = readUserSettings(env)
|
|
87
|
+
if (!dir || !data) return
|
|
88
|
+
const used = new Set()
|
|
89
|
+
for (const entry of Object.values(data.projects)) for (const hash of uploadHashes(entry)) used.add(hash)
|
|
90
|
+
let names = []
|
|
91
|
+
try {
|
|
92
|
+
names = fs.readdirSync(dir)
|
|
93
|
+
} catch {
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
for (const name of names) {
|
|
97
|
+
const hash = /^([0-9a-f]{32})\.png$/.exec(name)?.[1]
|
|
98
|
+
if (hash && !used.has(hash)) fs.rmSync(path.join(dir, name), { force: true })
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// An agent's identity on the board: the name its owner gives it, an icon and
|
|
2
|
+
// an accent tint. Display only: none of it changes which command runs or
|
|
3
|
+
// where a key goes, so it is saved without a confirmation, a restart or a
|
|
4
|
+
// connection test (settings-routes.js POST /identity).
|
|
5
|
+
//
|
|
6
|
+
// The name is untrusted text shown to every board viewer and written as the
|
|
7
|
+
// author of the agent's replies: plain text, one line, 1 to 40 characters,
|
|
8
|
+
// no control or text-direction characters. It is never read as Markdown or
|
|
9
|
+
// HTML, and reaches an agent prompt only inside quoted data.
|
|
10
|
+
//
|
|
11
|
+
// The icon is one of the built-in avatars (client/src/chat/agentIcons.jsx
|
|
12
|
+
// draws them; test/agent-identity.test.js checks the two lists match) or
|
|
13
|
+
// "upload:<hash>": an image the owner uploaded, stored by its content hash
|
|
14
|
+
// (icon-store.js). No Node imports here: the board and the demo share it.
|
|
15
|
+
|
|
16
|
+
export const AGENT_NAME_MAX = 40
|
|
17
|
+
export const AGENT_ICONS = ['boxy', 'dot', 'cyclops', 'ghost', 'cat', 'owl', 'bear', 'alien', 'cloud', 'planet', 'hex', 'drop']
|
|
18
|
+
// The accent tints, by name. The colours are the comment avatars' (white on
|
|
19
|
+
// each keeps AA contrast in light and dark, client/src/components/ui/avatar.jsx).
|
|
20
|
+
export const AGENT_TINTS = ['blue', 'violet', 'pink', 'amber', 'green', 'cyan', 'indigo', 'magenta']
|
|
21
|
+
export const UPLOAD_ICON_RE = /^upload:([0-9a-f]{32})$/
|
|
22
|
+
export const IDENTITY_KEYS = ['label', 'icon', 'tint']
|
|
23
|
+
|
|
24
|
+
// C0 and C1 controls, line and paragraph separators, and the characters that
|
|
25
|
+
// reorder or hide text (bidi marks, overrides and isolates, zero-width
|
|
26
|
+
// marks), as code point ranges.
|
|
27
|
+
const FORBIDDEN = [
|
|
28
|
+
[0x00, 0x1f],
|
|
29
|
+
[0x7f, 0x9f],
|
|
30
|
+
[0x200b, 0x200f],
|
|
31
|
+
[0x2028, 0x202e],
|
|
32
|
+
[0x2060, 0x2069],
|
|
33
|
+
[0xfeff, 0xfeff],
|
|
34
|
+
]
|
|
35
|
+
const forbidden = (text) =>
|
|
36
|
+
[...text].some((char) => FORBIDDEN.some(([from, to]) => char.codePointAt(0) >= from && char.codePointAt(0) <= to))
|
|
37
|
+
|
|
38
|
+
// { name, problem }: the trimmed name, or why it is refused. `name` is null
|
|
39
|
+
// for an empty value (the caller falls back to the agent's built-in name).
|
|
40
|
+
export function cleanAgentName(value) {
|
|
41
|
+
if (value === undefined || value === null) return { name: null, problem: null }
|
|
42
|
+
if (typeof value !== 'string') return { name: null, problem: 'name: text, 1 to 40 characters' }
|
|
43
|
+
if (forbidden(value)) return { name: null, problem: 'name: one line of plain text, without control characters' }
|
|
44
|
+
const name = value.trim()
|
|
45
|
+
if (!name) return { name: null, problem: null }
|
|
46
|
+
// Counted in characters as a person sees them typed, not UTF-16 units.
|
|
47
|
+
if ([...name].length > AGENT_NAME_MAX) return { name: null, problem: `name: at most ${AGENT_NAME_MAX} characters` }
|
|
48
|
+
return { name, problem: null }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const isBuiltInIcon = (value) => AGENT_ICONS.includes(value)
|
|
52
|
+
export const isUploadIcon = (value) => typeof value === 'string' && UPLOAD_ICON_RE.test(value)
|
|
53
|
+
export const isAgentIcon = (value) => isBuiltInIcon(value) || isUploadIcon(value)
|
|
54
|
+
export const isAgentTint = (value) => AGENT_TINTS.includes(value)
|
|
55
|
+
|
|
56
|
+
// The hash of an uploaded icon, or null for a built-in one or none.
|
|
57
|
+
export const uploadHash = (icon) => (typeof icon === 'string' ? UPLOAD_ICON_RE.exec(icon)?.[1] || null : null)
|
|
58
|
+
|
|
59
|
+
// The identity fields of a saved profile or entry, only the valid ones.
|
|
60
|
+
// A file edited by hand with an unknown icon or tint shows the default look.
|
|
61
|
+
export function identityOf(source) {
|
|
62
|
+
return {
|
|
63
|
+
icon: isAgentIcon(source?.icon) ? source.icon : null,
|
|
64
|
+
tint: isAgentTint(source?.tint) ? source.tint : null,
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Every uploaded icon a settings entry refers to (its endpoint, the agent a
|
|
69
|
+
// flag fixes, each profile).
|
|
70
|
+
export function uploadHashes(entry) {
|
|
71
|
+
const hashes = new Set()
|
|
72
|
+
for (const source of [entry, entry?.fixedAgent, ...(Array.isArray(entry?.profiles) ? entry.profiles : [])]) {
|
|
73
|
+
const hash = uploadHash(source?.icon)
|
|
74
|
+
if (hash) hashes.add(hash)
|
|
75
|
+
}
|
|
76
|
+
return hashes
|
|
77
|
+
}
|
package/src/agent/owner-mcp.js
CHANGED
|
@@ -3,24 +3,40 @@
|
|
|
3
3
|
import { fileURLToPath } from 'node:url'
|
|
4
4
|
import { loadConfig } from '../config.js'
|
|
5
5
|
import { createMcpServer } from '../mcp.js'
|
|
6
|
+
import { SETTINGS_FILE_VAR, savedAgentName } from './user-settings.js'
|
|
6
7
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
// `agent`: { which, name } (routes.js): which saved agent this session runs
|
|
10
|
+
// ("fixed", "default" or a profile id) and what it was called when the
|
|
11
|
+
// session started. Its replies are signed with the name it has when it
|
|
12
|
+
// replies (user-settings.js savedAgentName), so a rename shows on the next
|
|
13
|
+
// reply without restarting the agent; the starting name is the fallback.
|
|
14
|
+
export function ownerMcpServers(config, boardId, { allowCapture = true, agent = null, env = process.env } = {}) {
|
|
9
15
|
if (!config.file) return []
|
|
16
|
+
const settingsFile = env[SETTINGS_FILE_VAR]
|
|
10
17
|
return [
|
|
11
18
|
{
|
|
12
19
|
name: 'shapewall',
|
|
13
20
|
command: process.execPath,
|
|
14
|
-
args: [
|
|
15
|
-
|
|
21
|
+
args: [
|
|
22
|
+
fileURLToPath(import.meta.url),
|
|
23
|
+
config.file,
|
|
24
|
+
boardId,
|
|
25
|
+
allowCapture ? 'capture' : 'no-capture',
|
|
26
|
+
...(agent?.name ? [agent.which || 'default', agent.name] : []),
|
|
27
|
+
],
|
|
28
|
+
// The agent's small environment may not name the settings file.
|
|
29
|
+
env: settingsFile ? [{ name: SETTINGS_FILE_VAR, value: settingsFile }] : [],
|
|
16
30
|
},
|
|
17
31
|
]
|
|
18
32
|
}
|
|
19
33
|
|
|
20
34
|
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
21
35
|
const config = loadConfig(process.argv[2])
|
|
36
|
+
const [which, startName] = process.argv.slice(5)
|
|
22
37
|
const server = createMcpServer({
|
|
23
38
|
config,
|
|
39
|
+
agentAuthor: startName ? () => savedAgentName(config.dir, which) || startName : null,
|
|
24
40
|
boardId: process.argv[3],
|
|
25
41
|
allowCapture: process.argv[4] === 'capture',
|
|
26
42
|
toolNames: [
|