shapewall 0.6.0 → 0.7.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/CHANGELOG.md +252 -0
- package/README.md +39 -2
- package/THIRD_PARTY.md +15 -0
- package/dist/agent/package-lock.json +594 -2
- package/dist/client/assets/{BoardChat-DdwBcb2N.js → BoardChat-WS8mAIW6.js} +1 -1
- package/dist/client/assets/{BuzzDialog-DpUcnU6S.js → BuzzDialog-B-Mlr6wF.js} +1 -1
- package/dist/client/assets/{ChecksPanel-CngYV4yz.js → ChecksPanel-Dx1ZLBR6.js} +1 -1
- package/dist/client/assets/{History-CD0saQA5.js → History-sXhmpcvs.js} +1 -1
- package/dist/client/assets/{LocalSettings-MZy2baig.js → LocalSettings-CtGzz9F3.js} +1 -1
- package/dist/client/assets/{Management-CSvZ-SHO.js → Management-CGHe8Wt9.js} +1 -1
- package/dist/client/assets/{QuickConnect-foLh2QUm.js → QuickConnect-DEk84E4A.js} +1 -1
- package/dist/client/assets/{ShareDialog-DPWDftoL.js → ShareDialog-CGGx-AYK.js} +1 -1
- package/dist/client/assets/{app-update-dialog-CtiXpTRD.js → app-update-dialog-_bVp8hnC.js} +1 -1
- package/dist/client/assets/{circle-x-CteRBtXC.js → circle-x-BWoHA1QY.js} +1 -1
- package/dist/client/assets/index-Bm-Xd3YN.js +37 -0
- package/dist/client/assets/index-C7Ostk3K.css +2 -0
- package/dist/client/assets/{play-BjRNIGSf.js → play-BzQ3tRTv.js} +1 -1
- package/dist/client/assets/{refresh-cw-r_tZiFfB.js → refresh-cw-BYBMyDKT.js} +1 -1
- package/dist/client/assets/{ui-zQpn-PdL.js → ui-CAY6myRA.js} +1 -1
- package/dist/client/build-info.json +1 -1
- package/dist/client/index.html +3 -3
- package/dist/client/sw.js +2 -2
- package/dist/console/assets/LocalAccountsApp-CWRguRRL.js +1 -0
- package/dist/console/assets/LocalConsole--I2SaIpr.js +2 -0
- package/dist/console/assets/LocalUsage-BmpCZ36k.js +1 -0
- package/dist/console/assets/app-update-dialog-B8M9plaT.js +1 -0
- package/dist/console/assets/app-version-muKrQqbL.js +1 -0
- package/dist/console/assets/console-CrhTsPbz.css +2 -0
- package/dist/console/assets/console-DxapQ9oS.js +11 -0
- package/dist/console/assets/local-agents-CoqD4dSN.js +6 -0
- package/dist/console/assets/minus-DDQ0ydcM.js +1 -0
- package/dist/console/assets/tailnet-C5Flwl_d.js +2 -0
- package/dist/console/assets/theme-DCd0qh4l.js +1 -0
- package/dist/console/assets/ui-Bry1mnCY.js +41 -0
- package/dist/console/assets/usage-CIPWnHaS.css +1 -0
- package/dist/console/assets/usage-CqVjMb7m.js +5 -0
- package/dist/console/assets/usage-D1G0GgE3.js +56 -0
- package/dist/console/build-info.json +1 -1
- package/dist/console/console.html +8 -2
- package/docs/agent-hardening.md +31 -17
- package/docs/agents.md +35 -0
- package/docs/architecture.md +10 -4
- package/docs/deployment.md +39 -17
- package/docs/design-system.md +56 -7
- package/docs/hosted.md +1004 -43
- package/docs/images/board-overview.png +0 -0
- package/docs/images/journeys.png +0 -0
- package/docs/images/live-comment.png +0 -0
- package/docs/images/phone-comment.png +0 -0
- package/docs/images/phone-overview.png +0 -0
- package/docs/images/variant.png +0 -0
- package/docs/where-to-run.md +82 -1
- package/package.json +6 -1
- package/src/agent/backends/acp.js +224 -26
- package/src/agent/routes.js +21 -0
- package/src/agent/usage-log.js +251 -0
- package/src/cli/args.js +24 -0
- package/src/cli/help.js +37 -2
- package/src/cli/init.js +2 -1
- package/src/cli/serve.js +20 -5
- package/src/cli.js +8 -0
- package/src/hosted/access-cli.js +99 -1
- package/src/hosted/activity-core.js +232 -0
- package/src/hosted/activity.js +375 -0
- package/src/hosted/admin.js +80 -13
- package/src/hosted/agent-approvals.js +2 -2
- package/src/hosted/agent-routes.js +3 -3
- package/src/hosted/agents.js +11 -4
- package/src/hosted/app.js +89 -7
- package/src/hosted/auth-routes.js +156 -15
- package/src/hosted/auth.js +123 -20
- package/src/hosted/board-routes.js +3 -3
- package/src/hosted/chat-frames.js +5 -15
- package/src/hosted/chat-permissions.js +12 -0
- package/src/hosted/chat-routes.js +8 -8
- package/src/hosted/chat-store.js +20 -3
- package/src/hosted/comment-files.js +5 -2
- package/src/hosted/console-routes.js +111 -34
- package/src/hosted/db.js +130 -0
- package/src/hosted/device-routes.js +25 -3
- package/src/hosted/device.js +23 -4
- package/src/hosted/guards.js +337 -27
- package/src/hosted/http.js +6 -3
- package/src/hosted/membership.js +13 -2
- package/src/hosted/operator-access.js +418 -0
- package/src/hosted/operator.js +106 -2
- package/src/hosted/ops-cli.js +238 -3
- package/src/hosted/pages.js +2 -0
- package/src/hosted/passkey-policy.js +75 -0
- package/src/hosted/permissions.js +14 -6
- package/src/hosted/presence.js +14 -2
- package/src/hosted/projects.js +2 -1
- package/src/hosted/public.js +4 -4
- package/src/hosted/ratelimit.js +6 -0
- package/src/hosted/retention.js +18 -2
- package/src/hosted/server.js +123 -11
- package/src/hosted/shares.js +2 -2
- package/src/hosted/step-up-settings.js +68 -0
- package/src/hosted/step-up.js +135 -0
- package/src/hosted/tailnet-identity.js +24 -0
- package/src/hosted/tailnet-routes.js +342 -0
- package/src/hosted/tailnet.js +220 -0
- package/src/hosted/tailscale.js +75 -9
- package/src/hosted/tenancy.js +48 -1
- package/src/hosted/token-api.js +2 -2
- package/src/hosted/tokens.js +9 -2
- package/src/hosted/usage-core.js +624 -0
- package/src/hosted/usage-layout.js +724 -0
- package/src/hosted/usage-routes.js +375 -0
- package/src/hosted/usage-shape.js +256 -0
- package/src/hosted/usage.js +641 -0
- package/src/remote/agent-connect.js +37 -1
- package/src/remote/agent-link.js +2 -0
- package/src/remote/login.js +33 -8
- package/src/remote/share.js +1 -1
- package/src/remote/tailnet-cli.js +547 -0
- package/src/server/app.js +15 -0
- package/src/server/pairing-routes.js +34 -5
- package/src/server/tailscale.js +97 -4
- package/src/tailnet-proof.js +766 -0
- package/dist/client/assets/index-Cxz1UVcV.css +0 -2
- package/dist/client/assets/index-uUZVBYUS.js +0 -37
- package/dist/console/assets/LocalAccountsApp-DIdy1KnN.js +0 -1
- package/dist/console/assets/LocalConsole-DfcQztF-.js +0 -1
- package/dist/console/assets/app-update-dialog-ttl9lF5A.js +0 -1
- package/dist/console/assets/console-OqAjD0kV.js +0 -55
- package/dist/console/assets/console-kvjrAArQ.css +0 -2
|
@@ -18,6 +18,7 @@ import os from 'node:os'
|
|
|
18
18
|
import path from 'node:path'
|
|
19
19
|
import { KNOWN_AGENTS, detectAgents } from '../agent/acp/detect.js'
|
|
20
20
|
import { acpAgentKind } from '../agent/acp/command.js'
|
|
21
|
+
import { ACP_DEFAULTS, acpHandshake, adapterName, adapterWarning } from '../agent/backends/acp.js'
|
|
21
22
|
import { createBackend } from '../agent/backends/index.js'
|
|
22
23
|
import { agentSettings } from '../agent/config.js'
|
|
23
24
|
import { REMOTE_FIX_PREAMBLE, REMOTE_PREAMBLE } from '../agent/context.js'
|
|
@@ -237,6 +238,16 @@ export function policyChanges(flags, saved, kind = null) {
|
|
|
237
238
|
return changes
|
|
238
239
|
}
|
|
239
240
|
|
|
241
|
+
// What this machine's rules come to, for the approval page: who may allow
|
|
242
|
+
// edits from the board (or "none"), whether edits may be allowed without
|
|
243
|
+
// asking, and the branch a fix starts from. Commands are left out: none is
|
|
244
|
+
// in effect for an agent they were not proven with.
|
|
245
|
+
export function askedOf(policy, kind = null) {
|
|
246
|
+
const approvals = POLICY_APPROVALS.includes(policy?.approvals) ? policy.approvals : 'none'
|
|
247
|
+
const auto = (Array.isArray(policy?.auto) ? policy.auto : []).filter((item) => item !== 'commands' || COMMANDS_PROVEN.includes(kind))
|
|
248
|
+
return { approvals, auto: approvals !== 'none' && auto.includes('edits'), base: approvals !== 'none' ? policy?.base || null : null }
|
|
249
|
+
}
|
|
250
|
+
|
|
240
251
|
export async function agentConnect(
|
|
241
252
|
flags,
|
|
242
253
|
print,
|
|
@@ -286,7 +297,10 @@ export async function agentConnect(
|
|
|
286
297
|
signal,
|
|
287
298
|
...(sleep ? { sleep } : {}),
|
|
288
299
|
purpose: 'agent',
|
|
289
|
-
|
|
300
|
+
// What this machine will take from the board, as it will be once this run's flags are saved:
|
|
301
|
+
// the approval page shows it, as this terminal's report.
|
|
302
|
+
agent: { kind, name: suggested, asks: askedOf({ ...policyNow, ...changes }, kind) },
|
|
303
|
+
command: 'shapewall agent connect',
|
|
290
304
|
onApproved: (result) => {
|
|
291
305
|
const file = saveAgentCredential(
|
|
292
306
|
origin,
|
|
@@ -337,6 +351,28 @@ export async function agentConnect(
|
|
|
337
351
|
throw new Error(`${label} is not started read-only on this machine. ${profile.refuse.join(' ')} See docs/agent-hardening.md.`)
|
|
338
352
|
for (const line of profile.notes) log(line)
|
|
339
353
|
|
|
354
|
+
// ---- Can a session be opened at all? ----
|
|
355
|
+
// Asked of the agent now, the way a question from the board would start it
|
|
356
|
+
// (no prompt is sent, so nothing is spent): an adapter that cannot open the
|
|
357
|
+
// session, or that this release was not tested with, is said here and not
|
|
358
|
+
// at somebody's first question.
|
|
359
|
+
const opens = async (what, how) => {
|
|
360
|
+
const result = await acpHandshake({ ...settings, ...how }, { env, root: config.dir, timeoutMs: ACP_DEFAULTS.startMs })
|
|
361
|
+
if (result.ok) return result
|
|
362
|
+
const said = adapterName(result.agentInfo)
|
|
363
|
+
if (result.stderr) log(`${label} last output: ${terminalSafe(result.stderr)}`)
|
|
364
|
+
throw new Error(
|
|
365
|
+
`${label} could not open ${what} on this machine, so it is not connected${said && !result.message.includes(said) ? ` (adapter: ${terminalSafe(said)})` : ''}. ${terminalSafe(result.message)}`,
|
|
366
|
+
)
|
|
367
|
+
}
|
|
368
|
+
const opened = await opens('a read-only session', { readOnly: true })
|
|
369
|
+
if (edits)
|
|
370
|
+
await opens('a session for edits', { readOnly: false, remoteEdit: { commands: policy.commands, allowPaths: policy.allowPaths } })
|
|
371
|
+
const adapter = terminalSafe(adapterName(opened.agentInfo) || 'an adapter that does not say its version')
|
|
372
|
+
const untested = adapterWarning(kind, opened.agentInfo, label)
|
|
373
|
+
if (untested) log(`Warning: ${terminalSafe(untested)}`)
|
|
374
|
+
else log(`${label} answers through ${adapter}, a version this release was tested with.`)
|
|
375
|
+
|
|
340
376
|
const backend = createBackend(
|
|
341
377
|
// Read and answer only (src/agent/backends/acp.js readOnly), with the
|
|
342
378
|
// connected agent's own first words. Images are not sent to it yet.
|
package/src/remote/agent-link.js
CHANGED
|
@@ -510,6 +510,8 @@ export async function runAgentLink({
|
|
|
510
510
|
agentName: job.agent.name,
|
|
511
511
|
...fixTurn,
|
|
512
512
|
})
|
|
513
|
+
// What the chat is told went wrong is in this machine's log too.
|
|
514
|
+
if (reply.status === 'error' && reply.error?.message) log(`turn ${id}: failed: ${reply.error.message}`)
|
|
513
515
|
// Stopped from here (Ctrl+C, a lost link) reads differently from Stop on the board.
|
|
514
516
|
if (reply.status === 'stopped' && ['shutdown', 'link_lost'].includes(controller.signal.reason)) {
|
|
515
517
|
reply.status = 'error'
|
package/src/remote/login.js
CHANGED
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
// over once; it goes into the credentials file (0600, see credentials.js)
|
|
7
7
|
// and is never printed. `push`, `comments`, `watch` and `mcp --remote` use
|
|
8
8
|
// it from then on.
|
|
9
|
+
//
|
|
10
|
+
// On a server with tailnet sign-in, run on a tailnet machine: the server
|
|
11
|
+
// already knows the machine's user, and that account approves the login
|
|
12
|
+
// itself, with no code and no browser (src/remote/tailnet-cli.js). The
|
|
13
|
+
// project comes from --project (and --workspace); the code below is the
|
|
14
|
+
// fallback whenever that does not apply.
|
|
9
15
|
|
|
10
16
|
import os from 'node:os'
|
|
11
17
|
import { spawn } from 'node:child_process'
|
|
@@ -90,6 +96,10 @@ export async function login(
|
|
|
90
96
|
// in place of saving it as this server's login.
|
|
91
97
|
agent = null,
|
|
92
98
|
onApproved = null,
|
|
99
|
+
// false: never ask the server who this machine's tailnet user is (tests of the code flow).
|
|
100
|
+
tailnet = true,
|
|
101
|
+
// The command that was run, for "run it again" (`shapewall agent connect`, `shapewall import`).
|
|
102
|
+
command = 'shapewall login',
|
|
93
103
|
} = {},
|
|
94
104
|
) {
|
|
95
105
|
out = safeOut(out)
|
|
@@ -111,18 +121,30 @@ export async function login(
|
|
|
111
121
|
// The page is ours to build: the server's verificationUrl is not used.
|
|
112
122
|
const page = deviceLoginUrl(origin)
|
|
113
123
|
if (!page) throw new Error(`Cannot build a login page for ${origin}; open its /device page yourself.`)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
// Tailnet sign-in: approved by this machine's tailnet user, when the server knows one who may.
|
|
125
|
+
const { approveByTailnet } = await import('./tailnet-cli.js')
|
|
126
|
+
const approvedHere = tailnet
|
|
127
|
+
? await approveByTailnet({ origin, userCode, flags, purpose, agent, out, fetchImpl, machine }).catch((error) => {
|
|
128
|
+
// A choice only flags can make (which project): that is the answer, not a fallback.
|
|
129
|
+
throw error
|
|
130
|
+
})
|
|
131
|
+
: false
|
|
132
|
+
if (!approvedHere) {
|
|
133
|
+
out(`${purpose === 'agent' ? 'To connect this agent' : 'To log in'}, open ${page} and enter this code:`)
|
|
134
|
+
out('')
|
|
135
|
+
out(` ${userCode}`)
|
|
136
|
+
out('')
|
|
137
|
+
out(`Check that the console shows the same code and "${machine}". It expires in ${Math.round(Number(expiresIn) / 60) || 10} minutes.`)
|
|
138
|
+
if (open(page, env)) out('(Opened it in your browser.)')
|
|
139
|
+
}
|
|
140
|
+
let first = approvedHere
|
|
120
141
|
const deadline = Date.now() + Math.min(Math.max(Number(expiresIn) || 600, 1), 3600) * 1000
|
|
121
142
|
for (;;) {
|
|
122
143
|
if (signal?.aborted) throw new Error('Login cancelled.')
|
|
123
|
-
if (Date.now() > deadline) throw new Error(
|
|
144
|
+
if (Date.now() > deadline) throw new Error(`The code expired before anyone approved it. Run ${command} again for a new one.`)
|
|
124
145
|
// 1 to 30 seconds whatever the server says (NaN would poll in a tight loop).
|
|
125
|
-
await sleep(Math.min(Math.max(Number(interval) || 3, 1), 30) * 1000)
|
|
146
|
+
if (!first) await sleep(Math.min(Math.max(Number(interval) || 3, 1), 30) * 1000)
|
|
147
|
+
first = false
|
|
126
148
|
let polled
|
|
127
149
|
try {
|
|
128
150
|
polled = await post(fetchImpl, origin, '/api/v1/device/poll', { deviceCode })
|
|
@@ -135,6 +157,9 @@ export async function login(
|
|
|
135
157
|
continue
|
|
136
158
|
}
|
|
137
159
|
if (polled.status !== 200 || polled.data?.status !== 'approved') {
|
|
160
|
+
// The server's words name "shapewall login"; an expired code names the command that was run.
|
|
161
|
+
if (polled.status === 410 && polled.data?.error?.code === 'login_expired')
|
|
162
|
+
throw new Error(`The code expired before anyone approved it. Run ${command} again for a new one.`)
|
|
138
163
|
throw new Error(terminalSafe(polled.data?.error?.message) || `The login did not finish (${polled.status}).`)
|
|
139
164
|
}
|
|
140
165
|
const result = polled.data
|
package/src/remote/share.js
CHANGED
|
@@ -287,7 +287,7 @@ async function runShare(
|
|
|
287
287
|
'This token has no one-time import scope. Unset SHAPEWALL_TOKEN/--token-file, then run shapewall share to approve a moving-project login.',
|
|
288
288
|
)
|
|
289
289
|
out('Sign in to move a local project. Pick or create its destination and check the one-time Import box.')
|
|
290
|
-
await loginImpl(flags, out, { env, fetchImpl, purpose: 'import', signal, ...(open ? { open } : {}) })
|
|
290
|
+
await loginImpl(flags, out, { env, fetchImpl, purpose: 'import', command: 'shapewall share', signal, ...(open ? { open } : {}) })
|
|
291
291
|
settings = remoteSettings(flags, env)
|
|
292
292
|
remote = createRemote({ ...settings, fetchImpl })
|
|
293
293
|
project = await remote.project()
|