@agenthippo-ai/agenthippo 1.110.11 → 1.110.20

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 (534) hide show
  1. package/out/agentpack/types.js +2 -5
  2. package/out/analytics/dashboard/artifactManager.js +2 -439
  3. package/out/analytics/dashboard/fleetDisplayUtils.js +2 -162
  4. package/out/analytics/dashboard/fleetOrchestrator.js +3 -142
  5. package/out/analytics/dashboard/fleetRegistry.js +2 -79
  6. package/out/analytics/dashboard/fleetRowDefaults.js +2 -87
  7. package/out/analytics/dashboard/fleetScriptAdapter.js +2 -146
  8. package/out/analytics/dashboard/fleetTypes.js +2 -29
  9. package/out/analytics/dashboard/index.js +2 -17
  10. package/out/analytics/dashboard/indexingService.js +2 -422
  11. package/out/analytics/dashboard/localFleetAdapter.js +2 -302
  12. package/out/analytics/dashboard/performanceMonitor.js +5 -76
  13. package/out/analytics/dashboard/processManager.js +2 -209
  14. package/out/analytics/dashboard/provider.js +38 -3817
  15. package/out/analytics/dashboard/queryRunner.js +62 -750
  16. package/out/analytics/dashboard/scheduledFleetStorage.js +2 -241
  17. package/out/analytics/dashboard/sessionJsonlFleet.js +3 -204
  18. package/out/analytics/dashboard/teamViewDiscovery.js +2 -106
  19. package/out/analytics/dashboard/webview/panel.js +34 -2318
  20. package/out/analytics/dashboard/webview/runtime-bridge.js +2 -82
  21. package/out/analytics/lifecycle.js +2 -43
  22. package/out/analytics/service.js +8 -1283
  23. package/out/auth/authBaseUrl.js +2 -59
  24. package/out/auth/bootstrapApply.js +2 -71
  25. package/out/auth/brokerClient.js +2 -160
  26. package/out/auth/callbackUri.js +2 -59
  27. package/out/auth/githubStoreGate.js +2 -70
  28. package/out/auth/loopbackAuthServer.js +4 -159
  29. package/out/auth/onboardingPrompt.js +2 -112
  30. package/out/auth/pkce.js +2 -9
  31. package/out/auth/provider.js +2 -226
  32. package/out/auth/sessionStore.js +2 -156
  33. package/out/auth/signInFlow.js +2 -183
  34. package/out/cli/index.js +618 -564
  35. package/out/cli/run-custom-engine-runner.js +3 -318
  36. package/out/cli/vscode-shim.js +2 -86
  37. package/out/engines/factory.js +2 -45
  38. package/out/engines/types.js +2 -17
  39. package/out/examples/run-headless-repl.js +6 -286
  40. package/out/examples/run-headless.js +2 -187
  41. package/out/extension.js +32 -4473
  42. package/out/gateway/gatewayRouteIndex.js +6 -371
  43. package/out/gateway/gatewaySessionStore.js +3 -243
  44. package/out/gateway/index.js +2 -31
  45. package/out/gateway/resetMappings.js +2 -52
  46. package/out/gateway/service.js +5 -1249
  47. package/out/mcp/publish.js +2 -143
  48. package/out/remote/handleRemoteChat.js +2 -169
  49. package/out/remote/remotePackStatusBar.js +3 -103
  50. package/out/remote/remoteTrust.js +6 -277
  51. package/out/remote/serveClient.js +4 -277
  52. package/out/remoteSkills.js +3 -191
  53. package/out/runtime/index.js +2 -32
  54. package/out/runtime/vscode/index.js +2 -20
  55. package/out/runtime/vscode/vscode-config-provider.js +2 -77
  56. package/out/runtime/vscode/vscode-edit-tracker.js +2 -122
  57. package/out/runtime/vscode/vscode-logger.js +2 -30
  58. package/out/runtime/vscode/vscode-permission-handler.js +2 -72
  59. package/out/scripts/agentide-litellm.sh +0 -1
  60. package/out/scripts/agentide_litellm_hooks_v1.py +127 -459
  61. package/out/scripts/analytics/agent-fleet-widget.js +18 -257
  62. package/out/scripts/analytics/agentide-litellm-otel.config.yaml +0 -4
  63. package/out/scripts/analytics/duckdbLocator.js +2 -28
  64. package/out/scripts/analytics/generate-default-charts.py +43 -323
  65. package/out/scripts/analytics/hotspot-analysis-widget.js +4 -430
  66. package/out/scripts/analytics/index-traces.py +78 -1036
  67. package/out/scripts/analytics/session-comparison-widget.js +26 -472
  68. package/out/scripts/analytics/session-timeline-widget.js +25 -846
  69. package/out/scripts/analytics/token-cost-flamegraph-widget.js +4 -461
  70. package/out/scripts/analytics/token-cost-trend-widget.js +4 -534
  71. package/out/scripts/analytics/workflows-collector.cjs +4 -314
  72. package/out/scripts/analytics/workflows-daemon.mjs +9 -185
  73. package/out/scripts/analytics/workflows-widget.cjs +15 -159
  74. package/out/scripts/analytics/wow-model-widget.js +10 -120
  75. package/out/scripts/vendor-tools.mjs +2 -233
  76. package/out/skills/publish.js +3 -178
  77. package/out/store/github/setup.js +7 -212
  78. package/out/store/oramaIndex.js +2 -884
  79. package/out/sync.js +26 -1829
  80. package/out/terminalLogger.js +5 -358
  81. package/out/utils/pathSafety.js +2 -60
  82. package/out/utils/pythonRunner.js +4 -258
  83. package/out/utils/toolPath.js +2 -83
  84. package/out/workspaceFolders.js +2 -59
  85. package/package.json +10 -6
  86. package/out/agentpack/github.js +0 -547
  87. package/out/agentpack/index.js +0 -69
  88. package/out/agentpack/install.js +0 -297
  89. package/out/agentpack/manager.js +0 -441
  90. package/out/agentpack/manifest.js +0 -135
  91. package/out/agentpack/paths.js +0 -521
  92. package/out/agentpack/publish.js +0 -248
  93. package/out/agentpack/stores.js +0 -554
  94. package/out/analytics/dashboard/fleetStatusUtils.js +0 -30
  95. package/out/analytics/dashboard/fleetTitleUtils.js +0 -68
  96. package/out/analytics/dashboard/refreshPolicy.js +0 -16
  97. package/out/analytics/dashboard/scheduledFleetFingerprint.js +0 -22
  98. package/out/analytics/dashboard/scheduledFleetUtils.js +0 -22
  99. package/out/analytics/dashboard/sessionEventFleetStats.js +0 -118
  100. package/out/analytics/dashboard/viewsConfigMerge.js +0 -221
  101. package/out/analytics/dashboard/webview/codicon.ttf +0 -0
  102. package/out/analytics/identity.js +0 -0
  103. package/out/analytics/sessionEvents.js +0 -324
  104. package/out/auth/callbackUriParse.js +0 -59
  105. package/out/auth/types.js +0 -12
  106. package/out/auth-broker/config.js +0 -112
  107. package/out/auth-broker/jwt.js +0 -105
  108. package/out/auth-broker/pkce.js +0 -59
  109. package/out/auth-broker/server.js +0 -681
  110. package/out/auth-broker/store.js +0 -275
  111. package/out/authority/warrant.js +0 -206
  112. package/out/base-prompts/mcp-servers/.mcp.json +0 -13
  113. package/out/base-prompts/mcp-servers/langfuse-analytics/README.md +0 -142
  114. package/out/base-prompts/mcp-servers/langfuse-analytics/mcp.json +0 -13
  115. package/out/base-prompts/mcp-servers/langfuse-analytics/package-lock.json +0 -1192
  116. package/out/base-prompts/mcp-servers/langfuse-analytics/package.json +0 -23
  117. package/out/base-prompts/mcp-servers/langfuse-analytics/scripts/run-with-env.sh +0 -12
  118. package/out/base-prompts/mcp-servers/langfuse-analytics/scripts/sdk-test.js +0 -102
  119. package/out/base-prompts/mcp-servers/langfuse-analytics/scripts/simple-test.js +0 -137
  120. package/out/base-prompts/mcp-servers/langfuse-analytics/scripts/test-client.js +0 -118
  121. package/out/base-prompts/mcp-servers/langfuse-analytics/scripts/test-server.js +0 -209
  122. package/out/base-prompts/mcp-servers/langfuse-analytics/src/client.ts +0 -431
  123. package/out/base-prompts/mcp-servers/langfuse-analytics/src/index.ts +0 -270
  124. package/out/base-prompts/mcp-servers/langfuse-analytics/tsconfig.json +0 -18
  125. package/out/base-prompts/rules/AGENTS.md +0 -204
  126. package/out/base-prompts/skills/agent-browser/SKILL.md +0 -102
  127. package/out/base-prompts/skills/agent-builder/SKILL.md +0 -73
  128. package/out/base-prompts/skills/agent-builder/references/agent-pack.md +0 -63
  129. package/out/base-prompts/skills/agent-builder/references/crewai.md +0 -66
  130. package/out/base-prompts/skills/agent-builder/references/langchain.md +0 -60
  131. package/out/base-prompts/skills/agent-builder/references/raw-sdk.md +0 -73
  132. package/out/base-prompts/skills/agent-engine-creator/SKILL.md +0 -586
  133. package/out/base-prompts/skills/agent-engine-installer/SKILL.md +0 -106
  134. package/out/base-prompts/skills/agent-engine-installer/scripts/install-engine.mjs +0 -259
  135. package/out/base-prompts/skills/agent-engine-installer/scripts/install-engine.ps1 +0 -189
  136. package/out/base-prompts/skills/agenthippo-cli/SKILL.md +0 -69
  137. package/out/base-prompts/skills/agenthippo-cli/scripts/install.sh +0 -63
  138. package/out/base-prompts/skills/agentpack-creator/SKILL.md +0 -375
  139. package/out/base-prompts/skills/agentpack-creator/references/agent-templates.md +0 -261
  140. package/out/base-prompts/skills/agentpack-creator/references/agents-md-guide.md +0 -195
  141. package/out/base-prompts/skills/agentpack-creator/scripts/init_pack.py +0 -391
  142. package/out/base-prompts/skills/agentpack-creator/scripts/init_pack_test.py +0 -294
  143. package/out/base-prompts/skills/agentpack-testbench/SKILL.md +0 -135
  144. package/out/base-prompts/skills/algorithmic-art/LICENSE.txt +0 -202
  145. package/out/base-prompts/skills/algorithmic-art/SKILL.md +0 -405
  146. package/out/base-prompts/skills/algorithmic-art/templates/generator_template.js +0 -223
  147. package/out/base-prompts/skills/algorithmic-art/templates/viewer.html +0 -599
  148. package/out/base-prompts/skills/debug-agent/SKILL.md +0 -83
  149. package/out/base-prompts/skills/desktop-automation/SKILL.md +0 -166
  150. package/out/base-prompts/skills/desktop-automation/references/agenthippo-ui-recipes.md +0 -441
  151. package/out/base-prompts/skills/desktop-automation/scripts/windows-desktop-uia.psm1 +0 -280
  152. package/out/base-prompts/skills/docx/LICENSE.txt +0 -30
  153. package/out/base-prompts/skills/docx/SKILL.md +0 -197
  154. package/out/base-prompts/skills/docx/docx-js.md +0 -350
  155. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +0 -1499
  156. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +0 -146
  157. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +0 -1085
  158. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +0 -11
  159. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +0 -3081
  160. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +0 -23
  161. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +0 -185
  162. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +0 -287
  163. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +0 -1676
  164. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +0 -28
  165. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +0 -144
  166. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +0 -174
  167. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +0 -25
  168. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +0 -18
  169. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +0 -59
  170. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +0 -56
  171. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +0 -195
  172. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +0 -582
  173. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +0 -25
  174. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +0 -4439
  175. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +0 -570
  176. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +0 -509
  177. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +0 -12
  178. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +0 -108
  179. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +0 -96
  180. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +0 -3646
  181. package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +0 -116
  182. package/out/base-prompts/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +0 -42
  183. package/out/base-prompts/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +0 -50
  184. package/out/base-prompts/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +0 -49
  185. package/out/base-prompts/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +0 -33
  186. package/out/base-prompts/skills/docx/ooxml/schemas/mce/mc.xsd +0 -75
  187. package/out/base-prompts/skills/docx/ooxml/schemas/microsoft/wml-2010.xsd +0 -560
  188. package/out/base-prompts/skills/docx/ooxml/schemas/microsoft/wml-2012.xsd +0 -67
  189. package/out/base-prompts/skills/docx/ooxml/schemas/microsoft/wml-2018.xsd +0 -14
  190. package/out/base-prompts/skills/docx/ooxml/schemas/microsoft/wml-cex-2018.xsd +0 -20
  191. package/out/base-prompts/skills/docx/ooxml/schemas/microsoft/wml-cid-2016.xsd +0 -13
  192. package/out/base-prompts/skills/docx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +0 -4
  193. package/out/base-prompts/skills/docx/ooxml/schemas/microsoft/wml-symex-2015.xsd +0 -8
  194. package/out/base-prompts/skills/docx/ooxml/scripts/pack.py +0 -159
  195. package/out/base-prompts/skills/docx/ooxml/scripts/unpack.py +0 -29
  196. package/out/base-prompts/skills/docx/ooxml/scripts/validate.py +0 -69
  197. package/out/base-prompts/skills/docx/ooxml/scripts/validation/__init__.py +0 -15
  198. package/out/base-prompts/skills/docx/ooxml/scripts/validation/base.py +0 -951
  199. package/out/base-prompts/skills/docx/ooxml/scripts/validation/docx.py +0 -274
  200. package/out/base-prompts/skills/docx/ooxml/scripts/validation/pptx.py +0 -315
  201. package/out/base-prompts/skills/docx/ooxml/scripts/validation/redlining.py +0 -279
  202. package/out/base-prompts/skills/docx/ooxml.md +0 -610
  203. package/out/base-prompts/skills/docx/scripts/__init__.py +0 -1
  204. package/out/base-prompts/skills/docx/scripts/document.py +0 -1276
  205. package/out/base-prompts/skills/docx/scripts/templates/comments.xml +0 -3
  206. package/out/base-prompts/skills/docx/scripts/templates/commentsExtended.xml +0 -3
  207. package/out/base-prompts/skills/docx/scripts/templates/commentsExtensible.xml +0 -3
  208. package/out/base-prompts/skills/docx/scripts/templates/commentsIds.xml +0 -3
  209. package/out/base-prompts/skills/docx/scripts/templates/people.xml +0 -3
  210. package/out/base-prompts/skills/docx/scripts/utilities.py +0 -374
  211. package/out/base-prompts/skills/gateway-outbound/SKILL.md +0 -136
  212. package/out/base-prompts/skills/mcp-builder/LICENSE.txt +0 -202
  213. package/out/base-prompts/skills/mcp-builder/SKILL.md +0 -328
  214. package/out/base-prompts/skills/mcp-builder/reference/evaluation.md +0 -602
  215. package/out/base-prompts/skills/mcp-builder/reference/mcp_best_practices.md +0 -249
  216. package/out/base-prompts/skills/mcp-builder/reference/node_mcp_server.md +0 -970
  217. package/out/base-prompts/skills/mcp-builder/reference/python_mcp_server.md +0 -719
  218. package/out/base-prompts/skills/mcp-builder/scripts/connections.py +0 -151
  219. package/out/base-prompts/skills/mcp-builder/scripts/evaluation.py +0 -373
  220. package/out/base-prompts/skills/mcp-builder/scripts/example_evaluation.xml +0 -22
  221. package/out/base-prompts/skills/mcp-builder/scripts/requirements.txt +0 -2
  222. package/out/base-prompts/skills/openclaw/SKILL.md +0 -406
  223. package/out/base-prompts/skills/openclaw/scripts/run-smoke.sh +0 -61
  224. package/out/base-prompts/skills/pdf/LICENSE.txt +0 -30
  225. package/out/base-prompts/skills/pdf/SKILL.md +0 -294
  226. package/out/base-prompts/skills/pdf/forms.md +0 -205
  227. package/out/base-prompts/skills/pdf/reference.md +0 -612
  228. package/out/base-prompts/skills/pdf/scripts/check_bounding_boxes.py +0 -70
  229. package/out/base-prompts/skills/pdf/scripts/check_bounding_boxes_test.py +0 -226
  230. package/out/base-prompts/skills/pdf/scripts/check_fillable_fields.py +0 -12
  231. package/out/base-prompts/skills/pdf/scripts/convert_pdf_to_images.py +0 -35
  232. package/out/base-prompts/skills/pdf/scripts/create_validation_image.py +0 -41
  233. package/out/base-prompts/skills/pdf/scripts/extract_form_field_info.py +0 -152
  234. package/out/base-prompts/skills/pdf/scripts/fill_fillable_fields.py +0 -114
  235. package/out/base-prompts/skills/pdf/scripts/fill_pdf_form_with_annotations.py +0 -108
  236. package/out/base-prompts/skills/pptx/LICENSE.txt +0 -30
  237. package/out/base-prompts/skills/pptx/SKILL.md +0 -484
  238. package/out/base-prompts/skills/pptx/html2pptx.md +0 -625
  239. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +0 -1499
  240. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +0 -146
  241. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +0 -1085
  242. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +0 -11
  243. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +0 -3081
  244. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +0 -23
  245. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +0 -185
  246. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +0 -287
  247. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +0 -1676
  248. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +0 -28
  249. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +0 -144
  250. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +0 -174
  251. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +0 -25
  252. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +0 -18
  253. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +0 -59
  254. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +0 -56
  255. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +0 -195
  256. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +0 -582
  257. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +0 -25
  258. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +0 -4439
  259. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +0 -570
  260. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +0 -509
  261. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +0 -12
  262. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +0 -108
  263. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +0 -96
  264. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +0 -3646
  265. package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +0 -116
  266. package/out/base-prompts/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +0 -42
  267. package/out/base-prompts/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +0 -50
  268. package/out/base-prompts/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +0 -49
  269. package/out/base-prompts/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +0 -33
  270. package/out/base-prompts/skills/pptx/ooxml/schemas/mce/mc.xsd +0 -75
  271. package/out/base-prompts/skills/pptx/ooxml/schemas/microsoft/wml-2010.xsd +0 -560
  272. package/out/base-prompts/skills/pptx/ooxml/schemas/microsoft/wml-2012.xsd +0 -67
  273. package/out/base-prompts/skills/pptx/ooxml/schemas/microsoft/wml-2018.xsd +0 -14
  274. package/out/base-prompts/skills/pptx/ooxml/schemas/microsoft/wml-cex-2018.xsd +0 -20
  275. package/out/base-prompts/skills/pptx/ooxml/schemas/microsoft/wml-cid-2016.xsd +0 -13
  276. package/out/base-prompts/skills/pptx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +0 -4
  277. package/out/base-prompts/skills/pptx/ooxml/schemas/microsoft/wml-symex-2015.xsd +0 -8
  278. package/out/base-prompts/skills/pptx/ooxml/scripts/pack.py +0 -159
  279. package/out/base-prompts/skills/pptx/ooxml/scripts/unpack.py +0 -29
  280. package/out/base-prompts/skills/pptx/ooxml/scripts/validate.py +0 -69
  281. package/out/base-prompts/skills/pptx/ooxml/scripts/validation/__init__.py +0 -15
  282. package/out/base-prompts/skills/pptx/ooxml/scripts/validation/base.py +0 -951
  283. package/out/base-prompts/skills/pptx/ooxml/scripts/validation/docx.py +0 -274
  284. package/out/base-prompts/skills/pptx/ooxml/scripts/validation/pptx.py +0 -315
  285. package/out/base-prompts/skills/pptx/ooxml/scripts/validation/redlining.py +0 -279
  286. package/out/base-prompts/skills/pptx/ooxml.md +0 -427
  287. package/out/base-prompts/skills/pptx/scripts/html2pptx.js +0 -984
  288. package/out/base-prompts/skills/pptx/scripts/inventory.py +0 -1020
  289. package/out/base-prompts/skills/pptx/scripts/rearrange.py +0 -231
  290. package/out/base-prompts/skills/pptx/scripts/replace.py +0 -385
  291. package/out/base-prompts/skills/pptx/scripts/thumbnail.py +0 -450
  292. package/out/base-prompts/skills/prompt-lab/SKILL.md +0 -149
  293. package/out/base-prompts/skills/prompt-lab/scripts/query-analytics.sh +0 -2551
  294. package/out/base-prompts/skills/skill-creator/LICENSE.txt +0 -202
  295. package/out/base-prompts/skills/skill-creator/SKILL.md +0 -371
  296. package/out/base-prompts/skills/skill-creator/references/output-patterns.md +0 -82
  297. package/out/base-prompts/skills/skill-creator/references/workflows.md +0 -28
  298. package/out/base-prompts/skills/skill-creator/scripts/init_skill.py +0 -303
  299. package/out/base-prompts/skills/skill-creator/scripts/package_skill.py +0 -110
  300. package/out/base-prompts/skills/skill-creator/scripts/quick_validate.py +0 -95
  301. package/out/base-prompts/skills/skill-installer/SKILL.md +0 -251
  302. package/out/base-prompts/skills/skill-installer/references/store-api.md +0 -219
  303. package/out/base-prompts/skills/spotlight-dashboard/SKILL.md +0 -83
  304. package/out/base-prompts/skills/spotlight-insights/SKILL.md +0 -101
  305. package/out/base-prompts/skills/spotlight-optimize/SKILL.md +0 -93
  306. package/out/base-prompts/skills/spotlight-optimize/scripts/query-analytics.sh +0 -2551
  307. package/out/base-prompts/skills/spotlight-query/SKILL.md +0 -314
  308. package/out/base-prompts/skills/spotlight-query/references/otel-schema.md +0 -163
  309. package/out/base-prompts/skills/spotlight-query/scripts/query-analytics.sh +0 -2551
  310. package/out/base-prompts/skills/spotlight-query/scripts/query-analytics.test.sh +0 -744
  311. package/out/base-prompts/skills/spotlight-query/scripts/test-fixtures/analytics/sessions/sess-test-1.jsonl +0 -14
  312. package/out/base-prompts/skills/spotlight-query/scripts/test-fixtures/analytics/traces/.duckdb-index.json +0 -7
  313. package/out/base-prompts/skills/spotlight-query/scripts/test-fixtures/analytics/traces/sample.jsonl +0 -5
  314. package/out/base-prompts/skills/spotlight-report/SKILL.md +0 -86
  315. package/out/base-prompts/skills/spotlight-visualize/SKILL.md +0 -92
  316. package/out/base-prompts/skills/spotlight-visualize/scripts/query-analytics.sh +0 -2551
  317. package/out/base-prompts/skills/xlsx/LICENSE.txt +0 -30
  318. package/out/base-prompts/skills/xlsx/SKILL.md +0 -289
  319. package/out/base-prompts/skills/xlsx/recalc.py +0 -178
  320. package/out/branding.js +0 -49
  321. package/out/cli/commands/anywhere.js +0 -66
  322. package/out/cli/commands/ask.js +0 -246
  323. package/out/cli/commands/auth-broker.js +0 -24
  324. package/out/cli/commands/auth.js +0 -219
  325. package/out/cli/commands/chat.js +0 -357
  326. package/out/cli/commands/conformance.js +0 -249
  327. package/out/cli/commands/data-plane.js +0 -151
  328. package/out/cli/commands/deploy.js +0 -263
  329. package/out/cli/commands/gateway.js +0 -218
  330. package/out/cli/commands/idp.js +0 -85
  331. package/out/cli/commands/pack.js +0 -399
  332. package/out/cli/commands/probe-custom-engine.js +0 -82
  333. package/out/cli/commands/sandbox.js +0 -351
  334. package/out/cli/commands/serve.js +0 -1950
  335. package/out/cli/commands/store.js +0 -927
  336. package/out/cli/credential-context.js +0 -108
  337. package/out/cli/data-plane/broker.js +0 -78
  338. package/out/cli/data-plane/connector-host.js +0 -121
  339. package/out/cli/data-plane/egress.js +0 -189
  340. package/out/cli/data-plane/gateway.js +0 -218
  341. package/out/cli/data-plane/index.js +0 -153
  342. package/out/cli/data-plane/registry.js +0 -89
  343. package/out/cli/data-plane/remote.js +0 -106
  344. package/out/cli/data-plane/sidecar.js +0 -225
  345. package/out/cli/deploy/blueprints/registry.js +0 -84
  346. package/out/cli/deploy/layers/identity.js +0 -175
  347. package/out/cli/deploy-init.js +0 -3023
  348. package/out/cli/deps.js +0 -342
  349. package/out/cli/idp-init.js +0 -338
  350. package/out/cli/pack-install-ref.js +0 -15
  351. package/out/cli/pack-loader.js +0 -418
  352. package/out/cli/pack-runtime.js +0 -61
  353. package/out/cli/runtime.js +0 -450
  354. package/out/cli/serve-hardening.js +0 -776
  355. package/out/cli/state-sync.js +0 -424
  356. package/out/cli/utils.js +0 -231
  357. package/out/engines/base.js +0 -188
  358. package/out/engines/claude.js +0 -1254
  359. package/out/engines/codex.js +0 -862
  360. package/out/engines/custom.js +0 -680
  361. package/out/engines/customEngineIpc.js +0 -95
  362. package/out/engines/customEngineRunnerEmbed.js +0 -107
  363. package/out/engines/customRegistry.js +0 -274
  364. package/out/engines/embeddedCustomEngineRunner.generated.js +0 -9
  365. package/out/engines/engineApiKey.js +0 -138
  366. package/out/engines/install.js +0 -372
  367. package/out/engines/persistentEngineWorker.js +0 -320
  368. package/out/engines/publish.js +0 -341
  369. package/out/evidence/sessionShip.js +0 -643
  370. package/out/gateway/bridge.js +0 -843
  371. package/out/gateway/cli-agent-id.js +0 -36
  372. package/out/gateway/client.js +0 -336
  373. package/out/gateway/client.test.js +0 -395
  374. package/out/gateway/gateway-scope-errors.js +0 -14
  375. package/out/gateway/gatewayBackup.js +0 -76
  376. package/out/gateway/installSource.js +0 -68
  377. package/out/gateway/lifecycle.js +0 -3190
  378. package/out/gateway/openclaw-channel-routing.js +0 -317
  379. package/out/gateway/outboundHandles.js +0 -373
  380. package/out/gateway/outboundPaths.js +0 -75
  381. package/out/gateway/outboundSend.js +0 -254
  382. package/out/gateway/protocol.js +0 -48
  383. package/out/gateway/secretsPreflight.js +0 -90
  384. package/out/gateway/sessionRouting.js +0 -77
  385. package/out/headless/index.js +0 -546
  386. package/out/headless/sync.js +0 -473
  387. package/out/live-e2e/mcp-demo/server.mjs +0 -32
  388. package/out/live-probe/connector.mjs +0 -8
  389. package/out/live-probe/env-report.mjs +0 -8
  390. package/out/mcp.js +0 -654
  391. package/out/pack/caps.js +0 -271
  392. package/out/pack/governor.js +0 -326
  393. package/out/pack/lease-schema.js +0 -273
  394. package/out/pack/lease.js +0 -682
  395. package/out/pack/reconcile.js +0 -217
  396. package/out/pack/signature.js +0 -839
  397. package/out/permissions.js +0 -108
  398. package/out/permissions.mapping.yaml +0 -68
  399. package/out/registry/index.js +0 -332
  400. package/out/runner/host.js +0 -141
  401. package/out/runner/protocol.js +0 -128
  402. package/out/runner/remoteEngine.js +0 -166
  403. package/out/runtime/interfaces/config-provider.js +0 -32
  404. package/out/runtime/interfaces/edit-tracker.js +0 -24
  405. package/out/runtime/interfaces/index.js +0 -29
  406. package/out/runtime/interfaces/logger.js +0 -40
  407. package/out/runtime/interfaces/permission-handler.js +0 -66
  408. package/out/runtime/interfaces/session-store.js +0 -342
  409. package/out/runtime/vscode/vscode-session-store.js +0 -22
  410. package/out/sandbox/containerDriver.js +0 -572
  411. package/out/sandbox/processDriver.js +0 -318
  412. package/out/sandbox/sandboxRunner.js +0 -303
  413. package/out/sandbox/support.js +0 -301
  414. package/out/sandbox/types.js +0 -55
  415. package/out/scripts/analytics/fleet-local-adapter.js +0 -246
  416. package/out/scripts/analytics/live-fleet-4-collector.cjs +0 -315
  417. package/out/scripts/analytics/live-fleet-4-daemon.mjs +0 -134
  418. package/out/scripts/analytics/live-fleet-4-widget.cjs +0 -433
  419. package/out/scripts/gateway/Dockerfile.serve +0 -45
  420. package/out/scripts/gateway/docker-serve.sh +0 -248
  421. package/out/scripts/gateway/setup-gateway-server.ps1 +0 -953
  422. package/out/scripts/gateway/setup-gateway-server.sh +0 -935
  423. package/out/session.js +0 -272
  424. package/out/shared/agentEngines.js +0 -170
  425. package/out/shared/index.js +0 -109
  426. package/out/shared/models.js +0 -136
  427. package/out/shared/providers.js +0 -205
  428. package/out/spotlight/install.js +0 -345
  429. package/out/spotlight/publish.js +0 -544
  430. package/out/spotlight/yaml.js +0 -31
  431. package/out/store/index.js +0 -786
  432. package/out/store/shared.js +0 -241
  433. package/out/test/agentEnvFile.test.js +0 -97
  434. package/out/test/agentYaml.test.js +0 -373
  435. package/out/test/agentpack.test.js +0 -639
  436. package/out/test/analytics-lifecycle.test.js +0 -174
  437. package/out/test/analytics.test.js +0 -756
  438. package/out/test/auth-baseurl.test.js +0 -132
  439. package/out/test/auth-bootstrapApply.test.js +0 -123
  440. package/out/test/auth-broker-hardening.test.js +0 -227
  441. package/out/test/auth-broker.test.js +0 -541
  442. package/out/test/auth-callback.test.js +0 -62
  443. package/out/test/blueprint-registry.test.js +0 -105
  444. package/out/test/branding.test.js +0 -242
  445. package/out/test/caps-governor.test.js +0 -460
  446. package/out/test/cli-agent-id.test.js +0 -55
  447. package/out/test/codex-new-file-survival.test.js +0 -119
  448. package/out/test/configuration-scopes.test.js +0 -131
  449. package/out/test/credential-context.test.js +0 -160
  450. package/out/test/custom-env-layering.test.js +0 -151
  451. package/out/test/customEngineInstall.test.js +0 -100
  452. package/out/test/customRegistry.test.js +0 -122
  453. package/out/test/data-plane-engine-wiring.test.js +0 -282
  454. package/out/test/data-plane.test.js +0 -624
  455. package/out/test/deploy-init.test.js +0 -860
  456. package/out/test/deps-auto-install.test.js +0 -81
  457. package/out/test/egress-broker.test.js +0 -172
  458. package/out/test/engine-integration.test.js +0 -297
  459. package/out/test/enginePaths.test.js +0 -195
  460. package/out/test/enginePublish.test.js +0 -82
  461. package/out/test/fleetDisplayUtils.test.js +0 -100
  462. package/out/test/gateway-client.test.js +0 -409
  463. package/out/test/gateway-install-source.test.js +0 -111
  464. package/out/test/gateway-lifecycle.test.js +0 -608
  465. package/out/test/gateway-outbound.test.js +0 -538
  466. package/out/test/gateway-reset-mappings.test.js +0 -221
  467. package/out/test/gateway-route-index.test.js +0 -235
  468. package/out/test/gateway-secrets-preflight.test.js +0 -127
  469. package/out/test/gateway-session-routing.test.js +0 -65
  470. package/out/test/gateway-session-store.test.js +0 -216
  471. package/out/test/github.test.js +0 -232
  472. package/out/test/governor-hardening.test.js +0 -222
  473. package/out/test/headless-sync.test.js +0 -301
  474. package/out/test/helpers/manifest-fixtures.js +0 -27
  475. package/out/test/idp-init.test.js +0 -151
  476. package/out/test/lease-signature.test.js +0 -357
  477. package/out/test/lease-trust-root.test.js +0 -273
  478. package/out/test/lease-validation.test.js +0 -224
  479. package/out/test/lease.test.js +0 -114
  480. package/out/test/localFleetAdapter.test.js +0 -91
  481. package/out/test/mcp-obo.test.js +0 -107
  482. package/out/test/mcp.test.js +0 -389
  483. package/out/test/model-routing.test.js +0 -133
  484. package/out/test/openclaw-channel-routing.test.js +0 -191
  485. package/out/test/pack-admission.test.js +0 -216
  486. package/out/test/pack-digest-parity.test.js +0 -140
  487. package/out/test/pack-reconcile.test.js +0 -183
  488. package/out/test/pack-signature-artifact.test.js +0 -103
  489. package/out/test/pack-signature.test.js +0 -176
  490. package/out/test/pack-trust-root.test.js +0 -202
  491. package/out/test/pathSafety.test.js +0 -63
  492. package/out/test/permissions.test.js +0 -175
  493. package/out/test/persistent-engine-worker.test.js +0 -220
  494. package/out/test/refreshPolicy.test.js +0 -60
  495. package/out/test/registry.test.js +0 -351
  496. package/out/test/remote-trust.test.js +0 -242
  497. package/out/test/runner-protocol.test.js +0 -249
  498. package/out/test/runtime.test.js +0 -349
  499. package/out/test/sandbox-driver.test.js +0 -553
  500. package/out/test/sandbox-hardening.test.js +0 -406
  501. package/out/test/sandbox-runner.test.js +0 -343
  502. package/out/test/sandbox-scope.test.js +0 -449
  503. package/out/test/scheduledFleetStorage.test.js +0 -72
  504. package/out/test/serve-cron-acceptance.test.js +0 -370
  505. package/out/test/serve-gateway-turn.test.js +0 -389
  506. package/out/test/serve-hardening.test.js +0 -591
  507. package/out/test/serveClient.test.js +0 -209
  508. package/out/test/sessionJsonlFleet.test.js +0 -78
  509. package/out/test/sessionShip.test.js +0 -618
  510. package/out/test/shared.test.js +0 -173
  511. package/out/test/skills-mcp.test.js +0 -299
  512. package/out/test/spotlightPublish.test.js +0 -327
  513. package/out/test/spotlightYaml.test.js +0 -58
  514. package/out/test/state-sync-peer.test.js +0 -156
  515. package/out/test/store-install-safe.test.js +0 -69
  516. package/out/test/store.test.js +0 -331
  517. package/out/test/stores.test.js +0 -504
  518. package/out/test/sync-switch.test.js +0 -251
  519. package/out/test/teamViewDiscovery.test.js +0 -90
  520. package/out/test/tls-bypass.test.js +0 -90
  521. package/out/test/toolPath.test.js +0 -120
  522. package/out/test/utils.test.js +0 -308
  523. package/out/test/viewsConfigMerge.test.js +0 -180
  524. package/out/test/warrant.test.js +0 -138
  525. package/out/test/windows-command-line.test.js +0 -75
  526. package/out/utils/agentEnvFile.js +0 -131
  527. package/out/utils/binary.js +0 -175
  528. package/out/utils/index.js +0 -37
  529. package/out/utils/network.js +0 -74
  530. package/out/utils/paths.js +0 -116
  531. package/out/utils/pid.js +0 -180
  532. package/out/utils/resolveNodeBinary.js +0 -168
  533. package/out/utils/windowsCommandLine.js +0 -29
  534. package/out/utils.js +0 -968
@@ -1,379 +1,18 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) AgentHippo.ai. All rights reserved.
4
- *--------------------------------------------------------------------------------------------*/
5
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = { enumerable: true, get: function() { return m[k]; } };
10
- }
11
- Object.defineProperty(o, k2, desc);
12
- }) : (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- o[k2] = m[k];
15
- }));
16
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
- Object.defineProperty(o, "default", { enumerable: true, value: v });
18
- }) : function(o, v) {
19
- o["default"] = v;
20
- });
21
- var __importStar = (this && this.__importStar) || (function () {
22
- var ownKeys = function(o) {
23
- ownKeys = Object.getOwnPropertyNames || function (o) {
24
- var ar = [];
25
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
- return ar;
27
- };
28
- return ownKeys(o);
29
- };
30
- return function (mod) {
31
- if (mod && mod.__esModule) return mod;
32
- var result = {};
33
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
- __setModuleDefault(result, mod);
35
- return result;
36
- };
37
- })();
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.QueryRunnerImpl = exports.QueryRunnerError = void 0;
40
- const vscode = __importStar(require("vscode"));
41
- const path = __importStar(require("path"));
42
- const fs_1 = require("fs");
43
- const child_process_1 = require("child_process");
44
- const util_1 = require("util");
45
- const index_1 = require("../../utils/index");
46
- const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
47
- class QueryRunnerError extends Error {
48
- code;
49
- constructor(message, code) {
50
- super(message);
51
- this.code = code;
52
- this.name = 'QueryRunnerError';
53
- }
54
- }
55
- exports.QueryRunnerError = QueryRunnerError;
56
- // -----------------------------------------------------------------------------
57
- // Implementation
58
- // -----------------------------------------------------------------------------
59
- const CACHE_TTL = 30_000;
60
- const INDEXED_DB_FILENAME = 'analytics.duckdb';
61
- const INDEXED_DB_REQUIRED_TABLE = 'spans';
62
- const INDEXED_DB_REQUIRED_COLUMNS = ['trace_id', 'start_ms', 'duration_ms', 'cost', 'model', 'session_id', 'project_id', 'agent_id'];
63
- const DEFAULT_DUCKDB_MEMORY_LIMIT_MB = 1024;
64
- const DEFAULT_DUCKDB_THREADS = 2;
65
- const DEFAULT_DUCKDB_QUERY_TIMEOUT_SECONDS = 30;
66
- const DEFAULT_DUCKDB_MAX_RESULT_ROWS = 5000;
67
- const MIN_DUCKDB_MEMORY_MB = 64;
68
- const MIN_DUCKDB_THREADS = 1;
69
- const MIN_DUCKDB_TIMEOUT_SECONDS = 5;
70
- const MIN_DUCKDB_MAX_RESULT_ROWS = 100;
71
- const MAX_DUCKDB_MAX_RESULT_ROWS = 100_000;
72
- const DEFAULT_DUCKDB_TEMP_DIRECTORY = path.join((0, index_1.getAgentideHome)(), 'analytics', 'tmp', 'duckdb');
73
- const FLEET_SESSIONS_TABLE = 'fleet_sessions';
74
- class QueryRunnerImpl {
75
- outputChannel;
76
- cache = new Map();
77
- duckdbPath;
78
- indexedDbPath;
79
- schemaValidated = false;
80
- fleetSchemaReady = false;
81
- fleetSchemaEnsurePromise;
82
- activeDuckDbQueries = 0;
83
- duckDbQueryWaiters = [];
84
- maxDuckDbConcurrentQueries = 1;
85
- lastLoggedRuntimeProfile;
86
- analyticsConfig;
87
- tracesDir = path.join((0, index_1.getAgentideHome)(), 'analytics', 'traces');
88
- constructor(outputChannel) {
89
- this.outputChannel = outputChannel;
90
- }
91
- async ensureDuckDB() {
92
- if (this.duckdbPath) {
93
- return this.duckdbPath;
94
- }
95
- const candidates = process.platform === 'win32'
96
- ? ['duckdb', 'duckdb.exe', path.join((0, index_1.getAgentideHome)(), 'bin', 'duckdb.exe'), path.join((0, index_1.getAgentideHome)(), 'bin', 'duckdb')]
97
- : ['duckdb', path.join((0, index_1.getAgentideHome)(), 'bin', 'duckdb'), '/opt/homebrew/bin/duckdb', '/usr/local/bin/duckdb', '/usr/bin/duckdb'];
98
- for (const candidate of candidates) {
99
- try {
100
- await execFileAsync(candidate, ['--version'], { timeout: 5000 });
101
- this.duckdbPath = candidate;
102
- this.outputChannel.appendLine(`[QueryRunner] Using DuckDB at: ${candidate}`);
103
- return candidate;
104
- }
105
- catch {
106
- // continue
107
- }
108
- }
109
- const installHint = process.platform === 'win32'
110
- ? 'Run Setup Spotlight first (it installs ~/.agent-hippo/bin/duckdb.exe)'
111
- : 'Run Setup Spotlight first or install with: brew install duckdb';
112
- throw new QueryRunnerError(`DuckDB not found. ${installHint}`, 'DUCKDB_NOT_FOUND');
113
- }
114
- getIndexedDbPath() {
115
- return path.join(this.tracesDir, INDEXED_DB_FILENAME);
116
- }
117
- getAnalyticsConfig() {
118
- if (this.analyticsConfig) {
119
- return this.analyticsConfig;
120
- }
121
- const config = vscode.workspace.getConfiguration('agentide.analytics');
122
- const memoryLimitMb = Math.max(MIN_DUCKDB_MEMORY_MB, Number(config.get('duckdb.memoryLimitMb', DEFAULT_DUCKDB_MEMORY_LIMIT_MB)) || DEFAULT_DUCKDB_MEMORY_LIMIT_MB);
123
- const threads = Math.max(MIN_DUCKDB_THREADS, Number(config.get('duckdb.threads', DEFAULT_DUCKDB_THREADS)) || DEFAULT_DUCKDB_THREADS);
124
- const timeoutSeconds = Math.max(MIN_DUCKDB_TIMEOUT_SECONDS, Number(config.get('duckdb.queryTimeoutSeconds', DEFAULT_DUCKDB_QUERY_TIMEOUT_SECONDS)) || DEFAULT_DUCKDB_QUERY_TIMEOUT_SECONDS);
125
- const maxResultRows = Math.max(MIN_DUCKDB_MAX_RESULT_ROWS, Math.min(MAX_DUCKDB_MAX_RESULT_ROWS, Number(config.get('duckdb.maxResultRows', DEFAULT_DUCKDB_MAX_RESULT_ROWS)) || DEFAULT_DUCKDB_MAX_RESULT_ROWS));
126
- const tempDirectory = (config.get('duckdb.tempDirectory', '') || '').trim() || DEFAULT_DUCKDB_TEMP_DIRECTORY;
127
- this.analyticsConfig = { memoryLimitMb, threads, queryTimeoutMs: timeoutSeconds * 1000, maxResultRows, tempDirectory };
128
- return this.analyticsConfig;
129
- }
130
- sqlLiteral(value) {
131
- return '\'' + value.replace(/'/g, '\'\'') + '\'';
132
- }
133
- normalizeFilters(filters) {
134
- const scope = filters?.scope === 'workspace' ? 'workspace' : 'global';
135
- const projectId = filters?.projectId?.trim() || undefined;
136
- const agentId = filters?.agentId?.trim() || undefined;
137
- return { scope, projectId, agentId };
138
- }
139
- buildTraceFilterConditions(filters, alias) {
140
- const normalized = this.normalizeFilters(filters);
141
- const prefix = alias ? `${alias}.` : '';
142
- const conditions = [];
143
- if (normalized.scope === 'workspace') {
144
- if (!normalized.projectId) {
145
- conditions.push('1 = 0');
146
- }
147
- else {
148
- conditions.push(`(${prefix}project_id = ${this.sqlLiteral(normalized.projectId)} OR ${prefix}project_id IS NULL)`);
149
- }
150
- }
151
- if (normalized.agentId) {
152
- conditions.push(`${prefix}agent_id = ${this.sqlLiteral(normalized.agentId)}`);
153
- }
154
- return conditions;
155
- }
156
- buildFilterCacheKey(filters) {
157
- const normalized = this.normalizeFilters(filters);
158
- return `${normalized.scope}|${normalized.projectId ?? ''}|${normalized.agentId ?? ''}`;
159
- }
160
- buildRuntimeSettingsSql() {
161
- const cfg = this.getAnalyticsConfig();
162
- const lines = [`SET memory_limit='${cfg.memoryLimitMb}MB';`, `SET threads=${cfg.threads};`, 'SET preserve_insertion_order=false;'];
163
- if (cfg.tempDirectory) {
164
- lines.push(`SET temp_directory=${this.sqlLiteral(cfg.tempDirectory)};`);
165
- }
166
- return lines.join('\n');
167
- }
168
- logRuntimeProfileOnce() {
169
- const cfg = this.getAnalyticsConfig();
170
- const profile = `${cfg.memoryLimitMb}|${cfg.threads}|${cfg.queryTimeoutMs}|${cfg.maxResultRows}|${cfg.tempDirectory}`;
171
- if (this.lastLoggedRuntimeProfile === profile) {
172
- return;
173
- }
174
- this.lastLoggedRuntimeProfile = profile;
175
- this.outputChannel.appendLine(`[QueryRunner] DuckDB runtime profile: memory=${cfg.memoryLimitMb}MB threads=${cfg.threads} timeoutMs=${cfg.queryTimeoutMs} maxRows=${cfg.maxResultRows} tempDir=${cfg.tempDirectory}`);
176
- }
177
- async ensureIndexedDbReady(duckdb) {
178
- if (this.indexedDbPath && this.schemaValidated) {
179
- return this.indexedDbPath;
180
- }
181
- const dbPath = this.getIndexedDbPath();
182
- try {
183
- await fs_1.promises.access(dbPath, fs_1.constants.R_OK);
184
- }
185
- catch {
186
- throw new QueryRunnerError(`Indexed analytics DB not found at ${dbPath}. Run Setup Spotlight or re-index traces.`, 'INDEX_UNAVAILABLE');
187
- }
188
- const cfg = this.getAnalyticsConfig();
189
- await fs_1.promises.mkdir(cfg.tempDirectory, { recursive: true }).catch(() => undefined);
190
- const requiredColumns = INDEXED_DB_REQUIRED_COLUMNS.map(col => this.sqlLiteral(col)).join(', ');
191
- const validationSql = `${this.buildRuntimeSettingsSql()}\nSELECT (SELECT COUNT(*) FROM information_schema.tables WHERE table_name = '${INDEXED_DB_REQUIRED_TABLE}') AS table_count, (SELECT COUNT(*) FROM information_schema.columns WHERE table_name = '${INDEXED_DB_REQUIRED_TABLE}' AND column_name IN (${requiredColumns})) AS column_count;`;
192
- try {
193
- const { stdout } = await execFileAsync(duckdb, ['-readonly', dbPath, '-json', '-c', validationSql], { timeout: cfg.queryTimeoutMs, maxBuffer: 1024 * 1024 });
194
- const rows = stdout.trim() ? JSON.parse(stdout) : [];
195
- const row = rows[0];
196
- if (!row || Number(row.table_count) < 1 || Number(row.column_count) < INDEXED_DB_REQUIRED_COLUMNS.length) {
197
- throw new QueryRunnerError('Indexed analytics DB schema is stale or incomplete. Re-index traces and refresh.', 'INDEX_UNAVAILABLE');
198
- }
199
- }
200
- catch (error) {
201
- if (error instanceof QueryRunnerError) {
202
- throw error;
203
- }
204
- throw new QueryRunnerError(`Indexed analytics DB is unreadable at ${dbPath}. Run Setup Spotlight or re-index traces.`, 'INDEX_UNAVAILABLE');
205
- }
206
- this.schemaValidated = true;
207
- this.indexedDbPath = dbPath;
208
- return dbPath;
209
- }
210
- clampLimit(limit) {
211
- return Math.max(1, Math.min(this.getAnalyticsConfig().maxResultRows, Math.floor(limit || 1)));
212
- }
213
- async acquireDuckDbQuerySlot() {
214
- while (this.activeDuckDbQueries >= this.maxDuckDbConcurrentQueries) {
215
- await new Promise(resolve => this.duckDbQueryWaiters.push(resolve));
216
- }
217
- this.activeDuckDbQueries += 1;
218
- }
219
- releaseDuckDbQuerySlot() {
220
- this.activeDuckDbQueries = Math.max(0, this.activeDuckDbQueries - 1);
221
- const next = this.duckDbQueryWaiters.shift();
222
- next?.();
223
- }
224
- async runDuckDB(sqlBody) {
225
- const duckdb = await this.ensureDuckDB();
226
- await this.acquireDuckDbQuerySlot();
227
- try {
228
- const dbPath = await this.ensureIndexedDbReady(duckdb);
229
- this.logRuntimeProfileOnce();
230
- const sql = `${this.buildRuntimeSettingsSql()}\n${sqlBody}`;
231
- const cfg = this.getAnalyticsConfig();
232
- const { stdout, stderr } = await execFileAsync(duckdb, ['-readonly', dbPath, '-json', '-c', sql], { timeout: cfg.queryTimeoutMs, maxBuffer: 10 * 1024 * 1024 });
233
- if (stderr && !stderr.includes('Warning')) {
234
- this.outputChannel.appendLine(`[QueryRunner] DuckDB stderr: ${stderr}`);
235
- }
236
- if (!stdout.trim()) {
237
- return [];
238
- }
239
- return JSON.parse(stdout);
240
- }
241
- catch (error) {
242
- if (error instanceof QueryRunnerError) {
243
- throw error;
244
- }
245
- if (error instanceof Error && error.message.includes('timeout')) {
246
- throw new QueryRunnerError(`Query timed out (>${Math.floor(this.getAnalyticsConfig().queryTimeoutMs / 1000)}s)`, 'TIMEOUT');
247
- }
248
- throw new QueryRunnerError(`Query failed: ${error}`, 'QUERY_ERROR');
249
- }
250
- finally {
251
- this.releaseDuckDbQuerySlot();
252
- }
253
- }
254
- sqlNullableLiteral(value) {
255
- if (value === undefined || value === null) {
256
- return 'NULL';
257
- }
258
- return this.sqlLiteral(String(value));
259
- }
260
- sqlBool(value) {
261
- return value ? 'TRUE' : 'FALSE';
262
- }
263
- isDuckDbLockError(error) {
264
- const message = error instanceof Error ? error.message : String(error);
265
- return message.includes('Could not set lock on file')
266
- || message.includes('Conflicting lock is held');
267
- }
268
- isFleetSchemaMismatchError(error) {
269
- if (this.isDuckDbLockError(error)) {
270
- return false;
271
- }
272
- const message = error instanceof Error ? error.message : String(error);
273
- return message.includes('ON CONFLICT')
274
- || message.includes('Constraint')
275
- || message.includes('conflict target')
276
- || message.includes('unique constraint')
277
- || message.includes('PRIMARY KEY')
278
- || message.includes('primary key');
279
- }
280
- async sleep(ms) {
281
- await new Promise(resolve => setTimeout(resolve, ms));
282
- }
283
- async runDuckDBExecForFleet(sqlBody) {
284
- const duckdb = await this.ensureDuckDB();
285
- await this.acquireDuckDbQuerySlot();
286
- try {
287
- const dbPath = await this.ensureIndexedDbReady(duckdb);
288
- const cfg = this.getAnalyticsConfig();
289
- const sql = `${this.buildRuntimeSettingsSql()}\n${sqlBody}`;
290
- await execFileAsync(duckdb, [dbPath, '-json', '-c', sql], {
291
- timeout: cfg.queryTimeoutMs,
292
- maxBuffer: 10 * 1024 * 1024,
293
- });
294
- }
295
- finally {
296
- this.releaseDuckDbQuerySlot();
297
- }
298
- }
299
- async runDuckDBExecForFleetWithLockRetry(sqlBody, options) {
300
- const maxWaitMs = Math.max(0, Math.floor(options?.maxWaitMs ?? 2000));
301
- const startedAt = Date.now();
302
- let attempt = 0;
303
- while (true) {
304
- try {
305
- await this.runDuckDBExecForFleet(sqlBody);
306
- return;
307
- }
308
- catch (error) {
309
- if (!this.isDuckDbLockError(error)) {
310
- throw error;
311
- }
312
- const elapsed = Date.now() - startedAt;
313
- if (elapsed >= maxWaitMs) {
314
- throw error;
315
- }
316
- const delay = Math.min(250, 30 * Math.pow(2, attempt));
317
- attempt += 1;
318
- await this.sleep(delay);
319
- }
320
- }
321
- }
322
- getFromCache(key) {
323
- const entry = this.cache.get(key);
324
- if (entry && entry.expiresAt > Date.now()) {
325
- return entry.data;
326
- }
327
- this.cache.delete(key);
328
- return null;
329
- }
330
- setCache(key, data) {
331
- this.cache.set(key, { data, expiresAt: Date.now() + CACHE_TTL });
332
- }
333
- invalidateCache() {
334
- this.cache.clear();
335
- this.analyticsConfig = undefined;
336
- }
337
- async getCostSummary(filters) {
338
- const cacheKey = `costSummary:${this.buildFilterCacheKey(filters)}`;
339
- const cached = this.getFromCache(cacheKey);
340
- if (cached) {
341
- return cached;
342
- }
343
- try {
344
- const conditions = ['cost IS NOT NULL', ...this.buildTraceFilterConditions(filters)];
345
- const whereClause = conditions.join(' AND ');
346
- const rows = await this.runDuckDB(`
1
+ /*! Copyright (c) 2026 AgentHippo.ai. All rights reserved. Proprietary; see LICENSE. */
2
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(l,t,e,n){n===void 0&&(n=e);var i=Object.getOwnPropertyDescriptor(t,e);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(l,n,i)}):(function(l,t,e,n){n===void 0&&(n=e),l[n]=t[e]})),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?(function(l,t){Object.defineProperty(l,"default",{enumerable:!0,value:t})}):function(l,t){l.default=t}),__importStar=this&&this.__importStar||(function(){var l=function(t){return l=Object.getOwnPropertyNames||function(e){var n=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[n.length]=i);return n},l(t)};return function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n=l(t),i=0;i<n.length;i++)n[i]!=="default"&&__createBinding(e,t,n[i]);return __setModuleDefault(e,t),e}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.QueryRunnerImpl=exports.QueryRunnerError=void 0;const vscode=__importStar(require("vscode")),path=__importStar(require("path")),fs_1=require("fs"),child_process_1=require("child_process"),util_1=require("util"),index_1=require("../../utils/index"),execFileAsync=(0,util_1.promisify)(child_process_1.execFile);class QueryRunnerError extends Error{code;constructor(t,e){super(t),this.code=e,this.name="QueryRunnerError"}}exports.QueryRunnerError=QueryRunnerError;const CACHE_TTL=3e4,INDEXED_DB_FILENAME="analytics.duckdb",INDEXED_DB_REQUIRED_TABLE="spans",INDEXED_DB_REQUIRED_COLUMNS=["trace_id","start_ms","duration_ms","cost","model","session_id","project_id","agent_id"],DEFAULT_DUCKDB_MEMORY_LIMIT_MB=1024,DEFAULT_DUCKDB_THREADS=2,DEFAULT_DUCKDB_QUERY_TIMEOUT_SECONDS=30,DEFAULT_DUCKDB_MAX_RESULT_ROWS=5e3,MIN_DUCKDB_MEMORY_MB=64,MIN_DUCKDB_THREADS=1,MIN_DUCKDB_TIMEOUT_SECONDS=5,MIN_DUCKDB_MAX_RESULT_ROWS=100,MAX_DUCKDB_MAX_RESULT_ROWS=1e5,DEFAULT_DUCKDB_TEMP_DIRECTORY=path.join((0,index_1.getAgentideHome)(),"analytics","tmp","duckdb"),FLEET_SESSIONS_TABLE="fleet_sessions";class QueryRunnerImpl{outputChannel;cache=new Map;duckdbPath;indexedDbPath;schemaValidated=!1;fleetSchemaReady=!1;fleetSchemaEnsurePromise;activeDuckDbQueries=0;duckDbQueryWaiters=[];maxDuckDbConcurrentQueries=1;lastLoggedRuntimeProfile;analyticsConfig;tracesDir=path.join((0,index_1.getAgentideHome)(),"analytics","traces");constructor(t){this.outputChannel=t}async ensureDuckDB(){if(this.duckdbPath)return this.duckdbPath;const t=process.platform==="win32"?["duckdb","duckdb.exe",path.join((0,index_1.getAgentideHome)(),"bin","duckdb.exe"),path.join((0,index_1.getAgentideHome)(),"bin","duckdb")]:["duckdb",path.join((0,index_1.getAgentideHome)(),"bin","duckdb"),"/opt/homebrew/bin/duckdb","/usr/local/bin/duckdb","/usr/bin/duckdb"];for(const n of t)try{return await execFileAsync(n,["--version"],{timeout:5e3}),this.duckdbPath=n,this.outputChannel.appendLine(`[QueryRunner] Using DuckDB at: ${n}`),n}catch{}const e=process.platform==="win32"?"Run Setup Spotlight first (it installs ~/.agent-hippo/bin/duckdb.exe)":"Run Setup Spotlight first or install with: brew install duckdb";throw new QueryRunnerError(`DuckDB not found. ${e}`,"DUCKDB_NOT_FOUND")}getIndexedDbPath(){return path.join(this.tracesDir,INDEXED_DB_FILENAME)}getAnalyticsConfig(){if(this.analyticsConfig)return this.analyticsConfig;const t=vscode.workspace.getConfiguration("agentide.analytics"),e=Math.max(MIN_DUCKDB_MEMORY_MB,Number(t.get("duckdb.memoryLimitMb",DEFAULT_DUCKDB_MEMORY_LIMIT_MB))||DEFAULT_DUCKDB_MEMORY_LIMIT_MB),n=Math.max(MIN_DUCKDB_THREADS,Number(t.get("duckdb.threads",DEFAULT_DUCKDB_THREADS))||DEFAULT_DUCKDB_THREADS),i=Math.max(MIN_DUCKDB_TIMEOUT_SECONDS,Number(t.get("duckdb.queryTimeoutSeconds",DEFAULT_DUCKDB_QUERY_TIMEOUT_SECONDS))||DEFAULT_DUCKDB_QUERY_TIMEOUT_SECONDS),a=Math.max(MIN_DUCKDB_MAX_RESULT_ROWS,Math.min(MAX_DUCKDB_MAX_RESULT_ROWS,Number(t.get("duckdb.maxResultRows",DEFAULT_DUCKDB_MAX_RESULT_ROWS))||DEFAULT_DUCKDB_MAX_RESULT_ROWS)),s=(t.get("duckdb.tempDirectory","")||"").trim()||DEFAULT_DUCKDB_TEMP_DIRECTORY;return this.analyticsConfig={memoryLimitMb:e,threads:n,queryTimeoutMs:i*1e3,maxResultRows:a,tempDirectory:s},this.analyticsConfig}sqlLiteral(t){return"'"+t.replace(/'/g,"''")+"'"}normalizeFilters(t){const e=t?.scope==="workspace"?"workspace":"global",n=t?.projectId?.trim()||void 0,i=t?.agentId?.trim()||void 0;return{scope:e,projectId:n,agentId:i}}buildTraceFilterConditions(t,e){const n=this.normalizeFilters(t),i=e?`${e}.`:"",a=[];return n.scope==="workspace"&&(n.projectId?a.push(`(${i}project_id = ${this.sqlLiteral(n.projectId)} OR ${i}project_id IS NULL)`):a.push("1 = 0")),n.agentId&&a.push(`${i}agent_id = ${this.sqlLiteral(n.agentId)}`),a}buildFilterCacheKey(t){const e=this.normalizeFilters(t);return`${e.scope}|${e.projectId??""}|${e.agentId??""}`}buildRuntimeSettingsSql(){const t=this.getAnalyticsConfig(),e=[`SET memory_limit='${t.memoryLimitMb}MB';`,`SET threads=${t.threads};`,"SET preserve_insertion_order=false;"];return t.tempDirectory&&e.push(`SET temp_directory=${this.sqlLiteral(t.tempDirectory)};`),e.join(`
3
+ `)}logRuntimeProfileOnce(){const t=this.getAnalyticsConfig(),e=`${t.memoryLimitMb}|${t.threads}|${t.queryTimeoutMs}|${t.maxResultRows}|${t.tempDirectory}`;this.lastLoggedRuntimeProfile!==e&&(this.lastLoggedRuntimeProfile=e,this.outputChannel.appendLine(`[QueryRunner] DuckDB runtime profile: memory=${t.memoryLimitMb}MB threads=${t.threads} timeoutMs=${t.queryTimeoutMs} maxRows=${t.maxResultRows} tempDir=${t.tempDirectory}`))}async ensureIndexedDbReady(t){if(this.indexedDbPath&&this.schemaValidated)return this.indexedDbPath;const e=this.getIndexedDbPath();try{await fs_1.promises.access(e,fs_1.constants.R_OK)}catch{throw new QueryRunnerError(`Indexed analytics DB not found at ${e}. Run Setup Spotlight or re-index traces.`,"INDEX_UNAVAILABLE")}const n=this.getAnalyticsConfig();await fs_1.promises.mkdir(n.tempDirectory,{recursive:!0}).catch(()=>{});const i=INDEXED_DB_REQUIRED_COLUMNS.map(s=>this.sqlLiteral(s)).join(", "),a=`${this.buildRuntimeSettingsSql()}
4
+ SELECT (SELECT COUNT(*) FROM information_schema.tables WHERE table_name = '${INDEXED_DB_REQUIRED_TABLE}') AS table_count, (SELECT COUNT(*) FROM information_schema.columns WHERE table_name = '${INDEXED_DB_REQUIRED_TABLE}' AND column_name IN (${i})) AS column_count;`;try{const{stdout:s}=await execFileAsync(t,["-readonly",e,"-json","-c",a],{timeout:n.queryTimeoutMs,maxBuffer:1048576}),o=(s.trim()?JSON.parse(s):[])[0];if(!o||Number(o.table_count)<1||Number(o.column_count)<INDEXED_DB_REQUIRED_COLUMNS.length)throw new QueryRunnerError("Indexed analytics DB schema is stale or incomplete. Re-index traces and refresh.","INDEX_UNAVAILABLE")}catch(s){throw s instanceof QueryRunnerError?s:new QueryRunnerError(`Indexed analytics DB is unreadable at ${e}. Run Setup Spotlight or re-index traces.`,"INDEX_UNAVAILABLE")}return this.schemaValidated=!0,this.indexedDbPath=e,e}clampLimit(t){return Math.max(1,Math.min(this.getAnalyticsConfig().maxResultRows,Math.floor(t||1)))}async acquireDuckDbQuerySlot(){for(;this.activeDuckDbQueries>=this.maxDuckDbConcurrentQueries;)await new Promise(t=>this.duckDbQueryWaiters.push(t));this.activeDuckDbQueries+=1}releaseDuckDbQuerySlot(){this.activeDuckDbQueries=Math.max(0,this.activeDuckDbQueries-1),this.duckDbQueryWaiters.shift()?.()}async runDuckDB(t){const e=await this.ensureDuckDB();await this.acquireDuckDbQuerySlot();try{const n=await this.ensureIndexedDbReady(e);this.logRuntimeProfileOnce();const i=`${this.buildRuntimeSettingsSql()}
5
+ ${t}`,a=this.getAnalyticsConfig(),{stdout:s,stderr:r}=await execFileAsync(e,["-readonly",n,"-json","-c",i],{timeout:a.queryTimeoutMs,maxBuffer:10*1024*1024});return r&&!r.includes("Warning")&&this.outputChannel.appendLine(`[QueryRunner] DuckDB stderr: ${r}`),s.trim()?JSON.parse(s):[]}catch(n){throw n instanceof QueryRunnerError?n:n instanceof Error&&n.message.includes("timeout")?new QueryRunnerError(`Query timed out (>${Math.floor(this.getAnalyticsConfig().queryTimeoutMs/1e3)}s)`,"TIMEOUT"):new QueryRunnerError(`Query failed: ${n}`,"QUERY_ERROR")}finally{this.releaseDuckDbQuerySlot()}}sqlNullableLiteral(t){return t==null?"NULL":this.sqlLiteral(String(t))}sqlBool(t){return t?"TRUE":"FALSE"}isDuckDbLockError(t){const e=t instanceof Error?t.message:String(t);return e.includes("Could not set lock on file")||e.includes("Conflicting lock is held")}isFleetSchemaMismatchError(t){if(this.isDuckDbLockError(t))return!1;const e=t instanceof Error?t.message:String(t);return e.includes("ON CONFLICT")||e.includes("Constraint")||e.includes("conflict target")||e.includes("unique constraint")||e.includes("PRIMARY KEY")||e.includes("primary key")}async sleep(t){await new Promise(e=>setTimeout(e,t))}async runDuckDBExecForFleet(t){const e=await this.ensureDuckDB();await this.acquireDuckDbQuerySlot();try{const n=await this.ensureIndexedDbReady(e),i=this.getAnalyticsConfig(),a=`${this.buildRuntimeSettingsSql()}
6
+ ${t}`;await execFileAsync(e,[n,"-json","-c",a],{timeout:i.queryTimeoutMs,maxBuffer:10*1024*1024})}finally{this.releaseDuckDbQuerySlot()}}async runDuckDBExecForFleetWithLockRetry(t,e){const n=Math.max(0,Math.floor(e?.maxWaitMs??2e3)),i=Date.now();let a=0;for(;;)try{await this.runDuckDBExecForFleet(t);return}catch(s){if(!this.isDuckDbLockError(s)||Date.now()-i>=n)throw s;const o=Math.min(250,30*Math.pow(2,a));a+=1,await this.sleep(o)}}getFromCache(t){const e=this.cache.get(t);return e&&e.expiresAt>Date.now()?e.data:(this.cache.delete(t),null)}setCache(t,e){this.cache.set(t,{data:e,expiresAt:Date.now()+CACHE_TTL})}invalidateCache(){this.cache.clear(),this.analyticsConfig=void 0}async getCostSummary(t){const e=`costSummary:${this.buildFilterCacheKey(t)}`,n=this.getFromCache(e);if(n)return n;try{const a=["cost IS NOT NULL",...this.buildTraceFilterConditions(t)].join(" AND "),r=(await this.runDuckDB(`
347
7
  SELECT
348
8
  COALESCE(SUM(cost), 0) as totalCost,
349
9
  COUNT(*) as totalRequests,
350
10
  COALESCE(AVG(duration_ms), 0) as avgDurationMs,
351
11
  COALESCE(SUM(input_tokens), 0) as totalInputTokens,
352
12
  COALESCE(SUM(output_tokens), 0) as totalOutputTokens,
353
- COALESCE((SELECT model FROM spans WHERE ${whereClause} GROUP BY model ORDER BY SUM(cost) DESC LIMIT 1), 'unknown') as topModel
13
+ COALESCE((SELECT model FROM spans WHERE ${a} GROUP BY model ORDER BY SUM(cost) DESC LIMIT 1), 'unknown') as topModel
354
14
  FROM spans
355
- WHERE ${whereClause}`);
356
- const row = rows[0] ?? { totalCost: 0, totalRequests: 0, avgDurationMs: 0, totalInputTokens: 0, totalOutputTokens: 0, topModel: 'unknown' };
357
- this.setCache(cacheKey, row);
358
- return row;
359
- }
360
- catch (error) {
361
- if (error instanceof QueryRunnerError && error.code === 'INDEX_UNAVAILABLE') {
362
- return { totalCost: 0, totalRequests: 0, avgDurationMs: 0, totalInputTokens: 0, totalOutputTokens: 0, topModel: 'unknown' };
363
- }
364
- throw error;
365
- }
366
- }
367
- async getRecentSessions(limit = 10, filters) {
368
- const safeLimit = this.clampLimit(limit);
369
- const cacheKey = `recentSessions:${safeLimit}:${this.buildFilterCacheKey(filters)}`;
370
- const cached = this.getFromCache(cacheKey);
371
- if (cached) {
372
- return cached;
373
- }
374
- try {
375
- const conditions = ['session_id IS NOT NULL', 'cost IS NOT NULL', ...this.buildTraceFilterConditions(filters)];
376
- const rows = await this.runDuckDB(`
15
+ WHERE ${a}`))[0]??{totalCost:0,totalRequests:0,avgDurationMs:0,totalInputTokens:0,totalOutputTokens:0,topModel:"unknown"};return this.setCache(e,r),r}catch(i){if(i instanceof QueryRunnerError&&i.code==="INDEX_UNAVAILABLE")return{totalCost:0,totalRequests:0,avgDurationMs:0,totalInputTokens:0,totalOutputTokens:0,topModel:"unknown"};throw i}}async getRecentSessions(t=10,e){const n=this.clampLimit(t),i=`recentSessions:${n}:${this.buildFilterCacheKey(e)}`,a=this.getFromCache(i);if(a)return a;try{const s=["session_id IS NOT NULL","cost IS NOT NULL",...this.buildTraceFilterConditions(e)],r=await this.runDuckDB(`
377
16
  SELECT
378
17
  session_id as sessionId,
379
18
  agent_id as agentId,
@@ -382,30 +21,10 @@ SELECT
382
21
  AVG(duration_ms) as avgDurationMs,
383
22
  MIN(to_timestamp(start_ms / 1000)) as startedAt
384
23
  FROM spans
385
- WHERE ${conditions.join(' AND ')}
24
+ WHERE ${s.join(" AND ")}
386
25
  GROUP BY session_id, agent_id
387
26
  ORDER BY MAX(start_ms) DESC
388
- LIMIT ${safeLimit}`);
389
- this.setCache(cacheKey, rows);
390
- return rows;
391
- }
392
- catch (error) {
393
- if (error instanceof QueryRunnerError && error.code === 'INDEX_UNAVAILABLE') {
394
- return [];
395
- }
396
- throw error;
397
- }
398
- }
399
- async getFleetSessions(limit = 200, filters) {
400
- const safeLimit = this.clampLimit(limit);
401
- const cacheKey = `fleetSessions:${safeLimit}:${this.buildFilterCacheKey(filters)}`;
402
- const cached = this.getFromCache(cacheKey);
403
- if (cached) {
404
- return cached;
405
- }
406
- try {
407
- const conditions = ['session_id IS NOT NULL', ...this.buildTraceFilterConditions(filters)];
408
- const sqlWithEngine = `
27
+ LIMIT ${n}`);return this.setCache(i,r),r}catch(s){if(s instanceof QueryRunnerError&&s.code==="INDEX_UNAVAILABLE")return[];throw s}}async getFleetSessions(t=200,e){const n=this.clampLimit(t),i=`fleetSessions:${n}:${this.buildFilterCacheKey(e)}`,a=this.getFromCache(i);if(a)return a;try{const s=["session_id IS NOT NULL",...this.buildTraceFilterConditions(e)],r=`
409
28
  SELECT
410
29
  session_id as sessionId,
411
30
  agent_id as agentId,
@@ -416,14 +35,13 @@ SELECT
416
35
  COALESCE(model, 'unknown') as model,
417
36
  COALESCE(engine, '') as engine
418
37
  FROM spans
419
- WHERE ${conditions.join(' AND ')}
38
+ WHERE ${s.join(" AND ")}
420
39
  QUALIFY row_number() OVER (
421
40
  PARTITION BY session_id
422
41
  ORDER BY start_ms DESC
423
42
  ) = 1
424
43
  ORDER BY start_ms DESC
425
- LIMIT ${safeLimit}`;
426
- const sqlWithoutEngine = `
44
+ LIMIT ${n}`,o=`
427
45
  SELECT
428
46
  session_id as sessionId,
429
47
  agent_id as agentId,
@@ -433,202 +51,34 @@ SELECT
433
51
  0 as totalTokens,
434
52
  COALESCE(model, 'unknown') as model
435
53
  FROM spans
436
- WHERE ${conditions.join(' AND ')}
54
+ WHERE ${s.join(" AND ")}
437
55
  QUALIFY row_number() OVER (
438
56
  PARTITION BY session_id
439
57
  ORDER BY start_ms DESC
440
58
  ) = 1
441
59
  ORDER BY start_ms DESC
442
- LIMIT ${safeLimit}`;
443
- let rows;
444
- try {
445
- rows = await this.runDuckDB(sqlWithEngine);
446
- }
447
- catch (engineErr) {
448
- const msg = engineErr instanceof Error ? engineErr.message : String(engineErr);
449
- if (msg.includes('engine') || msg.includes('column') || msg.includes('referenced')) {
450
- rows = await this.runDuckDB(sqlWithoutEngine);
451
- rows = rows.map((r) => ({ ...r, engine: '' }));
452
- }
453
- else {
454
- throw engineErr;
455
- }
456
- }
457
- this.setCache(cacheKey, rows);
458
- return rows;
459
- }
460
- catch (error) {
461
- if (error instanceof QueryRunnerError && error.code === 'INDEX_UNAVAILABLE') {
462
- return [];
463
- }
464
- throw error;
465
- }
466
- }
467
- async getModelBreakdown(filters) {
468
- const cacheKey = `modelBreakdown:${this.buildFilterCacheKey(filters)}`;
469
- const cached = this.getFromCache(cacheKey);
470
- if (cached) {
471
- return cached;
472
- }
473
- try {
474
- const conditions = ['cost IS NOT NULL', ...this.buildTraceFilterConditions(filters)];
475
- const rows = await this.runDuckDB(`
60
+ LIMIT ${n}`;let u;try{u=await this.runDuckDB(r)}catch(d){const h=d instanceof Error?d.message:String(d);if(h.includes("engine")||h.includes("column")||h.includes("referenced"))u=await this.runDuckDB(o),u=u.map(c=>({...c,engine:""}));else throw d}return this.setCache(i,u),u}catch(s){if(s instanceof QueryRunnerError&&s.code==="INDEX_UNAVAILABLE")return[];throw s}}async getModelBreakdown(t){const e=`modelBreakdown:${this.buildFilterCacheKey(t)}`,n=this.getFromCache(e);if(n)return n;try{const i=["cost IS NOT NULL",...this.buildTraceFilterConditions(t)],a=await this.runDuckDB(`
476
61
  SELECT COALESCE(model, 'unknown') as model, SUM(cost) as cost, COUNT(*) as requestCount
477
62
  FROM spans
478
- WHERE ${conditions.join(' AND ')}
63
+ WHERE ${i.join(" AND ")}
479
64
  GROUP BY model
480
- ORDER BY cost DESC`);
481
- const totalCost = rows.reduce((sum, row) => sum + Number(row.cost || 0), 0);
482
- const result = rows.map(row => ({ ...row, percentage: totalCost > 0 ? (row.cost / totalCost) * 100 : 0 }));
483
- this.setCache(cacheKey, result);
484
- return result;
485
- }
486
- catch (error) {
487
- if (error instanceof QueryRunnerError && error.code === 'INDEX_UNAVAILABLE') {
488
- return [];
489
- }
490
- throw error;
491
- }
492
- }
493
- async getCostTrend(days = 7, filters) {
494
- const cacheKey = `costTrend:${days}:${this.buildFilterCacheKey(filters)}`;
495
- const cached = this.getFromCache(cacheKey);
496
- if (cached) {
497
- return cached;
498
- }
499
- try {
500
- const conditions = ['cost IS NOT NULL', `start_ms > (EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - INTERVAL '${Math.max(1, Math.floor(days || 1))} days')) * 1000)`, ...this.buildTraceFilterConditions(filters)];
501
- const rows = await this.runDuckDB(`
65
+ ORDER BY cost DESC`),s=a.reduce((o,u)=>o+Number(u.cost||0),0),r=a.map(o=>({...o,percentage:s>0?o.cost/s*100:0}));return this.setCache(e,r),r}catch(i){if(i instanceof QueryRunnerError&&i.code==="INDEX_UNAVAILABLE")return[];throw i}}async getCostTrend(t=7,e){const n=`costTrend:${t}:${this.buildFilterCacheKey(e)}`,i=this.getFromCache(n);if(i)return i;try{const a=["cost IS NOT NULL",`start_ms > (EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - INTERVAL '${Math.max(1,Math.floor(t||1))} days')) * 1000)`,...this.buildTraceFilterConditions(e)],s=await this.runDuckDB(`
502
66
  SELECT strftime(to_timestamp(start_ms / 1000), '%Y-%m-%d') as date, SUM(cost) as cost, COUNT(*) as requestCount
503
67
  FROM spans
504
- WHERE ${conditions.join(' AND ')}
68
+ WHERE ${a.join(" AND ")}
505
69
  GROUP BY date
506
- ORDER BY date ASC`);
507
- this.setCache(cacheKey, rows);
508
- return rows;
509
- }
510
- catch (error) {
511
- if (error instanceof QueryRunnerError && error.code === 'INDEX_UNAVAILABLE') {
512
- return [];
513
- }
514
- throw error;
515
- }
516
- }
517
- async getAgentIds(filters) {
518
- const normalized = this.normalizeFilters(filters);
519
- const scopeOnlyFilters = { scope: normalized.scope, projectId: normalized.projectId };
520
- const cacheKey = `agentIds:${this.buildFilterCacheKey(scopeOnlyFilters)}`;
521
- const cached = this.getFromCache(cacheKey);
522
- if (cached) {
523
- return cached;
524
- }
525
- try {
526
- const conditions = ['agent_id IS NOT NULL', ...this.buildTraceFilterConditions(scopeOnlyFilters)];
527
- const rows = await this.runDuckDB(`
70
+ ORDER BY date ASC`);return this.setCache(n,s),s}catch(a){if(a instanceof QueryRunnerError&&a.code==="INDEX_UNAVAILABLE")return[];throw a}}async getAgentIds(t){const e=this.normalizeFilters(t),n={scope:e.scope,projectId:e.projectId},i=`agentIds:${this.buildFilterCacheKey(n)}`,a=this.getFromCache(i);if(a)return a;try{const s=["agent_id IS NOT NULL",...this.buildTraceFilterConditions(n)],o=(await this.runDuckDB(`
528
71
  SELECT DISTINCT agent_id as agentId
529
72
  FROM spans
530
- WHERE ${conditions.join(' AND ')}
531
- ORDER BY agent_id ASC`);
532
- const ids = rows.map(row => row.agentId).filter((value) => Boolean(value));
533
- this.setCache(cacheKey, ids);
534
- return ids;
535
- }
536
- catch (error) {
537
- if (error instanceof QueryRunnerError && error.code === 'INDEX_UNAVAILABLE') {
538
- return [];
539
- }
540
- throw error;
541
- }
542
- }
543
- async hasData(filters) {
544
- const cacheKey = `hasData:${this.buildFilterCacheKey(filters)}`;
545
- const cached = this.getFromCache(cacheKey);
546
- if (cached !== null) {
547
- return cached;
548
- }
549
- try {
550
- const conditions = ['cost IS NOT NULL', ...this.buildTraceFilterConditions(filters)];
551
- const rows = await this.runDuckDB(`SELECT COUNT(*) as count FROM spans WHERE ${conditions.join(' AND ')}`);
552
- const hasData = Number(rows[0]?.count ?? 0) > 0;
553
- this.setCache(cacheKey, hasData);
554
- return hasData;
555
- }
556
- catch (error) {
557
- if (error instanceof QueryRunnerError && error.code === 'INDEX_UNAVAILABLE') {
558
- this.setCache(cacheKey, false);
559
- return false;
560
- }
561
- return false;
562
- }
563
- }
564
- async getDataHash(filters) {
565
- const cacheKey = `dataHash:${this.buildFilterCacheKey(filters)}`;
566
- const cached = this.getFromCache(cacheKey);
567
- if (cached !== null) {
568
- return cached;
569
- }
570
- try {
571
- const conditions = ['cost IS NOT NULL', ...this.buildTraceFilterConditions(filters)];
572
- const rows = await this.runDuckDB(`
73
+ WHERE ${s.join(" AND ")}
74
+ ORDER BY agent_id ASC`)).map(u=>u.agentId).filter(u=>!!u);return this.setCache(i,o),o}catch(s){if(s instanceof QueryRunnerError&&s.code==="INDEX_UNAVAILABLE")return[];throw s}}async hasData(t){const e=`hasData:${this.buildFilterCacheKey(t)}`,n=this.getFromCache(e);if(n!==null)return n;try{const i=["cost IS NOT NULL",...this.buildTraceFilterConditions(t)],a=await this.runDuckDB(`SELECT COUNT(*) as count FROM spans WHERE ${i.join(" AND ")}`),s=Number(a[0]?.count??0)>0;return this.setCache(e,s),s}catch(i){return i instanceof QueryRunnerError&&i.code==="INDEX_UNAVAILABLE"&&this.setCache(e,!1),!1}}async getDataHash(t){const e=`dataHash:${this.buildFilterCacheKey(t)}`,n=this.getFromCache(e);if(n!==null)return n;try{const i=["cost IS NOT NULL",...this.buildTraceFilterConditions(t)],s=(await this.runDuckDB(`
573
75
  SELECT
574
76
  COUNT(*) as spanCount,
575
77
  COALESCE(CAST(SUM(start_ms) AS BIGINT), 0) as startSum,
576
78
  COALESCE(CAST(SUM(CAST(cost * 1000000 AS BIGINT)) AS BIGINT), 0) as costMicros,
577
79
  COALESCE(MAX(start_ms), 0) as latestStartMs
578
80
  FROM spans
579
- WHERE ${conditions.join(' AND ')}`);
580
- const row = rows[0];
581
- if (!row || Number(row.spanCount) === 0) {
582
- this.setCache(cacheKey, '');
583
- return '';
584
- }
585
- const hash = [Number(row.spanCount), Number(row.startSum), Number(row.costMicros), Number(row.latestStartMs)].join('-');
586
- this.setCache(cacheKey, hash);
587
- return hash;
588
- }
589
- catch (error) {
590
- if (error instanceof QueryRunnerError && error.code === 'INDEX_UNAVAILABLE') {
591
- this.setCache(cacheKey, '');
592
- return '';
593
- }
594
- return '';
595
- }
596
- }
597
- async getDashboardBootstrap(filters) {
598
- const normalized = this.normalizeFilters(filters);
599
- const scopeFilters = { scope: normalized.scope, projectId: normalized.projectId };
600
- const [hasData, dataHash, agentIds, summary] = await Promise.all([
601
- this.hasData(filters),
602
- this.getDataHash(filters),
603
- this.getAgentIds(scopeFilters),
604
- this.getCostSummary(filters),
605
- ]);
606
- return { summary, agentIds, hasData, dataHash };
607
- }
608
- async getDuckDbBinaryPath() {
609
- return await this.ensureDuckDB();
610
- }
611
- async getAnalyticsDbPath() {
612
- const duckdb = await this.ensureDuckDB();
613
- return await this.ensureIndexedDbReady(duckdb);
614
- }
615
- async ensureFleetSchema() {
616
- if (this.fleetSchemaReady) {
617
- return;
618
- }
619
- if (!this.fleetSchemaEnsurePromise) {
620
- this.fleetSchemaEnsurePromise = this.ensureFleetSchemaInternal()
621
- .then(() => {
622
- this.fleetSchemaReady = true;
623
- })
624
- .finally(() => {
625
- this.fleetSchemaEnsurePromise = undefined;
626
- });
627
- }
628
- await this.fleetSchemaEnsurePromise;
629
- }
630
- async ensureFleetSchemaInternal() {
631
- const createTableSql = `
81
+ WHERE ${i.join(" AND ")}`))[0];if(!s||Number(s.spanCount)===0)return this.setCache(e,""),"";const r=[Number(s.spanCount),Number(s.startSum),Number(s.costMicros),Number(s.latestStartMs)].join("-");return this.setCache(e,r),r}catch(i){return i instanceof QueryRunnerError&&i.code==="INDEX_UNAVAILABLE"&&this.setCache(e,""),""}}async getDashboardBootstrap(t){const e=this.normalizeFilters(t),n={scope:e.scope,projectId:e.projectId},[i,a,s,r]=await Promise.all([this.hasData(t),this.getDataHash(t),this.getAgentIds(n),this.getCostSummary(t)]);return{summary:r,agentIds:s,hasData:i,dataHash:a}}async getDuckDbBinaryPath(){return await this.ensureDuckDB()}async getAnalyticsDbPath(){const t=await this.ensureDuckDB();return await this.ensureIndexedDbReady(t)}async ensureFleetSchema(){this.fleetSchemaReady||(this.fleetSchemaEnsurePromise||(this.fleetSchemaEnsurePromise=this.ensureFleetSchemaInternal().then(()=>{this.fleetSchemaReady=!0}).finally(()=>{this.fleetSchemaEnsurePromise=void 0})),await this.fleetSchemaEnsurePromise)}async ensureFleetSchemaInternal(){const t=`
632
82
  CREATE TABLE IF NOT EXISTS ${FLEET_SESSIONS_TABLE} (
633
83
  source VARCHAR NOT NULL,
634
84
  session_id VARCHAR NOT NULL,
@@ -648,12 +98,7 @@ CREATE TABLE IF NOT EXISTS ${FLEET_SESSIONS_TABLE} (
648
98
  updated_at TIMESTAMP,
649
99
  PRIMARY KEY (source, session_id)
650
100
  );
651
- `;
652
- // 1) Create table if missing.
653
- await this.runDuckDBExecForFleetWithLockRetry(createTableSql, { maxWaitMs: 2000 });
654
- // 2) Validate uniqueness/constraint shape supports ON CONFLICT (source, session_id).
655
- // Older dev DBs may exist with a different PK shape, which would break Fleet upserts.
656
- const schemaCheckSql = `
101
+ `;await this.runDuckDBExecForFleetWithLockRetry(t,{maxWaitMs:2e3});const e=`
657
102
  BEGIN;
658
103
  INSERT INTO ${FLEET_SESSIONS_TABLE} (
659
104
  source,
@@ -693,17 +138,7 @@ ON CONFLICT (source, session_id) DO UPDATE SET
693
138
  DELETE FROM ${FLEET_SESSIONS_TABLE}
694
139
  WHERE source = '__schema_check__' AND session_id = '__schema_check__';
695
140
  COMMIT;
696
- `;
697
- try {
698
- await this.runDuckDBExecForFleetWithLockRetry(schemaCheckSql, { maxWaitMs: 2000 });
699
- }
700
- catch (error) {
701
- if (!this.isFleetSchemaMismatchError(error)) {
702
- throw error;
703
- }
704
- // 3) Migration fallback: re-create fleet_sessions with the correct PK,
705
- // preserving card_title when possible.
706
- const migrationSql = `
141
+ `;try{await this.runDuckDBExecForFleetWithLockRetry(e,{maxWaitMs:2e3})}catch(n){if(!this.isFleetSchemaMismatchError(n))throw n;const i=`
707
142
  BEGIN;
708
143
  CREATE TABLE IF NOT EXISTS ${FLEET_SESSIONS_TABLE}__new (
709
144
  source VARCHAR NOT NULL,
@@ -751,18 +186,7 @@ FROM ${FLEET_SESSIONS_TABLE};
751
186
  DROP TABLE ${FLEET_SESSIONS_TABLE};
752
187
  ALTER TABLE ${FLEET_SESSIONS_TABLE}__new RENAME TO ${FLEET_SESSIONS_TABLE};
753
188
  COMMIT;
754
- `;
755
- this.outputChannel.appendLine(`[QueryRunner] Migrating fleet_sessions schema to (source, session_id) PK (legacy DB detected).`);
756
- await this.runDuckDBExecForFleetWithLockRetry(migrationSql, { maxWaitMs: 5000 });
757
- }
758
- }
759
- async readFleetSessions(options) {
760
- await this.ensureFleetSchema();
761
- const sources = options?.sources?.filter(s => typeof s === 'string' && s.trim() !== '') ?? [];
762
- const sourceCondition = sources.length > 0
763
- ? `WHERE source IN (${sources.map(s => this.sqlLiteral(String(s))).join(', ')})`
764
- : '';
765
- const sql = `
189
+ `;this.outputChannel.appendLine("[QueryRunner] Migrating fleet_sessions schema to (source, session_id) PK (legacy DB detected)."),await this.runDuckDBExecForFleetWithLockRetry(i,{maxWaitMs:5e3})}}async readFleetSessions(t){await this.ensureFleetSchema();const e=t?.sources?.filter(s=>typeof s=="string"&&s.trim()!=="")??[],n=e.length>0?`WHERE source IN (${e.map(s=>this.sqlLiteral(String(s))).join(", ")})`:"",i=`
766
190
  SELECT
767
191
  source as source,
768
192
  session_id as sessionId,
@@ -781,102 +205,36 @@ SELECT
781
205
  disconnect_capable as disconnectCapable,
782
206
  updated_at as updatedAt
783
207
  FROM ${FLEET_SESSIONS_TABLE}
784
- ${sourceCondition}
785
- ORDER BY updated_at DESC`;
786
- const rows = await this.runDuckDB(sql);
787
- return rows.map((r) => {
788
- const status = String(r.status ?? '').trim();
789
- const disconnect = r.disconnectCapable;
790
- const startedAt = typeof r.startedAt === 'string' ? r.startedAt : String(r.startedAt ?? '');
791
- const endedAt = typeof r.endedAt === 'string' ? r.endedAt : String(r.endedAt ?? '');
792
- return {
793
- source: typeof r.source === 'string' ? r.source : String(r.source ?? ''),
794
- sessionId: typeof r.sessionId === 'string' ? r.sessionId : String(r.sessionId ?? ''),
795
- agentId: typeof r.agentId === 'string' && r.agentId.trim() ? r.agentId : undefined,
796
- status: status === 'scheduled' ? 'scheduled' : status === 'done' ? 'done' : 'in_progress',
797
- startedAt,
798
- endedAt,
799
- cardTitle: typeof r.cardTitle === 'string' ? r.cardTitle : undefined,
800
- taskTitle: typeof r.taskTitle === 'string' ? r.taskTitle : String(r.taskTitle ?? ''),
801
- model: typeof r.model === 'string' ? r.model : String(r.model ?? ''),
802
- engine: typeof r.engine === 'string' ? r.engine : String(r.engine ?? ''),
803
- channelType: typeof r.channelType === 'string' ? r.channelType : String(r.channelType ?? 'none'),
804
- channelTarget: typeof r.channelTarget === 'string' ? r.channelTarget : String(r.channelTarget ?? ''),
805
- turns: Number(r.turns ?? 0),
806
- totalTokens: Number(r.totalTokens ?? 0),
807
- disconnectCapable: disconnect === true || disconnect === 1 || disconnect === 'true',
808
- updatedAt: typeof r.updatedAt === 'string' ? r.updatedAt : String(r.updatedAt ?? new Date().toISOString()),
809
- };
810
- });
811
- }
812
- async writeFleetSessions(sourceId, rows) {
813
- if (!Array.isArray(rows)) {
814
- return;
815
- }
816
- await this.ensureFleetSchema();
817
- const safeSourceId = String(sourceId ?? '').trim() || 'local';
818
- const sessionIds = Array.from(new Set(rows
819
- .map(r => String(r.sessionId ?? '').trim())
820
- .filter(Boolean)));
821
- const existingTitles = new Map();
822
- if (sessionIds.length > 0) {
823
- const titleSql = `
208
+ ${n}
209
+ ORDER BY updated_at DESC`;return(await this.runDuckDB(i)).map(s=>{const r=String(s.status??"").trim(),o=s.disconnectCapable,u=typeof s.startedAt=="string"?s.startedAt:String(s.startedAt??""),d=typeof s.endedAt=="string"?s.endedAt:String(s.endedAt??"");return{source:typeof s.source=="string"?s.source:String(s.source??""),sessionId:typeof s.sessionId=="string"?s.sessionId:String(s.sessionId??""),agentId:typeof s.agentId=="string"&&s.agentId.trim()?s.agentId:void 0,status:r==="scheduled"?"scheduled":r==="done"?"done":"in_progress",startedAt:u,endedAt:d,cardTitle:typeof s.cardTitle=="string"?s.cardTitle:void 0,taskTitle:typeof s.taskTitle=="string"?s.taskTitle:String(s.taskTitle??""),model:typeof s.model=="string"?s.model:String(s.model??""),engine:typeof s.engine=="string"?s.engine:String(s.engine??""),channelType:typeof s.channelType=="string"?s.channelType:String(s.channelType??"none"),channelTarget:typeof s.channelTarget=="string"?s.channelTarget:String(s.channelTarget??""),turns:Number(s.turns??0),totalTokens:Number(s.totalTokens??0),disconnectCapable:o===!0||o===1||o==="true",updatedAt:typeof s.updatedAt=="string"?s.updatedAt:String(s.updatedAt??new Date().toISOString())}})}async writeFleetSessions(t,e){if(!Array.isArray(e))return;await this.ensureFleetSchema();const n=String(t??"").trim()||"local",i=Array.from(new Set(e.map(o=>String(o.sessionId??"").trim()).filter(Boolean))),a=new Map;if(i.length>0){const o=`
824
210
  SELECT
825
211
  session_id as sessionId,
826
212
  card_title as cardTitle
827
213
  FROM ${FLEET_SESSIONS_TABLE}
828
- WHERE source = ${this.sqlLiteral(safeSourceId)}
829
- AND session_id IN (${sessionIds.map(id => this.sqlLiteral(id)).join(', ')})
830
- `;
831
- const titleRows = await this.runDuckDB(titleSql);
832
- for (const row of titleRows) {
833
- const key = String(row.sessionId ?? '').trim();
834
- const value = row.cardTitle == null ? '' : String(row.cardTitle);
835
- if (key && value.trim()) {
836
- existingTitles.set(key, value);
837
- }
838
- }
839
- }
840
- if (rows.length === 0) {
841
- return;
842
- }
843
- const clearSql = `
214
+ WHERE source = ${this.sqlLiteral(n)}
215
+ AND session_id IN (${i.map(d=>this.sqlLiteral(d)).join(", ")})
216
+ `,u=await this.runDuckDB(o);for(const d of u){const h=String(d.sessionId??"").trim(),c=d.cardTitle==null?"":String(d.cardTitle);h&&c.trim()&&a.set(h,c)}}if(e.length===0)return;const s=`
844
217
  DELETE FROM ${FLEET_SESSIONS_TABLE}
845
- WHERE source = ${this.sqlLiteral(safeSourceId)};
846
- `;
847
- await this.runDuckDBExecForFleetWithLockRetry(clearSql, { maxWaitMs: 2000 });
848
- const chunkSize = 200;
849
- for (let i = 0; i < rows.length; i += chunkSize) {
850
- const chunk = rows.slice(i, i + chunkSize);
851
- const values = chunk.map(r => {
852
- const u = r.updatedAt != null && r.updatedAt !== '' ? this.sqlLiteral(r.updatedAt) : 'current_timestamp';
853
- const preservedCardTitle = existingTitles.get(String(r.sessionId ?? '').trim());
854
- const resolvedCardTitle = preservedCardTitle ?? r.cardTitle;
855
- const incomingCardTitle = resolvedCardTitle !== undefined ? this.sqlNullableLiteral(resolvedCardTitle) : 'NULL';
856
- return `(
857
- ${this.sqlLiteral(safeSourceId)},
858
- ${this.sqlLiteral(r.sessionId)},
859
- ${r.agentId ? this.sqlLiteral(r.agentId) : 'NULL'},
860
- ${this.sqlLiteral(r.status)},
861
- ${this.sqlLiteral(r.startedAt ?? '')},
862
- ${this.sqlLiteral(r.endedAt ?? '')},
863
- ${incomingCardTitle},
864
- ${this.sqlLiteral(r.taskTitle ?? '')},
865
- ${this.sqlLiteral(r.model ?? '')},
866
- ${this.sqlLiteral(r.engine ?? '')},
867
- ${this.sqlLiteral(r.channelType ?? '')},
868
- ${this.sqlLiteral(r.channelTarget ?? '')},
869
- ${Number.isFinite(r.turns) ? String(Math.floor(r.turns)) : '0'},
870
- ${Number.isFinite(r.totalTokens) ? String(Math.floor(r.totalTokens)) : '0'},
871
- ${this.sqlBool(Boolean(r.disconnectCapable))},
872
- ${u}
873
- )`;
874
- }).join(',\n');
875
- // Upsert semantics:
876
- // - refresh updates runtime fields (status/times/tokens/etc)
877
- // - preserves user-edited card_title if it exists (non-empty)
878
- // - initializes card_title from incoming card_title, else task_title.
879
- const sql = `
218
+ WHERE source = ${this.sqlLiteral(n)};
219
+ `;await this.runDuckDBExecForFleetWithLockRetry(s,{maxWaitMs:2e3});const r=200;for(let o=0;o<e.length;o+=r){const d=e.slice(o,o+r).map(c=>{const _=c.updatedAt!=null&&c.updatedAt!==""?this.sqlLiteral(c.updatedAt):"current_timestamp",m=a.get(String(c.sessionId??"").trim())??c.cardTitle,E=m!==void 0?this.sqlNullableLiteral(m):"NULL";return`(
220
+ ${this.sqlLiteral(n)},
221
+ ${this.sqlLiteral(c.sessionId)},
222
+ ${c.agentId?this.sqlLiteral(c.agentId):"NULL"},
223
+ ${this.sqlLiteral(c.status)},
224
+ ${this.sqlLiteral(c.startedAt??"")},
225
+ ${this.sqlLiteral(c.endedAt??"")},
226
+ ${E},
227
+ ${this.sqlLiteral(c.taskTitle??"")},
228
+ ${this.sqlLiteral(c.model??"")},
229
+ ${this.sqlLiteral(c.engine??"")},
230
+ ${this.sqlLiteral(c.channelType??"")},
231
+ ${this.sqlLiteral(c.channelTarget??"")},
232
+ ${Number.isFinite(c.turns)?String(Math.floor(c.turns)):"0"},
233
+ ${Number.isFinite(c.totalTokens)?String(Math.floor(c.totalTokens)):"0"},
234
+ ${this.sqlBool(!!c.disconnectCapable)},
235
+ ${_}
236
+ )`}).join(`,
237
+ `),h=`
880
238
  INSERT INTO ${FLEET_SESSIONS_TABLE} (
881
239
  source,
882
240
  session_id,
@@ -895,7 +253,7 @@ INSERT INTO ${FLEET_SESSIONS_TABLE} (
895
253
  disconnect_capable,
896
254
  updated_at
897
255
  ) VALUES
898
- ${values}
256
+ ${d}
899
257
  ON CONFLICT (source, session_id) DO UPDATE SET
900
258
  agent_id = excluded.agent_id,
901
259
  status = excluded.status,
@@ -915,26 +273,13 @@ ON CONFLICT (source, session_id) DO UPDATE SET
915
273
  total_tokens = excluded.total_tokens,
916
274
  disconnect_capable = excluded.disconnect_capable,
917
275
  updated_at = excluded.updated_at;
918
- `;
919
- await this.runDuckDBExecForFleetWithLockRetry(sql, { maxWaitMs: 2000 });
920
- }
921
- }
922
- async updateFleetCardTitle(sourceId, sessionId, cardTitle) {
923
- await this.ensureFleetSchema();
924
- const safeSessionId = String(sessionId ?? '').trim();
925
- if (!safeSessionId) {
926
- return;
927
- }
928
- const title = cardTitle ?? '';
929
- const safeSourceId = String(sourceId ?? '').trim() || 'local';
930
- // Lock contention happens during background indexing; retry writes briefly.
931
- const sql = `
276
+ `;await this.runDuckDBExecForFleetWithLockRetry(h,{maxWaitMs:2e3})}}async updateFleetCardTitle(t,e,n){await this.ensureFleetSchema();const i=String(e??"").trim();if(!i)return;const a=n??"",s=String(t??"").trim()||"local",r=`
932
277
  BEGIN;
933
278
  UPDATE ${FLEET_SESSIONS_TABLE}
934
- SET card_title = ${this.sqlLiteral(title)},
279
+ SET card_title = ${this.sqlLiteral(a)},
935
280
  updated_at = current_timestamp
936
- WHERE source = ${this.sqlLiteral(safeSourceId)}
937
- AND session_id = ${this.sqlLiteral(safeSessionId)};
281
+ WHERE source = ${this.sqlLiteral(s)}
282
+ AND session_id = ${this.sqlLiteral(i)};
938
283
 
939
284
  INSERT INTO ${FLEET_SESSIONS_TABLE} (
940
285
  source,
@@ -942,53 +287,20 @@ INSERT INTO ${FLEET_SESSIONS_TABLE} (
942
287
  card_title,
943
288
  updated_at
944
289
  ) SELECT
945
- ${this.sqlLiteral(safeSourceId)},
946
- ${this.sqlLiteral(safeSessionId)},
947
- ${this.sqlLiteral(title)},
290
+ ${this.sqlLiteral(s)},
291
+ ${this.sqlLiteral(i)},
292
+ ${this.sqlLiteral(a)},
948
293
  current_timestamp
949
294
  WHERE NOT EXISTS (
950
295
  SELECT 1 FROM ${FLEET_SESSIONS_TABLE}
951
- WHERE source = ${this.sqlLiteral(safeSourceId)}
952
- AND session_id = ${this.sqlLiteral(safeSessionId)}
296
+ WHERE source = ${this.sqlLiteral(s)}
297
+ AND session_id = ${this.sqlLiteral(i)}
953
298
  );
954
299
  COMMIT;
955
- `;
956
- await this.runDuckDBExecForFleetWithLockRetry(sql, { maxWaitMs: 2000 });
957
- }
958
- async readFleetCardTitles(sessionIds) {
959
- const ids = Array.from(new Set(sessionIds.filter(s => typeof s === 'string' && s.trim() !== '')));
960
- if (ids.length === 0) {
961
- return {};
962
- }
963
- await this.ensureFleetSchema();
964
- const out = {};
965
- const chunkSize = 200;
966
- for (let i = 0; i < ids.length; i += chunkSize) {
967
- const chunk = ids.slice(i, i + chunkSize);
968
- const sql = `
300
+ `;await this.runDuckDBExecForFleetWithLockRetry(r,{maxWaitMs:2e3})}async readFleetCardTitles(t){const e=Array.from(new Set(t.filter(a=>typeof a=="string"&&a.trim()!=="")));if(e.length===0)return{};await this.ensureFleetSchema();const n={},i=200;for(let a=0;a<e.length;a+=i){const s=e.slice(a,a+i),r=`
969
301
  SELECT
970
302
  session_id as sessionId,
971
303
  arg_max(card_title, updated_at) as cardTitle
972
304
  FROM ${FLEET_SESSIONS_TABLE}
973
- WHERE session_id IN (${chunk.map(s => this.sqlLiteral(String(s))).join(', ')})
974
- GROUP BY session_id`;
975
- const rows = await this.runDuckDB(sql);
976
- for (const row of rows) {
977
- if (!row.sessionId) {
978
- continue;
979
- }
980
- out[row.sessionId] = row.cardTitle === null ? '' : String(row.cardTitle);
981
- }
982
- }
983
- return out;
984
- }
985
- dispose() {
986
- this.cache.clear();
987
- this.activeDuckDbQueries = 0;
988
- while (this.duckDbQueryWaiters.length > 0) {
989
- const waiter = this.duckDbQueryWaiters.shift();
990
- waiter?.();
991
- }
992
- }
993
- }
994
- exports.QueryRunnerImpl = QueryRunnerImpl;
305
+ WHERE session_id IN (${s.map(u=>this.sqlLiteral(String(u))).join(", ")})
306
+ GROUP BY session_id`,o=await this.runDuckDB(r);for(const u of o)u.sessionId&&(n[u.sessionId]=u.cardTitle===null?"":String(u.cardTitle))}return n}dispose(){for(this.cache.clear(),this.activeDuckDbQueries=0;this.duckDbQueryWaiters.length>0;)this.duckDbQueryWaiters.shift()?.()}}exports.QueryRunnerImpl=QueryRunnerImpl;