@rubytech/create-maxy-code 0.1.437 → 0.1.439

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 (60) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/lib/admin-access-password/__tests__/index.test.ts +31 -0
  3. package/payload/platform/lib/admin-access-password/dist/index.d.ts +8 -0
  4. package/payload/platform/lib/admin-access-password/dist/index.d.ts.map +1 -1
  5. package/payload/platform/lib/admin-access-password/dist/index.js +5 -1
  6. package/payload/platform/lib/admin-access-password/dist/index.js.map +1 -1
  7. package/payload/platform/lib/admin-access-password/src/index.ts +14 -1
  8. package/payload/platform/lib/admins-write/__tests__/index.test.ts +27 -0
  9. package/payload/platform/lib/admins-write/dist/index.d.ts +8 -0
  10. package/payload/platform/lib/admins-write/dist/index.d.ts.map +1 -1
  11. package/payload/platform/lib/admins-write/dist/index.js +5 -1
  12. package/payload/platform/lib/admins-write/dist/index.js.map +1 -1
  13. package/payload/platform/lib/admins-write/src/index.ts +14 -1
  14. package/payload/platform/plugins/admin/.claude-plugin/plugin.json +1 -1
  15. package/payload/platform/plugins/admin/PLUGIN.md +4 -2
  16. package/payload/platform/plugins/admin/mcp/dist/credential-identity.d.ts +23 -0
  17. package/payload/platform/plugins/admin/mcp/dist/credential-identity.d.ts.map +1 -0
  18. package/payload/platform/plugins/admin/mcp/dist/credential-identity.js +35 -0
  19. package/payload/platform/plugins/admin/mcp/dist/credential-identity.js.map +1 -0
  20. package/payload/platform/plugins/admin/mcp/dist/index.js +110 -57
  21. package/payload/platform/plugins/admin/mcp/dist/index.js.map +1 -1
  22. package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.d.ts +22 -0
  23. package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.d.ts.map +1 -1
  24. package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.js +62 -2
  25. package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.js.map +1 -1
  26. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +7 -1
  27. package/payload/platform/plugins/docs/references/admin-identity-gate.md +40 -0
  28. package/payload/platform/plugins/docs/references/internals.md +4 -0
  29. package/payload/platform/plugins/docs/references/plugins-guide.md +2 -0
  30. package/payload/platform/plugins/graph-viewer/.claude-plugin/plugin.json +13 -0
  31. package/payload/platform/plugins/graph-viewer/PLUGIN.md +1 -1
  32. package/payload/platform/plugins/graph-viewer/lib/mcp-spawn-tee/index.js +193 -0
  33. package/payload/platform/plugins/graph-viewer/lib/mcp-spawn-tee/package.json +3 -0
  34. package/payload/platform/plugins/linkedin-import/skills/linkedin-import/references/profile.md +1 -1
  35. package/payload/platform/scripts/remediate-glsmith-identity.sh +500 -0
  36. package/payload/platform/scripts/seed-neo4j.sh +77 -12
  37. package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
  38. package/payload/platform/services/claude-session-manager/dist/http-server.js +20 -4
  39. package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
  40. package/payload/platform/services/claude-session-manager/dist/identity-audit.d.ts +51 -0
  41. package/payload/platform/services/claude-session-manager/dist/identity-audit.d.ts.map +1 -0
  42. package/payload/platform/services/claude-session-manager/dist/identity-audit.js +103 -0
  43. package/payload/platform/services/claude-session-manager/dist/identity-audit.js.map +1 -0
  44. package/payload/platform/services/claude-session-manager/dist/index.js +69 -0
  45. package/payload/platform/services/claude-session-manager/dist/index.js.map +1 -1
  46. package/payload/platform/services/claude-session-manager/dist/mcp-user-binding.d.ts +25 -0
  47. package/payload/platform/services/claude-session-manager/dist/mcp-user-binding.d.ts.map +1 -0
  48. package/payload/platform/services/claude-session-manager/dist/mcp-user-binding.js +42 -0
  49. package/payload/platform/services/claude-session-manager/dist/mcp-user-binding.js.map +1 -0
  50. package/payload/platform/services/claude-session-manager/dist/redundant-operator-seat-audit.d.ts +44 -0
  51. package/payload/platform/services/claude-session-manager/dist/redundant-operator-seat-audit.d.ts.map +1 -0
  52. package/payload/platform/services/claude-session-manager/dist/redundant-operator-seat-audit.js +127 -0
  53. package/payload/platform/services/claude-session-manager/dist/redundant-operator-seat-audit.js.map +1 -0
  54. package/payload/platform/services/claude-session-manager/dist/tool-registration-drift.d.ts +57 -0
  55. package/payload/platform/services/claude-session-manager/dist/tool-registration-drift.d.ts.map +1 -0
  56. package/payload/platform/services/claude-session-manager/dist/tool-registration-drift.js +147 -0
  57. package/payload/platform/services/claude-session-manager/dist/tool-registration-drift.js.map +1 -0
  58. package/payload/server/{chunk-LMLVOZ6G.js → chunk-UGPQCVIW.js} +11 -38
  59. package/payload/server/maxy-edge.js +1 -1
  60. package/payload/server/server.js +15 -16
@@ -0,0 +1,127 @@
1
+ // Task 1568 — standing redundant-operator-seat audit. A role:"client" sub-account
2
+ // carries exactly one identity node, its business owner (AdminUser{role:'owner'}).
3
+ // Any other AdminUser{accountId} on a client account is a redundant operator seat:
4
+ // since Task 999 admin access is install-wide, so the seat grants nothing an
5
+ // install-wide admin does not already have, and it fragments identity. admin-add
6
+ // no longer creates one going forward; this periodic read is the only signal for
7
+ // seats persisted before that fix, because a redundant seat emits no error and
8
+ // does not reproduce on demand. Detector only — removal is a deliberate
9
+ // remediation (Task 1569), never an automatic timer-driven delete.
10
+ //
11
+ // admin-add seats carry no au.role (role 'admin' lives on the ADMIN_OF edge), so
12
+ // the predicate is not-the-owner rather than a role:'admin' match. Best-effort by
13
+ // construction: a Neo4j-unreachable read logs `op=unavailable` rather than
14
+ // crashing the manager (Neo4j may not be up at boot). Shape mirrors
15
+ // rootless-client-audit.ts: a pure predicate + formatter (unit-tested) + an
16
+ // impure collector + a start/stop factory whose setInterval is unref'd.
17
+ import neo4j from 'neo4j-driver';
18
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
19
+ import { join } from 'node:path';
20
+ const TAG = '[identity-audit]';
21
+ /** The redundant-seat invariant, read side: an AdminUser on a client account is a
22
+ * redundant operator seat unless it is the owner. admin-add seats carry no
23
+ * au.role, so the predicate is not-the-owner, never a role:'admin' match. */
24
+ export function isRedundantOperatorSeat(role) {
25
+ return (role ?? '').trim() !== 'owner';
26
+ }
27
+ /** One alarm line per flagged seat; ids truncated to 8 for readability. */
28
+ export function formatRedundantSeatLine(f) {
29
+ return `${TAG} op=redundant-operator-seat account=${f.accountId.slice(0, 8)} adminUserId=${f.adminUserId.slice(0, 8)}`;
30
+ }
31
+ /** Return every non-owner AdminUser seated on the given client accounts. One
32
+ * round-trip: the cypher returns all AdminUser{accountId} rows for the client
33
+ * ids and the not-owner filter is applied in JS (same predicate the audit
34
+ * exposes). Empty input issues no query. */
35
+ export async function auditRedundantOperatorSeats(session, clientIds) {
36
+ if (clientIds.length === 0)
37
+ return [];
38
+ const res = await session.run(`UNWIND $ids AS id
39
+ MATCH (au:AdminUser {accountId: id})
40
+ RETURN id AS accountId, coalesce(au.userId, '') AS adminUserId, au.role AS role`, { ids: clientIds });
41
+ const findings = [];
42
+ for (const rec of res.records) {
43
+ if (isRedundantOperatorSeat(rec.get('role'))) {
44
+ findings.push({
45
+ accountId: String(rec.get('accountId')),
46
+ adminUserId: String(rec.get('adminUserId')),
47
+ });
48
+ }
49
+ }
50
+ return findings;
51
+ }
52
+ /** Enumerate role:"client" accountIds under the accounts root (filesystem). */
53
+ function clientAccountIds(accountsRoot) {
54
+ let entries;
55
+ try {
56
+ entries = readdirSync(accountsRoot);
57
+ }
58
+ catch {
59
+ return [];
60
+ }
61
+ const out = [];
62
+ for (const entry of entries) {
63
+ const cfgPath = join(accountsRoot, entry, 'account.json');
64
+ if (!existsSync(cfgPath))
65
+ continue;
66
+ try {
67
+ const cfg = JSON.parse(readFileSync(cfgPath, 'utf-8'));
68
+ if (cfg.role === 'client')
69
+ out.push(entry);
70
+ }
71
+ catch {
72
+ // unparseable account.json — excluded
73
+ }
74
+ }
75
+ return out;
76
+ }
77
+ /** Run one audit pass and log an alarm line per flagged seat. Best-effort Neo4j:
78
+ * absent env or an unreachable/erroring read logs `op=unavailable` and never
79
+ * throws. A clean pass logs a single `op=ok` line so the audit's own liveness is
80
+ * visible. */
81
+ export async function emitRedundantOperatorSeatAudit(deps) {
82
+ if (!deps.neo4jUri || !deps.neo4jPassword) {
83
+ deps.logger(`${TAG} op=unavailable reason=no-neo4j-env`);
84
+ return;
85
+ }
86
+ const driver = neo4j.driver(deps.neo4jUri, neo4j.auth.basic(deps.neo4jUser, deps.neo4jPassword));
87
+ const session = driver.session();
88
+ try {
89
+ const findings = await auditRedundantOperatorSeats(session, clientAccountIds(deps.accountsRoot));
90
+ if (findings.length === 0) {
91
+ deps.logger(`${TAG} op=ok redundant-operator-seats=0`);
92
+ return;
93
+ }
94
+ for (const f of findings)
95
+ deps.logger(formatRedundantSeatLine(f));
96
+ }
97
+ catch (err) {
98
+ deps.logger(`${TAG} op=unavailable reason=${err instanceof Error ? err.message : String(err)}`);
99
+ }
100
+ finally {
101
+ await session.close();
102
+ await driver.close();
103
+ }
104
+ }
105
+ /** Standing periodic audit. Unref'd interval so it never holds the process open;
106
+ * each tick re-emits best-effort. */
107
+ export function createRedundantOperatorSeatAudit(deps) {
108
+ let timer = null;
109
+ return {
110
+ start() {
111
+ if (timer)
112
+ return;
113
+ timer = setInterval(() => {
114
+ void emitRedundantOperatorSeatAudit(deps);
115
+ }, deps.intervalMs);
116
+ if (typeof timer.unref === 'function')
117
+ timer.unref();
118
+ },
119
+ stop() {
120
+ if (timer) {
121
+ clearInterval(timer);
122
+ timer = null;
123
+ }
124
+ },
125
+ };
126
+ }
127
+ //# sourceMappingURL=redundant-operator-seat-audit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redundant-operator-seat-audit.js","sourceRoot":"","sources":["../src/redundant-operator-seat-audit.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,mFAAmF;AACnF,mFAAmF;AACnF,6EAA6E;AAC7E,iFAAiF;AACjF,iFAAiF;AACjF,+EAA+E;AAC/E,wEAAwE;AACxE,mEAAmE;AACnE,EAAE;AACF,iFAAiF;AACjF,kFAAkF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A;gBACpB,KAAK,GAAG,IAAI,CAAA;YACd,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,57 @@
1
+ export type ToolRegistrationDriftReason = 'not-installed' | 'no-mcpServers-manifest' | 'dist-missing';
2
+ /** The generated-manifest disposition of one tool-plugin on disk. A tool-plugin
3
+ * declares tools and ships an mcp/ directory (an mcpServers descriptor in the
4
+ * tool surface) — the plugins whose server must mount for their tools to be
5
+ * callable, whether admin- or specialist-facing. */
6
+ export interface ToolPluginManifestState {
7
+ manifestPresent: boolean;
8
+ hasMcpServers: boolean;
9
+ distPresent: boolean;
10
+ }
11
+ export interface ToolRegistrationDriftDefect {
12
+ accountId: string;
13
+ /** Tool-plugin dir name as it appears in account.json enabledPlugins. */
14
+ plugin: string;
15
+ /** The MCP server the mounted plugin would expose (== plugin dir name). */
16
+ expectedServer: string;
17
+ reason: ToolRegistrationDriftReason;
18
+ }
19
+ export interface ToolRegistrationDriftResult {
20
+ ok: boolean;
21
+ defects: ToolRegistrationDriftDefect[];
22
+ /** Count of (account, tool-plugin) pairs checked. */
23
+ inspected: number;
24
+ }
25
+ /** Classify one tool-plugin's manifest state into a drift reason, or null when
26
+ * the server would mount (manifest present, carries mcpServers, dist on disk). */
27
+ export declare function classifyToolRegistration(state: ToolPluginManifestState): ToolRegistrationDriftReason | null;
28
+ /** Cross-check each account's enabled tool-plugins against their generated
29
+ * manifests. `toolPlugins` maps a tool-plugin dir name to its on-disk manifest
30
+ * state; an enabledPlugins entry absent from that map is not a tool-plugin
31
+ * (platform non-tool plugin, skill-only premium sub, leaked foreign sub) and is
32
+ * out of scope here. */
33
+ export declare function assertToolRegistrationDrift(accounts: ReadonlyArray<{
34
+ accountId: string;
35
+ enabledPlugins: readonly string[];
36
+ }>, toolPlugins: ReadonlyMap<string, ToolPluginManifestState>): ToolRegistrationDriftResult;
37
+ /** Index plugin dirs across the roots, keyed by dir basename — the same key
38
+ * loadToolSurface and account.json enabledPlugins use. Platform plugins live at
39
+ * `<root>/<name>`; premium subs at `<premiumRoot>/<bundle>/plugins/<sub>`;
40
+ * standalone premium bundles at `<premiumRoot>/<bundle>`. */
41
+ export declare function indexPluginDirs(pluginRoots: readonly string[]): Map<string, string>;
42
+ /** Read the generated-manifest state of every named tool-plugin. A name with no
43
+ * dir on disk is reported as manifestPresent:false (→ not-installed), so a
44
+ * tool-plugin that vanished from disk is still surfaced rather than skipped. A
45
+ * present-but-corrupt manifest reads as manifestPresent:true, hasMcpServers:
46
+ * false (→ no-mcpServers-manifest).
47
+ *
48
+ * A tool-plugin whose `mcp:` server is a shared `platform/lib/<name>` binary
49
+ * rather than a plugin-local `mcp/` dir (e.g. `graph`, served by
50
+ * `platform/lib/graph-mcp`) is EXCLUDED from the result — the manifest
51
+ * generator only emits `mcpServers` for plugins that ship a plugin-local `mcp/`
52
+ * (its `hasMcp` predicate), so a shared-lib plugin's generated manifest carries
53
+ * no `mcpServers` by architecture, not by a `skip` flag. Judging it by the
54
+ * generated-manifest criterion would false-FATAL on every boot. This mirrors
55
+ * the generator's `hasMcp` check exactly. */
56
+ export declare function readToolPluginManifestStates(pluginRoots: readonly string[], toolPluginNames: Iterable<string>): Map<string, ToolPluginManifestState>;
57
+ //# sourceMappingURL=tool-registration-drift.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-registration-drift.d.ts","sourceRoot":"","sources":["../src/tool-registration-drift.ts"],"names":[],"mappings":"AAkBA,MAAM,MAAM,2BAA2B,GACnC,eAAe,GACf,wBAAwB,GACxB,cAAc,CAAA;AAElB;;;qDAGqD;AACrD,MAAM,WAAW,uBAAuB;IACtC,eAAe,EAAE,OAAO,CAAA;IACxB,aAAa,EAAE,OAAO,CAAA;IACtB,WAAW,EAAE,OAAO,CAAA;CACrB;AAED,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,MAAM,CAAA;IACjB,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAA;IACd,2EAA2E;IAC3E,cAAc,EAAE,MAAM,CAAA;IACtB,MAAM,EAAE,2BAA2B,CAAA;CACpC;AAED,MAAM,WAAW,2BAA2B;IAC1C,EAAE,EAAE,OAAO,CAAA;IACX,OAAO,EAAE,2BAA2B,EAAE,CAAA;IACtC,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;mFACmF;AACnF,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,uBAAuB,GAC7B,2BAA2B,GAAG,IAAI,CAKpC;AAED;;;;yBAIyB;AACzB,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,aAAa,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC,EACjF,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,uBAAuB,CAAC,GACxD,2BAA2B,CAe7B;AAED;;;8DAG8D;AAC9D,wBAAgB,eAAe,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAkCnF;AAED;;;;;;;;;;;;;8CAa8C;AAC9C,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,GAChC,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAmCtC"}
@@ -0,0 +1,147 @@
1
+ // Boot-time tool-availability reconciliation. Maxy enables a tool-bearing plugin
2
+ // per account (account.json enabledPlugins) and the plugin's PLUGIN.md declares
3
+ // tools plus an `mcp:` block — but only the GENERATED `.claude-plugin/plugin.json`
4
+ // mcpServers block makes Claude Code spawn the server. A plugin on
5
+ // `mcp-manifest: skip` keeps its PLUGIN.md `mcp:` block (so the source-level
6
+ // `mcp-allowlist-without-server` gate passes) while the generator drops mcpServers
7
+ // from the artifact CC consumes — the server never mounts and every tool it owns
8
+ // is "listed but not live", silent until an operator complains. This module names
9
+ // that gap at manager boot.
10
+ //
11
+ // Twin of skill-registration-drift.ts (which does the same for a sub-plugin's
12
+ // SKILLS). Like that check this one does NOT refuse boot — an unmounted
13
+ // tool-plugin must not brick the whole install; the manager logs a standing
14
+ // FATAL line per defect and continues (Task 1574).
15
+ import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
16
+ import { join } from 'node:path';
17
+ /** Classify one tool-plugin's manifest state into a drift reason, or null when
18
+ * the server would mount (manifest present, carries mcpServers, dist on disk). */
19
+ export function classifyToolRegistration(state) {
20
+ if (!state.manifestPresent)
21
+ return 'not-installed';
22
+ if (!state.hasMcpServers)
23
+ return 'no-mcpServers-manifest';
24
+ if (!state.distPresent)
25
+ return 'dist-missing';
26
+ return null;
27
+ }
28
+ /** Cross-check each account's enabled tool-plugins against their generated
29
+ * manifests. `toolPlugins` maps a tool-plugin dir name to its on-disk manifest
30
+ * state; an enabledPlugins entry absent from that map is not a tool-plugin
31
+ * (platform non-tool plugin, skill-only premium sub, leaked foreign sub) and is
32
+ * out of scope here. */
33
+ export function assertToolRegistrationDrift(accounts, toolPlugins) {
34
+ const defects = [];
35
+ let inspected = 0;
36
+ for (const account of accounts) {
37
+ for (const plugin of account.enabledPlugins) {
38
+ const state = toolPlugins.get(plugin);
39
+ if (!state)
40
+ continue; // not a tool-plugin on disk — out of scope
41
+ inspected += 1;
42
+ const reason = classifyToolRegistration(state);
43
+ if (reason) {
44
+ defects.push({ accountId: account.accountId, plugin, expectedServer: plugin, reason });
45
+ }
46
+ }
47
+ }
48
+ return { ok: defects.length === 0, defects, inspected };
49
+ }
50
+ /** Index plugin dirs across the roots, keyed by dir basename — the same key
51
+ * loadToolSurface and account.json enabledPlugins use. Platform plugins live at
52
+ * `<root>/<name>`; premium subs at `<premiumRoot>/<bundle>/plugins/<sub>`;
53
+ * standalone premium bundles at `<premiumRoot>/<bundle>`. */
54
+ export function indexPluginDirs(pluginRoots) {
55
+ const out = new Map();
56
+ const addIfPlugin = (name, dir) => {
57
+ if (name.startsWith('.'))
58
+ return;
59
+ try {
60
+ if (!statSync(dir).isDirectory())
61
+ return;
62
+ }
63
+ catch {
64
+ return;
65
+ }
66
+ if (existsSync(join(dir, 'PLUGIN.md')))
67
+ out.set(name, dir);
68
+ };
69
+ for (const root of pluginRoots) {
70
+ let entries;
71
+ try {
72
+ entries = readdirSync(root);
73
+ }
74
+ catch {
75
+ continue;
76
+ }
77
+ for (const name of entries) {
78
+ const dir = join(root, name);
79
+ addIfPlugin(name, dir); // platform plugin / standalone premium bundle
80
+ const subDir = join(dir, 'plugins'); // premium bundle subs
81
+ if (existsSync(subDir)) {
82
+ let subs;
83
+ try {
84
+ subs = readdirSync(subDir);
85
+ }
86
+ catch {
87
+ subs = [];
88
+ }
89
+ for (const sub of subs)
90
+ addIfPlugin(sub, join(subDir, sub));
91
+ }
92
+ }
93
+ }
94
+ return out;
95
+ }
96
+ /** Read the generated-manifest state of every named tool-plugin. A name with no
97
+ * dir on disk is reported as manifestPresent:false (→ not-installed), so a
98
+ * tool-plugin that vanished from disk is still surfaced rather than skipped. A
99
+ * present-but-corrupt manifest reads as manifestPresent:true, hasMcpServers:
100
+ * false (→ no-mcpServers-manifest).
101
+ *
102
+ * A tool-plugin whose `mcp:` server is a shared `platform/lib/<name>` binary
103
+ * rather than a plugin-local `mcp/` dir (e.g. `graph`, served by
104
+ * `platform/lib/graph-mcp`) is EXCLUDED from the result — the manifest
105
+ * generator only emits `mcpServers` for plugins that ship a plugin-local `mcp/`
106
+ * (its `hasMcp` predicate), so a shared-lib plugin's generated manifest carries
107
+ * no `mcpServers` by architecture, not by a `skip` flag. Judging it by the
108
+ * generated-manifest criterion would false-FATAL on every boot. This mirrors
109
+ * the generator's `hasMcp` check exactly. */
110
+ export function readToolPluginManifestStates(pluginRoots, toolPluginNames) {
111
+ const dirs = indexPluginDirs(pluginRoots);
112
+ const out = new Map();
113
+ for (const name of toolPluginNames) {
114
+ const dir = dirs.get(name);
115
+ if (!dir) {
116
+ out.set(name, { manifestPresent: false, hasMcpServers: false, distPresent: false });
117
+ continue;
118
+ }
119
+ // Mirror generate-plugin-manifests.mjs `hasMcp`: only a plugin-local mcp/
120
+ // dir yields a generated mcpServers block. Shared-lib-server plugins are a
121
+ // different mount architecture, out of this gate's remit.
122
+ const hasLocalMcp = existsSync(join(dir, 'mcp', 'dist', 'index.js')) ||
123
+ existsSync(join(dir, 'mcp', 'package.json'));
124
+ if (!hasLocalMcp)
125
+ continue;
126
+ const manifestPath = join(dir, '.claude-plugin', 'plugin.json');
127
+ const manifestPresent = existsSync(manifestPath);
128
+ let hasMcpServers = false;
129
+ if (manifestPresent) {
130
+ try {
131
+ const parsed = JSON.parse(readFileSync(manifestPath, 'utf-8'));
132
+ hasMcpServers =
133
+ !!parsed.mcpServers &&
134
+ typeof parsed.mcpServers === 'object' &&
135
+ !Array.isArray(parsed.mcpServers) &&
136
+ Object.keys(parsed.mcpServers).length > 0;
137
+ }
138
+ catch {
139
+ /* corrupt manifest → hasMcpServers stays false → no-mcpServers-manifest */
140
+ }
141
+ }
142
+ const distPresent = existsSync(join(dir, 'mcp', 'dist', 'index.js'));
143
+ out.set(name, { manifestPresent, hasMcpServers, distPresent });
144
+ }
145
+ return out;
146
+ }
147
+ //# sourceMappingURL=tool-registration-drift.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-registration-drift.js","sourceRoot":"","sources":["../src/tool-registration-drift.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,gFAAgF;AAChF,mFAAmF;AACnF,mEAAmE;AACnE,6EAA6E;AAC7E,mFAAmF;AACnF,iFAAiF;AACjF,kFAAkF;AAClF,4BAA4B;AAC5B,EAAE;AACF,8EAA8E;AAC9E,wEAAwE;AACxE,4EAA4E;AAC5E,mDAAmD;AAEnD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAiChC;mFACmF;AACnF,MAAM,UAAU,wBAAwB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CAAC;YAAC,MAAM,CAAC;gBACP,2EAA2E;YAC7E,CAAC;QACH,CAAC;QACD,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;QACpE,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,eAAe,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC,CAAA;IAChE,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -2774,7 +2774,8 @@ function rowIds(users) {
2774
2774
  function appendUsersAuditLine(audit, fields) {
2775
2775
  const sess = audit.session ? ` session=${id8(audit.session)}` : "";
2776
2776
  const actor = audit.actor.includes("-") ? id8(audit.actor) : audit.actor;
2777
- const line = `[users-audit] action=${fields.action} actor=${actor}${sess} field=${fields.field} rowsBefore=${fields.rowsBefore} rowsAfter=${fields.rowsAfter} ts=${(/* @__PURE__ */ new Date()).toISOString()}
2777
+ const targetFields = audit.target !== void 0 ? ` target=${audit.target.includes("-") ? id8(audit.target) : audit.target} explicitUserId=${audit.explicitUserId ? "true" : "false"}` : "";
2778
+ const line = `[users-audit] action=${fields.action} actor=${actor}${targetFields}${sess} field=${fields.field} rowsBefore=${fields.rowsBefore} rowsAfter=${fields.rowsAfter} ts=${(/* @__PURE__ */ new Date()).toISOString()}
2778
2779
  `;
2779
2780
  try {
2780
2781
  mkdirSync2(dirname(audit.logFile), { recursive: true, mode: 448 });
@@ -4515,7 +4516,7 @@ async function findRecentConversation(visitorId, accountId, agentSlug, maxAgeHou
4515
4516
  await session.close();
4516
4517
  }
4517
4518
  }
4518
- async function createNewAdminConversation(userId, accountId, cacheKey2, adminName, preMintedSessionId) {
4519
+ async function createNewAdminConversation(userId, accountId, cacheKey2, preMintedSessionId) {
4519
4520
  if (!userId || !cacheKey2 || !accountId) {
4520
4521
  console.error(`[admin/conversation-write] schema-violation userId=${userId ? "set" : "EMPTY"} cacheKey=${cacheKey2 ? "set" : "EMPTY"} accountId=${accountId ? "set" : "EMPTY"}`);
4521
4522
  return null;
@@ -4528,7 +4529,6 @@ async function createNewAdminConversation(userId, accountId, cacheKey2, adminNam
4528
4529
  WITH existing IS NULL AS adminUserCreated
4529
4530
  MERGE (au:AdminUser {userId: $userId})
4530
4531
  ON CREATE SET au.accountId = $accountId,
4531
- au.name = COALESCE($adminName, 'Admin'),
4532
4532
  au.createdAt = datetime(),
4533
4533
  au.scope = 'admin'
4534
4534
  CREATE (c:Conversation:AdminConversation {
@@ -4543,7 +4543,7 @@ async function createNewAdminConversation(userId, accountId, cacheKey2, adminNam
4543
4543
  updatedAt: datetime()
4544
4544
  })-[:STARTED_BY]->(au)
4545
4545
  RETURN adminUserCreated`,
4546
- { sessionId, accountId, userId, adminName: adminName ?? null }
4546
+ { sessionId, accountId, userId }
4547
4547
  );
4548
4548
  const adminUserCreated = result.records[0]?.get("adminUserCreated") === true;
4549
4549
  cacheSessionId(cacheKey2, sessionId);
@@ -5113,14 +5113,15 @@ async function getUserTimezone(accountId, userId) {
5113
5113
  await session.close();
5114
5114
  }
5115
5115
  }
5116
- async function loadAdminUserName(accountId, userId) {
5116
+ async function loadAdminUserName(userId) {
5117
5117
  const session = getSession();
5118
5118
  try {
5119
5119
  const result = await session.run(
5120
- `MATCH (au:AdminUser {userId: $userId})-[:OWNS]->(p:Person {accountId: $accountId})
5120
+ `MATCH (au:AdminUser {userId: $userId})-[:OWNS]->(p:Person)
5121
+ WHERE p.accountId = au.accountId
5121
5122
  RETURN p.givenName AS givenName, p.familyName AS familyName, p.avatar AS avatar
5122
5123
  LIMIT 1`,
5123
- { accountId, userId }
5124
+ { userId }
5124
5125
  );
5125
5126
  if (result.records.length === 0) {
5126
5127
  return { source: "fallback", reason: "no-person-node" };
@@ -5142,33 +5143,6 @@ async function loadAdminUserName(accountId, userId) {
5142
5143
  await session.close();
5143
5144
  }
5144
5145
  }
5145
- async function loadAdminDisplayIdentity(accountId, userId) {
5146
- const session = getSession();
5147
- try {
5148
- const result = await session.run(
5149
- `MATCH (au:AdminUser {userId: $userId})
5150
- OPTIONAL MATCH (au)-[:OWNS]->(p:Person {accountId: $accountId})
5151
- RETURN au.name AS name, p.avatar AS avatar
5152
- LIMIT 1`,
5153
- { accountId, userId }
5154
- );
5155
- if (result.records.length === 0) {
5156
- return { source: "fallback", reason: "no-admin-user" };
5157
- }
5158
- const name = result.records[0].get("name");
5159
- const avatar = result.records[0].get("avatar");
5160
- if (!name || name.trim().length === 0) {
5161
- return { source: "fallback", reason: "no-name" };
5162
- }
5163
- const trimmedAvatar = avatar && avatar.trim().length > 0 ? avatar.trim() : null;
5164
- return { source: "admin-user", name: name.trim(), avatar: trimmedAvatar };
5165
- } catch (err) {
5166
- console.error(`[admin-identity] loadAdminDisplayIdentity failed: ${err instanceof Error ? err.message : String(err)}`);
5167
- return { source: "fallback", reason: "neo4j-unreachable" };
5168
- } finally {
5169
- await session.close();
5170
- }
5171
- }
5172
5146
  async function loadPersonNameByElementId(accountId, personId) {
5173
5147
  const session = getSession();
5174
5148
  try {
@@ -5226,9 +5200,9 @@ async function writeAdminUserAndPerson(params) {
5226
5200
  // on the operator's first memory write. Mirrors seed-neo4j.sh:175-181
5227
5201
  // and the sibling writers (neo4j-store.ts:537,:931). COALESCE on MATCH
5228
5202
  // preserves an already-stamped node.
5229
- ON CREATE SET au.name = $fullName, au.createdAt = $now,
5203
+ ON CREATE SET au.createdAt = $now,
5230
5204
  au.accountId = $accountId, au.role = 'owner'
5231
- ON MATCH SET au.name = $fullName, au.updatedAt = $now,
5205
+ ON MATCH SET au.updatedAt = $now,
5232
5206
  au.accountId = COALESCE(au.accountId, $accountId),
5233
5207
  au.role = COALESCE(au.role, 'owner')
5234
5208
  WITH au
@@ -5274,7 +5248,7 @@ async function writeAdminUserAndPerson(params) {
5274
5248
  }
5275
5249
  RETURN reused, profileIsNew, elementId(p) AS personElementId,
5276
5250
  p.givenName AS givenName, p.familyName AS familyName`,
5277
- { userId, fullName: trimmed, accountId, givenName, familyName, now, personEmbedding, serverTimezone }
5251
+ { userId, accountId, givenName, familyName, now, personEmbedding, serverTimezone }
5278
5252
  );
5279
5253
  if (result.records.length === 0) {
5280
5254
  throw new Error("writeAdminUserAndPerson: no record returned");
@@ -6020,7 +5994,6 @@ export {
6020
5994
  renameConversation,
6021
5995
  getUserTimezone,
6022
5996
  loadAdminUserName,
6023
- loadAdminDisplayIdentity,
6024
5997
  loadPersonNameByElementId,
6025
5998
  writeAdminUserAndPerson,
6026
5999
  loadUserProfile,
@@ -16,7 +16,7 @@ import {
16
16
  sanitizeClientCorrId,
17
17
  vncLog,
18
18
  websockifyLog
19
- } from "./chunk-LMLVOZ6G.js";
19
+ } from "./chunk-UGPQCVIW.js";
20
20
  import "./chunk-PFF6I7KP.js";
21
21
 
22
22
  // server/edge.ts
@@ -70,7 +70,6 @@ import {
70
70
  linkConversationTranscript,
71
71
  listAdminSessions,
72
72
  listValidAccounts,
73
- loadAdminDisplayIdentity,
74
73
  loadAdminUserName,
75
74
  loadPersonNameByElementId,
76
75
  loadUserProfile,
@@ -112,7 +111,7 @@ import {
112
111
  vncLog,
113
112
  walkPremiumBundles,
114
113
  writeAdminUserAndPerson
115
- } from "./chunk-LMLVOZ6G.js";
114
+ } from "./chunk-UGPQCVIW.js";
116
115
  import {
117
116
  __commonJS,
118
117
  __toESM
@@ -8567,7 +8566,7 @@ app3.get("/", requireAdminSession, async (c) => {
8567
8566
  }
8568
8567
  const auid = adminUserIdBySession.get(row.sessionId);
8569
8568
  if (auid) {
8570
- const resolved = await loadAdminUserName(scopeAccountId, auid);
8569
+ const resolved = await loadAdminUserName(auid);
8571
8570
  if (resolved.source === "neo4j") {
8572
8571
  row.personName = resolved.joined;
8573
8572
  adminNameCount += 1;
@@ -9071,7 +9070,7 @@ app4.get("/conversations", requireAdminSession, async (c) => {
9071
9070
  return;
9072
9071
  }
9073
9072
  const idRes = classifyAdminUserId(users, admins, senderId);
9074
- const nameRes = idRes.kind === "resolved" ? await loadAdminUserName(account.accountId, idRes.userId) : null;
9073
+ const nameRes = idRes.kind === "resolved" ? await loadAdminUserName(idRes.userId) : null;
9075
9074
  const { name, reason } = resolveOperatorDisplay(idRes, nameRes);
9076
9075
  if (reason) console.error(`[wa-reader] op=operator-unresolved senderId=${senderId} reason=${reason}`);
9077
9076
  nameBySender.set(senderId, name);
@@ -11492,7 +11491,8 @@ function formatAuditRowIds(userIds) {
11492
11491
  function appendUsersAuditLine(audit, fields) {
11493
11492
  const sess = audit.session ? ` session=${id8(audit.session)}` : "";
11494
11493
  const actor = audit.actor.includes("-") ? id8(audit.actor) : audit.actor;
11495
- const line = `[users-audit] action=${fields.action} actor=${actor}${sess} field=${fields.field} rowsBefore=${fields.rowsBefore} rowsAfter=${fields.rowsAfter} ts=${(/* @__PURE__ */ new Date()).toISOString()}
11494
+ const targetFields = audit.target !== void 0 ? ` target=${audit.target.includes("-") ? id8(audit.target) : audit.target} explicitUserId=${audit.explicitUserId ? "true" : "false"}` : "";
11495
+ const line = `[users-audit] action=${fields.action} actor=${actor}${targetFields}${sess} field=${fields.field} rowsBefore=${fields.rowsBefore} rowsAfter=${fields.rowsAfter} ts=${(/* @__PURE__ */ new Date()).toISOString()}
11496
11496
  `;
11497
11497
  try {
11498
11498
  mkdirSync5(dirname7(audit.logFile), { recursive: true, mode: 448 });
@@ -12233,13 +12233,13 @@ var client_error_default = app10;
12233
12233
  // server/routes/admin/session.ts
12234
12234
  import { randomUUID as randomUUID8 } from "crypto";
12235
12235
  async function resolveUserIdentity(accountId, userId) {
12236
- const result = await loadAdminDisplayIdentity(accountId, userId);
12237
- if (result.source === "admin-user") {
12238
- console.log(`[admin-identity] userName-source=admin-user userId=${userId.slice(0, 8)} accountId=${accountId.slice(0, 8)} name=${result.name} avatar=${result.avatar ? "present" : "absent"}`);
12239
- return { userName: result.name, avatar: result.avatar };
12236
+ const result = await loadAdminUserName(userId);
12237
+ if (result.source === "neo4j") {
12238
+ console.log(`[admin-identity] userName-source=person userId=${userId.slice(0, 8)} accountId=${accountId.slice(0, 8)} name=${result.joined} avatar=${result.avatar ? "present" : "absent"}`);
12239
+ return { userName: result.joined, avatar: result.avatar };
12240
12240
  }
12241
12241
  console.log(`[admin-identity] userName-source=fallback reason=${result.reason} userId=${userId.slice(0, 8)} accountId=${accountId.slice(0, 8)}`);
12242
- const userName = result.reason === "neo4j-unreachable" ? "Owner" : void 0;
12242
+ const userName = result.reason === "neo4j-unreachable" ? void 0 : null;
12243
12243
  return { userName, avatar: null };
12244
12244
  }
12245
12245
  async function createAdminSession(accountId, thinkingView, userId, userName, role, avatar) {
@@ -12247,7 +12247,7 @@ async function createAdminSession(accountId, thinkingView, userId, userName, rol
12247
12247
  const effectiveThinkingView = thinkingView ?? account?.config.thinkingView ?? "default";
12248
12248
  const signedSessionToken = randomUUID8();
12249
12249
  const cacheKey = fingerprintSessionKey(signedSessionToken);
12250
- registerSession(cacheKey, "admin", accountId, void 0, userId, userName, role);
12250
+ registerSession(cacheKey, "admin", accountId, void 0, userId, userName ?? void 0, role);
12251
12251
  if (userId) setWantsPriorConversation(cacheKey);
12252
12252
  const businessName = await fetchAccountName(accountId) || void 0;
12253
12253
  let initialSessionId = null;
@@ -12324,7 +12324,7 @@ app11.get("/", async (c) => {
12324
12324
  const resolved = await resolveUserIdentity(accountId, restoredUserId);
12325
12325
  restoredUserName = resolved.userName;
12326
12326
  restoredAvatar = resolved.avatar;
12327
- if (resolved.userName !== void 0) {
12327
+ if (typeof resolved.userName === "string") {
12328
12328
  registerSession(cacheKey, "admin", accountId, void 0, restoredUserId, resolved.userName, role ?? void 0);
12329
12329
  }
12330
12330
  }
@@ -13476,7 +13476,7 @@ async function resolveOwnerProfileBlock(accountId, userId) {
13476
13476
  async function resolveAuthenticatedName(accountId, userId) {
13477
13477
  if (!userId) return void 0;
13478
13478
  try {
13479
- const res = await loadAdminUserName(accountId, userId);
13479
+ const res = await loadAdminUserName(userId);
13480
13480
  return res.source === "neo4j" ? res.joined : void 0;
13481
13481
  } catch (err) {
13482
13482
  console.error(
@@ -18381,7 +18381,6 @@ app34.post("/", requireAdminSession, async (c) => {
18381
18381
  adminUserId,
18382
18382
  convAccountId,
18383
18383
  `session:${plan.sessionId}`,
18384
- authenticatedName,
18385
18384
  plan.sessionId
18386
18385
  );
18387
18386
  console.log(
@@ -22002,8 +22001,8 @@ import { join as join34 } from "path";
22002
22001
  var ADMIN_ROLE2 = "admin";
22003
22002
  var WEBCHAT_CHANNEL2 = "webchat";
22004
22003
  var SESSION_META_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.meta\.json$/i;
22005
- var defaultResolveName = async (accountId, userId) => {
22006
- const res = await loadAdminUserName(accountId, userId);
22004
+ var defaultResolveName = async (_accountId, userId) => {
22005
+ const res = await loadAdminUserName(userId);
22007
22006
  return res.source === "neo4j" && res.joined.length > 0 ? res.joined : null;
22008
22007
  };
22009
22008
  async function readRaw2(path2) {