shapewall 0.3.3 → 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.
Files changed (157) hide show
  1. package/CHANGELOG.md +501 -0
  2. package/README.md +87 -4
  3. package/THIRD_PARTY.md +15 -0
  4. package/dist/agent/package-lock.json +594 -2
  5. package/dist/client/assets/BoardChat-WS8mAIW6.js +27 -0
  6. package/dist/client/assets/{BuzzDialog-Ix9qJvim.js → BuzzDialog-B-Mlr6wF.js} +1 -1
  7. package/dist/client/assets/ChecksPanel-Dx1ZLBR6.js +1 -0
  8. package/dist/client/assets/History-sXhmpcvs.js +1 -0
  9. package/dist/client/assets/LocalSettings-CtGzz9F3.js +1 -0
  10. package/dist/client/assets/{Management-NVFDtSZB.js → Management-CGHe8Wt9.js} +1 -1
  11. package/dist/client/assets/QuickConnect-DEk84E4A.js +1 -0
  12. package/dist/client/assets/{ShareDialog-By0ETg6n.js → ShareDialog-CGGx-AYK.js} +2 -2
  13. package/dist/client/assets/{app-update-dialog-RGIw24iZ.js → app-update-dialog-_bVp8hnC.js} +1 -1
  14. package/dist/client/assets/{circle-x-B6KfScOE.js → circle-x-BWoHA1QY.js} +1 -1
  15. package/dist/client/assets/index-Bm-Xd3YN.js +37 -0
  16. package/dist/client/assets/index-C7Ostk3K.css +2 -0
  17. package/dist/client/assets/play-BzQ3tRTv.js +1 -0
  18. package/dist/client/assets/{refresh-cw-vkgvCCfR.js → refresh-cw-BYBMyDKT.js} +1 -1
  19. package/dist/client/assets/{runtime-Bft6x_6E.js → runtime-Bvq10IhH.js} +1 -1
  20. package/dist/client/assets/ui-CAY6myRA.js +41 -0
  21. package/dist/client/build-info.json +1 -1
  22. package/dist/client/index.html +3 -3
  23. package/dist/client/sw.js +2 -2
  24. package/dist/console/assets/LocalAccountsApp-CWRguRRL.js +1 -0
  25. package/dist/console/assets/LocalConsole--I2SaIpr.js +2 -0
  26. package/dist/console/assets/LocalUsage-BmpCZ36k.js +1 -0
  27. package/dist/console/assets/app-update-dialog-B8M9plaT.js +1 -0
  28. package/dist/console/assets/app-version-muKrQqbL.js +1 -0
  29. package/dist/console/assets/console-CrhTsPbz.css +2 -0
  30. package/dist/console/assets/console-DxapQ9oS.js +11 -0
  31. package/dist/console/assets/local-agents-CoqD4dSN.js +6 -0
  32. package/dist/console/assets/minus-DDQ0ydcM.js +1 -0
  33. package/dist/console/assets/tailnet-C5Flwl_d.js +2 -0
  34. package/dist/console/assets/theme-DCd0qh4l.js +1 -0
  35. package/dist/console/assets/ui-Bry1mnCY.js +41 -0
  36. package/dist/console/assets/usage-CIPWnHaS.css +1 -0
  37. package/dist/console/assets/usage-CqVjMb7m.js +5 -0
  38. package/dist/console/assets/usage-D1G0GgE3.js +56 -0
  39. package/dist/console/build-info.json +1 -1
  40. package/dist/console/console.html +8 -2
  41. package/docs/agent-hardening.md +206 -0
  42. package/docs/agent-recipes.md +23 -0
  43. package/docs/agent-workflow.md +5 -0
  44. package/docs/agents.md +49 -6
  45. package/docs/architecture.md +10 -4
  46. package/docs/deployment.md +39 -17
  47. package/docs/design-system.md +56 -7
  48. package/docs/hosted.md +1800 -46
  49. package/docs/images/board-overview.png +0 -0
  50. package/docs/images/journeys.png +0 -0
  51. package/docs/images/live-comment.png +0 -0
  52. package/docs/images/phone-comment.png +0 -0
  53. package/docs/images/phone-overview.png +0 -0
  54. package/docs/images/variant.png +0 -0
  55. package/docs/where-to-run.md +119 -3
  56. package/package.json +6 -1
  57. package/src/agent/backends/acp.js +745 -44
  58. package/src/agent/branch-mode.js +17 -3
  59. package/src/agent/card-hash.js +65 -0
  60. package/src/agent/context.js +41 -0
  61. package/src/agent/exec-paths.js +105 -0
  62. package/src/agent/routes.js +23 -2
  63. package/src/agent/run.js +11 -1
  64. package/src/agent/starter/cli.js +6 -1
  65. package/src/agent/turn-changes.js +70 -8
  66. package/src/agent/usage-log.js +251 -0
  67. package/src/cli/args.js +37 -0
  68. package/src/cli/commands.js +20 -5
  69. package/src/cli/help.js +73 -3
  70. package/src/cli/init.js +2 -1
  71. package/src/cli/serve.js +20 -5
  72. package/src/cli.js +8 -0
  73. package/src/hosted/access-cli.js +99 -1
  74. package/src/hosted/activity-core.js +232 -0
  75. package/src/hosted/activity.js +375 -0
  76. package/src/hosted/admin.js +87 -13
  77. package/src/hosted/agent-approvals.js +29 -4
  78. package/src/hosted/agent-link.js +1032 -0
  79. package/src/hosted/agent-policy.js +10 -3
  80. package/src/hosted/agent-presence.js +63 -22
  81. package/src/hosted/agent-routes.js +135 -0
  82. package/src/hosted/agents.js +1206 -0
  83. package/src/hosted/app.js +178 -12
  84. package/src/hosted/auth-routes.js +156 -15
  85. package/src/hosted/auth.js +123 -20
  86. package/src/hosted/board-routes.js +129 -5
  87. package/src/hosted/chat-frames.js +246 -0
  88. package/src/hosted/chat-job.js +204 -0
  89. package/src/hosted/chat-permissions.js +203 -0
  90. package/src/hosted/chat-routes.js +1009 -0
  91. package/src/hosted/chat-store.js +477 -0
  92. package/src/hosted/comment-files.js +11 -1
  93. package/src/hosted/comments.js +1 -1
  94. package/src/hosted/console-routes.js +122 -34
  95. package/src/hosted/db.js +295 -0
  96. package/src/hosted/device-routes.js +88 -10
  97. package/src/hosted/device.js +54 -4
  98. package/src/hosted/events.js +3 -3
  99. package/src/hosted/guards.js +337 -27
  100. package/src/hosted/http.js +6 -3
  101. package/src/hosted/membership.js +22 -3
  102. package/src/hosted/operator-access.js +418 -0
  103. package/src/hosted/operator.js +106 -2
  104. package/src/hosted/ops-cli.js +238 -3
  105. package/src/hosted/pages.js +4 -0
  106. package/src/hosted/passkey-policy.js +75 -0
  107. package/src/hosted/permissions.js +52 -6
  108. package/src/hosted/presence.js +31 -2
  109. package/src/hosted/projects.js +30 -2
  110. package/src/hosted/public.js +4 -4
  111. package/src/hosted/ratelimit.js +14 -0
  112. package/src/hosted/retention.js +18 -2
  113. package/src/hosted/server.js +123 -11
  114. package/src/hosted/shares.js +2 -2
  115. package/src/hosted/step-up-settings.js +68 -0
  116. package/src/hosted/step-up.js +135 -0
  117. package/src/hosted/tailnet-identity.js +24 -0
  118. package/src/hosted/tailnet-routes.js +342 -0
  119. package/src/hosted/tailnet.js +220 -0
  120. package/src/hosted/tailscale.js +75 -9
  121. package/src/hosted/tenancy.js +66 -1
  122. package/src/hosted/token-api.js +119 -20
  123. package/src/hosted/token-events.js +5 -3
  124. package/src/hosted/tokens.js +29 -6
  125. package/src/hosted/turn-hub.js +152 -0
  126. package/src/hosted/usage-core.js +624 -0
  127. package/src/hosted/usage-layout.js +724 -0
  128. package/src/hosted/usage-routes.js +375 -0
  129. package/src/hosted/usage-shape.js +256 -0
  130. package/src/hosted/usage.js +641 -0
  131. package/src/remote/agent-connect.js +469 -0
  132. package/src/remote/agent-fix.js +611 -0
  133. package/src/remote/agent-job.js +216 -0
  134. package/src/remote/agent-link.js +906 -0
  135. package/src/remote/agent-policy-file.js +242 -0
  136. package/src/remote/credentials.js +35 -1
  137. package/src/remote/login.js +44 -9
  138. package/src/remote/share.js +1 -1
  139. package/src/remote/tailnet-cli.js +547 -0
  140. package/src/server/app.js +15 -0
  141. package/src/server/pairing-routes.js +34 -5
  142. package/src/server/tailscale.js +97 -4
  143. package/src/tailnet-proof.js +766 -0
  144. package/dist/client/assets/BoardChat-DxehB761.js +0 -27
  145. package/dist/client/assets/ChecksPanel-pA_ueIaJ.js +0 -1
  146. package/dist/client/assets/History-C9N32kCv.js +0 -1
  147. package/dist/client/assets/LocalSettings-DawtKnvi.js +0 -1
  148. package/dist/client/assets/QuickConnect-DO1TjS1t.js +0 -1
  149. package/dist/client/assets/index-CsqLdqGx.css +0 -2
  150. package/dist/client/assets/index-DnZarJ3U.js +0 -37
  151. package/dist/client/assets/shield-check-QzwGhz0t.js +0 -1
  152. package/dist/client/assets/ui-DI-FGWWK.js +0 -41
  153. package/dist/console/assets/LocalAccountsApp-VOCZg8dg.js +0 -1
  154. package/dist/console/assets/LocalConsole-CMwAW-mF.js +0 -1
  155. package/dist/console/assets/app-update-dialog-Cw6UDqNP.js +0 -1
  156. package/dist/console/assets/console-DgfWmUEx.js +0 -55
  157. package/dist/console/assets/console-Lis0vvdL.css +0 -2
@@ -30,10 +30,30 @@ export async function hostedCommand(positional, flags, out, err = out) {
30
30
  await operatorCommand(sub, { dataDir: dataDirOf(flags), flags, env: process.env, out })
31
31
  return 0
32
32
  }
33
+ if (sub === 'claim') return claim(flags, out)
33
34
  if (sub === 'admin') return admin(rest, flags, out)
34
35
  if (sub === 'backup') return backupCommand(flags, out)
35
36
  if (sub === 'restore') return restoreCommand(flags, out, err)
36
- throw new Error(`unknown hosted command "${show(sub).slice(0, 40)}" (admin, backup, restore; or no command to run the server)`)
37
+ throw new Error(`unknown hosted command "${show(sub).slice(0, 40)}" (claim, admin, backup, restore; or no command to run the server)`)
38
+ }
39
+
40
+ // ---- The first account, without the browser (tailnet sign-in) ----
41
+
42
+ // `shapewall hosted claim --data DIR --login LOGIN` on the server's own
43
+ // machine: whoever can read the data folder controls the server, and says
44
+ // whose it is (src/hosted/access-cli.js claimCommand; the server never
45
+ // takes a tailnet identity from its own machine). `shapewall hosted claim
46
+ // --setup-link URL` from another tailnet device: the server sees who asks,
47
+ // and --login can only refuse another answer (src/remote/tailnet-cli.js).
48
+ async function claim(flags, out) {
49
+ // From another tailnet device, with the setup link itself: the server sees who asks.
50
+ if (typeof flags['setup-link'] === 'string') {
51
+ const { claimServer } = await import('../remote/tailnet-cli.js')
52
+ return claimServer({ setupUrl: flags['setup-link'], flags, out })
53
+ }
54
+ // On the server's own machine: the data folder is the proof, --login says whose it is.
55
+ const { operatorCommand } = await import('./access-cli.js')
56
+ return operatorCommand('claim', { dataDir: dataDirOf(flags), flags, env: process.env, out })
37
57
  }
38
58
 
39
59
  // ---- Run the server ----
@@ -63,9 +83,12 @@ async function serve(flags, out) {
63
83
  usercontentOrigin: flags['usercontent-origin'] || env.SHAPEWALL_USERCONTENT_ORIGIN || env.SHAPEWALL_HOSTED_USERCONTENT_ORIGIN || null,
64
84
  previousOrigin: flags['previous-origin'] || env.SHAPEWALL_HOSTED_PREVIOUS_ORIGIN || null,
65
85
  reportEmail: flags['report-email'] || env.SHAPEWALL_HOSTED_REPORT_EMAIL || null,
86
+ ownersSeeSignIns: Boolean(flags['owners-see-sign-ins']) || env.SHAPEWALL_HOSTED_OWNERS_SEE_SIGN_INS === '1',
66
87
  signup: flags.signup || env.SHAPEWALL_HOSTED_SIGNUP || 'invite',
67
88
  trustProxy,
68
89
  tailscale,
90
+ tailnetSignIn: Boolean(flags['tailnet-sign-in']) || env.SHAPEWALL_HOSTED_TAILNET_SIGN_IN === '1',
91
+ tailnetPasskeys: Boolean(flags['tailnet-passkeys']) || env.SHAPEWALL_HOSTED_TAILNET_PASSKEYS === '1',
69
92
  quotasFile: flags.quotas || env.SHAPEWALL_HOSTED_QUOTAS || null,
70
93
  retentionHours: intFlag(flags, 'retention-hours', { min: 0, max: 24 * 30, fallback: undefined }),
71
94
  retentionKeep: intFlag(flags, 'retention-keep', { min: 0, max: 100, fallback: undefined }),
@@ -73,7 +96,8 @@ async function serve(flags, out) {
73
96
  })
74
97
  } catch (error) {
75
98
  const { TailscaleError } = await import('./tailscale.js')
76
- if (error instanceof TailscaleError) {
99
+ const { TailnetSignInError } = await import('./server.js')
100
+ if (error instanceof TailscaleError || error instanceof TailnetSignInError) {
77
101
  out(error.message)
78
102
  return 1
79
103
  }
@@ -154,7 +178,23 @@ const ADMIN_HELP = `shapewall hosted admin <command> --data DIR (on the server
154
178
  reports [--all] abuse reports (open ones; --all with closed)
155
179
  reports close ID [--note TEXT]
156
180
  retention WS --keep N|default older versions kept per page and viewport
181
+ retention WS --usage-days N|default how long usage records are kept (400 days by default)
157
182
  retention --run [--dry-run] prune now (the server also does it every 6 hours)
183
+ members list who is in the workspace, with roles
184
+ members add --login TAILNET_LOGIN | --handle HANDLE [--role ROLE] put someone in, or change their role
185
+ (a tailnet login with no account yet gets an invite only it can take)
186
+ members remove --login TAILNET_LOGIN | --handle HANDLE take someone out; what they made to let others in is revoked
187
+ members relink --handle HANDLE [--login TAILNET_LOGIN] their tailnet login again: the next arrival as it is taken as
188
+ them (for "This tailnet login belongs to someone else here"); --login links another login.
189
+ Or: members relink --login TAILNET_LOGIN (the account linked to it now)
190
+ members unlink --handle HANDLE take the tailnet login off an account
191
+ invites list | invites revoke ID
192
+ invites create --login TAILNET_LOGIN [--role ROLE] [--days N] or a link: --link --origin https://the.server
193
+ projects list
194
+ passkeys status|on|off on a server with tailnet sign-in: whether anyone may add a passkey (off by default)
195
+ passkeys list --handle HANDLE | --login TAILNET_LOGIN an account's passkeys (ids, where added, on hold)
196
+ passkeys remove ID --handle HANDLE | --login TAILNET_LOGIN remove one, also the last; ends the account's passkey sessions
197
+ --workspace ID which workspace, when the server has several (members, invites, projects)
158
198
  log [--limit N] the operator log
159
199
  --operator NAME who you are in the operator log (default user@host)
160
200
  --json machine-readable output`
@@ -258,10 +298,22 @@ async function admin(positional, flags, out) {
258
298
  out(
259
299
  `${dryRun ? 'Would remove' : 'Removed'} ${result.files} old version files (${mb(result.bytes)}) from ${result.boards} boards in ${result.workspaces} workspaces.`,
260
300
  )
301
+ if (result.usageRows) out(`${dryRun ? 'Would remove' : 'Removed'} ${result.usageRows} old usage records.`)
302
+ return 0
303
+ }
304
+ if (target && flags['usage-days'] !== undefined) {
305
+ const days = flags['usage-days'] === 'default' ? null : intFlag(flags, 'usage-days', { min: 1, max: 3650 })
306
+ const result = ops.setUsageRetentionFor(db, { workspaceId: target, days, operator })
307
+ if (flags.json) return json(result)
308
+ out(
309
+ `${result.id} (${show(result.name)}) keeps usage records for ${result.usageDays} days${result.own ? '' : ' (the server default)'}.`,
310
+ )
261
311
  return 0
262
312
  }
263
313
  if (!target || flags.keep === undefined)
264
- throw new ops.OperatorError('usage: hosted admin retention WS --keep N|default, or hosted admin retention --run [--dry-run]')
314
+ throw new ops.OperatorError(
315
+ 'usage: hosted admin retention WS --keep N|default, hosted admin retention WS --usage-days N|default, or hosted admin retention --run [--dry-run]',
316
+ )
265
317
  const keep = flags.keep === 'default' ? null : intFlag(flags, 'keep', { min: 0, max: 100 })
266
318
  const result = ops.setRetention(db, { workspaceId: target, keep, operator })
267
319
  if (flags.json) return json(result)
@@ -270,6 +322,189 @@ async function admin(positional, flags, out) {
270
322
  )
271
323
  return 0
272
324
  }
325
+ case 'members': {
326
+ const access = await import('./operator-access.js')
327
+ const where = { workspaceId: flags.workspace, operator }
328
+ if (!target || target === 'list') {
329
+ const result = access.listMembers(db, where)
330
+ if (flags.json) return json(result)
331
+ out(`${show(result.workspace.name)} (${result.workspace.id}):`)
332
+ for (const member of result.members)
333
+ out(
334
+ ` @${show(member.handle)} ${member.role} ${show(member.name)}` +
335
+ `${member.tailnetLogin ? ` tailnet ${show(member.tailnetLogin)}` : ''}${member.passkeys ? ` ${member.passkeys} passkey${member.passkeys === 1 ? '' : 's'}` : ''}`,
336
+ )
337
+ return 0
338
+ }
339
+ if (target === 'add') {
340
+ const result = access.addMember(db, { ...where, handle: flags.handle, login: flags.login, role: flags.role })
341
+ if (flags.json) return json(result)
342
+ if (result.invited)
343
+ return say(
344
+ `${show(result.invite.tailnetLogin)} has no account here yet: invited to ${show(result.workspace.name)} as ${result.invite.role}. ` +
345
+ 'Only that tailnet login can take it: they open the server from one of their tailnet devices.',
346
+ )
347
+ return say(
348
+ result.changedFrom
349
+ ? `@${show(result.member.handle)} is now ${result.member.role} in ${show(result.workspace.name)} (was ${result.changedFrom}).`
350
+ : `@${show(result.member.handle)} is in ${show(result.workspace.name)} as ${result.member.role}.`,
351
+ )
352
+ }
353
+ if (target === 'remove') {
354
+ const result = access.removeMember(db, { ...where, handle: flags.handle, login: flags.login })
355
+ if (flags.json) return json(result)
356
+ const { invites, shares, tokens } = result.revoked
357
+ return say(
358
+ `Removed @${show(result.removed.handle)} (${result.removed.role}) from ${show(result.workspace.name)}. ` +
359
+ `Revoked: ${invites} invites, ${shares} share links, ${tokens} API tokens they made.`,
360
+ )
361
+ }
362
+ if (target === 'relink') {
363
+ const result = access.relinkMember(db, { handle: flags.handle, login: flags.login, operator })
364
+ if (flags.json) return json(result)
365
+ out(
366
+ `@${show(result.user.handle)} is linked to ${show(result.login)}${result.was && result.was !== result.login ? ` (was ${show(result.was)})` : ''}. ` +
367
+ 'Whoever next arrives through the tailnet as that login, from a device of theirs, is taken as this account from then on.',
368
+ )
369
+ return say(
370
+ `${result.sessionsEnded} tailnet session${result.sessionsEnded === 1 ? '' : 's'} of the account ended. Make sure it is the right person who opens the server next.`,
371
+ )
372
+ }
373
+ if (target === 'unlink') {
374
+ const result = access.unlinkMember(db, { handle: flags.handle, login: flags.login, operator })
375
+ if (flags.json) return json(result)
376
+ out(
377
+ `@${show(result.user.handle)} is no longer linked to ${show(result.was)}; ${result.sessionsEnded} tailnet session${result.sessionsEnded === 1 ? '' : 's'} ended.`,
378
+ )
379
+ return say(
380
+ result.passkeys
381
+ ? 'The account signs in with its passkey, where this server allows passkeys.'
382
+ : 'The account has no passkey: nothing signs it in until it is linked again (hosted admin members relink --handle ... --login ...).',
383
+ )
384
+ }
385
+ throw new ops.OperatorError(
386
+ 'usage: hosted admin members list|add|remove|relink|unlink --login TAILNET_LOGIN | --handle HANDLE [--role ROLE]',
387
+ )
388
+ }
389
+ case 'invites': {
390
+ const access = await import('./operator-access.js')
391
+ const where = { workspaceId: flags.workspace, operator }
392
+ if (!target || target === 'list') {
393
+ const result = access.listInvites(db, where)
394
+ if (flags.json) return json(result)
395
+ if (!result.invites.length) return say(`No open invites to ${show(result.workspace.name)}.`)
396
+ out(`Open invites to ${show(result.workspace.name)}:`)
397
+ for (const invite of result.invites)
398
+ out(
399
+ ` ${invite.id} ${invite.role} ${invite.tailnetLogin ? `for ${show(invite.tailnetLogin)}` : 'a link'} until ${invite.expiresAt.slice(0, 16).replace('T', ' ')}`,
400
+ )
401
+ return 0
402
+ }
403
+ if (target === 'create') {
404
+ const result = access.createInvite(db, {
405
+ ...where,
406
+ login: typeof flags.login === 'string' ? flags.login : null,
407
+ origin: flags.link && typeof flags.origin === 'string' ? flags.origin : null,
408
+ role: flags.role,
409
+ days: flags.days === undefined ? 7 : Number(flags.days),
410
+ })
411
+ if (flags.json) return json(result)
412
+ if (result.url) {
413
+ out(`An invite to ${show(result.workspace.name)} as ${result.invite.role}. Whoever has this link can use it once:`)
414
+ return say(` ${result.url}`)
415
+ }
416
+ return say(
417
+ `Invited ${show(result.invite.tailnetLogin)} to ${show(result.workspace.name)} as ${result.invite.role}. Only that tailnet login can take it.`,
418
+ )
419
+ }
420
+ if (target === 'revoke') {
421
+ const result = access.revokeInvite(db, { ...where, id: extra })
422
+ if (flags.json) return json(result)
423
+ return say(`Revoked the invite ${result.revoked}.`)
424
+ }
425
+ throw new ops.OperatorError('usage: hosted admin invites list | create --login TAILNET_LOGIN [--role ROLE] | revoke ID')
426
+ }
427
+ case 'projects': {
428
+ const access = await import('./operator-access.js')
429
+ if (target && target !== 'list') throw new ops.OperatorError('usage: hosted admin projects list')
430
+ const result = access.listProjects(db, { workspaceId: flags.workspace, operator })
431
+ if (flags.json) return json(result)
432
+ if (!result.projects.length) return say(`${show(result.workspace.name)} has no project yet.`)
433
+ out(`Projects in ${show(result.workspace.name)}:`)
434
+ for (const project of result.projects) out(` ${show(project.slug)} ${show(project.name)} (${project.id})`)
435
+ return 0
436
+ }
437
+ case 'passkeys': {
438
+ if (['on', 'off', 'status'].includes(target)) {
439
+ const access = await import('./operator-access.js')
440
+ const result = target === 'status' ? access.passkeysStatus(db) : access.setPasskeys(db, { on: target === 'on', operator })
441
+ if (flags.json) return json(result)
442
+ out(
443
+ result.setting === null
444
+ ? 'Passkeys on a tailnet sign-in server: not set here. They are off unless the server runs with --tailnet-passkeys.'
445
+ : result.setting
446
+ ? 'Passkeys are ON for a server with tailnet sign-in: an account may add a passkey, and one that has a passkey confirms with it.'
447
+ : 'Passkeys are OFF for a server with tailnet sign-in: the Tailscale account is the only sign-in, and nobody is asked for a passkey.',
448
+ )
449
+ out('A running server follows this at once. A server without --tailnet-sign-in always uses passkeys, whatever this says.')
450
+ if (result.sessionsEnded)
451
+ out(
452
+ `${result.sessionsEnded} session${result.sessionsEnded === 1 ? '' : 's'} that a passkey or a recovery code started ${result.sessionsEnded === 1 ? 'was' : 'were'} ended.`,
453
+ )
454
+ if (result.holdsRestarted)
455
+ out(
456
+ `${result.holdsRestarted} passkey${result.holdsRestarted === 1 ? '' : 's'} that ${result.holdsRestarted === 1 ? 'was' : 'were'} on hold start${result.holdsRestarted === 1 ? 's its' : ' their'} 24 hours again.`,
457
+ )
458
+ for (const workspace of result.workspaces || [])
459
+ out(
460
+ `${show(workspace.name)} (${workspace.id}) asks for a passkey in its settings (${workspace.settings.join(', ')}): ` +
461
+ (result.setting ? 'asked again from now.' : 'not asked while passkeys are off. Its audit log says so.'),
462
+ )
463
+ if (result.setting === false && result.passkeyOnly)
464
+ out(
465
+ `${result.passkeyOnly} account${result.passkeyOnly === 1 ? ' is' : 's are'} not linked to a tailnet login: with passkeys off ${result.passkeyOnly === 1 ? 'it' : 'they'} cannot sign in.`,
466
+ )
467
+ if (result.setting === false && result.withPasskey)
468
+ out(
469
+ `${result.withPasskey} account${result.withPasskey === 1 ? ' has' : 's have'} a passkey; it is kept and not used while passkeys are off.`,
470
+ )
471
+ return 0
472
+ }
473
+ const who = { handle: flags.handle, login: flags.login, operator }
474
+ if (target === 'list') {
475
+ const result = ops.listPasskeysOf(db, who)
476
+ if (flags.json) return json(result)
477
+ const name = `@${show(result.user.handle)}${result.user.tailnetLogin ? ` (tailnet login ${show(result.user.tailnetLogin)})` : ''}`
478
+ if (!result.passkeys.length) return say(`${name} has no passkey.`)
479
+ out(`${name}:`)
480
+ for (const key of result.passkeys)
481
+ out(
482
+ ` ${key.id}\n ${show(key.nickname) || '(no name)'}; added ${key.createdAt.slice(0, 16).replace('T', ' ')}` +
483
+ `${key.addedFrom ? ` from ${show(key.addedFrom)} in a tailnet session` : ''}; last used ${key.lastUsedAt ? key.lastUsedAt.slice(0, 16).replace('T', ' ') : 'never'}` +
484
+ `${key.onHoldUntil ? `; on hold until ${key.onHoldUntil.slice(0, 16).replace('T', ' ')}` : ''}`,
485
+ )
486
+ return 0
487
+ }
488
+ if (target === 'remove') {
489
+ if (!extra) throw new ops.OperatorError('usage: hosted admin passkeys remove ID --handle HANDLE | --login TAILNET_LOGIN')
490
+ const result = ops.removePasskeyOf(db, { ...who, id: extra })
491
+ if (flags.json) return json(result)
492
+ out(
493
+ `Removed the passkey ${show(result.removed.nickname) || result.removed.id.slice(0, 12)} of @${show(result.user.handle)}. ` +
494
+ `${result.sessionsEnded} passkey session${result.sessionsEnded === 1 ? '' : 's'} ended; ${result.left} passkey${result.left === 1 ? '' : 's'} left.`,
495
+ )
496
+ if (!result.left)
497
+ out(
498
+ result.user.tailnetLogin
499
+ ? `The account has no passkey now: ${show(result.user.tailnetLogin)} signs in through the tailnet and can add one.`
500
+ : 'The account has no passkey now: it signs in with a recovery code, if it has one left.',
501
+ )
502
+ return 0
503
+ }
504
+ throw new ops.OperatorError(
505
+ 'usage: hosted admin passkeys status|on|off, or passkeys list|remove ID --handle HANDLE | --login TAILNET_LOGIN',
506
+ )
507
+ }
273
508
  case 'log': {
274
509
  ops.recordOperatorRead(db, { action: 'log', operator })
275
510
  const rows = ops.operatorLog(db, { limit: intFlag(flags, 'limit', { min: 1, max: 10_000, fallback: 50 }) })
@@ -63,6 +63,10 @@ export function mountPages(app, { db, dataDir, consoleDir, clientDir, turnstile,
63
63
  '/w/:ws',
64
64
  '/w/:ws/:section',
65
65
  '/w/:ws/projects/:pid',
66
+ // A project's Agents page.
67
+ '/w/:ws/agents/:pid',
68
+ // A person's page and an agent's page, under Activity.
69
+ '/w/:ws/activity/:subject',
66
70
  ])
67
71
  app.get(route, (req, res) => sendConsole(req, res))
68
72
 
@@ -0,0 +1,75 @@
1
+ // Whether passkeys exist on this server.
2
+ //
3
+ // On a server without tailnet sign-in (its own domain, or a tailnet with
4
+ // passkeys) they are the sign-in, always.
5
+ //
6
+ // On a server started with --tailnet-sign-in, Tailscale is the sign-in and
7
+ // passkeys are OFF unless the operator turns them on: one identity (your
8
+ // Tailscale account), your different machines, and no second credential. The
9
+ // tailnet is the trust boundary there: anything running as you on one of
10
+ // your tailnet devices can act as you, so the few things that always ask
11
+ // (src/hosted/step-up.js, the fixed core) ask for a typed confirmation
12
+ // instead of a passkey (src/hosted/guards.js). An operator who wants more
13
+ // turns passkeys on:
14
+ // - `shapewall hosted --tailnet-passkeys` (or $SHAPEWALL_HOSTED_TAILNET_PASSKEYS=1), or
15
+ // - `shapewall hosted admin passkeys on|off --data DIR` (kept in the
16
+ // database, read on every request, and it wins over the flag).
17
+ // With them on, an account may add a passkey, and then the fixed core needs
18
+ // it, with the protections for a first passkey (hold, notice, removal).
19
+
20
+ import { accounts } from './tenancy.js'
21
+
22
+ const KEY = 'tailnet_passkeys'
23
+ // When the operator last switched them off: holds of passkeys stand still from then (see holdsAt).
24
+ const OFF_AT = 'tailnet_passkeys_off_at'
25
+
26
+ export function serverSetting(db, key) {
27
+ return accounts(db).get('SELECT value FROM server_settings WHERE key = :key', { key })?.value ?? null
28
+ }
29
+
30
+ export function setServerSetting(db, key, value, at) {
31
+ accounts(db).run(
32
+ `INSERT INTO server_settings (key, value, updated_at) VALUES (:key, :value, :at)
33
+ ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at`,
34
+ { key, value: String(value), at },
35
+ )
36
+ }
37
+
38
+ // The operator's switch: true, false, or null (not set: the flag decides).
39
+ export const tailnetPasskeysSetting = (db) => {
40
+ const value = serverSetting(db, KEY)
41
+ return value === null ? null : value === '1'
42
+ }
43
+ export const setTailnetPasskeys = (db, on, at) => {
44
+ setServerSetting(db, KEY, on ? '1' : '0', at)
45
+ if (on) accounts(db).run('DELETE FROM server_settings WHERE key = :key', { key: OFF_AT })
46
+ else if (!serverSetting(db, OFF_AT)) setServerSetting(db, OFF_AT, at, at)
47
+ }
48
+ export const tailnetPasskeysOffAt = (db) => serverSetting(db, OFF_AT)
49
+
50
+ // tailnet: the tailnet gate of this server, or null (no tailnet sign-in).
51
+ export function createPasskeyPolicy({ db, tailnet = null, flag = false }) {
52
+ const on = () => {
53
+ if (!tailnet) return true
54
+ const set = tailnetPasskeysSetting(db)
55
+ return set === null ? Boolean(flag) : set
56
+ }
57
+ // The moment a passkey's 24 hour hold is judged at. While passkeys are off nobody can use one, so a hold
58
+ // does not run out behind the account's back: it stands as it was when they were switched off (and starts
59
+ // again when they are switched on, src/hosted/operator-access.js). null: now.
60
+ const holdsAt = () => {
61
+ if (on()) return null
62
+ const at = tailnetPasskeysOffAt(db)
63
+ return at && Number.isFinite(Date.parse(at)) ? new Date(at) : null
64
+ }
65
+ return { on, holdsAt, tailnetSignIn: Boolean(tailnet) }
66
+ }
67
+
68
+ // Every route that makes, uses or manages a passkey or a recovery code, or
69
+ // links a passkey account to a tailnet login. Off with passkeys.
70
+ const PASSKEY_ROUTES = /^\/auth\/(?:register|login|recovery|reauth|passkeys|recovery-codes|rebind|tailnet\/link)(?:\/|$)/i
71
+
72
+ export const PASSKEYS_OFF_MESSAGE =
73
+ 'Passkeys are off on this server: your Tailscale account is the sign-in. Whoever runs the server can turn them on (shapewall hosted admin passkeys on).'
74
+
75
+ export const isPasskeyRoute = (path) => PASSKEY_ROUTES.test(String(path || ''))
@@ -6,8 +6,10 @@
6
6
  //
7
7
  // viewer sees projects, boards and comments
8
8
  // member + comments, replies, reactions, resolve and reopen; edits and deletes their own
9
+ // member + their own agent usage (and that of agents they connected)
9
10
  // admin + projects, tokens, invites (up to admin), share links, members
10
- // and viewers, any comment, the access overview, audit log, settings
11
+ // and viewers, any comment, the access overview, audit log, settings,
12
+ // the workspace's usage, everyone's activity, the access review
11
13
  // owner + admins and owners, owner invites, deleting the workspace
12
14
  // guest a share link visitor: one project; comments and replies on a
13
15
  // comment link, nothing else
@@ -38,6 +40,14 @@ export const NEEDS = {
38
40
  access: 'admin',
39
41
  audit: 'admin',
40
42
  export: 'admin',
43
+ // Usage: a member reads their own turns and the agents they connected;
44
+ // admins and owners the workspace (src/hosted/usage.js usageScope).
45
+ usage: 'member',
46
+ // Activity: anyone in the workspace reads their own; admins and owners all of it.
47
+ activity: 'viewer',
48
+ accessReview: 'admin',
49
+ // The layout of the Usage dashboard that everyone in the workspace starts from.
50
+ usageDefaultLayout: 'owner',
41
51
  deleteWorkspace: 'owner',
42
52
  }
43
53
  export const can = (role, need) => roleAtLeast(role, NEEDS[need])
@@ -61,6 +71,44 @@ export function guestPermissions(mode) {
61
71
  export const canEditComment = ({ isAuthor }) => Boolean(isAuthor)
62
72
  export const canDeleteComment = ({ role, isAuthor }) => roleAtLeast(role, 'member') && (Boolean(isAuthor) || roleAtLeast(role, 'admin'))
63
73
 
74
+ // ---- Agents on a hosted server (src/hosted/agents.js) ----
75
+ //
76
+ // Every role rule about agents is here, so the console, the board, a later
77
+ // CLI command or admin tool, and the approval cards of connected agents all
78
+ // ask the same functions.
79
+ //
80
+ // Who may send an agent work (its audience): only the person who connected
81
+ // it, named members, or everyone the project's agent policy trusts.
82
+ export const AGENT_AUDIENCES = ['owner', 'members', 'trusted']
83
+ // Whether an agent's edits and commands always wait for a person, or are
84
+ // approved automatically.
85
+ export const APPROVAL_RULES = ['ask', 'auto']
86
+ // The least role that may change an agent's approval rule, or answer its
87
+ // approvals: each is a setting per agent, admin by default.
88
+ export const APPROVAL_ROLES = ['admin', 'owner']
89
+ // Rename, icon, default agent, audience, revoke: the people who manage tokens.
90
+ export const canManageAgents = (role) => roleAtLeast(role, NEEDS.tokens)
91
+ export const canChangeApprovalRule = (role, agent) => canManageAgents(role) && roleAtLeast(role, agent?.approvalChangeRole || 'admin')
92
+ // Which role those two take is itself an owner's decision.
93
+ export const canChangeApprovalRoles = (role) => role === 'owner'
94
+ export const canAnswerApproval = (role, agent) => roleAtLeast(role, agent?.approvalAnswerRole || 'admin')
95
+ // Automatic approval needs the agent's own machine to have opted in twice:
96
+ // to approvals from the board at all (`agent.machineApprovals`, what a
97
+ // connected agent reported: "none", "owner" or "admins"), and to "allowed
98
+ // without asking" for at least one kind of request (`agent.machineAuto`:
99
+ // "edits", "commands"). Without both, "always ask" is the only rule in
100
+ // effect, whatever is stored. Even with both, the machine keeps its own
101
+ // limits: the rule never widens what may be edited or which commands run.
102
+ export const APPROVAL_KINDS = ['edits', 'commands']
103
+ const machineAutoKinds = (agent) =>
104
+ ['owner', 'admins'].includes(agent?.machineApprovals)
105
+ ? APPROVAL_KINDS.filter((kind) => Array.isArray(agent?.machineAuto) && agent.machineAuto.includes(kind))
106
+ : []
107
+ export const approvalAutoAvailable = (agent) => machineAutoKinds(agent).length > 0
108
+ export const effectiveApprovalRule = (agent) => (agent?.approvalRule === 'auto' && approvalAutoAvailable(agent) ? 'auto' : 'ask')
109
+ // The rule in effect for one kind of request: "auto" only for a kind the machine named.
110
+ export const approvalRuleFor = (agent, kind) => (agent?.approvalRule === 'auto' && machineAutoKinds(agent).includes(kind) ? 'auto' : 'ask')
111
+
64
112
  // Roles: admins manage members and viewers (and may make admins); only
65
113
  // owners change owners or admins. `newRole` null asks about removing.
66
114
  export function canManage(actorRole, targetRole, newRole = null) {
@@ -82,11 +130,9 @@ export const canInvite = (actorRole, role) =>
82
130
  can(actorRole, 'invites') && ROLES.includes(role) && (role !== 'owner' || actorRole === 'owner')
83
131
  export const invitableRoles = (actorRole) => ROLES.filter((role) => canInvite(actorRole, role))
84
132
 
85
- // Changes that need a passkey check in the last 10 minutes.
86
- export const inviteNeedsFresh = (role) => role === 'owner' || role === 'admin'
87
- export const roleChangeNeedsFresh = (targetRole, newRole) =>
88
- newRole === 'owner' || newRole === 'admin' || (['owner', 'admin'].includes(targetRole) && targetRole !== newRole)
89
- export const removalNeedsFresh = (targetRole, { self = false } = {}) => !self && ['owner', 'admin'].includes(targetRole)
133
+ // Which of these ask for the passkey again is in src/hosted/step-up.js:
134
+ // anything that makes, changes or removes an owner always does; the same
135
+ // for an admin only when the workspace's owner switched that on.
90
136
 
91
137
  // A workspace always keeps an owner.
92
138
  export const leavesNoOwner = ({ targetRole, newRole = null, owners }) => targetRole === 'owner' && newRole !== 'owner' && owners <= 1
@@ -10,6 +10,7 @@ import { PUBLIC_ID_RE, readPublic } from './public.js'
10
10
  import { createProjectStore } from './projects.js'
11
11
  import { roleIn, tenant } from './tenancy.js'
12
12
  import { guestCookieName, sessionCookieName } from './cookies.js'
13
+ import { sessionReader } from './tailnet.js'
13
14
  import { ID_PATTERNS, SHARE_ID_RE } from './crypto.js'
14
15
  import { ID_RE } from '../config.js'
15
16
 
@@ -75,10 +76,21 @@ function cookie(req, name) {
75
76
  }
76
77
 
77
78
  // Re-run for every message and heartbeat. No cached membership or share grant.
78
- export function presenceAuthorizer({ db, dataDir, origin, auth, now = () => new Date(), guestOnly = false }) {
79
+ export function presenceAuthorizer({
80
+ db,
81
+ dataDir,
82
+ origin,
83
+ auth,
84
+ now = () => new Date(),
85
+ guestOnly = false,
86
+ tailnet = null,
87
+ passkeys = null,
88
+ }) {
79
89
  const url = new URL(origin)
80
90
  const secure = url.protocol === 'https:'
81
91
  const iso = () => now().toISOString()
92
+ // A tailnet session counts only with its identity, here as on every request.
93
+ const readSession = sessionReader({ auth, tailnet, passkeys })
82
94
  return (req) => {
83
95
  if (
84
96
  req.headers.origin !== url.origin ||
@@ -100,7 +112,7 @@ export function presenceAuthorizer({ db, dataDir, origin, auth, now = () => new
100
112
  let access
101
113
  if (member && !guestOnly) {
102
114
  const token = cookie(req, sessionCookieName(secure))
103
- const session = token && auth.readSession(token)
115
+ const session = token && readSession(req, token)
104
116
  if (!session || !roleIn(db, session.user.id, member[1])) return null
105
117
  access = {
106
118
  workspace: member[1],
@@ -171,6 +183,23 @@ export function createPresenceHub({ events = null, limits = {}, now = () => Date
171
183
  }
172
184
  const unsubscribe = events?.subscribe((event) => {
173
185
  if (event.type === 'close') return close()
186
+ // Chat with connected agents (src/hosted/chat-routes.js) and agents
187
+ // coming and going: a nudge for signed-in members only, never a share
188
+ // link's guest. Ids of shared threads only; the board refetches.
189
+ if (event.type === 'chat.turn' || event.type === 'agent.changed') {
190
+ if (!event.workspace || !event.project) return
191
+ const prefix = `${event.workspace}:${event.project}:`
192
+ for (const [key, room] of rooms) {
193
+ if (!key.startsWith(prefix) || (event.board && key !== `${prefix}${event.board}`)) continue
194
+ for (const peer of [...room.peers])
195
+ if (peer.access.kind === 'member' && live(peer))
196
+ send(peer, {
197
+ type: 'agents',
198
+ ...(event.type === 'chat.turn' ? { thread: typeof event.thread === 'string' ? event.thread : null } : {}),
199
+ })
200
+ }
201
+ return
202
+ }
174
203
  if (!event.board || !event.workspace || !event.project) return
175
204
  const room = rooms.get(`${event.workspace}:${event.project}:${event.board}`)
176
205
  if (!room) return
@@ -10,6 +10,7 @@ import path from 'node:path'
10
10
  import { ID_RE } from '../config.js'
11
11
  import { ID_PATTERNS, newId } from './crypto.js'
12
12
  import { transaction } from './db.js'
13
+ import { RUN_DURATION } from './usage-shape.js'
13
14
 
14
15
  export const SLUG_RE = /^[a-z0-9][a-z0-9-]{0,39}$/
15
16
  export const PROJECTS_MAX = 50
@@ -105,7 +106,17 @@ export function createProjectStore(t, { db, dataDir, maxProjects = PROJECTS_MAX
105
106
  const project = get(projectId)
106
107
  if (!project) throw new ProjectError(404, 'unknown_project', 'No such project.')
107
108
  transaction(db, () => {
108
- for (const table of ['comment_files', 'comments', 'boards', 'api_tokens', 'pushes']) {
109
+ for (const table of [
110
+ 'chat_permissions',
111
+ 'chat_turns',
112
+ 'chat_messages',
113
+ 'chat_threads',
114
+ 'comment_files',
115
+ 'comments',
116
+ 'boards',
117
+ 'api_tokens',
118
+ 'pushes',
119
+ ]) {
109
120
  t.run(`DELETE FROM ${table} WHERE workspace_id = :ws AND project_id = :id`, { id: project.id })
110
121
  }
111
122
  t.run('DELETE FROM projects WHERE workspace_id = :ws AND id = :id', { id: project.id })
@@ -130,7 +141,19 @@ export function createProjectStore(t, { db, dataDir, maxProjects = PROJECTS_MAX
130
141
  // board id starts a new board (comment numbers from 1 again). The
131
142
  // workspace's storage count is a sum over these rows, so it drops by
132
143
  // itself. Returns what went: { board, comments, bytes }.
133
- const BOARD_TABLES = ['comment_files', 'comment_imports', 'agent_approvals', 'agent_claims', 'comments', 'pushes', 'boards']
144
+ const BOARD_TABLES = [
145
+ 'chat_permissions',
146
+ 'chat_turns',
147
+ 'chat_messages',
148
+ 'chat_threads',
149
+ 'comment_files',
150
+ 'comment_imports',
151
+ 'agent_approvals',
152
+ 'agent_claims',
153
+ 'comments',
154
+ 'pushes',
155
+ 'boards',
156
+ ]
134
157
  function removeBoard(projectId, boardId) {
135
158
  const id = String(boardId || '')
136
159
  const project = get(projectId)
@@ -142,6 +165,11 @@ export function createProjectStore(t, { db, dataDir, maxProjects = PROJECTS_MAX
142
165
  const comments = t.get(`SELECT COUNT(*) AS n FROM comments ${where}`, key).n
143
166
  const images = t.get(`SELECT COALESCE(SUM(bytes), 0) AS n FROM comment_files ${where}`, key).n
144
167
  const open = t.all(`SELECT id FROM pushes ${where} AND status = 'open'`, key).map((push) => push.id)
168
+ // The usage record of a run on this board stays (it is history), closed.
169
+ t.run(`UPDATE agent_runs SET ended_at = :at, outcome = 'removed', ${RUN_DURATION} ${where} AND ended_at IS NULL`, {
170
+ ...key,
171
+ at: new Date().toISOString(),
172
+ })
145
173
  for (const table of BOARD_TABLES) t.run(`DELETE FROM ${table} ${where}`, key)
146
174
  return { comments, bytes: row.bytes + images, open }
147
175
  })
@@ -26,7 +26,7 @@ export const publicUrl = (publicId) => `/p/${publicId}/`
26
26
 
27
27
  // The workspace switch and the per-project switch, for the console.
28
28
  export function mountPublicAdmin(router, deps) {
29
- const { db, handle, inWorkspace, inProject, freshOrThrow, auditOf, HttpError, iso } = deps
29
+ const { db, handle, inWorkspace, inProject, stepUpOrThrow, auditOf, HttpError, iso } = deps
30
30
 
31
31
  router.patch(
32
32
  '/workspaces/:ws/public-projects',
@@ -36,9 +36,9 @@ export function mountPublicAdmin(router, deps) {
36
36
  if (typeof enabled !== 'boolean') throw new HttpError(400, 'invalid_settings', 'enabled: true or false.')
37
37
  const current = Boolean(req.t.get('SELECT public_projects FROM workspaces WHERE workspace_id = :ws').public_projects)
38
38
  if (enabled && !current) {
39
- // Putting boards on the open web: the owner, with a passkey check.
39
+ // Putting boards on the open web: the owner (and the passkey again when the workspace asks).
40
40
  if (req.role !== 'owner') throw new HttpError(403, 'forbidden', 'Only an owner turns public projects on.')
41
- freshOrThrow(req)
41
+ stepUpOrThrow(req, 'tokens')
42
42
  }
43
43
  if (enabled !== current) {
44
44
  transaction(db, () => {
@@ -69,7 +69,7 @@ export function mountPublicAdmin(router, deps) {
69
69
  if (req.role !== 'owner') throw new HttpError(403, 'forbidden', 'Only an owner makes a project public.')
70
70
  const on = req.t.get('SELECT public_projects FROM workspaces WHERE workspace_id = :ws').public_projects
71
71
  if (!on) throw new HttpError(409, 'public_off', 'Public projects are off in this workspace. An owner turns them on in Settings.')
72
- freshOrThrow(req)
72
+ stepUpOrThrow(req, 'tokens')
73
73
  const id = newPublicId()
74
74
  req.t.run('UPDATE projects SET public_id = :pub, public_at = :at, public_by = :user WHERE workspace_id = :ws AND id = :id', {
75
75
  pub: id,
@@ -55,6 +55,8 @@ export function createRateLimiter({ now = () => Date.now() } = {}) {
55
55
  // and expensive to abuse; recovery codes get the tightest limit.
56
56
  export const LIMITS = {
57
57
  ceremony: { limit: 30, windowMs: 60_000 },
58
+ // POST /auth/tailnet/sign-in, per tailnet login.
59
+ tailnetSignIn: { limit: 30, windowMs: 60_000 },
58
60
  // Failed recovery codes only: per handle and IP, and per IP. A stranger
59
61
  // cannot use up someone else's attempts from another address.
60
62
  recoveryFail: { limit: 5, windowMs: 15 * 60_000 },
@@ -68,6 +70,14 @@ export const LIMITS = {
68
70
  sessionFiles: { limit: 6000, windowMs: 60_000 },
69
71
  token: { limit: 1200, windowMs: 60_000 },
70
72
  tokenBadAuth: { limit: 20, windowMs: 60_000 },
73
+ // A connected agent's link (src/hosted/agent-link.js): streamed answers
74
+ // arrive in small batches, in a bucket of their own so they never use up
75
+ // the token's budget for comments and pushes.
76
+ agentLink: { limit: 6000, windowMs: 60_000 },
77
+ // How often one agent's link may open (each open is a write and a broadcast).
78
+ agentLinkOpen: { limit: 6, windowMs: 60_000 },
79
+ // Chat messages a person sends to connected agents (src/hosted/chat-routes.js).
80
+ chatSend: { limit: 20, windowMs: 60_000 },
71
81
  push: { limit: 20, windowMs: 60 * 60_000 },
72
82
  // Invite emails per workspace (the link can always be copied instead).
73
83
  inviteEmail: { limit: 20, windowMs: 60 * 60_000 },
@@ -93,4 +103,8 @@ export const LIMITS = {
93
103
  deviceLookup: { limit: 10, windowMs: 60_000 },
94
104
  // Workspace exports per person (each is a zip of everything).
95
105
  export: { limit: 5, windowMs: 60 * 60_000 },
106
+ // Usage, activity and access review downloads, per person.
107
+ usageExport: { limit: 30, windowMs: 60 * 60_000 },
108
+ // Activity searches and filters by agent or project (they read the log entry by entry), per person.
109
+ activitySearch: { limit: 60, windowMs: 60_000 },
96
110
  }