stitchkit 0.133.2 → 0.134.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 +115 -0
- package/README.md +14 -11
- package/dist/agent-executor/acp/v1-connect.d.ts +3 -0
- package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-map.d.ts +13 -3
- package/dist/agent-executor/acp/v1-map.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-protocol.d.ts +59 -0
- package/dist/agent-executor/acp/v1-protocol.d.ts.map +1 -1
- package/dist/agent-executor/codex/connect.d.ts +2 -0
- package/dist/agent-executor/codex/connect.d.ts.map +1 -1
- package/dist/agent-executor/codex/driver.d.ts +3 -0
- package/dist/agent-executor/codex/driver.d.ts.map +1 -1
- package/dist/agent-executor/contract.d.ts +42 -0
- package/dist/agent-executor/contract.d.ts.map +1 -1
- package/dist/agent-executor/engine-process.d.ts +20 -0
- package/dist/agent-executor/engine-process.d.ts.map +1 -1
- package/dist/agent-executor/executor-contract.d.ts +42 -0
- package/dist/agent-executor/executor-contract.d.ts.map +1 -1
- package/dist/agent-executor/handoff-schemas.d.ts +30 -0
- package/dist/agent-executor/handoff-schemas.d.ts.map +1 -1
- package/dist/agent-executor/projection.d.ts.map +1 -1
- package/dist/agent-executor/session-primitives.d.ts +4 -1
- package/dist/agent-executor/session-primitives.d.ts.map +1 -1
- package/dist/agent-executor/vocabulary.d.ts +100 -0
- package/dist/agent-executor/vocabulary.d.ts.map +1 -1
- package/dist/agent-parts/model.d.ts +1559 -0
- package/dist/agent-parts/model.d.ts.map +1 -0
- package/dist/agent-parts/parts.d.ts +21 -0
- package/dist/agent-parts/parts.d.ts.map +1 -1
- package/dist/agent-runtime/ai-sdk-convert.d.ts +15 -0
- package/dist/agent-runtime/ai-sdk-convert.d.ts.map +1 -0
- package/dist/agent-runtime/ai-sdk.d.ts +31 -0
- package/dist/agent-runtime/ai-sdk.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic-media.d.ts +11 -0
- package/dist/agent-runtime/anthropic-media.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic-messages.d.ts +24 -0
- package/dist/agent-runtime/anthropic-messages.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic-options.d.ts +79 -0
- package/dist/agent-runtime/anthropic-options.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic-response.d.ts +19 -0
- package/dist/agent-runtime/anthropic-response.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic-sse.d.ts +4 -0
- package/dist/agent-runtime/anthropic-sse.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic.d.ts +27 -0
- package/dist/agent-runtime/anthropic.d.ts.map +1 -0
- package/dist/agent-runtime/branch-observations.d.ts +25 -25
- package/dist/agent-runtime/branch-provider.d.ts +86 -0
- package/dist/agent-runtime/branch-provider.d.ts.map +1 -1
- package/dist/agent-runtime/branch-replay.d.ts +30 -0
- package/dist/agent-runtime/branch-replay.d.ts.map +1 -1
- package/dist/agent-runtime/browser-control-contract.d.ts +204 -0
- package/dist/agent-runtime/browser-control-contract.d.ts.map +1 -1
- package/dist/agent-runtime/browser-controller-view.d.ts +44 -0
- package/dist/agent-runtime/browser-controller-view.d.ts.map +1 -0
- package/dist/agent-runtime/browser-controller.d.ts +12 -8
- package/dist/agent-runtime/browser-controller.d.ts.map +1 -1
- package/dist/agent-runtime/child-budget-policy.d.ts +2 -3
- package/dist/agent-runtime/child-budget-policy.d.ts.map +1 -1
- package/dist/agent-runtime/compaction.d.ts +27 -10
- package/dist/agent-runtime/compaction.d.ts.map +1 -1
- package/dist/agent-runtime/control-interaction-schema.d.ts +157 -0
- package/dist/agent-runtime/control-interaction-schema.d.ts.map +1 -0
- package/dist/agent-runtime/control-schema.d.ts +183 -27
- package/dist/agent-runtime/control-schema.d.ts.map +1 -1
- package/dist/agent-runtime/control-view.d.ts +64 -0
- package/dist/agent-runtime/control-view.d.ts.map +1 -0
- package/dist/agent-runtime/conversations.d.ts +10 -0
- package/dist/agent-runtime/conversations.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tool-selection.d.ts +2 -2
- package/dist/agent-runtime/deferred-tool-selection.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tool-types.d.ts +2 -2
- package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tools-internal.d.ts +8 -11
- 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-schema.d.ts +80 -0
- package/dist/agent-runtime/event-schema.d.ts.map +1 -1
- package/dist/agent-runtime/harness-contract.d.ts +2 -2
- package/dist/agent-runtime/harness-contract.d.ts.map +1 -1
- package/dist/agent-runtime/harness-control.d.ts.map +1 -1
- package/dist/agent-runtime/harness-realtime.d.ts.map +1 -1
- package/dist/agent-runtime/harness.d.ts +2 -2
- package/dist/agent-runtime/harness.d.ts.map +1 -1
- package/dist/agent-runtime/history.d.ts +25 -16
- package/dist/agent-runtime/history.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-attempt.d.ts +7 -3
- package/dist/agent-runtime/invocation-attempt.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-payload.d.ts +13 -7
- package/dist/agent-runtime/invocation-payload.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-stream.d.ts +20 -0
- package/dist/agent-runtime/invocation-stream.d.ts.map +1 -0
- package/dist/agent-runtime/invocations.d.ts +2 -2
- package/dist/agent-runtime/invocations.d.ts.map +1 -1
- package/dist/agent-runtime/models-driver-step.d.ts +212 -0
- package/dist/agent-runtime/models-driver-step.d.ts.map +1 -0
- package/dist/agent-runtime/models-driver-telemetry.d.ts +42 -0
- package/dist/agent-runtime/models-driver-telemetry.d.ts.map +1 -0
- package/dist/agent-runtime/models-driver.d.ts +235 -0
- package/dist/agent-runtime/models-driver.d.ts.map +1 -0
- package/dist/agent-runtime/models.d.ts +3 -26
- package/dist/agent-runtime/models.d.ts.map +1 -1
- package/dist/agent-runtime/observability.d.ts +64 -0
- package/dist/agent-runtime/observability.d.ts.map +1 -1
- package/dist/agent-runtime/openai-messages.d.ts +11 -0
- package/dist/agent-runtime/openai-messages.d.ts.map +1 -0
- package/dist/agent-runtime/openai-options.d.ts +91 -0
- package/dist/agent-runtime/openai-options.d.ts.map +1 -0
- package/dist/agent-runtime/openai-response.d.ts +77 -0
- package/dist/agent-runtime/openai-response.d.ts.map +1 -0
- package/dist/agent-runtime/openai-sse-state.d.ts +54 -0
- package/dist/agent-runtime/openai-sse-state.d.ts.map +1 -0
- package/dist/agent-runtime/openai-sse.d.ts +4 -0
- package/dist/agent-runtime/openai-sse.d.ts.map +1 -0
- package/dist/agent-runtime/openai.d.ts +31 -0
- package/dist/agent-runtime/openai.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-admission.d.ts +3 -0
- package/dist/agent-runtime/openrouter-admission.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter-benchmarks.d.ts +17 -0
- package/dist/agent-runtime/openrouter-benchmarks.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-catalog-cache.d.ts +70 -0
- package/dist/agent-runtime/openrouter-catalog-cache.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-catalog-query.d.ts +57 -0
- package/dist/agent-runtime/openrouter-catalog-query.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-catalog.d.ts +189 -14
- package/dist/agent-runtime/openrouter-catalog.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter-models.d.ts +168 -31
- package/dist/agent-runtime/openrouter-models.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter-options.d.ts +45 -15
- package/dist/agent-runtime/openrouter-options.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter-response.d.ts +22 -0
- package/dist/agent-runtime/openrouter-response.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter.d.ts +21 -24
- package/dist/agent-runtime/openrouter.d.ts.map +1 -1
- package/dist/agent-runtime/owned-provider-stream.d.ts +4 -4
- package/dist/agent-runtime/owned-provider-stream.d.ts.map +1 -1
- package/dist/agent-runtime/prompt.d.ts +3 -3
- package/dist/agent-runtime/prompt.d.ts.map +1 -1
- package/dist/agent-runtime/protocol.d.ts +28 -3
- package/dist/agent-runtime/protocol.d.ts.map +1 -1
- package/dist/agent-runtime/provider-cache.d.ts +30 -0
- package/dist/agent-runtime/provider-cache.d.ts.map +1 -0
- package/dist/agent-runtime/provider-content.d.ts +147 -0
- package/dist/agent-runtime/provider-content.d.ts.map +1 -1
- package/dist/agent-runtime/provider-failure.d.ts +51 -26
- package/dist/agent-runtime/provider-failure.d.ts.map +1 -1
- package/dist/agent-runtime/provider-history.d.ts +13 -0
- package/dist/agent-runtime/provider-history.d.ts.map +1 -0
- package/dist/agent-runtime/provider-http.d.ts +68 -0
- package/dist/agent-runtime/provider-http.d.ts.map +1 -0
- package/dist/agent-runtime/provider-journal.d.ts +149 -0
- package/dist/agent-runtime/provider-journal.d.ts.map +1 -1
- package/dist/agent-runtime/provider-json-schema-strip.d.ts +8 -0
- package/dist/agent-runtime/provider-json-schema-strip.d.ts.map +1 -0
- package/dist/agent-runtime/provider-json-schema.d.ts +28 -0
- package/dist/agent-runtime/provider-json-schema.d.ts.map +1 -0
- package/dist/agent-runtime/provider-media.d.ts +49 -0
- package/dist/agent-runtime/provider-media.d.ts.map +1 -0
- package/dist/agent-runtime/provider-openai-chat-helpers.d.ts +27 -0
- package/dist/agent-runtime/provider-openai-chat-helpers.d.ts.map +1 -0
- package/dist/agent-runtime/provider-openai-chat-sse.d.ts +25 -0
- package/dist/agent-runtime/provider-openai-chat-sse.d.ts.map +1 -0
- package/dist/agent-runtime/provider-openai-chat.d.ts +27 -0
- package/dist/agent-runtime/provider-openai-chat.d.ts.map +1 -0
- package/dist/agent-runtime/provider-origin.d.ts +3 -12
- package/dist/agent-runtime/provider-origin.d.ts.map +1 -1
- package/dist/agent-runtime/provider-sse.d.ts +30 -0
- package/dist/agent-runtime/provider-sse.d.ts.map +1 -0
- package/dist/agent-runtime/provider-stream-parts.d.ts +5 -0
- package/dist/agent-runtime/provider-stream-parts.d.ts.map +1 -0
- package/dist/agent-runtime/provider-stream-segments.d.ts +63 -0
- package/dist/agent-runtime/provider-stream-segments.d.ts.map +1 -0
- package/dist/agent-runtime/provider-usage.d.ts +24 -0
- package/dist/agent-runtime/provider-usage.d.ts.map +1 -0
- package/dist/agent-runtime/retry-policy.d.ts +19 -3
- package/dist/agent-runtime/retry-policy.d.ts.map +1 -1
- package/dist/agent-runtime/run-acquisition.d.ts +4 -4
- package/dist/agent-runtime/run-acquisition.d.ts.map +1 -1
- package/dist/agent-runtime/run-approval.d.ts +82 -0
- package/dist/agent-runtime/run-approval.d.ts.map +1 -0
- package/dist/agent-runtime/run-complete-retry.d.ts +24 -0
- package/dist/agent-runtime/run-complete-retry.d.ts.map +1 -0
- package/dist/agent-runtime/run-complete-stream.d.ts +9 -0
- package/dist/agent-runtime/run-complete-stream.d.ts.map +1 -0
- package/dist/agent-runtime/run-complete-tools.d.ts +21 -0
- package/dist/agent-runtime/run-complete-tools.d.ts.map +1 -0
- package/dist/agent-runtime/run-complete-types.d.ts +168 -0
- package/dist/agent-runtime/run-complete-types.d.ts.map +1 -0
- package/dist/agent-runtime/run-complete.d.ts +25 -0
- package/dist/agent-runtime/run-complete.d.ts.map +1 -0
- package/dist/agent-runtime/run-driver-compose.d.ts +21 -0
- package/dist/agent-runtime/run-driver-compose.d.ts.map +1 -0
- package/dist/agent-runtime/run-execution-state.d.ts +23 -10
- package/dist/agent-runtime/run-execution-state.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution.d.ts +2 -2
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/run-failure.d.ts +2 -2
- package/dist/agent-runtime/run-failure.d.ts.map +1 -1
- package/dist/agent-runtime/run-history-parts.d.ts +14 -0
- package/dist/agent-runtime/run-history-parts.d.ts.map +1 -0
- package/dist/agent-runtime/run-loop-events.d.ts +126 -0
- package/dist/agent-runtime/run-loop-events.d.ts.map +1 -0
- package/dist/agent-runtime/run-model-attempts.d.ts +2 -2
- package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -1
- package/dist/agent-runtime/run-model-messages.d.ts +9 -0
- package/dist/agent-runtime/run-model-messages.d.ts.map +1 -0
- package/dist/agent-runtime/run-model-step.d.ts +43 -0
- package/dist/agent-runtime/run-model-step.d.ts.map +1 -0
- package/dist/agent-runtime/run-model-stream.d.ts +27 -0
- package/dist/agent-runtime/run-model-stream.d.ts.map +1 -0
- package/dist/agent-runtime/run-operation-lifecycle.d.ts +8 -4
- package/dist/agent-runtime/run-operation-lifecycle.d.ts.map +1 -1
- package/dist/agent-runtime/run-prompt-history.d.ts +8 -13
- package/dist/agent-runtime/run-prompt-history.d.ts.map +1 -1
- package/dist/agent-runtime/run-provider-ledger.d.ts +7 -4
- package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -1
- package/dist/agent-runtime/run-step-barriers.d.ts +58 -16
- package/dist/agent-runtime/run-step-barriers.d.ts.map +1 -1
- package/dist/agent-runtime/run-step-helpers.d.ts +49 -0
- package/dist/agent-runtime/run-step-helpers.d.ts.map +1 -0
- package/dist/agent-runtime/run-step-prepare.d.ts +34 -0
- package/dist/agent-runtime/run-step-prepare.d.ts.map +1 -0
- package/dist/agent-runtime/run-step-spend.d.ts +85 -10
- package/dist/agent-runtime/run-step-spend.d.ts.map +1 -1
- package/dist/agent-runtime/run-stream-parts.d.ts +13 -9
- package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -1
- package/dist/agent-runtime/run-stream-recorded.d.ts +8 -0
- package/dist/agent-runtime/run-stream-recorded.d.ts.map +1 -0
- package/dist/agent-runtime/run-stream-step-text.d.ts +29 -0
- package/dist/agent-runtime/run-stream-step-text.d.ts.map +1 -0
- package/dist/agent-runtime/run-terminal.d.ts +3 -3
- package/dist/agent-runtime/run-terminal.d.ts.map +1 -1
- package/dist/agent-runtime/run-tool-approval-flow.d.ts +36 -0
- package/dist/agent-runtime/run-tool-approval-flow.d.ts.map +1 -0
- package/dist/agent-runtime/run-tool-approval-records.d.ts +24 -0
- package/dist/agent-runtime/run-tool-approval-records.d.ts.map +1 -0
- package/dist/agent-runtime/run-tool-call.d.ts +73 -0
- package/dist/agent-runtime/run-tool-call.d.ts.map +1 -0
- package/dist/agent-runtime/run-tool-errors.d.ts +29 -0
- package/dist/agent-runtime/run-tool-errors.d.ts.map +1 -0
- package/dist/agent-runtime/run-tool-executor.d.ts +34 -0
- package/dist/agent-runtime/run-tool-executor.d.ts.map +1 -0
- package/dist/agent-runtime/run-tool-progress.d.ts +2 -2
- package/dist/agent-runtime/run-tool-progress.d.ts.map +1 -1
- package/dist/agent-runtime/run-turn-preparation.d.ts +7 -6
- package/dist/agent-runtime/run-turn-preparation.d.ts.map +1 -1
- package/dist/agent-runtime/run-unacquired.d.ts +2 -2
- package/dist/agent-runtime/run-unacquired.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-control.d.ts +4 -4
- package/dist/agent-runtime/runtime-control.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-internals.d.ts +35 -44
- package/dist/agent-runtime/runtime-internals.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-recovery.d.ts +3 -3
- package/dist/agent-runtime/runtime-recovery.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-state.d.ts +3 -3
- package/dist/agent-runtime/runtime-state.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-submit.d.ts +2 -2
- package/dist/agent-runtime/runtime-submit.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +51 -16
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-process-linux.d.ts +8 -0
- package/dist/agent-runtime/sandbox-process-linux.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-process-macos.d.ts +21 -0
- package/dist/agent-runtime/sandbox-process-macos.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-process-spec.d.ts +114 -0
- package/dist/agent-runtime/sandbox-process-spec.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-process-wrapper.d.ts +19 -0
- package/dist/agent-runtime/sandbox-process-wrapper.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-message.d.ts +10 -0
- package/dist/agent-runtime/schemas-message.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-provider.d.ts +2 -0
- package/dist/agent-runtime/schemas-provider.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-run.d.ts +10 -0
- package/dist/agent-runtime/schemas-run.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-usage-state.d.ts +6 -0
- package/dist/agent-runtime/schemas-usage-state.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-usage.d.ts +8 -0
- package/dist/agent-runtime/schemas-usage.d.ts.map +1 -1
- package/dist/agent-runtime/sql-rows.d.ts +20 -10
- package/dist/agent-runtime/sql-rows.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +40 -20
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-support.d.ts +20 -10
- package/dist/agent-runtime/store-conformance-support.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver-contract.d.ts +70 -0
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
- package/dist/agent-runtime/store-events.d.ts +120 -0
- package/dist/agent-runtime/store-events.d.ts.map +1 -1
- package/dist/agent-runtime/store.d.ts +140 -0
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-commit.d.ts +10 -0
- package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
- package/dist/agent-runtime/testing.d.ts +20 -0
- package/dist/agent-runtime/testing.d.ts.map +1 -1
- package/dist/browser/client-call-arguments.d.ts.map +1 -1
- package/dist/browser/client-executors.d.ts.map +1 -1
- package/dist/browser/client-url.d.ts.map +1 -1
- package/dist/browser/client.d.ts +6 -0
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/device-presence-client.d.ts +42 -0
- package/dist/browser/device-presence-client.d.ts.map +1 -0
- package/dist/browser/device-presence-ops.d.ts +47 -0
- package/dist/browser/device-presence-ops.d.ts.map +1 -0
- package/dist/browser/device-presence-relay-adapter.d.ts +37 -0
- package/dist/browser/device-presence-relay-adapter.d.ts.map +1 -0
- package/dist/browser/http-fetch.d.ts +7 -2
- package/dist/browser/http-fetch.d.ts.map +1 -1
- package/dist/browser/http-helpers.d.ts +15 -0
- package/dist/browser/http-helpers.d.ts.map +1 -0
- package/dist/browser/http.d.ts +8 -0
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/contract/client-types.d.ts +8 -0
- package/dist/contract/client-types.d.ts.map +1 -1
- package/dist/contract/runtime-context.d.ts +13 -1
- package/dist/contract/runtime-context.d.ts.map +1 -1
- package/dist/device-relay/agent-handlers.d.ts +45 -0
- package/dist/device-relay/agent-handlers.d.ts.map +1 -0
- package/dist/device-relay/agent.d.ts +80 -0
- package/dist/device-relay/agent.d.ts.map +1 -0
- package/dist/device-relay/broker.d.ts +49 -0
- package/dist/device-relay/broker.d.ts.map +1 -0
- package/dist/device-relay/contract.d.ts +614 -0
- package/dist/device-relay/contract.d.ts.map +1 -0
- package/dist/device-relay/encoding.d.ts +30 -0
- package/dist/device-relay/encoding.d.ts.map +1 -0
- package/dist/device-relay/hub-connection.d.ts +43 -0
- package/dist/device-relay/hub-connection.d.ts.map +1 -0
- package/dist/device-relay/hub-dispatch.d.ts +19 -0
- package/dist/device-relay/hub-dispatch.d.ts.map +1 -0
- package/dist/device-relay/hub-handshake.d.ts +20 -0
- package/dist/device-relay/hub-handshake.d.ts.map +1 -0
- package/dist/device-relay/hub-shared-streams.d.ts +24 -0
- package/dist/device-relay/hub-shared-streams.d.ts.map +1 -0
- package/dist/device-relay/hub-streams.d.ts +57 -0
- package/dist/device-relay/hub-streams.d.ts.map +1 -0
- package/dist/device-relay/hub.d.ts +117 -0
- package/dist/device-relay/hub.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/acp.d.ts +1 -1
- package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +183 -29
- package/dist/entrypoints/agent-executor/claude-sdk.js +15 -15
- package/dist/entrypoints/agent-executor/claude.js +13 -15
- package/dist/entrypoints/agent-executor/codex.js +88 -48
- package/dist/entrypoints/agent-executor/testing/claude-sdk.js +5 -5
- package/dist/entrypoints/agent-executor/testing.js +31 -30
- package/dist/entrypoints/agent-executor.d.ts +2 -2
- package/dist/entrypoints/agent-executor.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor.js +23 -17
- package/dist/entrypoints/agent-runtime/ai-sdk.d.ts +9 -0
- package/dist/entrypoints/agent-runtime/ai-sdk.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/ai-sdk.js +821 -0
- package/dist/entrypoints/agent-runtime/anthropic.d.ts +4 -0
- package/dist/entrypoints/agent-runtime/anthropic.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/anthropic.js +1260 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts +4 -1
- package/dist/entrypoints/agent-runtime/browser.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/browser.js +449 -50
- package/dist/entrypoints/agent-runtime/coding-tools.js +3 -3
- package/dist/entrypoints/agent-runtime/harness.js +24 -19
- package/dist/entrypoints/agent-runtime/openai.d.ts +4 -0
- package/dist/entrypoints/agent-runtime/openai.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/openai.js +1246 -0
- package/dist/entrypoints/agent-runtime/openrouter.d.ts +5 -2
- package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/openrouter.js +2355 -371
- package/dist/entrypoints/agent-runtime/postgres.js +12 -10
- package/dist/entrypoints/agent-runtime/realtime.js +11 -10
- package/dist/entrypoints/agent-runtime/sandbox.d.ts +3 -0
- package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/sandbox.js +530 -7
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +13 -11
- package/dist/entrypoints/agent-runtime/sqlite/node.js +13 -11
- 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 +56 -15
- package/dist/entrypoints/agent-runtime.d.ts +14 -6
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +1412 -115
- package/dist/entrypoints/application/diagnostic-journal.js +6 -6
- package/dist/entrypoints/application/directory-inbox.js +6 -6
- package/dist/entrypoints/application/opentelemetry.js +3 -3
- package/dist/entrypoints/application.js +17 -17
- package/dist/entrypoints/cli/publish.js +8 -8
- package/dist/entrypoints/cli.js +14 -15
- package/dist/entrypoints/contract.d.ts +1 -0
- package/dist/entrypoints/contract.d.ts.map +1 -1
- package/dist/entrypoints/contract.js +13 -9
- package/dist/entrypoints/device-relay.d.ts +10 -0
- package/dist/entrypoints/device-relay.d.ts.map +1 -0
- package/dist/entrypoints/device-relay.js +2517 -0
- package/dist/entrypoints/files/packaging.js +3 -3
- package/dist/entrypoints/files.js +11 -11
- package/dist/entrypoints/geo.js +5 -5
- package/dist/entrypoints/google.js +1 -1
- package/dist/entrypoints/handler.js +6 -6
- package/dist/entrypoints/http.js +9 -9
- package/dist/entrypoints/index.js +21 -17
- package/dist/entrypoints/live.js +4 -4
- package/dist/entrypoints/node.js +13 -13
- package/dist/entrypoints/observability.js +9 -9
- package/dist/entrypoints/process/bootstrap.js +1 -1
- package/dist/entrypoints/process.js +5 -5
- package/dist/entrypoints/react.js +4 -4
- package/dist/entrypoints/realtime.d.ts +3 -0
- package/dist/entrypoints/realtime.d.ts.map +1 -1
- package/dist/entrypoints/realtime.js +413 -4
- package/dist/entrypoints/release.js +1 -1
- package/dist/entrypoints/remote.js +10 -10
- package/dist/entrypoints/server.d.ts +1 -0
- package/dist/entrypoints/server.d.ts.map +1 -1
- package/dist/entrypoints/server.js +546 -40
- package/dist/entrypoints/service-host/macos.js +10 -10
- package/dist/entrypoints/service-host/work.js +7 -7
- package/dist/entrypoints/service-host.js +15 -15
- package/dist/entrypoints/spend.js +3 -3
- package/dist/entrypoints/sync.js +4 -4
- package/dist/entrypoints/telegram/screens.js +6 -6
- package/dist/entrypoints/telegram.js +20 -20
- package/dist/entrypoints/testing.js +14 -14
- package/dist/entrypoints/tools/agent.d.ts +2 -1
- package/dist/entrypoints/tools/agent.d.ts.map +1 -1
- package/dist/entrypoints/tools/agent.js +8 -7
- package/dist/entrypoints/tools/connections.js +5 -5
- package/dist/entrypoints/tools/invoker.js +3 -4
- package/dist/entrypoints/tools/mcp.js +8 -9
- package/dist/entrypoints/tools/toolkit.js +32 -13
- package/dist/entrypoints/tools.d.ts +3 -1
- package/dist/entrypoints/tools.d.ts.map +1 -1
- package/dist/entrypoints/tools.js +37 -35
- package/dist/entrypoints/tracking/contract.js +1 -1
- package/dist/entrypoints/tracking/performance.js +4 -4
- package/dist/entrypoints/tracking.js +3 -3
- package/dist/{index-09f7w2qq.js → index-02kdtrcd.js} +1 -1
- package/dist/{index-y53cqwke.js → index-033tyx59.js} +1 -1
- package/dist/{index-9ft4n9j1.js → index-05b65gj4.js} +2 -2
- package/dist/{index-d04w81fz.js → index-0sxj3y45.js} +1 -1
- package/dist/{index-dm6nxkn1.js → index-18pf56dq.js} +4 -6
- package/dist/index-1gmgwfn3.js +439 -0
- package/dist/index-23wn8sgf.js +47 -0
- package/dist/{index-tqjamnax.js → index-27srek2g.js} +15 -13
- package/dist/{index-2nwvn7m2.js → index-29v1p1f4.js} +2 -2
- package/dist/index-36dmtzjr.js +194 -0
- package/dist/{index-ycr4pk0z.js → index-42n9jycn.js} +3 -3
- package/dist/{index-ke02kxsr.js → index-43k180c2.js} +1 -1
- package/dist/{index-pbekeqzm.js → index-5c4m8zdf.js} +2 -2
- package/dist/{index-qggqqja2.js → index-5dxgx3yj.js} +1 -1
- package/dist/{index-x5ayy5bn.js → index-5gdexvke.js} +3 -1
- package/dist/{index-t1a2jrg7.js → index-5xsxvk2x.js} +1 -1
- package/dist/{index-mbd92r1w.js → index-654rhe5d.js} +1 -1
- package/dist/{index-2dzc7mv9.js → index-67pnt4bh.js} +1 -1
- package/dist/index-6kpwkpgx.js +415 -0
- package/dist/{index-s43tr4my.js → index-6kwdfb9m.js} +18 -3
- package/dist/{index-1qwd54n3.js → index-6nzzj7qr.js} +1 -1
- package/dist/{index-rkjfzs0a.js → index-6p5pshcd.js} +2 -2
- package/dist/{index-118aebbg.js → index-6t4c98gr.js} +1 -1
- package/dist/{index-pws5c3x6.js → index-6xw1wf4m.js} +51 -32
- package/dist/{index-kwsr7j5k.js → index-6yb4stq3.js} +1 -1
- package/dist/{index-8jf4bt7v.js → index-76yhxa41.js} +8 -8
- package/dist/{index-7416mhyh.js → index-79vqbjcz.js} +1 -1
- package/dist/{index-13wmzpa6.js → index-7an2fs5h.js} +1 -1
- package/dist/index-7qza24g1.js +14 -0
- package/dist/{index-gtaaxe9d.js → index-8cek82ar.js} +1 -1
- package/dist/index-9f60gnfn.js +393 -0
- package/dist/{index-stpy56r3.js → index-aacwkve4.js} +209 -10
- package/dist/{index-rpyn7geq.js → index-ac3rfec5.js} +2 -2
- package/dist/{index-d2drhb9c.js → index-b0mh2t9x.js} +2 -2
- package/dist/index-b23s6e2c.js +158 -0
- package/dist/{index-an7vcmwf.js → index-bvpevwt6.js} +5 -5
- package/dist/{index-msxf2r8x.js → index-by8w2461.js} +1 -1
- package/dist/{index-8t9dr41h.js → index-c0yym4a0.js} +4 -4
- package/dist/{index-wddcfbng.js → index-c7fj4yw9.js} +1 -1
- package/dist/{index-tf70nm22.js → index-cb4nnvfr.js} +8 -6
- package/dist/{index-205456mf.js → index-d3s070eh.js} +2 -2
- package/dist/{index-apf5g7y9.js → index-dz6tstcp.js} +2 -2
- package/dist/{index-agy5fqgf.js → index-e1y74yra.js} +15 -8
- package/dist/index-edtg4tak.js +55 -0
- package/dist/{index-pq6g1k9t.js → index-ek9w11r0.js} +2 -2
- package/dist/{index-x46y9z26.js → index-epyj7ptp.js} +7 -5
- package/dist/{index-6kmjcm81.js → index-er483f3w.js} +93 -4
- package/dist/{index-827bgv33.js → index-f16b7rze.js} +1 -1
- package/dist/{index-gbhj370g.js → index-fec05c9k.js} +21 -21
- package/dist/{index-9wdrwx3b.js → index-fjac2w5e.js} +20 -22
- package/dist/{index-6918kxbf.js → index-fthw8dwa.js} +1 -0
- package/dist/{index-2mz8hj58.js → index-g04hszcm.js} +1 -1
- package/dist/{index-rw8ze745.js → index-ga6avd48.js} +1 -1
- package/dist/{index-paff5y0r.js → index-grhhsrd5.js} +9 -7
- package/dist/{index-mxt0wfjy.js → index-h20qcyh5.js} +5 -2
- package/dist/index-j3r7r1mh.js +150 -0
- package/dist/{index-vgytj9wp.js → index-jmaw365j.js} +1 -1
- package/dist/{index-cjytermm.js → index-jzdbkanz.js} +3 -3
- package/dist/index-k137ezb6.js +79 -0
- package/dist/{index-tazm4dxf.js → index-kdw0n92g.js} +1 -1
- package/dist/{index-wh70tmpd.js → index-ke6jtxkd.js} +1 -1
- package/dist/index-kgj8j7bv.js +83 -0
- package/dist/{index-9kpxz49v.js → index-kgkevngs.js} +1 -1
- package/dist/{index-hab790s6.js → index-kp1j7cc8.js} +4 -4
- package/dist/{index-jcge9tx3.js → index-krekhmp7.js} +142 -123
- package/dist/{index-3y2tzhr8.js → index-ky79wwgs.js} +4 -4
- package/dist/{index-39rmc00v.js → index-mfe9a266.js} +1 -1
- package/dist/{index-qpzyahe3.js → index-mgr0mdqp.js} +5 -2
- package/dist/{index-n20tybgk.js → index-mh3jdb25.js} +2 -2
- package/dist/{index-g5fgeb6v.js → index-mkmep637.js} +1 -1
- package/dist/{index-02r5sq9p.js → index-mrng24wq.js} +19 -21
- package/dist/index-mx2gya05.js +465 -0
- package/dist/{index-8yt3rwe7.js → index-n2t87ggz.js} +5 -5
- package/dist/index-nfeafbzh.js +7379 -0
- package/dist/{index-j0ef04jw.js → index-nfm15ej7.js} +4 -4
- package/dist/index-pd9e8rz4.js +193 -0
- package/dist/{index-zwgwyvdt.js → index-pdcbjd6a.js} +1 -1
- package/dist/{index-q427q23r.js → index-pjjh91vw.js} +2 -2
- package/dist/{index-gnjgkecx.js → index-q46b16xz.js} +1 -1
- package/dist/{index-9xr44d2g.js → index-qv5v6w9c.js} +330 -106
- package/dist/{index-tmv3ez1h.js → index-qymek778.js} +69 -12
- package/dist/{index-yrr3n391.js → index-ry8m2mhg.js} +2 -2
- package/dist/{index-93n6jwy0.js → index-s0n0nnz5.js} +3 -3
- package/dist/{index-1p8q0yrt.js → index-t5zp1jjj.js} +5 -7
- package/dist/{index-2rf33y2h.js → index-tav72wz5.js} +4 -2
- package/dist/{index-jpecjm30.js → index-tgehj4bp.js} +1 -1
- package/dist/{index-ma26mfnt.js → index-v5hmyef8.js} +1 -1
- package/dist/index-vebzvse6.js +230 -0
- package/dist/index-vv0hxrmy.js +295 -0
- package/dist/index-vxm0ya3f.js +707 -0
- package/dist/{index-t3qcac2a.js → index-w3s79kcb.js} +1 -1
- package/dist/{index-r97ppg0g.js → index-x1r7kxzd.js} +1 -1
- package/dist/{index-kynwa08q.js → index-xrsryvd2.js} +2 -2
- package/dist/{index-3mcbr8sx.js → index-xtxxt87z.js} +1 -1
- package/dist/index-zk839vzf.js +231 -0
- package/dist/{index-9c76vfxf.js → index-zyyerdny.js} +4 -4
- package/dist/internal/base64.d.ts +9 -0
- package/dist/internal/base64.d.ts.map +1 -0
- package/dist/internal/deadline-budget.d.ts +57 -0
- package/dist/internal/deadline-budget.d.ts.map +1 -0
- package/dist/internal/deadline.d.ts.map +1 -1
- package/dist/internal/timers.d.ts +2 -0
- package/dist/internal/timers.d.ts.map +1 -1
- package/dist/realtime/device-presence-contract.d.ts +194 -0
- package/dist/realtime/device-presence-contract.d.ts.map +1 -0
- package/dist/server/context-contribution.d.ts.map +1 -1
- package/dist/server/contract-method.d.ts.map +1 -1
- package/dist/server/device-presence-handlers.d.ts +54 -0
- package/dist/server/device-presence-handlers.d.ts.map +1 -0
- package/dist/server/device-presence-registry.d.ts +35 -0
- package/dist/server/device-presence-registry.d.ts.map +1 -0
- package/dist/server/device-presence.d.ts +45 -0
- package/dist/server/device-presence.d.ts.map +1 -0
- package/dist/server/endpoint-dispatch.d.ts.map +1 -1
- package/dist/server/middleware/cors.d.ts +3 -1
- package/dist/server/middleware/cors.d.ts.map +1 -1
- package/dist/server/types.d.ts +4 -11
- package/dist/server/types.d.ts.map +1 -1
- package/dist/service-host/systemd-render-shared.d.ts.map +1 -1
- package/dist/tools/agent-messages.d.ts +6 -0
- package/dist/tools/agent-messages.d.ts.map +1 -0
- package/dist/tools/agent-tool-error.d.ts +2 -2
- package/dist/tools/agent-tools.d.ts +153 -0
- package/dist/tools/agent-tools.d.ts.map +1 -0
- package/dist/tools/agent.d.ts +6 -56
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +3 -4
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/toolkit.d.ts +3 -1
- package/dist/tools/toolkit.d.ts.map +1 -1
- package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -1
- package/llms/agent-executor-acp.txt +2 -2
- package/llms/agent-executor-codex.txt +1 -1
- package/llms/agent-executor.txt +7 -3
- package/llms/agent-runtime-ai-sdk.txt +26 -0
- package/llms/agent-runtime-anthropic.txt +33 -0
- package/llms/agent-runtime-browser.txt +22 -8
- package/llms/agent-runtime-harness.txt +2 -2
- package/llms/agent-runtime-openai.txt +31 -0
- package/llms/agent-runtime-openrouter.txt +17 -7
- package/llms/agent-runtime-sandbox.txt +53 -1
- package/llms/agent-runtime-testing.txt +4 -2
- package/llms/agent-runtime.2.txt +158 -271
- package/llms/agent-runtime.3.txt +289 -243
- package/llms/agent-runtime.4.txt +273 -216
- package/llms/agent-runtime.5.txt +209 -2
- package/llms/agent-runtime.txt +238 -181
- package/llms/contract.txt +2 -1
- package/llms/device-relay.txt +34 -0
- package/llms/realtime.txt +20 -0
- package/llms/server.2.txt +125 -1
- package/llms/server.3.txt +111 -122
- package/llms/server.4.txt +1 -1
- package/llms/server.5.txt +3 -1
- package/llms/server.txt +31 -1
- package/llms/spend.txt +11 -6
- package/llms/stitchkit.2.txt +21 -43
- package/llms/stitchkit.3.txt +43 -0
- package/llms/stitchkit.txt +93 -84
- package/llms/tools-agent.txt +7 -5
- package/llms/tools-toolkit.txt +1 -1
- package/llms/tools.4.txt +7 -2
- package/llms/{upgrading-0.128.0-0.133.0.txt → upgrading-0.128.0-0.134.0.txt} +173 -3
- package/llms/upgrading.txt +1 -1
- package/llms-full.txt +981 -210
- package/llms.txt +21 -17
- package/package.json +18 -7
- package/dist/index-0p0s5hrj.js +0 -249
- package/dist/index-1dn2wjq6.js +0 -135
- package/dist/index-1psbyyhj.js +0 -21
- package/dist/index-34k82crg.js +0 -3961
- package/dist/index-5n3a8hd8.js +0 -102
- package/dist/index-97rp94ff.js +0 -8
- package/dist/index-bn2baakz.js +0 -336
- package/dist/index-eh71zr32.js +0 -14
- package/dist/index-emgrmavr.js +0 -1193
- package/dist/index-fzd477xk.js +0 -135
- package/dist/index-vgzhw2zk.js +0 -304
- package/dist/internal/ai-sdk-typed.d.ts +0 -14
- package/dist/internal/ai-sdk-typed.d.ts.map +0 -1
- package/dist/tools/runtime-call-context.d.ts +0 -15
- package/dist/tools/runtime-call-context.d.ts.map +0 -1
- package/dist/{index-vmbxj75t.js → index-jwtmw39p.js} +0 -0
- package/dist/{index-877e9y8r.js → index-sk03xe0n.js} +3 -3
- package/dist/{index-21cfxc4z.js → index-vh4291qh.js} +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import"../index-6kec3b14.js";
|
|
2
2
|
import"../index-673drwkn.js";
|
|
3
|
-
import"../index-
|
|
3
|
+
import"../index-jwtmw39p.js";
|
|
4
4
|
import {
|
|
5
5
|
errorCode2,
|
|
6
6
|
normalizeError2
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
DEFAULT_CORS_EXPOSE_HEADERS2,
|
|
14
14
|
corsHeaders2,
|
|
15
15
|
corsPreflightResponse2
|
|
16
|
-
} from "../index-
|
|
16
|
+
} from "../index-654rhe5d.js";
|
|
17
17
|
import {
|
|
18
18
|
joinRoutePath,
|
|
19
19
|
parseTrailingWildcard
|
|
@@ -24,14 +24,20 @@ import {
|
|
|
24
24
|
ShutdownStatusSchema2,
|
|
25
25
|
ShutdownResultSchema2,
|
|
26
26
|
createServerLifecycle
|
|
27
|
-
} from "../index-
|
|
27
|
+
} from "../index-5xsxvk2x.js";
|
|
28
28
|
import {
|
|
29
29
|
fingerprintOperations,
|
|
30
30
|
contractIdentityContract2
|
|
31
|
-
} from "../index-
|
|
31
|
+
} from "../index-c0yym4a0.js";
|
|
32
32
|
import"../index-yt1gg11x.js";
|
|
33
33
|
import"../index-werjqesf.js";
|
|
34
|
-
import"../index-
|
|
34
|
+
import"../index-zyyerdny.js";
|
|
35
|
+
import"../index-814xpr6d.js";
|
|
36
|
+
import {
|
|
37
|
+
DEFAULT_DEVICE_PRESENCE_COMMAND_TIMEOUT_MS2
|
|
38
|
+
} from "../index-36dmtzjr.js";
|
|
39
|
+
import"../index-0k1ba0ss.js";
|
|
40
|
+
import"../index-4s0fep5q.js";
|
|
35
41
|
import {
|
|
36
42
|
createScopedImplementRegistry2,
|
|
37
43
|
implementRegistry2,
|
|
@@ -47,18 +53,26 @@ import {
|
|
|
47
53
|
createSocketIOServer2,
|
|
48
54
|
socketIoLane2,
|
|
49
55
|
createUnixClientTransport2
|
|
50
|
-
} from "../index-
|
|
56
|
+
} from "../index-fec05c9k.js";
|
|
51
57
|
import"../index-27hck3z2.js";
|
|
52
58
|
import {
|
|
53
59
|
toJsonSchema,
|
|
54
60
|
jsonSchemaFields
|
|
55
61
|
} from "../index-ngwf1s3c.js";
|
|
56
|
-
import"../index-0k1ba0ss.js";
|
|
57
|
-
import"../index-4s0fep5q.js";
|
|
58
62
|
import"../index-xqhede6x.js";
|
|
59
63
|
import {
|
|
60
64
|
createFileStateStore2
|
|
61
|
-
} from "../index-
|
|
65
|
+
} from "../index-kgkevngs.js";
|
|
66
|
+
import {
|
|
67
|
+
withUnixSocketLockSync,
|
|
68
|
+
assertUnixSocketMode,
|
|
69
|
+
unlinkUnixSocketIfMatching,
|
|
70
|
+
unlinkUnixSocketIfOwned,
|
|
71
|
+
assertUnixSocketPathLength,
|
|
72
|
+
assertPrivateUnixSocketDirectory,
|
|
73
|
+
publishStagedUnixSocket,
|
|
74
|
+
bindUnixSocket2
|
|
75
|
+
} from "../index-kp1j7cc8.js";
|
|
62
76
|
import {
|
|
63
77
|
bindRealtimeServer2
|
|
64
78
|
} from "../index-y68gavb5.js";
|
|
@@ -75,31 +89,10 @@ import {
|
|
|
75
89
|
ndjsonRoute2,
|
|
76
90
|
sseRoute2,
|
|
77
91
|
createHandler2
|
|
78
|
-
} from "../index-
|
|
92
|
+
} from "../index-qymek778.js";
|
|
79
93
|
import {
|
|
80
94
|
secretsEqual
|
|
81
95
|
} from "../index-apv5xfef.js";
|
|
82
|
-
import {
|
|
83
|
-
withUnixSocketLockSync,
|
|
84
|
-
assertUnixSocketMode,
|
|
85
|
-
unlinkUnixSocketIfMatching,
|
|
86
|
-
unlinkUnixSocketIfOwned,
|
|
87
|
-
assertUnixSocketPathLength,
|
|
88
|
-
assertPrivateUnixSocketDirectory,
|
|
89
|
-
publishStagedUnixSocket,
|
|
90
|
-
bindUnixSocket2
|
|
91
|
-
} from "../index-hab790s6.js";
|
|
92
|
-
import {
|
|
93
|
-
jsonResponse
|
|
94
|
-
} from "../index-kyejf658.js";
|
|
95
|
-
import"../index-2nwvn7m2.js";
|
|
96
|
-
import"../index-ke02kxsr.js";
|
|
97
|
-
import {
|
|
98
|
-
inputIsQuery
|
|
99
|
-
} from "../index-xhzq2qvj.js";
|
|
100
|
-
import {
|
|
101
|
-
UnixClientTransportError2
|
|
102
|
-
} from "../index-cv9b7fz2.js";
|
|
103
96
|
import {
|
|
104
97
|
verifyJwt2,
|
|
105
98
|
signJwt2,
|
|
@@ -108,14 +101,23 @@ import {
|
|
|
108
101
|
import {
|
|
109
102
|
deriveCodeChallenge2
|
|
110
103
|
} from "../index-ap3gqe56.js";
|
|
104
|
+
import {
|
|
105
|
+
isWithinDir2,
|
|
106
|
+
realPathWithinDir
|
|
107
|
+
} from "../index-5cc6r990.js";
|
|
111
108
|
import {
|
|
112
109
|
defineMultipartStream2,
|
|
113
110
|
createMultipartStream2,
|
|
114
111
|
implement2,
|
|
115
112
|
createImplement2,
|
|
116
113
|
createScopedImplement2
|
|
117
|
-
} from "../index-
|
|
118
|
-
import"../index-
|
|
114
|
+
} from "../index-6nzzj7qr.js";
|
|
115
|
+
import"../index-fthw8dwa.js";
|
|
116
|
+
import {
|
|
117
|
+
jsonResponse
|
|
118
|
+
} from "../index-kyejf658.js";
|
|
119
|
+
import"../index-29v1p1f4.js";
|
|
120
|
+
import"../index-43k180c2.js";
|
|
119
121
|
import {
|
|
120
122
|
generateTraceId2,
|
|
121
123
|
resolveTraceId2,
|
|
@@ -124,13 +126,12 @@ import {
|
|
|
124
126
|
getClientInfo2,
|
|
125
127
|
isPublicIp2
|
|
126
128
|
} from "../index-5q0qpw3v.js";
|
|
127
|
-
import {
|
|
128
|
-
isWithinDir2,
|
|
129
|
-
realPathWithinDir
|
|
130
|
-
} from "../index-5cc6r990.js";
|
|
131
129
|
import {
|
|
132
130
|
bytesToBase64Url
|
|
133
131
|
} from "../index-dwfv9a85.js";
|
|
132
|
+
import {
|
|
133
|
+
inputIsQuery
|
|
134
|
+
} from "../index-xhzq2qvj.js";
|
|
134
135
|
import {
|
|
135
136
|
isUnsafeKey
|
|
136
137
|
} from "../index-zsarb5xp.js";
|
|
@@ -150,11 +151,19 @@ import {
|
|
|
150
151
|
isStitchErrorCode2
|
|
151
152
|
} from "../index-7fjbdga8.js";
|
|
152
153
|
import {
|
|
153
|
-
|
|
154
|
-
} from "../index-
|
|
154
|
+
UnixClientTransportError2
|
|
155
|
+
} from "../index-cv9b7fz2.js";
|
|
155
156
|
import {
|
|
157
|
+
assertPositiveSafeInteger
|
|
158
|
+
} from "../index-gr0kxymw.js";
|
|
159
|
+
import {
|
|
160
|
+
assertTimerMs,
|
|
156
161
|
withDeadline
|
|
157
|
-
} from "../index-
|
|
162
|
+
} from "../index-e1y74yra.js";
|
|
163
|
+
import {
|
|
164
|
+
isRecord,
|
|
165
|
+
transportResult
|
|
166
|
+
} from "../index-ps3djm8d.js";
|
|
158
167
|
// src/realtime/registry.ts
|
|
159
168
|
var authorizedRoom = Symbol("stitchkit.authorized-room");
|
|
160
169
|
function freezeRoom(name) {
|
|
@@ -829,6 +838,502 @@ function withContractIdentity(services) {
|
|
|
829
838
|
})
|
|
830
839
|
];
|
|
831
840
|
}
|
|
841
|
+
// src/server/device-presence-registry.ts
|
|
842
|
+
var DEFAULT_MAX_PENDING_COMMANDS = 1024;
|
|
843
|
+
var DEFAULT_MAX_PENDING_COMMANDS_PER_ACCOUNT = 64;
|
|
844
|
+
var DEFAULT_MAX_COMMAND_TIMEOUT_MS = 60000;
|
|
845
|
+
var MAX_RETAINED_ACCOUNT_REVISIONS = 4096;
|
|
846
|
+
var registryAuxIndex = new WeakMap;
|
|
847
|
+
function getPresenceAuxIndex(state) {
|
|
848
|
+
let aux = registryAuxIndex.get(state);
|
|
849
|
+
if (!aux) {
|
|
850
|
+
aux = { deviceOwners: new Map, pendingCountByAccount: new Map };
|
|
851
|
+
registryAuxIndex.set(state, aux);
|
|
852
|
+
}
|
|
853
|
+
return aux;
|
|
854
|
+
}
|
|
855
|
+
function indexDeviceOwner(state, deviceId, accountId) {
|
|
856
|
+
const owners = getPresenceAuxIndex(state).deviceOwners;
|
|
857
|
+
let set = owners.get(deviceId);
|
|
858
|
+
if (!set) {
|
|
859
|
+
set = new Set;
|
|
860
|
+
owners.set(deviceId, set);
|
|
861
|
+
}
|
|
862
|
+
set.add(accountId);
|
|
863
|
+
}
|
|
864
|
+
function unindexDeviceOwner(state, deviceId, accountId) {
|
|
865
|
+
const owners = getPresenceAuxIndex(state).deviceOwners;
|
|
866
|
+
const set = owners.get(deviceId);
|
|
867
|
+
if (!set)
|
|
868
|
+
return;
|
|
869
|
+
set.delete(accountId);
|
|
870
|
+
if (set.size === 0)
|
|
871
|
+
owners.delete(deviceId);
|
|
872
|
+
}
|
|
873
|
+
function pendingCommandKey(accountId, commandId) {
|
|
874
|
+
return `${accountId.length}:${accountId}:${commandId}`;
|
|
875
|
+
}
|
|
876
|
+
function removePendingCommand(state, scopedKey) {
|
|
877
|
+
const pending = state.pendingCommands.get(scopedKey);
|
|
878
|
+
if (!pending)
|
|
879
|
+
return;
|
|
880
|
+
state.pendingCommands.delete(scopedKey);
|
|
881
|
+
const counts = getPresenceAuxIndex(state).pendingCountByAccount;
|
|
882
|
+
const next = (counts.get(pending.accountId) ?? 1) - 1;
|
|
883
|
+
if (next <= 0)
|
|
884
|
+
counts.delete(pending.accountId);
|
|
885
|
+
else
|
|
886
|
+
counts.set(pending.accountId, next);
|
|
887
|
+
return pending;
|
|
888
|
+
}
|
|
889
|
+
function trimRetainedRevisions(state) {
|
|
890
|
+
if (state.revisionByAccount.size <= MAX_RETAINED_ACCOUNT_REVISIONS)
|
|
891
|
+
return;
|
|
892
|
+
for (const accountId of state.revisionByAccount.keys()) {
|
|
893
|
+
if (state.revisionByAccount.size <= MAX_RETAINED_ACCOUNT_REVISIONS)
|
|
894
|
+
break;
|
|
895
|
+
if (!state.accountSockets.has(accountId) && !state.devicesByAccount.has(accountId)) {
|
|
896
|
+
state.revisionByAccount.delete(accountId);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
function cleanupEmptyAccount(state, accountId) {
|
|
901
|
+
const members = state.accountSockets.get(accountId);
|
|
902
|
+
const devices = state.devicesByAccount.get(accountId);
|
|
903
|
+
if (members && members.size === 0)
|
|
904
|
+
state.accountSockets.delete(accountId);
|
|
905
|
+
if (devices && devices.size === 0)
|
|
906
|
+
state.devicesByAccount.delete(accountId);
|
|
907
|
+
trimRetainedRevisions(state);
|
|
908
|
+
}
|
|
909
|
+
function commandError(commandId, code, message) {
|
|
910
|
+
return { schemaVersion: 1, commandId, outcome: "error", code, message };
|
|
911
|
+
}
|
|
912
|
+
function presenceError(code, message) {
|
|
913
|
+
return { schemaVersion: 1, outcome: "error", code, message };
|
|
914
|
+
}
|
|
915
|
+
function emitRegistrySnapshot(state, accountId, buildSnapshot, emitEvent) {
|
|
916
|
+
const nextRevision = (state.revisionByAccount.get(accountId) ?? 0) + 1;
|
|
917
|
+
state.revisionByAccount.delete(accountId);
|
|
918
|
+
state.revisionByAccount.set(accountId, nextRevision);
|
|
919
|
+
const snapshot = buildSnapshot(state, accountId);
|
|
920
|
+
const members = state.accountSockets.get(accountId);
|
|
921
|
+
if (members) {
|
|
922
|
+
for (const member of [...members]) {
|
|
923
|
+
if (!member.disconnected) {
|
|
924
|
+
emitEvent(member.connection, state.contract.events.snapshot, snapshot);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
try {
|
|
929
|
+
state.options.onSnapshot?.(snapshot);
|
|
930
|
+
} catch (error) {
|
|
931
|
+
state.options.logger?.warn("DevicePresenceServer onSnapshot threw", { error });
|
|
932
|
+
}
|
|
933
|
+
cleanupEmptyAccount(state, accountId);
|
|
934
|
+
return snapshot;
|
|
935
|
+
}
|
|
936
|
+
function failPendingCommandsForSocket(state, socketId, message) {
|
|
937
|
+
for (const [scopedKey, pending] of [...state.pendingCommands]) {
|
|
938
|
+
if (pending.targetSocketId !== socketId)
|
|
939
|
+
continue;
|
|
940
|
+
removePendingCommand(state, scopedKey);
|
|
941
|
+
clearTimeout(pending.timer);
|
|
942
|
+
pending.settle(commandError(pending.commandId, "DEVICE_OFFLINE", message));
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
function validateCommandLimits(state, accountId, scopedKey, payload) {
|
|
946
|
+
if (state.pendingCommands.has(scopedKey)) {
|
|
947
|
+
return {
|
|
948
|
+
ok: false,
|
|
949
|
+
error: commandError(payload.commandId, "INVALID_COMMAND", `Command id "${payload.commandId}" is already in flight`)
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
const aux = getPresenceAuxIndex(state);
|
|
953
|
+
const maxPerAccount = Math.min(DEFAULT_MAX_PENDING_COMMANDS, DEFAULT_MAX_PENDING_COMMANDS_PER_ACCOUNT);
|
|
954
|
+
if (state.pendingCommands.size >= DEFAULT_MAX_PENDING_COMMANDS || (aux.pendingCountByAccount.get(accountId) ?? 0) >= maxPerAccount) {
|
|
955
|
+
return {
|
|
956
|
+
ok: false,
|
|
957
|
+
error: commandError(payload.commandId, "INVALID_COMMAND", "Too many pending remote commands in flight")
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
const maxTimeoutMs = Math.max(DEFAULT_MAX_COMMAND_TIMEOUT_MS, state.defaultCommandTimeoutMs);
|
|
961
|
+
if (payload.timeoutMs !== undefined && payload.timeoutMs > maxTimeoutMs) {
|
|
962
|
+
return {
|
|
963
|
+
ok: false,
|
|
964
|
+
error: commandError(payload.commandId, "INVALID_COMMAND", `Command timeoutMs (${payload.timeoutMs}) exceeds server limit (${maxTimeoutMs}ms)`)
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
return {
|
|
968
|
+
ok: true,
|
|
969
|
+
timeoutMs: payload.timeoutMs ?? Math.min(state.defaultCommandTimeoutMs, maxTimeoutMs)
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
// src/server/device-presence-handlers.ts
|
|
974
|
+
function buildAccountSnapshot(state, accountId) {
|
|
975
|
+
const devices = state.devicesByAccount.get(accountId);
|
|
976
|
+
const sorted = devices ? [...devices.values()].sort((a, b) => a.deviceId.localeCompare(b.deviceId)).map((record) => ({
|
|
977
|
+
deviceId: record.deviceId,
|
|
978
|
+
name: record.name,
|
|
979
|
+
platform: record.platform,
|
|
980
|
+
connectedAt: record.connectedAt,
|
|
981
|
+
capabilities: [...record.capabilities],
|
|
982
|
+
states: transportResult({ ...record.states })
|
|
983
|
+
})) : [];
|
|
984
|
+
return {
|
|
985
|
+
schemaVersion: 1,
|
|
986
|
+
accountId,
|
|
987
|
+
revision: state.revisionByAccount.get(accountId) ?? 0,
|
|
988
|
+
devices: sorted
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
function emitServerEvent(connection, event, payload) {
|
|
992
|
+
Reflect.apply(connection.events.emit, connection.events, [event, payload]);
|
|
993
|
+
}
|
|
994
|
+
function emitAccountSnapshot(state, accountId) {
|
|
995
|
+
return emitRegistrySnapshot(state, accountId, buildAccountSnapshot, emitServerEvent);
|
|
996
|
+
}
|
|
997
|
+
function detachSocketFromAccount(state, entry) {
|
|
998
|
+
const previousAccountId = entry.accountId;
|
|
999
|
+
const previousDeviceId = entry.deviceId;
|
|
1000
|
+
entry.accountId = null;
|
|
1001
|
+
entry.deviceId = null;
|
|
1002
|
+
if (!previousAccountId)
|
|
1003
|
+
return;
|
|
1004
|
+
const members = state.accountSockets.get(previousAccountId);
|
|
1005
|
+
if (members) {
|
|
1006
|
+
members.delete(entry);
|
|
1007
|
+
if (members.size === 0)
|
|
1008
|
+
state.accountSockets.delete(previousAccountId);
|
|
1009
|
+
}
|
|
1010
|
+
let deviceRemoved = false;
|
|
1011
|
+
if (previousDeviceId) {
|
|
1012
|
+
const devices = state.devicesByAccount.get(previousAccountId);
|
|
1013
|
+
const active = devices?.get(previousDeviceId);
|
|
1014
|
+
if (active && active.socketId === entry.socketId) {
|
|
1015
|
+
devices?.delete(previousDeviceId);
|
|
1016
|
+
unindexDeviceOwner(state, previousDeviceId, previousAccountId);
|
|
1017
|
+
if (devices && devices.size === 0)
|
|
1018
|
+
state.devicesByAccount.delete(previousAccountId);
|
|
1019
|
+
deviceRemoved = true;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
failPendingCommandsForSocket(state, entry.socketId, "Target device disconnected before responding");
|
|
1023
|
+
if (deviceRemoved)
|
|
1024
|
+
emitAccountSnapshot(state, previousAccountId);
|
|
1025
|
+
else
|
|
1026
|
+
cleanupEmptyAccount(state, previousAccountId);
|
|
1027
|
+
}
|
|
1028
|
+
async function syncSocketAccount(state, entry) {
|
|
1029
|
+
let resolved = null;
|
|
1030
|
+
try {
|
|
1031
|
+
const candidate = await state.options.accountOf(entry.connection.raw.data, entry.socketId);
|
|
1032
|
+
resolved = typeof candidate === "string" && candidate.trim().length > 0 ? candidate : null;
|
|
1033
|
+
} catch (error) {
|
|
1034
|
+
state.options.logger?.warn("DevicePresenceServer accountOf threw", { error });
|
|
1035
|
+
resolved = null;
|
|
1036
|
+
}
|
|
1037
|
+
if (state.unbound || entry.disconnected) {
|
|
1038
|
+
detachSocketFromAccount(state, entry);
|
|
1039
|
+
return null;
|
|
1040
|
+
}
|
|
1041
|
+
if (entry.accountId !== resolved) {
|
|
1042
|
+
detachSocketFromAccount(state, entry);
|
|
1043
|
+
if (resolved !== null) {
|
|
1044
|
+
entry.accountId = resolved;
|
|
1045
|
+
let members = state.accountSockets.get(resolved);
|
|
1046
|
+
if (!members) {
|
|
1047
|
+
members = new Set;
|
|
1048
|
+
state.accountSockets.set(resolved, members);
|
|
1049
|
+
}
|
|
1050
|
+
members.add(entry);
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
return resolved;
|
|
1054
|
+
}
|
|
1055
|
+
async function handleAnnounceRequest(state, entry, rawPayload, ack) {
|
|
1056
|
+
const accountId = await syncSocketAccount(state, entry);
|
|
1057
|
+
if (state.unbound || entry.disconnected)
|
|
1058
|
+
return;
|
|
1059
|
+
if (!accountId) {
|
|
1060
|
+
ack(presenceError("FORBIDDEN", "Connection is not authorized for account device presence"));
|
|
1061
|
+
return;
|
|
1062
|
+
}
|
|
1063
|
+
const payload = transportResult(rawPayload);
|
|
1064
|
+
let devices = state.devicesByAccount.get(accountId);
|
|
1065
|
+
if (!devices) {
|
|
1066
|
+
devices = new Map;
|
|
1067
|
+
state.devicesByAccount.set(accountId, devices);
|
|
1068
|
+
}
|
|
1069
|
+
if (entry.deviceId && entry.deviceId !== payload.deviceId) {
|
|
1070
|
+
const prev = devices.get(entry.deviceId);
|
|
1071
|
+
if (prev && prev.socketId === entry.socketId) {
|
|
1072
|
+
devices.delete(entry.deviceId);
|
|
1073
|
+
unindexDeviceOwner(state, entry.deviceId, accountId);
|
|
1074
|
+
failPendingCommandsForSocket(state, entry.socketId, "Target device changed its announced identity");
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
const existing = devices.get(payload.deviceId);
|
|
1078
|
+
if (!existing && devices.size >= state.maxDevicesPerAccount) {
|
|
1079
|
+
ack(presenceError("INVALID_COMMAND", `Account reached maximum online devices (${state.maxDevicesPerAccount})`));
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
if (existing && existing.socketId !== entry.socketId) {
|
|
1083
|
+
const previousSocket = state.sockets.get(existing.socketId);
|
|
1084
|
+
if (previousSocket && previousSocket.deviceId === payload.deviceId) {
|
|
1085
|
+
previousSocket.deviceId = null;
|
|
1086
|
+
}
|
|
1087
|
+
failPendingCommandsForSocket(state, existing.socketId, "Target device reconnected on a newer socket before responding");
|
|
1088
|
+
}
|
|
1089
|
+
const nextStates = payload.states ? { ...payload.states } : existing && existing.socketId === entry.socketId ? { ...existing.states } : {};
|
|
1090
|
+
devices.set(payload.deviceId, {
|
|
1091
|
+
accountId,
|
|
1092
|
+
deviceId: payload.deviceId,
|
|
1093
|
+
socketId: entry.socketId,
|
|
1094
|
+
name: payload.name,
|
|
1095
|
+
platform: payload.platform,
|
|
1096
|
+
connectedAt: new Date(state.now()).toISOString(),
|
|
1097
|
+
capabilities: payload.capabilities ? [...new Set(payload.capabilities)] : [],
|
|
1098
|
+
states: nextStates
|
|
1099
|
+
});
|
|
1100
|
+
indexDeviceOwner(state, payload.deviceId, accountId);
|
|
1101
|
+
entry.deviceId = payload.deviceId;
|
|
1102
|
+
const snapshot = emitAccountSnapshot(state, accountId);
|
|
1103
|
+
ack({ schemaVersion: 1, outcome: "ok", snapshot });
|
|
1104
|
+
}
|
|
1105
|
+
async function handleSetStateRequest(state, entry, rawPayload, ack) {
|
|
1106
|
+
const accountId = await syncSocketAccount(state, entry);
|
|
1107
|
+
if (state.unbound || entry.disconnected)
|
|
1108
|
+
return;
|
|
1109
|
+
if (!accountId) {
|
|
1110
|
+
ack(presenceError("FORBIDDEN", "Connection is not authorized for account device presence"));
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
if (!entry.deviceId) {
|
|
1114
|
+
ack(presenceError("DEVICE_OFFLINE", "Device must announce before publishing capability state"));
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
const active = state.devicesByAccount.get(accountId)?.get(entry.deviceId);
|
|
1118
|
+
if (!active || active.socketId !== entry.socketId) {
|
|
1119
|
+
ack(presenceError("DEVICE_OFFLINE", "Device socket is no longer the active registration for this deviceId"));
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
const payload = transportResult(rawPayload);
|
|
1123
|
+
if (payload.state === null)
|
|
1124
|
+
delete active.states[payload.capability];
|
|
1125
|
+
else
|
|
1126
|
+
active.states[payload.capability] = payload.state;
|
|
1127
|
+
const snapshot = emitAccountSnapshot(state, accountId);
|
|
1128
|
+
ack({ schemaVersion: 1, outcome: "ok", revision: snapshot.revision });
|
|
1129
|
+
}
|
|
1130
|
+
async function handleCommandRequest(state, entry, rawPayload, ack) {
|
|
1131
|
+
const payload = transportResult(rawPayload);
|
|
1132
|
+
const accountId = await syncSocketAccount(state, entry);
|
|
1133
|
+
if (state.unbound || entry.disconnected)
|
|
1134
|
+
return;
|
|
1135
|
+
if (!accountId) {
|
|
1136
|
+
ack(commandError(payload.commandId, "FORBIDDEN", "Connection is not authorized for account device presence"));
|
|
1137
|
+
return;
|
|
1138
|
+
}
|
|
1139
|
+
const scopedKey = pendingCommandKey(accountId, payload.commandId);
|
|
1140
|
+
const limitCheck = validateCommandLimits(state, accountId, scopedKey, payload);
|
|
1141
|
+
if (!limitCheck.ok) {
|
|
1142
|
+
ack(limitCheck.error);
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
const aux = getPresenceAuxIndex(state);
|
|
1146
|
+
const targetRecord = state.devicesByAccount.get(accountId)?.get(payload.targetDeviceId);
|
|
1147
|
+
if (!targetRecord) {
|
|
1148
|
+
const owners = aux.deviceOwners.get(payload.targetDeviceId);
|
|
1149
|
+
const foreignOwner = owners !== undefined && owners.size > 0;
|
|
1150
|
+
ack(commandError(payload.commandId, foreignOwner ? "FORBIDDEN" : "DEVICE_OFFLINE", foreignOwner ? "Caller is not authorized to send commands to this device" : `Target device "${payload.targetDeviceId}" is offline`));
|
|
1151
|
+
return;
|
|
1152
|
+
}
|
|
1153
|
+
const targetSocket = state.sockets.get(targetRecord.socketId);
|
|
1154
|
+
if (!targetSocket || targetSocket.disconnected) {
|
|
1155
|
+
ack(commandError(payload.commandId, "DEVICE_OFFLINE", `Target device "${payload.targetDeviceId}" is offline`));
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
const timeoutMs = limitCheck.timeoutMs;
|
|
1159
|
+
let settled = false;
|
|
1160
|
+
const settle = (result) => {
|
|
1161
|
+
if (settled)
|
|
1162
|
+
return;
|
|
1163
|
+
settled = true;
|
|
1164
|
+
ack({ ...result, commandId: payload.commandId });
|
|
1165
|
+
};
|
|
1166
|
+
const timer = setTimeout(() => {
|
|
1167
|
+
removePendingCommand(state, scopedKey);
|
|
1168
|
+
settle(commandError(payload.commandId, "TIMEOUT", `Target device "${payload.targetDeviceId}" did not respond within ${timeoutMs}ms`));
|
|
1169
|
+
}, timeoutMs);
|
|
1170
|
+
timer.unref?.();
|
|
1171
|
+
state.pendingCommands.set(scopedKey, {
|
|
1172
|
+
accountId,
|
|
1173
|
+
commandId: payload.commandId,
|
|
1174
|
+
capability: payload.capability,
|
|
1175
|
+
targetSocketId: targetSocket.socketId,
|
|
1176
|
+
timer,
|
|
1177
|
+
settle
|
|
1178
|
+
});
|
|
1179
|
+
aux.pendingCountByAccount.set(accountId, (aux.pendingCountByAccount.get(accountId) ?? 0) + 1);
|
|
1180
|
+
const delivery = transportResult({
|
|
1181
|
+
schemaVersion: 1,
|
|
1182
|
+
commandId: payload.commandId,
|
|
1183
|
+
fromDeviceId: entry.deviceId ?? entry.socketId,
|
|
1184
|
+
capability: payload.capability,
|
|
1185
|
+
command: payload.command
|
|
1186
|
+
});
|
|
1187
|
+
emitServerEvent(targetSocket.connection, state.contract.events.commandDeliver, delivery);
|
|
1188
|
+
}
|
|
1189
|
+
function handleCommandResultFrame(state, entry, rawPayload) {
|
|
1190
|
+
if (!entry.accountId)
|
|
1191
|
+
return;
|
|
1192
|
+
const result = transportResult(rawPayload);
|
|
1193
|
+
const scopedKey = pendingCommandKey(entry.accountId, result.commandId);
|
|
1194
|
+
const existing = state.pendingCommands.get(scopedKey);
|
|
1195
|
+
if (!existing || existing.targetSocketId !== entry.socketId)
|
|
1196
|
+
return;
|
|
1197
|
+
const pending = removePendingCommand(state, scopedKey);
|
|
1198
|
+
if (!pending)
|
|
1199
|
+
return;
|
|
1200
|
+
clearTimeout(pending.timer);
|
|
1201
|
+
if (result.outcome === "ok") {
|
|
1202
|
+
const capDef = state.contract.capabilities[pending.capability];
|
|
1203
|
+
if (capDef?.result) {
|
|
1204
|
+
const parsed = capDef.result.safeParse(result.result);
|
|
1205
|
+
if (!parsed.success) {
|
|
1206
|
+
pending.settle(commandError(result.commandId, "HANDLER_ERROR", `Target device returned invalid result for capability "${pending.capability}"`));
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
pending.settle({
|
|
1210
|
+
schemaVersion: 1,
|
|
1211
|
+
commandId: result.commandId,
|
|
1212
|
+
outcome: "ok",
|
|
1213
|
+
result: parsed.data
|
|
1214
|
+
});
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
pending.settle(result);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
// src/server/device-presence.ts
|
|
1222
|
+
var DEFAULT_MAX_DEVICES_PER_ACCOUNT = 64;
|
|
1223
|
+
function bindDevicePresence(contract, handle, options) {
|
|
1224
|
+
const defaultCommandTimeoutMs = options.commandTimeoutMs ?? DEFAULT_DEVICE_PRESENCE_COMMAND_TIMEOUT_MS2;
|
|
1225
|
+
const maxDevicesPerAccount = options.maxDevicesPerAccount ?? DEFAULT_MAX_DEVICES_PER_ACCOUNT;
|
|
1226
|
+
assertTimerMs("DevicePresenceServerOptions.commandTimeoutMs", defaultCommandTimeoutMs);
|
|
1227
|
+
assertPositiveSafeInteger("DevicePresenceServerOptions.maxDevicesPerAccount", maxDevicesPerAccount);
|
|
1228
|
+
const server = bindRealtimeServer2(contract.realtime, handle, {
|
|
1229
|
+
...options.onRejected && { onRejected: options.onRejected },
|
|
1230
|
+
...options.logger && { logger: options.logger }
|
|
1231
|
+
});
|
|
1232
|
+
const state = {
|
|
1233
|
+
contract,
|
|
1234
|
+
options,
|
|
1235
|
+
defaultCommandTimeoutMs,
|
|
1236
|
+
maxDevicesPerAccount,
|
|
1237
|
+
now: options.now ?? (() => Date.now()),
|
|
1238
|
+
sockets: new Map,
|
|
1239
|
+
accountSockets: new Map,
|
|
1240
|
+
devicesByAccount: new Map,
|
|
1241
|
+
revisionByAccount: new Map,
|
|
1242
|
+
pendingCommands: new Map,
|
|
1243
|
+
unbound: false
|
|
1244
|
+
};
|
|
1245
|
+
const stopConnections = server.onConnection((connection) => {
|
|
1246
|
+
if (state.unbound)
|
|
1247
|
+
return;
|
|
1248
|
+
const entry = {
|
|
1249
|
+
socketId: connection.raw.id,
|
|
1250
|
+
connection,
|
|
1251
|
+
accountId: null,
|
|
1252
|
+
deviceId: null,
|
|
1253
|
+
disconnected: false,
|
|
1254
|
+
cleanups: []
|
|
1255
|
+
};
|
|
1256
|
+
state.sockets.set(entry.socketId, entry);
|
|
1257
|
+
const onDisconnect = () => {
|
|
1258
|
+
if (entry.disconnected)
|
|
1259
|
+
return;
|
|
1260
|
+
entry.disconnected = true;
|
|
1261
|
+
for (const cleanup of entry.cleanups)
|
|
1262
|
+
cleanup();
|
|
1263
|
+
entry.cleanups.length = 0;
|
|
1264
|
+
state.sockets.delete(entry.socketId);
|
|
1265
|
+
detachSocketFromAccount(state, entry);
|
|
1266
|
+
};
|
|
1267
|
+
connection.raw.on("disconnect", onDisconnect);
|
|
1268
|
+
entry.cleanups.push(() => {
|
|
1269
|
+
connection.raw.off("disconnect", onDisconnect);
|
|
1270
|
+
});
|
|
1271
|
+
entry.cleanups.push(connection.events.on(contract.events.announce, (payload, ack) => {
|
|
1272
|
+
handleAnnounceRequest(state, entry, payload, transportResult(ack));
|
|
1273
|
+
}), connection.events.on(contract.events.setState, (payload, ack) => {
|
|
1274
|
+
handleSetStateRequest(state, entry, payload, transportResult(ack));
|
|
1275
|
+
}), connection.events.on(contract.events.sendCommand, (payload, ack) => {
|
|
1276
|
+
handleCommandRequest(state, entry, payload, transportResult(ack));
|
|
1277
|
+
}), connection.events.on(contract.events.commandResult, (payload) => {
|
|
1278
|
+
handleCommandResultFrame(state, entry, payload);
|
|
1279
|
+
}));
|
|
1280
|
+
syncSocketAccount(state, entry).then((accountId) => {
|
|
1281
|
+
if (!accountId || state.unbound || entry.disconnected)
|
|
1282
|
+
return;
|
|
1283
|
+
emitServerEvent(connection, contract.events.snapshot, buildAccountSnapshot(state, accountId));
|
|
1284
|
+
});
|
|
1285
|
+
});
|
|
1286
|
+
return {
|
|
1287
|
+
getAccountSnapshot: (accountId) => buildAccountSnapshot(state, accountId),
|
|
1288
|
+
listDevices: (accountId) => buildAccountSnapshot(state, accountId).devices,
|
|
1289
|
+
snapshot() {
|
|
1290
|
+
const accounts = {};
|
|
1291
|
+
const keys = new Set([...state.accountSockets.keys(), ...state.devicesByAccount.keys()]);
|
|
1292
|
+
for (const accountId of [...keys].sort()) {
|
|
1293
|
+
accounts[accountId] = buildAccountSnapshot(state, accountId);
|
|
1294
|
+
}
|
|
1295
|
+
return {
|
|
1296
|
+
accounts,
|
|
1297
|
+
activeSockets: state.sockets.size,
|
|
1298
|
+
pendingCommands: state.pendingCommands.size
|
|
1299
|
+
};
|
|
1300
|
+
},
|
|
1301
|
+
async readmit(socketId) {
|
|
1302
|
+
const entry = state.sockets.get(socketId);
|
|
1303
|
+
if (!entry || entry.disconnected || state.unbound)
|
|
1304
|
+
return;
|
|
1305
|
+
const previousAccountId = entry.accountId;
|
|
1306
|
+
const nextAccountId = await syncSocketAccount(state, entry);
|
|
1307
|
+
if (nextAccountId && nextAccountId !== previousAccountId && !entry.disconnected && !state.unbound) {
|
|
1308
|
+
emitServerEvent(entry.connection, contract.events.snapshot, buildAccountSnapshot(state, nextAccountId));
|
|
1309
|
+
}
|
|
1310
|
+
},
|
|
1311
|
+
unbind() {
|
|
1312
|
+
if (state.unbound)
|
|
1313
|
+
return;
|
|
1314
|
+
state.unbound = true;
|
|
1315
|
+
stopConnections();
|
|
1316
|
+
for (const [scopedKey, pending] of [...state.pendingCommands]) {
|
|
1317
|
+
removePendingCommand(state, scopedKey);
|
|
1318
|
+
clearTimeout(pending.timer);
|
|
1319
|
+
pending.settle(commandError(pending.commandId, "DEVICE_OFFLINE", "Device presence server unbound before command completed"));
|
|
1320
|
+
}
|
|
1321
|
+
for (const entry of [...state.sockets.values()]) {
|
|
1322
|
+
entry.disconnected = true;
|
|
1323
|
+
for (const cleanup of entry.cleanups)
|
|
1324
|
+
cleanup();
|
|
1325
|
+
entry.cleanups.length = 0;
|
|
1326
|
+
}
|
|
1327
|
+
state.sockets.clear();
|
|
1328
|
+
state.accountSockets.clear();
|
|
1329
|
+
state.devicesByAccount.clear();
|
|
1330
|
+
state.revisionByAccount.clear();
|
|
1331
|
+
const aux = getPresenceAuxIndex(state);
|
|
1332
|
+
aux.deviceOwners.clear();
|
|
1333
|
+
aux.pendingCountByAccount.clear();
|
|
1334
|
+
}
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
832
1337
|
// src/server/event-bus.ts
|
|
833
1338
|
function isDecision(value) {
|
|
834
1339
|
if (typeof value !== "object" || value === null)
|
|
@@ -2039,6 +2544,7 @@ export {
|
|
|
2039
2544
|
ShutdownStatusSchema2 as ShutdownStatusSchema,
|
|
2040
2545
|
UnixClientTransportError2 as UnixClientTransportError,
|
|
2041
2546
|
badRequest2 as badRequest,
|
|
2547
|
+
bindDevicePresence,
|
|
2042
2548
|
bindProcessSignals2 as bindProcessSignals,
|
|
2043
2549
|
bindRealtimeServer2 as bindRealtimeServer,
|
|
2044
2550
|
bindReleaseRefreshSignal,
|