dotdo 0.0.1 → 0.1.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/LICENSE +1 -1
- package/README.md +446 -315
- package/cli/README.md +238 -0
- package/cli/agent.ts +72 -0
- package/cli/bin.js +44 -0
- package/cli/bin.ts +38 -0
- package/cli/build.ts +157 -0
- package/cli/commands/auth/login.ts +14 -0
- package/cli/commands/auth/logout.ts +6 -0
- package/cli/commands/auth/whoami.ts +16 -0
- package/cli/commands/deploy-multi.ts +245 -0
- package/cli/commands/dev/deploy.ts +100 -0
- package/cli/commands/dev/dev.ts +95 -0
- package/cli/commands/dev/logs.ts +91 -0
- package/cli/commands/dev-local.ts +88 -0
- package/cli/commands/do-ops.ts +314 -0
- package/cli/commands/index.ts +100 -0
- package/cli/commands/init.ts +247 -0
- package/cli/commands/introspect/emitter.ts +315 -0
- package/cli/commands/introspect/index.ts +193 -0
- package/cli/commands/link.ts +598 -0
- package/cli/commands/snippets.ts +415 -0
- package/cli/commands/tunnel.ts +239 -0
- package/cli/device-auth.ts +289 -0
- package/cli/fallback.ts +12 -0
- package/cli/index.ts +121 -0
- package/cli/main.ts +246 -0
- package/cli/mcp-stdio.ts +790 -0
- package/cli/package.json +62 -0
- package/cli/runtime/do-registry.ts +193 -0
- package/cli/runtime/embedded-db.ts +344 -0
- package/cli/runtime/index.ts +9 -0
- package/cli/runtime/miniflare-adapter.ts +162 -0
- package/cli/sandbox.ts +82 -0
- package/cli/src/args.ts +174 -0
- package/cli/src/auth.ts +55 -0
- package/cli/src/commands/call.ts +84 -0
- package/cli/src/commands/charge.ts +96 -0
- package/cli/src/commands/config.ts +115 -0
- package/cli/src/commands/email.ts +112 -0
- package/cli/src/commands/llm.ts +115 -0
- package/cli/src/commands/queue.ts +134 -0
- package/cli/src/commands/text.ts +86 -0
- package/cli/src/config.ts +185 -0
- package/cli/src/output.ts +246 -0
- package/cli/src/rpc.ts +192 -0
- package/cli/utils/config.ts +282 -0
- package/cli/utils/detect.ts +73 -0
- package/cli/utils/index.ts +15 -0
- package/cli/utils/logger.ts +232 -0
- package/dist/ai/index.js +19 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/template-literals.js +852 -0
- package/dist/ai/template-literals.js.map +1 -0
- package/dist/api/middleware/auth-federation.js +573 -0
- package/dist/api/middleware/auth-federation.js.map +1 -0
- package/dist/api/middleware/auth.js +545 -0
- package/dist/api/middleware/auth.js.map +1 -0
- package/dist/db/actions.js +212 -0
- package/dist/db/actions.js.map +1 -0
- package/dist/db/auth.js +506 -0
- package/dist/db/auth.js.map +1 -0
- package/dist/db/branches.js +65 -0
- package/dist/db/branches.js.map +1 -0
- package/dist/db/clickhouse.js +1074 -0
- package/dist/db/clickhouse.js.map +1 -0
- package/dist/db/dlq.js +39 -0
- package/dist/db/dlq.js.map +1 -0
- package/dist/db/events.js +28 -0
- package/dist/db/events.js.map +1 -0
- package/dist/db/exec.js +64 -0
- package/dist/db/exec.js.map +1 -0
- package/dist/db/files.js +85 -0
- package/dist/db/files.js.map +1 -0
- package/dist/db/flags.js +24 -0
- package/dist/db/flags.js.map +1 -0
- package/dist/db/git.js +116 -0
- package/dist/db/git.js.map +1 -0
- package/dist/db/iceberg/inverted-index.js +862 -0
- package/dist/db/iceberg/inverted-index.js.map +1 -0
- package/dist/db/iceberg/puffin.js +878 -0
- package/dist/db/iceberg/puffin.js.map +1 -0
- package/dist/db/iceberg/search-manifest.js +422 -0
- package/dist/db/iceberg/search-manifest.js.map +1 -0
- package/dist/db/iceberg/types.js +8 -0
- package/dist/db/iceberg/types.js.map +1 -0
- package/dist/db/index.js +121 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/integrations.js +368 -0
- package/dist/db/integrations.js.map +1 -0
- package/dist/db/json-indexes.js +332 -0
- package/dist/db/json-indexes.js.map +1 -0
- package/dist/db/linked-accounts.js +287 -0
- package/dist/db/linked-accounts.js.map +1 -0
- package/dist/db/nouns.js +183 -0
- package/dist/db/nouns.js.map +1 -0
- package/dist/db/objects.js +170 -0
- package/dist/db/objects.js.map +1 -0
- package/dist/db/primitives/dag-scheduler/index.js +869 -0
- package/dist/db/primitives/dag-scheduler/index.js.map +1 -0
- package/dist/db/primitives/exactly-once-context.js +237 -0
- package/dist/db/primitives/exactly-once-context.js.map +1 -0
- package/dist/db/primitives/index.js +62 -0
- package/dist/db/primitives/index.js.map +1 -0
- package/dist/db/primitives/keyed-router.js +145 -0
- package/dist/db/primitives/keyed-router.js.map +1 -0
- package/dist/db/primitives/observability.js +162 -0
- package/dist/db/primitives/observability.js.map +1 -0
- package/dist/db/primitives/schema-evolution.js +643 -0
- package/dist/db/primitives/schema-evolution.js.map +1 -0
- package/dist/db/primitives/stateful-operator/index.js +770 -0
- package/dist/db/primitives/stateful-operator/index.js.map +1 -0
- package/dist/db/primitives/temporal-store.js +306 -0
- package/dist/db/primitives/temporal-store.js.map +1 -0
- package/dist/db/primitives/typed-column-store.js +1229 -0
- package/dist/db/primitives/typed-column-store.js.map +1 -0
- package/dist/db/primitives/utils/duration.js +162 -0
- package/dist/db/primitives/utils/duration.js.map +1 -0
- package/dist/db/primitives/utils/murmur3.js +116 -0
- package/dist/db/primitives/utils/murmur3.js.map +1 -0
- package/dist/db/primitives/watermark-service.js +136 -0
- package/dist/db/primitives/watermark-service.js.map +1 -0
- package/dist/db/primitives/window-manager.js +764 -0
- package/dist/db/primitives/window-manager.js.map +1 -0
- package/dist/db/relationships.js +66 -0
- package/dist/db/relationships.js.map +1 -0
- package/dist/db/schema-minimal.js +61 -0
- package/dist/db/schema-minimal.js.map +1 -0
- package/dist/db/search.js +28 -0
- package/dist/db/search.js.map +1 -0
- package/dist/db/stores.js +1665 -0
- package/dist/db/stores.js.map +1 -0
- package/dist/db/things.js +297 -0
- package/dist/db/things.js.map +1 -0
- package/dist/db/vault.js +171 -0
- package/dist/db/vault.js.map +1 -0
- package/dist/db/verbs.js +102 -0
- package/dist/db/verbs.js.map +1 -0
- package/dist/do/base.js +48 -0
- package/dist/do/base.js.map +1 -0
- package/dist/do/tiny.js +31 -0
- package/dist/do/tiny.js.map +1 -0
- package/dist/lib/DOAuth.js +261 -0
- package/dist/lib/DOAuth.js.map +1 -0
- package/dist/lib/DODispatcher.js +72 -0
- package/dist/lib/DODispatcher.js.map +1 -0
- package/dist/lib/Modifier.js +189 -0
- package/dist/lib/Modifier.js.map +1 -0
- package/dist/lib/StateStorage.js +403 -0
- package/dist/lib/StateStorage.js.map +1 -0
- package/dist/lib/TypeRegistry.js +122 -0
- package/dist/lib/TypeRegistry.js.map +1 -0
- package/dist/lib/ai/gateway.js +247 -0
- package/dist/lib/ai/gateway.js.map +1 -0
- package/dist/lib/ai/tool-loop-agent.js +591 -0
- package/dist/lib/ai/tool-loop-agent.js.map +1 -0
- package/dist/lib/auto-wiring.js +439 -0
- package/dist/lib/auto-wiring.js.map +1 -0
- package/dist/lib/browse/browserbase.js +163 -0
- package/dist/lib/browse/browserbase.js.map +1 -0
- package/dist/lib/browse/cloudflare.js +144 -0
- package/dist/lib/browse/cloudflare.js.map +1 -0
- package/dist/lib/browse/index.js +62 -0
- package/dist/lib/browse/index.js.map +1 -0
- package/dist/lib/browse/types.js +13 -0
- package/dist/lib/browse/types.js.map +1 -0
- package/dist/lib/cache/index.js +37 -0
- package/dist/lib/cache/index.js.map +1 -0
- package/dist/lib/cache/visibility.js +638 -0
- package/dist/lib/cache/visibility.js.map +1 -0
- package/dist/lib/capabilities.js +268 -0
- package/dist/lib/capabilities.js.map +1 -0
- package/dist/lib/channels/base.js +106 -0
- package/dist/lib/channels/base.js.map +1 -0
- package/dist/lib/channels/discord.js +94 -0
- package/dist/lib/channels/discord.js.map +1 -0
- package/dist/lib/channels/email.js +204 -0
- package/dist/lib/channels/email.js.map +1 -0
- package/dist/lib/channels/index.js +90 -0
- package/dist/lib/channels/index.js.map +1 -0
- package/dist/lib/channels/mdxui-chat.js +95 -0
- package/dist/lib/channels/mdxui-chat.js.map +1 -0
- package/dist/lib/channels/slack-blockkit.js +121 -0
- package/dist/lib/channels/slack-blockkit.js.map +1 -0
- package/dist/lib/channels/types.js +7 -0
- package/dist/lib/channels/types.js.map +1 -0
- package/dist/lib/cloudflare/ai.js +654 -0
- package/dist/lib/cloudflare/ai.js.map +1 -0
- package/dist/lib/cloudflare/index.js +88 -0
- package/dist/lib/cloudflare/index.js.map +1 -0
- package/dist/lib/cloudflare/kv.js +342 -0
- package/dist/lib/cloudflare/kv.js.map +1 -0
- package/dist/lib/cloudflare/queues.js +434 -0
- package/dist/lib/cloudflare/queues.js.map +1 -0
- package/dist/lib/cloudflare/r2.js +604 -0
- package/dist/lib/cloudflare/r2.js.map +1 -0
- package/dist/lib/cloudflare/vectorize.js +494 -0
- package/dist/lib/cloudflare/vectorize.js.map +1 -0
- package/dist/lib/cloudflare/workflows.js +569 -0
- package/dist/lib/cloudflare/workflows.js.map +1 -0
- package/dist/lib/colo/caching.js +196 -0
- package/dist/lib/colo/caching.js.map +1 -0
- package/dist/lib/colo/detection.js +194 -0
- package/dist/lib/colo/detection.js.map +1 -0
- package/dist/lib/colo/external-data.js +219 -0
- package/dist/lib/colo/external-data.js.map +1 -0
- package/dist/lib/colo/globe-data.js +179 -0
- package/dist/lib/colo/globe-data.js.map +1 -0
- package/dist/lib/colo/index.js +16 -0
- package/dist/lib/colo/index.js.map +1 -0
- package/dist/lib/decorators.js +37 -0
- package/dist/lib/decorators.js.map +1 -0
- package/dist/lib/discovery.js +81 -0
- package/dist/lib/discovery.js.map +1 -0
- package/dist/lib/executors/AgenticFunctionExecutor.js +619 -0
- package/dist/lib/executors/AgenticFunctionExecutor.js.map +1 -0
- package/dist/lib/executors/BaseFunctionExecutor.js +328 -0
- package/dist/lib/executors/BaseFunctionExecutor.js.map +1 -0
- package/dist/lib/executors/CascadeExecutor.js +418 -0
- package/dist/lib/executors/CascadeExecutor.js.map +1 -0
- package/dist/lib/executors/CodeFunctionExecutor.js +904 -0
- package/dist/lib/executors/CodeFunctionExecutor.js.map +1 -0
- package/dist/lib/executors/GenerativeFunctionExecutor.js +904 -0
- package/dist/lib/executors/GenerativeFunctionExecutor.js.map +1 -0
- package/dist/lib/executors/HumanFunctionExecutor.js +884 -0
- package/dist/lib/executors/HumanFunctionExecutor.js.map +1 -0
- package/dist/lib/executors/ParallelStepExecutor.js +308 -0
- package/dist/lib/executors/ParallelStepExecutor.js.map +1 -0
- package/dist/lib/executors/types.js +12 -0
- package/dist/lib/executors/types.js.map +1 -0
- package/dist/lib/experiments.js +89 -0
- package/dist/lib/experiments.js.map +1 -0
- package/dist/lib/flags/store.js +262 -0
- package/dist/lib/flags/store.js.map +1 -0
- package/dist/lib/functions/FunctionComposition.js +467 -0
- package/dist/lib/functions/FunctionComposition.js.map +1 -0
- package/dist/lib/functions/FunctionMiddleware.js +457 -0
- package/dist/lib/functions/FunctionMiddleware.js.map +1 -0
- package/dist/lib/functions/FunctionRegistry.js +426 -0
- package/dist/lib/functions/FunctionRegistry.js.map +1 -0
- package/dist/lib/functions/createFunction.js +1048 -0
- package/dist/lib/functions/createFunction.js.map +1 -0
- package/dist/lib/humans/index.js +68 -0
- package/dist/lib/humans/index.js.map +1 -0
- package/dist/lib/humans/templates.js +117 -0
- package/dist/lib/humans/templates.js.map +1 -0
- package/dist/lib/identity.js +98 -0
- package/dist/lib/identity.js.map +1 -0
- package/dist/lib/index.js +9 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/logging/error-logger.js +163 -0
- package/dist/lib/logging/error-logger.js.map +1 -0
- package/dist/lib/logging/index.js +160 -0
- package/dist/lib/logging/index.js.map +1 -0
- package/dist/lib/mixins/bash.js +753 -0
- package/dist/lib/mixins/bash.js.map +1 -0
- package/dist/lib/mixins/fs.js +648 -0
- package/dist/lib/mixins/fs.js.map +1 -0
- package/dist/lib/mixins/git.js +1006 -0
- package/dist/lib/mixins/git.js.map +1 -0
- package/dist/lib/mixins/npm.js +662 -0
- package/dist/lib/mixins/npm.js.map +1 -0
- package/dist/lib/noun-id.js +278 -0
- package/dist/lib/noun-id.js.map +1 -0
- package/dist/lib/rate-limit/sliding-window.js +148 -0
- package/dist/lib/rate-limit/sliding-window.js.map +1 -0
- package/dist/lib/rate-limit.js +110 -0
- package/dist/lib/rate-limit.js.map +1 -0
- package/dist/lib/rpc/bindings.js +548 -0
- package/dist/lib/rpc/bindings.js.map +1 -0
- package/dist/lib/rpc/index.js +64 -0
- package/dist/lib/rpc/index.js.map +1 -0
- package/dist/lib/safe-stringify.js +223 -0
- package/dist/lib/safe-stringify.js.map +1 -0
- package/dist/lib/sandbox/miniflare-sandbox.js +1007 -0
- package/dist/lib/sandbox/miniflare-sandbox.js.map +1 -0
- package/dist/lib/sqids.js +110 -0
- package/dist/lib/sqids.js.map +1 -0
- package/dist/lib/sql/adapters/index.js +10 -0
- package/dist/lib/sql/adapters/index.js.map +1 -0
- package/dist/lib/sql/adapters/node-sql-parser.js +552 -0
- package/dist/lib/sql/adapters/node-sql-parser.js.map +1 -0
- package/dist/lib/sql/adapters/pgsql-parser.js +1190 -0
- package/dist/lib/sql/adapters/pgsql-parser.js.map +1 -0
- package/dist/lib/sql/index.js +277 -0
- package/dist/lib/sql/index.js.map +1 -0
- package/dist/lib/sql/types.js +56 -0
- package/dist/lib/sql/types.js.map +1 -0
- package/dist/lib/type-classifier.js +126 -0
- package/dist/lib/type-classifier.js.map +1 -0
- package/dist/lib/utils/html.js +47 -0
- package/dist/lib/utils/html.js.map +1 -0
- package/dist/lib/validation.js +48 -0
- package/dist/lib/validation.js.map +1 -0
- package/dist/lib/vault/store.js +411 -0
- package/dist/lib/vault/store.js.map +1 -0
- package/dist/metrics/hunch.js +739 -0
- package/dist/metrics/hunch.js.map +1 -0
- package/dist/objects/API.js +302 -0
- package/dist/objects/API.js.map +1 -0
- package/dist/objects/Agent.js +179 -0
- package/dist/objects/Agent.js.map +1 -0
- package/dist/objects/AgenticFunctionExecutor.js +8 -0
- package/dist/objects/AgenticFunctionExecutor.js.map +1 -0
- package/dist/objects/App.js +83 -0
- package/dist/objects/App.js.map +1 -0
- package/dist/objects/Browser.js +884 -0
- package/dist/objects/Browser.js.map +1 -0
- package/dist/objects/Business.js +107 -0
- package/dist/objects/Business.js.map +1 -0
- package/dist/objects/CLI.js +221 -0
- package/dist/objects/CLI.js.map +1 -0
- package/dist/objects/CodeFunctionExecutor.js +8 -0
- package/dist/objects/CodeFunctionExecutor.js.map +1 -0
- package/dist/objects/Collection.js +161 -0
- package/dist/objects/Collection.js.map +1 -0
- package/dist/objects/DO.js +41 -0
- package/dist/objects/DO.js.map +1 -0
- package/dist/objects/DOBase.js +2309 -0
- package/dist/objects/DOBase.js.map +1 -0
- package/dist/objects/DOCache.js +153 -0
- package/dist/objects/DOCache.js.map +1 -0
- package/dist/objects/DOFull.js +1676 -0
- package/dist/objects/DOFull.js.map +1 -0
- package/dist/objects/DOTiny.js +207 -0
- package/dist/objects/DOTiny.js.map +1 -0
- package/dist/objects/Directory.js +199 -0
- package/dist/objects/Directory.js.map +1 -0
- package/dist/objects/Entity.js +413 -0
- package/dist/objects/Entity.js.map +1 -0
- package/dist/objects/Function.js +116 -0
- package/dist/objects/Function.js.map +1 -0
- package/dist/objects/Human.js +231 -0
- package/dist/objects/Human.js.map +1 -0
- package/dist/objects/HumanFunctionExecutor.js +8 -0
- package/dist/objects/HumanFunctionExecutor.js.map +1 -0
- package/dist/objects/IcebergMetadataDO.js +938 -0
- package/dist/objects/IcebergMetadataDO.js.map +1 -0
- package/dist/objects/IntegrationsDO.js +1174 -0
- package/dist/objects/IntegrationsDO.js.map +1 -0
- package/dist/objects/ObservabilityBroadcaster.js +149 -0
- package/dist/objects/ObservabilityBroadcaster.js.map +1 -0
- package/dist/objects/Package.js +154 -0
- package/dist/objects/Package.js.map +1 -0
- package/dist/objects/Product.js +193 -0
- package/dist/objects/Product.js.map +1 -0
- package/dist/objects/SDK.js +152 -0
- package/dist/objects/SDK.js.map +1 -0
- package/dist/objects/SaaS.js +235 -0
- package/dist/objects/SaaS.js.map +1 -0
- package/dist/objects/SandboxDO.js +759 -0
- package/dist/objects/SandboxDO.js.map +1 -0
- package/dist/objects/Service.js +337 -0
- package/dist/objects/Service.js.map +1 -0
- package/dist/objects/Site.js +80 -0
- package/dist/objects/Site.js.map +1 -0
- package/dist/objects/Startup.js +479 -0
- package/dist/objects/Startup.js.map +1 -0
- package/dist/objects/ThingsDO.js +170 -0
- package/dist/objects/ThingsDO.js.map +1 -0
- package/dist/objects/VectorShardDO.js +650 -0
- package/dist/objects/VectorShardDO.js.map +1 -0
- package/dist/objects/Worker.js +144 -0
- package/dist/objects/Worker.js.map +1 -0
- package/dist/objects/Workflow.js +196 -0
- package/dist/objects/Workflow.js.map +1 -0
- package/dist/objects/WorkflowFactory.js +313 -0
- package/dist/objects/WorkflowFactory.js.map +1 -0
- package/dist/objects/WorkflowRuntime.js +863 -0
- package/dist/objects/WorkflowRuntime.js.map +1 -0
- package/dist/objects/circuit-breaker-bulkhead.js +178 -0
- package/dist/objects/circuit-breaker-bulkhead.js.map +1 -0
- package/dist/objects/createFunction.js +934 -0
- package/dist/objects/createFunction.js.map +1 -0
- package/dist/objects/index.js +80 -0
- package/dist/objects/index.js.map +1 -0
- package/dist/objects/lifecycle/Branch.js +275 -0
- package/dist/objects/lifecycle/Branch.js.map +1 -0
- package/dist/objects/lifecycle/Clone.js +1499 -0
- package/dist/objects/lifecycle/Clone.js.map +1 -0
- package/dist/objects/lifecycle/Compact.js +237 -0
- package/dist/objects/lifecycle/Compact.js.map +1 -0
- package/dist/objects/lifecycle/Promote.js +476 -0
- package/dist/objects/lifecycle/Promote.js.map +1 -0
- package/dist/objects/lifecycle/Shard.js +560 -0
- package/dist/objects/lifecycle/Shard.js.map +1 -0
- package/dist/objects/lifecycle/index.js +15 -0
- package/dist/objects/lifecycle/index.js.map +1 -0
- package/dist/objects/lifecycle/types.js +33 -0
- package/dist/objects/lifecycle/types.js.map +1 -0
- package/dist/objects/mixins/infrastructure.js +171 -0
- package/dist/objects/mixins/infrastructure.js.map +1 -0
- package/dist/objects/modules/StoresModule.js +153 -0
- package/dist/objects/modules/StoresModule.js.map +1 -0
- package/dist/objects/persistence/checkpoint-manager.js +606 -0
- package/dist/objects/persistence/checkpoint-manager.js.map +1 -0
- package/dist/objects/persistence/index.js +72 -0
- package/dist/objects/persistence/index.js.map +1 -0
- package/dist/objects/persistence/migration-runner.js +562 -0
- package/dist/objects/persistence/migration-runner.js.map +1 -0
- package/dist/objects/persistence/replication-manager.js +501 -0
- package/dist/objects/persistence/replication-manager.js.map +1 -0
- package/dist/objects/persistence/tiered-storage-manager.js +595 -0
- package/dist/objects/persistence/tiered-storage-manager.js.map +1 -0
- package/dist/objects/persistence/types.js +14 -0
- package/dist/objects/persistence/types.js.map +1 -0
- package/dist/objects/persistence/wal-manager.js +653 -0
- package/dist/objects/persistence/wal-manager.js.map +1 -0
- package/dist/objects/presets/index.js +20 -0
- package/dist/objects/presets/index.js.map +1 -0
- package/dist/objects/presets/primitives.js +188 -0
- package/dist/objects/presets/primitives.js.map +1 -0
- package/dist/objects/primitives/alarm-adapter.js +141 -0
- package/dist/objects/primitives/alarm-adapter.js.map +1 -0
- package/dist/objects/primitives/index.js +337 -0
- package/dist/objects/primitives/index.js.map +1 -0
- package/dist/objects/primitives/storage-adapter.js +182 -0
- package/dist/objects/primitives/storage-adapter.js.map +1 -0
- package/dist/objects/primitives/with-primitives.js +102 -0
- package/dist/objects/primitives/with-primitives.js.map +1 -0
- package/dist/objects/services/StoreManager.js +227 -0
- package/dist/objects/services/StoreManager.js.map +1 -0
- package/dist/objects/services/index.js +13 -0
- package/dist/objects/services/index.js.map +1 -0
- package/dist/objects/transport/auth-layer.js +1451 -0
- package/dist/objects/transport/auth-layer.js.map +1 -0
- package/dist/objects/transport/capnweb-target.js +355 -0
- package/dist/objects/transport/capnweb-target.js.map +1 -0
- package/dist/objects/transport/chain.js +441 -0
- package/dist/objects/transport/chain.js.map +1 -0
- package/dist/objects/transport/handler.js +58 -0
- package/dist/objects/transport/handler.js.map +1 -0
- package/dist/objects/transport/index.js +53 -0
- package/dist/objects/transport/index.js.map +1 -0
- package/dist/objects/transport/mcp-server.js +691 -0
- package/dist/objects/transport/mcp-server.js.map +1 -0
- package/dist/objects/transport/rest-autowire.js +1508 -0
- package/dist/objects/transport/rest-autowire.js.map +1 -0
- package/dist/objects/transport/rest-router.js +440 -0
- package/dist/objects/transport/rest-router.js.map +1 -0
- package/dist/objects/transport/rpc-server.js +1539 -0
- package/dist/objects/transport/rpc-server.js.map +1 -0
- package/dist/objects/transport/shared.js +576 -0
- package/dist/objects/transport/shared.js.map +1 -0
- package/dist/objects/transport/sync-engine.js +291 -0
- package/dist/objects/transport/sync-engine.js.map +1 -0
- package/dist/objects/transport/types.js +8 -0
- package/dist/objects/transport/types.js.map +1 -0
- package/dist/sandbox/index.js +258 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/snippets/artifacts-config.js +241 -0
- package/dist/snippets/artifacts-config.js.map +1 -0
- package/dist/snippets/artifacts-ingest.js +832 -0
- package/dist/snippets/artifacts-ingest.js.map +1 -0
- package/dist/snippets/artifacts-serve.js +1035 -0
- package/dist/snippets/artifacts-serve.js.map +1 -0
- package/dist/snippets/artifacts-types.js +161 -0
- package/dist/snippets/artifacts-types.js.map +1 -0
- package/dist/snippets/cache-probe.js +376 -0
- package/dist/snippets/cache-probe.js.map +1 -0
- package/dist/snippets/cache.js +10 -0
- package/dist/snippets/cache.js.map +1 -0
- package/dist/snippets/events.js +469 -0
- package/dist/snippets/events.js.map +1 -0
- package/dist/snippets/index.js +7 -0
- package/dist/snippets/index.js.map +1 -0
- package/dist/snippets/proxy.js +495 -0
- package/dist/snippets/proxy.js.map +1 -0
- package/dist/snippets/search.js +1759 -0
- package/dist/snippets/search.js.map +1 -0
- package/dist/streams/index.js +30 -0
- package/dist/streams/index.js.map +1 -0
- package/dist/streams/observability.js +68 -0
- package/dist/streams/observability.js.map +1 -0
- package/dist/types/AI.js +92 -0
- package/dist/types/AI.js.map +1 -0
- package/dist/types/AIFunction.js +171 -0
- package/dist/types/AIFunction.js.map +1 -0
- package/dist/types/BrowseVerb.js +89 -0
- package/dist/types/BrowseVerb.js.map +1 -0
- package/dist/types/Browser.js +31 -0
- package/dist/types/Browser.js.map +1 -0
- package/dist/types/Chaos.js +15 -0
- package/dist/types/Chaos.js.map +1 -0
- package/dist/types/CloudflareBindings.js +109 -0
- package/dist/types/CloudflareBindings.js.map +1 -0
- package/dist/types/Collection.js +50 -0
- package/dist/types/Collection.js.map +1 -0
- package/dist/types/DO.js +2 -0
- package/dist/types/DO.js.map +1 -0
- package/dist/types/DOLocation.js +63 -0
- package/dist/types/DOLocation.js.map +1 -0
- package/dist/types/EventHandler.js +57 -0
- package/dist/types/EventHandler.js.map +1 -0
- package/dist/types/Experiment.js +33 -0
- package/dist/types/Experiment.js.map +1 -0
- package/dist/types/Flag.js +57 -0
- package/dist/types/Flag.js.map +1 -0
- package/dist/types/Lifecycle.js +13 -0
- package/dist/types/Lifecycle.js.map +1 -0
- package/dist/types/Location.js +169 -0
- package/dist/types/Location.js.map +1 -0
- package/dist/types/Noun.js +66 -0
- package/dist/types/Noun.js.map +1 -0
- package/dist/types/SessionEvent.js +194 -0
- package/dist/types/SessionEvent.js.map +1 -0
- package/dist/types/Thing.js +55 -0
- package/dist/types/Thing.js.map +1 -0
- package/dist/types/ThingDO.js +153 -0
- package/dist/types/ThingDO.js.map +1 -0
- package/dist/types/Things.js +2 -0
- package/dist/types/Things.js.map +1 -0
- package/dist/types/Verb.js +119 -0
- package/dist/types/Verb.js.map +1 -0
- package/dist/types/WorkflowContext.js +70 -0
- package/dist/types/WorkflowContext.js.map +1 -0
- package/dist/types/analytics-api.js +13 -0
- package/dist/types/analytics-api.js.map +1 -0
- package/dist/types/capabilities.js +135 -0
- package/dist/types/capabilities.js.map +1 -0
- package/dist/types/drizzle.js +12 -0
- package/dist/types/drizzle.js.map +1 -0
- package/dist/types/event.js +201 -0
- package/dist/types/event.js.map +1 -0
- package/dist/types/fn.js +12 -0
- package/dist/types/fn.js.map +1 -0
- package/dist/types/iceberg.js +48 -0
- package/dist/types/iceberg.js.map +1 -0
- package/dist/types/ids.js +170 -0
- package/dist/types/ids.js.map +1 -0
- package/dist/types/index.js +41 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/introspect.js +54 -0
- package/dist/types/introspect.js.map +1 -0
- package/dist/types/observability.js +124 -0
- package/dist/types/observability.js.map +1 -0
- package/dist/types/sync-protocol.js +175 -0
- package/dist/types/sync-protocol.js.map +1 -0
- package/dist/types/vector.js +13 -0
- package/dist/types/vector.js.map +1 -0
- package/dist/workflows/ScheduleManager.js +473 -0
- package/dist/workflows/ScheduleManager.js.map +1 -0
- package/dist/workflows/StepDOBridge.js +149 -0
- package/dist/workflows/StepDOBridge.js.map +1 -0
- package/dist/workflows/StepResultStorage.js +232 -0
- package/dist/workflows/StepResultStorage.js.map +1 -0
- package/dist/workflows/WaitForEventManager.js +461 -0
- package/dist/workflows/WaitForEventManager.js.map +1 -0
- package/dist/workflows/analyzer.js +332 -0
- package/dist/workflows/analyzer.js.map +1 -0
- package/dist/workflows/compat/activity-router.js +484 -0
- package/dist/workflows/compat/activity-router.js.map +1 -0
- package/dist/workflows/compat/backends/cloudflare-workflows.js +431 -0
- package/dist/workflows/compat/backends/cloudflare-workflows.js.map +1 -0
- package/dist/workflows/compat/backends/index.js +14 -0
- package/dist/workflows/compat/backends/index.js.map +1 -0
- package/dist/workflows/compat/errors/index.js +375 -0
- package/dist/workflows/compat/errors/index.js.map +1 -0
- package/dist/workflows/compat/index.js +79 -0
- package/dist/workflows/compat/index.js.map +1 -0
- package/dist/workflows/compat/inngest/index.js +989 -0
- package/dist/workflows/compat/inngest/index.js.map +1 -0
- package/dist/workflows/compat/qstash/index.js +1263 -0
- package/dist/workflows/compat/qstash/index.js.map +1 -0
- package/dist/workflows/compat/temporal/activities.js +739 -0
- package/dist/workflows/compat/temporal/activities.js.map +1 -0
- package/dist/workflows/compat/temporal/child-workflows.js +154 -0
- package/dist/workflows/compat/temporal/child-workflows.js.map +1 -0
- package/dist/workflows/compat/temporal/client.js +381 -0
- package/dist/workflows/compat/temporal/client.js.map +1 -0
- package/dist/workflows/compat/temporal/context.js +309 -0
- package/dist/workflows/compat/temporal/context.js.map +1 -0
- package/dist/workflows/compat/temporal/determinism.js +216 -0
- package/dist/workflows/compat/temporal/determinism.js.map +1 -0
- package/dist/workflows/compat/temporal/errors.js +128 -0
- package/dist/workflows/compat/temporal/errors.js.map +1 -0
- package/dist/workflows/compat/temporal/index.js +2464 -0
- package/dist/workflows/compat/temporal/index.js.map +1 -0
- package/dist/workflows/compat/temporal/saga.js +504 -0
- package/dist/workflows/compat/temporal/saga.js.map +1 -0
- package/dist/workflows/compat/temporal/signals.js +364 -0
- package/dist/workflows/compat/temporal/signals.js.map +1 -0
- package/dist/workflows/compat/temporal/storage.js +271 -0
- package/dist/workflows/compat/temporal/storage.js.map +1 -0
- package/dist/workflows/compat/temporal/timers.js +347 -0
- package/dist/workflows/compat/temporal/timers.js.map +1 -0
- package/dist/workflows/compat/temporal/types.js +7 -0
- package/dist/workflows/compat/temporal/types.js.map +1 -0
- package/dist/workflows/compat/temporal/unified-primitives.js +339 -0
- package/dist/workflows/compat/temporal/unified-primitives.js.map +1 -0
- package/dist/workflows/compat/trigger/index.js +468 -0
- package/dist/workflows/compat/trigger/index.js.map +1 -0
- package/dist/workflows/compat/utils/index.js +69 -0
- package/dist/workflows/compat/utils/index.js.map +1 -0
- package/dist/workflows/context/correlation-capability.js +266 -0
- package/dist/workflows/context/correlation-capability.js.map +1 -0
- package/dist/workflows/context/correlation.js +484 -0
- package/dist/workflows/context/correlation.js.map +1 -0
- package/dist/workflows/context/experiment.js +289 -0
- package/dist/workflows/context/experiment.js.map +1 -0
- package/dist/workflows/context/flag.js +244 -0
- package/dist/workflows/context/flag.js.map +1 -0
- package/dist/workflows/context/foundation.js +648 -0
- package/dist/workflows/context/foundation.js.map +1 -0
- package/dist/workflows/context/human-base.js +106 -0
- package/dist/workflows/context/human-base.js.map +1 -0
- package/dist/workflows/context/human.js +368 -0
- package/dist/workflows/context/human.js.map +1 -0
- package/dist/workflows/context/measure.js +354 -0
- package/dist/workflows/context/measure.js.map +1 -0
- package/dist/workflows/context/rate-limit.js +358 -0
- package/dist/workflows/context/rate-limit.js.map +1 -0
- package/dist/workflows/context/user.js +117 -0
- package/dist/workflows/context/user.js.map +1 -0
- package/dist/workflows/context/vault.js +360 -0
- package/dist/workflows/context/vault.js.map +1 -0
- package/dist/workflows/data/entity-events/entity-events.js +489 -0
- package/dist/workflows/data/entity-events/entity-events.js.map +1 -0
- package/dist/workflows/data/experiment/index.js +599 -0
- package/dist/workflows/data/experiment/index.js.map +1 -0
- package/dist/workflows/data/goal/context.js +558 -0
- package/dist/workflows/data/goal/context.js.map +1 -0
- package/dist/workflows/data/goal/index.js +32 -0
- package/dist/workflows/data/goal/index.js.map +1 -0
- package/dist/workflows/data/measure/index.js +840 -0
- package/dist/workflows/data/measure/index.js.map +1 -0
- package/dist/workflows/data/stream/index.js +1149 -0
- package/dist/workflows/data/stream/index.js.map +1 -0
- package/dist/workflows/data/track/context.js +883 -0
- package/dist/workflows/data/track/context.js.map +1 -0
- package/dist/workflows/data/track/index.js +15 -0
- package/dist/workflows/data/track/index.js.map +1 -0
- package/dist/workflows/data/view/context.js +864 -0
- package/dist/workflows/data/view/context.js.map +1 -0
- package/dist/workflows/domain.js +93 -0
- package/dist/workflows/domain.js.map +1 -0
- package/dist/workflows/flag.js +176 -0
- package/dist/workflows/flag.js.map +1 -0
- package/dist/workflows/flags.js +217 -0
- package/dist/workflows/flags.js.map +1 -0
- package/dist/workflows/hash.js +209 -0
- package/dist/workflows/hash.js.map +1 -0
- package/dist/workflows/index.js +50 -0
- package/dist/workflows/index.js.map +1 -0
- package/dist/workflows/on.js +378 -0
- package/dist/workflows/on.js.map +1 -0
- package/dist/workflows/pipeline-promise.js +481 -0
- package/dist/workflows/pipeline-promise.js.map +1 -0
- package/dist/workflows/pipeline-types.js +20 -0
- package/dist/workflows/pipeline-types.js.map +1 -0
- package/dist/workflows/proxy.js +76 -0
- package/dist/workflows/proxy.js.map +1 -0
- package/dist/workflows/runtime.js +310 -0
- package/dist/workflows/runtime.js.map +1 -0
- package/dist/workflows/schedule-builder.js +327 -0
- package/dist/workflows/schedule-builder.js.map +1 -0
- package/dist/workflows/visibility/index.js +146 -0
- package/dist/workflows/visibility/index.js.map +1 -0
- package/dist/workflows/visibility/query-parser.js +150 -0
- package/dist/workflows/visibility/query-parser.js.map +1 -0
- package/dist/workflows/visibility/store.js +223 -0
- package/dist/workflows/visibility/store.js.map +1 -0
- package/dist/workflows/visibility/types.js +30 -0
- package/dist/workflows/visibility/types.js.map +1 -0
- package/dist/workflows/workflow.js +53 -0
- package/dist/workflows/workflow.js.map +1 -0
- package/package.json +294 -46
package/cli/mcp-stdio.ts
ADDED
|
@@ -0,0 +1,790 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP stdio Transport Module
|
|
3
|
+
*
|
|
4
|
+
* Implements MCP (Model Context Protocol) communication over stdin/stdout
|
|
5
|
+
* using JSON-RPC 2.0 with newline-delimited message framing.
|
|
6
|
+
*
|
|
7
|
+
* @see https://modelcontextprotocol.io/docs/concepts/transports
|
|
8
|
+
* @see https://www.jsonrpc.org/specification
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { EventEmitter } from 'events'
|
|
12
|
+
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Type Exports
|
|
15
|
+
// ============================================================================
|
|
16
|
+
|
|
17
|
+
export interface JsonRpcMessage {
|
|
18
|
+
jsonrpc: '2.0'
|
|
19
|
+
id?: string | number | null
|
|
20
|
+
method?: string
|
|
21
|
+
params?: Record<string, unknown>
|
|
22
|
+
result?: unknown
|
|
23
|
+
error?: {
|
|
24
|
+
code: number
|
|
25
|
+
message: string
|
|
26
|
+
data?: unknown
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface JsonRpcRequest extends JsonRpcMessage {
|
|
31
|
+
id: string | number
|
|
32
|
+
method: string
|
|
33
|
+
params?: Record<string, unknown>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface JsonRpcResponse extends JsonRpcMessage {
|
|
37
|
+
id: string | number | null
|
|
38
|
+
result?: unknown
|
|
39
|
+
error?: {
|
|
40
|
+
code: number
|
|
41
|
+
message: string
|
|
42
|
+
data?: unknown
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface JsonRpcNotification extends JsonRpcMessage {
|
|
47
|
+
method: string
|
|
48
|
+
params?: Record<string, unknown>
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface TransportOptions {
|
|
52
|
+
stdin: NodeJS.ReadableStream | { on: Function; pipe: Function; destroy: Function }
|
|
53
|
+
stdout: NodeJS.WritableStream | { write: Function; end: Function; destroy: Function }
|
|
54
|
+
stderr?: NodeJS.WritableStream | { write: Function; end: Function; destroy: Function }
|
|
55
|
+
delimiter?: string
|
|
56
|
+
encoding?: BufferEncoding
|
|
57
|
+
maxMessageSize?: number
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface MessageHandler {
|
|
61
|
+
(message: JsonRpcMessage, send: (response: JsonRpcMessage) => Promise<void>): Promise<void> | void
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface StdioSession {
|
|
65
|
+
id: string
|
|
66
|
+
createdAt: number
|
|
67
|
+
lastActivity: number
|
|
68
|
+
state: 'created' | 'initialized' | 'running' | 'closed'
|
|
69
|
+
clientInfo?: { name: string; version: string }
|
|
70
|
+
transport?: McpStdioTransport
|
|
71
|
+
inactivityTimeout?: number
|
|
72
|
+
|
|
73
|
+
initialize(params: {
|
|
74
|
+
protocolVersion: string
|
|
75
|
+
clientInfo: { name: string; version: string }
|
|
76
|
+
capabilities: Record<string, unknown>
|
|
77
|
+
}): void
|
|
78
|
+
start(): void
|
|
79
|
+
close(): void
|
|
80
|
+
touch(): void
|
|
81
|
+
attachTransport(transport: McpStdioTransport): void
|
|
82
|
+
respond(id: string | number, result: unknown): Promise<void>
|
|
83
|
+
notify(method: string, params?: Record<string, unknown>): Promise<void>
|
|
84
|
+
registerTool(tool: McpTool): void
|
|
85
|
+
unregisterTool(name: string): void
|
|
86
|
+
getTools(): McpTool[]
|
|
87
|
+
on(event: string, callback: (...args: unknown[]) => void): void
|
|
88
|
+
startTimeoutTimer(): void
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface McpTool {
|
|
92
|
+
name: string
|
|
93
|
+
description: string
|
|
94
|
+
inputSchema: Record<string, unknown>
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface MessageFramer {
|
|
98
|
+
push(data: string): void
|
|
99
|
+
getMessages(): string[]
|
|
100
|
+
reset(): void
|
|
101
|
+
bufferSize(): number
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface MessageFramerOptions {
|
|
105
|
+
delimiter?: string
|
|
106
|
+
maxBufferSize?: number
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ============================================================================
|
|
110
|
+
// MCP Bridge Types (for HTTP proxy)
|
|
111
|
+
// ============================================================================
|
|
112
|
+
|
|
113
|
+
export interface McpBridgeOptions {
|
|
114
|
+
targetUrl?: string
|
|
115
|
+
fetch?: typeof fetch
|
|
116
|
+
retries?: number
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface McpBridge {
|
|
120
|
+
targetUrl: string
|
|
121
|
+
proxy(message: JsonRpcMessage): Promise<JsonRpcResponse>
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface McpServerOptions {
|
|
125
|
+
stdin: NodeJS.ReadableStream | { on: Function; pipe: Function; destroy: Function }
|
|
126
|
+
stdout: NodeJS.WritableStream | { write: Function; end: Function; destroy: Function }
|
|
127
|
+
fetch?: typeof fetch
|
|
128
|
+
targetUrl?: string
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface McpServer {
|
|
132
|
+
isRunning(): boolean
|
|
133
|
+
stop(): Promise<void>
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ============================================================================
|
|
137
|
+
// JSON-RPC Message Parsing
|
|
138
|
+
// ============================================================================
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Parse a JSON-RPC message from string
|
|
142
|
+
*/
|
|
143
|
+
export function parseJsonRpcMessage(input: string): JsonRpcMessage {
|
|
144
|
+
let parsed: Record<string, unknown>
|
|
145
|
+
try {
|
|
146
|
+
parsed = JSON.parse(input)
|
|
147
|
+
} catch {
|
|
148
|
+
throw new Error('Failed to parse JSON')
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Validate jsonrpc version
|
|
152
|
+
if (parsed.jsonrpc !== '2.0') {
|
|
153
|
+
throw new Error('Invalid or missing jsonrpc version')
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Validate id type if present
|
|
157
|
+
if (parsed.id !== undefined && parsed.id !== null) {
|
|
158
|
+
if (typeof parsed.id !== 'string' && typeof parsed.id !== 'number') {
|
|
159
|
+
throw new Error('Invalid id type: must be string, number, or null')
|
|
160
|
+
}
|
|
161
|
+
if (typeof parsed.id === 'object') {
|
|
162
|
+
throw new Error('Invalid id type: must be string, number, or null')
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Validate params if present (MCP requires object, not array)
|
|
167
|
+
if (parsed.params !== undefined) {
|
|
168
|
+
if (Array.isArray(parsed.params)) {
|
|
169
|
+
throw new Error('MCP requires params to be an object, not an array')
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return parsed as JsonRpcMessage
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Serialize a JSON-RPC message to string
|
|
178
|
+
*/
|
|
179
|
+
export function serializeJsonRpcMessage(message: JsonRpcMessage): string {
|
|
180
|
+
return JSON.stringify(message)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// ============================================================================
|
|
184
|
+
// Message Framing
|
|
185
|
+
// ============================================================================
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Create a message framer for handling newline-delimited JSON
|
|
189
|
+
*/
|
|
190
|
+
export function createMessageFramer(options?: MessageFramerOptions): MessageFramer {
|
|
191
|
+
const delimiter = options?.delimiter ?? '\n'
|
|
192
|
+
const maxBufferSize = options?.maxBufferSize ?? Infinity
|
|
193
|
+
let buffer = ''
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
push(data: string): void {
|
|
197
|
+
if (buffer.length + data.length > maxBufferSize) {
|
|
198
|
+
throw new Error('Buffer size limit exceeded')
|
|
199
|
+
}
|
|
200
|
+
buffer += data
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
getMessages(): string[] {
|
|
204
|
+
const messages: string[] = []
|
|
205
|
+
let delimiterIndex: number
|
|
206
|
+
|
|
207
|
+
while ((delimiterIndex = buffer.indexOf(delimiter)) !== -1) {
|
|
208
|
+
const message = buffer.slice(0, delimiterIndex)
|
|
209
|
+
buffer = buffer.slice(delimiterIndex + delimiter.length)
|
|
210
|
+
if (message.length > 0) {
|
|
211
|
+
messages.push(message)
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return messages
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
reset(): void {
|
|
219
|
+
buffer = ''
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
bufferSize(): number {
|
|
223
|
+
return buffer.length
|
|
224
|
+
},
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// ============================================================================
|
|
229
|
+
// McpStdioTransport Class
|
|
230
|
+
// ============================================================================
|
|
231
|
+
|
|
232
|
+
export class McpStdioTransport extends EventEmitter {
|
|
233
|
+
private options: TransportOptions
|
|
234
|
+
private connected: boolean = false
|
|
235
|
+
private messageHandler?: MessageHandler
|
|
236
|
+
private framer: MessageFramer
|
|
237
|
+
private writeQueue: Promise<void> = Promise.resolve()
|
|
238
|
+
|
|
239
|
+
constructor(options: TransportOptions) {
|
|
240
|
+
super()
|
|
241
|
+
this.options = options
|
|
242
|
+
this.framer = createMessageFramer({
|
|
243
|
+
delimiter: options.delimiter ?? '\n',
|
|
244
|
+
maxBufferSize: options.maxMessageSize,
|
|
245
|
+
})
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
isConnected(): boolean {
|
|
249
|
+
return this.connected
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
async start(): Promise<void> {
|
|
253
|
+
if (this.connected) {
|
|
254
|
+
throw new Error('Transport is already connected')
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
this.connected = true
|
|
258
|
+
this.emit('connected')
|
|
259
|
+
|
|
260
|
+
// Listen for data from stdin
|
|
261
|
+
this.options.stdin.on('data', (data: Buffer | string) => {
|
|
262
|
+
this.handleIncomingData(data)
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
// Handle stdin close
|
|
266
|
+
this.options.stdin.on('close', () => {
|
|
267
|
+
this.handleDisconnect()
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
// Handle stdin error
|
|
271
|
+
this.options.stdin.on('error', (error: Error) => {
|
|
272
|
+
this.emit('error', error)
|
|
273
|
+
})
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
private handleIncomingData(data: Buffer | string): void {
|
|
277
|
+
const str = typeof data === 'string' ? data : data.toString(this.options.encoding ?? 'utf-8')
|
|
278
|
+
|
|
279
|
+
try {
|
|
280
|
+
this.framer.push(str)
|
|
281
|
+
} catch {
|
|
282
|
+
this.emit('error', new Error('Message size limit exceeded'))
|
|
283
|
+
return
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const messages = this.framer.getMessages()
|
|
287
|
+
for (const raw of messages) {
|
|
288
|
+
this.processMessage(raw)
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
private processMessage(raw: string): void {
|
|
293
|
+
// Handle empty messages gracefully
|
|
294
|
+
if (!raw.trim()) {
|
|
295
|
+
return
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
let message: JsonRpcMessage
|
|
299
|
+
try {
|
|
300
|
+
message = parseJsonRpcMessage(raw)
|
|
301
|
+
} catch (error) {
|
|
302
|
+
const parseError = error as Error
|
|
303
|
+
// Only emit error if there are listeners (avoid unhandled error events)
|
|
304
|
+
if (this.listenerCount('error') > 0) {
|
|
305
|
+
this.emit('error', new Error(`JSON parse error: ${parseError.message}`))
|
|
306
|
+
}
|
|
307
|
+
// Send parse error response
|
|
308
|
+
this.sendErrorResponse(null, -32700, 'Parse error')
|
|
309
|
+
return
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// Validate that it's a request (has method) or response (has result/error)
|
|
313
|
+
const isRequest = 'method' in message
|
|
314
|
+
const isResponse = 'result' in message || 'error' in message
|
|
315
|
+
|
|
316
|
+
if (!isRequest && !isResponse && message.id !== undefined) {
|
|
317
|
+
// Has id but no method and no result/error - invalid request
|
|
318
|
+
// Only emit error if there are listeners (avoid unhandled error events)
|
|
319
|
+
if (this.listenerCount('error') > 0) {
|
|
320
|
+
this.emit('error', new Error('Invalid request: missing method'))
|
|
321
|
+
}
|
|
322
|
+
this.sendErrorResponse(message.id as string | number | null, -32600, 'Invalid Request')
|
|
323
|
+
return
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Emit message event
|
|
327
|
+
this.emit('message', message)
|
|
328
|
+
|
|
329
|
+
// Call message handler if registered
|
|
330
|
+
if (this.messageHandler) {
|
|
331
|
+
const sendFn = (response: JsonRpcMessage) => this.send(response)
|
|
332
|
+
Promise.resolve(this.messageHandler(message, sendFn)).catch((err) => {
|
|
333
|
+
if (this.listenerCount('error') > 0) {
|
|
334
|
+
this.emit('error', err)
|
|
335
|
+
}
|
|
336
|
+
})
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
private async sendErrorResponse(id: string | number | null, code: number, message: string): Promise<void> {
|
|
341
|
+
try {
|
|
342
|
+
await this.send({
|
|
343
|
+
jsonrpc: '2.0',
|
|
344
|
+
id,
|
|
345
|
+
error: { code, message },
|
|
346
|
+
})
|
|
347
|
+
} catch {
|
|
348
|
+
// Ignore errors when sending error response
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
private handleDisconnect(): void {
|
|
353
|
+
if (this.connected) {
|
|
354
|
+
this.connected = false
|
|
355
|
+
this.emit('disconnected')
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
async close(): Promise<void> {
|
|
360
|
+
if (this.connected) {
|
|
361
|
+
this.connected = false
|
|
362
|
+
this.emit('disconnected')
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
async send(message: JsonRpcMessage): Promise<void> {
|
|
367
|
+
if (!this.connected) {
|
|
368
|
+
throw new Error('Transport is closed')
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const serialized = serializeJsonRpcMessage(message) + (this.options.delimiter ?? '\n')
|
|
372
|
+
|
|
373
|
+
// Queue writes to preserve order
|
|
374
|
+
this.writeQueue = this.writeQueue.then(() => {
|
|
375
|
+
return new Promise<void>((resolve) => {
|
|
376
|
+
try {
|
|
377
|
+
const stdout = this.options.stdout as { write: Function }
|
|
378
|
+
const result = stdout.write(serialized, () => {
|
|
379
|
+
resolve()
|
|
380
|
+
})
|
|
381
|
+
// If write returns false (backpressure), resolve immediately anyway
|
|
382
|
+
// The callback will still fire later, but we don't wait for it
|
|
383
|
+
if (result === false) {
|
|
384
|
+
resolve()
|
|
385
|
+
}
|
|
386
|
+
} catch (error) {
|
|
387
|
+
this.emit('error', error)
|
|
388
|
+
resolve()
|
|
389
|
+
}
|
|
390
|
+
})
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
await this.writeQueue
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
setMessageHandler(handler: MessageHandler): void {
|
|
397
|
+
this.messageHandler = handler
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// ============================================================================
|
|
402
|
+
// Factory Functions
|
|
403
|
+
// ============================================================================
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Create a new MCP stdio transport
|
|
407
|
+
*/
|
|
408
|
+
export function createStdioTransport(options: TransportOptions): McpStdioTransport {
|
|
409
|
+
return new McpStdioTransport(options)
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// ============================================================================
|
|
413
|
+
// Session Management
|
|
414
|
+
// ============================================================================
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Create a new MCP stdio session
|
|
418
|
+
*/
|
|
419
|
+
export function createStdioSession(options?: { inactivityTimeout?: number }): StdioSession {
|
|
420
|
+
const emitter = new EventEmitter()
|
|
421
|
+
let state: 'created' | 'initialized' | 'running' | 'closed' = 'created'
|
|
422
|
+
let clientInfo: { name: string; version: string } | undefined
|
|
423
|
+
let transport: McpStdioTransport | undefined
|
|
424
|
+
let lastActivity = Date.now()
|
|
425
|
+
let timeoutTimer: ReturnType<typeof setTimeout> | undefined
|
|
426
|
+
const tools: Map<string, McpTool> = new Map()
|
|
427
|
+
|
|
428
|
+
const session: StdioSession = {
|
|
429
|
+
id: generateSessionId(),
|
|
430
|
+
createdAt: Date.now(),
|
|
431
|
+
get lastActivity() {
|
|
432
|
+
return lastActivity
|
|
433
|
+
},
|
|
434
|
+
get state() {
|
|
435
|
+
return state
|
|
436
|
+
},
|
|
437
|
+
get clientInfo() {
|
|
438
|
+
return clientInfo
|
|
439
|
+
},
|
|
440
|
+
get transport() {
|
|
441
|
+
return transport
|
|
442
|
+
},
|
|
443
|
+
get inactivityTimeout() {
|
|
444
|
+
return options?.inactivityTimeout
|
|
445
|
+
},
|
|
446
|
+
|
|
447
|
+
initialize(params: {
|
|
448
|
+
protocolVersion: string
|
|
449
|
+
clientInfo: { name: string; version: string }
|
|
450
|
+
capabilities: Record<string, unknown>
|
|
451
|
+
}): void {
|
|
452
|
+
if (state === 'closed') {
|
|
453
|
+
throw new Error('Cannot initialize closed session')
|
|
454
|
+
}
|
|
455
|
+
clientInfo = params.clientInfo
|
|
456
|
+
state = 'initialized'
|
|
457
|
+
this.touch()
|
|
458
|
+
},
|
|
459
|
+
|
|
460
|
+
start(): void {
|
|
461
|
+
if (state === 'initialized') {
|
|
462
|
+
state = 'running'
|
|
463
|
+
this.touch()
|
|
464
|
+
}
|
|
465
|
+
},
|
|
466
|
+
|
|
467
|
+
close(): void {
|
|
468
|
+
if (timeoutTimer) {
|
|
469
|
+
clearTimeout(timeoutTimer)
|
|
470
|
+
}
|
|
471
|
+
state = 'closed'
|
|
472
|
+
if (transport) {
|
|
473
|
+
transport.close()
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
|
|
477
|
+
touch(): void {
|
|
478
|
+
lastActivity = Date.now()
|
|
479
|
+
if (timeoutTimer && options?.inactivityTimeout) {
|
|
480
|
+
clearTimeout(timeoutTimer)
|
|
481
|
+
timeoutTimer = setTimeout(() => {
|
|
482
|
+
emitter.emit('timeout')
|
|
483
|
+
}, options.inactivityTimeout)
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
|
|
487
|
+
attachTransport(t: McpStdioTransport): void {
|
|
488
|
+
transport = t
|
|
489
|
+
|
|
490
|
+
// Listen for messages and handle MCP protocol
|
|
491
|
+
transport.on('message', async (msg: JsonRpcMessage) => {
|
|
492
|
+
this.touch()
|
|
493
|
+
|
|
494
|
+
// Handle initialize request
|
|
495
|
+
if (msg.method === 'initialize' && msg.params && msg.id !== undefined) {
|
|
496
|
+
this.initialize(msg.params as {
|
|
497
|
+
protocolVersion: string
|
|
498
|
+
clientInfo: { name: string; version: string }
|
|
499
|
+
capabilities: Record<string, unknown>
|
|
500
|
+
})
|
|
501
|
+
// Send initialize response
|
|
502
|
+
await this.respond(msg.id as string | number, {
|
|
503
|
+
protocolVersion: '2024-11-05',
|
|
504
|
+
serverInfo: { name: 'dotdo', version: '1.0.0' },
|
|
505
|
+
capabilities: { tools: {}, resources: {} },
|
|
506
|
+
})
|
|
507
|
+
return
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// Handle tools/list request
|
|
511
|
+
if (msg.method === 'tools/list' && msg.id !== undefined) {
|
|
512
|
+
await this.respond(msg.id as string | number, {
|
|
513
|
+
tools: this.getTools(),
|
|
514
|
+
})
|
|
515
|
+
return
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// Handle tools/call request - echo the tool name for now
|
|
519
|
+
if (msg.method === 'tools/call' && msg.id !== undefined && msg.params) {
|
|
520
|
+
const toolName = (msg.params as { name: string }).name
|
|
521
|
+
const args = (msg.params as { arguments?: Record<string, unknown> }).arguments ?? {}
|
|
522
|
+
const tool = tools.get(toolName)
|
|
523
|
+
if (tool) {
|
|
524
|
+
// Simple echo implementation for testing
|
|
525
|
+
await this.respond(msg.id as string | number, {
|
|
526
|
+
content: [{ type: 'text', text: `Tool ${toolName} called with: ${JSON.stringify(args)}` }],
|
|
527
|
+
})
|
|
528
|
+
} else {
|
|
529
|
+
await transport.send({
|
|
530
|
+
jsonrpc: '2.0',
|
|
531
|
+
id: msg.id,
|
|
532
|
+
error: { code: -32601, message: `Tool not found: ${toolName}` },
|
|
533
|
+
})
|
|
534
|
+
}
|
|
535
|
+
return
|
|
536
|
+
}
|
|
537
|
+
})
|
|
538
|
+
},
|
|
539
|
+
|
|
540
|
+
async respond(id: string | number, result: unknown): Promise<void> {
|
|
541
|
+
if (transport) {
|
|
542
|
+
await transport.send({
|
|
543
|
+
jsonrpc: '2.0',
|
|
544
|
+
id,
|
|
545
|
+
result,
|
|
546
|
+
})
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
|
|
550
|
+
async notify(method: string, params?: Record<string, unknown>): Promise<void> {
|
|
551
|
+
if (transport) {
|
|
552
|
+
await transport.send({
|
|
553
|
+
jsonrpc: '2.0',
|
|
554
|
+
method,
|
|
555
|
+
params,
|
|
556
|
+
})
|
|
557
|
+
}
|
|
558
|
+
},
|
|
559
|
+
|
|
560
|
+
registerTool(tool: McpTool): void {
|
|
561
|
+
tools.set(tool.name, tool)
|
|
562
|
+
// Send notification if initialized
|
|
563
|
+
if (state === 'initialized' || state === 'running') {
|
|
564
|
+
this.notify('notifications/tools/list_changed', {})
|
|
565
|
+
}
|
|
566
|
+
},
|
|
567
|
+
|
|
568
|
+
unregisterTool(name: string): void {
|
|
569
|
+
tools.delete(name)
|
|
570
|
+
// Send notification if initialized
|
|
571
|
+
if (state === 'initialized' || state === 'running') {
|
|
572
|
+
this.notify('notifications/tools/list_changed', {})
|
|
573
|
+
}
|
|
574
|
+
},
|
|
575
|
+
|
|
576
|
+
getTools(): McpTool[] {
|
|
577
|
+
return Array.from(tools.values())
|
|
578
|
+
},
|
|
579
|
+
|
|
580
|
+
on(event: string, callback: (...args: unknown[]) => void): void {
|
|
581
|
+
emitter.on(event, callback)
|
|
582
|
+
},
|
|
583
|
+
|
|
584
|
+
startTimeoutTimer(): void {
|
|
585
|
+
if (options?.inactivityTimeout) {
|
|
586
|
+
timeoutTimer = setTimeout(() => {
|
|
587
|
+
emitter.emit('timeout')
|
|
588
|
+
}, options.inactivityTimeout)
|
|
589
|
+
}
|
|
590
|
+
},
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
return session
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
function generateSessionId(): string {
|
|
597
|
+
return `session-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
// ============================================================================
|
|
601
|
+
// Helper Functions
|
|
602
|
+
// ============================================================================
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Normalize a URL by removing trailing slashes and /mcp suffix
|
|
606
|
+
*/
|
|
607
|
+
function normalizeTargetUrl(url: string): string {
|
|
608
|
+
let normalized = url
|
|
609
|
+
// Remove trailing slash
|
|
610
|
+
if (normalized.endsWith('/')) {
|
|
611
|
+
normalized = normalized.slice(0, -1)
|
|
612
|
+
}
|
|
613
|
+
// Remove /mcp suffix if present
|
|
614
|
+
if (normalized.endsWith('/mcp')) {
|
|
615
|
+
normalized = normalized.slice(0, -4)
|
|
616
|
+
}
|
|
617
|
+
return normalized
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Validate URL format
|
|
622
|
+
*/
|
|
623
|
+
function isValidUrl(url: string): boolean {
|
|
624
|
+
try {
|
|
625
|
+
new URL(url)
|
|
626
|
+
return true
|
|
627
|
+
} catch {
|
|
628
|
+
return false
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// ============================================================================
|
|
633
|
+
// MCP HTTP Bridge Functions
|
|
634
|
+
// ============================================================================
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Create a new MCP HTTP bridge that proxies stdio to DO's /mcp endpoint
|
|
638
|
+
*/
|
|
639
|
+
export function createMcpBridge(options?: McpBridgeOptions): McpBridge {
|
|
640
|
+
const rawUrl = options?.targetUrl ?? process.env.DO_URL
|
|
641
|
+
|
|
642
|
+
// Throw if no URL configured
|
|
643
|
+
if (!rawUrl) {
|
|
644
|
+
throw new Error('DO_URL not configured: provide targetUrl option or set DO_URL environment variable')
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// Validate URL format
|
|
648
|
+
if (!isValidUrl(rawUrl)) {
|
|
649
|
+
throw new Error('Invalid URL format')
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
const targetUrl = normalizeTargetUrl(rawUrl)
|
|
653
|
+
const fetchFn = options?.fetch ?? fetch
|
|
654
|
+
const maxRetries = options?.retries ?? 0
|
|
655
|
+
|
|
656
|
+
return {
|
|
657
|
+
targetUrl,
|
|
658
|
+
async proxy(message: JsonRpcMessage): Promise<JsonRpcResponse> {
|
|
659
|
+
let lastError: Error | undefined
|
|
660
|
+
|
|
661
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
662
|
+
try {
|
|
663
|
+
const res = await fetchFn(`${targetUrl}/mcp`, {
|
|
664
|
+
method: 'POST',
|
|
665
|
+
headers: { 'Content-Type': 'application/json' },
|
|
666
|
+
body: JSON.stringify(message),
|
|
667
|
+
})
|
|
668
|
+
|
|
669
|
+
// Handle HTTP errors
|
|
670
|
+
if (!res.ok) {
|
|
671
|
+
const status = res.status
|
|
672
|
+
const statusText = res.statusText || ''
|
|
673
|
+
let errorMessage: string
|
|
674
|
+
|
|
675
|
+
if (status === 401) {
|
|
676
|
+
errorMessage = `401 Unauthorized`
|
|
677
|
+
} else if (status === 404) {
|
|
678
|
+
errorMessage = `404 Not Found`
|
|
679
|
+
} else if (status >= 500) {
|
|
680
|
+
errorMessage = `${status} Internal Server Error`
|
|
681
|
+
} else {
|
|
682
|
+
errorMessage = `HTTP ${status}: ${statusText}`
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
return {
|
|
686
|
+
jsonrpc: '2.0',
|
|
687
|
+
id: message.id ?? null,
|
|
688
|
+
error: {
|
|
689
|
+
code: -32603,
|
|
690
|
+
message: errorMessage,
|
|
691
|
+
},
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
try {
|
|
696
|
+
return (await res.json()) as JsonRpcResponse
|
|
697
|
+
} catch {
|
|
698
|
+
// JSON parse error
|
|
699
|
+
return {
|
|
700
|
+
jsonrpc: '2.0',
|
|
701
|
+
id: message.id ?? null,
|
|
702
|
+
error: {
|
|
703
|
+
code: -32700,
|
|
704
|
+
message: 'Parse error: Invalid JSON response from server',
|
|
705
|
+
},
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
} catch (error) {
|
|
709
|
+
lastError = error as Error
|
|
710
|
+
// If we have more retries, continue
|
|
711
|
+
if (attempt < maxRetries) {
|
|
712
|
+
continue
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
// Return error response for network/connection errors
|
|
718
|
+
return {
|
|
719
|
+
jsonrpc: '2.0',
|
|
720
|
+
id: message.id ?? null,
|
|
721
|
+
error: {
|
|
722
|
+
code: -32603,
|
|
723
|
+
message: `Connection failed: ${lastError?.message ?? 'Unknown error'}`,
|
|
724
|
+
},
|
|
725
|
+
}
|
|
726
|
+
},
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* Start MCP stdio server that proxies to DO
|
|
732
|
+
*/
|
|
733
|
+
export async function startMcpServer(options: McpServerOptions): Promise<McpServer> {
|
|
734
|
+
// Validate DO_URL is configured
|
|
735
|
+
const targetUrl = options.targetUrl ?? process.env.DO_URL
|
|
736
|
+
if (!targetUrl) {
|
|
737
|
+
throw new Error('DO_URL not configured: provide targetUrl option or set DO_URL environment variable')
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
const transport = createStdioTransport({
|
|
741
|
+
stdin: options.stdin,
|
|
742
|
+
stdout: options.stdout,
|
|
743
|
+
})
|
|
744
|
+
|
|
745
|
+
const bridge = createMcpBridge({
|
|
746
|
+
targetUrl,
|
|
747
|
+
fetch: options.fetch,
|
|
748
|
+
})
|
|
749
|
+
|
|
750
|
+
let running = true
|
|
751
|
+
|
|
752
|
+
transport.setMessageHandler(async (message, send) => {
|
|
753
|
+
const response = await bridge.proxy(message)
|
|
754
|
+
await send(response)
|
|
755
|
+
})
|
|
756
|
+
|
|
757
|
+
await transport.start()
|
|
758
|
+
|
|
759
|
+
return {
|
|
760
|
+
isRunning(): boolean {
|
|
761
|
+
return running
|
|
762
|
+
},
|
|
763
|
+
async stop(): Promise<void> {
|
|
764
|
+
running = false
|
|
765
|
+
await transport.close()
|
|
766
|
+
},
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* MCP command handler for CLI
|
|
772
|
+
*/
|
|
773
|
+
export async function mcpCommand(args?: { url?: string }): Promise<void> {
|
|
774
|
+
const server = await startMcpServer({
|
|
775
|
+
stdin: process.stdin,
|
|
776
|
+
stdout: process.stdout,
|
|
777
|
+
targetUrl: args?.url ?? process.env.DO_URL,
|
|
778
|
+
})
|
|
779
|
+
|
|
780
|
+
// Handle process signals
|
|
781
|
+
process.on('SIGINT', async () => {
|
|
782
|
+
await server.stop()
|
|
783
|
+
process.exit(0)
|
|
784
|
+
})
|
|
785
|
+
|
|
786
|
+
process.on('SIGTERM', async () => {
|
|
787
|
+
await server.stop()
|
|
788
|
+
process.exit(0)
|
|
789
|
+
})
|
|
790
|
+
}
|