@rubytech/create-maxy-code 0.1.307 → 0.1.308

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 (77) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/lib/admin-access-password/__tests__/index.test.ts +114 -0
  3. package/payload/platform/lib/admin-access-password/dist/index.d.ts +40 -0
  4. package/payload/platform/lib/admin-access-password/dist/index.d.ts.map +1 -0
  5. package/payload/platform/lib/admin-access-password/dist/index.js +172 -0
  6. package/payload/platform/lib/admin-access-password/dist/index.js.map +1 -0
  7. package/payload/platform/lib/admin-access-password/src/index.ts +152 -0
  8. package/payload/platform/lib/admin-access-password/tsconfig.json +8 -0
  9. package/payload/platform/lib/models/dist/index.d.ts +6 -0
  10. package/payload/platform/lib/models/dist/index.d.ts.map +1 -1
  11. package/payload/platform/lib/models/dist/index.js +10 -1
  12. package/payload/platform/lib/models/dist/index.js.map +1 -1
  13. package/payload/platform/lib/models/src/index.ts +9 -0
  14. package/payload/platform/package.json +2 -2
  15. package/payload/platform/plugins/admin/PLUGIN.md +1 -0
  16. package/payload/platform/plugins/admin/mcp/dist/index.js +60 -19
  17. package/payload/platform/plugins/admin/mcp/dist/index.js.map +1 -1
  18. package/payload/platform/plugins/admin/skills/admin-user-management/SKILL.md +8 -2
  19. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +3 -3
  20. package/payload/platform/plugins/docs/references/admin-ui.md +1 -1
  21. package/payload/platform/plugins/docs/references/internals.md +1 -1
  22. package/payload/platform/scripts/check-no-esm-require.mjs +4 -0
  23. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.d.ts.map +1 -1
  24. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js +1 -0
  25. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
  26. package/payload/platform/services/claude-session-manager/dist/http-server.d.ts +3 -0
  27. package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
  28. package/payload/platform/services/claude-session-manager/dist/http-server.js +182 -1
  29. package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
  30. package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts +12 -0
  31. package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
  32. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +52 -1
  33. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
  34. package/payload/platform/services/claude-session-manager/dist/session-sidecar.d.ts.map +1 -1
  35. package/payload/platform/services/claude-session-manager/dist/session-sidecar.js +9 -3
  36. package/payload/platform/services/claude-session-manager/dist/session-sidecar.js.map +1 -1
  37. package/payload/platform/services/claude-session-manager/dist/webchat-channel-mcp.d.ts +8 -0
  38. package/payload/platform/services/claude-session-manager/dist/webchat-channel-mcp.d.ts.map +1 -1
  39. package/payload/platform/services/claude-session-manager/dist/webchat-channel-mcp.js +7 -0
  40. package/payload/platform/services/claude-session-manager/dist/webchat-channel-mcp.js.map +1 -1
  41. package/payload/platform/services/webchat-channel/dist/instructions.d.ts +8 -0
  42. package/payload/platform/services/webchat-channel/dist/instructions.d.ts.map +1 -0
  43. package/payload/platform/services/webchat-channel/dist/instructions.js +44 -0
  44. package/payload/platform/services/webchat-channel/dist/instructions.js.map +1 -0
  45. package/payload/platform/services/webchat-channel/dist/server.d.ts.map +1 -1
  46. package/payload/platform/services/webchat-channel/dist/server.js +11 -18
  47. package/payload/platform/services/webchat-channel/dist/server.js.map +1 -1
  48. package/payload/server/{chunk-4QFPGAUZ.js → chunk-FBGIHWWM.js} +170 -82
  49. package/payload/server/maxy-edge.js +1 -1
  50. package/payload/server/public/assets/{AdminLoginScreens-BsC-EwAn.js → AdminLoginScreens-BZIA9Z6o.js} +1 -1
  51. package/payload/server/public/assets/AdminShell-iazLHsk7.js +1 -0
  52. package/payload/server/public/assets/{Checkbox-DoPOlZTV.js → Checkbox-8elc7oXU.js} +1 -1
  53. package/payload/server/public/assets/{admin-DSwmdCKp.js → admin-BEx6o3fa.js} +1 -1
  54. package/payload/server/public/assets/{audio-attachment-mime-BA10IzqQ.js → audio-attachment-mime-DzbKNqbH.js} +1 -1
  55. package/payload/server/public/assets/{brand-C001cin3.css → brand-CmMZe4RK.css} +1 -1
  56. package/payload/server/public/assets/{browser-BKR1eJJb.js → browser-D16sPVkI.js} +1 -1
  57. package/payload/server/public/assets/chat-x4PnXhkd.js +1 -0
  58. package/payload/server/public/assets/{data-CuVmW1WN.js → data-DqG45sq0.js} +1 -1
  59. package/payload/server/public/assets/{file-download-4_hQmMwU.js → file-download-BvGS7Qmi.js} +1 -1
  60. package/payload/server/public/assets/{graph-D29p1FJH.js → graph-DKSjcpmR.js} +1 -1
  61. package/payload/server/public/assets/{graph-labels-DF3QVHkH.js → graph-labels-CVWPQgBV.js} +1 -1
  62. package/payload/server/public/assets/{operator-CQRaBNN7.js → operator-Cnzbhdh2.js} +1 -1
  63. package/payload/server/public/assets/page-CH8JQkQN.js +1 -0
  64. package/payload/server/public/assets/{public-B7BQwWpP.js → public-CA90VhI9.js} +1 -1
  65. package/payload/server/public/assets/{useSelectionMode-ghXuZicl.js → useSelectionMode-FIodJKzS.js} +1 -1
  66. package/payload/server/public/browser.html +6 -6
  67. package/payload/server/public/chat.html +8 -8
  68. package/payload/server/public/data.html +5 -5
  69. package/payload/server/public/graph.html +8 -8
  70. package/payload/server/public/index.html +9 -9
  71. package/payload/server/public/operator.html +10 -10
  72. package/payload/server/public/public.html +6 -6
  73. package/payload/server/server.js +3980 -3516
  74. package/payload/server/public/assets/AdminShell-CiKKN22G.js +0 -1
  75. package/payload/server/public/assets/chat-DZXNRiy-.js +0 -1
  76. package/payload/server/public/assets/page-Dz2F3QtB.js +0 -1
  77. /package/payload/server/public/assets/{brand-BaRMO3mZ.js → brand-Dh5UlVO2.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: platform-architecture
3
3
  description: Use when grounding any documented-surface claim about what Maxy ships — plugins, skills, specialists, install/deploy flows, internals. This is the install catalogue, not evidence of what is enabled on the current account. For install state on this account, call `capabilities-here`; for documented surface, cite the `Source:` URL inline.
4
- content-hash: sha256:24fdd4305e1a509669173cd92e915199878082f69b436987e0a8e89f0cf793c9
4
+ content-hash: sha256:3dc18de6b756569b69f9991344abc2af34919802f4e632a815f2250b8a11f786
5
5
  brand: maxy-code
6
6
  product-name: Maxy
7
7
  ---
@@ -2288,7 +2288,7 @@ either is a regression.
2288
2288
 
2289
2289
  **`/chat` Claude-desktop transcript presentation.** The admin webchat keeps the shared `Transcript` shell (stream, follow-tail) but injects a /chat-only item renderer via the component's optional `renderItems` prop: `renderChatTimeline` in `app/chat/transcript-render.tsx`. Presentation: operator turns render as a right-aligned grey bubble with only the message text (no label, no per-turn time); all agent output renders as plain prose (the reply-document filename line stays, as prose); a maximal consecutive run of `tool-call`/`tool-result` turns renders as one collapsed grey one-liner ("Used N tools ›") whose expansion shows every call and result payload — a lone call still gets the one-liner, and prose or a directive row ends a run. The WhatsApp reader (`/whatsapp`) omits the prop and keeps the default `renderTimeline`, so its rendering is unchanged; both presentations are test-pinned (`app/whatsapp/__tests__/Transcript-*.test.tsx` unmodified, `app/chat/__tests__/transcript-render.test.tsx` new).
2290
2290
 
2291
- **maxy title for public sessions.** A `role=public` webchat spawn never produces a useful Claude Code `ai-title` (an anonymous one-line visitor turn), so every public row would otherwise read identically. The webchat route (`chat.ts`) composes a deterministic title — `Web · <senderId[:8]>[ · <personId>] · <UTC YYYY-MM-DD HH:mm>` (personId present only for gated visitors) — and threads it through the bridge (`dispatchOnce` → `managerSpawn`) to the manager `POST /spawn` body as `name`. `/spawn` validates it with `validateUserTitle` and, for `role=public` only, writes it into `UserTitleStore` so it occupies the operator-rename tier and wins over `ai-title`. Admin (`/rc-spawn`) and WhatsApp titling are unchanged. Observability: every public spawn logs `[spawn] role=public … title="…"` (or `title=missing`); the manager's row builder emits `[public-title] sessionId=… unexpected titleSource=<ai|null>` on the next list read for any public row that did not resolve from the user tier.
2291
+ **maxy title for public sessions.** A `role=public` webchat spawn never produces a useful Claude Code `ai-title` (an anonymous one-line visitor turn), so every public row would otherwise read identically. The webchat route (`chat.ts`) composes a deterministic title — `Web · <senderId[:8]>[ · <personId>] · <UTC YYYY-MM-DD HH:mm>` (personId present only for gated visitors) — and threads it through the native webchat gateway's public spawn (`handleInbound` → `buildPublicWebchatSpawnRequest` → `managerSpawn`) to the manager `POST /public-spawn` body as `name`. `/spawn` validates it with `validateUserTitle` and, for `role=public` only, writes it into `UserTitleStore` so it occupies the operator-rename tier and wins over `ai-title`. Admin (`/rc-spawn`) and WhatsApp titling are unchanged. Observability: every public spawn logs `[spawn] role=public … title="…"` (or `title=missing`); the manager's row builder emits `[public-title] sessionId=… unexpected titleSource=<ai|null>` on the next list read for any public row that did not resolve from the user tier.
2292
2292
 
2293
2293
  ### Graph
2294
2294
 
@@ -3273,7 +3273,7 @@ The `brand-excluded` branch closes the recurring crash-restart loop on brands th
3273
3273
 
3274
3274
  **Per-spawn signals (server.log).** Every spawn emits `pty-spawn-mcp-config servers=<N> tools=<M> bytes=<B> path=<…>` once, plus one `pty-spawn-agents-dir role=<admin|public> path=<…>` per added directory. Specialist spawns additionally emit `pty-spawn-allowlist specialist=<name> count=<N> stripped=<S> sourced-from=agent-frontmatter` where `stripped` is the count of brand-excluded tool names removed before argv emission. The diagnostic one-liner is `grep -E 'pty-spawn-mcp-config|pty-spawn-agents-dir|pty-spawn-allowlist|mcp-config-allowlist-coverage|specialist-tool-strip|boot-failed reason=' ~/.<brand>/logs/server.log | tail -50`.
3275
3275
 
3276
- **Channel follower cold-start retry.** Each channel PTY session (webchat, whatsapp, email) has one JSONL follower ([`platform/ui/app/lib/channel-pty-bridge/follower.ts`](../../../ui/app/lib/channel-pty-bridge/follower.ts)) reading `GET /<sessionId>/log?follow=1` and fanning each assistant `end_turn` out to the awaiting `dispatchOnce`. A freshly-spawned PTY has no JSONL on disk until claude flushes its first line; during that window the manager answers `202 {pending:true}`. The follower retries every `CHANNEL_PTY_FOLLOWER_RETRY_MS` (default 1000) until a 200 stream opens or `CHANNEL_PTY_FOLLOWER_PENDING_MAX_MS` elapses. The follower is shared across channels, so that window defaults to the longest channel turn window (whatsapp's `WHATSAPP_PTY_TURN_TIMEOUT_MS`, 300000 — longer than webchat's 120000) so it never abandons a turn the caller is still awaiting. Because public sessions idle-reap, every webchat greeting is the first turn of a fresh spawn and crosses this window — before the retry, a 202 (which satisfies `res.ok`) was consumed as a single non-event line, the stream ended, and the follower died silently, timing out every public turn. The lifecycle is greppable as `follower-connect status=<code>` → `follower-retry attempt=N reason=pending` → `follower-open` → `outbound bytes=N`; `follower-give-up reason=pending-timeout` marks the JSONL never appearing. A `reject reason=turn-timeout` with no preceding `follower-open` (and no manager `log-follow-open`) for that sessionId is the signature. See `.docs/gated-public-agents.md` "Webchat turn lifecycle" for the full tag list.
3276
+ **Channel follower cold-start retry.** Each `dispatchOnce`-based channel PTY session has one JSONL follower ([`platform/ui/app/lib/channel-pty-bridge/follower.ts`](../../../ui/app/lib/channel-pty-bridge/follower.ts)) reading `GET /<sessionId>/log?follow=1` and fanning each assistant `end_turn` out to the awaiting `dispatchOnce`. (WhatsApp and public webchat have since migrated to the native event channel — an MCP notification in, a `reply`-tool call out — and no longer use this follower; the remaining `dispatchOnce` channels are email and telegram. The webchat detail below is the historical record of the bug the retry fixed.) A freshly-spawned PTY has no JSONL on disk until claude flushes its first line; during that window the manager answers `202 {pending:true}`. The follower retries every `CHANNEL_PTY_FOLLOWER_RETRY_MS` (default 1000) until a 200 stream opens or `CHANNEL_PTY_FOLLOWER_PENDING_MAX_MS` elapses. The follower is shared across channels, so that window defaults to the longest channel turn window (whatsapp's `WHATSAPP_PTY_TURN_TIMEOUT_MS`, 300000 — longer than webchat's 120000) so it never abandons a turn the caller is still awaiting. Because public sessions idle-reap, every webchat greeting is the first turn of a fresh spawn and crosses this window — before the retry, a 202 (which satisfies `res.ok`) was consumed as a single non-event line, the stream ended, and the follower died silently, timing out every public turn. The lifecycle is greppable as `follower-connect status=<code>` → `follower-retry attempt=N reason=pending` → `follower-open` → `outbound bytes=N`; `follower-give-up reason=pending-timeout` marks the JSONL never appearing. A `reject reason=turn-timeout` with no preceding `follower-open` (and no manager `log-follow-open`) for that sessionId is the signature. See `.docs/gated-public-agents.md` "Webchat turn lifecycle" for the full tag list.
3277
3277
 
3278
3278
  **Brand-process start counter.** `platform/ui/server-init.cjs` increments a persistent counter at `/tmp/server-init-<accountId>-restart.count` on every fresh start and emits `[server-init] start count=<N> account=<accountId> counter-path=<…>` to `server.log`. /tmp clears on reboot, so a clean reboot starts the count fresh; any value `>1` between operator-observed reboots means the brand process (driven by its `Requires=<brand>-claude-session-manager.service` clause) is restarting. The diagnostic one-liner is `grep '\[server-init\] start' ~/.<brand>/logs/server.log | tail -5` — the trailing `count=` value is the loop depth without counting SIGTERMs.
3279
3279
 
@@ -57,7 +57,7 @@ either is a regression.
57
57
 
58
58
  **`/chat` Claude-desktop transcript presentation.** The admin webchat keeps the shared `Transcript` shell (stream, follow-tail) but injects a /chat-only item renderer via the component's optional `renderItems` prop: `renderChatTimeline` in `app/chat/transcript-render.tsx`. Presentation: operator turns render as a right-aligned grey bubble with only the message text (no label, no per-turn time); all agent output renders as plain prose (the reply-document filename line stays, as prose); a maximal consecutive run of `tool-call`/`tool-result` turns renders as one collapsed grey one-liner ("Used N tools ›") whose expansion shows every call and result payload — a lone call still gets the one-liner, and prose or a directive row ends a run. The WhatsApp reader (`/whatsapp`) omits the prop and keeps the default `renderTimeline`, so its rendering is unchanged; both presentations are test-pinned (`app/whatsapp/__tests__/Transcript-*.test.tsx` unmodified, `app/chat/__tests__/transcript-render.test.tsx` new).
59
59
 
60
- **maxy title for public sessions.** A `role=public` webchat spawn never produces a useful Claude Code `ai-title` (an anonymous one-line visitor turn), so every public row would otherwise read identically. The webchat route (`chat.ts`) composes a deterministic title — `Web · <senderId[:8]>[ · <personId>] · <UTC YYYY-MM-DD HH:mm>` (personId present only for gated visitors) — and threads it through the bridge (`dispatchOnce` → `managerSpawn`) to the manager `POST /spawn` body as `name`. `/spawn` validates it with `validateUserTitle` and, for `role=public` only, writes it into `UserTitleStore` so it occupies the operator-rename tier and wins over `ai-title`. Admin (`/rc-spawn`) and WhatsApp titling are unchanged. Observability: every public spawn logs `[spawn] role=public … title="…"` (or `title=missing`); the manager's row builder emits `[public-title] sessionId=… unexpected titleSource=<ai|null>` on the next list read for any public row that did not resolve from the user tier.
60
+ **maxy title for public sessions.** A `role=public` webchat spawn never produces a useful Claude Code `ai-title` (an anonymous one-line visitor turn), so every public row would otherwise read identically. The webchat route (`chat.ts`) composes a deterministic title — `Web · <senderId[:8]>[ · <personId>] · <UTC YYYY-MM-DD HH:mm>` (personId present only for gated visitors) — and threads it through the native webchat gateway's public spawn (`handleInbound` → `buildPublicWebchatSpawnRequest` → `managerSpawn`) to the manager `POST /public-spawn` body as `name`. `/spawn` validates it with `validateUserTitle` and, for `role=public` only, writes it into `UserTitleStore` so it occupies the operator-rename tier and wins over `ai-title`. Admin (`/rc-spawn`) and WhatsApp titling are unchanged. Observability: every public spawn logs `[spawn] role=public … title="…"` (or `title=missing`); the manager's row builder emits `[public-title] sessionId=… unexpected titleSource=<ai|null>` on the next list read for any public row that did not resolve from the user tier.
61
61
 
62
62
  ### Graph
63
63
 
@@ -477,7 +477,7 @@ The `brand-excluded` branch closes the recurring crash-restart loop on brands th
477
477
 
478
478
  **Per-spawn signals (server.log).** Every spawn emits `pty-spawn-mcp-config servers=<N> tools=<M> bytes=<B> path=<…>` once, plus one `pty-spawn-agents-dir role=<admin|public> path=<…>` per added directory. Specialist spawns additionally emit `pty-spawn-allowlist specialist=<name> count=<N> stripped=<S> sourced-from=agent-frontmatter` where `stripped` is the count of brand-excluded tool names removed before argv emission. The diagnostic one-liner is `grep -E 'pty-spawn-mcp-config|pty-spawn-agents-dir|pty-spawn-allowlist|mcp-config-allowlist-coverage|specialist-tool-strip|boot-failed reason=' ~/.<brand>/logs/server.log | tail -50`.
479
479
 
480
- **Channel follower cold-start retry.** Each channel PTY session (webchat, whatsapp, email) has one JSONL follower ([`platform/ui/app/lib/channel-pty-bridge/follower.ts`](../../../ui/app/lib/channel-pty-bridge/follower.ts)) reading `GET /<sessionId>/log?follow=1` and fanning each assistant `end_turn` out to the awaiting `dispatchOnce`. A freshly-spawned PTY has no JSONL on disk until claude flushes its first line; during that window the manager answers `202 {pending:true}`. The follower retries every `CHANNEL_PTY_FOLLOWER_RETRY_MS` (default 1000) until a 200 stream opens or `CHANNEL_PTY_FOLLOWER_PENDING_MAX_MS` elapses. The follower is shared across channels, so that window defaults to the longest channel turn window (whatsapp's `WHATSAPP_PTY_TURN_TIMEOUT_MS`, 300000 — longer than webchat's 120000) so it never abandons a turn the caller is still awaiting. Because public sessions idle-reap, every webchat greeting is the first turn of a fresh spawn and crosses this window — before the retry, a 202 (which satisfies `res.ok`) was consumed as a single non-event line, the stream ended, and the follower died silently, timing out every public turn. The lifecycle is greppable as `follower-connect status=<code>` → `follower-retry attempt=N reason=pending` → `follower-open` → `outbound bytes=N`; `follower-give-up reason=pending-timeout` marks the JSONL never appearing. A `reject reason=turn-timeout` with no preceding `follower-open` (and no manager `log-follow-open`) for that sessionId is the signature. See `.docs/gated-public-agents.md` "Webchat turn lifecycle" for the full tag list.
480
+ **Channel follower cold-start retry.** Each `dispatchOnce`-based channel PTY session has one JSONL follower ([`platform/ui/app/lib/channel-pty-bridge/follower.ts`](../../../ui/app/lib/channel-pty-bridge/follower.ts)) reading `GET /<sessionId>/log?follow=1` and fanning each assistant `end_turn` out to the awaiting `dispatchOnce`. (WhatsApp and public webchat have since migrated to the native event channel — an MCP notification in, a `reply`-tool call out — and no longer use this follower; the remaining `dispatchOnce` channels are email and telegram. The webchat detail below is the historical record of the bug the retry fixed.) A freshly-spawned PTY has no JSONL on disk until claude flushes its first line; during that window the manager answers `202 {pending:true}`. The follower retries every `CHANNEL_PTY_FOLLOWER_RETRY_MS` (default 1000) until a 200 stream opens or `CHANNEL_PTY_FOLLOWER_PENDING_MAX_MS` elapses. The follower is shared across channels, so that window defaults to the longest channel turn window (whatsapp's `WHATSAPP_PTY_TURN_TIMEOUT_MS`, 300000 — longer than webchat's 120000) so it never abandons a turn the caller is still awaiting. Because public sessions idle-reap, every webchat greeting is the first turn of a fresh spawn and crosses this window — before the retry, a 202 (which satisfies `res.ok`) was consumed as a single non-event line, the stream ended, and the follower died silently, timing out every public turn. The lifecycle is greppable as `follower-connect status=<code>` → `follower-retry attempt=N reason=pending` → `follower-open` → `outbound bytes=N`; `follower-give-up reason=pending-timeout` marks the JSONL never appearing. A `reject reason=turn-timeout` with no preceding `follower-open` (and no manager `log-follow-open`) for that sessionId is the signature. See `.docs/gated-public-agents.md` "Webchat turn lifecycle" for the full tag list.
481
481
 
482
482
  **Brand-process start counter.** `platform/ui/server-init.cjs` increments a persistent counter at `/tmp/server-init-<accountId>-restart.count` on every fresh start and emits `[server-init] start count=<N> account=<accountId> counter-path=<…>` to `server.log`. /tmp clears on reboot, so a clean reboot starts the count fresh; any value `>1` between operator-observed reboots means the brand process (driven by its `Requires=<brand>-claude-session-manager.service` clause) is restarting. The diagnostic one-liner is `grep '\[server-init\] start' ~/.<brand>/logs/server.log | tail -5` — the trailing `count=` value is the loop depth without counting SIGTERMs.
483
483
 
@@ -55,6 +55,10 @@ const ALLOWLIST = new Set([
55
55
  // before the module's `../paths` mock fires, to redirect MAXY_DIR off the
56
56
  // operator's real home config.
57
57
  'platform/ui/app/lib/__tests__/operator-domains.test.ts',
58
+ // Same vi.hoisted pattern: the per-admin remote-auth test builds a tmpdir
59
+ // before the `../paths` mock fires, to point USERS_FILE/REMOTE_PASSWORD_FILE
60
+ // at a temp dir off the operator's real home config.
61
+ 'platform/ui/app/lib/__tests__/remote-auth-per-admin.test.ts',
58
62
  ])
59
63
 
60
64
  const REQUIRE_CALL_RE = /\brequire\s*\(/
@@ -1 +1 @@
1
- {"version":3,"file":"canonical-tool-names.generated.d.ts","sourceRoot":"","sources":["../src/canonical-tool-names.generated.ts"],"names":[],"mappings":"AAQA,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAiB7C,CAAA;AAED,gEAAgE;AAChE,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAiLtD,CAAA"}
1
+ {"version":3,"file":"canonical-tool-names.generated.d.ts","sourceRoot":"","sources":["../src/canonical-tool-names.generated.ts"],"names":[],"mappings":"AAQA,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAiB7C,CAAA;AAED,gEAAgE;AAChE,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAkLtD,CAAA"}
@@ -45,6 +45,7 @@ export const CANONICAL_MAXY_TOOL_NAMES = [
45
45
  "mcp__plugin_admin_admin__public-hostname",
46
46
  "mcp__plugin_admin_admin__publish-site",
47
47
  "mcp__plugin_admin_admin__qr-generate",
48
+ "mcp__plugin_admin_admin__remote-auth-revoke-password",
48
49
  "mcp__plugin_admin_admin__remote-auth-set-password",
49
50
  "mcp__plugin_admin_admin__remote-auth-status",
50
51
  "mcp__plugin_admin_admin__session-reset",
@@ -1 +1 @@
1
- {"version":3,"file":"canonical-tool-names.generated.js","sourceRoot":"","sources":["../src/canonical-tool-names.generated.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,kEAAkE;AAClE,yDAAyD;AACzD,kFAAkF;AAClF,EAAE;AACF,yEAAyE;AACzE,6DAA6D;AAE7D,+EAA+E;AAC/E,MAAM,CAAC,MAAM,gBAAgB,GAAsB;IACjD,OAAO;IACP,KAAK;IACL,SAAS;IACT,UAAU;IACV,OAAO;IACP,OAAO;IACP,cAAc;IACd,QAAQ;IACR,SAAS;IACT,WAAW;IACX,YAAY;IACZ,UAAU;IACV,SAAS;IACT,UAAU;IACV,MAAM;IACN,WAAW;CACZ,CAAA;AAED,gEAAgE;AAChE,MAAM,CAAC,MAAM,yBAAyB,GAAsB;IAC1D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C;IACpC,oCAAoC;IACpC,kDAAkD;IAClD,kDAAkD;IAClD,mDAAmD;IACnD,+CAA+C;IAC/C,gDAAgD;IAChD,gDAAgD;IAChD,kDAAkD;IAClD,oDAAoD;CACrD,CAAA"}
1
+ {"version":3,"file":"canonical-tool-names.generated.js","sourceRoot":"","sources":["../src/canonical-tool-names.generated.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,kEAAkE;AAClE,yDAAyD;AACzD,kFAAkF;AAClF,EAAE;AACF,yEAAyE;AACzE,6DAA6D;AAE7D,+EAA+E;AAC/E,MAAM,CAAC,MAAM,gBAAgB,GAAsB;IACjD,OAAO;IACP,KAAK;IACL,SAAS;IACT,UAAU;IACV,OAAO;IACP,OAAO;IACP,cAAc;IACd,QAAQ;IACR,SAAS;IACT,WAAW;IACX,YAAY;IACZ,UAAU;IACV,SAAS;IACT,UAAU;IACV,MAAM;IACN,WAAW;CACZ,CAAA;AAED,gEAAgE;AAChE,MAAM,CAAC,MAAM,yBAAyB,GAAsB;IAC1D,yCAAyC;IACzC,yCAAyC;IACzC,yCAAyC;IACzC,sCAAsC;IACtC,yCAAyC;IACzC,wCAAwC;IACxC,oCAAoC;IACpC,qCAAqC;IACrC,uCAAuC;IACvC,2CAA2C;IAC3C,4CAA4C;IAC5C,qCAAqC;IACrC,yCAAyC;IACzC,4CAA4C;IAC5C,oCAAoC;IACpC,sCAAsC;IACtC,0CAA0C;IAC1C,uCAAuC;IACvC,sCAAsC;IACtC,sDAAsD;IACtD,mDAAmD;IACnD,6CAA6C;IAC7C,wCAAwC;IACxC,yCAAyC;IACzC,qCAAqC;IACrC,uCAAuC;IACvC,sCAAsC;IACtC,wCAAwC;IACxC,+BAA+B;IAC/B,qCAAqC;IACrC,sCAAsC;IACtC,yCAAyC;IACzC,4CAA4C;IAC5C,uDAAuD;IACvD,+CAA+C;IAC/C,2CAA2C;IAC3C,gDAAgD;IAChD,oDAAoD;IACpD,4CAA4C;IAC5C,+CAA+C;IAC/C,+CAA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;IACvD,qDAAqD;IACrD,oDAAoD;IACpD,oDAAoD;IACpD,gDAAgD;IAChD,kDAAkD;IAClD,mDAAmD;IACnD,iDAAiD;IACjD,sDAAsD;IACtD,uDAAuD;IACvD,yDAAyD;IACzD,oDAAoD;IACpD,mDAAmD;IACnD,wDAAwD;IACxD,iDAAiD;IACjD,wDAAwD;IACxD,kDAAkD;IAClD,oDAAoD;IACpD,iDAAiD;IACjD,wCAAwC;IACxC,gDAAgD;IAChD,0DAA0D;IAC1D,sCAAsC;IACtC,kDAAkD;IAClD,gDAAgD;IAChD,kEAAkE;IAClE,uDAAuD;IACvD,oDAAoD;IACpD,oDAAoD;IACpD,qDAAqD;IACrD,oDAAoD;IACpD,kDAAkD;IAClD,gDAAgD;IAChD,yCAAyC;IACzC,uCAAuC;IACvC,oCAAoC;IACpC,qCAAqC;IACrC,uCAAuC;IACvC,qCAAqC;IACrC,qCAAqC;IACrC,sCAAsC;IACtC,oCAAoC;IACpC,iCAAiC;IACjC,kCAAkC;IAClC,mCAAmC;IACnC,oCAAoC;IACpC,oCAAoC;IACpC,kDAAkD;IAClD,kDAAkD;IAClD,mDAAmD;IACnD,+CAA+C;IAC/C,gDAAgD;IAChD,gDAAgD;IAChD,kDAAkD;IAClD,oDAAoD;CACrD,CAAA"}
@@ -35,6 +35,9 @@ export interface HttpDeps extends Omit<SpawnDeps, 'onSessionReady' | 'watcher'>
35
35
  * short value to exercise the bind-timeout response without a 60s wait. */
36
36
  rcSpawnUrlWaitMs?: number;
37
37
  }
38
+ export declare function forkArgvSegment(fromSessionId: string, newSessionId: string, model: string): string[];
39
+ export declare function formatReseatLine(fromModel: string | null, toModel: string, oldSessionId: string, newSessionId: string, observed: string | null): string;
40
+ export declare function firstPostArmAssistantModel(lines: string[], armTimeMs: number): string | null;
38
41
  /** Task 189 — Hono instance with the test-only fan-out trigger attached.
39
42
  * The vitest fixture for the `/events` url-capture re-emit drives this
40
43
  * directly (no real PTY spawn in the suite); production callers route
@@ -1 +1 @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EAAE,MAAM,CAAA;CAC1B;AAwGD,wBAAgB,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAEpG;AAMD,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,GACtB,MAAM,CAER;AAkCD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAe5F;AAwJD;;;kEAGkE;AAClE,MAAM,MAAM,OAAO,GAAG,IAAI,GAAG;IAC3B,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACpD;;;+CAG2C;IAC3C,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAChD,CAAA;AAmBD,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CA+lEpD"}
@@ -182,6 +182,111 @@ function resolveRow(watcher, id) {
182
182
  // auto-archive` lines cover the lifecycle.
183
183
  const END_TURN_SIGNATURE = '"stop_reason":"end_turn"';
184
184
  const AUTO_ARCHIVE_SPECIALIST = 'database-operator';
185
+ // Task 876 — re-seat (operator-initiated model change for an existing admin
186
+ // webchat session). Fork the source onto a fresh session born on the chosen
187
+ // model: `--resume <old>` seeds history, `--fork-session` mints into the
188
+ // pre-supplied `--session-id <new>`, `--model` pins the fork's first turn.
189
+ // Pure so the argv shape is unit-tested without a spawn.
190
+ export function forkArgvSegment(fromSessionId, newSessionId, model) {
191
+ return ['--resume', fromSessionId, '--fork-session', '--session-id', newSessionId, '--model', model];
192
+ }
193
+ // Task 876 — the re-seat post-condition line. Emitted ONLY after a real
194
+ // assistant turn on the fork is read (intention is not logged, per the
195
+ // observability contract): a re-seat that silently lands on the wrong model
196
+ // is visible rather than reported as success. Correlation key: old→new id.
197
+ export function formatReseatLine(fromModel, toModel, oldSessionId, newSessionId, observed) {
198
+ return `[webchat:reseat] op=reseat from-model=${fromModel ?? 'unknown'} to-model=${toModel} old-session=${oldSessionId} new-session=${newSessionId} first-turn-model=${observed ?? 'unknown'}`;
199
+ }
200
+ // Task 876 — read the most-recent real (non-synthetic) assistant model from a
201
+ // session's JSONL. The source's last answered model is the re-seat's
202
+ // from-model; a stranded session whose only tail is a synthetic error yields
203
+ // null ('unknown'). Bottom-up scan: the latest answered turn wins.
204
+ function lastRealAssistantModel(jsonlPath) {
205
+ let lines;
206
+ try {
207
+ lines = readFileSync(jsonlPath, 'utf8').split('\n').filter((l) => l.length > 0);
208
+ }
209
+ catch {
210
+ return null;
211
+ }
212
+ for (let i = lines.length - 1; i >= 0; i--) {
213
+ try {
214
+ const rec = JSON.parse(lines[i]);
215
+ if (rec.type === 'assistant' && typeof rec.message?.model === 'string' && rec.message.model !== '<synthetic>') {
216
+ return rec.message.model;
217
+ }
218
+ }
219
+ catch {
220
+ /* a mid-write line — skip it */
221
+ }
222
+ }
223
+ return null;
224
+ }
225
+ // Task 876 — the FORK's first post-reseat assistant model. The fork JSONL
226
+ // opens with the copied history, and `--fork-session` PRESERVES each copied
227
+ // turn's original `timestamp` (verified: only `sessionId` is rewritten), so a
228
+ // post-arm timestamp cleanly discriminates the operator's first new turn from
229
+ // the copied history — independent of WHEN the copy flushes to disk (a
230
+ // line-count baseline would race the flush). Returns the first non-synthetic
231
+ // assistant model whose turn timestamp is strictly after `armTimeMs`, or null
232
+ // when no such turn has landed yet.
233
+ export function firstPostArmAssistantModel(lines, armTimeMs) {
234
+ for (const line of lines) {
235
+ if (line.length === 0)
236
+ continue;
237
+ try {
238
+ const rec = JSON.parse(line);
239
+ if (rec.type !== 'assistant')
240
+ continue;
241
+ const model = rec.message?.model;
242
+ if (typeof model !== 'string' || model === '<synthetic>')
243
+ continue;
244
+ const ts = typeof rec.timestamp === 'string' ? Date.parse(rec.timestamp) : NaN;
245
+ if (Number.isFinite(ts) && ts > armTimeMs)
246
+ return model;
247
+ }
248
+ catch {
249
+ /* a mid-write line — skip it */
250
+ }
251
+ }
252
+ return null;
253
+ }
254
+ // Task 876 — arm a one-shot reader on the FORK's first post-reseat assistant
255
+ // turn. `armTimeMs` is captured here (after bind); only assistant turns
256
+ // timestamped after it are read, so the copied history (old timestamps) is
257
+ // skipped however late it flushes. Emits the correlation line once a real
258
+ // model is read, then detaches; cleaned up on PTY exit.
259
+ function attachReseatObserve(deps, newSessionId, ctx) {
260
+ let done = false;
261
+ const jsonlPath = jsonlPathForSessionId(deps.spawnCwd, newSessionId);
262
+ const armTimeMs = Date.now();
263
+ function tryEmit() {
264
+ if (done)
265
+ return;
266
+ let lines;
267
+ try {
268
+ lines = readFileSync(jsonlPath, 'utf8').split('\n');
269
+ }
270
+ catch {
271
+ return;
272
+ }
273
+ const observed = firstPostArmAssistantModel(lines, armTimeMs);
274
+ if (observed === null)
275
+ return;
276
+ done = true;
277
+ deps.logger(formatReseatLine(ctx.fromModel, ctx.toModel, ctx.oldSessionId, newSessionId, observed));
278
+ }
279
+ const unsubscribe = deps.watcher.subscribe((event) => {
280
+ if (done)
281
+ return;
282
+ if (event.sessionId !== newSessionId)
283
+ return;
284
+ if (event.source !== 'jsonl')
285
+ return;
286
+ tryEmit();
287
+ });
288
+ onPtyExit(newSessionId, () => unsubscribe());
289
+ }
185
290
  // One-shot auto-close: once the session's JSONL contains an assistant
186
291
  // message with `stop_reason === "end_turn"`, stop the PTY so the session
187
292
  // closes after its single turn. Shared by the public-spawn database-operator
@@ -632,6 +737,17 @@ export function buildHttpApp(deps) {
632
737
  const personId = typeof body.personId === 'string' && body.personId.length > 0 && body.personId.length <= 128
633
738
  ? body.personId
634
739
  : undefined;
740
+ // Task 756 — the per-conversation webchat native channel for a public
741
+ // spawn. Shape-validated here (all three fields are non-empty strings, the
742
+ // gateway is loopback http) before it reaches the spawn, which composes it
743
+ // under the public ringfence (deny-all + reply-only allow + strict mcp).
744
+ const wc = body.webchatChannel;
745
+ const webchatChannel = wc && typeof wc === 'object'
746
+ && typeof wc.key === 'string' && wc.key.length > 0
747
+ && typeof wc.gatewayUrl === 'string' && wc.gatewayUrl.startsWith('http')
748
+ && typeof wc.serverPath === 'string' && wc.serverPath.startsWith('/')
749
+ ? { key: wc.key, gatewayUrl: wc.gatewayUrl, serverPath: wc.serverPath }
750
+ : undefined;
635
751
  // Task 624 — maxy-composed public-session title. Validated by the same
636
752
  // validateUserTitle the /:sessionId/rename route uses; persisted only for
637
753
  // role=public after the sessionId is minted. An invalid/absent name leaves
@@ -708,6 +824,7 @@ export function buildHttpApp(deps) {
708
824
  conversationNodeId,
709
825
  sliceToken,
710
826
  personId,
827
+ webchatChannel,
711
828
  });
712
829
  if (!result.ok) {
713
830
  if ('rejected' in result) {
@@ -1618,6 +1735,14 @@ export function buildHttpApp(deps) {
1618
1735
  }
1619
1736
  const sessionId = typeof body.sessionId === 'string' && body.sessionId.length > 0 ? body.sessionId : null;
1620
1737
  const name = typeof body.name === 'string' && body.name.length > 0 ? body.name : null;
1738
+ // Task 876 — re-seat fork. `forkFromSessionId` is the source whose history
1739
+ // is copied; `sessionId` is the caller-pre-minted fork target; `model` is
1740
+ // the chosen model. The UI allowlist (isSelectableModel) is the
1741
+ // authoritative gate; this shape-guard is defence-in-depth so a malformed
1742
+ // value cannot reach the `--model` argv (the manager has no rootDir-clean
1743
+ // path to import the models lib, so it guards on shape, not the exact list).
1744
+ const forkFromSessionId = typeof body.forkFromSessionId === 'string' && UUID_PATTERN.test(body.forkFromSessionId) ? body.forkFromSessionId : null;
1745
+ const reseatModel = typeof body.model === 'string' && /^claude-[a-z0-9.-]+(\[1m\])?$/i.test(body.model) ? body.model : null;
1621
1746
  // Task 626 — per-visitor slice ringfence for the public session-end review
1622
1747
  // rc session. Shape-gated identically to /public-spawn so a body-controlled
1623
1748
  // value cannot reach the child env. Absent on channel-admin / LinkedIn.
@@ -1687,6 +1812,27 @@ export function buildHttpApp(deps) {
1687
1812
  timed(deps.logger, 'POST', '/rc-spawn', 400, Date.now() - start);
1688
1813
  return c.json({ error: 'sessionId must be a v4 UUID' }, 400);
1689
1814
  }
1815
+ // Task 876 — re-seat fork validation. The fork needs a pre-minted target
1816
+ // id that does NOT yet exist, a shape-valid model, and a source whose
1817
+ // transcript exists (history to copy). Any failure → 400, no spawn.
1818
+ if (forkFromSessionId !== null) {
1819
+ if (sessionId === null) {
1820
+ timed(deps.logger, 'POST', '/rc-spawn', 400, Date.now() - start);
1821
+ return c.json({ error: 're-seat requires a pre-minted sessionId' }, 400);
1822
+ }
1823
+ if (reseatModel === null) {
1824
+ timed(deps.logger, 'POST', '/rc-spawn', 400, Date.now() - start);
1825
+ return c.json({ error: 're-seat requires a valid model' }, 400);
1826
+ }
1827
+ if (!findExistingJsonlForSessionId(deps.claudeConfigDir, forkFromSessionId)) {
1828
+ timed(deps.logger, 'POST', '/rc-spawn', 400, Date.now() - start);
1829
+ return c.json({ error: 're-seat source has no transcript' }, 400);
1830
+ }
1831
+ if (findExistingJsonlForSessionId(deps.claudeConfigDir, sessionId)) {
1832
+ timed(deps.logger, 'POST', '/rc-spawn', 400, Date.now() - start);
1833
+ return c.json({ error: 're-seat target id already exists' }, 400);
1834
+ }
1835
+ }
1690
1836
  // Task 702 — never run two processes on one sessionId. If we already own a
1691
1837
  // live PTY for this id, the spawn is a no-op (a bridge that lost its
1692
1838
  // in-memory index after a restart re-asks; the live PTY takes the next
@@ -1728,8 +1874,14 @@ export function buildHttpApp(deps) {
1728
1874
  const argv = ['--remote-control'];
1729
1875
  if (name)
1730
1876
  argv.push(name);
1731
- if (sessionId)
1877
+ // Task 876 — a re-seat forks the source onto the pre-minted target id; the
1878
+ // ordinary fresh/resume single-id push is replaced by the fork segment.
1879
+ if (forkFromSessionId !== null && reseatModel !== null && sessionId) {
1880
+ argv.push(...forkArgvSegment(forkFromSessionId, sessionId, reseatModel));
1881
+ }
1882
+ else if (sessionId) {
1732
1883
  argv.push(mode === 'resume' ? '--resume' : '--session-id', sessionId);
1884
+ }
1733
1885
  // Task 592 — per-spawn bypass-permissions waiver. The brand settings.json
1734
1886
  // carries `defaultMode: bypassPermissions` (Task 583); without this flag
1735
1887
  // the first-time "WARNING: … 1. No, exit 2. Yes, I accept" disclaimer
@@ -2250,6 +2402,35 @@ export function buildHttpApp(deps) {
2250
2402
  // unit driven by node-pty; the operator-visible spawnMethod marker
2251
2403
  // is kept stable so server.log greps survive the Task 573 cleanup.
2252
2404
  deps.logger(`[sessions-rc-resume] mode=${mode} sessionId=${sessionId ?? 'none'} jsonlPath=${existingJsonlPath ?? 'none'} name=${name ?? 'none'} spawnedPid=${pty.pid} bridgeId=${bridgeSessionId ?? 'pending'} spawnMethod=systemd-scope env.CLAUDE_CONFIG_DIR=${deps.claudeConfigDir}`);
2405
+ // Task 876 — re-seat post-bind. Once the fork is bound: (1) arm the
2406
+ // one-shot observer so the post-condition line emits on the fork's first
2407
+ // real turn, and (2) best-effort stop the source session's live PTY — the
2408
+ // operator has explicitly moved off it (the removed-model case has no live
2409
+ // PTY, so the stop is a no-op there). Neither must fail the response.
2410
+ if (forkFromSessionId !== null && reseatModel !== null && sessionId && outcome === 'bound') {
2411
+ const sourceJsonl = findExistingJsonlForSessionId(deps.claudeConfigDir, forkFromSessionId);
2412
+ const fromModel = sourceJsonl ? lastRealAssistantModel(sourceJsonl) : null;
2413
+ attachReseatObserve(deps, sessionId, { fromModel, toModel: reseatModel, oldSessionId: forkFromSessionId });
2414
+ try {
2415
+ const source = deps.watcher.getBySessionId(forkFromSessionId);
2416
+ if (source && source.scopeUnitToken) {
2417
+ await stopSession({
2418
+ killGraceMs: deps.killGraceMs,
2419
+ logger: deps.logger,
2420
+ runSystemctl: deps.runSystemctl,
2421
+ rowScopeUnitToken: source.scopeUnitToken,
2422
+ rowPid: source.pid,
2423
+ }, forkFromSessionId);
2424
+ deps.logger(`[webchat:reseat] op=old-session-stop old-session=${forkFromSessionId} result=stopped`);
2425
+ }
2426
+ else {
2427
+ deps.logger(`[webchat:reseat] op=old-session-stop old-session=${forkFromSessionId} result=absent`);
2428
+ }
2429
+ }
2430
+ catch (err) {
2431
+ deps.logger(`[webchat:reseat] op=old-session-stop old-session=${forkFromSessionId} result=error err=${JSON.stringify(err instanceof Error ? err.message : String(err))}`);
2432
+ }
2433
+ }
2253
2434
  timed(deps.logger, 'POST', '/rc-spawn', 200, Date.now() - start);
2254
2435
  // `slug` is the Task 648 canonical field the client navigates by;
2255
2436
  // `bridgeSessionId` is the same value, retained so pre-648 consumers and