xithead 1.5.0 → 1.5.1
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/design-system/README.md +80 -0
- package/package.json +20 -1
- package/public/apple-touch-icon.png +0 -0
- package/public/logo-transparent.png +0 -0
- package/public/xithead.ps1 +937 -0
- package/scripts/README.md +77 -0
- package/scripts/audit_wheel_glibc_symbols.py +217 -0
- package/scripts/build-master-design-system.cjs +33 -0
- package/scripts/build_rust_extension.sh +58 -0
- package/scripts/changelog-gen.py +203 -0
- package/scripts/eval_output_shaper.py +235 -0
- package/scripts/export_kompress_v2_onnx.py +267 -0
- package/scripts/fixtures/anthropic_replay_body.json +133 -0
- package/scripts/fixtures/codex_response_create_frame.json +52 -0
- package/scripts/install-git-hooks.sh +104 -0
- package/scripts/install.ps1 +1809 -0
- package/scripts/install.sh +1673 -0
- package/scripts/pr-governance.py +297 -0
- package/scripts/record_fixtures.py +59 -0
- package/scripts/refresh_model_limits.sh +48 -0
- package/scripts/replay_codex_ws_load.py +445 -0
- package/scripts/repro_codex_replay.py +699 -0
- package/scripts/smoke_issue_327.py +233 -0
- package/scripts/sync-plugin-versions.py +116 -0
- package/scripts/tests/test_changelog_gen.py +302 -0
- package/scripts/tests/test_pr_governance.py +163 -0
- package/scripts/tests/test_pr_health_labels.py +94 -0
- package/scripts/tests/test_pr_health_workflow.py +14 -0
- package/scripts/tests/test_sync_plugin_versions.py +131 -0
- package/scripts/tests/test_version_sync.py +291 -0
- package/scripts/validate-workflows.sh +39 -0
- package/scripts/verify-versions.py +106 -0
- package/scripts/version-sync.py +207 -0
- package/tailwind.config.js +31 -0
- package/tsconfig.json +84 -0
- package/.actrc +0 -14
- package/.actrc.local.example +0 -15
- package/.changelog.md +0 -2
- package/.claude/agents/academic-anthropologist.md +0 -125
- package/.claude/agents/academic-geographer.md +0 -127
- package/.claude/agents/academic-historian.md +0 -123
- package/.claude/agents/academic-narratologist.md +0 -118
- package/.claude/agents/academic-psychologist.md +0 -118
- package/.claude/agents/academic-statistician.md +0 -144
- package/.claude/agents/accounts-payable-agent.md +0 -205
- package/.claude/agents/agentic-identity-trust.md +0 -394
- package/.claude/agents/agents-orchestrator.md +0 -367
- package/.claude/agents/automation-governance-architect.md +0 -216
- package/.claude/agents/blender-addon-engineer.md +0 -243
- package/.claude/agents/business-strategist.md +0 -488
- package/.claude/agents/change-management-consultant.md +0 -497
- package/.claude/agents/chief-financial-officer.md +0 -388
- package/.claude/agents/corporate-training-designer.md +0 -192
- package/.claude/agents/customer-service.md +0 -398
- package/.claude/agents/customer-success-manager.md +0 -460
- package/.claude/agents/data-consolidation-agent.md +0 -60
- package/.claude/agents/data-privacy-officer.md +0 -412
- package/.claude/agents/design-brand-guardian.md +0 -322
- package/.claude/agents/design-image-prompt-engineer.md +0 -236
- package/.claude/agents/design-inclusive-visuals-specialist.md +0 -73
- package/.claude/agents/design-persona-walkthrough.md +0 -272
- package/.claude/agents/design-ui-designer.md +0 -386
- package/.claude/agents/design-ui-finish-gate-reviewer.md +0 -217
- package/.claude/agents/design-ux-architect.md +0 -482
- package/.claude/agents/design-ux-researcher.md +0 -329
- package/.claude/agents/design-visual-storyteller.md +0 -149
- package/.claude/agents/design-whimsy-injector.md +0 -460
- package/.claude/agents/economy-designer.md +0 -156
- package/.claude/agents/engineering-ai-data-remediation-engineer.md +0 -211
- package/.claude/agents/engineering-ai-engineer.md +0 -146
- package/.claude/agents/engineering-api-platform-engineer.md +0 -181
- package/.claude/agents/engineering-ats-validator-architect.md +0 -383
- package/.claude/agents/engineering-autonomous-optimization-architect.md +0 -121
- package/.claude/agents/engineering-backend-architect.md +0 -255
- package/.claude/agents/engineering-china-network-engineer.md +0 -252
- package/.claude/agents/engineering-cms-developer.md +0 -536
- package/.claude/agents/engineering-code-reviewer.md +0 -76
- package/.claude/agents/engineering-codebase-onboarding-engineer.md +0 -173
- package/.claude/agents/engineering-data-engineer.md +0 -349
- package/.claude/agents/engineering-data-visualization-engineer.md +0 -151
- package/.claude/agents/engineering-database-optimizer.md +0 -188
- package/.claude/agents/engineering-database-reliability-engineer.md +0 -201
- package/.claude/agents/engineering-desktop-app-engineer.md +0 -209
- package/.claude/agents/engineering-developer-tooling-engineer.md +0 -153
- package/.claude/agents/engineering-devops-automator.md +0 -385
- package/.claude/agents/engineering-drupal-performance.md +0 -347
- package/.claude/agents/engineering-drupal-shopping-cart.md +0 -360
- package/.claude/agents/engineering-electrical-engineer.md +0 -575
- package/.claude/agents/engineering-email-intelligence-engineer.md +0 -390
- package/.claude/agents/engineering-embedded-firmware-engineer.md +0 -196
- package/.claude/agents/engineering-feishu-integration-developer.md +0 -606
- package/.claude/agents/engineering-filament-optimization-specialist.md +0 -283
- package/.claude/agents/engineering-finops-engineer.md +0 -164
- package/.claude/agents/engineering-frontend-developer.md +0 -257
- package/.claude/agents/engineering-gaussdb-expert.md +0 -334
- package/.claude/agents/engineering-git-workflow-master.md +0 -98
- package/.claude/agents/engineering-i18n-engineer.md +0 -214
- package/.claude/agents/engineering-identity-access-engineer.md +0 -217
- package/.claude/agents/engineering-incident-response-commander.md +0 -444
- package/.claude/agents/engineering-iot-fleet-engineer.md +0 -148
- package/.claude/agents/engineering-it-service-manager.md +0 -561
- package/.claude/agents/engineering-knowledge-graph-engineer.md +0 -372
- package/.claude/agents/engineering-llm-post-training-engineer.md +0 -166
- package/.claude/agents/engineering-minimal-change-engineer.md +0 -207
- package/.claude/agents/engineering-mobile-app-builder.md +0 -493
- package/.claude/agents/engineering-mobile-release-engineer.md +0 -164
- package/.claude/agents/engineering-multi-agent-systems-architect.md +0 -600
- package/.claude/agents/engineering-network-engineer.md +0 -245
- package/.claude/agents/engineering-orgscript-engineer.md +0 -113
- package/.claude/agents/engineering-payments-billing-engineer.md +0 -228
- package/.claude/agents/engineering-pdf-engine-architect.md +0 -696
- package/.claude/agents/engineering-platform-engineer.md +0 -270
- package/.claude/agents/engineering-privacy-engineer.md +0 -152
- package/.claude/agents/engineering-prompt-engineer.md +0 -209
- package/.claude/agents/engineering-rag-pipeline-engineer.md +0 -450
- package/.claude/agents/engineering-rapid-prototyper.md +0 -466
- package/.claude/agents/engineering-realtime-collaboration-engineer.md +0 -200
- package/.claude/agents/engineering-rust-refactoring-specialist.md +0 -313
- package/.claude/agents/engineering-search-relevance-engineer.md +0 -237
- package/.claude/agents/engineering-section-508-specialist.md +0 -339
- package/.claude/agents/engineering-senior-developer.md +0 -176
- package/.claude/agents/engineering-servicenow-developer-mentor.md +0 -180
- package/.claude/agents/engineering-software-architect.md +0 -112
- package/.claude/agents/engineering-solidity-smart-contract-engineer.md +0 -522
- package/.claude/agents/engineering-sre.md +0 -90
- package/.claude/agents/engineering-technical-writer.md +0 -393
- package/.claude/agents/engineering-universal-document-compiler.md +0 -370
- package/.claude/agents/engineering-uswds-developer.md +0 -340
- package/.claude/agents/engineering-video-streaming-engineer.md +0 -151
- package/.claude/agents/engineering-voice-ai-integration-engineer.md +0 -584
- package/.claude/agents/engineering-webassembly-engineer.md +0 -153
- package/.claude/agents/engineering-wechat-mini-program-developer.md +0 -356
- package/.claude/agents/engineering-wordpress-performance.md +0 -346
- package/.claude/agents/engineering-wordpress-shopping-cart.md +0 -346
- package/.claude/agents/esg-sustainability-officer.md +0 -396
- package/.claude/agents/finance-bookkeeper-controller.md +0 -260
- package/.claude/agents/finance-financial-analyst.md +0 -234
- package/.claude/agents/finance-fpa-analyst.md +0 -263
- package/.claude/agents/finance-investment-researcher.md +0 -272
- package/.claude/agents/finance-tax-strategist.md +0 -239
- package/.claude/agents/game-audio-engineer.md +0 -264
- package/.claude/agents/game-designer.md +0 -167
- package/.claude/agents/gis-3d-scene-developer.md +0 -111
- package/.claude/agents/gis-analyst.md +0 -91
- package/.claude/agents/gis-bim-specialist.md +0 -108
- package/.claude/agents/gis-cartography-designer.md +0 -150
- package/.claude/agents/gis-drone-reality-mapping.md +0 -120
- package/.claude/agents/gis-geoai-ml-engineer.md +0 -105
- package/.claude/agents/gis-geoprocessing-specialist.md +0 -97
- package/.claude/agents/gis-qa-engineer.md +0 -133
- package/.claude/agents/gis-solution-engineer.md +0 -101
- package/.claude/agents/gis-spatial-data-engineer.md +0 -97
- package/.claude/agents/gis-spatial-data-scientist.md +0 -111
- package/.claude/agents/gis-technical-consultant.md +0 -86
- package/.claude/agents/gis-web-gis-developer.md +0 -108
- package/.claude/agents/godot-gameplay-scripter.md +0 -338
- package/.claude/agents/godot-multiplayer-engineer.md +0 -301
- package/.claude/agents/godot-shader-developer.md +0 -267
- package/.claude/agents/government-digital-presales-consultant.md +0 -363
- package/.claude/agents/grant-writer.md +0 -511
- package/.claude/agents/healthcare-aging-parent-care-companion.md +0 -414
- package/.claude/agents/healthcare-clinical-evidence-agent.md +0 -231
- package/.claude/agents/healthcare-customer-service.md +0 -389
- package/.claude/agents/healthcare-innovation-strategist.md +0 -433
- package/.claude/agents/healthcare-marketing-compliance.md +0 -395
- package/.claude/agents/healthcare-sovereign-health-systems-agent.md +0 -312
- package/.claude/agents/hospitality-guest-services.md +0 -603
- package/.claude/agents/hr-onboarding.md +0 -451
- package/.claude/agents/identity-graph-operator.md +0 -303
- package/.claude/agents/language-translator.md +0 -264
- package/.claude/agents/legal-billing-time-tracking.md +0 -569
- package/.claude/agents/legal-client-intake.md +0 -492
- package/.claude/agents/legal-document-review.md +0 -454
- package/.claude/agents/level-designer.md +0 -208
- package/.claude/agents/loan-officer-assistant.md +0 -555
- package/.claude/agents/lsp-index-engineer.md +0 -320
- package/.claude/agents/ma-integration-manager.md +0 -427
- package/.claude/agents/macos-spatial-metal-engineer.md +0 -337
- package/.claude/agents/marketing-aeo-foundations.md +0 -264
- package/.claude/agents/marketing-agentic-search-optimizer.md +0 -279
- package/.claude/agents/marketing-ai-citation-strategist.md +0 -172
- package/.claude/agents/marketing-app-store-optimizer.md +0 -321
- package/.claude/agents/marketing-baidu-seo-specialist.md +0 -226
- package/.claude/agents/marketing-bilibili-content-strategist.md +0 -199
- package/.claude/agents/marketing-book-co-author.md +0 -110
- package/.claude/agents/marketing-carousel-growth-engine.md +0 -204
- package/.claude/agents/marketing-china-ecommerce-operator.md +0 -283
- package/.claude/agents/marketing-china-market-localization-strategist.md +0 -283
- package/.claude/agents/marketing-content-creator.md +0 -54
- package/.claude/agents/marketing-cross-border-ecommerce.md +0 -259
- package/.claude/agents/marketing-developer-community-builder.md +0 -285
- package/.claude/agents/marketing-douyin-strategist.md +0 -149
- package/.claude/agents/marketing-email-strategist.md +0 -249
- package/.claude/agents/marketing-global-podcast-strategist.md +0 -206
- package/.claude/agents/marketing-growth-hacker.md +0 -54
- package/.claude/agents/marketing-instagram-curator.md +0 -113
- package/.claude/agents/marketing-kuaishou-strategist.md +0 -223
- package/.claude/agents/marketing-linkedin-content-creator.md +0 -214
- package/.claude/agents/marketing-livestream-commerce-coach.md +0 -305
- package/.claude/agents/marketing-multi-platform-publisher.md +0 -217
- package/.claude/agents/marketing-podcast-strategist.md +0 -277
- package/.claude/agents/marketing-pr-communications-manager.md +0 -473
- package/.claude/agents/marketing-private-domain-operator.md +0 -308
- package/.claude/agents/marketing-reddit-community-builder.md +0 -123
- package/.claude/agents/marketing-seo-specialist.md +0 -370
- package/.claude/agents/marketing-short-video-editing-coach.md +0 -412
- package/.claude/agents/marketing-social-media-strategist.md +0 -125
- package/.claude/agents/marketing-tiktok-strategist.md +0 -125
- package/.claude/agents/marketing-twitter-engager.md +0 -126
- package/.claude/agents/marketing-video-optimization-specialist.md +0 -119
- package/.claude/agents/marketing-wechat-official-account.md +0 -145
- package/.claude/agents/marketing-weibo-strategist.md +0 -240
- package/.claude/agents/marketing-x-twitter-intelligence-analyst.md +0 -161
- package/.claude/agents/marketing-xiaohongshu-specialist.md +0 -138
- package/.claude/agents/marketing-zhihu-strategist.md +0 -162
- package/.claude/agents/medical-billing-coding-specialist.md +0 -491
- package/.claude/agents/narrative-designer.md +0 -243
- package/.claude/agents/operations-manager.md +0 -399
- package/.claude/agents/organizational-psychologist.md +0 -391
- package/.claude/agents/paid-media-auditor.md +0 -71
- package/.claude/agents/paid-media-creative-strategist.md +0 -71
- package/.claude/agents/paid-media-paid-social-strategist.md +0 -71
- package/.claude/agents/paid-media-ppc-strategist.md +0 -71
- package/.claude/agents/paid-media-programmatic-buyer.md +0 -71
- package/.claude/agents/paid-media-search-query-analyst.md +0 -71
- package/.claude/agents/paid-media-tracking-specialist.md +0 -71
- package/.claude/agents/personal-growth-mentor.md +0 -159
- package/.claude/agents/product-behavioral-nudge-engine.md +0 -83
- package/.claude/agents/product-dx-engineer.md +0 -332
- package/.claude/agents/product-feedback-synthesizer.md +0 -119
- package/.claude/agents/product-manager.md +0 -469
- package/.claude/agents/product-sprint-prioritizer.md +0 -154
- package/.claude/agents/product-trend-researcher.md +0 -159
- package/.claude/agents/project-management-experiment-tracker.md +0 -198
- package/.claude/agents/project-management-jira-workflow-steward.md +0 -233
- package/.claude/agents/project-management-meeting-notes-specialist.md +0 -95
- package/.claude/agents/project-management-project-shepherd.md +0 -194
- package/.claude/agents/project-management-studio-operations.md +0 -200
- package/.claude/agents/project-management-studio-producer.md +0 -203
- package/.claude/agents/project-manager-senior.md +0 -135
- package/.claude/agents/real-estate-buyer-seller.md +0 -596
- package/.claude/agents/recruitment-specialist.md +0 -515
- package/.claude/agents/report-distribution-agent.md +0 -65
- package/.claude/agents/research-synthesist.md +0 -136
- package/.claude/agents/resume-tailor.md +0 -230
- package/.claude/agents/retail-customer-returns.md +0 -566
- package/.claude/agents/roblox-avatar-creator.md +0 -297
- package/.claude/agents/roblox-experience-designer.md +0 -306
- package/.claude/agents/roblox-systems-scripter.md +0 -332
- package/.claude/agents/sales-account-strategist.md +0 -227
- package/.claude/agents/sales-coach.md +0 -271
- package/.claude/agents/sales-data-extraction-agent.md +0 -67
- package/.claude/agents/sales-deal-strategist.md +0 -180
- package/.claude/agents/sales-discovery-coach.md +0 -225
- package/.claude/agents/sales-engineer.md +0 -182
- package/.claude/agents/sales-offer-lead-gen-strategist.md +0 -257
- package/.claude/agents/sales-outbound-strategist.md +0 -201
- package/.claude/agents/sales-outreach.md +0 -425
- package/.claude/agents/sales-pipeline-analyst.md +0 -267
- package/.claude/agents/sales-proposal-strategist.md +0 -217
- package/.claude/agents/security-ai-generated-code-auditor.md +0 -207
- package/.claude/agents/security-appsec-engineer.md +0 -536
- package/.claude/agents/security-architect.md +0 -307
- package/.claude/agents/security-blockchain-security-auditor.md +0 -482
- package/.claude/agents/security-cloud-security-architect.md +0 -576
- package/.claude/agents/security-compliance-auditor.md +0 -158
- package/.claude/agents/security-incident-responder.md +0 -450
- package/.claude/agents/security-penetration-tester.md +0 -399
- package/.claude/agents/security-secrets-credential-engineer.md +0 -189
- package/.claude/agents/security-senior-secops.md +0 -760
- package/.claude/agents/security-threat-detection-engineer.md +0 -553
- package/.claude/agents/security-threat-intelligence-analyst.md +0 -661
- package/.claude/agents/specialized-chief-of-staff.md +0 -279
- package/.claude/agents/specialized-civil-engineer.md +0 -356
- package/.claude/agents/specialized-codebase-archaeologist.md +0 -341
- package/.claude/agents/specialized-cultural-intelligence-strategist.md +0 -88
- package/.claude/agents/specialized-developer-advocate.md +0 -317
- package/.claude/agents/specialized-document-generator.md +0 -55
- package/.claude/agents/specialized-fedramp-rmf-compliance.md +0 -378
- package/.claude/agents/specialized-focus-music-architect.md +0 -175
- package/.claude/agents/specialized-french-consulting-market.md +0 -194
- package/.claude/agents/specialized-korean-business-navigator.md +0 -216
- package/.claude/agents/specialized-master-plan-architect.md +0 -157
- package/.claude/agents/specialized-mcp-builder.md +0 -260
- package/.claude/agents/specialized-model-qa.md +0 -528
- package/.claude/agents/specialized-pricing-analyst.md +0 -243
- package/.claude/agents/specialized-salesforce-architect.md +0 -182
- package/.claude/agents/specialized-strategy-duel-agent.md +0 -130
- package/.claude/agents/specialized-workflow-architect.md +0 -597
- package/.claude/agents/study-abroad-advisor.md +0 -282
- package/.claude/agents/supply-chain-strategist.md +0 -591
- package/.claude/agents/support-analytics-reporter.md +0 -387
- package/.claude/agents/support-executive-summary-generator.md +0 -212
- package/.claude/agents/support-finance-tracker.md +0 -480
- package/.claude/agents/support-infrastructure-maintainer.md +0 -628
- package/.claude/agents/support-legal-compliance-checker.md +0 -591
- package/.claude/agents/support-support-responder.md +0 -607
- package/.claude/agents/technical-artist.md +0 -233
- package/.claude/agents/terminal-integration-specialist.md +0 -70
- package/.claude/agents/testing-accessibility-auditor.md +0 -327
- package/.claude/agents/testing-api-tester.md +0 -334
- package/.claude/agents/testing-evidence-collector.md +0 -210
- package/.claude/agents/testing-performance-benchmarker.md +0 -283
- package/.claude/agents/testing-reality-checker.md +0 -249
- package/.claude/agents/testing-test-automation-engineer.md +0 -196
- package/.claude/agents/testing-test-results-analyzer.md +0 -330
- package/.claude/agents/testing-tool-evaluator.md +0 -416
- package/.claude/agents/testing-workflow-optimizer.md +0 -463
- package/.claude/agents/unity-architect.md +0 -271
- package/.claude/agents/unity-editor-tool-developer.md +0 -310
- package/.claude/agents/unity-multiplayer-engineer.md +0 -323
- package/.claude/agents/unity-shader-graph-artist.md +0 -269
- package/.claude/agents/unreal-multiplayer-architect.md +0 -364
- package/.claude/agents/unreal-systems-engineer.md +0 -322
- package/.claude/agents/unreal-technical-artist.md +0 -256
- package/.claude/agents/unreal-world-builder.md +0 -273
- package/.claude/agents/visionos-spatial-engineer.md +0 -54
- package/.claude/agents/xr-cockpit-interaction-specialist.md +0 -32
- package/.claude/agents/xr-immersive-developer.md +0 -32
- package/.claude/agents/xr-interface-architect.md +0 -32
- package/.claude/agents/zk-steward.md +0 -211
- package/.claude-plugin/marketplace.json +0 -30
- package/.commitlintrc.json +0 -26
- package/.devcontainer/Dockerfile +0 -24
- package/.devcontainer/devcontainer.json +0 -70
- package/.devcontainer/docker-compose.memory.yml +0 -42
- package/.devcontainer/memory-stack/devcontainer.json +0 -84
- package/.devcontainer/post-create.sh +0 -83
- package/.dockerignore +0 -23
- package/.env.act.example +0 -15
- package/.env.example +0 -171
- package/.eslintrc.json +0 -16
- package/.git-blame-ignore-revs +0 -10
- package/.gitattributes +0 -2
- package/.gitguardian.yaml +0 -50
- package/.githooks/pre-commit +0 -6
- package/.pre-commit-config.yaml +0 -30
- package/.release-please-config-xithead.json +0 -22
- package/.release-please-config.json +0 -44
- package/.release-please-manifest-xithead.json +0 -3
- package/.release-please-manifest.json +0 -3
- package/CODE_OF_CONDUCT.md +0 -133
- package/CONTRIBUTING.md +0 -133
- package/Cargo.lock +0 -5557
- package/Cargo.toml +0 -121
- package/Dockerfile +0 -38
- package/Dockerfile.proxy +0 -48
- package/ENTERPRISE.md +0 -5
- package/FEATURES_ADVANCED.md +0 -311
- package/Headroom-2.gif +0 -0
- package/HeadroomDemo-Fast.gif +0 -0
- package/MANIFEST.in +0 -4
- package/MODERNIZATION_GUIDE.md +0 -358
- package/Makefile +0 -140
- package/NOTICE +0 -43
- package/NPM_TOKEN_SETUP.md +0 -81
- package/PR.md +0 -170
- package/PUBLISH.md +0 -77
- package/README_FRONTEND.md +0 -196
- package/REALIGNMENT/00-overview.md +0 -53
- package/REALIGNMENT/01-bug-list.md +0 -421
- package/REALIGNMENT/02-architecture.md +0 -322
- package/REALIGNMENT/03-phase-A-lockdown.md +0 -420
- package/REALIGNMENT/04-phase-B-live-zone.md +0 -470
- package/REALIGNMENT/05-phase-C-rust-proxy.md +0 -329
- package/REALIGNMENT/06-phase-D-bedrock-vertex.md +0 -222
- package/REALIGNMENT/07-phase-E-cache-stabilization.md +0 -338
- package/REALIGNMENT/08-phase-F-auth-mode.md +0 -254
- package/REALIGNMENT/09-phase-G-rtk-observability.md +0 -194
- package/REALIGNMENT/10-phase-H-python-retirement.md +0 -214
- package/REALIGNMENT/11-phase-I-test-infra.md +0 -385
- package/REALIGNMENT/12-decisions-needed.md +0 -196
- package/REALIGNMENT/INDEX.md +0 -82
- package/REFACTORING_CAMPAIGN.md +0 -277
- package/RESTRUCTURE_PLAN.md +0 -100
- package/RUST_DEV.md +0 -361
- package/SECURITY.md +0 -65
- package/SETUP_AUTO_PUBLISH.md +0 -164
- package/TESTING-copilot-subscription.md +0 -153
- package/codecov.yml +0 -34
- package/crates/headroom-core/Cargo.toml +0 -165
- package/crates/headroom-core/benches/auth_mode.rs +0 -74
- package/crates/headroom-core/benches/ccr_store.rs +0 -224
- package/crates/headroom-core/benches/tokenizer.rs +0 -52
- package/crates/headroom-core/config/pipeline.toml +0 -151
- package/crates/headroom-core/proptest-regressions/transforms/tag_protector.txt +0 -9
- package/crates/headroom-core/src/auth_mode.rs +0 -250
- package/crates/headroom-core/src/cache_control.rs +0 -414
- package/crates/headroom-core/src/ccr/backends/in_memory.rs +0 -317
- package/crates/headroom-core/src/ccr/backends/mod.rs +0 -152
- package/crates/headroom-core/src/ccr/backends/redis.rs +0 -146
- package/crates/headroom-core/src/ccr/backends/sqlite.rs +0 -205
- package/crates/headroom-core/src/ccr/mod.rs +0 -119
- package/crates/headroom-core/src/compression_policy.rs +0 -505
- package/crates/headroom-core/src/lib.rs +0 -33
- package/crates/headroom-core/src/relevance/base.rs +0 -139
- package/crates/headroom-core/src/relevance/bm25.rs +0 -385
- package/crates/headroom-core/src/relevance/embedding.rs +0 -354
- package/crates/headroom-core/src/relevance/hybrid.rs +0 -364
- package/crates/headroom-core/src/relevance/mod.rs +0 -64
- package/crates/headroom-core/src/signals/keyword_detector.rs +0 -433
- package/crates/headroom-core/src/signals/line_importance.rs +0 -84
- package/crates/headroom-core/src/signals/mod.rs +0 -61
- package/crates/headroom-core/src/signals/tiered.rs +0 -141
- package/crates/headroom-core/src/tokenizer/estimator.rs +0 -152
- package/crates/headroom-core/src/tokenizer/hf_impl.rs +0 -314
- package/crates/headroom-core/src/tokenizer/mod.rs +0 -56
- package/crates/headroom-core/src/tokenizer/registry.rs +0 -342
- package/crates/headroom-core/src/tokenizer/tiktoken_impl.rs +0 -265
- package/crates/headroom-core/src/transforms/adaptive_sizer.rs +0 -610
- package/crates/headroom-core/src/transforms/anchor_selector.rs +0 -1189
- package/crates/headroom-core/src/transforms/content_detector.rs +0 -769
- package/crates/headroom-core/src/transforms/detection.rs +0 -222
- package/crates/headroom-core/src/transforms/diff_compressor.rs +0 -1685
- package/crates/headroom-core/src/transforms/live_zone.rs +0 -2967
- package/crates/headroom-core/src/transforms/log_compressor.rs +0 -1295
- package/crates/headroom-core/src/transforms/magika_detector.rs +0 -395
- package/crates/headroom-core/src/transforms/mod.rs +0 -64
- package/crates/headroom-core/src/transforms/pipeline/config.rs +0 -331
- package/crates/headroom-core/src/transforms/pipeline/mod.rs +0 -103
- package/crates/headroom-core/src/transforms/pipeline/offloads/diff_noise.rs +0 -524
- package/crates/headroom-core/src/transforms/pipeline/offloads/diff_offload.rs +0 -279
- package/crates/headroom-core/src/transforms/pipeline/offloads/json_offload.rs +0 -400
- package/crates/headroom-core/src/transforms/pipeline/offloads/log_offload.rs +0 -284
- package/crates/headroom-core/src/transforms/pipeline/offloads/mod.rs +0 -34
- package/crates/headroom-core/src/transforms/pipeline/offloads/search_offload.rs +0 -331
- package/crates/headroom-core/src/transforms/pipeline/orchestrator.rs +0 -848
- package/crates/headroom-core/src/transforms/pipeline/reformats/json_minifier.rs +0 -175
- package/crates/headroom-core/src/transforms/pipeline/reformats/log_template.rs +0 -545
- package/crates/headroom-core/src/transforms/pipeline/reformats/mod.rs +0 -12
- package/crates/headroom-core/src/transforms/pipeline/traits.rs +0 -338
- package/crates/headroom-core/src/transforms/recommendations.rs +0 -329
- package/crates/headroom-core/src/transforms/safety.rs +0 -215
- package/crates/headroom-core/src/transforms/search_compressor.rs +0 -902
- package/crates/headroom-core/src/transforms/smart_crusher/analyzer.rs +0 -1262
- package/crates/headroom-core/src/transforms/smart_crusher/anchors.rs +0 -407
- package/crates/headroom-core/src/transforms/smart_crusher/builder.rs +0 -263
- package/crates/headroom-core/src/transforms/smart_crusher/classifier.rs +0 -214
- package/crates/headroom-core/src/transforms/smart_crusher/compaction/classifier.rs +0 -283
- package/crates/headroom-core/src/transforms/smart_crusher/compaction/compactor.rs +0 -733
- package/crates/headroom-core/src/transforms/smart_crusher/compaction/formatter.rs +0 -961
- package/crates/headroom-core/src/transforms/smart_crusher/compaction/ir.rs +0 -252
- package/crates/headroom-core/src/transforms/smart_crusher/compaction/mod.rs +0 -127
- package/crates/headroom-core/src/transforms/smart_crusher/compaction/walker.rs +0 -397
- package/crates/headroom-core/src/transforms/smart_crusher/config.rs +0 -173
- package/crates/headroom-core/src/transforms/smart_crusher/constraints.rs +0 -159
- package/crates/headroom-core/src/transforms/smart_crusher/crusher.rs +0 -1665
- package/crates/headroom-core/src/transforms/smart_crusher/crushers.rs +0 -865
- package/crates/headroom-core/src/transforms/smart_crusher/error_keywords.rs +0 -77
- package/crates/headroom-core/src/transforms/smart_crusher/field_detect.rs +0 -393
- package/crates/headroom-core/src/transforms/smart_crusher/hashing.rs +0 -72
- package/crates/headroom-core/src/transforms/smart_crusher/mod.rs +0 -81
- package/crates/headroom-core/src/transforms/smart_crusher/observer.rs +0 -66
- package/crates/headroom-core/src/transforms/smart_crusher/orchestration.rs +0 -459
- package/crates/headroom-core/src/transforms/smart_crusher/outliers.rs +0 -507
- package/crates/headroom-core/src/transforms/smart_crusher/planning.rs +0 -904
- package/crates/headroom-core/src/transforms/smart_crusher/statistics.rs +0 -510
- package/crates/headroom-core/src/transforms/smart_crusher/stats_math.rs +0 -287
- package/crates/headroom-core/src/transforms/smart_crusher/traits.rs +0 -203
- package/crates/headroom-core/src/transforms/smart_crusher/types.rs +0 -263
- package/crates/headroom-core/src/transforms/tag_protector.rs +0 -1272
- package/crates/headroom-core/src/transforms/unidiff_detector.rs +0 -232
- package/crates/headroom-parity/Cargo.toml +0 -26
- package/crates/headroom-parity/examples/diff_fixture.rs +0 -66
- package/crates/headroom-parity/src/bin/parity_run.rs +0 -78
- package/crates/headroom-parity/src/lib.rs +0 -613
- package/crates/headroom-proxy/Cargo.toml +0 -119
- package/crates/headroom-proxy/data/model_prices_and_context_window.json +0 -39767
- package/crates/headroom-proxy/src/bedrock/auth_mode_layer.rs +0 -192
- package/crates/headroom-proxy/src/bedrock/envelope.rs +0 -239
- package/crates/headroom-proxy/src/bedrock/eventstream.rs +0 -769
- package/crates/headroom-proxy/src/bedrock/eventstream_to_sse.rs +0 -459
- package/crates/headroom-proxy/src/bedrock/invoke.rs +0 -735
- package/crates/headroom-proxy/src/bedrock/invoke_streaming.rs +0 -1098
- package/crates/headroom-proxy/src/bedrock/mod.rs +0 -66
- package/crates/headroom-proxy/src/bedrock/sigv4.rs +0 -324
- package/crates/headroom-proxy/src/bedrock/vendor.rs +0 -82
- package/crates/headroom-proxy/src/cache_stabilization/anthropic_cache_control.rs +0 -698
- package/crates/headroom-proxy/src/cache_stabilization/drift_detector.rs +0 -683
- package/crates/headroom-proxy/src/cache_stabilization/mod.rs +0 -61
- package/crates/headroom-proxy/src/cache_stabilization/openai_cache_key.rs +0 -600
- package/crates/headroom-proxy/src/cache_stabilization/tool_def_normalize.rs +0 -514
- package/crates/headroom-proxy/src/cache_stabilization/volatile_detector.rs +0 -720
- package/crates/headroom-proxy/src/compression/anthropic.rs +0 -92
- package/crates/headroom-proxy/src/compression/live_zone_anthropic.rs +0 -1311
- package/crates/headroom-proxy/src/compression/live_zone_openai.rs +0 -660
- package/crates/headroom-proxy/src/compression/live_zone_responses.rs +0 -678
- package/crates/headroom-proxy/src/compression/mod.rs +0 -127
- package/crates/headroom-proxy/src/compression/model_limits.rs +0 -211
- package/crates/headroom-proxy/src/config.rs +0 -646
- package/crates/headroom-proxy/src/error.rs +0 -69
- package/crates/headroom-proxy/src/handlers/chat_completions.rs +0 -100
- package/crates/headroom-proxy/src/handlers/conversations.rs +0 -241
- package/crates/headroom-proxy/src/handlers/mod.rs +0 -13
- package/crates/headroom-proxy/src/handlers/responses.rs +0 -256
- package/crates/headroom-proxy/src/headers.rs +0 -288
- package/crates/headroom-proxy/src/health.rs +0 -41
- package/crates/headroom-proxy/src/lib.rs +0 -21
- package/crates/headroom-proxy/src/main.rs +0 -141
- package/crates/headroom-proxy/src/observability/cache_hit_rate.rs +0 -340
- package/crates/headroom-proxy/src/observability/compression_ratio.rs +0 -158
- package/crates/headroom-proxy/src/observability/metric_names.rs +0 -174
- package/crates/headroom-proxy/src/observability/mod.rs +0 -68
- package/crates/headroom-proxy/src/observability/prometheus.rs +0 -394
- package/crates/headroom-proxy/src/observability/proxy_metrics.rs +0 -368
- package/crates/headroom-proxy/src/proxy.rs +0 -1619
- package/crates/headroom-proxy/src/responses_items.rs +0 -565
- package/crates/headroom-proxy/src/sse/anthropic.rs +0 -415
- package/crates/headroom-proxy/src/sse/framing.rs +0 -366
- package/crates/headroom-proxy/src/sse/mod.rs +0 -40
- package/crates/headroom-proxy/src/sse/openai_chat.rs +0 -231
- package/crates/headroom-proxy/src/sse/openai_responses.rs +0 -458
- package/crates/headroom-proxy/src/vertex/adc.rs +0 -315
- package/crates/headroom-proxy/src/vertex/envelope.rs +0 -167
- package/crates/headroom-proxy/src/vertex/mod.rs +0 -277
- package/crates/headroom-proxy/src/vertex/raw_predict.rs +0 -490
- package/crates/headroom-proxy/src/vertex/stream_raw_predict.rs +0 -49
- package/crates/headroom-proxy/src/websocket.rs +0 -246
- package/crates/headroom-py/Cargo.toml +0 -37
- package/crates/headroom-py/build.rs +0 -77
- package/crates/headroom-py/glibc_compat.c +0 -170
- package/crates/headroom-py/src/lib.rs +0 -1655
- package/deny.toml +0 -32
- package/docker/differential-network-capture/Dockerfile.runner +0 -14
- package/docker/differential-network-capture/docker-compose.yml +0 -142
- package/docker/differential-network-capture/run-claude-lane.sh +0 -24
- package/docker/docker-compose.native.yml +0 -44
- package/docker-bake.hcl +0 -88
- package/docker-compose.yml +0 -80
- package/e2e/_lib/make_shim.ps1 +0 -24
- package/e2e/_lib/make_shim.sh +0 -28
- package/e2e/docker-native-install.sh +0 -120
- package/e2e/init/Dockerfile +0 -79
- package/e2e/wrap/Dockerfile +0 -115
- package/examples/07-context-compression.ipynb +0 -279
- package/examples/deployment/macos-launchagent/com.headroom.proxy.plist.template +0 -65
- package/examples/deployment/macos-launchagent/install.sh +0 -227
- package/examples/deployment/macos-launchagent/shell-integration.sh +0 -74
- package/examples/deployment/macos-launchagent/uninstall.sh +0 -145
- package/headroom-savings.png +0 -0
- package/headroom_learn.gif +0 -0
- package/llms.txt +0 -67
- package/mkdocs.yml +0 -136
- package/npm/bin/xithead.js +0 -366
- package/npm/bin/xtream-head.js +0 -366
- package/npm/index.d.ts +0 -57
- package/npm/index.js +0 -139
- package/npm/package.json +0 -55
- package/npm/postinstall.js +0 -43
- package/plugins/headroom-agent-hooks/.claude-plugin/plugin.json +0 -17
- package/plugins/headroom-agent-hooks/hooks/hooks.json +0 -29
- package/plugins/headroom-oauth2/LICENSE +0 -3
- package/plugins/headroom-oauth2/SPEC.md +0 -115
- package/plugins/headroom-oauth2/pyproject.toml +0 -48
- package/plugins/hermes/headroom_retrieve/plugin.yaml +0 -6
- package/plugins/openclaw/hook-shim/HOOK.md +0 -21
- package/plugins/openclaw/hook-shim/handler.js +0 -3
- package/plugins/openclaw/openclaw.plugin.json +0 -98
- package/plugins/openclaw/package-lock.json +0 -2692
- package/plugins/openclaw/package.json +0 -54
- package/plugins/openclaw/prepare-dist.mjs +0 -56
- package/plugins/openclaw/src/convert.ts +0 -418
- package/plugins/openclaw/src/engine.ts +0 -284
- package/plugins/openclaw/src/gateway-config.ts +0 -143
- package/plugins/openclaw/src/index.ts +0 -11
- package/plugins/openclaw/src/plugin/index.ts +0 -98
- package/plugins/openclaw/src/proxy-manager.ts +0 -477
- package/plugins/openclaw/src/tools/headroom-retrieve.ts +0 -76
- package/plugins/openclaw/test/convert.test.ts +0 -96
- package/plugins/openclaw/test/engine-normalization.test.ts +0 -21
- package/plugins/openclaw/test/engine.test.ts +0 -101
- package/plugins/openclaw/test/gateway-config.test.ts +0 -278
- package/plugins/openclaw/test/plugin-runtime-routing.test.ts +0 -141
- package/plugins/openclaw/test/proxy-manager.test.ts +0 -343
- package/plugins/openclaw/tsup.config.ts +0 -9
- package/pyproject.toml +0 -438
- package/rust-toolchain.toml +0 -16
- package/sdk/typescript/examples/basic-compress.ts +0 -64
- package/sdk/typescript/examples/ccr-retrieve.ts +0 -80
- package/sdk/typescript/examples/hooks-custom-compression.ts +0 -117
- package/sdk/typescript/examples/middleware-composition.ts +0 -59
- package/sdk/typescript/examples/multi-provider.ts +0 -53
- package/sdk/typescript/examples/openai-anthropic-adapters.ts +0 -73
- package/sdk/typescript/examples/shared-context-multi-agent.ts +0 -74
- package/sdk/typescript/examples/simulation-dry-run.ts +0 -80
- package/sdk/typescript/examples/streaming-chat.ts +0 -71
- package/sdk/typescript/examples/structured-output.ts +0 -99
- package/sdk/typescript/examples/tool-calling-agent.ts +0 -86
- package/sdk/typescript/examples/with-headroom-vercel.ts +0 -57
- package/sdk/typescript/package-lock.json +0 -3437
- package/sdk/typescript/package.json +0 -108
- package/sdk/typescript/src/adapters/anthropic.ts +0 -218
- package/sdk/typescript/src/adapters/gemini.ts +0 -83
- package/sdk/typescript/src/adapters/openai.ts +0 -77
- package/sdk/typescript/src/adapters/vercel-ai.ts +0 -131
- package/sdk/typescript/src/client.ts +0 -632
- package/sdk/typescript/src/compress.ts +0 -87
- package/sdk/typescript/src/errors.ts +0 -114
- package/sdk/typescript/src/hooks.ts +0 -113
- package/sdk/typescript/src/index.ts +0 -140
- package/sdk/typescript/src/paths.ts +0 -272
- package/sdk/typescript/src/shared-context.ts +0 -188
- package/sdk/typescript/src/simulate.ts +0 -52
- package/sdk/typescript/src/types/config.ts +0 -183
- package/sdk/typescript/src/types/models.ts +0 -314
- package/sdk/typescript/src/types.ts +0 -139
- package/sdk/typescript/src/utils/case.ts +0 -34
- package/sdk/typescript/src/utils/format.ts +0 -480
- package/sdk/typescript/src/utils/stream.ts +0 -50
- package/sdk/typescript/test/adapters/anthropic.test.ts +0 -217
- package/sdk/typescript/test/adapters/gemini.test.ts +0 -131
- package/sdk/typescript/test/adapters/openai.test.ts +0 -174
- package/sdk/typescript/test/adapters/vercel-ai.test.ts +0 -306
- package/sdk/typescript/test/client-expanded.test.ts +0 -333
- package/sdk/typescript/test/client.test.ts +0 -266
- package/sdk/typescript/test/compress.test.ts +0 -118
- package/sdk/typescript/test/config.test.ts +0 -275
- package/sdk/typescript/test/errors.test.ts +0 -169
- package/sdk/typescript/test/format-integration.test.ts +0 -252
- package/sdk/typescript/test/hooks.test.ts +0 -265
- package/sdk/typescript/test/integration.test.ts +0 -249
- package/sdk/typescript/test/mdx-examples.test.ts +0 -253
- package/sdk/typescript/test/models.test.ts +0 -318
- package/sdk/typescript/test/parity.test.ts +0 -337
- package/sdk/typescript/test/paths.test.ts +0 -447
- package/sdk/typescript/test/shared-context.test.ts +0 -245
- package/sdk/typescript/test/simulate.test.ts +0 -84
- package/sdk/typescript/test/types.test.ts +0 -244
- package/sdk/typescript/test/utils/case.test.ts +0 -129
- package/sdk/typescript/test/utils/detect-format.test.ts +0 -133
- package/sdk/typescript/test/utils/format.test.ts +0 -434
- package/sdk/typescript/test/vercel-ai-e2e.test.ts +0 -179
- package/sdk/typescript/tsup.config.ts +0 -17
- package/uv.lock +0 -6951
- package/xithead.egg-info/PKG-INFO +0 -22
- package/xithead.egg-info/SOURCES.txt +0 -16
- package/xithead.egg-info/dependency_links.txt +0 -1
- package/xithead.egg-info/entry_points.txt +0 -2
- package/xithead.egg-info/requires.txt +0 -10
- package/xithead.egg-info/top_level.txt +0 -2
- package/xithead.ps1 +0 -136
- package/xithead.sh +0 -129
- package/xithead_dist/pyproject.toml +0 -39
- package/xithead_dist/xithead.egg-info/PKG-INFO +0 -22
- package/xithead_dist/xithead.egg-info/SOURCES.txt +0 -16
- package/xithead_dist/xithead.egg-info/dependency_links.txt +0 -1
- package/xithead_dist/xithead.egg-info/entry_points.txt +0 -3
- package/xithead_dist/xithead.egg-info/requires.txt +0 -10
- package/xithead_dist/xithead.egg-info/top_level.txt +0 -2
|
@@ -0,0 +1,1673 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
IMAGE_DEFAULT="ghcr.io/chopratejas/headroom:latest"
|
|
6
|
+
INSTALL_IMAGE="${HEADROOM_DOCKER_IMAGE:-${IMAGE_DEFAULT}}"
|
|
7
|
+
INSTALL_DIR="${HOME}/.local/bin"
|
|
8
|
+
if [[ ! -d "${HOME}/.local" ]]; then
|
|
9
|
+
INSTALL_DIR="${HOME}/bin"
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
BASH_PATH="${BASH:-$(command -v bash)}"
|
|
13
|
+
if ((BASH_VERSINFO[0] < 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] < 3))); then
|
|
14
|
+
printf 'ERROR: Headroom Docker-native install requires bash >= 4.3\n' >&2
|
|
15
|
+
exit 1
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
info() {
|
|
19
|
+
printf '==> %s\n' "$*"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
warn() {
|
|
23
|
+
printf 'WARN: %s\n' "$*" >&2
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
die() {
|
|
27
|
+
printf 'ERROR: %s\n' "$*" >&2
|
|
28
|
+
exit 1
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
require_cmd() {
|
|
32
|
+
command -v "$1" >/dev/null 2>&1 || die "Missing required command: $1"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
append_path_block() {
|
|
36
|
+
local target_file="$1"
|
|
37
|
+
local marker_start="# >>> headroom docker-native >>>"
|
|
38
|
+
local marker_end="# <<< headroom docker-native <<<"
|
|
39
|
+
local block="${marker_start}
|
|
40
|
+
export PATH=\"${INSTALL_DIR}:\$PATH\"
|
|
41
|
+
${marker_end}"
|
|
42
|
+
|
|
43
|
+
touch "${target_file}"
|
|
44
|
+
if grep -Fq "${marker_start}" "${target_file}"; then
|
|
45
|
+
return
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
{
|
|
49
|
+
printf '\n%s\n' "${block}"
|
|
50
|
+
} >>"${target_file}"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
write_wrapper() {
|
|
54
|
+
local wrapper_path="${INSTALL_DIR}/headroom"
|
|
55
|
+
|
|
56
|
+
{
|
|
57
|
+
printf '#!%s\n\n' "${BASH_PATH}"
|
|
58
|
+
printf 'HEADROOM_IMAGE_DEFAULT=%q\n' "${INSTALL_IMAGE}"
|
|
59
|
+
cat <<'WRAPPER'
|
|
60
|
+
|
|
61
|
+
set -euo pipefail
|
|
62
|
+
|
|
63
|
+
HEADROOM_IMAGE="${HEADROOM_DOCKER_IMAGE:-${HEADROOM_IMAGE_DEFAULT}}"
|
|
64
|
+
HEADROOM_CONTAINER_HOME="${HEADROOM_CONTAINER_HOME:-/tmp/headroom-home}"
|
|
65
|
+
HEADROOM_HOST_HOME="${HOME:?}"
|
|
66
|
+
|
|
67
|
+
if ((BASH_VERSINFO[0] < 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] < 3))); then
|
|
68
|
+
printf 'ERROR: Headroom Docker-native wrapper requires bash >= 4.3\n' >&2
|
|
69
|
+
exit 1
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
warn() {
|
|
73
|
+
printf 'WARN: %s\n' "$*" >&2
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
die() {
|
|
77
|
+
printf 'ERROR: %s\n' "$*" >&2
|
|
78
|
+
exit 1
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
require_cmd() {
|
|
82
|
+
command -v "$1" >/dev/null 2>&1 || die "Missing required command: $1"
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
detect_rtk_target() {
|
|
86
|
+
local system
|
|
87
|
+
local machine
|
|
88
|
+
system="$(uname -s)"
|
|
89
|
+
machine="$(uname -m)"
|
|
90
|
+
|
|
91
|
+
case "${system}" in
|
|
92
|
+
Darwin)
|
|
93
|
+
if [[ "${machine}" == "arm64" ]]; then
|
|
94
|
+
printf 'aarch64-apple-darwin'
|
|
95
|
+
else
|
|
96
|
+
printf 'x86_64-apple-darwin'
|
|
97
|
+
fi
|
|
98
|
+
;;
|
|
99
|
+
Linux)
|
|
100
|
+
if [[ "${machine}" == "aarch64" ]]; then
|
|
101
|
+
printf 'aarch64-unknown-linux-gnu'
|
|
102
|
+
else
|
|
103
|
+
printf 'x86_64-unknown-linux-musl'
|
|
104
|
+
fi
|
|
105
|
+
;;
|
|
106
|
+
*)
|
|
107
|
+
die "Unsupported host platform for Docker-native wrapper: ${system}/${machine}"
|
|
108
|
+
;;
|
|
109
|
+
esac
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
ensure_host_dirs() {
|
|
113
|
+
mkdir -p \
|
|
114
|
+
"${HEADROOM_HOST_HOME}/.headroom" \
|
|
115
|
+
"${HEADROOM_HOST_HOME}/.claude" \
|
|
116
|
+
"${HEADROOM_HOST_HOME}/.codex" \
|
|
117
|
+
"${HEADROOM_HOST_HOME}/.gemini"
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
append_passthrough_envs() {
|
|
121
|
+
local -n ref=$1
|
|
122
|
+
local name
|
|
123
|
+
|
|
124
|
+
for name in $(compgen -e); do
|
|
125
|
+
case "${name}" in
|
|
126
|
+
HEADROOM_*|ANTHROPIC_*|OPENAI_*|GEMINI_*|AWS_*|AZURE_*|VERTEX_*|GOOGLE_*|GOOGLE_CLOUD_*|MISTRAL_*|GROQ_*|OPENROUTER_*|XAI_*|TOGETHER_*|COHERE_*|OLLAMA_*|LITELLM_*|OTEL_*|SUPABASE_*|QDRANT_*|NEO4J_*|LANGSMITH_*)
|
|
127
|
+
ref+=(--env "${name}")
|
|
128
|
+
;;
|
|
129
|
+
esac
|
|
130
|
+
done
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
append_common_container_args() {
|
|
134
|
+
local -n ref=$1
|
|
135
|
+
|
|
136
|
+
ensure_host_dirs
|
|
137
|
+
ref+=(-w /workspace)
|
|
138
|
+
ref+=(--env "HOME=${HEADROOM_CONTAINER_HOME}")
|
|
139
|
+
ref+=(--env "PYTHONUNBUFFERED=1")
|
|
140
|
+
# Canonical Headroom filesystem contract (issue #175) — forward into the
|
|
141
|
+
# container so the proxy resolves state/config to the bind-mounted path.
|
|
142
|
+
ref+=(--env "HEADROOM_WORKSPACE_DIR=${HEADROOM_CONTAINER_HOME}/.headroom")
|
|
143
|
+
ref+=(--env "HEADROOM_CONFIG_DIR=${HEADROOM_CONTAINER_HOME}/.headroom/config")
|
|
144
|
+
ref+=(-v "${PWD}:/workspace")
|
|
145
|
+
ref+=(-v "${HEADROOM_HOST_HOME}/.headroom:${HEADROOM_CONTAINER_HOME}/.headroom")
|
|
146
|
+
ref+=(-v "${HEADROOM_HOST_HOME}/.claude:${HEADROOM_CONTAINER_HOME}/.claude")
|
|
147
|
+
ref+=(-v "${HEADROOM_HOST_HOME}/.codex:${HEADROOM_CONTAINER_HOME}/.codex")
|
|
148
|
+
ref+=(-v "${HEADROOM_HOST_HOME}/.gemini:${HEADROOM_CONTAINER_HOME}/.gemini")
|
|
149
|
+
|
|
150
|
+
if command -v id >/dev/null 2>&1; then
|
|
151
|
+
ref+=(--user "$(id -u):$(id -g)")
|
|
152
|
+
fi
|
|
153
|
+
|
|
154
|
+
append_passthrough_envs "$1"
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
append_tty_args() {
|
|
158
|
+
local -n ref=$1
|
|
159
|
+
|
|
160
|
+
if [[ -t 0 && -t 1 ]]; then
|
|
161
|
+
ref+=(-it)
|
|
162
|
+
elif [[ -t 0 ]]; then
|
|
163
|
+
ref+=(-i)
|
|
164
|
+
elif [[ -t 1 ]]; then
|
|
165
|
+
ref+=(-t)
|
|
166
|
+
fi
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
run_headroom() {
|
|
170
|
+
local args=()
|
|
171
|
+
args=(docker run --rm)
|
|
172
|
+
append_tty_args args
|
|
173
|
+
append_common_container_args args
|
|
174
|
+
args+=(--entrypoint headroom "${HEADROOM_IMAGE}" "$@")
|
|
175
|
+
"${args[@]}"
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
docker_container_exists() {
|
|
179
|
+
local name="$1"
|
|
180
|
+
docker ps --format '{{.Names}}' | grep -Fxq "${name}"
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
wait_for_proxy() {
|
|
184
|
+
local container_name="$1"
|
|
185
|
+
local port="$2"
|
|
186
|
+
local attempt
|
|
187
|
+
|
|
188
|
+
for attempt in $(seq 1 45); do
|
|
189
|
+
if command -v curl >/dev/null 2>&1; then
|
|
190
|
+
if curl --fail --silent "http://127.0.0.1:${port}/readyz" >/dev/null; then
|
|
191
|
+
return 0
|
|
192
|
+
fi
|
|
193
|
+
elif (echo >/dev/tcp/127.0.0.1/"${port}") >/dev/null 2>&1; then
|
|
194
|
+
return 0
|
|
195
|
+
fi
|
|
196
|
+
|
|
197
|
+
if ! docker_container_exists "${container_name}"; then
|
|
198
|
+
break
|
|
199
|
+
fi
|
|
200
|
+
|
|
201
|
+
sleep 1
|
|
202
|
+
done
|
|
203
|
+
|
|
204
|
+
docker logs "${container_name}" >&2 || true
|
|
205
|
+
return 1
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
start_proxy_container() {
|
|
209
|
+
local port="$1"
|
|
210
|
+
shift
|
|
211
|
+
|
|
212
|
+
local container_name="headroom-proxy-${port}-$$"
|
|
213
|
+
local args=()
|
|
214
|
+
args=(docker run -d --rm --name "${container_name}" -p "${port}:${port}")
|
|
215
|
+
append_common_container_args args
|
|
216
|
+
args+=("${HEADROOM_IMAGE}" --host 0.0.0.0 --port "${port}" "$@")
|
|
217
|
+
"${args[@]}" >/dev/null
|
|
218
|
+
|
|
219
|
+
if ! wait_for_proxy "${container_name}" "${port}"; then
|
|
220
|
+
docker stop "${container_name}" >/dev/null 2>&1 || true
|
|
221
|
+
die "Xtream Head proxy failed to start on port ${port}"
|
|
222
|
+
fi
|
|
223
|
+
|
|
224
|
+
printf '%s\n' "${container_name}"
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
stop_proxy_container() {
|
|
228
|
+
local container_name="${1:-}"
|
|
229
|
+
if [[ -n "${container_name}" ]]; then
|
|
230
|
+
docker stop "${container_name}" >/dev/null 2>&1 || true
|
|
231
|
+
fi
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
persistent_profile_root() {
|
|
235
|
+
local profile="$1"
|
|
236
|
+
validate_profile_name "${profile}"
|
|
237
|
+
printf '%s/.headroom/deploy/%s\n' "${HEADROOM_HOST_HOME}" "${profile}"
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
persistent_state_path() {
|
|
241
|
+
local profile="$1"
|
|
242
|
+
printf '%s/docker-native.env\n' "$(persistent_profile_root "${profile}")"
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
persistent_manifest_path() {
|
|
246
|
+
local profile="$1"
|
|
247
|
+
printf '%s/manifest.json\n' "$(persistent_profile_root "${profile}")"
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
persistent_container_name() {
|
|
251
|
+
local profile="$1"
|
|
252
|
+
validate_profile_name "${profile}"
|
|
253
|
+
printf 'headroom-%s\n' "${profile}"
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
validate_profile_name() {
|
|
257
|
+
local profile="$1"
|
|
258
|
+
[[ "${profile}" =~ ^[A-Za-z0-9._-]+$ ]] || die "Invalid profile name '${profile}'"
|
|
259
|
+
[[ "${profile}" != "." && "${profile}" != ".." ]] || die "Invalid profile name '${profile}'"
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
validate_port() {
|
|
263
|
+
local port="$1"
|
|
264
|
+
[[ "${port}" =~ ^[0-9]+$ ]] || die "Invalid port '${port}'"
|
|
265
|
+
((10#${port} >= 1 && 10#${port} <= 65535)) || die "Invalid port '${port}'"
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
validate_positive_integer() {
|
|
269
|
+
local value="$1"
|
|
270
|
+
[[ "${value}" =~ ^[0-9]+$ ]] || die "Invalid value '${value}'"
|
|
271
|
+
((10#${value} >= 1)) || die "Invalid value '${value}'"
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
require_option_value() {
|
|
275
|
+
(($# >= 2)) || die "Option $1 requires a value"
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
json_escape() {
|
|
279
|
+
local value="$1"
|
|
280
|
+
value="${value//\\/\\\\}"
|
|
281
|
+
value="${value//\"/\\\"}"
|
|
282
|
+
value="${value//$'\n'/\\n}"
|
|
283
|
+
printf '%s' "${value}"
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
json_array_from_args() {
|
|
287
|
+
local first=1
|
|
288
|
+
local arg
|
|
289
|
+
printf '['
|
|
290
|
+
for arg in "$@"; do
|
|
291
|
+
if [[ "${first}" -eq 0 ]]; then
|
|
292
|
+
printf ','
|
|
293
|
+
fi
|
|
294
|
+
first=0
|
|
295
|
+
printf '"%s"' "$(json_escape "${arg}")"
|
|
296
|
+
done
|
|
297
|
+
printf ']'
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
append_persistent_container_args() {
|
|
301
|
+
local -n ref=$1
|
|
302
|
+
|
|
303
|
+
ensure_host_dirs
|
|
304
|
+
ref+=(--workdir "${HEADROOM_CONTAINER_HOME}")
|
|
305
|
+
ref+=(--env "HOME=${HEADROOM_CONTAINER_HOME}")
|
|
306
|
+
ref+=(--env "PYTHONUNBUFFERED=1")
|
|
307
|
+
# Canonical Headroom filesystem contract (issue #175).
|
|
308
|
+
ref+=(--env "HEADROOM_WORKSPACE_DIR=${HEADROOM_CONTAINER_HOME}/.headroom")
|
|
309
|
+
ref+=(--env "HEADROOM_CONFIG_DIR=${HEADROOM_CONTAINER_HOME}/.headroom/config")
|
|
310
|
+
ref+=(-v "${HEADROOM_HOST_HOME}/.headroom:${HEADROOM_CONTAINER_HOME}/.headroom")
|
|
311
|
+
ref+=(-v "${HEADROOM_HOST_HOME}/.claude:${HEADROOM_CONTAINER_HOME}/.claude")
|
|
312
|
+
ref+=(-v "${HEADROOM_HOST_HOME}/.codex:${HEADROOM_CONTAINER_HOME}/.codex")
|
|
313
|
+
ref+=(-v "${HEADROOM_HOST_HOME}/.gemini:${HEADROOM_CONTAINER_HOME}/.gemini")
|
|
314
|
+
|
|
315
|
+
if command -v id >/dev/null 2>&1; then
|
|
316
|
+
ref+=(--user "$(id -u):$(id -g)")
|
|
317
|
+
fi
|
|
318
|
+
|
|
319
|
+
append_passthrough_envs "$1"
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
build_manifest_proxy_args() {
|
|
323
|
+
local -n out_args=$1
|
|
324
|
+
local port="$2"
|
|
325
|
+
local proxy_mode="$3"
|
|
326
|
+
local backend="$4"
|
|
327
|
+
local anyllm="$5"
|
|
328
|
+
local region="$6"
|
|
329
|
+
local memory_enabled="$7"
|
|
330
|
+
local telemetry_enabled="$8"
|
|
331
|
+
|
|
332
|
+
out_args=(--host 127.0.0.1 --port "${port}" --mode "${proxy_mode}" --backend "${backend}")
|
|
333
|
+
if [[ "${telemetry_enabled}" -eq 0 ]]; then
|
|
334
|
+
out_args+=(--no-telemetry)
|
|
335
|
+
fi
|
|
336
|
+
if [[ "${memory_enabled}" -eq 1 ]]; then
|
|
337
|
+
out_args+=(--memory --memory-db-path "${HEADROOM_CONTAINER_HOME}/.headroom/memory.db")
|
|
338
|
+
fi
|
|
339
|
+
if [[ -n "${anyllm}" ]]; then
|
|
340
|
+
out_args+=(--anyllm-provider "${anyllm}")
|
|
341
|
+
fi
|
|
342
|
+
if [[ -n "${region}" ]]; then
|
|
343
|
+
out_args+=(--region "${region}")
|
|
344
|
+
fi
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
write_persistent_state() {
|
|
348
|
+
local profile="$1"
|
|
349
|
+
local image="$2"
|
|
350
|
+
local port="$3"
|
|
351
|
+
local backend="$4"
|
|
352
|
+
local anyllm="$5"
|
|
353
|
+
local region="$6"
|
|
354
|
+
local proxy_mode="$7"
|
|
355
|
+
local memory_enabled="$8"
|
|
356
|
+
local telemetry_enabled="$9"
|
|
357
|
+
|
|
358
|
+
local root
|
|
359
|
+
root="$(persistent_profile_root "${profile}")"
|
|
360
|
+
mkdir -p "${root}"
|
|
361
|
+
|
|
362
|
+
{
|
|
363
|
+
printf 'PROFILE=%s\n' "${profile}"
|
|
364
|
+
printf 'IMAGE=%s\n' "${image}"
|
|
365
|
+
printf 'PORT=%s\n' "${port}"
|
|
366
|
+
printf 'BACKEND=%s\n' "${backend}"
|
|
367
|
+
printf 'ANYLLM_PROVIDER=%s\n' "${anyllm}"
|
|
368
|
+
printf 'REGION=%s\n' "${region}"
|
|
369
|
+
printf 'PROXY_MODE=%s\n' "${proxy_mode}"
|
|
370
|
+
printf 'MEMORY_ENABLED=%s\n' "${memory_enabled}"
|
|
371
|
+
printf 'TELEMETRY_ENABLED=%s\n' "${telemetry_enabled}"
|
|
372
|
+
printf 'CONTAINER_NAME=%s\n' "$(persistent_container_name "${profile}")"
|
|
373
|
+
printf 'HEALTH_URL=%s\n' "http://127.0.0.1:${port}/readyz"
|
|
374
|
+
} >"$(persistent_state_path "${profile}")"
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
write_persistent_manifest() {
|
|
378
|
+
local profile="$1"
|
|
379
|
+
local image="$2"
|
|
380
|
+
local port="$3"
|
|
381
|
+
local backend="$4"
|
|
382
|
+
local anyllm="$5"
|
|
383
|
+
local region="$6"
|
|
384
|
+
local proxy_mode="$7"
|
|
385
|
+
local memory_enabled="$8"
|
|
386
|
+
local telemetry_enabled="$9"
|
|
387
|
+
local -n proxy_args_ref=${10}
|
|
388
|
+
|
|
389
|
+
local root
|
|
390
|
+
local manifest_path
|
|
391
|
+
local anyllm_json="null"
|
|
392
|
+
local region_json="null"
|
|
393
|
+
local memory_json="false"
|
|
394
|
+
local telemetry_json="true"
|
|
395
|
+
|
|
396
|
+
root="$(persistent_profile_root "${profile}")"
|
|
397
|
+
manifest_path="$(persistent_manifest_path "${profile}")"
|
|
398
|
+
mkdir -p "${root}"
|
|
399
|
+
|
|
400
|
+
if [[ -n "${anyllm}" ]]; then
|
|
401
|
+
anyllm_json="\"$(json_escape "${anyllm}")\""
|
|
402
|
+
fi
|
|
403
|
+
if [[ -n "${region}" ]]; then
|
|
404
|
+
region_json="\"$(json_escape "${region}")\""
|
|
405
|
+
fi
|
|
406
|
+
if [[ "${memory_enabled}" -eq 1 ]]; then
|
|
407
|
+
memory_json="true"
|
|
408
|
+
fi
|
|
409
|
+
if [[ "${telemetry_enabled}" -eq 0 ]]; then
|
|
410
|
+
telemetry_json="false"
|
|
411
|
+
fi
|
|
412
|
+
|
|
413
|
+
cat >"${manifest_path}" <<EOF
|
|
414
|
+
{
|
|
415
|
+
"profile": "$(json_escape "${profile}")",
|
|
416
|
+
"preset": "persistent-docker",
|
|
417
|
+
"runtime_kind": "docker",
|
|
418
|
+
"supervisor_kind": "none",
|
|
419
|
+
"scope": "user",
|
|
420
|
+
"provider_mode": "manual",
|
|
421
|
+
"targets": [],
|
|
422
|
+
"port": ${port},
|
|
423
|
+
"host": "127.0.0.1",
|
|
424
|
+
"backend": "$(json_escape "${backend}")",
|
|
425
|
+
"anyllm_provider": ${anyllm_json},
|
|
426
|
+
"region": ${region_json},
|
|
427
|
+
"proxy_mode": "$(json_escape "${proxy_mode}")",
|
|
428
|
+
"memory_enabled": ${memory_json},
|
|
429
|
+
"memory_db_path": "$(json_escape "${HEADROOM_CONTAINER_HOME}/.headroom/memory.db")",
|
|
430
|
+
"telemetry_enabled": ${telemetry_json},
|
|
431
|
+
"image": "$(json_escape "${image}")",
|
|
432
|
+
"service_name": "headroom-$(json_escape "${profile}")",
|
|
433
|
+
"container_name": "$(json_escape "$(persistent_container_name "${profile}")")",
|
|
434
|
+
"health_url": "http://127.0.0.1:${port}/readyz",
|
|
435
|
+
"base_env": {
|
|
436
|
+
"HEADROOM_PORT": "${port}",
|
|
437
|
+
"HEADROOM_HOST": "127.0.0.1",
|
|
438
|
+
"HEADROOM_MODE": "$(json_escape "${proxy_mode}")",
|
|
439
|
+
"HEADROOM_BACKEND": "$(json_escape "${backend}")"
|
|
440
|
+
},
|
|
441
|
+
"tool_envs": {},
|
|
442
|
+
"proxy_args": $(json_array_from_args "${proxy_args_ref[@]}"),
|
|
443
|
+
"mutations": [],
|
|
444
|
+
"artifacts": []
|
|
445
|
+
}
|
|
446
|
+
EOF
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
load_persistent_state() {
|
|
450
|
+
local profile="$1"
|
|
451
|
+
local state_path
|
|
452
|
+
validate_profile_name "${profile}"
|
|
453
|
+
state_path="$(persistent_state_path "${profile}")"
|
|
454
|
+
[[ -f "${state_path}" ]] || die "No docker-native persistent deployment profile named '${profile}'"
|
|
455
|
+
PROFILE=""
|
|
456
|
+
IMAGE=""
|
|
457
|
+
PORT=""
|
|
458
|
+
BACKEND=""
|
|
459
|
+
ANYLLM_PROVIDER=""
|
|
460
|
+
REGION=""
|
|
461
|
+
PROXY_MODE=""
|
|
462
|
+
MEMORY_ENABLED=""
|
|
463
|
+
TELEMETRY_ENABLED=""
|
|
464
|
+
CONTAINER_NAME=""
|
|
465
|
+
HEALTH_URL=""
|
|
466
|
+
while IFS='=' read -r key value; do
|
|
467
|
+
case "${key}" in
|
|
468
|
+
PROFILE|IMAGE|PORT|BACKEND|ANYLLM_PROVIDER|REGION|PROXY_MODE|MEMORY_ENABLED|TELEMETRY_ENABLED|CONTAINER_NAME|HEALTH_URL)
|
|
469
|
+
printf -v "${key}" '%s' "${value}"
|
|
470
|
+
;;
|
|
471
|
+
esac
|
|
472
|
+
done <"${state_path}"
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
start_persistent_docker_install() {
|
|
476
|
+
local profile="$1"
|
|
477
|
+
local image="$2"
|
|
478
|
+
local port="$3"
|
|
479
|
+
local backend="$4"
|
|
480
|
+
local anyllm="$5"
|
|
481
|
+
local region="$6"
|
|
482
|
+
local proxy_mode="$7"
|
|
483
|
+
local memory_enabled="$8"
|
|
484
|
+
local telemetry_enabled="$9"
|
|
485
|
+
|
|
486
|
+
local container_name
|
|
487
|
+
local proxy_args=()
|
|
488
|
+
local args=()
|
|
489
|
+
|
|
490
|
+
validate_profile_name "${profile}"
|
|
491
|
+
container_name="$(persistent_container_name "${profile}")"
|
|
492
|
+
build_manifest_proxy_args proxy_args "${port}" "${proxy_mode}" "${backend}" "${anyllm}" "${region}" "${memory_enabled}" "${telemetry_enabled}"
|
|
493
|
+
|
|
494
|
+
docker rm -f "${container_name}" >/dev/null 2>&1 || true
|
|
495
|
+
|
|
496
|
+
args=(docker run -d --restart unless-stopped --name "${container_name}" -p "${port}:${port}")
|
|
497
|
+
append_persistent_container_args args
|
|
498
|
+
args+=(
|
|
499
|
+
--env "HEADROOM_DEPLOYMENT_PROFILE=${profile}"
|
|
500
|
+
--env "HEADROOM_DEPLOYMENT_PRESET=persistent-docker"
|
|
501
|
+
--env "HEADROOM_DEPLOYMENT_RUNTIME=docker"
|
|
502
|
+
--env "HEADROOM_DEPLOYMENT_SUPERVISOR=none"
|
|
503
|
+
--env "HEADROOM_DEPLOYMENT_SCOPE=user"
|
|
504
|
+
)
|
|
505
|
+
args+=("${image}" --host 0.0.0.0 "${proxy_args[@]:2}")
|
|
506
|
+
"${args[@]}" >/dev/null
|
|
507
|
+
|
|
508
|
+
if ! wait_for_proxy "${container_name}" "${port}"; then
|
|
509
|
+
docker rm -f "${container_name}" >/dev/null 2>&1 || true
|
|
510
|
+
die "Headroom persistent Docker deployment failed to start on port ${port}"
|
|
511
|
+
fi
|
|
512
|
+
|
|
513
|
+
write_persistent_state "${profile}" "${image}" "${port}" "${backend}" "${anyllm}" "${region}" "${proxy_mode}" "${memory_enabled}" "${telemetry_enabled}"
|
|
514
|
+
write_persistent_manifest "${profile}" "${image}" "${port}" "${backend}" "${anyllm}" "${region}" "${proxy_mode}" "${memory_enabled}" "${telemetry_enabled}" proxy_args
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
stop_persistent_docker_install() {
|
|
518
|
+
local profile="$1"
|
|
519
|
+
local container_name
|
|
520
|
+
|
|
521
|
+
load_persistent_state "${profile}"
|
|
522
|
+
container_name="${CONTAINER_NAME}"
|
|
523
|
+
docker stop "${container_name}" >/dev/null 2>&1 || true
|
|
524
|
+
docker rm -f "${container_name}" >/dev/null 2>&1 || true
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
status_persistent_docker_install() {
|
|
528
|
+
local profile="$1"
|
|
529
|
+
local status="stopped"
|
|
530
|
+
local ready="no"
|
|
531
|
+
|
|
532
|
+
load_persistent_state "${profile}"
|
|
533
|
+
if docker_container_exists "${CONTAINER_NAME}"; then
|
|
534
|
+
status="running"
|
|
535
|
+
if command -v curl >/dev/null 2>&1; then
|
|
536
|
+
if curl --fail --silent "${HEALTH_URL}" >/dev/null; then
|
|
537
|
+
ready="yes"
|
|
538
|
+
fi
|
|
539
|
+
elif (echo >/dev/tcp/127.0.0.1/"${PORT}") >/dev/null 2>&1; then
|
|
540
|
+
ready="yes"
|
|
541
|
+
fi
|
|
542
|
+
fi
|
|
543
|
+
|
|
544
|
+
printf 'Profile: %s\n' "${PROFILE}"
|
|
545
|
+
printf 'Preset: persistent-docker\n'
|
|
546
|
+
printf 'Runtime: docker\n'
|
|
547
|
+
printf 'Supervisor: none\n'
|
|
548
|
+
printf 'Port: %s\n' "${PORT}"
|
|
549
|
+
printf 'Status: %s\n' "${status}"
|
|
550
|
+
printf 'Ready: %s\n' "${ready}"
|
|
551
|
+
printf 'Health URL: %s\n' "${HEALTH_URL}"
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
remove_persistent_docker_install() {
|
|
555
|
+
local profile="$1"
|
|
556
|
+
local root
|
|
557
|
+
|
|
558
|
+
load_persistent_state "${profile}"
|
|
559
|
+
docker stop "${CONTAINER_NAME}" >/dev/null 2>&1 || true
|
|
560
|
+
docker rm -f "${CONTAINER_NAME}" >/dev/null 2>&1 || true
|
|
561
|
+
root="$(persistent_profile_root "${profile}")"
|
|
562
|
+
rm -rf "${root}"
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
print_install_help() {
|
|
566
|
+
cat <<'EOF'
|
|
567
|
+
Usage: xtream-head install [OPTIONS] COMMAND [ARGS]...
|
|
568
|
+
|
|
569
|
+
Manage persistent Docker-native Headroom deployments.
|
|
570
|
+
|
|
571
|
+
The Docker-native wrapper currently supports the persistent-docker preset only.
|
|
572
|
+
Use the Python-native `xtream-head install` command for persistent-service and
|
|
573
|
+
persistent-task installs, or when you need provider/user/system config mutation.
|
|
574
|
+
|
|
575
|
+
Options:
|
|
576
|
+
-?, --help Show this message and exit.
|
|
577
|
+
|
|
578
|
+
Commands:
|
|
579
|
+
apply Install a persistent Docker deployment.
|
|
580
|
+
remove Remove a persistent Docker deployment.
|
|
581
|
+
restart Restart a persistent Docker deployment.
|
|
582
|
+
start Start a persistent Docker deployment.
|
|
583
|
+
status Show persistent Docker deployment status.
|
|
584
|
+
stop Stop a persistent Docker deployment.
|
|
585
|
+
EOF
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
print_install_apply_help() {
|
|
589
|
+
cat <<'EOF'
|
|
590
|
+
Usage: xtream-head install apply [OPTIONS]
|
|
591
|
+
|
|
592
|
+
Install a persistent Docker deployment.
|
|
593
|
+
|
|
594
|
+
Options:
|
|
595
|
+
--preset [persistent-docker] Docker-native wrapper supports persistent-docker only.
|
|
596
|
+
--runtime [docker] Docker-native wrapper supports runtime=docker only.
|
|
597
|
+
--profile TEXT Deployment profile name. [default: default]
|
|
598
|
+
-p, --port INTEGER Persistent proxy port. [default: 8787]
|
|
599
|
+
--backend TEXT Proxy backend. [default: anthropic]
|
|
600
|
+
--anyllm-provider TEXT Provider for any-llm backends.
|
|
601
|
+
--region TEXT Cloud region for Bedrock / Vertex style backends.
|
|
602
|
+
--mode TEXT Proxy optimization mode. [default: token]
|
|
603
|
+
--memory Enable persistent memory in the runtime.
|
|
604
|
+
--no-telemetry Disable anonymous telemetry in the runtime.
|
|
605
|
+
--image TEXT Docker image to use. [default: HEADROOM_DOCKER_IMAGE or ghcr.io/chopratejas/headroom:latest]
|
|
606
|
+
-?, --help Show this message and exit.
|
|
607
|
+
EOF
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
print_wrap_help() {
|
|
611
|
+
cat <<'EOF'
|
|
612
|
+
Usage: xtream-head wrap <COMMAND> [OPTIONS] [-- ARGS...]
|
|
613
|
+
|
|
614
|
+
Launch supported host tools through a Docker-native Xtream Head proxy.
|
|
615
|
+
|
|
616
|
+
Supported commands:
|
|
617
|
+
claude
|
|
618
|
+
codex
|
|
619
|
+
aider
|
|
620
|
+
cursor
|
|
621
|
+
openclaw
|
|
622
|
+
|
|
623
|
+
Notes:
|
|
624
|
+
- GitHub Copilot CLI wrapping is not supported by the Docker-native wrapper.
|
|
625
|
+
- Use the Python-native CLI for unsupported wrap targets.
|
|
626
|
+
EOF
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
parse_install_apply_args() {
|
|
630
|
+
local -n out_profile=$1
|
|
631
|
+
local -n out_port=$2
|
|
632
|
+
local -n out_backend=$3
|
|
633
|
+
local -n out_anyllm=$4
|
|
634
|
+
local -n out_region=$5
|
|
635
|
+
local -n out_mode=$6
|
|
636
|
+
local -n out_memory=$7
|
|
637
|
+
local -n out_telemetry=$8
|
|
638
|
+
local -n out_image=$9
|
|
639
|
+
shift 9
|
|
640
|
+
|
|
641
|
+
out_profile="default"
|
|
642
|
+
out_port=8787
|
|
643
|
+
out_backend="anthropic"
|
|
644
|
+
out_anyllm=""
|
|
645
|
+
out_region=""
|
|
646
|
+
out_mode="token"
|
|
647
|
+
out_memory=0
|
|
648
|
+
out_telemetry=1
|
|
649
|
+
out_image="${HEADROOM_IMAGE}"
|
|
650
|
+
|
|
651
|
+
while (($#)); do
|
|
652
|
+
case "$1" in
|
|
653
|
+
--preset)
|
|
654
|
+
require_option_value "$@"
|
|
655
|
+
[[ "$2" == "persistent-docker" ]] || die "Docker-native wrapper supports only --preset persistent-docker"
|
|
656
|
+
shift 2
|
|
657
|
+
;;
|
|
658
|
+
--preset=*)
|
|
659
|
+
[[ "${1#*=}" == "persistent-docker" ]] || die "Docker-native wrapper supports only --preset persistent-docker"
|
|
660
|
+
shift
|
|
661
|
+
;;
|
|
662
|
+
--runtime)
|
|
663
|
+
require_option_value "$@"
|
|
664
|
+
[[ "$2" == "docker" ]] || die "Docker-native wrapper supports only --runtime docker"
|
|
665
|
+
shift 2
|
|
666
|
+
;;
|
|
667
|
+
--runtime=*)
|
|
668
|
+
[[ "${1#*=}" == "docker" ]] || die "Docker-native wrapper supports only --runtime docker"
|
|
669
|
+
shift
|
|
670
|
+
;;
|
|
671
|
+
--scope|--providers|--target)
|
|
672
|
+
die "Docker-native wrapper install does not support provider/user/system mutation flags; use the Python-native CLI for those flows"
|
|
673
|
+
;;
|
|
674
|
+
--scope=*|--providers=*|--target=*)
|
|
675
|
+
die "Docker-native wrapper install does not support provider/user/system mutation flags; use the Python-native CLI for those flows"
|
|
676
|
+
;;
|
|
677
|
+
--profile)
|
|
678
|
+
require_option_value "$@"
|
|
679
|
+
out_profile="$2"
|
|
680
|
+
shift 2
|
|
681
|
+
;;
|
|
682
|
+
--profile=*)
|
|
683
|
+
out_profile="${1#*=}"
|
|
684
|
+
shift
|
|
685
|
+
;;
|
|
686
|
+
--port|-p)
|
|
687
|
+
require_option_value "$@"
|
|
688
|
+
out_port="$2"
|
|
689
|
+
shift 2
|
|
690
|
+
;;
|
|
691
|
+
--port=*|-p=*)
|
|
692
|
+
out_port="${1#*=}"
|
|
693
|
+
shift
|
|
694
|
+
;;
|
|
695
|
+
--backend)
|
|
696
|
+
require_option_value "$@"
|
|
697
|
+
out_backend="$2"
|
|
698
|
+
shift 2
|
|
699
|
+
;;
|
|
700
|
+
--backend=*)
|
|
701
|
+
out_backend="${1#*=}"
|
|
702
|
+
shift
|
|
703
|
+
;;
|
|
704
|
+
--anyllm-provider)
|
|
705
|
+
require_option_value "$@"
|
|
706
|
+
out_anyllm="$2"
|
|
707
|
+
shift 2
|
|
708
|
+
;;
|
|
709
|
+
--anyllm-provider=*)
|
|
710
|
+
out_anyllm="${1#*=}"
|
|
711
|
+
shift
|
|
712
|
+
;;
|
|
713
|
+
--region)
|
|
714
|
+
require_option_value "$@"
|
|
715
|
+
out_region="$2"
|
|
716
|
+
shift 2
|
|
717
|
+
;;
|
|
718
|
+
--region=*)
|
|
719
|
+
out_region="${1#*=}"
|
|
720
|
+
shift
|
|
721
|
+
;;
|
|
722
|
+
--mode)
|
|
723
|
+
require_option_value "$@"
|
|
724
|
+
out_mode="$2"
|
|
725
|
+
shift 2
|
|
726
|
+
;;
|
|
727
|
+
--mode=*)
|
|
728
|
+
out_mode="${1#*=}"
|
|
729
|
+
shift
|
|
730
|
+
;;
|
|
731
|
+
--memory)
|
|
732
|
+
out_memory=1
|
|
733
|
+
shift
|
|
734
|
+
;;
|
|
735
|
+
--no-telemetry)
|
|
736
|
+
out_telemetry=0
|
|
737
|
+
shift
|
|
738
|
+
;;
|
|
739
|
+
--image)
|
|
740
|
+
require_option_value "$@"
|
|
741
|
+
out_image="$2"
|
|
742
|
+
shift 2
|
|
743
|
+
;;
|
|
744
|
+
--image=*)
|
|
745
|
+
out_image="${1#*=}"
|
|
746
|
+
shift
|
|
747
|
+
;;
|
|
748
|
+
--help|-?)
|
|
749
|
+
print_install_apply_help
|
|
750
|
+
exit 0
|
|
751
|
+
;;
|
|
752
|
+
*)
|
|
753
|
+
die "Unsupported option for 'xtream-head install apply': $1"
|
|
754
|
+
;;
|
|
755
|
+
esac
|
|
756
|
+
done
|
|
757
|
+
|
|
758
|
+
validate_port "${out_port}"
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
parse_install_profile_arg() {
|
|
762
|
+
local -n out_profile=$1
|
|
763
|
+
shift
|
|
764
|
+
|
|
765
|
+
out_profile="default"
|
|
766
|
+
while (($#)); do
|
|
767
|
+
case "$1" in
|
|
768
|
+
--profile)
|
|
769
|
+
require_option_value "$@"
|
|
770
|
+
out_profile="$2"
|
|
771
|
+
shift 2
|
|
772
|
+
;;
|
|
773
|
+
--profile=*)
|
|
774
|
+
out_profile="${1#*=}"
|
|
775
|
+
shift
|
|
776
|
+
;;
|
|
777
|
+
--help|-?)
|
|
778
|
+
print_install_help
|
|
779
|
+
exit 0
|
|
780
|
+
;;
|
|
781
|
+
*)
|
|
782
|
+
die "Unsupported option for 'xtream-head install': $1"
|
|
783
|
+
;;
|
|
784
|
+
esac
|
|
785
|
+
done
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
run_claude_rtk_init() {
|
|
789
|
+
local rtk_bin="${HEADROOM_HOST_HOME}/.headroom/bin/rtk"
|
|
790
|
+
if [[ ! -x "${rtk_bin}" ]]; then
|
|
791
|
+
warn "rtk was not installed at ${rtk_bin}; Claude hooks were not registered"
|
|
792
|
+
return
|
|
793
|
+
fi
|
|
794
|
+
|
|
795
|
+
if ! "${rtk_bin}" init --global --auto-patch >/dev/null 2>&1; then
|
|
796
|
+
warn "Failed to register Claude hooks with rtk; continuing without hook registration"
|
|
797
|
+
fi
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
selected_context_tool() {
|
|
801
|
+
local value="${HEADROOM_CONTEXT_TOOL:-rtk}"
|
|
802
|
+
value="${value,,}"
|
|
803
|
+
value="${value//_/-}"
|
|
804
|
+
if [[ -z "${value}" ]]; then
|
|
805
|
+
value="rtk"
|
|
806
|
+
elif [[ "${value}" == "leanctx" ]]; then
|
|
807
|
+
value="lean-ctx"
|
|
808
|
+
fi
|
|
809
|
+
|
|
810
|
+
case "${value}" in
|
|
811
|
+
rtk|lean-ctx)
|
|
812
|
+
printf '%s\n' "${value}"
|
|
813
|
+
;;
|
|
814
|
+
*)
|
|
815
|
+
die "HEADROOM_CONTEXT_TOOL must be one of: lean-ctx, rtk"
|
|
816
|
+
;;
|
|
817
|
+
esac
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
run_lean_ctx_init() {
|
|
821
|
+
local agent="$1"
|
|
822
|
+
if ! command -v lean-ctx >/dev/null 2>&1; then
|
|
823
|
+
warn "lean-ctx is not installed on PATH; ${agent} lean-ctx setup was skipped"
|
|
824
|
+
return
|
|
825
|
+
fi
|
|
826
|
+
|
|
827
|
+
if ! lean-ctx init --agent "${agent}" >/dev/null 2>&1; then
|
|
828
|
+
warn "Failed to initialize lean-ctx for ${agent}; continuing without lean-ctx setup"
|
|
829
|
+
fi
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
parse_wrap_args() {
|
|
833
|
+
local -n out_known=$1
|
|
834
|
+
local -n out_host=$2
|
|
835
|
+
local -n out_port=$3
|
|
836
|
+
local -n out_no_rtk=$4
|
|
837
|
+
local -n out_no_proxy=$5
|
|
838
|
+
local -n out_learn=$6
|
|
839
|
+
local -n out_backend=$7
|
|
840
|
+
local -n out_anyllm=$8
|
|
841
|
+
local -n out_region=$9
|
|
842
|
+
shift 9
|
|
843
|
+
|
|
844
|
+
out_known=()
|
|
845
|
+
out_host=()
|
|
846
|
+
out_port=8787
|
|
847
|
+
out_no_rtk=0
|
|
848
|
+
out_no_proxy=0
|
|
849
|
+
out_learn=0
|
|
850
|
+
out_backend=""
|
|
851
|
+
out_anyllm=""
|
|
852
|
+
out_region=""
|
|
853
|
+
|
|
854
|
+
while (($#)); do
|
|
855
|
+
case "$1" in
|
|
856
|
+
--)
|
|
857
|
+
shift
|
|
858
|
+
out_host+=("$@")
|
|
859
|
+
break
|
|
860
|
+
;;
|
|
861
|
+
--port|-p)
|
|
862
|
+
require_option_value "$@"
|
|
863
|
+
out_port="$2"
|
|
864
|
+
validate_port "${out_port}"
|
|
865
|
+
out_known+=("$1" "$2")
|
|
866
|
+
shift 2
|
|
867
|
+
;;
|
|
868
|
+
--port=*)
|
|
869
|
+
out_port="${1#*=}"
|
|
870
|
+
validate_port "${out_port}"
|
|
871
|
+
out_known+=("$1")
|
|
872
|
+
shift
|
|
873
|
+
;;
|
|
874
|
+
--no-rtk)
|
|
875
|
+
out_no_rtk=1
|
|
876
|
+
out_known+=("$1")
|
|
877
|
+
shift
|
|
878
|
+
;;
|
|
879
|
+
--no-proxy)
|
|
880
|
+
out_no_proxy=1
|
|
881
|
+
out_known+=("$1")
|
|
882
|
+
shift
|
|
883
|
+
;;
|
|
884
|
+
--learn)
|
|
885
|
+
out_learn=1
|
|
886
|
+
out_known+=("$1")
|
|
887
|
+
shift
|
|
888
|
+
;;
|
|
889
|
+
--verbose|-v)
|
|
890
|
+
out_known+=("$1")
|
|
891
|
+
shift
|
|
892
|
+
;;
|
|
893
|
+
--backend)
|
|
894
|
+
require_option_value "$@"
|
|
895
|
+
out_backend="$2"
|
|
896
|
+
out_known+=("$1" "$2")
|
|
897
|
+
shift 2
|
|
898
|
+
;;
|
|
899
|
+
--backend=*)
|
|
900
|
+
out_backend="${1#*=}"
|
|
901
|
+
out_known+=("$1")
|
|
902
|
+
shift
|
|
903
|
+
;;
|
|
904
|
+
--anyllm-provider)
|
|
905
|
+
require_option_value "$@"
|
|
906
|
+
out_anyllm="$2"
|
|
907
|
+
out_known+=("$1" "$2")
|
|
908
|
+
shift 2
|
|
909
|
+
;;
|
|
910
|
+
--anyllm-provider=*)
|
|
911
|
+
out_anyllm="${1#*=}"
|
|
912
|
+
out_known+=("$1")
|
|
913
|
+
shift
|
|
914
|
+
;;
|
|
915
|
+
--region)
|
|
916
|
+
require_option_value "$@"
|
|
917
|
+
out_region="$2"
|
|
918
|
+
out_known+=("$1" "$2")
|
|
919
|
+
shift 2
|
|
920
|
+
;;
|
|
921
|
+
--region=*)
|
|
922
|
+
out_region="${1#*=}"
|
|
923
|
+
out_known+=("$1")
|
|
924
|
+
shift
|
|
925
|
+
;;
|
|
926
|
+
*)
|
|
927
|
+
out_host+=("$@")
|
|
928
|
+
break
|
|
929
|
+
;;
|
|
930
|
+
esac
|
|
931
|
+
done
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
run_prepare_only() {
|
|
935
|
+
local tool="$1"
|
|
936
|
+
shift
|
|
937
|
+
|
|
938
|
+
local args=()
|
|
939
|
+
args=(docker run --rm)
|
|
940
|
+
append_tty_args args
|
|
941
|
+
append_common_container_args args
|
|
942
|
+
args+=(--env "HEADROOM_RTK_TARGET=$(detect_rtk_target)")
|
|
943
|
+
args+=(--entrypoint headroom "${HEADROOM_IMAGE}" wrap "${tool}" --prepare-only "$@")
|
|
944
|
+
"${args[@]}"
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
run_host_tool() {
|
|
948
|
+
local binary="$1"
|
|
949
|
+
shift
|
|
950
|
+
|
|
951
|
+
command -v "${binary}" >/dev/null 2>&1 || die "'${binary}' not found in PATH"
|
|
952
|
+
"${binary}" "$@"
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
contains_help_flag() {
|
|
956
|
+
local arg
|
|
957
|
+
for arg in "$@"; do
|
|
958
|
+
if [[ "${arg}" == "--" ]]; then
|
|
959
|
+
break
|
|
960
|
+
fi
|
|
961
|
+
if [[ "${arg}" == "--help" || "${arg}" == "-?" ]]; then
|
|
962
|
+
return 0
|
|
963
|
+
fi
|
|
964
|
+
done
|
|
965
|
+
|
|
966
|
+
return 1
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
parse_openclaw_wrap_args() {
|
|
970
|
+
local -n out_plugin_path=$1
|
|
971
|
+
local -n out_plugin_spec=$2
|
|
972
|
+
local -n out_skip_build=$3
|
|
973
|
+
local -n out_copy=$4
|
|
974
|
+
local -n out_proxy_port=$5
|
|
975
|
+
local -n out_startup_timeout_ms=$6
|
|
976
|
+
local -n out_gateway_provider_ids=$7
|
|
977
|
+
local -n out_python_path=$8
|
|
978
|
+
local -n out_no_auto_start=$9
|
|
979
|
+
local -n out_no_restart=${10}
|
|
980
|
+
local -n out_verbose=${11}
|
|
981
|
+
shift 11
|
|
982
|
+
|
|
983
|
+
out_plugin_path=""
|
|
984
|
+
out_plugin_spec="xtream-head/openclaw"
|
|
985
|
+
out_skip_build=0
|
|
986
|
+
out_copy=0
|
|
987
|
+
out_proxy_port=8787
|
|
988
|
+
out_startup_timeout_ms=20000
|
|
989
|
+
out_gateway_provider_ids=()
|
|
990
|
+
out_python_path=""
|
|
991
|
+
out_no_auto_start=0
|
|
992
|
+
out_no_restart=0
|
|
993
|
+
out_verbose=0
|
|
994
|
+
|
|
995
|
+
while (($#)); do
|
|
996
|
+
case "$1" in
|
|
997
|
+
--plugin-path)
|
|
998
|
+
require_option_value "$@"
|
|
999
|
+
out_plugin_path="$2"
|
|
1000
|
+
shift 2
|
|
1001
|
+
;;
|
|
1002
|
+
--plugin-path=*)
|
|
1003
|
+
out_plugin_path="${1#*=}"
|
|
1004
|
+
shift
|
|
1005
|
+
;;
|
|
1006
|
+
--plugin-spec)
|
|
1007
|
+
require_option_value "$@"
|
|
1008
|
+
out_plugin_spec="$2"
|
|
1009
|
+
shift 2
|
|
1010
|
+
;;
|
|
1011
|
+
--plugin-spec=*)
|
|
1012
|
+
out_plugin_spec="${1#*=}"
|
|
1013
|
+
shift
|
|
1014
|
+
;;
|
|
1015
|
+
--skip-build)
|
|
1016
|
+
out_skip_build=1
|
|
1017
|
+
shift
|
|
1018
|
+
;;
|
|
1019
|
+
--copy)
|
|
1020
|
+
out_copy=1
|
|
1021
|
+
shift
|
|
1022
|
+
;;
|
|
1023
|
+
--proxy-port)
|
|
1024
|
+
require_option_value "$@"
|
|
1025
|
+
out_proxy_port="$2"
|
|
1026
|
+
validate_port "${out_proxy_port}"
|
|
1027
|
+
shift 2
|
|
1028
|
+
;;
|
|
1029
|
+
--proxy-port=*)
|
|
1030
|
+
out_proxy_port="${1#*=}"
|
|
1031
|
+
validate_port "${out_proxy_port}"
|
|
1032
|
+
shift
|
|
1033
|
+
;;
|
|
1034
|
+
--startup-timeout-ms)
|
|
1035
|
+
require_option_value "$@"
|
|
1036
|
+
out_startup_timeout_ms="$2"
|
|
1037
|
+
validate_positive_integer "${out_startup_timeout_ms}"
|
|
1038
|
+
shift 2
|
|
1039
|
+
;;
|
|
1040
|
+
--startup-timeout-ms=*)
|
|
1041
|
+
out_startup_timeout_ms="${1#*=}"
|
|
1042
|
+
validate_positive_integer "${out_startup_timeout_ms}"
|
|
1043
|
+
shift
|
|
1044
|
+
;;
|
|
1045
|
+
--gateway-provider-id)
|
|
1046
|
+
require_option_value "$@"
|
|
1047
|
+
out_gateway_provider_ids+=("$2")
|
|
1048
|
+
shift 2
|
|
1049
|
+
;;
|
|
1050
|
+
--gateway-provider-id=*)
|
|
1051
|
+
out_gateway_provider_ids+=("${1#*=}")
|
|
1052
|
+
shift
|
|
1053
|
+
;;
|
|
1054
|
+
--python-path)
|
|
1055
|
+
require_option_value "$@"
|
|
1056
|
+
out_python_path="$2"
|
|
1057
|
+
shift 2
|
|
1058
|
+
;;
|
|
1059
|
+
--python-path=*)
|
|
1060
|
+
out_python_path="${1#*=}"
|
|
1061
|
+
shift
|
|
1062
|
+
;;
|
|
1063
|
+
--no-auto-start)
|
|
1064
|
+
out_no_auto_start=1
|
|
1065
|
+
shift
|
|
1066
|
+
;;
|
|
1067
|
+
--no-restart)
|
|
1068
|
+
out_no_restart=1
|
|
1069
|
+
shift
|
|
1070
|
+
;;
|
|
1071
|
+
--verbose|-v)
|
|
1072
|
+
out_verbose=1
|
|
1073
|
+
shift
|
|
1074
|
+
;;
|
|
1075
|
+
*)
|
|
1076
|
+
die "Unsupported option for 'xtream-head wrap openclaw': $1"
|
|
1077
|
+
;;
|
|
1078
|
+
esac
|
|
1079
|
+
done
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
parse_openclaw_unwrap_args() {
|
|
1083
|
+
local -n out_no_restart=$1
|
|
1084
|
+
local -n out_verbose=$2
|
|
1085
|
+
shift 2
|
|
1086
|
+
|
|
1087
|
+
out_no_restart=0
|
|
1088
|
+
out_verbose=0
|
|
1089
|
+
|
|
1090
|
+
while (($#)); do
|
|
1091
|
+
case "$1" in
|
|
1092
|
+
--no-restart)
|
|
1093
|
+
out_no_restart=1
|
|
1094
|
+
shift
|
|
1095
|
+
;;
|
|
1096
|
+
--verbose|-v)
|
|
1097
|
+
out_verbose=1
|
|
1098
|
+
shift
|
|
1099
|
+
;;
|
|
1100
|
+
*)
|
|
1101
|
+
die "Unsupported option for 'xtream-head unwrap openclaw': $1"
|
|
1102
|
+
;;
|
|
1103
|
+
esac
|
|
1104
|
+
done
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
get_openclaw_existing_entry_json() {
|
|
1108
|
+
local output=""
|
|
1109
|
+
if output="$(openclaw config get plugins.entries.headroom 2>/dev/null)"; then
|
|
1110
|
+
printf '%s' "${output}"
|
|
1111
|
+
fi
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
prepare_openclaw_entry_json() {
|
|
1115
|
+
local existing_entry_json="$1"
|
|
1116
|
+
local proxy_port="$2"
|
|
1117
|
+
local startup_timeout_ms="$3"
|
|
1118
|
+
local python_path="$4"
|
|
1119
|
+
local no_auto_start="$5"
|
|
1120
|
+
shift 5
|
|
1121
|
+
local gateway_provider_ids=("$@")
|
|
1122
|
+
local args=()
|
|
1123
|
+
args=(docker run --rm)
|
|
1124
|
+
append_common_container_args args
|
|
1125
|
+
args+=(--entrypoint headroom "${HEADROOM_IMAGE}" wrap openclaw --prepare-only)
|
|
1126
|
+
args+=(--proxy-port "${proxy_port}" --startup-timeout-ms "${startup_timeout_ms}")
|
|
1127
|
+
|
|
1128
|
+
if [[ -n "${existing_entry_json}" ]]; then
|
|
1129
|
+
args+=(--existing-entry-json "${existing_entry_json}")
|
|
1130
|
+
fi
|
|
1131
|
+
if [[ -n "${python_path}" ]]; then
|
|
1132
|
+
args+=(--python-path "${python_path}")
|
|
1133
|
+
fi
|
|
1134
|
+
if [[ "${no_auto_start}" -eq 1 ]]; then
|
|
1135
|
+
args+=(--no-auto-start)
|
|
1136
|
+
fi
|
|
1137
|
+
|
|
1138
|
+
local provider_id
|
|
1139
|
+
for provider_id in "${gateway_provider_ids[@]}"; do
|
|
1140
|
+
args+=(--gateway-provider-id "${provider_id}")
|
|
1141
|
+
done
|
|
1142
|
+
|
|
1143
|
+
"${args[@]}"
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
prepare_openclaw_unwrap_entry_json() {
|
|
1147
|
+
local existing_entry_json="$1"
|
|
1148
|
+
local args=()
|
|
1149
|
+
args=(docker run --rm)
|
|
1150
|
+
append_common_container_args args
|
|
1151
|
+
args+=(--entrypoint headroom "${HEADROOM_IMAGE}" unwrap openclaw --prepare-only)
|
|
1152
|
+
if [[ -n "${existing_entry_json}" ]]; then
|
|
1153
|
+
args+=(--existing-entry-json "${existing_entry_json}")
|
|
1154
|
+
fi
|
|
1155
|
+
"${args[@]}"
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
run_openclaw_checked() {
|
|
1159
|
+
local action="$1"
|
|
1160
|
+
shift
|
|
1161
|
+
local output=""
|
|
1162
|
+
|
|
1163
|
+
if ! output="$("$@" 2>&1)"; then
|
|
1164
|
+
output="${output//$'\r'/}"
|
|
1165
|
+
die "${action} failed: ${output:-unknown error}"
|
|
1166
|
+
fi
|
|
1167
|
+
|
|
1168
|
+
printf '%s' "${output//$'\r'/}"
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
run_openclaw_checked_in_dir() {
|
|
1172
|
+
local action="$1"
|
|
1173
|
+
local cwd="$2"
|
|
1174
|
+
shift 2
|
|
1175
|
+
local output=""
|
|
1176
|
+
|
|
1177
|
+
if ! output="$(cd "${cwd}" && "$@" 2>&1)"; then
|
|
1178
|
+
output="${output//$'\r'/}"
|
|
1179
|
+
die "${action} failed: ${output:-unknown error}"
|
|
1180
|
+
fi
|
|
1181
|
+
|
|
1182
|
+
printf '%s' "${output//$'\r'/}"
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
resolve_openclaw_extensions_dir() {
|
|
1186
|
+
local config_output
|
|
1187
|
+
config_output="$(run_openclaw_checked "openclaw config file" openclaw config file)"
|
|
1188
|
+
local config_path
|
|
1189
|
+
config_path="$(printf '%s\n' "${config_output}" | tail -n 1)"
|
|
1190
|
+
[[ -n "${config_path}" ]] || die "Unable to resolve OpenClaw config path."
|
|
1191
|
+
printf '%s\n' "$(dirname "${config_path}")/extensions"
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
copy_openclaw_plugin_into_extensions() {
|
|
1195
|
+
local plugin_dir="$1"
|
|
1196
|
+
local dist_dir="${plugin_dir}/dist"
|
|
1197
|
+
local hook_shim_dir="${plugin_dir}/hook-shim"
|
|
1198
|
+
[[ -d "${dist_dir}" ]] || die "Plugin dist folder missing at ${dist_dir}. Build the plugin first."
|
|
1199
|
+
[[ -d "${hook_shim_dir}" ]] || die "Plugin hook-shim folder missing at ${hook_shim_dir}. Build the plugin first."
|
|
1200
|
+
|
|
1201
|
+
local extensions_dir
|
|
1202
|
+
extensions_dir="$(resolve_openclaw_extensions_dir)"
|
|
1203
|
+
local target_dir="${extensions_dir}/headroom"
|
|
1204
|
+
mkdir -p "${target_dir}"
|
|
1205
|
+
rm -rf "${target_dir}/dist" "${target_dir}/hook-shim"
|
|
1206
|
+
cp -R "${dist_dir}" "${target_dir}/dist"
|
|
1207
|
+
cp -R "${hook_shim_dir}" "${target_dir}/hook-shim"
|
|
1208
|
+
|
|
1209
|
+
local filename
|
|
1210
|
+
for filename in openclaw.plugin.json package.json README.md; do
|
|
1211
|
+
if [[ -f "${plugin_dir}/${filename}" ]]; then
|
|
1212
|
+
cp "${plugin_dir}/${filename}" "${target_dir}/${filename}"
|
|
1213
|
+
fi
|
|
1214
|
+
done
|
|
1215
|
+
|
|
1216
|
+
printf '%s\n' "${target_dir}"
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
install_openclaw_plugin() {
|
|
1220
|
+
local plugin_path="$1"
|
|
1221
|
+
local plugin_spec="$2"
|
|
1222
|
+
local skip_build="$3"
|
|
1223
|
+
local copy_mode="$4"
|
|
1224
|
+
local verbose="$5"
|
|
1225
|
+
|
|
1226
|
+
local local_source_mode=0
|
|
1227
|
+
if [[ -n "${plugin_path}" ]]; then
|
|
1228
|
+
local_source_mode=1
|
|
1229
|
+
[[ -d "${plugin_path}" ]] || die "Plugin path not found: ${plugin_path}."
|
|
1230
|
+
[[ -f "${plugin_path}/package.json" ]] || die "Invalid plugin path (missing package.json): ${plugin_path}"
|
|
1231
|
+
[[ -f "${plugin_path}/openclaw.plugin.json" ]] || die "Invalid plugin path (missing openclaw.plugin.json): ${plugin_path}"
|
|
1232
|
+
fi
|
|
1233
|
+
|
|
1234
|
+
if [[ "${local_source_mode}" -eq 1 && "${skip_build}" -eq 0 ]]; then
|
|
1235
|
+
require_cmd npm
|
|
1236
|
+
info "Building OpenClaw plugin (npm install + npm run build)..."
|
|
1237
|
+
run_openclaw_checked_in_dir "npm install" "${plugin_path}" npm install >/dev/null
|
|
1238
|
+
run_openclaw_checked_in_dir "npm run build" "${plugin_path}" npm run build >/dev/null
|
|
1239
|
+
fi
|
|
1240
|
+
|
|
1241
|
+
local install_output=""
|
|
1242
|
+
local install_status=0
|
|
1243
|
+
set +e
|
|
1244
|
+
if [[ "${local_source_mode}" -eq 1 ]]; then
|
|
1245
|
+
if [[ "${copy_mode}" -eq 1 ]]; then
|
|
1246
|
+
install_output="$(openclaw plugins install --dangerously-force-unsafe-install "${plugin_path}" 2>&1)"
|
|
1247
|
+
install_status=$?
|
|
1248
|
+
else
|
|
1249
|
+
install_output="$(cd "${plugin_path}" && openclaw plugins install --dangerously-force-unsafe-install --link . 2>&1)"
|
|
1250
|
+
install_status=$?
|
|
1251
|
+
fi
|
|
1252
|
+
else
|
|
1253
|
+
install_output="$(openclaw plugins install --dangerously-force-unsafe-install "${plugin_spec}" 2>&1)"
|
|
1254
|
+
install_status=$?
|
|
1255
|
+
fi
|
|
1256
|
+
set -e
|
|
1257
|
+
install_output="${install_output//$'\r'/}"
|
|
1258
|
+
|
|
1259
|
+
if [[ "${install_status}" -eq 0 ]]; then
|
|
1260
|
+
if [[ "${verbose}" -eq 1 && -n "${install_output}" ]]; then
|
|
1261
|
+
printf '%s\n' "${install_output}"
|
|
1262
|
+
fi
|
|
1263
|
+
return
|
|
1264
|
+
fi
|
|
1265
|
+
|
|
1266
|
+
local lower_output="${install_output,,}"
|
|
1267
|
+
if [[ "${lower_output}" == *"plugin already exists"* ]]; then
|
|
1268
|
+
info "Plugin already installed; continuing with configuration/update steps."
|
|
1269
|
+
return
|
|
1270
|
+
fi
|
|
1271
|
+
|
|
1272
|
+
if [[ "${lower_output}" == *"also not a valid hook pack"* && "${local_source_mode}" -eq 1 && "${copy_mode}" -eq 0 ]]; then
|
|
1273
|
+
info "OpenClaw linked-path install bug detected; applying extension-path fallback..."
|
|
1274
|
+
local target_dir
|
|
1275
|
+
target_dir="$(copy_openclaw_plugin_into_extensions "${plugin_path}")"
|
|
1276
|
+
info "Fallback plugin copy completed: ${target_dir}"
|
|
1277
|
+
return
|
|
1278
|
+
fi
|
|
1279
|
+
|
|
1280
|
+
die "openclaw plugins install failed: ${install_output:-exit code ${install_status}}"
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
restart_or_start_openclaw_gateway() {
|
|
1284
|
+
local output=""
|
|
1285
|
+
if output="$(openclaw gateway restart 2>&1)"; then
|
|
1286
|
+
OPENCLAW_GATEWAY_ACTION="restarted"
|
|
1287
|
+
OPENCLAW_GATEWAY_OUTPUT="${output//$'\r'/}"
|
|
1288
|
+
return
|
|
1289
|
+
fi
|
|
1290
|
+
|
|
1291
|
+
OPENCLAW_GATEWAY_OUTPUT="$(run_openclaw_checked "openclaw gateway start" openclaw gateway start)"
|
|
1292
|
+
OPENCLAW_GATEWAY_ACTION="started"
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
wrap_openclaw_host() {
|
|
1296
|
+
local plugin_path plugin_spec skip_build copy_mode proxy_port startup_timeout_ms python_path
|
|
1297
|
+
local no_auto_start no_restart verbose
|
|
1298
|
+
local gateway_provider_ids=()
|
|
1299
|
+
|
|
1300
|
+
parse_openclaw_wrap_args \
|
|
1301
|
+
plugin_path \
|
|
1302
|
+
plugin_spec \
|
|
1303
|
+
skip_build \
|
|
1304
|
+
copy_mode \
|
|
1305
|
+
proxy_port \
|
|
1306
|
+
startup_timeout_ms \
|
|
1307
|
+
gateway_provider_ids \
|
|
1308
|
+
python_path \
|
|
1309
|
+
no_auto_start \
|
|
1310
|
+
no_restart \
|
|
1311
|
+
verbose \
|
|
1312
|
+
"$@"
|
|
1313
|
+
|
|
1314
|
+
require_cmd openclaw
|
|
1315
|
+
local existing_entry_json=""
|
|
1316
|
+
existing_entry_json="$(get_openclaw_existing_entry_json)"
|
|
1317
|
+
local entry_json
|
|
1318
|
+
entry_json="$(prepare_openclaw_entry_json "${existing_entry_json}" "${proxy_port}" "${startup_timeout_ms}" "${python_path}" "${no_auto_start}" "${gateway_provider_ids[@]}")"
|
|
1319
|
+
|
|
1320
|
+
printf '\n ╔═══════════════════════════════════════════════╗\n'
|
|
1321
|
+
printf ' ║ HEADROOM WRAP: OPENCLAW ║\n'
|
|
1322
|
+
printf ' ╚═══════════════════════════════════════════════╝\n\n'
|
|
1323
|
+
if [[ -n "${plugin_path}" ]]; then
|
|
1324
|
+
printf ' Plugin source: local (%s)\n' "${plugin_path}"
|
|
1325
|
+
else
|
|
1326
|
+
printf ' Plugin source: npm (%s)\n' "${plugin_spec}"
|
|
1327
|
+
fi
|
|
1328
|
+
|
|
1329
|
+
printf ' Writing plugin configuration...\n'
|
|
1330
|
+
run_openclaw_checked \
|
|
1331
|
+
"openclaw config set plugins.entries.headroom" \
|
|
1332
|
+
openclaw config set plugins.entries.headroom "${entry_json}" --strict-json >/dev/null
|
|
1333
|
+
|
|
1334
|
+
printf ' Installing OpenClaw plugin with required unsafe-install flag...\n'
|
|
1335
|
+
install_openclaw_plugin "${plugin_path}" "${plugin_spec}" "${skip_build}" "${copy_mode}" "${verbose}"
|
|
1336
|
+
|
|
1337
|
+
run_openclaw_checked \
|
|
1338
|
+
"openclaw config set plugins.slots.contextEngine" \
|
|
1339
|
+
openclaw config set plugins.slots.contextEngine '"headroom"' --strict-json >/dev/null
|
|
1340
|
+
run_openclaw_checked "openclaw config validate" openclaw config validate >/dev/null
|
|
1341
|
+
|
|
1342
|
+
if [[ "${no_restart}" -eq 1 ]]; then
|
|
1343
|
+
printf ' Skipping gateway restart (--no-restart).\n'
|
|
1344
|
+
printf ' Run `openclaw gateway restart` (or `openclaw gateway start`) to apply plugin changes.\n'
|
|
1345
|
+
else
|
|
1346
|
+
printf ' Applying plugin changes to OpenClaw gateway...\n'
|
|
1347
|
+
restart_or_start_openclaw_gateway
|
|
1348
|
+
printf ' Gateway %s.\n' "${OPENCLAW_GATEWAY_ACTION}"
|
|
1349
|
+
if [[ "${verbose}" -eq 1 && -n "${OPENCLAW_GATEWAY_OUTPUT}" ]]; then
|
|
1350
|
+
printf '%s\n' "${OPENCLAW_GATEWAY_OUTPUT}"
|
|
1351
|
+
fi
|
|
1352
|
+
fi
|
|
1353
|
+
|
|
1354
|
+
local inspect_output=""
|
|
1355
|
+
inspect_output="$(run_openclaw_checked "openclaw plugins inspect headroom" openclaw plugins inspect headroom)"
|
|
1356
|
+
if [[ "${verbose}" -eq 1 && -n "${inspect_output}" ]]; then
|
|
1357
|
+
printf '%s\n' "${inspect_output}"
|
|
1358
|
+
fi
|
|
1359
|
+
|
|
1360
|
+
printf '\n✓ OpenClaw is configured to use Xtream Head context compression.\n'
|
|
1361
|
+
printf ' Plugin: headroom\n'
|
|
1362
|
+
printf ' Slot: plugins.slots.contextEngine = headroom\n\n'
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
unwrap_openclaw_host() {
|
|
1366
|
+
local no_restart verbose
|
|
1367
|
+
parse_openclaw_unwrap_args no_restart verbose "$@"
|
|
1368
|
+
|
|
1369
|
+
require_cmd openclaw
|
|
1370
|
+
local existing_entry_json=""
|
|
1371
|
+
existing_entry_json="$(get_openclaw_existing_entry_json)"
|
|
1372
|
+
local entry_json
|
|
1373
|
+
entry_json="$(prepare_openclaw_unwrap_entry_json "${existing_entry_json}")"
|
|
1374
|
+
|
|
1375
|
+
printf '\n ╔═══════════════════════════════════════════════╗\n'
|
|
1376
|
+
printf ' ║ HEADROOM UNWRAP: OPENCLAW ║\n'
|
|
1377
|
+
printf ' ╚═══════════════════════════════════════════════╝\n\n'
|
|
1378
|
+
printf ' Disabling Headroom plugin and removing engine mapping...\n'
|
|
1379
|
+
|
|
1380
|
+
run_openclaw_checked \
|
|
1381
|
+
"openclaw config set plugins.entries.headroom" \
|
|
1382
|
+
openclaw config set plugins.entries.headroom "${entry_json}" --strict-json >/dev/null
|
|
1383
|
+
run_openclaw_checked \
|
|
1384
|
+
"openclaw config set plugins.slots.contextEngine" \
|
|
1385
|
+
openclaw config set plugins.slots.contextEngine '"legacy"' --strict-json >/dev/null
|
|
1386
|
+
run_openclaw_checked "openclaw config validate" openclaw config validate >/dev/null
|
|
1387
|
+
|
|
1388
|
+
if [[ "${no_restart}" -eq 1 ]]; then
|
|
1389
|
+
printf ' Skipping gateway restart (--no-restart).\n'
|
|
1390
|
+
printf ' Run `openclaw gateway restart` (or `openclaw gateway start`) to apply unwrap changes.\n'
|
|
1391
|
+
else
|
|
1392
|
+
printf ' Applying unwrap changes to OpenClaw gateway...\n'
|
|
1393
|
+
restart_or_start_openclaw_gateway
|
|
1394
|
+
printf ' Gateway %s.\n' "${OPENCLAW_GATEWAY_ACTION}"
|
|
1395
|
+
if [[ "${verbose}" -eq 1 && -n "${OPENCLAW_GATEWAY_OUTPUT}" ]]; then
|
|
1396
|
+
printf '%s\n' "${OPENCLAW_GATEWAY_OUTPUT}"
|
|
1397
|
+
fi
|
|
1398
|
+
fi
|
|
1399
|
+
|
|
1400
|
+
if [[ "${verbose}" -eq 1 ]]; then
|
|
1401
|
+
local inspect_output=""
|
|
1402
|
+
inspect_output="$(run_openclaw_checked "openclaw plugins inspect headroom" openclaw plugins inspect headroom)"
|
|
1403
|
+
if [[ -n "${inspect_output}" ]]; then
|
|
1404
|
+
printf '%s\n' "${inspect_output}"
|
|
1405
|
+
fi
|
|
1406
|
+
fi
|
|
1407
|
+
|
|
1408
|
+
printf '\n✓ OpenClaw Headroom wrap removed.\n'
|
|
1409
|
+
printf ' Plugin: headroom (installed, disabled)\n'
|
|
1410
|
+
printf ' Slot: plugins.slots.contextEngine = legacy\n\n'
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
main() {
|
|
1414
|
+
require_cmd docker
|
|
1415
|
+
|
|
1416
|
+
if (($# == 0)); then
|
|
1417
|
+
run_headroom --help
|
|
1418
|
+
return
|
|
1419
|
+
fi
|
|
1420
|
+
|
|
1421
|
+
case "$1" in
|
|
1422
|
+
install)
|
|
1423
|
+
if (($# == 1)) || [[ "$2" == "--help" || "$2" == "-?" ]]; then
|
|
1424
|
+
print_install_help
|
|
1425
|
+
return
|
|
1426
|
+
fi
|
|
1427
|
+
|
|
1428
|
+
local install_command="$2"
|
|
1429
|
+
shift 2
|
|
1430
|
+
case "${install_command}" in
|
|
1431
|
+
apply)
|
|
1432
|
+
local profile port backend anyllm region proxy_mode memory_enabled telemetry_enabled image
|
|
1433
|
+
parse_install_apply_args profile port backend anyllm region proxy_mode memory_enabled telemetry_enabled image "$@"
|
|
1434
|
+
start_persistent_docker_install "${profile}" "${image}" "${port}" "${backend}" "${anyllm}" "${region}" "${proxy_mode}" "${memory_enabled}" "${telemetry_enabled}"
|
|
1435
|
+
printf "Installed docker-native persistent deployment '%s' on port %s.\n" "${profile}" "${port}"
|
|
1436
|
+
;;
|
|
1437
|
+
status)
|
|
1438
|
+
local profile
|
|
1439
|
+
parse_install_profile_arg profile "$@"
|
|
1440
|
+
status_persistent_docker_install "${profile}"
|
|
1441
|
+
;;
|
|
1442
|
+
start)
|
|
1443
|
+
local profile
|
|
1444
|
+
parse_install_profile_arg profile "$@"
|
|
1445
|
+
load_persistent_state "${profile}"
|
|
1446
|
+
start_persistent_docker_install "${PROFILE}" "${IMAGE}" "${PORT}" "${BACKEND}" "${ANYLLM_PROVIDER}" "${REGION}" "${PROXY_MODE}" "${MEMORY_ENABLED}" "${TELEMETRY_ENABLED}"
|
|
1447
|
+
printf "Started docker-native persistent deployment '%s'.\n" "${profile}"
|
|
1448
|
+
;;
|
|
1449
|
+
stop)
|
|
1450
|
+
local profile
|
|
1451
|
+
parse_install_profile_arg profile "$@"
|
|
1452
|
+
stop_persistent_docker_install "${profile}"
|
|
1453
|
+
printf "Stopped docker-native persistent deployment '%s'.\n" "${profile}"
|
|
1454
|
+
;;
|
|
1455
|
+
restart)
|
|
1456
|
+
local profile
|
|
1457
|
+
parse_install_profile_arg profile "$@"
|
|
1458
|
+
load_persistent_state "${profile}"
|
|
1459
|
+
start_persistent_docker_install "${PROFILE}" "${IMAGE}" "${PORT}" "${BACKEND}" "${ANYLLM_PROVIDER}" "${REGION}" "${PROXY_MODE}" "${MEMORY_ENABLED}" "${TELEMETRY_ENABLED}"
|
|
1460
|
+
printf "Restarted docker-native persistent deployment '%s'.\n" "${profile}"
|
|
1461
|
+
;;
|
|
1462
|
+
remove)
|
|
1463
|
+
local profile
|
|
1464
|
+
parse_install_profile_arg profile "$@"
|
|
1465
|
+
remove_persistent_docker_install "${profile}"
|
|
1466
|
+
printf "Removed docker-native persistent deployment '%s'.\n" "${profile}"
|
|
1467
|
+
;;
|
|
1468
|
+
*)
|
|
1469
|
+
die "Unsupported install target: ${install_command}"
|
|
1470
|
+
;;
|
|
1471
|
+
esac
|
|
1472
|
+
;;
|
|
1473
|
+
wrap)
|
|
1474
|
+
if (($# == 1)) || [[ "$2" == "--help" || "$2" == "-?" ]]; then
|
|
1475
|
+
print_wrap_help
|
|
1476
|
+
return
|
|
1477
|
+
fi
|
|
1478
|
+
|
|
1479
|
+
(($# >= 2)) || die "Usage: xtream-head wrap <claude|codex|aider|cursor|openclaw> [...]"
|
|
1480
|
+
local tool="$2"
|
|
1481
|
+
shift 2
|
|
1482
|
+
|
|
1483
|
+
case "${tool}" in
|
|
1484
|
+
claude|codex|aider|cursor|openclaw)
|
|
1485
|
+
;;
|
|
1486
|
+
*)
|
|
1487
|
+
die "Docker-native wrapper does not support 'wrap ${tool}'. Supported targets: claude, codex, aider, cursor, openclaw"
|
|
1488
|
+
;;
|
|
1489
|
+
esac
|
|
1490
|
+
|
|
1491
|
+
if [[ "${tool}" == "openclaw" ]]; then
|
|
1492
|
+
if contains_help_flag "$@"; then
|
|
1493
|
+
run_xtream-head wrap openclaw "$@"
|
|
1494
|
+
return
|
|
1495
|
+
fi
|
|
1496
|
+
wrap_openclaw_host "$@"
|
|
1497
|
+
return
|
|
1498
|
+
fi
|
|
1499
|
+
|
|
1500
|
+
if contains_help_flag "$@"; then
|
|
1501
|
+
run_xtream-head wrap "${tool}" "$@"
|
|
1502
|
+
return
|
|
1503
|
+
fi
|
|
1504
|
+
|
|
1505
|
+
local known_args host_args port no_rtk no_proxy learn backend anyllm region context_tool
|
|
1506
|
+
parse_wrap_args known_args host_args port no_rtk no_proxy learn backend anyllm region "$@"
|
|
1507
|
+
context_tool="$(selected_context_tool)"
|
|
1508
|
+
|
|
1509
|
+
local proxy_args=()
|
|
1510
|
+
if [[ "${learn}" -eq 1 ]]; then
|
|
1511
|
+
proxy_args+=(--learn)
|
|
1512
|
+
fi
|
|
1513
|
+
if [[ -n "${backend}" ]]; then
|
|
1514
|
+
proxy_args+=(--backend "${backend}")
|
|
1515
|
+
fi
|
|
1516
|
+
if [[ -n "${anyllm}" ]]; then
|
|
1517
|
+
proxy_args+=(--anyllm-provider "${anyllm}")
|
|
1518
|
+
fi
|
|
1519
|
+
if [[ -n "${region}" ]]; then
|
|
1520
|
+
proxy_args+=(--region "${region}")
|
|
1521
|
+
fi
|
|
1522
|
+
|
|
1523
|
+
local container_name=""
|
|
1524
|
+
if [[ "${no_proxy}" -eq 0 ]]; then
|
|
1525
|
+
container_name="$(start_proxy_container "${port}" "${proxy_args[@]}")"
|
|
1526
|
+
fi
|
|
1527
|
+
trap 'stop_proxy_container "${container_name}"' EXIT INT TERM
|
|
1528
|
+
|
|
1529
|
+
local prep_args=("${known_args[@]}")
|
|
1530
|
+
if [[ "${no_proxy}" -eq 0 ]]; then
|
|
1531
|
+
prep_args+=(--no-proxy)
|
|
1532
|
+
fi
|
|
1533
|
+
if [[ "${no_rtk}" -eq 0 && "${context_tool}" == "lean-ctx" ]]; then
|
|
1534
|
+
prep_args+=(--no-rtk)
|
|
1535
|
+
fi
|
|
1536
|
+
run_prepare_only "${tool}" "${prep_args[@]}"
|
|
1537
|
+
|
|
1538
|
+
if [[ "${no_rtk}" -eq 0 && "${context_tool}" == "lean-ctx" ]]; then
|
|
1539
|
+
run_lean_ctx_init "${tool}"
|
|
1540
|
+
fi
|
|
1541
|
+
|
|
1542
|
+
case "${tool}" in
|
|
1543
|
+
claude)
|
|
1544
|
+
if [[ "${no_rtk}" -eq 0 && "${context_tool}" == "rtk" ]]; then
|
|
1545
|
+
run_claude_rtk_init
|
|
1546
|
+
fi
|
|
1547
|
+
ANTHROPIC_BASE_URL="http://127.0.0.1:${port}" run_host_tool claude "${host_args[@]}"
|
|
1548
|
+
;;
|
|
1549
|
+
codex)
|
|
1550
|
+
OPENAI_BASE_URL="http://127.0.0.1:${port}/v1" run_host_tool codex "${host_args[@]}"
|
|
1551
|
+
;;
|
|
1552
|
+
aider)
|
|
1553
|
+
OPENAI_API_BASE="http://127.0.0.1:${port}/v1" \
|
|
1554
|
+
ANTHROPIC_BASE_URL="http://127.0.0.1:${port}" \
|
|
1555
|
+
run_host_tool aider "${host_args[@]}"
|
|
1556
|
+
;;
|
|
1557
|
+
cursor)
|
|
1558
|
+
cat <<EOF
|
|
1559
|
+
Xtream Head proxy is running for Cursor.
|
|
1560
|
+
|
|
1561
|
+
OpenAI base URL: http://127.0.0.1:${port}/v1
|
|
1562
|
+
Anthropic base URL: http://127.0.0.1:${port}
|
|
1563
|
+
|
|
1564
|
+
Press Ctrl+C to stop the proxy.
|
|
1565
|
+
EOF
|
|
1566
|
+
while true; do
|
|
1567
|
+
sleep 1
|
|
1568
|
+
done
|
|
1569
|
+
;;
|
|
1570
|
+
esac
|
|
1571
|
+
;;
|
|
1572
|
+
unwrap)
|
|
1573
|
+
if (($# == 1)) || [[ "$2" == "--help" || "$2" == "-?" ]]; then
|
|
1574
|
+
run_xtream-head unwrap --help
|
|
1575
|
+
return
|
|
1576
|
+
fi
|
|
1577
|
+
|
|
1578
|
+
if (($# >= 2)) && [[ "$2" == "openclaw" ]]; then
|
|
1579
|
+
shift 2
|
|
1580
|
+
if contains_help_flag "$@"; then
|
|
1581
|
+
run_xtream-head unwrap openclaw "$@"
|
|
1582
|
+
return
|
|
1583
|
+
fi
|
|
1584
|
+
unwrap_openclaw_host "$@"
|
|
1585
|
+
return
|
|
1586
|
+
fi
|
|
1587
|
+
run_headroom "$@"
|
|
1588
|
+
;;
|
|
1589
|
+
proxy)
|
|
1590
|
+
shift
|
|
1591
|
+
local port=8787
|
|
1592
|
+
local args=()
|
|
1593
|
+
args=(proxy)
|
|
1594
|
+
while (($#)); do
|
|
1595
|
+
case "$1" in
|
|
1596
|
+
--port|-p)
|
|
1597
|
+
require_option_value "$@"
|
|
1598
|
+
port="$2"
|
|
1599
|
+
validate_port "${port}"
|
|
1600
|
+
args+=("$1" "$2")
|
|
1601
|
+
shift 2
|
|
1602
|
+
;;
|
|
1603
|
+
--port=*)
|
|
1604
|
+
port="${1#*=}"
|
|
1605
|
+
validate_port "${port}"
|
|
1606
|
+
args+=("$1")
|
|
1607
|
+
shift
|
|
1608
|
+
;;
|
|
1609
|
+
*)
|
|
1610
|
+
args+=("$1")
|
|
1611
|
+
shift
|
|
1612
|
+
;;
|
|
1613
|
+
esac
|
|
1614
|
+
done
|
|
1615
|
+
local run_args=()
|
|
1616
|
+
run_args=(docker run --rm)
|
|
1617
|
+
append_tty_args run_args
|
|
1618
|
+
append_common_container_args run_args
|
|
1619
|
+
run_args+=(-p "${port}:${port}")
|
|
1620
|
+
run_args+=(--entrypoint headroom "${HEADROOM_IMAGE}" "${args[@]}")
|
|
1621
|
+
"${run_args[@]}"
|
|
1622
|
+
;;
|
|
1623
|
+
*)
|
|
1624
|
+
run_headroom "$@"
|
|
1625
|
+
;;
|
|
1626
|
+
esac
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
main "$@"
|
|
1630
|
+
WRAPPER
|
|
1631
|
+
} >"${wrapper_path}"
|
|
1632
|
+
|
|
1633
|
+
chmod +x "${wrapper_path}"
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
main() {
|
|
1637
|
+
require_cmd docker
|
|
1638
|
+
docker version >/dev/null 2>&1 || die "Docker is installed but not available to the current user"
|
|
1639
|
+
|
|
1640
|
+
mkdir -p "${INSTALL_DIR}"
|
|
1641
|
+
write_wrapper
|
|
1642
|
+
|
|
1643
|
+
append_path_block "${HOME}/.bashrc"
|
|
1644
|
+
append_path_block "${HOME}/.zshrc"
|
|
1645
|
+
append_path_block "${HOME}/.profile"
|
|
1646
|
+
|
|
1647
|
+
if [[ -n "${HEADROOM_DOCKER_IMAGE:-}" ]]; then
|
|
1648
|
+
if docker image inspect "${INSTALL_IMAGE}" >/dev/null 2>&1; then
|
|
1649
|
+
info "Using existing HEADROOM_DOCKER_IMAGE=${INSTALL_IMAGE}"
|
|
1650
|
+
else
|
|
1651
|
+
info "Pulling ${INSTALL_IMAGE}"
|
|
1652
|
+
docker pull "${INSTALL_IMAGE}" >/dev/null
|
|
1653
|
+
fi
|
|
1654
|
+
else
|
|
1655
|
+
info "Pulling ${IMAGE_DEFAULT}"
|
|
1656
|
+
docker pull "${IMAGE_DEFAULT}" >/dev/null
|
|
1657
|
+
fi
|
|
1658
|
+
|
|
1659
|
+
cat <<EOF
|
|
1660
|
+
|
|
1661
|
+
Headroom Docker-native install complete.
|
|
1662
|
+
|
|
1663
|
+
Installed wrapper:
|
|
1664
|
+
${INSTALL_DIR}/headroom
|
|
1665
|
+
|
|
1666
|
+
Next steps:
|
|
1667
|
+
1. Restart your shell or run: export PATH="${INSTALL_DIR}:\$PATH"
|
|
1668
|
+
2. Try: xtream-head proxy
|
|
1669
|
+
3. Docs: https://github.com/Xtream-ITSolutions/xithead/blob/main/docs/docker-install.md
|
|
1670
|
+
EOF
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
main "$@"
|