@nodetool-ai/websocket 0.7.0-rc.22 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -0
- package/dist/.nodetool-build-stamp +1 -0
- package/dist/agent/run-node-tool.d.ts +39 -0
- package/dist/agent/run-node-tool.d.ts.map +1 -0
- package/dist/agent/run-node-tool.js +55 -0
- package/dist/agent/run-node-tool.js.map +1 -0
- package/dist/chat-prediction-forwarder.d.ts +13 -0
- package/dist/chat-prediction-forwarder.d.ts.map +1 -0
- package/dist/chat-prediction-forwarder.js +22 -0
- package/dist/chat-prediction-forwarder.js.map +1 -0
- package/dist/chat-tool-call-repair.d.ts +45 -0
- package/dist/chat-tool-call-repair.d.ts.map +1 -0
- package/dist/chat-tool-call-repair.js +100 -0
- package/dist/chat-tool-call-repair.js.map +1 -0
- package/dist/chat-turn-registry.d.ts +169 -0
- package/dist/chat-turn-registry.d.ts.map +1 -0
- package/dist/chat-turn-registry.js +326 -0
- package/dist/chat-turn-registry.js.map +1 -0
- package/dist/collection-api.d.ts +2 -2
- package/dist/collection-api.d.ts.map +1 -1
- package/dist/collection-api.js +44 -13
- package/dist/collection-api.js.map +1 -1
- package/dist/configured-providers.d.ts +52 -0
- package/dist/configured-providers.d.ts.map +1 -0
- package/dist/configured-providers.js +85 -0
- package/dist/configured-providers.js.map +1 -0
- package/dist/cors.d.ts +22 -0
- package/dist/cors.d.ts.map +1 -0
- package/dist/cors.js +91 -0
- package/dist/cors.js.map +1 -0
- package/dist/credit-gate.d.ts +36 -0
- package/dist/credit-gate.d.ts.map +1 -0
- package/dist/credit-gate.js +76 -0
- package/dist/credit-gate.js.map +1 -0
- package/dist/custom-providers.d.ts +40 -0
- package/dist/custom-providers.d.ts.map +1 -0
- package/dist/custom-providers.js +134 -0
- package/dist/custom-providers.js.map +1 -0
- package/dist/debug-sessions.d.ts +10 -0
- package/dist/debug-sessions.d.ts.map +1 -0
- package/dist/debug-sessions.js +9 -0
- package/dist/debug-sessions.js.map +1 -0
- package/dist/drain.d.ts +34 -0
- package/dist/drain.d.ts.map +1 -0
- package/dist/drain.js +68 -0
- package/dist/drain.js.map +1 -0
- package/dist/e2e-server.d.ts +30 -0
- package/dist/e2e-server.d.ts.map +1 -0
- package/dist/e2e-server.js +111 -0
- package/dist/e2e-server.js.map +1 -0
- package/dist/example-workflows.d.ts +20 -0
- package/dist/example-workflows.d.ts.map +1 -0
- package/dist/example-workflows.js +123 -0
- package/dist/example-workflows.js.map +1 -0
- package/dist/extension-cdp-bridge.d.ts +85 -0
- package/dist/extension-cdp-bridge.d.ts.map +1 -0
- package/dist/extension-cdp-bridge.js +163 -0
- package/dist/extension-cdp-bridge.js.map +1 -0
- package/dist/external-mcp.d.ts +58 -0
- package/dist/external-mcp.d.ts.map +1 -0
- package/dist/external-mcp.js +288 -0
- package/dist/external-mcp.js.map +1 -0
- package/dist/fake-runtime.d.ts +114 -0
- package/dist/fake-runtime.d.ts.map +1 -0
- package/dist/fake-runtime.js +270 -0
- package/dist/fake-runtime.js.map +1 -0
- package/dist/file-api.d.ts +4 -7
- package/dist/file-api.d.ts.map +1 -1
- package/dist/file-api.js +122 -39
- package/dist/file-api.js.map +1 -1
- package/dist/frontend-renderer-registry.d.ts +75 -0
- package/dist/frontend-renderer-registry.d.ts.map +1 -0
- package/dist/frontend-renderer-registry.js +111 -0
- package/dist/frontend-renderer-registry.js.map +1 -0
- package/dist/generation-recovery.d.ts +13 -0
- package/dist/generation-recovery.d.ts.map +1 -0
- package/dist/generation-recovery.js +197 -0
- package/dist/generation-recovery.js.map +1 -0
- package/dist/headless-job-runner.d.ts +71 -0
- package/dist/headless-job-runner.d.ts.map +1 -0
- package/dist/headless-job-runner.js +198 -0
- package/dist/headless-job-runner.js.map +1 -0
- package/dist/http-api.d.ts +157 -24
- package/dist/http-api.d.ts.map +1 -1
- package/dist/http-api.js +613 -646
- package/dist/http-api.js.map +1 -1
- package/dist/http-body-schemas.d.ts +109 -0
- package/dist/http-body-schemas.d.ts.map +1 -0
- package/dist/http-body-schemas.js +146 -0
- package/dist/http-body-schemas.js.map +1 -0
- package/dist/index.d.ts +11 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/job-control.d.ts +57 -0
- package/dist/job-control.d.ts.map +1 -0
- package/dist/job-control.js +134 -0
- package/dist/job-control.js.map +1 -0
- package/dist/job-queue.d.ts +47 -0
- package/dist/job-queue.d.ts.map +1 -0
- package/dist/job-queue.js +52 -0
- package/dist/job-queue.js.map +1 -0
- package/dist/job-run-registry.d.ts +176 -0
- package/dist/job-run-registry.d.ts.map +1 -0
- package/dist/job-run-registry.js +312 -0
- package/dist/job-run-registry.js.map +1 -0
- package/dist/lib/app-build-service.d.ts +16 -0
- package/dist/lib/app-build-service.d.ts.map +1 -0
- package/dist/lib/app-build-service.js +39 -0
- package/dist/lib/app-build-service.js.map +1 -0
- package/dist/lib/app-debug-service.d.ts +16 -0
- package/dist/lib/app-debug-service.d.ts.map +1 -0
- package/dist/lib/app-debug-service.js +48 -0
- package/dist/lib/app-debug-service.js.map +1 -0
- package/dist/lib/app-deployment-service.d.ts +82 -0
- package/dist/lib/app-deployment-service.d.ts.map +1 -0
- package/dist/lib/app-deployment-service.js +282 -0
- package/dist/lib/app-deployment-service.js.map +1 -0
- package/dist/lib/app-run-server.d.ts +7 -0
- package/dist/lib/app-run-server.d.ts.map +1 -0
- package/dist/lib/app-run-server.js +6 -0
- package/dist/lib/app-run-server.js.map +1 -0
- package/dist/lib/app-session-scope.d.ts +91 -0
- package/dist/lib/app-session-scope.d.ts.map +1 -0
- package/dist/lib/app-session-scope.js +91 -0
- package/dist/lib/app-session-scope.js.map +1 -0
- package/dist/lib/applications-service.d.ts +173 -0
- package/dist/lib/applications-service.d.ts.map +1 -0
- package/dist/lib/applications-service.js +491 -0
- package/dist/lib/applications-service.js.map +1 -0
- package/dist/lib/asset-duration.d.ts +7 -0
- package/dist/lib/asset-duration.d.ts.map +1 -0
- package/dist/lib/asset-duration.js +24 -0
- package/dist/lib/asset-duration.js.map +1 -0
- package/dist/lib/asset-export.d.ts +34 -0
- package/dist/lib/asset-export.d.ts.map +1 -0
- package/dist/lib/asset-export.js +113 -0
- package/dist/lib/asset-export.js.map +1 -0
- package/dist/lib/asset-model-interface.d.ts +41 -0
- package/dist/lib/asset-model-interface.d.ts.map +1 -0
- package/dist/lib/asset-model-interface.js +74 -0
- package/dist/lib/asset-model-interface.js.map +1 -0
- package/dist/lib/asset-paths.d.ts +52 -0
- package/dist/lib/asset-paths.d.ts.map +1 -1
- package/dist/lib/asset-paths.js +145 -1
- package/dist/lib/asset-paths.js.map +1 -1
- package/dist/lib/asset-response.d.ts +12 -0
- package/dist/lib/asset-response.d.ts.map +1 -0
- package/dist/lib/asset-response.js +88 -0
- package/dist/lib/asset-response.js.map +1 -0
- package/dist/lib/audio-peaks.d.ts +23 -0
- package/dist/lib/audio-peaks.d.ts.map +1 -0
- package/dist/lib/audio-peaks.js +331 -0
- package/dist/lib/audio-peaks.js.map +1 -0
- package/dist/lib/bridge.d.ts +9 -1
- package/dist/lib/bridge.d.ts.map +1 -1
- package/dist/lib/bridge.js +27 -4
- package/dist/lib/bridge.js.map +1 -1
- package/dist/lib/compression.d.ts +3 -0
- package/dist/lib/compression.d.ts.map +1 -0
- package/dist/lib/compression.js +3 -0
- package/dist/lib/compression.js.map +1 -0
- package/dist/lib/document-model-interfaces.d.ts +30 -0
- package/dist/lib/document-model-interfaces.d.ts.map +1 -0
- package/dist/lib/document-model-interfaces.js +295 -0
- package/dist/lib/document-model-interfaces.js.map +1 -0
- package/dist/lib/env-config.d.ts +9 -0
- package/dist/lib/env-config.d.ts.map +1 -0
- package/dist/lib/env-config.js +18 -0
- package/dist/lib/env-config.js.map +1 -0
- package/dist/lib/example-apps.d.ts +43 -0
- package/dist/lib/example-apps.d.ts.map +1 -0
- package/dist/lib/example-apps.js +145 -0
- package/dist/lib/example-apps.js.map +1 -0
- package/dist/lib/example-games.d.ts +5 -0
- package/dist/lib/example-games.d.ts.map +1 -0
- package/dist/lib/example-games.js +13 -0
- package/dist/lib/example-games.js.map +1 -0
- package/dist/lib/example-recipes.d.ts +33 -0
- package/dist/lib/example-recipes.d.ts.map +1 -0
- package/dist/lib/example-recipes.js +213 -0
- package/dist/lib/example-recipes.js.map +1 -0
- package/dist/lib/example-storyboards.d.ts +40 -0
- package/dist/lib/example-storyboards.d.ts.map +1 -0
- package/dist/lib/example-storyboards.js +131 -0
- package/dist/lib/example-storyboards.js.map +1 -0
- package/dist/lib/example-thumbnail.d.ts +21 -0
- package/dist/lib/example-thumbnail.d.ts.map +1 -0
- package/dist/lib/example-thumbnail.js +50 -0
- package/dist/lib/example-thumbnail.js.map +1 -0
- package/dist/lib/example-timelines.d.ts +9 -0
- package/dist/lib/example-timelines.d.ts.map +1 -0
- package/dist/lib/example-timelines.js +25 -0
- package/dist/lib/example-timelines.js.map +1 -0
- package/dist/lib/extension-dist.d.ts +24 -0
- package/dist/lib/extension-dist.d.ts.map +1 -0
- package/dist/lib/extension-dist.js +67 -0
- package/dist/lib/extension-dist.js.map +1 -0
- package/dist/lib/external-asset-lookup.d.ts +30 -0
- package/dist/lib/external-asset-lookup.d.ts.map +1 -0
- package/dist/lib/external-asset-lookup.js +99 -0
- package/dist/lib/external-asset-lookup.js.map +1 -0
- package/dist/lib/external-assets.d.ts +13 -0
- package/dist/lib/external-assets.d.ts.map +1 -0
- package/dist/lib/external-assets.js +46 -0
- package/dist/lib/external-assets.js.map +1 -0
- package/dist/lib/fly-replay.d.ts +34 -0
- package/dist/lib/fly-replay.d.ts.map +1 -0
- package/dist/lib/fly-replay.js +111 -0
- package/dist/lib/fly-replay.js.map +1 -0
- package/dist/lib/http-rate-limit.d.ts +32 -0
- package/dist/lib/http-rate-limit.d.ts.map +1 -0
- package/dist/lib/http-rate-limit.js +47 -0
- package/dist/lib/http-rate-limit.js.map +1 -0
- package/dist/lib/instance-id.d.ts +25 -0
- package/dist/lib/instance-id.d.ts.map +1 -0
- package/dist/lib/instance-id.js +44 -0
- package/dist/lib/instance-id.js.map +1 -0
- package/dist/lib/link-codes.d.ts +82 -0
- package/dist/lib/link-codes.d.ts.map +1 -0
- package/dist/lib/link-codes.js +100 -0
- package/dist/lib/link-codes.js.map +1 -0
- package/dist/lib/local-asset-upload.d.ts +5 -0
- package/dist/lib/local-asset-upload.d.ts.map +1 -0
- package/dist/lib/local-asset-upload.js +69 -0
- package/dist/lib/local-asset-upload.js.map +1 -0
- package/dist/lib/local-file-access.d.ts +31 -0
- package/dist/lib/local-file-access.d.ts.map +1 -0
- package/dist/lib/local-file-access.js +169 -0
- package/dist/lib/local-file-access.js.map +1 -0
- package/dist/lib/localhost-trust.d.ts +59 -0
- package/dist/lib/localhost-trust.d.ts.map +1 -0
- package/dist/lib/localhost-trust.js +139 -0
- package/dist/lib/localhost-trust.js.map +1 -0
- package/dist/lib/mcp-mount.d.ts +25 -0
- package/dist/lib/mcp-mount.d.ts.map +1 -0
- package/dist/lib/mcp-mount.js +32 -0
- package/dist/lib/mcp-mount.js.map +1 -0
- package/dist/lib/media-size.d.ts +21 -0
- package/dist/lib/media-size.d.ts.map +1 -0
- package/dist/lib/media-size.js +48 -0
- package/dist/lib/media-size.js.map +1 -0
- package/dist/lib/media.d.ts +38 -0
- package/dist/lib/media.d.ts.map +1 -0
- package/dist/lib/media.js +146 -0
- package/dist/lib/media.js.map +1 -0
- package/dist/lib/package-asset-export.d.ts +83 -0
- package/dist/lib/package-asset-export.d.ts.map +1 -0
- package/dist/lib/package-asset-export.js +212 -0
- package/dist/lib/package-asset-export.js.map +1 -0
- package/dist/lib/package-assets.d.ts +41 -0
- package/dist/lib/package-assets.d.ts.map +1 -0
- package/dist/lib/package-assets.js +155 -0
- package/dist/lib/package-assets.js.map +1 -0
- package/dist/lib/project-delete.d.ts +11 -0
- package/dist/lib/project-delete.d.ts.map +1 -0
- package/dist/lib/project-delete.js +67 -0
- package/dist/lib/project-delete.js.map +1 -0
- package/dist/lib/project-document-copy.d.ts +31 -0
- package/dist/lib/project-document-copy.d.ts.map +1 -0
- package/dist/lib/project-document-copy.js +473 -0
- package/dist/lib/project-document-copy.js.map +1 -0
- package/dist/lib/public-app-assets.d.ts +8 -0
- package/dist/lib/public-app-assets.d.ts.map +1 -0
- package/dist/lib/public-app-assets.js +77 -0
- package/dist/lib/public-app-assets.js.map +1 -0
- package/dist/lib/public-routes.d.ts +95 -0
- package/dist/lib/public-routes.d.ts.map +1 -0
- package/dist/lib/public-routes.js +154 -0
- package/dist/lib/public-routes.js.map +1 -0
- package/dist/lib/runtime-detection.d.ts +17 -0
- package/dist/lib/runtime-detection.d.ts.map +1 -0
- package/dist/lib/runtime-detection.js +90 -0
- package/dist/lib/runtime-detection.js.map +1 -0
- package/dist/lib/storage-access.d.ts +21 -0
- package/dist/lib/storage-access.d.ts.map +1 -0
- package/dist/lib/storage-access.js +74 -0
- package/dist/lib/storage-access.js.map +1 -0
- package/dist/lib/storage.d.ts +9 -0
- package/dist/lib/storage.d.ts.map +1 -0
- package/dist/lib/storage.js +28 -0
- package/dist/lib/storage.js.map +1 -0
- package/dist/lib/storyboard-export.d.ts +64 -0
- package/dist/lib/storyboard-export.d.ts.map +1 -0
- package/dist/lib/storyboard-export.js +183 -0
- package/dist/lib/storyboard-export.js.map +1 -0
- package/dist/lib/style-presets.d.ts +34 -0
- package/dist/lib/style-presets.d.ts.map +1 -0
- package/dist/lib/style-presets.js +62 -0
- package/dist/lib/style-presets.js.map +1 -0
- package/dist/lib/temp-url-resolver.d.ts +35 -0
- package/dist/lib/temp-url-resolver.d.ts.map +1 -0
- package/dist/lib/temp-url-resolver.js +88 -0
- package/dist/lib/temp-url-resolver.js.map +1 -0
- package/dist/lib/thumbnail.d.ts +74 -0
- package/dist/lib/thumbnail.d.ts.map +1 -0
- package/dist/lib/thumbnail.js +302 -0
- package/dist/lib/thumbnail.js.map +1 -0
- package/dist/lib/timeline-bundle.d.ts +1689 -0
- package/dist/lib/timeline-bundle.d.ts.map +1 -0
- package/dist/lib/timeline-bundle.js +330 -0
- package/dist/lib/timeline-bundle.js.map +1 -0
- package/dist/lib/video-proxy.d.ts +114 -0
- package/dist/lib/video-proxy.d.ts.map +1 -0
- package/dist/lib/video-proxy.js +545 -0
- package/dist/lib/video-proxy.js.map +1 -0
- package/dist/lib/wire-values.d.ts +31 -0
- package/dist/lib/wire-values.d.ts.map +1 -0
- package/dist/lib/wire-values.js +49 -0
- package/dist/lib/wire-values.js.map +1 -0
- package/dist/lib/workflow-bundle.d.ts +102 -0
- package/dist/lib/workflow-bundle.d.ts.map +1 -0
- package/dist/lib/workflow-bundle.js +306 -0
- package/dist/lib/workflow-bundle.js.map +1 -0
- package/dist/lib/workflow-service.d.ts +82 -0
- package/dist/lib/workflow-service.d.ts.map +1 -0
- package/dist/lib/workflow-service.js +194 -0
- package/dist/lib/workflow-service.js.map +1 -0
- package/dist/lib/workflow-workspace.d.ts +20 -0
- package/dist/lib/workflow-workspace.d.ts.map +1 -0
- package/dist/lib/workflow-workspace.js +65 -0
- package/dist/lib/workflow-workspace.js.map +1 -0
- package/dist/lib/ws-connection-health.d.ts +10 -0
- package/dist/lib/ws-connection-health.d.ts.map +1 -0
- package/dist/lib/ws-connection-health.js +38 -0
- package/dist/lib/ws-connection-health.js.map +1 -0
- package/dist/lib/ws-rate-limit.d.ts +22 -0
- package/dist/lib/ws-rate-limit.d.ts.map +1 -0
- package/dist/lib/ws-rate-limit.js +45 -0
- package/dist/lib/ws-rate-limit.js.map +1 -0
- package/dist/lib/ws-upgrade.d.ts +40 -0
- package/dist/lib/ws-upgrade.d.ts.map +1 -0
- package/dist/lib/ws-upgrade.js +66 -0
- package/dist/lib/ws-upgrade.js.map +1 -0
- package/dist/lib/zip-stream.d.ts +46 -0
- package/dist/lib/zip-stream.d.ts.map +1 -0
- package/dist/lib/zip-stream.js +140 -0
- package/dist/lib/zip-stream.js.map +1 -0
- package/dist/mcp-agent-tools.d.ts +56 -0
- package/dist/mcp-agent-tools.d.ts.map +1 -0
- package/dist/mcp-agent-tools.js +1216 -0
- package/dist/mcp-agent-tools.js.map +1 -0
- package/dist/mcp-server.d.ts +56 -7
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +255 -762
- package/dist/mcp-server.js.map +1 -1
- package/dist/mcp-tool-deps.d.ts +20 -0
- package/dist/mcp-tool-deps.d.ts.map +1 -0
- package/dist/mcp-tool-deps.js +61 -0
- package/dist/mcp-tool-deps.js.map +1 -0
- package/dist/messagepack.d.ts +7 -0
- package/dist/messagepack.d.ts.map +1 -0
- package/dist/messagepack.js +19 -0
- package/dist/messagepack.js.map +1 -0
- package/dist/model-download-runtime.d.ts +9 -0
- package/dist/model-download-runtime.d.ts.map +1 -0
- package/dist/model-download-runtime.js +77 -0
- package/dist/model-download-runtime.js.map +1 -0
- package/dist/model-execution-availability.d.ts +14 -0
- package/dist/model-execution-availability.d.ts.map +1 -0
- package/dist/model-execution-availability.js +161 -0
- package/dist/model-execution-availability.js.map +1 -0
- package/dist/models-api.d.ts +51 -5
- package/dist/models-api.d.ts.map +1 -1
- package/dist/models-api.js +160 -690
- package/dist/models-api.js.map +1 -1
- package/dist/node-registry-setup.d.ts +84 -0
- package/dist/node-registry-setup.d.ts.map +1 -0
- package/dist/node-registry-setup.js +256 -0
- package/dist/node-registry-setup.js.map +1 -0
- package/dist/oauth/cimd.d.ts +28 -0
- package/dist/oauth/cimd.d.ts.map +1 -0
- package/dist/oauth/cimd.js +177 -0
- package/dist/oauth/cimd.js.map +1 -0
- package/dist/oauth/gate.d.ts +38 -0
- package/dist/oauth/gate.d.ts.map +1 -0
- package/dist/oauth/gate.js +77 -0
- package/dist/oauth/gate.js.map +1 -0
- package/dist/oauth/metadata.d.ts +35 -0
- package/dist/oauth/metadata.d.ts.map +1 -0
- package/dist/oauth/metadata.js +56 -0
- package/dist/oauth/metadata.js.map +1 -0
- package/dist/oauth/pending-store.d.ts +79 -0
- package/dist/oauth/pending-store.d.ts.map +1 -0
- package/dist/oauth/pending-store.js +133 -0
- package/dist/oauth/pending-store.js.map +1 -0
- package/dist/oauth/pkce.d.ts +16 -0
- package/dist/oauth/pkce.d.ts.map +1 -0
- package/dist/oauth/pkce.js +29 -0
- package/dist/oauth/pkce.js.map +1 -0
- package/dist/oauth/validate.d.ts +25 -0
- package/dist/oauth/validate.d.ts.map +1 -0
- package/dist/oauth/validate.js +62 -0
- package/dist/oauth/validate.js.map +1 -0
- package/dist/oauth/www-authenticate.d.ts +9 -0
- package/dist/oauth/www-authenticate.d.ts.map +1 -0
- package/dist/oauth/www-authenticate.js +33 -0
- package/dist/oauth/www-authenticate.js.map +1 -0
- package/dist/oauth-api.d.ts +19 -0
- package/dist/oauth-api.d.ts.map +1 -1
- package/dist/oauth-api.js +531 -12
- package/dist/oauth-api.js.map +1 -1
- package/dist/openai-api.d.ts.map +1 -1
- package/dist/openai-api.js +4 -9
- package/dist/openai-api.js.map +1 -1
- package/dist/pack-snapshot.d.ts +24 -0
- package/dist/pack-snapshot.d.ts.map +1 -0
- package/dist/pack-snapshot.js +35 -0
- package/dist/pack-snapshot.js.map +1 -0
- package/dist/plugins/websocket.d.ts +21 -4
- package/dist/plugins/websocket.d.ts.map +1 -1
- package/dist/plugins/websocket.js +136 -290
- package/dist/plugins/websocket.js.map +1 -1
- package/dist/resolve-media-urls.d.ts +17 -3
- package/dist/resolve-media-urls.d.ts.map +1 -1
- package/dist/resolve-media-urls.js +117 -31
- package/dist/resolve-media-urls.js.map +1 -1
- package/dist/resource-events.d.ts +28 -0
- package/dist/resource-events.d.ts.map +1 -0
- package/dist/resource-events.js +20 -0
- package/dist/resource-events.js.map +1 -0
- package/dist/routes/account.d.ts +100 -0
- package/dist/routes/account.d.ts.map +1 -0
- package/dist/routes/account.js +197 -0
- package/dist/routes/account.js.map +1 -0
- package/dist/routes/applications.d.ts +36 -0
- package/dist/routes/applications.d.ts.map +1 -0
- package/dist/routes/applications.js +183 -0
- package/dist/routes/applications.js.map +1 -0
- package/dist/routes/assets.d.ts +3 -3
- package/dist/routes/assets.d.ts.map +1 -1
- package/dist/routes/assets.js +78 -44
- package/dist/routes/assets.js.map +1 -1
- package/dist/routes/atlascloud-webhook.d.ts +93 -0
- package/dist/routes/atlascloud-webhook.d.ts.map +1 -0
- package/dist/routes/atlascloud-webhook.js +369 -0
- package/dist/routes/atlascloud-webhook.js.map +1 -0
- package/dist/routes/collections.d.ts.map +1 -1
- package/dist/routes/config.d.ts +26 -0
- package/dist/routes/config.d.ts.map +1 -0
- package/dist/routes/config.js +64 -0
- package/dist/routes/config.js.map +1 -0
- package/dist/routes/documents.d.ts +27 -0
- package/dist/routes/documents.d.ts.map +1 -0
- package/dist/routes/documents.js +155 -0
- package/dist/routes/documents.js.map +1 -0
- package/dist/routes/fal-credits.d.ts +4 -0
- package/dist/routes/fal-credits.d.ts.map +1 -0
- package/dist/routes/fal-credits.js +101 -0
- package/dist/routes/fal-credits.js.map +1 -0
- package/dist/routes/fal-pricing-estimate.d.ts +4 -0
- package/dist/routes/fal-pricing-estimate.d.ts.map +1 -0
- package/dist/routes/fal-pricing-estimate.js +114 -0
- package/dist/routes/fal-pricing-estimate.js.map +1 -0
- package/dist/routes/fal-pricing.d.ts +4 -0
- package/dist/routes/fal-pricing.d.ts.map +1 -0
- package/dist/routes/fal-pricing.js +93 -0
- package/dist/routes/fal-pricing.js.map +1 -0
- package/dist/routes/fal-webhook.d.ts +102 -0
- package/dist/routes/fal-webhook.d.ts.map +1 -0
- package/dist/routes/fal-webhook.js +379 -0
- package/dist/routes/fal-webhook.js.map +1 -0
- package/dist/routes/files.d.ts.map +1 -1
- package/dist/routes/files.js +4 -3
- package/dist/routes/files.js.map +1 -1
- package/dist/routes/health.d.ts +1 -0
- package/dist/routes/health.d.ts.map +1 -1
- package/dist/routes/health.js +41 -7
- package/dist/routes/health.js.map +1 -1
- package/dist/routes/integrations.d.ts +39 -0
- package/dist/routes/integrations.d.ts.map +1 -0
- package/dist/routes/integrations.js +211 -0
- package/dist/routes/integrations.js.map +1 -0
- package/dist/routes/js-scripts.d.ts +26 -0
- package/dist/routes/js-scripts.d.ts.map +1 -0
- package/dist/routes/js-scripts.js +116 -0
- package/dist/routes/js-scripts.js.map +1 -0
- package/dist/routes/kie-credits.d.ts +4 -0
- package/dist/routes/kie-credits.d.ts.map +1 -0
- package/dist/routes/kie-credits.js +93 -0
- package/dist/routes/kie-credits.js.map +1 -0
- package/dist/routes/kie-pricing.d.ts +4 -0
- package/dist/routes/kie-pricing.d.ts.map +1 -0
- package/dist/routes/kie-pricing.js +45 -0
- package/dist/routes/kie-pricing.js.map +1 -0
- package/dist/routes/kie-webhook.d.ts +4 -0
- package/dist/routes/kie-webhook.d.ts.map +1 -0
- package/dist/routes/kie-webhook.js +70 -0
- package/dist/routes/kie-webhook.js.map +1 -0
- package/dist/routes/nodes.d.ts.map +1 -1
- package/dist/routes/nodes.js +6 -59
- package/dist/routes/nodes.js.map +1 -1
- package/dist/routes/oauth-as.d.ts +30 -0
- package/dist/routes/oauth-as.d.ts.map +1 -0
- package/dist/routes/oauth-as.js +412 -0
- package/dist/routes/oauth-as.js.map +1 -0
- package/dist/routes/oauth.d.ts.map +1 -1
- package/dist/routes/openai.d.ts.map +1 -1
- package/dist/routes/public-apps.d.ts +27 -0
- package/dist/routes/public-apps.d.ts.map +1 -0
- package/dist/routes/public-apps.js +99 -0
- package/dist/routes/public-apps.js.map +1 -0
- package/dist/routes/sandbox-modules.d.ts +17 -0
- package/dist/routes/sandbox-modules.d.ts.map +1 -0
- package/dist/routes/sandbox-modules.js +85 -0
- package/dist/routes/sandbox-modules.js.map +1 -0
- package/dist/routes/sdk-v1.d.ts +24 -0
- package/dist/routes/sdk-v1.d.ts.map +1 -0
- package/dist/routes/sdk-v1.js +320 -0
- package/dist/routes/sdk-v1.js.map +1 -0
- package/dist/routes/storage.d.ts.map +1 -1
- package/dist/routes/storyboards.d.ts +16 -0
- package/dist/routes/storyboards.d.ts.map +1 -0
- package/dist/routes/storyboards.js +97 -0
- package/dist/routes/storyboards.js.map +1 -0
- package/dist/routes/timeline-animations.d.ts +23 -0
- package/dist/routes/timeline-animations.d.ts.map +1 -0
- package/dist/routes/timeline-animations.js +99 -0
- package/dist/routes/timeline-animations.js.map +1 -0
- package/dist/routes/timeline-audio-bake.d.ts +51 -0
- package/dist/routes/timeline-audio-bake.d.ts.map +1 -0
- package/dist/routes/timeline-audio-bake.js +110 -0
- package/dist/routes/timeline-audio-bake.js.map +1 -0
- package/dist/routes/timeline-fonts.d.ts +29 -0
- package/dist/routes/timeline-fonts.d.ts.map +1 -0
- package/dist/routes/timeline-fonts.js +64 -0
- package/dist/routes/timeline-fonts.js.map +1 -0
- package/dist/routes/timeline-isolate-subject.d.ts +55 -0
- package/dist/routes/timeline-isolate-subject.d.ts.map +1 -0
- package/dist/routes/timeline-isolate-subject.js +128 -0
- package/dist/routes/timeline-isolate-subject.js.map +1 -0
- package/dist/routes/timeline-track-object.d.ts +39 -0
- package/dist/routes/timeline-track-object.d.ts.map +1 -0
- package/dist/routes/timeline-track-object.js +97 -0
- package/dist/routes/timeline-track-object.js.map +1 -0
- package/dist/routes/timelines.d.ts +18 -0
- package/dist/routes/timelines.d.ts.map +1 -0
- package/dist/routes/timelines.js +191 -0
- package/dist/routes/timelines.js.map +1 -0
- package/dist/routes/workflows.d.ts +6 -9
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/routes/workflows.js +100 -11
- package/dist/routes/workflows.js.map +1 -1
- package/dist/routes/workspace.d.ts.map +1 -1
- package/dist/run-supervisor.d.ts +30 -0
- package/dist/run-supervisor.d.ts.map +1 -0
- package/dist/run-supervisor.js +86 -0
- package/dist/run-supervisor.js.map +1 -0
- package/dist/sandbox-catalog.d.ts +28 -0
- package/dist/sandbox-catalog.d.ts.map +1 -0
- package/dist/sandbox-catalog.js +74 -0
- package/dist/sandbox-catalog.js.map +1 -0
- package/dist/screenshot-projects.d.ts +27 -0
- package/dist/screenshot-projects.d.ts.map +1 -0
- package/dist/screenshot-projects.js +880 -0
- package/dist/screenshot-projects.js.map +1 -0
- package/dist/screenshot-server.js +947 -43
- package/dist/screenshot-server.js.map +1 -1
- package/dist/sdk/sdk-cached-model-inventory.d.ts +21 -0
- package/dist/sdk/sdk-cached-model-inventory.d.ts.map +1 -0
- package/dist/sdk/sdk-cached-model-inventory.js +51 -0
- package/dist/sdk/sdk-cached-model-inventory.js.map +1 -0
- package/dist/sdk/sdk-capabilities-service.d.ts +32 -0
- package/dist/sdk/sdk-capabilities-service.d.ts.map +1 -0
- package/dist/sdk/sdk-capabilities-service.js +47 -0
- package/dist/sdk/sdk-capabilities-service.js.map +1 -0
- package/dist/sdk/sdk-execution-readiness-probe.d.ts +19 -0
- package/dist/sdk/sdk-execution-readiness-probe.d.ts.map +1 -0
- package/dist/sdk/sdk-execution-readiness-probe.js +90 -0
- package/dist/sdk/sdk-execution-readiness-probe.js.map +1 -0
- package/dist/sdk/sdk-execution-target-readiness.d.ts +15 -0
- package/dist/sdk/sdk-execution-target-readiness.d.ts.map +1 -0
- package/dist/sdk/sdk-execution-target-readiness.js +50 -0
- package/dist/sdk/sdk-execution-target-readiness.js.map +1 -0
- package/dist/sdk/sdk-feature-flags.d.ts +18 -0
- package/dist/sdk/sdk-feature-flags.d.ts.map +1 -0
- package/dist/sdk/sdk-feature-flags.js +30 -0
- package/dist/sdk/sdk-feature-flags.js.map +1 -0
- package/dist/sdk/sdk-huggingface-download-state.d.ts +15 -0
- package/dist/sdk/sdk-huggingface-download-state.d.ts.map +1 -0
- package/dist/sdk/sdk-huggingface-download-state.js +25 -0
- package/dist/sdk/sdk-huggingface-download-state.js.map +1 -0
- package/dist/sdk/sdk-live-runner-registry.d.ts +21 -0
- package/dist/sdk/sdk-live-runner-registry.d.ts.map +1 -0
- package/dist/sdk/sdk-live-runner-registry.js +26 -0
- package/dist/sdk/sdk-live-runner-registry.js.map +1 -0
- package/dist/sdk/sdk-model-catalog-service.d.ts +20 -0
- package/dist/sdk/sdk-model-catalog-service.d.ts.map +1 -0
- package/dist/sdk/sdk-model-catalog-service.js +219 -0
- package/dist/sdk/sdk-model-catalog-service.js.map +1 -0
- package/dist/sdk/sdk-model-download-service.d.ts +39 -0
- package/dist/sdk/sdk-model-download-service.d.ts.map +1 -0
- package/dist/sdk/sdk-model-download-service.js +274 -0
- package/dist/sdk/sdk-model-download-service.js.map +1 -0
- package/dist/sdk/sdk-model-requirement-probe.d.ts +30 -0
- package/dist/sdk/sdk-model-requirement-probe.d.ts.map +1 -0
- package/dist/sdk/sdk-model-requirement-probe.js +120 -0
- package/dist/sdk/sdk-model-requirement-probe.js.map +1 -0
- package/dist/sdk/sdk-node-package-requirement-probe.d.ts +20 -0
- package/dist/sdk/sdk-node-package-requirement-probe.d.ts.map +1 -0
- package/dist/sdk/sdk-node-package-requirement-probe.js +44 -0
- package/dist/sdk/sdk-node-package-requirement-probe.js.map +1 -0
- package/dist/sdk/sdk-node-type-inventory-service.d.ts +11 -0
- package/dist/sdk/sdk-node-type-inventory-service.d.ts.map +1 -0
- package/dist/sdk/sdk-node-type-inventory-service.js +36 -0
- package/dist/sdk/sdk-node-type-inventory-service.js.map +1 -0
- package/dist/sdk/sdk-preflight-orchestrator.d.ts +54 -0
- package/dist/sdk/sdk-preflight-orchestrator.d.ts.map +1 -0
- package/dist/sdk/sdk-preflight-orchestrator.js +63 -0
- package/dist/sdk/sdk-preflight-orchestrator.js.map +1 -0
- package/dist/sdk/sdk-preflight-requirement-resolver.d.ts +35 -0
- package/dist/sdk/sdk-preflight-requirement-resolver.d.ts.map +1 -0
- package/dist/sdk/sdk-preflight-requirement-resolver.js +67 -0
- package/dist/sdk/sdk-preflight-requirement-resolver.js.map +1 -0
- package/dist/sdk/sdk-preflight-service.d.ts +61 -0
- package/dist/sdk/sdk-preflight-service.d.ts.map +1 -0
- package/dist/sdk/sdk-preflight-service.js +104 -0
- package/dist/sdk/sdk-preflight-service.js.map +1 -0
- package/dist/sdk/sdk-preflight-workflow-source.d.ts +18 -0
- package/dist/sdk/sdk-preflight-workflow-source.d.ts.map +1 -0
- package/dist/sdk/sdk-preflight-workflow-source.js +42 -0
- package/dist/sdk/sdk-preflight-workflow-source.js.map +1 -0
- package/dist/sdk/sdk-route-policy.d.ts +3 -0
- package/dist/sdk/sdk-route-policy.d.ts.map +1 -0
- package/dist/sdk/sdk-route-policy.js +18 -0
- package/dist/sdk/sdk-route-policy.js.map +1 -0
- package/dist/sdk/sdk-runtime-capabilities-service.d.ts +60 -0
- package/dist/sdk/sdk-runtime-capabilities-service.d.ts.map +1 -0
- package/dist/sdk/sdk-runtime-capabilities-service.js +30 -0
- package/dist/sdk/sdk-runtime-capabilities-service.js.map +1 -0
- package/dist/sdk/sdk-runtime-requirement-probe.d.ts +13 -0
- package/dist/sdk/sdk-runtime-requirement-probe.d.ts.map +1 -0
- package/dist/sdk/sdk-runtime-requirement-probe.js +55 -0
- package/dist/sdk/sdk-runtime-requirement-probe.js.map +1 -0
- package/dist/sdk/sdk-static-preflight-service.d.ts +66 -0
- package/dist/sdk/sdk-static-preflight-service.d.ts.map +1 -0
- package/dist/sdk/sdk-static-preflight-service.js +492 -0
- package/dist/sdk/sdk-static-preflight-service.js.map +1 -0
- package/dist/sdk/sdk-temporary-asset-service.d.ts +18 -0
- package/dist/sdk/sdk-temporary-asset-service.d.ts.map +1 -0
- package/dist/sdk/sdk-temporary-asset-service.js +33 -0
- package/dist/sdk/sdk-temporary-asset-service.js.map +1 -0
- package/dist/sdk/sdk-temporary-asset-upload-http-handler.d.ts +9 -0
- package/dist/sdk/sdk-temporary-asset-upload-http-handler.d.ts.map +1 -0
- package/dist/sdk/sdk-temporary-asset-upload-http-handler.js +65 -0
- package/dist/sdk/sdk-temporary-asset-upload-http-handler.js.map +1 -0
- package/dist/sdk/sdk-v1-handler-map.d.ts +44 -0
- package/dist/sdk/sdk-v1-handler-map.d.ts.map +1 -0
- package/dist/sdk/sdk-v1-handler-map.js +37 -0
- package/dist/sdk/sdk-v1-handler-map.js.map +1 -0
- package/dist/sdk/sdk-v1-service-error.d.ts +21 -0
- package/dist/sdk/sdk-v1-service-error.d.ts.map +1 -0
- package/dist/sdk/sdk-v1-service-error.js +62 -0
- package/dist/sdk/sdk-v1-service-error.js.map +1 -0
- package/dist/sdk/sdk-v1-service.d.ts +74 -0
- package/dist/sdk/sdk-v1-service.d.ts.map +1 -0
- package/dist/sdk/sdk-v1-service.js +219 -0
- package/dist/sdk/sdk-v1-service.js.map +1 -0
- package/dist/sdk/sdk-worker-readiness-adapter.d.ts +22 -0
- package/dist/sdk/sdk-worker-readiness-adapter.d.ts.map +1 -0
- package/dist/sdk/sdk-worker-readiness-adapter.js +29 -0
- package/dist/sdk/sdk-worker-readiness-adapter.js.map +1 -0
- package/dist/server.js +1019 -201
- package/dist/server.js.map +1 -1
- package/dist/session/asset-autosave.d.ts +80 -0
- package/dist/session/asset-autosave.d.ts.map +1 -0
- package/dist/session/asset-autosave.js +456 -0
- package/dist/session/asset-autosave.js.map +1 -0
- package/dist/session/chat-compaction.d.ts +107 -0
- package/dist/session/chat-compaction.d.ts.map +1 -0
- package/dist/session/chat-compaction.js +191 -0
- package/dist/session/chat-compaction.js.map +1 -0
- package/dist/session/chat-history.d.ts +75 -0
- package/dist/session/chat-history.d.ts.map +1 -0
- package/dist/session/chat-history.js +194 -0
- package/dist/session/chat-history.js.map +1 -0
- package/dist/session/chat-prompt.d.ts +45 -0
- package/dist/session/chat-prompt.d.ts.map +1 -0
- package/dist/session/chat-prompt.js +480 -0
- package/dist/session/chat-prompt.js.map +1 -0
- package/dist/session/chat-turn.d.ts +336 -0
- package/dist/session/chat-turn.d.ts.map +1 -0
- package/dist/session/chat-turn.js +3516 -0
- package/dist/session/chat-turn.js.map +1 -0
- package/dist/session/client-session.d.ts +59 -0
- package/dist/session/client-session.d.ts.map +1 -0
- package/dist/session/client-session.js +2 -0
- package/dist/session/client-session.js.map +1 -0
- package/dist/session/commands.d.ts +133 -0
- package/dist/session/commands.d.ts.map +1 -0
- package/dist/session/commands.js +778 -0
- package/dist/session/commands.js.map +1 -0
- package/dist/session/inference.d.ts +213 -0
- package/dist/session/inference.d.ts.map +1 -0
- package/dist/session/inference.js +1072 -0
- package/dist/session/inference.js.map +1 -0
- package/dist/session/job-execution.d.ts +477 -0
- package/dist/session/job-execution.d.ts.map +1 -0
- package/dist/session/job-execution.js +2089 -0
- package/dist/session/job-execution.js.map +1 -0
- package/dist/session/media-generation.d.ts +94 -0
- package/dist/session/media-generation.d.ts.map +1 -0
- package/dist/session/media-generation.js +234 -0
- package/dist/session/media-generation.js.map +1 -0
- package/dist/session/model-interfaces.d.ts +27 -0
- package/dist/session/model-interfaces.d.ts.map +1 -0
- package/dist/session/model-interfaces.js +132 -0
- package/dist/session/model-interfaces.js.map +1 -0
- package/dist/session/sanitize.d.ts +7 -0
- package/dist/session/sanitize.d.ts.map +1 -0
- package/dist/session/sanitize.js +64 -0
- package/dist/session/sanitize.js.map +1 -0
- package/dist/settings-registry.d.ts +6 -15
- package/dist/settings-registry.d.ts.map +1 -1
- package/dist/settings-registry.js +6 -103
- package/dist/settings-registry.js.map +1 -1
- package/dist/storage-api.d.ts +20 -0
- package/dist/storage-api.d.ts.map +1 -1
- package/dist/storage-api.js +260 -77
- package/dist/storage-api.js.map +1 -1
- package/dist/storage-retention.d.ts +9 -0
- package/dist/storage-retention.d.ts.map +1 -0
- package/dist/storage-retention.js +74 -0
- package/dist/storage-retention.js.map +1 -0
- package/dist/system-stats.d.ts +52 -0
- package/dist/system-stats.d.ts.map +1 -0
- package/dist/system-stats.js +134 -0
- package/dist/system-stats.js.map +1 -0
- package/dist/test-ui-server.d.ts +46 -0
- package/dist/test-ui-server.d.ts.map +1 -1
- package/dist/test-ui-server.js +188 -41
- package/dist/test-ui-server.js.map +1 -1
- package/dist/triggers/boot.d.ts +73 -0
- package/dist/triggers/boot.d.ts.map +1 -0
- package/dist/triggers/boot.js +149 -0
- package/dist/triggers/boot.js.map +1 -0
- package/dist/triggers/dispatcher.d.ts +234 -0
- package/dist/triggers/dispatcher.d.ts.map +1 -0
- package/dist/triggers/dispatcher.js +525 -0
- package/dist/triggers/dispatcher.js.map +1 -0
- package/dist/triggers/file-watch.d.ts +90 -0
- package/dist/triggers/file-watch.d.ts.map +1 -0
- package/dist/triggers/file-watch.js +405 -0
- package/dist/triggers/file-watch.js.map +1 -0
- package/dist/triggers/registration-sync.d.ts +34 -0
- package/dist/triggers/registration-sync.d.ts.map +1 -0
- package/dist/triggers/registration-sync.js +162 -0
- package/dist/triggers/registration-sync.js.map +1 -0
- package/dist/triggers/schedule-timing.d.ts +52 -0
- package/dist/triggers/schedule-timing.d.ts.map +1 -0
- package/dist/triggers/schedule-timing.js +90 -0
- package/dist/triggers/schedule-timing.js.map +1 -0
- package/dist/triggers/scheduler.d.ts +55 -0
- package/dist/triggers/scheduler.d.ts.map +1 -0
- package/dist/triggers/scheduler.js +122 -0
- package/dist/triggers/scheduler.js.map +1 -0
- package/dist/triggers/settle.d.ts +66 -0
- package/dist/triggers/settle.d.ts.map +1 -0
- package/dist/triggers/settle.js +99 -0
- package/dist/triggers/settle.js.map +1 -0
- package/dist/triggers/stores.d.ts +38 -0
- package/dist/triggers/stores.d.ts.map +1 -0
- package/dist/triggers/stores.js +168 -0
- package/dist/triggers/stores.js.map +1 -0
- package/dist/triggers/webhook-route.d.ts +49 -0
- package/dist/triggers/webhook-route.d.ts.map +1 -0
- package/dist/triggers/webhook-route.js +148 -0
- package/dist/triggers/webhook-route.js.map +1 -0
- package/dist/trpc/context.d.ts +52 -5
- package/dist/trpc/context.d.ts.map +1 -1
- package/dist/trpc/context.js +4 -1
- package/dist/trpc/context.js.map +1 -1
- package/dist/trpc/error-formatter.d.ts.map +1 -1
- package/dist/trpc/error-formatter.js +23 -2
- package/dist/trpc/error-formatter.js.map +1 -1
- package/dist/trpc/error-logging.d.ts +14 -0
- package/dist/trpc/error-logging.d.ts.map +1 -0
- package/dist/trpc/error-logging.js +27 -0
- package/dist/trpc/error-logging.js.map +1 -0
- package/dist/trpc/index.d.ts +2 -2
- package/dist/trpc/index.d.ts.map +1 -1
- package/dist/trpc/index.js +0 -2
- package/dist/trpc/index.js.map +1 -1
- package/dist/trpc/middleware.d.ts +6 -3
- package/dist/trpc/middleware.d.ts.map +1 -1
- package/dist/trpc/router.d.ts +29791 -1303
- package/dist/trpc/router.d.ts.map +1 -1
- package/dist/trpc/router.js +46 -3
- package/dist/trpc/router.js.map +1 -1
- package/dist/trpc/routers/agent-access.d.ts +149 -0
- package/dist/trpc/routers/agent-access.d.ts.map +1 -0
- package/dist/trpc/routers/agent-access.js +224 -0
- package/dist/trpc/routers/agent-access.js.map +1 -0
- package/dist/trpc/routers/applications.d.ts +1117 -0
- package/dist/trpc/routers/applications.d.ts.map +1 -0
- package/dist/trpc/routers/applications.js +218 -0
- package/dist/trpc/routers/applications.js.map +1 -0
- package/dist/trpc/routers/assets.d.ts +184 -42
- package/dist/trpc/routers/assets.d.ts.map +1 -1
- package/dist/trpc/routers/assets.js +499 -105
- package/dist/trpc/routers/assets.js.map +1 -1
- package/dist/trpc/routers/code-gen.d.ts +99 -0
- package/dist/trpc/routers/code-gen.d.ts.map +1 -0
- package/dist/trpc/routers/code-gen.js +164 -0
- package/dist/trpc/routers/code-gen.js.map +1 -0
- package/dist/trpc/routers/collections.d.ts +1 -26
- package/dist/trpc/routers/collections.d.ts.map +1 -1
- package/dist/trpc/routers/collections.js +145 -78
- package/dist/trpc/routers/collections.js.map +1 -1
- package/dist/trpc/routers/costs.d.ts +40 -96
- package/dist/trpc/routers/costs.d.ts.map +1 -1
- package/dist/trpc/routers/costs.js +14 -89
- package/dist/trpc/routers/costs.js.map +1 -1
- package/dist/trpc/routers/credits.d.ts +110 -0
- package/dist/trpc/routers/credits.d.ts.map +1 -0
- package/dist/trpc/routers/credits.js +69 -0
- package/dist/trpc/routers/credits.js.map +1 -0
- package/dist/trpc/routers/custom-providers.d.ts +88 -0
- package/dist/trpc/routers/custom-providers.d.ts.map +1 -0
- package/dist/trpc/routers/custom-providers.js +140 -0
- package/dist/trpc/routers/custom-providers.js.map +1 -0
- package/dist/trpc/routers/documents.d.ts +61 -0
- package/dist/trpc/routers/documents.d.ts.map +1 -0
- package/dist/trpc/routers/documents.js +23 -0
- package/dist/trpc/routers/documents.js.map +1 -0
- package/dist/trpc/routers/extension.d.ts +24 -0
- package/dist/trpc/routers/extension.d.ts.map +1 -0
- package/dist/trpc/routers/extension.js +28 -0
- package/dist/trpc/routers/extension.js.map +1 -0
- package/dist/trpc/routers/external-mcp.d.ts +108 -0
- package/dist/trpc/routers/external-mcp.d.ts.map +1 -0
- package/dist/trpc/routers/external-mcp.js +70 -0
- package/dist/trpc/routers/external-mcp.js.map +1 -0
- package/dist/trpc/routers/files.d.ts +9 -2
- package/dist/trpc/routers/files.d.ts.map +1 -1
- package/dist/trpc/routers/files.js +67 -37
- package/dist/trpc/routers/files.js.map +1 -1
- package/dist/trpc/routers/fonts.d.ts +30 -0
- package/dist/trpc/routers/fonts.d.ts.map +1 -0
- package/dist/trpc/routers/fonts.js +112 -0
- package/dist/trpc/routers/fonts.js.map +1 -0
- package/dist/trpc/routers/games.d.ts +7610 -0
- package/dist/trpc/routers/games.d.ts.map +1 -0
- package/dist/trpc/routers/games.js +456 -0
- package/dist/trpc/routers/games.js.map +1 -0
- package/dist/trpc/routers/integrations.d.ts +86 -0
- package/dist/trpc/routers/integrations.d.ts.map +1 -0
- package/dist/trpc/routers/integrations.js +129 -0
- package/dist/trpc/routers/integrations.js.map +1 -0
- package/dist/trpc/routers/jobs.d.ts +88 -27
- package/dist/trpc/routers/jobs.d.ts.map +1 -1
- package/dist/trpc/routers/jobs.js +113 -35
- package/dist/trpc/routers/jobs.js.map +1 -1
- package/dist/trpc/routers/js-scripts.d.ts +410 -0
- package/dist/trpc/routers/js-scripts.d.ts.map +1 -0
- package/dist/trpc/routers/js-scripts.js +303 -0
- package/dist/trpc/routers/js-scripts.js.map +1 -0
- package/dist/trpc/routers/mcp-config.d.ts +1 -1
- package/dist/trpc/routers/mcp-config.js +5 -3
- package/dist/trpc/routers/mcp-config.js.map +1 -1
- package/dist/trpc/routers/memories.d.ts +79 -0
- package/dist/trpc/routers/memories.d.ts.map +1 -0
- package/dist/trpc/routers/memories.js +66 -0
- package/dist/trpc/routers/memories.js.map +1 -0
- package/dist/trpc/routers/messages.d.ts +4 -77
- package/dist/trpc/routers/messages.d.ts.map +1 -1
- package/dist/trpc/routers/messages.js +9 -58
- package/dist/trpc/routers/messages.js.map +1 -1
- package/dist/trpc/routers/models.d.ts +1403 -238
- package/dist/trpc/routers/models.d.ts.map +1 -1
- package/dist/trpc/routers/models.js +532 -294
- package/dist/trpc/routers/models.js.map +1 -1
- package/dist/trpc/routers/nodes.d.ts +32 -16
- package/dist/trpc/routers/nodes.d.ts.map +1 -1
- package/dist/trpc/routers/nodes.js +70 -31
- package/dist/trpc/routers/nodes.js.map +1 -1
- package/dist/trpc/routers/packs.d.ts +184 -0
- package/dist/trpc/routers/packs.d.ts.map +1 -0
- package/dist/trpc/routers/packs.js +259 -0
- package/dist/trpc/routers/packs.js.map +1 -0
- package/dist/trpc/routers/projects.d.ts +422 -0
- package/dist/trpc/routers/projects.d.ts.map +1 -0
- package/dist/trpc/routers/projects.js +373 -0
- package/dist/trpc/routers/projects.js.map +1 -0
- package/dist/trpc/routers/resources.d.ts +120 -0
- package/dist/trpc/routers/resources.d.ts.map +1 -0
- package/dist/trpc/routers/resources.js +212 -0
- package/dist/trpc/routers/resources.js.map +1 -0
- package/dist/trpc/routers/scripts.d.ts +1116 -0
- package/dist/trpc/routers/scripts.d.ts.map +1 -0
- package/dist/trpc/routers/scripts.js +131 -0
- package/dist/trpc/routers/scripts.js.map +1 -0
- package/dist/trpc/routers/segmentation.d.ts +62 -0
- package/dist/trpc/routers/segmentation.d.ts.map +1 -0
- package/dist/trpc/routers/segmentation.js +146 -0
- package/dist/trpc/routers/segmentation.js.map +1 -0
- package/dist/trpc/routers/settings.d.ts +177 -10
- package/dist/trpc/routers/settings.d.ts.map +1 -1
- package/dist/trpc/routers/settings.js +123 -33
- package/dist/trpc/routers/settings.js.map +1 -1
- package/dist/trpc/routers/sketch.d.ts +854 -0
- package/dist/trpc/routers/sketch.d.ts.map +1 -0
- package/dist/trpc/routers/sketch.js +617 -0
- package/dist/trpc/routers/sketch.js.map +1 -0
- package/dist/trpc/routers/skills.d.ts +76 -22
- package/dist/trpc/routers/skills.d.ts.map +1 -1
- package/dist/trpc/routers/skills.js +195 -170
- package/dist/trpc/routers/skills.js.map +1 -1
- package/dist/trpc/routers/storage.d.ts +3 -30
- package/dist/trpc/routers/storage.d.ts.map +1 -1
- package/dist/trpc/routers/storage.js +60 -117
- package/dist/trpc/routers/storage.js.map +1 -1
- package/dist/trpc/routers/storyboards.d.ts +5907 -0
- package/dist/trpc/routers/storyboards.d.ts.map +1 -0
- package/dist/trpc/routers/storyboards.js +156 -0
- package/dist/trpc/routers/storyboards.js.map +1 -0
- package/dist/trpc/routers/threads.d.ts +33 -21
- package/dist/trpc/routers/threads.d.ts.map +1 -1
- package/dist/trpc/routers/threads.js +36 -30
- package/dist/trpc/routers/threads.js.map +1 -1
- package/dist/trpc/routers/timeline.d.ts +8516 -0
- package/dist/trpc/routers/timeline.d.ts.map +1 -0
- package/dist/trpc/routers/timeline.js +493 -0
- package/dist/trpc/routers/timeline.js.map +1 -0
- package/dist/trpc/routers/triggers.d.ts +46 -0
- package/dist/trpc/routers/triggers.d.ts.map +1 -0
- package/dist/trpc/routers/triggers.js +117 -0
- package/dist/trpc/routers/triggers.js.map +1 -0
- package/dist/trpc/routers/users.d.ts +1 -14
- package/dist/trpc/routers/users.d.ts.map +1 -1
- package/dist/trpc/routers/users.js +1 -12
- package/dist/trpc/routers/users.js.map +1 -1
- package/dist/trpc/routers/worker.d.ts +242 -0
- package/dist/trpc/routers/worker.d.ts.map +1 -0
- package/dist/trpc/routers/worker.js +220 -0
- package/dist/trpc/routers/worker.js.map +1 -0
- package/dist/trpc/routers/workflows.d.ts +385 -197
- package/dist/trpc/routers/workflows.d.ts.map +1 -1
- package/dist/trpc/routers/workflows.js +326 -345
- package/dist/trpc/routers/workflows.js.map +1 -1
- package/dist/trpc/routers/workspace.d.ts +59 -33
- package/dist/trpc/routers/workspace.d.ts.map +1 -1
- package/dist/trpc/routers/workspace.js +230 -93
- package/dist/trpc/routers/workspace.js.map +1 -1
- package/dist/trpc/sandbox-coverage.d.ts +64 -0
- package/dist/trpc/sandbox-coverage.d.ts.map +1 -0
- package/dist/trpc/sandbox-coverage.js +1049 -0
- package/dist/trpc/sandbox-coverage.js.map +1 -0
- package/dist/websocket-client-session.d.ts +320 -0
- package/dist/websocket-client-session.d.ts.map +1 -0
- package/dist/websocket-client-session.js +1253 -0
- package/dist/websocket-client-session.js.map +1 -0
- package/dist/workflow-interface-service.d.ts +87 -0
- package/dist/workflow-interface-service.d.ts.map +1 -0
- package/dist/workflow-interface-service.js +131 -0
- package/dist/workflow-interface-service.js.map +1 -0
- package/dist/workspace-api.d.ts.map +1 -1
- package/dist/workspace-api.js +33 -23
- package/dist/workspace-api.js.map +1 -1
- package/dist/ws-adapter.d.ts +46 -3
- package/dist/ws-adapter.d.ts.map +1 -1
- package/dist/ws-adapter.js +164 -26
- package/dist/ws-adapter.js.map +1 -1
- package/package.json +81 -35
- package/dist/agent/agent-runtime.d.ts +0 -47
- package/dist/agent/agent-runtime.d.ts.map +0 -1
- package/dist/agent/agent-runtime.js +0 -579
- package/dist/agent/agent-runtime.js.map +0 -1
- package/dist/agent/codex-agent.d.ts +0 -41
- package/dist/agent/codex-agent.d.ts.map +0 -1
- package/dist/agent/codex-agent.js +0 -334
- package/dist/agent/codex-agent.js.map +0 -1
- package/dist/agent/index.d.ts +0 -6
- package/dist/agent/index.d.ts.map +0 -1
- package/dist/agent/index.js +0 -4
- package/dist/agent/index.js.map +0 -1
- package/dist/agent/llm-agent.d.ts +0 -51
- package/dist/agent/llm-agent.d.ts.map +0 -1
- package/dist/agent/llm-agent.js +0 -526
- package/dist/agent/llm-agent.js.map +0 -1
- package/dist/agent/mcp-tool-server.d.ts +0 -33
- package/dist/agent/mcp-tool-server.d.ts.map +0 -1
- package/dist/agent/mcp-tool-server.js +0 -292
- package/dist/agent/mcp-tool-server.js.map +0 -1
- package/dist/agent/opencode-agent.d.ts +0 -32
- package/dist/agent/opencode-agent.d.ts.map +0 -1
- package/dist/agent/opencode-agent.js +0 -332
- package/dist/agent/opencode-agent.js.map +0 -1
- package/dist/agent/pi-agent.d.ts +0 -42
- package/dist/agent/pi-agent.d.ts.map +0 -1
- package/dist/agent/pi-agent.js +0 -429
- package/dist/agent/pi-agent.js.map +0 -1
- package/dist/agent/sdk-provider.d.ts +0 -46
- package/dist/agent/sdk-provider.d.ts.map +0 -1
- package/dist/agent/sdk-provider.js +0 -50
- package/dist/agent/sdk-provider.js.map +0 -1
- package/dist/agent/socket-route.d.ts +0 -11
- package/dist/agent/socket-route.d.ts.map +0 -1
- package/dist/agent/socket-route.js +0 -262
- package/dist/agent/socket-route.js.map +0 -1
- package/dist/agent/transport.d.ts +0 -39
- package/dist/agent/transport.d.ts.map +0 -1
- package/dist/agent/transport.js +0 -17
- package/dist/agent/transport.js.map +0 -1
- package/dist/agent/types.d.ts +0 -11
- package/dist/agent/types.d.ts.map +0 -1
- package/dist/agent/types.js +0 -10
- package/dist/agent/types.js.map +0 -1
- package/dist/routes/jobs.d.ts +0 -16
- package/dist/routes/jobs.d.ts.map +0 -1
- package/dist/routes/jobs.js +0 -25
- package/dist/routes/jobs.js.map +0 -1
- package/dist/trpc/routers/sandboxes.d.ts +0 -64
- package/dist/trpc/routers/sandboxes.d.ts.map +0 -1
- package/dist/trpc/routers/sandboxes.js +0 -327
- package/dist/trpc/routers/sandboxes.js.map +0 -1
- package/dist/unified-websocket-runner.d.ts +0 -280
- package/dist/unified-websocket-runner.d.ts.map +0 -1
- package/dist/unified-websocket-runner.js +0 -3840
- package/dist/unified-websocket-runner.js.map +0 -1
package/dist/server.js
CHANGED
|
@@ -6,49 +6,112 @@
|
|
|
6
6
|
* An HTTP→HTTPS redirect server starts on port 80 when TLS is active.
|
|
7
7
|
* Connect the CLI with: npm run chat -- --url ws://localhost:7777/ws
|
|
8
8
|
*/
|
|
9
|
+
import { startGenerationReconcileWorker, sweepInterruptedGenerations } from "@nodetool-ai/execution";
|
|
9
10
|
import { join, resolve, dirname } from "node:path";
|
|
10
11
|
import { fileURLToPath } from "node:url";
|
|
11
12
|
import { existsSync, mkdirSync, readFileSync, readdirSync } from "node:fs";
|
|
12
13
|
import { spawnSync } from "node:child_process";
|
|
13
14
|
import { createServer as createHttpServer } from "node:http";
|
|
14
15
|
import crypto from "node:crypto";
|
|
15
|
-
import { createLogger, configureLogging, getDefaultDbPath } from "@nodetool-ai/config";
|
|
16
|
-
import { NodeRegistry } from "@nodetool-ai/node-sdk";
|
|
17
|
-
import { registerBaseNodes } from "@nodetool-ai/base-nodes";
|
|
18
|
-
import { registerElevenLabsNodes } from "@nodetool-ai/elevenlabs-nodes";
|
|
19
|
-
import { registerTransformersJsNodes } from "@nodetool-ai/transformers-js-nodes";
|
|
16
|
+
import { createLogger, configureLogging, getDefaultDbPath, getPostgresDatabaseUrl, loadEnvironment } from "@nodetool-ai/config";
|
|
20
17
|
import { registerTransformersJsProvider } from "@nodetool-ai/transformers-js-provider";
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
18
|
+
import { setCodeNodeAgentsModule } from "@nodetool-ai/base-nodes";
|
|
19
|
+
import * as agentsModule from "@nodetool-ai/agents";
|
|
20
|
+
import { bootstrapNodeRegistry, mergePythonBridgeMetadata } from "./node-registry-setup.js";
|
|
21
|
+
import { corsOriginDelegate } from "./cors.js";
|
|
22
|
+
import { zipExtensionDist } from "./lib/extension-dist.js";
|
|
23
|
+
import { isPublicAuthExemptRoute } from "./lib/public-routes.js";
|
|
24
|
+
import { isWebSocketUpgrade, denyUnauthorized, denyDraining } from "./lib/ws-upgrade.js";
|
|
25
|
+
import { isDraining, startDrain } from "./drain.js";
|
|
26
|
+
import { chatTurnRegistry } from "./chat-turn-registry.js";
|
|
27
|
+
import { jobRunRegistry } from "./job-run-registry.js";
|
|
28
|
+
import { replayUpgradeToOwner } from "./lib/fly-replay.js";
|
|
29
|
+
import { startJobCancelPoller } from "./job-control.js";
|
|
30
|
+
import { resolveTrustLocalhost, isLoopbackAddress, parseTrustedProxies, parseTrustedLocalNetworks, isTrustedLocalAddress } from "./lib/localhost-trust.js";
|
|
31
|
+
import { initTelemetry, shutdownTelemetry, createPythonBridge, WebsocketPythonBridge, SwappableBridge, logPythonWorkerStderr } from "@nodetool-ai/runtime";
|
|
32
|
+
import { deriveKey, getMasterKey, initMasterKey } from "@nodetool-ai/security";
|
|
33
|
+
import { setDefaultModelInterfaces } from "@nodetool-ai/runtime";
|
|
34
|
+
import { serverModelInterfaces } from "./websocket-client-session.js";
|
|
35
|
+
import { WorkerManager, attachWorkerActivityHeartbeat, startReaper } from "@nodetool-ai/compute";
|
|
36
|
+
import { getSecret, AccessToken, getWorkerProfile, initDb, initPostgresDb, isAccessToken, McpOauthClient, MCP_OAUTH_ACCESS_TOKEN_PREFIX, migrateSqliteDb, runSeeds } from "@nodetool-ai/models";
|
|
37
|
+
import { isMcpHttpEnabled, MCP_ENABLE_FLAG } from "./lib/mcp-mount.js";
|
|
38
|
+
import { authenticateMcpAccessToken, mcpBearerChallenge } from "./oauth/gate.js";
|
|
39
|
+
import { registerPythonProviders, relayWorkerDownload } from "./models-api.js";
|
|
40
|
+
import { syncCustomProviderRegistry } from "./custom-providers.js";
|
|
41
|
+
import { runAutomaticStorageCleanup } from "./storage-retention.js";
|
|
42
|
+
import { createGenerationRecoveryWorker } from "./generation-recovery.js";
|
|
43
|
+
/** User id the auth middleware assigns in local (no-account) mode. */
|
|
44
|
+
const LOCAL_USER_ID = "1";
|
|
45
|
+
/** How long an MCP OAuth client nobody ever approved is kept before the
|
|
46
|
+
* periodic cleanup deletes it. */
|
|
47
|
+
const UNUSED_OAUTH_CLIENT_TTL_MS = 30 * 24 * 60 * 60 * 1000;
|
|
48
|
+
import { TRPC_MAX_BATCH_SIZE } from "@nodetool-ai/protocol";
|
|
29
49
|
import { handleMcpHttpRequest } from "./mcp-server.js";
|
|
30
50
|
import Fastify from "fastify";
|
|
31
51
|
import fastifyWebSocket from "@fastify/websocket";
|
|
32
52
|
import fastifyCors from "@fastify/cors";
|
|
53
|
+
import fastifyRateLimit from "@fastify/rate-limit";
|
|
33
54
|
import fastifyStatic from "@fastify/static";
|
|
34
|
-
import {
|
|
35
|
-
import { SupabaseAuthProvider, LocalAuthProvider } from "@nodetool-ai/auth";
|
|
55
|
+
import { packWebSocketMessage } from "./messagepack.js";
|
|
56
|
+
import { SupabaseAuthProvider, LocalAuthProvider, DelegatedTokenProvider, isDelegatedToken, AppSessionTokenProvider, isAppSessionToken } from "@nodetool-ai/auth";
|
|
36
57
|
import { fastifyTRPCPlugin } from "@trpc/server/adapters/fastify";
|
|
37
58
|
import { appRouter } from "./trpc/router.js";
|
|
38
59
|
import { createContextFactory } from "./trpc/context.js";
|
|
60
|
+
import { getHttpRateLimitConfig, rateLimitKey, isRateLimitExempt } from "./lib/http-rate-limit.js";
|
|
61
|
+
import { createTriggerWebhookRoute, startTriggerServices, triggersEnabled } from "./triggers/boot.js";
|
|
39
62
|
import websocketPlugin from "./plugins/websocket.js";
|
|
40
|
-
import healthRoute from "./routes/health.js";
|
|
63
|
+
import healthRoute, { getVersion } from "./routes/health.js";
|
|
64
|
+
import configRoute, { describeMissingAnonKey } from "./routes/config.js";
|
|
41
65
|
import assetsRoutes from "./routes/assets.js";
|
|
66
|
+
import timelineFontRoutes from "./routes/timeline-fonts.js";
|
|
67
|
+
import sdkV1Routes from "./routes/sdk-v1.js";
|
|
42
68
|
import workflowsRoutes from "./routes/workflows.js";
|
|
43
|
-
import jobsRoutes from "./routes/jobs.js";
|
|
44
69
|
import nodesRoutes from "./routes/nodes.js";
|
|
45
70
|
import storageRoutes from "./routes/storage.js";
|
|
46
71
|
import openaiRoutes from "./routes/openai.js";
|
|
47
72
|
import oauthRoutes from "./routes/oauth.js";
|
|
73
|
+
import { oauthAsRoutes } from "./routes/oauth-as.js";
|
|
74
|
+
import { isSdkV1AuthenticationRequired, isSdkV1DiscoveryRequest } from "./sdk/sdk-route-policy.js";
|
|
75
|
+
import { createNodeToolSdkV1CapabilitiesProvider } from "./sdk/sdk-runtime-capabilities-service.js";
|
|
76
|
+
import { createSdkV1ModelDownloadService } from "./sdk/sdk-model-download-service.js";
|
|
77
|
+
import { getSdkV1ModelCatalog, SdkModelCatalogServiceError } from "./sdk/sdk-model-catalog-service.js";
|
|
78
|
+
import { unifiedModel } from "@nodetool-ai/protocol/api-schemas/models.js";
|
|
79
|
+
import { createNodeToolSdkV1PreflightService } from "./sdk/sdk-preflight-service.js";
|
|
80
|
+
import { createSdkV1ExecutionTargetReadiness } from "./sdk/sdk-execution-target-readiness.js";
|
|
81
|
+
import { SdkLiveRunnerRegistry } from "./sdk/sdk-live-runner-registry.js";
|
|
82
|
+
import { createSdkV1Service } from "./sdk/sdk-v1-service.js";
|
|
83
|
+
import { createSdkV1ImplementationBoundary } from "./sdk/sdk-v1-handler-map.js";
|
|
84
|
+
import { createSdkV1TemporaryAssetService } from "./sdk/sdk-temporary-asset-service.js";
|
|
85
|
+
import { getTempAdapter } from "./lib/storage.js";
|
|
86
|
+
import { FrontendRendererRegistry } from "./frontend-renderer-registry.js";
|
|
48
87
|
import workspaceRoutes from "./routes/workspace.js";
|
|
88
|
+
import { initWorkspaceChangeEvents, initWorkspaceStorage } from "./lib/workflow-workspace.js";
|
|
49
89
|
import filesRoutes from "./routes/files.js";
|
|
50
90
|
import collectionsRoutes from "./routes/collections.js";
|
|
51
|
-
import
|
|
91
|
+
import applicationsRoutes from "./routes/applications.js";
|
|
92
|
+
import publicAppRoutes from "./routes/public-apps.js";
|
|
93
|
+
import { appDeploymentsEnabled } from "./lib/app-deployment-service.js";
|
|
94
|
+
import accountRoutes from "./routes/account.js";
|
|
95
|
+
import jsScriptsRoutes from "./routes/js-scripts.js";
|
|
96
|
+
import timelineAnimationRoutes from "./routes/timeline-animations.js";
|
|
97
|
+
import timelineAudioBakeRoutes from "./routes/timeline-audio-bake.js";
|
|
98
|
+
import timelineIsolateSubjectRoutes from "./routes/timeline-isolate-subject.js";
|
|
99
|
+
import timelineTrackObjectRoutes from "./routes/timeline-track-object.js";
|
|
100
|
+
import storyboardsRoutes from "./routes/storyboards.js";
|
|
101
|
+
import timelinesRoutes from "./routes/timelines.js";
|
|
102
|
+
import documentsRoutes from "./routes/documents.js";
|
|
103
|
+
import sandboxModulesRoutes from "./routes/sandbox-modules.js";
|
|
104
|
+
import falCreditsRoute from "./routes/fal-credits.js";
|
|
105
|
+
import falPricingRoute from "./routes/fal-pricing.js";
|
|
106
|
+
import falPricingEstimateRoute from "./routes/fal-pricing-estimate.js";
|
|
107
|
+
import kieCreditsRoute from "./routes/kie-credits.js";
|
|
108
|
+
import kiePricingRoute from "./routes/kie-pricing.js";
|
|
109
|
+
import kieWebhookRoute from "./routes/kie-webhook.js";
|
|
110
|
+
import falWebhookRoute from "./routes/fal-webhook.js";
|
|
111
|
+
import atlasCloudWebhookRoute from "./routes/atlascloud-webhook.js";
|
|
112
|
+
import { createIntegrationRoutes } from "./routes/integrations.js";
|
|
113
|
+
import { isNonEmptyString, isString } from "./lib/wire-values.js";
|
|
114
|
+
import { logTrpcRequestError } from "./trpc/error-logging.js";
|
|
52
115
|
// @llamaindex/liteparse bundles a webpack pdf.js whose `isNodeJS` heuristic
|
|
53
116
|
// resolves to false inside Electron utilityProcess (process.type === "utility"),
|
|
54
117
|
// causing it to take browser-only code paths that reference the global `document`
|
|
@@ -57,8 +120,13 @@ import { agentSocketRoute, getAgentRuntime } from "./agent/index.js";
|
|
|
57
120
|
// the heuristic back to Node mode so NodeBinaryDataFactory / fs-based asset
|
|
58
121
|
// loading is selected. No-op outside Electron.
|
|
59
122
|
{
|
|
60
|
-
|
|
61
|
-
|
|
123
|
+
// Electron adds these two to the Node `process`; on plain Node both reads
|
|
124
|
+
// come back undefined and the check below fails, as it should.
|
|
125
|
+
const electronVersion = process.versions["electron"];
|
|
126
|
+
// SAFETY: `type` is Electron's addition to the Node `process`, so it is
|
|
127
|
+
// declared optional here and reads undefined everywhere else.
|
|
128
|
+
const processType = process.type;
|
|
129
|
+
if (electronVersion && processType && processType !== "browser") {
|
|
62
130
|
try {
|
|
63
131
|
Object.defineProperty(process, "type", {
|
|
64
132
|
value: "browser",
|
|
@@ -71,6 +139,7 @@ import { agentSocketRoute, getAgentRuntime } from "./agent/index.js";
|
|
|
71
139
|
}
|
|
72
140
|
}
|
|
73
141
|
}
|
|
142
|
+
loadEnvironment(resolve(dirname(fileURLToPath(import.meta.url)), "../../.."));
|
|
74
143
|
const log = createLogger("nodetool.websocket.server");
|
|
75
144
|
// Apply log level from NODETOOL_LOG_LEVEL / LOG_LEVEL env vars (the module
|
|
76
145
|
// initialises eagerly, but an explicit call here picks up any env mutations
|
|
@@ -78,11 +147,18 @@ const log = createLogger("nodetool.websocket.server");
|
|
|
78
147
|
configureLogging();
|
|
79
148
|
await initTelemetry();
|
|
80
149
|
const startupT0 = performance.now();
|
|
150
|
+
/**
|
|
151
|
+
* When this process started. A generation row still `running` from before
|
|
152
|
+
* this moment belongs to a process that is gone, and the sweep closes it
|
|
153
|
+
* (docs/media-generation-tracking-design.md § 6.3).
|
|
154
|
+
*/
|
|
155
|
+
const PROCESS_STARTED_AT = new Date().toISOString();
|
|
156
|
+
let stopGenerationReconcileWorker = null;
|
|
81
157
|
function startupMs() {
|
|
82
158
|
return `${(performance.now() - startupT0).toFixed(0)}ms`;
|
|
83
159
|
}
|
|
84
160
|
async function broadcastResourceChange(app, change) {
|
|
85
|
-
const message =
|
|
161
|
+
const message = packWebSocketMessage({
|
|
86
162
|
type: "resource_change",
|
|
87
163
|
...change
|
|
88
164
|
});
|
|
@@ -129,21 +205,111 @@ async function notifyPythonBridgeResourceChanges(app, pythonBridge) {
|
|
|
129
205
|
// ---------------------------------------------------------------------------
|
|
130
206
|
// Database setup
|
|
131
207
|
// ---------------------------------------------------------------------------
|
|
132
|
-
|
|
208
|
+
function maskDatabaseUrl(url) {
|
|
209
|
+
try {
|
|
210
|
+
const parsed = new URL(url);
|
|
211
|
+
if (parsed.password) {
|
|
212
|
+
parsed.password = "***";
|
|
213
|
+
}
|
|
214
|
+
return parsed.toString();
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
return "(provided)";
|
|
218
|
+
}
|
|
219
|
+
}
|
|
133
220
|
try {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
221
|
+
const postgresDatabaseUrl = getPostgresDatabaseUrl();
|
|
222
|
+
if (postgresDatabaseUrl) {
|
|
223
|
+
await initPostgresDb(postgresDatabaseUrl);
|
|
224
|
+
log.info(`PostgreSQL database ready [${startupMs()}]`, {
|
|
225
|
+
url: maskDatabaseUrl(postgresDatabaseUrl)
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
const dbPath = getDefaultDbPath();
|
|
230
|
+
log.info(`Initializing SQLite database at: ${dbPath}`);
|
|
231
|
+
mkdirSync(dirname(dbPath), { recursive: true });
|
|
232
|
+
const appliedMigrations = await migrateSqliteDb(dbPath);
|
|
233
|
+
if (appliedMigrations.length > 0) {
|
|
234
|
+
log.info(`SQLite migrations applied [${startupMs()}]`, {
|
|
235
|
+
count: appliedMigrations.length,
|
|
236
|
+
versions: appliedMigrations
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
initDb(dbPath);
|
|
240
|
+
log.info(`SQLite database ready [${startupMs()}]`, { path: dbPath });
|
|
241
|
+
}
|
|
242
|
+
// Initialize master key from keychain before any secret access. Callers
|
|
243
|
+
// that need provider credentials bind their own `(key) => getSecret(key,
|
|
244
|
+
// userId)` closure when invoking provider APIs — there is no shared
|
|
245
|
+
// global resolver.
|
|
140
246
|
await initMasterKey();
|
|
141
|
-
|
|
247
|
+
// Bookkeeping for media generations: close the rows a restart orphaned, and
|
|
248
|
+
// keep refining estimates into billed amounts while the server runs.
|
|
249
|
+
void sweepInterruptedGenerations(PROCESS_STARTED_AT).catch((err) => {
|
|
250
|
+
log.warn("Interrupted-generation sweep failed", {
|
|
251
|
+
error: err instanceof Error ? err.message : String(err)
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
stopGenerationReconcileWorker = startGenerationReconcileWorker({
|
|
255
|
+
resolveSecret: (key, userId) => getSecret(key, userId)
|
|
256
|
+
});
|
|
257
|
+
const runHistoryCleanup = () => {
|
|
258
|
+
void runAutomaticStorageCleanup(LOCAL_USER_ID)
|
|
259
|
+
.then((result) => {
|
|
260
|
+
if (result && result.total > 0) {
|
|
261
|
+
log.info("Cleaned retained workflow and run history", result);
|
|
262
|
+
}
|
|
263
|
+
})
|
|
264
|
+
.catch((error) => {
|
|
265
|
+
log.warn("Automatic history cleanup failed", error instanceof Error ? error : new Error(String(error)));
|
|
266
|
+
});
|
|
267
|
+
// `/oauth/register` is anonymous and writes a durable row, so the rows it
|
|
268
|
+
// leaves behind need a sweep of their own: a client nobody ever approved
|
|
269
|
+
// is dead weight. One with any grant — active or revoked — is kept.
|
|
270
|
+
void McpOauthClient.gcUnused(UNUSED_OAUTH_CLIENT_TTL_MS)
|
|
271
|
+
.then((deleted) => {
|
|
272
|
+
if (deleted > 0) {
|
|
273
|
+
log.info("Deleted unapproved MCP OAuth clients", { deleted });
|
|
274
|
+
}
|
|
275
|
+
})
|
|
276
|
+
.catch((error) => {
|
|
277
|
+
log.warn("MCP OAuth client cleanup failed", error instanceof Error ? error : new Error(String(error)));
|
|
278
|
+
});
|
|
279
|
+
};
|
|
280
|
+
runHistoryCleanup();
|
|
281
|
+
const historyCleanupTimer = setInterval(runHistoryCleanup, 6 * 60 * 60 * 1000);
|
|
282
|
+
historyCleanupTimer.unref?.();
|
|
142
283
|
}
|
|
143
284
|
catch (err) {
|
|
144
285
|
log.error("Database setup failed", err instanceof Error ? err : new Error(String(err)));
|
|
145
286
|
process.exit(1);
|
|
146
287
|
}
|
|
288
|
+
// Persistence for every context this process builds. Each entrance used to
|
|
289
|
+
// wire its own, and the ones that forgot produced runs that could not save an
|
|
290
|
+
// asset — the same workflow ran from the editor and threw over HTTP. A
|
|
291
|
+
// context that wires its own still wins.
|
|
292
|
+
setDefaultModelInterfaces(serverModelInterfaces());
|
|
293
|
+
// Seed built-in workflows — non-fatal; a seed failure should not prevent startup.
|
|
294
|
+
try {
|
|
295
|
+
await runSeeds();
|
|
296
|
+
log.info(`Seeds applied [${startupMs()}]`);
|
|
297
|
+
}
|
|
298
|
+
catch (err) {
|
|
299
|
+
log.warn("Seeds failed (non-fatal)", err instanceof Error ? err : new Error(String(err)));
|
|
300
|
+
}
|
|
301
|
+
// User-defined OpenAI-compatible providers for the local user, so a workflow
|
|
302
|
+
// run through a headless entrance reaches them without a settings request
|
|
303
|
+
// first. Each request re-syncs the caller's own catalog.
|
|
304
|
+
try {
|
|
305
|
+
const ids = await syncCustomProviderRegistry(LOCAL_USER_ID);
|
|
306
|
+
if (ids.length > 0) {
|
|
307
|
+
log.info(`Registered custom providers: ${ids.join(", ")}`);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
catch (err) {
|
|
311
|
+
log.warn("Custom provider sync failed (non-fatal)", err instanceof Error ? err : new Error(String(err)));
|
|
312
|
+
}
|
|
147
313
|
// ---------------------------------------------------------------------------
|
|
148
314
|
// Python pip metadata root detection
|
|
149
315
|
// ---------------------------------------------------------------------------
|
|
@@ -201,7 +367,7 @@ print(json.dumps(sorted(roots)))
|
|
|
201
367
|
try {
|
|
202
368
|
const roots = JSON.parse(proc.stdout.trim());
|
|
203
369
|
if (Array.isArray(roots)) {
|
|
204
|
-
return roots.filter((p) =>
|
|
370
|
+
return roots.filter((p) => isNonEmptyString(p) && existsSync(p));
|
|
205
371
|
}
|
|
206
372
|
}
|
|
207
373
|
catch {
|
|
@@ -239,28 +405,135 @@ log.info(`Metadata roots detected [${startupMs()}]`, {
|
|
|
239
405
|
// ---------------------------------------------------------------------------
|
|
240
406
|
// Node registry
|
|
241
407
|
// ---------------------------------------------------------------------------
|
|
242
|
-
const registry =
|
|
243
|
-
|
|
244
|
-
log
|
|
245
|
-
|
|
246
|
-
registerElevenLabsNodes(registry);
|
|
247
|
-
registerTransformersJsNodes(registry);
|
|
248
|
-
registerFalNodes(registry);
|
|
249
|
-
registerKieNodes(registry);
|
|
250
|
-
registerReplicateNodes(registry);
|
|
251
|
-
registerTransformersJsProvider();
|
|
408
|
+
const registry = await bootstrapNodeRegistry({
|
|
409
|
+
metadataRoots,
|
|
410
|
+
log
|
|
411
|
+
});
|
|
252
412
|
log.info(`Node registry ready [${startupMs()}]`);
|
|
413
|
+
// The Code node reaches the toolbelt and its `@nodetool-ai/sandbox-nodetool/*`
|
|
414
|
+
// imports through the agents package, which it resolves by bare specifier.
|
|
415
|
+
// That specifier resolves in a checkout and nowhere in the bundled backend —
|
|
416
|
+
// esbuild inlines the workspace packages into server.mjs — so hand it the copy
|
|
417
|
+
// this module already holds. Without it, a Code node body in the desktop app
|
|
418
|
+
// and in the Docker image runs with an empty `nodetool.capabilities()`.
|
|
419
|
+
setCodeNodeAgentsModule(agentsModule);
|
|
420
|
+
if (process.env["NODETOOL_ENV"] !== "production") {
|
|
421
|
+
registerTransformersJsProvider();
|
|
422
|
+
}
|
|
253
423
|
// ---------------------------------------------------------------------------
|
|
254
424
|
// Python bridge
|
|
255
425
|
// ---------------------------------------------------------------------------
|
|
256
|
-
const
|
|
426
|
+
const localBridge = createPythonBridge({
|
|
257
427
|
workerArgs: process.env["NODETOOL_WORKER_NAMESPACES"]
|
|
258
428
|
? ["--namespaces", process.env["NODETOOL_WORKER_NAMESPACES"]]
|
|
259
429
|
: []
|
|
260
430
|
});
|
|
431
|
+
// The ONE stable bridge reference handed to every consumer. It delegates to the
|
|
432
|
+
// local bridge by default; attaching a worker swaps in a dedicated WebSocket
|
|
433
|
+
// bridge to that worker (so ALL Python work — execution AND model management —
|
|
434
|
+
// targets the worker's GPU) and detach swaps back. Because the reference is
|
|
435
|
+
// stable and re-emits its target's events, consumers never re-read it and
|
|
436
|
+
// listeners are wired exactly once.
|
|
437
|
+
const pythonBridge = new SwappableBridge(localBridge);
|
|
261
438
|
let pythonBridgeReady = false;
|
|
439
|
+
// Worker bridge bookkeeping so it can be closed after swapping away. Only the
|
|
440
|
+
// remote WebSocket bridge is tracked here; the local stdio bridge is owned by
|
|
441
|
+
// `localBridge` above and never closed on swap.
|
|
442
|
+
let workerBridge = null;
|
|
443
|
+
const isLocalActive = () => pythonBridge.target === localBridge;
|
|
444
|
+
const getPythonBridgeReady = () => isLocalActive() ? pythonBridgeReady : pythonBridge.isConnected;
|
|
445
|
+
// ---------------------------------------------------------------------------
|
|
446
|
+
// Worker provisioning (GPU workers via @nodetool-ai/compute)
|
|
447
|
+
// ---------------------------------------------------------------------------
|
|
448
|
+
const workerManager = new WorkerManager();
|
|
449
|
+
/**
|
|
450
|
+
* Re-point the Python bridge for worker attach/detach by SWAPPING the
|
|
451
|
+
* SwappableBridge's target (a local stdio bridge cannot be re-pointed in place).
|
|
452
|
+
*
|
|
453
|
+
* On attach: build a dedicated WebSocket bridge to the worker, connect it
|
|
454
|
+
* (discover + status), swap it in as the target — so subsequent execution and
|
|
455
|
+
* model-management calls run on the worker — then close the previous worker
|
|
456
|
+
* bridge. Throws (failing the attach) if the worker can't be reached. On detach
|
|
457
|
+
* (`null`): swap back to the local bridge and dispose the worker bridge.
|
|
458
|
+
*
|
|
459
|
+
* `swap()` itself never connects or closes a bridge — lifecycle is owned here:
|
|
460
|
+
* connect before swapping in, close after swapping away.
|
|
461
|
+
*/
|
|
462
|
+
async function repointPythonBridge(target) {
|
|
463
|
+
if (target) {
|
|
464
|
+
const next = new WebsocketPythonBridge({
|
|
465
|
+
wsUrl: target.wsUrl,
|
|
466
|
+
workerToken: target.token ?? undefined
|
|
467
|
+
});
|
|
468
|
+
try {
|
|
469
|
+
await next.connect();
|
|
470
|
+
}
|
|
471
|
+
catch (err) {
|
|
472
|
+
next.close();
|
|
473
|
+
throw err;
|
|
474
|
+
}
|
|
475
|
+
const previous = workerBridge;
|
|
476
|
+
workerBridge = next;
|
|
477
|
+
pythonBridge.swap(next);
|
|
478
|
+
if (previous)
|
|
479
|
+
previous.close();
|
|
480
|
+
log.info("Python bridge re-pointed to attached worker");
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
const previous = workerBridge;
|
|
484
|
+
workerBridge = null;
|
|
485
|
+
pythonBridge.swap(localBridge);
|
|
486
|
+
if (previous)
|
|
487
|
+
previous.close();
|
|
488
|
+
log.info("Python bridge re-pointed back to the local worker");
|
|
489
|
+
}
|
|
490
|
+
/** Bound for the readiness probe: TCP/WS handshake + discover RPC. */
|
|
491
|
+
const WORKER_PROBE_TIMEOUT_MS = 8000;
|
|
492
|
+
/**
|
|
493
|
+
* Probe a `running` worker's readiness by opening a transient bridge to its
|
|
494
|
+
* `{wsUrl, token}` — the same handshake attach performs — then closing it. A
|
|
495
|
+
* resolved connect (WS open + `discover` answered) means the worker process is
|
|
496
|
+
* actually serving, not merely that the pod's port is mapped. Never throws:
|
|
497
|
+
* failures (still booting, unreachable) report `{ healthy: false }`.
|
|
498
|
+
*/
|
|
499
|
+
async function probeWorkerHealth(target) {
|
|
500
|
+
if (!target.wsUrl) {
|
|
501
|
+
return { healthy: false, error: "Worker has no WebSocket URL yet" };
|
|
502
|
+
}
|
|
503
|
+
const probe = new WebsocketPythonBridge({
|
|
504
|
+
wsUrl: target.wsUrl,
|
|
505
|
+
workerToken: target.token ?? undefined,
|
|
506
|
+
// One-shot probe: no reconnect, bounded handshake.
|
|
507
|
+
autoRestart: false,
|
|
508
|
+
startupTimeoutMs: WORKER_PROBE_TIMEOUT_MS,
|
|
509
|
+
reconnectRpcTimeoutMs: WORKER_PROBE_TIMEOUT_MS
|
|
510
|
+
});
|
|
511
|
+
// A probe must never escalate a socket 'error' into a crash.
|
|
512
|
+
probe.on("error", () => { });
|
|
513
|
+
try {
|
|
514
|
+
await probe.connect();
|
|
515
|
+
return {
|
|
516
|
+
healthy: true,
|
|
517
|
+
protocolVersion: probe.supportsModelManagement() ? 2 : 1
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
catch (err) {
|
|
521
|
+
return {
|
|
522
|
+
healthy: false,
|
|
523
|
+
error: err instanceof Error ? err.message : String(err)
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
finally {
|
|
527
|
+
try {
|
|
528
|
+
probe.close();
|
|
529
|
+
}
|
|
530
|
+
catch {
|
|
531
|
+
/* best-effort cleanup */
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
262
535
|
function logPythonBridgeDiagnostics(context) {
|
|
263
|
-
const loadErrors =
|
|
536
|
+
const loadErrors = localBridge.getLoadErrors?.() ?? [];
|
|
264
537
|
if (loadErrors.length === 0)
|
|
265
538
|
return;
|
|
266
539
|
log.warn(`Python bridge ${context} with ${loadErrors.length} load error(s)`);
|
|
@@ -273,64 +546,24 @@ function logPythonBridgeDiagnostics(context) {
|
|
|
273
546
|
}
|
|
274
547
|
pythonBridge.on("stderr", (msg) => {
|
|
275
548
|
for (const line of msg.split("\n")) {
|
|
276
|
-
|
|
277
|
-
log.debug(`[python-worker] ${line}`);
|
|
549
|
+
logPythonWorkerStderr(line, log);
|
|
278
550
|
}
|
|
279
551
|
});
|
|
552
|
+
pythonBridge.on("error", (err) => {
|
|
553
|
+
log.error(`Python bridge protocol error: ${err.message}`);
|
|
554
|
+
pythonBridgeReady = false;
|
|
555
|
+
});
|
|
280
556
|
pythonBridge.on("exit", (code) => {
|
|
281
557
|
log.warn(`Python worker exited with code ${code}`);
|
|
282
558
|
pythonBridgeReady = false;
|
|
283
559
|
});
|
|
284
|
-
//
|
|
285
|
-
//
|
|
286
|
-
//
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
GoogleGroundedSearchTool,
|
|
292
|
-
GoogleImageGenerationTool,
|
|
293
|
-
OpenAIWebSearchTool,
|
|
294
|
-
OpenAIImageGenerationTool,
|
|
295
|
-
OpenAITextToSpeechTool,
|
|
296
|
-
BrowserTool,
|
|
297
|
-
ScreenshotTool,
|
|
298
|
-
HttpRequestTool,
|
|
299
|
-
CalculatorTool,
|
|
300
|
-
RunCodeTool,
|
|
301
|
-
StatisticsTool,
|
|
302
|
-
GeometryTool,
|
|
303
|
-
ConversionTool,
|
|
304
|
-
SearchEmailTool,
|
|
305
|
-
ArchiveEmailTool,
|
|
306
|
-
AddLabelToEmailTool,
|
|
307
|
-
DataForSEOSearchTool,
|
|
308
|
-
DataForSEONewsTool,
|
|
309
|
-
DataForSEOImagesTool
|
|
310
|
-
];
|
|
311
|
-
// Lazy tool class map — defers instantiation until first access.
|
|
312
|
-
let _toolClassMap = null;
|
|
313
|
-
function getToolClassMap() {
|
|
314
|
-
if (!_toolClassMap) {
|
|
315
|
-
_toolClassMap = new Map();
|
|
316
|
-
for (const cls of builtinToolClasses) {
|
|
317
|
-
const instance = new cls();
|
|
318
|
-
_toolClassMap.set(instance.name, cls);
|
|
319
|
-
}
|
|
320
|
-
log.info(`Tool class map built (${_toolClassMap.size} tools) [${startupMs()}]`);
|
|
321
|
-
}
|
|
322
|
-
return _toolClassMap;
|
|
323
|
-
}
|
|
324
|
-
// Expose as a getter-backed object so existing code using toolClassMap works unchanged.
|
|
325
|
-
const toolClassMap = new Proxy(new Map(), {
|
|
326
|
-
get(_target, prop, _receiver) {
|
|
327
|
-
const map = getToolClassMap();
|
|
328
|
-
const value = map[prop];
|
|
329
|
-
if (typeof value === "function") {
|
|
330
|
-
return value.bind(map);
|
|
331
|
-
}
|
|
332
|
-
return value;
|
|
333
|
-
}
|
|
560
|
+
// Keep the attached worker's `last_activity_at` fresh so the cost guard's
|
|
561
|
+
// reaper measures idle time from real bridge traffic, not from creation. The
|
|
562
|
+
// throttling and the best-effort write live in @nodetool-ai/compute so the CLI
|
|
563
|
+
// gets the same behaviour; a local stdio bridge emits no "activity", so this is
|
|
564
|
+
// inert there.
|
|
565
|
+
attachWorkerActivityHeartbeat(pythonBridge, {
|
|
566
|
+
resolveInstanceId: async () => (await workerManager.getActiveWorker())?.id ?? null
|
|
334
567
|
});
|
|
335
568
|
// ---------------------------------------------------------------------------
|
|
336
569
|
// TLS configuration
|
|
@@ -370,26 +603,45 @@ const port = Number(process.env["PORT"] ?? 7777);
|
|
|
370
603
|
const isProduction = process.env["NODETOOL_ENV"] === "production";
|
|
371
604
|
// In production, bind to all interfaces unless HOST is explicitly set
|
|
372
605
|
const host = process.env["HOST"] ?? (isProduction ? "0.0.0.0" : "127.0.0.1");
|
|
606
|
+
// The `/mcp` streamable-HTTP mount. Off in production by default: it carries
|
|
607
|
+
// the full agent toolbelt for whichever user it binds, so a deployment opts in
|
|
608
|
+
// with NODETOOL_ENABLE_MCP=1 and authenticates the agent like any other client.
|
|
609
|
+
// The gate is shared with the settings UI, which reports it (see lib/mcp-mount).
|
|
610
|
+
const mcpHttpEnabled = isMcpHttpEnabled();
|
|
611
|
+
// The `WWW-Authenticate` challenge for an unauthenticated or invalid `/mcp`
|
|
612
|
+
// request (docs/mcp-oauth-design.md § "401 challenge") comes from
|
|
613
|
+
// `oauth/gate.ts` — the same gate the AS routes use, so the server never
|
|
614
|
+
// advertises a discovery flow the AS answers with 404. A server where the
|
|
615
|
+
// flow cannot complete answers the plain 401 it always has.
|
|
616
|
+
// Reverse proxies whose X-Forwarded-For header may be trusted to determine the
|
|
617
|
+
// real client IP. Comma-separated IPs/CIDRs (e.g. "127.0.0.1,10.0.0.0/8").
|
|
618
|
+
// When empty, X-Forwarded-For is NOT trusted: req.ip falls back to the socket
|
|
619
|
+
// peer address so clients cannot spoof their origin via headers.
|
|
620
|
+
const trustedProxies = parseTrustedProxies(process.env["NODETOOL_TRUSTED_PROXIES"]);
|
|
373
621
|
// ---------------------------------------------------------------------------
|
|
374
622
|
// Fastify app
|
|
375
623
|
// ---------------------------------------------------------------------------
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
624
|
+
const serverOptions = {
|
|
625
|
+
// Only trust X-Forwarded-For from explicitly configured proxies. With no
|
|
626
|
+
// proxies configured this is `false`, so req.ip is the unspoofable socket
|
|
627
|
+
// peer address.
|
|
628
|
+
trustProxy: trustedProxies.length > 0 ? trustedProxies : false,
|
|
379
629
|
bodyLimit: 100 * 1024 * 1024, // 100 MB
|
|
380
630
|
logger: false,
|
|
381
631
|
// tRPC's httpBatchLink encodes all batched procedure names into a single
|
|
382
632
|
// URL path segment joined with commas (e.g. `/trpc/foo,bar,baz`). Fastify's
|
|
383
|
-
// default `maxParamLength` of 100 rejects larger batches with a 404
|
|
384
|
-
//
|
|
633
|
+
// default `maxParamLength` of 100 rejects larger batches with a 404, and 2000
|
|
634
|
+
// was not enough either: one model-picker mount produced a ~2900 char path.
|
|
635
|
+
// The clients cap a batch at 20 procedures (`maxItems`); this is the backstop.
|
|
385
636
|
routerOptions: {
|
|
386
637
|
ignoreTrailingSlash: true,
|
|
387
|
-
maxParamLength:
|
|
638
|
+
maxParamLength: 8000
|
|
388
639
|
},
|
|
389
640
|
genReqId: (req) => {
|
|
390
641
|
return req.headers["x-request-id"] || crypto.randomUUID();
|
|
391
642
|
}
|
|
392
|
-
}
|
|
643
|
+
};
|
|
644
|
+
const app = Fastify(httpsOptions ? { https: httpsOptions, ...serverOptions } : serverOptions);
|
|
393
645
|
// ---------------------------------------------------------------------------
|
|
394
646
|
// Request ID correlation
|
|
395
647
|
// ---------------------------------------------------------------------------
|
|
@@ -398,6 +650,51 @@ app.addHook("onRequest", async (request) => {
|
|
|
398
650
|
});
|
|
399
651
|
app.addHook("onSend", async (request, reply) => {
|
|
400
652
|
reply.header("X-Request-Id", request.id);
|
|
653
|
+
// Baseline security response headers. The web app's CSP lives in a `<meta>`
|
|
654
|
+
// tag, which browsers ignore for `frame-ancestors` — that directive is only
|
|
655
|
+
// honoured in a header, so clickjacking protection has to be set here.
|
|
656
|
+
//
|
|
657
|
+
// `/api/storage/*` is exempt: those bytes are designed to be embedded from
|
|
658
|
+
// other origins (MCP App iframes, the Electron renderer, external preview
|
|
659
|
+
// clients — see storage-api.ts), and the endpoint deliberately serves
|
|
660
|
+
// unknown extensions as `application/octet-stream` for `<img>`/`<video>` to
|
|
661
|
+
// sniff. Both `nosniff` and the frame headers would break that contract.
|
|
662
|
+
const path = request.url.split("?")[0] ?? "/";
|
|
663
|
+
if (!path.startsWith("/api/storage/")) {
|
|
664
|
+
reply.header("X-Content-Type-Options", "nosniff");
|
|
665
|
+
reply.header("X-Frame-Options", "SAMEORIGIN");
|
|
666
|
+
reply.header("Content-Security-Policy", "frame-ancestors 'self'");
|
|
667
|
+
}
|
|
668
|
+
reply.header("Referrer-Policy", "strict-origin-when-cross-origin");
|
|
669
|
+
});
|
|
670
|
+
// CORS must be registered before hooks that can short-circuit. Auth failures
|
|
671
|
+
// and rate-limit responses still need ACAO for first-party web deployments.
|
|
672
|
+
await app.register(fastifyCors, { origin: corsOriginDelegate });
|
|
673
|
+
// ---------------------------------------------------------------------------
|
|
674
|
+
// Per-IP HTTP rate limiting
|
|
675
|
+
// ---------------------------------------------------------------------------
|
|
676
|
+
// Registered before the auth hook so floods are rejected with 429 before any
|
|
677
|
+
// token verification work. Localhost is exempt; tune via NODETOOL_RATE_LIMIT_*.
|
|
678
|
+
const httpRateLimit = getHttpRateLimitConfig();
|
|
679
|
+
// Always register so every request path (including the auth hook) shares one
|
|
680
|
+
// limiter. When disabled via env, use a cap large enough to be inert in
|
|
681
|
+
// practice while keeping CodeQL/static setup able to see the plugin.
|
|
682
|
+
const httpRateLimitMax = httpRateLimit.enabled
|
|
683
|
+
? httpRateLimit.max
|
|
684
|
+
: Number.MAX_SAFE_INTEGER;
|
|
685
|
+
await app.register(fastifyRateLimit, {
|
|
686
|
+
global: true,
|
|
687
|
+
max: httpRateLimitMax,
|
|
688
|
+
timeWindow: httpRateLimit.timeWindow,
|
|
689
|
+
keyGenerator: (req) => rateLimitKey(req, httpRateLimit.trustProxy),
|
|
690
|
+
allowList: (req) => isRateLimitExempt(rateLimitKey(req, httpRateLimit.trustProxy))
|
|
691
|
+
});
|
|
692
|
+
log.info(httpRateLimit.enabled
|
|
693
|
+
? "Per-IP HTTP rate limiting enabled"
|
|
694
|
+
: "Per-IP HTTP rate limiting disabled (limiter registered with no practical cap)", {
|
|
695
|
+
max: httpRateLimitMax,
|
|
696
|
+
timeWindowMs: httpRateLimit.timeWindow,
|
|
697
|
+
trustProxy: httpRateLimit.trustProxy
|
|
401
698
|
});
|
|
402
699
|
// ---------------------------------------------------------------------------
|
|
403
700
|
// Auth
|
|
@@ -412,63 +709,252 @@ const supabaseProvider = supabaseMode
|
|
|
412
709
|
})
|
|
413
710
|
: null;
|
|
414
711
|
const localProvider = supabaseProvider ? null : new LocalAuthProvider();
|
|
712
|
+
// A server that enforces auth but never got an anon key serves a healthy
|
|
713
|
+
// /health and a well-formed /api/config while no user can log in. Say so at
|
|
714
|
+
// boot, where an operator reading the deploy log will see it.
|
|
715
|
+
const missingAnonKey = describeMissingAnonKey();
|
|
716
|
+
if (missingAnonKey) {
|
|
717
|
+
log.error(missingAnonKey);
|
|
718
|
+
}
|
|
719
|
+
// Auth is enforced whenever a remote identity provider is configured.
|
|
720
|
+
const enforceAuth = supabaseMode;
|
|
721
|
+
// Whether loopback connections may bypass auth as user "1". Explicit
|
|
722
|
+
// NODETOOL_TRUST_LOCALHOST wins; otherwise this defaults off when auth is
|
|
723
|
+
// enforced (so reverse-proxied/containerized deployments — where the proxy
|
|
724
|
+
// connects from loopback — don't silently disable auth) and on for local dev.
|
|
725
|
+
const trustLocalhost = resolveTrustLocalhost({
|
|
726
|
+
envValue: process.env["NODETOOL_TRUST_LOCALHOST"],
|
|
727
|
+
enforceAuth
|
|
728
|
+
});
|
|
729
|
+
if (enforceAuth && trustLocalhost) {
|
|
730
|
+
log.warn("NODETOOL_TRUST_LOCALHOST is enabled while auth is enforced: any " +
|
|
731
|
+
"connection from loopback (including a reverse proxy) bypasses " +
|
|
732
|
+
"authentication. Unset it unless the proxy is fully trusted.");
|
|
733
|
+
}
|
|
734
|
+
// Source networks trusted to run as the local user "1" without a token. Needed
|
|
735
|
+
// for containerized self-hosting: Docker NATs a published-port connection to
|
|
736
|
+
// the bridge gateway (e.g. 172.17.0.1), so it never arrives from loopback and
|
|
737
|
+
// the isLoopbackAddress bypass can't fire. Honored ONLY in Local mode — when
|
|
738
|
+
// auth is enforced a CIDR must never bypass a real login, so the list is empty.
|
|
739
|
+
const trustLocalNetworks = enforceAuth
|
|
740
|
+
? []
|
|
741
|
+
: parseTrustedLocalNetworks(process.env["NODETOOL_TRUST_LOCAL_NETWORKS"]);
|
|
742
|
+
if (enforceAuth && process.env["NODETOOL_TRUST_LOCAL_NETWORKS"]) {
|
|
743
|
+
log.warn("NODETOOL_TRUST_LOCAL_NETWORKS is set while auth is enforced (Supabase " +
|
|
744
|
+
"mode); it is ignored so every request must present a valid token.");
|
|
745
|
+
}
|
|
746
|
+
else if (trustLocalNetworks.length > 0) {
|
|
747
|
+
log.warn(`Local mode: trusting connections from ${trustLocalNetworks.join(", ")} ` +
|
|
748
|
+
'as user "1" without authentication. Only expose this instance to ' +
|
|
749
|
+
"networks you trust.");
|
|
750
|
+
}
|
|
751
|
+
// Messaging integrations (Telegram, later Discord). The service token is what
|
|
752
|
+
// enables the surface: without it there are no integration routes and no
|
|
753
|
+
// delegated tokens to verify.
|
|
754
|
+
const integrationServiceToken = process.env["NODETOOL_INTEGRATION_TOKEN"];
|
|
755
|
+
const integrationsEnabled = Boolean(integrationServiceToken && integrationServiceToken.length >= 16);
|
|
756
|
+
if (integrationServiceToken && !integrationsEnabled) {
|
|
757
|
+
log.warn("NODETOOL_INTEGRATION_TOKEN is shorter than 16 characters and was " +
|
|
758
|
+
"ignored; the /api/integrations routes are not registered.");
|
|
759
|
+
}
|
|
760
|
+
// Delegated tokens are signed with a key derived from the master key, so
|
|
761
|
+
// rotating the master key revokes every outstanding one. Derived lazily: a
|
|
762
|
+
// server that never mints one never reads the key.
|
|
763
|
+
let cachedDelegatedKey = null;
|
|
764
|
+
const delegatedSigningKey = () => (cachedDelegatedKey ??= deriveKey(getMasterKey(), "nodetool-delegated-token"));
|
|
765
|
+
const delegatedProvider = integrationsEnabled
|
|
766
|
+
? new DelegatedTokenProvider(delegatedSigningKey)
|
|
767
|
+
: null;
|
|
768
|
+
// A deployed mini app's run sessions are signed with their own key, derived
|
|
769
|
+
// from the same master key under a different label. Rotating the master key
|
|
770
|
+
// invalidates every outstanding session; a distinct label keeps a session
|
|
771
|
+
// token from ever verifying as a delegated one, or the reverse.
|
|
772
|
+
let cachedAppSessionKey = null;
|
|
773
|
+
const appSessionSigningKey = () => (cachedAppSessionKey ??= deriveKey(getMasterKey(), "nodetool-app-session"));
|
|
774
|
+
// Public app deployments exist only in production; outside it the routes are
|
|
775
|
+
// still registered and every handler refuses, so the surface is decided by one
|
|
776
|
+
// predicate at request time rather than by boot order.
|
|
777
|
+
const appSessionProvider = new AppSessionTokenProvider(appSessionSigningKey);
|
|
415
778
|
app.decorateRequest("userId", null);
|
|
779
|
+
app.decorateRequest("authToken", null);
|
|
780
|
+
app.decorateRequest("appSession", null);
|
|
781
|
+
// Global @fastify/rate-limit (registered above) runs before this hook on every
|
|
782
|
+
// request, including public auth exemptions handled by isPublicAuthExemptRoute.
|
|
783
|
+
// CodeQL js/missing-rate-limiting does not attribute a global Fastify plugin to
|
|
784
|
+
// a hook handler, so it would read this as unlimited. It ships in
|
|
785
|
+
// security-extended, which our default-setup code scanning does not run, so it
|
|
786
|
+
// never fires here. Nothing excludes it either: default setup reads no config
|
|
787
|
+
// file, so suppressing an alert means dismissing it in the Security UI.
|
|
416
788
|
app.addHook("onRequest", async (req, reply) => {
|
|
417
789
|
// Let CORS preflight through — the @fastify/cors plugin handles OPTIONS responses
|
|
418
790
|
if (req.method === "OPTIONS")
|
|
419
791
|
return;
|
|
420
|
-
// Public routes — no auth required
|
|
792
|
+
// Public routes — no auth required (still rate-limited globally above).
|
|
421
793
|
const pathname = req.url.split("?")[0];
|
|
422
|
-
if (pathname
|
|
423
|
-
pathname
|
|
424
|
-
|
|
425
|
-
pathname === "/api/assets/packages" ||
|
|
426
|
-
pathname.startsWith("/api/assets/packages/") ||
|
|
427
|
-
pathname === "/api/nodes/metadata") {
|
|
794
|
+
if (isPublicAuthExemptRoute(pathname, req.method) ||
|
|
795
|
+
(isSdkV1DiscoveryRequest(pathname, req.method) &&
|
|
796
|
+
!isSdkV1AuthenticationRequired(process.env, enforceAuth))) {
|
|
428
797
|
return;
|
|
429
798
|
}
|
|
430
799
|
// Static frontend assets don't require auth (served by fastifyStatic)
|
|
800
|
+
// `GET /mcp` is the MCP SSE stream, not a static asset — it must go through
|
|
801
|
+
// auth so the mount can bind the session's user.
|
|
431
802
|
if (hasStaticApp &&
|
|
432
803
|
req.method === "GET" &&
|
|
433
804
|
!pathname.startsWith("/api") &&
|
|
434
805
|
!pathname.startsWith("/ws") &&
|
|
435
806
|
!pathname.startsWith("/v1") &&
|
|
436
|
-
!pathname.startsWith("/trpc")
|
|
807
|
+
!pathname.startsWith("/trpc") &&
|
|
808
|
+
!pathname.startsWith("/mcp")) {
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
// req.ip reflects X-Forwarded-For only when the request arrived through a
|
|
812
|
+
// configured trusted proxy (see NODETOOL_TRUSTED_PROXIES); otherwise it is
|
|
813
|
+
// the unspoofable socket peer address.
|
|
814
|
+
const clientIp = req.ip;
|
|
815
|
+
// Loopback connections bypass auth as user "1" only when explicitly trusted.
|
|
816
|
+
// Behind a reverse proxy/container/SSH tunnel the proxy itself connects from
|
|
817
|
+
// loopback, so this is gated by NODETOOL_TRUST_LOCALHOST (off by default when
|
|
818
|
+
// auth is enforced). Docker's bridge NAT means the peer is the gateway rather
|
|
819
|
+
// than loopback, so NODETOOL_TRUST_LOCAL_NETWORKS additionally trusts that
|
|
820
|
+
// source range (Local mode only).
|
|
821
|
+
if ((trustLocalhost && isLoopbackAddress(clientIp)) ||
|
|
822
|
+
isTrustedLocalAddress(clientIp, trustLocalNetworks)) {
|
|
823
|
+
req.userId = "1";
|
|
437
824
|
return;
|
|
438
825
|
}
|
|
439
826
|
// Extract token from the appropriate source
|
|
440
|
-
const isWs = req
|
|
827
|
+
const isWs = isWebSocketUpgrade(req);
|
|
441
828
|
const searchParams = new URLSearchParams(req.url.split("?")[1] ?? "");
|
|
442
829
|
const provider = supabaseProvider ?? localProvider;
|
|
443
830
|
const token = isWs
|
|
444
831
|
? provider.extractTokenFromWs(req.headers, searchParams)
|
|
445
832
|
: provider.extractTokenFromHeaders(req.headers);
|
|
833
|
+
// MCP OAuth access tokens (`nta_`) authorize `/mcp` ONLY — the audience
|
|
834
|
+
// binding is structural, not claim-parsing (docs/mcp-oauth-design.md §
|
|
835
|
+
// "Token model and storage"). A valid token whose stored `resource` no
|
|
836
|
+
// longer matches this deployment's canonical `/mcp` URI (the server was
|
|
837
|
+
// rehosted since it was minted) or that is presented outside `/mcp` is
|
|
838
|
+
// denied with `invalid_token`, never silently ignored — falling through to
|
|
839
|
+
// the `ntk_`/session checks below would let an audience-scoped credential
|
|
840
|
+
// be probed against the rest of the API.
|
|
841
|
+
if (token && token.startsWith(MCP_OAUTH_ACCESS_TOKEN_PREFIX)) {
|
|
842
|
+
const decision = await authenticateMcpAccessToken(token, req.url.split("?")[0] ?? "/");
|
|
843
|
+
if (decision.ok) {
|
|
844
|
+
req.userId = decision.userId;
|
|
845
|
+
req.authToken = token;
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
denyUnauthorized(req, reply, { error: "invalid_token" }, decision.challenge);
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
// Access tokens (`ntk_`) are the credential a person mints in the app and
|
|
852
|
+
// pastes into an MCP client's config. They authenticate in every auth mode,
|
|
853
|
+
// including local: a self-hoster exposing /mcp beyond loopback should be
|
|
854
|
+
// able to hand out a revocable per-agent token rather than widen
|
|
855
|
+
// NODETOOL_TRUST_LOCAL_NETWORKS. A token that fails here falls through, so
|
|
856
|
+
// an expired or revoked one is refused by the mode's own rules.
|
|
857
|
+
if (token && isAccessToken(token)) {
|
|
858
|
+
const accessToken = await AccessToken.verify(token);
|
|
859
|
+
if (accessToken) {
|
|
860
|
+
req.userId = accessToken.user_id;
|
|
861
|
+
req.authToken = token;
|
|
862
|
+
void accessToken.touch().catch(() => {
|
|
863
|
+
// last_used_at is a convenience for the revoke UI; a failed write
|
|
864
|
+
// must not fail the request it was recording.
|
|
865
|
+
});
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
// A deployed mini app's session token (`nda_`) authenticates a visitor who
|
|
870
|
+
// has the app's hidden URL. It carries the owner's user id *and* the one
|
|
871
|
+
// application it may act on, and its whole point is that it reaches nothing
|
|
872
|
+
// else — so the confinement is applied right here, at the door, rather than
|
|
873
|
+
// trusted to every handler downstream. `/ws` is the only path it opens: the
|
|
874
|
+
// run transport, and exactly that path — `/ws/download` and `/ws/extension`
|
|
875
|
+
// are model downloads and the browser-extension bridge, neither of which a
|
|
876
|
+
// visitor to somebody's app has any business opening. The public app routes
|
|
877
|
+
// need no token at all (they are auth-exempt above), and every other path —
|
|
878
|
+
// tRPC, the REST library, assets, settings — is refused, because the
|
|
879
|
+
// owner's account is not what the visitor was given a link to.
|
|
880
|
+
//
|
|
881
|
+
// A failed verification does *not* fall through to the providers below. An
|
|
882
|
+
// expired or tampered app session must be refused as itself; letting it
|
|
883
|
+
// reach the session check would turn a confined credential into a probe
|
|
884
|
+
// against the rest of the API.
|
|
885
|
+
if (token && isAppSessionToken(token)) {
|
|
886
|
+
const session = await appSessionProvider.verifyToken(token);
|
|
887
|
+
if (session.ok &&
|
|
888
|
+
session.applicationId &&
|
|
889
|
+
session.userId &&
|
|
890
|
+
appDeploymentsEnabled() &&
|
|
891
|
+
pathname === "/ws") {
|
|
892
|
+
req.userId = session.userId;
|
|
893
|
+
req.authToken = token;
|
|
894
|
+
req.appSession = {
|
|
895
|
+
applicationId: session.applicationId,
|
|
896
|
+
version: session.applicationVersion ?? 0
|
|
897
|
+
};
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
denyUnauthorized(req, reply, { error: "Unauthorized" });
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
// Delegated tokens (a messaging bridge acting as the linked user) are
|
|
904
|
+
// checked only when they announce themselves by prefix. Anything else —
|
|
905
|
+
// including a delegated token that is expired or tampered with — falls
|
|
906
|
+
// through to the configured provider, which rejects it.
|
|
907
|
+
if (delegatedProvider && token && isDelegatedToken(token)) {
|
|
908
|
+
const delegated = await delegatedProvider.verifyToken(token);
|
|
909
|
+
if (delegated.ok) {
|
|
910
|
+
req.userId = delegated.userId ?? null;
|
|
911
|
+
req.authToken = token;
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
// /mcp gets a WWW-Authenticate challenge on every unauthenticated/invalid
|
|
916
|
+
// denial below it — but only when the OAuth flow can actually complete
|
|
917
|
+
// (see mcpBearerChallenge). Every other path is unaffected.
|
|
918
|
+
const challenge = pathname.startsWith("/mcp")
|
|
919
|
+
? mcpBearerChallenge()
|
|
920
|
+
: undefined;
|
|
446
921
|
if (supabaseMode) {
|
|
447
922
|
if (!token) {
|
|
448
|
-
reply
|
|
923
|
+
denyUnauthorized(req, reply, { error: "Unauthorized" }, challenge);
|
|
449
924
|
return;
|
|
450
925
|
}
|
|
451
926
|
const result = await supabaseProvider.verifyToken(token);
|
|
452
927
|
if (!result.ok) {
|
|
453
|
-
reply
|
|
928
|
+
denyUnauthorized(req, reply, { error: result.error ?? "Unauthorized" }, challenge);
|
|
454
929
|
return;
|
|
455
930
|
}
|
|
456
931
|
req.userId = result.userId ?? null;
|
|
932
|
+
req.authToken = token;
|
|
457
933
|
return;
|
|
458
934
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
935
|
+
denyUnauthorized(req, reply, { error: "Remote access requires authentication" }, challenge);
|
|
936
|
+
});
|
|
937
|
+
// Multi-instance only: a handshake asking to resume a run that another machine
|
|
938
|
+
// owns is answered with a fly-replay instruction instead of being accepted
|
|
939
|
+
// here, so the client reconnects onto the process holding the run's session.
|
|
940
|
+
// Registered after the auth hook because it scopes the lookup to req.userId.
|
|
941
|
+
// Inert (one env read, no DB) without NODETOOL_INSTANCE_ID / FLY_MACHINE_ID.
|
|
942
|
+
app.addHook("onRequest", async (req, reply) => {
|
|
943
|
+
await replayUpgradeToOwner(req, reply);
|
|
944
|
+
});
|
|
945
|
+
// A machine that is draining takes no new sockets: the handshake is answered
|
|
946
|
+
// with 503 rather than accepted, so the client's reconnect backoff carries it
|
|
947
|
+
// to a machine that is staying. Its /health is already failing, so the proxy
|
|
948
|
+
// normally routes elsewhere before this is reached; this covers the window
|
|
949
|
+
// between the drain starting and the next health check.
|
|
950
|
+
app.addHook("onRequest", async (req, reply) => {
|
|
951
|
+
if (!isDraining() || !isWebSocketUpgrade(req))
|
|
466
952
|
return;
|
|
467
|
-
|
|
468
|
-
|
|
953
|
+
const path = req.url.split("?")[0] ?? "";
|
|
954
|
+
if (path !== "/ws" && !path.startsWith("/ws/"))
|
|
955
|
+
return;
|
|
956
|
+
denyDraining(req, reply);
|
|
469
957
|
});
|
|
470
|
-
// CORS
|
|
471
|
-
await app.register(fastifyCors, { origin: true });
|
|
472
958
|
// WebSocket support
|
|
473
959
|
await app.register(fastifyWebSocket);
|
|
474
960
|
// Parse all request bodies as raw Buffer — the Web API handlers do their own parsing
|
|
@@ -491,6 +977,7 @@ app.addContentTypeParser("*", { parseAs: "buffer" }, (_req, body, done) => {
|
|
|
491
977
|
const _serverDir = dirname(fileURLToPath(import.meta.url));
|
|
492
978
|
const _envExamplesDir = process.env["NODETOOL_BASE_EXAMPLES_DIR"];
|
|
493
979
|
const _bundledExamplesDir = resolve(_serverDir, "examples", "nodetool-base");
|
|
980
|
+
const _bundledAssetsDir = resolve(_serverDir, "assets", "nodetool-base");
|
|
494
981
|
const _monoExamplesDir = resolve(_serverDir, "..", "..", "..", "packages", "base-nodes", "nodetool", "examples", "nodetool-base");
|
|
495
982
|
const _examplesDirCandidates = [
|
|
496
983
|
_envExamplesDir && existsSync(_envExamplesDir) ? _envExamplesDir : null,
|
|
@@ -507,9 +994,161 @@ else {
|
|
|
507
994
|
// ---------------------------------------------------------------------------
|
|
508
995
|
// API options for HTTP route handlers
|
|
509
996
|
// ---------------------------------------------------------------------------
|
|
510
|
-
const
|
|
997
|
+
const sdkLiveRunnerRegistry = new SdkLiveRunnerRegistry();
|
|
998
|
+
const frontendRendererRegistry = new FrontendRendererRegistry();
|
|
999
|
+
const resolveExecutionTarget = createSdkV1ExecutionTargetReadiness({
|
|
1000
|
+
getActiveWorker: () => workerManager.getActiveWorker()
|
|
1001
|
+
});
|
|
1002
|
+
function listRegistryRecommendedModels() {
|
|
1003
|
+
const models = [];
|
|
1004
|
+
for (const metadata of registry.listMetadata()) {
|
|
1005
|
+
for (const candidate of metadata.recommended_models ?? []) {
|
|
1006
|
+
const parsed = unifiedModel.safeParse(candidate);
|
|
1007
|
+
if (parsed.success) {
|
|
1008
|
+
models.push({
|
|
1009
|
+
...parsed.data,
|
|
1010
|
+
provider: parsed.data.provider == null ? undefined : parsed.data.provider
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
return models;
|
|
1016
|
+
}
|
|
1017
|
+
const sdkModelDownloadService = createSdkV1ModelDownloadService({
|
|
1018
|
+
startWorkerDownload: (userId, request, operationId, onProgress) => relayWorkerDownload({
|
|
1019
|
+
send: (data) => onProgress(JSON.parse(data))
|
|
1020
|
+
}, pythonBridge, workerManager, {
|
|
1021
|
+
command: "start_download",
|
|
1022
|
+
repo_id: request.repo_id,
|
|
1023
|
+
path: request.path ?? null,
|
|
1024
|
+
allow_patterns: request.allow_patterns ?? null,
|
|
1025
|
+
ignore_patterns: request.ignore_patterns ?? null,
|
|
1026
|
+
model_type: request.model_type,
|
|
1027
|
+
scope: "worker"
|
|
1028
|
+
}, operationId, userId),
|
|
1029
|
+
cancelWorkerDownload: (operationId) => pythonBridge.cancelModelDownload(operationId)
|
|
1030
|
+
});
|
|
1031
|
+
const apiOptions = {
|
|
1032
|
+
metadataRoots,
|
|
1033
|
+
registry,
|
|
1034
|
+
getPythonBridgeReady,
|
|
1035
|
+
sdkV1Boundary: createSdkV1ImplementationBoundary(createSdkV1Service({
|
|
1036
|
+
getCapabilities: createNodeToolSdkV1CapabilitiesProvider({
|
|
1037
|
+
nodetoolVersion: getVersion(),
|
|
1038
|
+
registry,
|
|
1039
|
+
pythonBridge: () => (getPythonBridgeReady() ? "ready" : "starting"),
|
|
1040
|
+
profiles: {
|
|
1041
|
+
discovery: "available",
|
|
1042
|
+
execution: "available",
|
|
1043
|
+
preflight: "available",
|
|
1044
|
+
model_catalog: "available",
|
|
1045
|
+
model_download: "available",
|
|
1046
|
+
temporary_asset_upload: "available"
|
|
1047
|
+
},
|
|
1048
|
+
authModes: enforceAuth ? ["bearer"] : ["trusted_local"],
|
|
1049
|
+
assetUriSchemes: ["asset"],
|
|
1050
|
+
limits: {
|
|
1051
|
+
maxRpcBatch: 100,
|
|
1052
|
+
// The initial SDK profile deliberately prefers asset references for
|
|
1053
|
+
// media instead of promising an inline payload size.
|
|
1054
|
+
maxInlineBytes: 0,
|
|
1055
|
+
maxQueuedJobs: 0,
|
|
1056
|
+
maxJobEventReplay: 0,
|
|
1057
|
+
requestTimeoutSeconds: 30
|
|
1058
|
+
}
|
|
1059
|
+
}),
|
|
1060
|
+
preflightService: createNodeToolSdkV1PreflightService({
|
|
1061
|
+
registry,
|
|
1062
|
+
getPythonBridgeReady,
|
|
1063
|
+
getExecutionTargetReadiness: ({ request, principal }) => {
|
|
1064
|
+
const target = request.execution_target;
|
|
1065
|
+
if (target?.kind === "runner") {
|
|
1066
|
+
const ready = sdkLiveRunnerRegistry.has(target.runner_id, principal.userId);
|
|
1067
|
+
return {
|
|
1068
|
+
id: target.runner_id,
|
|
1069
|
+
name: "Live runner",
|
|
1070
|
+
ready,
|
|
1071
|
+
message: ready ? null : "Selected live runner is not available."
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
return resolveExecutionTarget(target);
|
|
1075
|
+
},
|
|
1076
|
+
getExecutionCapacitySnapshot: ({ request, principal }) => {
|
|
1077
|
+
const target = request.execution_target;
|
|
1078
|
+
if (target?.kind !== "runner") {
|
|
1079
|
+
throw new Error("Execution capacity requires a selected live runner.");
|
|
1080
|
+
}
|
|
1081
|
+
return sdkLiveRunnerRegistry.getCapacity({
|
|
1082
|
+
runnerId: target.runner_id,
|
|
1083
|
+
userId: principal.userId,
|
|
1084
|
+
workflowId: request.workflow_id,
|
|
1085
|
+
concurrent: target.concurrent
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
}),
|
|
1089
|
+
modelCatalogService: {
|
|
1090
|
+
list: (args) => getSdkV1ModelCatalog({
|
|
1091
|
+
...args,
|
|
1092
|
+
recommendedModels: listRegistryRecommendedModels(),
|
|
1093
|
+
getWorkerModels: async () => {
|
|
1094
|
+
const activeWorker = await workerManager?.getActiveWorker();
|
|
1095
|
+
if (!activeWorker) {
|
|
1096
|
+
throw new SdkModelCatalogServiceError("No worker is attached to this server.");
|
|
1097
|
+
}
|
|
1098
|
+
if (!pythonBridge.supportsModelManagement()) {
|
|
1099
|
+
throw new SdkModelCatalogServiceError("The attached worker does not support model management.");
|
|
1100
|
+
}
|
|
1101
|
+
const models = [];
|
|
1102
|
+
for (const candidate of await pythonBridge.listCachedModels()) {
|
|
1103
|
+
const parsed = unifiedModel.safeParse(candidate);
|
|
1104
|
+
if (parsed.success)
|
|
1105
|
+
models.push(parsed.data);
|
|
1106
|
+
}
|
|
1107
|
+
return models;
|
|
1108
|
+
}
|
|
1109
|
+
})
|
|
1110
|
+
},
|
|
1111
|
+
modelDownloadService: sdkModelDownloadService,
|
|
1112
|
+
temporaryAssetService: createSdkV1TemporaryAssetService({
|
|
1113
|
+
getStorage: getTempAdapter
|
|
1114
|
+
})
|
|
1115
|
+
}))
|
|
1116
|
+
};
|
|
511
1117
|
if (_resolvedExamplesDir) {
|
|
512
1118
|
apiOptions.examplesDir = _resolvedExamplesDir;
|
|
1119
|
+
if (existsSync(_bundledAssetsDir)) {
|
|
1120
|
+
apiOptions.examplesAssetsFallbackDir = _bundledAssetsDir;
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
// Constant package assets (`package://<pkg>/<file>`) are served read-only at
|
|
1124
|
+
// `/api/assets/packages/<pkg>/<file>` from `<root>/<pkg>/<file>`. The bundled
|
|
1125
|
+
// root sits next to server.mjs (no Python needed); the monorepo root is used
|
|
1126
|
+
// in dev/dist runs.
|
|
1127
|
+
const _bundledPackageAssetsRoot = resolve(_serverDir, "assets");
|
|
1128
|
+
const _monoPackageAssetsRoot = resolve(_serverDir, "..", "..", "..", "packages", "base-nodes", "nodetool", "assets");
|
|
1129
|
+
// The bundled typefaces (D8). Two layouts, checked rather than assumed: the
|
|
1130
|
+
// packaged backend stages them beside `server.mjs`, a checkout keeps them in
|
|
1131
|
+
// the timeline package's own `fonts/` directory. `registerBundledFonts` in
|
|
1132
|
+
// `@nodetool-ai/timeline/fonts/node` resolves the same two for the Node
|
|
1133
|
+
// rasterizers; this is the copy the HTTP route serves to the browser from.
|
|
1134
|
+
const _bundledFontsDir = [
|
|
1135
|
+
resolve(_serverDir, "fonts"),
|
|
1136
|
+
resolve(_serverDir, "..", "..", "..", "packages", "timeline", "fonts")
|
|
1137
|
+
].find((dir) => existsSync(dir));
|
|
1138
|
+
if (_bundledFontsDir) {
|
|
1139
|
+
apiOptions.bundledFontsDir = _bundledFontsDir;
|
|
1140
|
+
}
|
|
1141
|
+
const _packageAssetsRoots = [
|
|
1142
|
+
existsSync(_bundledPackageAssetsRoot) ? _bundledPackageAssetsRoot : null,
|
|
1143
|
+
existsSync(_monoPackageAssetsRoot) ? _monoPackageAssetsRoot : null
|
|
1144
|
+
].filter((d) => Boolean(d));
|
|
1145
|
+
if (_packageAssetsRoots.length > 0) {
|
|
1146
|
+
apiOptions.packageAssetsRoots = _packageAssetsRoots;
|
|
1147
|
+
// Let in-process workflow execution resolve `package://` refs straight from
|
|
1148
|
+
// disk instead of guessing the loopback port for an HTTP round-trip.
|
|
1149
|
+
if (!process.env["NODETOOL_PACKAGE_ASSETS_DIR"]) {
|
|
1150
|
+
process.env["NODETOOL_PACKAGE_ASSETS_DIR"] = _packageAssetsRoots[0];
|
|
1151
|
+
}
|
|
513
1152
|
}
|
|
514
1153
|
const staticFolder = process.env["STATIC_FOLDER"];
|
|
515
1154
|
const hasStaticApp = Boolean(staticFolder && existsSync(staticFolder));
|
|
@@ -520,31 +1159,42 @@ const createContext = createContextFactory({
|
|
|
520
1159
|
registry,
|
|
521
1160
|
apiOptions,
|
|
522
1161
|
pythonBridge,
|
|
523
|
-
getPythonBridgeReady
|
|
1162
|
+
getPythonBridgeReady,
|
|
1163
|
+
workerManager,
|
|
1164
|
+
repointPythonBridge,
|
|
1165
|
+
probeWorkerHealth
|
|
524
1166
|
});
|
|
525
1167
|
await app.register(fastifyTRPCPlugin, {
|
|
526
1168
|
prefix: "/trpc",
|
|
527
1169
|
trpcOptions: {
|
|
528
1170
|
router: appRouter,
|
|
529
1171
|
createContext,
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
1172
|
+
// The web client forces all batches to POST (httpBatchLink
|
|
1173
|
+
// `methodOverride: "POST"`) so long batched inputs ride in the body instead
|
|
1174
|
+
// of the URL, which reverse proxies reject once the query string grows too
|
|
1175
|
+
// large (see web/src/trpc/client.ts and issues #3979/#3981). Without this
|
|
1176
|
+
// flag the server rejects POST-to-query with 405, leaving panels empty.
|
|
1177
|
+
allowMethodOverride: true,
|
|
1178
|
+
maxBatchSize: TRPC_MAX_BATCH_SIZE,
|
|
1179
|
+
onError({ path, error, req }) {
|
|
1180
|
+
logTrpcRequestError(log, {
|
|
1181
|
+
path,
|
|
1182
|
+
error,
|
|
1183
|
+
requestId: req.id
|
|
1184
|
+
});
|
|
539
1185
|
}
|
|
540
1186
|
}
|
|
541
1187
|
});
|
|
542
1188
|
await app.register(websocketPlugin, {
|
|
543
1189
|
registry,
|
|
544
1190
|
pythonBridge,
|
|
545
|
-
|
|
1191
|
+
apiOptions,
|
|
1192
|
+
sdkLiveRunnerRegistry,
|
|
1193
|
+
frontendRendererRegistry,
|
|
1194
|
+
workerManager,
|
|
1195
|
+
getPythonBridgeReady,
|
|
546
1196
|
ensurePythonBridge: async () => {
|
|
547
|
-
if (
|
|
1197
|
+
if (getPythonBridgeReady())
|
|
548
1198
|
return;
|
|
549
1199
|
log.info(`Lazily starting Python bridge [${startupMs()}]`);
|
|
550
1200
|
try {
|
|
@@ -554,31 +1204,18 @@ await app.register(websocketPlugin, {
|
|
|
554
1204
|
log.warn(`Python bridge lazy start failed [${startupMs()}]`, err instanceof Error ? err : new Error(String(err)));
|
|
555
1205
|
throw err;
|
|
556
1206
|
}
|
|
1207
|
+
// A worker bridge is connected eagerly on attach; readiness then derives
|
|
1208
|
+
// from its live connection state. Only the local bridge does the one-time
|
|
1209
|
+
// node-metadata registration below.
|
|
1210
|
+
if (!isLocalActive()) {
|
|
1211
|
+
log.info(`Worker Python bridge connected [${startupMs()}]`);
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
557
1214
|
pythonBridgeReady = true;
|
|
558
1215
|
log.info(`Python bridge lazy start completed [${startupMs()}]`);
|
|
559
1216
|
const meta = pythonBridge.getNodeMetadata();
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
for (const nodeMeta of meta) {
|
|
563
|
-
if (!nodeMeta.node_type)
|
|
564
|
-
continue;
|
|
565
|
-
if (registry.getMetadata(nodeMeta.node_type))
|
|
566
|
-
continue;
|
|
567
|
-
bridgeOnly++;
|
|
568
|
-
registry.loadMetadata(nodeMeta.node_type, {
|
|
569
|
-
...nodeMeta,
|
|
570
|
-
namespace: nodeMeta.node_type.split(".").slice(0, -1).join("."),
|
|
571
|
-
layout: "default",
|
|
572
|
-
recommended_models: [],
|
|
573
|
-
basic_fields: [],
|
|
574
|
-
required_settings: nodeMeta.required_settings ?? [],
|
|
575
|
-
is_dynamic: nodeMeta.is_dynamic ?? false,
|
|
576
|
-
is_streaming_output: nodeMeta.is_streaming_output ?? false,
|
|
577
|
-
expose_as_tool: false,
|
|
578
|
-
supports_dynamic_outputs: false
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
log.info(`Python bridge connected [${startupMs()}] — ${meta.length} Python nodes (${bridgeOnly} bridge-only, ${meta.length - bridgeOnly} from JSON)`);
|
|
1217
|
+
const mergeResult = mergePythonBridgeMetadata(registry, meta);
|
|
1218
|
+
log.info(`Python bridge connected [${startupMs()}] — ${mergeResult.total} Python nodes (${mergeResult.bridgeOnly} bridge-only, ${mergeResult.alreadyKnown} already registered)`);
|
|
582
1219
|
pythonBridge
|
|
583
1220
|
.getWorkerStatus?.()
|
|
584
1221
|
?.then((status) => {
|
|
@@ -599,26 +1236,82 @@ await app.register(websocketPlugin, {
|
|
|
599
1236
|
notifyPythonBridgeResourceChanges(app, pythonBridge).catch((err) => {
|
|
600
1237
|
log.warn("Failed to notify Python bridge resource changes", err instanceof Error ? err : new Error(String(err)));
|
|
601
1238
|
});
|
|
602
|
-
}
|
|
603
|
-
toolClassMap
|
|
1239
|
+
}
|
|
604
1240
|
});
|
|
1241
|
+
// One poller for the whole process, not one per connection: it re-reads this
|
|
1242
|
+
// instance's own running runs so a cancel written on another instance lands
|
|
1243
|
+
// here. The registry it consults is process-wide.
|
|
1244
|
+
const stopJobCancelPoller = startJobCancelPoller();
|
|
605
1245
|
await app.register(healthRoute);
|
|
1246
|
+
await app.register(configRoute);
|
|
606
1247
|
// All HTTP API routes receive apiOptions
|
|
607
1248
|
const routeOpts = { apiOptions };
|
|
1249
|
+
await app.register(sdkV1Routes, routeOpts);
|
|
608
1250
|
await app.register(assetsRoutes, routeOpts);
|
|
1251
|
+
await app.register(timelineFontRoutes, routeOpts);
|
|
609
1252
|
await app.register(workflowsRoutes, routeOpts);
|
|
610
|
-
await app.register(jobsRoutes, routeOpts);
|
|
611
1253
|
await app.register(nodesRoutes, routeOpts);
|
|
612
1254
|
await app.register(storageRoutes, routeOpts);
|
|
613
1255
|
await app.register(openaiRoutes, routeOpts);
|
|
614
1256
|
await app.register(oauthRoutes, routeOpts);
|
|
1257
|
+
// MCP OAuth 2.1 AS + well-known discovery routes (docs/mcp-oauth-design.md).
|
|
1258
|
+
// Self-contained: registers its own content-type parsers on its own
|
|
1259
|
+
// encapsulated context, so it is unaffected by the raw-buffer parser the
|
|
1260
|
+
// outer app installs above. 404s every route on its own when the flow is
|
|
1261
|
+
// unconfigured or NODETOOL_DISABLE_MCP_OAUTH=1 — nothing to gate here.
|
|
1262
|
+
await app.register(oauthAsRoutes);
|
|
615
1263
|
await app.register(workspaceRoutes, routeOpts);
|
|
1264
|
+
// A cloud deployment keeps workspaces in the asset bucket rather than on the
|
|
1265
|
+
// machine's disk, which it would lose on every replacement. No-op locally.
|
|
1266
|
+
initWorkspaceStorage();
|
|
1267
|
+
// The Workspace Explorer has no other way to hear about a file a run wrote:
|
|
1268
|
+
// workspace files are not database rows.
|
|
1269
|
+
initWorkspaceChangeEvents();
|
|
616
1270
|
await app.register(filesRoutes, routeOpts);
|
|
617
1271
|
await app.register(collectionsRoutes, routeOpts);
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
1272
|
+
await app.register(applicationsRoutes, routeOpts);
|
|
1273
|
+
await app.register(publicAppRoutes, { appSessionSigningKey });
|
|
1274
|
+
await app.register(jsScriptsRoutes, routeOpts);
|
|
1275
|
+
await app.register(timelineAnimationRoutes, routeOpts);
|
|
1276
|
+
await app.register(timelineAudioBakeRoutes, routeOpts);
|
|
1277
|
+
await app.register(timelineIsolateSubjectRoutes, routeOpts);
|
|
1278
|
+
await app.register(timelineTrackObjectRoutes, routeOpts);
|
|
1279
|
+
await app.register(storyboardsRoutes, routeOpts);
|
|
1280
|
+
await app.register(timelinesRoutes, routeOpts);
|
|
1281
|
+
// PDF/DOCX text extraction for script and screenplay imports. Stores
|
|
1282
|
+
// nothing and needs no apiOptions.
|
|
1283
|
+
await app.register(documentsRoutes);
|
|
1284
|
+
// Art. 20 export and Art. 17 erasure. The subject is always the caller:
|
|
1285
|
+
// no admin path, no subject id anywhere in the URL or body.
|
|
1286
|
+
await app.register(accountRoutes, routeOpts);
|
|
1287
|
+
await app.register(sandboxModulesRoutes);
|
|
1288
|
+
await app.register(falCreditsRoute);
|
|
1289
|
+
await app.register(falPricingRoute);
|
|
1290
|
+
await app.register(falPricingEstimateRoute);
|
|
1291
|
+
await app.register(kieCreditsRoute);
|
|
1292
|
+
await app.register(kiePricingRoute);
|
|
1293
|
+
await app.register(kieWebhookRoute);
|
|
1294
|
+
// fal callbacks authenticate with signed headers and commit to the durable
|
|
1295
|
+
// generation inbox before the route acknowledges them.
|
|
1296
|
+
await app.register(falWebhookRoute);
|
|
1297
|
+
// AtlasCloud callbacks authenticate with an Ed25519 signature over the raw
|
|
1298
|
+
// body and hand the finished prediction to the run waiting on it.
|
|
1299
|
+
await app.register(atlasCloudWebhookRoute);
|
|
1300
|
+
// Messaging-integration identity routes (`/api/integrations/:provider/*`).
|
|
1301
|
+
// The plugin registers nothing unless NODETOOL_INTEGRATION_TOKEN is set, so a
|
|
1302
|
+
// server without it answers 404 on every one of these paths.
|
|
1303
|
+
await app.register(createIntegrationRoutes({ signingKey: delegatedSigningKey, enforceAuth }));
|
|
1304
|
+
// Trigger webhook ingestion (`POST /api/webhooks/:token`). Registered here
|
|
1305
|
+
// because Fastify routes must exist before `app.listen`; the plugin reaches the
|
|
1306
|
+
// wakeup service and dispatcher started below through module accessors.
|
|
1307
|
+
if (triggersEnabled()) {
|
|
1308
|
+
await app.register(createTriggerWebhookRoute());
|
|
1309
|
+
}
|
|
1310
|
+
// The `/mcp` mount is a bare MCP over-HTTP transport (the configuration
|
|
1311
|
+
// endpoints moved to the tRPC `mcpConfig` router, which stays local-only). In
|
|
1312
|
+
// production it registers only with NODETOOL_ENABLE_MCP=1, and it binds the
|
|
1313
|
+
// user the auth hook resolved rather than the local single user.
|
|
1314
|
+
if (mcpHttpEnabled) {
|
|
622
1315
|
app.all("/mcp", async (req, reply) => {
|
|
623
1316
|
const protocol = httpsOptions ? "https" : "http";
|
|
624
1317
|
const url = `${protocol}://${req.headers.host ?? `127.0.0.1:${port}`}${req.url}`;
|
|
@@ -629,7 +1322,7 @@ if (!isProduction) {
|
|
|
629
1322
|
headers.append(key, item);
|
|
630
1323
|
}
|
|
631
1324
|
}
|
|
632
|
-
else if (
|
|
1325
|
+
else if (value != null) {
|
|
633
1326
|
headers.set(key, value);
|
|
634
1327
|
}
|
|
635
1328
|
}
|
|
@@ -637,7 +1330,7 @@ if (!isProduction) {
|
|
|
637
1330
|
? undefined
|
|
638
1331
|
: Buffer.isBuffer(req.body)
|
|
639
1332
|
? req.body
|
|
640
|
-
:
|
|
1333
|
+
: isString(req.body)
|
|
641
1334
|
? req.body
|
|
642
1335
|
: req.body == null
|
|
643
1336
|
? Buffer.alloc(0)
|
|
@@ -645,10 +1338,30 @@ if (!isProduction) {
|
|
|
645
1338
|
const request = new Request(url, {
|
|
646
1339
|
method: req.method,
|
|
647
1340
|
headers,
|
|
648
|
-
body: requestBody
|
|
649
|
-
|
|
1341
|
+
body: Buffer.isBuffer(requestBody)
|
|
1342
|
+
? new Uint8Array(requestBody)
|
|
1343
|
+
: requestBody,
|
|
1344
|
+
// `duplex` is required by Node's fetch when streaming bodies but is
|
|
1345
|
+
// missing from some `@types/node`/`undici-types` versions of RequestInit.
|
|
1346
|
+
...{ duplex: "half" }
|
|
1347
|
+
});
|
|
1348
|
+
// The scope is the user the auth hook resolved for this request. With no
|
|
1349
|
+
// user, no scope is passed and mcp-server.ts answers 401 at initialize
|
|
1350
|
+
// instead of handing out an anonymous full-access session.
|
|
1351
|
+
const response = await handleMcpHttpRequest(request, {
|
|
1352
|
+
metadataRoots,
|
|
1353
|
+
registry,
|
|
1354
|
+
examplesDir: apiOptions.examplesDir,
|
|
1355
|
+
frontendRendererRegistry,
|
|
1356
|
+
allowLocalFilePaths: !isProduction && isLoopbackAddress(req.ip),
|
|
1357
|
+
agentToolsScope: req.userId
|
|
1358
|
+
? {
|
|
1359
|
+
userId: req.userId,
|
|
1360
|
+
source: isProduction ? "http-session" : "local-dev-http"
|
|
1361
|
+
}
|
|
1362
|
+
: undefined,
|
|
1363
|
+
unauthorizedChallenge: mcpBearerChallenge()
|
|
650
1364
|
});
|
|
651
|
-
const response = await handleMcpHttpRequest(request, { metadataRoots });
|
|
652
1365
|
if (!response) {
|
|
653
1366
|
reply.status(404).send({ error: "Not found" });
|
|
654
1367
|
return;
|
|
@@ -661,7 +1374,9 @@ if (!isProduction) {
|
|
|
661
1374
|
reply.send(payload);
|
|
662
1375
|
});
|
|
663
1376
|
}
|
|
664
|
-
|
|
1377
|
+
else {
|
|
1378
|
+
log.info(`MCP over HTTP (/mcp) disabled in production; set ${MCP_ENABLE_FLAG}=1 to enable`);
|
|
1379
|
+
}
|
|
665
1380
|
log.info(`Routes registered [${startupMs()}]`);
|
|
666
1381
|
if (hasStaticApp && staticFolder) {
|
|
667
1382
|
log.info("Serving static app", { root: staticFolder });
|
|
@@ -676,6 +1391,20 @@ if (hasStaticApp && staticFolder) {
|
|
|
676
1391
|
return reply.sendFile("index.html");
|
|
677
1392
|
});
|
|
678
1393
|
}
|
|
1394
|
+
// Download the built Chrome extension as a zip, for the install helper UI.
|
|
1395
|
+
app.get("/api/extension/download", async (_req, reply) => {
|
|
1396
|
+
try {
|
|
1397
|
+
const zip = await zipExtensionDist();
|
|
1398
|
+
return reply
|
|
1399
|
+
.header("Content-Type", "application/zip")
|
|
1400
|
+
.header("Content-Disposition", 'attachment; filename="nodetool-chrome-extension.zip"')
|
|
1401
|
+
.send(zip);
|
|
1402
|
+
}
|
|
1403
|
+
catch (err) {
|
|
1404
|
+
log.warn(`Extension download failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
1405
|
+
return reply.status(404).send({ detail: "Extension build not found" });
|
|
1406
|
+
}
|
|
1407
|
+
});
|
|
679
1408
|
// Log all 404s so we can identify missing routes
|
|
680
1409
|
app.setNotFoundHandler((req, reply) => {
|
|
681
1410
|
const pathname = req.url.split("?")[0] ?? "/";
|
|
@@ -685,8 +1414,14 @@ app.setNotFoundHandler((req, reply) => {
|
|
|
685
1414
|
!pathname.startsWith("/health") &&
|
|
686
1415
|
!pathname.startsWith("/ws") &&
|
|
687
1416
|
!pathname.startsWith("/v1") &&
|
|
688
|
-
!pathname.startsWith("/
|
|
1417
|
+
!pathname.startsWith("/.well-known/") &&
|
|
1418
|
+
// /oauth/consent is the one /oauth path that IS the SPA — the MCP OAuth
|
|
1419
|
+
// consent page (docs/mcp-oauth-design.md). Every other /oauth/* path is
|
|
1420
|
+
// an AS API route (authorize/token/register/revoke), and unmatched
|
|
1421
|
+
// requests there must 404 rather than get served index.html.
|
|
1422
|
+
(pathname === "/oauth/consent" || !pathname.startsWith("/oauth")) &&
|
|
689
1423
|
!pathname.startsWith("/trpc") &&
|
|
1424
|
+
!pathname.startsWith("/mcp") &&
|
|
690
1425
|
!pathname.includes(".")) {
|
|
691
1426
|
return reply.sendFile("index.html");
|
|
692
1427
|
}
|
|
@@ -730,18 +1465,111 @@ app.listen({ port, host }, (err) => {
|
|
|
730
1465
|
log.info(`WebSocket endpoint: ${tlsEnabled ? "wss" : "ws"}://${host}:${port}/ws`);
|
|
731
1466
|
});
|
|
732
1467
|
// ---------------------------------------------------------------------------
|
|
1468
|
+
// Triggers — durable wakeup service, dispatcher, and ingestion adapters
|
|
1469
|
+
// ---------------------------------------------------------------------------
|
|
1470
|
+
//
|
|
1471
|
+
// Starting the dispatcher also drains the boot backlog: every unprocessed
|
|
1472
|
+
// `trigger_inputs` row a previous process life stored is dispatched now. Set
|
|
1473
|
+
// NODETOOL_DISABLE_TRIGGERS=1 to opt this process out.
|
|
1474
|
+
const triggerServices = startTriggerServices({ registry });
|
|
1475
|
+
// ---------------------------------------------------------------------------
|
|
1476
|
+
// Worker cost guard — reconcile orphaned GPU pods on boot, then reap on a loop
|
|
1477
|
+
// ---------------------------------------------------------------------------
|
|
1478
|
+
const WORKER_REAPER_INTERVAL_MS = 60_000;
|
|
1479
|
+
workerManager
|
|
1480
|
+
.reconcile()
|
|
1481
|
+
.then((summary) => {
|
|
1482
|
+
if (summary.liveCount > 0 || summary.orphans.length > 0) {
|
|
1483
|
+
log.info(`Worker reconcile: ${summary.liveCount} live, ` +
|
|
1484
|
+
`${summary.orphans.length} orphaned, ~$${summary.estimatedCostUsd.toFixed(2)}`);
|
|
1485
|
+
}
|
|
1486
|
+
})
|
|
1487
|
+
.catch((reconcileErr) => {
|
|
1488
|
+
log.warn("Worker reconcile failed at startup", reconcileErr instanceof Error
|
|
1489
|
+
? reconcileErr
|
|
1490
|
+
: new Error(String(reconcileErr)));
|
|
1491
|
+
});
|
|
1492
|
+
const stopReaper = startReaper({
|
|
1493
|
+
manager: workerManager,
|
|
1494
|
+
getProfile: (name) => getWorkerProfile(name),
|
|
1495
|
+
now: () => Date.now()
|
|
1496
|
+
}, WORKER_REAPER_INTERVAL_MS);
|
|
1497
|
+
const generationRecoveryWorker = createGenerationRecoveryWorker();
|
|
1498
|
+
const generationRecoveryTimer = setInterval(() => {
|
|
1499
|
+
void generationRecoveryWorker.runOnce().catch((error) => {
|
|
1500
|
+
log.warn("Durable generation recovery failed", error instanceof Error ? error : new Error(String(error)));
|
|
1501
|
+
});
|
|
1502
|
+
}, 30_000);
|
|
1503
|
+
generationRecoveryTimer.unref?.();
|
|
1504
|
+
void generationRecoveryWorker.runOnce().catch((error) => {
|
|
1505
|
+
log.warn("Durable generation recovery failed at startup", error instanceof Error ? error : new Error(String(error)));
|
|
1506
|
+
});
|
|
1507
|
+
// ---------------------------------------------------------------------------
|
|
733
1508
|
// Graceful shutdown — ensure child processes (Python worker, etc.) are killed
|
|
734
1509
|
// ---------------------------------------------------------------------------
|
|
1510
|
+
/**
|
|
1511
|
+
* How long SIGTERM waits for aborted turns and runs to settle. Under Fly's
|
|
1512
|
+
* 300 s cap between the signal and the kill; the drain the deploy script runs
|
|
1513
|
+
* first is what actually waits for a long turn, so this is the fallback for a
|
|
1514
|
+
* restart nobody drained.
|
|
1515
|
+
*/
|
|
1516
|
+
function shutdownGraceMs() {
|
|
1517
|
+
const raw = process.env["NODETOOL_SHUTDOWN_GRACE_MS"];
|
|
1518
|
+
if (!raw)
|
|
1519
|
+
return 240_000;
|
|
1520
|
+
const parsed = Number.parseInt(raw, 10);
|
|
1521
|
+
return Number.isFinite(parsed) && parsed >= 0 ? parsed : 240_000;
|
|
1522
|
+
}
|
|
1523
|
+
let shuttingDown = false;
|
|
735
1524
|
async function shutdown(signal) {
|
|
1525
|
+
// The wait below can last minutes; a second signal in that window must not
|
|
1526
|
+
// run the teardown a second time on top of the first.
|
|
1527
|
+
if (shuttingDown) {
|
|
1528
|
+
log.info(`${signal} received again — shutdown already in progress`);
|
|
1529
|
+
return;
|
|
1530
|
+
}
|
|
1531
|
+
shuttingDown = true;
|
|
736
1532
|
log.info(`${signal} received — shutting down`);
|
|
1533
|
+
// Take no new work first, so nothing starts during the wait below.
|
|
1534
|
+
startDrain();
|
|
1535
|
+
const abortedTurns = chatTurnRegistry.abortAll("shutdown");
|
|
1536
|
+
const cancelledJobs = jobRunRegistry.cancelAll();
|
|
1537
|
+
if (abortedTurns > 0 || cancelledJobs > 0) {
|
|
1538
|
+
log.info("Aborting in-flight work", {
|
|
1539
|
+
turns: abortedTurns,
|
|
1540
|
+
jobs: cancelledJobs
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
const grace = shutdownGraceMs();
|
|
1544
|
+
const [turnsDrained, jobsDrained] = await Promise.all([
|
|
1545
|
+
chatTurnRegistry.drained(grace),
|
|
1546
|
+
jobRunRegistry.drained(grace)
|
|
1547
|
+
]);
|
|
1548
|
+
if (!turnsDrained || !jobsDrained) {
|
|
1549
|
+
// The turn's own `finally` writes the stand-in tool-result rows, so a
|
|
1550
|
+
// turn still running here is one whose transcript stays incomplete.
|
|
1551
|
+
log.warn("Shutdown grace expired with work still running", {
|
|
1552
|
+
graceMs: grace,
|
|
1553
|
+
turns: chatTurnRegistry.runningCount(),
|
|
1554
|
+
jobs: jobRunRegistry.runningCount()
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
// Spans are batched, so without this every span the last turns produced dies
|
|
1558
|
+
// with the process.
|
|
1559
|
+
await shutdownTelemetry();
|
|
737
1560
|
log.info("Closing Python bridge");
|
|
1561
|
+
stopReaper();
|
|
1562
|
+
clearInterval(generationRecoveryTimer);
|
|
1563
|
+
stopJobCancelPoller();
|
|
1564
|
+
stopGenerationReconcileWorker?.();
|
|
738
1565
|
try {
|
|
739
|
-
|
|
1566
|
+
await triggerServices.stop();
|
|
740
1567
|
}
|
|
741
|
-
catch {
|
|
742
|
-
|
|
1568
|
+
catch (err) {
|
|
1569
|
+
log.warn("Trigger services failed to stop cleanly", err instanceof Error ? err : new Error(String(err)));
|
|
743
1570
|
}
|
|
744
|
-
|
|
1571
|
+
localBridge.close();
|
|
1572
|
+
workerBridge?.close();
|
|
745
1573
|
try {
|
|
746
1574
|
await app.close();
|
|
747
1575
|
}
|
|
@@ -752,12 +1580,20 @@ async function shutdown(signal) {
|
|
|
752
1580
|
}
|
|
753
1581
|
process.on("SIGINT", () => void shutdown("SIGINT"));
|
|
754
1582
|
process.on("SIGTERM", () => void shutdown("SIGTERM"));
|
|
1583
|
+
// The deploy's drain signal: stop taking work and let the turns in flight
|
|
1584
|
+
// finish, without a deadline. `scripts/fly-rolling-deploy.sh` sends it, waits
|
|
1585
|
+
// for /health to report no turns and no jobs, and only then replaces the
|
|
1586
|
+
// machine — which is what keeps a 30-minute turn off Fly's 300 s SIGTERM cap.
|
|
1587
|
+
process.on("SIGUSR2", () => {
|
|
1588
|
+
log.info("SIGUSR2 received — draining");
|
|
1589
|
+
startDrain();
|
|
1590
|
+
});
|
|
755
1591
|
// On Windows, Ctrl+C in some terminals fires SIGBREAK instead of SIGINT
|
|
756
1592
|
if (process.platform === "win32") {
|
|
757
1593
|
process.on("SIGBREAK", () => void shutdown("SIGBREAK"));
|
|
758
1594
|
}
|
|
759
|
-
// Start Python bridge eagerly if
|
|
760
|
-
if (pythonBridge.
|
|
1595
|
+
// Start Python bridge eagerly if a worker is available.
|
|
1596
|
+
if (pythonBridge.isAvailable()) {
|
|
761
1597
|
log.info(`Starting Python bridge eagerly [${startupMs()}]`);
|
|
762
1598
|
pythonBridge
|
|
763
1599
|
.ensureConnected()
|
|
@@ -765,27 +1601,8 @@ if (pythonBridge.hasPython()) {
|
|
|
765
1601
|
pythonBridgeReady = true;
|
|
766
1602
|
log.info(`Python bridge eager start completed [${startupMs()}]`);
|
|
767
1603
|
const meta = pythonBridge.getNodeMetadata();
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
if (!nodeMeta.node_type)
|
|
771
|
-
continue;
|
|
772
|
-
if (registry.getMetadata(nodeMeta.node_type))
|
|
773
|
-
continue;
|
|
774
|
-
bridgeOnly++;
|
|
775
|
-
registry.loadMetadata(nodeMeta.node_type, {
|
|
776
|
-
...nodeMeta,
|
|
777
|
-
namespace: nodeMeta.node_type.split(".").slice(0, -1).join("."),
|
|
778
|
-
layout: "default",
|
|
779
|
-
recommended_models: [],
|
|
780
|
-
basic_fields: [],
|
|
781
|
-
required_settings: nodeMeta.required_settings ?? [],
|
|
782
|
-
is_dynamic: nodeMeta.is_dynamic ?? false,
|
|
783
|
-
is_streaming_output: nodeMeta.is_streaming_output ?? false,
|
|
784
|
-
expose_as_tool: false,
|
|
785
|
-
supports_dynamic_outputs: false
|
|
786
|
-
});
|
|
787
|
-
}
|
|
788
|
-
log.info(`Python bridge connected [${startupMs()}] — ${meta.length} Python nodes (${bridgeOnly} bridge-only, ${meta.length - bridgeOnly} from JSON)`);
|
|
1604
|
+
const mergeResult = mergePythonBridgeMetadata(registry, meta);
|
|
1605
|
+
log.info(`Python bridge connected [${startupMs()}] — ${mergeResult.total} Python nodes (${mergeResult.bridgeOnly} bridge-only, ${mergeResult.alreadyKnown} already registered)`);
|
|
789
1606
|
pythonBridge
|
|
790
1607
|
.getWorkerStatus?.()
|
|
791
1608
|
?.then((status) => {
|
|
@@ -812,8 +1629,9 @@ if (pythonBridge.hasPython()) {
|
|
|
812
1629
|
});
|
|
813
1630
|
}
|
|
814
1631
|
else {
|
|
815
|
-
|
|
816
|
-
|
|
1632
|
+
const pythonAllowedInProduction = process.env["NODETOOL_ALLOW_PYTHON_BRIDGE_IN_PRODUCTION"] === "1";
|
|
1633
|
+
log.info(isProduction && !pythonAllowedInProduction
|
|
1634
|
+
? "Python bridge disabled in production — Python nodes will not be available; set NODETOOL_ALLOW_PYTHON_BRIDGE_IN_PRODUCTION=1 to enable (the image ships no Python worker: install nodetool-core and point NODETOOL_PYTHON at that interpreter)"
|
|
817
1635
|
: "Python not found — Python nodes will not be available");
|
|
818
1636
|
}
|
|
819
1637
|
//# sourceMappingURL=server.js.map
|