stitchkit 0.126.0 → 0.127.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1636 -0
- package/README.md +12 -4
- package/dist/agent-executor/acp/scenarios.d.ts +4 -0
- package/dist/agent-executor/acp/scenarios.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-connect.d.ts +89 -0
- package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-driver.d.ts +31 -0
- package/dist/agent-executor/acp/v1-driver.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-map.d.ts +41 -0
- package/dist/agent-executor/acp/v1-map.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-protocol.d.ts +270 -0
- package/dist/agent-executor/acp/v1-protocol.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-session.d.ts +22 -0
- package/dist/agent-executor/acp/v1-session.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-turn.d.ts +25 -0
- package/dist/agent-executor/acp/v1-turn.d.ts.map +1 -0
- package/dist/agent-executor/claude/classify.d.ts +54 -0
- package/dist/agent-executor/claude/classify.d.ts.map +1 -0
- package/dist/agent-executor/claude/cli-driver.d.ts +27 -0
- package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -0
- package/dist/agent-executor/claude/limits.d.ts +8 -0
- package/dist/agent-executor/claude/limits.d.ts.map +1 -0
- package/dist/agent-executor/claude/protocol.d.ts +188 -0
- package/dist/agent-executor/claude/protocol.d.ts.map +1 -0
- package/dist/agent-executor/claude/scenarios.d.ts +4 -0
- package/dist/agent-executor/claude/scenarios.d.ts.map +1 -0
- package/dist/agent-executor/claude/session.d.ts +22 -0
- package/dist/agent-executor/claude/session.d.ts.map +1 -0
- package/dist/agent-executor/claude/transcript.d.ts +33 -0
- package/dist/agent-executor/claude/transcript.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/driver.d.ts +31 -0
- package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/session.d.ts +10 -0
- package/dist/agent-executor/claude-sdk/session.d.ts.map +1 -0
- package/dist/agent-executor/codex/classify.d.ts +28 -0
- package/dist/agent-executor/codex/classify.d.ts.map +1 -0
- package/dist/agent-executor/codex/driver.d.ts +23 -0
- package/dist/agent-executor/codex/driver.d.ts.map +1 -0
- package/dist/agent-executor/codex/limits.d.ts +4 -0
- package/dist/agent-executor/codex/limits.d.ts.map +1 -0
- package/dist/agent-executor/codex/protocol.d.ts +152 -0
- package/dist/agent-executor/codex/protocol.d.ts.map +1 -0
- package/dist/agent-executor/codex/scenarios.d.ts +4 -0
- package/dist/agent-executor/codex/scenarios.d.ts.map +1 -0
- package/dist/agent-executor/codex/session.d.ts +41 -0
- package/dist/agent-executor/codex/session.d.ts.map +1 -0
- package/dist/agent-executor/contract.d.ts +454 -0
- package/dist/agent-executor/contract.d.ts.map +1 -0
- package/dist/agent-executor/dispatch.d.ts +41 -0
- package/dist/agent-executor/dispatch.d.ts.map +1 -0
- package/dist/agent-executor/engine-process.d.ts +45 -0
- package/dist/agent-executor/engine-process.d.ts.map +1 -0
- package/dist/agent-executor/engine-requests.d.ts +63 -0
- package/dist/agent-executor/engine-requests.d.ts.map +1 -0
- package/dist/agent-executor/engine.d.ts +64 -0
- package/dist/agent-executor/engine.d.ts.map +1 -0
- package/dist/agent-executor/executor-contract.d.ts +387 -0
- package/dist/agent-executor/executor-contract.d.ts.map +1 -0
- package/dist/agent-executor/executor-machine.d.ts +50 -0
- package/dist/agent-executor/executor-machine.d.ts.map +1 -0
- package/dist/agent-executor/hello.d.ts +235 -0
- package/dist/agent-executor/hello.d.ts.map +1 -0
- package/dist/agent-executor/json-rpc-peer.d.ts +48 -0
- package/dist/agent-executor/json-rpc-peer.d.ts.map +1 -0
- package/dist/agent-executor/leases.d.ts +159 -0
- package/dist/agent-executor/leases.d.ts.map +1 -0
- package/dist/agent-executor/plan-limits.d.ts +25 -0
- package/dist/agent-executor/plan-limits.d.ts.map +1 -0
- package/dist/agent-executor/profile.d.ts +52 -0
- package/dist/agent-executor/profile.d.ts.map +1 -0
- package/dist/agent-executor/projection.d.ts +14 -0
- package/dist/agent-executor/projection.d.ts.map +1 -0
- package/dist/agent-executor/session-primitives.d.ts +72 -0
- package/dist/agent-executor/session-primitives.d.ts.map +1 -0
- package/dist/agent-executor/testing/conformance.d.ts +55 -0
- package/dist/agent-executor/testing/conformance.d.ts.map +1 -0
- package/dist/agent-executor/testing/fake-claude-engine.d.ts +18 -0
- package/dist/agent-executor/testing/fake-claude-engine.d.ts.map +1 -0
- package/dist/agent-executor/testing/fake-engine.d.ts +52 -0
- package/dist/agent-executor/testing/fake-engine.d.ts.map +1 -0
- package/dist/agent-executor/turn-phases.d.ts +10 -0
- package/dist/agent-executor/turn-phases.d.ts.map +1 -0
- package/dist/agent-executor/vocabulary.d.ts +353 -0
- package/dist/agent-executor/vocabulary.d.ts.map +1 -0
- package/dist/agent-parts/parts.d.ts +160 -0
- package/dist/agent-parts/parts.d.ts.map +1 -0
- package/dist/agent-runtime/agent-tool.d.ts +1 -1
- package/dist/agent-runtime/agent-tool.d.ts.map +1 -1
- package/dist/agent-runtime/archive-projection.d.ts +5 -0
- package/dist/agent-runtime/archive-projection.d.ts.map +1 -1
- package/dist/agent-runtime/branch-contract.d.ts +59 -2
- package/dist/agent-runtime/branch-contract.d.ts.map +1 -1
- package/dist/agent-runtime/branch-events.d.ts +7 -0
- package/dist/agent-runtime/branch-events.d.ts.map +1 -1
- package/dist/agent-runtime/branch-identities.d.ts +40 -6
- package/dist/agent-runtime/branch-identities.d.ts.map +1 -1
- package/dist/agent-runtime/branch-messages.d.ts +11 -29
- package/dist/agent-runtime/branch-messages.d.ts.map +1 -1
- package/dist/agent-runtime/branch-observations.d.ts +138 -28
- package/dist/agent-runtime/branch-observations.d.ts.map +1 -1
- package/dist/agent-runtime/branch-provider.d.ts +32 -51
- package/dist/agent-runtime/branch-provider.d.ts.map +1 -1
- package/dist/agent-runtime/branch-refusal.d.ts +60 -0
- package/dist/agent-runtime/branch-refusal.d.ts.map +1 -0
- package/dist/agent-runtime/branch-runtime-tools.d.ts +14 -0
- package/dist/agent-runtime/branch-runtime-tools.d.ts.map +1 -0
- package/dist/agent-runtime/branch-source.d.ts +7 -2
- package/dist/agent-runtime/branch-source.d.ts.map +1 -1
- package/dist/agent-runtime/branch-transitions.d.ts.map +1 -1
- package/dist/agent-runtime/browser-control-contract.d.ts +2 -2
- package/dist/agent-runtime/browser-controller.d.ts.map +1 -1
- package/dist/agent-runtime/child-blocking.d.ts +17 -6
- package/dist/agent-runtime/child-blocking.d.ts.map +1 -1
- package/dist/agent-runtime/child-budget-policy.d.ts +4 -9
- package/dist/agent-runtime/child-budget-policy.d.ts.map +1 -1
- package/dist/agent-runtime/child-tools.d.ts +19 -8
- package/dist/agent-runtime/child-tools.d.ts.map +1 -1
- package/dist/agent-runtime/children-contract.d.ts +84 -3
- package/dist/agent-runtime/children-contract.d.ts.map +1 -1
- package/dist/agent-runtime/children-control.d.ts +23 -2
- package/dist/agent-runtime/children-control.d.ts.map +1 -1
- package/dist/agent-runtime/children-spawn.d.ts +9 -0
- package/dist/agent-runtime/children-spawn.d.ts.map +1 -1
- package/dist/agent-runtime/children-state.d.ts +121 -19
- package/dist/agent-runtime/children-state.d.ts.map +1 -1
- package/dist/agent-runtime/children-usage.d.ts +10 -1
- package/dist/agent-runtime/children-usage.d.ts.map +1 -1
- package/dist/agent-runtime/children.d.ts +3 -3
- package/dist/agent-runtime/children.d.ts.map +1 -1
- package/dist/agent-runtime/{sandbox-coding.d.ts → coding-sandbox.d.ts} +2 -9
- package/dist/agent-runtime/coding-sandbox.d.ts.map +1 -0
- package/dist/agent-runtime/coding-shell-process.d.ts +2 -0
- package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts +32 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-shell.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tools.d.ts.map +1 -1
- package/dist/agent-runtime/compaction.d.ts.map +1 -1
- package/dist/agent-runtime/companion-host.d.ts +38 -0
- package/dist/agent-runtime/companion-host.d.ts.map +1 -0
- package/dist/agent-runtime/context-issue.d.ts +5 -0
- package/dist/agent-runtime/context-issue.d.ts.map +1 -0
- package/dist/agent-runtime/control-schema.d.ts +2 -2
- package/dist/agent-runtime/control-schema.d.ts.map +1 -1
- package/dist/agent-runtime/conversations.d.ts.map +1 -1
- package/dist/agent-runtime/coordinator.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tool-types.d.ts +17 -5
- package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tools-internal.d.ts +2 -0
- package/dist/agent-runtime/deferred-tools-internal.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tools.d.ts.map +1 -1
- package/dist/agent-runtime/event-durability.d.ts +8 -0
- package/dist/agent-runtime/event-durability.d.ts.map +1 -0
- package/dist/agent-runtime/event-schema.d.ts +13 -5
- package/dist/agent-runtime/event-schema.d.ts.map +1 -1
- package/dist/agent-runtime/event-search-postgres.d.ts +38 -0
- package/dist/agent-runtime/event-search-postgres.d.ts.map +1 -0
- package/dist/agent-runtime/event-search-terms.d.ts +37 -0
- package/dist/agent-runtime/event-search-terms.d.ts.map +1 -0
- package/dist/agent-runtime/event-search-tools.d.ts +64 -4
- package/dist/agent-runtime/event-search-tools.d.ts.map +1 -1
- package/dist/agent-runtime/event-search.d.ts +16 -3
- package/dist/agent-runtime/event-search.d.ts.map +1 -1
- package/dist/agent-runtime/fault-bench.d.ts.map +1 -1
- package/dist/agent-runtime/harness-control.d.ts +8 -0
- package/dist/agent-runtime/harness-control.d.ts.map +1 -1
- package/dist/agent-runtime/harness-realtime.d.ts +0 -2
- package/dist/agent-runtime/harness-realtime.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-read.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-schema.d.ts +23 -0
- package/dist/agent-runtime/invocation-schema.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-spend.d.ts +9 -0
- package/dist/agent-runtime/invocation-spend.d.ts.map +1 -0
- package/dist/agent-runtime/invocations.d.ts.map +1 -1
- package/dist/agent-runtime/managed-tools.d.ts +2 -2
- package/dist/agent-runtime/managed-tools.d.ts.map +1 -1
- package/dist/agent-runtime/observability.d.ts +42 -4
- package/dist/agent-runtime/observability.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter-admission.d.ts +81 -0
- package/dist/agent-runtime/openrouter-admission.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-catalog.d.ts +83 -0
- package/dist/agent-runtime/openrouter-catalog.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-models.d.ts +66 -0
- package/dist/agent-runtime/openrouter-models.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-options.d.ts +106 -0
- package/dist/agent-runtime/openrouter-options.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-route.d.ts +50 -0
- package/dist/agent-runtime/openrouter-route.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-spend.d.ts +24 -0
- package/dist/agent-runtime/openrouter-spend.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter.d.ts +23 -2
- package/dist/agent-runtime/openrouter.d.ts.map +1 -1
- package/dist/agent-runtime/owned-provider-stream.d.ts.map +1 -1
- package/dist/agent-runtime/postgres-schema.d.ts +34 -0
- package/dist/agent-runtime/postgres-schema.d.ts.map +1 -0
- package/dist/agent-runtime/postgres-transactions.d.ts +54 -0
- package/dist/agent-runtime/postgres-transactions.d.ts.map +1 -0
- package/dist/agent-runtime/postgres.d.ts +72 -0
- package/dist/agent-runtime/postgres.d.ts.map +1 -0
- package/dist/agent-runtime/projections.d.ts +57 -17
- package/dist/agent-runtime/projections.d.ts.map +1 -1
- package/dist/agent-runtime/provider-journal.d.ts +57 -0
- package/dist/agent-runtime/provider-journal.d.ts.map +1 -1
- package/dist/agent-runtime/purge.d.ts.map +1 -1
- package/dist/agent-runtime/retry-policy.d.ts +6 -0
- package/dist/agent-runtime/retry-policy.d.ts.map +1 -1
- package/dist/agent-runtime/run-acquisition.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution-state.d.ts +26 -2
- package/dist/agent-runtime/run-execution-state.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/run-failure.d.ts.map +1 -1
- package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -1
- package/dist/agent-runtime/run-provider-ledger.d.ts +2 -0
- package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -1
- package/dist/agent-runtime/run-step-barriers.d.ts +72 -0
- package/dist/agent-runtime/run-step-barriers.d.ts.map +1 -0
- package/dist/agent-runtime/run-step-spend.d.ts +319 -0
- package/dist/agent-runtime/run-step-spend.d.ts.map +1 -0
- package/dist/agent-runtime/run-stream-parts.d.ts +2 -0
- package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -1
- package/dist/agent-runtime/{tool-progress.d.ts → run-tool-progress.d.ts} +1 -1
- package/dist/agent-runtime/run-tool-progress.d.ts.map +1 -0
- package/dist/agent-runtime/run-turn-preparation.d.ts +3 -1
- package/dist/agent-runtime/run-turn-preparation.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-admission-gate.d.ts +0 -14
- package/dist/agent-runtime/runtime-admission-gate.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-internals.d.ts +6 -0
- package/dist/agent-runtime/runtime-internals.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-state.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +31 -2
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-binding.d.ts +10 -0
- package/dist/agent-runtime/sandbox-binding.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-bubblewrap-storage.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-contract.d.ts +1 -1
- package/dist/agent-runtime/sandbox-contract.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox.d.ts +5 -0
- package/dist/agent-runtime/sandbox.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-contract.d.ts +3 -2
- package/dist/agent-runtime/schedule-contract.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-dispatch.d.ts +3 -2
- package/dist/agent-runtime/schedule-dispatch.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-records.d.ts +6 -6
- package/dist/agent-runtime/schedule-records.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-tools.d.ts +19 -8
- package/dist/agent-runtime/schedule-tools.d.ts.map +1 -1
- package/dist/agent-runtime/schedules.d.ts +13 -3
- package/dist/agent-runtime/schedules.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-message.d.ts +118 -0
- package/dist/agent-runtime/schemas-message.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-provider.d.ts +8 -0
- package/dist/agent-runtime/schemas-provider.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-records.d.ts +5 -0
- package/dist/agent-runtime/schemas-records.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-run.d.ts +487 -0
- package/dist/agent-runtime/schemas-run.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-usage.d.ts +129 -0
- package/dist/agent-runtime/schemas-usage.d.ts.map +1 -0
- package/dist/agent-runtime/schemas.d.ts +11 -886
- package/dist/agent-runtime/schemas.d.ts.map +1 -1
- package/dist/agent-runtime/spill.d.ts +9 -7
- package/dist/agent-runtime/spill.d.ts.map +1 -1
- package/dist/agent-runtime/sql-events.d.ts +6 -0
- package/dist/agent-runtime/sql-events.d.ts.map +1 -0
- package/dist/agent-runtime/sql-history.d.ts +8 -0
- package/dist/agent-runtime/sql-history.d.ts.map +1 -0
- package/dist/agent-runtime/sql-ledger.d.ts +5 -0
- package/dist/agent-runtime/sql-ledger.d.ts.map +1 -0
- package/dist/agent-runtime/sql-purge.d.ts +13 -0
- package/dist/agent-runtime/sql-purge.d.ts.map +1 -0
- package/dist/agent-runtime/sql-reads.d.ts +16 -0
- package/dist/agent-runtime/sql-reads.d.ts.map +1 -0
- package/dist/agent-runtime/{sqlite-rows.d.ts → sql-rows.d.ts} +24 -10
- package/dist/agent-runtime/sql-rows.d.ts.map +1 -0
- package/dist/agent-runtime/sql-session.d.ts +71 -0
- package/dist/agent-runtime/sql-session.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-bun.d.ts +1 -1
- package/dist/agent-runtime/sqlite-bun.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-node.d.ts +1 -1
- package/dist/agent-runtime/sqlite-node.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-purge.d.ts +2 -3
- package/dist/agent-runtime/sqlite-purge.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-schema.d.ts +1 -1
- package/dist/agent-runtime/sqlite-schema.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-transactions.d.ts +10 -6
- package/dist/agent-runtime/sqlite-transactions.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite.d.ts +10 -29
- package/dist/agent-runtime/sqlite.d.ts.map +1 -1
- package/dist/agent-runtime/state-tools.d.ts +8 -4
- package/dist/agent-runtime/state-tools.d.ts.map +1 -1
- package/dist/agent-runtime/store-archive.d.ts.map +1 -1
- package/dist/agent-runtime/store-branch.d.ts +6 -1
- package/dist/agent-runtime/store-branch.d.ts.map +1 -1
- package/dist/agent-runtime/store-capabilities.d.ts +42 -0
- package/dist/agent-runtime/store-capabilities.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-branch.d.ts +5 -2
- package/dist/agent-runtime/store-conformance-branch.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-capabilities.d.ts +6 -0
- package/dist/agent-runtime/store-conformance-capabilities.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-event-once.d.ts +12 -0
- package/dist/agent-runtime/store-conformance-event-once.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +20 -20
- package/dist/agent-runtime/store-conformance-seed.d.ts +8 -0
- package/dist/agent-runtime/store-conformance-seed.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance.d.ts +31 -8
- package/dist/agent-runtime/store-conformance.d.ts.map +1 -1
- package/dist/agent-runtime/store-create.d.ts +1 -1
- package/dist/agent-runtime/store-create.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver-contract.d.ts +15 -8
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
- package/dist/agent-runtime/store-event-once.d.ts.map +1 -1
- package/dist/agent-runtime/store-events.d.ts +114 -0
- package/dist/agent-runtime/store-events.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory-archive.d.ts +2 -0
- package/dist/agent-runtime/store-memory-archive.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory.d.ts +2 -2
- package/dist/agent-runtime/store-memory.d.ts.map +1 -1
- package/dist/agent-runtime/store-mutate.d.ts.map +1 -1
- package/dist/agent-runtime/store-reduce-shared.d.ts +2 -1
- package/dist/agent-runtime/store-reduce-shared.d.ts.map +1 -1
- package/dist/agent-runtime/store-reducer.d.ts.map +1 -1
- package/dist/agent-runtime/store-replay.d.ts.map +1 -1
- package/dist/agent-runtime/store.d.ts +15 -2
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-commit.d.ts +10 -10
- package/dist/application/admission-run.d.ts.map +1 -1
- package/dist/application/admission.d.ts.map +1 -1
- package/dist/application/change-subscription.d.ts.map +1 -1
- package/dist/application/decisions.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-lock-format.d.ts +9 -0
- package/dist/application/diagnostic-journal-lock-format.d.ts.map +1 -0
- package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
- package/dist/application/directory-inbox-delivery.d.ts.map +1 -1
- package/dist/application/grammy-update-admission.d.ts.map +1 -1
- package/dist/application/health.d.ts.map +1 -1
- package/dist/application/kernel-admission.d.ts.map +1 -1
- package/dist/application/kernel-contract.d.ts.map +1 -1
- package/dist/application/kernel-restart.d.ts.map +1 -1
- package/dist/application/kernel-rollback.d.ts.map +1 -1
- package/dist/application/kernel-shutdown.d.ts.map +1 -1
- package/dist/application/kernel-state.d.ts.map +1 -1
- package/dist/application/notification-outbox-state.d.ts.map +1 -1
- package/dist/application/notification-outbox.d.ts +1 -1
- package/dist/application/notification-outbox.d.ts.map +1 -1
- package/dist/application/revision-signal.d.ts.map +1 -1
- package/dist/application/schedule-run.d.ts.map +1 -1
- package/dist/application/schedule.d.ts.map +1 -1
- package/dist/application/sqlite-migrations.d.ts +104 -0
- package/dist/application/sqlite-migrations.d.ts.map +1 -0
- package/dist/application/watch-hub-core.d.ts.map +1 -1
- package/dist/browser/bridge-errors.d.ts +24 -0
- package/dist/browser/bridge-errors.d.ts.map +1 -0
- package/dist/browser/bridge-fetch.d.ts +30 -0
- package/dist/browser/bridge-fetch.d.ts.map +1 -0
- package/dist/browser/bridge-inbound.d.ts +28 -0
- package/dist/browser/bridge-inbound.d.ts.map +1 -0
- package/dist/browser/cancellation.d.ts +10 -2
- package/dist/browser/cancellation.d.ts.map +1 -1
- package/dist/browser/chunked-upload.d.ts +1 -1
- package/dist/browser/chunked-upload.d.ts.map +1 -1
- package/dist/browser/client-call-arguments.d.ts +31 -0
- package/dist/browser/client-call-arguments.d.ts.map +1 -0
- package/dist/browser/client-executors.d.ts +6 -0
- package/dist/browser/client-executors.d.ts.map +1 -1
- package/dist/browser/client.d.ts +9 -0
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/http.d.ts +17 -2
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/browser/realtime-client.d.ts +0 -5
- package/dist/browser/realtime-client.d.ts.map +1 -1
- package/dist/browser/session-credentials-storage.d.ts +48 -0
- package/dist/browser/session-credentials-storage.d.ts.map +1 -0
- package/dist/browser/session-credentials.d.ts +26 -5
- package/dist/browser/session-credentials.d.ts.map +1 -1
- package/dist/browser/session-refresh-policy.d.ts +124 -0
- package/dist/browser/session-refresh-policy.d.ts.map +1 -0
- package/dist/browser/session-refresh-timer.d.ts +30 -0
- package/dist/browser/session-refresh-timer.d.ts.map +1 -0
- package/dist/browser/session.d.ts.map +1 -1
- package/dist/browser/socket-io-connection.d.ts.map +1 -1
- package/dist/browser/socket-io-explicit-peer.d.ts +0 -1
- package/dist/browser/socket-io-explicit-peer.d.ts.map +1 -1
- package/dist/browser/stream.d.ts +1 -1
- package/dist/browser/stream.d.ts.map +1 -1
- package/dist/browser/upload-progress.d.ts +3 -0
- package/dist/browser/upload-progress.d.ts.map +1 -1
- package/dist/contract/bridge-envelope.d.ts +155 -0
- package/dist/contract/bridge-envelope.d.ts.map +1 -0
- package/dist/contract/define-validation.d.ts +2 -0
- package/dist/contract/define-validation.d.ts.map +1 -1
- package/dist/contract/define.d.ts +3 -0
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/errors.d.ts +4 -4
- package/dist/contract/errors.d.ts.map +1 -1
- package/dist/contract/normalize.d.ts +3 -1
- package/dist/contract/normalize.d.ts.map +1 -1
- package/dist/contract/operation-effect.d.ts +29 -0
- package/dist/contract/operation-effect.d.ts.map +1 -0
- package/dist/contract/runtime-context.d.ts +2 -0
- package/dist/contract/runtime-context.d.ts.map +1 -1
- package/dist/contract/tool-options.d.ts +7 -0
- package/dist/contract/tool-options.d.ts.map +1 -1
- package/dist/declaration/command.d.ts +26 -0
- package/dist/declaration/command.d.ts.map +1 -0
- package/dist/declaration/declaration.d.ts +4 -22
- package/dist/declaration/declaration.d.ts.map +1 -1
- package/dist/declaration/machine-names.d.ts +11 -0
- package/dist/declaration/machine-names.d.ts.map +1 -0
- package/dist/durability/effect.d.ts.map +1 -1
- package/dist/durability/engine.d.ts.map +1 -1
- package/dist/durability/events.d.ts +5 -8
- package/dist/durability/events.d.ts.map +1 -1
- package/dist/durability/parks.d.ts +0 -5
- package/dist/durability/parks.d.ts.map +1 -1
- package/dist/durability/scheduler.d.ts +5 -0
- package/dist/durability/scheduler.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.d.ts +4 -0
- package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/acp.js +910 -0
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts +2 -0
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/claude-sdk.js +309 -0
- package/dist/entrypoints/agent-executor/claude.d.ts +5 -0
- package/dist/entrypoints/agent-executor/claude.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/claude.js +403 -0
- package/dist/entrypoints/agent-executor/codex.d.ts +4 -0
- package/dist/entrypoints/agent-executor/codex.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/codex.js +798 -0
- package/dist/entrypoints/agent-executor/testing.d.ts +4 -0
- package/dist/entrypoints/agent-executor/testing.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/testing.js +375 -0
- package/dist/entrypoints/agent-executor.d.ts +15 -0
- package/dist/entrypoints/agent-executor.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor.js +455 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts +1 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/browser.js +60 -30
- package/dist/entrypoints/agent-runtime/coding-tools.js +9 -12
- package/dist/entrypoints/agent-runtime/harness.js +35 -22
- package/dist/entrypoints/agent-runtime/openrouter.d.ts +6 -0
- package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/openrouter.js +675 -45
- package/dist/entrypoints/agent-runtime/postgres.d.ts +4 -0
- package/dist/entrypoints/agent-runtime/postgres.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/postgres.js +330 -0
- package/dist/entrypoints/agent-runtime/realtime.js +46 -49
- package/dist/entrypoints/agent-runtime/sandbox.d.ts +3 -1
- package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/sandbox.js +74 -67
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +18 -18
- package/dist/entrypoints/agent-runtime/sqlite/node.js +18 -18
- package/dist/entrypoints/agent-runtime/testing.d.ts +1 -1
- package/dist/entrypoints/agent-runtime/testing.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/testing.js +394 -95
- package/dist/entrypoints/agent-runtime.d.ts +21 -13
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +1280 -1086
- package/dist/entrypoints/application/diagnostic-journal.js +16 -11
- package/dist/entrypoints/application/directory-inbox.js +20 -14
- package/dist/entrypoints/application/grammy.js +11 -8
- package/dist/entrypoints/application/opentelemetry.js +3 -3
- package/dist/entrypoints/application.d.ts +4 -2
- package/dist/entrypoints/application.d.ts.map +1 -1
- package/dist/entrypoints/application.js +409 -108
- package/dist/entrypoints/bin/upgrade-cli.d.ts +0 -12
- package/dist/entrypoints/bin/upgrade-cli.d.ts.map +1 -1
- package/dist/entrypoints/bin/upgrade-cli.js +11 -7
- package/dist/entrypoints/cli/publish.js +10 -9
- package/dist/entrypoints/cli.d.ts +10 -3
- package/dist/entrypoints/cli.d.ts.map +1 -1
- package/dist/entrypoints/cli.js +91 -29
- package/dist/entrypoints/contract.d.ts +2 -1
- package/dist/entrypoints/contract.d.ts.map +1 -1
- package/dist/entrypoints/contract.js +13 -7
- package/dist/entrypoints/declaration.d.ts +2 -0
- package/dist/entrypoints/declaration.d.ts.map +1 -1
- package/dist/entrypoints/declaration.js +55 -44
- package/dist/entrypoints/files/packaging.js +8 -5
- package/dist/entrypoints/files.d.ts +5 -0
- package/dist/entrypoints/files.d.ts.map +1 -1
- package/dist/entrypoints/files.js +236 -47
- package/dist/entrypoints/geo.js +9 -4
- package/dist/entrypoints/google.js +14 -13
- package/dist/entrypoints/handler.d.ts +12 -0
- package/dist/entrypoints/handler.d.ts.map +1 -0
- package/dist/entrypoints/handler.js +350 -0
- package/dist/entrypoints/http.d.ts +4 -0
- package/dist/entrypoints/http.d.ts.map +1 -1
- package/dist/entrypoints/http.js +411 -5
- package/dist/entrypoints/index.d.ts +2 -0
- package/dist/entrypoints/index.d.ts.map +1 -1
- package/dist/entrypoints/index.js +664 -91
- package/dist/entrypoints/live.js +22 -12
- package/dist/entrypoints/node.d.ts +2 -1
- package/dist/entrypoints/node.d.ts.map +1 -1
- package/dist/entrypoints/node.js +34 -25
- package/dist/entrypoints/observability.d.ts +2 -0
- package/dist/entrypoints/observability.d.ts.map +1 -1
- package/dist/entrypoints/observability.js +205 -131
- package/dist/entrypoints/primitives.js +152 -14
- package/dist/entrypoints/process/owner-loss.js +2 -2
- package/dist/entrypoints/process.js +18 -92
- package/dist/entrypoints/react.js +6 -5
- package/dist/entrypoints/realtime.d.ts +1 -0
- package/dist/entrypoints/realtime.d.ts.map +1 -1
- package/dist/entrypoints/realtime.js +6 -3
- package/dist/entrypoints/release.js +4 -0
- package/dist/entrypoints/remote.js +7 -6
- package/dist/entrypoints/server.d.ts +3 -1
- package/dist/entrypoints/server.d.ts.map +1 -1
- package/dist/entrypoints/server.js +295 -194
- package/dist/entrypoints/service-host/macos.d.ts +16 -0
- package/dist/entrypoints/service-host/macos.d.ts.map +1 -0
- package/dist/entrypoints/service-host/macos.js +1998 -0
- package/dist/entrypoints/service-host.d.ts +23 -0
- package/dist/entrypoints/service-host.d.ts.map +1 -0
- package/dist/entrypoints/service-host.js +2544 -0
- package/dist/entrypoints/spend/testing.d.ts +2 -0
- package/dist/entrypoints/spend/testing.d.ts.map +1 -0
- package/dist/entrypoints/spend/testing.js +442 -0
- package/dist/entrypoints/spend.d.ts +8 -0
- package/dist/entrypoints/spend.d.ts.map +1 -0
- package/dist/entrypoints/spend.js +593 -0
- package/dist/entrypoints/sync/postgres.d.ts +12 -0
- package/dist/entrypoints/sync/postgres.d.ts.map +1 -0
- package/dist/entrypoints/sync/postgres.js +737 -0
- package/dist/entrypoints/sync.d.ts +12 -0
- package/dist/entrypoints/sync.d.ts.map +1 -0
- package/dist/entrypoints/sync.js +782 -0
- package/dist/entrypoints/telegram/grammy.js +5 -5
- package/dist/entrypoints/telegram/html.d.ts +2 -0
- package/dist/entrypoints/telegram/html.d.ts.map +1 -1
- package/dist/entrypoints/telegram/html.js +839 -2
- package/dist/entrypoints/telegram/screens.js +13 -15
- package/dist/entrypoints/telegram.d.ts +1 -1
- package/dist/entrypoints/telegram.d.ts.map +1 -1
- package/dist/entrypoints/telegram.js +286 -76
- package/dist/entrypoints/testing.js +33 -41
- package/dist/entrypoints/tools/agent.js +12 -9
- package/dist/entrypoints/tools/connections.js +664 -63
- package/dist/entrypoints/tools/contract.d.ts +2 -2
- package/dist/entrypoints/tools/contract.js +4 -1
- package/dist/entrypoints/tools/invoker.js +9 -7
- package/dist/entrypoints/tools/mcp.js +16 -13
- package/dist/entrypoints/tools/toolkit.js +21 -18
- package/dist/entrypoints/tools.d.ts +3 -1
- package/dist/entrypoints/tools.d.ts.map +1 -1
- package/dist/entrypoints/tools.js +105 -92
- package/dist/entrypoints/tracking/contract.js +2 -1
- package/dist/entrypoints/tracking/performance.js +4 -0
- package/dist/entrypoints/tracking.js +6 -1
- package/dist/entrypoints/voice.js +3 -3
- package/dist/entrypoints/xlsx.js +1 -1
- package/dist/files/boundary.d.ts.map +1 -1
- package/dist/files/chunk-spool.d.ts +27 -0
- package/dist/files/chunk-spool.d.ts.map +1 -1
- package/dist/files/directory-appearance.d.ts +44 -0
- package/dist/files/directory-appearance.d.ts.map +1 -0
- package/dist/files/file-io.d.ts.map +1 -1
- package/dist/files/file-stamp.d.ts +35 -0
- package/dist/files/file-stamp.d.ts.map +1 -0
- package/dist/files/json-file-reading.d.ts +37 -0
- package/dist/files/json-file-reading.d.ts.map +1 -0
- package/dist/files/native-packaging.d.ts.map +1 -1
- package/dist/files/polled-json.d.ts +121 -0
- package/dist/files/polled-json.d.ts.map +1 -0
- package/dist/files/regular-file.d.ts +125 -0
- package/dist/files/regular-file.d.ts.map +1 -0
- package/dist/geo/index.d.ts +2 -1
- package/dist/geo/index.d.ts.map +1 -1
- package/dist/geo/resolver.d.ts.map +1 -1
- package/dist/geo/types.d.ts +0 -1
- package/dist/geo/types.d.ts.map +1 -1
- package/dist/google/google.d.ts +6 -0
- package/dist/google/google.d.ts.map +1 -1
- package/dist/{index-w0eqdhyd.js → index-09f7w2qq.js} +6 -1
- package/dist/index-0djnptn8.js +501 -0
- package/dist/index-0hdm5sx6.js +1457 -0
- package/dist/{index-t05a2ry4.js → index-0p0s5hrj.js} +8 -14
- package/dist/{index-1c945ten.js → index-0r15pkjq.js} +1 -1
- package/dist/{index-v1swr26p.js → index-0tyt97nk.js} +2 -2
- package/dist/{index-332d0m9g.js → index-0x4mnwg5.js} +4 -0
- package/dist/index-118aebbg.js +48 -0
- package/dist/index-1q0n6zek.js +184 -0
- package/dist/index-27hck3z2.js +307 -0
- package/dist/index-2rf33y2h.js +77 -0
- package/dist/index-360j58vb.js +63 -0
- package/dist/{index-tt30h7mr.js → index-39n02e0q.js} +1 -1
- package/dist/index-3agqmmrg.js +42 -0
- package/dist/{index-n6hvd1r2.js → index-3b31z0pc.js} +22 -15
- package/dist/index-3djgv3ch.js +472 -0
- package/dist/{index-mfntvj58.js → index-3dq8466w.js} +1 -1
- package/dist/index-3gwp8ez6.js +200 -0
- package/dist/{index-x2d51zay.js → index-3ypvpkwr.js} +309 -345
- package/dist/index-4gk6k3zc.js +248 -0
- package/dist/index-4qvyhn23.js +40 -0
- package/dist/index-4s2w4g37.js +647 -0
- package/dist/index-4ynw5ktx.js +78 -0
- package/dist/index-5awtbyns.js +19 -0
- package/dist/{index-kxff9e9w.js → index-5e0zsbf7.js} +5 -4
- package/dist/{index-nz06qw5a.js → index-5jyjb4s0.js} +1 -1
- package/dist/{index-7zksb1ty.js → index-5ptwb6ka.js} +1 -1
- package/dist/{index-w3nv6kr8.js → index-5q0qpw3v.js} +54 -9
- package/dist/{index-mm89hd8v.js → index-5t4fpdct.js} +1 -1
- package/dist/{index-0v9xb8pz.js → index-5y7j383h.js} +5 -5
- package/dist/index-5zwac8ft.js +221 -0
- package/dist/{index-v62cpkx3.js → index-6g85s734.js} +1 -1
- package/dist/{index-sqc6ezrb.js → index-6kec3b14.js} +17 -4
- package/dist/{index-kqnd6a85.js → index-7416mhyh.js} +1 -1
- package/dist/{index-m0wsfmrc.js → index-7csn6pva.js} +37 -24
- package/dist/{index-dqpesdck.js → index-7grgs8cx.js} +25 -5
- package/dist/{index-jjvr9f15.js → index-7kfcb576.js} +129 -39
- package/dist/{index-cvjddnvd.js → index-7xp05h20.js} +19 -10
- package/dist/{index-48acz7z0.js → index-83n766x4.js} +91 -50
- package/dist/{index-ss67fxhj.js → index-877e9y8r.js} +7 -7
- package/dist/{index-aw6kx2e6.js → index-8gmmdz7k.js} +1 -1
- package/dist/{index-wt6rw7rf.js → index-8xr2eq99.js} +29 -21
- package/dist/{index-rz3z13e9.js → index-97q9kykw.js} +1 -1
- package/dist/index-97rp94ff.js +8 -0
- package/dist/{index-0w0hxp7n.js → index-9pv126eh.js} +3 -9
- package/dist/{index-x2rvpbtj.js → index-9wh98cpa.js} +110 -16
- package/dist/{index-egg0yp2j.js → index-9xr44d2g.js} +86 -210
- package/dist/{index-b2sey031.js → index-9y0afd5f.js} +24 -23
- package/dist/index-a725ayvz.js +405 -0
- package/dist/{index-nmaqxdx7.js → index-ac5rj3d4.js} +203 -90
- package/dist/{index-wqzw3qg9.js → index-agy5fqgf.js} +32 -13
- package/dist/index-ajmtxsky.js +193 -0
- package/dist/{index-ndjzbt2v.js → index-akf0xkrm.js} +4 -3
- package/dist/index-akfgymyr.js +8 -0
- package/dist/index-apv5xfef.js +13 -0
- package/dist/index-ax3wns1a.js +93 -0
- package/dist/{index-ft2wvst5.js → index-bbzvrq66.js} +1603 -342
- package/dist/index-bh4pmtr9.js +317 -0
- package/dist/{index-fa53vygr.js → index-bmaz3jzy.js} +3 -3
- package/dist/{index-8kzct1d6.js → index-bn2baakz.js} +143 -143
- package/dist/{index-m8ddk770.js → index-brhhaygm.js} +1 -1
- package/dist/index-caywx1c0.js +199 -0
- package/dist/index-cbhxhma2.js +90 -0
- package/dist/index-cfnmvcq8.js +11 -0
- package/dist/index-cv9b7fz2.js +42 -0
- package/dist/index-d4svrknj.js +156 -0
- package/dist/{index-a3z56mtn.js → index-d96c1n1q.js} +5 -3
- package/dist/{index-3ymcmpa9.js → index-dvd1qdwa.js} +33 -163
- package/dist/{index-v7rbjatr.js → index-dwa6pskj.js} +1837 -1151
- package/dist/{index-ne4j9998.js → index-e06z0tkb.js} +123 -94
- package/dist/{index-99nnsz39.js → index-en8e5zsj.js} +15 -135
- package/dist/index-fcw255hd.js +929 -0
- package/dist/{index-20hn8pbh.js → index-fmzg39a8.js} +1 -1
- package/dist/{index-fvd6pvw3.js → index-g1q7fwn9.js} +2 -2
- package/dist/index-g56ht6qf.js +98 -0
- package/dist/{index-f56ct5gb.js → index-gj1rjf78.js} +4 -3
- package/dist/{index-g6a3na27.js → index-gnjgkecx.js} +7 -3
- package/dist/index-hy4653g4.js +345 -0
- package/dist/index-j13gzgdv.js +403 -0
- package/dist/{index-pa9bhefy.js → index-j516jaaz.js} +37 -11
- package/dist/{index-t8jz0e20.js → index-j903yhp4.js} +30 -38
- package/dist/{index-9ypczvpj.js → index-jb4m241t.js} +2 -0
- package/dist/index-jrka9029.js +177 -0
- package/dist/{index-cjzaj7ev.js → index-jxtg307y.js} +23 -21
- package/dist/index-kmbpej2y.js +1152 -0
- package/dist/{index-bz9cmnqq.js → index-kt6dh1n6.js} +4 -4
- package/dist/index-ky3ardqn.js +80 -0
- package/dist/index-kyejf658.js +14 -0
- package/dist/{index-zyc64nbh.js → index-kynwa08q.js} +52 -47
- package/dist/index-kzavdze2.js +15 -0
- package/dist/{index-m200b8hs.js → index-mbd92r1w.js} +5 -3
- package/dist/index-mxt0wfjy.js +58 -0
- package/dist/{index-9cxxfkhb.js → index-n20tybgk.js} +14 -9
- package/dist/index-nbv44x0x.js +250 -0
- package/dist/index-ngwf1s3c.js +51 -0
- package/dist/{index-zfncctjp.js → index-nk0cy9g1.js} +5 -4
- package/dist/index-p1m9djt6.js +108 -0
- package/dist/{index-hs76yzt7.js → index-paff5y0r.js} +17 -11
- package/dist/{index-qaet40b2.js → index-prf6ayhf.js} +5 -7
- package/dist/{index-hkxgennw.js → index-ps3djm8d.js} +7 -1
- package/dist/{index-1v3k5zgx.js → index-qnzhmk2s.js} +528 -1129
- package/dist/{index-3bzk2645.js → index-r9kq5ark.js} +1 -1
- package/dist/{index-hkw233vx.js → index-rbd2rq3z.js} +2 -2
- package/dist/{index-r0xr7y4m.js → index-rhb33thr.js} +138 -33
- package/dist/{index-kffm4r8w.js → index-rj32hkkp.js} +2 -2
- package/dist/index-rptj3qnc.js +96 -0
- package/dist/{index-hqsbtvta.js → index-rpyn7geq.js} +11 -3
- package/dist/{index-m9hb9wnk.js → index-sfzfd2m2.js} +2 -2
- package/dist/{index-sqkttz7z.js → index-sv5svtq7.js} +1 -1
- package/dist/{index-srs8hj9c.js → index-sx3g49y2.js} +5 -1
- package/dist/{index-9mjrnqxs.js → index-t1a2jrg7.js} +21 -91
- package/dist/{index-a6w6mwda.js → index-tazm4dxf.js} +1 -1
- package/dist/{index-b51tzcgh.js → index-tf70nm22.js} +2 -2
- package/dist/index-ttexdtjj.js +28 -0
- package/dist/{index-103dp7fz.js → index-v37b2cd6.js} +1956 -3151
- package/dist/{index-0ndz5r8z.js → index-v59pxmf1.js} +17 -9
- package/dist/{index-rfkh44ss.js → index-vgytj9wp.js} +1 -1
- package/dist/{index-tnnmekgb.js → index-wa6h4tz6.js} +3 -3
- package/dist/{index-4efxzrht.js → index-wavv538x.js} +211 -196
- package/dist/{index-1szhrfsf.js → index-wbnpa8z6.js} +7 -5
- package/dist/index-werjqesf.js +43 -0
- package/dist/{index-7qyv50r4.js → index-wv8dqy7q.js} +2 -2
- package/dist/index-wz392jyz.js +10 -0
- package/dist/{index-1d7s7da0.js → index-x6sp5vpa.js} +36 -5
- package/dist/{index-bqzgaj57.js → index-x90w78yz.js} +183 -61
- package/dist/index-xgae0bn7.js +37 -0
- package/dist/index-xmr47znh.js +160 -0
- package/dist/{index-ftk3838x.js → index-xq4s9mka.js} +7 -2
- package/dist/{index-ww3gss55.js → index-xrgn784x.js} +1 -1
- package/dist/{index-fpwbskp2.js → index-xtby8rj3.js} +1 -1
- package/dist/index-xtkw9866.js +107 -0
- package/dist/{index-btjwc7xr.js → index-xypxnzhp.js} +15 -14
- package/dist/{index-yex7eg1v.js → index-y7sy1xdp.js} +6 -2
- package/dist/index-z4k0hqp9.js +476 -0
- package/dist/{index-a7ebd769.js → index-zwgwyvdt.js} +3 -3
- package/dist/internal/abort-error.d.ts +9 -0
- package/dist/internal/abort-error.d.ts.map +1 -0
- package/dist/internal/abort-race.d.ts +47 -4
- package/dist/internal/abort-race.d.ts.map +1 -1
- package/dist/internal/atomic-file.d.ts +19 -0
- package/dist/internal/atomic-file.d.ts.map +1 -1
- package/dist/internal/backoff.d.ts.map +1 -1
- package/dist/internal/bounded-body.d.ts +37 -1
- package/dist/internal/bounded-body.d.ts.map +1 -1
- package/dist/internal/bounded-file-read.d.ts +31 -15
- package/dist/internal/bounded-file-read.d.ts.map +1 -1
- package/dist/internal/bun-command.d.ts +11 -0
- package/dist/internal/bun-command.d.ts.map +1 -1
- package/dist/internal/channel.d.ts.map +1 -1
- package/dist/internal/darwin-binding-error.d.ts.map +1 -1
- package/dist/internal/darwin-binding.d.ts +10 -0
- package/dist/internal/darwin-binding.d.ts.map +1 -1
- package/dist/internal/deadline.d.ts +22 -2
- package/dist/internal/deadline.d.ts.map +1 -1
- package/dist/internal/exclusive-lock-owner.d.ts +20 -1
- package/dist/internal/exclusive-lock-owner.d.ts.map +1 -1
- package/dist/internal/exclusive-lock-read.d.ts +2 -0
- package/dist/internal/exclusive-lock-read.d.ts.map +1 -1
- package/dist/internal/exclusive-lock.d.ts +26 -0
- package/dist/internal/exclusive-lock.d.ts.map +1 -1
- package/dist/internal/file-observation.d.ts +49 -0
- package/dist/internal/file-observation.d.ts.map +1 -1
- package/dist/internal/json-response.d.ts +10 -0
- package/dist/internal/json-response.d.ts.map +1 -0
- package/dist/internal/open-descriptors.d.ts +5 -0
- package/dist/internal/open-descriptors.d.ts.map +1 -1
- package/dist/internal/optional-peer.d.ts.map +1 -1
- package/dist/internal/pinned-http.d.ts.map +1 -1
- package/dist/internal/positive-integer.d.ts +14 -6
- package/dist/internal/positive-integer.d.ts.map +1 -1
- package/dist/internal/postgres-query.d.ts +16 -0
- package/dist/internal/postgres-query.d.ts.map +1 -0
- package/dist/internal/process-identity.d.ts +21 -1
- package/dist/internal/process-identity.d.ts.map +1 -1
- package/dist/internal/process-instance.d.ts +6 -0
- package/dist/internal/process-instance.d.ts.map +1 -1
- package/dist/internal/request.d.ts +4 -0
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/secret-equal.d.ts +11 -0
- package/dist/internal/secret-equal.d.ts.map +1 -0
- package/dist/internal/secure-fetch.d.ts.map +1 -1
- package/dist/internal/sqlite.d.ts +8 -0
- package/dist/internal/sqlite.d.ts.map +1 -1
- package/dist/internal/timers.d.ts +20 -0
- package/dist/internal/timers.d.ts.map +1 -1
- package/dist/internal/typed.d.ts +11 -0
- package/dist/internal/typed.d.ts.map +1 -1
- package/dist/internal/unix-client-error.d.ts +21 -0
- package/dist/internal/unix-client-error.d.ts.map +1 -0
- package/dist/internal/unix-socket-lock.d.ts +23 -0
- package/dist/internal/unix-socket-lock.d.ts.map +1 -0
- package/dist/internal/unix-socket.d.ts +60 -0
- package/dist/internal/unix-socket.d.ts.map +1 -1
- package/dist/internal/upgrade-affects.d.ts +3 -3
- package/dist/internal/upgrade-affects.d.ts.map +1 -1
- package/dist/internal/upgrade-plan.d.ts.map +1 -1
- package/dist/json-schema/dialect.d.ts +0 -6
- package/dist/json-schema/dialect.d.ts.map +1 -1
- package/dist/json-schema/keywords.d.ts +116 -0
- package/dist/json-schema/keywords.d.ts.map +1 -0
- package/dist/json-schema/string-format.d.ts.map +1 -1
- package/dist/live/events.d.ts.map +1 -1
- package/dist/live/watch-client.d.ts.map +1 -1
- package/dist/observability/bounded-logger.d.ts +3 -0
- package/dist/observability/bounded-logger.d.ts.map +1 -1
- package/dist/observability/bounded-sink.d.ts.map +1 -1
- package/dist/observability/context.d.ts +12 -2
- package/dist/observability/context.d.ts.map +1 -1
- package/dist/observability/event-loop-delay.d.ts +62 -0
- package/dist/observability/event-loop-delay.d.ts.map +1 -0
- package/dist/observability/json-logger.d.ts.map +1 -1
- package/dist/observability/log-repeat.d.ts +44 -0
- package/dist/observability/log-repeat.d.ts.map +1 -0
- package/dist/observability/spool-core.d.ts +95 -0
- package/dist/observability/spool-core.d.ts.map +1 -0
- package/dist/observability/spool-file.d.ts +46 -0
- package/dist/observability/spool-file.d.ts.map +1 -0
- package/dist/observability/spool.d.ts +14 -8
- package/dist/observability/spool.d.ts.map +1 -1
- package/dist/observability/trace.d.ts.map +1 -1
- package/dist/observability/work.d.ts.map +1 -1
- package/dist/primitives/index.d.ts +1 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/order-key.d.ts +37 -0
- package/dist/primitives/order-key.d.ts.map +1 -0
- package/dist/process/bun-child.d.ts.map +1 -1
- package/dist/process/command-owner.d.ts.map +1 -1
- package/dist/process/contract.d.ts +4 -3
- package/dist/process/contract.d.ts.map +1 -1
- package/dist/process/group-presence.d.ts.map +1 -1
- package/dist/process/group.d.ts +5 -1
- package/dist/process/group.d.ts.map +1 -1
- package/dist/process/launch.d.ts +5 -3
- package/dist/process/launch.d.ts.map +1 -1
- package/dist/process/owner-loss-guard.d.ts.map +1 -1
- package/dist/react/cache-bridge.d.ts.map +1 -1
- package/dist/release/watcher.d.ts.map +1 -1
- package/dist/server/bridge-host.d.ts +51 -0
- package/dist/server/bridge-host.d.ts.map +1 -0
- package/dist/server/bun.d.ts +4 -4
- package/dist/server/bun.d.ts.map +1 -1
- package/dist/server/context-contribution.d.ts.map +1 -1
- package/dist/server/contract-method.d.ts.map +1 -1
- package/dist/server/create.d.ts +1 -0
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/endpoint-dispatch.d.ts.map +1 -1
- package/dist/server/endpoint-response.d.ts.map +1 -1
- package/dist/server/error-dispatch.d.ts +2 -0
- package/dist/server/error-dispatch.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +2 -0
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/handler-state.d.ts +13 -2
- package/dist/server/handler-state.d.ts.map +1 -1
- package/dist/server/implement.d.ts +1 -0
- package/dist/server/implement.d.ts.map +1 -1
- package/dist/server/local-host.d.ts +47 -0
- package/dist/server/local-host.d.ts.map +1 -0
- package/dist/server/logger.d.ts +20 -3
- package/dist/server/logger.d.ts.map +1 -1
- package/dist/server/logging.d.ts +2 -1
- package/dist/server/logging.d.ts.map +1 -1
- package/dist/server/middleware/cors.d.ts +1 -0
- package/dist/server/middleware/cors.d.ts.map +1 -1
- package/dist/server/middleware/signed-link.d.ts +42 -0
- package/dist/server/middleware/signed-link.d.ts.map +1 -0
- package/dist/server/multipart-reader.d.ts +3 -1
- package/dist/server/multipart-reader.d.ts.map +1 -1
- package/dist/server/multipart.d.ts.map +1 -1
- package/dist/server/oauth/cimd.d.ts.map +1 -1
- package/dist/server/oauth/endpoints.d.ts.map +1 -1
- package/dist/server/openapi.d.ts.map +1 -1
- package/dist/server/protocol-outcome.d.ts +17 -0
- package/dist/server/protocol-outcome.d.ts.map +1 -0
- package/dist/server/raw.d.ts.map +1 -1
- package/dist/server/request-completion.d.ts +3 -1
- package/dist/server/request-completion.d.ts.map +1 -1
- package/dist/server/shutdown.d.ts.map +1 -1
- package/dist/server/socket-io-config.d.ts +1 -1
- package/dist/server/socket-io-config.d.ts.map +1 -1
- package/dist/server/streaming-route.d.ts.map +1 -1
- package/dist/server/types.d.ts +13 -10
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/unix-client-body.d.ts +4 -1
- package/dist/server/unix-client-body.d.ts.map +1 -1
- package/dist/server/unix-client-bun.d.ts.map +1 -1
- package/dist/server/unix-client.d.ts +1 -1
- package/dist/server/unix-client.d.ts.map +1 -1
- package/dist/service-host/artifact-activation.d.ts +58 -0
- package/dist/service-host/artifact-activation.d.ts.map +1 -0
- package/dist/service-host/artifact-manifest.d.ts +68 -0
- package/dist/service-host/artifact-manifest.d.ts.map +1 -0
- package/dist/service-host/artifact.d.ts +43 -0
- package/dist/service-host/artifact.d.ts.map +1 -0
- package/dist/service-host/config-reloader-contract.d.ts +66 -0
- package/dist/service-host/config-reloader-contract.d.ts.map +1 -0
- package/dist/service-host/config-reloader-helpers.d.ts +32 -0
- package/dist/service-host/config-reloader-helpers.d.ts.map +1 -0
- package/dist/service-host/config-reloader-source.d.ts +47 -0
- package/dist/service-host/config-reloader-source.d.ts.map +1 -0
- package/dist/service-host/config-reloader.d.ts +6 -0
- package/dist/service-host/config-reloader.d.ts.map +1 -0
- package/dist/service-host/host-adapter.d.ts +72 -0
- package/dist/service-host/host-adapter.d.ts.map +1 -0
- package/dist/service-host/identity-unix-socket.d.ts +101 -0
- package/dist/service-host/identity-unix-socket.d.ts.map +1 -0
- package/dist/service-host/identity.d.ts +117 -0
- package/dist/service-host/identity.d.ts.map +1 -0
- package/dist/service-host/launchd-plist.d.ts +77 -0
- package/dist/service-host/launchd-plist.d.ts.map +1 -0
- package/dist/service-host/launchd-render.d.ts +91 -0
- package/dist/service-host/launchd-render.d.ts.map +1 -0
- package/dist/service-host/launchd.d.ts +82 -0
- package/dist/service-host/launchd.d.ts.map +1 -0
- package/dist/service-host/macos/bundle-plist.d.ts +50 -0
- package/dist/service-host/macos/bundle-plist.d.ts.map +1 -0
- package/dist/service-host/macos/bundle.d.ts +66 -0
- package/dist/service-host/macos/bundle.d.ts.map +1 -0
- package/dist/service-host/macos/codesign.d.ts +95 -0
- package/dist/service-host/macos/codesign.d.ts.map +1 -0
- package/dist/service-host/macos/icon.d.ts +93 -0
- package/dist/service-host/macos/icon.d.ts.map +1 -0
- package/dist/service-host/macos/launch-services.d.ts +88 -0
- package/dist/service-host/macos/launch-services.d.ts.map +1 -0
- package/dist/service-host/macos/launcher.d.ts +59 -0
- package/dist/service-host/macos/launcher.d.ts.map +1 -0
- package/dist/service-host/macos/responsibility.d.ts +90 -0
- package/dist/service-host/macos/responsibility.d.ts.map +1 -0
- package/dist/service-host/macos/runner.d.ts +69 -0
- package/dist/service-host/macos/runner.d.ts.map +1 -0
- package/dist/service-host/plist-xml.d.ts +48 -0
- package/dist/service-host/plist-xml.d.ts.map +1 -0
- package/dist/service-host/process-evidence.d.ts +17 -0
- package/dist/service-host/process-evidence.d.ts.map +1 -0
- package/dist/service-host/systemd-inspect.d.ts +126 -0
- package/dist/service-host/systemd-inspect.d.ts.map +1 -0
- package/dist/service-host/systemd-links.d.ts +23 -0
- package/dist/service-host/systemd-links.d.ts.map +1 -0
- package/dist/service-host/systemd-render.d.ts +93 -0
- package/dist/service-host/systemd-render.d.ts.map +1 -0
- package/dist/service-host/systemd.d.ts +50 -0
- package/dist/service-host/systemd.d.ts.map +1 -0
- package/dist/spend/attribution.d.ts +17 -0
- package/dist/spend/attribution.d.ts.map +1 -0
- package/dist/spend/coverage-guard.d.ts +60 -0
- package/dist/spend/coverage-guard.d.ts.map +1 -0
- package/dist/spend/coverage-lexer.d.ts +20 -0
- package/dist/spend/coverage-lexer.d.ts.map +1 -0
- package/dist/spend/facts.d.ts +23 -0
- package/dist/spend/facts.d.ts.map +1 -0
- package/dist/spend/gateway-stream.d.ts +25 -0
- package/dist/spend/gateway-stream.d.ts.map +1 -0
- package/dist/spend/gateway.d.ts +64 -0
- package/dist/spend/gateway.d.ts.map +1 -0
- package/dist/spend/receipt-merge.d.ts +13 -0
- package/dist/spend/receipt-merge.d.ts.map +1 -0
- package/dist/spend/receipt-spool.d.ts +35 -0
- package/dist/spend/receipt-spool.d.ts.map +1 -0
- package/dist/spend/reconcile.d.ts +45 -0
- package/dist/spend/reconcile.d.ts.map +1 -0
- package/dist/spend/schemas.d.ts +249 -0
- package/dist/spend/schemas.d.ts.map +1 -0
- package/dist/sync/outbox.d.ts +131 -0
- package/dist/sync/outbox.d.ts.map +1 -0
- package/dist/sync/overlay.d.ts +59 -0
- package/dist/sync/overlay.d.ts.map +1 -0
- package/dist/sync/protocol.d.ts +132 -0
- package/dist/sync/protocol.d.ts.map +1 -0
- package/dist/sync/server-store-check.d.ts +10 -0
- package/dist/sync/server-store-check.d.ts.map +1 -0
- package/dist/sync/server-store-memory.d.ts +14 -0
- package/dist/sync/server-store-memory.d.ts.map +1 -0
- package/dist/sync/server-store-postgres.d.ts +25 -0
- package/dist/sync/server-store-postgres.d.ts.map +1 -0
- package/dist/sync/server-store.d.ts +139 -0
- package/dist/sync/server-store.d.ts.map +1 -0
- package/dist/sync/session-machine.d.ts +79 -0
- package/dist/sync/session-machine.d.ts.map +1 -0
- package/dist/sync/session-snapshot.d.ts +19 -0
- package/dist/sync/session-snapshot.d.ts.map +1 -0
- package/dist/sync/session-steps.d.ts +15 -0
- package/dist/sync/session-steps.d.ts.map +1 -0
- package/dist/sync/session.d.ts +142 -0
- package/dist/sync/session.d.ts.map +1 -0
- package/dist/sync/tombstones.d.ts +53 -0
- package/dist/sync/tombstones.d.ts.map +1 -0
- package/dist/telegram/bot-api.d.ts.map +1 -1
- package/dist/telegram/broadcast-failure.d.ts.map +1 -1
- package/dist/telegram/budget-transformer.d.ts.map +1 -1
- package/dist/telegram/crypto.d.ts +2 -10
- package/dist/telegram/crypto.d.ts.map +1 -1
- package/dist/telegram/html/markdown-inline.d.ts +19 -0
- package/dist/telegram/html/markdown-inline.d.ts.map +1 -0
- package/dist/telegram/html/markdown-lines.d.ts +51 -0
- package/dist/telegram/html/markdown-lines.d.ts.map +1 -0
- package/dist/telegram/html/markdown-split.d.ts +49 -0
- package/dist/telegram/html/markdown-split.d.ts.map +1 -0
- package/dist/telegram/html/markdown.d.ts +14 -0
- package/dist/telegram/html/markdown.d.ts.map +1 -0
- package/dist/telegram/html/nodes.d.ts +26 -4
- package/dist/telegram/html/nodes.d.ts.map +1 -1
- package/dist/telegram/html/parse.d.ts.map +1 -1
- package/dist/telegram/html/render.d.ts.map +1 -1
- package/dist/telegram/init-data.d.ts.map +1 -1
- package/dist/telegram/local-files.d.ts.map +1 -1
- package/dist/telegram/operator-channel.d.ts +15 -2
- package/dist/telegram/operator-channel.d.ts.map +1 -1
- package/dist/telegram/outbound-budget.d.ts.map +1 -1
- package/dist/telegram/outbound-cost.d.ts +9 -1
- package/dist/telegram/outbound-cost.d.ts.map +1 -1
- package/dist/telegram/outbound-queue.d.ts +2 -1
- package/dist/telegram/outbound-queue.d.ts.map +1 -1
- package/dist/telegram/screens/outcome.d.ts.map +1 -1
- package/dist/telegram/send-failure.d.ts.map +1 -1
- package/dist/telegram/transport-connect.d.ts.map +1 -1
- package/dist/telegram/transport.d.ts.map +1 -1
- package/dist/telegram/update-intake.d.ts.map +1 -1
- package/dist/telegram/update-store-postgres.d.ts +2 -2
- package/dist/telegram/update-store-postgres.d.ts.map +1 -1
- package/dist/telegram/webhook.d.ts.map +1 -1
- package/dist/testing/managed-resource-conformance.d.ts.map +1 -1
- package/dist/testing/surface-conformance.d.ts.map +1 -1
- package/dist/testing/surface-manifest.d.ts +2 -0
- package/dist/testing/surface-manifest.d.ts.map +1 -1
- package/dist/tools/access.d.ts +34 -0
- package/dist/tools/access.d.ts.map +1 -0
- package/dist/tools/agent.d.ts +14 -6
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/cli/args-classify.d.ts +154 -0
- package/dist/tools/cli/args-classify.d.ts.map +1 -0
- package/dist/tools/cli/args-fields.d.ts +14 -7
- package/dist/tools/cli/args-fields.d.ts.map +1 -1
- package/dist/tools/cli/args-json.d.ts +1 -1
- package/dist/tools/cli/args-json.d.ts.map +1 -1
- package/dist/tools/cli/args-route.d.ts +4 -48
- package/dist/tools/cli/args-route.d.ts.map +1 -1
- package/dist/tools/cli/args-scan.d.ts +70 -0
- package/dist/tools/cli/args-scan.d.ts.map +1 -0
- package/dist/tools/cli/args-tokens.d.ts +2 -1
- package/dist/tools/cli/args-tokens.d.ts.map +1 -1
- package/dist/tools/cli/args.d.ts +31 -19
- package/dist/tools/cli/args.d.ts.map +1 -1
- package/dist/tools/cli/checkpoint.d.ts.map +1 -1
- package/dist/tools/cli/command-shape.d.ts +5 -0
- package/dist/tools/cli/command-shape.d.ts.map +1 -1
- package/dist/tools/cli/command.d.ts +57 -2
- package/dist/tools/cli/command.d.ts.map +1 -1
- package/dist/tools/cli/config.d.ts +15 -58
- package/dist/tools/cli/config.d.ts.map +1 -1
- package/dist/tools/cli/create-cli.d.ts +7 -3
- package/dist/tools/cli/create-cli.d.ts.map +1 -1
- package/dist/tools/cli/format.d.ts.map +1 -1
- package/dist/tools/cli/help.d.ts.map +1 -1
- package/dist/tools/cli/invoke.d.ts +70 -20
- package/dist/tools/cli/invoke.d.ts.map +1 -1
- package/dist/tools/cli/io.d.ts.map +1 -1
- package/dist/tools/cli/managed-surface.d.ts.map +1 -1
- package/dist/tools/cli/notices.d.ts.map +1 -1
- package/dist/tools/cli/policy.d.ts +66 -10
- package/dist/tools/cli/policy.d.ts.map +1 -1
- package/dist/tools/cli/prepare.d.ts +5 -4
- package/dist/tools/cli/prepare.d.ts.map +1 -1
- package/dist/tools/cli/run-managed.d.ts.map +1 -1
- package/dist/tools/cli/run-native.d.ts.map +1 -1
- package/dist/tools/cli/run-stream.d.ts.map +1 -1
- package/dist/tools/cli/runner.d.ts +28 -0
- package/dist/tools/cli/runner.d.ts.map +1 -0
- package/dist/tools/cli/session.d.ts +12 -6
- package/dist/tools/cli/session.d.ts.map +1 -1
- package/dist/tools/cli/stream-surface.d.ts.map +1 -1
- package/dist/tools/cli/stream.d.ts.map +1 -1
- package/dist/tools/cli/unavailable.d.ts +2 -0
- package/dist/tools/cli/unavailable.d.ts.map +1 -1
- package/dist/tools/cli/unix-outcome.d.ts +8 -0
- package/dist/tools/cli/unix-outcome.d.ts.map +1 -0
- package/dist/tools/cli/update.d.ts.map +1 -1
- package/dist/tools/cli/view-columns.d.ts +18 -0
- package/dist/tools/cli/view-columns.d.ts.map +1 -0
- package/dist/tools/cli/view.d.ts.map +1 -1
- package/dist/tools/connections/define.d.ts.map +1 -1
- package/dist/tools/connections/foreign-schema-join.d.ts +28 -0
- package/dist/tools/connections/foreign-schema-join.d.ts.map +1 -0
- package/dist/tools/connections/foreign-schema.d.ts +9 -0
- package/dist/tools/connections/foreign-schema.d.ts.map +1 -0
- package/dist/tools/connections/limits.d.ts +1 -1
- package/dist/tools/connections/limits.d.ts.map +1 -1
- package/dist/tools/connections/mcp-client.d.ts.map +1 -1
- package/dist/tools/connections/mcp.d.ts.map +1 -1
- package/dist/tools/connections/openapi.d.ts.map +1 -1
- package/dist/tools/connections/runtime.d.ts +18 -6
- package/dist/tools/connections/runtime.d.ts.map +1 -1
- package/dist/tools/connections/sse-session.d.ts.map +1 -1
- package/dist/tools/connections/types.d.ts +12 -2
- package/dist/tools/connections/types.d.ts.map +1 -1
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/internal/expose.d.ts +6 -0
- package/dist/tools/internal/expose.d.ts.map +1 -0
- package/dist/tools/internal/json-projection.d.ts +17 -0
- package/dist/tools/internal/json-projection.d.ts.map +1 -0
- package/dist/tools/internal/surface-projector.d.ts +18 -4
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/invoker.d.ts +9 -2
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/lifecycle.d.ts +8 -2
- package/dist/tools/lifecycle.d.ts.map +1 -1
- package/dist/tools/list-names.d.ts +1 -1
- package/dist/tools/list-names.d.ts.map +1 -1
- package/dist/tools/manifest.d.ts +2 -0
- package/dist/tools/manifest.d.ts.map +1 -1
- package/dist/tools/mcp/handler.d.ts.map +1 -1
- package/dist/tools/mcp/mount.d.ts +26 -14
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/prepare.d.ts +2 -0
- package/dist/tools/mcp/prepare.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts.map +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
- package/dist/tools/mcp/stdio.d.ts.map +1 -1
- package/dist/tools/mount.d.ts +7 -2
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/native-definition.d.ts +1 -1
- package/dist/tools/native-definition.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-runtime-tools.d.ts +2 -2
- package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-runtime-types.d.ts +1 -1
- package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -1
- package/dist/tools/operations/define-wait-tool.d.ts.map +1 -1
- package/dist/tools/operations/mount-wait.d.ts.map +1 -1
- package/dist/tools/operations/wait-core.d.ts.map +1 -1
- package/dist/tools/read-operation.d.ts +6 -4
- package/dist/tools/read-operation.d.ts.map +1 -1
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/runtime-tool-declaration.d.ts +4 -1
- package/dist/tools/runtime-tool-declaration.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +6 -1
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/schema/coerce.d.ts.map +1 -1
- package/dist/tools/schema/inline-references.d.ts +7 -0
- package/dist/tools/schema/inline-references.d.ts.map +1 -0
- package/dist/tools/schema/json-schema-origin.d.ts +1 -1
- package/dist/tools/schema/json-schema-origin.d.ts.map +1 -1
- package/dist/tools/schema/presentation.d.ts +6 -0
- package/dist/tools/schema/presentation.d.ts.map +1 -1
- package/dist/tools/schema/schema.d.ts +2 -0
- package/dist/tools/schema/schema.d.ts.map +1 -1
- package/dist/tools/schema/untyped-properties.d.ts.map +1 -1
- package/dist/tools/surface.d.ts.map +1 -1
- package/dist/tools/toolkit.d.ts +6 -3
- package/dist/tools/toolkit.d.ts.map +1 -1
- package/dist/tools/transfer/define-download-tool.d.ts.map +1 -1
- package/dist/tools/transfer/define-upload-tool.d.ts.map +1 -1
- package/dist/tools/transfer/define-view-file-tool.d.ts +2 -1
- package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -1
- package/dist/tools/transfer/mount-download.d.ts.map +1 -1
- package/dist/tools/transfer/view-file-contract.d.ts +2 -2
- package/dist/tools/transfer/view-file.d.ts +1 -2
- package/dist/tools/transfer/view-file.d.ts.map +1 -1
- package/dist/tracking/client.d.ts +0 -13
- package/dist/tracking/client.d.ts.map +1 -1
- package/dist/tracking/delivery.d.ts.map +1 -1
- package/dist/tracking/performance/collector.d.ts.map +1 -1
- package/llms/agent-executor-acp.txt +51 -0
- package/llms/agent-executor-claude-sdk.txt +31 -0
- package/llms/agent-executor-claude.txt +29 -0
- package/llms/agent-executor-codex.txt +25 -0
- package/llms/agent-executor-testing.txt +26 -0
- package/llms/agent-executor.txt +40 -0
- package/llms/agent-runtime-harness.txt +68 -5
- package/llms/agent-runtime-openrouter.txt +8 -2
- package/llms/agent-runtime-postgres.txt +30 -0
- package/llms/agent-runtime-react.txt +1 -1
- package/llms/agent-runtime-realtime.txt +1 -1
- package/llms/agent-runtime-sandbox.txt +5 -2
- package/llms/agent-runtime-sqlite-bun.txt +2 -2
- package/llms/agent-runtime-sqlite-node.txt +2 -2
- package/llms/agent-runtime-testing.txt +2 -1
- package/llms/agent-runtime.2.txt +450 -501
- package/llms/agent-runtime.3.txt +229 -267
- package/llms/agent-runtime.4.txt +23 -242
- package/llms/agent-runtime.5.txt +1 -1
- package/llms/agent-runtime.txt +551 -2
- package/llms/application-diagnostic-journal.txt +2 -0
- package/llms/application.2.txt +3 -0
- package/llms/application.3.txt +21 -4
- package/llms/application.txt +4 -1
- package/llms/cli.2.txt +259 -99
- package/llms/cli.3.txt +90 -0
- package/llms/cli.txt +95 -184
- package/llms/contract.txt +7 -6
- package/llms/declaration.txt +1 -1
- package/llms/files.txt +11 -0
- package/llms/handler.txt +25 -0
- package/llms/http.txt +18 -1
- package/llms/node.txt +3 -2
- package/llms/observability.2.txt +105 -0
- package/llms/observability.txt +14 -90
- package/llms/primitives.txt +27 -0
- package/llms/process.2.txt +2 -2
- package/llms/process.txt +10 -9
- package/llms/realtime.txt +11 -0
- package/llms/server.2.txt +355 -0
- package/llms/server.4.txt +45 -6
- package/llms/server.5.txt +6 -1
- package/llms/server.txt +143 -256
- package/llms/service-host-macos.txt +53 -0
- package/llms/service-host.txt +69 -0
- package/llms/spend-testing.txt +21 -0
- package/llms/spend.txt +173 -0
- package/llms/stitchkit.2.txt +368 -42
- package/llms/stitchkit.3.txt +164 -13
- package/llms/stitchkit.txt +95 -417
- package/llms/sync-postgres.txt +31 -0
- package/llms/sync.txt +396 -0
- package/llms/telegram-html.txt +4 -1
- package/llms/telegram.2.txt +4 -4
- package/llms/telegram.txt +105 -14
- package/llms/testing.txt +4 -3
- package/llms/tools-connections.txt +4 -4
- package/llms/tools.2.txt +78 -17
- package/llms/tools.3.txt +12 -8
- package/llms/tools.txt +85 -78
- package/llms/upgrading-0.127.0.txt +1059 -0
- package/llms/upgrading.txt +1 -0
- package/llms-full.txt +3557 -531
- package/llms.txt +43 -27
- package/native/darwin-arm64.node +0 -0
- package/native/darwin-x64.node +0 -0
- package/native-assets.json +4 -4
- package/package.json +67 -9
- package/dist/agent-runtime/sandbox-coding.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-events.d.ts +0 -5
- package/dist/agent-runtime/sqlite-events.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-history.d.ts +0 -7
- package/dist/agent-runtime/sqlite-history.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-ledger.d.ts +0 -7
- package/dist/agent-runtime/sqlite-ledger.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-reads.d.ts +0 -14
- package/dist/agent-runtime/sqlite-reads.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-rows.d.ts.map +0 -1
- package/dist/agent-runtime/tool-progress.d.ts.map +0 -1
- package/dist/entrypoints/application/schemas.d.ts +0 -15
- package/dist/entrypoints/application/schemas.d.ts.map +0 -1
- package/dist/entrypoints/application/schemas.js +0 -27
- package/dist/index-0s4xebbg.js +0 -8
- package/dist/index-57ppvpw0.js +0 -1150
- package/dist/index-5dmk54h9.js +0 -256
- package/dist/index-7cn66qdk.js +0 -92
- package/dist/index-8x0q6yfb.js +0 -247
- package/dist/index-a5qr2rj6.js +0 -26
- package/dist/index-b0kddvzw.js +0 -35
- package/dist/index-drcjjhy1.js +0 -40
- package/dist/index-eemvahkc.js +0 -21
- package/dist/index-gfk7nrht.js +0 -0
- package/dist/index-jp2qd9jb.js +0 -108
- package/dist/index-nx6eazt0.js +0 -160
- package/dist/index-wxadzdb7.js +0 -55
- package/dist/internal/until-aborted.d.ts +0 -9
- package/dist/internal/until-aborted.d.ts.map +0 -1
- package/dist/server/unix-client-error.d.ts +0 -9
- package/dist/server/unix-client-error.d.ts.map +0 -1
- package/llms/application-schemas.txt +0 -42
|
@@ -0,0 +1,1998 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readRegularFile2
|
|
3
|
+
} from "../../index-3gwp8ez6.js";
|
|
4
|
+
import {
|
|
5
|
+
requireDarwinServiceHostMethod,
|
|
6
|
+
loadDarwinBinding
|
|
7
|
+
} from "../../index-6kec3b14.js";
|
|
8
|
+
import {
|
|
9
|
+
computeSha256Hex,
|
|
10
|
+
isProcessGoneError,
|
|
11
|
+
renderPlistStringElement,
|
|
12
|
+
renderPlistKeyElement,
|
|
13
|
+
renderPlistValue,
|
|
14
|
+
renderPlistDocument,
|
|
15
|
+
createDefaultLaunchdHostAdapter2,
|
|
16
|
+
lintLaunchdPlist2,
|
|
17
|
+
readLaunchdPlist2
|
|
18
|
+
} from "../../index-fcw255hd.js";
|
|
19
|
+
import {
|
|
20
|
+
NativeCommandError2
|
|
21
|
+
} from "../../index-v59pxmf1.js";
|
|
22
|
+
import"../../index-7kfcb576.js";
|
|
23
|
+
import {
|
|
24
|
+
sameProcessInstance,
|
|
25
|
+
observeProcessInstance2
|
|
26
|
+
} from "../../index-x90w78yz.js";
|
|
27
|
+
import {
|
|
28
|
+
runNativeCommand2
|
|
29
|
+
} from "../../index-5ptwb6ka.js";
|
|
30
|
+
import {
|
|
31
|
+
messageOf
|
|
32
|
+
} from "../../index-r9kq5ark.js";
|
|
33
|
+
import {
|
|
34
|
+
writeFileAtomic2
|
|
35
|
+
} from "../../index-5zwac8ft.js";
|
|
36
|
+
import {
|
|
37
|
+
errnoOf
|
|
38
|
+
} from "../../index-jj9228tt.js";
|
|
39
|
+
import {
|
|
40
|
+
serializeCanonicalJson
|
|
41
|
+
} from "../../index-fmzg39a8.js";
|
|
42
|
+
|
|
43
|
+
// src/service-host/macos/bundle.ts
|
|
44
|
+
import { randomBytes } from "node:crypto";
|
|
45
|
+
import { constants as fsConstants } from "node:fs";
|
|
46
|
+
import { lstat as lstat2, mkdir as mkdir2, open, rename, rm as rm3, writeFile as writeFile3 } from "node:fs/promises";
|
|
47
|
+
import { basename, dirname as dirname2, join as join3, posix as posix3 } from "node:path";
|
|
48
|
+
|
|
49
|
+
// src/service-host/macos/bundle-plist.ts
|
|
50
|
+
import { z } from "zod";
|
|
51
|
+
var BUNDLE_SPEC_DIGEST_PLIST_KEY = "StitchkitBundleSpecDigest";
|
|
52
|
+
var SAFE_SEGMENT_PATTERN = /^[A-Za-z0-9._-]+$/;
|
|
53
|
+
var SAFE_BUNDLE_ID_PATTERN = /^[A-Za-z0-9.-]+$/;
|
|
54
|
+
var MANAGED_INFO_PLIST_KEYS = new Set([
|
|
55
|
+
"LSBackgroundOnly",
|
|
56
|
+
"LSUIElement",
|
|
57
|
+
"LSMinimumSystemVersion",
|
|
58
|
+
"NSHighResolutionCapable",
|
|
59
|
+
BUNDLE_SPEC_DIGEST_PLIST_KEY
|
|
60
|
+
]);
|
|
61
|
+
var MacosBundleInfoPlistConfigSchema = z.strictObject({
|
|
62
|
+
bundleIdentifier: z.string().min(1),
|
|
63
|
+
bundleName: z.string().min(1),
|
|
64
|
+
displayName: z.string().min(1).optional(),
|
|
65
|
+
executableName: z.string().min(1),
|
|
66
|
+
bundleVersion: z.string().min(1).default("1"),
|
|
67
|
+
shortVersionString: z.string().min(1).default("1.0.0"),
|
|
68
|
+
iconFile: z.string().min(1).optional(),
|
|
69
|
+
lsBackgroundOnly: z.boolean().default(true),
|
|
70
|
+
lsUIElement: z.boolean().default(true),
|
|
71
|
+
lsMinimumSystemVersion: z.string().min(1).default("13.0"),
|
|
72
|
+
specDigest: z.string().regex(/^[0-9a-f]{64}$/),
|
|
73
|
+
extraEntries: z.record(z.string(), z.union([z.string(), z.boolean(), z.number()])).optional()
|
|
74
|
+
}).check((ctx) => {
|
|
75
|
+
const value = ctx.value;
|
|
76
|
+
if (!SAFE_BUNDLE_ID_PATTERN.test(value.bundleIdentifier)) {
|
|
77
|
+
ctx.issues.push({
|
|
78
|
+
code: "custom",
|
|
79
|
+
input: value.bundleIdentifier,
|
|
80
|
+
path: ["bundleIdentifier"],
|
|
81
|
+
message: "bundleIdentifier must contain only ASCII letters, digits, dots, or hyphens"
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (value.executableName === "." || value.executableName === ".." || !SAFE_SEGMENT_PATTERN.test(value.executableName)) {
|
|
85
|
+
ctx.issues.push({
|
|
86
|
+
code: "custom",
|
|
87
|
+
input: value.executableName,
|
|
88
|
+
path: ["executableName"],
|
|
89
|
+
message: "executableName must be a single safe path segment"
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (value.extraEntries !== undefined) {
|
|
93
|
+
for (const key of Object.keys(value.extraEntries)) {
|
|
94
|
+
if (key.startsWith("CFBundle") || MANAGED_INFO_PLIST_KEYS.has(key)) {
|
|
95
|
+
ctx.issues.push({
|
|
96
|
+
code: "custom",
|
|
97
|
+
input: value.extraEntries,
|
|
98
|
+
path: ["extraEntries", key],
|
|
99
|
+
message: `${key} is managed automatically and cannot be overridden via extraEntries`
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
function plistEntry(key, value) {
|
|
106
|
+
const renderedKey = ` ${renderPlistKeyElement(key, key)}`;
|
|
107
|
+
const renderedVal = typeof value === "string" ? ` ${renderPlistStringElement(key, value)}` : renderPlistValue(key, value, { indent: 4 });
|
|
108
|
+
return `${renderedKey}
|
|
109
|
+
${renderedVal}`;
|
|
110
|
+
}
|
|
111
|
+
function renderBundleInfoPlist(config) {
|
|
112
|
+
const parsed = MacosBundleInfoPlistConfigSchema.parse(config);
|
|
113
|
+
const entries = [
|
|
114
|
+
plistEntry("CFBundleDevelopmentRegion", "en"),
|
|
115
|
+
plistEntry("CFBundleExecutable", parsed.executableName),
|
|
116
|
+
plistEntry("CFBundleIdentifier", parsed.bundleIdentifier),
|
|
117
|
+
plistEntry("CFBundleInfoDictionaryVersion", "6.0"),
|
|
118
|
+
plistEntry("CFBundleName", parsed.bundleName)
|
|
119
|
+
];
|
|
120
|
+
if (parsed.displayName !== undefined) {
|
|
121
|
+
entries.push(plistEntry("CFBundleDisplayName", parsed.displayName));
|
|
122
|
+
}
|
|
123
|
+
entries.push(plistEntry("CFBundlePackageType", "APPL"), plistEntry("CFBundleShortVersionString", parsed.shortVersionString), plistEntry("CFBundleVersion", parsed.bundleVersion));
|
|
124
|
+
if (parsed.iconFile !== undefined) {
|
|
125
|
+
entries.push(plistEntry("CFBundleIconFile", parsed.iconFile));
|
|
126
|
+
}
|
|
127
|
+
entries.push(plistEntry("LSBackgroundOnly", parsed.lsBackgroundOnly), plistEntry("LSUIElement", parsed.lsUIElement), plistEntry("LSMinimumSystemVersion", parsed.lsMinimumSystemVersion), plistEntry("NSHighResolutionCapable", true), plistEntry(BUNDLE_SPEC_DIGEST_PLIST_KEY, parsed.specDigest));
|
|
128
|
+
if (parsed.extraEntries !== undefined) {
|
|
129
|
+
const keys = Object.keys(parsed.extraEntries).sort();
|
|
130
|
+
for (const key of keys) {
|
|
131
|
+
const value = parsed.extraEntries[key];
|
|
132
|
+
if (value === undefined)
|
|
133
|
+
continue;
|
|
134
|
+
entries.push(plistEntry(key, value));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return renderPlistDocument(entries);
|
|
138
|
+
}
|
|
139
|
+
function iconDigestInput(icon) {
|
|
140
|
+
if (icon === undefined)
|
|
141
|
+
return null;
|
|
142
|
+
if (icon.kind === "svg") {
|
|
143
|
+
return {
|
|
144
|
+
kind: "svg",
|
|
145
|
+
sha256: computeSha256Hex(icon.svg),
|
|
146
|
+
applySquircleFrame: icon.applySquircleFrame ?? true,
|
|
147
|
+
backgroundColor: icon.backgroundColor ?? null
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
kind: icon.kind,
|
|
152
|
+
sha256: computeSha256Hex(icon.bytes),
|
|
153
|
+
applySquircleFrame: icon.kind === "png" ? icon.applySquircleFrame ?? false : true,
|
|
154
|
+
backgroundColor: icon.backgroundColor ?? null
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function computeBundleSpecDigest(spec, launcherSource) {
|
|
158
|
+
return computeSha256Hex(serializeCanonicalJson({
|
|
159
|
+
bundleIdentifier: spec.bundleIdentifier,
|
|
160
|
+
bundleName: spec.bundleName,
|
|
161
|
+
displayName: spec.displayName ?? null,
|
|
162
|
+
executableName: spec.executableName,
|
|
163
|
+
bundleVersion: spec.bundleVersion ?? "1",
|
|
164
|
+
shortVersionString: spec.shortVersionString ?? "1.0.0",
|
|
165
|
+
lsBackgroundOnly: spec.lsBackgroundOnly ?? true,
|
|
166
|
+
lsUIElement: spec.lsUIElement ?? true,
|
|
167
|
+
lsMinimumSystemVersion: spec.lsMinimumSystemVersion ?? "13.0",
|
|
168
|
+
requireHardenedRuntime: spec.requireHardenedRuntime ?? true,
|
|
169
|
+
entitlementsPath: spec.entitlementsPath ?? null,
|
|
170
|
+
entitlementsSha256: spec.entitlementsSha256 ?? null,
|
|
171
|
+
signingIdentity: spec.signingIdentity ?? null,
|
|
172
|
+
expectedTeamId: spec.expectedTeamId ?? null,
|
|
173
|
+
arch: spec.arch ?? null,
|
|
174
|
+
extraInfoPlistEntries: spec.extraInfoPlistEntries ?? null,
|
|
175
|
+
launcherSourceSha256: computeSha256Hex(launcherSource),
|
|
176
|
+
icon: iconDigestInput(spec.icon)
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// src/service-host/macos/runner.ts
|
|
181
|
+
import { realpath } from "node:fs/promises";
|
|
182
|
+
import { posix } from "node:path";
|
|
183
|
+
var CODESIGN_PATH = "/usr/bin/codesign";
|
|
184
|
+
var SECURITY_PATH = "/usr/bin/security";
|
|
185
|
+
var CLANG_PATH = "/usr/bin/clang";
|
|
186
|
+
var SIPS_PATH = "/usr/bin/sips";
|
|
187
|
+
var QLMANAGE_PATH = "/usr/bin/qlmanage";
|
|
188
|
+
var ICONUTIL_PATH = "/usr/bin/iconutil";
|
|
189
|
+
var PS_PATH = "/bin/ps";
|
|
190
|
+
var DEFAULT_TIMEOUT_MS = 60000;
|
|
191
|
+
var DEFAULT_MAX_OUTPUT_BYTES = 16 * 1024 * 1024;
|
|
192
|
+
var MAX_STREAMED_STDERR_BYTES = 64 * 1024;
|
|
193
|
+
var MACOS_COMMAND_PATH = "/usr/bin:/bin:/usr/sbin:/sbin";
|
|
194
|
+
var MACOS_COMMAND_KEYS = [
|
|
195
|
+
"HOME",
|
|
196
|
+
"TMPDIR",
|
|
197
|
+
"DEVELOPER_DIR",
|
|
198
|
+
"SDKROOT",
|
|
199
|
+
"TOOLCHAINS"
|
|
200
|
+
];
|
|
201
|
+
function macosCommandEnv(extra) {
|
|
202
|
+
const env = { PATH: MACOS_COMMAND_PATH };
|
|
203
|
+
for (const key of MACOS_COMMAND_KEYS) {
|
|
204
|
+
const value = process.env[key];
|
|
205
|
+
if (value !== undefined)
|
|
206
|
+
env[key] = value;
|
|
207
|
+
}
|
|
208
|
+
return { ...env, ...extra };
|
|
209
|
+
}
|
|
210
|
+
function createDefaultMacosCommandRunner() {
|
|
211
|
+
const decoder = new TextDecoder;
|
|
212
|
+
return {
|
|
213
|
+
async runCommand(executable, args, options) {
|
|
214
|
+
const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
215
|
+
const env = macosCommandEnv(options?.env);
|
|
216
|
+
if (options?.onOutput !== undefined) {
|
|
217
|
+
const sink = options.onOutput;
|
|
218
|
+
const stderrChunks = [];
|
|
219
|
+
let stderrBytes = 0;
|
|
220
|
+
const result = await runNativeCommand2({
|
|
221
|
+
executable,
|
|
222
|
+
args: [...args],
|
|
223
|
+
envPolicy: "declared-only",
|
|
224
|
+
env,
|
|
225
|
+
capture: false,
|
|
226
|
+
timeoutMs,
|
|
227
|
+
...options.maxOutputBytes !== undefined ? { maxOutputBytes: options.maxOutputBytes } : {},
|
|
228
|
+
...options.stdin !== undefined ? { stdin: options.stdin } : {},
|
|
229
|
+
...options.cwd !== undefined ? { cwd: options.cwd } : {},
|
|
230
|
+
async onOutput(bytes, channel) {
|
|
231
|
+
if (channel === "stderr" && stderrBytes < MAX_STREAMED_STDERR_BYTES) {
|
|
232
|
+
const remaining = MAX_STREAMED_STDERR_BYTES - stderrBytes;
|
|
233
|
+
const slice = bytes.byteLength <= remaining ? bytes : bytes.subarray(0, remaining);
|
|
234
|
+
stderrChunks.push(slice.slice());
|
|
235
|
+
stderrBytes += slice.byteLength;
|
|
236
|
+
}
|
|
237
|
+
await sink(bytes, channel);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
const stderrCombined = new Uint8Array(stderrBytes);
|
|
241
|
+
let offset = 0;
|
|
242
|
+
for (const chunk of stderrChunks) {
|
|
243
|
+
stderrCombined.set(chunk, offset);
|
|
244
|
+
offset += chunk.byteLength;
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
exitCode: result.exitCode ?? 1,
|
|
248
|
+
stdout: "",
|
|
249
|
+
stderr: decoder.decode(stderrCombined)
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
const result = await runNativeCommand2({
|
|
253
|
+
executable,
|
|
254
|
+
args: [...args],
|
|
255
|
+
envPolicy: "declared-only",
|
|
256
|
+
env,
|
|
257
|
+
capture: true,
|
|
258
|
+
maxOutputBytes: options?.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES,
|
|
259
|
+
timeoutMs,
|
|
260
|
+
...options?.stdin !== undefined ? { stdin: options.stdin } : {},
|
|
261
|
+
...options?.cwd !== undefined ? { cwd: options.cwd } : {}
|
|
262
|
+
});
|
|
263
|
+
return {
|
|
264
|
+
exitCode: result.exitCode ?? 1,
|
|
265
|
+
stdout: decoder.decode(result.stdout),
|
|
266
|
+
stderr: decoder.decode(result.stderr)
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
function normalizeMacosSyntheticPath(targetPath) {
|
|
272
|
+
const normalized = posix.normalize(targetPath).replace(/\/+$/, "");
|
|
273
|
+
if (normalized.length === 0)
|
|
274
|
+
return "/";
|
|
275
|
+
const lowered = normalized.toLowerCase();
|
|
276
|
+
if (lowered === "/var" || lowered.startsWith("/var/") || lowered === "/tmp" || lowered.startsWith("/tmp/") || lowered === "/etc" || lowered.startsWith("/etc/")) {
|
|
277
|
+
return `/private${normalized}`;
|
|
278
|
+
}
|
|
279
|
+
return normalized;
|
|
280
|
+
}
|
|
281
|
+
function macosPathKey(targetPath) {
|
|
282
|
+
return normalizeMacosSyntheticPath(targetPath).toLowerCase();
|
|
283
|
+
}
|
|
284
|
+
async function canonicalizeMacosPath(targetPath, realpathFn = realpath) {
|
|
285
|
+
try {
|
|
286
|
+
return normalizeMacosSyntheticPath(await realpathFn(targetPath));
|
|
287
|
+
} catch {
|
|
288
|
+
return normalizeMacosSyntheticPath(targetPath);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
function isPathWithinDirectory(candidate, directory) {
|
|
292
|
+
const normCandidate = macosPathKey(candidate);
|
|
293
|
+
const normDir = macosPathKey(directory);
|
|
294
|
+
if (normDir === "/")
|
|
295
|
+
return normCandidate.startsWith("/");
|
|
296
|
+
return normCandidate === normDir || normCandidate.startsWith(`${normDir}/`);
|
|
297
|
+
}
|
|
298
|
+
var APPLICATIONS_PREFIX = "/applications/";
|
|
299
|
+
var PROTECTED_SYSTEM_PREFIXES = [
|
|
300
|
+
"/system/",
|
|
301
|
+
APPLICATIONS_PREFIX,
|
|
302
|
+
"/library/apple/",
|
|
303
|
+
"/usr/",
|
|
304
|
+
"/bin/",
|
|
305
|
+
"/sbin/"
|
|
306
|
+
];
|
|
307
|
+
var FORBIDDEN_BUILD_ROOTS = new Set("/ /system /applications /library /library/apple /users /var /private /private/var /tmp /private/tmp /etc /private/etc /usr /bin /sbin".split(" "));
|
|
308
|
+
var USER_HOME_ROOT_PATTERN = /^\/users\/[^/]+$/;
|
|
309
|
+
function isProtectedMacosSystemPath(targetPath, options = { applications: "protected" }) {
|
|
310
|
+
const normalized = (posix.normalize(targetPath).replace(/\/+$/, "") || "/").toLowerCase();
|
|
311
|
+
const synthetic = macosPathKey(targetPath);
|
|
312
|
+
return PROTECTED_SYSTEM_PREFIXES.some((prefix) => {
|
|
313
|
+
if (prefix === APPLICATIONS_PREFIX && options.applications === "install-target")
|
|
314
|
+
return false;
|
|
315
|
+
const root = prefix.slice(0, -1);
|
|
316
|
+
return normalized === root || normalized.startsWith(prefix) || synthetic === root || synthetic.startsWith(prefix);
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
function isMacosForbiddenBuildRoot(targetPath) {
|
|
320
|
+
const rawLower = (posix.normalize(targetPath).replace(/\/+$/, "") || "/").toLowerCase();
|
|
321
|
+
const syntheticLower = macosPathKey(targetPath);
|
|
322
|
+
if (FORBIDDEN_BUILD_ROOTS.has(rawLower) || FORBIDDEN_BUILD_ROOTS.has(syntheticLower) || isProtectedMacosSystemPath(targetPath)) {
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
const strippedRaw = rawLower.startsWith("/private/") ? rawLower.slice("/private".length) : rawLower;
|
|
326
|
+
const strippedSynthetic = syntheticLower.startsWith("/private/") ? syntheticLower.slice("/private".length) : syntheticLower;
|
|
327
|
+
return USER_HOME_ROOT_PATTERN.test(strippedRaw) || USER_HOME_ROOT_PATTERN.test(strippedSynthetic);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// src/service-host/macos/codesign.ts
|
|
331
|
+
var DEVELOPER_ID_PREFIX = "Developer ID Application:";
|
|
332
|
+
var DEVELOPER_ID_INTERMEDIATE_AUTHORITY = "Developer ID Certification Authority";
|
|
333
|
+
var APPLE_ROOT_AUTHORITY = "Apple Root CA";
|
|
334
|
+
var SHA1_PATTERN = /^[0-9A-Fa-f]{40}$/;
|
|
335
|
+
var TEAM_ID_PATTERN = /^[A-Z0-9]{10}$/;
|
|
336
|
+
var CDHASH_PATTERN = /^[0-9a-fA-F]{40,64}$/;
|
|
337
|
+
var HARDENED_RUNTIME_FLAG = 65536;
|
|
338
|
+
var IDENTITY_LINE_PATTERN = /^\s*\d+\)\s+([0-9A-Fa-f]{40})\s+"([^"]+)"(.*)$/;
|
|
339
|
+
var TEAM_SUFFIX_PATTERN = /\(([A-Z0-9]{10})\)\s*$/;
|
|
340
|
+
|
|
341
|
+
class MacosCodesignError extends Error {
|
|
342
|
+
code;
|
|
343
|
+
constructor(code, message, options) {
|
|
344
|
+
super(message, options);
|
|
345
|
+
this.code = code;
|
|
346
|
+
this.name = "MacosCodesignError";
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
function parseDeveloperIdsOutput(stdout) {
|
|
350
|
+
const identities = [];
|
|
351
|
+
const seen = new Set;
|
|
352
|
+
for (const rawLine of stdout.split(`
|
|
353
|
+
`)) {
|
|
354
|
+
const match = IDENTITY_LINE_PATTERN.exec(rawLine.trimEnd());
|
|
355
|
+
if (!match)
|
|
356
|
+
continue;
|
|
357
|
+
const sha1 = (match[1] ?? "").toUpperCase();
|
|
358
|
+
const commonName = (match[2] ?? "").trim();
|
|
359
|
+
const trailing = match[3] ?? "";
|
|
360
|
+
if (trailing.includes("CSSMERR_") || commonName.includes("CSSMERR_"))
|
|
361
|
+
continue;
|
|
362
|
+
if (!commonName.startsWith(DEVELOPER_ID_PREFIX) || seen.has(sha1))
|
|
363
|
+
continue;
|
|
364
|
+
seen.add(sha1);
|
|
365
|
+
const teamMatch = TEAM_SUFFIX_PATTERN.exec(commonName);
|
|
366
|
+
identities.push({ sha1, commonName, teamId: teamMatch?.[1] ?? null });
|
|
367
|
+
}
|
|
368
|
+
return identities;
|
|
369
|
+
}
|
|
370
|
+
async function findDeveloperIds(options) {
|
|
371
|
+
const runner = options?.runner ?? createDefaultMacosCommandRunner();
|
|
372
|
+
const args = ["find-identity", "-v", "-p", "codesigning"];
|
|
373
|
+
if (options?.keychain !== undefined) {
|
|
374
|
+
if (options.keychain.length === 0 || options.keychain.startsWith("-") || /[\0\r\n]/.test(options.keychain)) {
|
|
375
|
+
throw new MacosCodesignError("INVALID_IDENTITY", "Invalid keychain path");
|
|
376
|
+
}
|
|
377
|
+
args.push(options.keychain);
|
|
378
|
+
}
|
|
379
|
+
const result = await runner.runCommand(SECURITY_PATH, args, {
|
|
380
|
+
timeoutMs: options?.timeoutMs
|
|
381
|
+
});
|
|
382
|
+
if (result.exitCode !== 0) {
|
|
383
|
+
throw new MacosCodesignError("COMMAND_FAILED", `security find-identity failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
|
|
384
|
+
}
|
|
385
|
+
return parseDeveloperIdsOutput(result.stdout);
|
|
386
|
+
}
|
|
387
|
+
function failIdentity(message) {
|
|
388
|
+
throw new MacosCodesignError("INVALID_IDENTITY", message);
|
|
389
|
+
}
|
|
390
|
+
async function resolveSigningIdentity(options) {
|
|
391
|
+
if (options?.identity !== undefined) {
|
|
392
|
+
if (options.identity === null) {
|
|
393
|
+
failIdentity("Signing identity must not be null; ad-hoc signing is forbidden");
|
|
394
|
+
}
|
|
395
|
+
const trimmed = options.identity.trim();
|
|
396
|
+
if (trimmed.length === 0 || trimmed === "-") {
|
|
397
|
+
failIdentity('Empty or ad-hoc ("-") signing identity is forbidden');
|
|
398
|
+
}
|
|
399
|
+
if (trimmed.includes("CSSMERR_") || /[\0\r\n]/.test(trimmed)) {
|
|
400
|
+
failIdentity(`Rejected invalid or flagged signing identity: ${JSON.stringify(trimmed)}`);
|
|
401
|
+
}
|
|
402
|
+
if (SHA1_PATTERN.test(trimmed)) {
|
|
403
|
+
const upper = trimmed.toUpperCase();
|
|
404
|
+
const matched = (await findDeveloperIds(options)).find((entry) => entry.sha1 === upper);
|
|
405
|
+
if (!matched) {
|
|
406
|
+
failIdentity(`Signing certificate SHA-1 ${upper} is not a valid Developer ID Application identity`);
|
|
407
|
+
}
|
|
408
|
+
return matched.sha1;
|
|
409
|
+
}
|
|
410
|
+
if (!trimmed.startsWith(DEVELOPER_ID_PREFIX) || trimmed.slice(DEVELOPER_ID_PREFIX.length).trim().length === 0) {
|
|
411
|
+
failIdentity(`Signing identity must start with "${DEVELOPER_ID_PREFIX}" and name a subject (got ${JSON.stringify(trimmed)})`);
|
|
412
|
+
}
|
|
413
|
+
return trimmed;
|
|
414
|
+
}
|
|
415
|
+
const identities = await findDeveloperIds(options);
|
|
416
|
+
if (identities.length === 0) {
|
|
417
|
+
throw new MacosCodesignError("NO_DEVELOPER_ID", "No valid Developer ID Application certificate found in keychain");
|
|
418
|
+
}
|
|
419
|
+
if (identities.length > 1) {
|
|
420
|
+
const names = identities.map((entry) => `${entry.commonName} (${entry.sha1})`).join(", ");
|
|
421
|
+
throw new MacosCodesignError("AMBIGUOUS_IDENTITY", `Multiple Developer ID Application certificates found; specify identity explicitly: ${names}`);
|
|
422
|
+
}
|
|
423
|
+
const single = identities[0];
|
|
424
|
+
if (!single)
|
|
425
|
+
throw new MacosCodesignError("NO_DEVELOPER_ID", "No valid Developer ID Application certificate");
|
|
426
|
+
return single.commonName;
|
|
427
|
+
}
|
|
428
|
+
function parseCodesignDetails(stderr) {
|
|
429
|
+
let identifier = null;
|
|
430
|
+
let teamIdentifier = null;
|
|
431
|
+
let cdHash = null;
|
|
432
|
+
let signature = null;
|
|
433
|
+
let flags = null;
|
|
434
|
+
let hasHardenedRuntime = false;
|
|
435
|
+
const authorities = [];
|
|
436
|
+
for (const rawLine of stderr.split(`
|
|
437
|
+
`)) {
|
|
438
|
+
const line = rawLine.trim();
|
|
439
|
+
if (line.length === 0)
|
|
440
|
+
continue;
|
|
441
|
+
if (line.startsWith("Identifier="))
|
|
442
|
+
identifier = line.slice("Identifier=".length).trim();
|
|
443
|
+
else if (line.startsWith("TeamIdentifier="))
|
|
444
|
+
teamIdentifier = line.slice("TeamIdentifier=".length).trim();
|
|
445
|
+
else if (line.startsWith("CDHash="))
|
|
446
|
+
cdHash = line.slice("CDHash=".length).trim().toLowerCase();
|
|
447
|
+
else if (line.startsWith("Signature="))
|
|
448
|
+
signature = line.slice("Signature=".length).trim();
|
|
449
|
+
else if (line.startsWith("Authority=")) {
|
|
450
|
+
const authority = line.slice("Authority=".length).trim();
|
|
451
|
+
if (authority.length > 0)
|
|
452
|
+
authorities.push(authority);
|
|
453
|
+
} else if (line.startsWith("CodeDirectory ")) {
|
|
454
|
+
const flagMatch = /\bflags=(0x[0-9a-fA-F]+(?:\([^)]*\))?)/.exec(line);
|
|
455
|
+
if (flagMatch?.[1] !== undefined) {
|
|
456
|
+
flags = flagMatch[1];
|
|
457
|
+
const hexMatch = /^0x([0-9a-fA-F]+)/.exec(flags);
|
|
458
|
+
const numeric = hexMatch?.[1] !== undefined ? Number.parseInt(hexMatch[1], 16) : 0;
|
|
459
|
+
hasHardenedRuntime = (numeric & HARDENED_RUNTIME_FLAG) !== 0 || /\([^)]*\bruntime\b[^)]*\)/.test(flags);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return {
|
|
464
|
+
identifier,
|
|
465
|
+
teamIdentifier,
|
|
466
|
+
cdHash,
|
|
467
|
+
signature,
|
|
468
|
+
flags,
|
|
469
|
+
hasHardenedRuntime,
|
|
470
|
+
authorities
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function failVerify(message) {
|
|
474
|
+
throw new MacosCodesignError("VERIFICATION_FAILED", message);
|
|
475
|
+
}
|
|
476
|
+
function developerIdRequirement(teamId) {
|
|
477
|
+
if (!TEAM_ID_PATTERN.test(teamId))
|
|
478
|
+
failVerify(`Invalid TeamIdentifier: ${JSON.stringify(teamId)}`);
|
|
479
|
+
return `anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists and certificate leaf[subject.OU] = "${teamId}"`;
|
|
480
|
+
}
|
|
481
|
+
function assertValidAuthorityChain(authorities) {
|
|
482
|
+
const leaf = authorities[0] ?? "";
|
|
483
|
+
const intermediate = authorities[1] ?? "";
|
|
484
|
+
const root = authorities[2] ?? "";
|
|
485
|
+
if (authorities.length !== 3 || !leaf.startsWith(DEVELOPER_ID_PREFIX) || leaf.slice(DEVELOPER_ID_PREFIX.length).trim().length === 0 || intermediate !== DEVELOPER_ID_INTERMEDIATE_AUTHORITY || root !== APPLE_ROOT_AUTHORITY) {
|
|
486
|
+
failVerify(`Invalid Developer ID certificate chain: [${authorities.join(" -> ")}]`);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
async function verifySignedBundle(options) {
|
|
490
|
+
if (!options.bundlePath.startsWith("/") || /[\0\r\n]/.test(options.bundlePath)) {
|
|
491
|
+
failVerify(`Invalid bundlePath: ${JSON.stringify(options.bundlePath)}`);
|
|
492
|
+
}
|
|
493
|
+
const runner = options.runner ?? createDefaultMacosCommandRunner();
|
|
494
|
+
const cmdOpts = { timeoutMs: options.timeoutMs };
|
|
495
|
+
const displayResult = await runner.runCommand(CODESIGN_PATH, ["-dvvv", options.bundlePath], cmdOpts);
|
|
496
|
+
if (displayResult.exitCode !== 0) {
|
|
497
|
+
failVerify(`codesign -dvvv failed for ${options.bundlePath} (exit ${displayResult.exitCode}): ${displayResult.stderr.trim()}`);
|
|
498
|
+
}
|
|
499
|
+
const details = parseCodesignDetails(displayResult.stderr);
|
|
500
|
+
if (details.signature?.toLowerCase() === "adhoc") {
|
|
501
|
+
failVerify(`Bundle ${options.bundlePath} has an ad-hoc signature`);
|
|
502
|
+
}
|
|
503
|
+
if (details.identifier !== options.expectedBundleId) {
|
|
504
|
+
failVerify(`Bundle identifier mismatch for ${options.bundlePath}: expected ${options.expectedBundleId}, observed ${details.identifier ?? "none"}`);
|
|
505
|
+
}
|
|
506
|
+
if (details.teamIdentifier === null || details.teamIdentifier === "not set" || !TEAM_ID_PATTERN.test(details.teamIdentifier)) {
|
|
507
|
+
failVerify(`Invalid or missing TeamIdentifier for ${options.bundlePath}: ${details.teamIdentifier ?? "none"}`);
|
|
508
|
+
}
|
|
509
|
+
if (options.expectedTeamId !== undefined && details.teamIdentifier !== options.expectedTeamId) {
|
|
510
|
+
failVerify(`TeamIdentifier mismatch for ${options.bundlePath}: expected ${options.expectedTeamId}, observed ${details.teamIdentifier}`);
|
|
511
|
+
}
|
|
512
|
+
if (details.cdHash === null || !CDHASH_PATTERN.test(details.cdHash)) {
|
|
513
|
+
failVerify(`Missing or malformed CDHash for ${options.bundlePath}: ${details.cdHash ?? "none"}`);
|
|
514
|
+
}
|
|
515
|
+
assertValidAuthorityChain(details.authorities);
|
|
516
|
+
if ((options.requireHardenedRuntime ?? true) && !details.hasHardenedRuntime) {
|
|
517
|
+
failVerify(`Bundle ${options.bundlePath} is missing the hardened runtime flag`);
|
|
518
|
+
}
|
|
519
|
+
const verifyResult = await runner.runCommand(CODESIGN_PATH, [
|
|
520
|
+
"--verify",
|
|
521
|
+
"--deep",
|
|
522
|
+
"--strict",
|
|
523
|
+
"--verbose=2",
|
|
524
|
+
`-R=${developerIdRequirement(details.teamIdentifier)}`,
|
|
525
|
+
options.bundlePath
|
|
526
|
+
], cmdOpts);
|
|
527
|
+
if (verifyResult.exitCode !== 0) {
|
|
528
|
+
failVerify(`codesign --verify failed for ${options.bundlePath} (exit ${verifyResult.exitCode}): ${verifyResult.stderr.trim()}`);
|
|
529
|
+
}
|
|
530
|
+
return {
|
|
531
|
+
bundlePath: options.bundlePath,
|
|
532
|
+
identifier: details.identifier,
|
|
533
|
+
teamIdentifier: details.teamIdentifier,
|
|
534
|
+
cdHash: details.cdHash,
|
|
535
|
+
authorities: details.authorities,
|
|
536
|
+
hasHardenedRuntime: details.hasHardenedRuntime
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
async function signBundle(options) {
|
|
540
|
+
if (!options.bundlePath.startsWith("/") || /[\0\r\n]/.test(options.bundlePath)) {
|
|
541
|
+
throw new MacosCodesignError("COMMAND_FAILED", `Invalid bundlePath: ${JSON.stringify(options.bundlePath)}`);
|
|
542
|
+
}
|
|
543
|
+
const runner = options.runner ?? createDefaultMacosCommandRunner();
|
|
544
|
+
const validatedIdentity = await resolveSigningIdentity({
|
|
545
|
+
identity: options.identity,
|
|
546
|
+
runner,
|
|
547
|
+
timeoutMs: options.timeoutMs
|
|
548
|
+
});
|
|
549
|
+
const args = ["--force", "--sign", validatedIdentity];
|
|
550
|
+
if (options.hardenedRuntime ?? true)
|
|
551
|
+
args.push("--options", "runtime");
|
|
552
|
+
if (options.timestamp ?? true)
|
|
553
|
+
args.push("--timestamp");
|
|
554
|
+
if (options.deep === true)
|
|
555
|
+
args.push("--deep");
|
|
556
|
+
if (options.entitlementsPath !== undefined) {
|
|
557
|
+
if (!options.entitlementsPath.startsWith("/") || /[\0\r\n]/.test(options.entitlementsPath)) {
|
|
558
|
+
throw new MacosCodesignError("COMMAND_FAILED", "Invalid entitlementsPath");
|
|
559
|
+
}
|
|
560
|
+
args.push("--entitlements", options.entitlementsPath);
|
|
561
|
+
}
|
|
562
|
+
args.push(options.bundlePath);
|
|
563
|
+
const result = await runner.runCommand(CODESIGN_PATH, args, {
|
|
564
|
+
timeoutMs: options.timeoutMs
|
|
565
|
+
});
|
|
566
|
+
if (result.exitCode !== 0) {
|
|
567
|
+
throw new MacosCodesignError("COMMAND_FAILED", `codesign failed for ${options.bundlePath} (exit ${result.exitCode}): ${result.stderr.trim()}`);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// src/service-host/macos/icon.ts
|
|
572
|
+
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
573
|
+
import { dirname, join } from "node:path";
|
|
574
|
+
import { z as z2 } from "zod";
|
|
575
|
+
var APPLE_ICON_CANVAS_PX = 1024;
|
|
576
|
+
var APPLE_ICON_TILE_PX = 824;
|
|
577
|
+
var APPLE_ICON_INSET_PX = 100;
|
|
578
|
+
var APPLE_ICON_CORNER_RADIUS_PX = 185;
|
|
579
|
+
var APPLE_ICONSET_SLOTS = [
|
|
580
|
+
{ filename: "icon_16x16.png", pixels: 16 },
|
|
581
|
+
{ filename: "icon_16x16@2x.png", pixels: 32 },
|
|
582
|
+
{ filename: "icon_32x32.png", pixels: 32 },
|
|
583
|
+
{ filename: "icon_32x32@2x.png", pixels: 64 },
|
|
584
|
+
{ filename: "icon_128x128.png", pixels: 128 },
|
|
585
|
+
{ filename: "icon_128x128@2x.png", pixels: 256 },
|
|
586
|
+
{ filename: "icon_256x256.png", pixels: 256 },
|
|
587
|
+
{ filename: "icon_256x256@2x.png", pixels: 512 },
|
|
588
|
+
{ filename: "icon_512x512.png", pixels: 512 },
|
|
589
|
+
{ filename: "icon_512x512@2x.png", pixels: 1024 }
|
|
590
|
+
];
|
|
591
|
+
var SAFE_COLOR_PATTERN = /^(?:#[0-9a-fA-F]{3,8}|[a-zA-Z]{3,24}|rgba?\([0-9.,\s%]+\))$/;
|
|
592
|
+
var PNG_MAGIC = [137, 80, 78, 71, 13, 10, 26, 10];
|
|
593
|
+
|
|
594
|
+
class MacosIconError extends Error {
|
|
595
|
+
code;
|
|
596
|
+
constructor(code, message, options) {
|
|
597
|
+
super(message, options);
|
|
598
|
+
this.name = "MacosIconError";
|
|
599
|
+
this.code = code;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
var MacosIconSourceSchema = z2.discriminatedUnion("kind", [
|
|
603
|
+
z2.strictObject({
|
|
604
|
+
kind: z2.literal("svg"),
|
|
605
|
+
svg: z2.string().min(1),
|
|
606
|
+
applySquircleFrame: z2.boolean().default(true),
|
|
607
|
+
backgroundColor: z2.string().min(1).optional()
|
|
608
|
+
}),
|
|
609
|
+
z2.strictObject({
|
|
610
|
+
kind: z2.literal("jpeg"),
|
|
611
|
+
bytes: z2.instanceof(Uint8Array),
|
|
612
|
+
backgroundColor: z2.string().min(1).optional()
|
|
613
|
+
}),
|
|
614
|
+
z2.strictObject({
|
|
615
|
+
kind: z2.literal("png"),
|
|
616
|
+
bytes: z2.instanceof(Uint8Array),
|
|
617
|
+
applySquircleFrame: z2.boolean().default(false),
|
|
618
|
+
backgroundColor: z2.string().min(1).optional()
|
|
619
|
+
})
|
|
620
|
+
]);
|
|
621
|
+
var FORBIDDEN_SVG_CONSTRUCTS = [
|
|
622
|
+
{ label: "DOCTYPE declaration", pattern: /<!DOCTYPE\b/i },
|
|
623
|
+
{ label: "ENTITY declaration", pattern: /<!ENTITY\b/i },
|
|
624
|
+
{ label: "xml-stylesheet processing instruction", pattern: /<\?xml-stylesheet\b/i },
|
|
625
|
+
{
|
|
626
|
+
label: "script or foreignObject element",
|
|
627
|
+
pattern: /<(?:[\w-]+:)?(?:script|foreignObject)\b/i
|
|
628
|
+
},
|
|
629
|
+
{ label: "CSS @import directive", pattern: /@import\b/i },
|
|
630
|
+
{ label: "inline event handler attribute", pattern: /\bon[a-z]+\s*=/i }
|
|
631
|
+
];
|
|
632
|
+
var HREF_ATTR_PATTERN = /(?:^|[\s<])(?:[\w-]+:)?href\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi;
|
|
633
|
+
var CSS_URL_PATTERN = /\burl\s*\(\s*([^)]*)\)/gi;
|
|
634
|
+
var ALLOWED_FRAGMENT_REF = /^#[A-Za-z_][\w.-]*$/;
|
|
635
|
+
var ALLOWED_DATA_IMAGE_URI = /^data:image\/(?:png|jpeg);base64,[A-Za-z0-9+/=\s]+$/i;
|
|
636
|
+
function assertSafeSvg(svg) {
|
|
637
|
+
if (!/<svg\b/i.test(svg)) {
|
|
638
|
+
throw new MacosIconError("UNSAFE_SVG", "SVG source must contain an <svg> root element");
|
|
639
|
+
}
|
|
640
|
+
for (const check of FORBIDDEN_SVG_CONSTRUCTS) {
|
|
641
|
+
if (check.pattern.test(svg)) {
|
|
642
|
+
throw new MacosIconError("UNSAFE_SVG", `SVG source rejected: forbidden ${check.label}`);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
for (const match of svg.matchAll(HREF_ATTR_PATTERN)) {
|
|
646
|
+
const rawValue = (match[1] ?? match[2] ?? match[3] ?? "").trim();
|
|
647
|
+
if (!ALLOWED_FRAGMENT_REF.test(rawValue) && !ALLOWED_DATA_IMAGE_URI.test(rawValue)) {
|
|
648
|
+
throw new MacosIconError("UNSAFE_SVG", `SVG source rejected: disallowed href value (${JSON.stringify(rawValue.slice(0, 48))})`);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
for (const match of svg.matchAll(CSS_URL_PATTERN)) {
|
|
652
|
+
const cleaned = (match[1] ?? "").trim().replace(/^["']|["']$/g, "").trim();
|
|
653
|
+
if (!ALLOWED_FRAGMENT_REF.test(cleaned)) {
|
|
654
|
+
throw new MacosIconError("UNSAFE_SVG", `SVG source rejected: disallowed url() reference (${JSON.stringify(cleaned.slice(0, 48))})`);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
function assertSafeColor(color) {
|
|
659
|
+
if (!SAFE_COLOR_PATTERN.test(color.trim())) {
|
|
660
|
+
throw new MacosIconError("INVALID_SOURCE", `Invalid icon backgroundColor: ${JSON.stringify(color)}`);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
function assertPngMagic(bytes) {
|
|
664
|
+
if (bytes.byteLength < PNG_MAGIC.length) {
|
|
665
|
+
throw new MacosIconError("INVALID_SOURCE", "PNG source is truncated");
|
|
666
|
+
}
|
|
667
|
+
for (let index = 0;index < PNG_MAGIC.length; index += 1) {
|
|
668
|
+
if (bytes[index] !== PNG_MAGIC[index]) {
|
|
669
|
+
throw new MacosIconError("INVALID_SOURCE", "PNG source does not start with PNG signature");
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
function assertJpegMagic(bytes) {
|
|
674
|
+
if (bytes.byteLength < 3 || bytes[0] !== 255 || bytes[1] !== 216) {
|
|
675
|
+
throw new MacosIconError("INVALID_SOURCE", "JPEG source does not start with SOI marker");
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
function assertValidIcnsBytes(bytes) {
|
|
679
|
+
if (bytes.byteLength < 8 || bytes[0] !== 105 || bytes[1] !== 99 || bytes[2] !== 110 || bytes[3] !== 115) {
|
|
680
|
+
throw new MacosIconError("INVALID_ICNS", 'Generated icon file is missing the "icns" magic');
|
|
681
|
+
}
|
|
682
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
683
|
+
const declaredLength = view.getUint32(4, false);
|
|
684
|
+
if (declaredLength < 8 || declaredLength > bytes.byteLength) {
|
|
685
|
+
throw new MacosIconError("INVALID_ICNS", `Generated icns header length (${declaredLength}) is invalid for ${bytes.byteLength} bytes`);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
function renderAppleSquircleSvg(options) {
|
|
689
|
+
const hasSvg = options.innerSvg !== undefined;
|
|
690
|
+
const hasImage = options.embeddedImage !== undefined;
|
|
691
|
+
if (hasSvg === hasImage) {
|
|
692
|
+
throw new MacosIconError("INVALID_SOURCE", "renderAppleSquircleSvg requires exactly one of innerSvg or embeddedImage");
|
|
693
|
+
}
|
|
694
|
+
if (options.backgroundColor !== undefined) {
|
|
695
|
+
assertSafeColor(options.backgroundColor);
|
|
696
|
+
}
|
|
697
|
+
const inset = APPLE_ICON_INSET_PX;
|
|
698
|
+
const tile = APPLE_ICON_TILE_PX;
|
|
699
|
+
const radius = APPLE_ICON_CORNER_RADIUS_PX;
|
|
700
|
+
const canvas = APPLE_ICON_CANVAS_PX;
|
|
701
|
+
let body;
|
|
702
|
+
if (options.innerSvg !== undefined) {
|
|
703
|
+
assertSafeSvg(options.innerSvg);
|
|
704
|
+
const stripped = options.innerSvg.replace(/<\?xml[\s\S]*?\?>/gi, "").trim();
|
|
705
|
+
body = ` <svg x="${inset}" y="${inset}" width="${tile}" height="${tile}">
|
|
706
|
+
${stripped}
|
|
707
|
+
</svg>`;
|
|
708
|
+
} else {
|
|
709
|
+
const image = options.embeddedImage;
|
|
710
|
+
if (!image) {
|
|
711
|
+
throw new MacosIconError("INVALID_SOURCE", "Missing embedded image");
|
|
712
|
+
}
|
|
713
|
+
if (image.mime === "image/jpeg")
|
|
714
|
+
assertJpegMagic(image.bytes);
|
|
715
|
+
else
|
|
716
|
+
assertPngMagic(image.bytes);
|
|
717
|
+
const encoded = Buffer.from(image.bytes).toString("base64");
|
|
718
|
+
body = ` <image href="data:${image.mime};base64,${encoded}" x="${inset}" y="${inset}" width="${tile}" height="${tile}" preserveAspectRatio="xMidYMid slice" />`;
|
|
719
|
+
}
|
|
720
|
+
const backgroundRect = options.backgroundColor !== undefined ? ` <rect x="${inset}" y="${inset}" width="${tile}" height="${tile}" fill="${options.backgroundColor.trim()}" />
|
|
721
|
+
` : "";
|
|
722
|
+
return [
|
|
723
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${canvas}" height="${canvas}" viewBox="0 0 ${canvas} ${canvas}">`,
|
|
724
|
+
" <defs>",
|
|
725
|
+
' <clipPath id="apple-squircle">',
|
|
726
|
+
` <rect x="${inset}" y="${inset}" width="${tile}" height="${tile}" rx="${radius}" ry="${radius}" />`,
|
|
727
|
+
" </clipPath>",
|
|
728
|
+
" </defs>",
|
|
729
|
+
' <g clip-path="url(#apple-squircle)">',
|
|
730
|
+
`${backgroundRect}${body}`,
|
|
731
|
+
" </g>",
|
|
732
|
+
"</svg>",
|
|
733
|
+
""
|
|
734
|
+
].join(`
|
|
735
|
+
`);
|
|
736
|
+
}
|
|
737
|
+
async function generateAppIconIcns(options) {
|
|
738
|
+
if (!options.outputPath.startsWith("/") || options.outputPath.includes("\x00")) {
|
|
739
|
+
throw new MacosIconError("INVALID_SOURCE", `Invalid icns outputPath: ${JSON.stringify(options.outputPath)}`);
|
|
740
|
+
}
|
|
741
|
+
const parsedResult = MacosIconSourceSchema.safeParse(options.source);
|
|
742
|
+
if (!parsedResult.success) {
|
|
743
|
+
throw new MacosIconError("INVALID_SOURCE", `Invalid macOS icon source: ${parsedResult.error.message}`, { cause: parsedResult.error });
|
|
744
|
+
}
|
|
745
|
+
const source = parsedResult.data;
|
|
746
|
+
const runner = options.runner ?? createDefaultMacosCommandRunner();
|
|
747
|
+
const cmdOpts = options.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : undefined;
|
|
748
|
+
const parentDir = dirname(options.outputPath);
|
|
749
|
+
await mkdir(parentDir, { recursive: true });
|
|
750
|
+
const stagingDir = await mkdtemp(join(parentDir, ".icon-stage-"));
|
|
751
|
+
const masterPngPath = join(stagingDir, "master.png");
|
|
752
|
+
const iconsetDir = join(stagingDir, "AppIcon.iconset");
|
|
753
|
+
const stagedIcnsPath = join(stagingDir, "AppIcon.icns");
|
|
754
|
+
const defaultRasterizeSvg = async (svgDoc, sizePx, outPngPath) => {
|
|
755
|
+
const svgPath = join(stagingDir, "icon.svg");
|
|
756
|
+
const qlOutPath = join(stagingDir, "icon.svg.png");
|
|
757
|
+
await writeFile(svgPath, svgDoc, "utf8");
|
|
758
|
+
const qlResult = await runner.runCommand(QLMANAGE_PATH, ["-t", "-s", String(sizePx), "-o", stagingDir, svgPath], cmdOpts);
|
|
759
|
+
if (qlResult.exitCode !== 0) {
|
|
760
|
+
throw new MacosIconError("COMMAND_FAILED", `qlmanage failed to rasterize SVG (exit ${qlResult.exitCode}): ${qlResult.stderr.trim()}`);
|
|
761
|
+
}
|
|
762
|
+
const sipsResult = await runner.runCommand(SIPS_PATH, [
|
|
763
|
+
"-s",
|
|
764
|
+
"format",
|
|
765
|
+
"png",
|
|
766
|
+
"-z",
|
|
767
|
+
String(sizePx),
|
|
768
|
+
String(sizePx),
|
|
769
|
+
qlOutPath,
|
|
770
|
+
"--out",
|
|
771
|
+
outPngPath
|
|
772
|
+
], cmdOpts);
|
|
773
|
+
if (sipsResult.exitCode !== 0) {
|
|
774
|
+
throw new MacosIconError("COMMAND_FAILED", `sips failed to normalize rasterized SVG (exit ${sipsResult.exitCode}): ${sipsResult.stderr.trim()}`);
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
const rasterizeSvg = options.rasterizeSvg ?? defaultRasterizeSvg;
|
|
778
|
+
try {
|
|
779
|
+
if (source.kind === "svg") {
|
|
780
|
+
assertSafeSvg(source.svg);
|
|
781
|
+
const svgDoc = source.applySquircleFrame ? renderAppleSquircleSvg({
|
|
782
|
+
innerSvg: source.svg,
|
|
783
|
+
backgroundColor: source.backgroundColor
|
|
784
|
+
}) : source.svg;
|
|
785
|
+
await rasterizeSvg(svgDoc, APPLE_ICON_CANVAS_PX, masterPngPath);
|
|
786
|
+
} else if (source.kind === "jpeg") {
|
|
787
|
+
assertJpegMagic(source.bytes);
|
|
788
|
+
const svgDoc = renderAppleSquircleSvg({
|
|
789
|
+
embeddedImage: { mime: "image/jpeg", bytes: source.bytes },
|
|
790
|
+
backgroundColor: source.backgroundColor
|
|
791
|
+
});
|
|
792
|
+
await rasterizeSvg(svgDoc, APPLE_ICON_CANVAS_PX, masterPngPath);
|
|
793
|
+
} else {
|
|
794
|
+
assertPngMagic(source.bytes);
|
|
795
|
+
if (source.applySquircleFrame) {
|
|
796
|
+
const svgDoc = renderAppleSquircleSvg({
|
|
797
|
+
embeddedImage: { mime: "image/png", bytes: source.bytes },
|
|
798
|
+
backgroundColor: source.backgroundColor
|
|
799
|
+
});
|
|
800
|
+
await rasterizeSvg(svgDoc, APPLE_ICON_CANVAS_PX, masterPngPath);
|
|
801
|
+
} else {
|
|
802
|
+
await writeFile(masterPngPath, source.bytes);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
await mkdir(iconsetDir, { recursive: true });
|
|
806
|
+
for (const slot of APPLE_ICONSET_SLOTS) {
|
|
807
|
+
const slotPath = join(iconsetDir, slot.filename);
|
|
808
|
+
const sipsResult = await runner.runCommand(SIPS_PATH, ["-z", String(slot.pixels), String(slot.pixels), masterPngPath, "--out", slotPath], cmdOpts);
|
|
809
|
+
if (sipsResult.exitCode !== 0) {
|
|
810
|
+
throw new MacosIconError("COMMAND_FAILED", `sips failed for ${slot.filename} (exit ${sipsResult.exitCode}): ${sipsResult.stderr.trim()}`);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
const iconutilResult = await runner.runCommand(ICONUTIL_PATH, ["-c", "icns", iconsetDir, "-o", stagedIcnsPath], cmdOpts);
|
|
814
|
+
if (iconutilResult.exitCode !== 0) {
|
|
815
|
+
throw new MacosIconError("COMMAND_FAILED", `iconutil failed (exit ${iconutilResult.exitCode}): ${iconutilResult.stderr.trim()}`);
|
|
816
|
+
}
|
|
817
|
+
const icnsBytes = new Uint8Array(await readFile(stagedIcnsPath));
|
|
818
|
+
assertValidIcnsBytes(icnsBytes);
|
|
819
|
+
await writeFileAtomic2(options.outputPath, icnsBytes, { mode: 420 });
|
|
820
|
+
return {
|
|
821
|
+
outputPath: options.outputPath,
|
|
822
|
+
sha256: computeSha256Hex(icnsBytes),
|
|
823
|
+
byteLength: icnsBytes.byteLength
|
|
824
|
+
};
|
|
825
|
+
} finally {
|
|
826
|
+
await rm(stagingDir, { recursive: true, force: true }).catch(() => {
|
|
827
|
+
return;
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
// src/service-host/macos/launch-services.ts
|
|
833
|
+
import { lstat, realpath as realpath2 } from "node:fs/promises";
|
|
834
|
+
import { homedir } from "node:os";
|
|
835
|
+
import { posix as posix2 } from "node:path";
|
|
836
|
+
var LSREGISTER_PATH = "/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";
|
|
837
|
+
var KLS_APPLICATION_NOT_FOUND_ERR = -10814;
|
|
838
|
+
var DEFAULT_LSREGISTER_DUMP_MAX_BYTES = 128 * 1024 * 1024;
|
|
839
|
+
var DEFAULT_MAX_UNREGISTRATIONS = 64;
|
|
840
|
+
var MAX_DUMP_LINE_CHARS = 65536;
|
|
841
|
+
var NOT_FOUND_ERR_PATTERN = /(?:^|[^\d-])(-10814)(?!\d)|kLSApplicationNotFoundErr/;
|
|
842
|
+
var TRAILING_HEX_ID_PATTERN = /\s+\(0x[0-9a-fA-F]+\)\s*$/;
|
|
843
|
+
var SECTION_DIVIDER_PATTERN = /^-{10,}$/;
|
|
844
|
+
|
|
845
|
+
class MacosLaunchServicesError extends Error {
|
|
846
|
+
code;
|
|
847
|
+
constructor(code, message, options) {
|
|
848
|
+
super(message, options);
|
|
849
|
+
this.code = code;
|
|
850
|
+
this.name = "MacosLaunchServicesError";
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
function failOptions(message) {
|
|
854
|
+
throw new MacosLaunchServicesError("INVALID_OPTIONS", message);
|
|
855
|
+
}
|
|
856
|
+
function assertAbsolutePath(label, targetPath) {
|
|
857
|
+
if (!targetPath.startsWith("/") || targetPath.includes("\x00") || targetPath.length === 0) {
|
|
858
|
+
failOptions(`${label} must be an absolute path without NUL bytes: ${JSON.stringify(targetPath)}`);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
function assertPositiveLimit(label, value, fallback) {
|
|
862
|
+
const limit = value ?? fallback;
|
|
863
|
+
if (!Number.isSafeInteger(limit) || limit <= 0)
|
|
864
|
+
failOptions(`Invalid ${label}: ${limit}`);
|
|
865
|
+
return limit;
|
|
866
|
+
}
|
|
867
|
+
async function registerBundle(options) {
|
|
868
|
+
assertAbsolutePath("bundlePath", options.bundlePath);
|
|
869
|
+
const runner = options.runner ?? createDefaultMacosCommandRunner();
|
|
870
|
+
const result = await runner.runCommand(LSREGISTER_PATH, ["-f", options.bundlePath], {
|
|
871
|
+
timeoutMs: options.timeoutMs
|
|
872
|
+
});
|
|
873
|
+
if (result.exitCode !== 0) {
|
|
874
|
+
throw new MacosLaunchServicesError("COMMAND_FAILED", `lsregister -f failed for ${options.bundlePath} (exit ${result.exitCode}): ${(result.stderr || result.stdout).trim()}`);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
async function forgetRegistration(options) {
|
|
878
|
+
assertAbsolutePath("bundlePath", options.bundlePath);
|
|
879
|
+
const runner = options.runner ?? createDefaultMacosCommandRunner();
|
|
880
|
+
const result = await runner.runCommand(LSREGISTER_PATH, ["-u", options.bundlePath], {
|
|
881
|
+
timeoutMs: options.timeoutMs
|
|
882
|
+
});
|
|
883
|
+
if (result.exitCode === 0)
|
|
884
|
+
return "unregistered";
|
|
885
|
+
const combined = `${result.stderr}
|
|
886
|
+
${result.stdout}`;
|
|
887
|
+
const sanitized = combined.replaceAll(options.bundlePath, "");
|
|
888
|
+
if (NOT_FOUND_ERR_PATTERN.test(sanitized))
|
|
889
|
+
return "not-registered";
|
|
890
|
+
throw new MacosLaunchServicesError("COMMAND_FAILED", `lsregister -u failed for ${options.bundlePath} (exit ${result.exitCode}): ${combined.trim()}`);
|
|
891
|
+
}
|
|
892
|
+
function stripHexId(raw) {
|
|
893
|
+
return raw.trim().replace(TRAILING_HEX_ID_PATTERN, "").trim();
|
|
894
|
+
}
|
|
895
|
+
function createLsregisterDumpParser(onRecord) {
|
|
896
|
+
let pending = "";
|
|
897
|
+
let discardingLongLine = false;
|
|
898
|
+
let currentPath = null;
|
|
899
|
+
let currentBundleId = null;
|
|
900
|
+
const emitSection = () => {
|
|
901
|
+
if (currentPath !== null)
|
|
902
|
+
onRecord({ path: currentPath, bundleIdentifier: currentBundleId });
|
|
903
|
+
currentPath = null;
|
|
904
|
+
currentBundleId = null;
|
|
905
|
+
};
|
|
906
|
+
const processLine = (rawLine) => {
|
|
907
|
+
const trimmed = rawLine.trim();
|
|
908
|
+
if (SECTION_DIVIDER_PATTERN.test(trimmed)) {
|
|
909
|
+
emitSection();
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
if (trimmed.startsWith("path:")) {
|
|
913
|
+
if (currentPath === null) {
|
|
914
|
+
const value = stripHexId(trimmed.slice(5));
|
|
915
|
+
if (value.startsWith("/") && !value.includes("\x00"))
|
|
916
|
+
currentPath = value;
|
|
917
|
+
}
|
|
918
|
+
} else if (trimmed.startsWith("identifier:")) {
|
|
919
|
+
if (currentBundleId === null) {
|
|
920
|
+
const value = stripHexId(trimmed.slice(11));
|
|
921
|
+
if (value.length > 0 && value !== "(null)")
|
|
922
|
+
currentBundleId = value;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
return {
|
|
927
|
+
push(text) {
|
|
928
|
+
let start = 0;
|
|
929
|
+
if (discardingLongLine) {
|
|
930
|
+
const nl = text.indexOf(`
|
|
931
|
+
`);
|
|
932
|
+
if (nl < 0)
|
|
933
|
+
return;
|
|
934
|
+
discardingLongLine = false;
|
|
935
|
+
start = nl + 1;
|
|
936
|
+
}
|
|
937
|
+
const chunk = start > 0 ? text.slice(start) : text;
|
|
938
|
+
const combined = pending.length > 0 ? pending + chunk : chunk;
|
|
939
|
+
let cursor = 0;
|
|
940
|
+
for (let nl = combined.indexOf(`
|
|
941
|
+
`, cursor);nl >= 0; nl = combined.indexOf(`
|
|
942
|
+
`, cursor)) {
|
|
943
|
+
if (nl - cursor <= MAX_DUMP_LINE_CHARS) {
|
|
944
|
+
processLine(combined.slice(cursor, nl));
|
|
945
|
+
}
|
|
946
|
+
cursor = nl + 1;
|
|
947
|
+
}
|
|
948
|
+
const remainderLen = combined.length - cursor;
|
|
949
|
+
if (remainderLen > MAX_DUMP_LINE_CHARS) {
|
|
950
|
+
pending = "";
|
|
951
|
+
discardingLongLine = true;
|
|
952
|
+
} else {
|
|
953
|
+
pending = cursor > 0 ? combined.slice(cursor) : combined;
|
|
954
|
+
}
|
|
955
|
+
},
|
|
956
|
+
flush() {
|
|
957
|
+
if (!discardingLongLine && pending.length > 0) {
|
|
958
|
+
processLine(pending);
|
|
959
|
+
}
|
|
960
|
+
pending = "";
|
|
961
|
+
discardingLongLine = false;
|
|
962
|
+
emitSection();
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
function parseLsregisterDump(dumpText) {
|
|
967
|
+
const records = [];
|
|
968
|
+
const parser = createLsregisterDumpParser((record) => records.push(record));
|
|
969
|
+
parser.push(dumpText);
|
|
970
|
+
parser.flush();
|
|
971
|
+
return records;
|
|
972
|
+
}
|
|
973
|
+
async function scanLsregisterDump(options) {
|
|
974
|
+
const maxDumpBytes = assertPositiveLimit("maxDumpBytes", options.maxDumpBytes, DEFAULT_LSREGISTER_DUMP_MAX_BYTES);
|
|
975
|
+
const runner = options.runner ?? createDefaultMacosCommandRunner();
|
|
976
|
+
const decoder = new TextDecoder("utf-8");
|
|
977
|
+
let totalBytes = 0;
|
|
978
|
+
let recordCount = 0;
|
|
979
|
+
let receivedStreamChunk = false;
|
|
980
|
+
const queuedRecords = [];
|
|
981
|
+
const parser = createLsregisterDumpParser((record) => {
|
|
982
|
+
recordCount += 1;
|
|
983
|
+
queuedRecords.push(record);
|
|
984
|
+
});
|
|
985
|
+
const drainQueued = async () => {
|
|
986
|
+
while (queuedRecords.length > 0) {
|
|
987
|
+
const next = queuedRecords.shift();
|
|
988
|
+
if (next !== undefined)
|
|
989
|
+
await options.onRecord(next);
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
const addBytes = (count) => {
|
|
993
|
+
totalBytes += count;
|
|
994
|
+
if (totalBytes > maxDumpBytes) {
|
|
995
|
+
throw new MacosLaunchServicesError("LIMIT_EXCEEDED", `lsregister -dump exceeded maxDumpBytes (${maxDumpBytes})`);
|
|
996
|
+
}
|
|
997
|
+
};
|
|
998
|
+
let result;
|
|
999
|
+
try {
|
|
1000
|
+
result = await runner.runCommand(LSREGISTER_PATH, ["-dump"], {
|
|
1001
|
+
maxOutputBytes: maxDumpBytes,
|
|
1002
|
+
timeoutMs: options.timeoutMs,
|
|
1003
|
+
async onOutput(chunk, channel) {
|
|
1004
|
+
if (channel !== "stdout")
|
|
1005
|
+
return;
|
|
1006
|
+
receivedStreamChunk = true;
|
|
1007
|
+
addBytes(chunk.byteLength);
|
|
1008
|
+
parser.push(decoder.decode(chunk, { stream: true }));
|
|
1009
|
+
await drainQueued();
|
|
1010
|
+
}
|
|
1011
|
+
});
|
|
1012
|
+
} catch (cause) {
|
|
1013
|
+
if (cause instanceof NativeCommandError2 && cause.code === "COMMAND_LIMIT") {
|
|
1014
|
+
throw new MacosLaunchServicesError("LIMIT_EXCEEDED", `lsregister -dump exceeded runner limit (${maxDumpBytes} bytes)`, { cause });
|
|
1015
|
+
}
|
|
1016
|
+
throw cause;
|
|
1017
|
+
}
|
|
1018
|
+
if (result.exitCode !== 0) {
|
|
1019
|
+
throw new MacosLaunchServicesError("COMMAND_FAILED", `lsregister -dump failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
|
|
1020
|
+
}
|
|
1021
|
+
if (!receivedStreamChunk && result.stdout.length > 0) {
|
|
1022
|
+
addBytes(new TextEncoder().encode(result.stdout).byteLength);
|
|
1023
|
+
parser.push(result.stdout);
|
|
1024
|
+
} else {
|
|
1025
|
+
const trailing = decoder.decode();
|
|
1026
|
+
if (trailing.length > 0)
|
|
1027
|
+
parser.push(trailing);
|
|
1028
|
+
}
|
|
1029
|
+
parser.flush();
|
|
1030
|
+
await drainQueued();
|
|
1031
|
+
return { totalBytes, recordCount };
|
|
1032
|
+
}
|
|
1033
|
+
function matchesBundleFilter(record, bundleId, bundleIdPrefix) {
|
|
1034
|
+
if (bundleId === undefined && bundleIdPrefix === undefined)
|
|
1035
|
+
return true;
|
|
1036
|
+
if (record.bundleIdentifier === null)
|
|
1037
|
+
return false;
|
|
1038
|
+
return bundleId !== undefined && record.bundleIdentifier === bundleId || bundleIdPrefix !== undefined && record.bundleIdentifier.startsWith(bundleIdPrefix);
|
|
1039
|
+
}
|
|
1040
|
+
async function defaultPathExists(targetPath) {
|
|
1041
|
+
try {
|
|
1042
|
+
await lstat(targetPath);
|
|
1043
|
+
return true;
|
|
1044
|
+
} catch (cause) {
|
|
1045
|
+
const code = errnoOf(cause);
|
|
1046
|
+
return code !== "ENOENT" && code !== "ENOTDIR";
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
async function sweepRegistrations(config, select) {
|
|
1050
|
+
const maxUnregistrations = assertPositiveLimit("maxUnregistrations", config.maxUnregistrations, DEFAULT_MAX_UNREGISTRATIONS);
|
|
1051
|
+
const candidates = new Set;
|
|
1052
|
+
const skippedProtected = new Set;
|
|
1053
|
+
let scanned = 0;
|
|
1054
|
+
await scanLsregisterDump({
|
|
1055
|
+
runner: config.runner,
|
|
1056
|
+
maxDumpBytes: config.maxDumpBytes,
|
|
1057
|
+
timeoutMs: config.timeoutMs,
|
|
1058
|
+
async onRecord(record) {
|
|
1059
|
+
scanned += 1;
|
|
1060
|
+
if (!matchesBundleFilter(record, config.bundleId, config.bundleIdPrefix))
|
|
1061
|
+
return;
|
|
1062
|
+
const decision = await select(record);
|
|
1063
|
+
if (decision === "protected")
|
|
1064
|
+
skippedProtected.add(record.path);
|
|
1065
|
+
else if (decision === "unregister")
|
|
1066
|
+
candidates.add(record.path);
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1069
|
+
if (candidates.size > maxUnregistrations) {
|
|
1070
|
+
throw new MacosLaunchServicesError("LIMIT_EXCEEDED", `Refusing to unregister ${candidates.size} LaunchServices entries (maxUnregistrations=${maxUnregistrations})`);
|
|
1071
|
+
}
|
|
1072
|
+
const unregistered = [];
|
|
1073
|
+
const alreadyAbsent = [];
|
|
1074
|
+
for (const candidate of candidates) {
|
|
1075
|
+
const outcome = await forgetRegistration({
|
|
1076
|
+
bundlePath: candidate,
|
|
1077
|
+
runner: config.runner,
|
|
1078
|
+
timeoutMs: config.timeoutMs
|
|
1079
|
+
});
|
|
1080
|
+
if (outcome === "unregistered")
|
|
1081
|
+
unregistered.push(candidate);
|
|
1082
|
+
else
|
|
1083
|
+
alreadyAbsent.push(candidate);
|
|
1084
|
+
}
|
|
1085
|
+
return { scanned, unregistered, skippedProtected: [...skippedProtected], alreadyAbsent };
|
|
1086
|
+
}
|
|
1087
|
+
async function forgetStaleRegistrations(options) {
|
|
1088
|
+
const bundleId = options.bundleId?.trim();
|
|
1089
|
+
const bundleIdPrefix = options.bundleIdPrefix?.trim();
|
|
1090
|
+
if ((!bundleId || bundleId.length === 0) && (!bundleIdPrefix || bundleIdPrefix.length === 0)) {
|
|
1091
|
+
failOptions("forgetStaleRegistrations requires a non-empty bundleId or bundleIdPrefix");
|
|
1092
|
+
}
|
|
1093
|
+
if (bundleId?.includes("*") || bundleIdPrefix?.includes("*")) {
|
|
1094
|
+
failOptions("Wildcards are not permitted in bundleId or bundleIdPrefix");
|
|
1095
|
+
}
|
|
1096
|
+
const realpathFn = options.realpathFn ?? realpath2;
|
|
1097
|
+
const pathExists = options.pathExists ?? defaultPathExists;
|
|
1098
|
+
const keepCanonical = new Set;
|
|
1099
|
+
for (const keep of options.keepPaths ?? []) {
|
|
1100
|
+
assertAbsolutePath("keepPaths[]", keep);
|
|
1101
|
+
keepCanonical.add(macosPathKey(await canonicalizeMacosPath(keep, realpathFn)));
|
|
1102
|
+
}
|
|
1103
|
+
return sweepRegistrations({ ...options, bundleId, bundleIdPrefix }, async (record) => {
|
|
1104
|
+
const canonicalRecord = await canonicalizeMacosPath(record.path, realpathFn);
|
|
1105
|
+
if (isProtectedMacosSystemPath(record.path) || isProtectedMacosSystemPath(canonicalRecord)) {
|
|
1106
|
+
return "protected";
|
|
1107
|
+
}
|
|
1108
|
+
if (keepCanonical.has(macosPathKey(canonicalRecord)))
|
|
1109
|
+
return "skip";
|
|
1110
|
+
if (await pathExists(record.path) && !options.removeExistingOutsideKeep)
|
|
1111
|
+
return "skip";
|
|
1112
|
+
return "unregister";
|
|
1113
|
+
});
|
|
1114
|
+
}
|
|
1115
|
+
async function resolveForbiddenHomes(realpathFn) {
|
|
1116
|
+
const homes = new Set;
|
|
1117
|
+
for (const raw of [homedir(), process.env.HOME]) {
|
|
1118
|
+
if (typeof raw === "string" && raw.startsWith("/") && raw.length > 1) {
|
|
1119
|
+
homes.add(macosPathKey(raw));
|
|
1120
|
+
homes.add(macosPathKey(await canonicalizeMacosPath(raw, realpathFn)));
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
return homes;
|
|
1124
|
+
}
|
|
1125
|
+
async function forgetBuildTree(options) {
|
|
1126
|
+
assertAbsolutePath("buildDir", options.buildDir);
|
|
1127
|
+
if (options.buildDir.split("/").includes("..")) {
|
|
1128
|
+
failOptions(`buildDir must not contain '..' segments: ${options.buildDir}`);
|
|
1129
|
+
}
|
|
1130
|
+
const rawNormalized = posix2.normalize(options.buildDir).replace(/\/+$/, "") || "/";
|
|
1131
|
+
const realpathFn = options.realpathFn ?? realpath2;
|
|
1132
|
+
const canonicalBuildDir = await canonicalizeMacosPath(rawNormalized, realpathFn);
|
|
1133
|
+
const forbiddenHomes = await resolveForbiddenHomes(realpathFn);
|
|
1134
|
+
if (isMacosForbiddenBuildRoot(rawNormalized) || isMacosForbiddenBuildRoot(canonicalBuildDir) || forbiddenHomes.has(macosPathKey(rawNormalized)) || forbiddenHomes.has(macosPathKey(canonicalBuildDir))) {
|
|
1135
|
+
failOptions(`Refusing to sweep LaunchServices entries for root, home, or system directory: ${options.buildDir}`);
|
|
1136
|
+
}
|
|
1137
|
+
return sweepRegistrations(options, async (record) => {
|
|
1138
|
+
const canonicalRecord = await canonicalizeMacosPath(record.path, realpathFn);
|
|
1139
|
+
if (!isPathWithinDirectory(canonicalRecord, canonicalBuildDir))
|
|
1140
|
+
return "skip";
|
|
1141
|
+
if (isProtectedMacosSystemPath(record.path) || isProtectedMacosSystemPath(canonicalRecord)) {
|
|
1142
|
+
return "protected";
|
|
1143
|
+
}
|
|
1144
|
+
return "unregister";
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
// src/service-host/macos/launcher.ts
|
|
1149
|
+
import { chmod, mkdtemp as mkdtemp2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
1150
|
+
import { tmpdir } from "node:os";
|
|
1151
|
+
import { join as join2 } from "node:path";
|
|
1152
|
+
import { z as z3 } from "zod";
|
|
1153
|
+
var LAUNCHER_EXIT_NOT_LAUNCHD = 78;
|
|
1154
|
+
var MAX_FIXED_ARGS = 64;
|
|
1155
|
+
var MAX_ENV_OVERRIDES = 64;
|
|
1156
|
+
var MAX_STRING_BYTES = 4096;
|
|
1157
|
+
var ENV_KEY_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
1158
|
+
|
|
1159
|
+
class MacosLauncherError extends Error {
|
|
1160
|
+
code;
|
|
1161
|
+
constructor(code, message, options) {
|
|
1162
|
+
super(message, options);
|
|
1163
|
+
this.name = "MacosLauncherError";
|
|
1164
|
+
this.code = code;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
function byteLengthOf(value) {
|
|
1168
|
+
return new TextEncoder().encode(value).byteLength;
|
|
1169
|
+
}
|
|
1170
|
+
var MacosLauncherConfigSchema = z3.strictObject({
|
|
1171
|
+
targetExecutable: z3.string().min(1),
|
|
1172
|
+
fixedArgs: z3.array(z3.string()).max(MAX_FIXED_ARGS).default([]),
|
|
1173
|
+
forwardArgv: z3.boolean().default(false),
|
|
1174
|
+
requireLaunchdParent: z3.boolean().default(true),
|
|
1175
|
+
envOverrides: z3.record(z3.string(), z3.string()).optional(),
|
|
1176
|
+
workingDirectory: z3.string().min(1).optional()
|
|
1177
|
+
}).check((ctx) => {
|
|
1178
|
+
const value = ctx.value;
|
|
1179
|
+
if (!value.targetExecutable.startsWith("/") || value.targetExecutable.includes("\x00") || byteLengthOf(value.targetExecutable) > MAX_STRING_BYTES) {
|
|
1180
|
+
ctx.issues.push({
|
|
1181
|
+
code: "custom",
|
|
1182
|
+
input: value.targetExecutable,
|
|
1183
|
+
path: ["targetExecutable"],
|
|
1184
|
+
message: "targetExecutable must be an absolute path without NUL bytes (<= 4096 bytes)"
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
for (let index = 0;index < value.fixedArgs.length; index += 1) {
|
|
1188
|
+
const arg = value.fixedArgs[index] ?? "";
|
|
1189
|
+
if (arg.includes("\x00") || byteLengthOf(arg) > MAX_STRING_BYTES) {
|
|
1190
|
+
ctx.issues.push({
|
|
1191
|
+
code: "custom",
|
|
1192
|
+
input: arg,
|
|
1193
|
+
path: ["fixedArgs", index],
|
|
1194
|
+
message: "fixedArgs entries must not contain NUL bytes and must be <= 4096 bytes"
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
if (value.workingDirectory !== undefined) {
|
|
1199
|
+
if (!value.workingDirectory.startsWith("/") || value.workingDirectory.includes("\x00") || byteLengthOf(value.workingDirectory) > MAX_STRING_BYTES) {
|
|
1200
|
+
ctx.issues.push({
|
|
1201
|
+
code: "custom",
|
|
1202
|
+
input: value.workingDirectory,
|
|
1203
|
+
path: ["workingDirectory"],
|
|
1204
|
+
message: "workingDirectory must be an absolute path without NUL bytes (<= 4096 bytes)"
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
if (value.envOverrides !== undefined) {
|
|
1209
|
+
const entries = Object.entries(value.envOverrides);
|
|
1210
|
+
if (entries.length > MAX_ENV_OVERRIDES) {
|
|
1211
|
+
ctx.issues.push({
|
|
1212
|
+
code: "custom",
|
|
1213
|
+
input: value.envOverrides,
|
|
1214
|
+
path: ["envOverrides"],
|
|
1215
|
+
message: `envOverrides cannot exceed ${MAX_ENV_OVERRIDES} entries`
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
for (const [key, val] of entries) {
|
|
1219
|
+
if (!ENV_KEY_PATTERN.test(key) || byteLengthOf(key) > MAX_STRING_BYTES) {
|
|
1220
|
+
ctx.issues.push({
|
|
1221
|
+
code: "custom",
|
|
1222
|
+
input: key,
|
|
1223
|
+
path: ["envOverrides", key],
|
|
1224
|
+
message: `Invalid environment variable key: ${JSON.stringify(key)}`
|
|
1225
|
+
});
|
|
1226
|
+
}
|
|
1227
|
+
if (val.includes("\x00") || byteLengthOf(val) > MAX_STRING_BYTES) {
|
|
1228
|
+
ctx.issues.push({
|
|
1229
|
+
code: "custom",
|
|
1230
|
+
input: val,
|
|
1231
|
+
path: ["envOverrides", key],
|
|
1232
|
+
message: "envOverrides values must not contain NUL bytes and must be <= 4096 bytes"
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
});
|
|
1238
|
+
function encodeCByteArray(value) {
|
|
1239
|
+
const bytes = new TextEncoder().encode(value);
|
|
1240
|
+
const parts = [];
|
|
1241
|
+
for (const byte of bytes) {
|
|
1242
|
+
parts.push(`0x${byte.toString(16).padStart(2, "0")}`);
|
|
1243
|
+
}
|
|
1244
|
+
parts.push("0x00");
|
|
1245
|
+
return `{ ${parts.join(", ")} }`;
|
|
1246
|
+
}
|
|
1247
|
+
function renderMacosLauncherSource(config) {
|
|
1248
|
+
const parsedResult = MacosLauncherConfigSchema.safeParse(config);
|
|
1249
|
+
if (!parsedResult.success) {
|
|
1250
|
+
throw new MacosLauncherError("INVALID_CONFIG", `Invalid macOS launcher configuration: ${parsedResult.error.message}`, { cause: parsedResult.error });
|
|
1251
|
+
}
|
|
1252
|
+
const parsed = parsedResult.data;
|
|
1253
|
+
const dataDecls = [
|
|
1254
|
+
`static char k_target[] = ${encodeCByteArray(parsed.targetExecutable)};`
|
|
1255
|
+
];
|
|
1256
|
+
for (let index = 0;index < parsed.fixedArgs.length; index += 1) {
|
|
1257
|
+
const arg = parsed.fixedArgs[index] ?? "";
|
|
1258
|
+
dataDecls.push(`static char k_arg_${index}[] = ${encodeCByteArray(arg)};`);
|
|
1259
|
+
}
|
|
1260
|
+
if (parsed.workingDirectory !== undefined) {
|
|
1261
|
+
dataDecls.push(`static char k_working_dir[] = ${encodeCByteArray(parsed.workingDirectory)};`);
|
|
1262
|
+
}
|
|
1263
|
+
const envEntries = parsed.envOverrides === undefined ? [] : Object.entries(parsed.envOverrides).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
|
|
1264
|
+
for (let index = 0;index < envEntries.length; index += 1) {
|
|
1265
|
+
const entry = envEntries[index];
|
|
1266
|
+
if (!entry)
|
|
1267
|
+
continue;
|
|
1268
|
+
dataDecls.push(`static char k_env_key_${index}[] = ${encodeCByteArray(entry[0])};`);
|
|
1269
|
+
dataDecls.push(`static char k_env_val_${index}[] = ${encodeCByteArray(entry[1])};`);
|
|
1270
|
+
}
|
|
1271
|
+
const preSpawnLines = [];
|
|
1272
|
+
if (parsed.requireLaunchdParent) {
|
|
1273
|
+
preSpawnLines.push(" if (getppid() != 1) {", ` _exit(${LAUNCHER_EXIT_NOT_LAUNCHD});`, " }");
|
|
1274
|
+
}
|
|
1275
|
+
if (parsed.workingDirectory !== undefined) {
|
|
1276
|
+
preSpawnLines.push(" if (chdir(k_working_dir) != 0) {", " _exit(126);", " }");
|
|
1277
|
+
}
|
|
1278
|
+
for (let index = 0;index < envEntries.length; index += 1) {
|
|
1279
|
+
preSpawnLines.push(` if (setenv(k_env_key_${index}, k_env_val_${index}, 1) != 0) {`, " _exit(126);", " }");
|
|
1280
|
+
}
|
|
1281
|
+
const argvLines = [];
|
|
1282
|
+
if (!parsed.forwardArgv) {
|
|
1283
|
+
const items = [
|
|
1284
|
+
"k_target",
|
|
1285
|
+
...parsed.fixedArgs.map((_, index) => `k_arg_${index}`),
|
|
1286
|
+
"NULL"
|
|
1287
|
+
];
|
|
1288
|
+
argvLines.push(" (void)argc;", " (void)argv;");
|
|
1289
|
+
argvLines.push(` char *child_argv[] = { ${items.join(", ")} };`);
|
|
1290
|
+
} else {
|
|
1291
|
+
const fixedCount = 1 + parsed.fixedArgs.length;
|
|
1292
|
+
argvLines.push(" size_t extra_argc = (argc > 1) ? (size_t)(argc - 1) : 0;", " if (extra_argc > 4096) {", " _exit(126);", " }", ` size_t total_argc = ${fixedCount}u + extra_argc + 1u;`, " char **child_argv = (char **)calloc(total_argc, sizeof(char *));", " if (child_argv == NULL) {", " _exit(126);", " }", " child_argv[0] = k_target;");
|
|
1293
|
+
for (let index = 0;index < parsed.fixedArgs.length; index += 1) {
|
|
1294
|
+
argvLines.push(` child_argv[${index + 1}] = k_arg_${index};`);
|
|
1295
|
+
}
|
|
1296
|
+
argvLines.push(" for (size_t i = 0; i < extra_argc; i++) {", ` child_argv[${fixedCount}u + i] = argv[1 + (int)i];`, " }", ` child_argv[${fixedCount}u + extra_argc] = NULL;`);
|
|
1297
|
+
}
|
|
1298
|
+
const freeArgvLine = parsed.forwardArgv ? ` free(child_argv);
|
|
1299
|
+
` : "";
|
|
1300
|
+
return [
|
|
1301
|
+
"#define _DARWIN_C_SOURCE",
|
|
1302
|
+
"#define _POSIX_C_SOURCE 200809L",
|
|
1303
|
+
"",
|
|
1304
|
+
"#include <errno.h>",
|
|
1305
|
+
"#include <signal.h>",
|
|
1306
|
+
"#include <spawn.h>",
|
|
1307
|
+
"#include <stddef.h>",
|
|
1308
|
+
"#include <stdint.h>",
|
|
1309
|
+
"#include <stdlib.h>",
|
|
1310
|
+
"#include <string.h>",
|
|
1311
|
+
"#include <sys/wait.h>",
|
|
1312
|
+
"#include <unistd.h>",
|
|
1313
|
+
"",
|
|
1314
|
+
"extern char **environ;",
|
|
1315
|
+
"",
|
|
1316
|
+
"static volatile sig_atomic_t g_child_pid = 0;",
|
|
1317
|
+
"",
|
|
1318
|
+
...dataDecls,
|
|
1319
|
+
"",
|
|
1320
|
+
"static void forward_signal(int sig) {",
|
|
1321
|
+
" int saved_errno = errno;",
|
|
1322
|
+
" pid_t child = (pid_t)g_child_pid;",
|
|
1323
|
+
" if (child > 0) {",
|
|
1324
|
+
" (void)kill(child, sig);",
|
|
1325
|
+
" }",
|
|
1326
|
+
" errno = saved_errno;",
|
|
1327
|
+
"}",
|
|
1328
|
+
"",
|
|
1329
|
+
"int main(int argc, char **argv) {",
|
|
1330
|
+
...preSpawnLines,
|
|
1331
|
+
...argvLines,
|
|
1332
|
+
" sigset_t blocked;",
|
|
1333
|
+
" sigset_t previous;",
|
|
1334
|
+
" if (sigemptyset(&blocked) != 0) _exit(126);",
|
|
1335
|
+
" if (sigaddset(&blocked, SIGTERM) != 0) _exit(126);",
|
|
1336
|
+
" if (sigaddset(&blocked, SIGINT) != 0) _exit(126);",
|
|
1337
|
+
" if (sigaddset(&blocked, SIGHUP) != 0) _exit(126);",
|
|
1338
|
+
" if (sigaddset(&blocked, SIGQUIT) != 0) _exit(126);",
|
|
1339
|
+
" if (sigprocmask(SIG_BLOCK, &blocked, &previous) != 0) _exit(126);",
|
|
1340
|
+
"",
|
|
1341
|
+
" struct sigaction action;",
|
|
1342
|
+
" memset(&action, 0, sizeof(action));",
|
|
1343
|
+
" action.sa_handler = forward_signal;",
|
|
1344
|
+
" if (sigemptyset(&action.sa_mask) != 0) _exit(126);",
|
|
1345
|
+
" action.sa_flags = 0;",
|
|
1346
|
+
" if (sigaction(SIGTERM, &action, NULL) != 0) _exit(126);",
|
|
1347
|
+
" if (sigaction(SIGINT, &action, NULL) != 0) _exit(126);",
|
|
1348
|
+
" if (sigaction(SIGHUP, &action, NULL) != 0) _exit(126);",
|
|
1349
|
+
" if (sigaction(SIGQUIT, &action, NULL) != 0) _exit(126);",
|
|
1350
|
+
"",
|
|
1351
|
+
" posix_spawnattr_t attr;",
|
|
1352
|
+
" if (posix_spawnattr_init(&attr) != 0) _exit(126);",
|
|
1353
|
+
" if (posix_spawnattr_setsigmask(&attr, &previous) != 0) {",
|
|
1354
|
+
" (void)posix_spawnattr_destroy(&attr);",
|
|
1355
|
+
" _exit(126);",
|
|
1356
|
+
" }",
|
|
1357
|
+
" if (posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGMASK) != 0) {",
|
|
1358
|
+
" (void)posix_spawnattr_destroy(&attr);",
|
|
1359
|
+
" _exit(126);",
|
|
1360
|
+
" }",
|
|
1361
|
+
"",
|
|
1362
|
+
" pid_t child = 0;",
|
|
1363
|
+
" int spawn_rc = posix_spawn(&child, k_target, NULL, &attr, child_argv, environ);",
|
|
1364
|
+
" (void)posix_spawnattr_destroy(&attr);",
|
|
1365
|
+
`${freeArgvLine} if (spawn_rc != 0 || child <= 0) _exit(127);`,
|
|
1366
|
+
"",
|
|
1367
|
+
" g_child_pid = (sig_atomic_t)child;",
|
|
1368
|
+
" if (sigprocmask(SIG_SETMASK, &previous, NULL) != 0) {",
|
|
1369
|
+
" (void)kill(child, SIGTERM);",
|
|
1370
|
+
" _exit(126);",
|
|
1371
|
+
" }",
|
|
1372
|
+
"",
|
|
1373
|
+
" int status = 0;",
|
|
1374
|
+
" pid_t waited;",
|
|
1375
|
+
" do {",
|
|
1376
|
+
" waited = waitpid(child, &status, 0);",
|
|
1377
|
+
" } while (waited < 0 && errno == EINTR);",
|
|
1378
|
+
" g_child_pid = 0;",
|
|
1379
|
+
" if (waited < 0) _exit(126);",
|
|
1380
|
+
" if (WIFEXITED(status)) return WEXITSTATUS(status);",
|
|
1381
|
+
" if (WIFSIGNALED(status)) return 128 + WTERMSIG(status);",
|
|
1382
|
+
" return 1;",
|
|
1383
|
+
"}",
|
|
1384
|
+
""
|
|
1385
|
+
].join(`
|
|
1386
|
+
`);
|
|
1387
|
+
}
|
|
1388
|
+
async function compileMacosLauncher(options) {
|
|
1389
|
+
if (!options.outputPath.startsWith("/") || /[\0\r\n]/.test(options.outputPath)) {
|
|
1390
|
+
throw new MacosLauncherError("INVALID_CONFIG", `Invalid launcher outputPath: ${JSON.stringify(options.outputPath)}`);
|
|
1391
|
+
}
|
|
1392
|
+
if (options.sourcePath !== undefined && (!options.sourcePath.startsWith("/") || /[\0\r\n]/.test(options.sourcePath))) {
|
|
1393
|
+
throw new MacosLauncherError("INVALID_CONFIG", `Invalid launcher sourcePath: ${JSON.stringify(options.sourcePath)}`);
|
|
1394
|
+
}
|
|
1395
|
+
const source = renderMacosLauncherSource(options.config);
|
|
1396
|
+
const sourceDigest = computeSha256Hex(source);
|
|
1397
|
+
const runner = options.runner ?? createDefaultMacosCommandRunner();
|
|
1398
|
+
let tempDir;
|
|
1399
|
+
let cSourcePath;
|
|
1400
|
+
if (options.sourcePath !== undefined) {
|
|
1401
|
+
cSourcePath = options.sourcePath;
|
|
1402
|
+
} else {
|
|
1403
|
+
tempDir = await mkdtemp2(join2(tmpdir(), "stitchkit-launcher-"));
|
|
1404
|
+
cSourcePath = join2(tempDir, "launcher.c");
|
|
1405
|
+
}
|
|
1406
|
+
try {
|
|
1407
|
+
await writeFile2(cSourcePath, source, { encoding: "utf8", mode: 384 });
|
|
1408
|
+
const args = [
|
|
1409
|
+
"-std=c11",
|
|
1410
|
+
"-O2",
|
|
1411
|
+
"-Wall",
|
|
1412
|
+
"-Wextra",
|
|
1413
|
+
"-Werror",
|
|
1414
|
+
"-fstack-protector-strong",
|
|
1415
|
+
...options.arch !== undefined ? ["-arch", options.arch] : [],
|
|
1416
|
+
"-o",
|
|
1417
|
+
options.outputPath,
|
|
1418
|
+
cSourcePath
|
|
1419
|
+
];
|
|
1420
|
+
const result = await runner.runCommand(CLANG_PATH, args, {
|
|
1421
|
+
...options.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : {}
|
|
1422
|
+
});
|
|
1423
|
+
if (result.exitCode !== 0) {
|
|
1424
|
+
throw new MacosLauncherError("COMPILE_FAILED", `clang failed to compile macOS launcher (exit ${result.exitCode}): ${result.stderr.trim()}`);
|
|
1425
|
+
}
|
|
1426
|
+
await chmod(options.outputPath, 493).catch(() => {
|
|
1427
|
+
return;
|
|
1428
|
+
});
|
|
1429
|
+
return { outputPath: options.outputPath, sourceDigest };
|
|
1430
|
+
} finally {
|
|
1431
|
+
if (tempDir !== undefined) {
|
|
1432
|
+
await rm2(tempDir, { recursive: true, force: true }).catch(() => {
|
|
1433
|
+
return;
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
// src/service-host/macos/bundle.ts
|
|
1440
|
+
class MacosBundleInstallError extends Error {
|
|
1441
|
+
code;
|
|
1442
|
+
rolledBack;
|
|
1443
|
+
rollbackError;
|
|
1444
|
+
preservedPreviousBundlePath;
|
|
1445
|
+
constructor(code, message, options) {
|
|
1446
|
+
super(message, options);
|
|
1447
|
+
this.name = "MacosBundleInstallError";
|
|
1448
|
+
this.code = code;
|
|
1449
|
+
this.rolledBack = options?.rolledBack ?? false;
|
|
1450
|
+
this.rollbackError = options?.rollbackError;
|
|
1451
|
+
this.preservedPreviousBundlePath = options?.preservedPreviousBundlePath;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
async function swapDirectoriesDarwin(fromDirPath, toDirPath) {
|
|
1455
|
+
const renameSwapAt = requireDarwinServiceHostMethod(loadDarwinBinding(), "renameSwapAt");
|
|
1456
|
+
const flags = fsConstants.O_RDONLY | fsConstants.O_DIRECTORY;
|
|
1457
|
+
const fromParent = await open(dirname2(fromDirPath), flags);
|
|
1458
|
+
try {
|
|
1459
|
+
const toParent = await open(dirname2(toDirPath), flags);
|
|
1460
|
+
try {
|
|
1461
|
+
renameSwapAt(fromParent.fd, basename(fromDirPath), toParent.fd, basename(toDirPath));
|
|
1462
|
+
} finally {
|
|
1463
|
+
await toParent.close();
|
|
1464
|
+
}
|
|
1465
|
+
} finally {
|
|
1466
|
+
await fromParent.close();
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
function createDefaultMacosBundleHostAdapter(overrides) {
|
|
1470
|
+
const runner = overrides?.runner ?? createDefaultMacosCommandRunner();
|
|
1471
|
+
const launchdAdapter = createDefaultLaunchdHostAdapter2();
|
|
1472
|
+
return {
|
|
1473
|
+
runner,
|
|
1474
|
+
swapDirectories: overrides?.swapDirectories ?? swapDirectoriesDarwin,
|
|
1475
|
+
readPlist: overrides?.readPlist ?? ((plistPath) => readLaunchdPlist2({ path: plistPath, adapter: launchdAdapter })),
|
|
1476
|
+
lintPlist: overrides?.lintPlist ?? ((plistPath) => lintLaunchdPlist2({ path: plistPath, adapter: launchdAdapter })),
|
|
1477
|
+
registerBundle: overrides?.registerBundle ?? ((appPath) => registerBundle({ bundlePath: appPath, runner })),
|
|
1478
|
+
forgetRegistration: overrides?.forgetRegistration ?? (async (appPath) => {
|
|
1479
|
+
await forgetRegistration({ bundlePath: appPath, runner });
|
|
1480
|
+
}),
|
|
1481
|
+
rasterizeSvg: overrides?.rasterizeSvg
|
|
1482
|
+
};
|
|
1483
|
+
}
|
|
1484
|
+
function failInvalidPath(message) {
|
|
1485
|
+
throw new MacosBundleInstallError("INVALID_PATH", message);
|
|
1486
|
+
}
|
|
1487
|
+
function normalizeBundleTargetPath(bundlePath) {
|
|
1488
|
+
if (!bundlePath.startsWith("/") || /[\0\r\n]/.test(bundlePath) || bundlePath.split("/").includes("..")) {
|
|
1489
|
+
failInvalidPath(`bundlePath must be a clean absolute path ending with ".app": ${JSON.stringify(bundlePath)}`);
|
|
1490
|
+
}
|
|
1491
|
+
const normalized = posix3.normalize(bundlePath).replace(/\/+$/, "");
|
|
1492
|
+
const lowered = normalized.toLowerCase();
|
|
1493
|
+
if (!lowered.endsWith(".app") || lowered === "/.app" || isProtectedMacosSystemPath(normalized, { applications: "install-target" })) {
|
|
1494
|
+
failInvalidPath(`Refusing to install bundle at forbidden or invalid path: ${bundlePath}`);
|
|
1495
|
+
}
|
|
1496
|
+
return normalized;
|
|
1497
|
+
}
|
|
1498
|
+
function assertValidEntitlementsPath(entitlementsPath) {
|
|
1499
|
+
if (!entitlementsPath.startsWith("/") || /[\0\r\n]/.test(entitlementsPath) || entitlementsPath.split("/").includes("..")) {
|
|
1500
|
+
failInvalidPath(`entitlementsPath must be a clean absolute path: ${JSON.stringify(entitlementsPath)}`);
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
async function inspectExistingBundle(bundlePath) {
|
|
1504
|
+
try {
|
|
1505
|
+
const stats = await lstat2(bundlePath);
|
|
1506
|
+
if (stats.isSymbolicLink())
|
|
1507
|
+
failInvalidPath(`Refusing to replace symlink: ${bundlePath}`);
|
|
1508
|
+
if (!stats.isDirectory())
|
|
1509
|
+
failInvalidPath(`Existing bundlePath is not a dir: ${bundlePath}`);
|
|
1510
|
+
return true;
|
|
1511
|
+
} catch (cause) {
|
|
1512
|
+
if (errnoOf(cause) === "ENOENT")
|
|
1513
|
+
return false;
|
|
1514
|
+
throw cause;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
function verifyBundleForOptions(bundlePath, options, runner) {
|
|
1518
|
+
return verifySignedBundle({
|
|
1519
|
+
bundlePath,
|
|
1520
|
+
expectedBundleId: options.bundleIdentifier,
|
|
1521
|
+
expectedTeamId: options.expectedTeamId,
|
|
1522
|
+
requireHardenedRuntime: options.requireHardenedRuntime ?? true,
|
|
1523
|
+
runner
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
async function tryCurrentBundle(options, specDigest, adapter) {
|
|
1527
|
+
try {
|
|
1528
|
+
const plist = await adapter.readPlist(join3(options.bundlePath, "Contents", "Info.plist"));
|
|
1529
|
+
if (plist === null || plist[BUNDLE_SPEC_DIGEST_PLIST_KEY] !== specDigest)
|
|
1530
|
+
return null;
|
|
1531
|
+
return await verifyBundleForOptions(options.bundlePath, options, adapter.runner);
|
|
1532
|
+
} catch {
|
|
1533
|
+
return null;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
async function buildAndSignStagedBundle(options, stagedApp, specDigest, resolvedIdentity, adapter) {
|
|
1537
|
+
const contentsDir = join3(stagedApp, "Contents");
|
|
1538
|
+
const macosDir = join3(contentsDir, "MacOS");
|
|
1539
|
+
const resourcesDir = join3(contentsDir, "Resources");
|
|
1540
|
+
await mkdir2(macosDir, { recursive: true });
|
|
1541
|
+
await mkdir2(resourcesDir, { recursive: true });
|
|
1542
|
+
await compileMacosLauncher({
|
|
1543
|
+
config: options.launcher,
|
|
1544
|
+
outputPath: join3(macosDir, options.executableName),
|
|
1545
|
+
arch: options.arch,
|
|
1546
|
+
runner: adapter.runner
|
|
1547
|
+
});
|
|
1548
|
+
let iconFile;
|
|
1549
|
+
if (options.icon !== undefined) {
|
|
1550
|
+
await generateAppIconIcns({
|
|
1551
|
+
source: options.icon,
|
|
1552
|
+
outputPath: join3(resourcesDir, "AppIcon.icns"),
|
|
1553
|
+
runner: adapter.runner,
|
|
1554
|
+
rasterizeSvg: adapter.rasterizeSvg
|
|
1555
|
+
});
|
|
1556
|
+
iconFile = "AppIcon";
|
|
1557
|
+
}
|
|
1558
|
+
const { bundleIdentifier, bundleName, displayName, executableName, bundleVersion } = options;
|
|
1559
|
+
const infoPlist = renderBundleInfoPlist({
|
|
1560
|
+
bundleIdentifier,
|
|
1561
|
+
bundleName,
|
|
1562
|
+
displayName,
|
|
1563
|
+
executableName,
|
|
1564
|
+
bundleVersion,
|
|
1565
|
+
shortVersionString: options.shortVersionString,
|
|
1566
|
+
iconFile,
|
|
1567
|
+
lsBackgroundOnly: options.lsBackgroundOnly,
|
|
1568
|
+
lsUIElement: options.lsUIElement,
|
|
1569
|
+
lsMinimumSystemVersion: options.lsMinimumSystemVersion,
|
|
1570
|
+
specDigest,
|
|
1571
|
+
extraEntries: options.extraInfoPlistEntries
|
|
1572
|
+
});
|
|
1573
|
+
const infoPlistPath = join3(contentsDir, "Info.plist");
|
|
1574
|
+
await writeFile3(infoPlistPath, infoPlist, { encoding: "utf8", mode: 420 });
|
|
1575
|
+
await adapter.lintPlist(infoPlistPath);
|
|
1576
|
+
const identity = resolvedIdentity ?? await resolveSigningIdentity({
|
|
1577
|
+
identity: options.signingIdentity,
|
|
1578
|
+
runner: adapter.runner
|
|
1579
|
+
});
|
|
1580
|
+
await signBundle({
|
|
1581
|
+
bundlePath: stagedApp,
|
|
1582
|
+
identity,
|
|
1583
|
+
hardenedRuntime: options.requireHardenedRuntime ?? true,
|
|
1584
|
+
entitlementsPath: options.entitlementsPath,
|
|
1585
|
+
runner: adapter.runner
|
|
1586
|
+
});
|
|
1587
|
+
return verifyBundleForOptions(stagedApp, options, adapter.runner);
|
|
1588
|
+
}
|
|
1589
|
+
async function ensureSignedBundle(rawOptions) {
|
|
1590
|
+
const bundlePath = normalizeBundleTargetPath(rawOptions.bundlePath);
|
|
1591
|
+
const options = bundlePath === rawOptions.bundlePath ? rawOptions : { ...rawOptions, bundlePath };
|
|
1592
|
+
const hadExisting = await inspectExistingBundle(options.bundlePath);
|
|
1593
|
+
const adapter = createDefaultMacosBundleHostAdapter(options.adapter);
|
|
1594
|
+
const resolvedExplicitIdentity = options.signingIdentity !== undefined ? await resolveSigningIdentity({
|
|
1595
|
+
identity: options.signingIdentity,
|
|
1596
|
+
runner: adapter.runner
|
|
1597
|
+
}) : undefined;
|
|
1598
|
+
let entitlementsSha256 = null;
|
|
1599
|
+
if (options.entitlementsPath !== undefined) {
|
|
1600
|
+
assertValidEntitlementsPath(options.entitlementsPath);
|
|
1601
|
+
try {
|
|
1602
|
+
entitlementsSha256 = computeSha256Hex(await readRegularFile2(options.entitlementsPath));
|
|
1603
|
+
} catch (cause) {
|
|
1604
|
+
throw new MacosBundleInstallError("STAGING_FAILED", `Unable to read entitlementsPath ${options.entitlementsPath}: ${messageOf(cause)}`, { cause });
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
const specDigest = computeBundleSpecDigest({
|
|
1608
|
+
...options,
|
|
1609
|
+
entitlementsSha256,
|
|
1610
|
+
signingIdentity: resolvedExplicitIdentity ?? options.signingIdentity
|
|
1611
|
+
}, renderMacosLauncherSource(options.launcher));
|
|
1612
|
+
if (!options.force && hadExisting) {
|
|
1613
|
+
const currentSignature = await tryCurrentBundle(options, specDigest, adapter);
|
|
1614
|
+
if (currentSignature !== null) {
|
|
1615
|
+
return {
|
|
1616
|
+
state: "current",
|
|
1617
|
+
bundlePath: options.bundlePath,
|
|
1618
|
+
specDigest,
|
|
1619
|
+
signature: currentSignature
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
const parentDir = dirname2(options.bundlePath);
|
|
1624
|
+
const appName = basename(options.bundlePath);
|
|
1625
|
+
await mkdir2(parentDir, { recursive: true });
|
|
1626
|
+
const stagingDir = join3(parentDir, `.${appName}-${randomBytes(6).toString("hex")}.install.noindex`);
|
|
1627
|
+
const stagedApp = join3(stagingDir, appName);
|
|
1628
|
+
const shouldRegister = options.registerWithLaunchServices ?? true;
|
|
1629
|
+
let phase = "staged";
|
|
1630
|
+
let preserveStagingDir = false;
|
|
1631
|
+
try {
|
|
1632
|
+
await mkdir2(stagingDir, { recursive: true, mode: 448 });
|
|
1633
|
+
const stagedSignature = await buildAndSignStagedBundle(options, stagedApp, specDigest, resolvedExplicitIdentity, adapter);
|
|
1634
|
+
try {
|
|
1635
|
+
if (hadExisting)
|
|
1636
|
+
await adapter.swapDirectories(stagedApp, options.bundlePath);
|
|
1637
|
+
else
|
|
1638
|
+
await rename(stagedApp, options.bundlePath);
|
|
1639
|
+
} catch (swapCause) {
|
|
1640
|
+
throw new MacosBundleInstallError("SWAP_FAILED", `Failed to install staged bundle into ${options.bundlePath}: ${messageOf(swapCause)}`, { cause: swapCause });
|
|
1641
|
+
}
|
|
1642
|
+
phase = "swapped";
|
|
1643
|
+
const liveSignature = await verifyBundleForOptions(options.bundlePath, options, adapter.runner);
|
|
1644
|
+
if (liveSignature.cdHash !== stagedSignature.cdHash) {
|
|
1645
|
+
throw new MacosBundleInstallError("VERIFICATION_FAILED", `Post-swap CDHash mismatch for ${options.bundlePath}: expected ${stagedSignature.cdHash}, observed ${liveSignature.cdHash}`);
|
|
1646
|
+
}
|
|
1647
|
+
if (options.afterSwapVerify !== undefined)
|
|
1648
|
+
await options.afterSwapVerify(liveSignature);
|
|
1649
|
+
if (shouldRegister)
|
|
1650
|
+
await adapter.registerBundle(options.bundlePath);
|
|
1651
|
+
phase = "installed";
|
|
1652
|
+
return {
|
|
1653
|
+
state: "installed",
|
|
1654
|
+
bundlePath: options.bundlePath,
|
|
1655
|
+
specDigest,
|
|
1656
|
+
signature: liveSignature
|
|
1657
|
+
};
|
|
1658
|
+
} catch (cause) {
|
|
1659
|
+
let rollbackError;
|
|
1660
|
+
if (phase === "swapped") {
|
|
1661
|
+
try {
|
|
1662
|
+
if (hadExisting)
|
|
1663
|
+
await adapter.swapDirectories(stagedApp, options.bundlePath);
|
|
1664
|
+
else
|
|
1665
|
+
await rm3(options.bundlePath, { recursive: true, force: true });
|
|
1666
|
+
phase = "rolled-back";
|
|
1667
|
+
} catch (rbErr) {
|
|
1668
|
+
phase = "rollback-failed";
|
|
1669
|
+
preserveStagingDir = true;
|
|
1670
|
+
rollbackError = rbErr;
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
if (phase === "rollback-failed") {
|
|
1674
|
+
throw new MacosBundleInstallError("ROLLBACK_FAILED", `${messageOf(cause)}; rollback also failed: ${messageOf(rollbackError)}`, {
|
|
1675
|
+
cause,
|
|
1676
|
+
rolledBack: false,
|
|
1677
|
+
rollbackError,
|
|
1678
|
+
preservedPreviousBundlePath: hadExisting ? stagedApp : undefined
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1681
|
+
const code = cause instanceof MacosBundleInstallError ? cause.code : phase === "rolled-back" ? "VERIFICATION_FAILED" : "STAGING_FAILED";
|
|
1682
|
+
throw new MacosBundleInstallError(code, messageOf(cause), {
|
|
1683
|
+
cause,
|
|
1684
|
+
rolledBack: phase === "rolled-back"
|
|
1685
|
+
});
|
|
1686
|
+
} finally {
|
|
1687
|
+
if (!preserveStagingDir) {
|
|
1688
|
+
if (phase === "installed" && shouldRegister) {
|
|
1689
|
+
await adapter.forgetRegistration(stagedApp).catch(() => {
|
|
1690
|
+
return;
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1693
|
+
await rm3(stagingDir, { recursive: true, force: true }).catch(() => {
|
|
1694
|
+
return;
|
|
1695
|
+
});
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
// src/service-host/macos/responsibility.ts
|
|
1700
|
+
import { posix as posix4 } from "node:path";
|
|
1701
|
+
import { z as z4 } from "zod";
|
|
1702
|
+
var MAX_PID = 2 ** 31 - 1;
|
|
1703
|
+
var DEFAULT_MAX_SUBTREE_PROCESSES = 1024;
|
|
1704
|
+
var PS_LINE_PATTERN = /^\s*(\d+)\s+(\d+)\s*$/;
|
|
1705
|
+
function parsePsPidPpidTable(stdout) {
|
|
1706
|
+
const entries = [];
|
|
1707
|
+
for (const rawLine of stdout.split(`
|
|
1708
|
+
`)) {
|
|
1709
|
+
const match = PS_LINE_PATTERN.exec(rawLine);
|
|
1710
|
+
if (!match)
|
|
1711
|
+
continue;
|
|
1712
|
+
const pid = Number(match[1]);
|
|
1713
|
+
const ppid = Number(match[2]);
|
|
1714
|
+
if (Number.isSafeInteger(pid) && pid > 0 && pid <= MAX_PID && Number.isSafeInteger(ppid) && ppid >= 0 && ppid <= MAX_PID) {
|
|
1715
|
+
entries.push({ pid, ppid });
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
return entries;
|
|
1719
|
+
}
|
|
1720
|
+
function collectProcessSubtreePids(rootPid, entries, options) {
|
|
1721
|
+
z4.number().int().positive().max(MAX_PID).parse(rootPid);
|
|
1722
|
+
const maxProcesses = options?.maxProcesses ?? DEFAULT_MAX_SUBTREE_PROCESSES;
|
|
1723
|
+
if (!Number.isSafeInteger(maxProcesses) || maxProcesses <= 0) {
|
|
1724
|
+
throw new RangeError(`Invalid maxProcesses: ${maxProcesses}`);
|
|
1725
|
+
}
|
|
1726
|
+
const childrenByParent = new Map;
|
|
1727
|
+
for (const entry of entries) {
|
|
1728
|
+
const children = childrenByParent.get(entry.ppid);
|
|
1729
|
+
if (children === undefined) {
|
|
1730
|
+
childrenByParent.set(entry.ppid, [entry.pid]);
|
|
1731
|
+
} else {
|
|
1732
|
+
children.push(entry.pid);
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
const visited = new Set([rootPid]);
|
|
1736
|
+
const ordered = [rootPid];
|
|
1737
|
+
let cursor = 0;
|
|
1738
|
+
while (cursor < ordered.length) {
|
|
1739
|
+
const current = ordered[cursor];
|
|
1740
|
+
cursor += 1;
|
|
1741
|
+
if (current === undefined)
|
|
1742
|
+
break;
|
|
1743
|
+
const children = childrenByParent.get(current);
|
|
1744
|
+
if (children === undefined)
|
|
1745
|
+
continue;
|
|
1746
|
+
for (const childPid of children) {
|
|
1747
|
+
if (visited.has(childPid))
|
|
1748
|
+
continue;
|
|
1749
|
+
visited.add(childPid);
|
|
1750
|
+
ordered.push(childPid);
|
|
1751
|
+
if (ordered.length > maxProcesses) {
|
|
1752
|
+
throw new RangeError(`Process subtree rooted at ${rootPid} exceeded maxProcesses (${maxProcesses})`);
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
return ordered;
|
|
1757
|
+
}
|
|
1758
|
+
function isExecutableInsideBundle(canonicalExecutablePath, canonicalBundlePath) {
|
|
1759
|
+
if (canonicalExecutablePath.includes("\x00") || canonicalBundlePath.includes("\x00") || canonicalExecutablePath.split("/").includes("..") || canonicalBundlePath.split("/").includes("..")) {
|
|
1760
|
+
return false;
|
|
1761
|
+
}
|
|
1762
|
+
const cleanExe = posix4.normalize(canonicalExecutablePath).replace(/\/+$/, "");
|
|
1763
|
+
const cleanBundle = posix4.normalize(canonicalBundlePath).replace(/\/+$/, "");
|
|
1764
|
+
if (cleanBundle.length === 0 || !cleanExe.startsWith("/") || !cleanBundle.startsWith("/")) {
|
|
1765
|
+
return false;
|
|
1766
|
+
}
|
|
1767
|
+
return macosPathKey(cleanExe).startsWith(`${macosPathKey(cleanBundle)}/contents/`);
|
|
1768
|
+
}
|
|
1769
|
+
function createDefaultMacosResponsibilityAdapter(runner = createDefaultMacosCommandRunner()) {
|
|
1770
|
+
return {
|
|
1771
|
+
async responsiblePid(pid) {
|
|
1772
|
+
const fn = requireDarwinServiceHostMethod(loadDarwinBinding(), "responsiblePid");
|
|
1773
|
+
return fn(pid);
|
|
1774
|
+
},
|
|
1775
|
+
async processPath(pid) {
|
|
1776
|
+
const fn = requireDarwinServiceHostMethod(loadDarwinBinding(), "processPath");
|
|
1777
|
+
return fn(pid);
|
|
1778
|
+
},
|
|
1779
|
+
observeProcessInstance: observeProcessInstance2,
|
|
1780
|
+
canonicalizePath: (targetPath) => canonicalizeMacosPath(targetPath),
|
|
1781
|
+
async listProcesses() {
|
|
1782
|
+
const result = await runner.runCommand(PS_PATH, ["-axo", "pid=,ppid="]);
|
|
1783
|
+
if (result.exitCode !== 0) {
|
|
1784
|
+
throw new Error(`ps failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
|
|
1785
|
+
}
|
|
1786
|
+
return parsePsPidPpidTable(result.stdout);
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1790
|
+
function unavailableInspection(pid, expectedBundlePath, reason, extra) {
|
|
1791
|
+
return {
|
|
1792
|
+
status: "unavailable",
|
|
1793
|
+
pid,
|
|
1794
|
+
responsiblePid: extra?.responsiblePid ?? null,
|
|
1795
|
+
responsiblePath: extra?.responsiblePath ?? null,
|
|
1796
|
+
expectedBundlePath,
|
|
1797
|
+
reason,
|
|
1798
|
+
...extra?.cause !== undefined ? { cause: extra.cause } : {}
|
|
1799
|
+
};
|
|
1800
|
+
}
|
|
1801
|
+
async function goneAfterSilentFailure(adapter, pid, cause) {
|
|
1802
|
+
if (errnoOf(cause) !== undefined)
|
|
1803
|
+
return false;
|
|
1804
|
+
const observation = await adapter.observeProcessInstance(pid);
|
|
1805
|
+
return observation.state === "unavailable" && isProcessGoneError(observation.cause);
|
|
1806
|
+
}
|
|
1807
|
+
async function inspectResponsibleProcess(options) {
|
|
1808
|
+
const pid = z4.number().int().positive().max(MAX_PID).parse(options.pid);
|
|
1809
|
+
const adapter = options.adapter ?? createDefaultMacosResponsibilityAdapter();
|
|
1810
|
+
const expectedRaw = options.expectedBundlePath ?? null;
|
|
1811
|
+
const before = await adapter.observeProcessInstance(pid);
|
|
1812
|
+
if (before.state === "unavailable") {
|
|
1813
|
+
const reason = isProcessGoneError(before.cause) ? "process-gone" : "process-unobservable";
|
|
1814
|
+
return unavailableInspection(pid, expectedRaw, reason, { cause: before.cause });
|
|
1815
|
+
}
|
|
1816
|
+
let respPid;
|
|
1817
|
+
try {
|
|
1818
|
+
respPid = await adapter.responsiblePid(pid);
|
|
1819
|
+
} catch (cause) {
|
|
1820
|
+
const code = errnoOf(cause);
|
|
1821
|
+
const reason = code === "ESRCH" || await goneAfterSilentFailure(adapter, pid, cause) ? "process-gone" : code === "EOPNOTSUPP" ? "responsibility-unsupported" : "responsibility-lookup-failed";
|
|
1822
|
+
return unavailableInspection(pid, expectedRaw, reason, { cause });
|
|
1823
|
+
}
|
|
1824
|
+
let respPath;
|
|
1825
|
+
try {
|
|
1826
|
+
respPath = await adapter.processPath(respPid);
|
|
1827
|
+
} catch (cause) {
|
|
1828
|
+
const reason = isProcessGoneError(cause) || await goneAfterSilentFailure(adapter, respPid, cause) ? "responsible-process-gone" : "process-path-failed";
|
|
1829
|
+
return unavailableInspection(pid, expectedRaw, reason, { responsiblePid: respPid, cause });
|
|
1830
|
+
}
|
|
1831
|
+
const after = await adapter.observeProcessInstance(pid);
|
|
1832
|
+
if (after.state === "unavailable") {
|
|
1833
|
+
const reason = isProcessGoneError(after.cause) ? "process-gone" : "process-unobservable";
|
|
1834
|
+
return unavailableInspection(pid, expectedRaw, reason, {
|
|
1835
|
+
responsiblePid: respPid,
|
|
1836
|
+
responsiblePath: respPath,
|
|
1837
|
+
cause: after.cause
|
|
1838
|
+
});
|
|
1839
|
+
}
|
|
1840
|
+
if (!sameProcessInstance(before.instance, after.instance)) {
|
|
1841
|
+
return unavailableInspection(pid, expectedRaw, "pid-reused", {
|
|
1842
|
+
responsiblePid: respPid,
|
|
1843
|
+
responsiblePath: respPath
|
|
1844
|
+
});
|
|
1845
|
+
}
|
|
1846
|
+
const canonicalRespPath = await adapter.canonicalizePath(respPath);
|
|
1847
|
+
if (expectedRaw === null) {
|
|
1848
|
+
return {
|
|
1849
|
+
status: "observed",
|
|
1850
|
+
pid,
|
|
1851
|
+
responsiblePid: respPid,
|
|
1852
|
+
responsiblePath: canonicalRespPath,
|
|
1853
|
+
expectedBundlePath: null
|
|
1854
|
+
};
|
|
1855
|
+
}
|
|
1856
|
+
const canonicalExpectedBundle = await adapter.canonicalizePath(expectedRaw);
|
|
1857
|
+
if (isExecutableInsideBundle(canonicalRespPath, canonicalExpectedBundle)) {
|
|
1858
|
+
return {
|
|
1859
|
+
status: "attributed",
|
|
1860
|
+
pid,
|
|
1861
|
+
responsiblePid: respPid,
|
|
1862
|
+
responsiblePath: canonicalRespPath,
|
|
1863
|
+
expectedBundlePath: canonicalExpectedBundle
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
return {
|
|
1867
|
+
status: "misattributed",
|
|
1868
|
+
pid,
|
|
1869
|
+
responsiblePid: respPid,
|
|
1870
|
+
responsiblePath: canonicalRespPath,
|
|
1871
|
+
expectedBundlePath: canonicalExpectedBundle,
|
|
1872
|
+
reason: "bundle-mismatch"
|
|
1873
|
+
};
|
|
1874
|
+
}
|
|
1875
|
+
async function verifyProcessSubtreeResponsibility(options) {
|
|
1876
|
+
const rootPid = z4.number().int().positive().max(MAX_PID).parse(options.rootPid);
|
|
1877
|
+
const adapter = options.adapter ?? createDefaultMacosResponsibilityAdapter();
|
|
1878
|
+
const canonicalExpectedBundle = await adapter.canonicalizePath(options.expectedBundlePath);
|
|
1879
|
+
let entries;
|
|
1880
|
+
try {
|
|
1881
|
+
entries = await adapter.listProcesses();
|
|
1882
|
+
} catch (cause) {
|
|
1883
|
+
return {
|
|
1884
|
+
status: "unavailable",
|
|
1885
|
+
rootPid,
|
|
1886
|
+
expectedBundlePath: canonicalExpectedBundle,
|
|
1887
|
+
checked: [],
|
|
1888
|
+
misattributed: [],
|
|
1889
|
+
unavailable: [
|
|
1890
|
+
{
|
|
1891
|
+
status: "unavailable",
|
|
1892
|
+
pid: rootPid,
|
|
1893
|
+
responsiblePid: null,
|
|
1894
|
+
responsiblePath: null,
|
|
1895
|
+
expectedBundlePath: canonicalExpectedBundle,
|
|
1896
|
+
reason: "process-table-failed",
|
|
1897
|
+
cause
|
|
1898
|
+
}
|
|
1899
|
+
],
|
|
1900
|
+
gonePids: []
|
|
1901
|
+
};
|
|
1902
|
+
}
|
|
1903
|
+
const pids = collectProcessSubtreePids(rootPid, entries, {
|
|
1904
|
+
maxProcesses: options.maxProcesses
|
|
1905
|
+
});
|
|
1906
|
+
const checked = [];
|
|
1907
|
+
const misattributed = [];
|
|
1908
|
+
const unavailable = [];
|
|
1909
|
+
const gonePids = [];
|
|
1910
|
+
for (const pid of pids) {
|
|
1911
|
+
const inspection = await inspectResponsibleProcess({
|
|
1912
|
+
pid,
|
|
1913
|
+
expectedBundlePath: canonicalExpectedBundle,
|
|
1914
|
+
adapter
|
|
1915
|
+
});
|
|
1916
|
+
if (inspection.status === "unavailable" && pid !== rootPid && inspection.reason === "process-gone") {
|
|
1917
|
+
gonePids.push(pid);
|
|
1918
|
+
continue;
|
|
1919
|
+
}
|
|
1920
|
+
checked.push(inspection);
|
|
1921
|
+
if (inspection.status === "misattributed")
|
|
1922
|
+
misattributed.push(inspection);
|
|
1923
|
+
else if (inspection.status === "unavailable")
|
|
1924
|
+
unavailable.push(inspection);
|
|
1925
|
+
}
|
|
1926
|
+
const status = misattributed.length > 0 ? "misattributed" : unavailable.length > 0 ? "unavailable" : "attributed";
|
|
1927
|
+
return {
|
|
1928
|
+
status,
|
|
1929
|
+
rootPid,
|
|
1930
|
+
expectedBundlePath: canonicalExpectedBundle,
|
|
1931
|
+
checked,
|
|
1932
|
+
misattributed,
|
|
1933
|
+
unavailable,
|
|
1934
|
+
gonePids
|
|
1935
|
+
};
|
|
1936
|
+
}
|
|
1937
|
+
export {
|
|
1938
|
+
APPLE_ICONSET_SLOTS,
|
|
1939
|
+
APPLE_ICON_CANVAS_PX,
|
|
1940
|
+
APPLE_ICON_CORNER_RADIUS_PX,
|
|
1941
|
+
APPLE_ICON_INSET_PX,
|
|
1942
|
+
APPLE_ICON_TILE_PX,
|
|
1943
|
+
BUNDLE_SPEC_DIGEST_PLIST_KEY,
|
|
1944
|
+
CLANG_PATH,
|
|
1945
|
+
CODESIGN_PATH,
|
|
1946
|
+
DEFAULT_LSREGISTER_DUMP_MAX_BYTES,
|
|
1947
|
+
DEFAULT_MAX_UNREGISTRATIONS,
|
|
1948
|
+
ICONUTIL_PATH,
|
|
1949
|
+
KLS_APPLICATION_NOT_FOUND_ERR,
|
|
1950
|
+
LAUNCHER_EXIT_NOT_LAUNCHD,
|
|
1951
|
+
LSREGISTER_PATH,
|
|
1952
|
+
MacosBundleInfoPlistConfigSchema,
|
|
1953
|
+
MacosBundleInstallError,
|
|
1954
|
+
MacosCodesignError,
|
|
1955
|
+
MacosIconError,
|
|
1956
|
+
MacosIconSourceSchema,
|
|
1957
|
+
MacosLaunchServicesError,
|
|
1958
|
+
MacosLauncherConfigSchema,
|
|
1959
|
+
MacosLauncherError,
|
|
1960
|
+
PS_PATH,
|
|
1961
|
+
QLMANAGE_PATH,
|
|
1962
|
+
SECURITY_PATH,
|
|
1963
|
+
SIPS_PATH,
|
|
1964
|
+
assertSafeSvg,
|
|
1965
|
+
assertValidIcnsBytes,
|
|
1966
|
+
canonicalizeMacosPath,
|
|
1967
|
+
collectProcessSubtreePids,
|
|
1968
|
+
compileMacosLauncher,
|
|
1969
|
+
computeBundleSpecDigest,
|
|
1970
|
+
createDefaultMacosBundleHostAdapter,
|
|
1971
|
+
createDefaultMacosCommandRunner,
|
|
1972
|
+
createDefaultMacosResponsibilityAdapter,
|
|
1973
|
+
createLsregisterDumpParser,
|
|
1974
|
+
ensureSignedBundle,
|
|
1975
|
+
findDeveloperIds,
|
|
1976
|
+
forgetBuildTree,
|
|
1977
|
+
forgetRegistration,
|
|
1978
|
+
forgetStaleRegistrations,
|
|
1979
|
+
generateAppIconIcns,
|
|
1980
|
+
inspectResponsibleProcess,
|
|
1981
|
+
isExecutableInsideBundle,
|
|
1982
|
+
isPathWithinDirectory,
|
|
1983
|
+
normalizeMacosSyntheticPath,
|
|
1984
|
+
parseCodesignDetails,
|
|
1985
|
+
parseDeveloperIdsOutput,
|
|
1986
|
+
parseLsregisterDump,
|
|
1987
|
+
parsePsPidPpidTable,
|
|
1988
|
+
registerBundle,
|
|
1989
|
+
renderAppleSquircleSvg,
|
|
1990
|
+
renderBundleInfoPlist,
|
|
1991
|
+
renderMacosLauncherSource,
|
|
1992
|
+
resolveSigningIdentity,
|
|
1993
|
+
scanLsregisterDump,
|
|
1994
|
+
signBundle,
|
|
1995
|
+
swapDirectoriesDarwin,
|
|
1996
|
+
verifyProcessSubtreeResponsibility,
|
|
1997
|
+
verifySignedBundle
|
|
1998
|
+
};
|