@crewx/sdk 0.9.0-rc.20 → 0.9.0-rc.201
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/README.md +1 -1
- package/dist/account/auth-client.d.ts +61 -0
- package/dist/account/auth-json-v2.d.ts +1 -0
- package/dist/account/auth-json.d.ts +30 -0
- package/dist/account/config.d.ts +37 -0
- package/dist/account/env-bootstrap.d.ts +11 -0
- package/dist/account/errors.d.ts +24 -0
- package/dist/account/index.d.ts +12 -0
- package/dist/account/index.js +2 -0
- package/dist/account/session-manager.d.ts +47 -0
- package/dist/activity-log/builder.d.ts +59 -6
- package/dist/agent/agent-list-view.d.ts +19 -0
- package/dist/agent-interceptor/chain.d.ts +25 -0
- package/dist/agent-interceptor/index.d.ts +6 -0
- package/dist/agent-interceptor/model-runner.d.ts +19 -0
- package/dist/agent-interceptor/program-runner.d.ts +13 -0
- package/dist/agent-interceptor/protocol.d.ts +68 -0
- package/dist/agent-interceptor/run-stop.d.ts +3 -0
- package/dist/agent-interceptor/schema.d.ts +267 -0
- package/dist/agent-interceptor/types.d.ts +88 -0
- package/dist/app/app-files/args.d.ts +12 -0
- package/dist/app/app-files/errors.d.ts +6 -0
- package/dist/app/app-files/index.d.ts +35 -0
- package/dist/app/app-files/lock.d.ts +26 -0
- package/dist/app/app-files/root.d.ts +22 -0
- package/dist/app/app-files/store.d.ts +48 -0
- package/dist/app/app-files/write.child.d.ts +1 -0
- package/dist/app/app.d.ts +168 -0
- package/dist/app/backend-env.d.ts +3 -0
- package/dist/app/content-media-types.d.ts +2 -0
- package/dist/app/context.d.ts +2 -0
- package/dist/app/entry.d.ts +9 -0
- package/dist/app/frame.d.ts +55 -0
- package/dist/app/index.d.ts +20 -0
- package/dist/app/index.js +13 -0
- package/dist/app/job-bridge.child.d.ts +1 -0
- package/dist/app/job-bridge.d.ts +67 -0
- package/dist/app/job-bridge.drain.child.d.ts +1 -0
- package/dist/app/job-bridge.example.d.ts +11 -0
- package/dist/app/job-contract.d.ts +40 -0
- package/dist/app/job-wire.d.ts +149 -0
- package/dist/app/protocol.d.ts +9 -0
- package/dist/app/runtime.d.ts +23 -0
- package/dist/app/schedule-contract.d.ts +59 -0
- package/dist/app/tool-mode.d.ts +3 -0
- package/dist/app-artifact-policy/check.d.ts +2 -0
- package/dist/app-artifact-policy/contract.d.ts +54 -0
- package/dist/app-artifact-policy/helper.d.ts +15 -0
- package/dist/app-artifact-policy/index.d.ts +3 -0
- package/dist/app-artifact-policy/index.js +18 -0
- package/dist/app-artifact-policy/paths.d.ts +24 -0
- package/dist/app-artifact-policy/scan.d.ts +47 -0
- package/dist/app-ui/index.d.ts +95 -0
- package/dist/app-ui/index.js +1 -0
- package/dist/attachment-receive/index.d.ts +76 -0
- package/dist/attachment-receive/index.js +2 -0
- package/dist/boxing/box.types.d.ts +4 -0
- package/dist/config/canonicalize-agent-options.d.ts +2 -0
- package/dist/config/default-agent-models.d.ts +11 -0
- package/dist/config/global-settings.d.ts +33 -0
- package/dist/config/migrate-grok-mode.d.ts +6 -0
- package/dist/config/model-compat.d.ts +31 -0
- package/dist/config/models.generated.d.ts +38 -0
- package/dist/config/models.remote.d.ts +1 -0
- package/dist/config/overdrive.d.ts +7 -0
- package/dist/config/pricing.d.ts +6 -3
- package/dist/config/pricing.generated.d.ts +4 -0
- package/dist/config/pricing.types.d.ts +4 -0
- package/dist/config/timeout.config.d.ts +4 -0
- package/dist/config/wi-boards.d.ts +19 -0
- package/dist/context/GoalLoader.d.ts +6 -0
- package/dist/context-budget/continuity.d.ts +64 -0
- package/dist/context-budget/fixed-slot-shrink.d.ts +97 -0
- package/dist/context-budget/index.d.ts +168 -0
- package/dist/conversation/index.d.ts +1 -1
- package/dist/conversation/sqlite-provider.d.ts +6 -3
- package/dist/conversation/to-template-messages.d.ts +9 -0
- package/dist/conversation/types.d.ts +86 -1
- package/dist/desktop/command-runner.d.ts +4 -0
- package/dist/desktop/default-adapters.d.ts +4 -0
- package/dist/desktop/global-install.d.ts +19 -0
- package/dist/desktop/index.d.ts +3 -0
- package/dist/desktop/index.js +3 -0
- package/dist/desktop/install.d.ts +5 -0
- package/dist/desktop/lnk.d.ts +22 -0
- package/dist/desktop/manifest.d.ts +21 -0
- package/dist/desktop/types.d.ts +67 -0
- package/dist/desktop/version.d.ts +1 -0
- package/dist/desktop/windows-paths.d.ts +21 -0
- package/dist/desktop/wrapper.d.ts +18 -0
- package/dist/esm/account/index.js +2 -0
- package/dist/esm/app/index.js +13 -0
- package/dist/esm/app-artifact-policy/index.js +18 -0
- package/dist/esm/attachment-receive/index.js +2 -0
- package/dist/esm/desktop/index.js +3 -0
- package/dist/esm/history-snapshot/index.js +16 -0
- package/dist/esm/index.js +1362 -224
- package/dist/esm/node/index.js +2 -0
- package/dist/esm/plugins/index.js +532 -214
- package/dist/esm/process/index.js +1 -0
- package/dist/esm/publish/index.js +2 -0
- package/dist/esm/repository/index.js +792 -207
- package/dist/esm/skills/index.js +2 -0
- package/dist/esm/testing/index.js +1 -1
- package/dist/events/types.d.ts +44 -0
- package/dist/facade/Crewx.d.ts +78 -5
- package/dist/facade/task-ticket.d.ts +14 -0
- package/dist/highlight/thread-highlight-prompt.d.ts +2 -0
- package/dist/highlight/thread-highlighter.d.ts +326 -0
- package/dist/history-snapshot/index.d.ts +82 -0
- package/dist/history-snapshot/index.js +16 -0
- package/dist/index.browser.d.ts +26 -1
- package/dist/index.browser.js +6 -2
- package/dist/index.d.ts +165 -18
- package/dist/index.js +1362 -224
- package/dist/internal/console-decoder.d.ts +38 -0
- package/dist/internal/windows-spawn.d.ts +10 -0
- package/dist/layout/types.d.ts +18 -1
- package/dist/lifecycle/process-lease.d.ts +80 -0
- package/dist/lifecycle/process-owner.d.ts +20 -0
- package/dist/lifecycle/task-heartbeat.d.ts +41 -0
- package/dist/lifecycle/task-stop.d.ts +112 -0
- package/dist/lifecycle/update-admission.d.ts +45 -0
- package/dist/local-server/base-url.d.ts +18 -0
- package/dist/local-server/index.d.ts +8 -0
- package/dist/local-server/opencode.d.ts +8 -0
- package/dist/local-server/probe.d.ts +3 -0
- package/dist/local-server/runtime.d.ts +26 -0
- package/dist/local-server/types.d.ts +43 -0
- package/dist/mcp-app/agent-access.d.ts +33 -0
- package/dist/mcp-app/app-handoff.d.ts +109 -0
- package/dist/mcp-app/app-icon-read.d.ts +7 -0
- package/dist/mcp-app/app-job-bridge.d.ts +30 -0
- package/dist/mcp-app/app-job-bridge.example.d.ts +36 -0
- package/dist/mcp-app/app-job.d.ts +168 -0
- package/dist/mcp-app/app-schedule.d.ts +85 -0
- package/dist/mcp-app/apps-context.d.ts +32 -0
- package/dist/mcp-app/bundle-provenance.d.ts +3 -0
- package/dist/mcp-app/candidate-registration.d.ts +4 -0
- package/dist/mcp-app/card-handler.d.ts +7 -0
- package/dist/mcp-app/catalog.d.ts +7 -0
- package/dist/mcp-app/content-channel.d.ts +86 -0
- package/dist/mcp-app/content-declarations.d.ts +31 -0
- package/dist/mcp-app/dev-checks.d.ts +31 -0
- package/dist/mcp-app/diagnostic-reason.d.ts +3 -0
- package/dist/mcp-app/discovery.d.ts +164 -0
- package/dist/mcp-app/errors.d.ts +7 -0
- package/dist/mcp-app/index.d.ts +46 -0
- package/dist/mcp-app/installed-app-ref.d.ts +25 -0
- package/dist/mcp-app/model-context.d.ts +29 -0
- package/dist/mcp-app/node-app-discovery-fs.d.ts +23 -0
- package/dist/mcp-app/product-bundle-assets.d.ts +27 -0
- package/dist/mcp-app/product-bundle-loader.d.ts +53 -0
- package/dist/mcp-app/projection.d.ts +14 -0
- package/dist/mcp-app/prompt-cards.d.ts +28 -0
- package/dist/mcp-app/registry.d.ts +28 -0
- package/dist/mcp-app/skill-backend.d.ts +141 -0
- package/dist/mcp-app/state-set.d.ts +9 -0
- package/dist/mcp-app/types.d.ts +501 -0
- package/dist/mcp-app/view-call.d.ts +7 -0
- package/dist/mcp-app/workspace-app-assets.d.ts +42 -0
- package/dist/mcp-app/workspace-app-scan-cache.d.ts +27 -0
- package/dist/mcp-app/workspace-snapshot.d.ts +81 -0
- package/dist/migrations/0011_far_black_tarantula.sql +1 -0
- package/dist/migrations/0012_blue_turbo.sql +23 -0
- package/dist/migrations/0013_hesitant_adam_destine.sql +15 -0
- package/dist/migrations/0014_organic_mongu.sql +73 -0
- package/dist/migrations/0015_panoramic_gorilla_man.sql +71 -0
- package/dist/migrations/0016_fuzzy_hemingway.sql +14 -0
- package/dist/migrations/0017_project_stage_sdk_migration.sql +29 -0
- package/dist/migrations/0018_bored_jackal.sql +33 -0
- package/dist/migrations/0019_backfill_task_thread_ids.sql +74 -0
- package/dist/migrations/0020_useful_iron_lad.sql +55 -0
- package/dist/migrations/0021_dashing_peter_quill.sql +51 -0
- package/dist/migrations/0022_wandering_bucky.sql +1 -0
- package/dist/migrations/0023_red_payback.sql +1 -0
- package/dist/migrations/0024_storage_metadata.sql +262 -0
- package/dist/migrations/0025_task_heartbeat.sql +8 -0
- package/dist/migrations/0025_thread_app_instance_ledger.sql +2 -0
- package/dist/migrations/0026_mcp_action_source.sql +47 -0
- package/dist/migrations/0027_task_stop_scope_cleanup.sql +5 -0
- package/dist/migrations/0027_ui_instance_active_unique.sql +2 -0
- package/dist/migrations/0029_nice_rhino.sql +1 -0
- package/dist/migrations/0031_petite_arclight.sql +6 -0
- package/dist/migrations/0032_ui_instance_opened_by.sql +1 -0
- package/dist/migrations/0033_thread_creator_boundary_guard.sql +38 -0
- package/dist/migrations/0034_keen_fallen_one.sql +36 -0
- package/dist/migrations/0035_request_log_daily.sql +11 -0
- package/dist/migrations/0036_ui_definition_archive.sql +8 -0
- package/dist/migrations/0037_ui_instance_agent_open_request.sql +1 -0
- package/dist/migrations/0038_task_rating.sql +3 -0
- package/dist/migrations/0039_aspiring_purifiers.sql +9 -0
- package/dist/migrations/0040_task_provider_inputs.sql +53 -0
- package/dist/migrations/0041_tranquil_vivisector.sql +54 -0
- package/dist/migrations/0042_breezy_blue_shield.sql +31 -0
- package/dist/migrations/0043_nervous_darkstar.sql +1 -0
- package/dist/migrations/0044_military_galactus.sql +8 -0
- package/dist/migrations/0045_task_pid_started_at.sql +1 -0
- package/dist/migrations/0046_acoustic_karnak.sql +49 -0
- package/dist/migrations/0047_doc_sync_connect_requests.sql +18 -0
- package/dist/migrations/0048_smart_gertrude_yorkes.sql +47 -0
- package/dist/migrations/meta/0011_snapshot.json +1342 -0
- package/dist/migrations/meta/0012_snapshot.json +1494 -0
- package/dist/migrations/meta/0013_snapshot.json +1592 -0
- package/dist/migrations/meta/0014_snapshot.json +1975 -0
- package/dist/migrations/meta/0015_snapshot.json +2315 -0
- package/dist/migrations/meta/0016_snapshot.json +2419 -0
- package/dist/migrations/meta/0017_snapshot.json +2419 -0
- package/dist/migrations/meta/0018_snapshot.json +2570 -0
- package/dist/migrations/meta/0020_snapshot.json +2895 -0
- package/dist/migrations/meta/0021_snapshot.json +3031 -0
- package/dist/migrations/meta/0022_snapshot.json +3039 -0
- package/dist/migrations/meta/0023_snapshot.json +3047 -0
- package/dist/migrations/meta/0029_snapshot.json +3206 -0
- package/dist/migrations/meta/0031_snapshot.json +3251 -0
- package/dist/migrations/meta/0034_snapshot.json +3473 -0
- package/dist/migrations/meta/0035_snapshot.json +3547 -0
- package/dist/migrations/meta/0036_snapshot.json +3591 -0
- package/dist/migrations/meta/0037_snapshot.json +3598 -0
- package/dist/migrations/meta/0038_snapshot.json +3626 -0
- package/dist/migrations/meta/0039_snapshot.json +3684 -0
- package/dist/migrations/meta/0040_snapshot.json +3759 -0
- package/dist/migrations/meta/0041_snapshot.json +4156 -0
- package/dist/migrations/meta/0042_snapshot.json +4383 -0
- package/dist/migrations/meta/0043_snapshot.json +4390 -0
- package/dist/migrations/meta/0044_snapshot.json +4435 -0
- package/dist/migrations/meta/0045_snapshot.json +4442 -0
- package/dist/migrations/meta/0046_snapshot.json +4733 -0
- package/dist/migrations/meta/0047_snapshot.json +4832 -0
- package/dist/migrations/meta/0048_snapshot.json +5128 -0
- package/dist/migrations/meta/_journal.json +266 -0
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +2 -0
- package/dist/paths.d.ts +1 -0
- package/dist/plugin/types.d.ts +1 -0
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +532 -214
- package/dist/plugins/sqlite-tracing.d.ts +46 -0
- package/dist/process/index.d.ts +2 -0
- package/dist/process/index.js +1 -0
- package/dist/process/process-control.d.ts +74 -0
- package/dist/prompt/tag-names.d.ts +22 -0
- package/dist/provider/acp/adapter.d.ts +37 -2
- package/dist/provider/acp/adapters/antigravity-account.d.ts +4 -0
- package/dist/provider/acp/completion-observer.d.ts +24 -0
- package/dist/provider/acp/connection.d.ts +69 -3
- package/dist/provider/acp/index.d.ts +3 -3
- package/dist/provider/acp/meta.d.ts +11 -0
- package/dist/provider/acp/register.d.ts +1 -0
- package/dist/provider/acp/runtime.d.ts +1 -0
- package/dist/provider/acp/types.d.ts +31 -4
- package/dist/provider/bridge.browser.d.ts +3 -0
- package/dist/provider/bridge.d.ts +25 -3
- package/dist/provider/classify-task-error.d.ts +2 -0
- package/dist/provider/claude-agent-env.d.ts +1 -0
- package/dist/provider/cli/adapter.types.d.ts +26 -2
- package/dist/provider/cli/adapters/agent-call.util.d.ts +1 -1
- package/dist/provider/cli/adapters/antigravity-stream.d.ts +27 -0
- package/dist/provider/cli/adapters/antigravity.d.ts +1 -0
- package/dist/provider/cli/adapters/cli-knob.util.d.ts +7 -0
- package/dist/provider/cli/adapters/codex-item.d.ts +1 -0
- package/dist/provider/cli/adapters/event-timestamp.util.d.ts +1 -0
- package/dist/provider/cli/adapters/grok.d.ts +2 -0
- package/dist/provider/cli/adapters/index.d.ts +5 -0
- package/dist/provider/cli/index.d.ts +3 -2
- package/dist/provider/cli/meta.d.ts +5 -0
- package/dist/provider/cli/protocol-envelope.d.ts +3 -0
- package/dist/provider/errors.d.ts +5 -1
- package/dist/provider/idle-watchdog.d.ts +19 -0
- package/dist/provider/models.d.ts +17 -12
- package/dist/provider/order.d.ts +1 -1
- package/dist/provider/parse-usage.d.ts +6 -0
- package/dist/provider/provider-selection.d.ts +8 -0
- package/dist/provider/redact-technical-message.d.ts +1 -0
- package/dist/provider/task-error.types.d.ts +17 -0
- package/dist/provider-account/accounts.d.ts +15 -0
- package/dist/provider-account/antigravity-acp/auth.d.ts +29 -0
- package/dist/provider-account/antigravity-acp/browser.d.ts +4 -0
- package/dist/provider-account/antigravity-acp/install.d.ts +42 -0
- package/dist/provider-account/antigravity-acp/lease.d.ts +23 -0
- package/dist/provider-account/antigravity-acp/lifecycle.d.ts +76 -0
- package/dist/provider-account/antigravity-acp/manifest.d.ts +76 -0
- package/dist/provider-account/antigravity-acp/profile.d.ts +4 -0
- package/dist/provider-account/capabilities.d.ts +6 -0
- package/dist/provider-account/index.d.ts +13 -0
- package/dist/provider-account/registry.d.ts +30 -0
- package/dist/provider-account/types.d.ts +47 -0
- package/dist/publish/constants.d.ts +6 -0
- package/dist/publish/errors.d.ts +7 -0
- package/dist/publish/index.d.ts +55 -0
- package/dist/publish/index.js +2 -0
- package/dist/publish/manifest.d.ts +47 -0
- package/dist/publish/marketplace-api.constants.d.ts +1 -0
- package/dist/publish/pack.d.ts +6 -0
- package/dist/publish/scan.d.ts +10 -0
- package/dist/publish/secrets.d.ts +6 -0
- package/dist/publish/upload.d.ts +19 -0
- package/dist/remote/execution-profile.d.ts +9 -0
- package/dist/remote/index.d.ts +1 -0
- package/dist/remote/types.d.ts +28 -0
- package/dist/repository/agent-send-history.repository.d.ts +23 -0
- package/dist/repository/agent-suggestion.repository.d.ts +34 -0
- package/dist/repository/base-sqlite-repository.d.ts +1 -0
- package/dist/repository/common-code.repository.d.ts +45 -0
- package/dist/repository/db.d.ts +13 -1
- package/dist/repository/index.d.ts +62 -6
- package/dist/repository/index.js +792 -207
- package/dist/repository/logs-db.d.ts +12 -0
- package/dist/repository/notification.repository.d.ts +58 -0
- package/dist/repository/project.repository.d.ts +90 -0
- package/dist/repository/public-task-answer.d.ts +24 -0
- package/dist/repository/request-log-mover.d.ts +70 -0
- package/dist/repository/request-log.repository.d.ts +7 -3
- package/dist/repository/run-columns.d.ts +10 -0
- package/dist/repository/run-history.repository.d.ts +112 -0
- package/dist/repository/schedule-run.repository.d.ts +103 -0
- package/dist/repository/sidebar-tab.repository.d.ts +86 -0
- package/dist/repository/storage-metadata.repository.d.ts +64 -0
- package/dist/repository/task-log-migration.d.ts +74 -0
- package/dist/repository/task-log.repository.d.ts +47 -0
- package/dist/repository/task-status.d.ts +21 -0
- package/dist/repository/task.repository.d.ts +330 -8
- package/dist/repository/thread-history.repository.d.ts +193 -0
- package/dist/repository/thread-origin-verdict.d.ts +27 -0
- package/dist/repository/thread-title.types.d.ts +29 -0
- package/dist/repository/thread.repository.d.ts +134 -5
- package/dist/repository/usage-backfill.d.ts +62 -0
- package/dist/repository/usage-from-logs.d.ts +22 -0
- package/dist/repository/workflow-anchor-kinds.d.ts +4 -0
- package/dist/repository/workspace.repository.d.ts +3 -0
- package/dist/route/decide.d.ts +54 -0
- package/dist/route/eligibility.d.ts +11 -0
- package/dist/route/errors.d.ts +11 -0
- package/dist/route/index.d.ts +14 -0
- package/dist/route/runner.d.ts +15 -0
- package/dist/route/sqlite-store.d.ts +17 -0
- package/dist/route/store.d.ts +45 -0
- package/dist/route/strategies.d.ts +4 -0
- package/dist/route/types.d.ts +212 -0
- package/dist/schema/agent-send-history.d.ts +85 -0
- package/dist/schema/agent-suggestions.d.ts +199 -0
- package/dist/schema/common-codes.d.ts +216 -0
- package/dist/schema/doc-sync-connect-requests.d.ts +140 -0
- package/dist/schema/doc-sync-links.d.ts +481 -0
- package/dist/schema/index.d.ts +21 -0
- package/dist/schema/model-routes.d.ts +581 -0
- package/dist/schema/notifications.d.ts +303 -0
- package/dist/schema/projects.d.ts +610 -0
- package/dist/schema/request-log-daily.d.ts +151 -0
- package/dist/schema/run-column-backfill.d.ts +81 -0
- package/dist/schema/schedule-runs.d.ts +451 -0
- package/dist/schema/sidebar-tabs.d.ts +466 -0
- package/dist/schema/storage-metadata.d.ts +181 -0
- package/dist/schema/task-log-events.d.ts +119 -0
- package/dist/schema/task-provider-inputs.d.ts +100 -0
- package/dist/schema/tasks.d.ts +1172 -1
- package/dist/schema/thread-creator-unverified.d.ts +45 -0
- package/dist/schema/thread-history.d.ts +734 -0
- package/dist/schema/threads.d.ts +59 -0
- package/dist/schema/ui-action-receipts.d.ts +358 -0
- package/dist/schema/ui-definition-archive.d.ts +63 -0
- package/dist/schema/ui-instance-repins.d.ts +222 -0
- package/dist/schema/ui-instances.d.ts +324 -0
- package/dist/schema/workspaces.d.ts +17 -0
- package/dist/skills/index.d.ts +15 -0
- package/dist/skills/index.js +2 -0
- package/dist/skills/types.d.ts +18 -0
- package/dist/task-log/anchor-child-tasks.d.ts +7 -0
- package/dist/task-log/delegation-trailer.d.ts +34 -0
- package/dist/template/engine.d.ts +2 -2
- package/dist/template/helpers/exec.browser.d.ts +4 -3
- package/dist/template/helpers/exec.d.ts +4 -3
- package/dist/template/helpers/format-conversation.d.ts +1 -0
- package/dist/template/types.d.ts +20 -0
- package/dist/testing/index.js +1 -1
- package/dist/types/index.d.ts +3493 -93
- package/dist/types/task-log.types.d.ts +6 -1
- package/dist/ui-card/index.d.ts +2 -0
- package/dist/ui-card/legacy-card-parser.d.ts +11 -0
- package/dist/ui-instance/definition.d.ts +6 -0
- package/dist/ui-instance/errors.d.ts +18 -0
- package/dist/ui-instance/index.d.ts +11 -0
- package/dist/ui-instance/json.d.ts +19 -0
- package/dist/ui-instance/lineage.d.ts +24 -0
- package/dist/ui-instance/runtime.d.ts +19 -0
- package/dist/ui-instance/store.d.ts +216 -0
- package/dist/ui-instance/types.d.ts +384 -0
- package/dist/ui-plugin/app-icon.d.ts +50 -0
- package/dist/ui-plugin/app-manifest.d.ts +64 -0
- package/dist/ui-plugin/csp.d.ts +28 -0
- package/dist/ui-plugin/index.d.ts +8 -0
- package/dist/ui-plugin/limits.d.ts +27 -0
- package/dist/ui-plugin/manifest.d.ts +3 -0
- package/dist/ui-plugin/types.d.ts +220 -0
- package/dist/ui-plugin/validator.d.ts +18 -0
- package/dist/utils/crewx-executable.d.ts +76 -0
- package/dist/utils/crewx-home.d.ts +1 -0
- package/dist/utils/env-defaults.d.ts +3 -0
- package/dist/utils/id.d.ts +1 -1
- package/dist/utils/local-identity.d.ts +2 -0
- package/dist/utils/runner-env.d.ts +3 -0
- package/dist/utils/timestamp.d.ts +1 -0
- package/dist/utils/workspace.d.ts +1 -0
- package/dist/wi/create.d.ts +48 -0
- package/dist/wi/select.d.ts +20 -0
- package/package.json +83 -3
- package/templates/agents/default.yaml +311 -128
- package/templates/documents/crewx-manual.md +138 -138
- package/templates/documents/crewx-quick-guide.md +8 -7
- package/templates/workflows/wi-default-flow.yaml +65 -0
- package/templates/workflows/wi-plan-flow.yaml +140 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export interface GoalSourceFile {
|
|
2
|
+
file: string;
|
|
3
|
+
path: string;
|
|
4
|
+
content: string;
|
|
5
|
+
}
|
|
6
|
+
export interface PathDocumentSource {
|
|
7
|
+
content: string;
|
|
8
|
+
path?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AvailableAppDescription {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
agent: 'direct' | 'approval' | 'none';
|
|
15
|
+
usage?: 'card' | 'window';
|
|
16
|
+
}
|
|
17
|
+
export interface SkillDescriptionSource {
|
|
18
|
+
metadata: {
|
|
19
|
+
name: string;
|
|
20
|
+
version: string;
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
filePath: string;
|
|
24
|
+
}
|
|
25
|
+
export type FixedSlotDegradationSlot = 'documents' | 'goals' | 'apps/skills';
|
|
26
|
+
export type FixedSlotMeasurementSlot = FixedSlotDegradationSlot | 'conversation';
|
|
27
|
+
export interface FixedSlotDegradation {
|
|
28
|
+
slot: FixedSlotDegradationSlot;
|
|
29
|
+
originalBytes: number;
|
|
30
|
+
shrunkBytes: number;
|
|
31
|
+
path: string;
|
|
32
|
+
}
|
|
33
|
+
export type FixedSlotAction = {
|
|
34
|
+
kind: 'document';
|
|
35
|
+
key: string;
|
|
36
|
+
path: string;
|
|
37
|
+
replacement: string;
|
|
38
|
+
originalBytes: number;
|
|
39
|
+
shrunkBytes: number;
|
|
40
|
+
savingBytes: number;
|
|
41
|
+
} | {
|
|
42
|
+
kind: 'goal';
|
|
43
|
+
file: string;
|
|
44
|
+
path: string;
|
|
45
|
+
replacement: string;
|
|
46
|
+
originalBytes: number;
|
|
47
|
+
shrunkBytes: number;
|
|
48
|
+
savingBytes: number;
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'apps/skills';
|
|
51
|
+
path: string;
|
|
52
|
+
notice: string;
|
|
53
|
+
noticeTarget: 'apps' | 'skills';
|
|
54
|
+
originalBytes: number;
|
|
55
|
+
shrunkBytes: number;
|
|
56
|
+
savingBytes: number;
|
|
57
|
+
};
|
|
58
|
+
export interface FixedSlotPlan {
|
|
59
|
+
actions: FixedSlotAction[];
|
|
60
|
+
beforeHistoryActionCount: number;
|
|
61
|
+
}
|
|
62
|
+
export interface FixedSlotPlanInput {
|
|
63
|
+
documents: Record<string, PathDocumentSource>;
|
|
64
|
+
renderedPrompt: string;
|
|
65
|
+
goals: readonly GoalSourceFile[];
|
|
66
|
+
apps: readonly AvailableAppDescription[] | undefined;
|
|
67
|
+
appsAvailableRendered?: string;
|
|
68
|
+
skills: readonly SkillDescriptionSource[];
|
|
69
|
+
projectRoot: string;
|
|
70
|
+
cli?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface GoalCompactionResult {
|
|
73
|
+
compacted: boolean;
|
|
74
|
+
content: string;
|
|
75
|
+
originalBytes: number;
|
|
76
|
+
compactedBytes: number;
|
|
77
|
+
removedSections: Array<{
|
|
78
|
+
name: string;
|
|
79
|
+
bytes: number;
|
|
80
|
+
}>;
|
|
81
|
+
keyResultItemCount: number;
|
|
82
|
+
reason?: 'missing-frontmatter' | 'missing-title' | 'missing-key-results' | 'no-key-result-items' | 'item-count-mismatch';
|
|
83
|
+
}
|
|
84
|
+
export interface DocumentCompactionResult {
|
|
85
|
+
content: string;
|
|
86
|
+
originalBytes: number;
|
|
87
|
+
compactedBytes: number;
|
|
88
|
+
tocBytes: number;
|
|
89
|
+
}
|
|
90
|
+
export declare function appsSkillsShorteningNotice(projectRoot: string, cli?: string): string;
|
|
91
|
+
export declare function compactPathDocument(content: string, path: string, cli?: string): DocumentCompactionResult;
|
|
92
|
+
export declare function compactGoal(markdown: string, path: string, cli?: string): GoalCompactionResult;
|
|
93
|
+
export declare function buildFixedSlotPlan(input: FixedSlotPlanInput): FixedSlotPlan;
|
|
94
|
+
export declare function degradationsForFixedSlotPlan(plan: FixedSlotPlan, stage: number): FixedSlotDegradation[];
|
|
95
|
+
export declare function fixedSlotActionCountBeforeHistory(plan: FixedSlotPlan): number;
|
|
96
|
+
export declare function fixedSlotActionCount(plan: FixedSlotPlan): number;
|
|
97
|
+
export declare function utf8ByteLength(value: string): number;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { FixedSlotDegradation } from './fixed-slot-shrink';
|
|
2
|
+
export declare const DEFAULT_INPUT_BUDGET_PERCENT = 60;
|
|
3
|
+
export declare const MIN_INPUT_BUDGET_PERCENT = 30;
|
|
4
|
+
export declare const MAX_INPUT_BUDGET_PERCENT = 80;
|
|
5
|
+
export declare const INPUT_BUDGET_TOKENIZER_ENCODING = "o200k_base";
|
|
6
|
+
export declare const FRESH_PROVIDER_INITIAL_INPUT_SEPARATOR = "\n\n---\n\n";
|
|
7
|
+
export declare const FRESH_PROVIDER_INITIAL_INPUT_FRAMING = "system_prompt\\n\\n---\\n\\nmessage";
|
|
8
|
+
export declare const RESUME_PROVIDER_INITIAL_INPUT_FRAMING = "message";
|
|
9
|
+
export type InputBudgetUnresolvedReason = 'invalid_input_budget_percent' | 'provider_catalog_unavailable' | 'model_not_found' | 'context_window_tokens_unavailable';
|
|
10
|
+
export type TokenizerFallbackReason = 'vendor_tokenizer_unavailable';
|
|
11
|
+
export interface ResolveInputBudgetOptions {
|
|
12
|
+
provider: string;
|
|
13
|
+
model: string;
|
|
14
|
+
inputBudgetPercent?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface TokenizerOptions {
|
|
17
|
+
provider?: string;
|
|
18
|
+
model?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface TokenizerMetadata {
|
|
21
|
+
provider: string;
|
|
22
|
+
model: string;
|
|
23
|
+
encoding: typeof INPUT_BUDGET_TOKENIZER_ENCODING;
|
|
24
|
+
exact: boolean;
|
|
25
|
+
fallbackReason?: TokenizerFallbackReason;
|
|
26
|
+
}
|
|
27
|
+
export interface ResolvedInputBudget {
|
|
28
|
+
resolved: true;
|
|
29
|
+
requestedProvider: string;
|
|
30
|
+
provider: string;
|
|
31
|
+
model: string;
|
|
32
|
+
contextWindowTokens: number;
|
|
33
|
+
inputBudgetPercent: number;
|
|
34
|
+
inputBudgetTokens: number;
|
|
35
|
+
tokenizer: TokenizerMetadata;
|
|
36
|
+
}
|
|
37
|
+
export interface UnresolvedInputBudget {
|
|
38
|
+
resolved: false;
|
|
39
|
+
requestedProvider: string;
|
|
40
|
+
provider: string;
|
|
41
|
+
model: string;
|
|
42
|
+
reason: InputBudgetUnresolvedReason;
|
|
43
|
+
inputBudgetPercent?: number;
|
|
44
|
+
tokenizer: TokenizerMetadata;
|
|
45
|
+
}
|
|
46
|
+
export type ResolveInputBudgetResult = ResolvedInputBudget | UnresolvedInputBudget;
|
|
47
|
+
export type ContextBudgetPhase = 'fresh' | 'resume';
|
|
48
|
+
export type ProviderInitialInputFraming = typeof FRESH_PROVIDER_INITIAL_INPUT_FRAMING | typeof RESUME_PROVIDER_INITIAL_INPUT_FRAMING;
|
|
49
|
+
export interface ContextBudgetLayoutCapability {
|
|
50
|
+
layoutId: string;
|
|
51
|
+
supportsSemanticContinuity: boolean;
|
|
52
|
+
slot: string | null;
|
|
53
|
+
requiredForOmittedTurns: boolean;
|
|
54
|
+
warning?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface ContextBudgetActivityDegradation {
|
|
57
|
+
taskId: string;
|
|
58
|
+
taskDistance: number;
|
|
59
|
+
action: 'reduced' | 'omitted';
|
|
60
|
+
}
|
|
61
|
+
export interface ContextBudgetInputByteLimit {
|
|
62
|
+
unit: 'utf8_bytes';
|
|
63
|
+
limit: number;
|
|
64
|
+
initialCount: number;
|
|
65
|
+
finalCount: number;
|
|
66
|
+
exceeded: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface ContextBudgetSlotSizes {
|
|
69
|
+
goals: number;
|
|
70
|
+
documents: number;
|
|
71
|
+
appsSkills: number;
|
|
72
|
+
conversation: number;
|
|
73
|
+
otherFixed: number;
|
|
74
|
+
}
|
|
75
|
+
export type ContextBudgetAssemblyErrorCode = 'INPUT_BUDGET_EXCEEDED' | 'CONTINUITY_SLOT_REQUIRED' | 'HISTORY_SNAPSHOT_UNAVAILABLE';
|
|
76
|
+
export declare class ContextBudgetLayoutError extends Error {
|
|
77
|
+
readonly layoutId: string;
|
|
78
|
+
readonly omittedTurnCount: number;
|
|
79
|
+
readonly code: "CONTINUITY_SLOT_REQUIRED";
|
|
80
|
+
constructor(message: string, layoutId: string, omittedTurnCount: number);
|
|
81
|
+
}
|
|
82
|
+
export interface ContextBudgetManifest {
|
|
83
|
+
runningInstructionAppsOmitted?: number;
|
|
84
|
+
phase: ContextBudgetPhase;
|
|
85
|
+
initialInputFraming: ProviderInitialInputFraming;
|
|
86
|
+
resolved: boolean;
|
|
87
|
+
reason?: InputBudgetUnresolvedReason;
|
|
88
|
+
requestedProvider: string;
|
|
89
|
+
requestedModel: string | null;
|
|
90
|
+
effectiveProvider: string;
|
|
91
|
+
effectiveModel: string | null;
|
|
92
|
+
contextWindowTokens: number | null;
|
|
93
|
+
inputBudgetPercent: number | null;
|
|
94
|
+
inputBudgetTokens: number | null;
|
|
95
|
+
tokenizer: TokenizerMetadata;
|
|
96
|
+
initialTokenCount: number | null;
|
|
97
|
+
finalTokenCount: number | null;
|
|
98
|
+
inputBudgetBytes?: ContextBudgetInputByteLimit;
|
|
99
|
+
fixedSlotDegradations?: FixedSlotDegradation[];
|
|
100
|
+
fixedSlotSizes?: ContextBudgetSlotSizes;
|
|
101
|
+
historySnapshot?: {
|
|
102
|
+
ref: string;
|
|
103
|
+
entries: number;
|
|
104
|
+
bytes: number;
|
|
105
|
+
expiresAtMs: number;
|
|
106
|
+
};
|
|
107
|
+
activityLogTokenCount: number | null;
|
|
108
|
+
activityIncludedEntries: number | null;
|
|
109
|
+
activityOmittedEntries: number | null;
|
|
110
|
+
activityRemovedForBudget: boolean;
|
|
111
|
+
activityNewestTaskTokenCap: number | null;
|
|
112
|
+
historyOriginalMessages: number;
|
|
113
|
+
historyIncludedMessages: number;
|
|
114
|
+
historyOmittedMessages: number;
|
|
115
|
+
turnOriginal: number;
|
|
116
|
+
turnIncluded: number;
|
|
117
|
+
turnOmitted: number;
|
|
118
|
+
highlightOriginal: number;
|
|
119
|
+
highlightIncluded: number;
|
|
120
|
+
highlightOmitted: number;
|
|
121
|
+
highlightTruncated: number;
|
|
122
|
+
representedOmittedTurns: number;
|
|
123
|
+
unrepresentedOmittedTurns: number;
|
|
124
|
+
activityDegraded: boolean;
|
|
125
|
+
activityIncludedTasks: number;
|
|
126
|
+
activityOmittedTasks: number;
|
|
127
|
+
activityDegradation: ContextBudgetActivityDegradation[];
|
|
128
|
+
highlightLookupFailed: boolean;
|
|
129
|
+
layoutCapability: ContextBudgetLayoutCapability;
|
|
130
|
+
overBudget: boolean;
|
|
131
|
+
overdriveProviderSuppressed?: boolean;
|
|
132
|
+
}
|
|
133
|
+
export interface TokenCountResult {
|
|
134
|
+
tokenCount: number;
|
|
135
|
+
tokenizer: TokenizerMetadata;
|
|
136
|
+
}
|
|
137
|
+
export interface TokenCounter {
|
|
138
|
+
metadata: TokenizerMetadata;
|
|
139
|
+
countTokens(text: string): number;
|
|
140
|
+
}
|
|
141
|
+
export interface FreshProviderInitialInput {
|
|
142
|
+
systemPrompt?: string | null;
|
|
143
|
+
message: string;
|
|
144
|
+
}
|
|
145
|
+
type PieceCacheEventType = 'hit' | 'miss' | 'evict' | 'full_encode';
|
|
146
|
+
interface PieceCacheEvent {
|
|
147
|
+
type: PieceCacheEventType;
|
|
148
|
+
piece?: string;
|
|
149
|
+
tokenCount?: number;
|
|
150
|
+
reason?: 'special_token';
|
|
151
|
+
}
|
|
152
|
+
type PieceCacheObserver = (event: PieceCacheEvent) => void;
|
|
153
|
+
interface TokenCounterInternalOptions {
|
|
154
|
+
pieceCacheMaxEntries?: number;
|
|
155
|
+
observePieceCache?: PieceCacheObserver;
|
|
156
|
+
}
|
|
157
|
+
export declare function normalizeInputBudgetProvider(provider: string): string;
|
|
158
|
+
export declare function resolveTokenizerMetadata(options?: TokenizerOptions): TokenizerMetadata;
|
|
159
|
+
export declare function countTokens(text: string, options?: TokenizerOptions): TokenCountResult;
|
|
160
|
+
export declare function renderFreshProviderInitialInput(input: FreshProviderInitialInput): string;
|
|
161
|
+
export declare function countFreshProviderInitialInput(input: FreshProviderInitialInput, count: (text: string) => number): number;
|
|
162
|
+
export declare function countUtf8Bytes(text: string): number;
|
|
163
|
+
export declare function countFreshProviderInitialInputBytes(input: FreshProviderInitialInput): number;
|
|
164
|
+
export declare function createTokenCounter(options?: TokenizerOptions): TokenCounter;
|
|
165
|
+
export declare function __createTokenCounterForTest(options?: TokenizerOptions, internalOptions?: TokenCounterInternalOptions): TokenCounter;
|
|
166
|
+
export declare function resolveInputBudget(options: ResolveInputBudgetOptions): ResolveInputBudgetResult;
|
|
167
|
+
export { DEFAULT_HIGHLIGHT_BUDGET_PERCENT, DEFAULT_PROTECTED_TURN_COUNT, MAX_ACTIVE_HIGHLIGHT_CHARS, MAX_ACTIVE_HIGHLIGHTS, MAX_THREAD_STATE_VALUE_CHARS, MAX_THREAD_TITLE_CHARS, buildSemanticContinuityContext, buildThreadStateContext, getConversationMessageTaskId, groupConversationTurns, materializeConversationTurn, selectConversationHighlights, selectConversationTurns, withoutDroppedAppCards, } from './continuity.js';
|
|
168
|
+
export type { BuildSemanticContinuityContextOptions, ConversationHighlightSelection, ConversationTurn, ConversationTurnSelection, GroupedConversationTurns, SelectConversationHighlightsOptions, SelectConversationTurnsOptions, } from './continuity.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
2
|
export { toTaskReader } from './to-task-reader.js';
|
|
3
|
-
export { toTemplateMessages } from './to-template-messages.js';
|
|
3
|
+
export { LEGACY_UI_CARD_SAFE_SUMMARY, sanitizeLegacyUiCardText, sanitizeTemplateMessages, toTemplateMessages, } from './to-template-messages.js';
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import type { ConversationThread, FetchHistoryOptions, IConversationHistoryProvider, Platform } from './types';
|
|
1
|
+
import type { ConversationHighlight, ConversationThread, ConversationThreadState, FetchHistoryOptions, IConversationHistoryProvider, Platform, ThreadCreationOptions } from './types';
|
|
2
2
|
export declare class SqliteConversationProvider implements IConversationHistoryProvider {
|
|
3
3
|
private readonly dbPath;
|
|
4
4
|
constructor(dbPath?: string);
|
|
5
5
|
private getThreadRepo;
|
|
6
|
+
private getThreadHistoryRepo;
|
|
6
7
|
updateThread(id: string, patch: {
|
|
7
8
|
title?: string;
|
|
8
9
|
}): void;
|
|
9
|
-
ensureThread(threadId: string, platform: Platform, workspaceId?: string): Promise<{
|
|
10
|
+
ensureThread(threadId: string, platform: Platform, workspaceId?: string, creator?: ThreadCreationOptions): Promise<{
|
|
10
11
|
created: boolean;
|
|
11
12
|
}>;
|
|
12
13
|
fetchHistory(threadId: string, options?: FetchHistoryOptions): Promise<ConversationThread>;
|
|
14
|
+
fetchThreadState(threadId: string): Promise<ConversationThreadState | undefined>;
|
|
15
|
+
fetchHighlights(threadId: string): Promise<ConversationHighlight[] | undefined>;
|
|
13
16
|
saveUserMessage(threadId: string, text: string, _userId?: string, _metadata?: Record<string, unknown>): Promise<{
|
|
14
17
|
id: string;
|
|
15
18
|
firstMessage: boolean;
|
|
@@ -18,6 +21,6 @@ export declare class SqliteConversationProvider implements IConversationHistoryP
|
|
|
18
21
|
id: string;
|
|
19
22
|
}>;
|
|
20
23
|
close(): void;
|
|
21
|
-
private
|
|
24
|
+
private readActiveHighlights;
|
|
22
25
|
private rowsToMessages;
|
|
23
26
|
}
|
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import type { ConversationThread, TemplateMessage } from './types';
|
|
2
|
+
import type { UiAgentContextProjection } from '../ui-instance/types.js';
|
|
3
|
+
import type { McpAppStateDescriptor } from '../mcp-app/types.js';
|
|
4
|
+
export declare const LEGACY_UI_CARD_SAFE_SUMMARY = "[workflow card omitted from AI context]";
|
|
5
|
+
export declare const V2_UI_INSTANCE_SAFE_SUMMARY = "[workflow UI instance omitted from AI context]";
|
|
6
|
+
export declare function sanitizeUiInstanceReferenceText(text: string): string;
|
|
7
|
+
export declare function sanitizeLegacyUiCardText(text: string): string;
|
|
8
|
+
export declare function sanitizeTemplateMessages(messages: readonly TemplateMessage[]): TemplateMessage[];
|
|
9
|
+
export declare function appendUiProjections(messages: readonly TemplateMessage[], projections: readonly UiAgentContextProjection[] | undefined): TemplateMessage[];
|
|
10
|
+
export declare function appendMcpAppProjections(messages: readonly TemplateMessage[], descriptors: readonly McpAppStateDescriptor[] | undefined): TemplateMessage[];
|
|
2
11
|
export declare function toTemplateMessages(thread: ConversationThread): TemplateMessage[];
|
|
@@ -1,16 +1,84 @@
|
|
|
1
|
+
import type { ThreadCreationOptions } from '../repository/thread.repository';
|
|
2
|
+
export type { ThreadCreationOptions } from '../repository/thread.repository';
|
|
1
3
|
export interface ConversationMessage {
|
|
2
4
|
id: string;
|
|
3
5
|
userId?: string;
|
|
4
6
|
text: string;
|
|
5
7
|
isAssistant: boolean;
|
|
6
8
|
timestamp: number;
|
|
9
|
+
taskId?: string;
|
|
7
10
|
metadata?: Record<string, unknown>;
|
|
8
11
|
}
|
|
9
12
|
export type Platform = 'cli' | 'web' | 'api' | 'mcp' | `channel/${string}`;
|
|
13
|
+
export interface ConversationHighlight {
|
|
14
|
+
id: string;
|
|
15
|
+
text: string;
|
|
16
|
+
kind?: string;
|
|
17
|
+
source?: string;
|
|
18
|
+
coversFromTaskId?: string;
|
|
19
|
+
coversToTaskId?: string;
|
|
20
|
+
covers_from_task_id?: string;
|
|
21
|
+
covers_to_task_id?: string;
|
|
22
|
+
createdAt?: number | string;
|
|
23
|
+
created_at?: number | string;
|
|
24
|
+
}
|
|
25
|
+
export interface HistoryLookupNotice {
|
|
26
|
+
ref: string;
|
|
27
|
+
entries: number;
|
|
28
|
+
bytes: number;
|
|
29
|
+
expiresAtMs: number;
|
|
30
|
+
omittedTurns: number;
|
|
31
|
+
omittedMessageEntries: string;
|
|
32
|
+
omittedActivityTasks: number;
|
|
33
|
+
omittedActivityEntries: number | null;
|
|
34
|
+
omittedActivityEntryOrdinals: string;
|
|
35
|
+
omittedHighlights: number;
|
|
36
|
+
omittedHighlightEntries: string;
|
|
37
|
+
truncatedHighlights: number;
|
|
38
|
+
truncatedHighlightEntries: string;
|
|
39
|
+
coverage: {
|
|
40
|
+
historySource: 'sqlite' | 'custom' | 'caller' | 'unknown';
|
|
41
|
+
historyTaskLimit: number | null;
|
|
42
|
+
historyFetchedTasks: number | null;
|
|
43
|
+
historyLimitReached: boolean | null;
|
|
44
|
+
activityLookback: number;
|
|
45
|
+
activityTasks: number;
|
|
46
|
+
activityMaxEntryChars: number;
|
|
47
|
+
activityTruncatedEntries: number;
|
|
48
|
+
};
|
|
49
|
+
command: string;
|
|
50
|
+
rendered: string;
|
|
51
|
+
}
|
|
52
|
+
export interface SemanticContinuityContext {
|
|
53
|
+
highlights: ConversationHighlight[];
|
|
54
|
+
truncatedHighlights?: number;
|
|
55
|
+
omittedTurns: {
|
|
56
|
+
count: number;
|
|
57
|
+
represented: number;
|
|
58
|
+
unrepresented: number;
|
|
59
|
+
taskIds: string[];
|
|
60
|
+
};
|
|
61
|
+
historyLookup?: HistoryLookupNotice;
|
|
62
|
+
rendered?: string;
|
|
63
|
+
omittedRendered: string;
|
|
64
|
+
}
|
|
65
|
+
export type ConversationSemanticContinuityContext = SemanticContinuityContext;
|
|
66
|
+
export interface ConversationThreadStateValue {
|
|
67
|
+
code: string;
|
|
68
|
+
name: string;
|
|
69
|
+
}
|
|
70
|
+
export interface ConversationThreadState {
|
|
71
|
+
title?: string;
|
|
72
|
+
priority?: ConversationThreadStateValue;
|
|
73
|
+
state?: ConversationThreadStateValue;
|
|
74
|
+
rendered?: string;
|
|
75
|
+
}
|
|
76
|
+
export type ThreadStateContext = ConversationThreadState;
|
|
10
77
|
export interface ConversationThread {
|
|
11
78
|
threadId: string;
|
|
12
79
|
platform: Platform;
|
|
13
80
|
messages: ConversationMessage[];
|
|
81
|
+
highlights?: ConversationHighlight[];
|
|
14
82
|
metadata?: {
|
|
15
83
|
title?: string;
|
|
16
84
|
firstMessage?: string;
|
|
@@ -19,27 +87,44 @@ export interface ConversationThread {
|
|
|
19
87
|
updatedAt?: number;
|
|
20
88
|
};
|
|
21
89
|
}
|
|
90
|
+
export interface TemplateAppCard {
|
|
91
|
+
readonly instanceId: string;
|
|
92
|
+
readonly anchorTaskId: string;
|
|
93
|
+
readonly status: 'running' | 'waiting' | 'done' | 'failed' | 'expired';
|
|
94
|
+
readonly result?: 'saved' | 'deferred' | 'cancelled';
|
|
95
|
+
readonly agentId?: string;
|
|
96
|
+
readonly xml: string;
|
|
97
|
+
readonly replacesSlot?: boolean;
|
|
98
|
+
}
|
|
22
99
|
export interface TemplateMessage {
|
|
100
|
+
id?: string;
|
|
23
101
|
text: string;
|
|
24
102
|
isAssistant: boolean;
|
|
103
|
+
taskId?: string;
|
|
25
104
|
timestamp?: number;
|
|
26
105
|
metadata?: Record<string, unknown>;
|
|
106
|
+
activity_log?: string;
|
|
27
107
|
files?: Array<{
|
|
28
108
|
name: string;
|
|
29
109
|
size?: number;
|
|
30
110
|
localPath?: string;
|
|
31
111
|
}>;
|
|
112
|
+
appCard?: TemplateAppCard;
|
|
32
113
|
}
|
|
33
114
|
export interface FetchHistoryOptions {
|
|
34
115
|
limit?: number;
|
|
35
116
|
maxContextLength?: number;
|
|
117
|
+
includeHighlights?: boolean;
|
|
36
118
|
currentTraceId?: string;
|
|
119
|
+
agentId?: string;
|
|
37
120
|
}
|
|
38
121
|
export interface IConversationHistoryProvider {
|
|
39
|
-
ensureThread(threadId: string, platform: Platform, workspaceId?: string): Promise<{
|
|
122
|
+
ensureThread(threadId: string, platform: Platform, workspaceId?: string, creator?: ThreadCreationOptions): Promise<{
|
|
40
123
|
created: boolean;
|
|
41
124
|
}>;
|
|
42
125
|
fetchHistory(threadId: string, options?: FetchHistoryOptions): Promise<ConversationThread>;
|
|
126
|
+
fetchThreadState?(threadId: string): Promise<ConversationThreadState | undefined>;
|
|
127
|
+
fetchHighlights?(threadId: string): Promise<ConversationHighlight[] | undefined>;
|
|
43
128
|
saveUserMessage(threadId: string, text: string, userId?: string, metadata?: Record<string, unknown>): Promise<{
|
|
44
129
|
id: string;
|
|
45
130
|
firstMessage: boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CommandRunner, GlobalCrewxInfo, ShortcutProgressEvent } from './types';
|
|
2
|
+
export interface DetectGlobalCrewxOptions {
|
|
3
|
+
env: NodeJS.ProcessEnv;
|
|
4
|
+
cwd: string;
|
|
5
|
+
run: CommandRunner;
|
|
6
|
+
}
|
|
7
|
+
export declare function detectGlobalCrewx(opts: DetectGlobalCrewxOptions): Promise<GlobalCrewxInfo>;
|
|
8
|
+
export interface EnsureGlobalCrewxOptions {
|
|
9
|
+
env: NodeJS.ProcessEnv;
|
|
10
|
+
cwd: string;
|
|
11
|
+
run: CommandRunner;
|
|
12
|
+
targetVersion: string;
|
|
13
|
+
currentInfo?: GlobalCrewxInfo;
|
|
14
|
+
installRoot?: string;
|
|
15
|
+
onProgress?: (event: ShortcutProgressEvent) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function ensureGlobalCrewx(opts: EnsureGlobalCrewxOptions): Promise<{
|
|
18
|
+
info: GlobalCrewxInfo;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { getShortcutStatus, installShortcut, uninstallShortcut, dismissShortcutNotice, } from './install';
|
|
2
|
+
export { killProcessTree } from './command-runner';
|
|
3
|
+
export { ShortcutError, type ShortcutState, type DesktopSource, type GlobalCrewxInfo, type ShortcutStatus, type ShortcutInstallResult, type ShortcutProgressPhase, type ShortcutProgressEvent, type ShortcutEnvOptions, type InstallShortcutOptions, type ShortcutErrorCode, type CommandResult, type CommandRunner, type CommandRunOptions, type ShortcutFsLike, } from './types';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var m=require('path'),crypto=require('crypto'),fs=require('fs'),os=require('os'),child_process=require('child_process'),string_decoder=require('string_decoder'),module$1=require('module');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var m__namespace=/*#__PURE__*/_interopNamespace(m);var F=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var p=class extends Error{code;constructor(t,n){super(`${t}: ${n}`),this.code=t,this.name="ShortcutError";}};var q={existsSync:e=>fs.existsSync(e),readFileSync:e=>fs.readFileSync(e,"utf8"),readBinaryFileSync:e=>new Uint8Array(fs.readFileSync(e)),writeFileSync:(e,t)=>fs.writeFileSync(e,t,"utf8"),mkdirSync:e=>{fs.mkdirSync(e,{recursive:true});},unlinkSync:e=>{fs.unlinkSync(e);}},Y=os.homedir;function O(e){return typeof e!="string"?void 0:e.trim()||void 0}function L(e){return O(e)?.toLowerCase()??""}function _(e){try{return fs.statSync(e).isFile()}catch{return false}}function Ke(e,t){if(e===t)return true;let n=m__namespace.default.relative(e,t);return n!==""&&!n.startsWith("..")&&!m__namespace.default.isAbsolute(n)}function je(e,t){if(m__namespace.default.basename(e)!==".bin")return false;let n=m__namespace.default.dirname(e);if(m__namespace.default.basename(n)!=="node_modules")return false;let r=m__namespace.default.dirname(n);return Ke(r,t)}function Q(e,t={}){if(e.includes("/")||e.includes("\\")||m__namespace.default.isAbsolute(e))return e;let n=t.platform??process.platform,r=t.env??process.env,o=m__namespace.default.resolve(t.cwd??process.cwd()),c=(t.resolution??"global_first")==="global_first",s=r.PATH??r.Path??process.env.PATH??process.env.Path??"",i=n==="win32"?";":":",a=s.split(i).map(l=>l.trim()).filter(Boolean),u=m__namespace.default.extname(e).length>0,d=r.PATHEXT??r.Pathext??process.env.PATHEXT??process.env.Pathext??".EXE;.CMD;.BAT;.COM",f=n==="win32"?u?[""]:d.split(";").map(l=>l.trim()).filter(Boolean).map(l=>l.startsWith(".")?l:`.${l}`):[""];for(let l of a){let P=m__namespace.default.resolve(o,l);if(!(c&&je(P,o)))for(let h of f){let y=L(h),w=h.toUpperCase();for(let g of [h,y,w]){let C=m__namespace.default.join(P,`${e}${g}`);if(_(C))return C}}}return e}function ze(e){if(!_(e))return null;try{let t=fs.readFileSync(e,"utf8"),n=m__namespace.default.dirname(e),r=[];for(let i of t.matchAll(/"([^"\r\n]*)"/g)){let d=(i[1]??"").match(/%~?dp0%?\s*[\\/]*(.*)$/i)?.[1]?.trim();if(!d)continue;let f=d.replace(/[\\/]+/g,m__namespace.default.sep).replace(/^[\\/]+/,""),l=m__namespace.default.resolve(n,f);_(l)&&r.push(l);}let o=[],c=new Map;for(let i of t.matchAll(/SET\s+"(\w+)=%~?dp0%?[\\/]?([^"]+)"/gi)){let a=i[1].toUpperCase(),u=i[2].trim().replace(/[\\/]+/g,m__namespace.default.sep).replace(/^[\\/]+/,"");c.set(a,m__namespace.default.resolve(n,u));}for(let i of t.split(/\r?\n/))if(i.includes("%*"))for(let a of i.matchAll(/"%(\w+)%"/g)){let u=c.get(a[1].toUpperCase());u&&_(u)&&o.push(u);}let s=i=>i.find(a=>{let u=L(m__namespace.default.basename(a));return u!=="node.exe"&&u!=="node"})??null;return s(o)??s(r)}catch{return null}}function qe(e,t){if(typeof t=="string")return O(t)||null;if(!t||typeof t!="object")return null;if(e){let n=t[e],r=typeof n=="string"?O(n):void 0;if(r)return r}for(let n of Object.values(t)){let r=typeof n=="string"?O(n):void 0;if(r)return r}return null}function Ye(e,t){if(!t)return null;let n=m__namespace.default.dirname(e),r=[m__namespace.default.resolve(n,"..",t),m__namespace.default.resolve(n,"node_modules",t)];for(let o of r){let c=m__namespace.default.join(o,"package.json");if(_(c))try{let s=JSON.parse(fs.readFileSync(c,"utf8")),i=qe(t,s.bin);if(!i)continue;let a=m__namespace.default.resolve(o,i);if(_(a))return a}catch{}}return null}function Qe(e){let t=e.platform??process.platform,n=e.env??process.env,r=e.execPath??process.execPath,o=e.cwd,c=e.resolution;if(t!=="win32")return {command:Q(e.command,{cwd:o,env:n,platform:t,resolution:c}),leadingArgv:[],resolution:"direct"};let s=Q(e.command,{cwd:o,env:n,platform:t,resolution:c}),i=L(m__namespace.default.extname(s));if(i===".js"||i===".cjs"||i===".mjs")return {command:r,leadingArgv:[s],resolution:"node-entrypoint",windowsHide:true};if(i===".cmd"||i===".bat"){let a=ze(s)??Ye(s,e.packageName);return a?L(m__namespace.default.extname(a))===".exe"?{command:a,leadingArgv:[],resolution:"exe-entrypoint",windowsHide:true}:{command:r,leadingArgv:[a],resolution:"node-entrypoint",windowsHide:true}:{command:s,leadingArgv:[],resolution:"unresolved-wrapper"}}return {command:s,leadingArgv:[],resolution:"direct",windowsHide:true}}function Ze(e){if(e.candidate.resolution!=="unresolved-wrapper")return {command:e.candidate.command,leadingArgv:e.candidate.leadingArgv,resolution:e.candidate.resolution,windowsHide:e.candidate.windowsHide};throw new Error(`${m__namespace.default.basename(e.candidate.command)} wrapper resolved, but no executable/Node entrypoint could be resolved without shell execution.`)}function ee(e){let t=Qe(e);return Ze({candidate:t})}function te(e,t){return {command:e.command,argv:[...e.leadingArgv,...t],resolution:e.resolution,shell:e.shell,windowsHide:e.windowsHide}}var D="\uFFFD",B=8,re=1e3,tt=new Map([[437,"ibm437"],[720,"ibm720"],[737,"ibm737"],[775,"ibm775"],[850,"ibm850"],[852,"ibm852"],[855,"ibm855"],[857,"ibm857"],[858,"ibm858"],[862,"ibm862"],[864,"ibm864"],[932,"shift_jis"],[936,"gb18030"],[949,"euc-kr"],[950,"big5"],[866,"ibm866"],[869,"ibm869"],[1250,"windows-1250"],[1251,"windows-1251"],[1252,"windows-1252"],[1253,"windows-1253"],[1254,"windows-1254"],[1255,"windows-1255"],[1256,"windows-1256"],[1257,"windows-1257"],[1258,"windows-1258"]]),T;function U(e){let t=0;for(let n of e)n===D&&(t+=1);return t}function $(e,t){return U(t)<U(e)?t:e}function nt(e){let t=e.match(/(?:^|[^0-9])([0-9]{1,5})(?![0-9])/);if(!t)return null;let n=Number(t[1]);return Number.isInteger(n)&&n>0&&n<=65535?n:null}function rt(e){if(e!==65001)return tt.get(e)}function ot(e){let t=rt(e);if(!t)return null;try{return new TextDecoder(t)}catch{return null}}function st(){return new Promise(e=>{let t=false,n,r=o=>{t||(t=true,n&&clearTimeout(n),e(o));};n=setTimeout(()=>r(null),re),n.unref();try{child_process.execFile("chcp.com",[],{encoding:"ascii",timeout:re,windowsHide:!0},(c,s)=>{if(c){r(null);return}r(nt(String(s)));}).once("error",()=>r(null));}catch{r(null);}})}function ie(){return process.platform!=="win32"?Promise.resolve(null):(T||(T=st(),T.then(e=>{},()=>{})),T)}function it(){process.platform==="win32"&&ie();}function se(e,t){if(t.length>=B)return t.subarray(t.length-B);let n=B-t.length,r=e.length>n?e.subarray(e.length-n):e;return Buffer.concat([r,t])}var b=class{platform;detectCodePage;utf8Decoder=new string_decoder.StringDecoder("utf8");codePage;fallbackDecoder;replayTail=Buffer.alloc(0);pendingUtf8="";pendingFallback="";pendingBytes=Buffer.alloc(0);queue=Promise.resolve();ended=false;constructor(t={}){this.platform=t.platform??process.platform,this.detectCodePage=t.detectCodePage??ie,this.codePage=t.codePage;}write(t){let n=Buffer.from(t);return this.enqueue(()=>this.decodeChunk(n))}end(){return this.enqueue(()=>this.finish())}enqueue(t){let n=this.queue.then(t);return this.queue=n.then(()=>{},()=>{}),n}clearPendingCandidate(){this.pendingUtf8="",this.pendingFallback="",this.pendingBytes=Buffer.alloc(0);}async resolveCodePage(){if(this.codePage!==void 0)return this.codePage;try{this.codePage=await this.detectCodePage();}catch{this.codePage=null;}return this.codePage}async getFallbackDecoder(){if(this.fallbackDecoder!==void 0)return this.fallbackDecoder;let t=await this.resolveCodePage();return this.fallbackDecoder=t===null?null:ot(t),this.fallbackDecoder}async decodeChunk(t){if(this.ended)return "";let n=this.utf8Decoder.write(t),r=n.includes(D);if(r&&(this.utf8Decoder=new string_decoder.StringDecoder("utf8")),this.platform!=="win32")return n;if(this.fallbackDecoder){let a=this.fallbackDecoder.decode(t,{stream:true}),u=se(this.pendingBytes,t);if(r){let d=this.pendingUtf8+n,f=this.pendingFallback+a;return this.clearPendingCandidate(),$(d,f)}if(U(a)>0){let d=this.pendingUtf8+n;return this.clearPendingCandidate(),this.fallbackDecoder=void 0,this.replayTail=u,d}if(this.pendingUtf8||this.pendingFallback){if(this.pendingUtf8+=n,this.pendingFallback+=a,this.pendingBytes=u,n.length===0||a.length===0)return "";let d=this.pendingUtf8;return this.clearPendingCandidate(),d}return n.length===0&&a.length>0?(this.pendingUtf8=n,this.pendingFallback=a,this.pendingBytes=u,""):n}let o=this.replayTail;if(this.fallbackDecoder===void 0&&(this.replayTail=se(this.replayTail,t)),!r)return n;let c=this.fallbackDecoder===void 0,s=await this.getFallbackDecoder();if(!s)return this.replayTail=Buffer.alloc(0),n;c&&o.length>0&&s.decode(o,{stream:true}),this.replayTail=Buffer.alloc(0);let i=s.decode(t,{stream:true});return $(n,i)}async finish(){if(this.ended)return "";this.ended=true;let t=this.utf8Decoder.end();if(this.platform!=="win32")return t;if(this.fallbackDecoder===void 0&&t.includes(D)){let c=await this.getFallbackDecoder();c&&this.replayTail.length>0&&(c.decode(this.replayTail,{stream:true}),this.replayTail=Buffer.alloc(0));}let n=this.pendingUtf8+t,r=this.fallbackDecoder?.decode()??"",o=this.pendingFallback+r;return this.clearPendingCandidate(),n.includes(D)?$(n,o):n}};it();var ae=3e3;var ct=2e3,ut=25,lt=100;function le(e){return e instanceof Error?e:e===void 0?void 0:new Error(String(e))}function ce(e){return typeof e=="object"&&e!==null&&"code"in e?String(e.code):void 0}function dt(e){return Number.isSafeInteger(e)&&e>0}function ft(e,t){return new Promise(n=>{let r;try{r=child_process.spawn(e,t,{windowsHide:!0});}catch(u){n({status:null,stdout:"",stderr:"",error:le(u)});return}let o="",c="",s=false,i,a=setTimeout(()=>{try{r.kill();}catch{}i({status:null,stdout:o,stderr:c,error:new Error(`Command timed out after ${ae}ms`)});},ae);i=u=>{s||(s=true,clearTimeout(a),n(u));},r.stdout?.setEncoding("utf8"),r.stderr?.setEncoding("utf8"),r.stdout?.on("data",u=>{o+=String(u);}),r.stderr?.on("data",u=>{c+=String(u);}),r.once("error",u=>{i({status:null,stdout:o,stderr:c,error:u});}),r.once("close",u=>{i({status:u,stdout:o,stderr:c});});})}async function mt(e,t,n){return n.runCommandAsync?n.runCommandAsync(e,t):n.runCommand?n.runCommand(e,t):ft(e,t)}function pt(e){return new Promise(t=>{setTimeout(t,Math.max(0,e));})}function ht(){return new Promise(e=>{setImmediate(e);})}function A(e,t=process.kill){try{return t(e,0),"alive"}catch(n){return ce(n)==="ESRCH"?"not_found":ce(n)==="EPERM"?"alive":"unknown"}}function wt(e,t){let n=A(-e,t),r=A(e,t);return n==="alive"||r==="alive"?"alive":n==="unknown"||r==="unknown"?"unknown":"not_found"}async function de(e,t,n,r){let o=Math.max(0,n),c=Math.max(1,r.pollIntervalMs??ut),s=Date.now()+o,i,a=o===0,u=r.sleep?Promise.resolve().then(()=>r.sleep(o)).then(()=>{},()=>{}):new Promise(d=>{i=setTimeout(d,o);});u.then(()=>{a=true;});try{for(await ht();;){let d=wt(e,t);if(d==="not_found")return d;let f=s-Date.now();if(a||f<=0)return d;await Promise.race([u,pt(Math.min(c,f))]);}}finally{i!==void 0&&clearTimeout(i);}}async function ue(e,t,n,r,o){let c=await de(e,t,o.hardConfirmMs??lt,{...o,sleep:void 0});return c==="not_found"?n?{status:"not_found",pid:e,method:r}:{status:"terminated",pid:e,method:r}:c==="alive"?{status:"failed",pid:e,method:r,error:"Process is still running after termination attempt"}:{status:"failed",pid:e,method:r,error:"Unable to verify process termination"}}async function fe(e,t={}){let n=t.platform??process.platform,r=n==="win32"?"taskkill":"process-group",o=l=>({status:"failed",pid:e,method:r,error:l});if(!dt(e))return o("Invalid process ID");let c=t.kill??process.kill,s=A(e,c);if(s==="not_found")return {status:"not_found",pid:e,method:r};if(s!=="alive")return o("Unable to determine whether the process is alive");if(n==="win32"){let l;try{l=await mt("taskkill",["/PID",String(e),"/T","/F"],t);}catch(h){l={status:null,stdout:"",stderr:"",error:le(h)};}let P=A(e,c);return P==="not_found"?l.status===0&&!l.error?{status:"terminated",pid:e,method:r}:{status:"not_found",pid:e,method:r}:o(P==="alive"?"Process is still running after termination attempt":"Unable to verify process termination")}let i,a=t.signal??"SIGKILL";try{c(-e,a);}catch(l){i=l;}if(a==="SIGKILL")return ue(e,c,i,r,t);if(await de(e,c,t.graceMs??ct,t)==="not_found")return i?{status:"not_found",pid:e,method:r}:{status:"terminated",pid:e,method:r};let d;try{c(-e,"SIGKILL");}catch(l){d=l;}let f=await ue(e,c,d,r,t);return f.status==="terminated"?f:f.status==="not_found"?i?f:{status:"terminated",pid:e,method:r}:o(f.error??"Process termination failed")}var gt=["CREWX_ASSIGNED_TASK_ID","CREWX_DETACHED_RUNNER"];function Pt(e,t){let n={};for(let[r,o]of Object.entries(e))o!==void 0&&(t.includes(r)||(n[r]=o));return n}function me(e){return Pt(e,gt)}var pe=3e4;function he(e){if(typeof e.pid!="number"){try{e.kill();}catch{}return}fe(e.pid,{signal:"SIGKILL"}).then(t=>{if(t.status==="failed")try{e.kill("SIGKILL");}catch{}},()=>{try{e.kill("SIGKILL");}catch{}});}var we=(e,t,n={})=>new Promise((r,o)=>{let c=me(n.env??process.env),s=process.platform,i;try{let g=ee({command:e,platform:s,env:c,cwd:n.cwd,allowShellFallback:!1});i=te(g,t);}catch(g){o(g instanceof Error?g:new Error(String(g)));return}let a=child_process.spawn(i.command,i.argv,{cwd:n.cwd,env:c,shell:i.shell,windowsHide:i.windowsHide??true,detached:s!=="win32"}),u="",d="",f=false,l=new b({platform:s}),P=new b({platform:s}),h=Promise.resolve(),y=Promise.resolve(),w=setTimeout(()=>{f||(f=true,he(a),o(new Error(`Command timed out after ${n.timeoutMs??pe}ms: ${e} ${t.join(" ")}`)));},n.timeoutMs??pe);a.stdout?.on("data",g=>{h=h.then(async()=>{u+=await l.write(g);});}),a.stderr?.on("data",g=>{y=y.then(async()=>{d+=await P.write(g);});}),a.on("error",g=>{f||(f=true,clearTimeout(w),o(g));}),a.on("close",g=>{f||(async()=>{await Promise.all([h,y]);let[C,Be]=await Promise.all([l.end(),P.end()]);f||(u+=C,d+=Be,f=true,clearTimeout(w),r({code:g??0,stdout:u,stderr:d}));})().catch(C=>{f||(f=true,clearTimeout(w),o(C instanceof Error?C:new Error(String(C))));});});});function Ct(){try{return (typeof F=="function"?F:module$1.createRequire(__filename)).resolve("@crewx/sdk/package.json")}catch{return null}}function Rt(){let e=[Ct(),m.join(__dirname,"../../package.json"),m.join(__dirname,"../../../package.json")].filter(t=>!!t);for(let t of e)try{let n=JSON.parse(fs.readFileSync(t,"utf8"));if(n.name==="@crewx/sdk"&&n.version)return n.version}catch{}return "0.0.0"}var Pe=Rt();var E=m__namespace.win32;function H(e){return E.join(e,".crewx")}function Ee(e){return E.join(H(e),"shortcut.json")}function ye(e){return E.join(H(e),"launcher.json")}function Ce(e){return E.join(H(e),"bin","crewx-launcher.cmd")}function Re(e){return E.join(e,"CrewX.lnk")}function V(e,t){return E.normalize(e).toLowerCase()===E.normalize(t).toLowerCase()}var vt="[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; [Environment]::GetFolderPath('DesktopDirectory')";async function ve(e){try{let n=await e.run("powershell",["-NoProfile","-NonInteractive","-Command",vt],{env:e.env}),r=n.stdout.trim();if(n.code===0&&r)return {dir:r,source:"known-folder"}}catch{}let t=e.env.USERPROFILE||e.env.Userprofile||e.homedir();return t?{dir:E.join(t,"Desktop"),source:"fallback"}:null}function X(e,t){let n=E.resolve(t,"node_modules",".bin").toLowerCase();return e.split(";").filter(r=>r?E.resolve(r).toLowerCase()!==n:true).join(";")}function _e(e){return e?/\\Program Files( \(x86\))?\\/i.test(e)&&/crewx/i.test(e):false}function _t(e,t){let n=a=>{let[u,...d]=a.split("-"),f=d.join("-")||void 0;return {parts:(u??"").split(".").map(P=>Number.parseInt(P,10)||0),pre:f}},r=n(e),o=n(t),c=Math.max(r.parts.length,o.parts.length);for(let a=0;a<c;a++){let u=r.parts[a]??0,d=o.parts[a]??0;if(u!==d)return u<d?-1:1}if(r.pre===o.pre)return 0;if(!r.pre&&o.pre)return 1;if(r.pre&&!o.pre)return -1;let s=Number.parseInt(r.pre.match(/(\d+)$/)?.[1]??"",10),i=Number.parseInt(o.pre.match(/(\d+)$/)?.[1]??"",10);return !Number.isNaN(s)&&!Number.isNaN(i)&&s!==i?s<i?-1:1:r.pre<o.pre?-1:r.pre>o.pre?1:0}function k(e,t){return _t(e,t)<0}var ke=m__namespace.win32,xe=1;function Ne(e,t){if(!e.existsSync(t))return null;try{let n=JSON.parse(e.readFileSync(t));return {schema:n.schema??xe,shortcutPath:n.shortcutPath,version:n.version,iconHash:typeof n.iconHash=="string"?n.iconHash:void 0,owned:!!n.owned,declined:!!n.declined,desktopSource:n.desktopSource,updatedAt:n.updatedAt}}catch{return null}}function M(e,t,n){let r={schema:xe,...n,updatedAt:new Date().toISOString()};e.mkdirSync(ke.dirname(t)),e.writeFileSync(t,JSON.stringify(r,null,2));}function W(e,t){if(!e.existsSync(t))return null;try{let n=JSON.parse(e.readFileSync(t));return {schema:n.schema??0,binPath:n.binPath,updatedAt:n.updatedAt}}catch{return null}}function Ie(e,t,n){e.mkdirSync(ke.dirname(t)),e.writeFileSync(t,JSON.stringify(n,null,2));}var bt=m__namespace.win32,x=1;function kt(e){return e.replace(/%/g,"%%")}function xt(e){return ["@echo off","setlocal DisableDelayedExpansion","chcp 65001 >nul","",'set "CREWX_WORKDIR=%USERPROFILE%\\crewx"','if not exist "%CREWX_WORKDIR%" mkdir "%CREWX_WORKDIR%" >nul 2>nul','cd /d "%CREWX_WORKDIR%"',"",'set "CREWX_PORT_EFFECTIVE=%CREWX_PORT%"','if "%CREWX_PORT_EFFECTIVE%"=="" set "CREWX_PORT_EFFECTIVE=8150"','set "CREWX_HEALTH_URL=http://127.0.0.1:%CREWX_PORT_EFFECTIVE%/api/v1/health"','set "CREWX_ORIGIN_URL=http://127.0.0.1:%CREWX_PORT_EFFECTIVE%/"',"",e.bakedBinPath?`set "CREWX_FALLBACK_BIN=${kt(e.bakedBinPath)}"`:'set "CREWX_FALLBACK_BIN="','set "CREWX_RESOLVED_BIN=%CREWX_BIN%"','if "%CREWX_RESOLVED_BIN%"=="" set "CREWX_RESOLVED_BIN=%CREWX_FALLBACK_BIN%"','if "%CREWX_RESOLVED_BIN%"=="" (',` for /f "delims=" %%I in ('where crewx 2^>nul') do (`,' if not defined CREWX_RESOLVED_BIN set "CREWX_RESOLVED_BIN=%%I"'," )",")","",'powershell -NoProfile -NonInteractive -Command "try { $r = Invoke-WebRequest -Uri $env:CREWX_HEALTH_URL -TimeoutSec 1 -UseBasicParsing; if ($r.StatusCode -eq 200) { exit 0 } else { exit 1 } } catch { exit 1 }"',"if %ERRORLEVEL% EQU 0 (",' start "" "%CREWX_ORIGIN_URL%"'," exit /b 0",")","",'if "%CREWX_RESOLVED_BIN%"=="" ('," echo CrewX executable not found. Please reinstall the desktop shortcut."," pause"," exit /b 1",")","",'start "CrewX" /min "%CREWX_RESOLVED_BIN%"',""].join(`\r
|
|
2
|
+
`)}function Le(e){let t=W(e.fs,e.launcherManifestPath),n=!!t&&t.schema>=x&&e.fs.existsSync(e.wrapperPath),r=n&&!t.binPath&&!!e.bakedBinPath;if(n&&!r)return {wrapperPath:e.wrapperPath,wrote:false,schema:t.schema};let c=xt({bakedBinPath:e.bakedBinPath});try{e.fs.mkdirSync(bt.dirname(e.wrapperPath)),e.fs.writeFileSync(e.wrapperPath,c),Ie(e.fs,e.launcherManifestPath,{schema:x,binPath:e.bakedBinPath,updatedAt:new Date().toISOString()});}catch(s){throw s instanceof p?s:new p("WRITE_DENIED",`Could not write launcher wrapper: ${s instanceof Error?s.message:String(s)}`)}return {wrapperPath:e.wrapperPath,wrote:true,schema:x}}var Nt=["$ws = New-Object -ComObject WScript.Shell","$sc = $ws.CreateShortcut($env:CREWX_LNK_PATH)","$sc.TargetPath = $env:CREWX_LNK_TARGET","if ($env:CREWX_LNK_WORKDIR) { $sc.WorkingDirectory = $env:CREWX_LNK_WORKDIR }","$sc.WindowStyle = 7","if ($env:CREWX_LNK_ICON) { $sc.IconLocation = $env:CREWX_LNK_ICON }","$sc.Save()"].join("; "),It=["[Console]::OutputEncoding = [System.Text.Encoding]::UTF8","$ws = New-Object -ComObject WScript.Shell","$sc = $ws.CreateShortcut($env:CREWX_LNK_PATH)","[PSCustomObject]@{ TargetPath = $sc.TargetPath; WorkingDirectory = $sc.WorkingDirectory; IconLocation = $sc.IconLocation } | ConvertTo-Json -Compress"].join("; ");async function Te(e){let t={...e.env,CREWX_LNK_PATH:e.shortcutPath,CREWX_LNK_TARGET:e.targetPath,CREWX_LNK_WORKDIR:e.workingDirectory??"",CREWX_LNK_ICON:e.iconPath??""},n;try{n=await e.run("powershell",["-NoProfile","-NonInteractive","-Command",Nt],{env:t});}catch(r){throw new p("POWERSHELL_UNAVAILABLE",`Could not run PowerShell: ${r instanceof Error?r.message:String(r)}`)}if(n.code!==0)throw new p("POWERSHELL_UNAVAILABLE",`Failed to create desktop shortcut: ${n.stderr||n.stdout}`)}function De(e){let t=e.trim(),n=t.lastIndexOf(",");return n!==-1&&/^-?\d+$/.test(t.slice(n+1).trim())&&(t=t.slice(0,n).trim()),t.length>=2&&t.startsWith('"')&&t.endsWith('"')&&(t=t.slice(1,-1).trim()),t}async function Ae(e){try{let t={...e.env,CREWX_LNK_PATH:e.shortcutPath},n=await e.run("powershell",["-NoProfile","-NonInteractive","-Command",It],{env:t});if(n.code!==0||!n.stdout.trim())return null;let r=JSON.parse(n.stdout.trim());return {targetPath:r.TargetPath??"",workingDirectory:r.WorkingDirectory??"",iconLocation:r.IconLocation??""}}catch{return null}}var K=m__namespace.win32;async function N(e){let t=X(e.env.PATH??e.env.Path??"",e.cwd),n={...e.env,PATH:t,Path:t},r;try{r=await e.run("npm",["list","-g","crewx","--depth=0","--json"],{env:n});}catch{return {installed:false}}let o;try{o=JSON.parse(r.stdout||"{}");}catch{return {installed:false}}let c=o.dependencies?.crewx;if(!c?.version)return {installed:false};let s;try{let a=await e.run("npm",["prefix","-g"],{env:n});a.code===0&&(s=a.stdout.trim()||void 0);}catch{}let i=s?K.join(s,"crewx.cmd"):void 0;return {installed:true,version:c.version,binPath:i,prefix:s}}var Ot=/EACCES|EPERM|EROFS/,Lt=/ENOTFOUND|ETIMEDOUT|ECONNREFUSED|network|registry/i,Tt=/^\d+\.\d+\.\d+/;function Dt(e){return !!e&&e!=="0.0.0"&&Tt.test(e)}var J=10*6e4;async function We(e){if(!Dt(e.targetVersion))throw new p("GLOBAL_INSTALL_FAILED",`RUNNING_VERSION_UNKNOWN: cannot reliably determine the running crewx version to install (got ${JSON.stringify(e.targetVersion)}); refusing to fall back to crewx@latest`);if(e.currentInfo?.installed&&e.currentInfo.version&&!k(e.currentInfo.version,e.targetVersion))return {info:e.currentInfo};let t=X(e.env.PATH??e.env.Path??"",e.cwd),n={...e.env,PATH:t,Path:t},r=`crewx@${e.targetVersion}`;e.onProgress?.({phase:"global-install",message:`Installing crewx globally (npm install -g ${r})`});let o;try{o=await e.run("npm",["install","-g",r,"--no-audit","--no-fund"],{env:n,timeoutMs:J});}catch(s){throw new p("NPM_UNAVAILABLE",`Could not run npm: ${s instanceof Error?s.message:String(s)}`)}if(o.code===0)return {info:await N({env:n,cwd:e.cwd,run:e.run})};let c=`${o.stdout}
|
|
3
|
+
${o.stderr}`;if(Ot.test(c)){e.onProgress?.({phase:"global-install",message:"Permission denied \u2014 retrying with a user-scoped npm prefix"});let s=e.env.LOCALAPPDATA||K.join(e.env.USERPROFILE??"","AppData","Local"),i={...n,npm_config_prefix:K.join(s,"crewx","npm")},a;try{a=await e.run("npm",["install","-g",r,"--no-audit","--no-fund"],{env:i,timeoutMs:J});}catch(u){throw new p("NPM_PERMISSION_DENIED",`Retry with user-scoped prefix failed: ${u instanceof Error?u.message:String(u)}`)}if(a.code===0)return {info:await N({env:i,cwd:e.cwd,run:e.run})};throw new p("NPM_PERMISSION_DENIED",`npm install -g failed after user-scoped prefix retry: ${a.stderr||a.stdout}`)}if(Lt.test(c)){if(!e.installRoot)throw new p("OFFLINE_NO_SOURCE","The npm registry is unreachable and no local installRoot was provided for an offline install");e.onProgress?.({phase:"global-install",message:`Registry unreachable \u2014 installing offline from ${e.installRoot}`});let s;try{s=await e.run("npm",["install","-g",e.installRoot,"--offline","--no-audit","--no-fund"],{env:n,timeoutMs:J});}catch(i){throw new p("GLOBAL_INSTALL_FAILED",`Offline install failed: ${i instanceof Error?i.message:String(i)}`)}if(s.code===0)return {info:await N({env:n,cwd:e.cwd,run:e.run})};throw new p("GLOBAL_INSTALL_FAILED",`Offline install failed: ${s.stderr||s.stdout}`)}throw new p("GLOBAL_INSTALL_FAILED",c.trim()||`npm install -g ${r} failed`)}function Mt(e){return e.run??we}function Wt(e){return e.fs??q}async function G(e){let t=e.platform??process.platform,n=e.env??process.env,r=e.homedir??Y,o=Mt(e),c=Wt(e),s=e.runningVersion??Pe,i=e.cwd??process.cwd(),a=r(),u=Ee(a),d=ye(a),f=Ce(a),l=null;t==="win32"&&(l=await ve({env:n,homedir:r,run:o}));let P=l?Re(l.dir):null;return {platform:t,env:n,homedir:r,run:o,fs:c,runningVersion:s,cwd:i,installRoot:e.installRoot,shortcutManifestPath:u,launcherManifestPath:d,wrapperPath:f,desktop:l,shortcutPath:P}}function Ge(e){return e?m__namespace.win32.normalize(e).toLowerCase().endsWith(`${m__namespace.win32.sep}bin${m__namespace.win32.sep}crewx.ico`):false}function j(e,t){let n=e.readBinaryFileSync;if(n)try{return crypto.createHash("sha256").update(n(t)).digest("hex")}catch{return}}async function Gt(e){try{await e.run("ie4uinit.exe",["-show"],{env:e.env});}catch{}}async function R(e){if(e.platform!=="win32")return {supported:false,state:"unsupported",globalCrewx:null,runningVersion:e.runningVersion,errors:[],manifest:null,iconStale:false};let t=[];e.desktop||t.push("NO_DESKTOP_DIR: could not resolve the Windows Desktop directory");let n=Ne(e.fs,e.shortcutManifestPath),r=W(e.fs,e.launcherManifestPath),o=await N({env:e.env,cwd:e.cwd,run:e.run}),c=e.shortcutPath?e.fs.existsSync(e.shortcutPath):false,s,i=false,a,u;if(!c)s=n?.declined?"declined":"not-installed";else {let d=!!n?.owned&&!!e.shortcutPath&&n.shortcutPath===e.shortcutPath,f=false,l=e.shortcutPath?await Ae({run:e.run,env:e.env,shortcutPath:e.shortcutPath}):null;if(d||(l&&V(l.targetPath,e.wrapperPath)?d=true:l&&_e(l.targetPath)&&(f=true)),f)s="foreign",t.push("NSIS_PRESENT: an NSIS-installed CrewX shortcut was detected");else if(!d)s="foreign";else if(n?.version&&k(e.runningVersion,n.version))s="superseded",t.push(`SUPERSEDED: running version ${e.runningVersion} is older than the installed shortcut's version ${n.version}; refusing to modify it`);else {let P=!r||r.schema<x||!e.fs.existsSync(e.wrapperPath);if(l){let h=De(l.iconLocation);if(!(!!h&&e.fs.existsSync(h)))i=true;else {a=h;let w=Fe(o,e.fs);w?V(h,w)?(u=j(e.fs,h),i=!u||n?.iconHash!==u):i=true:Ge(h)?(u=j(e.fs,h),i=!u||n?.iconHash!==u):i=true;}}s=P||i?"stale":"installed";}}return {supported:true,state:s,shortcutPath:e.shortcutPath??void 0,desktopDir:e.desktop?.dir,desktopSource:e.desktop?.source,wrapperPath:e.wrapperPath,wrapperSchema:r?.schema,globalCrewx:o.installed?o:{installed:false},runningVersion:e.runningVersion,errors:t,manifest:n,iconStale:i,iconPath:a,iconHash:u}}function Fe(e,t){if(!e?.installed||!e.prefix)return;let n=m__namespace.win32.join(e.prefix,"node_modules","crewx","bin","crewx.ico");return t.existsSync(n)?n:void 0}function v(e){let{manifest:t,iconStale:n,iconPath:r,iconHash:o,...c}=e;return c}async function Ft(e={}){let t=await G(e),n=await R(t);return v(n)}async function Bt(e={}){let t=await G(e);e.onProgress?.({phase:"detect",message:"Checking current shortcut status"});let n=await R(t),r=v(n);if(!r.supported)return {...r,changed:false,installedGlobal:false};if(r.state==="superseded")return {...r,changed:false,installedGlobal:false};if(r.state==="foreign"){if(n.errors.some(w=>w.startsWith("NSIS_PRESENT")))throw new p("NSIS_PRESENT",`An NSIS-installed CrewX shortcut was detected at ${r.shortcutPath}`);if(!e.force)throw new p("FOREIGN_SHORTCUT",`An existing shortcut at ${r.shortcutPath} is not managed by CrewX`)}if(!t.desktop||!t.shortcutPath)throw new p("NO_DESKTOP_DIR","Could not resolve the Windows Desktop directory");let o=false,c=false,s=r.globalCrewx,i=[],a=n.manifest?.iconHash,u=false;if(!!s?.installed&&!!s.version&&k(s.version,t.runningVersion)||!s?.installed&&r.state!=="installed"){let w=await We({env:t.env,cwd:t.cwd,run:t.run,targetVersion:t.runningVersion,currentInfo:s??void 0,installRoot:t.installRoot,onProgress:e.onProgress});s=w.info,c=w.info.installed,o=true,c||i.push(`GLOBAL_INSTALL_UNCONFIRMED: npm install -g crewx@${t.runningVersion} exited successfully but a follow-up check could not confirm the global install`);}if(e.onProgress?.({phase:"wrapper",message:"Ensuring launcher wrapper"}),Le({fs:t.fs,wrapperPath:t.wrapperPath,launcherManifestPath:t.launcherManifestPath,bakedBinPath:s?.binPath}).wrote&&(o=true),!((r.state==="installed"||r.state==="stale")&&!n.iconStale)){let w=Fe(s,t.fs)??(n.iconPath&&Ge(n.iconPath)&&t.fs.existsSync(n.iconPath)?n.iconPath:void 0);if(n.iconStale&&!w)throw new p("ICON_UNAVAILABLE",`Could not locate the global CrewX icon (bin\\crewx.ico) to repair the desktop shortcut at ${t.shortcutPath}; the existing shortcut was left untouched`);e.onProgress?.({phase:"lnk",message:"Creating desktop shortcut"}),await Te({run:t.run,env:t.env,shortcutPath:t.shortcutPath,targetPath:t.wrapperPath,iconPath:w}),o=true,u=n.iconStale;let g=w?j(t.fs,w):void 0;g&&(a=g);}o&&M(t.fs,t.shortcutManifestPath,{shortcutPath:t.shortcutPath,version:t.runningVersion,owned:true,declined:false,desktopSource:t.desktop.source,iconHash:a}),u&&await Gt(t);let h=await R(t),y=v(h);return {...y,errors:[...y.errors,...i],changed:o,installedGlobal:c}}async function $t(e={}){let t=await G(e),n=await R(t),r=v(n);if(!r.supported)return r;if((r.state==="installed"||r.state==="stale")&&t.shortcutPath)try{t.fs.unlinkSync(t.shortcutPath);}catch{}M(t.fs,t.shortcutManifestPath,{shortcutPath:void 0,version:n.manifest?.version,owned:false,declined:true,desktopSource:void 0,iconHash:void 0});let o=await R(t);return v(o)}async function Ut(e={}){let t=await G(e),n=await R(t),r=v(n);if(!r.supported)return r;M(t.fs,t.shortcutManifestPath,{shortcutPath:n.manifest?.shortcutPath,version:n.manifest?.version,owned:n.manifest?.owned??false,declined:true,desktopSource:n.manifest?.desktopSource,iconHash:n.manifest?.iconHash});let o=await R(t);return v(o)}exports.ShortcutError=p;exports.dismissShortcutNotice=Ut;exports.getShortcutStatus=Ft;exports.installShortcut=Bt;exports.killProcessTree=he;exports.uninstallShortcut=$t;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type InstallShortcutOptions, type ShortcutEnvOptions, type ShortcutInstallResult, type ShortcutStatus } from './types';
|
|
2
|
+
export declare function getShortcutStatus(options?: ShortcutEnvOptions): Promise<ShortcutStatus>;
|
|
3
|
+
export declare function installShortcut(options?: InstallShortcutOptions): Promise<ShortcutInstallResult>;
|
|
4
|
+
export declare function uninstallShortcut(options?: ShortcutEnvOptions): Promise<ShortcutStatus>;
|
|
5
|
+
export declare function dismissShortcutNotice(options?: ShortcutEnvOptions): Promise<ShortcutStatus>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CommandRunner } from './types';
|
|
2
|
+
export interface WriteLnkOptions {
|
|
3
|
+
run: CommandRunner;
|
|
4
|
+
env: NodeJS.ProcessEnv;
|
|
5
|
+
shortcutPath: string;
|
|
6
|
+
targetPath: string;
|
|
7
|
+
workingDirectory?: string;
|
|
8
|
+
iconPath?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function writeLnk(opts: WriteLnkOptions): Promise<void>;
|
|
11
|
+
export interface LnkInfo {
|
|
12
|
+
targetPath: string;
|
|
13
|
+
workingDirectory: string;
|
|
14
|
+
iconLocation: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ReadLnkOptions {
|
|
17
|
+
run: CommandRunner;
|
|
18
|
+
env: NodeJS.ProcessEnv;
|
|
19
|
+
shortcutPath: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function normalizeIconLocation(raw: string): string;
|
|
22
|
+
export declare function readLnkTarget(opts: ReadLnkOptions): Promise<LnkInfo | null>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DesktopSource, ShortcutFsLike } from './types';
|
|
2
|
+
export declare const MANIFEST_SCHEMA_VERSION = 1;
|
|
3
|
+
export interface ShortcutManifest {
|
|
4
|
+
schema: number;
|
|
5
|
+
shortcutPath?: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
iconHash?: string;
|
|
8
|
+
owned: boolean;
|
|
9
|
+
declined: boolean;
|
|
10
|
+
desktopSource?: DesktopSource;
|
|
11
|
+
updatedAt?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface LauncherManifest {
|
|
14
|
+
schema: number;
|
|
15
|
+
binPath?: string;
|
|
16
|
+
updatedAt?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function readShortcutManifest(fs: ShortcutFsLike, manifestPath: string): ShortcutManifest | null;
|
|
19
|
+
export declare function writeShortcutManifest(fs: ShortcutFsLike, manifestPath: string, data: Omit<ShortcutManifest, 'schema' | 'updatedAt'>): void;
|
|
20
|
+
export declare function readLauncherManifest(fs: ShortcutFsLike, manifestPath: string): LauncherManifest | null;
|
|
21
|
+
export declare function writeLauncherManifest(fs: ShortcutFsLike, manifestPath: string, data: LauncherManifest): void;
|