@crewx/sdk 0.9.0-rc.17 → 0.9.0-rc.170
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.d.ts +167 -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 +18 -0
- package/dist/app/index.js +12 -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/boxing/box.types.d.ts +4 -0
- package/dist/config/canonicalize-agent-options.d.ts +18 -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 +37 -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-budget/continuity.d.ts +63 -0
- package/dist/context-budget/index.d.ts +142 -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 +58 -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 +12 -0
- package/dist/esm/app-artifact-policy/index.js +18 -0
- package/dist/esm/desktop/index.js +3 -0
- package/dist/esm/index.js +1175 -224
- package/dist/esm/node/index.js +2 -0
- package/dist/esm/plugins/index.js +527 -214
- package/dist/esm/process/index.js +1 -0
- package/dist/esm/publish/index.js +2 -0
- package/dist/esm/repository/index.js +648 -211
- package/dist/esm/skills/index.js +2 -0
- package/dist/esm/testing/index.js +1 -1
- package/dist/events/types.d.ts +28 -0
- package/dist/facade/Crewx.d.ts +70 -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/index.browser.d.ts +25 -1
- package/dist/index.browser.js +6 -2
- package/dist/index.d.ts +157 -17
- package/dist/index.js +1175 -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 +82 -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 +26 -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 +45 -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 +488 -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 +75 -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/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/_journal.json +217 -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 +527 -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 +60 -0
- package/dist/prompt/tag-names.d.ts +22 -0
- package/dist/provider/acp/connection.d.ts +6 -0
- package/dist/provider/acp/meta.d.ts +11 -0
- package/dist/provider/bridge.d.ts +12 -2
- 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 +23 -2
- package/dist/provider/cli/adapters/agent-call.util.d.ts +1 -1
- 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/index.d.ts +5 -0
- package/dist/provider-account/registry.d.ts +30 -0
- package/dist/provider-account/types.d.ts +40 -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 +12 -1
- package/dist/repository/index.d.ts +53 -6
- package/dist/repository/index.js +648 -211
- 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/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 +44 -0
- package/dist/repository/task-status.d.ts +21 -0
- package/dist/repository/task.repository.d.ts +307 -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 +21 -0
- package/dist/repository/workspace.repository.d.ts +3 -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/index.d.ts +16 -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/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 +1058 -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 +1611 -3
- 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 +213 -0
- package/dist/ui-instance/types.d.ts +343 -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 +207 -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 +63 -3
- package/templates/agents/default.yaml +303 -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
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
import type { ModelApiPricing } from './pricing.types.js';
|
|
2
|
+
export declare const MODEL_TIERS: readonly ["flagship", "balanced", "speed"];
|
|
3
|
+
export type ModelTier = (typeof MODEL_TIERS)[number];
|
|
4
|
+
export declare const EFFORT_LEVELS: readonly ["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"];
|
|
5
|
+
export type EffortLevel = (typeof EFFORT_LEVELS)[number];
|
|
6
|
+
export type KnownEffortLevel = EffortLevel;
|
|
7
|
+
export declare const PROVIDER_ARGV_EFFORTS: Record<string, readonly string[]>;
|
|
8
|
+
export declare const MODEL_CATALOG_VERSION = 33;
|
|
9
|
+
export declare const MODEL_CATALOG_UPDATED = "2026-10-08T00:00:00Z";
|
|
1
10
|
export interface ModelCatalogEntry {
|
|
2
11
|
id: string;
|
|
3
12
|
name: string;
|
|
4
13
|
description?: string;
|
|
14
|
+
contextWindowTokens?: number;
|
|
15
|
+
tier?: ModelTier;
|
|
16
|
+
recommended?: boolean;
|
|
17
|
+
apiPricing?: ModelApiPricing;
|
|
5
18
|
}
|
|
6
19
|
export interface ProviderModeEntry {
|
|
7
20
|
id: string;
|
|
@@ -12,11 +25,35 @@ export interface ProviderModelOverride {
|
|
|
12
25
|
effort?: string[];
|
|
13
26
|
defaultEffort?: string;
|
|
14
27
|
}
|
|
28
|
+
export type ProviderOptionSpec = {
|
|
29
|
+
key: string;
|
|
30
|
+
type: 'boolean';
|
|
31
|
+
} | {
|
|
32
|
+
key: string;
|
|
33
|
+
type: 'enum';
|
|
34
|
+
values: string[];
|
|
35
|
+
};
|
|
36
|
+
export interface ProviderExecutionOptions {
|
|
37
|
+
mode: string;
|
|
38
|
+
effort: string;
|
|
39
|
+
providerOptions?: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
export interface ProviderDefaultProfile {
|
|
42
|
+
model: string;
|
|
43
|
+
query: ProviderExecutionOptions;
|
|
44
|
+
execute: ProviderExecutionOptions;
|
|
45
|
+
}
|
|
46
|
+
export interface ProviderDefaults {
|
|
47
|
+
version: number;
|
|
48
|
+
providers: Record<string, ProviderDefaultProfile>;
|
|
49
|
+
}
|
|
15
50
|
export interface ProviderCatalogEntry {
|
|
16
51
|
models: ModelCatalogEntry[];
|
|
17
52
|
modes: ProviderModeEntry[];
|
|
18
53
|
effort: string[];
|
|
19
54
|
modelOverrides: Record<string, ProviderModelOverride>;
|
|
55
|
+
providerOptions?: ProviderOptionSpec[];
|
|
20
56
|
}
|
|
21
57
|
export declare const PROVIDER_CATALOGS: Record<string, ProviderCatalogEntry>;
|
|
58
|
+
export declare const PROVIDER_DEFAULTS: ProviderDefaults;
|
|
22
59
|
export declare const PROVIDER_MODELS: Record<string, ModelCatalogEntry[]>;
|
|
@@ -3,6 +3,7 @@ export interface OverdriveProfile {
|
|
|
3
3
|
model?: string;
|
|
4
4
|
mode?: string;
|
|
5
5
|
effort?: string;
|
|
6
|
+
providerOptions?: Record<string, unknown>;
|
|
6
7
|
}
|
|
7
8
|
export type OverdriveSignalInput = boolean | {
|
|
8
9
|
mode?: 'count' | 'latch';
|
|
@@ -20,5 +21,11 @@ export interface OverdriveResolution {
|
|
|
20
21
|
mode?: string;
|
|
21
22
|
effort?: string;
|
|
22
23
|
crossProvider: boolean;
|
|
24
|
+
providerOptions?: Record<string, unknown>;
|
|
23
25
|
}
|
|
24
26
|
export declare function resolveOverdrive(agentOptions: unknown, mode: 'query' | 'execute', baseProvider: string, signal: OverdriveSignal): OverdriveResolution;
|
|
27
|
+
export interface ModeOverrideResolution {
|
|
28
|
+
provider?: string;
|
|
29
|
+
model?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function resolveModeOverride(agentOptions: unknown, mode: 'query' | 'execute'): ModeOverrideResolution;
|
package/dist/config/pricing.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type { ModelPricing } from './pricing.types.js';
|
|
2
|
-
export type { ModelPricing } from './pricing.types.js';
|
|
3
|
-
export { MODEL_PRICING } from './pricing.generated.js';
|
|
1
|
+
import type { ModelApiPricing, ModelPricing } from './pricing.types.js';
|
|
2
|
+
export type { ModelApiPricing, ModelPricing } from './pricing.types.js';
|
|
3
|
+
export { MODEL_PRICING, UNPUBLISHED_MODEL_IDS } from './pricing.generated.js';
|
|
4
4
|
export declare function setPricingOverride(models: Record<string, ModelPricing>): void;
|
|
5
5
|
export declare function clearPricingOverride(): void;
|
|
6
|
+
export declare function setApiPricingOverride(models: Record<string, ModelApiPricing>): void;
|
|
7
|
+
export declare function clearApiPricingOverride(): void;
|
|
6
8
|
export declare function normalizeModel(model: string): string;
|
|
9
|
+
export declare function lookupApiPricing(model: string | null | undefined): ModelApiPricing | undefined;
|
|
7
10
|
export declare function getPricing(model: string | null | undefined): ModelPricing;
|
|
8
11
|
export declare function calculateCost(inputTokens: number, outputTokens: number, model: string | null | undefined, cachedInputTokens?: number, _date?: Date): number;
|
|
9
12
|
export declare function resolveCost(costUsd: number | undefined, inputTokens: number | undefined, outputTokens: number | undefined, cachedInputTokens: number | undefined, model: string | null | undefined, date?: Date): number;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import type { ModelPricing } from './pricing.types.js';
|
|
2
2
|
export declare const MODEL_PRICING: Record<string, ModelPricing>;
|
|
3
|
+
export declare const MODEL_PRICING_VERSION = 33;
|
|
4
|
+
export declare const MODEL_PRICING_UPDATED = "2026-10-08T00:00:00Z";
|
|
5
|
+
export declare const UNPUBLISHED_MODEL_IDS: ReadonlySet<string>;
|
|
6
|
+
export declare const CATALOG_MODEL_IDS: ReadonlySet<string>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export interface TimeoutConfig {
|
|
2
2
|
queryMs: number;
|
|
3
3
|
executeMs: number;
|
|
4
|
+
idleMs: number;
|
|
4
5
|
}
|
|
6
|
+
export declare const DEFAULT_IDLE_MS: number;
|
|
7
|
+
export declare const DEFAULT_RESUME_TIMEOUT_MS = 60000;
|
|
8
|
+
export declare function parseIdleEnvOverride(env?: NodeJS.ProcessEnv): number | undefined;
|
|
5
9
|
export declare function getProviderTimeoutConfig(env?: NodeJS.ProcessEnv): TimeoutConfig;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CrewxProjectConfig } from '../types';
|
|
2
|
+
export declare const DEFAULT_WI_BOARD_ID = "default";
|
|
3
|
+
export declare const ARCHIVE_WI_BOARD_ID = "archive";
|
|
4
|
+
export declare const DEFAULT_WI_WORKFLOW_ID = "wi-default-flow";
|
|
5
|
+
export declare const WI_PLAN_WORKFLOW_ID = "wi-plan-flow";
|
|
6
|
+
export declare const WI_DEFAULT_FLOW_FILENAME = "wi-default-flow.yaml";
|
|
7
|
+
export declare const WI_PLAN_FLOW_FILENAME = "wi-plan-flow.yaml";
|
|
8
|
+
export declare const WI_BOARD_ID_PATTERN: RegExp;
|
|
9
|
+
export declare function isReservedWiBoardId(id: string): boolean;
|
|
10
|
+
export interface ResolvedWiBoard {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
workflowId: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
goalId?: string;
|
|
16
|
+
system: boolean;
|
|
17
|
+
readOnly: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function resolveWiBoards(config: CrewxProjectConfig | undefined): ResolvedWiBoard[];
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ConversationHighlight, ConversationThreadState, SemanticContinuityContext, TemplateMessage } from '../conversation/types.js';
|
|
2
|
+
export declare const DEFAULT_PROTECTED_TURN_COUNT = 5;
|
|
3
|
+
export declare const DEFAULT_HIGHLIGHT_BUDGET_PERCENT = 5;
|
|
4
|
+
export declare const MAX_ACTIVE_HIGHLIGHTS = 12;
|
|
5
|
+
export declare const MAX_ACTIVE_HIGHLIGHT_CHARS = 2000;
|
|
6
|
+
export declare const MAX_THREAD_TITLE_CHARS = 200;
|
|
7
|
+
export declare const MAX_THREAD_STATE_VALUE_CHARS = 64;
|
|
8
|
+
export interface ConversationTurn {
|
|
9
|
+
taskId?: string;
|
|
10
|
+
messages: TemplateMessage[];
|
|
11
|
+
ordinal: number;
|
|
12
|
+
}
|
|
13
|
+
export interface GroupedConversationTurns {
|
|
14
|
+
turns: ConversationTurn[];
|
|
15
|
+
unpairedMessages: TemplateMessage[];
|
|
16
|
+
droppedMessages: TemplateMessage[];
|
|
17
|
+
}
|
|
18
|
+
export interface ConversationTurnSelection {
|
|
19
|
+
includedTurns: ConversationTurn[];
|
|
20
|
+
omittedTurns: ConversationTurn[];
|
|
21
|
+
protectedTurns: ConversationTurn[];
|
|
22
|
+
tokenCount: number;
|
|
23
|
+
protectedTokenCount: number;
|
|
24
|
+
overBudget: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface SelectConversationTurnsOptions {
|
|
27
|
+
turns: readonly ConversationTurn[];
|
|
28
|
+
maxTokenCount: number;
|
|
29
|
+
countTokens: (text: string) => number;
|
|
30
|
+
protectedTurnCount?: number;
|
|
31
|
+
materializeTurn?: (turn: ConversationTurn) => string;
|
|
32
|
+
}
|
|
33
|
+
export interface ConversationHighlightSelection {
|
|
34
|
+
includedHighlights: ConversationHighlight[];
|
|
35
|
+
omittedHighlights: ConversationHighlight[];
|
|
36
|
+
truncatedHighlights: number;
|
|
37
|
+
representedTaskIds: string[];
|
|
38
|
+
unrepresentedTaskIds: string[];
|
|
39
|
+
tokenCount: number;
|
|
40
|
+
budgetTokens: number;
|
|
41
|
+
}
|
|
42
|
+
export interface SelectConversationHighlightsOptions {
|
|
43
|
+
highlights: readonly ConversationHighlight[];
|
|
44
|
+
omittedTaskIds: readonly string[];
|
|
45
|
+
taskOrder: readonly string[];
|
|
46
|
+
maxTokenCount: number;
|
|
47
|
+
countTokens: (text: string) => number;
|
|
48
|
+
applySafetyCap?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export declare function getConversationMessageTaskId(message: TemplateMessage): string | undefined;
|
|
51
|
+
export declare function groupConversationTurns(messages: readonly TemplateMessage[]): GroupedConversationTurns;
|
|
52
|
+
export declare function withoutDroppedAppCards(messages: readonly TemplateMessage[]): TemplateMessage[];
|
|
53
|
+
export declare function materializeConversationTurn(turn: ConversationTurn, includeActivityLog?: boolean): string;
|
|
54
|
+
export declare function selectConversationTurns(options: SelectConversationTurnsOptions): ConversationTurnSelection;
|
|
55
|
+
export declare function buildThreadStateContext(state: ConversationThreadState | undefined): ConversationThreadState | undefined;
|
|
56
|
+
export declare function selectConversationHighlights(options: SelectConversationHighlightsOptions): ConversationHighlightSelection;
|
|
57
|
+
export interface BuildSemanticContinuityContextOptions {
|
|
58
|
+
highlights: readonly ConversationHighlight[];
|
|
59
|
+
omittedTaskIds: readonly string[];
|
|
60
|
+
representedTaskIds: readonly string[];
|
|
61
|
+
applySafetyCap?: boolean;
|
|
62
|
+
}
|
|
63
|
+
export declare function buildSemanticContinuityContext(options: BuildSemanticContinuityContextOptions): SemanticContinuityContext;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
export declare const DEFAULT_INPUT_BUDGET_PERCENT = 60;
|
|
2
|
+
export declare const MIN_INPUT_BUDGET_PERCENT = 30;
|
|
3
|
+
export declare const MAX_INPUT_BUDGET_PERCENT = 80;
|
|
4
|
+
export declare const INPUT_BUDGET_TOKENIZER_ENCODING = "o200k_base";
|
|
5
|
+
export declare const FRESH_PROVIDER_INITIAL_INPUT_SEPARATOR = "\n\n---\n\n";
|
|
6
|
+
export declare const FRESH_PROVIDER_INITIAL_INPUT_FRAMING = "system_prompt\\n\\n---\\n\\nmessage";
|
|
7
|
+
export declare const RESUME_PROVIDER_INITIAL_INPUT_FRAMING = "message";
|
|
8
|
+
export type InputBudgetUnresolvedReason = 'invalid_input_budget_percent' | 'provider_catalog_unavailable' | 'model_not_found' | 'context_window_tokens_unavailable';
|
|
9
|
+
export type TokenizerFallbackReason = 'vendor_tokenizer_unavailable';
|
|
10
|
+
export interface ResolveInputBudgetOptions {
|
|
11
|
+
provider: string;
|
|
12
|
+
model: string;
|
|
13
|
+
inputBudgetPercent?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface TokenizerOptions {
|
|
16
|
+
provider?: string;
|
|
17
|
+
model?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface TokenizerMetadata {
|
|
20
|
+
provider: string;
|
|
21
|
+
model: string;
|
|
22
|
+
encoding: typeof INPUT_BUDGET_TOKENIZER_ENCODING;
|
|
23
|
+
exact: boolean;
|
|
24
|
+
fallbackReason?: TokenizerFallbackReason;
|
|
25
|
+
}
|
|
26
|
+
export interface ResolvedInputBudget {
|
|
27
|
+
resolved: true;
|
|
28
|
+
requestedProvider: string;
|
|
29
|
+
provider: string;
|
|
30
|
+
model: string;
|
|
31
|
+
contextWindowTokens: number;
|
|
32
|
+
inputBudgetPercent: number;
|
|
33
|
+
inputBudgetTokens: number;
|
|
34
|
+
tokenizer: TokenizerMetadata;
|
|
35
|
+
}
|
|
36
|
+
export interface UnresolvedInputBudget {
|
|
37
|
+
resolved: false;
|
|
38
|
+
requestedProvider: string;
|
|
39
|
+
provider: string;
|
|
40
|
+
model: string;
|
|
41
|
+
reason: InputBudgetUnresolvedReason;
|
|
42
|
+
inputBudgetPercent?: number;
|
|
43
|
+
tokenizer: TokenizerMetadata;
|
|
44
|
+
}
|
|
45
|
+
export type ResolveInputBudgetResult = ResolvedInputBudget | UnresolvedInputBudget;
|
|
46
|
+
export type ContextBudgetPhase = 'fresh' | 'resume';
|
|
47
|
+
export type ProviderInitialInputFraming = typeof FRESH_PROVIDER_INITIAL_INPUT_FRAMING | typeof RESUME_PROVIDER_INITIAL_INPUT_FRAMING;
|
|
48
|
+
export interface ContextBudgetLayoutCapability {
|
|
49
|
+
layoutId: string;
|
|
50
|
+
supportsSemanticContinuity: boolean;
|
|
51
|
+
slot: string | null;
|
|
52
|
+
requiredForOmittedTurns: boolean;
|
|
53
|
+
warning?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface ContextBudgetActivityDegradation {
|
|
56
|
+
taskId: string;
|
|
57
|
+
taskDistance: number;
|
|
58
|
+
action: 'reduced' | 'omitted';
|
|
59
|
+
}
|
|
60
|
+
export type ContextBudgetAssemblyErrorCode = 'INPUT_BUDGET_EXCEEDED' | 'CONTINUITY_SLOT_REQUIRED';
|
|
61
|
+
export declare class ContextBudgetLayoutError extends Error {
|
|
62
|
+
readonly layoutId: string;
|
|
63
|
+
readonly omittedTurnCount: number;
|
|
64
|
+
readonly code: "CONTINUITY_SLOT_REQUIRED";
|
|
65
|
+
constructor(message: string, layoutId: string, omittedTurnCount: number);
|
|
66
|
+
}
|
|
67
|
+
export interface ContextBudgetManifest {
|
|
68
|
+
runningInstructionAppsOmitted?: number;
|
|
69
|
+
phase: ContextBudgetPhase;
|
|
70
|
+
initialInputFraming: ProviderInitialInputFraming;
|
|
71
|
+
resolved: boolean;
|
|
72
|
+
reason?: InputBudgetUnresolvedReason;
|
|
73
|
+
requestedProvider: string;
|
|
74
|
+
requestedModel: string | null;
|
|
75
|
+
effectiveProvider: string;
|
|
76
|
+
effectiveModel: string | null;
|
|
77
|
+
contextWindowTokens: number | null;
|
|
78
|
+
inputBudgetPercent: number | null;
|
|
79
|
+
inputBudgetTokens: number | null;
|
|
80
|
+
tokenizer: TokenizerMetadata;
|
|
81
|
+
initialTokenCount: number | null;
|
|
82
|
+
finalTokenCount: number | null;
|
|
83
|
+
activityLogTokenCount: number | null;
|
|
84
|
+
activityIncludedEntries: number | null;
|
|
85
|
+
activityOmittedEntries: number | null;
|
|
86
|
+
activityRemovedForBudget: boolean;
|
|
87
|
+
activityNewestTaskTokenCap: number | null;
|
|
88
|
+
historyOriginalMessages: number;
|
|
89
|
+
historyIncludedMessages: number;
|
|
90
|
+
historyOmittedMessages: number;
|
|
91
|
+
turnOriginal: number;
|
|
92
|
+
turnIncluded: number;
|
|
93
|
+
turnOmitted: number;
|
|
94
|
+
highlightOriginal: number;
|
|
95
|
+
highlightIncluded: number;
|
|
96
|
+
highlightOmitted: number;
|
|
97
|
+
highlightTruncated: number;
|
|
98
|
+
representedOmittedTurns: number;
|
|
99
|
+
unrepresentedOmittedTurns: number;
|
|
100
|
+
activityDegraded: boolean;
|
|
101
|
+
activityIncludedTasks: number;
|
|
102
|
+
activityOmittedTasks: number;
|
|
103
|
+
activityDegradation: ContextBudgetActivityDegradation[];
|
|
104
|
+
highlightLookupFailed: boolean;
|
|
105
|
+
layoutCapability: ContextBudgetLayoutCapability;
|
|
106
|
+
overBudget: boolean;
|
|
107
|
+
overdriveProviderSuppressed?: boolean;
|
|
108
|
+
}
|
|
109
|
+
export interface TokenCountResult {
|
|
110
|
+
tokenCount: number;
|
|
111
|
+
tokenizer: TokenizerMetadata;
|
|
112
|
+
}
|
|
113
|
+
export interface TokenCounter {
|
|
114
|
+
metadata: TokenizerMetadata;
|
|
115
|
+
countTokens(text: string): number;
|
|
116
|
+
}
|
|
117
|
+
export interface FreshProviderInitialInput {
|
|
118
|
+
systemPrompt?: string | null;
|
|
119
|
+
message: string;
|
|
120
|
+
}
|
|
121
|
+
type PieceCacheEventType = 'hit' | 'miss' | 'evict' | 'full_encode';
|
|
122
|
+
interface PieceCacheEvent {
|
|
123
|
+
type: PieceCacheEventType;
|
|
124
|
+
piece?: string;
|
|
125
|
+
tokenCount?: number;
|
|
126
|
+
reason?: 'special_token';
|
|
127
|
+
}
|
|
128
|
+
type PieceCacheObserver = (event: PieceCacheEvent) => void;
|
|
129
|
+
interface TokenCounterInternalOptions {
|
|
130
|
+
pieceCacheMaxEntries?: number;
|
|
131
|
+
observePieceCache?: PieceCacheObserver;
|
|
132
|
+
}
|
|
133
|
+
export declare function normalizeInputBudgetProvider(provider: string): string;
|
|
134
|
+
export declare function resolveTokenizerMetadata(options?: TokenizerOptions): TokenizerMetadata;
|
|
135
|
+
export declare function countTokens(text: string, options?: TokenizerOptions): TokenCountResult;
|
|
136
|
+
export declare function renderFreshProviderInitialInput(input: FreshProviderInitialInput): string;
|
|
137
|
+
export declare function countFreshProviderInitialInput(input: FreshProviderInitialInput, count: (text: string) => number): number;
|
|
138
|
+
export declare function createTokenCounter(options?: TokenizerOptions): TokenCounter;
|
|
139
|
+
export declare function __createTokenCounterForTest(options?: TokenizerOptions, internalOptions?: TokenCounterInternalOptions): TokenCounter;
|
|
140
|
+
export declare function resolveInputBudget(options: ResolveInputBudgetOptions): ResolveInputBudgetResult;
|
|
141
|
+
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';
|
|
142
|
+
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,56 @@
|
|
|
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 SemanticContinuityContext {
|
|
26
|
+
highlights: ConversationHighlight[];
|
|
27
|
+
truncatedHighlights?: number;
|
|
28
|
+
omittedTurns: {
|
|
29
|
+
count: number;
|
|
30
|
+
represented: number;
|
|
31
|
+
unrepresented: number;
|
|
32
|
+
taskIds: string[];
|
|
33
|
+
};
|
|
34
|
+
rendered?: string;
|
|
35
|
+
omittedRendered: string;
|
|
36
|
+
}
|
|
37
|
+
export type ConversationSemanticContinuityContext = SemanticContinuityContext;
|
|
38
|
+
export interface ConversationThreadStateValue {
|
|
39
|
+
code: string;
|
|
40
|
+
name: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ConversationThreadState {
|
|
43
|
+
title?: string;
|
|
44
|
+
priority?: ConversationThreadStateValue;
|
|
45
|
+
state?: ConversationThreadStateValue;
|
|
46
|
+
rendered?: string;
|
|
47
|
+
}
|
|
48
|
+
export type ThreadStateContext = ConversationThreadState;
|
|
10
49
|
export interface ConversationThread {
|
|
11
50
|
threadId: string;
|
|
12
51
|
platform: Platform;
|
|
13
52
|
messages: ConversationMessage[];
|
|
53
|
+
highlights?: ConversationHighlight[];
|
|
14
54
|
metadata?: {
|
|
15
55
|
title?: string;
|
|
16
56
|
firstMessage?: string;
|
|
@@ -19,27 +59,44 @@ export interface ConversationThread {
|
|
|
19
59
|
updatedAt?: number;
|
|
20
60
|
};
|
|
21
61
|
}
|
|
62
|
+
export interface TemplateAppCard {
|
|
63
|
+
readonly instanceId: string;
|
|
64
|
+
readonly anchorTaskId: string;
|
|
65
|
+
readonly status: 'running' | 'waiting' | 'done' | 'failed' | 'expired';
|
|
66
|
+
readonly result?: 'saved' | 'deferred' | 'cancelled';
|
|
67
|
+
readonly agentId?: string;
|
|
68
|
+
readonly xml: string;
|
|
69
|
+
readonly replacesSlot?: boolean;
|
|
70
|
+
}
|
|
22
71
|
export interface TemplateMessage {
|
|
72
|
+
id?: string;
|
|
23
73
|
text: string;
|
|
24
74
|
isAssistant: boolean;
|
|
75
|
+
taskId?: string;
|
|
25
76
|
timestamp?: number;
|
|
26
77
|
metadata?: Record<string, unknown>;
|
|
78
|
+
activity_log?: string;
|
|
27
79
|
files?: Array<{
|
|
28
80
|
name: string;
|
|
29
81
|
size?: number;
|
|
30
82
|
localPath?: string;
|
|
31
83
|
}>;
|
|
84
|
+
appCard?: TemplateAppCard;
|
|
32
85
|
}
|
|
33
86
|
export interface FetchHistoryOptions {
|
|
34
87
|
limit?: number;
|
|
35
88
|
maxContextLength?: number;
|
|
89
|
+
includeHighlights?: boolean;
|
|
36
90
|
currentTraceId?: string;
|
|
91
|
+
agentId?: string;
|
|
37
92
|
}
|
|
38
93
|
export interface IConversationHistoryProvider {
|
|
39
|
-
ensureThread(threadId: string, platform: Platform, workspaceId?: string): Promise<{
|
|
94
|
+
ensureThread(threadId: string, platform: Platform, workspaceId?: string, creator?: ThreadCreationOptions): Promise<{
|
|
40
95
|
created: boolean;
|
|
41
96
|
}>;
|
|
42
97
|
fetchHistory(threadId: string, options?: FetchHistoryOptions): Promise<ConversationThread>;
|
|
98
|
+
fetchThreadState?(threadId: string): Promise<ConversationThreadState | undefined>;
|
|
99
|
+
fetchHighlights?(threadId: string): Promise<ConversationHighlight[] | undefined>;
|
|
43
100
|
saveUserMessage(threadId: string, text: string, userId?: string, metadata?: Record<string, unknown>): Promise<{
|
|
44
101
|
id: string;
|
|
45
102
|
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 p=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 p__namespace=/*#__PURE__*/_interopNamespace(p);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 m=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 I(e){return typeof e!="string"?void 0:e.trim()||void 0}function N(e){return I(e)?.toLowerCase()??""}function _(e){try{return fs.statSync(e).isFile()}catch{return false}}function Je(e,t){if(e===t)return true;let n=p__namespace.default.relative(e,t);return n!==""&&!n.startsWith("..")&&!p__namespace.default.isAbsolute(n)}function je(e,t){if(p__namespace.default.basename(e)!==".bin")return false;let n=p__namespace.default.dirname(e);if(p__namespace.default.basename(n)!=="node_modules")return false;let r=p__namespace.default.dirname(n);return Je(r,t)}function Q(e,t={}){if(e.includes("/")||e.includes("\\")||p__namespace.default.isAbsolute(e))return e;let n=t.platform??process.platform,r=t.env??process.env,o=p__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(u=>u.trim()).filter(Boolean),l=p__namespace.default.extname(e).length>0,d=r.PATHEXT??r.Pathext??process.env.PATHEXT??process.env.Pathext??".EXE;.CMD;.BAT;.COM",f=n==="win32"?l?[""]:d.split(";").map(u=>u.trim()).filter(Boolean).map(u=>u.startsWith(".")?u:`.${u}`):[""];for(let u of a){let P=p__namespace.default.resolve(o,u);if(!(c&&je(P,o)))for(let h of f){let y=N(h),w=h.toUpperCase();for(let g of [h,y,w]){let C=p__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=p__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,p__namespace.default.sep).replace(/^[\\/]+/,""),u=p__namespace.default.resolve(n,f);_(u)&&r.push(u);}let o=[],c=new Map;for(let i of t.matchAll(/SET\s+"(\w+)=%~?dp0%?[\\/]?([^"]+)"/gi)){let a=i[1].toUpperCase(),l=i[2].trim().replace(/[\\/]+/g,p__namespace.default.sep).replace(/^[\\/]+/,"");c.set(a,p__namespace.default.resolve(n,l));}for(let i of t.split(/\r?\n/))if(i.includes("%*"))for(let a of i.matchAll(/"%(\w+)%"/g)){let l=c.get(a[1].toUpperCase());l&&_(l)&&o.push(l);}let s=i=>i.find(a=>{let l=N(p__namespace.default.basename(a));return l!=="node.exe"&&l!=="node"})??null;return s(o)??s(r)}catch{return null}}function qe(e,t){if(typeof t=="string")return I(t)||null;if(!t||typeof t!="object")return null;if(e){let n=t[e],r=typeof n=="string"?I(n):void 0;if(r)return r}for(let n of Object.values(t)){let r=typeof n=="string"?I(n):void 0;if(r)return r}return null}function Ye(e,t){if(!t)return null;let n=p__namespace.default.dirname(e),r=[p__namespace.default.resolve(n,"..",t),p__namespace.default.resolve(n,"node_modules",t)];for(let o of r){let c=p__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=p__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=N(p__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?N(p__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(`${p__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 H(e){let t=0;for(let n of e)n===D&&(t+=1);return t}function $(e,t){return H(t)<H(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}),l=se(this.pendingBytes,t);if(r){let d=this.pendingUtf8+n,f=this.pendingFallback+a;return this.clearPendingCandidate(),$(d,f)}if(H(a)>0){let d=this.pendingUtf8+n;return this.clearPendingCandidate(),this.fallbackDecoder=void 0,this.replayTail=l,d}if(this.pendingUtf8||this.pendingFallback){if(this.pendingUtf8+=n,this.pendingFallback+=a,this.pendingBytes=l,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=l,""):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,lt=25,ut=100;function ue(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(l){n({status:null,stdout:"",stderr:"",error:ue(l)});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=l=>{s||(s=true,clearTimeout(a),n(l));},r.stdout?.setEncoding("utf8"),r.stderr?.setEncoding("utf8"),r.stdout?.on("data",l=>{o+=String(l);}),r.stderr?.on("data",l=>{c+=String(l);}),r.once("error",l=>{i({status:null,stdout:o,stderr:c,error:l});}),r.once("close",l=>{i({status:l,stdout:o,stderr:c});});})}async function pt(e,t,n){return n.runCommandAsync?n.runCommandAsync(e,t):n.runCommand?n.runCommand(e,t):ft(e,t)}function mt(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??lt),s=Date.now()+o,i,a=o===0,l=r.sleep?Promise.resolve().then(()=>r.sleep(o)).then(()=>{},()=>{}):new Promise(d=>{i=setTimeout(d,o);});l.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([l,mt(Math.min(c,f))]);}}finally{i!==void 0&&clearTimeout(i);}}async function le(e,t,n,r,o){let c=await de(e,t,o.hardConfirmMs??ut,{...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=u=>({status:"failed",pid:e,method:r,error:u});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 u;try{u=await pt("taskkill",["/PID",String(e),"/T","/F"],t);}catch(h){u={status:null,stdout:"",stderr:"",error:ue(h)};}let P=A(e,c);return P==="not_found"?u.status===0&&!u.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(u){i=u;}if(a==="SIGKILL")return le(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(u){d=u;}let f=await le(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 pe(e){return Pt(e,gt)}var me=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=pe(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"}),l="",d="",f=false,u=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??me}ms: ${e} ${t.join(" ")}`)));},n.timeoutMs??me);a.stdout?.on("data",g=>{h=h.then(async()=>{l+=await u.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([u.end(),P.end()]);f||(l+=C,d+=Be,f=true,clearTimeout(w),r({code:g??0,stdout:l,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(),p.join(__dirname,"../../package.json"),p.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=p__namespace.win32;function U(e){return E.join(e,".crewx")}function Ee(e){return E.join(U(e),"shortcut.json")}function ye(e){return E.join(U(e),"launcher.json")}function Ce(e){return E.join(U(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[l,...d]=a.split("-"),f=d.join("-")||void 0;return {parts:(l??"").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 l=r.parts[a]??0,d=o.parts[a]??0;if(l!==d)return l<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=p__namespace.win32,Oe=1;function xe(e,t){if(!e.existsSync(t))return null;try{let n=JSON.parse(e.readFileSync(t));return {schema:n.schema??Oe,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 W(e,t,n){let r={schema:Oe,...n,updatedAt:new Date().toISOString()};e.mkdirSync(ke.dirname(t)),e.writeFileSync(t,JSON.stringify(r,null,2));}function M(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 Le(e,t,n){e.mkdirSync(ke.dirname(t)),e.writeFileSync(t,JSON.stringify(n,null,2));}var bt=p__namespace.win32,O=1;function kt(e){return e.replace(/%/g,"%%")}function Ot(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 Ne(e){let t=M(e.fs,e.launcherManifestPath),n=!!t&&t.schema>=O&&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=Ot({bakedBinPath:e.bakedBinPath});try{e.fs.mkdirSync(bt.dirname(e.wrapperPath)),e.fs.writeFileSync(e.wrapperPath,c),Le(e.fs,e.launcherManifestPath,{schema:O,binPath:e.bakedBinPath,updatedAt:new Date().toISOString()});}catch(s){throw s instanceof m?s:new m("WRITE_DENIED",`Could not write launcher wrapper: ${s instanceof Error?s.message:String(s)}`)}return {wrapperPath:e.wrapperPath,wrote:true,schema:O}}var xt=["$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("; "),Lt=["[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",xt],{env:t});}catch(r){throw new m("POWERSHELL_UNAVAILABLE",`Could not run PowerShell: ${r instanceof Error?r.message:String(r)}`)}if(n.code!==0)throw new m("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",Lt],{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 J=p__namespace.win32;async function x(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?J.join(s,"crewx.cmd"):void 0;return {installed:true,version:c.version,binPath:i,prefix:s}}var It=/EACCES|EPERM|EROFS/,Nt=/ENOTFOUND|ETIMEDOUT|ECONNREFUSED|network|registry/i,Tt=/^\d+\.\d+\.\d+/;function Dt(e){return !!e&&e!=="0.0.0"&&Tt.test(e)}var K=10*6e4;async function Me(e){if(!Dt(e.targetVersion))throw new m("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:K});}catch(s){throw new m("NPM_UNAVAILABLE",`Could not run npm: ${s instanceof Error?s.message:String(s)}`)}if(o.code===0)return {info:await x({env:n,cwd:e.cwd,run:e.run})};let c=`${o.stdout}
|
|
3
|
+
${o.stderr}`;if(It.test(c)){e.onProgress?.({phase:"global-install",message:"Permission denied \u2014 retrying with a user-scoped npm prefix"});let s=e.env.LOCALAPPDATA||J.join(e.env.USERPROFILE??"","AppData","Local"),i={...n,npm_config_prefix:J.join(s,"crewx","npm")},a;try{a=await e.run("npm",["install","-g",r,"--no-audit","--no-fund"],{env:i,timeoutMs:K});}catch(l){throw new m("NPM_PERMISSION_DENIED",`Retry with user-scoped prefix failed: ${l instanceof Error?l.message:String(l)}`)}if(a.code===0)return {info:await x({env:i,cwd:e.cwd,run:e.run})};throw new m("NPM_PERMISSION_DENIED",`npm install -g failed after user-scoped prefix retry: ${a.stderr||a.stdout}`)}if(Nt.test(c)){if(!e.installRoot)throw new m("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:K});}catch(i){throw new m("GLOBAL_INSTALL_FAILED",`Offline install failed: ${i instanceof Error?i.message:String(i)}`)}if(s.code===0)return {info:await x({env:n,cwd:e.cwd,run:e.run})};throw new m("GLOBAL_INSTALL_FAILED",`Offline install failed: ${s.stderr||s.stdout}`)}throw new m("GLOBAL_INSTALL_FAILED",c.trim()||`npm install -g ${r} failed`)}function Wt(e){return e.run??we}function Mt(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=Wt(e),c=Mt(e),s=e.runningVersion??Pe,i=e.cwd??process.cwd(),a=r(),l=Ee(a),d=ye(a),f=Ce(a),u=null;t==="win32"&&(u=await ve({env:n,homedir:r,run:o}));let P=u?Re(u.dir):null;return {platform:t,env:n,homedir:r,run:o,fs:c,runningVersion:s,cwd:i,installRoot:e.installRoot,shortcutManifestPath:l,launcherManifestPath:d,wrapperPath:f,desktop:u,shortcutPath:P}}function Ge(e){return e?p__namespace.win32.normalize(e).toLowerCase().endsWith(`${p__namespace.win32.sep}bin${p__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=xe(e.fs,e.shortcutManifestPath),r=M(e.fs,e.launcherManifestPath),o=await x({env:e.env,cwd:e.cwd,run:e.run}),c=e.shortcutPath?e.fs.existsSync(e.shortcutPath):false,s,i=false,a,l;if(!c)s=n?.declined?"declined":"not-installed";else {let d=!!n?.owned&&!!e.shortcutPath&&n.shortcutPath===e.shortcutPath,f=false,u=e.shortcutPath?await Ae({run:e.run,env:e.env,shortcutPath:e.shortcutPath}):null;if(d||(u&&V(u.targetPath,e.wrapperPath)?d=true:u&&_e(u.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<O||!e.fs.existsSync(e.wrapperPath);if(u){let h=De(u.iconLocation);if(!(!!h&&e.fs.existsSync(h)))i=true;else {a=h;let w=Fe(o,e.fs);w?V(h,w)?(l=j(e.fs,h),i=!l||n?.iconHash!==l):i=true:Ge(h)?(l=j(e.fs,h),i=!l||n?.iconHash!==l):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:l}}function Fe(e,t){if(!e?.installed||!e.prefix)return;let n=p__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 m("NSIS_PRESENT",`An NSIS-installed CrewX shortcut was detected at ${r.shortcutPath}`);if(!e.force)throw new m("FOREIGN_SHORTCUT",`An existing shortcut at ${r.shortcutPath} is not managed by CrewX`)}if(!t.desktop||!t.shortcutPath)throw new m("NO_DESKTOP_DIR","Could not resolve the Windows Desktop directory");let o=false,c=false,s=r.globalCrewx,i=[],a=n.manifest?.iconHash,l=false;if(!!s?.installed&&!!s.version&&k(s.version,t.runningVersion)||!s?.installed&&r.state!=="installed"){let w=await Me({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"}),Ne({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 m("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,l=n.iconStale;let g=w?j(t.fs,w):void 0;g&&(a=g);}o&&W(t.fs,t.shortcutManifestPath,{shortcutPath:t.shortcutPath,version:t.runningVersion,owned:true,declined:false,desktopSource:t.desktop.source,iconHash:a}),l&&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{}W(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 Ht(e={}){let t=await G(e),n=await R(t),r=v(n);if(!r.supported)return r;W(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=m;exports.dismissShortcutNotice=Ht;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>;
|