@rubytech/create-maxy-code 0.1.39 → 0.1.41
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/dist/index.js +35 -101
- package/dist/uninstall.js +11 -102
- package/package.json +1 -1
- package/payload/platform/lib/mcp-stderr-tee/package.json +7 -0
- package/payload/platform/plugins/admin/hooks/turn-completed-graph-write.sh +142 -52
- package/payload/platform/plugins/docs/references/deployment.md +7 -3
- package/payload/platform/plugins/docs/references/platform.md +18 -4
- package/payload/platform/plugins/docs/references/plugins-guide.md +2 -0
- package/payload/platform/services/claude-session-manager/dist/config.d.ts +17 -0
- package/payload/platform/services/claude-session-manager/dist/config.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/config.js +37 -1
- package/payload/platform/services/claude-session-manager/dist/config.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/fs-watcher.d.ts +54 -0
- package/payload/platform/services/claude-session-manager/dist/fs-watcher.d.ts.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/fs-watcher.js +516 -0
- package/payload/platform/services/claude-session-manager/dist/fs-watcher.js.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/hooks-discovery.d.ts +7 -0
- package/payload/platform/services/claude-session-manager/dist/hooks-discovery.d.ts.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/hooks-discovery.js +90 -0
- package/payload/platform/services/claude-session-manager/dist/hooks-discovery.js.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/http-server.d.ts +3 -1
- 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 +426 -204
- package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/index.js +60 -13
- package/payload/platform/services/claude-session-manager/dist/index.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/jsonl-path.d.ts +2 -0
- package/payload/platform/services/claude-session-manager/dist/jsonl-path.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/jsonl-path.js +11 -6
- package/payload/platform/services/claude-session-manager/dist/jsonl-path.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts +40 -45
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +146 -162
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/reaper.d.ts +24 -0
- package/payload/platform/services/claude-session-manager/dist/reaper.d.ts.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/reaper.js +114 -0
- package/payload/platform/services/claude-session-manager/dist/reaper.js.map +1 -0
- package/payload/platform/services/claude-session-manager/dist/session-store.d.ts +16 -41
- package/payload/platform/services/claude-session-manager/dist/session-store.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/session-store.js +29 -68
- package/payload/platform/services/claude-session-manager/dist/session-store.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/system-prompt.d.ts +54 -0
- package/payload/platform/services/claude-session-manager/dist/system-prompt.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/system-prompt.js +111 -0
- package/payload/platform/services/claude-session-manager/dist/system-prompt.js.map +1 -1
- package/payload/platform/templates/agents/admin/IDENTITY.md +4 -2
- package/payload/platform/templates/agents/admin/SOUL.md +8 -14
- package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/dist/index.d.ts +51 -0
- package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/dist/index.d.ts.map +1 -0
- package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/dist/index.js +196 -0
- package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/dist/index.js.map +1 -0
- package/payload/premium-plugins/real-agent/lib/mcp-stderr-tee/package.json +7 -0
- package/payload/server/{chunk-NNHHGQJL.js → chunk-4P2MPERV.js} +6 -163
- package/payload/server/{chunk-3G6JMV7N.js → chunk-MEGIQYUD.js} +1 -1
- package/payload/server/{chunk-QC5LHYPH.js → chunk-XJVJ2B2Q.js} +1 -1
- package/payload/server/{cloudflare-task-tracker-NEB3X6O2.js → cloudflare-task-tracker-R6MMORFU.js} +2 -2
- package/payload/server/maxy-edge.js +2 -2
- package/payload/server/public/assets/{Checkbox-CmCjmfJy.js → Checkbox-blxv2XPY.js} +1 -1
- package/payload/server/public/assets/{admin-CtodW6As.js → admin-C3EvHpLN.js} +1 -1
- package/payload/server/public/assets/{architectureDiagram-Q4EWVU46-CfOjbx0H.js → architectureDiagram-Q4EWVU46-bETsVzGS.js} +1 -1
- package/payload/server/public/assets/{blockDiagram-DXYQGD6D-D0kA2C9i.js → blockDiagram-DXYQGD6D-5y0GBnfQ.js} +1 -1
- package/payload/server/public/assets/{brand-6hKfBgOI.css → brand-DQlLKLDH.css} +1 -1
- package/payload/server/public/assets/{c4Diagram-AHTNJAMY-CDgXiXgj.js → c4Diagram-AHTNJAMY-C1znpVGu.js} +1 -1
- package/payload/server/public/assets/channel-BWqTaXzb.js +1 -0
- package/payload/server/public/assets/{chunk-336JU56O-BfBTcT5X.js → chunk-336JU56O-DlCVUGzQ.js} +2 -2
- package/payload/server/public/assets/{chunk-426QAEUC-BdSSZ1Kw.js → chunk-426QAEUC-bGYkmA4z.js} +1 -1
- package/payload/server/public/assets/{chunk-4TB4RGXK-UvE1im9g.js → chunk-4TB4RGXK-6Sb0Undm.js} +1 -1
- package/payload/server/public/assets/{chunk-5FUZZQ4R-Dx4DslXz.js → chunk-5FUZZQ4R-CAT_Pq2T.js} +1 -1
- package/payload/server/public/assets/{chunk-5PVQY5BW-CNHawhLJ.js → chunk-5PVQY5BW-j231ESse.js} +1 -1
- package/payload/server/public/assets/{chunk-EDXVE4YY-Rmjv-1et.js → chunk-EDXVE4YY-BAlS4QL7.js} +1 -1
- package/payload/server/public/assets/{chunk-ENJZ2VHE-CL-LeH3r.js → chunk-ENJZ2VHE-D3Ku_BMP.js} +1 -1
- package/payload/server/public/assets/{chunk-ICPOFSXX-B2MFOJDt.js → chunk-ICPOFSXX-AR86A5WB.js} +1 -1
- package/payload/server/public/assets/{chunk-OYMX7WX6-BxcIcCt5.js → chunk-OYMX7WX6-DxGhapkW.js} +1 -1
- package/payload/server/public/assets/{chunk-U2HBQHQK-COzwOBrY.js → chunk-U2HBQHQK-DAlqsDo_.js} +1 -1
- package/payload/server/public/assets/{chunk-X2U36JSP-B0rjT5hL.js → chunk-X2U36JSP-lZdkkdyB.js} +1 -1
- package/payload/server/public/assets/{chunk-YZCP3GAM-pwrIw0XH.js → chunk-YZCP3GAM-CCjtXOFD.js} +1 -1
- package/payload/server/public/assets/{chunk-ZZ45TVLE-BXpeAm0k.js → chunk-ZZ45TVLE-ComtdKny.js} +1 -1
- package/payload/server/public/assets/classDiagram-6PBFFD2Q-B9hC6fOR.js +1 -0
- package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-afl_ydIG.js +1 -0
- package/payload/server/public/assets/clone-Lj83OaZ3.js +1 -0
- package/payload/server/public/assets/{dagre-DjOJn05k.js → dagre-DX8QJeVt.js} +1 -1
- package/payload/server/public/assets/{dagre-KV5264BT-PczvQiEh.js → dagre-KV5264BT-BcRbiZ1q.js} +1 -1
- package/payload/server/public/assets/data-CS_R5VWQ.js +1 -0
- package/payload/server/public/assets/{device-url-actions-C55ZS_Zg.js → device-url-actions-Cag9IJ7n.js} +1 -1
- package/payload/server/public/assets/{diagram-5BDNPKRD-D477xo5F.js → diagram-5BDNPKRD-Bw47VwHO.js} +1 -1
- package/payload/server/public/assets/{diagram-G4DWMVQ6-C-HAtbtT.js → diagram-G4DWMVQ6-B-aVfhiD.js} +1 -1
- package/payload/server/public/assets/{diagram-MMDJMWI5-B9wus4H0.js → diagram-MMDJMWI5-DERz2dKo.js} +1 -1
- package/payload/server/public/assets/{diagram-TYMM5635-UMZLloFr.js → diagram-TYMM5635-B7eEX9Ta.js} +1 -1
- package/payload/server/public/assets/{erDiagram-SMLLAGMA-B8E52Mp4.js → erDiagram-SMLLAGMA-G_JJq3zB.js} +1 -1
- package/payload/server/public/assets/{flowDiagram-DWJPFMVM-CUel34tq.js → flowDiagram-DWJPFMVM-BeY9QaO0.js} +1 -1
- package/payload/server/public/assets/{ganttDiagram-T4ZO3ILL-BfwE-Xav.js → ganttDiagram-T4ZO3ILL-IXviGYnx.js} +1 -1
- package/payload/server/public/assets/{gitGraphDiagram-UUTBAWPF-2d6tXRIM.js → gitGraphDiagram-UUTBAWPF-GlY6pZQ1.js} +1 -1
- package/payload/server/public/assets/graph-DtGkQBFr.js +1 -0
- package/payload/server/public/assets/graph-labels-Dwu1ON5v.js +1 -0
- package/payload/server/public/assets/{graphlib-CCo9-wNJ.js → graphlib-BWgAjZSb.js} +1 -1
- package/payload/server/public/assets/{infoDiagram-42DDH7IO-DB1SVWL6.js → infoDiagram-42DDH7IO-D4YZM0gD.js} +1 -1
- package/payload/server/public/assets/{ishikawaDiagram-UXIWVN3A-CdeMUTYS.js → ishikawaDiagram-UXIWVN3A-fR71GDOp.js} +1 -1
- package/payload/server/public/assets/{journeyDiagram-VCZTEJTY-D8x8TUoc.js → journeyDiagram-VCZTEJTY-C1TcY_6m.js} +1 -1
- package/payload/server/public/assets/{kanban-definition-6JOO6SKY-Cmkhd1mO.js → kanban-definition-6JOO6SKY-IPZKpnnG.js} +1 -1
- package/payload/server/public/assets/{line-CoHkpBv3.js → line-B2JtEL1B.js} +1 -1
- package/payload/server/public/assets/{mermaid-parser.core-C7R2PfZC.js → mermaid-parser.core-BKCLXqUh.js} +1 -1
- package/payload/server/public/assets/{mermaid.core-lQaq-kll.js → mermaid.core-CmNpCLB-.js} +3 -3
- package/payload/server/public/assets/{mindmap-definition-QFDTVHPH-CsPq3pX1.js → mindmap-definition-QFDTVHPH-BS0E2FPD.js} +1 -1
- package/payload/server/public/assets/{page-DwEaAdVp.js → page-BdI3GCun.js} +1 -1
- package/payload/server/public/assets/{page-CBKzjUHO.js → page-zIjAkU2y.js} +1 -1
- package/payload/server/public/assets/{pieDiagram-DEJITSTG-FZH9sTnP.js → pieDiagram-DEJITSTG-J61JDyk8.js} +1 -1
- package/payload/server/public/assets/{public-hGLzxhE_.js → public-C5vaQnC_.js} +4 -4
- package/payload/server/public/assets/{quadrantDiagram-34T5L4WZ-9poxfoqh.js → quadrantDiagram-34T5L4WZ-CLI03OtR.js} +1 -1
- package/payload/server/public/assets/{requirementDiagram-MS252O5E-Ce7iOdT_.js → requirementDiagram-MS252O5E-C8MCt5NO.js} +1 -1
- package/payload/server/public/assets/{sankeyDiagram-XADWPNL6-DINuXatI.js → sankeyDiagram-XADWPNL6-DQuugruj.js} +1 -1
- package/payload/server/public/assets/{sequenceDiagram-FGHM5R23-CSMec3EK.js → sequenceDiagram-FGHM5R23-CoYitwhO.js} +1 -1
- package/payload/server/public/assets/{stateDiagram-FHFEXIEX-15DKzypj.js → stateDiagram-FHFEXIEX-G68cHHoI.js} +1 -1
- package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-Dtgpgr_D.js +1 -0
- package/payload/server/public/assets/{timeline-definition-GMOUNBTQ-BxIRc9Pu.js → timeline-definition-GMOUNBTQ-CelLeJVS.js} +1 -1
- package/payload/server/public/assets/{vennDiagram-DHZGUBPP-DdgRyU55.js → vennDiagram-DHZGUBPP-BVgFPkJq.js} +1 -1
- package/payload/server/public/assets/{wardleyDiagram-NUSXRM2D-CKvhU1Uj.js → wardleyDiagram-NUSXRM2D-CzD_8hl2.js} +1 -1
- package/payload/server/public/assets/{xychartDiagram-5P7HB3ND-d0V1V4PD.js → xychartDiagram-5P7HB3ND-BuTxWdX5.js} +1 -1
- package/payload/server/public/data.html +5 -5
- package/payload/server/public/graph.html +6 -6
- package/payload/server/public/index.html +8 -8
- package/payload/server/public/public.html +5 -5
- package/payload/server/server.js +1058 -846
- package/payload/server/public/assets/channel-DA7MGMzQ.js +0 -1
- package/payload/server/public/assets/classDiagram-6PBFFD2Q-DqfmcWSr.js +0 -1
- package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-BVOMSbZ_.js +0 -1
- package/payload/server/public/assets/clone-Byp7hagU.js +0 -1
- package/payload/server/public/assets/data-A7azIkZU.js +0 -1
- package/payload/server/public/assets/graph-Dx83EhtP.js +0 -1
- package/payload/server/public/assets/graph-labels-Bg2Bzelb.js +0 -1
- package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-AcaK_QfD.js +0 -1
- /package/payload/server/public/assets/{brand-DXOx08r0.js → brand-D6mXeyxV.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -1597,9 +1597,8 @@ function provisionRemoteSessionSecret() {
|
|
|
1597
1597
|
// install-time admin-auth invariant. Walks every account.json
|
|
1598
1598
|
// under accountsDir and compares its admins[] to the persistent users.json,
|
|
1599
1599
|
// emitting one [install-invariant] line per divergence and one summary line.
|
|
1600
|
-
// Log-only (no install abort)
|
|
1601
|
-
//
|
|
1602
|
-
// the deployed fleet is audited clean. Mirror of
|
|
1600
|
+
// Log-only (no install abort); future sprint can promote to refuse-or-degrade
|
|
1601
|
+
// once the deployed fleet is audited clean. Mirror of
|
|
1603
1602
|
// checkAdminAuthInvariant() in platform/lib/admins-write/src/index.ts.
|
|
1604
1603
|
function runInstallInvariantCheck(usersFile, accountsDir) {
|
|
1605
1604
|
const TAG = "[install-invariant]";
|
|
@@ -1686,71 +1685,23 @@ function deployPayload() {
|
|
|
1686
1685
|
// Persistent config lives at ~/{configDir}/ — survives rm -rf ~/{installDir}
|
|
1687
1686
|
const persistentDir = resolve(process.env.HOME ?? "/root", BRAND.configDir);
|
|
1688
1687
|
const persistentPasswordFile = join(persistentDir, ".neo4j-password");
|
|
1689
|
-
const persistentAccountsDir = join(persistentDir, "accounts");
|
|
1690
1688
|
// Migrate: if password is in old location, move to persistent
|
|
1691
1689
|
const oldPasswordFile = join(INSTALL_DIR, "platform/config/.neo4j-password");
|
|
1692
1690
|
if (existsSync(oldPasswordFile) && !existsSync(persistentPasswordFile)) {
|
|
1693
1691
|
mkdirSync(persistentDir, { recursive: true });
|
|
1694
1692
|
cpSync(oldPasswordFile, persistentPasswordFile);
|
|
1695
1693
|
}
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
mkdirSync(persistentDir, { recursive: true });
|
|
1699
|
-
cpSync(oldAccountsDir, persistentAccountsDir, { recursive: true });
|
|
1700
|
-
}
|
|
1701
|
-
// users.json lives at <persistentDir>/users.json. earlier
|
|
1702
|
-
// installs wrote to <INSTALL_DIR>/platform/config/users.json (the wipe zone)
|
|
1703
|
-
// and relied on a one-shot copy-up at first install plus a copy-back after
|
|
1704
|
-
// every wipe. The copy-back overwrote LIVE with the FROZEN-AT-FIRST-INSTALL
|
|
1705
|
-
// backup, dropping every admin row added since first install. Writers (paths.ts,
|
|
1706
|
-
// admin-add, set-pin, seed-neo4j.sh, migrate-import.sh) now target the
|
|
1694
|
+
// users.json lives at <persistentDir>/users.json. Writers (paths.ts,
|
|
1695
|
+
// admin-add, set-pin, seed-neo4j.sh, migrate-import.sh) target the
|
|
1707
1696
|
// persistent file directly — see comment in platform/ui/app/lib/paths.ts.
|
|
1708
|
-
//
|
|
1709
|
-
// Legacy pickup: if a pre-Task-904 install left users.json inside the wipe
|
|
1710
|
-
// zone, copy it up once. Idempotent — guarded by !existsSync(persistentUsersFile).
|
|
1711
|
-
// Safe to delete this block one release has been deployed
|
|
1712
|
-
// everywhere; until then it absorbs upgrades from any pre-Task-904 version.
|
|
1713
1697
|
const persistentUsersFile = join(persistentDir, "users.json");
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
}
|
|
1720
|
-
// Claude Code OAuth credentials legacy pickup. earlier
|
|
1721
|
-
// installs shared `~/.claude/.credentials.json` across brands; the brand
|
|
1722
|
-
// main service's `claude` SDK subprocess and admin server now read from
|
|
1723
|
-
// `${persistDir}/.claude/.credentials.json` per the new
|
|
1724
|
-
// Environment=CLAUDE_CONFIG_DIR= block in port-resolution.ts.
|
|
1725
|
-
//
|
|
1726
|
-
// Move-semantics: the FIRST brand to install grabs the legacy file. The
|
|
1727
|
-
// operation is cpSync + unlinkSync (not renameSync) so it survives cross-
|
|
1728
|
-
// volume `~/` mounts that would EXDEV-fail rename. Subsequent brand
|
|
1729
|
-
// installs find no legacy file and require a fresh `claude /login`.
|
|
1730
|
-
//
|
|
1731
|
-
// Idempotency stamp at `${persistentDir}/.claude/.credentials-migrated`
|
|
1732
|
-
// prevents re-pickup on re-installs of the same brand even if an operator
|
|
1733
|
-
// later runs `claude /login` with no CLAUDE_CONFIG_DIR set, which would
|
|
1734
|
-
// re-create the legacy path.
|
|
1698
|
+
// Claude Code OAuth credentials live at
|
|
1699
|
+
// `${persistDir}/.claude/.credentials.json`. The brand main service's
|
|
1700
|
+
// `claude` SDK subprocess and admin server read from there via the
|
|
1701
|
+
// Environment=CLAUDE_CONFIG_DIR= block in port-resolution.ts. Fresh
|
|
1702
|
+
// installs prompt the operator to run `claude /login`.
|
|
1735
1703
|
const persistentClaudeDir = join(persistentDir, ".claude");
|
|
1736
|
-
|
|
1737
|
-
const legacyCredsFile = join(process.env.HOME ?? "/root", ".claude", ".credentials.json");
|
|
1738
|
-
const credsMigratedStamp = join(persistentClaudeDir, ".credentials-migrated");
|
|
1739
|
-
if (!existsSync(credsMigratedStamp)) {
|
|
1740
|
-
mkdirSync(persistentClaudeDir, { recursive: true });
|
|
1741
|
-
if (existsSync(legacyCredsFile) && !existsSync(persistentCredsFile)) {
|
|
1742
|
-
cpSync(legacyCredsFile, persistentCredsFile);
|
|
1743
|
-
try {
|
|
1744
|
-
unlinkSync(legacyCredsFile);
|
|
1745
|
-
}
|
|
1746
|
-
catch (err) {
|
|
1747
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1748
|
-
console.log(` [install] claude-creds pickup: legacy unlink warn=${msg}`);
|
|
1749
|
-
}
|
|
1750
|
-
console.log(` [install] claude-creds pickup: brand=${BRAND.hostname} source=${legacyCredsFile} target=${persistentCredsFile}`);
|
|
1751
|
-
}
|
|
1752
|
-
writeFileSync(credsMigratedStamp, new Date().toISOString() + "\n");
|
|
1753
|
-
}
|
|
1704
|
+
mkdirSync(persistentClaudeDir, { recursive: true });
|
|
1754
1705
|
// pre-populate the brand `.claude.json` so the manager's
|
|
1755
1706
|
// PTY-spawned `claude --verbose --remote-control` boots straight into the
|
|
1756
1707
|
// session URL without stopping at the first-run theme picker or the
|
|
@@ -1813,31 +1764,9 @@ function deployPayload() {
|
|
|
1813
1764
|
spawnSync("sleep", ["1"]);
|
|
1814
1765
|
}
|
|
1815
1766
|
}
|
|
1816
|
-
//
|
|
1817
|
-
//
|
|
1818
|
-
|
|
1819
|
-
const dataDir = join(INSTALL_DIR, "data");
|
|
1820
|
-
const dataAccountsDir = join(dataDir, "accounts");
|
|
1821
|
-
const dataUploadsDir = join(dataDir, "uploads");
|
|
1822
|
-
const oldLiveAccounts = join(INSTALL_DIR, "platform/config/accounts");
|
|
1823
|
-
if (!existsSync(dataAccountsDir)) {
|
|
1824
|
-
if (existsSync(oldLiveAccounts)) {
|
|
1825
|
-
mkdirSync(dataDir, { recursive: true });
|
|
1826
|
-
cpSync(oldLiveAccounts, dataAccountsDir, { recursive: true });
|
|
1827
|
-
console.log(" Migrated accounts to data/.");
|
|
1828
|
-
}
|
|
1829
|
-
else if (existsSync(persistentAccountsDir)) {
|
|
1830
|
-
mkdirSync(dataDir, { recursive: true });
|
|
1831
|
-
cpSync(persistentAccountsDir, dataAccountsDir, { recursive: true });
|
|
1832
|
-
console.log(" Restored accounts from persistent backup to data/.");
|
|
1833
|
-
}
|
|
1834
|
-
}
|
|
1835
|
-
const oldLiveUploads = join(INSTALL_DIR, "platform/data/attachments");
|
|
1836
|
-
if (!existsSync(dataUploadsDir) && existsSync(oldLiveUploads)) {
|
|
1837
|
-
mkdirSync(dataDir, { recursive: true });
|
|
1838
|
-
cpSync(oldLiveUploads, dataUploadsDir, { recursive: true });
|
|
1839
|
-
console.log(" Migrated uploads to data/.");
|
|
1840
|
-
}
|
|
1767
|
+
// User data lives at {installDir}/data/ — outside the platform/ wipe zone.
|
|
1768
|
+
// Install path creates this fresh; runtime writers populate it on demand.
|
|
1769
|
+
mkdirSync(join(INSTALL_DIR, "data"), { recursive: true });
|
|
1841
1770
|
// Wipe deployment directories to prevent stale files.
|
|
1842
1771
|
// data/ is NOT wiped — it contains user data (accounts, uploads) that must survive.
|
|
1843
1772
|
for (const dir of ["platform", "server", "maxy", "premium-plugins", "docs", ".claude"]) {
|
|
@@ -1862,11 +1791,9 @@ function deployPayload() {
|
|
|
1862
1791
|
// users.json is read directly from persistentDir by both
|
|
1863
1792
|
// platform/ui/app/lib/paths.ts (USERS_FILE = MAXY_DIR/users.json) and the
|
|
1864
1793
|
// admin MCP plugin (USERS_FILE = CONFIG_DIR/users.json). No copy into the
|
|
1865
|
-
// wipe zone
|
|
1866
|
-
//
|
|
1867
|
-
//
|
|
1868
|
-
// detectable in the install log without any runtime change (singular
|
|
1869
|
-
// "userId preserved" hid the multi-row failure mode).
|
|
1794
|
+
// wipe zone. The line below observes the row count + userId prefixes so a
|
|
1795
|
+
// future regression is grep-detectable in the install log without any
|
|
1796
|
+
// runtime change.
|
|
1870
1797
|
if (existsSync(persistentUsersFile)) {
|
|
1871
1798
|
try {
|
|
1872
1799
|
const raw = readFileSync(persistentUsersFile, "utf-8").trim();
|
|
@@ -1886,8 +1813,7 @@ function deployPayload() {
|
|
|
1886
1813
|
}
|
|
1887
1814
|
// install-time admin-auth invariant check. Walks every
|
|
1888
1815
|
// data/accounts/*/account.json admins[] and compares to the persistent
|
|
1889
|
-
// users.json. Log-only (does NOT refuse install)
|
|
1890
|
-
// with already-divergent state still upgrade; the [install-invariant]
|
|
1816
|
+
// users.json. Log-only (does NOT refuse install); the [install-invariant]
|
|
1891
1817
|
// line surfaces the bug to the operator without bricking the device.
|
|
1892
1818
|
// Inline rather than imported from platform/lib/admins-write because the
|
|
1893
1819
|
// installer is its own npm package and doesn't bundle the platform lib.
|
|
@@ -2406,11 +2332,26 @@ function writeInstallDefaults(accountId) {
|
|
|
2406
2332
|
writeFileSync(accountJsonPath, JSON.stringify(config, null, 2) + "\n");
|
|
2407
2333
|
console.log(` [install-defaults] account-json plugins=${enabledPlugins.length} outputStyle=default thinkingView=default`);
|
|
2408
2334
|
logFile(` [install-defaults] account-json plugins=${enabledPlugins.length} outputStyle=default thinkingView=default`);
|
|
2335
|
+
// Admin SOUL.md is sourced from the bundled template with ${PRODUCT_NAME}
|
|
2336
|
+
// substituted at install time. The template carries the Phase 1 standing
|
|
2337
|
+
// offer (brochure / preval / Loop CRM) so the agent ships with a stated
|
|
2338
|
+
// capability set rather than a one-line operator-tag.
|
|
2409
2339
|
const soulPath = join(accountDir, "agents/admin/SOUL.md");
|
|
2410
2340
|
mkdirSync(dirname(soulPath), { recursive: true });
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2341
|
+
const adminSoulTemplate = join(INSTALL_DIR, "platform/templates/agents/admin/SOUL.md");
|
|
2342
|
+
let soulContent;
|
|
2343
|
+
try {
|
|
2344
|
+
soulContent = readFileSync(adminSoulTemplate, "utf-8");
|
|
2345
|
+
}
|
|
2346
|
+
catch (err) {
|
|
2347
|
+
console.error(` [install-defaults] admin-soul template missing at ${adminSoulTemplate}: ${err.message}`);
|
|
2348
|
+
logFile(` [install-defaults] admin-soul template missing: ${err.message}`);
|
|
2349
|
+
return;
|
|
2350
|
+
}
|
|
2351
|
+
soulContent = soulContent.replace(/\$\{PRODUCT_NAME\}/g, BRAND.productName);
|
|
2352
|
+
writeFileSync(soulPath, soulContent);
|
|
2353
|
+
console.log(` [install-defaults] soul-md path=${soulPath} bytes=${soulContent.length}`);
|
|
2354
|
+
logFile(` [install-defaults] soul-md path=${soulPath} bytes=${soulContent.length}`);
|
|
2414
2355
|
// Public agent files — IDENTITY.md is always overwritten (Rubytech-controlled);
|
|
2415
2356
|
// SOUL.md and config.json are created if missing (user-controlled). All three
|
|
2416
2357
|
// are sourced from the payload templates under
|
|
@@ -2552,13 +2493,6 @@ function resolveInstallAccountId() {
|
|
|
2552
2493
|
catch { /* directory unreadable */ }
|
|
2553
2494
|
return "";
|
|
2554
2495
|
}
|
|
2555
|
-
// `installCrons()` and the `# BEGIN/END <BRAND> CRONS` block lived
|
|
2556
|
-
// here. All such events must be user-driven, not scheduled by the installer.
|
|
2557
|
-
// The legacy block recreated `data/accounts/<accountId>/logs/` every 60s via
|
|
2558
|
-
// `mkdir -p`, which tripped seed-neo4j.sh's stub-account-dirs guard on every
|
|
2559
|
-
// reinstall after `rm -rf ~/<installDir>`. Uninstall now strips the legacy
|
|
2560
|
-
// block (uninstall.ts `removeLegacyCronBlock`) so older installs migrate
|
|
2561
|
-
// cleanly. Consumer-side dispatcher replacement is tracked separately.
|
|
2562
2496
|
// retired the ttyd/tmux/xterm admin terminal stack. Upgrades run
|
|
2563
2497
|
// via the action runner — `systemd-run --user` transient units spawned by
|
|
2564
2498
|
// POST /api/admin/actions/upgrade — whose lifetime is independent of
|
package/dist/uninstall.js
CHANGED
|
@@ -158,11 +158,7 @@ function stopServices() {
|
|
|
158
158
|
// the edge service owns the public port and VNC stack. Stop it
|
|
159
159
|
// after the main brand service so the edge's ExecStopPost (vnc.sh stop)
|
|
160
160
|
// runs cleanly. The edge unit is per-brand (`<hostname>-edge`).
|
|
161
|
-
// retired the ttyd unit; pre-664 devices may still have
|
|
162
|
-
// `<hostname>-ttyd` — best-effort stop so the uninstall is clean on
|
|
163
|
-
// upgraded devices too.
|
|
164
161
|
const edgeUnitShort = `${BRAND.hostname}-edge`;
|
|
165
|
-
const legacyTtydUnitShort = `${BRAND.hostname}-ttyd`;
|
|
166
162
|
try {
|
|
167
163
|
spawnSync("systemctl", ["--user", "stop", edgeUnitShort], { stdio: "pipe", timeout: 15_000 });
|
|
168
164
|
console.log(` Stopped ${edgeUnitShort}`);
|
|
@@ -170,11 +166,6 @@ function stopServices() {
|
|
|
170
166
|
catch {
|
|
171
167
|
console.log(` ${edgeUnitShort} not running`);
|
|
172
168
|
}
|
|
173
|
-
try {
|
|
174
|
-
spawnSync("systemctl", ["--user", "stop", legacyTtydUnitShort], { stdio: "pipe", timeout: 15_000 });
|
|
175
|
-
console.log(` Stopped ${legacyTtydUnitShort} (legacy pre-664 unit)`);
|
|
176
|
-
}
|
|
177
|
-
catch { /* not present on post-664 installs */ }
|
|
178
169
|
// Stop Neo4j — dedicated branded instance if this brand uses one, else shared.
|
|
179
170
|
// Brand isolation: never stop `neo4j.service` when this brand runs
|
|
180
171
|
// a dedicated `neo4j-<hostname>.service` — stopping the shared instance would
|
|
@@ -234,80 +225,6 @@ function stopServices() {
|
|
|
234
225
|
console.log(" Stopped Ollama");
|
|
235
226
|
}
|
|
236
227
|
// ---------------------------------------------------------------------------
|
|
237
|
-
// Step 1b: Strip the legacy installer-registered cron block
|
|
238
|
-
//
|
|
239
|
-
// retired `installCrons()` in src/index.ts. Older installs (every
|
|
240
|
-
// brand prior to the release) wrote three minute-cadence entries
|
|
241
|
-
// between `# BEGIN <BRAND> CRONS` and `# END <BRAND> CRONS`. This step
|
|
242
|
-
// removes that block on uninstall so an upgraded device is fully torn down
|
|
243
|
-
// and a subsequent reinstall does not get re-seeded by cron recreating
|
|
244
|
-
// `data/accounts/<accountId>/logs/` every 60s (which tripped seed-neo4j.sh's
|
|
245
|
-
// stub-account-dirs guard). Idempotent:
|
|
246
|
-
// no-op when the block is absent. Gated on Linux to mirror the installer's
|
|
247
|
-
// `installCrons` which early-returned on every other platform.
|
|
248
|
-
// ---------------------------------------------------------------------------
|
|
249
|
-
function removeLegacyCronBlock() {
|
|
250
|
-
log("1b", "Removing legacy cron block...");
|
|
251
|
-
if (!isLinux()) {
|
|
252
|
-
console.log(" Skipped — non-Linux platform.");
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
if (!commandExists("crontab")) {
|
|
256
|
-
console.log(" crontab not available — nothing to strip.");
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
const current = spawnSync("crontab", ["-l"], { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
260
|
-
// Non-zero status (or empty stdout) on `crontab -l` means the user has no
|
|
261
|
-
// crontab at all — nothing to strip, and writing back would create one.
|
|
262
|
-
if (current.status !== 0 || !current.stdout) {
|
|
263
|
-
console.log(" Cron block: none present");
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
const beginMarker = `# BEGIN ${BRAND.productName.toUpperCase()} CRONS`;
|
|
267
|
-
const endMarker = `# END ${BRAND.productName.toUpperCase()} CRONS`;
|
|
268
|
-
const escapeRegex = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
269
|
-
const blockPattern = new RegExp(`${escapeRegex(beginMarker)}[\\s\\S]*?${escapeRegex(endMarker)}\\n?`, "g");
|
|
270
|
-
// Count entry lines (non-comment, non-blank) between markers for the
|
|
271
|
-
// operator-visible log. matchAll returns all block bodies in one pass.
|
|
272
|
-
const extractPattern = new RegExp(`${escapeRegex(beginMarker)}([\\s\\S]*?)${escapeRegex(endMarker)}`, "g");
|
|
273
|
-
let entryCount = 0;
|
|
274
|
-
for (const match of current.stdout.matchAll(extractPattern)) {
|
|
275
|
-
entryCount += match[1]
|
|
276
|
-
.split("\n")
|
|
277
|
-
.filter((l) => l.trim().length > 0 && !l.trim().startsWith("#"))
|
|
278
|
-
.length;
|
|
279
|
-
}
|
|
280
|
-
if (entryCount === 0 && !blockPattern.test(current.stdout)) {
|
|
281
|
-
console.log(" Cron block: none present");
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
const stripped = current.stdout.replace(blockPattern, "").trimEnd();
|
|
285
|
-
if (stripped.length === 0) {
|
|
286
|
-
// Block was the only content — remove the crontab outright so `crontab -l`
|
|
287
|
-
// reports "no crontab for admin" (success criterion). Writing an
|
|
288
|
-
// empty buffer via `crontab -` leaves a zero-byte crontab on Debian.
|
|
289
|
-
const removed = spawnSync("crontab", ["-r"], { stdio: "pipe" });
|
|
290
|
-
if (removed.status !== 0) {
|
|
291
|
-
console.log(` Cron block: stripped ${entryCount} entries but crontab -r failed — ${(removed.stderr ?? "").toString().trim()}`);
|
|
292
|
-
logFile(` crontab -r failed: ${removed.stderr}`);
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
else {
|
|
297
|
-
const write = spawnSync("crontab", ["-"], {
|
|
298
|
-
input: stripped + "\n",
|
|
299
|
-
encoding: "utf-8",
|
|
300
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
301
|
-
});
|
|
302
|
-
if (write.status !== 0) {
|
|
303
|
-
console.log(` Cron block: write failed — ${(write.stderr ?? "").trim()}`);
|
|
304
|
-
logFile(` crontab write failed: ${write.stderr}`);
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
console.log(` Cron block: removed ${entryCount} entries`);
|
|
309
|
-
}
|
|
310
|
-
// ---------------------------------------------------------------------------
|
|
311
228
|
// Step 2: Delete Cloudflare tunnel
|
|
312
229
|
// ---------------------------------------------------------------------------
|
|
313
230
|
function deleteCloudflareTunnel() {
|
|
@@ -702,27 +619,20 @@ function removeSystemdService() {
|
|
|
702
619
|
console.log(` Failed to remove service file: ${err instanceof Error ? err.message : String(err)}`);
|
|
703
620
|
}
|
|
704
621
|
}
|
|
705
|
-
// remove this brand's per-brand edge unit alongside the
|
|
706
|
-
// main brand unit. The per-brand ttyd unit is retired, but an
|
|
707
|
-
// upgraded device may still have `<hostname>-ttyd.service` on disk from
|
|
708
|
-
// a pre-664 install — cleanup both so the uninstall leaves nothing
|
|
709
|
-
// behind on either generation.
|
|
622
|
+
// remove this brand's per-brand edge unit alongside the main brand unit.
|
|
710
623
|
const thisBrandEdge = `${BRAND.hostname}-edge`;
|
|
711
|
-
|
|
712
|
-
|
|
624
|
+
try {
|
|
625
|
+
spawnSync("systemctl", ["--user", "disable", thisBrandEdge], { stdio: "pipe" });
|
|
626
|
+
}
|
|
627
|
+
catch { /* ignore */ }
|
|
628
|
+
const edgeUnitFile = resolve(HOME, `.config/systemd/user/${thisBrandEdge}.service`);
|
|
629
|
+
if (existsSync(edgeUnitFile)) {
|
|
713
630
|
try {
|
|
714
|
-
|
|
631
|
+
rmSync(edgeUnitFile);
|
|
632
|
+
console.log(` Removed ${thisBrandEdge}.service`);
|
|
715
633
|
}
|
|
716
|
-
catch {
|
|
717
|
-
|
|
718
|
-
if (existsSync(unitFile)) {
|
|
719
|
-
try {
|
|
720
|
-
rmSync(unitFile);
|
|
721
|
-
console.log(` Removed ${unit}.service`);
|
|
722
|
-
}
|
|
723
|
-
catch (err) {
|
|
724
|
-
console.log(` Failed to remove ${unit}.service: ${err instanceof Error ? err.message : String(err)}`);
|
|
725
|
-
}
|
|
634
|
+
catch (err) {
|
|
635
|
+
console.log(` Failed to remove ${thisBrandEdge}.service: ${err instanceof Error ? err.message : String(err)}`);
|
|
726
636
|
}
|
|
727
637
|
}
|
|
728
638
|
// Reload daemon
|
|
@@ -965,7 +875,6 @@ export async function runUninstall(options) {
|
|
|
965
875
|
const failures = [];
|
|
966
876
|
const steps = [
|
|
967
877
|
{ name: "Stop services", fn: stopServices },
|
|
968
|
-
{ name: "Remove legacy cron block", fn: removeLegacyCronBlock },
|
|
969
878
|
{ name: "Delete Cloudflare tunnel", fn: deleteCloudflareTunnel },
|
|
970
879
|
...(options.exportPath
|
|
971
880
|
? [{ name: "Export data", fn: () => exportData(options.exportPath) }]
|
package/package.json
CHANGED
|
@@ -1,37 +1,71 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Stop hook — fires on every completed admin-agent turn and dispatches one
|
|
3
|
-
# background PTY against `specialists:database-operator
|
|
4
|
-
#
|
|
5
|
-
#
|
|
3
|
+
# background PTY against `specialists:database-operator`. The hidden PTY is
|
|
4
|
+
# the only writer to the Neo4j graph; the admin agent stays focused on the
|
|
5
|
+
# operator's request.
|
|
6
|
+
#
|
|
7
|
+
# Pipeline (Task 094 redesign):
|
|
8
|
+
# 1. /spawn (no stdinPayload) — manager awaits its watcher's PID-file
|
|
9
|
+
# event before returning. Response carries the recorder's intrinsic
|
|
10
|
+
# sessionId.
|
|
11
|
+
# 2. POST /<recorder-sessionId>/input — body is the database-operator
|
|
12
|
+
# prompt followed by the filtered JSONL tail of the just-completed
|
|
13
|
+
# turn (user / assistant / tool-call records only; queue-operation,
|
|
14
|
+
# auto_mode, deferred_tools_delta, hook_*, last-prompt, skill_listing,
|
|
15
|
+
# mcp_instructions_delta, permission-mode are dropped).
|
|
16
|
+
# 3. When the recorder's Stop hook fires, this hook runs again INSIDE
|
|
17
|
+
# the recorder PTY; the MAXY_HIDDEN_SPAWN gate exits early so no
|
|
18
|
+
# recursion. The recorder's PTY exits naturally; its Stop is then
|
|
19
|
+
# driven by POST /<sessionId>/stop from the same hook invocation
|
|
20
|
+
# that posted /input.
|
|
6
21
|
#
|
|
7
22
|
# Gating:
|
|
8
|
-
# - MAXY_SESSION_ROLE must equal "admin"
|
|
9
|
-
# - MAXY_HIDDEN_SPAWN must equal "0" (skip recursive fires
|
|
10
|
-
# hidden database-operator PTY itself; without this gate every
|
|
11
|
-
# recorder turn would spawn another recorder forever)
|
|
23
|
+
# - MAXY_SESSION_ROLE must equal "admin"
|
|
24
|
+
# - MAXY_HIDDEN_SPAWN must equal "0" (skip recursive fires)
|
|
12
25
|
#
|
|
13
26
|
# Input: Claude Code's Stop hook stdin shape
|
|
14
27
|
# { "session_id": "<intrinsic>", "transcript_path": "<jsonl path>", ... }
|
|
15
28
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
# Failure modes are silent (exit 0) — this hook is observability + write
|
|
20
|
-
# orchestration; a failure here must never break the operator's session.
|
|
29
|
+
# Failure modes are silent (exit 0) — a failure here must never break the
|
|
30
|
+
# operator's session.
|
|
21
31
|
|
|
22
32
|
set -uo pipefail
|
|
23
33
|
|
|
24
34
|
START_MS=$(python3 -c 'import time; print(int(time.time()*1000))')
|
|
25
35
|
|
|
26
|
-
# Gate 1: only fire on admin foreground PTYs.
|
|
27
36
|
if [ "${MAXY_SESSION_ROLE:-}" != "admin" ]; then
|
|
28
37
|
exit 0
|
|
29
38
|
fi
|
|
30
39
|
if [ "${MAXY_HIDDEN_SPAWN:-0}" = "1" ]; then
|
|
40
|
+
# Recorder PTY's own Stop hook. Read its session_id and ask the manager
|
|
41
|
+
# to SIGTERM the recorder so it does not idle in the active recents list
|
|
42
|
+
# after its single turn completes. Keep the JSONL — it's the audit trail.
|
|
43
|
+
if [ -t 0 ]; then
|
|
44
|
+
exit 0
|
|
45
|
+
fi
|
|
46
|
+
REC_INPUT=$(cat)
|
|
47
|
+
if [ -z "$REC_INPUT" ]; then
|
|
48
|
+
exit 0
|
|
49
|
+
fi
|
|
50
|
+
REC_SESSION_ID=$(printf '%s' "$REC_INPUT" | python3 -c '
|
|
51
|
+
import sys, json
|
|
52
|
+
try:
|
|
53
|
+
d = json.load(sys.stdin)
|
|
54
|
+
print(d.get("session_id", "") or "")
|
|
55
|
+
except Exception:
|
|
56
|
+
print("")
|
|
57
|
+
' 2>/dev/null)
|
|
58
|
+
if [ -z "$REC_SESSION_ID" ]; then
|
|
59
|
+
exit 0
|
|
60
|
+
fi
|
|
61
|
+
REC_PORT="${CLAUDE_SESSION_MANAGER_PORT:-19400}"
|
|
62
|
+
curl -sS -X POST \
|
|
63
|
+
--max-time 5 \
|
|
64
|
+
"http://127.0.0.1:${REC_PORT}/${REC_SESSION_ID}/stop" >/dev/null 2>&1
|
|
65
|
+
echo "[recorder] self-stop sessionId=${REC_SESSION_ID:0:8}" >&2
|
|
31
66
|
exit 0
|
|
32
67
|
fi
|
|
33
68
|
|
|
34
|
-
# Gate 2: stdin must be a JSON envelope. Fail-open on parse failure.
|
|
35
69
|
if [ -t 0 ]; then
|
|
36
70
|
exit 0
|
|
37
71
|
fi
|
|
@@ -40,8 +74,6 @@ if [ -z "$INPUT" ]; then
|
|
|
40
74
|
exit 0
|
|
41
75
|
fi
|
|
42
76
|
|
|
43
|
-
# Extract session_id and transcript_path via python3 (grep on JSON is
|
|
44
|
-
# fragile when values carry escaped quotes).
|
|
45
77
|
PARSED=$(printf '%s' "$INPUT" | python3 -c '
|
|
46
78
|
import sys, json
|
|
47
79
|
try:
|
|
@@ -52,63 +84,121 @@ try:
|
|
|
52
84
|
except Exception:
|
|
53
85
|
print("\t")
|
|
54
86
|
' 2>/dev/null)
|
|
55
|
-
|
|
87
|
+
ADMIN_SESSION_ID="${PARSED%% *}"
|
|
56
88
|
TRANSCRIPT_PATH="${PARSED#* }"
|
|
57
89
|
|
|
58
|
-
if [ -z "$
|
|
90
|
+
if [ -z "$ADMIN_SESSION_ID" ] || [ -z "$TRANSCRIPT_PATH" ] || [ ! -f "$TRANSCRIPT_PATH" ]; then
|
|
59
91
|
exit 0
|
|
60
92
|
fi
|
|
61
93
|
|
|
62
|
-
#
|
|
63
|
-
#
|
|
64
|
-
#
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
94
|
+
# Filter the JSONL tail down to records the database-operator cares about:
|
|
95
|
+
# user prompts, assistant messages, and tool calls. Drop ephemeral
|
|
96
|
+
# admin-state records that bloat the prompt without graph value.
|
|
97
|
+
FILTERED_TAIL=$(python3 - "$TRANSCRIPT_PATH" <<'PY'
|
|
98
|
+
import sys, json
|
|
99
|
+
DROP = {
|
|
100
|
+
'queue-operation', 'auto_mode', 'deferred_tools_delta',
|
|
101
|
+
'last-prompt', 'skill_listing', 'mcp_instructions_delta',
|
|
102
|
+
'permission-mode',
|
|
103
|
+
}
|
|
104
|
+
def keep(rec):
|
|
105
|
+
t = rec.get('type') if isinstance(rec, dict) else None
|
|
106
|
+
if not isinstance(t, str): return False
|
|
107
|
+
if t in DROP: return False
|
|
108
|
+
if t.startswith('hook_'): return False
|
|
109
|
+
if t in ('user', 'assistant', 'message'): return True
|
|
110
|
+
if 'tool' in t.lower(): return True
|
|
111
|
+
return False
|
|
112
|
+
|
|
113
|
+
path = sys.argv[1]
|
|
114
|
+
# Read whole file; admin transcripts are bounded by Claude Code's own
|
|
115
|
+
# compaction so the read cost is reasonable. Take the last 200 records
|
|
116
|
+
# from the kept set so a long transcript doesn't blow the prompt budget.
|
|
117
|
+
out = []
|
|
118
|
+
try:
|
|
119
|
+
with open(path, 'r', encoding='utf-8') as f:
|
|
120
|
+
for line in f:
|
|
121
|
+
line = line.strip()
|
|
122
|
+
if not line: continue
|
|
123
|
+
try: rec = json.loads(line)
|
|
124
|
+
except Exception: continue
|
|
125
|
+
if keep(rec): out.append(rec)
|
|
126
|
+
except Exception:
|
|
127
|
+
pass
|
|
128
|
+
out = out[-200:]
|
|
129
|
+
print(json.dumps(out, separators=(',', ':')))
|
|
130
|
+
PY
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
FILTERED_COUNT=$(printf '%s' "$FILTERED_TAIL" | python3 -c 'import sys,json; d=json.load(sys.stdin); print(len(d) if isinstance(d,list) else 0)' 2>/dev/null || echo 0)
|
|
68
134
|
|
|
69
|
-
# Manager port — environment override or compile-time default. The
|
|
70
|
-
# installer's systemd unit stamps CLAUDE_SESSION_MANAGER_PORT so this
|
|
71
|
-
# resolves to the brand's loopback port at runtime.
|
|
72
135
|
MANAGER_PORT="${CLAUDE_SESSION_MANAGER_PORT:-19400}"
|
|
136
|
+
MANAGER_BASE="http://127.0.0.1:${MANAGER_PORT}"
|
|
73
137
|
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
# (admin-agent JSONL is more authoritative than any post-hoc summary the
|
|
77
|
-
# hook could synthesise).
|
|
138
|
+
# Spawn the recorder PTY. Manager blocks on its watcher's PID-file event
|
|
139
|
+
# and returns the recorder's intrinsic sessionId in the response body.
|
|
78
140
|
SPAWN_BODY=$(python3 -c '
|
|
79
|
-
import
|
|
80
|
-
sid = sys.argv[1]
|
|
81
|
-
tail = sys.argv[2]
|
|
141
|
+
import json, sys
|
|
82
142
|
body = {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
"stdinPayload": json.dumps({
|
|
89
|
-
"conversationId": sid,
|
|
90
|
-
"occurredAt": __import__("datetime").datetime.utcnow().isoformat() + "Z",
|
|
91
|
-
"transcriptTail": tail,
|
|
92
|
-
}),
|
|
143
|
+
"senderId": "turn-recorder",
|
|
144
|
+
"role": "admin",
|
|
145
|
+
"channel": "browser",
|
|
146
|
+
"hidden": True,
|
|
147
|
+
"specialist": "database-operator",
|
|
93
148
|
}
|
|
94
149
|
print(json.dumps(body))
|
|
95
|
-
'
|
|
150
|
+
')
|
|
96
151
|
|
|
97
|
-
|
|
152
|
+
SPAWN_RES=$(curl -sS -X POST \
|
|
153
|
+
-H 'Content-Type: application/json' \
|
|
154
|
+
--max-time 10 \
|
|
155
|
+
--data "$SPAWN_BODY" \
|
|
156
|
+
"${MANAGER_BASE}/spawn" 2>/dev/null)
|
|
157
|
+
|
|
158
|
+
RECORDER_SESSION_ID=$(printf '%s' "$SPAWN_RES" | python3 -c '
|
|
159
|
+
import sys, json
|
|
160
|
+
try:
|
|
161
|
+
d = json.load(sys.stdin)
|
|
162
|
+
print(d.get("sessionId", "") or "")
|
|
163
|
+
except Exception:
|
|
164
|
+
print("")
|
|
165
|
+
' 2>/dev/null)
|
|
166
|
+
|
|
167
|
+
if [ -z "$RECORDER_SESSION_ID" ]; then
|
|
168
|
+
echo "turn-completed-graph-write spawn-failed conversationId=${ADMIN_SESSION_ID:0:8}" >&2
|
|
98
169
|
exit 0
|
|
99
170
|
fi
|
|
100
171
|
|
|
101
|
-
#
|
|
102
|
-
|
|
103
|
-
|
|
172
|
+
# Compose the input message: prompt prefix + filtered transcript JSON.
|
|
173
|
+
INPUT_BODY=$(python3 -c '
|
|
174
|
+
import sys, json
|
|
175
|
+
sid = sys.argv[1]
|
|
176
|
+
tail_json = sys.argv[2]
|
|
177
|
+
prompt = (
|
|
178
|
+
"You are the database-operator specialist. Record the following completed turn "
|
|
179
|
+
"into the Neo4j graph. The transcript is a JSON array of filtered records "
|
|
180
|
+
"from the admin agent (user prompts, assistant responses, tool calls). "
|
|
181
|
+
f"Conversation id: {sid}.\n\nTranscript:\n{tail_json}\n"
|
|
182
|
+
)
|
|
183
|
+
print(json.dumps({"text": prompt}))
|
|
184
|
+
' "$ADMIN_SESSION_ID" "$FILTERED_TAIL" 2>/dev/null)
|
|
185
|
+
|
|
186
|
+
if [ -z "$INPUT_BODY" ]; then
|
|
187
|
+
exit 0
|
|
188
|
+
fi
|
|
189
|
+
|
|
190
|
+
INPUT_BYTES=$(printf '%s' "$INPUT_BODY" | wc -c | tr -d ' ')
|
|
191
|
+
|
|
104
192
|
curl -sS -X POST \
|
|
105
193
|
-H 'Content-Type: application/json' \
|
|
106
194
|
--max-time 5 \
|
|
107
|
-
--data "$
|
|
108
|
-
"
|
|
195
|
+
--data "$INPUT_BODY" \
|
|
196
|
+
"${MANAGER_BASE}/${RECORDER_SESSION_ID}/input" >/dev/null 2>&1
|
|
197
|
+
|
|
198
|
+
echo "[recorder] input-posted sessionId=${RECORDER_SESSION_ID:0:8} bytes=${INPUT_BYTES} filtered-from-records=${FILTERED_COUNT}" >&2
|
|
109
199
|
|
|
110
200
|
END_MS=$(python3 -c 'import time; print(int(time.time()*1000))')
|
|
111
201
|
ELAPSED=$((END_MS - START_MS))
|
|
112
|
-
echo "turn-completed-graph-write fired conversationId=${
|
|
202
|
+
echo "turn-completed-graph-write fired conversationId=${ADMIN_SESSION_ID:0:8} recorderSessionId=${RECORDER_SESSION_ID:0:8} filtered=${FILTERED_COUNT} ms=${ELAPSED}" >&2
|
|
113
203
|
|
|
114
204
|
exit 0
|