@rubytech/create-realagent 1.0.870 → 1.0.871

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 (25) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/scripts/__tests__/admin-persist-audit.test.ts +182 -0
  3. package/payload/platform/scripts/admin-persist-audit.ts +43 -17
  4. package/payload/server/chunk-5U36PKG4.js +11326 -0
  5. package/payload/server/chunk-NDEQBCVI.js +1160 -0
  6. package/payload/server/client-pool-XAEDMS5D.js +34 -0
  7. package/payload/server/maxy-edge.js +2 -2
  8. package/payload/server/public/assets/{Checkbox-B9hff9s8.js → Checkbox-CDffo5el.js} +1 -1
  9. package/payload/server/public/assets/{admin-Cpi6L_g7.js → admin-BSdV45P5.js} +2 -2
  10. package/payload/server/public/assets/data-vFVtOwuC.js +1 -0
  11. package/payload/server/public/assets/{graph-labels-ChinGFwI.js → graph-labels-C-KsUF_B.js} +1 -1
  12. package/payload/server/public/assets/graph-q802cxLY.js +1 -0
  13. package/payload/server/public/assets/{jsx-runtime-CVA1ZrPS.css → jsx-runtime-C1hGBzVx.css} +1 -1
  14. package/payload/server/public/assets/{page-OVrxtgOZ.js → page-B5b7tyz-.js} +1 -1
  15. package/payload/server/public/assets/{page-DqPf65sS.js → page-DsW7P98i.js} +1 -1
  16. package/payload/server/public/assets/{public-CJN5KAiK.js → public-BkNXx-3G.js} +1 -1
  17. package/payload/server/public/assets/{useVoiceRecorder-DyVx7e7a.js → useVoiceRecorder-DCVSlfUk.js} +1 -1
  18. package/payload/server/public/data.html +5 -5
  19. package/payload/server/public/graph.html +6 -6
  20. package/payload/server/public/index.html +8 -8
  21. package/payload/server/public/public.html +5 -5
  22. package/payload/server/server.js +38 -18
  23. package/payload/server/public/assets/data-Da6iYRW1.js +0 -1
  24. package/payload/server/public/assets/graph-BHq-JYwV.js +0 -1
  25. /package/payload/server/public/assets/{jsx-runtime-nxP_2eNo.js → jsx-runtime-DFrHsKhm.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubytech/create-realagent",
3
- "version": "1.0.870",
3
+ "version": "1.0.871",
4
4
  "description": "Install Real Agent — Built for agents. By agents.",
5
5
  "bin": {
6
6
  "create-realagent": "./dist/index.js"
@@ -0,0 +1,182 @@
1
+ /**
2
+ * Task 943 — admin-persist-audit.
3
+ *
4
+ * Pins Task 940 success criterion #7: the audit harness counts JSONL
5
+ * assistant turns + render-component blocks against Neo4j `:Message` +
6
+ * `:Component` rows for a `conversationId`, prints one
7
+ *
8
+ * [admin-persist-audit] convId=<conv> sdkTurnUuid=<uuid> expected=<message|component> missing reason=neo4j-row-absent
9
+ *
10
+ * line per divergence, and exits non-zero on mismatch.
11
+ *
12
+ * The test mocks the Neo4j surface (`getRecentMessages`, `getSession`) so
13
+ * `runAudit` is a pure function of (JSONL fixture, Neo4j seed). The
14
+ * harness reads the fixture with the real `replayJsonl`, so the matching
15
+ * key (role + content) is verified end-to-end without a graph connection.
16
+ */
17
+ import { resolve } from "node:path";
18
+ import { describe, it, expect, vi, beforeEach } from "vitest";
19
+
20
+ const FIXTURE_PATH = resolve(__dirname, "../../ui/app/lib/__tests__/fixtures/task-940-session.jsonl");
21
+
22
+ // Mock the Neo4j surface. The audit harness imports `getRecentMessages`
23
+ // and `getSession` from `platform/ui/app/lib/neo4j-store`. We replace
24
+ // both with vi-managed fakes; each test reseeds them as needed.
25
+ const getRecentMessagesMock = vi.fn<[string, number?], Promise<Array<{
26
+ role: "user" | "assistant";
27
+ content: string;
28
+ messageId: string;
29
+ components?: Array<{ componentId: string; submitted: boolean }>;
30
+ }>>>();
31
+
32
+ const sessionRunMock = vi.fn<[string, Record<string, unknown>], Promise<{
33
+ records: Array<{ get(key: string): unknown }>;
34
+ }>>();
35
+ const sessionCloseMock = vi.fn<[], Promise<void>>();
36
+
37
+ vi.mock("../../ui/app/lib/neo4j-store", () => ({
38
+ getRecentMessages: (...args: Parameters<typeof getRecentMessagesMock>) => getRecentMessagesMock(...args),
39
+ getSession: () => ({
40
+ run: (cypher: string, params: Record<string, unknown>) => sessionRunMock(cypher, params),
41
+ close: () => sessionCloseMock(),
42
+ }),
43
+ }));
44
+
45
+ vi.mock("../../ui/app/lib/claude-agent/account", () => ({
46
+ ACCOUNTS_DIR: "/tmp/maxy-accounts-fixture",
47
+ }));
48
+
49
+ // PERSISTENT_COMPONENTS is also imported by the audit harness for the
50
+ // :KnowledgeDocument projection check. We mock the set so the test does
51
+ // not depend on the runtime persistent-component list — the fixture
52
+ // components (`document-editor`, `quick-chart`) are both included.
53
+ vi.mock("../../lib/persistent-components/src/index", () => ({
54
+ PERSISTENT_COMPONENTS: new Set<string>(["document-editor", "quick-chart"]),
55
+ isPersistentComponent: (name: string) => name === "document-editor" || name === "quick-chart",
56
+ }));
57
+
58
+ import { runAudit, type AuditArgs } from "../admin-persist-audit";
59
+
60
+ const CONV_ID = "11111111-aaaa-bbbb-cccc-dddddddddddd";
61
+ const ACCOUNT_ID = "b3b638d9-9999-8888-7777-666666666666";
62
+
63
+ const buildArgs = (): AuditArgs => ({
64
+ conversationId: CONV_ID,
65
+ accountId: ACCOUNT_ID,
66
+ jsonlPath: FIXTURE_PATH,
67
+ });
68
+
69
+ const captureConsole = () => {
70
+ const out: string[] = [];
71
+ const err: string[] = [];
72
+ const logSpy = vi.spyOn(console, "log").mockImplementation((...a) => { out.push(a.join(" ")); });
73
+ const errSpy = vi.spyOn(console, "error").mockImplementation((...a) => { err.push(a.join(" ")); });
74
+ return { out, err, restore: () => { logSpy.mockRestore(); errSpy.mockRestore(); } };
75
+ };
76
+
77
+ describe("Task 940 SC7 — admin-persist-audit divergence reporting", () => {
78
+ beforeEach(() => {
79
+ getRecentMessagesMock.mockReset();
80
+ sessionRunMock.mockReset();
81
+ sessionCloseMock.mockReset();
82
+ sessionCloseMock.mockResolvedValue(undefined);
83
+ });
84
+
85
+ it("Neo4j seed missing the assistant turn (and its components) → exit=1, one missing-message line + one missing-component line per component", async () => {
86
+ // Fixture has 1 user + 1 assistant (with 2 components). Seed Neo4j
87
+ // with the user only — the assistant turn is the silent persist
88
+ // failure the audit must surface.
89
+ getRecentMessagesMock.mockResolvedValue([
90
+ { role: "user", content: "Please render the doc and a chart.", messageId: "neo4j-user", components: [] },
91
+ ]);
92
+ // No persistent-component rows in Neo4j (since the assistant turn
93
+ // never persisted). The :KnowledgeDocument check finds nothing → no
94
+ // additional kd-absent divergences.
95
+ sessionRunMock.mockResolvedValue({ records: [] });
96
+
97
+ const cap = captureConsole();
98
+ try {
99
+ const code = await runAudit(buildArgs());
100
+ expect(code).toBe(1);
101
+
102
+ // One divergence line for the assistant message itself…
103
+ const messageMisses = cap.out.filter((l) => /expected=message missing reason=neo4j-row-absent/.test(l));
104
+ expect(messageMisses).toHaveLength(1);
105
+ expect(messageMisses[0]).toMatch(/sdkTurnUuid=22222222/); // matches fixture uuid prefix
106
+
107
+ // …plus one divergence line per component sibling that was queued
108
+ // by the assistant turn's render-component blocks.
109
+ const componentMisses = cap.out.filter((l) => /expected=component .* missing reason=neo4j-row-absent/.test(l));
110
+ expect(componentMisses).toHaveLength(2);
111
+ expect(componentMisses[0]).toMatch(/component_name=document-editor ordinal=0/);
112
+ expect(componentMisses[1]).toMatch(/component_name=quick-chart ordinal=1/);
113
+
114
+ // Status summary line ends with status=mismatch.
115
+ expect(cap.out.some((l) => /status=mismatch/.test(l))).toBe(true);
116
+ } finally {
117
+ cap.restore();
118
+ }
119
+ });
120
+
121
+ it("Neo4j seed in lockstep with JSONL → exit=0, status=ok, zero divergence lines", async () => {
122
+ getRecentMessagesMock.mockResolvedValue([
123
+ { role: "user", content: "Please render the doc and a chart.", messageId: "neo4j-user", components: [] },
124
+ {
125
+ role: "assistant",
126
+ content: "Here is the doc.\n\nAnd a chart follows.",
127
+ messageId: "neo4j-asst",
128
+ components: [
129
+ { componentId: "comp-doc", submitted: false },
130
+ { componentId: "comp-chart", submitted: false },
131
+ ],
132
+ },
133
+ ]);
134
+ // Persistent-component KD projection: both rows have a sibling
135
+ // :KnowledgeDocument row → no kd-absent divergences.
136
+ sessionRunMock.mockResolvedValue({
137
+ records: [
138
+ { get: (k: string) => ({ componentId: "comp-doc", componentName: "document-editor", accountId: ACCOUNT_ID, attachmentId: "att-doc", hasProjection: true })[k] },
139
+ { get: (k: string) => ({ componentId: "comp-chart", componentName: "quick-chart", accountId: ACCOUNT_ID, attachmentId: "att-chart", hasProjection: true })[k] },
140
+ ],
141
+ });
142
+
143
+ const cap = captureConsole();
144
+ try {
145
+ const code = await runAudit(buildArgs());
146
+ expect(code).toBe(0);
147
+ expect(cap.out.some((l) => /divergences=0 status=ok/.test(l))).toBe(true);
148
+ expect(cap.out.some((l) => /missing reason=neo4j-row-absent/.test(l))).toBe(false);
149
+ } finally {
150
+ cap.restore();
151
+ }
152
+ });
153
+
154
+ it("Neo4j throw on getRecentMessages → exit=2 (invocation error), no divergence lines", async () => {
155
+ getRecentMessagesMock.mockRejectedValue(new Error("bolt://neo4j unreachable"));
156
+ sessionRunMock.mockResolvedValue({ records: [] });
157
+
158
+ const cap = captureConsole();
159
+ try {
160
+ const code = await runAudit(buildArgs());
161
+ expect(code).toBe(2);
162
+ expect(cap.err.some((l) => /neo4j-read-failed/.test(l) && /bolt:\/\/neo4j unreachable/.test(l))).toBe(true);
163
+ } finally {
164
+ cap.restore();
165
+ }
166
+ });
167
+
168
+ it("JSONL absent → exit=2 (invocation error)", async () => {
169
+ const cap = captureConsole();
170
+ try {
171
+ const code = await runAudit({
172
+ conversationId: CONV_ID,
173
+ accountId: ACCOUNT_ID,
174
+ jsonlPath: resolve(__dirname, "fixtures/does-not-exist.jsonl"),
175
+ });
176
+ expect(code).toBe(2);
177
+ expect(cap.err.some((l) => /jsonl absent path=/.test(l))).toBe(true);
178
+ } finally {
179
+ cap.restore();
180
+ }
181
+ });
182
+ });
@@ -37,14 +37,19 @@ import { ACCOUNTS_DIR } from "../ui/app/lib/claude-agent/account";
37
37
  import { getRecentMessages, getSession } from "../ui/app/lib/neo4j-store";
38
38
  import { PERSISTENT_COMPONENTS } from "../lib/persistent-components/src/index";
39
39
 
40
- interface Args {
40
+ // Task 943 — `AuditArgs` and `runAudit` are exported so the test
41
+ // (`platform/scripts/__tests__/admin-persist-audit.test.ts`) can mock the
42
+ // Neo4j surface and drive the audit with synthetic JSONL + Neo4j seeds,
43
+ // verifying the divergence-line shape and non-zero exit code without
44
+ // re-executing the live session or requiring a real graph connection.
45
+ export interface AuditArgs {
41
46
  conversationId: string;
42
47
  accountId: string;
43
48
  jsonlPath: string;
44
49
  }
45
50
 
46
- function parseArgs(argv: string[]): Args | { error: string } {
47
- const out: Partial<Args> = {};
51
+ function parseArgs(argv: string[]): AuditArgs | { error: string } {
52
+ const out: Partial<AuditArgs> = {};
48
53
  let sessionId: string | undefined;
49
54
  let jsonlOverride: string | undefined;
50
55
  for (const a of argv) {
@@ -66,16 +71,11 @@ function parseArgs(argv: string[]): Args | { error: string } {
66
71
  } else {
67
72
  return { error: "either --jsonl or --session-id required" };
68
73
  }
69
- return out as Args;
74
+ return out as AuditArgs;
70
75
  }
71
76
 
72
- async function main(): Promise<number> {
73
- const parsed = parseArgs(process.argv.slice(2));
74
- if ("error" in parsed) {
75
- console.error(`[admin-persist-audit] usage error: ${parsed.error}`);
76
- return 2;
77
- }
78
- const { conversationId, jsonlPath } = parsed;
77
+ export async function runAudit(args: AuditArgs): Promise<number> {
78
+ const { conversationId, jsonlPath } = args;
79
79
 
80
80
  if (!existsSync(jsonlPath)) {
81
81
  console.error(`[admin-persist-audit] jsonl absent path=${jsonlPath} convId=${conversationId.slice(0, 8)}`);
@@ -183,9 +183,35 @@ async function main(): Promise<number> {
183
183
  return 1;
184
184
  }
185
185
 
186
- main()
187
- .then((code) => process.exit(code))
188
- .catch((err) => {
189
- console.error(`[admin-persist-audit] crashed: ${err instanceof Error ? err.stack : String(err)}`);
190
- process.exit(2);
191
- });
186
+ async function main(): Promise<number> {
187
+ const parsed = parseArgs(process.argv.slice(2));
188
+ if ("error" in parsed) {
189
+ console.error(`[admin-persist-audit] usage error: ${parsed.error}`);
190
+ return 2;
191
+ }
192
+ return runAudit(parsed);
193
+ }
194
+
195
+ // Task 943 — only invoke main() when this script is executed directly.
196
+ // Importing the module (e.g. from `admin-persist-audit.test.ts`) reads
197
+ // `runAudit` and `AuditArgs` without firing the top-level argv parser or
198
+ // process.exit, which would otherwise kill the vitest worker before any
199
+ // assertion ran. `import.meta.url` resolves to the script path under tsx;
200
+ // the suffix check matches both the .ts source and any compiled .js output.
201
+ const invokedDirectly = (() => {
202
+ try {
203
+ const entry = process.argv[1];
204
+ return typeof entry === "string" && import.meta.url.endsWith(entry.replace(/\\/g, "/").split("/").pop() ?? "");
205
+ } catch {
206
+ return false;
207
+ }
208
+ })();
209
+
210
+ if (invokedDirectly) {
211
+ main()
212
+ .then((code) => process.exit(code))
213
+ .catch((err) => {
214
+ console.error(`[admin-persist-audit] crashed: ${err instanceof Error ? err.stack : String(err)}`);
215
+ process.exit(2);
216
+ });
217
+ }