titan-agent 6.2.0 → 6.2.2

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 (157) hide show
  1. package/README.md +4 -4
  2. package/dist/agent/commandPost.js +3 -2
  3. package/dist/agent/commandPost.js.map +1 -1
  4. package/dist/gateway/routes/telephony.js +75 -19
  5. package/dist/gateway/routes/telephony.js.map +1 -1
  6. package/dist/gateway/routes/update.js +100 -0
  7. package/dist/gateway/routes/update.js.map +1 -0
  8. package/dist/gateway/server.js +2 -65
  9. package/dist/gateway/server.js.map +1 -1
  10. package/dist/skills/builtin/phone_call.js +23 -1
  11. package/dist/skills/builtin/phone_call.js.map +1 -1
  12. package/dist/telephony/phonePolicy.js +19 -3
  13. package/dist/telephony/phonePolicy.js.map +1 -1
  14. package/dist/utils/constants.js +1 -1
  15. package/dist/utils/constants.js.map +1 -1
  16. package/package.json +1 -1
  17. package/ui/dist/assets/{AuditPanel-DuxwAH5U.js → AuditPanel-BmFAKA7p.js} +1 -1
  18. package/ui/dist/assets/{AutonomyPanel-VWBgurnv.js → AutonomyPanel-BzuCEsiG.js} +1 -1
  19. package/ui/dist/assets/{AutopilotPanel-Dw8MYOtj.js → AutopilotPanel-DA1vFEl4.js} +1 -1
  20. package/ui/dist/assets/{AutoresearchPanel-CpEX0Zub.js → AutoresearchPanel-BeUCXYtX.js} +1 -1
  21. package/ui/dist/assets/{BackupPanel-n41_6i6x.js → BackupPanel-B6N1pfMT.js} +1 -1
  22. package/ui/dist/assets/{BrowserPanel-DEBTIt6h.js → BrowserPanel-BGHaPi3O.js} +1 -1
  23. package/ui/dist/assets/{CPActivity-em82PTiQ.js → CPActivity-BUSwjFj2.js} +1 -1
  24. package/ui/dist/assets/{CPAgentDetail-Bd8lKqcL.js → CPAgentDetail-DlUEVujH.js} +1 -1
  25. package/ui/dist/assets/{CPAgents-GRBrDd6c.js → CPAgents-CnRmsSMo.js} +1 -1
  26. package/ui/dist/assets/{CPApprovals-DdLaCgJZ.js → CPApprovals-CXdkzebd.js} +1 -1
  27. package/ui/dist/assets/{CPCosts-Cm8Hv9fv.js → CPCosts-CfcyIUZg.js} +1 -1
  28. package/ui/dist/assets/{CPDashboard-Dm9vUKLu.js → CPDashboard-DHlfE1mT.js} +1 -1
  29. package/ui/dist/assets/{CPFiles-DxMn1x2m.js → CPFiles-DyV9vsjE.js} +1 -1
  30. package/ui/dist/assets/{CPGoals-Wr1tCn6y.js → CPGoals-C17G2F0e.js} +1 -1
  31. package/ui/dist/assets/{CPInbox-CGYpK1rG.js → CPInbox-D5A3ja_Q.js} +1 -1
  32. package/ui/dist/assets/{CPIssueDetail-dTU59sgQ.js → CPIssueDetail-CoPv27Ll.js} +1 -1
  33. package/ui/dist/assets/{CPIssues-wgjI2eqS.js → CPIssues-C9EdfW1J.js} +1 -1
  34. package/ui/dist/assets/CPLayout-CHrlktMs.js +2 -0
  35. package/ui/dist/assets/{CPOrg-eT6LNmyy.js → CPOrg-DzoVDLKI.js} +1 -1
  36. package/ui/dist/assets/{CPRuns-B3sdo5g2.js → CPRuns-BHAyFv0K.js} +1 -1
  37. package/ui/dist/assets/{CPSocial-B99Mfee_.js → CPSocial-CjHD8dKM.js} +1 -1
  38. package/ui/dist/assets/{CPVoice-D4J6yFWu.js → CPVoice-aybMotU5.js} +1 -1
  39. package/ui/dist/assets/{ChannelsPanel--lhZqYLD.js → ChannelsPanel-8KfvAEYM.js} +1 -1
  40. package/ui/dist/assets/{CheckpointsPanel-DaOIUcEi.js → CheckpointsPanel-BCyLRLcg.js} +1 -1
  41. package/ui/dist/assets/{CommandPostHub-Pq9lQMW5.js → CommandPostHub-Ce-mWsu2.js} +3 -3
  42. package/ui/dist/assets/{CronPanel-CywjWM7O.js → CronPanel-A9JHvU_O.js} +1 -1
  43. package/ui/dist/assets/{DataTable-Bt0cxehB.js → DataTable-ol6IZMRj.js} +1 -1
  44. package/ui/dist/assets/{DreamPanel-Ct7MuLzD.js → DreamPanel-ZiOF8ybh.js} +1 -1
  45. package/ui/dist/assets/{EmptyState-iLOrbdU7.js → EmptyState-B1i1ZK0x.js} +1 -1
  46. package/ui/dist/assets/{EvalHarnessPanel-7KKDzeXw.js → EvalHarnessPanel-DRGc1zbp.js} +1 -1
  47. package/ui/dist/assets/{EvalPanel-70LzkLDO.js → EvalPanel-B_fiFImG.js} +1 -1
  48. package/ui/dist/assets/{FileViewer-h6A7YYTm.js → FileViewer-D14G6MQq.js} +1 -1
  49. package/ui/dist/assets/{FilesPanel-l8qC6eLD.js → FilesPanel-BIsMoSfg.js} +1 -1
  50. package/ui/dist/assets/{FleetPanel-Z3ResHIb.js → FleetPanel-CSjOOsbX.js} +1 -1
  51. package/ui/dist/assets/{HomelabPanel-9QhrXzo1.js → HomelabPanel-XHMxqiHu.js} +1 -1
  52. package/ui/dist/assets/InfraView-DNYgRXkB.js +2 -0
  53. package/ui/dist/assets/{InlineEditableField-DsVfGRH2.js → InlineEditableField-AOS-LBh_.js} +1 -1
  54. package/ui/dist/assets/{Input-Bzh0-cXU.js → Input-CTK9oH9g.js} +1 -1
  55. package/ui/dist/assets/{IntegrationsPanel-DBOdLYJ8.js → IntegrationsPanel-BKuC_5El.js} +1 -1
  56. package/ui/dist/assets/IntelligenceView-BUKpVpDQ.js +2 -0
  57. package/ui/dist/assets/{LearningPanel-CiSLVxUX.js → LearningPanel-RpDaPvCj.js} +1 -1
  58. package/ui/dist/assets/{LogsPanel-CPAAItsq.js → LogsPanel-9zIJP1Xv.js} +1 -1
  59. package/ui/dist/assets/{McpPanel-MYWE2Zqs.js → McpPanel-CNE7MhDu.js} +1 -1
  60. package/ui/dist/assets/{MemoryGraphPanel-BFr51D_1.js → MemoryGraphPanel-9DEsbOZF.js} +1 -1
  61. package/ui/dist/assets/{MemoryWikiPanel-BA7GUxhg.js → MemoryWikiPanel-CqNen9A6.js} +1 -1
  62. package/ui/dist/assets/{MeshPanel-5BDbwBVR.js → MeshPanel-Bq3pHHIT.js} +1 -1
  63. package/ui/dist/assets/{MissionCanvas-CrDZIQX6.js → MissionCanvas-Ci0hbAF0.js} +1 -1
  64. package/ui/dist/assets/{MissionChat-BDTWMQjj.js → MissionChat-BDqlCplQ.js} +1 -1
  65. package/ui/dist/assets/{MissionLibrary-DEPH2eEu.js → MissionLibrary-9SMdJnfa.js} +1 -1
  66. package/ui/dist/assets/{MissionStart-COLFZLHB.js → MissionStart-Cm7C3kyo.js} +1 -1
  67. package/ui/dist/assets/{Modal-nvni-LGR.js → Modal-B9KCAwCK.js} +1 -1
  68. package/ui/dist/assets/{NvidiaPanel-BCgVrdWt.js → NvidiaPanel-CpGBj1sn.js} +1 -1
  69. package/ui/dist/assets/{OrganismPanel-Cab4MV9i.js → OrganismPanel-DBHyylxC.js} +1 -1
  70. package/ui/dist/assets/{OverviewPanel-isNUxBki.js → OverviewPanel-DII4H_R7.js} +1 -1
  71. package/ui/dist/assets/{PageHeader-BJ1jHtOy.js → PageHeader-Bzb_WXw0.js} +1 -1
  72. package/ui/dist/assets/{PersonaProfilesPanel-BGiDuDPj.js → PersonaProfilesPanel-CXZTZhjo.js} +1 -1
  73. package/ui/dist/assets/{PersonasPanel-4-USk8fm.js → PersonasPanel-BYbD8XiV.js} +1 -1
  74. package/ui/dist/assets/{PhoneDeskPanel-CUz5YVUY.js → PhoneDeskPanel-Bol7fCCN.js} +1 -1
  75. package/ui/dist/assets/{RecipesPanel-DJd6Otdy.js → RecipesPanel-BRbXRcEn.js} +1 -1
  76. package/ui/dist/assets/{SecurityPanel-CKqTnhNY.js → SecurityPanel-BR3BT7Rb.js} +1 -1
  77. package/ui/dist/assets/{SelfImprovePanel-BiCjKpTM.js → SelfImprovePanel-BX9xYBxl.js} +1 -1
  78. package/ui/dist/assets/{SelfProposalsPanel-BQCwEHdF.js → SelfProposalsPanel-BOoDEAYp.js} +1 -1
  79. package/ui/dist/assets/{SessionsPanel-MTMSODP7.js → SessionsPanel-BICnNmn0.js} +1 -1
  80. package/ui/dist/assets/{SessionsTab-CEFFZWMK.js → SessionsTab-X10FeDWA.js} +1 -1
  81. package/ui/dist/assets/{SettingsPanel-CniESkQQ.js → SettingsPanel-MuC32AXw.js} +1 -1
  82. package/ui/dist/assets/SettingsView-Cv9IZqiU.js +2 -0
  83. package/ui/dist/assets/{SkeletonLoader-IpWkLmoy.js → SkeletonLoader-fwI4Z-f0.js} +1 -1
  84. package/ui/dist/assets/{SkillsPanel-CCP-gCR4.js → SkillsPanel-CKFndekU.js} +1 -1
  85. package/ui/dist/assets/{SomaView-BK_thK9H.js → SomaView-Ch7WlmBy.js} +1 -1
  86. package/ui/dist/assets/{StatCard-I0fVw2CH.js → StatCard-Bj2Q_4WS.js} +1 -1
  87. package/ui/dist/assets/{StatusBadge-e3tFf05B.js → StatusBadge-NtdTQ8_L.js} +1 -1
  88. package/ui/dist/assets/{Tabs-vGpPiBzr.js → Tabs-CC9aTVuL.js} +1 -1
  89. package/ui/dist/assets/{TeamsPanel-AFIQBzRK.js → TeamsPanel-DjFcLsdR.js} +1 -1
  90. package/ui/dist/assets/{TelemetryPanel-DKZGVmcp.js → TelemetryPanel-k7gJbZyS.js} +1 -1
  91. package/ui/dist/assets/{TitanCanvas-CqvuuIjd.js → TitanCanvas-MzLkpZhp.js} +25 -25
  92. package/ui/dist/assets/{ToolsView-DnIkrUvP.js → ToolsView-DcxwuM2l.js} +2 -2
  93. package/ui/dist/assets/{Tooltip-DNc5AWi0.js → Tooltip-CFYHfpgQ.js} +1 -1
  94. package/ui/dist/assets/{TraceViewer-MD9YRFVc.js → TraceViewer-BfLO9vwI.js} +1 -1
  95. package/ui/dist/assets/{TrainingPanel-BfXoR7_N.js → TrainingPanel-DUl6qChY.js} +1 -1
  96. package/ui/dist/assets/{VoiceOverlay-Bl81c4yf.js → VoiceOverlay-Dj_cR5_Y.js} +1 -1
  97. package/ui/dist/assets/{VramPanel-Ba8H8Qs2.js → VramPanel-th0_Eo8o.js} +1 -1
  98. package/ui/dist/assets/{WatchView-CoLHPGd7.js → WatchView-DyGhpKbv.js} +1 -1
  99. package/ui/dist/assets/{WorkTab-UppfR_AF.js → WorkTab-BG5VBljJ.js} +1 -1
  100. package/ui/dist/assets/{WorkflowsPanel-CdN7Epxr.js → WorkflowsPanel-C1hVHqAc.js} +1 -1
  101. package/ui/dist/assets/{archive-DWgNklp0.js → archive-C2_hAJXj.js} +1 -1
  102. package/ui/dist/assets/{arrow-left-CW5NV7E0.js → arrow-left-DFCBXvKS.js} +1 -1
  103. package/ui/dist/assets/{book-open-DRI_Y6cW.js → book-open-BgDKDGcH.js} +1 -1
  104. package/ui/dist/assets/{bot-DSGZRM5O.js → bot-C4ICYImG.js} +1 -1
  105. package/ui/dist/assets/{chart-column-D6yK9tts.js → chart-column-BIFJOG_f.js} +1 -1
  106. package/ui/dist/assets/{check-Cxp-6q4k.js → check-CmCL8yzl.js} +1 -1
  107. package/ui/dist/assets/{chevron-right-DkIMxdwH.js → chevron-right-U0Ujye5i.js} +1 -1
  108. package/ui/dist/assets/{chevron-up-BbDu8x1d.js → chevron-up-B6uSBxbj.js} +1 -1
  109. package/ui/dist/assets/{circle-check-big-DnJPBAGU.js → circle-check-big-BFw1nom4.js} +1 -1
  110. package/ui/dist/assets/{circle-stop-DOe0OacY.js → circle-stop-DbtGpdaw.js} +1 -1
  111. package/ui/dist/assets/{clipboard-list-Dj5RQbT8.js → clipboard-list-Dd3_U8cK.js} +1 -1
  112. package/ui/dist/assets/{clock-BS8fh7Rt.js → clock-DpJIc30t.js} +1 -1
  113. package/ui/dist/assets/{dollar-sign-DMXBeaTj.js → dollar-sign-DlrOHVzA.js} +1 -1
  114. package/ui/dist/assets/{download-BykARpbG.js → download-CZ5kTONh.js} +1 -1
  115. package/ui/dist/assets/{external-link-BfXhMi9L.js → external-link-CX-GvMky.js} +1 -1
  116. package/ui/dist/assets/{file-text-CUkSytWL.js → file-text-BtTsNJbB.js} +1 -1
  117. package/ui/dist/assets/{flask-conical-BS4cuENu.js → flask-conical-BaPYppKH.js} +1 -1
  118. package/ui/dist/assets/{folder-BDwoUobN.js → folder-BOnpha2-.js} +1 -1
  119. package/ui/dist/assets/{funnel-xr6Dd1ub.js → funnel-DaNi6kwp.js} +1 -1
  120. package/ui/dist/assets/{git-branch-C0Qk52W8.js → git-branch-gs6g9dSe.js} +1 -1
  121. package/ui/dist/assets/{index-CmaGnHzR.js → index-Dbv5oKsp.js} +2 -2
  122. package/ui/dist/assets/{layers-DPHYdeRk.js → layers-BKZz8iD1.js} +1 -1
  123. package/ui/dist/assets/{legacy-DzagVk5C.js → legacy-DbwFsW2A.js} +1 -1
  124. package/ui/dist/assets/{lightbulb-Bj6cj6Xl.js → lightbulb-DX6YLtPe.js} +1 -1
  125. package/ui/dist/assets/{list-todo-Cm4jNFHV.js → list-todo-qdMNm4-Q.js} +1 -1
  126. package/ui/dist/assets/{message-square-BrWLAovN.js → message-square-Cwo5FOho.js} +1 -1
  127. package/ui/dist/assets/{mic-BXNK4d7X.js → mic-BzvwK4IS.js} +1 -1
  128. package/ui/dist/assets/{missions-DEjMYSre.js → missions-CYlXuJED.js} +1 -1
  129. package/ui/dist/assets/{network-CrQn1GKv.js → network-Dt-RBtO_.js} +1 -1
  130. package/ui/dist/assets/{pause-DS5xgDMT.js → pause-Do3XNLtx.js} +1 -1
  131. package/ui/dist/assets/{pencil-DAI6FtFQ.js → pencil-DAGs9RFs.js} +1 -1
  132. package/ui/dist/assets/{play-DxBy837b.js → play-CNElkzEq.js} +1 -1
  133. package/ui/dist/assets/{plug-D0Bstfm0.js → plug-DCgrVnB8.js} +1 -1
  134. package/ui/dist/assets/{plus-DxgNIt8h.js → plus-BnsXhqXc.js} +1 -1
  135. package/ui/dist/assets/{proxy-KYomRnLW.js → proxy-BXHdgwrk.js} +1 -1
  136. package/ui/dist/assets/{radio-2vniRFTO.js → radio-BPz7sHXW.js} +1 -1
  137. package/ui/dist/assets/{refresh-cw-BFBnnWj8.js → refresh-cw-Cs4oDMNE.js} +1 -1
  138. package/ui/dist/assets/{rotate-ccw-B9wWlKRc.js → rotate-ccw-DSpsA3Wr.js} +1 -1
  139. package/ui/dist/assets/{save--wCYre_u.js → save-BhGg2pZh.js} +1 -1
  140. package/ui/dist/assets/{search-DOD1aOm8.js → search-BtxlIgqN.js} +1 -1
  141. package/ui/dist/assets/{send-Bb57UxT7.js → send-BzKTXI3q.js} +1 -1
  142. package/ui/dist/assets/{server-CBsCfofY.js → server-B1gIgixS.js} +1 -1
  143. package/ui/dist/assets/{shield-check-B24N03VU.js → shield-check-C39B-Wi3.js} +1 -1
  144. package/ui/dist/assets/{terminal-CZ77Swtc.js → terminal-CubaeYlJ.js} +1 -1
  145. package/ui/dist/assets/{test-tube-CkkvIu5j.js → test-tube-CYYLfFIz.js} +1 -1
  146. package/ui/dist/assets/{toggle-right-DgphAedS.js → toggle-right-BQ3iDgLG.js} +1 -1
  147. package/ui/dist/assets/{trash-2-C5KNXS-O.js → trash-2-CSxfLiVB.js} +1 -1
  148. package/ui/dist/assets/{trending-up-B3H8xrGD.js → trending-up-DXxKT18Q.js} +1 -1
  149. package/ui/dist/assets/{trophy-C-xSgHD2.js → trophy-osEOm2Vi.js} +1 -1
  150. package/ui/dist/assets/{volume-2-BXwRjeve.js → volume-2-C1OkTurz.js} +1 -1
  151. package/ui/dist/assets/{wifi-off-DOm__Zn6.js → wifi-off-DAhvsjnD.js} +1 -1
  152. package/ui/dist/index.html +1 -1
  153. package/ui/dist/sw.js +1 -1
  154. package/ui/dist/assets/CPLayout-CBtGEYSs.js +0 -2
  155. package/ui/dist/assets/InfraView-G1q6vF0Q.js +0 -2
  156. package/ui/dist/assets/IntelligenceView-J8Nbh4zs.js +0 -2
  157. package/ui/dist/assets/SettingsView-2AwXqlvc.js +0 -2
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { createApproval } from "../../agent/commandPost.js";
2
3
  import { loadConfig } from "../../config/config.js";
3
4
  import { writeReceipt } from "../../receipts/store.js";
4
5
  import { validateOutboundCallRequest } from "../../telephony/phonePolicy.js";
@@ -37,15 +38,35 @@ function registerPhoneCallSkill() {
37
38
  });
38
39
  return `Phone call blocked: ${policy.reason ?? "policy failure"}${policy.toNumberRedacted ? ` (${policy.toNumberRedacted})` : ""}`;
39
40
  }
41
+ const approval = createApproval({
42
+ type: "custom",
43
+ requestedBy: `phone-call-tool:${policy.mode}:${policy.approvalIdentity?.slice(0, 16) ?? policy.toNumberHash?.slice(0, 12) ?? "unknown"}`,
44
+ payload: {
45
+ category: "telephony_outbound_call",
46
+ kind: "telephony_outbound_call",
47
+ title: policy.approvalIdentity ?? `${policy.mode}:${policy.workflowId}:${policy.toNumberHash}:${policy.purpose}`,
48
+ approvalIdentity: policy.approvalIdentity,
49
+ neverAutoApprove: true,
50
+ mode: policy.mode,
51
+ workflowId: policy.workflowId,
52
+ toNumberRedacted: policy.toNumberRedacted,
53
+ toNumberHash: policy.toNumberHash,
54
+ toNumberOptOutHash: policy.toNumberOptOutHash,
55
+ purpose: policy.purpose,
56
+ source: "dograh"
57
+ }
58
+ });
40
59
  const receipt = writeReceipt({
41
60
  kind: "approval_request",
42
61
  status: "pending",
43
62
  summary: `Phone call approval required: ${policy.toNumberRedacted}`,
44
63
  meta: {
64
+ approvalActionId: approval.id,
45
65
  mode: policy.mode,
46
66
  workflowId: policy.workflowId,
47
67
  toNumberRedacted: policy.toNumberRedacted,
48
68
  toNumberHash: policy.toNumberHash,
69
+ toNumberOptOutHash: policy.toNumberOptOutHash,
49
70
  purpose: policy.purpose
50
71
  }
51
72
  });
@@ -53,7 +74,8 @@ function registerPhoneCallSkill() {
53
74
  `Phone call approval required for ${policy.toNumberRedacted}.`,
54
75
  `Purpose: ${policy.purpose}`,
55
76
  `Mode: ${policy.mode}`,
56
- `Approval action: ${receipt.action_id}`,
77
+ `Approval action: ${approval.id}`,
78
+ `Receipt action: ${receipt.action_id}`,
57
79
  "No call was started. Use Phone Desk approval to place the Dograh call."
58
80
  ].join("\n");
59
81
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/skills/builtin/phone_call.ts"],"sourcesContent":["import { loadConfig } from '../../config/config.js';\nimport { writeReceipt } from '../../receipts/store.js';\nimport { validateOutboundCallRequest } from '../../telephony/phonePolicy.js';\nimport { registerSkill } from '../registry.js';\n\nexport function registerPhoneCallSkill(): void {\n registerSkill(\n {\n name: 'phone_call',\n description: 'Request an approval-gated Dograh outbound phone call. The tool never dials directly.',\n version: '0.1.0',\n source: 'bundled',\n enabled: true,\n },\n {\n name: 'phone_call',\n description: 'Request a Dograh-powered outbound phone call through TITAN Phone Desk. This tool creates an approval request only; it does not directly dial. Use only when the user explicitly asks TITAN to call a person or business. Cold-call/campaign mode is blocked unless configured separately.',\n parameters: {\n type: 'object',\n properties: {\n toNumber: { type: 'string', description: 'Destination phone number in E.164 format, e.g. +15551234567' },\n purpose: { type: 'string', description: 'Human-readable reason/objective for the call' },\n workflowId: { type: 'string', description: 'Optional Dograh outbound workflow ID. Defaults to telephony.dograh.defaultOutboundWorkflowId.' },\n mode: { type: 'string', enum: ['test', 'callback', 'campaign'], description: 'Call mode. campaign remains policy-gated.' },\n },\n required: ['toNumber', 'purpose'],\n },\n execute: async (args) => {\n const config = loadConfig();\n const policy = validateOutboundCallRequest(config.telephony, args);\n if (!policy.ok) {\n writeReceipt({\n kind: 'error',\n status: 'fail',\n summary: `Phone call blocked: ${policy.reason ?? 'policy failure'}`,\n meta: { mode: policy.mode, toNumberRedacted: policy.toNumberRedacted },\n });\n return `Phone call blocked: ${policy.reason ?? 'policy failure'}${policy.toNumberRedacted ? ` (${policy.toNumberRedacted})` : ''}`;\n }\n\n const receipt = writeReceipt({\n kind: 'approval_request',\n status: 'pending',\n summary: `Phone call approval required: ${policy.toNumberRedacted}`,\n meta: {\n mode: policy.mode,\n workflowId: policy.workflowId,\n toNumberRedacted: policy.toNumberRedacted,\n toNumberHash: policy.toNumberHash,\n purpose: policy.purpose,\n },\n });\n\n return [\n `Phone call approval required for ${policy.toNumberRedacted}.`,\n `Purpose: ${policy.purpose}`,\n `Mode: ${policy.mode}`,\n `Approval action: ${receipt.action_id}`,\n 'No call was started. Use Phone Desk approval to place the Dograh call.',\n ].join('\\n');\n },\n },\n );\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,mCAAmC;AAC5C,SAAS,qBAAqB;AAEvB,SAAS,yBAA+B;AAC7C;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,SAAS;AAAA,IACX;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY;AAAA,UACV,UAAU,EAAE,MAAM,UAAU,aAAa,8DAA8D;AAAA,UACvG,SAAS,EAAE,MAAM,UAAU,aAAa,+CAA+C;AAAA,UACvF,YAAY,EAAE,MAAM,UAAU,aAAa,gGAAgG;AAAA,UAC3I,MAAM,EAAE,MAAM,UAAU,MAAM,CAAC,QAAQ,YAAY,UAAU,GAAG,aAAa,4CAA4C;AAAA,QAC3H;AAAA,QACA,UAAU,CAAC,YAAY,SAAS;AAAA,MAClC;AAAA,MACA,SAAS,OAAO,SAAS;AACvB,cAAM,SAAS,WAAW;AAC1B,cAAM,SAAS,4BAA4B,OAAO,WAAW,IAAI;AACjE,YAAI,CAAC,OAAO,IAAI;AACd,uBAAa;AAAA,YACX,MAAM;AAAA,YACN,QAAQ;AAAA,YACR,SAAS,uBAAuB,OAAO,UAAU,gBAAgB;AAAA,YACjE,MAAM,EAAE,MAAM,OAAO,MAAM,kBAAkB,OAAO,iBAAiB;AAAA,UACvE,CAAC;AACD,iBAAO,uBAAuB,OAAO,UAAU,gBAAgB,GAAG,OAAO,mBAAmB,KAAK,OAAO,gBAAgB,MAAM,EAAE;AAAA,QAClI;AAEA,cAAM,UAAU,aAAa;AAAA,UAC3B,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,SAAS,iCAAiC,OAAO,gBAAgB;AAAA,UACjE,MAAM;AAAA,YACJ,MAAM,OAAO;AAAA,YACb,YAAY,OAAO;AAAA,YACnB,kBAAkB,OAAO;AAAA,YACzB,cAAc,OAAO;AAAA,YACrB,SAAS,OAAO;AAAA,UAClB;AAAA,QACF,CAAC;AAED,eAAO;AAAA,UACL,oCAAoC,OAAO,gBAAgB;AAAA,UAC3D,YAAY,OAAO,OAAO;AAAA,UAC1B,SAAS,OAAO,IAAI;AAAA,UACpB,oBAAoB,QAAQ,SAAS;AAAA,UACrC;AAAA,QACF,EAAE,KAAK,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/skills/builtin/phone_call.ts"],"sourcesContent":["import { createApproval } from '../../agent/commandPost.js';\nimport { loadConfig } from '../../config/config.js';\nimport { writeReceipt } from '../../receipts/store.js';\nimport { validateOutboundCallRequest } from '../../telephony/phonePolicy.js';\nimport { registerSkill } from '../registry.js';\n\nexport function registerPhoneCallSkill(): void {\n registerSkill(\n {\n name: 'phone_call',\n description: 'Request an approval-gated Dograh outbound phone call. The tool never dials directly.',\n version: '0.1.0',\n source: 'bundled',\n enabled: true,\n },\n {\n name: 'phone_call',\n description: 'Request a Dograh-powered outbound phone call through TITAN Phone Desk. This tool creates an approval request only; it does not directly dial. Use only when the user explicitly asks TITAN to call a person or business. Cold-call/campaign mode is blocked unless configured separately.',\n parameters: {\n type: 'object',\n properties: {\n toNumber: { type: 'string', description: 'Destination phone number in E.164 format, e.g. +15551234567' },\n purpose: { type: 'string', description: 'Human-readable reason/objective for the call' },\n workflowId: { type: 'string', description: 'Optional Dograh outbound workflow ID. Defaults to telephony.dograh.defaultOutboundWorkflowId.' },\n mode: { type: 'string', enum: ['test', 'callback', 'campaign'], description: 'Call mode. campaign remains policy-gated.' },\n },\n required: ['toNumber', 'purpose'],\n },\n execute: async (args) => {\n const config = loadConfig();\n const policy = validateOutboundCallRequest(config.telephony, args);\n if (!policy.ok) {\n writeReceipt({\n kind: 'error',\n status: 'fail',\n summary: `Phone call blocked: ${policy.reason ?? 'policy failure'}`,\n meta: { mode: policy.mode, toNumberRedacted: policy.toNumberRedacted },\n });\n return `Phone call blocked: ${policy.reason ?? 'policy failure'}${policy.toNumberRedacted ? ` (${policy.toNumberRedacted})` : ''}`;\n }\n\n const approval = createApproval({\n type: 'custom',\n requestedBy: `phone-call-tool:${policy.mode}:${policy.approvalIdentity?.slice(0, 16) ?? policy.toNumberHash?.slice(0, 12) ?? 'unknown'}`,\n payload: {\n category: 'telephony_outbound_call',\n kind: 'telephony_outbound_call',\n title: policy.approvalIdentity ?? `${policy.mode}:${policy.workflowId}:${policy.toNumberHash}:${policy.purpose}`,\n approvalIdentity: policy.approvalIdentity,\n neverAutoApprove: true,\n mode: policy.mode,\n workflowId: policy.workflowId,\n toNumberRedacted: policy.toNumberRedacted,\n toNumberHash: policy.toNumberHash,\n toNumberOptOutHash: policy.toNumberOptOutHash,\n purpose: policy.purpose,\n source: 'dograh',\n },\n });\n const receipt = writeReceipt({\n kind: 'approval_request',\n status: 'pending',\n summary: `Phone call approval required: ${policy.toNumberRedacted}`,\n meta: {\n approvalActionId: approval.id,\n mode: policy.mode,\n workflowId: policy.workflowId,\n toNumberRedacted: policy.toNumberRedacted,\n toNumberHash: policy.toNumberHash,\n toNumberOptOutHash: policy.toNumberOptOutHash,\n purpose: policy.purpose,\n },\n });\n\n return [\n `Phone call approval required for ${policy.toNumberRedacted}.`,\n `Purpose: ${policy.purpose}`,\n `Mode: ${policy.mode}`,\n `Approval action: ${approval.id}`,\n `Receipt action: ${receipt.action_id}`,\n 'No call was started. Use Phone Desk approval to place the Dograh call.',\n ].join('\\n');\n },\n },\n );\n}\n"],"mappings":";AAAA,SAAS,sBAAsB;AAC/B,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,mCAAmC;AAC5C,SAAS,qBAAqB;AAEvB,SAAS,yBAA+B;AAC7C;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,SAAS;AAAA,IACX;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY;AAAA,UACV,UAAU,EAAE,MAAM,UAAU,aAAa,8DAA8D;AAAA,UACvG,SAAS,EAAE,MAAM,UAAU,aAAa,+CAA+C;AAAA,UACvF,YAAY,EAAE,MAAM,UAAU,aAAa,gGAAgG;AAAA,UAC3I,MAAM,EAAE,MAAM,UAAU,MAAM,CAAC,QAAQ,YAAY,UAAU,GAAG,aAAa,4CAA4C;AAAA,QAC3H;AAAA,QACA,UAAU,CAAC,YAAY,SAAS;AAAA,MAClC;AAAA,MACA,SAAS,OAAO,SAAS;AACvB,cAAM,SAAS,WAAW;AAC1B,cAAM,SAAS,4BAA4B,OAAO,WAAW,IAAI;AACjE,YAAI,CAAC,OAAO,IAAI;AACd,uBAAa;AAAA,YACX,MAAM;AAAA,YACN,QAAQ;AAAA,YACR,SAAS,uBAAuB,OAAO,UAAU,gBAAgB;AAAA,YACjE,MAAM,EAAE,MAAM,OAAO,MAAM,kBAAkB,OAAO,iBAAiB;AAAA,UACvE,CAAC;AACD,iBAAO,uBAAuB,OAAO,UAAU,gBAAgB,GAAG,OAAO,mBAAmB,KAAK,OAAO,gBAAgB,MAAM,EAAE;AAAA,QAClI;AAEA,cAAM,WAAW,eAAe;AAAA,UAC9B,MAAM;AAAA,UACN,aAAa,mBAAmB,OAAO,IAAI,IAAI,OAAO,kBAAkB,MAAM,GAAG,EAAE,KAAK,OAAO,cAAc,MAAM,GAAG,EAAE,KAAK,SAAS;AAAA,UACtI,SAAS;AAAA,YACP,UAAU;AAAA,YACV,MAAM;AAAA,YACN,OAAO,OAAO,oBAAoB,GAAG,OAAO,IAAI,IAAI,OAAO,UAAU,IAAI,OAAO,YAAY,IAAI,OAAO,OAAO;AAAA,YAC9G,kBAAkB,OAAO;AAAA,YACzB,kBAAkB;AAAA,YAClB,MAAM,OAAO;AAAA,YACb,YAAY,OAAO;AAAA,YACnB,kBAAkB,OAAO;AAAA,YACzB,cAAc,OAAO;AAAA,YACrB,oBAAoB,OAAO;AAAA,YAC3B,SAAS,OAAO;AAAA,YAChB,QAAQ;AAAA,UACV;AAAA,QACF,CAAC;AACD,cAAM,UAAU,aAAa;AAAA,UAC3B,MAAM;AAAA,UACN,QAAQ;AAAA,UACR,SAAS,iCAAiC,OAAO,gBAAgB;AAAA,UACjE,MAAM;AAAA,YACJ,kBAAkB,SAAS;AAAA,YAC3B,MAAM,OAAO;AAAA,YACb,YAAY,OAAO;AAAA,YACnB,kBAAkB,OAAO;AAAA,YACzB,cAAc,OAAO;AAAA,YACrB,oBAAoB,OAAO;AAAA,YAC3B,SAAS,OAAO;AAAA,UAClB;AAAA,QACF,CAAC;AAED,eAAO;AAAA,UACL,oCAAoC,OAAO,gBAAgB;AAAA,UAC3D,YAAY,OAAO,OAAO;AAAA,UAC1B,SAAS,OAAO,IAAI;AAAA,UACpB,oBAAoB,SAAS,EAAE;AAAA,UAC/B,mBAAmB,QAAQ,SAAS;AAAA,UACpC;AAAA,QACF,EAAE,KAAK,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -24,6 +24,14 @@ function hashPhoneForApproval(config, normalizedPhoneNumber) {
24
24
  function hashPhoneForOptOut(normalizedPhoneNumber) {
25
25
  return createHmac("sha256", "titan-telephony-opt-out-v1").update(normalizedPhoneNumber).digest("hex");
26
26
  }
27
+ function buildTelephonyApprovalIdentity(fields) {
28
+ return createHmac("sha256", "titan-telephony-approval-identity-v1").update(JSON.stringify({
29
+ mode: fields.mode,
30
+ workflowId: fields.workflowId,
31
+ purpose: fields.purpose,
32
+ toNumberHash: fields.toNumberHash
33
+ })).digest("hex");
34
+ }
27
35
  function normalizeMode(value) {
28
36
  return value === "campaign" || value === "callback" || value === "test" ? value : "callback";
29
37
  }
@@ -96,21 +104,29 @@ function validateOutboundCallRequest(config, input) {
96
104
  };
97
105
  }
98
106
  const purpose = safePurpose(input.purpose) || "Outbound Dograh call";
107
+ const toNumberHash = hashPhoneForApproval(config, toNumber);
108
+ const toNumberOptOutHash = hashPhoneForOptOut(toNumber);
109
+ const approvalIdentity = buildTelephonyApprovalIdentity({ mode, workflowId, purpose, toNumberHash });
99
110
  return {
100
111
  ok: true,
101
112
  toNumber,
102
113
  toNumberRedacted: redactPhoneNumber(toNumber),
103
- toNumberHash: hashPhoneForApproval(config, toNumber),
104
- toNumberOptOutHash: hashPhoneForOptOut(toNumber),
114
+ toNumberHash,
115
+ toNumberOptOutHash,
116
+ approvalIdentity,
105
117
  workflowId,
106
118
  purpose,
107
119
  mode,
108
- requiresApproval: config.requireApprovalForOutbound || mode === "campaign",
120
+ // Dograh outbound calls always require a consumable Command Post approval.
121
+ // The config flag is retained for backward-compatible config parsing but
122
+ // must not create an unapproved dialing path.
123
+ requiresApproval: true,
109
124
  telephonyConfigurationId: optionalPositiveInt(input.telephonyConfigurationId),
110
125
  fromPhoneNumberId: optionalPositiveInt(input.fromPhoneNumberId)
111
126
  };
112
127
  }
113
128
  export {
129
+ buildTelephonyApprovalIdentity,
114
130
  hashPhoneForApproval,
115
131
  hashPhoneForOptOut,
116
132
  normalizePhoneNumber,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/telephony/phonePolicy.ts"],"sourcesContent":["import { createHmac } from 'crypto';\nimport type { TitanConfig } from '../config/schema.js';\n\nexport type OutboundCallMode = 'test' | 'callback' | 'campaign';\n\nexport interface OutboundCallPolicyInput {\n toNumber?: unknown;\n workflowId?: unknown;\n purpose?: unknown;\n mode?: unknown;\n telephonyConfigurationId?: unknown;\n fromPhoneNumberId?: unknown;\n}\n\nexport interface OutboundCallPolicyResult {\n ok: boolean;\n reason?: string;\n toNumber?: string;\n toNumberRedacted?: string;\n toNumberHash?: string;\n toNumberOptOutHash?: string;\n workflowId?: string;\n purpose?: string;\n mode?: OutboundCallMode;\n requiresApproval?: boolean;\n telephonyConfigurationId?: number;\n fromPhoneNumberId?: number;\n}\n\ntype TelephonyConfig = TitanConfig['telephony'];\n\nconst E164_RE = /^\\+[1-9]\\d{7,14}$/;\nconst SAFE_PURPOSE_MAX = 160;\n\nexport function normalizePhoneNumber(value: unknown): string | null {\n if (typeof value !== 'string') return null;\n const trimmed = value.trim();\n if (trimmed.startsWith('+')) {\n const normalized = `+${trimmed.slice(1).replace(/\\D/g, '')}`;\n return E164_RE.test(normalized) ? normalized : null;\n }\n return null;\n}\n\nexport function redactPhoneNumber(value: string | undefined | null): string {\n const normalized = normalizePhoneNumber(value) ?? '';\n if (!normalized) return '[invalid-phone]';\n if (normalized.length <= 8) return `${normalized.slice(0, 2)}••${normalized.slice(-2)}`;\n return `${normalized.slice(0, 5)}••••${normalized.slice(-2)}`;\n}\n\nexport function hashPhoneForApproval(config: TelephonyConfig, normalizedPhoneNumber: string): string {\n const key = config.dograh.apiKey || 'titan-telephony-approval';\n return createHmac('sha256', key).update(normalizedPhoneNumber).digest('hex');\n}\n\nexport function hashPhoneForOptOut(normalizedPhoneNumber: string): string {\n return createHmac('sha256', 'titan-telephony-opt-out-v1').update(normalizedPhoneNumber).digest('hex');\n}\n\nfunction normalizeMode(value: unknown): OutboundCallMode {\n return value === 'campaign' || value === 'callback' || value === 'test' ? value : 'callback';\n}\n\nfunction safePurpose(value: unknown): string {\n if (typeof value !== 'string') return '';\n return value.replace(/[\\r\\n\\t]+/g, ' ').replace(/\\+\\d[\\d\\s().-]{6,}\\d/g, '[phone]').slice(0, SAFE_PURPOSE_MAX).trim();\n}\n\nfunction optionalPositiveInt(value: unknown): number | undefined {\n if (value === undefined || value === null || value === '') return undefined;\n const n = typeof value === 'number' ? value : Number(value);\n return Number.isInteger(n) && n > 0 ? n : undefined;\n}\n\nexport function validateOutboundCallRequest(\n config: TelephonyConfig,\n input: OutboundCallPolicyInput,\n): OutboundCallPolicyResult {\n if (!config.enabled) {\n return { ok: false, reason: 'Telephony is disabled.' };\n }\n if (!config.dograh.apiKey) {\n return { ok: false, reason: 'Dograh API key is not configured.' };\n }\n\n const toNumber = normalizePhoneNumber(input.toNumber);\n if (!toNumber) {\n return { ok: false, reason: 'Outbound call requires a valid E.164 destination number.' };\n }\n\n const mode = normalizeMode(input.mode);\n if (mode === 'campaign' && !config.allowCampaigns) {\n return {\n ok: false,\n reason: 'Campaign outbound calls are disabled. Enable telephony.allowCampaigns and compliance controls first.',\n toNumberRedacted: redactPhoneNumber(toNumber),\n toNumberHash: hashPhoneForApproval(config, toNumber),\n toNumberOptOutHash: hashPhoneForOptOut(toNumber),\n mode,\n };\n }\n\n if (mode === 'campaign') {\n if (!config.recordingDisclosure.trim()) {\n return {\n ok: false,\n reason: 'Campaign outbound calls require a recording disclosure before dialing.',\n toNumberRedacted: redactPhoneNumber(toNumber),\n mode,\n };\n }\n if (!config.optOutKeywords.some((keyword) => keyword.trim())) {\n return {\n ok: false,\n reason: 'Campaign outbound calls require at least one opt-out keyword before dialing.',\n toNumberRedacted: redactPhoneNumber(toNumber),\n mode,\n };\n }\n if (!Number.isInteger(config.maxCallsPerHour) || config.maxCallsPerHour < 1) {\n return {\n ok: false,\n reason: 'Campaign outbound calls require telephony.maxCallsPerHour to be at least 1.',\n toNumberRedacted: redactPhoneNumber(toNumber),\n mode,\n };\n }\n }\n\n const workflowId = typeof input.workflowId === 'string' && input.workflowId.trim()\n ? input.workflowId.trim()\n : config.dograh.defaultOutboundWorkflowId;\n if (!workflowId) {\n return {\n ok: false,\n reason: 'Dograh outbound workflow ID is not configured.',\n toNumberRedacted: redactPhoneNumber(toNumber),\n toNumberHash: hashPhoneForApproval(config, toNumber),\n toNumberOptOutHash: hashPhoneForOptOut(toNumber),\n mode,\n };\n }\n\n const purpose = safePurpose(input.purpose) || 'Outbound Dograh call';\n return {\n ok: true,\n toNumber,\n toNumberRedacted: redactPhoneNumber(toNumber),\n toNumberHash: hashPhoneForApproval(config, toNumber),\n toNumberOptOutHash: hashPhoneForOptOut(toNumber),\n workflowId,\n purpose,\n mode,\n requiresApproval: config.requireApprovalForOutbound || mode === 'campaign',\n telephonyConfigurationId: optionalPositiveInt(input.telephonyConfigurationId),\n fromPhoneNumberId: optionalPositiveInt(input.fromPhoneNumberId),\n };\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AA+B3B,MAAM,UAAU;AAChB,MAAM,mBAAmB;AAElB,SAAS,qBAAqB,OAA+B;AAClE,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,QAAQ,WAAW,GAAG,GAAG;AAC3B,UAAM,aAAa,IAAI,QAAQ,MAAM,CAAC,EAAE,QAAQ,OAAO,EAAE,CAAC;AAC1D,WAAO,QAAQ,KAAK,UAAU,IAAI,aAAa;AAAA,EACjD;AACA,SAAO;AACT;AAEO,SAAS,kBAAkB,OAA0C;AAC1E,QAAM,aAAa,qBAAqB,KAAK,KAAK;AAClD,MAAI,CAAC,WAAY,QAAO;AACxB,MAAI,WAAW,UAAU,EAAG,QAAO,GAAG,WAAW,MAAM,GAAG,CAAC,CAAC,eAAK,WAAW,MAAM,EAAE,CAAC;AACrF,SAAO,GAAG,WAAW,MAAM,GAAG,CAAC,CAAC,2BAAO,WAAW,MAAM,EAAE,CAAC;AAC7D;AAEO,SAAS,qBAAqB,QAAyB,uBAAuC;AACnG,QAAM,MAAM,OAAO,OAAO,UAAU;AACpC,SAAO,WAAW,UAAU,GAAG,EAAE,OAAO,qBAAqB,EAAE,OAAO,KAAK;AAC7E;AAEO,SAAS,mBAAmB,uBAAuC;AACxE,SAAO,WAAW,UAAU,4BAA4B,EAAE,OAAO,qBAAqB,EAAE,OAAO,KAAK;AACtG;AAEA,SAAS,cAAc,OAAkC;AACvD,SAAO,UAAU,cAAc,UAAU,cAAc,UAAU,SAAS,QAAQ;AACpF;AAEA,SAAS,YAAY,OAAwB;AAC3C,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,SAAO,MAAM,QAAQ,cAAc,GAAG,EAAE,QAAQ,yBAAyB,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,KAAK;AACtH;AAEA,SAAS,oBAAoB,OAAoC;AAC/D,MAAI,UAAU,UAAa,UAAU,QAAQ,UAAU,GAAI,QAAO;AAClE,QAAM,IAAI,OAAO,UAAU,WAAW,QAAQ,OAAO,KAAK;AAC1D,SAAO,OAAO,UAAU,CAAC,KAAK,IAAI,IAAI,IAAI;AAC5C;AAEO,SAAS,4BACd,QACA,OAC0B;AAC1B,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO,EAAE,IAAI,OAAO,QAAQ,yBAAyB;AAAA,EACvD;AACA,MAAI,CAAC,OAAO,OAAO,QAAQ;AACzB,WAAO,EAAE,IAAI,OAAO,QAAQ,oCAAoC;AAAA,EAClE;AAEA,QAAM,WAAW,qBAAqB,MAAM,QAAQ;AACpD,MAAI,CAAC,UAAU;AACb,WAAO,EAAE,IAAI,OAAO,QAAQ,2DAA2D;AAAA,EACzF;AAEA,QAAM,OAAO,cAAc,MAAM,IAAI;AACrC,MAAI,SAAS,cAAc,CAAC,OAAO,gBAAgB;AACjD,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,QAAQ;AAAA,MACR,kBAAkB,kBAAkB,QAAQ;AAAA,MAC5C,cAAc,qBAAqB,QAAQ,QAAQ;AAAA,MACnD,oBAAoB,mBAAmB,QAAQ;AAAA,MAC/C;AAAA,IACF;AAAA,EACF;AAEA,MAAI,SAAS,YAAY;AACvB,QAAI,CAAC,OAAO,oBAAoB,KAAK,GAAG;AACtC,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,QAAQ;AAAA,QACR,kBAAkB,kBAAkB,QAAQ;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AACA,QAAI,CAAC,OAAO,eAAe,KAAK,CAAC,YAAY,QAAQ,KAAK,CAAC,GAAG;AAC5D,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,QAAQ;AAAA,QACR,kBAAkB,kBAAkB,QAAQ;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AACA,QAAI,CAAC,OAAO,UAAU,OAAO,eAAe,KAAK,OAAO,kBAAkB,GAAG;AAC3E,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,QAAQ;AAAA,QACR,kBAAkB,kBAAkB,QAAQ;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,aAAa,OAAO,MAAM,eAAe,YAAY,MAAM,WAAW,KAAK,IAC7E,MAAM,WAAW,KAAK,IACtB,OAAO,OAAO;AAClB,MAAI,CAAC,YAAY;AACf,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,QAAQ;AAAA,MACR,kBAAkB,kBAAkB,QAAQ;AAAA,MAC5C,cAAc,qBAAqB,QAAQ,QAAQ;AAAA,MACnD,oBAAoB,mBAAmB,QAAQ;AAAA,MAC/C;AAAA,IACF;AAAA,EACF;AAEA,QAAM,UAAU,YAAY,MAAM,OAAO,KAAK;AAC9C,SAAO;AAAA,IACL,IAAI;AAAA,IACJ;AAAA,IACA,kBAAkB,kBAAkB,QAAQ;AAAA,IAC5C,cAAc,qBAAqB,QAAQ,QAAQ;AAAA,IACnD,oBAAoB,mBAAmB,QAAQ;AAAA,IAC/C;AAAA,IACA;AAAA,IACA;AAAA,IACA,kBAAkB,OAAO,8BAA8B,SAAS;AAAA,IAChE,0BAA0B,oBAAoB,MAAM,wBAAwB;AAAA,IAC5E,mBAAmB,oBAAoB,MAAM,iBAAiB;AAAA,EAChE;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/telephony/phonePolicy.ts"],"sourcesContent":["import { createHmac } from 'crypto';\nimport type { TitanConfig } from '../config/schema.js';\n\nexport type OutboundCallMode = 'test' | 'callback' | 'campaign';\n\nexport interface OutboundCallPolicyInput {\n toNumber?: unknown;\n workflowId?: unknown;\n purpose?: unknown;\n mode?: unknown;\n telephonyConfigurationId?: unknown;\n fromPhoneNumberId?: unknown;\n}\n\nexport interface OutboundCallPolicyResult {\n ok: boolean;\n reason?: string;\n toNumber?: string;\n toNumberRedacted?: string;\n toNumberHash?: string;\n toNumberOptOutHash?: string;\n approvalIdentity?: string;\n workflowId?: string;\n purpose?: string;\n mode?: OutboundCallMode;\n requiresApproval?: boolean;\n telephonyConfigurationId?: number;\n fromPhoneNumberId?: number;\n}\n\ntype TelephonyConfig = TitanConfig['telephony'];\n\nconst E164_RE = /^\\+[1-9]\\d{7,14}$/;\nconst SAFE_PURPOSE_MAX = 160;\n\nexport function normalizePhoneNumber(value: unknown): string | null {\n if (typeof value !== 'string') return null;\n const trimmed = value.trim();\n if (trimmed.startsWith('+')) {\n const normalized = `+${trimmed.slice(1).replace(/\\D/g, '')}`;\n return E164_RE.test(normalized) ? normalized : null;\n }\n return null;\n}\n\nexport function redactPhoneNumber(value: string | undefined | null): string {\n const normalized = normalizePhoneNumber(value) ?? '';\n if (!normalized) return '[invalid-phone]';\n if (normalized.length <= 8) return `${normalized.slice(0, 2)}••${normalized.slice(-2)}`;\n return `${normalized.slice(0, 5)}••••${normalized.slice(-2)}`;\n}\n\nexport function hashPhoneForApproval(config: TelephonyConfig, normalizedPhoneNumber: string): string {\n const key = config.dograh.apiKey || 'titan-telephony-approval';\n return createHmac('sha256', key).update(normalizedPhoneNumber).digest('hex');\n}\n\nexport function hashPhoneForOptOut(normalizedPhoneNumber: string): string {\n return createHmac('sha256', 'titan-telephony-opt-out-v1').update(normalizedPhoneNumber).digest('hex');\n}\n\nexport function buildTelephonyApprovalIdentity(fields: {\n mode: OutboundCallMode;\n workflowId: string;\n purpose: string;\n toNumberHash: string;\n}): string {\n return createHmac('sha256', 'titan-telephony-approval-identity-v1')\n .update(JSON.stringify({\n mode: fields.mode,\n workflowId: fields.workflowId,\n purpose: fields.purpose,\n toNumberHash: fields.toNumberHash,\n }))\n .digest('hex');\n}\n\nfunction normalizeMode(value: unknown): OutboundCallMode {\n return value === 'campaign' || value === 'callback' || value === 'test' ? value : 'callback';\n}\n\nfunction safePurpose(value: unknown): string {\n if (typeof value !== 'string') return '';\n return value.replace(/[\\r\\n\\t]+/g, ' ').replace(/\\+\\d[\\d\\s().-]{6,}\\d/g, '[phone]').slice(0, SAFE_PURPOSE_MAX).trim();\n}\n\nfunction optionalPositiveInt(value: unknown): number | undefined {\n if (value === undefined || value === null || value === '') return undefined;\n const n = typeof value === 'number' ? value : Number(value);\n return Number.isInteger(n) && n > 0 ? n : undefined;\n}\n\nexport function validateOutboundCallRequest(\n config: TelephonyConfig,\n input: OutboundCallPolicyInput,\n): OutboundCallPolicyResult {\n if (!config.enabled) {\n return { ok: false, reason: 'Telephony is disabled.' };\n }\n if (!config.dograh.apiKey) {\n return { ok: false, reason: 'Dograh API key is not configured.' };\n }\n\n const toNumber = normalizePhoneNumber(input.toNumber);\n if (!toNumber) {\n return { ok: false, reason: 'Outbound call requires a valid E.164 destination number.' };\n }\n\n const mode = normalizeMode(input.mode);\n if (mode === 'campaign' && !config.allowCampaigns) {\n return {\n ok: false,\n reason: 'Campaign outbound calls are disabled. Enable telephony.allowCampaigns and compliance controls first.',\n toNumberRedacted: redactPhoneNumber(toNumber),\n toNumberHash: hashPhoneForApproval(config, toNumber),\n toNumberOptOutHash: hashPhoneForOptOut(toNumber),\n mode,\n };\n }\n\n if (mode === 'campaign') {\n if (!config.recordingDisclosure.trim()) {\n return {\n ok: false,\n reason: 'Campaign outbound calls require a recording disclosure before dialing.',\n toNumberRedacted: redactPhoneNumber(toNumber),\n mode,\n };\n }\n if (!config.optOutKeywords.some((keyword) => keyword.trim())) {\n return {\n ok: false,\n reason: 'Campaign outbound calls require at least one opt-out keyword before dialing.',\n toNumberRedacted: redactPhoneNumber(toNumber),\n mode,\n };\n }\n if (!Number.isInteger(config.maxCallsPerHour) || config.maxCallsPerHour < 1) {\n return {\n ok: false,\n reason: 'Campaign outbound calls require telephony.maxCallsPerHour to be at least 1.',\n toNumberRedacted: redactPhoneNumber(toNumber),\n mode,\n };\n }\n }\n\n const workflowId = typeof input.workflowId === 'string' && input.workflowId.trim()\n ? input.workflowId.trim()\n : config.dograh.defaultOutboundWorkflowId;\n if (!workflowId) {\n return {\n ok: false,\n reason: 'Dograh outbound workflow ID is not configured.',\n toNumberRedacted: redactPhoneNumber(toNumber),\n toNumberHash: hashPhoneForApproval(config, toNumber),\n toNumberOptOutHash: hashPhoneForOptOut(toNumber),\n mode,\n };\n }\n\n const purpose = safePurpose(input.purpose) || 'Outbound Dograh call';\n const toNumberHash = hashPhoneForApproval(config, toNumber);\n const toNumberOptOutHash = hashPhoneForOptOut(toNumber);\n const approvalIdentity = buildTelephonyApprovalIdentity({ mode, workflowId, purpose, toNumberHash });\n return {\n ok: true,\n toNumber,\n toNumberRedacted: redactPhoneNumber(toNumber),\n toNumberHash,\n toNumberOptOutHash,\n approvalIdentity,\n workflowId,\n purpose,\n mode,\n // Dograh outbound calls always require a consumable Command Post approval.\n // The config flag is retained for backward-compatible config parsing but\n // must not create an unapproved dialing path.\n requiresApproval: true,\n telephonyConfigurationId: optionalPositiveInt(input.telephonyConfigurationId),\n fromPhoneNumberId: optionalPositiveInt(input.fromPhoneNumberId),\n };\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAgC3B,MAAM,UAAU;AAChB,MAAM,mBAAmB;AAElB,SAAS,qBAAqB,OAA+B;AAClE,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,QAAQ,WAAW,GAAG,GAAG;AAC3B,UAAM,aAAa,IAAI,QAAQ,MAAM,CAAC,EAAE,QAAQ,OAAO,EAAE,CAAC;AAC1D,WAAO,QAAQ,KAAK,UAAU,IAAI,aAAa;AAAA,EACjD;AACA,SAAO;AACT;AAEO,SAAS,kBAAkB,OAA0C;AAC1E,QAAM,aAAa,qBAAqB,KAAK,KAAK;AAClD,MAAI,CAAC,WAAY,QAAO;AACxB,MAAI,WAAW,UAAU,EAAG,QAAO,GAAG,WAAW,MAAM,GAAG,CAAC,CAAC,eAAK,WAAW,MAAM,EAAE,CAAC;AACrF,SAAO,GAAG,WAAW,MAAM,GAAG,CAAC,CAAC,2BAAO,WAAW,MAAM,EAAE,CAAC;AAC7D;AAEO,SAAS,qBAAqB,QAAyB,uBAAuC;AACnG,QAAM,MAAM,OAAO,OAAO,UAAU;AACpC,SAAO,WAAW,UAAU,GAAG,EAAE,OAAO,qBAAqB,EAAE,OAAO,KAAK;AAC7E;AAEO,SAAS,mBAAmB,uBAAuC;AACxE,SAAO,WAAW,UAAU,4BAA4B,EAAE,OAAO,qBAAqB,EAAE,OAAO,KAAK;AACtG;AAEO,SAAS,+BAA+B,QAKpC;AACT,SAAO,WAAW,UAAU,sCAAsC,EAC/D,OAAO,KAAK,UAAU;AAAA,IACrB,MAAM,OAAO;AAAA,IACb,YAAY,OAAO;AAAA,IACnB,SAAS,OAAO;AAAA,IAChB,cAAc,OAAO;AAAA,EACvB,CAAC,CAAC,EACD,OAAO,KAAK;AACjB;AAEA,SAAS,cAAc,OAAkC;AACvD,SAAO,UAAU,cAAc,UAAU,cAAc,UAAU,SAAS,QAAQ;AACpF;AAEA,SAAS,YAAY,OAAwB;AAC3C,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,SAAO,MAAM,QAAQ,cAAc,GAAG,EAAE,QAAQ,yBAAyB,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,KAAK;AACtH;AAEA,SAAS,oBAAoB,OAAoC;AAC/D,MAAI,UAAU,UAAa,UAAU,QAAQ,UAAU,GAAI,QAAO;AAClE,QAAM,IAAI,OAAO,UAAU,WAAW,QAAQ,OAAO,KAAK;AAC1D,SAAO,OAAO,UAAU,CAAC,KAAK,IAAI,IAAI,IAAI;AAC5C;AAEO,SAAS,4BACd,QACA,OAC0B;AAC1B,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO,EAAE,IAAI,OAAO,QAAQ,yBAAyB;AAAA,EACvD;AACA,MAAI,CAAC,OAAO,OAAO,QAAQ;AACzB,WAAO,EAAE,IAAI,OAAO,QAAQ,oCAAoC;AAAA,EAClE;AAEA,QAAM,WAAW,qBAAqB,MAAM,QAAQ;AACpD,MAAI,CAAC,UAAU;AACb,WAAO,EAAE,IAAI,OAAO,QAAQ,2DAA2D;AAAA,EACzF;AAEA,QAAM,OAAO,cAAc,MAAM,IAAI;AACrC,MAAI,SAAS,cAAc,CAAC,OAAO,gBAAgB;AACjD,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,QAAQ;AAAA,MACR,kBAAkB,kBAAkB,QAAQ;AAAA,MAC5C,cAAc,qBAAqB,QAAQ,QAAQ;AAAA,MACnD,oBAAoB,mBAAmB,QAAQ;AAAA,MAC/C;AAAA,IACF;AAAA,EACF;AAEA,MAAI,SAAS,YAAY;AACvB,QAAI,CAAC,OAAO,oBAAoB,KAAK,GAAG;AACtC,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,QAAQ;AAAA,QACR,kBAAkB,kBAAkB,QAAQ;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AACA,QAAI,CAAC,OAAO,eAAe,KAAK,CAAC,YAAY,QAAQ,KAAK,CAAC,GAAG;AAC5D,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,QAAQ;AAAA,QACR,kBAAkB,kBAAkB,QAAQ;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AACA,QAAI,CAAC,OAAO,UAAU,OAAO,eAAe,KAAK,OAAO,kBAAkB,GAAG;AAC3E,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,QAAQ;AAAA,QACR,kBAAkB,kBAAkB,QAAQ;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,aAAa,OAAO,MAAM,eAAe,YAAY,MAAM,WAAW,KAAK,IAC7E,MAAM,WAAW,KAAK,IACtB,OAAO,OAAO;AAClB,MAAI,CAAC,YAAY;AACf,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,QAAQ;AAAA,MACR,kBAAkB,kBAAkB,QAAQ;AAAA,MAC5C,cAAc,qBAAqB,QAAQ,QAAQ;AAAA,MACnD,oBAAoB,mBAAmB,QAAQ;AAAA,MAC/C;AAAA,IACF;AAAA,EACF;AAEA,QAAM,UAAU,YAAY,MAAM,OAAO,KAAK;AAC9C,QAAM,eAAe,qBAAqB,QAAQ,QAAQ;AAC1D,QAAM,qBAAqB,mBAAmB,QAAQ;AACtD,QAAM,mBAAmB,+BAA+B,EAAE,MAAM,YAAY,SAAS,aAAa,CAAC;AACnG,SAAO;AAAA,IACL,IAAI;AAAA,IACJ;AAAA,IACA,kBAAkB,kBAAkB,QAAQ;AAAA,IAC5C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAIA,kBAAkB;AAAA,IAClB,0BAA0B,oBAAoB,MAAM,wBAAwB;AAAA,IAC5E,mBAAmB,oBAAoB,MAAM,iBAAiB;AAAA,EAChE;AACF;","names":[]}
@@ -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 = "6.2.0";
4
+ const TITAN_VERSION = "6.2.2";
5
5
  const TITAN_CODENAME = "Living Canvas";
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 = '6.2.0';\nexport const TITAN_CODENAME = 'Living Canvas';\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// v6.1.0 — Mission Chat\nexport const MISSIONS_DIR = join(TITAN_HOME, 'missions');\nexport const PLAYS_DIR = join(TITAN_HOME, 'plays');\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\n// v6.0.1 — Hardcoded floor only. The actual default at runtime is picked\n// by `getDefaultModelId()` in `src/providers/defaultModel.ts`, which\n// detects the user's available API keys (Anthropic / OpenAI / Google /\n// OpenRouter) and selects accordingly. Falls back to local Ollama when\n// no cloud keys are set. This constant is the last-resort fallback for\n// callsites that don't go through the schema thunk.\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,eAAe,KAAK,YAAY,UAAU;AAChD,MAAM,YAAY,KAAK,YAAY,OAAO;AAG1C,MAAM,uBAAuB;AAC7B,MAAM,uBAAuB;AAC7B,MAAM,mBAAmB;AASzB,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 = '6.2.2';\nexport const TITAN_CODENAME = 'Living Canvas';\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// v6.1.0 — Mission Chat\nexport const MISSIONS_DIR = join(TITAN_HOME, 'missions');\nexport const PLAYS_DIR = join(TITAN_HOME, 'plays');\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\n// v6.0.1 — Hardcoded floor only. The actual default at runtime is picked\n// by `getDefaultModelId()` in `src/providers/defaultModel.ts`, which\n// detects the user's available API keys (Anthropic / OpenAI / Google /\n// OpenRouter) and selects accordingly. Falls back to local Ollama when\n// no cloud keys are set. This constant is the last-resort fallback for\n// callsites that don't go through the schema thunk.\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,eAAe,KAAK,YAAY,UAAU;AAChD,MAAM,YAAY,KAAK,YAAY,OAAO;AAG1C,MAAM,uBAAuB;AAC7B,MAAM,uBAAuB;AAC7B,MAAM,mBAAmB;AASzB,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":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "titan-agent",
3
- "version": "6.2.0",
3
+ "version": "6.2.2",
4
4
  "description": "TITAN — TypeScript AI agent framework with multi-agent orchestration, provider routing, approval gates, receipts, evals, gateway APIs, and a React Mission Control dashboard. Open-source, MIT licensed.",
5
5
  "author": "Tony Elliott (https://github.com/Djtony707)",
6
6
  "repository": {
@@ -1 +1 @@
1
- import{r as d,j as e,aJ as S,aK as A}from"./index-CmaGnHzR.js";import{C as v}from"./clipboard-list-Dj5RQbT8.js";import{R as C}from"./refresh-cw-BFBnnWj8.js";import{F as T}from"./funnel-xr6Dd1ub.js";function E(){var b;const[c,p]=d.useState([]),[r,h]=d.useState(null),[g,i]=d.useState(!0),[a,n]=d.useState(""),[l,x]=d.useState(""),m=async()=>{i(!0);try{const[t,s]=await Promise.all([S({source:a||void 0,action:l||void 0,limit:100}),A(24)]);p(t),h(s)}catch{}i(!1)};d.useEffect(()=>{m()},[a,l]);const j=t=>t==="success"?"text-[var(--success)]":t==="failure"?"text-[var(--error)]":t==="escalated"?"text-[var(--warning)]":"text-[var(--text-muted)]",f=t=>t==="success"?"bg-[var(--success)]/10 border-[var(--success)]/20":t==="failure"?"bg-[var(--error)]/10 border-[var(--error)]/20":t==="escalated"?"bg-[var(--warning)]/10 border-[var(--warning)]/20":"bg-[var(--bg-tertiary)] border-[var(--border)]",u=t=>t.startsWith("daemon")?"bg-purple-500/10 text-purple-400 border-purple-500/20":t==="autopilot"?"bg-blue-500/10 text-blue-400 border-blue-500/20":t==="user"?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":t==="initiative"?"bg-amber-500/10 text-amber-400 border-amber-500/20":"bg-[var(--bg-tertiary)] text-[var(--text-muted)] border-[var(--border)]",N=t=>{try{const s=new Date(t),o=new Date().getTime()-s.getTime();return o<6e4?`${Math.round(o/1e3)}s ago`:o<36e5?`${Math.round(o/6e4)}m ago`:o<864e5?`${Math.round(o/36e5)}h ago`:s.toLocaleDateString()}catch{return t}},y=[...new Set(c.map(t=>t.source))].sort(),w=[...new Set(c.map(t=>t.action))].sort();return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(v,{className:"w-6 h-6 text-[var(--accent)]"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-[var(--text)]",children:"Audit Log"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Every autonomous action logged for accountability"})]})]}),e.jsx("button",{onClick:m,className:"p-2 rounded-md border border-[var(--border)] text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] transition-colors",children:e.jsx(C,{size:14})})]}),r&&e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 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:"Actions (24h)"}),e.jsx("p",{className:"text-2xl font-bold text-[var(--text)]",children:r.totalActions})]}),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:"Success Rate"}),e.jsxs("p",{className:`text-2xl font-bold ${r.successRate>=80?"text-[var(--success)]":r.successRate>=50?"text-[var(--warning)]":"text-[var(--error)]"}`,children:[r.successRate,"%"]})]}),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:"Sources"}),e.jsx("p",{className:"text-2xl font-bold text-[var(--text)]",children:Object.keys(r.bySource).length})]}),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:"Top Tool"}),e.jsx("p",{className:"text-lg font-semibold text-[var(--accent)] truncate",children:((b=r.topTools[0])==null?void 0:b.tool)||"none"})]})]}),r&&Object.keys(r.bySource).length>0&&e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-[var(--text)] mb-3",children:"Actions by Source (24h)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(r.bySource).sort((t,s)=>s[1]-t[1]).map(([t,s])=>e.jsxs("button",{onClick:()=>n(a===t?"":t),className:`px-3 py-1.5 text-xs rounded-md border transition-colors ${a===t?"bg-[var(--accent)] text-white border-[var(--accent)]":u(t)}`,children:[t,": ",s]},t))})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(T,{size:14,className:"text-[var(--text-muted)]"}),e.jsxs("select",{value:a,onChange:t=>n(t.target.value),className:"px-3 py-1.5 text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md text-[var(--text)]",children:[e.jsx("option",{value:"",children:"All Sources"}),y.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsxs("select",{value:l,onChange:t=>x(t.target.value),className:"px-3 py-1.5 text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md text-[var(--text)]",children:[e.jsx("option",{value:"",children:"All Actions"}),w.map(t=>e.jsx("option",{value:t,children:t},t))]}),(a||l)&&e.jsx("button",{onClick:()=>{n(""),x("")},className:"text-xs text-[var(--accent)] hover:underline",children:"Clear"})]}),g?e.jsx("div",{className:"text-[var(--text-muted)] text-sm",children:"Loading audit log..."}):c.length===0?e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-8 text-center",children:[e.jsx(v,{className:"w-10 h-10 text-[var(--text-muted)] mx-auto mb-3"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:"No audit entries found"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Autonomous actions will appear here as TITAN operates."})]}):e.jsx("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg overflow-hidden",children: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-[var(--border)] text-[var(--text-muted)]",children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Time"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Action"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Source"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Tool"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Result"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Detail"})]})}),e.jsx("tbody",{children:c.map((t,s)=>e.jsxs("tr",{className:"border-b border-[var(--border)]/50 last:border-0 hover:bg-[var(--bg-tertiary)] transition-colors",children:[e.jsx("td",{className:"px-4 py-2 text-[var(--text-muted)] whitespace-nowrap",children:N(t.timestamp)}),e.jsx("td",{className:"px-4 py-2 text-[var(--text)] font-medium",children:t.action}),e.jsx("td",{className:"px-4 py-2",children:e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] border ${u(t.source)}`,children:t.source})}),e.jsx("td",{className:"px-4 py-2 text-[var(--text-secondary)] font-mono",children:t.tool||"-"}),e.jsx("td",{className:"px-4 py-2",children:t.result?e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] border ${f(t.result)} ${j(t.result)}`,children:t.result}):"-"}),e.jsx("td",{className:"px-4 py-2 text-[var(--text-muted)] max-w-[200px] truncate",children:t.detail?JSON.stringify(t.detail):"-"})]},s))})]})})})]})}export{E as default};
1
+ import{r as d,j as e,aJ as S,aK as A}from"./index-Dbv5oKsp.js";import{C as v}from"./clipboard-list-Dd3_U8cK.js";import{R as C}from"./refresh-cw-Cs4oDMNE.js";import{F as T}from"./funnel-DaNi6kwp.js";function E(){var b;const[c,p]=d.useState([]),[r,h]=d.useState(null),[g,i]=d.useState(!0),[a,n]=d.useState(""),[l,x]=d.useState(""),m=async()=>{i(!0);try{const[t,s]=await Promise.all([S({source:a||void 0,action:l||void 0,limit:100}),A(24)]);p(t),h(s)}catch{}i(!1)};d.useEffect(()=>{m()},[a,l]);const j=t=>t==="success"?"text-[var(--success)]":t==="failure"?"text-[var(--error)]":t==="escalated"?"text-[var(--warning)]":"text-[var(--text-muted)]",f=t=>t==="success"?"bg-[var(--success)]/10 border-[var(--success)]/20":t==="failure"?"bg-[var(--error)]/10 border-[var(--error)]/20":t==="escalated"?"bg-[var(--warning)]/10 border-[var(--warning)]/20":"bg-[var(--bg-tertiary)] border-[var(--border)]",u=t=>t.startsWith("daemon")?"bg-purple-500/10 text-purple-400 border-purple-500/20":t==="autopilot"?"bg-blue-500/10 text-blue-400 border-blue-500/20":t==="user"?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":t==="initiative"?"bg-amber-500/10 text-amber-400 border-amber-500/20":"bg-[var(--bg-tertiary)] text-[var(--text-muted)] border-[var(--border)]",N=t=>{try{const s=new Date(t),o=new Date().getTime()-s.getTime();return o<6e4?`${Math.round(o/1e3)}s ago`:o<36e5?`${Math.round(o/6e4)}m ago`:o<864e5?`${Math.round(o/36e5)}h ago`:s.toLocaleDateString()}catch{return t}},y=[...new Set(c.map(t=>t.source))].sort(),w=[...new Set(c.map(t=>t.action))].sort();return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(v,{className:"w-6 h-6 text-[var(--accent)]"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-[var(--text)]",children:"Audit Log"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Every autonomous action logged for accountability"})]})]}),e.jsx("button",{onClick:m,className:"p-2 rounded-md border border-[var(--border)] text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] transition-colors",children:e.jsx(C,{size:14})})]}),r&&e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 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:"Actions (24h)"}),e.jsx("p",{className:"text-2xl font-bold text-[var(--text)]",children:r.totalActions})]}),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:"Success Rate"}),e.jsxs("p",{className:`text-2xl font-bold ${r.successRate>=80?"text-[var(--success)]":r.successRate>=50?"text-[var(--warning)]":"text-[var(--error)]"}`,children:[r.successRate,"%"]})]}),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:"Sources"}),e.jsx("p",{className:"text-2xl font-bold text-[var(--text)]",children:Object.keys(r.bySource).length})]}),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:"Top Tool"}),e.jsx("p",{className:"text-lg font-semibold text-[var(--accent)] truncate",children:((b=r.topTools[0])==null?void 0:b.tool)||"none"})]})]}),r&&Object.keys(r.bySource).length>0&&e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-[var(--text)] mb-3",children:"Actions by Source (24h)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(r.bySource).sort((t,s)=>s[1]-t[1]).map(([t,s])=>e.jsxs("button",{onClick:()=>n(a===t?"":t),className:`px-3 py-1.5 text-xs rounded-md border transition-colors ${a===t?"bg-[var(--accent)] text-white border-[var(--accent)]":u(t)}`,children:[t,": ",s]},t))})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(T,{size:14,className:"text-[var(--text-muted)]"}),e.jsxs("select",{value:a,onChange:t=>n(t.target.value),className:"px-3 py-1.5 text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md text-[var(--text)]",children:[e.jsx("option",{value:"",children:"All Sources"}),y.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsxs("select",{value:l,onChange:t=>x(t.target.value),className:"px-3 py-1.5 text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md text-[var(--text)]",children:[e.jsx("option",{value:"",children:"All Actions"}),w.map(t=>e.jsx("option",{value:t,children:t},t))]}),(a||l)&&e.jsx("button",{onClick:()=>{n(""),x("")},className:"text-xs text-[var(--accent)] hover:underline",children:"Clear"})]}),g?e.jsx("div",{className:"text-[var(--text-muted)] text-sm",children:"Loading audit log..."}):c.length===0?e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-8 text-center",children:[e.jsx(v,{className:"w-10 h-10 text-[var(--text-muted)] mx-auto mb-3"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:"No audit entries found"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Autonomous actions will appear here as TITAN operates."})]}):e.jsx("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg overflow-hidden",children: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-[var(--border)] text-[var(--text-muted)]",children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Time"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Action"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Source"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Tool"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Result"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Detail"})]})}),e.jsx("tbody",{children:c.map((t,s)=>e.jsxs("tr",{className:"border-b border-[var(--border)]/50 last:border-0 hover:bg-[var(--bg-tertiary)] transition-colors",children:[e.jsx("td",{className:"px-4 py-2 text-[var(--text-muted)] whitespace-nowrap",children:N(t.timestamp)}),e.jsx("td",{className:"px-4 py-2 text-[var(--text)] font-medium",children:t.action}),e.jsx("td",{className:"px-4 py-2",children:e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] border ${u(t.source)}`,children:t.source})}),e.jsx("td",{className:"px-4 py-2 text-[var(--text-secondary)] font-mono",children:t.tool||"-"}),e.jsx("td",{className:"px-4 py-2",children:t.result?e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] border ${f(t.result)} ${j(t.result)}`,children:t.result}):"-"}),e.jsx("td",{className:"px-4 py-2 text-[var(--text-muted)] max-w-[200px] truncate",children:t.detail?JSON.stringify(t.detail):"-"})]},s))})]})})})]})}export{E as default};
@@ -1,4 +1,4 @@
1
- import{c as M,r as c,a8 as B,j as e,L as C,i as F,Z as E,a9 as O,t as T,b,f as g,B as q,U as G,G as V,h as I}from"./index-CmaGnHzR.js";import{S as D}from"./save--wCYre_u.js";import{C as H}from"./circle-check-big-DnJPBAGU.js";import{R as U}from"./refresh-cw-BFBnnWj8.js";import{R}from"./rotate-ccw-B9wWlKRc.js";import{R as J}from"./radio-2vniRFTO.js";import{B as Z}from"./bot-DSGZRM5O.js";import{S as W}from"./server-CBsCfofY.js";import{N as K}from"./network-CrQn1GKv.js";import{P as Q}from"./play-DxBy837b.js";import{M as X}from"./message-square-BrWLAovN.js";import{D as Y}from"./TitanCanvas-CqvuuIjd.js";import"./chevron-up-BbDu8x1d.js";import"./plus-DxgNIt8h.js";import"./file-text-CUkSytWL.js";import"./terminal-CZ77Swtc.js";import"./book-open-DRI_Y6cW.js";import"./pencil-DAI6FtFQ.js";import"./search-DOD1aOm8.js";import"./send-Bb57UxT7.js";import"./mic-BXNK4d7X.js";import"./flask-conical-BS4cuENu.js";import"./clock-BS8fh7Rt.js";import"./archive-DWgNklp0.js";import"./test-tube-CkkvIu5j.js";import"./VoiceOverlay-Bl81c4yf.js";import"./chevron-right-DkIMxdwH.js";import"./volume-2-BXwRjeve.js";import"./folder-BDwoUobN.js";import"./check-Cxp-6q4k.js";import"./shield-check-B24N03VU.js";import"./external-link-BfXhMi9L.js";import"./wifi-off-DOm__Zn6.js";/**
1
+ import{c as M,r as c,a8 as B,j as e,L as C,i as F,Z as E,a9 as O,t as T,b,f as g,B as q,U as G,G as V,h as I}from"./index-Dbv5oKsp.js";import{S as D}from"./save-BhGg2pZh.js";import{C as H}from"./circle-check-big-BFw1nom4.js";import{R as U}from"./refresh-cw-Cs4oDMNE.js";import{R}from"./rotate-ccw-DSpsA3Wr.js";import{R as J}from"./radio-BPz7sHXW.js";import{B as Z}from"./bot-C4ICYImG.js";import{S as W}from"./server-B1gIgixS.js";import{N as K}from"./network-Dt-RBtO_.js";import{P as Q}from"./play-CNElkzEq.js";import{M as X}from"./message-square-Cwo5FOho.js";import{D as Y}from"./TitanCanvas-MzLkpZhp.js";import"./chevron-up-B6uSBxbj.js";import"./plus-BnsXhqXc.js";import"./file-text-BtTsNJbB.js";import"./terminal-CubaeYlJ.js";import"./book-open-BgDKDGcH.js";import"./pencil-DAGs9RFs.js";import"./search-BtxlIgqN.js";import"./send-BzKTXI3q.js";import"./mic-BzvwK4IS.js";import"./flask-conical-BaPYppKH.js";import"./clock-DpJIc30t.js";import"./archive-C2_hAJXj.js";import"./test-tube-CYYLfFIz.js";import"./VoiceOverlay-Dj_cR5_Y.js";import"./chevron-right-U0Ujye5i.js";import"./volume-2-C1OkTurz.js";import"./folder-BOnpha2-.js";import"./check-CmCL8yzl.js";import"./shield-check-C39B-Wi3.js";import"./external-link-CX-GvMky.js";import"./wifi-off-DAhvsjnD.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-CmaGnHzR.js";import{P as c}from"./PageHeader-BJ1jHtOy.js";import"./chevron-right-DkIMxdwH.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-Dbv5oKsp.js";import{P as c}from"./PageHeader-Bzb_WXw0.js";import"./chevron-right-U0Ujye5i.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,4 +1,4 @@
1
- import{c as q,r as p,b as T,j as e,a7 as O,V as W}from"./index-CmaGnHzR.js";import{F as A}from"./flask-conical-BS4cuENu.js";import{P as D}from"./play-DxBy837b.js";import{P as B}from"./pause-DS5xgDMT.js";import{R as H}from"./refresh-cw-BFBnnWj8.js";import{T as V}from"./trophy-C-xSgHD2.js";import{T as G}from"./trending-up-B3H8xrGD.js";import{C as U}from"./clock-BS8fh7Rt.js";import{C as J}from"./chevron-right-DkIMxdwH.js";/**
1
+ import{c as q,r as p,b as T,j as e,a7 as O,V as W}from"./index-Dbv5oKsp.js";import{F as A}from"./flask-conical-BaPYppKH.js";import{P as D}from"./play-CNElkzEq.js";import{P as B}from"./pause-Do3XNLtx.js";import{R as H}from"./refresh-cw-Cs4oDMNE.js";import{T as V}from"./trophy-osEOm2Vi.js";import{T as G}from"./trending-up-DXxKT18Q.js";import{C as U}from"./clock-DpJIc30t.js";import{C as J}from"./chevron-right-U0Ujye5i.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 s,aN as p,j as e,aO as u,aP as h}from"./index-CmaGnHzR.js";import{P as g}from"./PageHeader-BJ1jHtOy.js";import{P as b}from"./plus-DxgNIt8h.js";import{R as y}from"./refresh-cw-BFBnnWj8.js";import{A as j}from"./archive-DWgNklp0.js";import{C as v}from"./circle-check-big-DnJPBAGU.js";import"./chevron-right-DkIMxdwH.js";function A(){const[c,m]=s.useState([]),[i,r]=s.useState(!0),[l,n]=s.useState(!1),[d,o]=s.useState(null),t=s.useCallback(async()=>{r(!0);try{const a=await p();m(a.backups||[])}catch{}r(!1)},[]);s.useEffect(()=>{t()},[t]);const x=async()=>{n(!0);try{await u(),await t()}catch{}n(!1)},f=async a=>{o(a);try{await h(a),alert("Backup verified successfully")}catch{alert("Backup verification failed")}o(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:x,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:t,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"]})]}),c.length===0&&!i&&e.jsx("div",{className:"text-sm text-[#52525b]",children:"No backups found."}),e.jsx("div",{className:"space-y-2",children:c.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:()=>f(a.path),disabled:d===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"})," ",d===a.path?"Verifying...":"Verify"]})]},a.path))})]})}export{A as default};
1
+ import{r as s,aN as p,j as e,aO as u,aP as h}from"./index-Dbv5oKsp.js";import{P as g}from"./PageHeader-Bzb_WXw0.js";import{P as b}from"./plus-BnsXhqXc.js";import{R as y}from"./refresh-cw-Cs4oDMNE.js";import{A as j}from"./archive-C2_hAJXj.js";import{C as v}from"./circle-check-big-BFw1nom4.js";import"./chevron-right-U0Ujye5i.js";function A(){const[c,m]=s.useState([]),[i,r]=s.useState(!0),[l,n]=s.useState(!1),[d,o]=s.useState(null),t=s.useCallback(async()=>{r(!0);try{const a=await p();m(a.backups||[])}catch{}r(!1)},[]);s.useEffect(()=>{t()},[t]);const x=async()=>{n(!0);try{await u(),await t()}catch{}n(!1)},f=async a=>{o(a);try{await h(a),alert("Backup verified successfully")}catch{alert("Backup verification failed")}o(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:x,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:t,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"]})]}),c.length===0&&!i&&e.jsx("div",{className:"text-sm text-[#52525b]",children:"No backups found."}),e.jsx("div",{className:"space-y-2",children:c.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:()=>f(a.path),disabled:d===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"})," ",d===a.path?"Verifying...":"Verify"]})]},a.path))})]})}export{A as default};
@@ -1,4 +1,4 @@
1
- import{c as i,r as s,j as e,G as m,aw as p}from"./index-CmaGnHzR.js";import{P as h}from"./PageHeader-BJ1jHtOy.js";import"./chevron-right-DkIMxdwH.js";/**
1
+ import{c as i,r as s,j as e,G as m,aw as p}from"./index-Dbv5oKsp.js";import{P as h}from"./PageHeader-Bzb_WXw0.js";import"./chevron-right-U0Ujye5i.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,x as b,j as e,A as u,Z as j,W as S,K as A,T as E}from"./index-CmaGnHzR.js";import"./Input-Bzh0-cXU.js";import{P as N}from"./PageHeader-BJ1jHtOy.js";import{E as T}from"./EmptyState-iLOrbdU7.js";import{T as C}from"./Tabs-vGpPiBzr.js";import{S as w}from"./SkeletonLoader-IpWkLmoy.js";import{S as P}from"./shield-check-B24N03VU.js";import{D as $}from"./dollar-sign-DMXBeaTj.js";import{B as k}from"./bot-DSGZRM5O.js";import"./clsx-B-dksMZM.js";import"./chevron-right-DkIMxdwH.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:k,goal:E,budget:$,approval:P,error:A,tool:S,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 K(){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 b(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(N,{title:"Activity",subtitle:"Auto-refreshes every 10s",breadcrumbs:[{label:"Command Post"},{label:"Activity"}]}),p.length>0&&e.jsx(C,{tabs:g,activeTab:n,onChange:h}),i&&e.jsx(w,{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,y=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:`${y} 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{K as default};
1
+ import{r as a,x as b,j as e,A as u,Z as j,W as S,K as A,T as E}from"./index-Dbv5oKsp.js";import"./Input-CTK9oH9g.js";import{P as N}from"./PageHeader-Bzb_WXw0.js";import{E as T}from"./EmptyState-B1i1ZK0x.js";import{T as C}from"./Tabs-CC9aTVuL.js";import{S as w}from"./SkeletonLoader-fwI4Z-f0.js";import{S as P}from"./shield-check-C39B-Wi3.js";import{D as $}from"./dollar-sign-DlrOHVzA.js";import{B as k}from"./bot-C4ICYImG.js";import"./clsx-B-dksMZM.js";import"./chevron-right-U0Ujye5i.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:k,goal:E,budget:$,approval:P,error:A,tool:S,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 K(){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 b(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(N,{title:"Activity",subtitle:"Auto-refreshes every 10s",breadcrumbs:[{label:"Command Post"},{label:"Activity"}]}),p.length>0&&e.jsx(C,{tabs:g,activeTab:n,onChange:h}),i&&e.jsx(w,{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,y=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:`${y} 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{K as default};
@@ -1 +1 @@
1
- import{p as O,u as Y,r as s,$ as G,Y as J,y as K,aB as Q,j as e,D as A,be as V}from"./index-CmaGnHzR.js";import{B as T}from"./Input-Bzh0-cXU.js";import{S as c}from"./StatusBadge-e3tFf05B.js";import{P as x}from"./PageHeader-BJ1jHtOy.js";import{E as W}from"./EmptyState-iLOrbdU7.js";import{T as X}from"./Tabs-vGpPiBzr.js";import{S as Z}from"./SkeletonLoader-IpWkLmoy.js";import{A as _}from"./arrow-left-CW5NV7E0.js";import{C as ee}from"./circle-check-big-DnJPBAGU.js";import{D as te}from"./dollar-sign-DMXBeaTj.js";import{C as se}from"./clock-BS8fh7Rt.js";import{S as ae}from"./save--wCYre_u.js";import"./clsx-B-dksMZM.js";import"./chevron-right-DkIMxdwH.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=Y(),[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 G()).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([J(a),K({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(()=>{Q().then(t=>$(t)).catch(()=>{})},[]);const B=async()=>{if(a){C(!0);try{const t=await V(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(X,{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(W,{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{p as O,u as Y,r as s,$ as G,Y as J,y as K,aB as Q,j as e,D as A,be as V}from"./index-Dbv5oKsp.js";import{B as T}from"./Input-CTK9oH9g.js";import{S as c}from"./StatusBadge-NtdTQ8_L.js";import{P as x}from"./PageHeader-Bzb_WXw0.js";import{E as W}from"./EmptyState-B1i1ZK0x.js";import{T as X}from"./Tabs-CC9aTVuL.js";import{S as Z}from"./SkeletonLoader-fwI4Z-f0.js";import{A as _}from"./arrow-left-DFCBXvKS.js";import{C as ee}from"./circle-check-big-BFw1nom4.js";import{D as te}from"./dollar-sign-DlrOHVzA.js";import{C as se}from"./clock-DpJIc30t.js";import{S as ae}from"./save-BhGg2pZh.js";import"./clsx-B-dksMZM.js";import"./chevron-right-U0Ujye5i.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=Y(),[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 G()).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([J(a),K({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(()=>{Q().then(t=>$(t)).catch(()=>{})},[]);const B=async()=>{if(a){C(!0);try{const t=await V(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(X,{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(W,{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,$ as m,j as e,U as p,D as u,X as h,b as j}from"./index-CmaGnHzR.js";import"./Input-Bzh0-cXU.js";import{S as g}from"./StatusBadge-e3tFf05B.js";import{P as f}from"./PageHeader-BJ1jHtOy.js";import{E as b}from"./EmptyState-iLOrbdU7.js";import{S as N}from"./SkeletonLoader-IpWkLmoy.js";import"./clsx-B-dksMZM.js";import"./chevron-right-DkIMxdwH.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 j(`/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(N,{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(b,{icon:e.jsx(p,{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(u,{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(h,{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(g,{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,$ as m,j as e,U as p,D as u,X as h,b as j}from"./index-Dbv5oKsp.js";import"./Input-CTK9oH9g.js";import{S as g}from"./StatusBadge-NtdTQ8_L.js";import{P as f}from"./PageHeader-Bzb_WXw0.js";import{E as b}from"./EmptyState-B1i1ZK0x.js";import{S as N}from"./SkeletonLoader-fwI4Z-f0.js";import"./clsx-B-dksMZM.js";import"./chevron-right-U0Ujye5i.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 j(`/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(N,{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(b,{icon:e.jsx(p,{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(u,{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(h,{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(g,{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 a,J as P,z,j as t,K as B,X as R,O as $,P as _}from"./index-CmaGnHzR.js";import{B as A}from"./Input-Bzh0-cXU.js";import{S as D}from"./StatusBadge-e3tFf05B.js";import{P as M}from"./PageHeader-BJ1jHtOy.js";import{E as L}from"./EmptyState-iLOrbdU7.js";import{T as W}from"./Tabs-vGpPiBzr.js";import{S as F}from"./SkeletonLoader-IpWkLmoy.js";import{e as H}from"./approvalHeadline-DB9SgR-9.js";import{S as I}from"./shield-check-B24N03VU.js";import{C as K}from"./check-Cxp-6q4k.js";import"./clsx-B-dksMZM.js";import"./chevron-right-DkIMxdwH.js";function U(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 q(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 J=[{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}=P(),x=a.useCallback(async()=>{try{const e=await z();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=J.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 ${q(s.urgency)}`,children:[s.urgency==="high"&&t.jsx(B,{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:U(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(K,{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
+ import{r as a,J as P,z,j as t,K as B,X as R,O as $,P as _}from"./index-Dbv5oKsp.js";import{B as A}from"./Input-CTK9oH9g.js";import{S as D}from"./StatusBadge-NtdTQ8_L.js";import{P as M}from"./PageHeader-Bzb_WXw0.js";import{E as L}from"./EmptyState-B1i1ZK0x.js";import{T as W}from"./Tabs-CC9aTVuL.js";import{S as F}from"./SkeletonLoader-fwI4Z-f0.js";import{e as H}from"./approvalHeadline-DB9SgR-9.js";import{S as I}from"./shield-check-C39B-Wi3.js";import{C as K}from"./check-CmCL8yzl.js";import"./clsx-B-dksMZM.js";import"./chevron-right-U0Ujye5i.js";function U(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 q(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 J=[{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}=P(),x=a.useCallback(async()=>{try{const e=await z();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=J.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 ${q(s.urgency)}`,children:[s.urgency==="high"&&t.jsx(B,{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:U(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(K,{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,a2 as F,j as e,a3 as I,a4 as $}from"./index-CmaGnHzR.js";import{B as u}from"./Input-Bzh0-cXU.js";import{S as w}from"./StatusBadge-e3tFf05B.js";import{P as A}from"./PageHeader-BJ1jHtOy.js";import{E as L}from"./EmptyState-iLOrbdU7.js";import{M as W}from"./Modal-nvni-LGR.js";import{S as M}from"./SkeletonLoader-IpWkLmoy.js";import{P as G}from"./plus-DxgNIt8h.js";import{D as H}from"./dollar-sign-DMXBeaTj.js";import{T as R}from"./trash-2-C5KNXS-O.js";import"./clsx-B-dksMZM.js";import"./chevron-right-DkIMxdwH.js";import"./proxy-KYomRnLW.js";function q(r){const l=r.limitUsd>0?r.currentSpend/r.limitUsd*100:0;return l>=100?"exceeded":l>=r.warningThresholdPercent?"warning":"healthy"}function ae(){const[r,l]=s.useState([]),[c,C]=s.useState(!0),[n,m]=s.useState(null),[S,a]=s.useState(!1),[k,g]=s.useState(!1),[o,p]=s.useState(""),[i,P]=s.useState("global"),[h,b]=s.useState(""),[j,B]=s.useState("monthly"),[f,v]=s.useState("10"),[y,z]=s.useState("80"),[N,T]=s.useState("warn"),d=s.useCallback(async()=>{try{const t=await F();l(t),m(null)}catch(t){m(t instanceof Error?t.message:"Failed to load budgets")}C(!1)},[]);s.useEffect(()=>{d()},[d]);const D=async()=>{if(o.trim()){g(!0);try{await $({name:o.trim(),scope:{type:i,targetId:h||void 0},period:j,limitUsd:parseFloat(f)||10,warningThresholdPercent:parseInt(y)||80,action:N,enabled:!0}),a(!1),p(""),b(""),v("10"),await d()}catch{}g(!1)}},E=async t=>{try{await I(t),await d()}catch{}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(A,{title:"Costs & Budgets",breadcrumbs:[{label:"Command Post"},{label:"Costs"}],actions:e.jsx(u,{size:"sm",icon:e.jsx(G,{size:14}),onClick:()=>a(!0),children:"Create Budget"})}),c&&e.jsx(M,{variant:"row",count:4}),n&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:n}),!c&&!n&&r.length===0&&e.jsx(L,{icon:e.jsx(H,{size:32}),title:"No budgets",description:"Create budget policies to control agent spending.",action:{label:"Create Budget",onClick:()=>a(!0)}}),!c&&!n&&r.length>0&&e.jsx("div",{className:"divide-y divide-border rounded-xl border border-border bg-bg-secondary overflow-hidden",children:r.map(t=>{const U=t.limitUsd>0?t.currentSpend/t.limitUsd*100:0,x=q(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(w,{status:x,size:"sm"}),!t.enabled&&e.jsx(w,{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,U)}%`}})})]}),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(R,{size:14})})]},t.id)})}),e.jsx(W,{open:S,onClose:()=>a(!1),title:"Create Budget Policy",footer:e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>a(!1),children:"Cancel"}),e.jsx(u,{size:"sm",onClick:D,loading:k,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=>p(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:i,onChange:t=>P(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:j,onChange:t=>B(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"})]})]})]}),i!=="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:`${i} ID...`,value:h,onChange:t=>b(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:f,onChange:t=>v(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=>z(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:N,onChange:t=>T(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{ae as default};
1
+ import{r as s,a2 as F,j as e,a3 as I,a4 as $}from"./index-Dbv5oKsp.js";import{B as u}from"./Input-CTK9oH9g.js";import{S as w}from"./StatusBadge-NtdTQ8_L.js";import{P as A}from"./PageHeader-Bzb_WXw0.js";import{E as L}from"./EmptyState-B1i1ZK0x.js";import{M as W}from"./Modal-B9KCAwCK.js";import{S as M}from"./SkeletonLoader-fwI4Z-f0.js";import{P as G}from"./plus-BnsXhqXc.js";import{D as H}from"./dollar-sign-DlrOHVzA.js";import{T as R}from"./trash-2-CSxfLiVB.js";import"./clsx-B-dksMZM.js";import"./chevron-right-U0Ujye5i.js";import"./proxy-BXHdgwrk.js";function q(r){const l=r.limitUsd>0?r.currentSpend/r.limitUsd*100:0;return l>=100?"exceeded":l>=r.warningThresholdPercent?"warning":"healthy"}function ae(){const[r,l]=s.useState([]),[c,C]=s.useState(!0),[n,m]=s.useState(null),[S,a]=s.useState(!1),[k,g]=s.useState(!1),[o,p]=s.useState(""),[i,P]=s.useState("global"),[h,b]=s.useState(""),[j,B]=s.useState("monthly"),[f,v]=s.useState("10"),[y,z]=s.useState("80"),[N,T]=s.useState("warn"),d=s.useCallback(async()=>{try{const t=await F();l(t),m(null)}catch(t){m(t instanceof Error?t.message:"Failed to load budgets")}C(!1)},[]);s.useEffect(()=>{d()},[d]);const D=async()=>{if(o.trim()){g(!0);try{await $({name:o.trim(),scope:{type:i,targetId:h||void 0},period:j,limitUsd:parseFloat(f)||10,warningThresholdPercent:parseInt(y)||80,action:N,enabled:!0}),a(!1),p(""),b(""),v("10"),await d()}catch{}g(!1)}},E=async t=>{try{await I(t),await d()}catch{}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(A,{title:"Costs & Budgets",breadcrumbs:[{label:"Command Post"},{label:"Costs"}],actions:e.jsx(u,{size:"sm",icon:e.jsx(G,{size:14}),onClick:()=>a(!0),children:"Create Budget"})}),c&&e.jsx(M,{variant:"row",count:4}),n&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:n}),!c&&!n&&r.length===0&&e.jsx(L,{icon:e.jsx(H,{size:32}),title:"No budgets",description:"Create budget policies to control agent spending.",action:{label:"Create Budget",onClick:()=>a(!0)}}),!c&&!n&&r.length>0&&e.jsx("div",{className:"divide-y divide-border rounded-xl border border-border bg-bg-secondary overflow-hidden",children:r.map(t=>{const U=t.limitUsd>0?t.currentSpend/t.limitUsd*100:0,x=q(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(w,{status:x,size:"sm"}),!t.enabled&&e.jsx(w,{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,U)}%`}})})]}),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(R,{size:14})})]},t.id)})}),e.jsx(W,{open:S,onClose:()=>a(!1),title:"Create Budget Policy",footer:e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>a(!1),children:"Cancel"}),e.jsx(u,{size:"sm",onClick:D,loading:k,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=>p(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:i,onChange:t=>P(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:j,onChange:t=>B(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"})]})]})]}),i!=="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:`${i} ID...`,value:h,onChange:t=>b(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:f,onChange:t=>v(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=>z(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:N,onChange:t=>T(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{ae as default};
@@ -1 +1 @@
1
- import{r as g,j as t,w as ae,x as re,y as ie,z as ne,U as oe,T as ce,A as q,D as X}from"./index-CmaGnHzR.js";import"./Input-Bzh0-cXU.js";import{S as de}from"./StatusBadge-e3tFf05B.js";import{P as J}from"./PageHeader-BJ1jHtOy.js";import{S as xe}from"./SkeletonLoader-IpWkLmoy.js";import{R as me}from"./refresh-cw-BFBnnWj8.js";import{L as K}from"./list-todo-Cm4jNFHV.js";import{D as fe}from"./dollar-sign-DMXBeaTj.js";import"./clsx-B-dksMZM.js";import"./chevron-right-DkIMxdwH.js";const Q={idle:"textSecondary",active:"success",paused:"warning",error:"error",stopped:"borderLight"},he={ceo:"C",manager:"M",engineer:"E",researcher:"R",general:"G"};function ge({agents:x,activity:m}){const v=g.useRef(null),R=g.useRef(x),p=g.useRef(m);return R.current=x,p.current=m,g.useEffect(()=>{const b=v.current;if(!b)return;const e=b.getContext("2d");if(!e)return;const w=window.devicePixelRatio||1;let L,$=0;const A=()=>{const i=document.documentElement,c=getComputedStyle(i),s=(u,j,l)=>{const k=u?c.getPropertyValue(u).trim():"";return k||c.getPropertyValue(j).trim()||l};return{bg:s("--theme-bg-base","--color-bg","#09090b"),bgTertiary:s("--theme-bg-grain","--color-bg-tertiary","#27272a"),border:s("--theme-metal-dark","--color-border","#3f3f46"),borderLight:s("--theme-metal","--color-border-light","#52525b"),textMuted:s("--theme-ink-soft","--color-text-muted","#71717a"),textSecondary:s("--theme-paper-fg","--color-text-secondary","#a1a1aa"),accent:s("--theme-accent","--color-accent","#6366f1"),accentLight:s(null,"--color-accent-light","#a5b4fc"),success:s(null,"--color-success","#22c55e"),warning:s(null,"--color-warning","#f59e0b"),error:s(null,"--color-error","#ef4444")}},M=()=>{const i=b.clientWidth,c=b.clientHeight;b.width=i*w,b.height=c*w,e.setTransform(w,0,0,w,0,0)};M(),window.addEventListener("resize",M);const I=()=>{$++;const i=$/15,c=b.clientWidth,s=b.clientHeight,u=R.current,j=p.current,l=A();e.fillStyle=l.bg,e.fillRect(0,0,c,s),e.strokeStyle="#141418",e.lineWidth=.5;for(let a=0;a<c;a+=24)e.beginPath(),e.moveTo(a,s*.72),e.lineTo(a,s),e.stroke();for(let a=s*.72;a<s;a+=24)e.beginPath(),e.moveTo(0,a),e.lineTo(c,a),e.stroke();if(u.length===0){e.fillStyle=l.bgTertiary,e.font="12px -apple-system, BlinkMacSystemFont, sans-serif",e.textAlign="center",e.fillText("No agents registered",c/2,s/2-10),e.font="10px -apple-system, BlinkMacSystemFont, sans-serif",e.fillStyle=l.border,e.fillText("Spawn agents to see them here",c/2,s/2+10),e.textAlign="start",L=requestAnimationFrame(I);return}const k=Math.min(u.length,8),D=Math.min(120,(c-20)/k),ee=(c-D*k)/2+D/2;for(let a=0;a<k;a++){const P=u[a],r=ee+a*D,n=s*.55,f=P.status==="active"?"active":P.status,z=l[Q[f]||Q.idle],o=Math.sin(i*.8+a*1.5)*1.5,F=j.some(d=>d.agentId===P.id&&Date.now()-new Date(d.timestamp).getTime()<3e4),E=Math.min(70,D-10),T=10,B=r-E/2,S=n+16;e.fillStyle=l.border,e.fillRect(B,S,E,T),e.fillStyle=l.borderLight,e.fillRect(B+1,S+1,E-2,T-2),e.fillStyle=l.border,e.fillRect(B+3,S+T,3,14),e.fillRect(B+E-6,S+T,3,14);const H=26,O=18,V=r-H/2,U=S-O;e.fillStyle=l.bgTertiary,e.fillRect(V,U,H,O);const Y=f==="error"?l.error:f==="active"?l.success:l.accent;if(e.fillStyle=Y+"30",e.fillRect(V+2,U+2,H-4,O-4),f==="active"||F){e.fillStyle=Y+"60";const d=2+Math.floor(i%3);for(let h=0;h<d;h++){const C=6+Math.sin(i*2+h+a)*5;e.fillRect(V+3,U+3+h*4,C,1.5)}}e.fillStyle=l.border,e.fillRect(r-2,S-1,4,3),e.fillStyle="#1e1e22",e.fillRect(r-10,n+10+o,20,8),e.fillRect(r-11,n-2+o,3,20),e.fillStyle=l.border,e.fillRect(r-7,n+o,14,12);const y=f==="active"&&F?Math.sin(i*1.5+a)*1.5:0;e.fillStyle=l.borderLight,e.fillRect(r-6,n-10+o+y,12,10);const G=Math.sin(i*.3+a*2)>.95?1:2;if(e.fillStyle=z,f==="stopped"?(e.fillRect(r-4,n-7+o+y,2,1),e.fillRect(r-3,n-6+o+y,2,1),e.fillRect(r+1,n-7+o+y,2,1),e.fillRect(r+2,n-6+o+y,2,1)):(e.fillRect(r-4,n-7+o+y,2,G),e.fillRect(r+2,n-7+o+y,2,G)),e.fillStyle=l.borderLight,e.fillRect(r-1,n-14+o+y,2,4),e.fillStyle=z,e.beginPath(),e.arc(r,n-15+o+y,2,0,Math.PI*2),e.fill(),f==="active"&&(e.globalAlpha=.3+Math.sin(i*3+a)*.2,e.beginPath(),e.arc(r,n-15+o+y,5,0,Math.PI*2),e.fill(),e.globalAlpha=1),f==="active"&&F){const d=Math.sin(i*6+a)*2,h=Math.sin(i*6+a+Math.PI)*2;e.fillStyle=l.border,e.fillRect(r-11,n+3+o+d,4,3),e.fillRect(r+7,n+3+o+h,4,3)}else e.fillStyle=l.border,e.fillRect(r-10,n+5+o,3,6),e.fillRect(r+7,n+5+o,3,6);if(f==="active"&&F){for(let d=0;d<2;d++){const h=i*1.5+d*Math.PI+a,C=14+Math.sin(i+d)*4,se=r+Math.cos(h)*C,le=n-3+Math.sin(h)*C*.4+o;e.globalAlpha=.25+Math.sin(i*2+d)*.15,e.fillStyle=z,e.beginPath(),e.arc(se,le,1,0,Math.PI*2),e.fill()}e.globalAlpha=1}if(f==="error"){for(let d=0;d<3;d++){const h=r+Math.sin(i*4+d*2)*12,C=n-5+Math.cos(i*3+d)*8+o;e.globalAlpha=.4+Math.sin(i+d)*.3,e.fillStyle=l.error,e.fillRect(h-1,C-1,2,2)}e.globalAlpha=1}e.fillStyle=f==="stopped"?l.border:l.textMuted,e.font="9px -apple-system, BlinkMacSystemFont, sans-serif",e.textAlign="center";const _=Math.max(44,E+14);let N=P.name;if(e.measureText(N).width>_){for(;N.length>1&&e.measureText(N+"…").width>_;)N=N.slice(0,-1);N=N.trimEnd()+"…"}e.fillText(N,r,S+T+24);const te=he[P.role]||"G";e.fillStyle=z+"60",e.font="bold 7px -apple-system, BlinkMacSystemFont, sans-serif",e.fillText(te,r,S+T+33),e.textAlign="start"}if(e.fillStyle=l.bgTertiary,e.font="bold 9px -apple-system, BlinkMacSystemFont, sans-serif",e.textAlign="center",e.fillText("COMMAND POST",c/2,s-6),e.textAlign="start",j.length>0){const a=j[j.length-1];if(Date.now()-new Date(a.timestamp).getTime()<6e4){e.fillStyle=l.accent+"40",e.fillRect(0,0,c,16),e.fillStyle=l.accentLight,e.font="8px -apple-system, BlinkMacSystemFont, sans-serif";const r=a.message.length>60?a.message.slice(0,57)+"...":a.message;e.textAlign="center",e.fillText(r,c/2,11),e.textAlign="start"}}L=requestAnimationFrame(I)};return I(),()=>{cancelAnimationFrame(L),window.removeEventListener("resize",M)}},[]),t.jsx("canvas",{ref:v,className:"w-full rounded-xl border border-border",style:{height:220,imageRendering:"pixelated"}})}function Z(x){const m=Math.floor((Date.now()-new Date(x).getTime())/1e3);return m<60?`${m}s`:m<3600?`${Math.floor(m/60)}m`:m<86400?`${Math.floor(m/3600)}h`:`${Math.floor(m/86400)}d`}function W({icon:x,label:m,value:v,sub:R,color:p}){return t.jsxs("div",{className:"bg-bg-tertiary/50 border border-border rounded-xl p-4",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(x,{size:14,className:p}),t.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:m})]}),t.jsx("div",{className:"text-2xl font-bold text-text",children:v}),R&&t.jsx("div",{className:"text-[11px] text-text-muted mt-1",children:R})]})}function Ae(){var c;const[x,m]=g.useState(null),[v,R]=g.useState([]),[p,b]=g.useState([]),[e,w]=g.useState(0),[L,$]=g.useState(!0),A=g.useCallback(async()=>{try{const[s,u,j,l]=await Promise.all([ae(),re(20),ie(),ne("pending")]);m(s),R(u),b(j),w(l.length)}catch{}$(!1)},[]);if(g.useEffect(()=>{A();const s=setInterval(A,15e3);return()=>clearInterval(s)},[A]),L)return t.jsxs("div",{className:"space-y-6",children:[t.jsx(J,{title:"Dashboard",breadcrumbs:[{label:"Command Post"},{label:"Dashboard"}]}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:t.jsx(xe,{variant:"metric",count:4})})]});if(!x)return t.jsx("div",{className:"text-center py-12 text-text-muted",children:"Failed to load dashboard"});const M=x.budgetUtilization??0,I=p.filter(s=>s.status==="in_progress").length,i=p.filter(s=>s.status==="blocked").length;return t.jsxs("div",{className:"space-y-6",children:[t.jsx(J,{title:"Dashboard",breadcrumbs:[{label:"Command Post"},{label:"Dashboard"}],actions:t.jsx("button",{onClick:A,className:"p-1.5 text-text-muted hover:text-text rounded-lg hover:bg-bg-tertiary transition-colors",children:t.jsx(me,{size:16})})}),t.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[t.jsx(W,{icon:oe,label:"Agents Enabled",value:x.totalAgents,sub:`${x.activeAgents} running, ${Math.max(0,x.totalAgents-x.activeAgents)} paused`,color:"text-info"}),t.jsx(W,{icon:K,label:"Tasks In Progress",value:I,sub:`${p.length} open, ${i} blocked`,color:"text-warning"}),t.jsx(W,{icon:fe,label:"Budget Used",value:`${Math.round(M)}%`,sub:M>=80?"Nearing limit":"Healthy",color:M>=80?"text-error":"text-success"}),t.jsx(W,{icon:ce,label:"Goals",value:((c=x.goalTree)==null?void 0:c.length)??0,sub:"in hierarchy",color:"text-purple"})]}),x.agents.length>0&&t.jsx(ge,{agents:x.agents,activity:v}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(q,{size:14,className:"text-accent"}),t.jsx("h3",{className:"text-sm font-semibold text-text",children:"Recent Activity"})]}),t.jsx(X,{to:"/command-post/activity",className:"text-[10px] text-accent hover:text-accent-hover",children:"View all"})]}),t.jsx("div",{className:"max-h-72 overflow-y-auto divide-y divide-border",children:v.length===0?t.jsx("div",{className:"py-8 text-center text-xs text-text-muted",children:"No activity yet"}):[...v].reverse().slice(0,15).map((s,u)=>t.jsxs("div",{className:"flex items-start gap-2 px-4 py-2",children:[t.jsx(q,{size:12,className:"text-text-muted mt-0.5 flex-shrink-0"}),t.jsx("span",{className:"text-[11px] text-text-secondary flex-1",children:s.message}),t.jsx("span",{className:"text-[10px] text-text-muted flex-shrink-0",children:Z(s.timestamp)})]},`${s.timestamp}-${u}`))})]}),t.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(K,{size:14,className:"text-accent"}),t.jsx("h3",{className:"text-sm font-semibold text-text",children:"Recent Issues"})]}),t.jsx(X,{to:"/command-post/issues",className:"text-[10px] text-accent hover:text-accent-hover",children:"View all"})]}),t.jsx("div",{className:"max-h-72 overflow-y-auto divide-y divide-border",children:p.length===0?t.jsx("div",{className:"py-8 text-center text-xs text-text-muted",children:"No issues yet"}):p.slice(0,10).map(s=>t.jsxs(X,{to:`/command-post/issues/${s.id}`,className:"flex items-center gap-2 px-4 py-2 hover:bg-bg-tertiary transition-colors",children:[t.jsx(de,{status:s.status,variant:"dot",size:"sm"}),t.jsx("span",{className:"text-[11px] text-text-secondary flex-1 truncate",children:s.title}),s.assigneeAgentId&&t.jsx("span",{className:"text-[10px] text-text-muted",children:s.assigneeAgentId}),t.jsx("span",{className:"text-[10px] text-text-muted flex-shrink-0",children:Z(s.updatedAt)})]},s.id))})]})]})]})}export{Ae as default};
1
+ import{r as g,j as t,w as ae,x as re,y as ie,z as ne,U as oe,T as ce,A as q,D as X}from"./index-Dbv5oKsp.js";import"./Input-CTK9oH9g.js";import{S as de}from"./StatusBadge-NtdTQ8_L.js";import{P as J}from"./PageHeader-Bzb_WXw0.js";import{S as xe}from"./SkeletonLoader-fwI4Z-f0.js";import{R as me}from"./refresh-cw-Cs4oDMNE.js";import{L as K}from"./list-todo-qdMNm4-Q.js";import{D as fe}from"./dollar-sign-DlrOHVzA.js";import"./clsx-B-dksMZM.js";import"./chevron-right-U0Ujye5i.js";const Q={idle:"textSecondary",active:"success",paused:"warning",error:"error",stopped:"borderLight"},he={ceo:"C",manager:"M",engineer:"E",researcher:"R",general:"G"};function ge({agents:x,activity:m}){const v=g.useRef(null),R=g.useRef(x),p=g.useRef(m);return R.current=x,p.current=m,g.useEffect(()=>{const b=v.current;if(!b)return;const e=b.getContext("2d");if(!e)return;const w=window.devicePixelRatio||1;let L,$=0;const A=()=>{const i=document.documentElement,c=getComputedStyle(i),s=(u,j,l)=>{const k=u?c.getPropertyValue(u).trim():"";return k||c.getPropertyValue(j).trim()||l};return{bg:s("--theme-bg-base","--color-bg","#09090b"),bgTertiary:s("--theme-bg-grain","--color-bg-tertiary","#27272a"),border:s("--theme-metal-dark","--color-border","#3f3f46"),borderLight:s("--theme-metal","--color-border-light","#52525b"),textMuted:s("--theme-ink-soft","--color-text-muted","#71717a"),textSecondary:s("--theme-paper-fg","--color-text-secondary","#a1a1aa"),accent:s("--theme-accent","--color-accent","#6366f1"),accentLight:s(null,"--color-accent-light","#a5b4fc"),success:s(null,"--color-success","#22c55e"),warning:s(null,"--color-warning","#f59e0b"),error:s(null,"--color-error","#ef4444")}},M=()=>{const i=b.clientWidth,c=b.clientHeight;b.width=i*w,b.height=c*w,e.setTransform(w,0,0,w,0,0)};M(),window.addEventListener("resize",M);const I=()=>{$++;const i=$/15,c=b.clientWidth,s=b.clientHeight,u=R.current,j=p.current,l=A();e.fillStyle=l.bg,e.fillRect(0,0,c,s),e.strokeStyle="#141418",e.lineWidth=.5;for(let a=0;a<c;a+=24)e.beginPath(),e.moveTo(a,s*.72),e.lineTo(a,s),e.stroke();for(let a=s*.72;a<s;a+=24)e.beginPath(),e.moveTo(0,a),e.lineTo(c,a),e.stroke();if(u.length===0){e.fillStyle=l.bgTertiary,e.font="12px -apple-system, BlinkMacSystemFont, sans-serif",e.textAlign="center",e.fillText("No agents registered",c/2,s/2-10),e.font="10px -apple-system, BlinkMacSystemFont, sans-serif",e.fillStyle=l.border,e.fillText("Spawn agents to see them here",c/2,s/2+10),e.textAlign="start",L=requestAnimationFrame(I);return}const k=Math.min(u.length,8),D=Math.min(120,(c-20)/k),ee=(c-D*k)/2+D/2;for(let a=0;a<k;a++){const P=u[a],r=ee+a*D,n=s*.55,f=P.status==="active"?"active":P.status,z=l[Q[f]||Q.idle],o=Math.sin(i*.8+a*1.5)*1.5,F=j.some(d=>d.agentId===P.id&&Date.now()-new Date(d.timestamp).getTime()<3e4),E=Math.min(70,D-10),T=10,B=r-E/2,S=n+16;e.fillStyle=l.border,e.fillRect(B,S,E,T),e.fillStyle=l.borderLight,e.fillRect(B+1,S+1,E-2,T-2),e.fillStyle=l.border,e.fillRect(B+3,S+T,3,14),e.fillRect(B+E-6,S+T,3,14);const H=26,O=18,V=r-H/2,U=S-O;e.fillStyle=l.bgTertiary,e.fillRect(V,U,H,O);const Y=f==="error"?l.error:f==="active"?l.success:l.accent;if(e.fillStyle=Y+"30",e.fillRect(V+2,U+2,H-4,O-4),f==="active"||F){e.fillStyle=Y+"60";const d=2+Math.floor(i%3);for(let h=0;h<d;h++){const C=6+Math.sin(i*2+h+a)*5;e.fillRect(V+3,U+3+h*4,C,1.5)}}e.fillStyle=l.border,e.fillRect(r-2,S-1,4,3),e.fillStyle="#1e1e22",e.fillRect(r-10,n+10+o,20,8),e.fillRect(r-11,n-2+o,3,20),e.fillStyle=l.border,e.fillRect(r-7,n+o,14,12);const y=f==="active"&&F?Math.sin(i*1.5+a)*1.5:0;e.fillStyle=l.borderLight,e.fillRect(r-6,n-10+o+y,12,10);const G=Math.sin(i*.3+a*2)>.95?1:2;if(e.fillStyle=z,f==="stopped"?(e.fillRect(r-4,n-7+o+y,2,1),e.fillRect(r-3,n-6+o+y,2,1),e.fillRect(r+1,n-7+o+y,2,1),e.fillRect(r+2,n-6+o+y,2,1)):(e.fillRect(r-4,n-7+o+y,2,G),e.fillRect(r+2,n-7+o+y,2,G)),e.fillStyle=l.borderLight,e.fillRect(r-1,n-14+o+y,2,4),e.fillStyle=z,e.beginPath(),e.arc(r,n-15+o+y,2,0,Math.PI*2),e.fill(),f==="active"&&(e.globalAlpha=.3+Math.sin(i*3+a)*.2,e.beginPath(),e.arc(r,n-15+o+y,5,0,Math.PI*2),e.fill(),e.globalAlpha=1),f==="active"&&F){const d=Math.sin(i*6+a)*2,h=Math.sin(i*6+a+Math.PI)*2;e.fillStyle=l.border,e.fillRect(r-11,n+3+o+d,4,3),e.fillRect(r+7,n+3+o+h,4,3)}else e.fillStyle=l.border,e.fillRect(r-10,n+5+o,3,6),e.fillRect(r+7,n+5+o,3,6);if(f==="active"&&F){for(let d=0;d<2;d++){const h=i*1.5+d*Math.PI+a,C=14+Math.sin(i+d)*4,se=r+Math.cos(h)*C,le=n-3+Math.sin(h)*C*.4+o;e.globalAlpha=.25+Math.sin(i*2+d)*.15,e.fillStyle=z,e.beginPath(),e.arc(se,le,1,0,Math.PI*2),e.fill()}e.globalAlpha=1}if(f==="error"){for(let d=0;d<3;d++){const h=r+Math.sin(i*4+d*2)*12,C=n-5+Math.cos(i*3+d)*8+o;e.globalAlpha=.4+Math.sin(i+d)*.3,e.fillStyle=l.error,e.fillRect(h-1,C-1,2,2)}e.globalAlpha=1}e.fillStyle=f==="stopped"?l.border:l.textMuted,e.font="9px -apple-system, BlinkMacSystemFont, sans-serif",e.textAlign="center";const _=Math.max(44,E+14);let N=P.name;if(e.measureText(N).width>_){for(;N.length>1&&e.measureText(N+"…").width>_;)N=N.slice(0,-1);N=N.trimEnd()+"…"}e.fillText(N,r,S+T+24);const te=he[P.role]||"G";e.fillStyle=z+"60",e.font="bold 7px -apple-system, BlinkMacSystemFont, sans-serif",e.fillText(te,r,S+T+33),e.textAlign="start"}if(e.fillStyle=l.bgTertiary,e.font="bold 9px -apple-system, BlinkMacSystemFont, sans-serif",e.textAlign="center",e.fillText("COMMAND POST",c/2,s-6),e.textAlign="start",j.length>0){const a=j[j.length-1];if(Date.now()-new Date(a.timestamp).getTime()<6e4){e.fillStyle=l.accent+"40",e.fillRect(0,0,c,16),e.fillStyle=l.accentLight,e.font="8px -apple-system, BlinkMacSystemFont, sans-serif";const r=a.message.length>60?a.message.slice(0,57)+"...":a.message;e.textAlign="center",e.fillText(r,c/2,11),e.textAlign="start"}}L=requestAnimationFrame(I)};return I(),()=>{cancelAnimationFrame(L),window.removeEventListener("resize",M)}},[]),t.jsx("canvas",{ref:v,className:"w-full rounded-xl border border-border",style:{height:220,imageRendering:"pixelated"}})}function Z(x){const m=Math.floor((Date.now()-new Date(x).getTime())/1e3);return m<60?`${m}s`:m<3600?`${Math.floor(m/60)}m`:m<86400?`${Math.floor(m/3600)}h`:`${Math.floor(m/86400)}d`}function W({icon:x,label:m,value:v,sub:R,color:p}){return t.jsxs("div",{className:"bg-bg-tertiary/50 border border-border rounded-xl p-4",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(x,{size:14,className:p}),t.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:m})]}),t.jsx("div",{className:"text-2xl font-bold text-text",children:v}),R&&t.jsx("div",{className:"text-[11px] text-text-muted mt-1",children:R})]})}function Ae(){var c;const[x,m]=g.useState(null),[v,R]=g.useState([]),[p,b]=g.useState([]),[e,w]=g.useState(0),[L,$]=g.useState(!0),A=g.useCallback(async()=>{try{const[s,u,j,l]=await Promise.all([ae(),re(20),ie(),ne("pending")]);m(s),R(u),b(j),w(l.length)}catch{}$(!1)},[]);if(g.useEffect(()=>{A();const s=setInterval(A,15e3);return()=>clearInterval(s)},[A]),L)return t.jsxs("div",{className:"space-y-6",children:[t.jsx(J,{title:"Dashboard",breadcrumbs:[{label:"Command Post"},{label:"Dashboard"}]}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:t.jsx(xe,{variant:"metric",count:4})})]});if(!x)return t.jsx("div",{className:"text-center py-12 text-text-muted",children:"Failed to load dashboard"});const M=x.budgetUtilization??0,I=p.filter(s=>s.status==="in_progress").length,i=p.filter(s=>s.status==="blocked").length;return t.jsxs("div",{className:"space-y-6",children:[t.jsx(J,{title:"Dashboard",breadcrumbs:[{label:"Command Post"},{label:"Dashboard"}],actions:t.jsx("button",{onClick:A,className:"p-1.5 text-text-muted hover:text-text rounded-lg hover:bg-bg-tertiary transition-colors",children:t.jsx(me,{size:16})})}),t.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[t.jsx(W,{icon:oe,label:"Agents Enabled",value:x.totalAgents,sub:`${x.activeAgents} running, ${Math.max(0,x.totalAgents-x.activeAgents)} paused`,color:"text-info"}),t.jsx(W,{icon:K,label:"Tasks In Progress",value:I,sub:`${p.length} open, ${i} blocked`,color:"text-warning"}),t.jsx(W,{icon:fe,label:"Budget Used",value:`${Math.round(M)}%`,sub:M>=80?"Nearing limit":"Healthy",color:M>=80?"text-error":"text-success"}),t.jsx(W,{icon:ce,label:"Goals",value:((c=x.goalTree)==null?void 0:c.length)??0,sub:"in hierarchy",color:"text-purple"})]}),x.agents.length>0&&t.jsx(ge,{agents:x.agents,activity:v}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(q,{size:14,className:"text-accent"}),t.jsx("h3",{className:"text-sm font-semibold text-text",children:"Recent Activity"})]}),t.jsx(X,{to:"/command-post/activity",className:"text-[10px] text-accent hover:text-accent-hover",children:"View all"})]}),t.jsx("div",{className:"max-h-72 overflow-y-auto divide-y divide-border",children:v.length===0?t.jsx("div",{className:"py-8 text-center text-xs text-text-muted",children:"No activity yet"}):[...v].reverse().slice(0,15).map((s,u)=>t.jsxs("div",{className:"flex items-start gap-2 px-4 py-2",children:[t.jsx(q,{size:12,className:"text-text-muted mt-0.5 flex-shrink-0"}),t.jsx("span",{className:"text-[11px] text-text-secondary flex-1",children:s.message}),t.jsx("span",{className:"text-[10px] text-text-muted flex-shrink-0",children:Z(s.timestamp)})]},`${s.timestamp}-${u}`))})]}),t.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(K,{size:14,className:"text-accent"}),t.jsx("h3",{className:"text-sm font-semibold text-text",children:"Recent Issues"})]}),t.jsx(X,{to:"/command-post/issues",className:"text-[10px] text-accent hover:text-accent-hover",children:"View all"})]}),t.jsx("div",{className:"max-h-72 overflow-y-auto divide-y divide-border",children:p.length===0?t.jsx("div",{className:"py-8 text-center text-xs text-text-muted",children:"No issues yet"}):p.slice(0,10).map(s=>t.jsxs(X,{to:`/command-post/issues/${s.id}`,className:"flex items-center gap-2 px-4 py-2 hover:bg-bg-tertiary transition-colors",children:[t.jsx(de,{status:s.status,variant:"dot",size:"sm"}),t.jsx("span",{className:"text-[11px] text-text-secondary flex-1 truncate",children:s.title}),s.assigneeAgentId&&t.jsx("span",{className:"text-[10px] text-text-muted",children:s.assigneeAgentId}),t.jsx("span",{className:"text-[10px] text-text-muted flex-shrink-0",children:Z(s.updatedAt)})]},s.id))})]})]})]})}export{Ae as default};