titan-agent 5.5.25 → 5.5.26

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 (131) hide show
  1. package/dist/utils/constants.js +1 -1
  2. package/dist/utils/constants.js.map +1 -1
  3. package/docs/VISIONARY-IDEAS-V2-2026-05-07.md +184 -0
  4. package/package.json +1 -1
  5. package/ui/dist/assets/{AuditPanel-VzSndmDN.js → AuditPanel-CvRjwjgo.js} +1 -1
  6. package/ui/dist/assets/{AutonomyPanel-BiFouzAV.js → AutonomyPanel-CW5ilCIR.js} +1 -1
  7. package/ui/dist/assets/{AutopilotPanel-fjOfM668.js → AutopilotPanel-BPE9SwMp.js} +1 -1
  8. package/ui/dist/assets/{AutoresearchPanel-CVCxzAH3.js → AutoresearchPanel-DWlHn2Si.js} +2 -2
  9. package/ui/dist/assets/{BackupPanel-CHVTG--q.js → BackupPanel-C2iGkdd9.js} +1 -1
  10. package/ui/dist/assets/{BrowserPanel-D5mvMKFU.js → BrowserPanel-CEvkPFJI.js} +1 -1
  11. package/ui/dist/assets/{CPActivity-B12mt35m.js → CPActivity-3b0MLCa-.js} +1 -1
  12. package/ui/dist/assets/{CPAgentDetail-DsdShc-1.js → CPAgentDetail-CrDHJY_H.js} +1 -1
  13. package/ui/dist/assets/{CPAgents-j_7C-oQV.js → CPAgents-CZu40HUP.js} +1 -1
  14. package/ui/dist/assets/{CPApprovals-BShKSX9X.js → CPApprovals-DznDDrlb.js} +1 -1
  15. package/ui/dist/assets/{CPCosts-CKPlhBDs.js → CPCosts-DQxHIYau.js} +1 -1
  16. package/ui/dist/assets/{CPDashboard-11c0nkxK.js → CPDashboard-BLEvJrgo.js} +1 -1
  17. package/ui/dist/assets/{CPFiles-BhLEOnXy.js → CPFiles-loecvM-G.js} +1 -1
  18. package/ui/dist/assets/{CPGoals-Bi3t1b2P.js → CPGoals-BVCQF4IL.js} +1 -1
  19. package/ui/dist/assets/{CPInbox-Bbr7khp6.js → CPInbox-slrOIxx-.js} +2 -2
  20. package/ui/dist/assets/{CPIssueDetail-DSdgNK8r.js → CPIssueDetail-D_8vCqQH.js} +1 -1
  21. package/ui/dist/assets/{CPIssues-DDEVKhX6.js → CPIssues-CusSfS3O.js} +1 -1
  22. package/ui/dist/assets/{CPLayout-DgPOfyGv.js → CPLayout-syNMzYrR.js} +3 -3
  23. package/ui/dist/assets/{CPOrg-Df73RrRJ.js → CPOrg-D5mWmkhs.js} +1 -1
  24. package/ui/dist/assets/{CPRuns-ByioAz8w.js → CPRuns-D3SA9ukd.js} +1 -1
  25. package/ui/dist/assets/{CPSocial-Dlnr_w1X.js → CPSocial-DAneCIFF.js} +2 -2
  26. package/ui/dist/assets/{ChannelsPanel-DQjQCTK5.js → ChannelsPanel-B5AdEWxL.js} +1 -1
  27. package/ui/dist/assets/{CheckpointsPanel-C4vKjlAJ.js → CheckpointsPanel-7Fwh6kCN.js} +1 -1
  28. package/ui/dist/assets/{CommandPostHub-C9pp5Giq.js → CommandPostHub-BI0jJGmE.js} +3 -3
  29. package/ui/dist/assets/{CronPanel-C6bzUfrD.js → CronPanel-CZ2X0pz9.js} +1 -1
  30. package/ui/dist/assets/{DaemonPanel-BA5Tb_UO.js → DaemonPanel-Cd5eyzlm.js} +1 -1
  31. package/ui/dist/assets/{DataTable-CH7IYJJh.js → DataTable-Cwe6RZ7I.js} +1 -1
  32. package/ui/dist/assets/DreamPanel-DWPboDM6.js +15 -0
  33. package/ui/dist/assets/{EmptyState-jU6yNDnF.js → EmptyState-ZooZL1_g.js} +1 -1
  34. package/ui/dist/assets/{EvalHarnessPanel-DnYqredY.js → EvalHarnessPanel-BEz3Ma-o.js} +2 -2
  35. package/ui/dist/assets/{EvalPanel-ChO7CD1r.js → EvalPanel-B_v-SYag.js} +1 -1
  36. package/ui/dist/assets/{FilesPanel-CaUkv2is.js → FilesPanel-C5yIW_hz.js} +2 -2
  37. package/ui/dist/assets/{FleetPanel-DC_5uj0N.js → FleetPanel-Bzc6J62L.js} +1 -1
  38. package/ui/dist/assets/{HomelabPanel-CE5PGRpL.js → HomelabPanel-DBk5e4SZ.js} +1 -1
  39. package/ui/dist/assets/InfraView-BCAYPfUO.js +2 -0
  40. package/ui/dist/assets/{InlineEditableField-BMQjiE6-.js → InlineEditableField-B87Qpvf4.js} +1 -1
  41. package/ui/dist/assets/{Input-Bu_b3qmY.js → Input-CdHGkE1K.js} +1 -1
  42. package/ui/dist/assets/{IntegrationsPanel-DsYpAq43.js → IntegrationsPanel-D_6DdT7E.js} +1 -1
  43. package/ui/dist/assets/IntelligenceView-CMYDd0k1.js +2 -0
  44. package/ui/dist/assets/{LearningPanel-UpQZC-mA.js → LearningPanel-Coaq3uSX.js} +1 -1
  45. package/ui/dist/assets/{LogsPanel-ClXJ4fcr.js → LogsPanel-CxV9clJv.js} +1 -1
  46. package/ui/dist/assets/{McpPanel-JKgtIERQ.js → McpPanel-38cTOVpq.js} +1 -1
  47. package/ui/dist/assets/{MemoryGraphPanel-Bo2OrvA6.js → MemoryGraphPanel-CdP8yBsU.js} +1 -1
  48. package/ui/dist/assets/{MemoryWikiPanel-BqJ1AmYm.js → MemoryWikiPanel-BZY4ltF8.js} +1 -1
  49. package/ui/dist/assets/{MeshPanel-BJVGYvwk.js → MeshPanel-Dve54mb5.js} +2 -2
  50. package/ui/dist/assets/{Modal-CAAooiZU.js → Modal-Dkw2zhkC.js} +1 -1
  51. package/ui/dist/assets/{NvidiaPanel-BtCg3G4w.js → NvidiaPanel-_lobfUui.js} +1 -1
  52. package/ui/dist/assets/{OrganismPanel-DgrTTzcF.js → OrganismPanel-CT14A5aM.js} +1 -1
  53. package/ui/dist/assets/{OverviewPanel-rVav1Hox.js → OverviewPanel-Co90aNww.js} +1 -1
  54. package/ui/dist/assets/{PageHeader-CnZtP8ek.js → PageHeader-BMCNQJ3s.js} +1 -1
  55. package/ui/dist/assets/{PaperclipPanel-C-FKdhiF.js → PaperclipPanel-DgRqyMbn.js} +1 -1
  56. package/ui/dist/assets/PersonaProfilesPanel-DxJHSnTb.js +8 -0
  57. package/ui/dist/assets/{PersonasPanel-BmlxokfB.js → PersonasPanel-CjBialC-.js} +1 -1
  58. package/ui/dist/assets/{RecipesPanel-BNKKChis.js → RecipesPanel-CKJlrAhx.js} +1 -1
  59. package/ui/dist/assets/{SecurityPanel-I7JRHiNy.js → SecurityPanel-Dq0SydvH.js} +1 -1
  60. package/ui/dist/assets/{SelfImprovePanel-u9h0Lt3p.js → SelfImprovePanel-DOBShe1x.js} +1 -1
  61. package/ui/dist/assets/{SelfProposalsPanel-DKl9iBjM.js → SelfProposalsPanel-Oew3Z8Tf.js} +1 -1
  62. package/ui/dist/assets/{SessionsPanel-BhRiWI_g.js → SessionsPanel-DLXg8395.js} +1 -1
  63. package/ui/dist/assets/{SessionsTab-Bk08wyeY.js → SessionsTab-DXAhXAOT.js} +1 -1
  64. package/ui/dist/assets/{SettingsPanel-haLfmG2k.js → SettingsPanel-DZrvjabq.js} +1 -1
  65. package/ui/dist/assets/SettingsView-DGRhvQ94.js +2 -0
  66. package/ui/dist/assets/{SkeletonLoader-B5v09EF_.js → SkeletonLoader-B6Y6z3-s.js} +1 -1
  67. package/ui/dist/assets/{SkillsPanel-BlAHFLcQ.js → SkillsPanel-Pv4AxzVg.js} +1 -1
  68. package/ui/dist/assets/{SomaView-CExtS3zw.js → SomaView-BcpblWA2.js} +1 -1
  69. package/ui/dist/assets/{StatCard-BIsyMybM.js → StatCard-BrB0-tqp.js} +1 -1
  70. package/ui/dist/assets/{StatusBadge-D5nU7El8.js → StatusBadge-Cbwzt8Ys.js} +1 -1
  71. package/ui/dist/assets/{Tabs-BBYZrBI8.js → Tabs-DKvN1LcI.js} +1 -1
  72. package/ui/dist/assets/{TeamsPanel-LPXJg823.js → TeamsPanel-DXikaA5z.js} +1 -1
  73. package/ui/dist/assets/{TelemetryPanel-EqpRBmOI.js → TelemetryPanel-BNP1aWLi.js} +1 -1
  74. package/ui/dist/assets/{TitanCanvas-BCbWnLMd.js → TitanCanvas-D3NdtqI0.js} +4 -4
  75. package/ui/dist/assets/{ToolsView-CeP0Zz-N.js → ToolsView-BZuBcd9r.js} +2 -2
  76. package/ui/dist/assets/{Tooltip-BSO2XVpF.js → Tooltip-O81VPUe6.js} +1 -1
  77. package/ui/dist/assets/{TraceViewer-BKI7o5B0.js → TraceViewer-B7S3UOqf.js} +1 -1
  78. package/ui/dist/assets/{TrainingPanel-c-RhjdE1.js → TrainingPanel-CXoifHlW.js} +1 -1
  79. package/ui/dist/assets/{VoiceOverlay-D-gc58b0.js → VoiceOverlay-CeYB8JMF.js} +3 -3
  80. package/ui/dist/assets/{VramPanel-C6xc7zgd.js → VramPanel-CMjIx0Kw.js} +1 -1
  81. package/ui/dist/assets/{WatchView-dqBVCVH0.js → WatchView-BAdVYzp6.js} +1 -1
  82. package/ui/dist/assets/{WorkTab-CBoLNrTM.js → WorkTab-CZ13oF2p.js} +1 -1
  83. package/ui/dist/assets/{WorkflowsPanel-BAnSTOYe.js → WorkflowsPanel-BuAfLuvM.js} +1 -1
  84. package/ui/dist/assets/{arrow-left-5chqas7J.js → arrow-left-DLTVGuvQ.js} +1 -1
  85. package/ui/dist/assets/{briefcase-D4vLzudp.js → briefcase-B_KGQ24t.js} +1 -1
  86. package/ui/dist/assets/{chart-column-CdFlBpoP.js → chart-column-Cb9OKV8X.js} +1 -1
  87. package/ui/dist/assets/{check-Bpm1IONe.js → check-CrjQyURH.js} +1 -1
  88. package/ui/dist/assets/{chevron-down-D7OLjvuD.js → chevron-down-UTFDbEQ3.js} +1 -1
  89. package/ui/dist/assets/{chevron-right-aQEw2mUW.js → chevron-right-CgXD9Slz.js} +1 -1
  90. package/ui/dist/assets/{chevron-up-C5g6pEj8.js → chevron-up-CXwVHYv7.js} +1 -1
  91. package/ui/dist/assets/{circle-check-big-fPhEdP88.js → circle-check-big-Ccs78slx.js} +1 -1
  92. package/ui/dist/assets/{clock-CTsgP_Sn.js → clock-Bm7r0-EW.js} +1 -1
  93. package/ui/dist/assets/{dollar-sign-CudFVYFc.js → dollar-sign-BjOfnLA5.js} +1 -1
  94. package/ui/dist/assets/{download-DZRxDn67.js → download-BHKBBC1o.js} +1 -1
  95. package/ui/dist/assets/{external-link-BZ0y_Ahx.js → external-link-CcrPL70b.js} +1 -1
  96. package/ui/dist/assets/{eye-off-BmJF0YYx.js → eye-off-Cj3Wt4rk.js} +1 -1
  97. package/ui/dist/assets/{folder-DA43TRCm.js → folder-C3yn66Ka.js} +1 -1
  98. package/ui/dist/assets/{funnel-J3mULzrz.js → funnel-CiTRfpfx.js} +1 -1
  99. package/ui/dist/assets/{git-branch-oHibJqDq.js → git-branch-C58Whecm.js} +1 -1
  100. package/ui/dist/assets/index-BDfE5K3X.css +1 -0
  101. package/ui/dist/assets/{index-DzwowwSI.js → index-Ba6pEFSB.js} +8 -8
  102. package/ui/dist/assets/{layers-DsyEyu7z.js → layers-C0cy_MXC.js} +1 -1
  103. package/ui/dist/assets/{legacy-8ITl64sV.js → legacy-BVhQQDrG.js} +1 -1
  104. package/ui/dist/assets/{lightbulb-C54Ske-p.js → lightbulb-DcczNTuC.js} +1 -1
  105. package/ui/dist/assets/{list-todo-Cnd4rdoK.js → list-todo-BA0K8B0w.js} +1 -1
  106. package/ui/dist/assets/{loader-circle-1YOBsoQp.js → loader-circle-DS59DE4w.js} +1 -1
  107. package/ui/dist/assets/{network-DbGDAdrn.js → network-D-P-nlHV.js} +1 -1
  108. package/ui/dist/assets/{pause-CYhO_uQo.js → pause-DmOSwMh6.js} +1 -1
  109. package/ui/dist/assets/{play-DVY9c5Ck.js → play-Cr53Iwat.js} +1 -1
  110. package/ui/dist/assets/{plug-BcXjlPUL.js → plug-CXDOaDg0.js} +1 -1
  111. package/ui/dist/assets/{plus-Csu2v9GN.js → plus-BUOjWfPb.js} +1 -1
  112. package/ui/dist/assets/{proxy-DxS2_9D7.js → proxy-BmDq-lG4.js} +1 -1
  113. package/ui/dist/assets/{rotate-ccw-Co-_W04j.js → rotate-ccw-DFyInSgJ.js} +1 -1
  114. package/ui/dist/assets/{save-Btx-kpoW.js → save-BHn8eVKt.js} +1 -1
  115. package/ui/dist/assets/{search-0hXTwEZR.js → search-B2AzV9aH.js} +1 -1
  116. package/ui/dist/assets/{send-TEpapzQR.js → send-3MPWl9QJ.js} +1 -1
  117. package/ui/dist/assets/{shield-check-DjBJXZUr.js → shield-check-CFSKu_na.js} +1 -1
  118. package/ui/dist/assets/{square-OweUvjP-.js → square-B5zS95Bg.js} +1 -1
  119. package/ui/dist/assets/{target-BRW80Xer.js → target-D7_0NmbL.js} +1 -1
  120. package/ui/dist/assets/{terminal-BtiqJ628.js → terminal-CbB-3SZc.js} +1 -1
  121. package/ui/dist/assets/{toggle-right-CKtSrl28.js → toggle-right-D2kZxm57.js} +1 -1
  122. package/ui/dist/assets/{trash-2-DgWrHVax.js → trash-2-HAJYvEBs.js} +1 -1
  123. package/ui/dist/assets/{trending-up-MpIrE4j6.js → trending-up-DPLGp1jF.js} +1 -1
  124. package/ui/dist/assets/{trophy-CECuZNhX.js → trophy-DDky8DFS.js} +1 -1
  125. package/ui/dist/assets/{users-dZgv4ePG.js → users-CPePALGx.js} +1 -1
  126. package/ui/dist/assets/{wrench-CDz3xYve.js → wrench-CppG-1zJ.js} +1 -1
  127. package/ui/dist/index.html +2 -2
  128. package/ui/dist/assets/InfraView-C-uSlvb9.js +0 -2
  129. package/ui/dist/assets/IntelligenceView-DUdIO1K7.js +0 -2
  130. package/ui/dist/assets/SettingsView--gi3fxI8.js +0 -2
  131. package/ui/dist/assets/index-BR0vfkIi.css +0 -1
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { homedir } from "os";
3
3
  import { join } from "path";
4
- const TITAN_VERSION = "5.5.25";
4
+ const TITAN_VERSION = "5.5.26";
5
5
  const TITAN_CODENAME = "Spacewalk";
6
6
  const TITAN_NAME = "TITAN";
7
7
  const TITAN_FULL_NAME = "The Intelligent Task Automation Network";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/constants.ts"],"sourcesContent":["/**\n * TITAN Constants\n */\nimport { homedir } from 'os';\nimport { join } from 'path';\n\nexport const TITAN_VERSION = '5.5.25';\nexport const TITAN_CODENAME = 'Spacewalk';\nexport const TITAN_NAME = 'TITAN';\nexport const TITAN_FULL_NAME = 'The Intelligent Task Automation Network';\nexport const TITAN_ASCII_LOGO = `\n╔══════════════════════════════════════════════════════╗\n║ ║\n║ ████████╗██╗████████╗ █████╗ ███╗ ██╗ ║\n║ ██║ ██║ ██║ ██╔══██╗████╗ ██║ ║\n║ ██║ ██║ ██║ ███████║██╔██╗ ██║ ║\n║ ██║ ██║ ██║ ██╔══██║██║╚██╗██║ ║\n║ ██║ ██║ ██║ ██║ ██║██║ ╚████║ ║\n║ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ║\n║ ║\n║ The Intelligent Task Automation Network ║\n║ v${TITAN_VERSION} • by Tony Elliott ║\n╚══════════════════════════════════════════════════════╝`;\n\n// Paths\n// Hunt Finding #03 (2026-04-14): honor TITAN_HOME env var if set.\n// Previously this was hardcoded to `~/.titan`, which meant:\n// - Docker containers couldn't override the config path\n// - Shared machines couldn't isolate per-user state\n// - Test fixtures couldn't run against an isolated home\n// - The systemd unit's `Environment=TITAN_HOME=...` was silently ignored\n// The env var is read once at module load (constants are resolved at import time).\n// If TITAN_HOME starts with `~/`, expand it to the user's home dir.\nfunction resolveTitanHome(): string {\n const envHome = process.env.TITAN_HOME;\n if (envHome && envHome.trim().length > 0) {\n const trimmed = envHome.trim();\n if (trimmed.startsWith('~/')) {\n return join(homedir(), trimmed.slice(2));\n }\n if (trimmed === '~') {\n return homedir();\n }\n return trimmed;\n }\n return join(homedir(), '.titan');\n}\nexport const TITAN_HOME = resolveTitanHome();\nexport const TITAN_CONFIG_PATH = join(TITAN_HOME, 'titan.json');\nexport const TITAN_DB_PATH = join(TITAN_HOME, 'titan.db');\nexport const TITAN_WORKSPACE = join(TITAN_HOME, 'workspace');\nexport const TITAN_SKILLS_DIR = join(TITAN_WORKSPACE, 'skills');\nexport const TITAN_LOGS_DIR = join(TITAN_HOME, 'logs');\nexport const TITAN_MEMORY_DIR = join(TITAN_HOME, 'memory');\n\n// Workspace prompt files (injected into agent context)\nexport const AGENTS_MD = join(TITAN_WORKSPACE, 'AGENTS.md');\nexport const SOUL_MD = join(TITAN_WORKSPACE, 'SOUL.md');\nexport const TOOLS_MD = join(TITAN_WORKSPACE, 'TOOLS.md');\nexport const TITAN_MD_FILENAME = 'TITAN.md';\nexport const AUTOPILOT_MD = join(TITAN_HOME, 'AUTOPILOT.md');\nexport const AUTOPILOT_RUNS_PATH = join(TITAN_HOME, 'autopilot-runs.jsonl');\nexport const TITAN_CREDENTIALS_DIR = join(TITAN_HOME, 'credentials');\n\n// Income & lead tracking\nexport const INCOME_LEDGER_PATH = join(TITAN_HOME, 'income-ledger.jsonl');\nexport const FREELANCE_LEADS_PATH = join(TITAN_HOME, 'freelance-leads.jsonl');\nexport const FREELANCE_PROFILE_PATH = join(TITAN_HOME, 'freelance-profile.json');\nexport const LEADS_PATH = join(TITAN_HOME, 'leads.jsonl');\nexport const TELEMETRY_EVENTS_PATH = join(TITAN_HOME, 'telemetry-events.jsonl');\nexport const SOMADRIVE_STATE_PATH = join(TITAN_HOME, 'soma-drive-state.json');\nexport const ACTIVITY_LOG_PATH = join(TITAN_HOME, 'activity-log.jsonl');\n\n// Gateway defaults\nexport const DEFAULT_GATEWAY_HOST = '0.0.0.0';\nexport const DEFAULT_GATEWAY_PORT = 48420;\nexport const DEFAULT_WEB_PORT = 48421;\n\n// Agent defaults\nexport const DEFAULT_MODEL = 'anthropic/claude-sonnet-4-20250514';\n/** v5.4.1: User-preference ceiling. Providers clamp per-model via\n * clampMaxTokens() so this can be high without causing 400s on\n * capped endpoints (e.g. Claude Sonnet 4 8K, Cohere 4K). */\nexport const DEFAULT_MAX_TOKENS = 200000;\nexport const DEFAULT_TEMPERATURE = 0.7;\nexport const MAX_CONTEXT_MESSAGES = 50;\nexport const SESSION_TIMEOUT_MS = 30 * 60 * 1000; // 30 minutes\n\n// Security\nexport const DEFAULT_SANDBOX_MODE = 'host';\n/** Default allowed tools. Empty = allow ALL registered tools.\n * Use security.deniedTools to block specific tools instead. */\nexport const ALLOWED_TOOLS_DEFAULT: string[] = [];\nexport const DENIED_TOOLS_DEFAULT: string[] = [];\n"],"mappings":";AAGA,SAAS,eAAe;AACxB,SAAS,YAAY;AAEd,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;AACvB,MAAM,aAAa;AACnB,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAW1B,aAAa;AAAA;AAYnB,SAAS,mBAA2B;AAChC,QAAM,UAAU,QAAQ,IAAI;AAC5B,MAAI,WAAW,QAAQ,KAAK,EAAE,SAAS,GAAG;AACtC,UAAM,UAAU,QAAQ,KAAK;AAC7B,QAAI,QAAQ,WAAW,IAAI,GAAG;AAC1B,aAAO,KAAK,QAAQ,GAAG,QAAQ,MAAM,CAAC,CAAC;AAAA,IAC3C;AACA,QAAI,YAAY,KAAK;AACjB,aAAO,QAAQ;AAAA,IACnB;AACA,WAAO;AAAA,EACX;AACA,SAAO,KAAK,QAAQ,GAAG,QAAQ;AACnC;AACO,MAAM,aAAa,iBAAiB;AACpC,MAAM,oBAAoB,KAAK,YAAY,YAAY;AACvD,MAAM,gBAAgB,KAAK,YAAY,UAAU;AACjD,MAAM,kBAAkB,KAAK,YAAY,WAAW;AACpD,MAAM,mBAAmB,KAAK,iBAAiB,QAAQ;AACvD,MAAM,iBAAiB,KAAK,YAAY,MAAM;AAC9C,MAAM,mBAAmB,KAAK,YAAY,QAAQ;AAGlD,MAAM,YAAY,KAAK,iBAAiB,WAAW;AACnD,MAAM,UAAU,KAAK,iBAAiB,SAAS;AAC/C,MAAM,WAAW,KAAK,iBAAiB,UAAU;AACjD,MAAM,oBAAoB;AAC1B,MAAM,eAAe,KAAK,YAAY,cAAc;AACpD,MAAM,sBAAsB,KAAK,YAAY,sBAAsB;AACnE,MAAM,wBAAwB,KAAK,YAAY,aAAa;AAG5D,MAAM,qBAAqB,KAAK,YAAY,qBAAqB;AACjE,MAAM,uBAAuB,KAAK,YAAY,uBAAuB;AACrE,MAAM,yBAAyB,KAAK,YAAY,wBAAwB;AACxE,MAAM,aAAa,KAAK,YAAY,aAAa;AACjD,MAAM,wBAAwB,KAAK,YAAY,wBAAwB;AACvE,MAAM,uBAAuB,KAAK,YAAY,uBAAuB;AACrE,MAAM,oBAAoB,KAAK,YAAY,oBAAoB;AAG/D,MAAM,uBAAuB;AAC7B,MAAM,uBAAuB;AAC7B,MAAM,mBAAmB;AAGzB,MAAM,gBAAgB;AAItB,MAAM,qBAAqB;AAC3B,MAAM,sBAAsB;AAC5B,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB,KAAK,KAAK;AAGrC,MAAM,uBAAuB;AAG7B,MAAM,wBAAkC,CAAC;AACzC,MAAM,uBAAiC,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/constants.ts"],"sourcesContent":["/**\n * TITAN Constants\n */\nimport { homedir } from 'os';\nimport { join } from 'path';\n\nexport const TITAN_VERSION = '5.5.26';\nexport const TITAN_CODENAME = 'Spacewalk';\nexport const TITAN_NAME = 'TITAN';\nexport const TITAN_FULL_NAME = 'The Intelligent Task Automation Network';\nexport const TITAN_ASCII_LOGO = `\n╔══════════════════════════════════════════════════════╗\n║ ║\n║ ████████╗██╗████████╗ █████╗ ███╗ ██╗ ║\n║ ██║ ██║ ██║ ██╔══██╗████╗ ██║ ║\n║ ██║ ██║ ██║ ███████║██╔██╗ ██║ ║\n║ ██║ ██║ ██║ ██╔══██║██║╚██╗██║ ║\n║ ██║ ██║ ██║ ██║ ██║██║ ╚████║ ║\n║ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ║\n║ ║\n║ The Intelligent Task Automation Network ║\n║ v${TITAN_VERSION} • by Tony Elliott ║\n╚══════════════════════════════════════════════════════╝`;\n\n// Paths\n// Hunt Finding #03 (2026-04-14): honor TITAN_HOME env var if set.\n// Previously this was hardcoded to `~/.titan`, which meant:\n// - Docker containers couldn't override the config path\n// - Shared machines couldn't isolate per-user state\n// - Test fixtures couldn't run against an isolated home\n// - The systemd unit's `Environment=TITAN_HOME=...` was silently ignored\n// The env var is read once at module load (constants are resolved at import time).\n// If TITAN_HOME starts with `~/`, expand it to the user's home dir.\nfunction resolveTitanHome(): string {\n const envHome = process.env.TITAN_HOME;\n if (envHome && envHome.trim().length > 0) {\n const trimmed = envHome.trim();\n if (trimmed.startsWith('~/')) {\n return join(homedir(), trimmed.slice(2));\n }\n if (trimmed === '~') {\n return homedir();\n }\n return trimmed;\n }\n return join(homedir(), '.titan');\n}\nexport const TITAN_HOME = resolveTitanHome();\nexport const TITAN_CONFIG_PATH = join(TITAN_HOME, 'titan.json');\nexport const TITAN_DB_PATH = join(TITAN_HOME, 'titan.db');\nexport const TITAN_WORKSPACE = join(TITAN_HOME, 'workspace');\nexport const TITAN_SKILLS_DIR = join(TITAN_WORKSPACE, 'skills');\nexport const TITAN_LOGS_DIR = join(TITAN_HOME, 'logs');\nexport const TITAN_MEMORY_DIR = join(TITAN_HOME, 'memory');\n\n// Workspace prompt files (injected into agent context)\nexport const AGENTS_MD = join(TITAN_WORKSPACE, 'AGENTS.md');\nexport const SOUL_MD = join(TITAN_WORKSPACE, 'SOUL.md');\nexport const TOOLS_MD = join(TITAN_WORKSPACE, 'TOOLS.md');\nexport const TITAN_MD_FILENAME = 'TITAN.md';\nexport const AUTOPILOT_MD = join(TITAN_HOME, 'AUTOPILOT.md');\nexport const AUTOPILOT_RUNS_PATH = join(TITAN_HOME, 'autopilot-runs.jsonl');\nexport const TITAN_CREDENTIALS_DIR = join(TITAN_HOME, 'credentials');\n\n// Income & lead tracking\nexport const INCOME_LEDGER_PATH = join(TITAN_HOME, 'income-ledger.jsonl');\nexport const FREELANCE_LEADS_PATH = join(TITAN_HOME, 'freelance-leads.jsonl');\nexport const FREELANCE_PROFILE_PATH = join(TITAN_HOME, 'freelance-profile.json');\nexport const LEADS_PATH = join(TITAN_HOME, 'leads.jsonl');\nexport const TELEMETRY_EVENTS_PATH = join(TITAN_HOME, 'telemetry-events.jsonl');\nexport const SOMADRIVE_STATE_PATH = join(TITAN_HOME, 'soma-drive-state.json');\nexport const ACTIVITY_LOG_PATH = join(TITAN_HOME, 'activity-log.jsonl');\n\n// Gateway defaults\nexport const DEFAULT_GATEWAY_HOST = '0.0.0.0';\nexport const DEFAULT_GATEWAY_PORT = 48420;\nexport const DEFAULT_WEB_PORT = 48421;\n\n// Agent defaults\nexport const DEFAULT_MODEL = 'anthropic/claude-sonnet-4-20250514';\n/** v5.4.1: User-preference ceiling. Providers clamp per-model via\n * clampMaxTokens() so this can be high without causing 400s on\n * capped endpoints (e.g. Claude Sonnet 4 8K, Cohere 4K). */\nexport const DEFAULT_MAX_TOKENS = 200000;\nexport const DEFAULT_TEMPERATURE = 0.7;\nexport const MAX_CONTEXT_MESSAGES = 50;\nexport const SESSION_TIMEOUT_MS = 30 * 60 * 1000; // 30 minutes\n\n// Security\nexport const DEFAULT_SANDBOX_MODE = 'host';\n/** Default allowed tools. Empty = allow ALL registered tools.\n * Use security.deniedTools to block specific tools instead. */\nexport const ALLOWED_TOOLS_DEFAULT: string[] = [];\nexport const DENIED_TOOLS_DEFAULT: string[] = [];\n"],"mappings":";AAGA,SAAS,eAAe;AACxB,SAAS,YAAY;AAEd,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;AACvB,MAAM,aAAa;AACnB,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAW1B,aAAa;AAAA;AAYnB,SAAS,mBAA2B;AAChC,QAAM,UAAU,QAAQ,IAAI;AAC5B,MAAI,WAAW,QAAQ,KAAK,EAAE,SAAS,GAAG;AACtC,UAAM,UAAU,QAAQ,KAAK;AAC7B,QAAI,QAAQ,WAAW,IAAI,GAAG;AAC1B,aAAO,KAAK,QAAQ,GAAG,QAAQ,MAAM,CAAC,CAAC;AAAA,IAC3C;AACA,QAAI,YAAY,KAAK;AACjB,aAAO,QAAQ;AAAA,IACnB;AACA,WAAO;AAAA,EACX;AACA,SAAO,KAAK,QAAQ,GAAG,QAAQ;AACnC;AACO,MAAM,aAAa,iBAAiB;AACpC,MAAM,oBAAoB,KAAK,YAAY,YAAY;AACvD,MAAM,gBAAgB,KAAK,YAAY,UAAU;AACjD,MAAM,kBAAkB,KAAK,YAAY,WAAW;AACpD,MAAM,mBAAmB,KAAK,iBAAiB,QAAQ;AACvD,MAAM,iBAAiB,KAAK,YAAY,MAAM;AAC9C,MAAM,mBAAmB,KAAK,YAAY,QAAQ;AAGlD,MAAM,YAAY,KAAK,iBAAiB,WAAW;AACnD,MAAM,UAAU,KAAK,iBAAiB,SAAS;AAC/C,MAAM,WAAW,KAAK,iBAAiB,UAAU;AACjD,MAAM,oBAAoB;AAC1B,MAAM,eAAe,KAAK,YAAY,cAAc;AACpD,MAAM,sBAAsB,KAAK,YAAY,sBAAsB;AACnE,MAAM,wBAAwB,KAAK,YAAY,aAAa;AAG5D,MAAM,qBAAqB,KAAK,YAAY,qBAAqB;AACjE,MAAM,uBAAuB,KAAK,YAAY,uBAAuB;AACrE,MAAM,yBAAyB,KAAK,YAAY,wBAAwB;AACxE,MAAM,aAAa,KAAK,YAAY,aAAa;AACjD,MAAM,wBAAwB,KAAK,YAAY,wBAAwB;AACvE,MAAM,uBAAuB,KAAK,YAAY,uBAAuB;AACrE,MAAM,oBAAoB,KAAK,YAAY,oBAAoB;AAG/D,MAAM,uBAAuB;AAC7B,MAAM,uBAAuB;AAC7B,MAAM,mBAAmB;AAGzB,MAAM,gBAAgB;AAItB,MAAM,qBAAqB;AAC3B,MAAM,sBAAsB;AAC5B,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB,KAAK,KAAK;AAGrC,MAAM,uBAAuB;AAG7B,MAAM,wBAAkC,CAAC;AACzC,MAAM,uBAAiC,CAAC;","names":[]}
@@ -0,0 +1,184 @@
1
+ # TITAN — Visionary Features V2 — 2026-05-07
2
+
3
+ > Pivot brief: V1 leaned on Tony's biography and produced demo-shaped features for viral clips. V2 targets the install→advocate flywheel: features that make a senior engineer at a YC AI-infra startup install TITAN, realize they can't go back, and tell three coworkers. Engineer-credible. Numbers, not vibes. Tied to TITAN's structural assets — multi-machine mesh, Soma drive history, persona-profile resolver, VRAM orchestrator, F5-TTS — not Tony's identity. The hook is the *shape of the abstraction*, not the artifact.
4
+
5
+ ---
6
+
7
+ ### 1. Drive-Aware Model Router
8
+
9
+ **The pitch:** "Your agent's reliability suddenly stopped degrading at 4pm? It's because TITAN noticed Safety drive crossed setpoint and re-routed your tool calls to a colder model."
10
+
11
+ **The engineer-credible problem:** Every agent framework's "model router" is a static decision tree (cost tier, function-call support, latency budget). None of them can answer the operator's real question: *why did my agent's pass-rate drop at 4pm yesterday?* Mastra/Vercel SDK route a request based on the request, not on the **operating state of the agent itself**. That's the gap: routing decisions don't see telemetry, so when a model degrades under load or budget pressure, the router keeps shoving requests at it.
12
+
13
+ **Why TITAN can ship this and they can't:** Soma drives already compute Safety from budget runway + recent error rate, every 60s. The 24h drive ring buffer + trajectoryLogger + provider router are all already wired. No competitor has a **homeostatic substrate underneath the router** — they'd have to build the drive layer first. TITAN inverts the pattern: the router consults `getDriveState().safety.satisfaction` *as a routing input*.
14
+
15
+ **The numbers:**
16
+ - Test-pass-rate improvement under degraded conditions: **+12-18% projected** (rerouting cloud→local Kimi when Anthropic 401-storms, vs. fallbackChain's reactive-only behavior — fallbackChain fires *after* the failure, this fires before).
17
+ - Mean-time-to-recovery from a provider incident: **~4min → <60s** (Safety drive picks up error-rate spike in one tick).
18
+ - Cost reduction during low-Purpose periods: **~30%** (when no priority-1 goals are active, drop to qwen-fast for tool-use; reuse existing model registry).
19
+
20
+ **MVP scope:**
21
+ - New `src/agent/driveAwareRouter.ts` — middleware between `agent.ts` and `providers/router.ts`. Reads `getCurrentDriveState()` + telemetryErrorRate.
22
+ - Three policies, declared in config: `safety_floor` (route to fallbackModel when Safety < 0.4), `cost_lid` (downgrade tier when Purpose < 0.3 for >10min), `curiosity_boost` (route to a stronger model when Curiosity is spiking and the user message is a hard question).
23
+ - New endpoint `GET /api/router/decisions?last=50` — returns the last N routing decisions with the drive snapshot that caused each one. **This is the killer artifact.** Engineers paste it in incident reviews.
24
+ - Reuse: `organism/drives.ts`, `providers/router.ts`, `agent/fallbackChain.ts`, `vram/orchestrator.ts` (downgrades that need a model swap go through the existing leaseManager).
25
+ - Mission Control panel: timeline of routing decisions overlaid on drive heatmap.
26
+
27
+ **The flywheel claim:** *"We're the only agent framework where the router has a feedback loop. Anthropic SDK picks a model. TITAN picks a model based on how the agent is feeling — and we have receipts."*
28
+
29
+ ---
30
+
31
+ ### 2. Trajectory Replay Test Harness
32
+
33
+ **The pitch:** "TITAN ships a `titan replay` command that reconstructs any production trajectory as a deterministic test fixture, including the drive state and the persona that was active. CI catches regressions in agent *behavior*, not just code."
34
+
35
+ **The engineer-credible problem:** Eval frameworks (Braintrust, Langsmith, Mastra eval) test agents against curated datasets. Nobody tests against **the trajectories your agent actually ran in production yesterday**. When a senior engineer ships a prompt change and silently breaks the live retry behavior on flaky tools, the eval suite misses it because the eval suite isn't real traffic. There's no `pytest tests/regression/` for agents.
36
+
37
+ **Why TITAN can ship this and they can't:** trajectoryLogger + persona-profile resolver + drive ring buffer + tool execution log are all already on disk. The full causal context of any production turn is reconstructable from `~/.titan/`. Mastra/Vercel persist nothing — there's no past trajectory to replay. This is purely *exposure of latent state*.
38
+
39
+ **The numbers:**
40
+ - Behavior-regression catch rate: prompt edits that break tool sequence get flagged in CI in **<2min** instead of "next time we run that workflow in prod."
41
+ - False-positive eval rate: deterministic replay (mocked tools, frozen drive snapshot) brings flakes to **near-zero** vs. live-eval flakes ~15-20%.
42
+ - Time to write a regression test: from "draft an eval scenario" (~30min per case) to **`titan replay --pin trajectory_id` (~5s)**.
43
+
44
+ **MVP scope:**
45
+ - New CLI `titan replay <trajectoryId>` — reads `getRecentTrajectories()`, hydrates drive snapshot from ring buffer at the timestamp, sets persona via `forceId`, replays the user message through the agent loop with tool calls **mocked from the trajectory's recorded responses**. Asserts the output matches.
46
+ - Snapshot format: extends existing trajectory schema with `driveSnapshot`, `personaId`, `modelTier`, recorded `toolCalls[].response`. Versioned.
47
+ - New gateway endpoint `POST /api/trajectories/:id/pin` — copies a trajectory + drive snapshot into `tests/regression/pinned/<slug>.json` and writes a vitest stub. One click in Mission Control = one new regression test.
48
+ - Reuse: `agent/trajectory.ts`, `organism/drives.ts` (snapshot reconstruction), `personaProfiles.ts`, existing vitest infra.
49
+ - v1 gates: only mockable trajectories pin (no live-network tools); a "pin this" button in trajectory log UI.
50
+
51
+ **The flywheel claim:** *"Production behavior is a regression test now. Click any turn in your trajectory log → it's a vitest case. Try doing that in Mastra."*
52
+
53
+ ---
54
+
55
+ ### 3. Persona A/B + Auto-Revert
56
+
57
+ **The pitch:** "Roll a new system prompt to 10% of customer traffic. If pass-rate drops or Safety drive crosses threshold for 30 min, TITAN reverts itself and posts the diff. Argo Rollouts for prompts."
58
+
59
+ **The engineer-credible problem:** Every agent shop has the same broken loop: edit prompt → deploy → hope someone notices if it gets worse → roll back manually three days later when a customer complains. There's no canary mechanism for prompts. Mastra/Vercel SDK don't ship one because they have no notion of *agent health* — they only know request status. **Datadog-shaped problem, not Twitter-shaped.**
60
+
61
+ **Why TITAN can ship this and they can't:** persona-profile resolver (just shipped v5.5.24) already keys behavior off channel/time/forceId — extend the resolver to key off a **deterministic hash of caller identity → cohort** and you have free per-tenant A/B. Soma drive metrics are the auto-revert signal. Nobody else has both.
62
+
63
+ **The numbers:**
64
+ - Bad-prompt blast radius: **10% × 30min** instead of "100% × N days until a human notices."
65
+ - Mean-time-to-revert: **<30 min, automatic** vs. typical 2-5 days manual.
66
+ - Revenue protection per bad ship: a single 24h customer-facing prompt regression on an enterprise tier (~$5K/day MRR per customer) → **multiply by N customers**. Replit's argument for $100K/yr writes itself.
67
+
68
+ **MVP scope:**
69
+ - Extend `personaProfiles.ts` with `cohort: { hashKey: 'tenantId'|'sessionId', percent: number, baseline: personaId, candidate: personaId }`.
70
+ - New `src/agent/personaRollout.ts` — computes pass-rate (existing eval harness) + Safety-drive trend per cohort over rolling 30min window. If candidate cohort < baseline by configurable margin OR Safety drops >0.2, auto-revert: flip `cohort.percent` to 0, log to audit trail.
71
+ - New endpoint `POST /api/personas/:id/canary` and `GET /api/personas/cohorts/health` returning per-cohort pass-rate, p50/p95 latency, drive deltas.
72
+ - Reuse: persona resolver, drives, evals (already on Phase E roadmap — *this is what makes evals visionary instead of table-stakes*), auditStore.
73
+ - Mission Control panel: side-by-side cohort cards with sparklines + a big red revert button (and an automated revert event log).
74
+
75
+ **The flywheel claim:** *"Promptops is shipping. We canary persona changes against Soma drives — bad prompts auto-revert in 30 min. Show me one other agent framework that does this."*
76
+
77
+ ---
78
+
79
+ ### 4. Mesh-Aware VRAM Lease Market
80
+
81
+ **The pitch:** "Your laptop needs 24GB to run Llama-70B for 90 seconds. Your other rig has it free. TITAN auto-leases the model on the remote box, streams tokens back over the mesh, and releases. Ray for hobbyists."
82
+
83
+ **The engineer-credible problem:** Heterogeneous-hardware orchestration is an enterprise-only category right now (Ray, Modal, RunPod). Senior engineers at AI-infra startups personally own multiple GPUs and use ~one of them at a time because nothing makes the mesh frictionless. Mastra/Vercel SDK are explicitly **single-machine**. Anthropic SDK doesn't even know GPUs exist. The gap is enormous, and nobody's filled it for the prosumer/homelab tier because nobody has both the **mesh transport** and the **VRAM orchestrator** in one runtime.
84
+
85
+ **Why TITAN can ship this and they can't:** mesh discovery (mDNS), HMAC-auth peer registry, per-peer model registry, and the VRAM orchestrator with leaseManager + autoSwap all already exist. The only missing piece is "cross-peer lease acquisition" — a 2-week build *because the substrate is done*.
86
+
87
+ **The numbers:**
88
+ - Cost to run a 70B model in your dev loop: **$0/hr** (your idle 5090 instead of $2-4/hr Together/RunPod).
89
+ - Cold-start latency for a model not loaded locally: **~6-15s** (mesh peer + warm Ollama) vs. **~30-90s** (cold cloud provider) vs. **fail** (single-machine framework).
90
+ - Effective VRAM available to a single agent: **sum of mesh peers** instead of `min(local)`. For Tony's setup, ~32GB → ~56GB.
91
+
92
+ **MVP scope:**
93
+ - New `src/vram/meshLease.ts` — `acquireMeshLease(modelId, estimatedMB, ttlMs)`. Polls mesh peers (existing `getPeers()`), filters by `peer.models.includes(modelId)` and free VRAM via a new `/api/vram/check` proxy. Lease record persisted at `~/.titan/leases.jsonl` (recoverable across restarts via `restartTracker.ts` pattern).
94
+ - New `src/providers/meshProxy.ts` — OpenAI-shaped provider that streams generation from a mesh peer's `/api/generate` endpoint over the existing HMAC-auth WebSocket transport.
95
+ - Lease scheduler: pick peer by `(free_vram >= needed) AND (load < 0.8) AND (rtt < 50ms)`, weighted lowest-load-first.
96
+ - Auto-release on idle (>60s no tokens) or explicit release. Heartbeat: lease holder pings peer every 10s; on miss, peer auto-releases.
97
+ - Mission Control: "Mesh VRAM" panel shows lease graph (which agent on which peer using which model), free VRAM per peer.
98
+ - Reuse: full `src/mesh/*`, `src/vram/orchestrator.ts`, `src/vram/leaseManager.ts`.
99
+
100
+ **The flywheel claim:** *"My laptop just borrowed 24GB of VRAM from my desktop and ran a 70B model for the duration of one tool call. Then it gave it back. Ray for the rest of us. 19 lines of yaml."*
101
+
102
+ ---
103
+
104
+ ### 5. Drive-Indexed Failure Forensics
105
+
106
+ **The pitch:** "Click any failed run. TITAN shows you what the agent's drives looked like in the 60 minutes before failure, what other agents were running, and which 3 historical failures had the most-similar drive trajectory. Datadog APM, but for agent state."
107
+
108
+ **The engineer-credible problem:** When an autonomous agent fails at 4pm on a Tuesday, you currently have a stack trace and maybe a tool log. You don't know: *was the system under budget pressure? Was there a tool-flake spike 20 min before? Did this same shape of failure happen last week?* This is the **operations problem** for autonomous agents that nobody's solving — Mastra/Anthropic SDK ship traces, not health histories. OTel + Langfuse give you spans; they don't give you **the agent's emotional state at the moment of failure**, which turns out to be the most predictive signal we have.
109
+
110
+ **Why TITAN can ship this and they can't:** Drive ring buffer (1440 ticks/24h) + trajectoryLogger + commandPost run history are all on disk. *Embedding the drive-state-at-failure as a vector* and doing nearest-neighbor lookup against historical failures is **5 days of work**. No competitor has the substrate.
111
+
112
+ **The numbers:**
113
+ - Mean-time-to-diagnose a flaky autonomous failure: from **20-60 min "look at logs"** to **<2 min** (similar-failure cluster surfaces the answer).
114
+ - Repeat-incident rate: **−40% projected** (operators see "this is the 4th time Safety crossed 0.3 right before a run failure" and fix the upstream cause).
115
+ - Onboarding time for new ops engineer: drive-shape clusters become **runbook anchors** ("Cluster #7 = Anthropic-rate-limit pattern; runbook: switch to Kimi").
116
+
117
+ **MVP scope:**
118
+ - New `src/organism/forensics.ts` — `embedDriveWindow(timestamp, windowMins=60)` returns a fixed-length vector (drives × time bins, normalized). Cheap, deterministic, no LLM.
119
+ - On every failed CPRun (existing event), persist `{runId, embedding, traceId, errorClass}` to `~/.titan/failure-embeddings.jsonl`.
120
+ - New endpoint `GET /api/forensics/:runId` — returns the 60-min drive snapshot + top-5 nearest historical failures (cosine sim on the embedding) + their resolutions if logged.
121
+ - Mission Control "Forensics" panel: 5-track drive heatmap centered on failure timestamp, similar-failure list with one-click jump.
122
+ - Reuse: drives, trajectoryLogger, commandPost, auditStore. **No new vector DB needed** — 1000 failures × 600-dim is 4MB on disk; brute-force cosine in Node is sub-ms.
123
+
124
+ **The flywheel claim:** *"Autonomous agents need APM. We shipped it. Every failure is grouped with its three closest historical siblings, indexed by drive shape. Try diagnosing 4am incidents without it once you've had it."*
125
+
126
+ ---
127
+
128
+ ### 6. Federated Failure Patterns (opt-in)
129
+
130
+ **The pitch:** "TITAN nodes opt-in to ship anonymized failure embeddings to a federated index. When your agent fails at 3am, you see 'this same drive-shape failure occurred on 14 other TITAN installs in the last 48h, here's the consensus root cause.' Network effects for agent reliability."
131
+
132
+ **The engineer-credible problem:** Right now every agent install is an island. Customer A's agent breaks Tuesday, customer B's breaks Wednesday with identical root cause, neither knows the other exists. The Anthropic SDK can't fix this — they'd need a multi-tenant telemetry plane and they don't have one. Mastra is single-machine. Sentry-style aggregate error telemetry is the obvious play and nobody has it for **agent runtime state** specifically because nobody else has *agent runtime state worth aggregating*.
133
+
134
+ **Why TITAN can ship this and they can't:** Failure embeddings (#5) are **already anonymized vectors** — no PII, no prompts, just drive shapes + error classes. PostHog telemetry pipe + bucketed system fingerprint are already shipping (v5.0). The federated index is `embedding + count + top-N error_class + top-N resolution_text` — no LLM, no data lake. **A Postgres + 200 lines of route code.**
135
+
136
+ **The numbers:**
137
+ - Time-to-known-issue lookup: **seconds** (vector NN) vs. **hours/days** (search GitHub issues, Discord, hope someone hit it).
138
+ - Adoption flywheel: every install that opts in makes the index more valuable, which makes opt-in more valuable. Classic network effect — and it's specific to TITAN's substrate, so no competitor can replicate without rebuilding the drive layer first.
139
+ - Concrete example: Kimi 401-storm pattern (already in Tony's CHANGELOG) hits 50 installs Tuesday → by Wednesday morning installs 51-N see "47 sibling installs hit this 36h ago, fix: swap model preset URL" the moment it triggers.
140
+
141
+ **MVP scope:**
142
+ - Opt-in `telemetry.federatedFailures: true` in config. **Off by default.** Document exactly what's transmitted: 600-dim vector, errorClass enum, TITAN version, anonymized fingerprint.
143
+ - New gateway-side service (small Cloudflare Worker + D1 vectors, or Supabase pgvector — 1 day) — receives embeddings, stores, serves NN queries.
144
+ - Client-side: on failure, if opted-in, query the index, surface results in Mission Control "Forensics" panel under a "Sibling failures" section.
145
+ - Resolution-text contribution: when an operator logs a fix in Mission Control, an opt-in toggle attaches the (sanitized) one-line fix to that embedding cluster.
146
+ - Hard privacy gate: never transmit prompts, tool call content, secrets, hostnames. Embeddings are mathematically just shape — they cannot reconstruct text.
147
+ - Reuse: PostHog plumbing, telemetry plumbing, forensics module from #5.
148
+
149
+ **The flywheel claim:** *"Sentry was a 9-figure outcome because dev errors get more valuable when they're aggregated. We're doing it for agent drive-state failures. Day 1 it's interesting. Day 90 it's the only reason you can sleep."*
150
+
151
+ ---
152
+
153
+ ### 7. Stateful Fork & 3-Way Merge for Agents
154
+
155
+ **The pitch:** "git for agents. Snapshot your agent's full state — drives, goals, knowledge, persona, recent context — fork it to a new port, run an experiment for 6 hours, then 3-way merge what it learned back into main. The framework where agents have branches."
156
+
157
+ **The engineer-credible problem:** Right now if you want to test "what would my agent do differently if I gave it a new tool / different persona / different model" you destructively edit your single agent and live with it. There's no `git checkout -b experiment`. Mastra/Vercel SDK have no persistent agent state to fork *from*. This is the abstraction every framework will eventually need and nobody has.
158
+
159
+ **Why TITAN can ship this and they can't:** Drive state, goals.json, knowledge.json, trajectoryLogger, persona profiles, command-post run history — **all on disk, all in `~/.titan/`**. `conflictResolver.ts` already exists and does 3-way merge for goals/knowledge. Spawning a second gateway on a different port is an existing test pattern. The full machinery is there; it just needs an exposed API.
160
+
161
+ **The numbers:**
162
+ - Time to test "what if agent had access to tool X": **5 min** (`titan fork --add-tool X`) instead of "edit config, restart, lose context, hope the experiment is interpretable."
163
+ - Failed-experiment rollback cost: **0** (fork lives in its own `TITAN_HOME`, just delete the directory).
164
+ - Ability to run two agents in parallel for paired-experiment evals (same starting context, different prompt): **first-class** vs. impossible-without-this-feature.
165
+
166
+ **MVP scope:**
167
+ - New `src/agent/timeMachine.ts` — `createSnapshot()` zips drive-state, goals, knowledge, persona config, last-N trajectories, command-post DB to `~/.titan/snapshots/<id>.tgz`.
168
+ - `forkFrom(snapshotId, port, overrides)` — spawns a child gateway process with `TITAN_HOME=~/.titan/forks/<id>`, applies overrides (e.g., add a persona, swap model), runs independently.
169
+ - `mergeFork(forkId, strategy='goals'|'knowledge'|'both')` — runs existing `conflictResolver.ts` 3-way merge against current main state.
170
+ - Fork TTL: 24h auto-cleanup unless promoted; capped at 5 concurrent forks (prevent fork bombs).
171
+ - Reuse: conflictResolver, restartTracker pattern, existing CLI infra.
172
+ - Endpoint: `POST /api/forks` / `GET /api/forks` / `POST /api/forks/:id/merge`.
173
+
174
+ **The flywheel claim:** *"My agent has branches. I forked it Monday with a new tool, ran it on real traffic for 24h, and just merged its learned knowledge back. git but for agent state. The first framework where this is a one-liner."*
175
+
176
+ ---
177
+
178
+ ## Top 2 picks (V2)
179
+
180
+ **#3 Persona A/B + Auto-Revert** is the strongest answer to the lock criterion. *Would Replit pay $100K/yr for this?* Yes — bad-prompt regressions on enterprise customer traffic cost real revenue, and the auto-revert + audit trail solves a problem their on-call team currently manages with Slack threads and dread. It also leverages persona-profiles (just shipped, so the foundation is real) and turns the eval framework on Phase E roadmap from table-stakes into a genuine moat. Senior engineers will retweet it; CTOs will line-item it.
181
+
182
+ **#4 Mesh-Aware VRAM Lease Market** is the strongest *shape-of-the-abstraction* claim — "I borrowed 24GB from my other machine for the duration of one tool call" is a sentence that doesn't exist in any other framework's vocabulary. Ship it and TITAN occupies a unique position: the only agent framework whose **structural advantage is that you can run more than one machine**. It also has the lowest-vapor MVP because every substrate piece (mesh transport, VRAM orchestrator, lease manager, model registry) is already shipping. 1-2 weeks; everyone with a homelab installs it day-1.
183
+
184
+ Honorable mention: **#5 Drive-Indexed Failure Forensics** is the lowest-cost ship and the hook with the longest tail — once an operator has used "show me sibling failures" they can't operate without it. Pair it with #6 (federated index) once the local version is mature and you have a Sentry-shaped business.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "titan-agent",
3
- "version": "5.5.25",
3
+ "version": "5.5.26",
4
4
  "description": "TITAN — Autonomous AI agent framework with self-improvement, multi-agent orchestration, 36 LLM providers, 16 channel adapters, GPU VRAM management, mesh networking, LiveKit voice, TITAN-Soma homeostatic drives, and a React Mission Control dashboard. Open-source, TypeScript, MIT licensed.",
5
5
  "author": "Tony Elliott (https://github.com/Djtony707)",
6
6
  "repository": {
@@ -1,4 +1,4 @@
1
- import{c as S,r as d,j as e,ae as A,af as k}from"./index-DzwowwSI.js";import{R as C}from"./terminal-BtiqJ628.js";import{F as T}from"./funnel-J3mULzrz.js";/**
1
+ import{c as S,r as d,j as e,ae as A,af as k}from"./index-Ba6pEFSB.js";import{R as C}from"./terminal-CbB-3SZc.js";import{F as T}from"./funnel-CiTRfpfx.js";/**
2
2
  * @license lucide-react v0.513.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as M,r as c,a4 as B,j as e,e as F,Z as E,ad as O,t as C,b,S as g,G as q,d as T}from"./index-DzwowwSI.js";import{L as I}from"./loader-circle-1YOBsoQp.js";import{S as G}from"./save-Btx-kpoW.js";import{C as V}from"./circle-check-big-fPhEdP88.js";import{R as D}from"./terminal-BtiqJ628.js";import{R}from"./rotate-ccw-Co-_W04j.js";import{R as H,b as U,a as J,D as Z}from"./TitanCanvas-BCbWnLMd.js";import{B as W}from"./wrench-CDz3xYve.js";import{N as K}from"./network-DbGDAdrn.js";import{P as Q}from"./play-DVY9c5Ck.js";import{U as X,M as Y}from"./users-dZgv4ePG.js";import"./chevron-up-C5g6pEj8.js";import"./plus-Csu2v9GN.js";import"./search-0hXTwEZR.js";import"./send-TEpapzQR.js";import"./VoiceOverlay-D-gc58b0.js";import"./chevron-right-aQEw2mUW.js";import"./chevron-down-D7OLjvuD.js";import"./folder-DA43TRCm.js";import"./clock-CTsgP_Sn.js";import"./check-Bpm1IONe.js";import"./shield-check-DjBJXZUr.js";import"./external-link-BZ0y_Ahx.js";/**
1
+ import{c as M,r as c,a4 as B,j as e,e as F,Z as E,ad as O,t as C,b,S as g,G as q,d as T}from"./index-Ba6pEFSB.js";import{L as I}from"./loader-circle-DS59DE4w.js";import{S as G}from"./save-BHn8eVKt.js";import{C as V}from"./circle-check-big-Ccs78slx.js";import{R as D}from"./terminal-CbB-3SZc.js";import{R}from"./rotate-ccw-DFyInSgJ.js";import{R as H,b as U,a as J,D as Z}from"./TitanCanvas-D3NdtqI0.js";import{B as W}from"./wrench-CppG-1zJ.js";import{N as K}from"./network-D-P-nlHV.js";import{P as Q}from"./play-Cr53Iwat.js";import{U as X,M as Y}from"./users-CPePALGx.js";import"./chevron-up-CXwVHYv7.js";import"./plus-BUOjWfPb.js";import"./search-B2AzV9aH.js";import"./send-3MPWl9QJ.js";import"./VoiceOverlay-CeYB8JMF.js";import"./chevron-right-CgXD9Slz.js";import"./chevron-down-UTFDbEQ3.js";import"./folder-C3yn66Ka.js";import"./clock-Bm7r0-EW.js";import"./check-CrjQyURH.js";import"./shield-check-CFSKu_na.js";import"./external-link-CcrPL70b.js";/**
2
2
  * @license lucide-react v0.513.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r,b as n,j as e}from"./index-DzwowwSI.js";import{P as c}from"./PageHeader-CnZtP8ek.js";import"./chevron-right-aQEw2mUW.js";function p(){const[t,s]=r.useState(null),[l,i]=r.useState(!0);return r.useEffect(()=>{n("/api/config",{headers:{"Content-Type":"application/json"}}).then(a=>a.json()).then(a=>{var o,d;return s({mode:((o=a.autonomy)==null?void 0:o.mode)||"supervised",interval:(d=a.autonomy)==null?void 0:d.autopilotIntervalMs})}).catch(()=>s({mode:"supervised"})).finally(()=>i(!1))},[]),l?e.jsx("div",{className:"text-[var(--text-muted)]",children:"Loading autopilot config..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(c,{title:"Autopilot",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Agent"},{label:"Autopilot"}]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Mode"}),e.jsx("p",{className:"text-lg font-semibold text-[var(--text)] capitalize",children:t==null?void 0:t.mode})]}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Interval"}),e.jsx("p",{className:"text-lg font-semibold text-[var(--text)]",children:t!=null&&t.interval?`${Math.round(t.interval/6e4)} min`:"Not set"})]})]}),e.jsx("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Autopilot mode enables TITAN to run scheduled tasks automatically. Configure via titan.json."})})]})}export{p as default};
1
+ import{r,b as n,j as e}from"./index-Ba6pEFSB.js";import{P as c}from"./PageHeader-BMCNQJ3s.js";import"./chevron-right-CgXD9Slz.js";function p(){const[t,s]=r.useState(null),[l,i]=r.useState(!0);return r.useEffect(()=>{n("/api/config",{headers:{"Content-Type":"application/json"}}).then(a=>a.json()).then(a=>{var o,d;return s({mode:((o=a.autonomy)==null?void 0:o.mode)||"supervised",interval:(d=a.autonomy)==null?void 0:d.autopilotIntervalMs})}).catch(()=>s({mode:"supervised"})).finally(()=>i(!1))},[]),l?e.jsx("div",{className:"text-[var(--text-muted)]",children:"Loading autopilot config..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(c,{title:"Autopilot",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Agent"},{label:"Autopilot"}]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Mode"}),e.jsx("p",{className:"text-lg font-semibold text-[var(--text)] capitalize",children:t==null?void 0:t.mode})]}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Interval"}),e.jsx("p",{className:"text-lg font-semibold text-[var(--text)]",children:t!=null&&t.interval?`${Math.round(t.interval/6e4)} min`:"Not set"})]})]}),e.jsx("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Autopilot mode enables TITAN to run scheduled tasks automatically. Configure via titan.json."})})]})}export{p as default};
@@ -1,6 +1,6 @@
1
- import{c as q,r as p,b as T,j as e,aN as O}from"./index-DzwowwSI.js";import{F as A}from"./folder-DA43TRCm.js";import{P as D}from"./play-DVY9c5Ck.js";import{P as W}from"./pause-CYhO_uQo.js";import{R as B}from"./terminal-BtiqJ628.js";import{T as H}from"./trophy-CECuZNhX.js";import{T as G}from"./trending-up-MpIrE4j6.js";import{C as U}from"./clock-CTsgP_Sn.js";import{C as V}from"./chevron-down-D7OLjvuD.js";import{C as J}from"./chevron-right-aQEw2mUW.js";/**
1
+ import{c as q,r as p,b as T,j as e,aU as O}from"./index-Ba6pEFSB.js";import{F as A}from"./folder-C3yn66Ka.js";import{P as D}from"./play-Cr53Iwat.js";import{P as W}from"./pause-DmOSwMh6.js";import{R as B}from"./terminal-CbB-3SZc.js";import{T as H}from"./trophy-DDky8DFS.js";import{T as U}from"./trending-up-DPLGp1jF.js";import{C as G}from"./clock-Bm7r0-EW.js";import{C as V}from"./chevron-down-UTFDbEQ3.js";import{C as J}from"./chevron-right-CgXD9Slz.js";/**
2
2
  * @license lucide-react v0.513.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const X=[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Y=q("settings-2",X);function L(t){const x=Date.now()-new Date(t).getTime(),i=Math.floor(x/6e4);if(i<1)return"just now";if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function P(t){if(t<60)return`${Math.round(t)}s`;const x=Math.floor(t/60),i=Math.round(t%60);return`${x}m ${i}s`}function K({runs:t}){if(t.length<2)return e.jsx("div",{className:"flex items-center justify-center h-[200px] rounded-xl border border-bg-tertiary bg-bg-secondary text-text-muted text-sm",children:"Need at least 2 runs to show chart"});const x=800,i=200,a={top:20,right:20,bottom:30,left:50},b=x-a.left-a.right,$=i-a.top-a.bottom,N=t.map(r=>r.val_score),y=Math.max(0,Math.min(...N)-5),_=Math.min(100,Math.max(...N)+5),j=t.length>0?t[0].val_score:null,f=r=>a.left+r/(t.length-1)*b,S=r=>a.top+$-(r-y)/(_-y)*$,v=t.map((r,l)=>`${l===0?"M":"L"} ${f(l)} ${S(r.val_score)}`).join(" "),d=j!=null?S(j):null;return e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary p-4 overflow-x-auto",children:[e.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Val Score Over Time"}),e.jsxs("svg",{viewBox:`0 0 ${x} ${i}`,className:"w-full",style:{minWidth:400},children:[[0,.25,.5,.75,1].map(r=>{const l=a.top+$*(1-r),R=y+(_-y)*r;return e.jsxs("g",{children:[e.jsx("line",{x1:a.left,y1:l,x2:x-a.right,y2:l,stroke:"#27272a",strokeWidth:"1"}),e.jsx("text",{x:a.left-8,y:l+4,textAnchor:"end",fill:"#52525b",fontSize:"10",children:R.toFixed(0)})]},r)}),j!=null&&j>=y&&j<=_&&d!=null&&e.jsxs("g",{children:[e.jsx("line",{x1:a.left,y1:d,x2:x-a.right,y2:d,stroke:"#eab308",strokeWidth:"1",strokeDasharray:"6,4"}),e.jsx("text",{x:x-a.right+4,y:d+3,fill:"#eab308",fontSize:"9",children:"baseline"})]}),e.jsx("path",{d:v,fill:"none",stroke:"#8b5cf6",strokeWidth:"2"}),t.map((r,l)=>{const R=l>0&&r.val_score>t[l-1].val_score,m=l>0&&r.val_score<t[l-1].val_score?"var(--color-error)":R?"var(--color-success)":"var(--color-purple)";return e.jsx("circle",{cx:f(l),cy:S(r.val_score),r:"4",fill:m,stroke:"#18181b",strokeWidth:"2",children:e.jsxs("title",{children:["Run ",l+1,": ",r.val_score," (",L(r.timestamp),")"]})},l)}),t.map((r,l)=>t.length>10&&l%Math.ceil(t.length/10)!==0&&l!==t.length-1?null:e.jsxs("text",{x:f(l),y:i-5,textAnchor:"middle",fill:"#52525b",fontSize:"9",children:["#",l+1]},l))]})]})}function C({icon:t,label:x,value:i,sub:a,color:b="text-text"}){return e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-text-muted",children:t}),e.jsx("span",{className:"text-[10px] font-medium text-text-muted uppercase tracking-wider",children:x})]}),e.jsx("div",{className:`text-2xl font-bold ${b}`,children:i}),a&&e.jsx("div",{className:"text-[10px] text-text-muted mt-0.5",children:a})]})}function ce(){const[t,x]=p.useState([]),[i,a]=p.useState(!0),[b,$]=p.useState(!1),[N,y]=p.useState(null),[_,j]=p.useState(!1),[f,S]=p.useState(!1),v=p.useRef(null),d=p.useCallback((s,h)=>{y({type:s,message:h}),setTimeout(()=>y(null),3e3)},[]),r=p.useCallback(async()=>{try{const s=await T("/api/autoresearch/results");if(s.ok){const h=await s.json();x(h.runs||[])}}catch{}finally{a(!1)}},[]);p.useEffect(()=>{r()},[r]),p.useEffect(()=>(f?v.current&&(clearInterval(v.current),v.current=null):v.current=setInterval(r,3e4),()=>{v.current&&clearInterval(v.current)}),[f,r]);const l=async()=>{j(!0);try{(await T("/api/autoresearch/trigger",{method:"POST"})).ok?d("success","Autoresearch experiment started"):d("error","Failed to trigger experiment")}catch{d("error","Failed to connect to API")}finally{j(!1)}},R=async()=>{try{(await T("/api/message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:"Deploy the best autoresearch LoRA adapter to Ollama. Use train_deploy."})})).ok?d("success","Deploying best model to Ollama..."):d("error","Failed to start deployment")}catch{d("error","Connection error")}},w=t.length>0?Math.max(...t.map(s=>s.val_score)):0,m=t.length>0?t[0].val_score:null,k=m!=null&&t.length>0?t.reduce((s,h)=>s+(h.val_score-m),0)/t.length:null,u=t.length>0?t[t.length-1]:null,g=u==null?void 0:u.hyperparams,F=(s,h)=>{const c=[],o=s.hyperparams,n=h.hyperparams;return o.lr!==n.lr&&c.push(`LR: ${n.lr} → ${o.lr}`),o.rank!==n.rank&&c.push(`Rank: ${n.rank} → ${o.rank}`),o.alpha!==n.alpha&&c.push(`Alpha: ${n.alpha} → ${o.alpha}`),o.epochs!==n.epochs&&c.push(`Epochs: ${n.epochs} → ${o.epochs}`),o.batch_size!==n.batch_size&&c.push(`Batch: ${n.batch_size} → ${o.batch_size}`),o.dropout!==n.dropout&&c.push(`Dropout: ${n.dropout} → ${o.dropout}`),o.grad_accum!==n.grad_accum&&c.push(`GradAccum: ${n.grad_accum} → ${o.grad_accum}`),o.max_seq_len!==n.max_seq_len&&c.push(`SeqLen: ${n.max_seq_len} → ${o.max_seq_len}`),c.length>0?c:["No changes"]};return i?e.jsx("div",{className:"space-y-4",children:[1,2,3].map(s=>e.jsx("div",{className:"h-20 animate-pulse rounded-xl border border-border bg-bg-secondary"},s))}):e.jsxs("div",{className:"space-y-6 max-w-6xl",children:[N&&e.jsx("div",{className:`fixed top-4 right-4 z-50 rounded-lg px-4 py-2.5 text-sm font-medium shadow-lg ${N.type==="success"?"bg-success/20 text-success border border-success/30":"bg-error/20 text-error border border-error/30"}`,children:N.message}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-xl font-bold text-text flex items-center gap-2",children:[e.jsx(A,{className:"h-5 w-5 text-purple"}),"Autoresearch"]}),e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:"Autonomous hyper-parameter search and LoRA fine-tuning"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>S(!f),className:"flex items-center gap-1 rounded-lg border border-bg-tertiary px-2.5 py-1.5 text-xs text-text-secondary hover:bg-bg-tertiary",children:[f?e.jsx(D,{className:"h-3 w-3"}):e.jsx(W,{className:"h-3 w-3"}),f?"Resume":"Pause"]}),e.jsx("button",{onClick:r,className:"flex items-center gap-1 rounded-lg border border-bg-tertiary px-2.5 py-1.5 text-xs text-text-secondary hover:bg-bg-tertiary",children:e.jsx(B,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[e.jsx(C,{icon:e.jsx(A,{className:"h-4 w-4"}),label:"Total Runs",value:t.length}),e.jsx(C,{icon:e.jsx(H,{className:"h-4 w-4"}),label:"Best Val Score",value:w>0?w.toFixed(1):"—",sub:m!=null&&w>m?`+${(w-m).toFixed(1)} from baseline`:void 0,color:m!=null&&w>m?"text-success":"text-text"}),e.jsx(C,{icon:e.jsx(G,{className:"h-4 w-4"}),label:"Avg Improvement",value:k!=null?`${k>=0?"+":""}${k.toFixed(1)}`:"—",color:k!=null?k>0?"text-success":k<0?"text-error":"text-text":"text-text"}),e.jsx(C,{icon:e.jsx(U,{className:"h-4 w-4"}),label:"Last Run",value:u?L(u.timestamp):"Never",sub:u?`Score: ${u.val_score}`:void 0})]}),e.jsx(K,{runs:t}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:l,disabled:_,className:"flex items-center gap-2 rounded-lg bg-purple px-4 py-2 text-sm font-medium text-white hover:bg-[#7c3aed] disabled:opacity-50",children:[e.jsx(D,{className:"h-4 w-4"}),_?"Starting...":"Run Experiment"]}),e.jsxs("button",{onClick:R,disabled:t.length===0,className:"flex items-center gap-2 rounded-lg border border-bg-tertiary px-4 py-2 text-sm font-medium text-text-secondary hover:bg-bg-tertiary disabled:opacity-50",children:[e.jsx(O,{className:"h-4 w-4"}),"Deploy Best Model"]}),u&&e.jsxs("span",{className:"text-xs text-text-muted",children:[u.num_examples," training examples · ",P(u.training_time_s)]})]}),t.length>0&&e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-bg-tertiary",children:[e.jsx("h3",{className:"text-sm font-medium text-text",children:"What Made TITAN Better"}),e.jsx("p",{className:"text-[10px] text-text-muted",children:"Experiment history — how each change affected val_score"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-bg-tertiary",children:[e.jsx("th",{className:"px-4 py-2 text-[10px] font-medium text-text-muted",children:"#"}),e.jsx("th",{className:"px-4 py-2 text-[10px] font-medium text-text-muted",children:"Date"}),e.jsx("th",{className:"px-4 py-2 text-[10px] font-medium text-text-muted",children:"Changes"}),e.jsx("th",{className:"px-4 py-2 text-[10px] font-medium text-text-muted text-right",children:"Score"}),e.jsx("th",{className:"px-4 py-2 text-[10px] font-medium text-text-muted text-right",children:"Δ"}),e.jsx("th",{className:"px-4 py-2 text-[10px] font-medium text-text-muted text-right",children:"Duration"}),e.jsx("th",{className:"px-4 py-2 text-[10px] font-medium text-text-muted text-right",children:"Examples"})]})}),e.jsx("tbody",{children:[...t].reverse().map((s,h)=>{const c=t.length-1-h,o=c>0?t[c-1]:null,n=o?s.val_score-o.val_score:m!=null?s.val_score-m:0,z=o?F(s,o):["Initial run"],M=new Date(s.timestamp);return e.jsxs("tr",{className:"border-b border-bg-tertiary last:border-0 hover:bg-[#27272a30]",children:[e.jsx("td",{className:"px-4 py-2 text-text-muted font-mono",children:c+1}),e.jsxs("td",{className:"px-4 py-2 text-text-secondary",children:[M.toLocaleDateString()," ",M.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]}),e.jsx("td",{className:"px-4 py-2 text-text-secondary",children:z.map((E,I)=>e.jsx("span",{className:"inline-block mr-1.5 rounded bg-bg-tertiary px-1.5 py-0.5 text-[10px] font-mono",children:E},I))}),e.jsx("td",{className:"px-4 py-2 text-right font-mono text-text font-medium",children:s.val_score.toFixed(1)}),e.jsx("td",{className:"px-4 py-2 text-right font-mono",children:e.jsxs("span",{className:n>0?"text-success":n<0?"text-error":"text-text-muted",children:[n>0?"+":"",n.toFixed(1)]})}),e.jsx("td",{className:"px-4 py-2 text-right text-text-muted",children:P(s.training_time_s)}),e.jsx("td",{className:"px-4 py-2 text-right text-text-muted",children:s.num_examples})]},c)})})]})})]}),e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>$(!b),className:"flex w-full items-center gap-2 text-xs font-medium text-text-secondary uppercase tracking-wider hover:text-text",children:[b?e.jsx(V,{className:"h-3.5 w-3.5"}):e.jsx(J,{className:"h-3.5 w-3.5"}),e.jsx(Y,{className:"h-3.5 w-3.5"}),"Current Hyperparameters"]}),b&&g&&e.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2 sm:grid-cols-4",children:[{label:"Learning Rate",value:g.lr},{label:"LoRA Rank",value:g.rank},{label:"LoRA Alpha",value:g.alpha},{label:"Dropout",value:g.dropout},{label:"Epochs",value:g.epochs},{label:"Batch Size",value:g.batch_size},{label:"Grad Accum",value:g.grad_accum},{label:"Max Seq Len",value:g.max_seq_len}].map(({label:s,value:h})=>e.jsxs("div",{className:"rounded-lg border border-bg-tertiary bg-bg-secondary px-3 py-2",children:[e.jsx("div",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:s}),e.jsx("div",{className:"text-sm font-mono text-text mt-0.5",children:h})]},s))}),b&&!g&&e.jsx("div",{className:"mt-3 rounded-lg border border-bg-tertiary bg-bg-secondary px-4 py-3 text-xs text-text-muted",children:"No runs yet — hyperparameters will appear after the first experiment"})]}),t.length===0&&e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary p-8 text-center",children:[e.jsx(A,{className:"h-8 w-8 text-text-muted mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-text-secondary",children:"No autoresearch runs yet"}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:'Click "Run Experiment" to start fine-tuning qwen3.5:35b on the RTX 5090'})]})]})}export{ce as default};
6
+ */const X=[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Y=q("settings-2",X);function L(t){const x=Date.now()-new Date(t).getTime(),i=Math.floor(x/6e4);if(i<1)return"just now";if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function P(t){if(t<60)return`${Math.round(t)}s`;const x=Math.floor(t/60),i=Math.round(t%60);return`${x}m ${i}s`}function K({runs:t}){if(t.length<2)return e.jsx("div",{className:"flex items-center justify-center h-[200px] rounded-xl border border-bg-tertiary bg-bg-secondary text-text-muted text-sm",children:"Need at least 2 runs to show chart"});const x=800,i=200,a={top:20,right:20,bottom:30,left:50},b=x-a.left-a.right,$=i-a.top-a.bottom,N=t.map(r=>r.val_score),y=Math.max(0,Math.min(...N)-5),_=Math.min(100,Math.max(...N)+5),j=t.length>0?t[0].val_score:null,f=r=>a.left+r/(t.length-1)*b,S=r=>a.top+$-(r-y)/(_-y)*$,v=t.map((r,l)=>`${l===0?"M":"L"} ${f(l)} ${S(r.val_score)}`).join(" "),d=j!=null?S(j):null;return e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary p-4 overflow-x-auto",children:[e.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Val Score Over Time"}),e.jsxs("svg",{viewBox:`0 0 ${x} ${i}`,className:"w-full",style:{minWidth:400},children:[[0,.25,.5,.75,1].map(r=>{const l=a.top+$*(1-r),R=y+(_-y)*r;return e.jsxs("g",{children:[e.jsx("line",{x1:a.left,y1:l,x2:x-a.right,y2:l,stroke:"#27272a",strokeWidth:"1"}),e.jsx("text",{x:a.left-8,y:l+4,textAnchor:"end",fill:"#52525b",fontSize:"10",children:R.toFixed(0)})]},r)}),j!=null&&j>=y&&j<=_&&d!=null&&e.jsxs("g",{children:[e.jsx("line",{x1:a.left,y1:d,x2:x-a.right,y2:d,stroke:"#eab308",strokeWidth:"1",strokeDasharray:"6,4"}),e.jsx("text",{x:x-a.right+4,y:d+3,fill:"#eab308",fontSize:"9",children:"baseline"})]}),e.jsx("path",{d:v,fill:"none",stroke:"#8b5cf6",strokeWidth:"2"}),t.map((r,l)=>{const R=l>0&&r.val_score>t[l-1].val_score,m=l>0&&r.val_score<t[l-1].val_score?"var(--color-error)":R?"var(--color-success)":"var(--color-purple)";return e.jsx("circle",{cx:f(l),cy:S(r.val_score),r:"4",fill:m,stroke:"#18181b",strokeWidth:"2",children:e.jsxs("title",{children:["Run ",l+1,": ",r.val_score," (",L(r.timestamp),")"]})},l)}),t.map((r,l)=>t.length>10&&l%Math.ceil(t.length/10)!==0&&l!==t.length-1?null:e.jsxs("text",{x:f(l),y:i-5,textAnchor:"middle",fill:"#52525b",fontSize:"9",children:["#",l+1]},l))]})]})}function C({icon:t,label:x,value:i,sub:a,color:b="text-text"}){return e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-text-muted",children:t}),e.jsx("span",{className:"text-[10px] font-medium text-text-muted uppercase tracking-wider",children:x})]}),e.jsx("div",{className:`text-2xl font-bold ${b}`,children:i}),a&&e.jsx("div",{className:"text-[10px] text-text-muted mt-0.5",children:a})]})}function ce(){const[t,x]=p.useState([]),[i,a]=p.useState(!0),[b,$]=p.useState(!1),[N,y]=p.useState(null),[_,j]=p.useState(!1),[f,S]=p.useState(!1),v=p.useRef(null),d=p.useCallback((s,h)=>{y({type:s,message:h}),setTimeout(()=>y(null),3e3)},[]),r=p.useCallback(async()=>{try{const s=await T("/api/autoresearch/results");if(s.ok){const h=await s.json();x(h.runs||[])}}catch{}finally{a(!1)}},[]);p.useEffect(()=>{r()},[r]),p.useEffect(()=>(f?v.current&&(clearInterval(v.current),v.current=null):v.current=setInterval(r,3e4),()=>{v.current&&clearInterval(v.current)}),[f,r]);const l=async()=>{j(!0);try{(await T("/api/autoresearch/trigger",{method:"POST"})).ok?d("success","Autoresearch experiment started"):d("error","Failed to trigger experiment")}catch{d("error","Failed to connect to API")}finally{j(!1)}},R=async()=>{try{(await T("/api/message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:"Deploy the best autoresearch LoRA adapter to Ollama. Use train_deploy."})})).ok?d("success","Deploying best model to Ollama..."):d("error","Failed to start deployment")}catch{d("error","Connection error")}},w=t.length>0?Math.max(...t.map(s=>s.val_score)):0,m=t.length>0?t[0].val_score:null,k=m!=null&&t.length>0?t.reduce((s,h)=>s+(h.val_score-m),0)/t.length:null,u=t.length>0?t[t.length-1]:null,g=u==null?void 0:u.hyperparams,F=(s,h)=>{const c=[],o=s.hyperparams,n=h.hyperparams;return o.lr!==n.lr&&c.push(`LR: ${n.lr} → ${o.lr}`),o.rank!==n.rank&&c.push(`Rank: ${n.rank} → ${o.rank}`),o.alpha!==n.alpha&&c.push(`Alpha: ${n.alpha} → ${o.alpha}`),o.epochs!==n.epochs&&c.push(`Epochs: ${n.epochs} → ${o.epochs}`),o.batch_size!==n.batch_size&&c.push(`Batch: ${n.batch_size} → ${o.batch_size}`),o.dropout!==n.dropout&&c.push(`Dropout: ${n.dropout} → ${o.dropout}`),o.grad_accum!==n.grad_accum&&c.push(`GradAccum: ${n.grad_accum} → ${o.grad_accum}`),o.max_seq_len!==n.max_seq_len&&c.push(`SeqLen: ${n.max_seq_len} → ${o.max_seq_len}`),c.length>0?c:["No changes"]};return i?e.jsx("div",{className:"space-y-4",children:[1,2,3].map(s=>e.jsx("div",{className:"h-20 animate-pulse rounded-xl border border-border bg-bg-secondary"},s))}):e.jsxs("div",{className:"space-y-6 max-w-6xl",children:[N&&e.jsx("div",{className:`fixed top-4 right-4 z-50 rounded-lg px-4 py-2.5 text-sm font-medium shadow-lg ${N.type==="success"?"bg-success/20 text-success border border-success/30":"bg-error/20 text-error border border-error/30"}`,children:N.message}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-xl font-bold text-text flex items-center gap-2",children:[e.jsx(A,{className:"h-5 w-5 text-purple"}),"Autoresearch"]}),e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:"Autonomous hyper-parameter search and LoRA fine-tuning"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>S(!f),className:"flex items-center gap-1 rounded-lg border border-bg-tertiary px-2.5 py-1.5 text-xs text-text-secondary hover:bg-bg-tertiary",children:[f?e.jsx(D,{className:"h-3 w-3"}):e.jsx(W,{className:"h-3 w-3"}),f?"Resume":"Pause"]}),e.jsx("button",{onClick:r,className:"flex items-center gap-1 rounded-lg border border-bg-tertiary px-2.5 py-1.5 text-xs text-text-secondary hover:bg-bg-tertiary",children:e.jsx(B,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[e.jsx(C,{icon:e.jsx(A,{className:"h-4 w-4"}),label:"Total Runs",value:t.length}),e.jsx(C,{icon:e.jsx(H,{className:"h-4 w-4"}),label:"Best Val Score",value:w>0?w.toFixed(1):"—",sub:m!=null&&w>m?`+${(w-m).toFixed(1)} from baseline`:void 0,color:m!=null&&w>m?"text-success":"text-text"}),e.jsx(C,{icon:e.jsx(U,{className:"h-4 w-4"}),label:"Avg Improvement",value:k!=null?`${k>=0?"+":""}${k.toFixed(1)}`:"—",color:k!=null?k>0?"text-success":k<0?"text-error":"text-text":"text-text"}),e.jsx(C,{icon:e.jsx(G,{className:"h-4 w-4"}),label:"Last Run",value:u?L(u.timestamp):"Never",sub:u?`Score: ${u.val_score}`:void 0})]}),e.jsx(K,{runs:t}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:l,disabled:_,className:"flex items-center gap-2 rounded-lg bg-purple px-4 py-2 text-sm font-medium text-white hover:bg-[#7c3aed] disabled:opacity-50",children:[e.jsx(D,{className:"h-4 w-4"}),_?"Starting...":"Run Experiment"]}),e.jsxs("button",{onClick:R,disabled:t.length===0,className:"flex items-center gap-2 rounded-lg border border-bg-tertiary px-4 py-2 text-sm font-medium text-text-secondary hover:bg-bg-tertiary disabled:opacity-50",children:[e.jsx(O,{className:"h-4 w-4"}),"Deploy Best Model"]}),u&&e.jsxs("span",{className:"text-xs text-text-muted",children:[u.num_examples," training examples · ",P(u.training_time_s)]})]}),t.length>0&&e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-bg-tertiary",children:[e.jsx("h3",{className:"text-sm font-medium text-text",children:"What Made TITAN Better"}),e.jsx("p",{className:"text-[10px] text-text-muted",children:"Experiment history — how each change affected val_score"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-bg-tertiary",children:[e.jsx("th",{className:"px-4 py-2 text-[10px] font-medium text-text-muted",children:"#"}),e.jsx("th",{className:"px-4 py-2 text-[10px] font-medium text-text-muted",children:"Date"}),e.jsx("th",{className:"px-4 py-2 text-[10px] font-medium text-text-muted",children:"Changes"}),e.jsx("th",{className:"px-4 py-2 text-[10px] font-medium text-text-muted text-right",children:"Score"}),e.jsx("th",{className:"px-4 py-2 text-[10px] font-medium text-text-muted text-right",children:"Δ"}),e.jsx("th",{className:"px-4 py-2 text-[10px] font-medium text-text-muted text-right",children:"Duration"}),e.jsx("th",{className:"px-4 py-2 text-[10px] font-medium text-text-muted text-right",children:"Examples"})]})}),e.jsx("tbody",{children:[...t].reverse().map((s,h)=>{const c=t.length-1-h,o=c>0?t[c-1]:null,n=o?s.val_score-o.val_score:m!=null?s.val_score-m:0,z=o?F(s,o):["Initial run"],M=new Date(s.timestamp);return e.jsxs("tr",{className:"border-b border-bg-tertiary last:border-0 hover:bg-[#27272a30]",children:[e.jsx("td",{className:"px-4 py-2 text-text-muted font-mono",children:c+1}),e.jsxs("td",{className:"px-4 py-2 text-text-secondary",children:[M.toLocaleDateString()," ",M.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]}),e.jsx("td",{className:"px-4 py-2 text-text-secondary",children:z.map((E,I)=>e.jsx("span",{className:"inline-block mr-1.5 rounded bg-bg-tertiary px-1.5 py-0.5 text-[10px] font-mono",children:E},I))}),e.jsx("td",{className:"px-4 py-2 text-right font-mono text-text font-medium",children:s.val_score.toFixed(1)}),e.jsx("td",{className:"px-4 py-2 text-right font-mono",children:e.jsxs("span",{className:n>0?"text-success":n<0?"text-error":"text-text-muted",children:[n>0?"+":"",n.toFixed(1)]})}),e.jsx("td",{className:"px-4 py-2 text-right text-text-muted",children:P(s.training_time_s)}),e.jsx("td",{className:"px-4 py-2 text-right text-text-muted",children:s.num_examples})]},c)})})]})})]}),e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>$(!b),className:"flex w-full items-center gap-2 text-xs font-medium text-text-secondary uppercase tracking-wider hover:text-text",children:[b?e.jsx(V,{className:"h-3.5 w-3.5"}):e.jsx(J,{className:"h-3.5 w-3.5"}),e.jsx(Y,{className:"h-3.5 w-3.5"}),"Current Hyperparameters"]}),b&&g&&e.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2 sm:grid-cols-4",children:[{label:"Learning Rate",value:g.lr},{label:"LoRA Rank",value:g.rank},{label:"LoRA Alpha",value:g.alpha},{label:"Dropout",value:g.dropout},{label:"Epochs",value:g.epochs},{label:"Batch Size",value:g.batch_size},{label:"Grad Accum",value:g.grad_accum},{label:"Max Seq Len",value:g.max_seq_len}].map(({label:s,value:h})=>e.jsxs("div",{className:"rounded-lg border border-bg-tertiary bg-bg-secondary px-3 py-2",children:[e.jsx("div",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:s}),e.jsx("div",{className:"text-sm font-mono text-text mt-0.5",children:h})]},s))}),b&&!g&&e.jsx("div",{className:"mt-3 rounded-lg border border-bg-tertiary bg-bg-secondary px-4 py-3 text-xs text-text-muted",children:"No runs yet — hyperparameters will appear after the first experiment"})]}),t.length===0&&e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary p-8 text-center",children:[e.jsx(A,{className:"h-8 w-8 text-text-muted mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-text-secondary",children:"No autoresearch runs yet"}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:'Click "Run Experiment" to start fine-tuning qwen3.5:35b on the RTX 5090'})]})]})}export{ce as default};
@@ -1 +1 @@
1
- import{r as t,aU as f,j as e,aV as u,aW as h}from"./index-DzwowwSI.js";import{P as g}from"./PageHeader-CnZtP8ek.js";import{P as b}from"./plus-Csu2v9GN.js";import{R as y}from"./terminal-BtiqJ628.js";import{A as j}from"./TitanCanvas-BCbWnLMd.js";import{C as v}from"./circle-check-big-fPhEdP88.js";import"./chevron-right-aQEw2mUW.js";import"./chevron-up-C5g6pEj8.js";import"./users-dZgv4ePG.js";import"./wrench-CDz3xYve.js";import"./network-DbGDAdrn.js";import"./save-Btx-kpoW.js";import"./rotate-ccw-Co-_W04j.js";import"./search-0hXTwEZR.js";import"./send-TEpapzQR.js";import"./VoiceOverlay-D-gc58b0.js";import"./chevron-down-D7OLjvuD.js";import"./folder-DA43TRCm.js";import"./clock-CTsgP_Sn.js";import"./check-Bpm1IONe.js";import"./shield-check-DjBJXZUr.js";import"./external-link-BZ0y_Ahx.js";import"./loader-circle-1YOBsoQp.js";function J(){const[r,p]=t.useState([]),[i,c]=t.useState(!0),[l,o]=t.useState(!1),[n,m]=t.useState(null),s=t.useCallback(async()=>{c(!0);try{const a=await f();p(a.backups||[])}catch{}c(!1)},[]);t.useEffect(()=>{s()},[s]);const d=async()=>{o(!0);try{await u(),await s()}catch{}o(!1)},x=async a=>{m(a);try{await h(a),alert("Backup verified successfully")}catch{alert("Backup verification failed")}m(null)};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{title:"Backup Manager",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"System"},{label:"Backups"}]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:d,disabled:l,className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-[#6366f1] text-white text-sm font-medium hover:bg-[#4f46e5] disabled:opacity-50",children:[e.jsx(b,{className:"w-4 h-4"})," ",l?"Creating...":"Create Backup"]}),e.jsxs("button",{onClick:s,disabled:i,className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-[#27272a] text-[#a1a1aa] text-sm font-medium hover:bg-[#3f3f46] disabled:opacity-50",children:[e.jsx(y,{className:`w-4 h-4 ${i?"animate-spin":""}`})," Refresh"]})]}),r.length===0&&!i&&e.jsx("div",{className:"text-sm text-[#52525b]",children:"No backups found."}),e.jsx("div",{className:"space-y-2",children:r.map(a=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(j,{className:"w-4 h-4 text-[#6366f1]"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[#e4e4e7]",children:new Date(a.createdAt).toLocaleString()}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[(a.sizeBytes/1024/1024).toFixed(1)," MB"]})]})]}),e.jsxs("button",{onClick:()=>x(a.path),disabled:n===a.path,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-md bg-[#27272a] text-[#a1a1aa] text-xs hover:bg-[#3f3f46] disabled:opacity-50",children:[e.jsx(v,{className:"w-3.5 h-3.5"})," ",n===a.path?"Verifying...":"Verify"]})]},a.path))})]})}export{J as default};
1
+ import{r as t,a$ as f,j as e,b0 as u,b1 as h}from"./index-Ba6pEFSB.js";import{P as g}from"./PageHeader-BMCNQJ3s.js";import{P as b}from"./plus-BUOjWfPb.js";import{R as y}from"./terminal-CbB-3SZc.js";import{A as j}from"./TitanCanvas-D3NdtqI0.js";import{C as v}from"./circle-check-big-Ccs78slx.js";import"./chevron-right-CgXD9Slz.js";import"./chevron-up-CXwVHYv7.js";import"./users-CPePALGx.js";import"./wrench-CppG-1zJ.js";import"./network-D-P-nlHV.js";import"./save-BHn8eVKt.js";import"./rotate-ccw-DFyInSgJ.js";import"./search-B2AzV9aH.js";import"./send-3MPWl9QJ.js";import"./VoiceOverlay-CeYB8JMF.js";import"./chevron-down-UTFDbEQ3.js";import"./folder-C3yn66Ka.js";import"./clock-Bm7r0-EW.js";import"./check-CrjQyURH.js";import"./shield-check-CFSKu_na.js";import"./external-link-CcrPL70b.js";import"./loader-circle-DS59DE4w.js";function O(){const[r,p]=t.useState([]),[i,c]=t.useState(!0),[l,o]=t.useState(!1),[n,m]=t.useState(null),s=t.useCallback(async()=>{c(!0);try{const a=await f();p(a.backups||[])}catch{}c(!1)},[]);t.useEffect(()=>{s()},[s]);const d=async()=>{o(!0);try{await u(),await s()}catch{}o(!1)},x=async a=>{m(a);try{await h(a),alert("Backup verified successfully")}catch{alert("Backup verification failed")}m(null)};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{title:"Backup Manager",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"System"},{label:"Backups"}]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:d,disabled:l,className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-[#6366f1] text-white text-sm font-medium hover:bg-[#4f46e5] disabled:opacity-50",children:[e.jsx(b,{className:"w-4 h-4"})," ",l?"Creating...":"Create Backup"]}),e.jsxs("button",{onClick:s,disabled:i,className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-[#27272a] text-[#a1a1aa] text-sm font-medium hover:bg-[#3f3f46] disabled:opacity-50",children:[e.jsx(y,{className:`w-4 h-4 ${i?"animate-spin":""}`})," Refresh"]})]}),r.length===0&&!i&&e.jsx("div",{className:"text-sm text-[#52525b]",children:"No backups found."}),e.jsx("div",{className:"space-y-2",children:r.map(a=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(j,{className:"w-4 h-4 text-[#6366f1]"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[#e4e4e7]",children:new Date(a.createdAt).toLocaleString()}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[(a.sizeBytes/1024/1024).toFixed(1)," MB"]})]})]}),e.jsxs("button",{onClick:()=>x(a.path),disabled:n===a.path,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-md bg-[#27272a] text-[#a1a1aa] text-xs hover:bg-[#3f3f46] disabled:opacity-50",children:[e.jsx(v,{className:"w-3.5 h-3.5"})," ",n===a.path?"Verifying...":"Verify"]})]},a.path))})]})}export{O as default};
@@ -1,4 +1,4 @@
1
- import{c as i,r as s,j as e,G as m,bc as p}from"./index-DzwowwSI.js";import{P as h}from"./PageHeader-CnZtP8ek.js";import"./chevron-right-aQEw2mUW.js";/**
1
+ import{c as i,r as s,j as e,G as m,bj as p}from"./index-Ba6pEFSB.js";import{P as h}from"./PageHeader-BMCNQJ3s.js";import"./chevron-right-CgXD9Slz.js";/**
2
2
  * @license lucide-react v0.513.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as a,bo as y,j as e,A as u,Z as j,T as S}from"./index-DzwowwSI.js";import"./Input-Bu_b3qmY.js";import{P as A}from"./PageHeader-CnZtP8ek.js";import{E as T}from"./EmptyState-jU6yNDnF.js";import{T as E}from"./Tabs-BBYZrBI8.js";import{S as N}from"./SkeletonLoader-B5v09EF_.js";import{W as C,B as w}from"./wrench-CDz3xYve.js";import{S as P}from"./shield-check-DjBJXZUr.js";import{D as $}from"./dollar-sign-CudFVYFc.js";import{T as k}from"./target-BRW80Xer.js";import"./loader-circle-1YOBsoQp.js";import"./chevron-right-aQEw2mUW.js";function I(s){const r=Math.floor((Date.now()-new Date(s).getTime())/1e3);return r<60?`${r}s`:r<3600?`${Math.floor(r/60)}m`:r<86400?`${Math.floor(r/3600)}h`:`${Math.floor(r/86400)}d`}const D={agent:w,goal:k,budget:$,approval:P,error:S,tool:C,system:j},M={agent:"text-accent",goal:"text-success",budget:"text-warning",approval:"text-info",error:"text-error",tool:"text-text-secondary",system:"text-text-muted"};function q(){const[s,r]=a.useState([]),[i,f]=a.useState(!0),[o,x]=a.useState(null),[n,h]=a.useState("all"),l=a.useRef(null),c=a.useCallback(async()=>{try{const t=await y(100);r(t),x(null)}catch(t){x(t instanceof Error?t.message:"Failed to load activity")}f(!1)},[]);a.useEffect(()=>(c(),l.current=setInterval(c,1e4),()=>{l.current&&clearInterval(l.current)}),[c]);const p=Array.from(new Set(s.map(t=>t.type))),g=[{id:"all",label:"All",count:s.length},...p.map(t=>({id:t,label:t.charAt(0).toUpperCase()+t.slice(1),count:s.filter(d=>d.type===t).length}))],m=n==="all"?s:s.filter(t=>t.type===n);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(A,{title:"Activity",subtitle:"Auto-refreshes every 10s",breadcrumbs:[{label:"Command Post"},{label:"Activity"}]}),p.length>0&&e.jsx(E,{tabs:g,activeTab:n,onChange:h}),i&&e.jsx(N,{variant:"row",count:8}),o&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:o}),!i&&!o&&m.length===0&&e.jsx(T,{icon:e.jsx(u,{size:32}),title:"No activity",description:"Agent activity will appear here as events occur."}),!i&&!o&&m.length>0&&e.jsx("div",{className:"divide-y divide-border rounded-xl border border-border bg-bg-secondary overflow-hidden",children:m.map((t,d)=>{const v=D[t.type]??u,b=M[t.type]??"text-text-muted";return e.jsxs("div",{className:"flex items-start gap-3 px-4 py-2.5",children:[e.jsx(v,{size:14,className:`${b} mt-0.5 flex-shrink-0`}),e.jsx("span",{className:"flex-1 text-sm text-text-secondary",children:t.message}),t.agentId&&e.jsx("span",{className:"text-[10px] text-text-muted flex-shrink-0",children:t.agentId}),e.jsx("span",{className:"text-xs text-text-muted flex-shrink-0",children:I(t.timestamp)})]},`${t.id}-${d}`)})})]})}export{q as default};
1
+ import{r as a,bv as y,j as e,A as u,Z as j,T as S}from"./index-Ba6pEFSB.js";import"./Input-CdHGkE1K.js";import{P as A}from"./PageHeader-BMCNQJ3s.js";import{E as T}from"./EmptyState-ZooZL1_g.js";import{T as E}from"./Tabs-DKvN1LcI.js";import{S as N}from"./SkeletonLoader-B6Y6z3-s.js";import{W as C,B as w}from"./wrench-CppG-1zJ.js";import{S as P}from"./shield-check-CFSKu_na.js";import{D as $}from"./dollar-sign-BjOfnLA5.js";import{T as k}from"./target-D7_0NmbL.js";import"./loader-circle-DS59DE4w.js";import"./chevron-right-CgXD9Slz.js";function I(s){const r=Math.floor((Date.now()-new Date(s).getTime())/1e3);return r<60?`${r}s`:r<3600?`${Math.floor(r/60)}m`:r<86400?`${Math.floor(r/3600)}h`:`${Math.floor(r/86400)}d`}const D={agent:w,goal:k,budget:$,approval:P,error:S,tool:C,system:j},M={agent:"text-accent",goal:"text-success",budget:"text-warning",approval:"text-info",error:"text-error",tool:"text-text-secondary",system:"text-text-muted"};function q(){const[s,r]=a.useState([]),[i,f]=a.useState(!0),[o,x]=a.useState(null),[n,h]=a.useState("all"),l=a.useRef(null),c=a.useCallback(async()=>{try{const t=await y(100);r(t),x(null)}catch(t){x(t instanceof Error?t.message:"Failed to load activity")}f(!1)},[]);a.useEffect(()=>(c(),l.current=setInterval(c,1e4),()=>{l.current&&clearInterval(l.current)}),[c]);const p=Array.from(new Set(s.map(t=>t.type))),g=[{id:"all",label:"All",count:s.length},...p.map(t=>({id:t,label:t.charAt(0).toUpperCase()+t.slice(1),count:s.filter(d=>d.type===t).length}))],m=n==="all"?s:s.filter(t=>t.type===n);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(A,{title:"Activity",subtitle:"Auto-refreshes every 10s",breadcrumbs:[{label:"Command Post"},{label:"Activity"}]}),p.length>0&&e.jsx(E,{tabs:g,activeTab:n,onChange:h}),i&&e.jsx(N,{variant:"row",count:8}),o&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:o}),!i&&!o&&m.length===0&&e.jsx(T,{icon:e.jsx(u,{size:32}),title:"No activity",description:"Agent activity will appear here as events occur."}),!i&&!o&&m.length>0&&e.jsx("div",{className:"divide-y divide-border rounded-xl border border-border bg-bg-secondary overflow-hidden",children:m.map((t,d)=>{const v=D[t.type]??u,b=M[t.type]??"text-text-muted";return e.jsxs("div",{className:"flex items-start gap-3 px-4 py-2.5",children:[e.jsx(v,{size:14,className:`${b} mt-0.5 flex-shrink-0`}),e.jsx("span",{className:"flex-1 text-sm text-text-secondary",children:t.message}),t.agentId&&e.jsx("span",{className:"text-[10px] text-text-muted flex-shrink-0",children:t.agentId}),e.jsx("span",{className:"text-xs text-text-muted flex-shrink-0",children:I(t.timestamp)})]},`${t.id}-${d}`)})})]})}export{q as default};
@@ -1 +1 @@
1
- import{u as O,i as G,r as s,bm as J,v as K,D as Q,a5 as V,j as e,L as A,a1 as W}from"./index-DzwowwSI.js";import{B as T}from"./Input-Bu_b3qmY.js";import{S as c}from"./StatusBadge-D5nU7El8.js";import{P as x}from"./PageHeader-CnZtP8ek.js";import{E as X}from"./EmptyState-jU6yNDnF.js";import{T as Y}from"./Tabs-BBYZrBI8.js";import{S as Z}from"./SkeletonLoader-B5v09EF_.js";import{A as _}from"./arrow-left-5chqas7J.js";import{C as ee}from"./circle-check-big-fPhEdP88.js";import{D as te}from"./dollar-sign-CudFVYFc.js";import{C as se}from"./clock-CTsgP_Sn.js";import{S as ae}from"./save-Btx-kpoW.js";import"./loader-circle-1YOBsoQp.js";import"./chevron-right-aQEw2mUW.js";function k(a){const o=Math.floor((Date.now()-new Date(a).getTime())/1e3);return o<60?`${o}s`:o<3600?`${Math.floor(o/60)}m`:o<86400?`${Math.floor(o/3600)}h`:`${Math.floor(o/86400)}d`}function re(a){return a?a<1e3?`${a}ms`:`${(a/1e3).toFixed(1)}s`:"-"}function je(){const{id:a}=O(),o=G(),[r,m]=s.useState(null),[n,E]=s.useState([]),[u,M]=s.useState([]),[P,b]=s.useState(!0),[p,i]=s.useState(null),[d,D]=s.useState("overview"),[h,g]=s.useState(""),[f,j]=s.useState(""),[v,N]=s.useState(""),[y,S]=s.useState(""),[z,C]=s.useState(!1),[R,$]=s.useState([]),w=s.useCallback(async()=>{if(a){try{const l=(await J()).find(q=>q.id===a);if(!l){i("Agent not found"),b(!1);return}m(l),g(l.role),j(l.reportsTo??""),N(l.title??""),S(l.model??"");const[H,U]=await Promise.all([K(a),Q({assignee:a})]);E(H),M(U),i(null)}catch(t){i(t instanceof Error?t.message:"Failed to load agent")}b(!1)}},[a]);s.useEffect(()=>{w()},[w]),s.useEffect(()=>{V().then(t=>$(t)).catch(()=>{})},[]);const B=async()=>{if(a){C(!0);try{const t=await W(a,{role:h,reportsTo:f||void 0,title:v||void 0,model:y||void 0});m(t)}catch{}C(!1)}},L=[{id:"overview",label:"Overview"},{id:"runs",label:"Runs",count:n.length},{id:"config",label:"Config"}];if(P)return e.jsxs("div",{className:"space-y-6",children:[e.jsx(x,{title:"Agent",breadcrumbs:[{label:"Command Post"},{label:"Agents",href:"/command-post/agents"},{label:"..."}]}),e.jsx(Z,{variant:"card",count:1})]});if(p||!r)return e.jsxs("div",{className:"space-y-6",children:[e.jsx(x,{title:"Agent",breadcrumbs:[{label:"Command Post"},{label:"Agents",href:"/command-post/agents"},{label:"Error"}]}),e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-error text-sm mb-4",children:p??"Agent not found"}),e.jsx(T,{variant:"secondary",size:"sm",onClick:()=>o("/command-post/agents"),children:"Back to Agents"})]})]});const I=Date.now()-new Date(r.createdAt).getTime(),F=Math.floor(I/36e5);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(x,{title:r.name,subtitle:r.title??r.role,breadcrumbs:[{label:"Command Post"},{label:"Agents",href:"/command-post/agents"},{label:r.name}],actions:e.jsxs(A,{to:"/command-post/agents",className:"flex items-center gap-1 text-xs text-text-muted hover:text-text",children:[e.jsx(_,{size:14})," Back"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(c,{status:r.status}),e.jsxs("span",{className:"text-xs text-text-muted",children:["Last heartbeat: ",k(r.lastHeartbeat)," ago"]})]}),e.jsx(Y,{tabs:L,activeTab:d,onChange:D}),d==="overview"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-bg-tertiary/50 border border-border rounded-xl p-4 text-center",children:[e.jsx(ee,{size:16,className:"text-success mx-auto mb-1"}),e.jsx("div",{className:"text-xl font-bold text-text",children:r.totalTasksCompleted}),e.jsx("div",{className:"text-[10px] text-text-muted",children:"Tasks Completed"})]}),e.jsxs("div",{className:"bg-bg-tertiary/50 border border-border rounded-xl p-4 text-center",children:[e.jsx(te,{size:16,className:"text-warning mx-auto mb-1"}),e.jsxs("div",{className:"text-xl font-bold text-text",children:["$",r.totalCostUsd.toFixed(4)]}),e.jsx("div",{className:"text-[10px] text-text-muted",children:"Total Cost"})]}),e.jsxs("div",{className:"bg-bg-tertiary/50 border border-border rounded-xl p-4 text-center",children:[e.jsx(se,{size:16,className:"text-accent mx-auto mb-1"}),e.jsxs("div",{className:"text-xl font-bold text-text",children:[F,"h"]}),e.jsx("div",{className:"text-[10px] text-text-muted",children:"Uptime"})]})]}),e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 border-b border-border",children:e.jsx("h3",{className:"text-sm font-semibold text-text",children:"Assigned Issues"})}),u.length===0?e.jsx("div",{className:"py-8 text-center text-xs text-text-muted",children:"No assigned issues"}):e.jsx("div",{className:"divide-y divide-border",children:u.map(t=>e.jsxs(A,{to:`/command-post/issues/${t.id}`,className:"flex items-center gap-2 px-4 py-2 hover:bg-bg-tertiary transition-colors",children:[e.jsx(c,{status:t.status,variant:"dot",size:"sm"}),e.jsx("span",{className:"text-xs text-text flex-1 truncate",children:t.title}),e.jsx("span",{className:"text-[10px] text-text-muted font-mono",children:t.identifier})]},t.id))})]})]}),d==="runs"&&e.jsx("div",{className:"bg-bg-secondary border border-border rounded-xl overflow-hidden",children:n.length===0?e.jsx(X,{title:"No runs",description:"This agent has not executed any runs yet."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-left",children:[e.jsx("th",{className:"px-4 py-2 text-text-muted font-medium",children:"Source"}),e.jsx("th",{className:"px-4 py-2 text-text-muted font-medium",children:"Status"}),e.jsx("th",{className:"px-4 py-2 text-text-muted font-medium",children:"Duration"}),e.jsx("th",{className:"px-4 py-2 text-text-muted font-medium",children:"Tools"}),e.jsx("th",{className:"px-4 py-2 text-text-muted font-medium",children:"Started"})]})}),e.jsx("tbody",{className:"divide-y divide-border",children:n.map(t=>e.jsxs("tr",{className:"hover:bg-bg-tertiary/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-2 text-text-secondary capitalize",children:t.source}),e.jsx("td",{className:"px-4 py-2",children:e.jsx(c,{status:t.status,size:"sm"})}),e.jsx("td",{className:"px-4 py-2 text-text-secondary",children:re(t.durationMs)}),e.jsx("td",{className:"px-4 py-2 text-text-muted",children:t.toolsUsed.length}),e.jsxs("td",{className:"px-4 py-2 text-text-muted",children:[k(t.startedAt)," ago"]})]},t.id))})]})})}),d==="config"&&e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-4 space-y-4 max-w-md",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Role"}),e.jsx("select",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:h,onChange:t=>g(t.target.value),children:["ceo","manager","engineer","researcher","general"].map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Reports To"}),e.jsx("input",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent",placeholder:"Agent ID...",value:f,onChange:t=>j(t.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Title"}),e.jsx("input",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent",placeholder:"e.g. Senior Engineer",value:v,onChange:t=>N(t.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Model"}),e.jsx("input",{list:"cp-agent-models",className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent",placeholder:"e.g. ollama/qwen3.5:cloud",value:y,onChange:t=>S(t.target.value)}),e.jsx("datalist",{id:"cp-agent-models",children:R.map(t=>e.jsx("option",{value:t.id,children:t.name??t.id},t.id))})]}),e.jsx(T,{size:"sm",icon:e.jsx(ae,{size:14}),onClick:B,loading:z,children:"Save"})]})]})}export{je as default};
1
+ import{u as O,i as G,r as s,bt as J,v as K,D as Q,a5 as V,j as e,L as A,a1 as W}from"./index-Ba6pEFSB.js";import{B as T}from"./Input-CdHGkE1K.js";import{S as c}from"./StatusBadge-Cbwzt8Ys.js";import{P as x}from"./PageHeader-BMCNQJ3s.js";import{E as X}from"./EmptyState-ZooZL1_g.js";import{T as Y}from"./Tabs-DKvN1LcI.js";import{S as Z}from"./SkeletonLoader-B6Y6z3-s.js";import{A as _}from"./arrow-left-DLTVGuvQ.js";import{C as ee}from"./circle-check-big-Ccs78slx.js";import{D as te}from"./dollar-sign-BjOfnLA5.js";import{C as se}from"./clock-Bm7r0-EW.js";import{S as ae}from"./save-BHn8eVKt.js";import"./loader-circle-DS59DE4w.js";import"./chevron-right-CgXD9Slz.js";function k(a){const o=Math.floor((Date.now()-new Date(a).getTime())/1e3);return o<60?`${o}s`:o<3600?`${Math.floor(o/60)}m`:o<86400?`${Math.floor(o/3600)}h`:`${Math.floor(o/86400)}d`}function re(a){return a?a<1e3?`${a}ms`:`${(a/1e3).toFixed(1)}s`:"-"}function je(){const{id:a}=O(),o=G(),[r,m]=s.useState(null),[n,E]=s.useState([]),[u,M]=s.useState([]),[P,b]=s.useState(!0),[p,i]=s.useState(null),[d,D]=s.useState("overview"),[h,g]=s.useState(""),[f,j]=s.useState(""),[v,N]=s.useState(""),[y,S]=s.useState(""),[z,C]=s.useState(!1),[R,$]=s.useState([]),w=s.useCallback(async()=>{if(a){try{const l=(await J()).find(q=>q.id===a);if(!l){i("Agent not found"),b(!1);return}m(l),g(l.role),j(l.reportsTo??""),N(l.title??""),S(l.model??"");const[H,U]=await Promise.all([K(a),Q({assignee:a})]);E(H),M(U),i(null)}catch(t){i(t instanceof Error?t.message:"Failed to load agent")}b(!1)}},[a]);s.useEffect(()=>{w()},[w]),s.useEffect(()=>{V().then(t=>$(t)).catch(()=>{})},[]);const B=async()=>{if(a){C(!0);try{const t=await W(a,{role:h,reportsTo:f||void 0,title:v||void 0,model:y||void 0});m(t)}catch{}C(!1)}},L=[{id:"overview",label:"Overview"},{id:"runs",label:"Runs",count:n.length},{id:"config",label:"Config"}];if(P)return e.jsxs("div",{className:"space-y-6",children:[e.jsx(x,{title:"Agent",breadcrumbs:[{label:"Command Post"},{label:"Agents",href:"/command-post/agents"},{label:"..."}]}),e.jsx(Z,{variant:"card",count:1})]});if(p||!r)return e.jsxs("div",{className:"space-y-6",children:[e.jsx(x,{title:"Agent",breadcrumbs:[{label:"Command Post"},{label:"Agents",href:"/command-post/agents"},{label:"Error"}]}),e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-error text-sm mb-4",children:p??"Agent not found"}),e.jsx(T,{variant:"secondary",size:"sm",onClick:()=>o("/command-post/agents"),children:"Back to Agents"})]})]});const I=Date.now()-new Date(r.createdAt).getTime(),F=Math.floor(I/36e5);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(x,{title:r.name,subtitle:r.title??r.role,breadcrumbs:[{label:"Command Post"},{label:"Agents",href:"/command-post/agents"},{label:r.name}],actions:e.jsxs(A,{to:"/command-post/agents",className:"flex items-center gap-1 text-xs text-text-muted hover:text-text",children:[e.jsx(_,{size:14})," Back"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(c,{status:r.status}),e.jsxs("span",{className:"text-xs text-text-muted",children:["Last heartbeat: ",k(r.lastHeartbeat)," ago"]})]}),e.jsx(Y,{tabs:L,activeTab:d,onChange:D}),d==="overview"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-bg-tertiary/50 border border-border rounded-xl p-4 text-center",children:[e.jsx(ee,{size:16,className:"text-success mx-auto mb-1"}),e.jsx("div",{className:"text-xl font-bold text-text",children:r.totalTasksCompleted}),e.jsx("div",{className:"text-[10px] text-text-muted",children:"Tasks Completed"})]}),e.jsxs("div",{className:"bg-bg-tertiary/50 border border-border rounded-xl p-4 text-center",children:[e.jsx(te,{size:16,className:"text-warning mx-auto mb-1"}),e.jsxs("div",{className:"text-xl font-bold text-text",children:["$",r.totalCostUsd.toFixed(4)]}),e.jsx("div",{className:"text-[10px] text-text-muted",children:"Total Cost"})]}),e.jsxs("div",{className:"bg-bg-tertiary/50 border border-border rounded-xl p-4 text-center",children:[e.jsx(se,{size:16,className:"text-accent mx-auto mb-1"}),e.jsxs("div",{className:"text-xl font-bold text-text",children:[F,"h"]}),e.jsx("div",{className:"text-[10px] text-text-muted",children:"Uptime"})]})]}),e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 border-b border-border",children:e.jsx("h3",{className:"text-sm font-semibold text-text",children:"Assigned Issues"})}),u.length===0?e.jsx("div",{className:"py-8 text-center text-xs text-text-muted",children:"No assigned issues"}):e.jsx("div",{className:"divide-y divide-border",children:u.map(t=>e.jsxs(A,{to:`/command-post/issues/${t.id}`,className:"flex items-center gap-2 px-4 py-2 hover:bg-bg-tertiary transition-colors",children:[e.jsx(c,{status:t.status,variant:"dot",size:"sm"}),e.jsx("span",{className:"text-xs text-text flex-1 truncate",children:t.title}),e.jsx("span",{className:"text-[10px] text-text-muted font-mono",children:t.identifier})]},t.id))})]})]}),d==="runs"&&e.jsx("div",{className:"bg-bg-secondary border border-border rounded-xl overflow-hidden",children:n.length===0?e.jsx(X,{title:"No runs",description:"This agent has not executed any runs yet."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-left",children:[e.jsx("th",{className:"px-4 py-2 text-text-muted font-medium",children:"Source"}),e.jsx("th",{className:"px-4 py-2 text-text-muted font-medium",children:"Status"}),e.jsx("th",{className:"px-4 py-2 text-text-muted font-medium",children:"Duration"}),e.jsx("th",{className:"px-4 py-2 text-text-muted font-medium",children:"Tools"}),e.jsx("th",{className:"px-4 py-2 text-text-muted font-medium",children:"Started"})]})}),e.jsx("tbody",{className:"divide-y divide-border",children:n.map(t=>e.jsxs("tr",{className:"hover:bg-bg-tertiary/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-2 text-text-secondary capitalize",children:t.source}),e.jsx("td",{className:"px-4 py-2",children:e.jsx(c,{status:t.status,size:"sm"})}),e.jsx("td",{className:"px-4 py-2 text-text-secondary",children:re(t.durationMs)}),e.jsx("td",{className:"px-4 py-2 text-text-muted",children:t.toolsUsed.length}),e.jsxs("td",{className:"px-4 py-2 text-text-muted",children:[k(t.startedAt)," ago"]})]},t.id))})]})})}),d==="config"&&e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-4 space-y-4 max-w-md",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Role"}),e.jsx("select",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:h,onChange:t=>g(t.target.value),children:["ceo","manager","engineer","researcher","general"].map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Reports To"}),e.jsx("input",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent",placeholder:"Agent ID...",value:f,onChange:t=>j(t.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Title"}),e.jsx("input",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent",placeholder:"e.g. Senior Engineer",value:v,onChange:t=>N(t.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Model"}),e.jsx("input",{list:"cp-agent-models",className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent",placeholder:"e.g. ollama/qwen3.5:cloud",value:y,onChange:t=>S(t.target.value)}),e.jsx("datalist",{id:"cp-agent-models",children:R.map(t=>e.jsx("option",{value:t.id,children:t.name??t.id},t.id))})]}),e.jsx(T,{size:"sm",icon:e.jsx(ae,{size:14}),onClick:B,loading:z,children:"Save"})]})]})}export{je as default};
@@ -1 +1 @@
1
- import{r,bm as m,j as e,L as p,X as u,b as h}from"./index-DzwowwSI.js";import"./Input-Bu_b3qmY.js";import{S as j}from"./StatusBadge-D5nU7El8.js";import{P as f}from"./PageHeader-CnZtP8ek.js";import{E as g}from"./EmptyState-jU6yNDnF.js";import{S as b}from"./SkeletonLoader-B5v09EF_.js";import{U as N}from"./users-dZgv4ePG.js";import"./loader-circle-1YOBsoQp.js";import"./chevron-right-aQEw2mUW.js";function y(a){const s=Math.floor((Date.now()-new Date(a).getTime())/1e3);return s<60?`${s}s`:s<3600?`${Math.floor(s/60)}m`:s<86400?`${Math.floor(s/3600)}h`:`${Math.floor(s/86400)}d`}function v(a){const s=a.split("/");return s[s.length-1]}function D(){const[a,s]=r.useState([]),[c,d]=r.useState(!0),[o,l]=r.useState(null),i=r.useCallback(async()=>{try{const t=await m();s(t),l(null)}catch(t){l(t instanceof Error?t.message:"Failed to load agents")}d(!1)},[]);r.useEffect(()=>{i()},[i]);const x=async(t,n)=>{n.preventDefault(),n.stopPropagation();try{await h(`/api/command-post/agents/${t}`,{method:"DELETE"}),await i()}catch{}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(f,{title:"Agents",breadcrumbs:[{label:"Command Post"},{label:"Agents"}]}),c&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.jsx(b,{variant:"card",count:6})}),o&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:o}),!c&&!o&&a.length===0&&e.jsx(g,{icon:e.jsx(N,{size:32}),title:"No agents registered",description:"Agents will appear here once they connect to Command Post."}),!c&&!o&&a.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:a.map(t=>e.jsxs(p,{to:`/command-post/agents/${t.id}`,className:"relative bg-bg-secondary border border-border rounded-xl p-4 hover:border-border-light transition-colors group",children:[t.role!=="ceo"&&e.jsx("button",{onClick:n=>x(t.id,n),className:"absolute top-3 right-3 p-1 rounded-md text-text-muted hover:text-error hover:bg-error/10 opacity-0 group-hover:opacity-100 transition-all",title:"Remove agent",children:e.jsx(u,{size:14})}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"text-sm font-semibold text-text",children:t.name}),e.jsx(j,{status:t.status,size:"sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Role"}),e.jsx("span",{className:"text-xs text-text-secondary capitalize",children:t.role})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Model"}),e.jsx("span",{className:"text-xs text-text-secondary truncate max-w-[140px]",children:v(t.model)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Last Heartbeat"}),e.jsxs("span",{className:"text-xs text-text-secondary",children:[y(t.lastHeartbeat)," ago"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Tasks Done"}),e.jsx("span",{className:"text-xs text-text-secondary",children:t.totalTasksCompleted})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Cost"}),e.jsxs("span",{className:"text-xs text-text-secondary",children:["$",t.totalCostUsd.toFixed(4)]})]})]})]},t.id))})]})}export{D as default};
1
+ import{r,bt as m,j as e,L as p,X as u,b as h}from"./index-Ba6pEFSB.js";import"./Input-CdHGkE1K.js";import{S as j}from"./StatusBadge-Cbwzt8Ys.js";import{P as f}from"./PageHeader-BMCNQJ3s.js";import{E as g}from"./EmptyState-ZooZL1_g.js";import{S as b}from"./SkeletonLoader-B6Y6z3-s.js";import{U as N}from"./users-CPePALGx.js";import"./loader-circle-DS59DE4w.js";import"./chevron-right-CgXD9Slz.js";function y(a){const s=Math.floor((Date.now()-new Date(a).getTime())/1e3);return s<60?`${s}s`:s<3600?`${Math.floor(s/60)}m`:s<86400?`${Math.floor(s/3600)}h`:`${Math.floor(s/86400)}d`}function v(a){const s=a.split("/");return s[s.length-1]}function D(){const[a,s]=r.useState([]),[c,d]=r.useState(!0),[o,l]=r.useState(null),i=r.useCallback(async()=>{try{const t=await m();s(t),l(null)}catch(t){l(t instanceof Error?t.message:"Failed to load agents")}d(!1)},[]);r.useEffect(()=>{i()},[i]);const x=async(t,n)=>{n.preventDefault(),n.stopPropagation();try{await h(`/api/command-post/agents/${t}`,{method:"DELETE"}),await i()}catch{}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(f,{title:"Agents",breadcrumbs:[{label:"Command Post"},{label:"Agents"}]}),c&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.jsx(b,{variant:"card",count:6})}),o&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:o}),!c&&!o&&a.length===0&&e.jsx(g,{icon:e.jsx(N,{size:32}),title:"No agents registered",description:"Agents will appear here once they connect to Command Post."}),!c&&!o&&a.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:a.map(t=>e.jsxs(p,{to:`/command-post/agents/${t.id}`,className:"relative bg-bg-secondary border border-border rounded-xl p-4 hover:border-border-light transition-colors group",children:[t.role!=="ceo"&&e.jsx("button",{onClick:n=>x(t.id,n),className:"absolute top-3 right-3 p-1 rounded-md text-text-muted hover:text-error hover:bg-error/10 opacity-0 group-hover:opacity-100 transition-all",title:"Remove agent",children:e.jsx(u,{size:14})}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"text-sm font-semibold text-text",children:t.name}),e.jsx(j,{status:t.status,size:"sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Role"}),e.jsx("span",{className:"text-xs text-text-secondary capitalize",children:t.role})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Model"}),e.jsx("span",{className:"text-xs text-text-secondary truncate max-w-[140px]",children:v(t.model)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Last Heartbeat"}),e.jsxs("span",{className:"text-xs text-text-secondary",children:[y(t.lastHeartbeat)," ago"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Tasks Done"}),e.jsx("span",{className:"text-xs text-text-secondary",children:t.totalTasksCompleted})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase",children:"Cost"}),e.jsxs("span",{className:"text-xs text-text-secondary",children:["$",t.totalCostUsd.toFixed(4)]})]})]})]},t.id))})]})}export{D as default};
@@ -1 +1 @@
1
- import{r as n,bn as B,B as P,j as t,T as z,X as R,O as $,P as _}from"./index-DzwowwSI.js";import{B as A}from"./Input-Bu_b3qmY.js";import{S as D}from"./StatusBadge-D5nU7El8.js";import{P as M}from"./PageHeader-CnZtP8ek.js";import{E as L}from"./EmptyState-jU6yNDnF.js";import{T as W}from"./Tabs-BBYZrBI8.js";import{S as F}from"./SkeletonLoader-B5v09EF_.js";import{e as H}from"./approvalHeadline-DB9SgR-9.js";import{S as I}from"./shield-check-DjBJXZUr.js";import{C as U}from"./check-Bpm1IONe.js";import"./loader-circle-1YOBsoQp.js";import"./chevron-right-aQEw2mUW.js";function q(r){const o=Math.floor((Date.now()-new Date(r).getTime())/1e3);return o<60?`${o}s`:o<3600?`${Math.floor(o/60)}m`:o<86400?`${Math.floor(o/3600)}h`:`${Math.floor(o/86400)}d`}function K(r){return r==="high"?"text-error bg-error/10 border-error/30":r==="medium"?"text-warn bg-warn/10 border-warn/30":"text-text-muted bg-bg-tertiary border-border"}const O=[{id:"all",label:"All"},{id:"pending",label:"Pending"},{id:"approved",label:"Approved"},{id:"rejected",label:"Rejected"}];function ne(){const[r,o]=n.useState([]),[m,k]=n.useState(!0),[i,d]=n.useState(null),[l,w]=n.useState("all"),[h,c]=n.useState(null),[b,v]=n.useState({}),[u,j]=n.useState(null),{toast:p}=B(),x=n.useCallback(async()=>{try{const e=await P();o(e),d(null)}catch(e){d(e instanceof Error?e.message:"Failed to load approvals")}k(!1)},[]);n.useEffect(()=>{x()},[x]);const y=async e=>{var s;c(e.id);try{const a=(s=b[e.id])==null?void 0:s.trim();await $(e.id,"user",a||void 0),await x();const f=e.type==="goal_proposal"||e.type==="soma_proposal",T=e.type==="custom"&&e.payload.kind==="driver_blocked";p("success",f?"Work approved — TITAN is starting…":T?"Unblocked — TITAN is resuming…":"Approved"),v(E=>{const N={...E};return delete N[e.id],N}),j(null)}catch(a){d(a instanceof Error?a.message:"Approve failed"),p("error","Approval failed")}c(null)},S=async e=>{c(e.id);try{await _(e.id,"user"),await x(),p("success","Rejected")}catch(s){d(s instanceof Error?s.message:"Reject failed"),p("error","Rejection failed")}c(null)},g=l==="all"?r:r.filter(e=>e.status===l),C=O.map(e=>({...e,count:e.id==="all"?r.length:r.filter(s=>s.status===e.id).length}));return t.jsxs("div",{className:"space-y-4",children:[t.jsx(M,{title:"Approvals",breadcrumbs:[{label:"Command Post"},{label:"Approvals"}]}),t.jsx(W,{tabs:C,activeTab:l,onChange:w}),m&&t.jsx(F,{variant:"row",count:5}),i&&t.jsx("div",{className:"text-center py-8 text-error text-sm",children:i}),!m&&!i&&g.length===0&&t.jsx(L,{icon:t.jsx(I,{size:32}),title:"No approvals",description:l==="pending"?"No pending approvals.":"No approvals to show."}),!m&&!i&&g.length>0&&t.jsx("div",{className:"divide-y divide-border rounded-xl border border-border bg-bg-secondary overflow-hidden",children:g.map(e=>{const s=H(e);return t.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5 flex-wrap",children:[t.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded border font-medium uppercase tracking-wide ${K(s.urgency)}`,children:[s.urgency==="high"&&t.jsx(z,{size:10,className:"inline mr-0.5"}),s.kindLabel]}),t.jsx(D,{status:e.status,size:"sm"}),t.jsxs("span",{className:"text-xs text-text-muted",children:["from ",t.jsx("span",{className:"font-medium text-text-secondary",children:e.requestedBy})]})]}),t.jsx("div",{className:"text-sm text-text font-medium leading-snug mb-0.5",children:s.headline}),s.detail&&t.jsx("div",{className:"text-xs text-text-secondary leading-snug",children:s.detail}),e.decidedBy&&t.jsxs("div",{className:"text-[10px] text-text-muted mt-1",children:["Decided by ",e.decidedBy,e.decisionNote?`: ${e.decisionNote}`:""]})]}),t.jsx("span",{className:"text-xs text-text-muted flex-shrink-0 pt-0.5",children:q(e.createdAt)}),e.status==="pending"&&t.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[e.type==="custom"&&e.payload.kind==="driver_blocked"&&t.jsx("button",{onClick:()=>j(u===e.id?null:e.id),className:"text-[10px] text-text-muted hover:text-text-secondary px-2 py-1 rounded hover:bg-bg-tertiary transition-colors",children:u===e.id?"Cancel":"Answer"}),t.jsx(A,{size:"sm",variant:"ghost",onClick:()=>y(e),loading:h===e.id,icon:t.jsx(U,{size:14}),children:"Approve"}),t.jsx(A,{size:"sm",variant:"ghost",onClick:()=>S(e),loading:h===e.id,icon:t.jsx(R,{size:14}),children:"Reject"})]}),u===e.id&&t.jsx("input",{type:"text",value:b[e.id]||"",onChange:a=>v(f=>({...f,[e.id]:a.target.value})),placeholder:"Type your answer...",className:"w-64 rounded-md border border-border bg-bg px-3 py-1.5 text-xs text-text outline-none focus:border-accent mt-1",onKeyDown:a=>{a.key==="Enter"&&y(e)},autoFocus:!0})]})]},e.id)})})]})}export{ne as default};
1
+ import{r as a,bu as B,B as P,j as t,T as z,X as R,O as $,P as _}from"./index-Ba6pEFSB.js";import{B as A}from"./Input-CdHGkE1K.js";import{S as D}from"./StatusBadge-Cbwzt8Ys.js";import{P as M}from"./PageHeader-BMCNQJ3s.js";import{E as L}from"./EmptyState-ZooZL1_g.js";import{T as W}from"./Tabs-DKvN1LcI.js";import{S as F}from"./SkeletonLoader-B6Y6z3-s.js";import{e as H}from"./approvalHeadline-DB9SgR-9.js";import{S as I}from"./shield-check-CFSKu_na.js";import{C as U}from"./check-CrjQyURH.js";import"./loader-circle-DS59DE4w.js";import"./chevron-right-CgXD9Slz.js";function q(r){const o=Math.floor((Date.now()-new Date(r).getTime())/1e3);return o<60?`${o}s`:o<3600?`${Math.floor(o/60)}m`:o<86400?`${Math.floor(o/3600)}h`:`${Math.floor(o/86400)}d`}function K(r){return r==="high"?"text-error bg-error/10 border-error/30":r==="medium"?"text-warn bg-warn/10 border-warn/30":"text-text-muted bg-bg-tertiary border-border"}const O=[{id:"all",label:"All"},{id:"pending",label:"Pending"},{id:"approved",label:"Approved"},{id:"rejected",label:"Rejected"}];function ae(){const[r,o]=a.useState([]),[m,k]=a.useState(!0),[i,d]=a.useState(null),[l,w]=a.useState("all"),[h,c]=a.useState(null),[b,v]=a.useState({}),[u,j]=a.useState(null),{toast:p}=B(),x=a.useCallback(async()=>{try{const e=await P();o(e),d(null)}catch(e){d(e instanceof Error?e.message:"Failed to load approvals")}k(!1)},[]);a.useEffect(()=>{x()},[x]);const y=async e=>{var s;c(e.id);try{const n=(s=b[e.id])==null?void 0:s.trim();await $(e.id,"user",n||void 0),await x();const f=e.type==="goal_proposal"||e.type==="soma_proposal",T=e.type==="custom"&&e.payload.kind==="driver_blocked";p("success",f?"Work approved — TITAN is starting…":T?"Unblocked — TITAN is resuming…":"Approved"),v(E=>{const N={...E};return delete N[e.id],N}),j(null)}catch(n){d(n instanceof Error?n.message:"Approve failed"),p("error","Approval failed")}c(null)},S=async e=>{c(e.id);try{await _(e.id,"user"),await x(),p("success","Rejected")}catch(s){d(s instanceof Error?s.message:"Reject failed"),p("error","Rejection failed")}c(null)},g=l==="all"?r:r.filter(e=>e.status===l),C=O.map(e=>({...e,count:e.id==="all"?r.length:r.filter(s=>s.status===e.id).length}));return t.jsxs("div",{className:"space-y-4",children:[t.jsx(M,{title:"Approvals",breadcrumbs:[{label:"Command Post"},{label:"Approvals"}]}),t.jsx(W,{tabs:C,activeTab:l,onChange:w}),m&&t.jsx(F,{variant:"row",count:5}),i&&t.jsx("div",{className:"text-center py-8 text-error text-sm",children:i}),!m&&!i&&g.length===0&&t.jsx(L,{icon:t.jsx(I,{size:32}),title:"No approvals",description:l==="pending"?"No pending approvals.":"No approvals to show."}),!m&&!i&&g.length>0&&t.jsx("div",{className:"divide-y divide-border rounded-xl border border-border bg-bg-secondary overflow-hidden",children:g.map(e=>{const s=H(e);return t.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5 flex-wrap",children:[t.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded border font-medium uppercase tracking-wide ${K(s.urgency)}`,children:[s.urgency==="high"&&t.jsx(z,{size:10,className:"inline mr-0.5"}),s.kindLabel]}),t.jsx(D,{status:e.status,size:"sm"}),t.jsxs("span",{className:"text-xs text-text-muted",children:["from ",t.jsx("span",{className:"font-medium text-text-secondary",children:e.requestedBy})]})]}),t.jsx("div",{className:"text-sm text-text font-medium leading-snug mb-0.5",children:s.headline}),s.detail&&t.jsx("div",{className:"text-xs text-text-secondary leading-snug",children:s.detail}),e.decidedBy&&t.jsxs("div",{className:"text-[10px] text-text-muted mt-1",children:["Decided by ",e.decidedBy,e.decisionNote?`: ${e.decisionNote}`:""]})]}),t.jsx("span",{className:"text-xs text-text-muted flex-shrink-0 pt-0.5",children:q(e.createdAt)}),e.status==="pending"&&t.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[e.type==="custom"&&e.payload.kind==="driver_blocked"&&t.jsx("button",{onClick:()=>j(u===e.id?null:e.id),className:"text-[10px] text-text-muted hover:text-text-secondary px-2 py-1 rounded hover:bg-bg-tertiary transition-colors",children:u===e.id?"Cancel":"Answer"}),t.jsx(A,{size:"sm",variant:"ghost",onClick:()=>y(e),loading:h===e.id,icon:t.jsx(U,{size:14}),children:"Approve"}),t.jsx(A,{size:"sm",variant:"ghost",onClick:()=>S(e),loading:h===e.id,icon:t.jsx(R,{size:14}),children:"Reject"})]}),u===e.id&&t.jsx("input",{type:"text",value:b[e.id]||"",onChange:n=>v(f=>({...f,[e.id]:n.target.value})),placeholder:"Type your answer...",className:"w-64 rounded-md border border-border bg-bg px-3 py-1.5 text-xs text-text outline-none focus:border-accent mt-1",onKeyDown:n=>{n.key==="Enter"&&y(e)},autoFocus:!0})]})]},e.id)})})]})}export{ae as default};
@@ -1 +1 @@
1
- import{r as s,bq as $,br as A,j as e,E as L,a0 as W}from"./index-DzwowwSI.js";import{B as u}from"./Input-Bu_b3qmY.js";import{S as C}from"./StatusBadge-D5nU7El8.js";import{P as M}from"./PageHeader-CnZtP8ek.js";import{E as R}from"./EmptyState-jU6yNDnF.js";import{M as G}from"./Modal-CAAooiZU.js";import{S as q}from"./SkeletonLoader-B5v09EF_.js";import{P as H}from"./plus-Csu2v9GN.js";import{D as J}from"./dollar-sign-CudFVYFc.js";import{T as K}from"./trash-2-DgWrHVax.js";import"./loader-circle-1YOBsoQp.js";import"./chevron-right-aQEw2mUW.js";import"./proxy-DxS2_9D7.js";function O(a){const l=a.limitUsd>0?a.currentSpend/a.limitUsd*100:0;return l>=100?"exceeded":l>=a.warningThresholdPercent?"warning":"healthy"}function oe(){const[a,l]=s.useState([]),[m,S]=s.useState([]),[c,k]=s.useState(!0),[n,g]=s.useState(null),[P,r]=s.useState(!1),[B,p]=s.useState(!1),[o,h]=s.useState(""),[d,z]=s.useState("global"),[b,j]=s.useState(""),[f,T]=s.useState("monthly"),[v,N]=s.useState("10"),[y,I]=s.useState("80"),[w,U]=s.useState("warn"),i=s.useCallback(async()=>{try{const t=await $();l(t),g(null)}catch(t){g(t instanceof Error?t.message:"Failed to load budgets")}k(!1)},[]);s.useEffect(()=>{i(),A().then(S).catch(()=>{})},[i]);const D=async()=>{if(o.trim()){p(!0);try{await W({name:o.trim(),scope:{type:d,targetId:b||void 0},period:f,limitUsd:parseFloat(v)||10,warningThresholdPercent:parseInt(y)||80,action:w,enabled:!0}),r(!1),h(""),j(""),N("10"),await i()}catch{}p(!1)}},E=async t=>{try{await L(t),await i()}catch{}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(M,{title:"Costs & Budgets",breadcrumbs:[{label:"Command Post"},{label:"Costs"}],actions:e.jsx(u,{size:"sm",icon:e.jsx(H,{size:14}),onClick:()=>r(!0),children:"Create Budget"})}),c&&e.jsx(q,{variant:"row",count:4}),n&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:n}),!c&&!n&&a.length===0&&e.jsx(R,{icon:e.jsx(J,{size:32}),title:"No budgets",description:"Create budget policies to control agent spending.",action:{label:"Create Budget",onClick:()=>r(!0)}}),!c&&!n&&a.length>0&&e.jsx("div",{className:"divide-y divide-border rounded-xl border border-border bg-bg-secondary overflow-hidden",children:a.map(t=>{const F=t.limitUsd>0?t.currentSpend/t.limitUsd*100:0,x=O(t);return e.jsxs("div",{className:"flex items-center gap-4 px-4 py-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium text-text",children:t.name}),e.jsx(C,{status:x,size:"sm"}),!t.enabled&&e.jsx(C,{status:"disabled",size:"sm"})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-text-muted",children:[e.jsxs("span",{className:"capitalize",children:[t.scope.type,t.scope.targetId?`: ${t.scope.targetId}`:""]}),e.jsx("span",{className:"capitalize",children:t.period}),e.jsxs("span",{children:["Action: ",t.action]})]})]}),e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsxs("div",{className:"text-sm font-medium text-text",children:["$",t.currentSpend.toFixed(2)," / $",t.limitUsd.toFixed(2)]}),e.jsx("div",{className:"w-24 h-1.5 bg-bg-tertiary rounded-full overflow-hidden mt-1",children:e.jsx("div",{className:`h-full rounded-full transition-all ${x==="exceeded"?"bg-error":x==="warning"?"bg-warning":"bg-success"}`,style:{width:`${Math.min(100,F)}%`}})})]}),e.jsx("button",{onClick:()=>E(t.id),className:"p-1.5 rounded-md text-text-muted hover:text-error hover:bg-error/10 transition-colors flex-shrink-0",title:"Delete budget",children:e.jsx(K,{size:14})})]},t.id)})}),m.length>0&&e.jsxs("div",{className:"rounded-xl border border-border bg-bg-secondary overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 border-b border-border",children:e.jsx("h3",{className:"text-sm font-medium text-text",children:"Active Reservations"})}),e.jsx("div",{className:"divide-y divide-border",children:m.map(t=>e.jsxs("div",{className:"px-4 py-3 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-text",children:t.agentId}),t.goalId&&e.jsxs("span",{className:"text-xs text-text-muted ml-2",children:["Goal: ",t.goalId]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full ${t.status==="reserved"?"bg-warning/20 text-warning":t.status==="settled"?"bg-success/20 text-success":"bg-bg-tertiary text-text-muted"}`,children:t.status}),e.jsxs("span",{className:"text-sm font-mono text-text",children:["$",t.status==="settled"?(t.actualUsd??0).toFixed(4):t.estimatedUsd.toFixed(4)]})]})]},t.id))})]}),e.jsx(G,{open:P,onClose:()=>r(!1),title:"Create Budget Policy",footer:e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>r(!1),children:"Cancel"}),e.jsx(u,{size:"sm",onClick:D,loading:B,disabled:!o.trim(),children:"Create"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Name"}),e.jsx("input",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent",placeholder:"Budget name...",value:o,onChange:t=>h(t.target.value),autoFocus:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Scope"}),e.jsxs("select",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:d,onChange:t=>z(t.target.value),children:[e.jsx("option",{value:"global",children:"Global"}),e.jsx("option",{value:"agent",children:"Agent"}),e.jsx("option",{value:"goal",children:"Goal"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Period"}),e.jsxs("select",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:f,onChange:t=>T(t.target.value),children:[e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"})]})]})]}),d!=="global"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Target ID"}),e.jsx("input",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent",placeholder:`${d} ID...`,value:b,onChange:t=>j(t.target.value)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Limit (USD)"}),e.jsx("input",{type:"number",className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:v,onChange:t=>N(t.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Warning %"}),e.jsx("input",{type:"number",className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:y,onChange:t=>I(t.target.value)})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Action on Threshold"}),e.jsxs("select",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:w,onChange:t=>U(t.target.value),children:[e.jsx("option",{value:"warn",children:"Warn"}),e.jsx("option",{value:"pause",children:"Pause"}),e.jsx("option",{value:"stop",children:"Stop"})]})]})]})})]})}export{oe as default};
1
+ import{r as s,bx as $,by as A,j as e,E as L,a0 as W}from"./index-Ba6pEFSB.js";import{B as u}from"./Input-CdHGkE1K.js";import{S as C}from"./StatusBadge-Cbwzt8Ys.js";import{P as M}from"./PageHeader-BMCNQJ3s.js";import{E as R}from"./EmptyState-ZooZL1_g.js";import{M as G}from"./Modal-Dkw2zhkC.js";import{S as H}from"./SkeletonLoader-B6Y6z3-s.js";import{P as q}from"./plus-BUOjWfPb.js";import{D as J}from"./dollar-sign-BjOfnLA5.js";import{T as K}from"./trash-2-HAJYvEBs.js";import"./loader-circle-DS59DE4w.js";import"./chevron-right-CgXD9Slz.js";import"./proxy-BmDq-lG4.js";function O(a){const l=a.limitUsd>0?a.currentSpend/a.limitUsd*100:0;return l>=100?"exceeded":l>=a.warningThresholdPercent?"warning":"healthy"}function oe(){const[a,l]=s.useState([]),[m,S]=s.useState([]),[c,k]=s.useState(!0),[n,g]=s.useState(null),[P,r]=s.useState(!1),[B,p]=s.useState(!1),[o,h]=s.useState(""),[d,z]=s.useState("global"),[b,j]=s.useState(""),[f,T]=s.useState("monthly"),[v,y]=s.useState("10"),[N,I]=s.useState("80"),[w,U]=s.useState("warn"),i=s.useCallback(async()=>{try{const t=await $();l(t),g(null)}catch(t){g(t instanceof Error?t.message:"Failed to load budgets")}k(!1)},[]);s.useEffect(()=>{i(),A().then(S).catch(()=>{})},[i]);const D=async()=>{if(o.trim()){p(!0);try{await W({name:o.trim(),scope:{type:d,targetId:b||void 0},period:f,limitUsd:parseFloat(v)||10,warningThresholdPercent:parseInt(N)||80,action:w,enabled:!0}),r(!1),h(""),j(""),y("10"),await i()}catch{}p(!1)}},E=async t=>{try{await L(t),await i()}catch{}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(M,{title:"Costs & Budgets",breadcrumbs:[{label:"Command Post"},{label:"Costs"}],actions:e.jsx(u,{size:"sm",icon:e.jsx(q,{size:14}),onClick:()=>r(!0),children:"Create Budget"})}),c&&e.jsx(H,{variant:"row",count:4}),n&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:n}),!c&&!n&&a.length===0&&e.jsx(R,{icon:e.jsx(J,{size:32}),title:"No budgets",description:"Create budget policies to control agent spending.",action:{label:"Create Budget",onClick:()=>r(!0)}}),!c&&!n&&a.length>0&&e.jsx("div",{className:"divide-y divide-border rounded-xl border border-border bg-bg-secondary overflow-hidden",children:a.map(t=>{const F=t.limitUsd>0?t.currentSpend/t.limitUsd*100:0,x=O(t);return e.jsxs("div",{className:"flex items-center gap-4 px-4 py-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium text-text",children:t.name}),e.jsx(C,{status:x,size:"sm"}),!t.enabled&&e.jsx(C,{status:"disabled",size:"sm"})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-text-muted",children:[e.jsxs("span",{className:"capitalize",children:[t.scope.type,t.scope.targetId?`: ${t.scope.targetId}`:""]}),e.jsx("span",{className:"capitalize",children:t.period}),e.jsxs("span",{children:["Action: ",t.action]})]})]}),e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsxs("div",{className:"text-sm font-medium text-text",children:["$",t.currentSpend.toFixed(2)," / $",t.limitUsd.toFixed(2)]}),e.jsx("div",{className:"w-24 h-1.5 bg-bg-tertiary rounded-full overflow-hidden mt-1",children:e.jsx("div",{className:`h-full rounded-full transition-all ${x==="exceeded"?"bg-error":x==="warning"?"bg-warning":"bg-success"}`,style:{width:`${Math.min(100,F)}%`}})})]}),e.jsx("button",{onClick:()=>E(t.id),className:"p-1.5 rounded-md text-text-muted hover:text-error hover:bg-error/10 transition-colors flex-shrink-0",title:"Delete budget",children:e.jsx(K,{size:14})})]},t.id)})}),m.length>0&&e.jsxs("div",{className:"rounded-xl border border-border bg-bg-secondary overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 border-b border-border",children:e.jsx("h3",{className:"text-sm font-medium text-text",children:"Active Reservations"})}),e.jsx("div",{className:"divide-y divide-border",children:m.map(t=>e.jsxs("div",{className:"px-4 py-3 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-text",children:t.agentId}),t.goalId&&e.jsxs("span",{className:"text-xs text-text-muted ml-2",children:["Goal: ",t.goalId]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full ${t.status==="reserved"?"bg-warning/20 text-warning":t.status==="settled"?"bg-success/20 text-success":"bg-bg-tertiary text-text-muted"}`,children:t.status}),e.jsxs("span",{className:"text-sm font-mono text-text",children:["$",t.status==="settled"?(t.actualUsd??0).toFixed(4):t.estimatedUsd.toFixed(4)]})]})]},t.id))})]}),e.jsx(G,{open:P,onClose:()=>r(!1),title:"Create Budget Policy",footer:e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>r(!1),children:"Cancel"}),e.jsx(u,{size:"sm",onClick:D,loading:B,disabled:!o.trim(),children:"Create"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Name"}),e.jsx("input",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent",placeholder:"Budget name...",value:o,onChange:t=>h(t.target.value),autoFocus:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Scope"}),e.jsxs("select",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:d,onChange:t=>z(t.target.value),children:[e.jsx("option",{value:"global",children:"Global"}),e.jsx("option",{value:"agent",children:"Agent"}),e.jsx("option",{value:"goal",children:"Goal"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Period"}),e.jsxs("select",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:f,onChange:t=>T(t.target.value),children:[e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"})]})]})]}),d!=="global"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Target ID"}),e.jsx("input",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent",placeholder:`${d} ID...`,value:b,onChange:t=>j(t.target.value)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Limit (USD)"}),e.jsx("input",{type:"number",className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:v,onChange:t=>y(t.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Warning %"}),e.jsx("input",{type:"number",className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:N,onChange:t=>I(t.target.value)})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Action on Threshold"}),e.jsxs("select",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:w,onChange:t=>U(t.target.value),children:[e.jsx("option",{value:"warn",children:"Warn"}),e.jsx("option",{value:"pause",children:"Pause"}),e.jsx("option",{value:"stop",children:"Stop"})]})]})]})})]})}export{oe as default};