@agenthippo-ai/agenthippo 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/bin/agenthippo.js +2 -0
- package/out/agentpack/github.js +547 -0
- package/out/agentpack/index.js +66 -0
- package/out/agentpack/install.js +297 -0
- package/out/agentpack/manager.js +441 -0
- package/out/agentpack/manifest.js +135 -0
- package/out/agentpack/paths.js +475 -0
- package/out/agentpack/publish.js +248 -0
- package/out/agentpack/stores.js +554 -0
- package/out/agentpack/types.js +5 -0
- package/out/analytics/dashboard/artifactManager.js +439 -0
- package/out/analytics/dashboard/fleetDisplayUtils.js +159 -0
- package/out/analytics/dashboard/fleetOrchestrator.js +142 -0
- package/out/analytics/dashboard/fleetRegistry.js +79 -0
- package/out/analytics/dashboard/fleetRowDefaults.js +87 -0
- package/out/analytics/dashboard/fleetScriptAdapter.js +146 -0
- package/out/analytics/dashboard/fleetStatusUtils.js +30 -0
- package/out/analytics/dashboard/fleetTitleUtils.js +68 -0
- package/out/analytics/dashboard/fleetTypes.js +29 -0
- package/out/analytics/dashboard/index.js +17 -0
- package/out/analytics/dashboard/indexingService.js +422 -0
- package/out/analytics/dashboard/localFleetAdapter.js +222 -0
- package/out/analytics/dashboard/performanceMonitor.js +76 -0
- package/out/analytics/dashboard/processManager.js +209 -0
- package/out/analytics/dashboard/provider.js +3885 -0
- package/out/analytics/dashboard/queryRunner.js +994 -0
- package/out/analytics/dashboard/refreshPolicy.js +16 -0
- package/out/analytics/dashboard/scheduledFleetFingerprint.js +22 -0
- package/out/analytics/dashboard/scheduledFleetStorage.js +241 -0
- package/out/analytics/dashboard/scheduledFleetUtils.js +22 -0
- package/out/analytics/dashboard/sessionEventFleetStats.js +118 -0
- package/out/analytics/dashboard/sessionJsonlFleet.js +204 -0
- package/out/analytics/dashboard/teamViewDiscovery.js +106 -0
- package/out/analytics/dashboard/viewsConfigMerge.js +221 -0
- package/out/analytics/dashboard/webview/analytics-panel.html +155 -0
- package/out/analytics/dashboard/webview/codicon.ttf +0 -0
- package/out/analytics/dashboard/webview/index.html +78 -0
- package/out/analytics/dashboard/webview/panel.js +2295 -0
- package/out/analytics/dashboard/webview/runtime-bridge.js +82 -0
- package/out/analytics/dashboard/webview/styles.css +1009 -0
- package/out/analytics/lifecycle.js +43 -0
- package/out/analytics/service.js +1279 -0
- package/out/analytics/sessionEvents.js +231 -0
- package/out/auth/bootstrapApply.js +72 -0
- package/out/auth/brokerClient.js +126 -0
- package/out/auth/callbackUri.js +59 -0
- package/out/auth/callbackUriParse.js +59 -0
- package/out/auth/githubStoreGate.js +70 -0
- package/out/auth/loopbackAuthServer.js +165 -0
- package/out/auth/pkce.js +9 -0
- package/out/auth/provider.js +239 -0
- package/out/auth/sessionStore.js +193 -0
- package/out/auth/signInFlow.js +182 -0
- package/out/auth/types.js +12 -0
- package/out/auth-broker/config.js +62 -0
- package/out/auth-broker/jwt.js +105 -0
- package/out/auth-broker/pkce.js +57 -0
- package/out/auth-broker/server.js +539 -0
- package/out/auth-broker/store.js +273 -0
- package/out/base-prompts/gateway/openclaw-starter.json5 +144 -0
- package/out/base-prompts/gateway/slack-socket-mode-minimal.manifest.json +44 -0
- package/out/base-prompts/mcp-servers/.mcp.json +13 -0
- package/out/base-prompts/mcp-servers/langfuse-analytics/README.md +142 -0
- package/out/base-prompts/mcp-servers/langfuse-analytics/mcp.json +13 -0
- package/out/base-prompts/mcp-servers/langfuse-analytics/package-lock.json +1192 -0
- package/out/base-prompts/mcp-servers/langfuse-analytics/package.json +23 -0
- package/out/base-prompts/mcp-servers/langfuse-analytics/scripts/run-with-env.sh +12 -0
- package/out/base-prompts/mcp-servers/langfuse-analytics/scripts/sdk-test.js +102 -0
- package/out/base-prompts/mcp-servers/langfuse-analytics/scripts/simple-test.js +137 -0
- package/out/base-prompts/mcp-servers/langfuse-analytics/scripts/test-client.js +118 -0
- package/out/base-prompts/mcp-servers/langfuse-analytics/scripts/test-server.js +209 -0
- package/out/base-prompts/mcp-servers/langfuse-analytics/src/client.ts +431 -0
- package/out/base-prompts/mcp-servers/langfuse-analytics/src/index.ts +270 -0
- package/out/base-prompts/mcp-servers/langfuse-analytics/tsconfig.json +18 -0
- package/out/base-prompts/rules/AGENTS.md +204 -0
- package/out/base-prompts/skills/agent-browser/SKILL.md +102 -0
- package/out/base-prompts/skills/agent-builder/SKILL.md +73 -0
- package/out/base-prompts/skills/agent-builder/references/agent-pack.md +63 -0
- package/out/base-prompts/skills/agent-builder/references/crewai.md +66 -0
- package/out/base-prompts/skills/agent-builder/references/langchain.md +60 -0
- package/out/base-prompts/skills/agent-builder/references/raw-sdk.md +73 -0
- package/out/base-prompts/skills/agent-engine-creator/SKILL.md +586 -0
- package/out/base-prompts/skills/agent-engine-installer/SKILL.md +106 -0
- package/out/base-prompts/skills/agent-engine-installer/scripts/install-engine.mjs +259 -0
- package/out/base-prompts/skills/agent-engine-installer/scripts/install-engine.ps1 +189 -0
- package/out/base-prompts/skills/agenthippo-cli/SKILL.md +69 -0
- package/out/base-prompts/skills/agenthippo-cli/scripts/install.sh +63 -0
- package/out/base-prompts/skills/agentpack-creator/SKILL.md +375 -0
- package/out/base-prompts/skills/agentpack-creator/references/agent-templates.md +261 -0
- package/out/base-prompts/skills/agentpack-creator/references/agents-md-guide.md +195 -0
- package/out/base-prompts/skills/agentpack-creator/scripts/init_pack.py +391 -0
- package/out/base-prompts/skills/agentpack-creator/scripts/init_pack_test.py +294 -0
- package/out/base-prompts/skills/agentpack-testbench/SKILL.md +135 -0
- package/out/base-prompts/skills/algorithmic-art/LICENSE.txt +202 -0
- package/out/base-prompts/skills/algorithmic-art/SKILL.md +405 -0
- package/out/base-prompts/skills/algorithmic-art/templates/generator_template.js +223 -0
- package/out/base-prompts/skills/algorithmic-art/templates/viewer.html +599 -0
- package/out/base-prompts/skills/debug-agent/SKILL.md +83 -0
- package/out/base-prompts/skills/desktop-automation/SKILL.md +166 -0
- package/out/base-prompts/skills/desktop-automation/references/agenthippo-ui-recipes.md +441 -0
- package/out/base-prompts/skills/desktop-automation/scripts/windows-desktop-uia.psm1 +280 -0
- package/out/base-prompts/skills/docx/LICENSE.txt +30 -0
- package/out/base-prompts/skills/docx/SKILL.md +197 -0
- package/out/base-prompts/skills/docx/docx-js.md +350 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/mce/mc.xsd +75 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/out/base-prompts/skills/docx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/out/base-prompts/skills/docx/ooxml/scripts/pack.py +159 -0
- package/out/base-prompts/skills/docx/ooxml/scripts/unpack.py +29 -0
- package/out/base-prompts/skills/docx/ooxml/scripts/validate.py +69 -0
- package/out/base-prompts/skills/docx/ooxml/scripts/validation/__init__.py +15 -0
- package/out/base-prompts/skills/docx/ooxml/scripts/validation/base.py +951 -0
- package/out/base-prompts/skills/docx/ooxml/scripts/validation/docx.py +274 -0
- package/out/base-prompts/skills/docx/ooxml/scripts/validation/pptx.py +315 -0
- package/out/base-prompts/skills/docx/ooxml/scripts/validation/redlining.py +279 -0
- package/out/base-prompts/skills/docx/ooxml.md +610 -0
- package/out/base-prompts/skills/docx/scripts/__init__.py +1 -0
- package/out/base-prompts/skills/docx/scripts/document.py +1276 -0
- package/out/base-prompts/skills/docx/scripts/templates/comments.xml +3 -0
- package/out/base-prompts/skills/docx/scripts/templates/commentsExtended.xml +3 -0
- package/out/base-prompts/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/out/base-prompts/skills/docx/scripts/templates/commentsIds.xml +3 -0
- package/out/base-prompts/skills/docx/scripts/templates/people.xml +3 -0
- package/out/base-prompts/skills/docx/scripts/utilities.py +374 -0
- package/out/base-prompts/skills/gateway-outbound/SKILL.md +136 -0
- package/out/base-prompts/skills/mcp-builder/LICENSE.txt +202 -0
- package/out/base-prompts/skills/mcp-builder/SKILL.md +328 -0
- package/out/base-prompts/skills/mcp-builder/reference/evaluation.md +602 -0
- package/out/base-prompts/skills/mcp-builder/reference/mcp_best_practices.md +249 -0
- package/out/base-prompts/skills/mcp-builder/reference/node_mcp_server.md +970 -0
- package/out/base-prompts/skills/mcp-builder/reference/python_mcp_server.md +719 -0
- package/out/base-prompts/skills/mcp-builder/scripts/connections.py +151 -0
- package/out/base-prompts/skills/mcp-builder/scripts/evaluation.py +373 -0
- package/out/base-prompts/skills/mcp-builder/scripts/example_evaluation.xml +22 -0
- package/out/base-prompts/skills/mcp-builder/scripts/requirements.txt +2 -0
- package/out/base-prompts/skills/openclaw/SKILL.md +406 -0
- package/out/base-prompts/skills/openclaw/scripts/run-smoke.sh +61 -0
- package/out/base-prompts/skills/pdf/LICENSE.txt +30 -0
- package/out/base-prompts/skills/pdf/SKILL.md +294 -0
- package/out/base-prompts/skills/pdf/forms.md +205 -0
- package/out/base-prompts/skills/pdf/reference.md +612 -0
- package/out/base-prompts/skills/pdf/scripts/check_bounding_boxes.py +70 -0
- package/out/base-prompts/skills/pdf/scripts/check_bounding_boxes_test.py +226 -0
- package/out/base-prompts/skills/pdf/scripts/check_fillable_fields.py +12 -0
- package/out/base-prompts/skills/pdf/scripts/convert_pdf_to_images.py +35 -0
- package/out/base-prompts/skills/pdf/scripts/create_validation_image.py +41 -0
- package/out/base-prompts/skills/pdf/scripts/extract_form_field_info.py +152 -0
- package/out/base-prompts/skills/pdf/scripts/fill_fillable_fields.py +114 -0
- package/out/base-prompts/skills/pdf/scripts/fill_pdf_form_with_annotations.py +108 -0
- package/out/base-prompts/skills/pptx/LICENSE.txt +30 -0
- package/out/base-prompts/skills/pptx/SKILL.md +484 -0
- package/out/base-prompts/skills/pptx/html2pptx.md +625 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/mce/mc.xsd +75 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/out/base-prompts/skills/pptx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/out/base-prompts/skills/pptx/ooxml/scripts/pack.py +159 -0
- package/out/base-prompts/skills/pptx/ooxml/scripts/unpack.py +29 -0
- package/out/base-prompts/skills/pptx/ooxml/scripts/validate.py +69 -0
- package/out/base-prompts/skills/pptx/ooxml/scripts/validation/__init__.py +15 -0
- package/out/base-prompts/skills/pptx/ooxml/scripts/validation/base.py +951 -0
- package/out/base-prompts/skills/pptx/ooxml/scripts/validation/docx.py +274 -0
- package/out/base-prompts/skills/pptx/ooxml/scripts/validation/pptx.py +315 -0
- package/out/base-prompts/skills/pptx/ooxml/scripts/validation/redlining.py +279 -0
- package/out/base-prompts/skills/pptx/ooxml.md +427 -0
- package/out/base-prompts/skills/pptx/scripts/html2pptx.js +984 -0
- package/out/base-prompts/skills/pptx/scripts/inventory.py +1020 -0
- package/out/base-prompts/skills/pptx/scripts/rearrange.py +231 -0
- package/out/base-prompts/skills/pptx/scripts/replace.py +385 -0
- package/out/base-prompts/skills/pptx/scripts/thumbnail.py +450 -0
- package/out/base-prompts/skills/prompt-lab/SKILL.md +149 -0
- package/out/base-prompts/skills/prompt-lab/scripts/query-analytics.sh +2551 -0
- package/out/base-prompts/skills/skill-creator/LICENSE.txt +202 -0
- package/out/base-prompts/skills/skill-creator/SKILL.md +371 -0
- package/out/base-prompts/skills/skill-creator/references/output-patterns.md +82 -0
- package/out/base-prompts/skills/skill-creator/references/workflows.md +28 -0
- package/out/base-prompts/skills/skill-creator/scripts/init_skill.py +303 -0
- package/out/base-prompts/skills/skill-creator/scripts/package_skill.py +110 -0
- package/out/base-prompts/skills/skill-creator/scripts/quick_validate.py +95 -0
- package/out/base-prompts/skills/skill-installer/SKILL.md +251 -0
- package/out/base-prompts/skills/skill-installer/references/store-api.md +219 -0
- package/out/base-prompts/skills/spotlight-dashboard/SKILL.md +83 -0
- package/out/base-prompts/skills/spotlight-insights/SKILL.md +101 -0
- package/out/base-prompts/skills/spotlight-optimize/SKILL.md +93 -0
- package/out/base-prompts/skills/spotlight-optimize/scripts/query-analytics.sh +2551 -0
- package/out/base-prompts/skills/spotlight-query/SKILL.md +314 -0
- package/out/base-prompts/skills/spotlight-query/references/otel-schema.md +163 -0
- package/out/base-prompts/skills/spotlight-query/scripts/query-analytics.sh +2551 -0
- package/out/base-prompts/skills/spotlight-query/scripts/query-analytics.test.sh +744 -0
- package/out/base-prompts/skills/spotlight-query/scripts/test-fixtures/analytics/sessions/sess-test-1.jsonl +14 -0
- package/out/base-prompts/skills/spotlight-query/scripts/test-fixtures/analytics/traces/.duckdb-index.json +7 -0
- package/out/base-prompts/skills/spotlight-query/scripts/test-fixtures/analytics/traces/sample.jsonl +5 -0
- package/out/base-prompts/skills/spotlight-report/SKILL.md +86 -0
- package/out/base-prompts/skills/spotlight-visualize/SKILL.md +92 -0
- package/out/base-prompts/skills/spotlight-visualize/scripts/query-analytics.sh +2551 -0
- package/out/base-prompts/skills/xlsx/LICENSE.txt +30 -0
- package/out/base-prompts/skills/xlsx/SKILL.md +289 -0
- package/out/base-prompts/skills/xlsx/recalc.py +178 -0
- package/out/branding.js +23 -0
- package/out/cli/commands/anywhere.js +66 -0
- package/out/cli/commands/ask.js +243 -0
- package/out/cli/commands/auth-broker.js +24 -0
- package/out/cli/commands/auth.js +219 -0
- package/out/cli/commands/chat.js +354 -0
- package/out/cli/commands/deploy.js +223 -0
- package/out/cli/commands/gateway.js +160 -0
- package/out/cli/commands/pack.js +220 -0
- package/out/cli/commands/probe-custom-engine.js +82 -0
- package/out/cli/commands/serve.js +583 -0
- package/out/cli/commands/store.js +919 -0
- package/out/cli/credential-context.js +113 -0
- package/out/cli/deploy-init.js +2087 -0
- package/out/cli/deps.js +238 -0
- package/out/cli/index.js +390 -0
- package/out/cli/pack-loader.js +376 -0
- package/out/cli/run-custom-engine-runner.js +318 -0
- package/out/cli/runtime.js +409 -0
- package/out/cli/serve-hardening.js +325 -0
- package/out/cli/state-sync.js +135 -0
- package/out/cli/utils.js +220 -0
- package/out/cli/vscode-shim.js +86 -0
- package/out/engines/base.js +159 -0
- package/out/engines/claude.js +1215 -0
- package/out/engines/codex.js +759 -0
- package/out/engines/custom.js +632 -0
- package/out/engines/customEngineIpc.js +95 -0
- package/out/engines/customEngineRunnerEmbed.js +107 -0
- package/out/engines/customRegistry.js +274 -0
- package/out/engines/embeddedCustomEngineRunner.generated.js +9 -0
- package/out/engines/engineApiKey.js +138 -0
- package/out/engines/factory.js +45 -0
- package/out/engines/install.js +372 -0
- package/out/engines/persistentEngineWorker.js +320 -0
- package/out/engines/publish.js +341 -0
- package/out/engines/types.js +17 -0
- package/out/examples/run-headless-repl.js +291 -0
- package/out/examples/run-headless.js +187 -0
- package/out/extension.js +4472 -0
- package/out/gateway/bridge.js +805 -0
- package/out/gateway/cli-agent-id.js +36 -0
- package/out/gateway/client.js +303 -0
- package/out/gateway/client.test.js +395 -0
- package/out/gateway/gateway-scope-errors.js +14 -0
- package/out/gateway/gatewayBackup.js +76 -0
- package/out/gateway/gatewayRouteIndex.js +371 -0
- package/out/gateway/gatewaySessionStore.js +243 -0
- package/out/gateway/index.js +31 -0
- package/out/gateway/lifecycle.js +3056 -0
- package/out/gateway/openclaw-channel-routing.js +317 -0
- package/out/gateway/outboundHandles.js +373 -0
- package/out/gateway/outboundPaths.js +72 -0
- package/out/gateway/outboundSend.js +254 -0
- package/out/gateway/protocol.js +48 -0
- package/out/gateway/resetMappings.js +52 -0
- package/out/gateway/service.js +1244 -0
- package/out/gateway/sessionRouting.js +77 -0
- package/out/headless/index.js +505 -0
- package/out/headless/sync.js +473 -0
- package/out/mcp/publish.js +143 -0
- package/out/mcp.js +597 -0
- package/out/permissions.js +108 -0
- package/out/permissions.mapping.yaml +68 -0
- package/out/registry/index.js +332 -0
- package/out/remote/handleRemoteChat.js +122 -0
- package/out/remote/remotePackStatusBar.js +103 -0
- package/out/remote/serveClient.js +216 -0
- package/out/remoteSkills.js +191 -0
- package/out/runtime/index.js +32 -0
- package/out/runtime/interfaces/config-provider.js +32 -0
- package/out/runtime/interfaces/edit-tracker.js +22 -0
- package/out/runtime/interfaces/index.js +29 -0
- package/out/runtime/interfaces/logger.js +40 -0
- package/out/runtime/interfaces/permission-handler.js +66 -0
- package/out/runtime/interfaces/session-store.js +342 -0
- package/out/runtime/vscode/index.js +20 -0
- package/out/runtime/vscode/vscode-config-provider.js +77 -0
- package/out/runtime/vscode/vscode-edit-tracker.js +120 -0
- package/out/runtime/vscode/vscode-logger.js +30 -0
- package/out/runtime/vscode/vscode-permission-handler.js +72 -0
- package/out/runtime/vscode/vscode-session-store.js +22 -0
- package/out/scripts/agentide-litellm.ps1 +501 -0
- package/out/scripts/agentide-litellm.sh +700 -0
- package/out/scripts/agentide_litellm_hooks_v1.py +604 -0
- package/out/scripts/analytics/agent-fleet-widget.js +954 -0
- package/out/scripts/analytics/agentide-litellm-otel.config.yaml +160 -0
- package/out/scripts/analytics/default-seed-scripts.json +12 -0
- package/out/scripts/analytics/duckdbLocator.js +29 -0
- package/out/scripts/analytics/fleet-local-adapter.js +246 -0
- package/out/scripts/analytics/fleet-workflow.sh +263 -0
- package/out/scripts/analytics/generate-default-charts.py +685 -0
- package/out/scripts/analytics/hotspot-analysis-widget.js +909 -0
- package/out/scripts/analytics/index-traces.py +1394 -0
- package/out/scripts/analytics/install-analytics.sh +286 -0
- package/out/scripts/analytics/live-fleet-4-collector.cjs +315 -0
- package/out/scripts/analytics/live-fleet-4-daemon.mjs +134 -0
- package/out/scripts/analytics/live-fleet-4-widget.cjs +433 -0
- package/out/scripts/analytics/otel-collector.yaml +55 -0
- package/out/scripts/analytics/query-analytics.ps1 +396 -0
- package/out/scripts/analytics/query-analytics.sh +2551 -0
- package/out/scripts/analytics/session-comparison-widget.js +1468 -0
- package/out/scripts/analytics/session-timeline-widget.js +2137 -0
- package/out/scripts/analytics/setup-analytics.ps1 +432 -0
- package/out/scripts/analytics/setup-analytics.sh +854 -0
- package/out/scripts/analytics/start-analytics.ps1 +169 -0
- package/out/scripts/analytics/start-analytics.sh +323 -0
- package/out/scripts/analytics/token-cost-flamegraph-widget.js +954 -0
- package/out/scripts/analytics/token-cost-trend-widget.js +1062 -0
- package/out/scripts/analytics/workflows-collector.cjs +315 -0
- package/out/scripts/analytics/workflows-daemon.mjs +186 -0
- package/out/scripts/analytics/workflows-widget.cjs +433 -0
- package/out/scripts/analytics/wow-model-widget.js +191 -0
- package/out/scripts/gateway/Dockerfile.serve +45 -0
- package/out/scripts/gateway/docker-serve.sh +248 -0
- package/out/scripts/gateway/setup-gateway-server.ps1 +953 -0
- package/out/scripts/gateway/setup-gateway-server.sh +935 -0
- package/out/scripts/gateway/setup-gateway.ps1 +1813 -0
- package/out/scripts/gateway/setup-gateway.sh +1541 -0
- package/out/scripts/setup-cli.ps1 +86 -0
- package/out/scripts/setup-cli.sh +117 -0
- package/out/scripts/tools-manifest.json +83 -0
- package/out/scripts/vendor-tools.mjs +234 -0
- package/out/session.js +272 -0
- package/out/shared/agentEngines.js +170 -0
- package/out/shared/index.js +109 -0
- package/out/shared/models.js +235 -0
- package/out/shared/providers.js +202 -0
- package/out/skills/publish.js +178 -0
- package/out/spotlight/install.js +339 -0
- package/out/spotlight/publish.js +544 -0
- package/out/spotlight/yaml.js +31 -0
- package/out/store/github/setup.js +235 -0
- package/out/store/github/templates/build-index.ts +339 -0
- package/out/store/github/templates/build-index.yml +97 -0
- package/out/store/github/templates/package.json +11 -0
- package/out/store/index.js +755 -0
- package/out/store/oramaIndex.js +884 -0
- package/out/store/shared.js +241 -0
- package/out/sync.js +1827 -0
- package/out/terminalLogger.js +358 -0
- package/out/test/agentEnvFile.test.js +97 -0
- package/out/test/agentYaml.test.js +373 -0
- package/out/test/agentpack.test.js +639 -0
- package/out/test/analytics-lifecycle.test.js +174 -0
- package/out/test/analytics.test.js +524 -0
- package/out/test/auth-bootstrapApply.test.js +102 -0
- package/out/test/auth-broker.test.js +434 -0
- package/out/test/auth-callback.test.js +62 -0
- package/out/test/branding.test.js +229 -0
- package/out/test/cli-agent-id.test.js +55 -0
- package/out/test/credential-context.test.js +105 -0
- package/out/test/customEngineInstall.test.js +100 -0
- package/out/test/customRegistry.test.js +122 -0
- package/out/test/deploy-init.test.js +532 -0
- package/out/test/deps-auto-install.test.js +81 -0
- package/out/test/engine-integration.test.js +297 -0
- package/out/test/enginePaths.test.js +195 -0
- package/out/test/enginePublish.test.js +82 -0
- package/out/test/fleetDisplayUtils.test.js +96 -0
- package/out/test/gateway-client.test.js +381 -0
- package/out/test/gateway-lifecycle.test.js +608 -0
- package/out/test/gateway-outbound.test.js +531 -0
- package/out/test/gateway-reset-mappings.test.js +221 -0
- package/out/test/gateway-route-index.test.js +235 -0
- package/out/test/gateway-session-routing.test.js +47 -0
- package/out/test/gateway-session-store.test.js +216 -0
- package/out/test/github.test.js +232 -0
- package/out/test/headless-sync.test.js +279 -0
- package/out/test/helpers/manifest-fixtures.js +27 -0
- package/out/test/mcp-obo.test.js +82 -0
- package/out/test/mcp.test.js +307 -0
- package/out/test/openclaw-channel-routing.test.js +191 -0
- package/out/test/pathSafety.test.js +63 -0
- package/out/test/permissions.test.js +175 -0
- package/out/test/persistent-engine-worker.test.js +220 -0
- package/out/test/refreshPolicy.test.js +60 -0
- package/out/test/registry.test.js +351 -0
- package/out/test/runtime.test.js +349 -0
- package/out/test/scheduledFleetStorage.test.js +72 -0
- package/out/test/serve-hardening.test.js +192 -0
- package/out/test/serveClient.test.js +173 -0
- package/out/test/sessionJsonlFleet.test.js +78 -0
- package/out/test/shared.test.js +173 -0
- package/out/test/skills-mcp.test.js +299 -0
- package/out/test/spotlightPublish.test.js +299 -0
- package/out/test/spotlightYaml.test.js +58 -0
- package/out/test/state-sync-peer.test.js +74 -0
- package/out/test/store.test.js +331 -0
- package/out/test/stores.test.js +504 -0
- package/out/test/sync-switch.test.js +251 -0
- package/out/test/teamViewDiscovery.test.js +90 -0
- package/out/test/toolPath.test.js +120 -0
- package/out/test/utils.test.js +308 -0
- package/out/test/viewsConfigMerge.test.js +180 -0
- package/out/test/windows-command-line.test.js +75 -0
- package/out/utils/agentEnvFile.js +131 -0
- package/out/utils/binary.js +175 -0
- package/out/utils/index.js +37 -0
- package/out/utils/network.js +74 -0
- package/out/utils/pathSafety.js +60 -0
- package/out/utils/paths.js +116 -0
- package/out/utils/pid.js +180 -0
- package/out/utils/pythonRunner.js +258 -0
- package/out/utils/resolveNodeBinary.js +168 -0
- package/out/utils/toolPath.js +83 -0
- package/out/utils/windowsCommandLine.js +29 -0
- package/out/utils.js +915 -0
- package/out/workspaceFolders.js +59 -0
- package/package.json +41 -0
|
@@ -0,0 +1,685 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Copyright (c) AgentHippo.ai. All rights reserved.
|
|
3
|
+
"""
|
|
4
|
+
Generate default analytics dashboard charts from OTEL trace data.
|
|
5
|
+
|
|
6
|
+
Usage:
|
|
7
|
+
uv run --with matplotlib python3 generate-default-charts.py <traces_dir> <output_dir>
|
|
8
|
+
uv run --with matplotlib python3 generate-default-charts.py
|
|
9
|
+
|
|
10
|
+
Reads DuckDB JSON output from stdin (piped from query script) or queries directly.
|
|
11
|
+
Outputs PNG charts to <output_dir>/charts/.
|
|
12
|
+
|
|
13
|
+
Exit codes:
|
|
14
|
+
0 = charts generated
|
|
15
|
+
1 = error
|
|
16
|
+
2 = no data available
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import json
|
|
20
|
+
import os
|
|
21
|
+
import sys
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
from datetime import datetime
|
|
24
|
+
|
|
25
|
+
try:
|
|
26
|
+
import duckdb as _duckdb_module
|
|
27
|
+
DUCKDB_AVAILABLE = True
|
|
28
|
+
except ImportError:
|
|
29
|
+
DUCKDB_AVAILABLE = False
|
|
30
|
+
|
|
31
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
32
|
+
# Config
|
|
33
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
34
|
+
|
|
35
|
+
CHART_WIDTH = 8
|
|
36
|
+
CHART_HEIGHT = 4.5
|
|
37
|
+
DPI = 150
|
|
38
|
+
|
|
39
|
+
# VS Code-friendly dark theme colors
|
|
40
|
+
BG_COLOR = '#1e1e1e'
|
|
41
|
+
FG_COLOR = '#cccccc'
|
|
42
|
+
GRID_COLOR = '#333333'
|
|
43
|
+
ACCENT_COLORS = ['#569cd6', '#4ec9b0', '#ce9178', '#dcdcaa', '#c586c0', '#9cdcfe', '#d4d4d4']
|
|
44
|
+
|
|
45
|
+
def parse_disabled_charts():
|
|
46
|
+
"""Read disabled chart filenames from AGENTIDE_DISABLED_CHARTS."""
|
|
47
|
+
raw = (os.environ.get('AGENTIDE_DISABLED_CHARTS') or '').strip()
|
|
48
|
+
if not raw:
|
|
49
|
+
return set()
|
|
50
|
+
|
|
51
|
+
disabled = set()
|
|
52
|
+
if raw.startswith('['):
|
|
53
|
+
try:
|
|
54
|
+
parsed = json.loads(raw)
|
|
55
|
+
if isinstance(parsed, list):
|
|
56
|
+
for item in parsed:
|
|
57
|
+
if isinstance(item, str) and item.strip():
|
|
58
|
+
disabled.add(Path(item.strip()).name.lower())
|
|
59
|
+
return disabled
|
|
60
|
+
except Exception:
|
|
61
|
+
pass
|
|
62
|
+
|
|
63
|
+
for part in raw.split(','):
|
|
64
|
+
name = part.strip()
|
|
65
|
+
if name:
|
|
66
|
+
disabled.add(Path(name).name.lower())
|
|
67
|
+
return disabled
|
|
68
|
+
|
|
69
|
+
def is_chart_disabled(disabled_set, filename):
|
|
70
|
+
return Path(filename).name.lower() in disabled_set
|
|
71
|
+
|
|
72
|
+
def remove_chart_if_exists(output_dir, filename):
|
|
73
|
+
target = Path(output_dir) / filename
|
|
74
|
+
try:
|
|
75
|
+
target.unlink()
|
|
76
|
+
except FileNotFoundError:
|
|
77
|
+
pass
|
|
78
|
+
except Exception:
|
|
79
|
+
pass
|
|
80
|
+
|
|
81
|
+
def format_session_handle(session_id):
|
|
82
|
+
"""Generate a short, stable session handle from full session id."""
|
|
83
|
+
value = (session_id or '').strip()
|
|
84
|
+
if not value:
|
|
85
|
+
return 'S-UNKNOWN'
|
|
86
|
+
first_segment = value.split('-', 1)[0] if '-' in value else value
|
|
87
|
+
return f'S-{first_segment[:8]}'
|
|
88
|
+
|
|
89
|
+
def setup_matplotlib():
|
|
90
|
+
"""Configure matplotlib for headless dark-theme charts."""
|
|
91
|
+
import matplotlib
|
|
92
|
+
matplotlib.use('Agg')
|
|
93
|
+
import matplotlib.pyplot as plt
|
|
94
|
+
|
|
95
|
+
plt.rcParams.update({
|
|
96
|
+
'figure.figsize': (CHART_WIDTH, CHART_HEIGHT),
|
|
97
|
+
'figure.dpi': DPI,
|
|
98
|
+
'figure.facecolor': BG_COLOR,
|
|
99
|
+
'axes.facecolor': BG_COLOR,
|
|
100
|
+
'axes.edgecolor': GRID_COLOR,
|
|
101
|
+
'axes.labelcolor': FG_COLOR,
|
|
102
|
+
'axes.titlesize': 13,
|
|
103
|
+
'axes.titleweight': 'bold',
|
|
104
|
+
'axes.titlepad': 14,
|
|
105
|
+
'axes.grid': True,
|
|
106
|
+
'grid.color': GRID_COLOR,
|
|
107
|
+
'grid.linewidth': 0.5,
|
|
108
|
+
'text.color': FG_COLOR,
|
|
109
|
+
'xtick.color': FG_COLOR,
|
|
110
|
+
'ytick.color': FG_COLOR,
|
|
111
|
+
'font.size': 10,
|
|
112
|
+
'font.family': 'sans-serif',
|
|
113
|
+
'legend.facecolor': BG_COLOR,
|
|
114
|
+
'legend.edgecolor': GRID_COLOR,
|
|
115
|
+
'legend.fontsize': 9,
|
|
116
|
+
'savefig.facecolor': BG_COLOR,
|
|
117
|
+
'savefig.edgecolor': BG_COLOR,
|
|
118
|
+
})
|
|
119
|
+
return plt
|
|
120
|
+
|
|
121
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
122
|
+
# DuckDB Queries
|
|
123
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
124
|
+
|
|
125
|
+
def run_query_conn(conn, sql):
|
|
126
|
+
"""Run a SQL query on an open DuckDB connection; return list of dicts."""
|
|
127
|
+
try:
|
|
128
|
+
rel = conn.execute(sql)
|
|
129
|
+
cols = [d[0] for d in rel.description]
|
|
130
|
+
return [dict(zip(cols, row)) for row in rel.fetchall()]
|
|
131
|
+
except Exception as exc:
|
|
132
|
+
sys.stderr.write(f'[Dashboard] Query failed: {exc}\n')
|
|
133
|
+
return []
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def open_duckdb_connection(traces_dir, use_indexed_db, index_db_path, trace_filter_clause):
|
|
137
|
+
"""
|
|
138
|
+
Open one DuckDB connection and materialise a `filtered_traces` temp table.
|
|
139
|
+
|
|
140
|
+
• indexed DB path → read-only connection to .duckdb file; uses pre-built spans table
|
|
141
|
+
• JSONL fallback → in-memory DB; parses JSONL *once* into a temp table
|
|
142
|
+
|
|
143
|
+
Always sets conservative memory / thread limits so multiple refreshes
|
|
144
|
+
can never compete for all available RAM.
|
|
145
|
+
Returns (conn, error_message). On failure conn is None.
|
|
146
|
+
"""
|
|
147
|
+
if not DUCKDB_AVAILABLE:
|
|
148
|
+
return None, (
|
|
149
|
+
'duckdb Python module not found. '
|
|
150
|
+
'Add "duckdb" to your analytics requirements.txt or run: pip install duckdb'
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
memory_limit_mb = max(64, int(os.environ.get('AGENTIDE_DUCKDB_MEMORY_LIMIT_MB', '256') or '256'))
|
|
154
|
+
threads = max(1, int(os.environ.get('AGENTIDE_DUCKDB_THREADS', '2') or '2'))
|
|
155
|
+
temp_directory_env = (os.environ.get('AGENTIDE_DUCKDB_TEMP_DIRECTORY') or '').strip()
|
|
156
|
+
|
|
157
|
+
conn = None
|
|
158
|
+
try:
|
|
159
|
+
if use_indexed_db and index_db_path and os.path.exists(index_db_path):
|
|
160
|
+
# ── Indexed DB path: read-only, low memory needed (pre-built spans table) ──
|
|
161
|
+
indexed_config = {
|
|
162
|
+
'threads': threads,
|
|
163
|
+
'memory_limit': f'{memory_limit_mb}MB',
|
|
164
|
+
}
|
|
165
|
+
if temp_directory_env:
|
|
166
|
+
indexed_config['temp_directory'] = temp_directory_env
|
|
167
|
+
conn = _duckdb_module.connect(
|
|
168
|
+
index_db_path, read_only=True,
|
|
169
|
+
config=indexed_config,
|
|
170
|
+
)
|
|
171
|
+
# spans table already normalised; just apply optional scope filters
|
|
172
|
+
conn.execute(
|
|
173
|
+
f"CREATE TEMP VIEW filtered_traces AS "
|
|
174
|
+
f"SELECT * FROM spans {trace_filter_clause}"
|
|
175
|
+
)
|
|
176
|
+
sys.stderr.write(f'[Dashboard] Using indexed DuckDB: {index_db_path}\n')
|
|
177
|
+
else:
|
|
178
|
+
# ── JSONL fallback: in-memory DB with streaming reads ──────────
|
|
179
|
+
# Use a VIEW so DuckDB streams JSONL per query instead of
|
|
180
|
+
# materialising all 228 MB into the buffer pool at once.
|
|
181
|
+
# Spill-to-disk ensures complex unnesting never hard-OOMs.
|
|
182
|
+
import tempfile, os as _os
|
|
183
|
+
_spill_dir = temp_directory_env or _os.path.join(tempfile.gettempdir(), 'duckdb_spotlight_spill')
|
|
184
|
+
_os.makedirs(_spill_dir, exist_ok=True)
|
|
185
|
+
conn = _duckdb_module.connect(
|
|
186
|
+
':memory:',
|
|
187
|
+
config={
|
|
188
|
+
'threads': threads,
|
|
189
|
+
'memory_limit': f'{memory_limit_mb}MB',
|
|
190
|
+
'temp_directory': _spill_dir,
|
|
191
|
+
'preserve_insertion_order': False,
|
|
192
|
+
},
|
|
193
|
+
)
|
|
194
|
+
conn.execute(
|
|
195
|
+
f"CREATE TEMP VIEW filtered_traces AS "
|
|
196
|
+
f"{base_query(traces_dir)}, "
|
|
197
|
+
f"filtered AS (SELECT * FROM traces {trace_filter_clause}) "
|
|
198
|
+
f"SELECT * FROM filtered"
|
|
199
|
+
)
|
|
200
|
+
sys.stderr.write(f'[Dashboard] Using JSONL streaming from {traces_dir}\n')
|
|
201
|
+
|
|
202
|
+
return conn, None
|
|
203
|
+
except Exception as exc:
|
|
204
|
+
if conn:
|
|
205
|
+
try:
|
|
206
|
+
conn.close()
|
|
207
|
+
except Exception:
|
|
208
|
+
pass
|
|
209
|
+
return None, f'DuckDB connection failed: {exc}'
|
|
210
|
+
|
|
211
|
+
def base_query(traces_dir):
|
|
212
|
+
"""Return the base CTE for OTEL trace parsing."""
|
|
213
|
+
return f"""
|
|
214
|
+
WITH raw_spans AS (
|
|
215
|
+
SELECT unnest(resourceSpans) as rs
|
|
216
|
+
FROM read_json('{traces_dir}/*.jsonl', format='newline_delimited', ignore_errors=true)
|
|
217
|
+
),
|
|
218
|
+
spans AS (SELECT unnest(rs.scopeSpans) as ss FROM raw_spans),
|
|
219
|
+
flat_spans AS (SELECT unnest(ss.spans) as span FROM spans),
|
|
220
|
+
parsed AS (
|
|
221
|
+
SELECT
|
|
222
|
+
span.traceId as trace_id,
|
|
223
|
+
span.name as span_name,
|
|
224
|
+
span.startTimeUnixNano::BIGINT / 1000000 as start_ms,
|
|
225
|
+
(span.endTimeUnixNano::BIGINT - span.startTimeUnixNano::BIGINT) / 1000000 as duration_ms,
|
|
226
|
+
json_extract(to_json(span), '$.attributes') as attrs_json
|
|
227
|
+
FROM flat_spans
|
|
228
|
+
),
|
|
229
|
+
attrs AS (
|
|
230
|
+
SELECT trace_id, span_name, duration_ms, start_ms,
|
|
231
|
+
json_extract_string(value, '$.key') as attr_key,
|
|
232
|
+
json_extract_string(value, '$.value.stringValue') as attr_string,
|
|
233
|
+
json_extract_string(value, '$.value.intValue') as attr_int,
|
|
234
|
+
json_extract(value, '$.value.doubleValue') as attr_double
|
|
235
|
+
FROM parsed, json_each(coalesce(attrs_json, '[]'::JSON))
|
|
236
|
+
WHERE span_name = 'Received Proxy Server Request'
|
|
237
|
+
OR EXISTS (SELECT 1 FROM json_each(coalesce(attrs_json, '[]'::JSON)) as attr
|
|
238
|
+
WHERE json_extract_string(attr.value, '$.key') = 'gen_ai.cost.total_cost')
|
|
239
|
+
),
|
|
240
|
+
traces AS (
|
|
241
|
+
SELECT
|
|
242
|
+
trace_id, span_name, duration_ms, start_ms,
|
|
243
|
+
max(CASE WHEN attr_key IN ('gen_ai.request.model','gen_ai.response.model','model') THEN attr_string END) as model,
|
|
244
|
+
max(CASE WHEN attr_key = 'gen_ai.cost.total_cost' THEN CAST(attr_double AS DOUBLE) END) as cost,
|
|
245
|
+
max(CASE WHEN attr_key = 'gen_ai.usage.input_tokens' THEN CAST(attr_int AS BIGINT) END) as input_tokens,
|
|
246
|
+
max(CASE WHEN attr_key = 'gen_ai.usage.output_tokens' THEN CAST(attr_int AS BIGINT) END) as output_tokens,
|
|
247
|
+
NULLIF(regexp_extract(max(CASE WHEN attr_key = 'metadata.requester_custom_headers' THEN attr_string END), 'x-litellm-metadata-session-id'': ''([^'']+)''', 1), '') as session_id,
|
|
248
|
+
NULLIF(regexp_extract(max(CASE WHEN attr_key = 'metadata.requester_custom_headers' THEN attr_string END), 'x-litellm-metadata-user-id'': ''([^'']+)''', 1), '') as user_id,
|
|
249
|
+
NULLIF(regexp_extract(max(CASE WHEN attr_key = 'metadata.requester_custom_headers' THEN attr_string END), 'x-litellm-metadata-project-id'': ''([^'']+)''', 1), '') as project_id,
|
|
250
|
+
NULLIF(regexp_extract(max(CASE WHEN attr_key = 'metadata.requester_custom_headers' THEN attr_string END), 'x-litellm-metadata-agent-id'': ''([^'']+)''', 1), '') as agent_id
|
|
251
|
+
FROM attrs
|
|
252
|
+
GROUP BY trace_id, span_name, duration_ms, start_ms
|
|
253
|
+
)"""
|
|
254
|
+
|
|
255
|
+
def sql_literal(value):
|
|
256
|
+
return "'" + value.replace("'", "''") + "'"
|
|
257
|
+
|
|
258
|
+
def build_trace_filter_clause(scope, project_id, agent_id):
|
|
259
|
+
conditions = []
|
|
260
|
+
if scope == 'workspace':
|
|
261
|
+
if project_id:
|
|
262
|
+
conditions.append(f"project_id = {sql_literal(project_id)}")
|
|
263
|
+
else:
|
|
264
|
+
conditions.append('1 = 0')
|
|
265
|
+
if agent_id:
|
|
266
|
+
conditions.append(f"agent_id = {sql_literal(agent_id)}")
|
|
267
|
+
if not conditions:
|
|
268
|
+
return ''
|
|
269
|
+
return 'WHERE ' + ' AND '.join(conditions)
|
|
270
|
+
|
|
271
|
+
def run_query(duckdb_path, traces_dir, sql_after_cte, trace_filter_clause=''):
|
|
272
|
+
"""Run a DuckDB query and return JSON results."""
|
|
273
|
+
full_sql = f"""{base_query(traces_dir)},
|
|
274
|
+
filtered_traces AS (
|
|
275
|
+
SELECT * FROM traces {trace_filter_clause}
|
|
276
|
+
)
|
|
277
|
+
{sql_after_cte}"""
|
|
278
|
+
try:
|
|
279
|
+
result = subprocess.run(
|
|
280
|
+
[duckdb_path, '-json', '-c', full_sql],
|
|
281
|
+
capture_output=True, text=True, timeout=30
|
|
282
|
+
)
|
|
283
|
+
if result.returncode != 0:
|
|
284
|
+
return []
|
|
285
|
+
output = result.stdout.strip()
|
|
286
|
+
if not output:
|
|
287
|
+
return []
|
|
288
|
+
return json.loads(output)
|
|
289
|
+
except Exception:
|
|
290
|
+
return []
|
|
291
|
+
|
|
292
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
293
|
+
# Chart Generators
|
|
294
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
295
|
+
|
|
296
|
+
def chart_daily_costs(plt, data, output_dir):
|
|
297
|
+
"""Line chart: daily cost trend with area fill."""
|
|
298
|
+
if not data:
|
|
299
|
+
return None
|
|
300
|
+
fig, ax = plt.subplots()
|
|
301
|
+
dates = [r['date'] for r in data]
|
|
302
|
+
costs = [float(r['cost'] or 0) for r in data]
|
|
303
|
+
display_dates = [d[5:] for d in dates] # MM-DD
|
|
304
|
+
|
|
305
|
+
ax.fill_between(range(len(dates)), costs, alpha=0.3, color=ACCENT_COLORS[0])
|
|
306
|
+
ax.plot(range(len(dates)), costs, '-o', color=ACCENT_COLORS[0], linewidth=2, markersize=5)
|
|
307
|
+
ax.set_xticks(range(len(dates)))
|
|
308
|
+
ax.set_xticklabels(display_dates, rotation=45, ha='right')
|
|
309
|
+
ax.set_ylabel('Cost ($)')
|
|
310
|
+
ax.set_title('Daily Cost Trend')
|
|
311
|
+
ax.yaxis.set_major_formatter(plt.FuncFormatter(lambda x, _: f'${x:.3f}'))
|
|
312
|
+
|
|
313
|
+
# Annotate total
|
|
314
|
+
total = sum(costs)
|
|
315
|
+
ax.annotate(f'Total: ${total:.4f}', xy=(0.98, 0.95), xycoords='axes fraction',
|
|
316
|
+
ha='right', va='top', fontsize=10, color=ACCENT_COLORS[1],
|
|
317
|
+
bbox=dict(boxstyle='round,pad=0.3', facecolor=BG_COLOR, edgecolor=GRID_COLOR))
|
|
318
|
+
|
|
319
|
+
plt.tight_layout()
|
|
320
|
+
path = os.path.join(output_dir, 'daily-cost-trend.png')
|
|
321
|
+
plt.savefig(path, bbox_inches='tight')
|
|
322
|
+
plt.close()
|
|
323
|
+
return path
|
|
324
|
+
|
|
325
|
+
def chart_model_breakdown(plt, data, output_dir):
|
|
326
|
+
"""Donut chart: cost by model."""
|
|
327
|
+
if not data:
|
|
328
|
+
return None
|
|
329
|
+
fig, ax = plt.subplots()
|
|
330
|
+
models = [r['model'] or 'unknown' for r in data]
|
|
331
|
+
costs = [float(r['cost'] or 0) for r in data]
|
|
332
|
+
requests = [int(r['requests'] or 0) for r in data]
|
|
333
|
+
|
|
334
|
+
# Shorten model names for display
|
|
335
|
+
short_names = []
|
|
336
|
+
for m in models:
|
|
337
|
+
name = m.replace('claude-', '').replace('gpt-', '').replace('-20250', '')
|
|
338
|
+
if len(name) > 20:
|
|
339
|
+
name = name[:18] + '..'
|
|
340
|
+
short_names.append(name)
|
|
341
|
+
|
|
342
|
+
colors = ACCENT_COLORS[:len(models)]
|
|
343
|
+
wedges, texts, autotexts = ax.pie(
|
|
344
|
+
costs, labels=short_names, colors=colors, autopct='%1.0f%%',
|
|
345
|
+
pctdistance=0.8, startangle=90,
|
|
346
|
+
wedgeprops=dict(width=0.5, edgecolor=BG_COLOR, linewidth=2)
|
|
347
|
+
)
|
|
348
|
+
for t in texts:
|
|
349
|
+
t.set_color(FG_COLOR)
|
|
350
|
+
t.set_fontsize(9)
|
|
351
|
+
for t in autotexts:
|
|
352
|
+
t.set_color(FG_COLOR)
|
|
353
|
+
t.set_fontsize(8)
|
|
354
|
+
|
|
355
|
+
# Center label
|
|
356
|
+
total = sum(costs)
|
|
357
|
+
ax.text(0, 0, f'${total:.3f}\ntotal', ha='center', va='center',
|
|
358
|
+
fontsize=12, fontweight='bold', color=FG_COLOR)
|
|
359
|
+
ax.set_title('Cost by Model')
|
|
360
|
+
|
|
361
|
+
plt.tight_layout()
|
|
362
|
+
path = os.path.join(output_dir, 'cost-by-model.png')
|
|
363
|
+
plt.savefig(path, bbox_inches='tight')
|
|
364
|
+
plt.close()
|
|
365
|
+
return path
|
|
366
|
+
|
|
367
|
+
def chart_top_sessions(plt, data, output_dir):
|
|
368
|
+
"""Horizontal bar chart: top sessions by cost."""
|
|
369
|
+
if not data:
|
|
370
|
+
return None
|
|
371
|
+
fig, ax = plt.subplots()
|
|
372
|
+
# Take top 8
|
|
373
|
+
data = data[:8]
|
|
374
|
+
session_ids = [format_session_handle(r.get('session_id')) for r in data]
|
|
375
|
+
costs = [float(r['cost'] or 0) for r in data]
|
|
376
|
+
requests = [int(r['requests'] or 0) for r in data]
|
|
377
|
+
|
|
378
|
+
session_ids.reverse()
|
|
379
|
+
costs.reverse()
|
|
380
|
+
requests.reverse()
|
|
381
|
+
|
|
382
|
+
bars = ax.barh(range(len(session_ids)), costs, color=ACCENT_COLORS[2], height=0.6)
|
|
383
|
+
ax.set_yticks(range(len(session_ids)))
|
|
384
|
+
ax.set_yticklabels(session_ids, fontsize=8)
|
|
385
|
+
ax.set_xlabel('Cost ($)')
|
|
386
|
+
ax.set_title('Top Sessions by Cost')
|
|
387
|
+
ax.xaxis.set_major_formatter(plt.FuncFormatter(lambda x, _: f'${x:.4f}'))
|
|
388
|
+
|
|
389
|
+
# Add request count labels
|
|
390
|
+
for i, (bar, req) in enumerate(zip(bars, requests)):
|
|
391
|
+
ax.text(bar.get_width() + max(costs) * 0.02, bar.get_y() + bar.get_height()/2,
|
|
392
|
+
f'{req} req', va='center', fontsize=8, color=FG_COLOR)
|
|
393
|
+
|
|
394
|
+
plt.tight_layout()
|
|
395
|
+
path = os.path.join(output_dir, 'top-sessions.png')
|
|
396
|
+
plt.savefig(path, bbox_inches='tight')
|
|
397
|
+
plt.close()
|
|
398
|
+
return path
|
|
399
|
+
|
|
400
|
+
def chart_token_efficiency(plt, data, output_dir):
|
|
401
|
+
"""Stacked bar: input vs output tokens by model (shows context bloat)."""
|
|
402
|
+
if not data:
|
|
403
|
+
return None
|
|
404
|
+
fig, ax = plt.subplots()
|
|
405
|
+
models = [r['model'] or 'unknown' for r in data]
|
|
406
|
+
input_t = [int(r['input_tokens'] or 0) for r in data]
|
|
407
|
+
output_t = [int(r['output_tokens'] or 0) for r in data]
|
|
408
|
+
|
|
409
|
+
short_names = []
|
|
410
|
+
for m in models:
|
|
411
|
+
name = m.replace('claude-', '').replace('gpt-', '').replace('-20250', '')
|
|
412
|
+
if len(name) > 16:
|
|
413
|
+
name = name[:14] + '..'
|
|
414
|
+
short_names.append(name)
|
|
415
|
+
|
|
416
|
+
x = range(len(short_names))
|
|
417
|
+
ax.bar(x, input_t, label='Input', color=ACCENT_COLORS[0], width=0.6)
|
|
418
|
+
ax.bar(x, output_t, bottom=input_t, label='Output', color=ACCENT_COLORS[1], width=0.6)
|
|
419
|
+
ax.set_xticks(x)
|
|
420
|
+
ax.set_xticklabels(short_names, rotation=45, ha='right', fontsize=8)
|
|
421
|
+
ax.set_ylabel('Tokens')
|
|
422
|
+
ax.set_title('Token Usage by Model')
|
|
423
|
+
ax.legend(loc='upper right')
|
|
424
|
+
ax.yaxis.set_major_formatter(plt.FuncFormatter(lambda x, _: f'{x/1000:.0f}K' if x >= 1000 else f'{x:.0f}'))
|
|
425
|
+
|
|
426
|
+
# Show ratio annotation
|
|
427
|
+
for i in range(len(models)):
|
|
428
|
+
total = input_t[i] + output_t[i]
|
|
429
|
+
if total > 0:
|
|
430
|
+
ratio = input_t[i] / max(output_t[i], 1)
|
|
431
|
+
ax.text(i, total + max(input_t[j] + output_t[j] for j in range(len(models))) * 0.02,
|
|
432
|
+
f'{ratio:.1f}x', ha='center', fontsize=7, color=ACCENT_COLORS[3])
|
|
433
|
+
|
|
434
|
+
plt.tight_layout()
|
|
435
|
+
path = os.path.join(output_dir, 'token-efficiency.png')
|
|
436
|
+
plt.savefig(path, bbox_inches='tight')
|
|
437
|
+
plt.close()
|
|
438
|
+
return path
|
|
439
|
+
|
|
440
|
+
def chart_latency_distribution(plt, data, output_dir):
|
|
441
|
+
"""Bar chart: latency percentiles by model."""
|
|
442
|
+
if not data:
|
|
443
|
+
return None
|
|
444
|
+
fig, ax = plt.subplots()
|
|
445
|
+
models = [r['model'] or 'unknown' for r in data]
|
|
446
|
+
p50 = [float(r['p50'] or 0) for r in data]
|
|
447
|
+
p95 = [float(r['p95'] or 0) for r in data]
|
|
448
|
+
p99 = [float(r['p99'] or 0) for r in data]
|
|
449
|
+
|
|
450
|
+
short_names = []
|
|
451
|
+
for m in models:
|
|
452
|
+
name = m.replace('claude-', '').replace('gpt-', '').replace('-20250', '')
|
|
453
|
+
if len(name) > 16:
|
|
454
|
+
name = name[:14] + '..'
|
|
455
|
+
short_names.append(name)
|
|
456
|
+
|
|
457
|
+
x = range(len(short_names))
|
|
458
|
+
width = 0.25
|
|
459
|
+
ax.bar([i - width for i in x], p50, width, label='p50', color=ACCENT_COLORS[0])
|
|
460
|
+
ax.bar(x, p95, width, label='p95', color=ACCENT_COLORS[2])
|
|
461
|
+
ax.bar([i + width for i in x], p99, width, label='p99', color=ACCENT_COLORS[4])
|
|
462
|
+
|
|
463
|
+
ax.set_xticks(x)
|
|
464
|
+
ax.set_xticklabels(short_names, rotation=45, ha='right', fontsize=8)
|
|
465
|
+
ax.set_ylabel('Latency (ms)')
|
|
466
|
+
ax.set_title('Response Latency by Model')
|
|
467
|
+
ax.legend(loc='upper right')
|
|
468
|
+
ax.yaxis.set_major_formatter(plt.FuncFormatter(lambda x, _: f'{x/1000:.1f}s' if x >= 1000 else f'{x:.0f}ms'))
|
|
469
|
+
|
|
470
|
+
plt.tight_layout()
|
|
471
|
+
path = os.path.join(output_dir, 'latency-distribution.png')
|
|
472
|
+
plt.savefig(path, bbox_inches='tight')
|
|
473
|
+
plt.close()
|
|
474
|
+
return path
|
|
475
|
+
|
|
476
|
+
def chart_hourly_activity(plt, data, output_dir):
|
|
477
|
+
"""Bar chart: request count by hour of day."""
|
|
478
|
+
if not data:
|
|
479
|
+
return None
|
|
480
|
+
fig, ax = plt.subplots()
|
|
481
|
+
hours = [int(r['hour']) for r in data]
|
|
482
|
+
counts = [int(r['count'] or 0) for r in data]
|
|
483
|
+
costs = [float(r['cost'] or 0) for r in data]
|
|
484
|
+
|
|
485
|
+
# Fill missing hours
|
|
486
|
+
hour_counts = [0] * 24
|
|
487
|
+
hour_costs = [0.0] * 24
|
|
488
|
+
for h, c, co in zip(hours, counts, costs):
|
|
489
|
+
if 0 <= h < 24:
|
|
490
|
+
hour_counts[h] = c
|
|
491
|
+
hour_costs[h] = co
|
|
492
|
+
|
|
493
|
+
colors = [ACCENT_COLORS[0] if c > 0 else GRID_COLOR for c in hour_counts]
|
|
494
|
+
bars = ax.bar(range(24), hour_counts, color=colors, width=0.8)
|
|
495
|
+
ax.set_xlabel('Hour of Day')
|
|
496
|
+
ax.set_ylabel('Requests')
|
|
497
|
+
ax.set_title('Activity by Hour')
|
|
498
|
+
ax.set_xticks(range(0, 24, 3))
|
|
499
|
+
ax.set_xticklabels([f'{h:02d}:00' for h in range(0, 24, 3)], fontsize=8)
|
|
500
|
+
|
|
501
|
+
# Highlight peak hour
|
|
502
|
+
if max(hour_counts) > 0:
|
|
503
|
+
peak = hour_counts.index(max(hour_counts))
|
|
504
|
+
bars[peak].set_color(ACCENT_COLORS[3])
|
|
505
|
+
ax.annotate(f'Peak: {peak:02d}:00', xy=(peak, hour_counts[peak]),
|
|
506
|
+
xytext=(peak + 2, hour_counts[peak] * 0.9),
|
|
507
|
+
arrowprops=dict(arrowstyle='->', color=ACCENT_COLORS[3], lw=1.5),
|
|
508
|
+
fontsize=9, color=ACCENT_COLORS[3])
|
|
509
|
+
|
|
510
|
+
plt.tight_layout()
|
|
511
|
+
path = os.path.join(output_dir, 'hourly-activity.png')
|
|
512
|
+
plt.savefig(path, bbox_inches='tight')
|
|
513
|
+
plt.close()
|
|
514
|
+
return path
|
|
515
|
+
|
|
516
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
517
|
+
# Main
|
|
518
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
519
|
+
|
|
520
|
+
def main():
|
|
521
|
+
traces_dir = ''
|
|
522
|
+
output_dir = ''
|
|
523
|
+
if len(sys.argv) >= 3:
|
|
524
|
+
traces_dir = sys.argv[1]
|
|
525
|
+
output_dir = sys.argv[2]
|
|
526
|
+
else:
|
|
527
|
+
traces_dir = os.environ.get('AGENTIDE_TRACES_DIR', '').strip()
|
|
528
|
+
output_dir = os.environ.get('AGENTIDE_OUTPUT_DIR', '').strip()
|
|
529
|
+
|
|
530
|
+
if not traces_dir or not output_dir:
|
|
531
|
+
print(
|
|
532
|
+
f"Usage: {sys.argv[0]} <traces_dir> <output_dir> "
|
|
533
|
+
"(or set AGENTIDE_TRACES_DIR + AGENTIDE_OUTPUT_DIR)",
|
|
534
|
+
file=sys.stderr,
|
|
535
|
+
)
|
|
536
|
+
sys.exit(1)
|
|
537
|
+
scope = os.environ.get('AGENTIDE_ANALYTICS_SCOPE', 'global').strip().lower()
|
|
538
|
+
if scope not in ('global', 'workspace'):
|
|
539
|
+
scope = 'global'
|
|
540
|
+
project_id = os.environ.get('AGENTIDE_ANALYTICS_PROJECT_ID', '').strip()
|
|
541
|
+
agent_id = os.environ.get('AGENTIDE_ANALYTICS_AGENT_ID', '').strip()
|
|
542
|
+
trace_filter_clause = build_trace_filter_clause(scope, project_id, agent_id)
|
|
543
|
+
|
|
544
|
+
# Verify traces exist
|
|
545
|
+
traces_path = Path(traces_dir)
|
|
546
|
+
if not traces_path.exists() or not list(traces_path.glob('*.jsonl')):
|
|
547
|
+
print(json.dumps({"status": "no_data", "charts": []}))
|
|
548
|
+
sys.exit(2)
|
|
549
|
+
|
|
550
|
+
# ── DuckDB: prefer indexed DB when available, fall back to JSONL ──────────
|
|
551
|
+
configured_index_db_path = os.environ.get('AGENTIDE_INDEX_DB_PATH', '').strip()
|
|
552
|
+
fallback_index_db_path = str((traces_path / 'analytics.duckdb').resolve())
|
|
553
|
+
index_db_path = configured_index_db_path or fallback_index_db_path
|
|
554
|
+
use_duckdb_env = os.environ.get('AGENTIDE_USE_DUCKDB', '').strip().lower() == 'true'
|
|
555
|
+
# Auto-enable indexed mode when the DB exists; AGENTIDE_USE_DUCKDB can still force true.
|
|
556
|
+
use_indexed_db = bool(index_db_path) and os.path.exists(index_db_path)
|
|
557
|
+
# If AGENTIDE_USE_DUCKDB=true is provided, it is honored; otherwise indexed mode is auto-on when DB exists.
|
|
558
|
+
if use_duckdb_env and not use_indexed_db:
|
|
559
|
+
sys.stderr.write('[Dashboard] AGENTIDE_USE_DUCKDB=true but indexed DB path was not found\n')
|
|
560
|
+
|
|
561
|
+
if use_indexed_db:
|
|
562
|
+
sys.stderr.write(f'[Dashboard] Indexed mode enabled: {index_db_path}\n')
|
|
563
|
+
else:
|
|
564
|
+
sys.stderr.write('[Dashboard] Indexed DB unavailable; falling back to JSONL mode\n')
|
|
565
|
+
|
|
566
|
+
# Default charts output location when not supplied by caller.
|
|
567
|
+
chart_dir_override = os.environ.get('AGENTIDE_CHART_DIR', '').strip()
|
|
568
|
+
|
|
569
|
+
conn, conn_error = open_duckdb_connection(
|
|
570
|
+
traces_dir, use_indexed_db, index_db_path, trace_filter_clause
|
|
571
|
+
)
|
|
572
|
+
if conn is None:
|
|
573
|
+
print(json.dumps({"status": "error", "error": conn_error}))
|
|
574
|
+
sys.exit(1)
|
|
575
|
+
|
|
576
|
+
# Ensure output dir
|
|
577
|
+
charts_dir = chart_dir_override or os.path.join(output_dir, 'charts')
|
|
578
|
+
os.makedirs(charts_dir, exist_ok=True)
|
|
579
|
+
disabled_charts = parse_disabled_charts()
|
|
580
|
+
|
|
581
|
+
plt = setup_matplotlib()
|
|
582
|
+
generated = []
|
|
583
|
+
|
|
584
|
+
try:
|
|
585
|
+
# All 5 queries run through the same connection — zero extra processes spawned.
|
|
586
|
+
|
|
587
|
+
# 1. Daily cost trend (past 14 days)
|
|
588
|
+
daily_data = run_query_conn(conn, """
|
|
589
|
+
SELECT strftime(to_timestamp(start_ms / 1000), '%Y-%m-%d') as date,
|
|
590
|
+
SUM(cost) as cost, COUNT(*) as requests
|
|
591
|
+
FROM filtered_traces WHERE cost IS NOT NULL
|
|
592
|
+
AND start_ms > (EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - INTERVAL '14 days')) * 1000)
|
|
593
|
+
GROUP BY date ORDER BY date ASC
|
|
594
|
+
""")
|
|
595
|
+
if is_chart_disabled(disabled_charts, 'daily-cost-trend.png'):
|
|
596
|
+
remove_chart_if_exists(charts_dir, 'daily-cost-trend.png')
|
|
597
|
+
else:
|
|
598
|
+
path = chart_daily_costs(plt, daily_data, charts_dir)
|
|
599
|
+
if path:
|
|
600
|
+
generated.append({"file": path, "title": "Daily Cost Trend", "type": "chart"})
|
|
601
|
+
|
|
602
|
+
# 2. Cost by model (donut)
|
|
603
|
+
model_data = run_query_conn(conn, """
|
|
604
|
+
SELECT COALESCE(model, 'unknown') as model, SUM(cost) as cost, COUNT(*) as requests,
|
|
605
|
+
SUM(input_tokens) as input_tokens, SUM(output_tokens) as output_tokens
|
|
606
|
+
FROM filtered_traces WHERE cost IS NOT NULL
|
|
607
|
+
GROUP BY model ORDER BY cost DESC
|
|
608
|
+
""")
|
|
609
|
+
if is_chart_disabled(disabled_charts, 'cost-by-model.png'):
|
|
610
|
+
remove_chart_if_exists(charts_dir, 'cost-by-model.png')
|
|
611
|
+
else:
|
|
612
|
+
path = chart_model_breakdown(plt, model_data, charts_dir)
|
|
613
|
+
if path:
|
|
614
|
+
generated.append({"file": path, "title": "Cost by Model", "type": "chart"})
|
|
615
|
+
|
|
616
|
+
# 3. Top sessions by cost
|
|
617
|
+
session_data = run_query_conn(conn, """
|
|
618
|
+
SELECT COALESCE(session_id, '(none)') as session_id, SUM(cost) as cost, COUNT(*) as requests
|
|
619
|
+
FROM filtered_traces WHERE cost IS NOT NULL AND session_id IS NOT NULL
|
|
620
|
+
GROUP BY session_id ORDER BY cost DESC LIMIT 10
|
|
621
|
+
""")
|
|
622
|
+
top_sessions_disabled = is_chart_disabled(disabled_charts, 'top-sessions.png')
|
|
623
|
+
if top_sessions_disabled:
|
|
624
|
+
remove_chart_if_exists(charts_dir, 'top-sessions.png')
|
|
625
|
+
else:
|
|
626
|
+
path = chart_top_sessions(plt, session_data, charts_dir)
|
|
627
|
+
if path:
|
|
628
|
+
generated.append({"file": path, "title": "Top Sessions by Cost", "type": "chart"})
|
|
629
|
+
|
|
630
|
+
# 4. Token efficiency by model (input vs output stacked) — reuses model_data
|
|
631
|
+
if is_chart_disabled(disabled_charts, 'token-efficiency.png'):
|
|
632
|
+
remove_chart_if_exists(charts_dir, 'token-efficiency.png')
|
|
633
|
+
else:
|
|
634
|
+
path = chart_token_efficiency(plt, model_data, charts_dir)
|
|
635
|
+
if path:
|
|
636
|
+
generated.append({"file": path, "title": "Token Usage by Model", "type": "chart"})
|
|
637
|
+
|
|
638
|
+
# 5. Latency distribution by model (p50/p95/p99)
|
|
639
|
+
latency_data = run_query_conn(conn, """
|
|
640
|
+
SELECT COALESCE(model, 'unknown') as model,
|
|
641
|
+
PERCENTILE_CONT(0.50) WITHIN GROUP (ORDER BY duration_ms) as p50,
|
|
642
|
+
PERCENTILE_CONT(0.95) WITHIN GROUP (ORDER BY duration_ms) as p95,
|
|
643
|
+
PERCENTILE_CONT(0.99) WITHIN GROUP (ORDER BY duration_ms) as p99
|
|
644
|
+
FROM filtered_traces WHERE cost IS NOT NULL
|
|
645
|
+
GROUP BY model ORDER BY p50 DESC
|
|
646
|
+
""")
|
|
647
|
+
if is_chart_disabled(disabled_charts, 'latency-distribution.png'):
|
|
648
|
+
remove_chart_if_exists(charts_dir, 'latency-distribution.png')
|
|
649
|
+
else:
|
|
650
|
+
path = chart_latency_distribution(plt, latency_data, charts_dir)
|
|
651
|
+
if path:
|
|
652
|
+
generated.append({"file": path, "title": "Latency Distribution", "type": "chart"})
|
|
653
|
+
|
|
654
|
+
# 6. Hourly activity heatmap
|
|
655
|
+
hourly_data = run_query_conn(conn, """
|
|
656
|
+
SELECT EXTRACT(HOUR FROM to_timestamp(start_ms / 1000)) as hour,
|
|
657
|
+
COUNT(*) as count, SUM(cost) as cost
|
|
658
|
+
FROM filtered_traces WHERE cost IS NOT NULL
|
|
659
|
+
GROUP BY hour ORDER BY hour
|
|
660
|
+
""")
|
|
661
|
+
if is_chart_disabled(disabled_charts, 'hourly-activity.png'):
|
|
662
|
+
remove_chart_if_exists(charts_dir, 'hourly-activity.png')
|
|
663
|
+
else:
|
|
664
|
+
path = chart_hourly_activity(plt, hourly_data, charts_dir)
|
|
665
|
+
if path:
|
|
666
|
+
generated.append({"file": path, "title": "Activity by Hour", "type": "chart"})
|
|
667
|
+
|
|
668
|
+
finally:
|
|
669
|
+
conn.close()
|
|
670
|
+
|
|
671
|
+
if not generated:
|
|
672
|
+
print(json.dumps({"status": "no_data", "charts": []}))
|
|
673
|
+
sys.exit(2)
|
|
674
|
+
|
|
675
|
+
# Output manifest
|
|
676
|
+
result = {
|
|
677
|
+
"status": "ok",
|
|
678
|
+
"generated_at": datetime.utcnow().isoformat() + "Z",
|
|
679
|
+
"charts": generated
|
|
680
|
+
}
|
|
681
|
+
print(json.dumps(result, indent=2))
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
if __name__ == '__main__':
|
|
685
|
+
main()
|