@rubytech/create-maxy-code 0.1.442 → 0.1.444

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 (84) hide show
  1. package/dist/__tests__/converge-client-admins.test.js +50 -0
  2. package/dist/converge-client-admins.js +67 -0
  3. package/dist/index.js +8 -0
  4. package/package.json +1 -1
  5. package/payload/platform/docs/superpowers/plans/2026-07-13-account-schema-ontology-projection.md +547 -0
  6. package/payload/platform/docs/superpowers/plans/2026-07-14-graph-top-level-labels-ontology-single-source.md +458 -0
  7. package/payload/platform/docs/superpowers/specs/2026-07-13-account-schema-ontology-projection-design.md +178 -0
  8. package/payload/platform/docs/superpowers/specs/2026-07-14-graph-top-level-labels-ontology-single-source-design.md +119 -0
  9. package/payload/platform/plugins/admin/.claude-plugin/plugin.json +1 -1
  10. package/payload/platform/plugins/admin/PLUGIN.md +7 -1
  11. package/payload/platform/plugins/admin/hooks/__tests__/fs-schema-guard.test.sh +19 -2
  12. package/payload/platform/plugins/admin/mcp/dist/index.js +165 -24
  13. package/payload/platform/plugins/admin/mcp/dist/index.js.map +1 -1
  14. package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.d.ts +37 -7
  15. package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.d.ts.map +1 -1
  16. package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.js +85 -7
  17. package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.js.map +1 -1
  18. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +9 -5
  19. package/payload/platform/plugins/docs/references/admin-session.md +2 -0
  20. package/payload/platform/plugins/docs/references/admin-ui.md +5 -1
  21. package/payload/platform/plugins/docs/references/cross-account-authority.md +3 -3
  22. package/payload/platform/plugins/memory/PLUGIN.md +2 -0
  23. package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/resolve-active-vertical.test.js +12 -0
  24. package/payload/platform/plugins/memory/mcp/dist/lib/__tests__/resolve-active-vertical.test.js.map +1 -1
  25. package/payload/platform/plugins/memory/mcp/dist/lib/resolve-active-vertical.d.ts +9 -1
  26. package/payload/platform/plugins/memory/mcp/dist/lib/resolve-active-vertical.d.ts.map +1 -1
  27. package/payload/platform/plugins/memory/mcp/dist/lib/resolve-active-vertical.js +19 -2
  28. package/payload/platform/plugins/memory/mcp/dist/lib/resolve-active-vertical.js.map +1 -1
  29. package/payload/platform/plugins/memory/references/schema-estate-agent.md +8 -3
  30. package/payload/platform/plugins/outlook/references/auth.md +8 -0
  31. package/payload/platform/plugins/outlook/skills/outlook/SKILL.md +3 -0
  32. package/payload/platform/plugins/whatsapp/mcp/dist/__tests__/format-attachment-suffix.test.d.ts +2 -0
  33. package/payload/platform/plugins/whatsapp/mcp/dist/__tests__/format-attachment-suffix.test.d.ts.map +1 -0
  34. package/payload/platform/plugins/whatsapp/mcp/dist/__tests__/format-attachment-suffix.test.js +44 -0
  35. package/payload/platform/plugins/whatsapp/mcp/dist/__tests__/format-attachment-suffix.test.js.map +1 -0
  36. package/payload/platform/plugins/whatsapp/mcp/dist/format.d.ts +7 -0
  37. package/payload/platform/plugins/whatsapp/mcp/dist/format.d.ts.map +1 -1
  38. package/payload/platform/plugins/whatsapp/mcp/dist/format.js +27 -0
  39. package/payload/platform/plugins/whatsapp/mcp/dist/format.js.map +1 -1
  40. package/payload/platform/plugins/whatsapp/mcp/dist/index.js +6 -19
  41. package/payload/platform/plugins/whatsapp/mcp/dist/index.js.map +1 -1
  42. package/payload/platform/plugins/whatsapp/references/channels-whatsapp.md +3 -1
  43. package/payload/platform/plugins/work/mcp/dist/tools/work-create.d.ts.map +1 -1
  44. package/payload/platform/plugins/work/mcp/dist/tools/work-create.js +10 -7
  45. package/payload/platform/plugins/work/mcp/dist/tools/work-create.js.map +1 -1
  46. package/payload/platform/scripts/__tests__/account-schema-owned-dirs.test.sh +58 -0
  47. package/payload/platform/scripts/__tests__/provision-role-stamp.test.sh +6 -0
  48. package/payload/platform/scripts/lib/account-schema-owned-dirs.py +143 -10
  49. package/payload/platform/scripts/lib/provision-account-dir.sh +5 -0
  50. package/payload/platform/scripts/name-glsmith-owner.sh +239 -0
  51. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.d.ts.map +1 -1
  52. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js +2 -0
  53. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
  54. package/payload/platform/services/claude-session-manager/dist/http-server.d.ts +1 -0
  55. package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
  56. package/payload/platform/services/claude-session-manager/dist/http-server.js +99 -8
  57. package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
  58. package/payload/platform/services/claude-session-manager/dist/index.js +0 -13
  59. package/payload/platform/services/claude-session-manager/dist/index.js.map +1 -1
  60. package/payload/platform/services/claude-session-manager/dist/jsonl-path.d.ts +8 -0
  61. package/payload/platform/services/claude-session-manager/dist/jsonl-path.d.ts.map +1 -1
  62. package/payload/platform/services/claude-session-manager/dist/jsonl-path.js +11 -0
  63. package/payload/platform/services/claude-session-manager/dist/jsonl-path.js.map +1 -1
  64. package/payload/platform/services/claude-session-manager/dist/passive-admin-assignment.d.ts +20 -0
  65. package/payload/platform/services/claude-session-manager/dist/passive-admin-assignment.d.ts.map +1 -0
  66. package/payload/platform/services/claude-session-manager/dist/passive-admin-assignment.js +66 -0
  67. package/payload/platform/services/claude-session-manager/dist/passive-admin-assignment.js.map +1 -0
  68. package/payload/platform/services/claude-session-manager/dist/passive-spawn-tools-tail.d.ts +19 -0
  69. package/payload/platform/services/claude-session-manager/dist/passive-spawn-tools-tail.d.ts.map +1 -0
  70. package/payload/platform/services/claude-session-manager/dist/passive-spawn-tools-tail.js +50 -0
  71. package/payload/platform/services/claude-session-manager/dist/passive-spawn-tools-tail.js.map +1 -0
  72. package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
  73. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +14 -1
  74. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
  75. package/payload/server/public/assets/{chat-DhD-NES_.js → chat-Dq-X-ia8.js} +1 -1
  76. package/payload/server/public/assets/{operator-zcIfeB14.js → operator-88m0DMl2.js} +1 -1
  77. package/payload/server/public/assets/page-BRfxFXyi.js +32 -0
  78. package/payload/server/public/assets/{public-C0ehZCdE.js → public-BX2MjsFY.js} +1 -1
  79. package/payload/server/public/chat.html +2 -2
  80. package/payload/server/public/operator.html +2 -2
  81. package/payload/server/public/public.html +2 -2
  82. package/payload/server/server.js +406 -182
  83. package/payload/platform/plugins/memory/references/schema-trades.md +0 -34
  84. package/payload/server/public/assets/page-6fCnIb45.js +0 -32
@@ -0,0 +1,119 @@
1
+ # Single-source the `/graph` top-level label allowlist from the vertical ontology — Design
2
+
3
+ Task: `.tasks/1624-single-source-graph-labels-top-level-from-vertical-ontology.md`.
4
+
5
+ ## Problem
6
+
7
+ A businessType's top-level operator-entry node types live in the `## Top-level node
8
+ types` table of each vertical's `schema-<vertical>.md` (established by 1622). A third
9
+ encoding of "top-level entity" still lives apart: `platform/ui/app/lib/graph-labels.ts`
10
+ `FILTER_TOP_LEVEL_LABELS` is a hand-maintained global union of every brand's top-level
11
+ labels — the `/graph` filter-popover chip allowlist. It drifts from the ontology by
12
+ construction: a top-level label added to a vertical schema does not become a chip until
13
+ someone also edits this TypeScript set.
14
+
15
+ ## Goal
16
+
17
+ Derive the `/graph` chip allowlist from the same per-vertical ontology source so a
18
+ top-level label added to a vertical schema surfaces as a chip with no second edit, while
19
+ preserving today's exact chip visibility as the acceptance baseline.
20
+
21
+ ## Blast radius (evidence)
22
+
23
+ `FILTER_TOP_LEVEL_LABELS` has four real code consumers:
24
+
25
+ 1. `server/routes/admin/graph-labels-in-graph.ts` — popover chip allowlist (the route the
26
+ task names). Passes the set as the `$allowed` cypher param; the cypher count-gates.
27
+ 2. `server/routes/admin/graph-subgraph.ts:280` — default-view label set.
28
+ 3. `server/routes/admin/graph-default-view.ts:158` — default-view eligibility check.
29
+ 4. `app/data/searchHelpers.ts:46` — client-side `/data` search chip pre-filter, a
30
+ build-time static import that cannot read files.
31
+
32
+ Scope decision (operator-confirmed): **the three server routes switch to the
33
+ ontology-derived source. The client `searchHelpers.ts` keeps the static set**, with a
34
+ follow-up task filed to close that last second source.
35
+
36
+ ## Facts that shape the mechanism
37
+
38
+ - Only `schema-construction.md` and `schema-estate-agent.md` currently carry a
39
+ `## Top-level node types` section. Every other vertical (and 1626) adds theirs later.
40
+ - `schema-base.md` has no top-level section; its `## Node Types` table mixes top-level and
41
+ child types (Message, Section, Chunk). Base labels therefore **cannot** be derived — they
42
+ stay an explicit list. This resolves the task's open base-list decision.
43
+ - The construction top-level table includes `WhatsAppGroup` typed `cdm:Channel`. The 1622
44
+ Python file-bucket generator excludes non-`schema:` rows (a channel gets no file bucket),
45
+ but `WhatsAppGroup` **is** a current graph chip. So the graph derivation takes **every**
46
+ Neo4j Label row and applies **no** namespace filter.
47
+ - The construction table has 5 columns, estate-agent 4. The Neo4j Label column is resolved
48
+ by header name, never by index.
49
+
50
+ ## Architecture
51
+
52
+ New server-only module `platform/ui/server/lib/top-level-labels.ts`:
53
+
54
+ ```
55
+ getTopLevelLabelAllowlist(opts?: { referencesDir?: string }): ReadonlySet<string>
56
+ ```
57
+
58
+ - Resolves `referencesDir` to `${MAXY_PLATFORM_ROOT}/plugins/memory/references` (same
59
+ env/`__dirname` fallback the UI server already uses), or the injected override.
60
+ - Reads every `schema-*.md`. For each, locates the `## Top-level node types` heading by
61
+ case-insensitive prefix, reads the first pipe-table beneath it (before the next `##`),
62
+ and extracts the `Neo4j Label` column by header name, stripping backticks.
63
+ - Unions parsed labels with the module const `STATIC_TOP_LEVEL_LABELS` — the base-schema
64
+ infra plus any vertical whose schema has no top-level section yet (knowledge-work today).
65
+ Documented to shrink as 1626 adds sections.
66
+ - Caches the result at module level (schema files are static per install). An injected
67
+ `referencesDir` bypasses the cache so tests are isolated.
68
+ - Emits one observability line on computation:
69
+ `op=top-level-labels source=ontology count=<n> files=<...> derived=<d> static=<s>`.
70
+
71
+ The three server routes replace `FILTER_TOP_LEVEL_LABELS` with
72
+ `getTopLevelLabelAllowlist()` (a `ReadonlySet<string>`, so `.has()` and spread are
73
+ preserved). Cypher count-gating is unchanged: a non-resident label surfaces no chip.
74
+
75
+ Unchanged: `FILTER_TOP_LEVEL_LABELS` (client), `HIDDEN_BY_DEFAULT_LABELS`,
76
+ `AGENT_ACTION_LABELS`, `EXCLUDED_EDGE_TYPES`.
77
+
78
+ ## Byte-identical guarantee
79
+
80
+ Derived union = construction table (11) ∪ estate table (4) ∪ `STATIC_TOP_LEVEL_LABELS`
81
+ (33) = the current 48-member `FILTER_TOP_LEVEL_LABELS`. Because the sets are equal, the
82
+ existing route tests (which assert membership against `FILTER_TOP_LEVEL_LABELS`) keep
83
+ passing unchanged.
84
+
85
+ `STATIC_TOP_LEVEL_LABELS` (top-level labels not yet sourced from a vertical section):
86
+
87
+ - Base-schema infra: `LocalBusiness`, `Service`, `PriceSpecification`,
88
+ `OpeningHoursSpecification`, `Organization`, `Person`, `UserProfile`, `Preference`,
89
+ `AdminUser`, `AccessGrant`, `KnowledgeDocument`, `DigitalDocument`, `CreativeWork`,
90
+ `Question`, `FAQPage`, `DefinedTerm`, `Review`, `ImageObject`, `Invoice`, `Task`,
91
+ `Project`, `Event`, `Workflow`, `Email`, `EmailAccount`, `Agent`.
92
+ - Knowledge-work vertical (no top-level section yet; 1626): `Objective`, `KeyResult`,
93
+ `Decision`, `Risk`, `Source`, `Finding`, `Hypothesis`.
94
+
95
+ ## Testing
96
+
97
+ Committed, colocated `platform/ui/server/lib/top-level-labels.test.ts`:
98
+
99
+ 1. `getTopLevelLabelAllowlist()` against the real references dir deep-equals
100
+ `FILTER_TOP_LEVEL_LABELS` (regression baseline).
101
+ 2. A fixture references dir with an added top-level row surfaces that label with no change
102
+ to any TypeScript set.
103
+ 3. A `cdm:`-namespaced row (e.g. `WhatsAppGroup`) is included (no namespace filter).
104
+
105
+ The pre-existing `labels-in-graph` and `graph-default-topLevel` tests must still pass
106
+ after the swap (count-gating and eligibility unchanged).
107
+
108
+ ## Observability
109
+
110
+ `op=top-level-labels source=ontology count=<n>` on the server log, emitted when the
111
+ allowlist is resolved, so an operator can confirm the chips come from the ontology, not a
112
+ stale hardcoded list.
113
+
114
+ ## Out of scope
115
+
116
+ - Client `searchHelpers.ts` static set — filed as a follow-up task.
117
+ - `HIDDEN_BY_DEFAULT_LABELS`, `AGENT_ACTION_LABELS`, `EXCLUDED_EDGE_TYPES`.
118
+ - Adding `## Top-level node types` sections to verticals that lack one (1626).
119
+ - The file-schema generator and quotation reification (landed in 1622).
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "admin",
3
- "description": "Platform administration plugin. Provides system-status, public-hostname (deterministic Cloudflare public-URL resolver, single call returning the operator's canonical hostname so agents never guess property names on :CloudflareHostname nodes), admin-hostname (the admin-host twin of public-hostname — resolves the host that serves /calendar and the rest of the admin shell behind sign-in from the same ingress + alias + operator files, so agents point the operator at the admin /calendar URL instead of the public host that 404s it), publish-site (move an extracted static-site tree under <accountDir>/sites/<slug>/, emit one canonical path slug, and refresh llms.txt at the site root — typed refusal taxonomy replaces the prior skill-prose contract), brand-settings, account-manage, capabilities-here (deterministic install-introspection — returns enabledPlugins, tier, models, installed platform + premium specialists, registered Claude Code agent types, and the brand block as a single JSON object; the canonical tool for grounding any claim about what is enabled on the current account), account-update, the multi-account managed-service lifecycle tools (account_list, account_create, account_delete, account_purge, account_channel_routing, account_channel_routing_set — one Rubytech operator hosting N client accounts on one house install; create/delete/purge are operator-only and purge is two-step with a typed confirmation; account_create requires a managing house admin (its userId) and refuses without one, recording it as the sub-account's managingAdminUserId, and also requires the client business owner's real name (ownerName), refusing a blank or the placeholder \"Owner\" and seeding it onto the sub-account's owner AdminUser and owner Person; account_reassign_admin repoints a client sub-account's managing admin to another live house admin (the repair path for a dangling managingAdminUserId); account_channel_routing_set repoints the install's single WhatsApp/Telegram inbound stream to a different sub-account), admin-add (refuses on a client sub-account, where admin access is already install-wide so a per-operator seat grants nothing — the sub-account's one identity, its business owner, is set at account creation; the house account, where operators hold PIN logins and admins[] rows, is unchanged), admin-remove (refuses to remove a house admin who still manages one or more client sub-accounts, naming them so the operator reassigns each with account_reassign_admin first — never silently orphans them), admin-list, admin-update-pin, agent-list, agent-config-read, logs-read, plugin-read, skill-load (one-call resolve+read for SKILL.md by skill name, the canonical primitive for loading a named skill; plugin-read remains the reader for references/* and PLUGIN.md), skill-search (free-text intent → skill resolver: ranks every plugin skill's SKILL.md name+description against a query and returns the top owners with their canonical skills/<slug>/ path, so intent→skill mapping survives the available-skills menu leaving context after a compaction), store-skill (deterministic write counterpart to plugin-read; persists operator-authored skills as plugin files under the active account), session-reset, session-resume, wifi, and action-approval tools (action-pending, action-approve, action-reject, action-edit) for managing the Maxy platform.",
3
+ "description": "Platform administration plugin. Provides system-status, public-hostname (deterministic Cloudflare public-URL resolver, single call returning the operator's canonical hostname so agents never guess property names on :CloudflareHostname nodes), admin-hostname (the admin-host twin of public-hostname — resolves the host that serves /calendar and the rest of the admin shell behind sign-in from the same ingress + alias + operator files, so agents point the operator at the admin /calendar URL instead of the public host that 404s it), publish-site (move an extracted static-site tree under <accountDir>/sites/<slug>/, emit one canonical path slug, and refresh llms.txt at the site root — typed refusal taxonomy replaces the prior skill-prose contract), brand-settings, account-manage, capabilities-here (deterministic install-introspection — returns enabledPlugins, tier, models, installed platform + premium specialists, registered Claude Code agent types, and the brand block as a single JSON object; the canonical tool for grounding any claim about what is enabled on the current account), account-update, the multi-account managed-service lifecycle tools (account_list, account_create, account_delete, account_purge, account_channel_routing, account_channel_routing_set — one Rubytech operator hosting N client accounts on one house install; create/delete/purge are operator-only and purge is two-step with a typed confirmation; account_create requires the client business owner's real name (ownerName), refusing a blank or the placeholder \"Owner\" and seeding it onto the sub-account's owner AdminUser and owner Person, while a managing house admin (its userId) is optional — when supplied it is validated as a live house admin and recorded as the sub-account's managingAdminUserId, and when omitted the sub-account is unmanaged and its passive-intake tasks route to the install's primary admin; account_reassign_admin repoints a client sub-account's managing admin to another live house admin (the repair path for a dangling managingAdminUserId, or to record one on an unmanaged account); account_roster is the canonical per-account identity view — one row per sub-account giving business name, role, the managing house admin resolved to a name with status (assigned/absent/dangling), the business owner from the graph with status (named/nameless), and the WhatsApp account-manager binding if any, each field carrying what it means and does not (managing admin is the responsible house team member not the owner; account manager is WhatsApp routing only with no admin rights), so the agent never stitches admin-list + account.json + whatsapp-config; account_set_owner_name names (or corrects) a client sub-account's business owner by writing the owned Person — the canonical name source — refusing a blank or the placeholder \"Owner\", the guarded repair for a nameless owner (the standing identity-audit op=nameless-owned-person detector); account_channel_routing_set repoints the install's single WhatsApp/Telegram inbound stream to a different sub-account), admin-add (refuses on a client sub-account, where admin access is already install-wide so a per-operator seat grants nothing — the sub-account's one identity, its business owner, is set at account creation; the house account, where operators hold PIN logins and admins[] rows, is unchanged), admin-remove (refuses to remove a house admin who still manages one or more client sub-accounts, naming them so the operator reassigns each with account_reassign_admin first — never silently orphans them), admin-list, admin-update-pin, agent-list, agent-config-read, logs-read, plugin-read, skill-load (one-call resolve+read for SKILL.md by skill name, the canonical primitive for loading a named skill; plugin-read remains the reader for references/* and PLUGIN.md), skill-search (free-text intent → skill resolver: ranks every plugin skill's SKILL.md name+description against a query and returns the top owners with their canonical skills/<slug>/ path, so intent→skill mapping survives the available-skills menu leaving context after a compaction), store-skill (deterministic write counterpart to plugin-read; persists operator-authored skills as plugin files under the active account), session-reset, session-resume, wifi, and action-approval tools (action-pending, action-approve, action-reject, action-edit) for managing the Maxy platform.",
4
4
  "version": "0.1.0",
5
5
  "author": {
6
6
  "name": "Rubytech LLC"
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: admin
3
3
  surface: platform
4
- description: "Platform administration plugin. Provides system-status, public-hostname (deterministic Cloudflare public-URL resolver, single call returning the operator's canonical hostname so agents never guess property names on :CloudflareHostname nodes), admin-hostname (the admin-host twin of public-hostname — resolves the host that serves /calendar and the rest of the admin shell behind sign-in from the same ingress + alias + operator files, so agents point the operator at the admin /calendar URL instead of the public host that 404s it), publish-site (move an extracted static-site tree under <accountDir>/sites/<slug>/, emit one canonical path slug, and refresh llms.txt at the site root — typed refusal taxonomy replaces the prior skill-prose contract), brand-settings, account-manage, capabilities-here (deterministic install-introspection — returns enabledPlugins, tier, models, installed platform + premium specialists, registered Claude Code agent types, and the brand block as a single JSON object; the canonical tool for grounding any claim about what is enabled on the current account), account-update, the multi-account managed-service lifecycle tools (account_list, account_create, account_delete, account_purge, account_channel_routing, account_channel_routing_set — one Rubytech operator hosting N client accounts on one house install; create/delete/purge are operator-only and purge is two-step with a typed confirmation; account_create requires a managing house admin (its userId) and refuses without one, recording it as the sub-account's managingAdminUserId, and also requires the client business owner's real name (ownerName), refusing a blank or the placeholder "Owner" and seeding it onto the sub-account's owner AdminUser and owner Person; account_reassign_admin repoints a client sub-account's managing admin to another live house admin (the repair path for a dangling managingAdminUserId); account_channel_routing_set repoints the install's single WhatsApp/Telegram inbound stream to a different sub-account), admin-add (refuses on a client sub-account, where admin access is already install-wide so a per-operator seat grants nothing — the sub-account's one identity, its business owner, is set at account creation; the house account, where operators hold PIN logins and admins[] rows, is unchanged), admin-remove (refuses to remove a house admin who still manages one or more client sub-accounts, naming them so the operator reassigns each with account_reassign_admin first — never silently orphans them), admin-list, admin-update-pin, agent-list, agent-config-read, logs-read, plugin-read, skill-load (one-call resolve+read for SKILL.md by skill name, the canonical primitive for loading a named skill; plugin-read remains the reader for references/* and PLUGIN.md), skill-search (free-text intent → skill resolver: ranks every plugin skill's SKILL.md name+description against a query and returns the top owners with their canonical skills/<slug>/ path, so intent→skill mapping survives the available-skills menu leaving context after a compaction), store-skill (deterministic write counterpart to plugin-read; persists operator-authored skills as plugin files under the active account), session-reset, session-resume, wifi, and action-approval tools (action-pending, action-approve, action-reject, action-edit) for managing the Maxy platform."
4
+ description: "Platform administration plugin. Provides system-status, public-hostname (deterministic Cloudflare public-URL resolver, single call returning the operator's canonical hostname so agents never guess property names on :CloudflareHostname nodes), admin-hostname (the admin-host twin of public-hostname — resolves the host that serves /calendar and the rest of the admin shell behind sign-in from the same ingress + alias + operator files, so agents point the operator at the admin /calendar URL instead of the public host that 404s it), publish-site (move an extracted static-site tree under <accountDir>/sites/<slug>/, emit one canonical path slug, and refresh llms.txt at the site root — typed refusal taxonomy replaces the prior skill-prose contract), brand-settings, account-manage, capabilities-here (deterministic install-introspection — returns enabledPlugins, tier, models, installed platform + premium specialists, registered Claude Code agent types, and the brand block as a single JSON object; the canonical tool for grounding any claim about what is enabled on the current account), account-update, the multi-account managed-service lifecycle tools (account_list, account_create, account_delete, account_purge, account_channel_routing, account_channel_routing_set — one Rubytech operator hosting N client accounts on one house install; create/delete/purge are operator-only and purge is two-step with a typed confirmation; account_create requires the client business owner's real name (ownerName), refusing a blank or the placeholder "Owner" and seeding it onto the sub-account's owner AdminUser and owner Person, while a managing house admin (its userId) is optional when supplied it is validated as a live house admin and recorded as the sub-account's managingAdminUserId, and when omitted the sub-account is unmanaged and its passive-intake tasks route to the install's primary admin; account_reassign_admin repoints a client sub-account's managing admin to another live house admin (the repair path for a dangling managingAdminUserId, or to record one on an unmanaged account); account_roster is the canonical per-account identity view — one row per sub-account giving business name, role, the managing house admin resolved to a name with status (assigned/absent/dangling), the business owner from the graph with status (named/nameless), and the WhatsApp account-manager binding if any, each field carrying what it means and does not (managing admin is the responsible house team member not the owner; account manager is WhatsApp routing only with no admin rights), so the agent never stitches admin-list + account.json + whatsapp-config; account_set_owner_name names (or corrects) a client sub-account's business owner by writing the owned Person the canonical name source — refusing a blank or the placeholder "Owner", the guarded repair for a nameless owner (the standing identity-audit op=nameless-owned-person detector); account_channel_routing_set repoints the install's single WhatsApp/Telegram inbound stream to a different sub-account), admin-add (refuses on a client sub-account, where admin access is already install-wide so a per-operator seat grants nothing — the sub-account's one identity, its business owner, is set at account creation; the house account, where operators hold PIN logins and admins[] rows, is unchanged), admin-remove (refuses to remove a house admin who still manages one or more client sub-accounts, naming them so the operator reassigns each with account_reassign_admin first — never silently orphans them), admin-list, admin-update-pin, agent-list, agent-config-read, logs-read, plugin-read, skill-load (one-call resolve+read for SKILL.md by skill name, the canonical primitive for loading a named skill; plugin-read remains the reader for references/* and PLUGIN.md), skill-search (free-text intent → skill resolver: ranks every plugin skill's SKILL.md name+description against a query and returns the top owners with their canonical skills/<slug>/ path, so intent→skill mapping survives the available-skills menu leaving context after a compaction), store-skill (deterministic write counterpart to plugin-read; persists operator-authored skills as plugin files under the active account), session-reset, session-resume, wifi, and action-approval tools (action-pending, action-approve, action-reject, action-edit) for managing the Maxy platform."
5
5
  tools:
6
6
  - name: system-status
7
7
  publicAllowlist: false
@@ -30,12 +30,18 @@ tools:
30
30
  - name: account_list
31
31
  publicAllowlist: false
32
32
  adminAllowlist: true
33
+ - name: account_roster
34
+ publicAllowlist: false
35
+ adminAllowlist: true
33
36
  - name: account_create
34
37
  publicAllowlist: false
35
38
  adminAllowlist: true
36
39
  - name: account_reassign_admin
37
40
  publicAllowlist: false
38
41
  adminAllowlist: true
42
+ - name: account_set_owner_name
43
+ publicAllowlist: false
44
+ adminAllowlist: true
39
45
  - name: account_delete
40
46
  publicAllowlist: false
41
47
  adminAllowlist: true
@@ -27,13 +27,23 @@ trap 'rm -rf "$ACCT"' EXIT
27
27
  cp "$TEMPLATE" "$ACCT/SCHEMA.md"
28
28
  mkdir -p "$ACCT/projects/Acme" "$ACCT/documents" "$ACCT/output"
29
29
 
30
+ # A second account modelling a provisioned construction account: jobs/ is a
31
+ # derived domain bucket (the generator appends it to the allowed block, like a
32
+ # plugin-owned dir). Kept separate so the template-parity assertion below still
33
+ # checks the pristine shipped set.
34
+ ACCT_D=$(mktemp -d)
35
+ trap 'rm -rf "$ACCT" "$ACCT_D"' EXIT
36
+ cp "$TEMPLATE" "$ACCT_D/SCHEMA.md"
37
+ awk '1; /^```allowed-top-level$/{print "jobs"}' "$ACCT_D/SCHEMA.md" > "$ACCT_D/SCHEMA.md.tmp" && mv "$ACCT_D/SCHEMA.md.tmp" "$ACCT_D/SCHEMA.md"
38
+ mkdir -p "$ACCT_D/jobs/5-oaktree/Quotations"
39
+
30
40
  PASS=0; FAIL=0
31
41
  # Run one case in the account dir as cwd.
32
42
  # $1 name $2 stdin $3 expected_exit $4 expected_log_re ("" = none)
33
43
  run_case() {
34
- local name="$1" stdin="$2" exp="$3" re="$4" ef actual
44
+ local name="$1" stdin="$2" exp="$3" re="$4" acct="${5:-$ACCT}" ef actual
35
45
  ef=$(mktemp)
36
- ( cd "$ACCT" && printf '%s' "$stdin" | bash "$HOOK" >/dev/null 2>"$ef" )
46
+ ( cd "$acct" && printf '%s' "$stdin" | bash "$HOOK" >/dev/null 2>"$ef" )
37
47
  actual=$?
38
48
  local sc; sc=$(cat "$ef"); rm -f "$ef"
39
49
  local ok=1
@@ -58,6 +68,13 @@ run_case "empty stdin block" ""
58
68
  # JSON null file_path must coerce to empty (allow), not the literal string "None".
59
69
  run_case "null path allow" '{"hook_event_name":"PreToolUse","tool_name":"Write","tool_input":{"file_path":null}}' 0 ""
60
70
 
71
+ # Derived domain buckets (construction account $ACCT_D): jobs/ passes at any
72
+ # depth (it is outside the three flat operator-data buckets), an undeclared
73
+ # top-level segment still blocks.
74
+ run_case "domain bucket deep allow" "$(mkenv Write file_path 'jobs/5-oaktree/Quotations/quote.pdf')" 0 "" "$ACCT_D"
75
+ run_case "domain bucket file allow" "$(mkenv Write file_path 'jobs/5-oaktree/notes.md')" 0 "" "$ACCT_D"
76
+ run_case "undeclared still blocks" "$(mkenv Write file_path 'invoices/x.pdf')" 2 "reason=top-level" "$ACCT_D"
77
+
61
78
  # Allowed-set parse == documented set.
62
79
  EXPECT="projects contacts documents url-get output generated extracted uploads agents specialists sites public cache secrets state logs tmp SCHEMA.md account.json AGENTS.md .claude .git"
63
80
  GOT=$(awk '/^```allowed-top-level$/{f=1;next} /^```$/{f=0} f' "$ACCT/SCHEMA.md" | tr '\n' ' ' | sed 's/ *$//')
@@ -28,7 +28,7 @@ import { publishSite } from "./tools/publish-site.js";
28
28
  import { resolveCapabilitiesHere } from "./tools/capabilities-here.js";
29
29
  import { runCatalogueCensus } from "./lib/catalogue-census.js";
30
30
  import { lifelineTool } from "../../../../lib/mcp-lifeline/dist/index.js";
31
- import { listAccountsFromDir, isHouseAccount, archiveAccountDir, provisionClientAccount, findHouseAccount, getChannelRoutingAccountId, setChannelRoutingAccountId, seedAccountGraphRoot, isPlaceholderOwnerName, refuseClientAdminAdd, readHouseAdminUserIds, setManagingAdmin, findClientAccountsManagedBy, reassignManagingAdmin, ACCOUNT_NODE_COUNT_CYPHER, ACCOUNT_PURGE_CYPHER, } from "./tools/account-lifecycle.js";
31
+ import { listAccountsFromDir, isHouseAccount, archiveAccountDir, provisionClientAccount, findHouseAccount, getChannelRoutingAccountId, setChannelRoutingAccountId, seedAccountGraphRoot, isPlaceholderOwnerName, refuseClientAdminAdd, readHouseAdminUserIds, setManagingAdmin, findClientAccountsManagedBy, reassignManagingAdmin, ACCOUNT_NODE_COUNT_CYPHER, ACCOUNT_PURGE_CYPHER, classifyManagingAdmin, ownerNameStatus, readManagingAdminUserId, setOwnerName, } from "./tools/account-lifecycle.js";
32
32
  function refusalGuidance(kind) {
33
33
  switch (kind) {
34
34
  case "unsafe-slug":
@@ -3313,19 +3313,121 @@ eagerTool(server, "account_list", "List every sub-account on this install (one h
3313
3313
  content: [{ type: "text", text: accounts.length ? lines.join("\n") : "No accounts found." }],
3314
3314
  };
3315
3315
  });
3316
- eagerTool(server, "account_create", "Provision a new CLIENT sub-account on this install (managed service). REQUIRES two things: `adminUserId`, the userId of the house team member who will manage this client (get the choices from admin-list; ask the operator which one before creating); and `ownerName`, the real name of the client business's owner (ask the operator for it — never invent it or reuse the house operator's name). Mints a UUID, scaffolds the account directory (agents, specialists, settings, account.json with role:\"client\" and managingAdminUserId), seeds default plugins, and seeds the account's graph root (a :LocalBusiness plus its owner :AdminUser and owner :Person carrying ownerName) so you can populate it immediately. Refuses if adminUserId is missing/not a house admin, or if ownerName is missing/blank/the placeholder \"Owner\". Returns the new accountId. Operator-only; never creates the house sub-account (that is the install itself).", {
3317
- adminUserId: z.string().describe("The userId of the house admin who will manage this client sub-account. Must be a current house admin (see admin-list). Required — creation is refused without it."),
3316
+ eagerTool(server, "account_roster", "Canonical per-account identity roster for this install. One row per sub-account: accountId, business name, role (house/client), the managing house admin (the responsible house team member NOT the owner) resolved to a name with status assigned/absent/dangling, the business owner (the client's owner identity on the graph) with status named/nameless, and the WhatsApp account-manager binding if any (WhatsApp routing only carries NO admin rights). This is the single tool for 'who owns each account and which admin manages it'; never stitch admin-list + account.json + whatsapp-config for this. Operator-only.", {}, async () => {
3317
+ if (!ACCOUNT_ID)
3318
+ return refuseNoAccount("account_roster");
3319
+ const TAG = "[account-roster]";
3320
+ const accounts = listAccountsFromDir(ACCOUNTS_ROOT);
3321
+ const liveHouse = readHouseAdminUserIds(ACCOUNTS_ROOT);
3322
+ // Graph reads: business name, owner (role:owner AdminUser's owned Person),
3323
+ // and managing-admin name (house AdminUser's owned Person). Best-effort — a
3324
+ // Neo4j hiccup renders the graph-derived fields unknown, never fails the roster.
3325
+ const businessName = new Map();
3326
+ const ownerName = new Map();
3327
+ const mgrName = new Map();
3328
+ try {
3329
+ const session = getSession();
3330
+ try {
3331
+ const ids = accounts.map((a) => a.accountId);
3332
+ const bn = await session.run(`UNWIND $ids AS id MATCH (b:LocalBusiness {accountId: id}) RETURN id, b.name AS name`, { ids });
3333
+ for (const r of bn.records)
3334
+ businessName.set(r.get("id"), (r.get("name") ?? "").trim());
3335
+ const own = await session.run(`UNWIND $ids AS id
3336
+ MATCH (au:AdminUser {accountId: id, role: 'owner'})-[:OWNS]->(p:Person)
3337
+ WHERE p.accountId = au.accountId
3338
+ RETURN id, p.givenName AS givenName, p.familyName AS familyName`, { ids });
3339
+ for (const r of own.records) {
3340
+ const g = r.get("givenName")?.trim() ?? "";
3341
+ const f = r.get("familyName")?.trim() ?? "";
3342
+ ownerName.set(r.get("id"), g ? (f ? `${g} ${f}` : g) : null);
3343
+ }
3344
+ const mgrIds = accounts.map((a) => readManagingAdminUserId(ACCOUNTS_ROOT, a.accountId)).filter((u) => !!u);
3345
+ if (mgrIds.length) {
3346
+ const mg = await session.run(`UNWIND $ids AS uid MATCH (au:AdminUser {userId: uid})-[:OWNS]->(p:Person)
3347
+ WHERE p.accountId = au.accountId
3348
+ RETURN uid, p.givenName AS givenName, p.familyName AS familyName`, { ids: mgrIds });
3349
+ for (const r of mg.records) {
3350
+ const g = r.get("givenName")?.trim() ?? "";
3351
+ const f = r.get("familyName")?.trim() ?? "";
3352
+ if (g)
3353
+ mgrName.set(r.get("uid"), f ? `${g} ${f}` : g);
3354
+ }
3355
+ }
3356
+ }
3357
+ finally {
3358
+ await session.close();
3359
+ }
3360
+ }
3361
+ catch { /* graph best-effort */ }
3362
+ // WhatsApp account-manager map (phone -> {managesAccount, mode}); reached the
3363
+ // same way admin already calls the UI server internal port (remote-auth).
3364
+ // Best-effort — null column on any failure.
3365
+ const amByAccount = new Map();
3366
+ try {
3367
+ const internalPort = parseInt(PLATFORM_PORT, 10);
3368
+ // Task 1636 — the config route is house-scoped; forward this operator
3369
+ // session's platform-stamped caller identity so the gate authorises the
3370
+ // read. account_roster is operator-only, so its house session carries
3371
+ // ACCOUNT_ID (+ HOUSE_ADMIN_SCOPE for a non-specialist house admin); the
3372
+ // agent cannot forge either. Absent (e.g. a non-house context) the gate
3373
+ // fails closed and this best-effort column stays null.
3374
+ const scopeHeaders = { "content-type": "application/json" };
3375
+ if (process.env.ACCOUNT_ID)
3376
+ scopeHeaders["x-maxy-caller-account"] = process.env.ACCOUNT_ID;
3377
+ if (process.env.HOUSE_ADMIN_SCOPE)
3378
+ scopeHeaders["x-maxy-house-admin-scope"] = process.env.HOUSE_ADMIN_SCOPE;
3379
+ const res = await fetch(`http://127.0.0.1:${internalPort}/api/whatsapp/config`, {
3380
+ method: "POST",
3381
+ headers: scopeHeaders,
3382
+ body: JSON.stringify({ action: "list-account-managers" }),
3383
+ signal: AbortSignal.timeout(5000),
3384
+ });
3385
+ if (res.ok) {
3386
+ const body = await res.json();
3387
+ for (const [phone, v] of Object.entries(body.accountManagers ?? {})) {
3388
+ const managesAccount = typeof v === "string" ? v : v.managesAccount;
3389
+ const mode = typeof v === "string" ? "active" : (v.mode ?? "active");
3390
+ amByAccount.set(managesAccount, { phone, mode });
3391
+ }
3392
+ }
3393
+ }
3394
+ catch { /* account-manager column best-effort */ }
3395
+ let namelessOwners = 0, absentMgr = 0, danglingMgr = 0;
3396
+ const lines = accounts.map((a) => {
3397
+ const biz = businessName.get(a.accountId) || "(unnamed)";
3398
+ if (a.isHouse)
3399
+ return `- **${biz}** — accountId: ${a.accountId}, role: house`;
3400
+ const mgrId = readManagingAdminUserId(ACCOUNTS_ROOT, a.accountId);
3401
+ const mgrStatus = classifyManagingAdmin(mgrId, liveHouse);
3402
+ if (mgrStatus === "absent")
3403
+ absentMgr++;
3404
+ else if (mgrStatus === "dangling")
3405
+ danglingMgr++;
3406
+ const oName = ownerName.get(a.accountId) ?? null;
3407
+ const oStatus = ownerNameStatus(oName);
3408
+ if (oStatus === "nameless")
3409
+ namelessOwners++;
3410
+ const am = amByAccount.get(a.accountId);
3411
+ const mgrLabel = mgrStatus === "assigned" ? `${mgrName.get(mgrId) ?? mgrId} (assigned)` : mgrStatus;
3412
+ const ownerLabel = oStatus === "named" ? `${oName} (named)` : "nameless";
3413
+ const amLabel = am ? `${am.phone}${am.mode === "passive" ? " (passive)" : " (active)"}` : "none";
3414
+ return `- **${biz}** — accountId: ${a.accountId}, role: client, managing admin: ${mgrLabel}, owner: ${ownerLabel}, account manager: ${amLabel}`;
3415
+ });
3416
+ process.stderr.write(`${TAG} op=roster accounts=${accounts.length} nameless-owners=${namelessOwners} absent-mgr=${absentMgr} dangling-mgr=${danglingMgr}\n`);
3417
+ return { content: [{ type: "text", text: accounts.length ? `Account roster:\n\n${lines.join("\n")}` : "No accounts found." }] };
3418
+ });
3419
+ eagerTool(server, "account_create", "Provision a new CLIENT sub-account on this install (managed service). REQUIRES `ownerName`, the real name of the client business's owner (ask the operator for it — never invent it or reuse the house operator's name). OPTIONALLY takes `adminUserId`, the userId of the house team member who will manage this client (get the choices from admin-list; ask the operator, but omit it if the client is run by its owner rather than a house admin). Mints a UUID, scaffolds the account directory (agents, specialists, settings, account.json with role:\"client\", and managingAdminUserId when an admin is named), seeds default plugins, and seeds the account's graph root (a :LocalBusiness plus its owner :AdminUser and owner :Person carrying ownerName) so you can populate it immediately. Refuses if ownerName is missing/blank/the placeholder \"Owner\", or if a supplied adminUserId is not a current house admin. When no managing admin is set, that account's passive-intake tasks route to the install's primary admin. Returns the new accountId. Operator-only; never creates the house sub-account (that is the install itself).", {
3420
+ adminUserId: z.string().optional().describe("The userId of the house admin who will manage this client sub-account. Optional — omit it for a client run by its owner rather than a house admin (its passive-intake tasks then route to the install's primary admin). When supplied, it must be a current house admin (see admin-list) or creation is refused."),
3318
3421
  ownerName: z.string().describe("The real name of the client business's owner. Applied to both the owner AdminUser and owner Person for the new sub-account. Required — creation is refused when missing, blank, or the placeholder \"Owner\". Ask the operator; never reuse the house operator's name."),
3319
3422
  }, async ({ adminUserId, ownerName }) => {
3320
3423
  if (!ACCOUNT_ID)
3321
3424
  return refuseNoAccount("account_create");
3322
- // Task 1500every client sub-account must carry a responsible house admin.
3323
- // Refuse (tool error, never a silent default) when none is named, or when
3324
- // the named userId is not a current house admin.
3325
- if (!adminUserId || !adminUserId.trim()) {
3326
- process.stderr.write(`[account-lifecycle] op=create-refused reason=no-admin adminUserId=-\n`);
3327
- return { content: [{ type: "text", text: `account_create refused: name the managing house admin (adminUserId). Call admin-list to see the choices and ask the operator which one manages this client.` }], isError: true };
3328
- }
3425
+ // Task 1630a managing admin is optional. `adminUserId` omitted/blank the
3426
+ // sub-account carries no managingAdminUserId and its passive-intake tasks fall
3427
+ // back to the install's primary admin. A supplied adminUserId is normalized
3428
+ // and still validated below (a named-but-wrong admin is an error, not a
3429
+ // fallback it catches operator typos, matching account_reassign_admin).
3430
+ const managingAdminUserId = adminUserId && adminUserId.trim() ? adminUserId.trim() : undefined;
3329
3431
  // Task 1567 — the business owner's name is a hard precondition of the
3330
3432
  // sub-account. Refuse before any scaffold so a nameless create leaves no
3331
3433
  // partial account directory or rootless graph behind. The same predicate
@@ -3334,10 +3436,9 @@ eagerTool(server, "account_create", "Provision a new CLIENT sub-account on this
3334
3436
  process.stderr.write(`[account-create] op=refused reason=no-owner-name\n`);
3335
3437
  return { content: [{ type: "text", text: `account_create refused: give the client business owner's real name (ownerName). It cannot be blank or the placeholder "Owner". Ask the operator whose business this is.` }], isError: true };
3336
3438
  }
3337
- const houseAdminUserIds = readHouseAdminUserIds(ACCOUNTS_ROOT);
3338
- if (!houseAdminUserIds.includes(adminUserId)) {
3339
- process.stderr.write(`[account-lifecycle] op=create-refused reason=unknown-admin adminUserId=${adminUserId.slice(0, 8)}\n`);
3340
- return { content: [{ type: "text", text: `account_create refused: ${adminUserId} is not a current house admin. Call admin-list for the valid managing-admin choices.` }], isError: true };
3439
+ if (managingAdminUserId && !readHouseAdminUserIds(ACCOUNTS_ROOT).includes(managingAdminUserId)) {
3440
+ process.stderr.write(`[account-lifecycle] op=create-refused reason=unknown-admin adminUserId=${managingAdminUserId.slice(0, 8)}\n`);
3441
+ return { content: [{ type: "text", text: `account_create refused: ${managingAdminUserId} is not a current house admin. Call admin-list for the valid managing-admin choices, or omit adminUserId to leave the client unmanaged.` }], isError: true };
3341
3442
  }
3342
3443
  const newId = randomUUID();
3343
3444
  try {
@@ -3380,26 +3481,33 @@ eagerTool(server, "account_create", "Provision a new CLIENT sub-account on this
3380
3481
  finally {
3381
3482
  await seedSession.close();
3382
3483
  }
3383
- process.stderr.write(`[account-lifecycle] op=create accountId=${newId} dir-exists=${dirExists} root-seeded=${rootSeeded} managingAdmin=${adminUserId.slice(0, 8)}\n`);
3484
+ process.stderr.write(`[account-lifecycle] op=create accountId=${newId} dir-exists=${dirExists} root-seeded=${rootSeeded} managingAdmin=${managingAdminUserId ? managingAdminUserId.slice(0, 8) : "-"}\n`);
3384
3485
  if (!rootSeeded) {
3385
3486
  return { content: [{ type: "text", text: `account_create FAILED: graph root not seeded for ${newId} (business+admin read-back failed). The account directory was scaffolded but is rootless — run account_delete ${newId} and retry.` }], isError: true };
3386
3487
  }
3387
- // Task 1500 — persist the validated managing admin on the new sub-account.
3488
+ // Task 1500/1630 — persist the managing admin on the new sub-account when
3489
+ // one was named. Skipped when adminUserId was omitted: the account is left
3490
+ // unmanaged and its passive-intake tasks fall back to the primary admin.
3388
3491
  // Done after the root seed so a rootless failure never leaves a half-created
3389
3492
  // account claiming a manager. Its own try: at this point the account is
3390
3493
  // fully created and seeded, so a write failure must not be reported as a
3391
3494
  // generic create failure (which would push the operator to retry and
3392
3495
  // orphan a second account). Report the real state — created but unmanaged —
3393
3496
  // with the recovery action.
3394
- try {
3395
- setManagingAdmin(ACCOUNTS_ROOT, newId, adminUserId);
3396
- }
3397
- catch (err) {
3398
- const msg = err instanceof Error ? err.message : String(err);
3399
- process.stderr.write(`[account-lifecycle] op=create-admin-write-failed accountId=${newId} error=${msg}\n`);
3400
- return { content: [{ type: "text", text: `account_create: sub-account ${newId} was created and its graph root seeded, but recording the managing admin failed: ${msg}. The account exists with no managing admin — run account_delete ${newId} and retry.` }], isError: true };
3497
+ if (managingAdminUserId) {
3498
+ try {
3499
+ setManagingAdmin(ACCOUNTS_ROOT, newId, managingAdminUserId);
3500
+ }
3501
+ catch (err) {
3502
+ const msg = err instanceof Error ? err.message : String(err);
3503
+ process.stderr.write(`[account-lifecycle] op=create-admin-write-failed accountId=${newId} error=${msg}\n`);
3504
+ return { content: [{ type: "text", text: `account_create: sub-account ${newId} was created and its graph root seeded, but recording the managing admin failed: ${msg}. The account exists with no managing admin — run account_reassign_admin ${newId} <adminUserId> to record one.` }], isError: true };
3505
+ }
3401
3506
  }
3402
- return { content: [{ type: "text", text: `Created client sub-account ${newId}, managed by admin ${adminUserId}. Switch to it from the sub-account picker to work in its data.` }] };
3507
+ const managedNote = managingAdminUserId
3508
+ ? `managed by admin ${managingAdminUserId}`
3509
+ : `with no managing admin (its passive-intake tasks route to the primary admin; use account_reassign_admin to assign one)`;
3510
+ return { content: [{ type: "text", text: `Created client sub-account ${newId}, ${managedNote}. Switch to it from the sub-account picker to work in its data.` }] };
3403
3511
  }
3404
3512
  catch (err) {
3405
3513
  const msg = err instanceof Error ? err.message : String(err);
@@ -3425,6 +3533,39 @@ eagerTool(server, "account_reassign_admin", "Reassign a CLIENT sub-account's man
3425
3533
  process.stderr.write(`[account-lifecycle] op=reassign accountId=${accountId} from=${res.previousAdminUserId ? res.previousAdminUserId.slice(0, 8) : "-"} to=${adminUserId.slice(0, 8)}\n`);
3426
3534
  return { content: [{ type: "text", text: `Reassigned client sub-account ${accountId} to managing admin ${adminUserId}. It takes effect on the next passive intake.` }] };
3427
3535
  });
3536
+ eagerTool(server, "account_set_owner_name", "Name (or correct the name of) a CLIENT sub-account's business owner. Pass `accountId` and `name` (the owner's real name; refused if blank or the placeholder \"Owner\"). Writes the name onto the owner's owned Person — the canonical name source — renaming the existing one if present, else creating it. Use to repair a nameless owner (identity-audit flags these as op=nameless-owned-person). Does not touch managingAdminUserId. Operator-only.", {
3537
+ accountId: z.string().describe("The client sub-account whose owner to name."),
3538
+ name: z.string().describe("The owner's real name. Refused if blank or the placeholder \"Owner\"."),
3539
+ }, async ({ accountId, name }) => {
3540
+ if (!ACCOUNT_ID)
3541
+ return refuseNoAccount("account_set_owner_name");
3542
+ const TAG = "[account-set-owner-name]";
3543
+ if (isPlaceholderOwnerName(name)) {
3544
+ process.stderr.write(`${TAG} op=refused reason=no-owner-name account=${accountId.slice(0, 8)}\n`);
3545
+ return { content: [{ type: "text", text: `account_set_owner_name refused: give the owner's real name (not blank or "Owner").` }], isError: true };
3546
+ }
3547
+ // The tool names a CLIENT business owner. The house account's owner is an
3548
+ // operator identity, not a client owner, so refuse it explicitly rather than
3549
+ // renaming a house operator's Person by a mistyped id.
3550
+ if (isHouseAccount(ACCOUNTS_ROOT, accountId)) {
3551
+ process.stderr.write(`${TAG} op=refused reason=house-account account=${accountId.slice(0, 8)}\n`);
3552
+ return { content: [{ type: "text", text: `account_set_owner_name refused: ${accountId} is the house account. This tool names a client sub-account's business owner.` }], isError: true };
3553
+ }
3554
+ const session = getSession();
3555
+ try {
3556
+ const r = await setOwnerName({ session, accountId, name });
3557
+ process.stderr.write(`${TAG} op=named account=${accountId.slice(0, 8)} renamed=${r.personRenamed} created=${r.personCreated}\n`);
3558
+ return { content: [{ type: "text", text: `Owner of ${accountId} set to ${r.givenName}${r.familyName ? " " + r.familyName : ""} (${r.personRenamed ? "renamed existing Person" : "created Person"}).` }] };
3559
+ }
3560
+ catch (err) {
3561
+ const msg = err instanceof Error ? err.message : String(err);
3562
+ process.stderr.write(`${TAG} op=failed account=${accountId.slice(0, 8)} error=${msg}\n`);
3563
+ return { content: [{ type: "text", text: `account_set_owner_name FAILED: ${msg}` }], isError: true };
3564
+ }
3565
+ finally {
3566
+ await session.close();
3567
+ }
3568
+ });
3428
3569
  eagerTool(server, "account_delete", "Archive a CLIENT sub-account: move its directory to data/accounts/.trash/ so it no longer appears in the sub-account list. Graph data is RETAINED — run account_purge with the typed confirmation to irreversibly delete it. Refuses to archive the house sub-account. Pass the accountId to archive.", {
3429
3570
  accountId: z.string().describe("The client accountId (UUID) to archive."),
3430
3571
  }, async ({ accountId }) => {