@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,759 @@
|
|
|
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.CodexEngine = void 0;
|
|
40
|
+
const fs_1 = require("fs");
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
const mcp_1 = require("../mcp");
|
|
43
|
+
const interfaces_1 = require("../runtime/interfaces");
|
|
44
|
+
const base_1 = require("./base");
|
|
45
|
+
const utils_1 = require("../utils");
|
|
46
|
+
const permissions_1 = require("../permissions");
|
|
47
|
+
const session_1 = require("../session");
|
|
48
|
+
const agentpack_1 = require("../agentpack");
|
|
49
|
+
// Note: HTTP edit server removed - file changes are now handled directly via file_change events
|
|
50
|
+
// -----------------------------------------------------------------------------
|
|
51
|
+
// Constants
|
|
52
|
+
// -----------------------------------------------------------------------------
|
|
53
|
+
const AGENTIDE_CODEX_PROVIDER_ID = 'agentide-litellm';
|
|
54
|
+
const AGENTIDE_CODEX_CUSTOM_PROVIDER_ID = 'agentide-custom';
|
|
55
|
+
// Analytics metadata env vars for session/user/project (used by x-litellm-metadata-* and Langfuse passthrough headers)
|
|
56
|
+
const AGENTIDE_CODEX_SESSION_ENV_VAR = 'AGENTIDE_ANALYTICS_SESSION_ID';
|
|
57
|
+
const AGENTIDE_CODEX_USER_ENV_VAR = 'AGENTIDE_ANALYTICS_USER_ID';
|
|
58
|
+
const AGENTIDE_CODEX_PROJECT_ID_ENV_VAR = 'AGENTIDE_ANALYTICS_PROJECT_ID';
|
|
59
|
+
// Analytics metadata env vars for enriched OTEL traces (see PLAN/analytics-design.md)
|
|
60
|
+
const AGENTIDE_CODEX_AGENT_ID_ENV_VAR = 'AGENTIDE_ANALYTICS_AGENT_ID';
|
|
61
|
+
const AGENTIDE_CODEX_AGENT_VERSION_ENV_VAR = 'AGENTIDE_ANALYTICS_AGENT_VERSION';
|
|
62
|
+
const AGENTIDE_CODEX_SOURCE_ENV_VAR = 'AGENTIDE_ANALYTICS_SOURCE';
|
|
63
|
+
const AGENTIDE_CODEX_ENGINE_ENV_VAR = 'AGENTIDE_ANALYTICS_ENGINE';
|
|
64
|
+
const AGENTIDE_CODEX_REQUEST_ID_ENV_VAR = 'AGENTIDE_ANALYTICS_REQUEST_ID';
|
|
65
|
+
// Bump when we change generated config semantics so long-lived sessions regenerate config.toml.
|
|
66
|
+
const AGENTIDE_CODEX_CONFIG_VERSION = 18; // v18: Codex CLI dropped wire_api=chat; always use responses
|
|
67
|
+
// Per-process runtime context for agents (not analytics): lets the agent locate its per-session context export.
|
|
68
|
+
const AGENTIDE_CONTEXT_EXPORT_PATH_ENV_VAR = 'AGENTIDE_CONTEXT_EXPORT_PATH';
|
|
69
|
+
const AGENTIDE_TERMINAL_LOG_PATH_ENV_VAR = 'AGENTIDE_TERMINAL_LOG_PATH';
|
|
70
|
+
function isCodexItemEvent(event) {
|
|
71
|
+
return event.type === 'item.started' || event.type === 'item.updated' || event.type === 'item.completed';
|
|
72
|
+
}
|
|
73
|
+
// -----------------------------------------------------------------------------
|
|
74
|
+
// Codex Engine
|
|
75
|
+
// -----------------------------------------------------------------------------
|
|
76
|
+
class CodexEngine {
|
|
77
|
+
config;
|
|
78
|
+
getSkillsSignature;
|
|
79
|
+
getBundledBasePromptsDir;
|
|
80
|
+
id = 'codex';
|
|
81
|
+
displayName = 'Codex';
|
|
82
|
+
lastWrittenConfigSignature;
|
|
83
|
+
lastCodexSkillsSignatureByWorkspaceRoot = new Map();
|
|
84
|
+
constructor(config, getSkillsSignature, getBundledBasePromptsDir) {
|
|
85
|
+
this.config = config;
|
|
86
|
+
this.getSkillsSignature = getSkillsSignature;
|
|
87
|
+
this.getBundledBasePromptsDir = getBundledBasePromptsDir;
|
|
88
|
+
}
|
|
89
|
+
async stream(message, options, emitter, runtime, signal) {
|
|
90
|
+
// Use logger from runtime context
|
|
91
|
+
const logger = runtime.logger;
|
|
92
|
+
// Edit tracker from runtime context (optional)
|
|
93
|
+
const editTracker = runtime.editTracker;
|
|
94
|
+
const { Codex } = await import('@openai/codex-sdk');
|
|
95
|
+
if (!options.modelId) {
|
|
96
|
+
throw new Error('Codex modelId not provided for streaming request');
|
|
97
|
+
}
|
|
98
|
+
// IMPORTANT: Do NOT strip the `litellm/` prefix. In LiteLLM deployments, the model identifier
|
|
99
|
+
// is often an alias that must match exactly (e.g. `litellm/gpt-4o-mini`).
|
|
100
|
+
const threadModelId = options.modelId;
|
|
101
|
+
// Resolve API routing (LiteLLM proxy vs direct OpenAI)
|
|
102
|
+
// Use openaiBaseUrl which has overrideOpenAIBaseUrl applied
|
|
103
|
+
const routing = (0, utils_1.resolveApiRouting)(options, this.config.litellmApiKey, this.config.litellmBaseUrl);
|
|
104
|
+
const apiKey = routing.apiKey;
|
|
105
|
+
const baseUrl = routing.openaiBaseUrl; // Use OpenAI-specific URL
|
|
106
|
+
const useLiteLLM = routing.useLiteLLM;
|
|
107
|
+
const sessionId = options.sessionId;
|
|
108
|
+
const analyticsUserId = options.analyticsUserId;
|
|
109
|
+
const analyticsProjectId = (0, base_1.resolveAnalyticsProjectId)(options.analyticsProjectId, options.workspaceRoot);
|
|
110
|
+
// Detect if this is a custom endpoint (not direct OpenAI API).
|
|
111
|
+
// The default OpenAI endpoint is https://api.openai.com/v1 - don't treat as custom for that.
|
|
112
|
+
const DEFAULT_OPENAI_ENDPOINT = 'https://api.openai.com/v1';
|
|
113
|
+
const isCustomEndpoint = baseUrl && baseUrl !== DEFAULT_OPENAI_ENDPOINT;
|
|
114
|
+
const routingDescription = useLiteLLM ? 'LiteLLM proxy' : (isCustomEndpoint ? 'custom provider' : 'direct OpenAI');
|
|
115
|
+
logger.info(`[AgentIDE] Codex routing: ${routingDescription}, baseUrl=${baseUrl || 'default'}, workspaceRoot=${options.workspaceRoot}`);
|
|
116
|
+
const isClaudeModel = threadModelId.toLowerCase().includes('claude');
|
|
117
|
+
// Codex CLI no longer supports wire_api=chat (see openai/codex#7782); always use responses.
|
|
118
|
+
const wireApi = 'responses';
|
|
119
|
+
logger.info(`[AgentIDE] Codex wire_api=${wireApi} (model=${threadModelId})`);
|
|
120
|
+
if (isClaudeModel && (useLiteLLM || isCustomEndpoint)) {
|
|
121
|
+
logger.info('[AgentIDE] Codex note: selected model appears to be Claude via proxy; reasoning summaries depend on provider support over the Responses API.');
|
|
122
|
+
}
|
|
123
|
+
// Build environment for Codex SDK (spawns internal CLI binary)
|
|
124
|
+
const codexEnv = {
|
|
125
|
+
...process.env,
|
|
126
|
+
...(runtime.cliEnvPatch ?? {}),
|
|
127
|
+
OPENAI_LOG: 'debug',
|
|
128
|
+
};
|
|
129
|
+
// Always expose the VS Code chat session id to the agent process so it can locate:
|
|
130
|
+
// .agentide/sessions/<sessionId>/context.md
|
|
131
|
+
const rawChatSessionId = sessionId?.trim();
|
|
132
|
+
const contextSessionId = options.contextSessionId?.trim() || rawChatSessionId;
|
|
133
|
+
if (contextSessionId) {
|
|
134
|
+
codexEnv[AGENTIDE_CONTEXT_EXPORT_PATH_ENV_VAR] = path.join(options.workspaceRoot, agentpack_1.AGENT_CONSTANTS.AGENTIDE_DIR_NAME, 'sessions', contextSessionId, 'context.md');
|
|
135
|
+
codexEnv[AGENTIDE_TERMINAL_LOG_PATH_ENV_VAR] = path.join(options.workspaceRoot, agentpack_1.AGENT_CONSTANTS.AGENTIDE_DIR_NAME, 'sessions', contextSessionId, 'terminal.md');
|
|
136
|
+
}
|
|
137
|
+
// Note: With full permissions, Codex writes files directly to disk.
|
|
138
|
+
// File changes are detected via the file_change event stream and
|
|
139
|
+
// routed through VS Code's edit session automatically.
|
|
140
|
+
// Resolve runtime paths for config directories (agent-isolated)
|
|
141
|
+
// Note: workingDirectory is ALWAYS workspaceRoot - active agent content is synced to workspace's .codex/
|
|
142
|
+
const agentId = options.agentPackId ?? 'default';
|
|
143
|
+
const runtimePaths = (0, agentpack_1.resolveRuntimePaths)(options.workspaceRoot, this.config.storagePath, agentId, options.agentPackVersion);
|
|
144
|
+
// Use agent-isolated CODEX_HOME (for session/state isolation)
|
|
145
|
+
const codexHome = runtimePaths.codexHome;
|
|
146
|
+
codexEnv['CODEX_HOME'] = codexHome;
|
|
147
|
+
await fs_1.promises.mkdir(codexHome, { recursive: true });
|
|
148
|
+
// Always set AGENT_ID for agent to know its identity
|
|
149
|
+
codexEnv['AGENT_ID'] = agentId;
|
|
150
|
+
if (options.agentPackVersion) {
|
|
151
|
+
codexEnv['AGENTIDE_AGENT_VERSION'] = options.agentPackVersion;
|
|
152
|
+
}
|
|
153
|
+
if (agentId !== 'default') {
|
|
154
|
+
logger.info(`[AgentIDE] Codex using agent: ${agentId}, CODEX_HOME=${codexHome} (agent-isolated)`);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
logger.info(`[AgentIDE] Codex using default agent, CODEX_HOME=${codexHome}`);
|
|
158
|
+
}
|
|
159
|
+
// Only pass baseUrl to config when using a custom endpoint (not default OpenAI)
|
|
160
|
+
const customBaseUrl = isCustomEndpoint ? baseUrl : undefined;
|
|
161
|
+
await this.ensureCodexConfig(useLiteLLM, customBaseUrl, threadModelId,
|
|
162
|
+
// Always use workspaceRoot - pack content is synced to workspace's .codex/
|
|
163
|
+
options.workspaceRoot, options.additionalDirectories ?? [], logger, codexHome, // Pass explicit codexHome for pack support
|
|
164
|
+
agentId, // Pass agent ID for correct skills path
|
|
165
|
+
runtime.permissionHandler instanceof interfaces_1.AutoApprovePermissionHandler);
|
|
166
|
+
// LiteLLM analytics metadata (enriched - see PLAN/analytics-design.md)
|
|
167
|
+
if (useLiteLLM && this.config.codexHome) {
|
|
168
|
+
if (analyticsUserId?.trim()) {
|
|
169
|
+
codexEnv[AGENTIDE_CODEX_USER_ENV_VAR] = analyticsUserId.trim();
|
|
170
|
+
}
|
|
171
|
+
if (sessionId?.trim()) {
|
|
172
|
+
codexEnv[AGENTIDE_CODEX_SESSION_ENV_VAR] = sessionId.trim();
|
|
173
|
+
}
|
|
174
|
+
if (analyticsProjectId?.trim()) {
|
|
175
|
+
codexEnv[AGENTIDE_CODEX_PROJECT_ID_ENV_VAR] = analyticsProjectId.trim();
|
|
176
|
+
}
|
|
177
|
+
codexEnv[AGENTIDE_CODEX_AGENT_ID_ENV_VAR] = agentId;
|
|
178
|
+
codexEnv[AGENTIDE_CODEX_AGENT_VERSION_ENV_VAR] = options.agentPackVersion ?? 'workspace';
|
|
179
|
+
codexEnv[AGENTIDE_CODEX_SOURCE_ENV_VAR] = 'agenthippo';
|
|
180
|
+
codexEnv[AGENTIDE_CODEX_ENGINE_ENV_VAR] = 'codex';
|
|
181
|
+
// Use requestId from options (generated by caller) for Layer 1/Layer 2 correlation
|
|
182
|
+
if (options.requestId) {
|
|
183
|
+
codexEnv[AGENTIDE_CODEX_REQUEST_ID_ENV_VAR] = options.requestId;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// For custom providers (OpenRouter, LiteLLM), set API key in CODEX_API_KEY.
|
|
187
|
+
// The config.toml's `env_key = "CODEX_API_KEY"` tells the CLI to read from this variable.
|
|
188
|
+
if (isCustomEndpoint && apiKey) {
|
|
189
|
+
codexEnv['CODEX_API_KEY'] = apiKey;
|
|
190
|
+
}
|
|
191
|
+
// Only set OPENAI_BASE_URL for custom endpoints (not direct OpenAI API)
|
|
192
|
+
if (isCustomEndpoint) {
|
|
193
|
+
codexEnv['OPENAI_BASE_URL'] = baseUrl;
|
|
194
|
+
logger.info(`[AgentIDE] Using custom OpenAI base URL: ${baseUrl}`);
|
|
195
|
+
if ((0, utils_1.applyLocalTlsBypass)(codexEnv, baseUrl)) {
|
|
196
|
+
logger.info('[AgentIDE] Disabling TLS verification for local HTTPS (Codex)');
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const convo = (0, session_1.buildConversationKey)('codex', options);
|
|
200
|
+
logger.info(`[AgentIDE] Codex conversationKey=${convo.key} (chatSessionId=${convo.chatSessionId}, signature=${convo.signatureHash}${convo.isEphemeral ? ', ephemeral' : ''})`);
|
|
201
|
+
await (0, session_1.withConversationLock)(convo.key, async () => {
|
|
202
|
+
await emitter.progress('Thinking...');
|
|
203
|
+
// Resolve unified permissions (from manifest via options, or defaults)
|
|
204
|
+
const effectivePerms = options.permissions ?? permissions_1.DEFAULT_PERMISSIONS;
|
|
205
|
+
logger.info(`[AgentIDE] Codex permissions: fileAccess=${effectivePerms.fileAccess}`);
|
|
206
|
+
// Build workspace folders list for permission mapping
|
|
207
|
+
const workspaceFolders = [
|
|
208
|
+
options.workspaceRoot,
|
|
209
|
+
...(options.additionalDirectories ?? []),
|
|
210
|
+
];
|
|
211
|
+
// Map unified permissions to Codex SDK options
|
|
212
|
+
const codexPermOpts = (0, permissions_1.toCodexOptions)(effectivePerms, workspaceFolders);
|
|
213
|
+
logger.info(`[AgentIDE] Codex mapped: sandboxMode=${codexPermOpts.sandboxMode}, approvalPolicy=${codexPermOpts.approvalPolicy}`);
|
|
214
|
+
// Build thread options
|
|
215
|
+
// workingDirectory is ALWAYS workspaceRoot - pack content is synced to workspace's .codex/
|
|
216
|
+
const threadWorkingDir = options.workspaceRoot;
|
|
217
|
+
const threadOptions = {
|
|
218
|
+
model: threadModelId,
|
|
219
|
+
// Use mapped permissions from unified AgentPermissions
|
|
220
|
+
sandboxMode: codexPermOpts.sandboxMode,
|
|
221
|
+
approvalPolicy: codexPermOpts.approvalPolicy,
|
|
222
|
+
additionalDirectories: codexPermOpts.additionalDirectories,
|
|
223
|
+
workingDirectory: threadWorkingDir,
|
|
224
|
+
// Allow running in non-git directories (e.g., new projects, ephemeral environments)
|
|
225
|
+
skipGitRepoCheck: true,
|
|
226
|
+
modelReasoningEffort: 'medium',
|
|
227
|
+
};
|
|
228
|
+
logger.info(`[AgentIDE] Codex modelReasoningEffort=${threadOptions.modelReasoningEffort ?? 'default'}`);
|
|
229
|
+
// For custom providers (OpenRouter, LiteLLM), the API key is read from
|
|
230
|
+
// CODEX_API_KEY env var via config.toml's env_key. Only pass apiKey
|
|
231
|
+
// directly to the constructor for direct OpenAI mode.
|
|
232
|
+
const codexApiKey = isCustomEndpoint ? undefined : apiKey;
|
|
233
|
+
const codex = new Codex({
|
|
234
|
+
apiKey: codexApiKey,
|
|
235
|
+
env: codexEnv,
|
|
236
|
+
...(this.config.codexExecutablePath ? { codexPathOverride: this.config.codexExecutablePath } : {}),
|
|
237
|
+
});
|
|
238
|
+
// const codex = new Codex({
|
|
239
|
+
// apiKey: codexApiKey,
|
|
240
|
+
// env: codexEnv,
|
|
241
|
+
// // Override Codex binary path for bundled CLI distribution
|
|
242
|
+
// ...(this.config.codexExecutablePath ? { codexPathOverride: this.config.codexExecutablePath } : {}),
|
|
243
|
+
// });
|
|
244
|
+
const threadIdToResume = (0, base_1.getPersistedSessionId)('codex', convo.key);
|
|
245
|
+
let thread;
|
|
246
|
+
if (threadIdToResume) {
|
|
247
|
+
try {
|
|
248
|
+
// Resume with the current model -- thread history persists across model changes
|
|
249
|
+
thread = codex.resumeThread(threadIdToResume, threadOptions);
|
|
250
|
+
logger.info(`[AgentIDE] Codex resuming thread: ${threadIdToResume} (model: ${threadModelId})`);
|
|
251
|
+
}
|
|
252
|
+
catch (e) {
|
|
253
|
+
logger.warn(`[AgentIDE] Failed to resume Codex thread (${threadIdToResume}): ${e instanceof Error ? e.message : String(e)}. Starting new thread.`);
|
|
254
|
+
thread = codex.startThread(threadOptions);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
thread = codex.startThread(threadOptions);
|
|
259
|
+
logger.info(`[AgentIDE] Codex starting new thread (model: ${threadModelId})`);
|
|
260
|
+
}
|
|
261
|
+
if (signal?.aborted) {
|
|
262
|
+
logger.info('[AgentIDE] Codex stream cancelled before starting turn');
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
let events;
|
|
266
|
+
try {
|
|
267
|
+
({ events } = await thread.runStreamed(message, { signal }));
|
|
268
|
+
}
|
|
269
|
+
catch (e) {
|
|
270
|
+
if (signal?.aborted) {
|
|
271
|
+
logger.info('[AgentIDE] Codex stream aborted while starting turn');
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
throw e;
|
|
275
|
+
}
|
|
276
|
+
const textTracker = new Map();
|
|
277
|
+
const pendingOperations = new Map(); // command item.id → operationId
|
|
278
|
+
const pendingNewFiles = new Map(); // command item.id → new file paths
|
|
279
|
+
let reasoningDeltaCount = 0;
|
|
280
|
+
let reasoningCharCount = 0;
|
|
281
|
+
let reasoningItemSeen = 0;
|
|
282
|
+
let loggedEmptyReasoningOnce = false;
|
|
283
|
+
const preview = (s) => s.replace(/\r/g, '').replace(/\n/g, '\\n').slice(0, 160);
|
|
284
|
+
try {
|
|
285
|
+
for await (const event of events) {
|
|
286
|
+
if (signal?.aborted) {
|
|
287
|
+
logger.info('[AgentIDE] Codex stream aborted; stopping event loop');
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const itemType = isCodexItemEvent(event) ? event.item.type : undefined;
|
|
291
|
+
logger.debug(`[AgentIDE] Codex event: ${event.type}${itemType ? ` (item: ${itemType})` : ''}`);
|
|
292
|
+
if (event.type === 'thread.started') {
|
|
293
|
+
const started = event;
|
|
294
|
+
const threadId = started.thread_id;
|
|
295
|
+
logger.info(`[AgentIDE] Codex thread started: ${threadId}`);
|
|
296
|
+
await (0, base_1.persistSessionIfNeeded)('codex', convo, threadId, options);
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
if (event.type === 'turn.failed') {
|
|
300
|
+
await emitter.error(event.error?.message || 'Codex turn failed');
|
|
301
|
+
throw new Error(event.error?.message || 'Codex turn failed');
|
|
302
|
+
}
|
|
303
|
+
if (event.type === 'error') {
|
|
304
|
+
await emitter.error(event.message || 'Codex stream error');
|
|
305
|
+
throw new Error(event.message || 'Codex stream error');
|
|
306
|
+
}
|
|
307
|
+
if (event.type === 'turn.completed') {
|
|
308
|
+
logger.info(`[AgentIDE] Codex usage: input=${event.usage.input_tokens}, cached=${event.usage.cached_input_tokens}, output=${event.usage.output_tokens}`);
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
if (isCodexItemEvent(event)) {
|
|
312
|
+
const { item } = event;
|
|
313
|
+
if (item.type === 'reasoning') {
|
|
314
|
+
reasoningItemSeen++;
|
|
315
|
+
const full = item.text ?? '';
|
|
316
|
+
const delta = (0, utils_1.computeTextDelta)(item.id, item.text ?? '', textTracker);
|
|
317
|
+
if (delta) {
|
|
318
|
+
reasoningDeltaCount++;
|
|
319
|
+
reasoningCharCount += delta.length;
|
|
320
|
+
if (reasoningDeltaCount <= 3) {
|
|
321
|
+
logger.debug(`[AgentIDE] Codex reasoning delta #${reasoningDeltaCount} (${delta.length} chars): ${preview(delta)}`);
|
|
322
|
+
}
|
|
323
|
+
await emitter.thinking(delta);
|
|
324
|
+
}
|
|
325
|
+
else if (!loggedEmptyReasoningOnce && full.length === 0) {
|
|
326
|
+
loggedEmptyReasoningOnce = true;
|
|
327
|
+
logger.debug('[AgentIDE] Codex reasoning item observed but text is empty so far.');
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
else if (item.type === 'agent_message') {
|
|
331
|
+
const delta = (0, utils_1.computeTextDelta)(item.id, item.text ?? '', textTracker);
|
|
332
|
+
if (delta) {
|
|
333
|
+
await emitter.text(delta);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
else if (item.type === 'command_execution') {
|
|
337
|
+
if (event.type === 'item.started') {
|
|
338
|
+
// Emit command as thinking so users can see what's being executed
|
|
339
|
+
await emitter.thinking(`**Running command**\n\`\`\`bash\n${item.command}\n\`\`\`\n`);
|
|
340
|
+
await emitter.toolStart('terminal', item.command, item.id, {
|
|
341
|
+
kind: 'terminal',
|
|
342
|
+
language: 'bash',
|
|
343
|
+
});
|
|
344
|
+
// Set up edit tracking for files in command
|
|
345
|
+
// Filter out binary files - they can't be diffed as text
|
|
346
|
+
if (rawChatSessionId && item.command && editTracker) {
|
|
347
|
+
const files = (0, utils_1.extractFilePaths)(item.command, options.workspaceRoot).filter(f => !(0, utils_1.isBinaryFile)(f));
|
|
348
|
+
if (files.length > 0) {
|
|
349
|
+
if ((0, utils_1.isCreateCommand)(item.command)) {
|
|
350
|
+
// Create command: all files are new
|
|
351
|
+
pendingNewFiles.set(item.id, files);
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
// Modify command: partition by existence (parallel check)
|
|
355
|
+
const checks = await Promise.all(files.map(async (f) => [f, await (0, utils_1.pathExists)(f)]));
|
|
356
|
+
const existing = checks.filter(([, exists]) => exists).map(([f]) => f);
|
|
357
|
+
const created = checks.filter(([, exists]) => !exists).map(([f]) => f);
|
|
358
|
+
if (created.length > 0) {
|
|
359
|
+
pendingNewFiles.set(item.id, created);
|
|
360
|
+
}
|
|
361
|
+
if (existing.length > 0) {
|
|
362
|
+
try {
|
|
363
|
+
const r = await editTracker.startTracking(rawChatSessionId, existing);
|
|
364
|
+
if (r?.operationId !== undefined) {
|
|
365
|
+
pendingOperations.set(item.id, r.operationId);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
catch { /* ignore */ }
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
// Stream command output as thinking content
|
|
375
|
+
if (event.type === 'item.updated' || event.type === 'item.completed') {
|
|
376
|
+
const outputDelta = (0, utils_1.computeTextDelta)(`${item.id}-output`, item.aggregated_output ?? '', textTracker);
|
|
377
|
+
if (outputDelta) {
|
|
378
|
+
await emitter.thinking(outputDelta);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if (event.type === 'item.completed') {
|
|
382
|
+
const exitMsg = item.exit_code !== undefined
|
|
383
|
+
// allow-any-unicode-next-line
|
|
384
|
+
? (item.exit_code === 0 ? '✓ Command completed' : `✗ Exited with code ${item.exit_code}`)
|
|
385
|
+
: '✓ Command completed';
|
|
386
|
+
await emitter.thinking(`\n${exitMsg}\n`);
|
|
387
|
+
await emitter.toolEnd('terminal', item.id, item.exit_code !== undefined ? `Exited with code ${item.exit_code}` : 'Completed', item.exit_code !== undefined ? item.exit_code !== 0 : false, { exitCode: item.exit_code });
|
|
388
|
+
// Finalize edit tracking
|
|
389
|
+
if (rawChatSessionId && editTracker) {
|
|
390
|
+
// Existing files: stop edit tracking to compute diffs
|
|
391
|
+
const opId = pendingOperations.get(item.id);
|
|
392
|
+
if (opId !== undefined) {
|
|
393
|
+
try {
|
|
394
|
+
await editTracker.stopTracking(rawChatSessionId, opId);
|
|
395
|
+
}
|
|
396
|
+
catch { /* ignore */ }
|
|
397
|
+
pendingOperations.delete(item.id);
|
|
398
|
+
}
|
|
399
|
+
// New files: read, delete, apply (so VS Code sees original=empty)
|
|
400
|
+
// Skip binary files - they would be corrupted by UTF-8 read/write
|
|
401
|
+
for (const f of pendingNewFiles.get(item.id) ?? []) {
|
|
402
|
+
try {
|
|
403
|
+
if ((0, utils_1.isBinaryFile)(f)) {
|
|
404
|
+
continue; // Don't track binary files for edit diffs
|
|
405
|
+
}
|
|
406
|
+
if (await (0, utils_1.pathExists)(f)) {
|
|
407
|
+
const code = await fs_1.promises.readFile(f, 'utf-8');
|
|
408
|
+
await fs_1.promises.unlink(f);
|
|
409
|
+
await editTracker.applyEdit(rawChatSessionId, f, code, true);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
catch { /* ignore */ }
|
|
413
|
+
}
|
|
414
|
+
pendingNewFiles.delete(item.id);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
else if (item.type === 'mcp_tool_call') {
|
|
419
|
+
if (event.type === 'item.started') {
|
|
420
|
+
// Emit MCP tool call as thinking
|
|
421
|
+
const argsStr = item.arguments ? `\n\`\`\`json\n${JSON.stringify(item.arguments, null, 2)}\n\`\`\`` : '';
|
|
422
|
+
await emitter.thinking(`**Calling MCP tool** \`${item.server}.${item.tool}\`${argsStr}\n`);
|
|
423
|
+
const argsPreview = item.arguments
|
|
424
|
+
? JSON.stringify(item.arguments, null, 2).slice(0, 400)
|
|
425
|
+
: '';
|
|
426
|
+
await emitter.toolStart(`${item.server}.${item.tool}`, argsPreview, item.id, { arguments: item.arguments });
|
|
427
|
+
}
|
|
428
|
+
if (event.type === 'item.completed') {
|
|
429
|
+
// Show MCP result or error
|
|
430
|
+
if (item.error?.message) {
|
|
431
|
+
// allow-any-unicode-next-line
|
|
432
|
+
await emitter.thinking(`\n✗ MCP error: ${item.error.message}\n`);
|
|
433
|
+
await emitter.toolEnd(`${item.server}.${item.tool}`, item.id, item.error.message, true, { error: item.error });
|
|
434
|
+
}
|
|
435
|
+
else if (item.result) {
|
|
436
|
+
const resultStr = JSON.stringify(item.result.structured_content ?? item.result.content, null, 2);
|
|
437
|
+
const truncated = resultStr.length > 500 ? resultStr.slice(0, 500) + '...' : resultStr;
|
|
438
|
+
await emitter.thinking(`\n✓ MCP result:\n\`\`\`json\n${truncated}\n\`\`\`\n`);
|
|
439
|
+
await emitter.toolEnd(`${item.server}.${item.tool}`, item.id, 'MCP call completed', false, { result: item.result });
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
await emitter.toolEnd(`${item.server}.${item.tool}`, item.id, 'MCP call completed', false);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
else if (item.type === 'file_change') {
|
|
447
|
+
if (event.type === 'item.started') {
|
|
448
|
+
const files = item.changes.map(c => `${c.kind} ${c.path}`).join(', ');
|
|
449
|
+
await emitter.thinking(`**File changes:** ${files}\n`);
|
|
450
|
+
await emitter.progress(`[Files] ${files}`);
|
|
451
|
+
// Start edit tracking BEFORE files are modified (snapshot current state)
|
|
452
|
+
// Filter out binary files - they can't be diffed as text
|
|
453
|
+
if (!rawChatSessionId) {
|
|
454
|
+
logger.debug(`[AgentIDE] Codex file_change: skipping edit tracking (no session ID)`);
|
|
455
|
+
}
|
|
456
|
+
else if (!editTracker) {
|
|
457
|
+
logger.warn(`[AgentIDE] Codex file_change: skipping edit tracking (no editTracker)`);
|
|
458
|
+
}
|
|
459
|
+
if (rawChatSessionId && editTracker) {
|
|
460
|
+
const filePaths = item.changes
|
|
461
|
+
.filter(c => {
|
|
462
|
+
const normalizedKind = (0, utils_1.normalizeFileChangeKind)(String(c.kind));
|
|
463
|
+
return (normalizedKind === 'create' || normalizedKind === 'modify') && !(0, utils_1.isBinaryFile)(c.path);
|
|
464
|
+
})
|
|
465
|
+
.map(c => {
|
|
466
|
+
// Resolve relative paths to absolute using workspaceRoot
|
|
467
|
+
return path.isAbsolute(c.path) ? c.path : path.join(options.workspaceRoot, c.path);
|
|
468
|
+
});
|
|
469
|
+
if (filePaths.length > 0) {
|
|
470
|
+
logger.info(`[AgentIDE] Codex file_change: starting edit tracking for ${filePaths.length} files: ${filePaths.join(', ')}`);
|
|
471
|
+
try {
|
|
472
|
+
const result = await editTracker.startTracking(rawChatSessionId, filePaths);
|
|
473
|
+
if (result?.operationId !== undefined) {
|
|
474
|
+
pendingOperations.set(item.id, result.operationId);
|
|
475
|
+
logger.info(`[AgentIDE] Codex file_change: edit tracking started (op=${result.operationId})`);
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
logger.warn(`[AgentIDE] Codex file_change: startTracking returned no operationId`);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
catch (e) {
|
|
482
|
+
logger.warn(`[AgentIDE] Codex file_change: failed to start edit tracking: ${e}`);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
else {
|
|
486
|
+
logger.debug(`[AgentIDE] Codex file_change: no trackable files (all filtered out)`);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
if (event.type === 'item.completed') {
|
|
491
|
+
// allow-any-unicode-next-line
|
|
492
|
+
const statusEmoji = item.status === 'completed' ? '✓' : '✗';
|
|
493
|
+
await emitter.thinking(`${statusEmoji} File changes ${item.status}\n`);
|
|
494
|
+
// Stop edit tracking AFTER files are modified (compute diffs from disk)
|
|
495
|
+
const operationId = pendingOperations.get(item.id);
|
|
496
|
+
if (rawChatSessionId && operationId !== undefined && editTracker) {
|
|
497
|
+
try {
|
|
498
|
+
await editTracker.stopTracking(rawChatSessionId, operationId);
|
|
499
|
+
logger.debug(`[AgentIDE] Stopped edit tracking (op=${operationId})`);
|
|
500
|
+
}
|
|
501
|
+
catch (e) {
|
|
502
|
+
logger.warn(`[AgentIDE] Failed to stop edit tracking: ${e}`);
|
|
503
|
+
}
|
|
504
|
+
finally {
|
|
505
|
+
pendingOperations.delete(item.id);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
else if (item.type === 'web_search') {
|
|
511
|
+
if (event.type === 'item.started') {
|
|
512
|
+
await emitter.thinking(`**Web search:** ${item.query}\n`);
|
|
513
|
+
await emitter.toolStart('web_search', item.query, item.id, { query: item.query });
|
|
514
|
+
}
|
|
515
|
+
if (event.type === 'item.completed') {
|
|
516
|
+
await emitter.toolEnd('web_search', item.id, 'Search completed', false, { query: item.query });
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
else if (item.type === 'todo_list') {
|
|
520
|
+
// Codex often does not emit "reasoning" text; stream the plan into Thinking as a useful transparency fallback.
|
|
521
|
+
if (event.type === 'item.started') {
|
|
522
|
+
const lines = item.items.map(i => `- [${i.completed ? 'x' : ' '}] ${i.text}`);
|
|
523
|
+
await emitter.thinking(`**Plan**\n${lines.join('\n')}\n`);
|
|
524
|
+
}
|
|
525
|
+
if (event.type === 'item.updated') {
|
|
526
|
+
// Update plan progress as thinking
|
|
527
|
+
const lines = item.items.map(i => `- [${i.completed ? 'x' : ' '}] ${i.text}`);
|
|
528
|
+
await emitter.thinking(`**Plan update**\n${lines.join('\n')}\n`);
|
|
529
|
+
}
|
|
530
|
+
if (event.type === 'item.started' || event.type === 'item.completed') {
|
|
531
|
+
const completed = item.items.filter(i => i.completed).length;
|
|
532
|
+
await emitter.progress(`[Plan] ${completed}/${item.items.length} steps complete`);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
else if (item.type === 'error') {
|
|
536
|
+
// NOTE: Codex CLI surfaces non-fatal warnings as `ErrorItem`s in the event stream
|
|
537
|
+
const msg = item.message || 'Codex warning';
|
|
538
|
+
logger.warn(`[AgentIDE] Codex warning: ${msg}`);
|
|
539
|
+
await emitter.thinking(`**Warning:** ${msg}\n`);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
catch (e) {
|
|
545
|
+
if (signal?.aborted) {
|
|
546
|
+
logger.info(`[AgentIDE] Codex stream aborted: ${e instanceof Error ? e.message : String(e)}`);
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
throw e;
|
|
550
|
+
}
|
|
551
|
+
logger.info(`[AgentIDE] Codex reasoning summary: items=${reasoningItemSeen}, deltas=${reasoningDeltaCount}, chars=${reasoningCharCount}`);
|
|
552
|
+
if (reasoningItemSeen === 0) {
|
|
553
|
+
logger.debug('[AgentIDE] Codex emitted no reasoning items. This SDK only exposes a reasoning *summary* when available; many runs may have none.');
|
|
554
|
+
}
|
|
555
|
+
(0, base_1.touchSessionIfNeeded)(convo);
|
|
556
|
+
}, {
|
|
557
|
+
signal,
|
|
558
|
+
// Agent turns may run for hours; keep this high as a safety net only.
|
|
559
|
+
timeoutMs: session_1.DEFAULT_CONVERSATION_LOCK_TIMEOUT_MS,
|
|
560
|
+
label: 'codex.stream'
|
|
561
|
+
});
|
|
562
|
+
await emitter.done();
|
|
563
|
+
logger.info('[AgentIDE] Codex streaming complete');
|
|
564
|
+
}
|
|
565
|
+
dispose() {
|
|
566
|
+
this.lastWrittenConfigSignature = undefined;
|
|
567
|
+
this.lastCodexSkillsSignatureByWorkspaceRoot.clear();
|
|
568
|
+
}
|
|
569
|
+
onMaintenance(_logger) {
|
|
570
|
+
// No-op for Codex currently.
|
|
571
|
+
// Future: could prune stale thread references, clean temp files, etc.
|
|
572
|
+
}
|
|
573
|
+
// ---------------------------------------------------------------------------
|
|
574
|
+
// Config Management
|
|
575
|
+
// ---------------------------------------------------------------------------
|
|
576
|
+
/**
|
|
577
|
+
* Ensure Codex CLI config.toml is written with the correct provider settings.
|
|
578
|
+
* @param useLiteLLM Whether routing through LiteLLM proxy
|
|
579
|
+
* @param customBaseUrl Custom endpoint URL (undefined for direct OpenAI API)
|
|
580
|
+
* @param modelId Target model ID
|
|
581
|
+
* @param workspaceRoot Workspace root path
|
|
582
|
+
* @param additionalDirectories Additional directories for Codex
|
|
583
|
+
* @param logger Logger for output
|
|
584
|
+
*/
|
|
585
|
+
async ensureCodexConfig(useLiteLLM, customBaseUrl, modelId, workspaceRoot, additionalDirectories, logger, explicitCodexHome, // For pack support
|
|
586
|
+
agentId = 'default', // Active agent ID for skills path
|
|
587
|
+
autoApproveMcp = false) {
|
|
588
|
+
const codexHome = explicitCodexHome ?? this.config.codexHome;
|
|
589
|
+
if (!codexHome) {
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
// Sync project skills into $CODEX_HOME/skills
|
|
593
|
+
try {
|
|
594
|
+
const skillsSig = this.getSkillsSignature(workspaceRoot);
|
|
595
|
+
await this.syncCodexSkillsToCodexHome(codexHome, workspaceRoot, agentId, logger, skillsSig);
|
|
596
|
+
}
|
|
597
|
+
catch (e) {
|
|
598
|
+
logger.warn(`[AgentIDE] Warning: failed to sync skills into $CODEX_HOME: ${e instanceof Error ? e.message : String(e)}`);
|
|
599
|
+
}
|
|
600
|
+
const codexInstructionsFile = await this.updateCodexRuntimeInstructionsFile(codexHome, workspaceRoot, additionalDirectories, agentId, logger);
|
|
601
|
+
// Codex CLI requires wire_api=responses (chat wire was removed in newer Codex releases).
|
|
602
|
+
const wireApi = 'responses';
|
|
603
|
+
const routingType = useLiteLLM ? 'litellm' : (customBaseUrl ? 'custom' : 'openai');
|
|
604
|
+
const signature = `${AGENTIDE_CODEX_CONFIG_VERSION}:${routingType}:${customBaseUrl ?? ''}:${wireApi}:${agentId}:${codexInstructionsFile ?? ''}:${(0, mcp_1.mcpConfigCacheSignatureSuffix)()}`;
|
|
605
|
+
if (this.lastWrittenConfigSignature === signature) {
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
await fs_1.promises.mkdir(codexHome, { recursive: true });
|
|
609
|
+
// Build config.toml with common settings and optional custom provider section
|
|
610
|
+
const lines = [
|
|
611
|
+
`# AgentIDE Codex config (generated) - ${routingType} mode`,
|
|
612
|
+
'model_reasoning_summary = "detailed"',
|
|
613
|
+
'hide_agent_reasoning = false',
|
|
614
|
+
// Surface raw reasoning content when the model emits it (improves streaming visibility)
|
|
615
|
+
// 'show_raw_agent_reasoning = true',
|
|
616
|
+
// Force Codex to send reasoning metadata even for unknown models
|
|
617
|
+
// 'model_supports_reasoning_summaries = true',
|
|
618
|
+
// Codex CLI loads a single "model instructions" file that acts like a system/developer prompt overlay.
|
|
619
|
+
// Note: experimental_instructions_file is deprecated and ignored by newer Codex CLI versions.
|
|
620
|
+
codexInstructionsFile ? `model_instructions_file = ${JSON.stringify(codexInstructionsFile)}` : undefined,
|
|
621
|
+
];
|
|
622
|
+
// Add custom provider section for LiteLLM or custom providers (e.g., OpenRouter)
|
|
623
|
+
if (customBaseUrl) {
|
|
624
|
+
const providerId = useLiteLLM ? AGENTIDE_CODEX_PROVIDER_ID : AGENTIDE_CODEX_CUSTOM_PROVIDER_ID;
|
|
625
|
+
const providerName = useLiteLLM ? 'AgentIDE LiteLLM' : 'AgentIDE Custom Provider';
|
|
626
|
+
lines.push('', `model_provider = "${providerId}"`, '', `[model_providers.${providerId}]`, `name = "${providerName}"`, `base_url = ${JSON.stringify(customBaseUrl)}`, 'env_key = "CODEX_API_KEY"', `wire_api = "${wireApi}"`, 'query_params = {}');
|
|
627
|
+
// LiteLLM-specific analytics headers (enriched - see PLAN/analytics-design.md)
|
|
628
|
+
if (useLiteLLM) {
|
|
629
|
+
lines.push(`env_http_headers = { ` +
|
|
630
|
+
`"x-litellm-metadata-session-id" = "${AGENTIDE_CODEX_SESSION_ENV_VAR}", ` +
|
|
631
|
+
`"x-litellm-metadata-user-id" = "${AGENTIDE_CODEX_USER_ENV_VAR}", ` +
|
|
632
|
+
`"x-litellm-metadata-project-id" = "${AGENTIDE_CODEX_PROJECT_ID_ENV_VAR}", ` +
|
|
633
|
+
`"langfuse_session_id" = "${AGENTIDE_CODEX_SESSION_ENV_VAR}", ` +
|
|
634
|
+
`"langfuse_trace_user_id" = "${AGENTIDE_CODEX_USER_ENV_VAR}", ` +
|
|
635
|
+
`"x-litellm-metadata-agent-id" = "${AGENTIDE_CODEX_AGENT_ID_ENV_VAR}", ` +
|
|
636
|
+
`"x-litellm-metadata-agent-version" = "${AGENTIDE_CODEX_AGENT_VERSION_ENV_VAR}", ` +
|
|
637
|
+
`"x-litellm-metadata-source" = "${AGENTIDE_CODEX_SOURCE_ENV_VAR}", ` +
|
|
638
|
+
`"x-litellm-metadata-engine" = "${AGENTIDE_CODEX_ENGINE_ENV_VAR}", ` +
|
|
639
|
+
`"x-litellm-metadata-request-id" = "${AGENTIDE_CODEX_REQUEST_ID_ENV_VAR}" }`);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
// Add MCP servers section (pack-aware)
|
|
643
|
+
const basePromptsDir = this.getBundledBasePromptsDir();
|
|
644
|
+
const servers = await (0, mcp_1.loadMcpServers)(agentId, workspaceRoot, basePromptsDir);
|
|
645
|
+
const mcpSection = (0, mcp_1.generateCodexMcpConfig)(servers, { autoApprove: autoApproveMcp });
|
|
646
|
+
if (servers.length > 0) {
|
|
647
|
+
const source = agentId === 'default' ? 'bundled' : `pack:${agentId}`;
|
|
648
|
+
logger.debug(`[AgentIDE] Codex MCP config (${source}): ${servers.length} server(s)`);
|
|
649
|
+
}
|
|
650
|
+
const configToml = lines.filter(Boolean).join('\n') + mcpSection;
|
|
651
|
+
await fs_1.promises.writeFile(path.join(codexHome, 'config.toml'), configToml, 'utf8');
|
|
652
|
+
this.lastWrittenConfigSignature = signature;
|
|
653
|
+
logger.info(`[AgentIDE] Codex configured (${routingType}) at ${codexHome}${customBaseUrl ? `, baseUrl=${customBaseUrl}, wire_api=${wireApi}` : ''}, model=${modelId ?? 'unknown'}`);
|
|
654
|
+
}
|
|
655
|
+
async updateCodexRuntimeInstructionsFile(codexHome, workspaceRoot, additionalDirectories, agentId, logger) {
|
|
656
|
+
// Read AGENTS.md from the active pack's source directory
|
|
657
|
+
// The source of truth is <BRAND_FOLDER>/agents/<agentId>/AGENTS.md
|
|
658
|
+
const packAgentsFile = path.join(workspaceRoot, agentpack_1.AGENT_CONSTANTS.AGENTIDE_DIR_NAME, 'agents', agentId, 'AGENTS.md');
|
|
659
|
+
let baseRules = '';
|
|
660
|
+
if (await (0, utils_1.pathExists)(packAgentsFile)) {
|
|
661
|
+
baseRules = await fs_1.promises.readFile(packAgentsFile, 'utf8');
|
|
662
|
+
logger.debug(`[AgentIDE] Codex instructions from pack: ${agentId}/AGENTS.md`);
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
// Fall back to bundled templates if pack's AGENTS.md doesn't exist
|
|
666
|
+
const bundledDir = this.getBundledBasePromptsDir();
|
|
667
|
+
if (bundledDir) {
|
|
668
|
+
const bundledAgentsFile = path.join(bundledDir, 'rules', 'AGENTS.md');
|
|
669
|
+
if (await (0, utils_1.pathExists)(bundledAgentsFile)) {
|
|
670
|
+
baseRules = await fs_1.promises.readFile(bundledAgentsFile, 'utf8');
|
|
671
|
+
logger.debug(`[AgentIDE] Codex instructions from bundled templates (pack ${agentId} has no AGENTS.md)`);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
if (!baseRules) {
|
|
675
|
+
logger.warn(`[AgentIDE] Warning: no AGENTS.md found for agent ${agentId} and no bundled fallback`);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
// Also read pack's context.md if it exists (combined with AGENTS.md like sync service does)
|
|
679
|
+
const packContextFile = path.join(workspaceRoot, agentpack_1.AGENT_CONSTANTS.AGENTIDE_DIR_NAME, 'agents', agentId, 'context.md');
|
|
680
|
+
let contextContent = '';
|
|
681
|
+
if (await (0, utils_1.pathExists)(packContextFile)) {
|
|
682
|
+
contextContent = await fs_1.promises.readFile(packContextFile, 'utf8');
|
|
683
|
+
}
|
|
684
|
+
const stableDirs = additionalDirectories.slice().filter(Boolean).sort();
|
|
685
|
+
const runtimeContext = {
|
|
686
|
+
workspaceRoot,
|
|
687
|
+
additionalDirectories: stableDirs,
|
|
688
|
+
};
|
|
689
|
+
const runtimeBlock = [
|
|
690
|
+
'## AgentIDE Runtime Context (managed)',
|
|
691
|
+
'',
|
|
692
|
+
'### Workspace Information',
|
|
693
|
+
'',
|
|
694
|
+
'```json',
|
|
695
|
+
JSON.stringify(runtimeContext, null, 2),
|
|
696
|
+
'```',
|
|
697
|
+
].join('\n');
|
|
698
|
+
// Combine: AGENTS.md + context.md + runtime block (mirrors sync service's combined rules format)
|
|
699
|
+
const parts = [baseRules.trimEnd()];
|
|
700
|
+
if (contextContent.trim()) {
|
|
701
|
+
parts.push(contextContent.trimEnd());
|
|
702
|
+
}
|
|
703
|
+
parts.push(runtimeBlock.trimEnd());
|
|
704
|
+
const combined = parts
|
|
705
|
+
.filter(Boolean)
|
|
706
|
+
.join('\n\n---\n\n')
|
|
707
|
+
.trimEnd()
|
|
708
|
+
.concat('\n');
|
|
709
|
+
const runtimeFile = path.join(codexHome, 'agentide.runtime.md');
|
|
710
|
+
await (0, utils_1.writeFileIfChanged)(runtimeFile, combined);
|
|
711
|
+
return runtimeFile;
|
|
712
|
+
}
|
|
713
|
+
async syncCodexSkillsToCodexHome(codexHome, workspaceRoot, agentId, logger, skillsSignature) {
|
|
714
|
+
// Skills are stored under the agent's directory: <BRAND_FOLDER>/agents/<agentId>/skills/
|
|
715
|
+
const srcSkillsRoot = path.join(workspaceRoot, agentpack_1.AGENT_CONSTANTS.AGENTIDE_DIR_NAME, 'agents', agentId, 'skills');
|
|
716
|
+
const dstSkillsRoot = path.join(codexHome, 'skills');
|
|
717
|
+
if (skillsSignature) {
|
|
718
|
+
const last = this.lastCodexSkillsSignatureByWorkspaceRoot.get(workspaceRoot);
|
|
719
|
+
const dstExists = await (0, utils_1.pathExists)(dstSkillsRoot);
|
|
720
|
+
if (last === skillsSignature && dstExists) {
|
|
721
|
+
logger.debug(`[AgentIDE] Codex skills unchanged (sig=${skillsSignature}), skipping $CODEX_HOME sync`);
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
// Ensure destination is fully overwritten (AgentIDE-managed).
|
|
726
|
+
try {
|
|
727
|
+
await fs_1.promises.rm(dstSkillsRoot, { recursive: true, force: true });
|
|
728
|
+
}
|
|
729
|
+
catch {
|
|
730
|
+
// ignore
|
|
731
|
+
}
|
|
732
|
+
if (!(await (0, utils_1.pathExists)(srcSkillsRoot))) {
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
await fs_1.promises.mkdir(dstSkillsRoot, { recursive: true });
|
|
736
|
+
let copied = 0;
|
|
737
|
+
const entries = await fs_1.promises.readdir(srcSkillsRoot, { withFileTypes: true });
|
|
738
|
+
for (const entry of entries) {
|
|
739
|
+
if (!entry.isDirectory()) {
|
|
740
|
+
continue;
|
|
741
|
+
}
|
|
742
|
+
if (entry.name.startsWith('.')) {
|
|
743
|
+
continue;
|
|
744
|
+
}
|
|
745
|
+
const srcSkill = path.join(srcSkillsRoot, entry.name);
|
|
746
|
+
const skillFile = path.join(srcSkill, 'SKILL.md');
|
|
747
|
+
if (!(await (0, utils_1.pathExists)(skillFile))) {
|
|
748
|
+
continue;
|
|
749
|
+
}
|
|
750
|
+
await (0, utils_1.copyDirRecursive)(srcSkill, path.join(dstSkillsRoot, entry.name));
|
|
751
|
+
copied++;
|
|
752
|
+
}
|
|
753
|
+
if (skillsSignature) {
|
|
754
|
+
this.lastCodexSkillsSignatureByWorkspaceRoot.set(workspaceRoot, skillsSignature);
|
|
755
|
+
}
|
|
756
|
+
logger.info(`[AgentIDE] Codex skills synced to $CODEX_HOME: ${copied} skill(s)`);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
exports.CodexEngine = CodexEngine;
|