@rubytech/create-maxy-code 0.1.437 → 0.1.438
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.
- package/package.json +1 -1
- package/payload/platform/lib/admin-access-password/__tests__/index.test.ts +31 -0
- package/payload/platform/lib/admin-access-password/dist/index.d.ts +8 -0
- package/payload/platform/lib/admin-access-password/dist/index.d.ts.map +1 -1
- package/payload/platform/lib/admin-access-password/dist/index.js +5 -1
- package/payload/platform/lib/admin-access-password/dist/index.js.map +1 -1
- package/payload/platform/lib/admin-access-password/src/index.ts +14 -1
- package/payload/platform/lib/admins-write/__tests__/index.test.ts +27 -0
- package/payload/platform/lib/admins-write/dist/index.d.ts +8 -0
- package/payload/platform/lib/admins-write/dist/index.d.ts.map +1 -1
- package/payload/platform/lib/admins-write/dist/index.js +5 -1
- package/payload/platform/lib/admins-write/dist/index.js.map +1 -1
- package/payload/platform/lib/admins-write/src/index.ts +14 -1
- package/payload/platform/plugins/admin/.claude-plugin/plugin.json +1 -1
- package/payload/platform/plugins/admin/PLUGIN.md +4 -2
- package/payload/platform/plugins/admin/mcp/dist/credential-identity.d.ts +23 -0
- package/payload/platform/plugins/admin/mcp/dist/credential-identity.d.ts.map +1 -0
- package/payload/platform/plugins/admin/mcp/dist/credential-identity.js +35 -0
- package/payload/platform/plugins/admin/mcp/dist/credential-identity.js.map +1 -0
- package/payload/platform/plugins/admin/mcp/dist/index.js +110 -57
- package/payload/platform/plugins/admin/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.d.ts +22 -0
- package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.d.ts.map +1 -1
- package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.js +62 -2
- package/payload/platform/plugins/admin/mcp/dist/tools/account-lifecycle.js.map +1 -1
- package/payload/platform/plugins/docs/references/admin-identity-gate.md +40 -0
- package/payload/platform/plugins/linkedin-import/skills/linkedin-import/references/profile.md +1 -1
- package/payload/platform/scripts/remediate-glsmith-identity.sh +500 -0
- package/payload/platform/scripts/seed-neo4j.sh +77 -12
- package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.js +20 -4
- package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/identity-audit.d.ts +51 -0
- package/payload/platform/services/claude-session-manager/dist/identity-audit.d.ts.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/identity-audit.js +103 -0
- package/payload/platform/services/claude-session-manager/dist/identity-audit.js.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/index.js +33 -0
- package/payload/platform/services/claude-session-manager/dist/index.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/mcp-user-binding.d.ts +25 -0
- package/payload/platform/services/claude-session-manager/dist/mcp-user-binding.d.ts.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/mcp-user-binding.js +42 -0
- package/payload/platform/services/claude-session-manager/dist/mcp-user-binding.js.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/redundant-operator-seat-audit.d.ts +44 -0
- package/payload/platform/services/claude-session-manager/dist/redundant-operator-seat-audit.d.ts.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/redundant-operator-seat-audit.js +127 -0
- package/payload/platform/services/claude-session-manager/dist/redundant-operator-seat-audit.js.map +1 -0
- package/payload/server/{chunk-LMLVOZ6G.js → chunk-UGPQCVIW.js} +11 -38
- package/payload/server/maxy-edge.js +1 -1
- package/payload/server/server.js +15 -16
package/payload/platform/services/claude-session-manager/dist/redundant-operator-seat-audit.js
ADDED
|
@@ -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
|
package/payload/platform/services/claude-session-manager/dist/redundant-operator-seat-audit.js.map
ADDED
|
@@ -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;AAClF,2EAA2E;AAC3E,oEAAoE;AACpE,4EAA4E;AAC5E,wEAAwE;AAExE,OAAO,KAAK,MAAM,cAAc,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,GAAG,GAAG,kBAAkB,CAAA;AAc9B;;8EAE8E;AAC9E,MAAM,UAAU,uBAAuB,CAAC,IAAmB;IACzD,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,OAAO,CAAA;AACxC,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,uBAAuB,CAAC,CAAuB;IAC7D,OAAO,GAAG,GAAG,uCAAuC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;AACxH,CAAC;AAED;;;6CAG6C;AAC7C,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAAyB,EACzB,SAAmB;IAEnB,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IACrC,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,GAAG,CAC3B;;qF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B,IAAI,CAAA;IACvC,OAAO;QACL,KAAK;YACH,IAAI,KAAK;gBAAE,OAAM;YACjB,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;gBACvB,KAAK,8BAA8B,CAAC,IAAI,CAAC,CAAA;YAC3C,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;YACnB,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU;gBAAE,KAAK,CAAC,KAAK,EAAE,CAAA;QACtD,CAAC;QACD,IAAI;YACF,IAAI,KAAK,EAAE,CAAC;gBACV,aAAa,CAAC,KAAK,CAAC,CAAA;gBACpB,KAAK,GAAG,IAAI,CAAA;YACd,CAAC;QACH,CAAC;KACF,CAAA;AACH,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
|
|
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,
|
|
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
|
|
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(
|
|
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
|
|
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
|
-
{
|
|
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.
|
|
5203
|
+
ON CREATE SET au.createdAt = $now,
|
|
5230
5204
|
au.accountId = $accountId, au.role = 'owner'
|
|
5231
|
-
ON MATCH SET au.
|
|
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,
|
|
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,
|
package/payload/server/server.js
CHANGED
|
@@ -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-
|
|
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(
|
|
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(
|
|
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
|
|
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
|
|
12237
|
-
if (result.source === "
|
|
12238
|
-
console.log(`[admin-identity] userName-source=
|
|
12239
|
-
return { userName: result.
|
|
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" ?
|
|
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
|
|
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(
|
|
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 (
|
|
22006
|
-
const res = await loadAdminUserName(
|
|
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) {
|