@rubytech/create-maxy-code 0.1.443 → 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 (59) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/plugins/admin/.claude-plugin/plugin.json +1 -1
  3. package/payload/platform/plugins/admin/PLUGIN.md +1 -1
  4. package/payload/platform/plugins/admin/mcp/dist/index.js +40 -24
  5. package/payload/platform/plugins/admin/mcp/dist/index.js.map +1 -1
  6. package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.d.ts +7 -7
  7. package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.d.ts.map +1 -1
  8. package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.js +7 -7
  9. package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.js.map +1 -1
  10. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +8 -4
  11. package/payload/platform/plugins/docs/references/admin-session.md +2 -0
  12. package/payload/platform/plugins/docs/references/admin-ui.md +4 -0
  13. package/payload/platform/plugins/docs/references/cross-account-authority.md +3 -3
  14. package/payload/platform/plugins/outlook/references/auth.md +8 -0
  15. package/payload/platform/plugins/outlook/skills/outlook/SKILL.md +3 -0
  16. package/payload/platform/plugins/whatsapp/mcp/dist/__tests__/format-attachment-suffix.test.d.ts +2 -0
  17. package/payload/platform/plugins/whatsapp/mcp/dist/__tests__/format-attachment-suffix.test.d.ts.map +1 -0
  18. package/payload/platform/plugins/whatsapp/mcp/dist/__tests__/format-attachment-suffix.test.js +44 -0
  19. package/payload/platform/plugins/whatsapp/mcp/dist/__tests__/format-attachment-suffix.test.js.map +1 -0
  20. package/payload/platform/plugins/whatsapp/mcp/dist/format.d.ts +7 -0
  21. package/payload/platform/plugins/whatsapp/mcp/dist/format.d.ts.map +1 -1
  22. package/payload/platform/plugins/whatsapp/mcp/dist/format.js +27 -0
  23. package/payload/platform/plugins/whatsapp/mcp/dist/format.js.map +1 -1
  24. package/payload/platform/plugins/whatsapp/mcp/dist/index.js +6 -19
  25. package/payload/platform/plugins/whatsapp/mcp/dist/index.js.map +1 -1
  26. package/payload/platform/plugins/whatsapp/references/channels-whatsapp.md +3 -1
  27. package/payload/platform/plugins/work/mcp/dist/tools/work-create.d.ts.map +1 -1
  28. package/payload/platform/plugins/work/mcp/dist/tools/work-create.js +10 -7
  29. package/payload/platform/plugins/work/mcp/dist/tools/work-create.js.map +1 -1
  30. package/payload/platform/services/claude-session-manager/dist/http-server.d.ts +1 -0
  31. package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
  32. package/payload/platform/services/claude-session-manager/dist/http-server.js +99 -8
  33. package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
  34. package/payload/platform/services/claude-session-manager/dist/index.js +0 -13
  35. package/payload/platform/services/claude-session-manager/dist/index.js.map +1 -1
  36. package/payload/platform/services/claude-session-manager/dist/jsonl-path.d.ts +8 -0
  37. package/payload/platform/services/claude-session-manager/dist/jsonl-path.d.ts.map +1 -1
  38. package/payload/platform/services/claude-session-manager/dist/jsonl-path.js +11 -0
  39. package/payload/platform/services/claude-session-manager/dist/jsonl-path.js.map +1 -1
  40. package/payload/platform/services/claude-session-manager/dist/passive-admin-assignment.d.ts +20 -0
  41. package/payload/platform/services/claude-session-manager/dist/passive-admin-assignment.d.ts.map +1 -0
  42. package/payload/platform/services/claude-session-manager/dist/passive-admin-assignment.js +66 -0
  43. package/payload/platform/services/claude-session-manager/dist/passive-admin-assignment.js.map +1 -0
  44. package/payload/platform/services/claude-session-manager/dist/passive-spawn-tools-tail.d.ts +19 -0
  45. package/payload/platform/services/claude-session-manager/dist/passive-spawn-tools-tail.d.ts.map +1 -0
  46. package/payload/platform/services/claude-session-manager/dist/passive-spawn-tools-tail.js +50 -0
  47. package/payload/platform/services/claude-session-manager/dist/passive-spawn-tools-tail.js.map +1 -0
  48. package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
  49. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +14 -1
  50. package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
  51. package/payload/server/public/assets/{chat-DhD-NES_.js → chat-Dq-X-ia8.js} +1 -1
  52. package/payload/server/public/assets/{operator-zcIfeB14.js → operator-88m0DMl2.js} +1 -1
  53. package/payload/server/public/assets/page-BRfxFXyi.js +32 -0
  54. package/payload/server/public/assets/{public-C0ehZCdE.js → public-BX2MjsFY.js} +1 -1
  55. package/payload/server/public/chat.html +2 -2
  56. package/payload/server/public/operator.html +2 -2
  57. package/payload/server/public/public.html +2 -2
  58. package/payload/server/server.js +65 -13
  59. package/payload/server/public/assets/page-6fCnIb45.js +0 -32
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubytech/create-maxy-code",
3
- "version": "0.1.443",
3
+ "version": "0.1.444",
4
4
  "description": "Install Maxy — AI for Productive People",
5
5
  "bin": {
6
6
  "create-maxy-code": "./dist/index.js"
@@ -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_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.",
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_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
+ 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
@@ -3365,9 +3365,20 @@ eagerTool(server, "account_roster", "Canonical per-account identity roster for t
3365
3365
  const amByAccount = new Map();
3366
3366
  try {
3367
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;
3368
3379
  const res = await fetch(`http://127.0.0.1:${internalPort}/api/whatsapp/config`, {
3369
3380
  method: "POST",
3370
- headers: { "content-type": "application/json" },
3381
+ headers: scopeHeaders,
3371
3382
  body: JSON.stringify({ action: "list-account-managers" }),
3372
3383
  signal: AbortSignal.timeout(5000),
3373
3384
  });
@@ -3405,19 +3416,18 @@ eagerTool(server, "account_roster", "Canonical per-account identity roster for t
3405
3416
  process.stderr.write(`${TAG} op=roster accounts=${accounts.length} nameless-owners=${namelessOwners} absent-mgr=${absentMgr} dangling-mgr=${danglingMgr}\n`);
3406
3417
  return { content: [{ type: "text", text: accounts.length ? `Account roster:\n\n${lines.join("\n")}` : "No accounts found." }] };
3407
3418
  });
3408
- 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).", {
3409
- 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."),
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."),
3410
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."),
3411
3422
  }, async ({ adminUserId, ownerName }) => {
3412
3423
  if (!ACCOUNT_ID)
3413
3424
  return refuseNoAccount("account_create");
3414
- // Task 1500every client sub-account must carry a responsible house admin.
3415
- // Refuse (tool error, never a silent default) when none is named, or when
3416
- // the named userId is not a current house admin.
3417
- if (!adminUserId || !adminUserId.trim()) {
3418
- process.stderr.write(`[account-lifecycle] op=create-refused reason=no-admin adminUserId=-\n`);
3419
- 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 };
3420
- }
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;
3421
3431
  // Task 1567 — the business owner's name is a hard precondition of the
3422
3432
  // sub-account. Refuse before any scaffold so a nameless create leaves no
3423
3433
  // partial account directory or rootless graph behind. The same predicate
@@ -3426,10 +3436,9 @@ eagerTool(server, "account_create", "Provision a new CLIENT sub-account on this
3426
3436
  process.stderr.write(`[account-create] op=refused reason=no-owner-name\n`);
3427
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 };
3428
3438
  }
3429
- const houseAdminUserIds = readHouseAdminUserIds(ACCOUNTS_ROOT);
3430
- if (!houseAdminUserIds.includes(adminUserId)) {
3431
- process.stderr.write(`[account-lifecycle] op=create-refused reason=unknown-admin adminUserId=${adminUserId.slice(0, 8)}\n`);
3432
- 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 };
3433
3442
  }
3434
3443
  const newId = randomUUID();
3435
3444
  try {
@@ -3472,26 +3481,33 @@ eagerTool(server, "account_create", "Provision a new CLIENT sub-account on this
3472
3481
  finally {
3473
3482
  await seedSession.close();
3474
3483
  }
3475
- 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`);
3476
3485
  if (!rootSeeded) {
3477
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 };
3478
3487
  }
3479
- // 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.
3480
3491
  // Done after the root seed so a rootless failure never leaves a half-created
3481
3492
  // account claiming a manager. Its own try: at this point the account is
3482
3493
  // fully created and seeded, so a write failure must not be reported as a
3483
3494
  // generic create failure (which would push the operator to retry and
3484
3495
  // orphan a second account). Report the real state — created but unmanaged —
3485
3496
  // with the recovery action.
3486
- try {
3487
- setManagingAdmin(ACCOUNTS_ROOT, newId, adminUserId);
3488
- }
3489
- catch (err) {
3490
- const msg = err instanceof Error ? err.message : String(err);
3491
- process.stderr.write(`[account-lifecycle] op=create-admin-write-failed accountId=${newId} error=${msg}\n`);
3492
- 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
+ }
3493
3506
  }
3494
- 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.` }] };
3495
3511
  }
3496
3512
  catch (err) {
3497
3513
  const msg = err instanceof Error ? err.message : String(err);