shapewall 0.3.3 → 0.6.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 +249 -0
- package/README.md +49 -3
- package/dist/agent/package-lock.json +2 -2
- package/dist/client/assets/BoardChat-DdwBcb2N.js +27 -0
- package/dist/client/assets/{BuzzDialog-Ix9qJvim.js → BuzzDialog-DpUcnU6S.js} +1 -1
- package/dist/client/assets/ChecksPanel-CngYV4yz.js +1 -0
- package/dist/client/assets/History-CD0saQA5.js +1 -0
- package/dist/client/assets/LocalSettings-MZy2baig.js +1 -0
- package/dist/client/assets/{Management-NVFDtSZB.js → Management-CSvZ-SHO.js} +1 -1
- package/dist/client/assets/QuickConnect-foLh2QUm.js +1 -0
- package/dist/client/assets/{ShareDialog-By0ETg6n.js → ShareDialog-DPWDftoL.js} +2 -2
- package/dist/client/assets/{app-update-dialog-RGIw24iZ.js → app-update-dialog-CtiXpTRD.js} +1 -1
- package/dist/client/assets/{circle-x-B6KfScOE.js → circle-x-CteRBtXC.js} +1 -1
- package/dist/client/assets/index-Cxz1UVcV.css +2 -0
- package/dist/client/assets/index-uUZVBYUS.js +37 -0
- package/dist/client/assets/play-BjRNIGSf.js +1 -0
- package/dist/client/assets/{refresh-cw-vkgvCCfR.js → refresh-cw-r_tZiFfB.js} +1 -1
- package/dist/client/assets/{runtime-Bft6x_6E.js → runtime-Bvq10IhH.js} +1 -1
- package/dist/client/assets/ui-zQpn-PdL.js +41 -0
- 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-VOCZg8dg.js → LocalAccountsApp-DIdy1KnN.js} +1 -1
- package/dist/console/assets/{LocalConsole-CMwAW-mF.js → LocalConsole-DfcQztF-.js} +1 -1
- package/dist/console/assets/{app-update-dialog-Cw6UDqNP.js → app-update-dialog-ttl9lF5A.js} +1 -1
- package/dist/console/assets/console-OqAjD0kV.js +55 -0
- package/dist/console/assets/console-kvjrAArQ.css +2 -0
- package/dist/console/build-info.json +1 -1
- package/dist/console/console.html +2 -2
- package/docs/agent-hardening.md +192 -0
- package/docs/agent-recipes.md +23 -0
- package/docs/agent-workflow.md +5 -0
- package/docs/agents.md +14 -6
- package/docs/hosted.md +804 -11
- package/docs/where-to-run.md +37 -2
- package/package.json +1 -1
- package/src/agent/backends/acp.js +528 -25
- package/src/agent/branch-mode.js +17 -3
- package/src/agent/card-hash.js +65 -0
- package/src/agent/context.js +41 -0
- package/src/agent/exec-paths.js +105 -0
- package/src/agent/routes.js +2 -2
- package/src/agent/run.js +11 -1
- package/src/agent/starter/cli.js +6 -1
- package/src/agent/turn-changes.js +70 -8
- package/src/cli/args.js +13 -0
- package/src/cli/commands.js +20 -5
- package/src/cli/help.js +36 -1
- package/src/hosted/admin.js +7 -0
- package/src/hosted/agent-approvals.js +28 -3
- package/src/hosted/agent-link.js +1032 -0
- package/src/hosted/agent-policy.js +10 -3
- package/src/hosted/agent-presence.js +63 -22
- package/src/hosted/agent-routes.js +135 -0
- package/src/hosted/agents.js +1199 -0
- package/src/hosted/app.js +89 -5
- package/src/hosted/board-routes.js +127 -3
- package/src/hosted/chat-frames.js +256 -0
- package/src/hosted/chat-job.js +204 -0
- package/src/hosted/chat-permissions.js +191 -0
- package/src/hosted/chat-routes.js +1009 -0
- package/src/hosted/chat-store.js +460 -0
- package/src/hosted/comment-files.js +8 -1
- package/src/hosted/comments.js +1 -1
- package/src/hosted/console-routes.js +11 -0
- package/src/hosted/db.js +165 -0
- package/src/hosted/device-routes.js +64 -8
- package/src/hosted/device.js +35 -4
- package/src/hosted/events.js +3 -3
- package/src/hosted/membership.js +9 -1
- package/src/hosted/pages.js +2 -0
- package/src/hosted/permissions.js +38 -0
- package/src/hosted/presence.js +17 -0
- package/src/hosted/projects.js +29 -2
- package/src/hosted/ratelimit.js +8 -0
- package/src/hosted/tenancy.js +18 -0
- package/src/hosted/token-api.js +118 -19
- package/src/hosted/token-events.js +5 -3
- package/src/hosted/tokens.js +21 -5
- package/src/hosted/turn-hub.js +152 -0
- package/src/remote/agent-connect.js +433 -0
- package/src/remote/agent-fix.js +611 -0
- package/src/remote/agent-job.js +216 -0
- package/src/remote/agent-link.js +904 -0
- package/src/remote/agent-policy-file.js +242 -0
- package/src/remote/credentials.js +35 -1
- package/src/remote/login.js +12 -2
- package/dist/client/assets/BoardChat-DxehB761.js +0 -27
- package/dist/client/assets/ChecksPanel-pA_ueIaJ.js +0 -1
- package/dist/client/assets/History-C9N32kCv.js +0 -1
- package/dist/client/assets/LocalSettings-DawtKnvi.js +0 -1
- package/dist/client/assets/QuickConnect-DO1TjS1t.js +0 -1
- package/dist/client/assets/index-CsqLdqGx.css +0 -2
- package/dist/client/assets/index-DnZarJ3U.js +0 -37
- package/dist/client/assets/shield-check-QzwGhz0t.js +0 -1
- package/dist/client/assets/ui-DI-FGWWK.js +0 -41
- package/dist/console/assets/console-DgfWmUEx.js +0 -55
- package/dist/console/assets/console-Lis0vvdL.css +0 -2
|
@@ -4,9 +4,22 @@ import { randomBytes } from 'node:crypto'
|
|
|
4
4
|
import { sha256 } from './crypto.js'
|
|
5
5
|
import { dispatchHash, AgentPolicyError, agentPolicy } from './agent-policy.js'
|
|
6
6
|
import { findApiToken } from './tenancy.js'
|
|
7
|
-
import { roleAtLeast } from './permissions.js'
|
|
7
|
+
import { canAnswerApproval, roleAtLeast } from './permissions.js'
|
|
8
8
|
|
|
9
|
-
export function mountHostedApprovals({
|
|
9
|
+
export function mountHostedApprovals({
|
|
10
|
+
v1,
|
|
11
|
+
boardApi,
|
|
12
|
+
handle,
|
|
13
|
+
scope,
|
|
14
|
+
db,
|
|
15
|
+
transaction,
|
|
16
|
+
policyFor,
|
|
17
|
+
agentsFor = null,
|
|
18
|
+
boardContext,
|
|
19
|
+
needFresh,
|
|
20
|
+
auditOf,
|
|
21
|
+
now,
|
|
22
|
+
}) {
|
|
10
23
|
const error = (statusCode, code, message) => new AgentPolicyError(statusCode, code, message)
|
|
11
24
|
const keyOf = (req) => ({ project: req.project.id, board: req.params.bid })
|
|
12
25
|
function validate(req, row) {
|
|
@@ -35,6 +48,13 @@ export function mountHostedApprovals({ v1, boardApi, handle, scope, db, transact
|
|
|
35
48
|
throw error(409, 'approval_expired', 'This approval no longer matches a live run.')
|
|
36
49
|
return row
|
|
37
50
|
}
|
|
51
|
+
// Who may answer an agent's approvals is a setting of that agent (admin by
|
|
52
|
+
// default, or owner): the same rule connected agents' cards will use
|
|
53
|
+
// (src/hosted/permissions.js canAnswerApproval).
|
|
54
|
+
const mayAnswer = (req, row) => {
|
|
55
|
+
const agent = agentsFor?.(req.t).forToken(req.project.id, row.token_id) || null
|
|
56
|
+
return canAnswerApproval(req.role, agent ? { approvalAnswerRole: agent.approval_answer_role } : null)
|
|
57
|
+
}
|
|
38
58
|
const byId = (req) =>
|
|
39
59
|
req.t.get('SELECT * FROM agent_approvals WHERE workspace_id = :ws AND project_id = :project AND board_id = :board AND id = :id', {
|
|
40
60
|
...keyOf(req),
|
|
@@ -49,6 +69,10 @@ export function mountHostedApprovals({ v1, boardApi, handle, scope, db, transact
|
|
|
49
69
|
throw error(400, 'invalid_command', 'Command: 1 to 8000 characters.')
|
|
50
70
|
const ctx = boardContext(req.t, req.project, req.params.bid)
|
|
51
71
|
const comment = ctx.comments.get(req.params.cid)
|
|
72
|
+
// A comment sent to another agent does not exist for this token, here
|
|
73
|
+
// as on every other route.
|
|
74
|
+
if (agentsFor && !agentsFor(req.t).workCheck(req.agent, req.project.id, comment).ok)
|
|
75
|
+
throw error(404, 'unknown_comment', 'No dispatched comment at that id.')
|
|
52
76
|
const at = now().toISOString()
|
|
53
77
|
const id = `sa_${randomBytes(10).toString('hex')}`
|
|
54
78
|
const claim = req.t.get(
|
|
@@ -119,7 +143,7 @@ export function mountHostedApprovals({ v1, boardApi, handle, scope, db, transact
|
|
|
119
143
|
approvals: rows.filter((row) => {
|
|
120
144
|
try {
|
|
121
145
|
validate(req, row)
|
|
122
|
-
return
|
|
146
|
+
return mayAnswer(req, row)
|
|
123
147
|
} catch {
|
|
124
148
|
return false
|
|
125
149
|
}
|
|
@@ -136,6 +160,7 @@ export function mountHostedApprovals({ v1, boardApi, handle, scope, db, transact
|
|
|
136
160
|
if (!['approved', 'denied'].includes(req.body?.state)) throw error(400, 'invalid_approval', 'Choose approved or denied.')
|
|
137
161
|
const row = transaction(db, () => {
|
|
138
162
|
const row = validate(req, byId(req))
|
|
163
|
+
if (!mayAnswer(req, row)) throw error(403, 'forbidden', "Answering this agent's approvals needs the owner role.")
|
|
139
164
|
if (row.state !== 'pending' || req.body?.hash !== row.command_hash)
|
|
140
165
|
throw error(409, 'approval_changed', 'This exact command is no longer pending.')
|
|
141
166
|
req.t.run(
|