@rubytech/create-realagent 1.0.824 → 1.0.826
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/task-secrets/dist/index.d.ts +40 -0
- package/payload/platform/lib/task-secrets/dist/index.d.ts.map +1 -0
- package/payload/platform/lib/task-secrets/dist/index.js +44 -0
- package/payload/platform/lib/task-secrets/dist/index.js.map +1 -0
- package/payload/platform/lib/task-secrets/src/__tests__/redact-secrets.test.ts +127 -0
- package/payload/platform/lib/task-secrets/src/index.ts +77 -0
- package/payload/platform/lib/task-secrets/tsconfig.json +9 -0
- package/payload/platform/lib/task-secrets/vitest.config.ts +9 -0
- package/payload/platform/neo4j/schema.cypher +11 -0
- package/payload/platform/package.json +2 -2
- package/payload/platform/plugins/admin/skills/business-profile/SKILL.md +2 -2
- package/payload/platform/plugins/admin/skills/onboarding/SKILL.md +12 -9
- package/payload/platform/plugins/admin/skills/plugin-management/SKILL.md +4 -4
- package/payload/platform/plugins/admin/skills/public-agent-manager/SKILL.md +2 -2
- package/payload/platform/plugins/admin/skills/stream-log-review/SKILL.md +6 -6
- package/payload/platform/plugins/admin/skills/unzip-attachment/references/safety.md +1 -1
- package/payload/platform/plugins/cloudflare/references/manual-setup.md +3 -3
- package/payload/platform/plugins/cloudflare/skills/setup-tunnel/SKILL.md +4 -4
- package/payload/platform/plugins/docs/references/cloudflare.md +1 -1
- package/payload/platform/plugins/docs/references/internals.md +2 -2
- package/payload/platform/plugins/docs/references/memory-guide.md +1 -1
- package/payload/platform/plugins/docs/references/troubleshooting.md +1 -1
- package/payload/platform/plugins/linkedin-import/skills/linkedin-import/SKILL.md +2 -2
- package/payload/platform/plugins/linkedin-import/skills/linkedin-import/references/connections.md +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/profile-update-not-applicable.test.d.ts +2 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/profile-update-not-applicable.test.d.ts.map +1 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/profile-update-not-applicable.test.js +87 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/profile-update-not-applicable.test.js.map +1 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/profile-read.d.ts +2 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/profile-read.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/profile-read.js +100 -8
- package/payload/platform/plugins/memory/mcp/dist/tools/profile-read.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/profile-update.d.ts +19 -0
- package/payload/platform/plugins/memory/mcp/dist/tools/profile-update.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/profile-update.js +60 -27
- package/payload/platform/plugins/memory/mcp/dist/tools/profile-update.js.map +1 -1
- package/payload/platform/plugins/memory/references/graph-primitives.md +5 -5
- package/payload/platform/plugins/memory/references/schema-base.md +1 -1
- package/payload/platform/plugins/memory/skills/document-ingest/SKILL.md +6 -6
- package/payload/platform/plugins/tasks/PLUGIN.md +1 -1
- package/payload/platform/plugins/tasks/mcp/dist/index.js +11 -2
- package/payload/platform/plugins/tasks/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/tasks/mcp/dist/tools/task-create.d.ts +19 -2
- package/payload/platform/plugins/tasks/mcp/dist/tools/task-create.d.ts.map +1 -1
- package/payload/platform/plugins/tasks/mcp/dist/tools/task-create.js +17 -1
- package/payload/platform/plugins/tasks/mcp/dist/tools/task-create.js.map +1 -1
- package/payload/platform/plugins/whatsapp-import/skills/whatsapp-import/SKILL.md +9 -9
- package/payload/platform/plugins/whatsapp-import/skills/whatsapp-import/references/export-parse.md +2 -2
- package/payload/platform/plugins/whatsapp-import/skills/whatsapp-import-enrich/SKILL.md +8 -8
- package/payload/platform/templates/agents/admin/IDENTITY.md +1 -1
- package/payload/platform/templates/specialists/agents/database-operator.md +10 -10
- package/payload/server/chunk-AEHTLEC3.js +2302 -0
- package/payload/server/chunk-F5QBVHLS.js +1116 -0
- package/payload/server/chunk-HAXOJNAM.js +10079 -0
- package/payload/server/chunk-TDTQEKNP.js +593 -0
- package/payload/server/chunk-ZTBTX3IO.js +642 -0
- package/payload/server/client-pool-FXCFSUXR.js +32 -0
- package/payload/server/cloudflare-task-tracker-3WV7DZKQ.js +17 -0
- package/payload/server/cloudflare-task-tracker-BAMJY4MH.js +17 -0
- package/payload/server/maxy-edge.js +3 -3
- package/payload/server/neo4j-migrations-5FVPIWDW.js +428 -0
- package/payload/server/server.js +20 -14
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CLOUDFLARE_TASK_DIAGNOSTICS,
|
|
3
|
+
appendCloudflareSteps,
|
|
4
|
+
completeCloudflareTask,
|
|
5
|
+
openCloudflareTask,
|
|
6
|
+
readTunnelState,
|
|
7
|
+
recoverRunningCloudflareTasks
|
|
8
|
+
} from "./chunk-ZTBTX3IO.js";
|
|
9
|
+
import "./chunk-AEHTLEC3.js";
|
|
10
|
+
export {
|
|
11
|
+
CLOUDFLARE_TASK_DIAGNOSTICS,
|
|
12
|
+
appendCloudflareSteps,
|
|
13
|
+
completeCloudflareTask,
|
|
14
|
+
openCloudflareTask,
|
|
15
|
+
readTunnelState,
|
|
16
|
+
recoverRunningCloudflareTasks
|
|
17
|
+
};
|
|
@@ -16,10 +16,10 @@ import {
|
|
|
16
16
|
sanitizeClientCorrId,
|
|
17
17
|
streamActionEvents,
|
|
18
18
|
vncLog
|
|
19
|
-
} from "./chunk-
|
|
20
|
-
import "./chunk-
|
|
19
|
+
} from "./chunk-HAXOJNAM.js";
|
|
20
|
+
import "./chunk-F5QBVHLS.js";
|
|
21
21
|
import "./chunk-5OG7TUQL.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-AEHTLEC3.js";
|
|
23
23
|
|
|
24
24
|
// server/edge.ts
|
|
25
25
|
import { createServer, request as httpRequest } from "http";
|
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ACCOUNTS_DIR
|
|
3
|
+
} from "./chunk-5OG7TUQL.js";
|
|
4
|
+
import {
|
|
5
|
+
getSession,
|
|
6
|
+
projectAgent
|
|
7
|
+
} from "./chunk-AEHTLEC3.js";
|
|
8
|
+
|
|
9
|
+
// app/lib/neo4j-migrations.ts
|
|
10
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
11
|
+
import { resolve as resolve4 } from "path";
|
|
12
|
+
|
|
13
|
+
// ../neo4j/migrations/004-prune-alien-accounts.ts
|
|
14
|
+
import { readFileSync, readdirSync } from "fs";
|
|
15
|
+
import { resolve } from "path";
|
|
16
|
+
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
17
|
+
async function pruneAlienAccounts(driver, platformRoot) {
|
|
18
|
+
const accountsDir = resolve(platformRoot, "..", "data", "accounts");
|
|
19
|
+
const validIds = enumerateValidAccountIds(accountsDir);
|
|
20
|
+
if (validIds.size === 0) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
`refusing to prune: no valid accounts found under ${accountsDir} \u2014 corrupt install? not deleting anything to avoid wiping the entire graph.`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
const valid = Array.from(validIds);
|
|
26
|
+
const session = driver.session();
|
|
27
|
+
try {
|
|
28
|
+
const peek = await session.run(
|
|
29
|
+
`MATCH (n)
|
|
30
|
+
WHERE n.accountId IS NOT NULL AND NOT n.accountId IN $valid
|
|
31
|
+
RETURN DISTINCT n.accountId AS aid`,
|
|
32
|
+
{ valid }
|
|
33
|
+
);
|
|
34
|
+
const alienIds = [];
|
|
35
|
+
for (const record of peek.records) {
|
|
36
|
+
const aid = record.get("aid");
|
|
37
|
+
if (typeof aid === "string") alienIds.push(aid);
|
|
38
|
+
}
|
|
39
|
+
if (alienIds.length === 0) return;
|
|
40
|
+
const result = await session.run(
|
|
41
|
+
`MATCH (n)
|
|
42
|
+
WHERE n.accountId IS NOT NULL AND NOT n.accountId IN $valid
|
|
43
|
+
DETACH DELETE n
|
|
44
|
+
RETURN count(n) AS pruned`,
|
|
45
|
+
{ valid }
|
|
46
|
+
);
|
|
47
|
+
const prunedRaw = result.records[0]?.get("pruned");
|
|
48
|
+
const pruned = typeof prunedRaw === "number" ? prunedRaw : prunedRaw?.toNumber?.() ?? 0;
|
|
49
|
+
console.error(
|
|
50
|
+
`[graph-invariant] alien-accounts pruned=${pruned} accountIds=${alienIds.join(",")}`
|
|
51
|
+
);
|
|
52
|
+
} finally {
|
|
53
|
+
await session.close();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function enumerateValidAccountIds(accountsDir) {
|
|
57
|
+
const valid = /* @__PURE__ */ new Set();
|
|
58
|
+
let names;
|
|
59
|
+
try {
|
|
60
|
+
names = readdirSync(accountsDir);
|
|
61
|
+
} catch (err) {
|
|
62
|
+
if (err.code === "ENOENT") return valid;
|
|
63
|
+
throw err;
|
|
64
|
+
}
|
|
65
|
+
for (const name of names) {
|
|
66
|
+
if (!UUID_RE.test(name)) continue;
|
|
67
|
+
const configPath = resolve(accountsDir, name, "account.json");
|
|
68
|
+
try {
|
|
69
|
+
JSON.parse(readFileSync(configPath, "utf-8"));
|
|
70
|
+
valid.add(name);
|
|
71
|
+
} catch (err) {
|
|
72
|
+
const code = err.code ?? "parse-error";
|
|
73
|
+
if (code === "ENOENT") continue;
|
|
74
|
+
console.error(
|
|
75
|
+
`[graph-invariant] account-json-skip uuid=${name} reason=${code}`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return valid;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ../neo4j/migrations/004-project-admin-agent.ts
|
|
83
|
+
import { existsSync, readdirSync as readdirSync2 } from "fs";
|
|
84
|
+
import { resolve as resolve2 } from "path";
|
|
85
|
+
async function projectAccountAdmin(accountId, accountDir) {
|
|
86
|
+
const adminDir = resolve2(accountDir, "agents", "admin");
|
|
87
|
+
const configPath = resolve2(adminDir, "config.json");
|
|
88
|
+
if (!existsSync(adminDir) || !existsSync(configPath)) {
|
|
89
|
+
return { projected: 0, failed: 0 };
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
await projectAgent(accountId, accountDir, "admin");
|
|
93
|
+
return { projected: 1, failed: 0 };
|
|
94
|
+
} catch (err) {
|
|
95
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
96
|
+
console.error(
|
|
97
|
+
`[admin-agent-graph-backfill] account=${accountId.slice(0, 8)} project FAILED error="${msg}"`
|
|
98
|
+
);
|
|
99
|
+
return { projected: 0, failed: 1 };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async function backfillAdminHandledBy(driver, accountId) {
|
|
103
|
+
const session = driver.session();
|
|
104
|
+
try {
|
|
105
|
+
const result = await session.run(
|
|
106
|
+
`MATCH (c:AdminConversation {accountId: $accountId})
|
|
107
|
+
WHERE NOT EXISTS((c)-[:HANDLED_BY]->(:Agent))
|
|
108
|
+
OPTIONAL MATCH (a:Agent {accountId: $accountId, slug: 'admin'})
|
|
109
|
+
FOREACH (_ IN CASE WHEN a IS NULL THEN [] ELSE [1] END | MERGE (c)-[:HANDLED_BY]->(a))
|
|
110
|
+
RETURN
|
|
111
|
+
count(c) AS candidates,
|
|
112
|
+
sum(CASE WHEN a IS NULL THEN 0 ELSE 1 END) AS edges`,
|
|
113
|
+
{ accountId }
|
|
114
|
+
);
|
|
115
|
+
const toNum = (v) => {
|
|
116
|
+
if (typeof v === "number") return v;
|
|
117
|
+
if (v && typeof v.toNumber === "function") {
|
|
118
|
+
return v.toNumber();
|
|
119
|
+
}
|
|
120
|
+
return 0;
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
candidates: toNum(result.records[0]?.get("candidates")),
|
|
124
|
+
edges: toNum(result.records[0]?.get("edges"))
|
|
125
|
+
};
|
|
126
|
+
} finally {
|
|
127
|
+
await session.close();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async function backfillChannel(driver, accountId) {
|
|
131
|
+
const session = driver.session();
|
|
132
|
+
try {
|
|
133
|
+
const result = await session.run(
|
|
134
|
+
`MATCH (c:Conversation {accountId: $accountId})
|
|
135
|
+
WHERE c.channel IS NULL
|
|
136
|
+
SET c.channel = 'webchat'
|
|
137
|
+
RETURN count(c) AS backfilled`,
|
|
138
|
+
{ accountId }
|
|
139
|
+
);
|
|
140
|
+
const raw = result.records[0]?.get("backfilled");
|
|
141
|
+
if (typeof raw === "number") return raw;
|
|
142
|
+
if (raw && typeof raw.toNumber === "function") {
|
|
143
|
+
return raw.toNumber();
|
|
144
|
+
}
|
|
145
|
+
return 0;
|
|
146
|
+
} finally {
|
|
147
|
+
await session.close();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async function applyAdminAgentBackfill(driver, platformRoot) {
|
|
151
|
+
const accountsDir = resolve2(platformRoot, "..", "data", "accounts");
|
|
152
|
+
const start = Date.now();
|
|
153
|
+
if (!existsSync(accountsDir)) {
|
|
154
|
+
console.error(
|
|
155
|
+
`[admin-agent-graph-backfill] accounts-dir missing at ${accountsDir} \u2014 nothing to do`
|
|
156
|
+
);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const accountEntries = readdirSync2(accountsDir, { withFileTypes: true }).filter((e) => e.isDirectory());
|
|
160
|
+
console.error(
|
|
161
|
+
`[admin-agent-graph-backfill] start accounts=${accountEntries.length}`
|
|
162
|
+
);
|
|
163
|
+
let totalProjected = 0;
|
|
164
|
+
let totalFailed = 0;
|
|
165
|
+
let totalHandledByCandidates = 0;
|
|
166
|
+
let totalHandledByEdges = 0;
|
|
167
|
+
let totalChannelBackfilled = 0;
|
|
168
|
+
const perAccount = [];
|
|
169
|
+
for (const entry of accountEntries) {
|
|
170
|
+
const accountDir = resolve2(accountsDir, entry.name);
|
|
171
|
+
const accountId = entry.name;
|
|
172
|
+
const accountStart = Date.now();
|
|
173
|
+
const { projected, failed } = await projectAccountAdmin(
|
|
174
|
+
accountId,
|
|
175
|
+
accountDir
|
|
176
|
+
);
|
|
177
|
+
totalProjected += projected;
|
|
178
|
+
totalFailed += failed;
|
|
179
|
+
let handledByStats = { candidates: 0, edges: 0 };
|
|
180
|
+
let channelBackfilled = 0;
|
|
181
|
+
try {
|
|
182
|
+
handledByStats = await backfillAdminHandledBy(driver, accountId);
|
|
183
|
+
totalHandledByCandidates += handledByStats.candidates;
|
|
184
|
+
totalHandledByEdges += handledByStats.edges;
|
|
185
|
+
} catch (err) {
|
|
186
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
187
|
+
console.error(
|
|
188
|
+
`[admin-agent-graph-backfill] account=${accountId.slice(0, 8)} handled-by-backfill FAILED error="${msg}"`
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
try {
|
|
192
|
+
channelBackfilled = await backfillChannel(driver, accountId);
|
|
193
|
+
totalChannelBackfilled += channelBackfilled;
|
|
194
|
+
} catch (err) {
|
|
195
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
196
|
+
console.error(
|
|
197
|
+
`[admin-agent-graph-backfill] account=${accountId.slice(0, 8)} channel-backfill FAILED error="${msg}"`
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
perAccount.push({
|
|
201
|
+
accountId,
|
|
202
|
+
projected,
|
|
203
|
+
failed,
|
|
204
|
+
handledByCandidates: handledByStats.candidates,
|
|
205
|
+
handledByEdges: handledByStats.edges,
|
|
206
|
+
channelBackfilled
|
|
207
|
+
});
|
|
208
|
+
const ms2 = Date.now() - accountStart;
|
|
209
|
+
console.error(
|
|
210
|
+
`[admin-agent-graph-backfill] account=${accountId.slice(0, 8)} projected=${projected} failed=${failed} handled-by-candidates=${handledByStats.candidates} handled-by-edges=${handledByStats.edges} channel-backfilled=${channelBackfilled} ms=${ms2}`
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
const ms = Date.now() - start;
|
|
214
|
+
console.error(
|
|
215
|
+
`[admin-agent-graph-backfill] done totals: projected=${totalProjected} failed=${totalFailed} handled-by-candidates=${totalHandledByCandidates} handled-by-edges=${totalHandledByEdges} channel-backfilled=${totalChannelBackfilled} ms=${ms}`
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
async function main() {
|
|
219
|
+
if (!existsSync(ACCOUNTS_DIR)) {
|
|
220
|
+
console.error(
|
|
221
|
+
`[admin-agent-graph-backfill] ACCOUNTS_DIR missing at ${ACCOUNTS_DIR} \u2014 nothing to do`
|
|
222
|
+
);
|
|
223
|
+
process.exit(0);
|
|
224
|
+
}
|
|
225
|
+
const driverShim = { session: () => getSession() };
|
|
226
|
+
const platformRoot = resolve2(ACCOUNTS_DIR, "..", "..", "platform");
|
|
227
|
+
try {
|
|
228
|
+
await applyAdminAgentBackfill(driverShim, platformRoot);
|
|
229
|
+
process.exit(0);
|
|
230
|
+
} catch (err) {
|
|
231
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
232
|
+
console.error(`[admin-agent-graph-backfill] fatal error="${msg}"`);
|
|
233
|
+
process.exit(2);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (process.argv[1]?.endsWith("004-project-admin-agent.ts")) {
|
|
237
|
+
main().catch((err) => {
|
|
238
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
239
|
+
console.error(`[admin-agent-graph-backfill] fatal error="${msg}"`);
|
|
240
|
+
process.exit(2);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// ../neo4j/migrations/005-removed-review-feature.ts
|
|
245
|
+
import { resolve as resolve3 } from "path";
|
|
246
|
+
import { unlinkSync } from "fs";
|
|
247
|
+
import { homedir } from "os";
|
|
248
|
+
import { basename, dirname } from "path";
|
|
249
|
+
async function removeReviewFeature(driver, platformRoot) {
|
|
250
|
+
const session = driver.session();
|
|
251
|
+
let eventsDeleted = 0;
|
|
252
|
+
let alertsDeleted = 0;
|
|
253
|
+
try {
|
|
254
|
+
const eventResult = await session.run(
|
|
255
|
+
`MATCH (e:Event)
|
|
256
|
+
WHERE e.actionTool = "review-digest-compose"
|
|
257
|
+
OR e.eventId STARTS WITH "review-digest-"
|
|
258
|
+
DETACH DELETE e
|
|
259
|
+
RETURN count(e) AS deleted`
|
|
260
|
+
);
|
|
261
|
+
eventsDeleted = toNumber(eventResult.records[0]?.get("deleted"));
|
|
262
|
+
const alertResult = await session.run(
|
|
263
|
+
`MATCH (a:ReviewAlert)
|
|
264
|
+
DETACH DELETE a
|
|
265
|
+
RETURN count(a) AS deleted`
|
|
266
|
+
);
|
|
267
|
+
alertsDeleted = toNumber(alertResult.records[0]?.get("deleted"));
|
|
268
|
+
} finally {
|
|
269
|
+
await session.close();
|
|
270
|
+
}
|
|
271
|
+
const installDirName = basename(dirname(platformRoot));
|
|
272
|
+
const configDir = resolve3(homedir(), `.${installDirName}`);
|
|
273
|
+
const artefacts = [
|
|
274
|
+
resolve3(configDir, "logs", "review.log"),
|
|
275
|
+
resolve3(configDir, "review-rules.json"),
|
|
276
|
+
resolve3(configDir, "review-state.json"),
|
|
277
|
+
resolve3(configDir, "review-pending-alerts.jsonl")
|
|
278
|
+
];
|
|
279
|
+
for (const path of artefacts) {
|
|
280
|
+
try {
|
|
281
|
+
unlinkSync(path);
|
|
282
|
+
} catch (err) {
|
|
283
|
+
const code = err.code;
|
|
284
|
+
if (code === "ENOENT") continue;
|
|
285
|
+
console.error(
|
|
286
|
+
`[migration] removed-review-feature unlink-skip path=${path} reason=${code ?? "unknown"}`
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
console.error(
|
|
291
|
+
`[migration] removed-review-feature events=${eventsDeleted} alerts=${alertsDeleted}`
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
function toNumber(v) {
|
|
295
|
+
if (typeof v === "number") return v;
|
|
296
|
+
if (v && typeof v.toNumber === "function") {
|
|
297
|
+
return v.toNumber();
|
|
298
|
+
}
|
|
299
|
+
return 0;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// ../neo4j/migrations/006-prune-bogus-whatsapp-persons.ts
|
|
303
|
+
var POLLUTED_NAME_REGEX = "(?s).*[\\n\\[].*";
|
|
304
|
+
async function pruneBogusWhatsappPersons(driver) {
|
|
305
|
+
const session = driver.session();
|
|
306
|
+
try {
|
|
307
|
+
const nonAutoRes = await session.run(
|
|
308
|
+
`MATCH (p:Person {source: 'whatsapp'})
|
|
309
|
+
WHERE coalesce(p.participantStatus, '') <> 'auto-created'
|
|
310
|
+
AND p.name =~ $regex
|
|
311
|
+
RETURN elementId(p) AS elementId, p.name AS name`,
|
|
312
|
+
{ regex: POLLUTED_NAME_REGEX }
|
|
313
|
+
);
|
|
314
|
+
const skippedNonAuto = nonAutoRes.records.length;
|
|
315
|
+
for (const record of nonAutoRes.records) {
|
|
316
|
+
const elementId = record.get("elementId");
|
|
317
|
+
const name = record.get("name");
|
|
318
|
+
console.error(
|
|
319
|
+
`[migration:whatsapp-bogus-person-prune] non-auto-match elementId=${elementId} name=${JSON.stringify(name)}`
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
const matchedRes = await session.run(
|
|
323
|
+
`MATCH (p:Person {source: 'whatsapp', participantStatus: 'auto-created'})
|
|
324
|
+
WHERE p.name =~ $regex
|
|
325
|
+
RETURN count(p) AS matched`,
|
|
326
|
+
{ regex: POLLUTED_NAME_REGEX }
|
|
327
|
+
);
|
|
328
|
+
const matched = toNumber2(matchedRes.records[0]?.get("matched"));
|
|
329
|
+
if (matched === 0) {
|
|
330
|
+
console.error(
|
|
331
|
+
`[migration:whatsapp-bogus-person-prune] matched=0 deleted=0 skipped-non-auto=${skippedNonAuto}`
|
|
332
|
+
);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const deleteRes = await session.run(
|
|
336
|
+
`MATCH (p:Person {source: 'whatsapp', participantStatus: 'auto-created'})
|
|
337
|
+
WHERE p.name =~ $regex
|
|
338
|
+
DETACH DELETE p
|
|
339
|
+
RETURN count(p) AS deleted`,
|
|
340
|
+
{ regex: POLLUTED_NAME_REGEX }
|
|
341
|
+
);
|
|
342
|
+
const deleted = toNumber2(deleteRes.records[0]?.get("deleted"));
|
|
343
|
+
console.error(
|
|
344
|
+
`[migration:whatsapp-bogus-person-prune] matched=${matched} deleted=${deleted} skipped-non-auto=${skippedNonAuto}`
|
|
345
|
+
);
|
|
346
|
+
} finally {
|
|
347
|
+
await session.close();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function toNumber2(v) {
|
|
351
|
+
if (typeof v === "number") return v;
|
|
352
|
+
if (v && typeof v.toNumber === "function") {
|
|
353
|
+
return v.toNumber();
|
|
354
|
+
}
|
|
355
|
+
return 0;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// app/lib/neo4j-migrations.ts
|
|
359
|
+
var BOOT_MIGRATIONS = [
|
|
360
|
+
{ fileName: "003-person-name-eradicate.cypher", slug: "person-name-eradicate" }
|
|
361
|
+
];
|
|
362
|
+
async function applyBootMigrations(driver, platformRoot) {
|
|
363
|
+
for (const migration of BOOT_MIGRATIONS) {
|
|
364
|
+
await applyOne(driver, platformRoot, migration);
|
|
365
|
+
}
|
|
366
|
+
try {
|
|
367
|
+
await pruneAlienAccounts(driver, platformRoot);
|
|
368
|
+
} catch (err) {
|
|
369
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
370
|
+
console.error(`[migration] failed prune-alien-accounts error="${msg}"`);
|
|
371
|
+
}
|
|
372
|
+
try {
|
|
373
|
+
await applyAdminAgentBackfill(driver, platformRoot);
|
|
374
|
+
} catch (err) {
|
|
375
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
376
|
+
console.error(`[migration] failed admin-agent-graph-backfill error="${msg}"`);
|
|
377
|
+
}
|
|
378
|
+
try {
|
|
379
|
+
await removeReviewFeature(driver, platformRoot);
|
|
380
|
+
} catch (err) {
|
|
381
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
382
|
+
console.error(`[migration] failed removed-review-feature error="${msg}"`);
|
|
383
|
+
}
|
|
384
|
+
try {
|
|
385
|
+
await pruneBogusWhatsappPersons(driver);
|
|
386
|
+
} catch (err) {
|
|
387
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
388
|
+
console.error(`[migration] failed prune-bogus-whatsapp-persons error="${msg}"`);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
async function applyOne(driver, platformRoot, migration) {
|
|
392
|
+
const path = resolve4(platformRoot, "neo4j/migrations", migration.fileName);
|
|
393
|
+
let cypher;
|
|
394
|
+
try {
|
|
395
|
+
cypher = readFileSync2(path, "utf-8");
|
|
396
|
+
} catch (err) {
|
|
397
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
398
|
+
console.error(
|
|
399
|
+
`[migration] failed ${migration.slug} error=cannot-read-file path=${path} msg=${msg}`
|
|
400
|
+
);
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
const session = driver.session();
|
|
404
|
+
try {
|
|
405
|
+
const result = await session.run(cypher);
|
|
406
|
+
const record = result.records[0];
|
|
407
|
+
const removedRaw = record?.get("removed");
|
|
408
|
+
const removed = toNumber3(removedRaw);
|
|
409
|
+
console.error(
|
|
410
|
+
`[migration] applied ${migration.slug} removed=${removed}`
|
|
411
|
+
);
|
|
412
|
+
} catch (err) {
|
|
413
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
414
|
+
console.error(`[migration] failed ${migration.slug} error="${msg}"`);
|
|
415
|
+
} finally {
|
|
416
|
+
await session.close();
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
function toNumber3(v) {
|
|
420
|
+
if (typeof v === "number") return v;
|
|
421
|
+
if (v && typeof v.toNumber === "function") {
|
|
422
|
+
return v.toNumber();
|
|
423
|
+
}
|
|
424
|
+
return 0;
|
|
425
|
+
}
|
|
426
|
+
export {
|
|
427
|
+
applyBootMigrations
|
|
428
|
+
};
|
package/payload/server/server.js
CHANGED
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
vncLog,
|
|
52
52
|
waitForExit,
|
|
53
53
|
writeChromiumWrapper
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-HAXOJNAM.js";
|
|
55
55
|
import {
|
|
56
56
|
agentLogStream,
|
|
57
57
|
clearSessionHistory,
|
|
@@ -79,7 +79,7 @@ import {
|
|
|
79
79
|
sigtermFlushStreamLogs,
|
|
80
80
|
unregisterSession,
|
|
81
81
|
validateSession
|
|
82
|
-
} from "./chunk-
|
|
82
|
+
} from "./chunk-F5QBVHLS.js";
|
|
83
83
|
import {
|
|
84
84
|
ACCOUNTS_DIR,
|
|
85
85
|
PLATFORM_ROOT,
|
|
@@ -96,7 +96,7 @@ import {
|
|
|
96
96
|
completeCloudflareTask,
|
|
97
97
|
openCloudflareTask,
|
|
98
98
|
readTunnelState
|
|
99
|
-
} from "./chunk-
|
|
99
|
+
} from "./chunk-ZTBTX3IO.js";
|
|
100
100
|
import {
|
|
101
101
|
GREETING_DIRECTIVE,
|
|
102
102
|
HAIKU_MODEL,
|
|
@@ -128,7 +128,7 @@ import {
|
|
|
128
128
|
verifyAndGetConversationUpdatedAt,
|
|
129
129
|
verifyConversationOwnership,
|
|
130
130
|
writeAdminUserAndPerson
|
|
131
|
-
} from "./chunk-
|
|
131
|
+
} from "./chunk-AEHTLEC3.js";
|
|
132
132
|
|
|
133
133
|
// ../lib/graph-trash/dist/index.js
|
|
134
134
|
var require_dist = __commonJS({
|
|
@@ -7284,7 +7284,7 @@ var app11 = new Hono();
|
|
|
7284
7284
|
app11.post("/cancel", requireAdminSession, async (c) => {
|
|
7285
7285
|
const session_key = c.var.sessionKey;
|
|
7286
7286
|
try {
|
|
7287
|
-
const { interruptClient: interruptClient2 } = await import("./client-pool-
|
|
7287
|
+
const { interruptClient: interruptClient2 } = await import("./client-pool-FXCFSUXR.js");
|
|
7288
7288
|
await interruptClient2(session_key);
|
|
7289
7289
|
return c.json({ ok: true });
|
|
7290
7290
|
} catch (err) {
|
|
@@ -8654,6 +8654,11 @@ function addAliasDomain(hostname2) {
|
|
|
8654
8654
|
writeFileSync6(ALIAS_DOMAINS_PATH, JSON.stringify([...existing], null, 2) + "\n", "utf-8");
|
|
8655
8655
|
}
|
|
8656
8656
|
|
|
8657
|
+
// app/lib/cloudflare-setup-types.ts
|
|
8658
|
+
var CLOUDFLARE_SETUP_FORM_SCHEMA = {
|
|
8659
|
+
secretFields: ["password", "session_key", "messageId"]
|
|
8660
|
+
};
|
|
8661
|
+
|
|
8657
8662
|
// server/routes/admin/cloudflare.ts
|
|
8658
8663
|
var SETUP_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
8659
8664
|
var DOMAINS_TIMEOUT_MS = 40 * 1e3;
|
|
@@ -9012,19 +9017,20 @@ app21.post("/setup", requireAdminSession, async (c) => {
|
|
|
9012
9017
|
if (await isActionActive("cloudflare-setup")) {
|
|
9013
9018
|
return err("request", "Another Cloudflare setup is already running. Wait for it to finish before starting a new one.");
|
|
9014
9019
|
}
|
|
9020
|
+
const taskInputs = {};
|
|
9021
|
+
for (const [key, value] of Object.entries(body)) {
|
|
9022
|
+
if (value !== void 0 && value !== null && value !== "") {
|
|
9023
|
+
taskInputs[key] = value;
|
|
9024
|
+
}
|
|
9025
|
+
}
|
|
9015
9026
|
let cloudflareTask;
|
|
9016
9027
|
try {
|
|
9017
9028
|
cloudflareTask = await openCloudflareTask({
|
|
9018
9029
|
accountId,
|
|
9019
9030
|
conversationKey: sessionKey,
|
|
9020
|
-
inputsProvided:
|
|
9021
|
-
inputs:
|
|
9022
|
-
|
|
9023
|
-
adminDomain: body.adminDomain,
|
|
9024
|
-
publicLabel: body.publicLabel,
|
|
9025
|
-
publicDomain: body.publicDomain,
|
|
9026
|
-
apex: body.apex
|
|
9027
|
-
},
|
|
9031
|
+
inputsProvided: Object.keys(taskInputs),
|
|
9032
|
+
inputs: taskInputs,
|
|
9033
|
+
inputSchema: CLOUDFLARE_SETUP_FORM_SCHEMA,
|
|
9028
9034
|
messageId: typeof body.messageId === "string" && body.messageId.length > 0 ? body.messageId : void 0
|
|
9029
9035
|
});
|
|
9030
9036
|
log(`phase=task-opened taskId=${cloudflareTask.taskId}`);
|
|
@@ -12713,7 +12719,7 @@ autoDeliverPremiumPlugins(bootEntitlement?.purchasedPlugins ?? void 0);
|
|
|
12713
12719
|
(async () => {
|
|
12714
12720
|
if (!bootAccount) return;
|
|
12715
12721
|
try {
|
|
12716
|
-
const { recoverRunningCloudflareTasks } = await import("./cloudflare-task-tracker-
|
|
12722
|
+
const { recoverRunningCloudflareTasks } = await import("./cloudflare-task-tracker-BAMJY4MH.js");
|
|
12717
12723
|
const result = await recoverRunningCloudflareTasks(
|
|
12718
12724
|
bootAccount.accountId,
|
|
12719
12725
|
configDirForWhatsApp,
|