managed-deepagents 0.5.0-dev.79 → 0.5.0-dev.81
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 +56 -13
- package/dist/channels/assistant-text.js +1 -1
- package/dist/channels/assistant-text.js.map +1 -1
- package/dist/channels/binding.d.ts.map +1 -1
- package/dist/channels/binding.js +3 -1
- package/dist/channels/binding.js.map +1 -1
- package/dist/channels/index.d.ts +6 -8
- package/dist/channels/index.d.ts.map +1 -1
- package/dist/channels/index.js +5 -5
- package/dist/channels/index.js.map +1 -1
- package/dist/channels/manifest.d.ts +36 -3
- package/dist/channels/manifest.d.ts.map +1 -1
- package/dist/channels/messaging-registry.d.ts +17 -0
- package/dist/channels/messaging-registry.d.ts.map +1 -0
- package/dist/channels/messaging-registry.js +44 -0
- package/dist/channels/messaging-registry.js.map +1 -0
- package/dist/channels/registry.d.ts +4 -3
- package/dist/channels/registry.d.ts.map +1 -1
- package/dist/channels/registry.js +6 -5
- package/dist/channels/registry.js.map +1 -1
- package/dist/channels/schedule-delivery.d.ts +4 -1
- package/dist/channels/schedule-delivery.d.ts.map +1 -1
- package/dist/channels/schedule-delivery.js +4 -2
- package/dist/channels/schedule-delivery.js.map +1 -1
- package/dist/connectors/github/adapter-core.d.ts +15 -0
- package/dist/connectors/github/adapter-core.d.ts.map +1 -0
- package/dist/connectors/github/adapter-core.js +52 -0
- package/dist/connectors/github/adapter-core.js.map +1 -0
- package/dist/{channels → connectors}/github/define.d.ts +28 -58
- package/dist/connectors/github/define.d.ts.map +1 -0
- package/dist/connectors/github/define.js +72 -0
- package/dist/connectors/github/define.js.map +1 -0
- package/dist/{channels → connectors}/github/http.d.ts +4 -4
- package/dist/connectors/github/http.d.ts.map +1 -0
- package/dist/{channels → connectors}/github/http.js +24 -25
- package/dist/connectors/github/http.js.map +1 -0
- package/dist/connectors/github/index.d.ts +59 -16
- package/dist/connectors/github/index.d.ts.map +1 -1
- package/dist/connectors/github/index.js +159 -73
- package/dist/connectors/github/index.js.map +1 -1
- package/dist/connectors/github/match.d.ts +20 -0
- package/dist/connectors/github/match.d.ts.map +1 -0
- package/dist/connectors/github/match.js +41 -0
- package/dist/connectors/github/match.js.map +1 -0
- package/dist/{channels → connectors}/github/normalize.d.ts +1 -1
- package/dist/connectors/github/normalize.d.ts.map +1 -0
- package/dist/{channels → connectors}/github/normalize.js +2 -2
- package/dist/connectors/github/normalize.js.map +1 -0
- package/dist/connectors/github/sandbox.d.ts.map +1 -1
- package/dist/connectors/github/sandbox.js +30 -23
- package/dist/connectors/github/sandbox.js.map +1 -1
- package/dist/connectors/github/source-thread.d.ts.map +1 -0
- package/dist/connectors/github/source-thread.js.map +1 -0
- package/dist/{channels → connectors}/github/transport.d.ts +7 -1
- package/dist/connectors/github/transport.d.ts.map +1 -0
- package/dist/{channels → connectors}/github/transport.js +18 -4
- package/dist/connectors/github/transport.js.map +1 -0
- package/dist/connectors/langsmith/index.d.ts +29 -17
- package/dist/connectors/langsmith/index.d.ts.map +1 -1
- package/dist/connectors/langsmith/index.js +34 -29
- package/dist/connectors/langsmith/index.js.map +1 -1
- package/dist/connectors/langsmith/routes.d.ts +4 -15
- package/dist/connectors/langsmith/routes.d.ts.map +1 -1
- package/dist/connectors/langsmith/routes.js +63 -72
- package/dist/connectors/langsmith/routes.js.map +1 -1
- package/dist/connectors/marketplace/catalog.d.ts +96 -0
- package/dist/connectors/marketplace/catalog.d.ts.map +1 -0
- package/dist/connectors/marketplace/catalog.js +213 -0
- package/dist/connectors/marketplace/catalog.js.map +1 -0
- package/dist/connectors/marketplace/fleet-mcp.d.ts +62 -0
- package/dist/connectors/marketplace/fleet-mcp.d.ts.map +1 -0
- package/dist/connectors/marketplace/fleet-mcp.js +215 -0
- package/dist/connectors/marketplace/fleet-mcp.js.map +1 -0
- package/dist/connectors/marketplace/index.d.ts +31 -0
- package/dist/connectors/marketplace/index.d.ts.map +1 -0
- package/dist/connectors/marketplace/index.js +39 -0
- package/dist/connectors/marketplace/index.js.map +1 -0
- package/dist/connectors/marketplace/load.d.ts +15 -0
- package/dist/connectors/marketplace/load.d.ts.map +1 -0
- package/dist/connectors/marketplace/load.js +265 -0
- package/dist/connectors/marketplace/load.js.map +1 -0
- package/dist/connectors/mcp/index.d.ts +13 -20
- package/dist/connectors/mcp/index.d.ts.map +1 -1
- package/dist/connectors/mcp/index.js +92 -112
- package/dist/connectors/mcp/index.js.map +1 -1
- package/dist/connectors/mcp/load.d.ts.map +1 -1
- package/dist/connectors/mcp/load.js +16 -40
- package/dist/connectors/mcp/load.js.map +1 -1
- package/dist/{channels → connectors}/slack/adapter-core.d.ts +1 -1
- package/dist/connectors/slack/adapter-core.d.ts.map +1 -0
- package/dist/connectors/slack/adapter-core.js.map +1 -0
- package/dist/{channels → connectors}/slack/adapter.d.ts +3 -4
- package/dist/connectors/slack/adapter.d.ts.map +1 -0
- package/dist/{channels → connectors}/slack/adapter.js +1 -1
- package/dist/connectors/slack/adapter.js.map +1 -0
- package/dist/{channels → connectors}/slack/http.d.ts +6 -40
- package/dist/connectors/slack/http.d.ts.map +1 -0
- package/dist/{channels → connectors}/slack/http.js +38 -127
- package/dist/connectors/slack/http.js.map +1 -0
- package/dist/connectors/slack/index.d.ts +108 -0
- package/dist/connectors/slack/index.d.ts.map +1 -0
- package/dist/connectors/slack/index.js +191 -0
- package/dist/connectors/slack/index.js.map +1 -0
- package/dist/{channels → connectors}/slack/normalize.d.ts +5 -5
- package/dist/connectors/slack/normalize.d.ts.map +1 -0
- package/dist/{channels → connectors}/slack/normalize.js +21 -20
- package/dist/connectors/slack/normalize.js.map +1 -0
- package/dist/connectors/slack/source-thread.d.ts.map +1 -0
- package/dist/connectors/slack/source-thread.js.map +1 -0
- package/dist/{channels → connectors}/slack/transport.d.ts +1 -1
- package/dist/connectors/slack/transport.d.ts.map +1 -0
- package/dist/{channels → connectors}/slack/transport.js +4 -3
- package/dist/connectors/slack/transport.js.map +1 -0
- package/dist/connectors/tool-selection.d.ts +55 -0
- package/dist/connectors/tool-selection.d.ts.map +1 -0
- package/dist/connectors/tool-selection.js +112 -0
- package/dist/connectors/tool-selection.js.map +1 -0
- package/dist/connectors/toolserver/catalog.d.ts +332 -0
- package/dist/connectors/toolserver/catalog.d.ts.map +1 -0
- package/dist/connectors/toolserver/catalog.js +463 -0
- package/dist/connectors/toolserver/catalog.js.map +1 -0
- package/dist/connectors/toolserver/connectors.d.ts +698 -0
- package/dist/connectors/toolserver/connectors.d.ts.map +1 -0
- package/dist/connectors/toolserver/connectors.js +13 -0
- package/dist/connectors/toolserver/connectors.js.map +1 -0
- package/dist/connectors/toolserver/index.d.ts +144 -0
- package/dist/connectors/toolserver/index.d.ts.map +1 -0
- package/dist/connectors/toolserver/index.js +107 -0
- package/dist/connectors/toolserver/index.js.map +1 -0
- package/dist/connectors/toolserver/integrations.d.ts +103 -0
- package/dist/connectors/toolserver/integrations.d.ts.map +1 -0
- package/dist/connectors/toolserver/integrations.js +277 -0
- package/dist/connectors/toolserver/integrations.js.map +1 -0
- package/dist/connectors/toolserver/load.d.ts +55 -0
- package/dist/connectors/toolserver/load.d.ts.map +1 -0
- package/dist/connectors/toolserver/load.js +290 -0
- package/dist/connectors/toolserver/load.js.map +1 -0
- package/dist/extension.d.ts +77 -0
- package/dist/extension.d.ts.map +1 -0
- package/dist/extension.js +127 -0
- package/dist/extension.js.map +1 -0
- package/dist/identity/actor-subject.d.ts +60 -0
- package/dist/identity/actor-subject.d.ts.map +1 -0
- package/dist/identity/actor-subject.js +107 -0
- package/dist/identity/actor-subject.js.map +1 -0
- package/dist/identity/byo-oauth.d.ts +81 -0
- package/dist/identity/byo-oauth.d.ts.map +1 -0
- package/dist/identity/byo-oauth.js +145 -0
- package/dist/identity/byo-oauth.js.map +1 -0
- package/dist/identity/claims.d.ts +18 -0
- package/dist/identity/claims.d.ts.map +1 -0
- package/dist/identity/claims.js +37 -0
- package/dist/identity/claims.js.map +1 -0
- package/dist/identity/connect-inference.d.ts +38 -0
- package/dist/identity/connect-inference.d.ts.map +1 -0
- package/dist/identity/connect-inference.js +55 -0
- package/dist/identity/connect-inference.js.map +1 -0
- package/dist/identity/connect-provider-types.d.ts +35 -6
- package/dist/identity/connect-provider-types.d.ts.map +1 -1
- package/dist/identity/connect-provider-types.js +3 -1
- package/dist/identity/connect-provider-types.js.map +1 -1
- package/dist/identity/connect-provider.d.ts +9 -4
- package/dist/identity/connect-provider.d.ts.map +1 -1
- package/dist/identity/connect-provider.js +38 -12
- package/dist/identity/connect-provider.js.map +1 -1
- package/dist/identity/credential-resolvers.d.ts +33 -0
- package/dist/identity/credential-resolvers.d.ts.map +1 -0
- package/dist/identity/credential-resolvers.js +62 -0
- package/dist/identity/credential-resolvers.js.map +1 -0
- package/dist/identity/fleet-connect-hint.d.ts +39 -0
- package/dist/identity/fleet-connect-hint.d.ts.map +1 -0
- package/dist/identity/fleet-connect-hint.js +134 -0
- package/dist/identity/fleet-connect-hint.js.map +1 -0
- package/dist/identity/fleet-connect.d.ts +92 -0
- package/dist/identity/fleet-connect.d.ts.map +1 -0
- package/dist/identity/fleet-connect.js +256 -0
- package/dist/identity/fleet-connect.js.map +1 -0
- package/dist/identity/fleet-integration-connect.d.ts +32 -0
- package/dist/identity/fleet-integration-connect.d.ts.map +1 -0
- package/dist/identity/fleet-integration-connect.js +35 -0
- package/dist/identity/fleet-integration-connect.js.map +1 -0
- package/dist/identity/fleet.d.ts +56 -0
- package/dist/identity/fleet.d.ts.map +1 -0
- package/dist/identity/fleet.js +133 -0
- package/dist/identity/fleet.js.map +1 -0
- package/dist/identity/github/connect-http.d.ts +9 -4
- package/dist/identity/github/connect-http.d.ts.map +1 -1
- package/dist/identity/github/connect-http.js +34 -15
- package/dist/identity/github/connect-http.js.map +1 -1
- package/dist/identity/github/credentials-store.d.ts +10 -10
- package/dist/identity/github/credentials-store.d.ts.map +1 -1
- package/dist/identity/github/credentials-store.js +40 -43
- package/dist/identity/github/credentials-store.js.map +1 -1
- package/dist/identity/github/credentials.d.ts +16 -13
- package/dist/identity/github/credentials.d.ts.map +1 -1
- package/dist/identity/github/credentials.js +43 -23
- package/dist/identity/github/credentials.js.map +1 -1
- package/dist/identity/github/index.d.ts +2 -3
- package/dist/identity/github/index.d.ts.map +1 -1
- package/dist/identity/github/index.js +1 -2
- package/dist/identity/github/index.js.map +1 -1
- package/dist/identity/github/oauth.d.ts +3 -6
- package/dist/identity/github/oauth.d.ts.map +1 -1
- package/dist/identity/github/oauth.js +9 -48
- package/dist/identity/github/oauth.js.map +1 -1
- package/dist/identity/google/connect-http.d.ts +38 -0
- package/dist/identity/google/connect-http.d.ts.map +1 -0
- package/dist/identity/google/connect-http.js +59 -0
- package/dist/identity/google/connect-http.js.map +1 -0
- package/dist/identity/google/index.d.ts +7 -0
- package/dist/identity/google/index.d.ts.map +1 -0
- package/dist/identity/google/index.js +6 -0
- package/dist/identity/google/index.js.map +1 -0
- package/dist/identity/google/oauth.d.ts +22 -0
- package/dist/identity/google/oauth.d.ts.map +1 -0
- package/dist/identity/google/oauth.js +48 -0
- package/dist/identity/google/oauth.js.map +1 -0
- package/dist/identity/index.d.ts +51 -29
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/index.js +122 -131
- package/dist/identity/index.js.map +1 -1
- package/dist/identity/linkedin/connect-http.d.ts +38 -0
- package/dist/identity/linkedin/connect-http.d.ts.map +1 -0
- package/dist/identity/linkedin/connect-http.js +59 -0
- package/dist/identity/linkedin/connect-http.js.map +1 -0
- package/dist/identity/linkedin/index.d.ts +7 -0
- package/dist/identity/linkedin/index.d.ts.map +1 -0
- package/dist/identity/linkedin/index.js +6 -0
- package/dist/identity/linkedin/index.js.map +1 -0
- package/dist/identity/linkedin/oauth.d.ts +22 -0
- package/dist/identity/linkedin/oauth.d.ts.map +1 -0
- package/dist/identity/linkedin/oauth.js +47 -0
- package/dist/identity/linkedin/oauth.js.map +1 -0
- package/dist/identity/loopback.d.ts +27 -2
- package/dist/identity/loopback.d.ts.map +1 -1
- package/dist/identity/loopback.js +61 -8
- package/dist/identity/loopback.js.map +1 -1
- package/dist/identity/marketplace/connect-hint.d.ts +31 -0
- package/dist/identity/marketplace/connect-hint.d.ts.map +1 -0
- package/dist/identity/marketplace/connect-hint.js +59 -0
- package/dist/identity/marketplace/connect-hint.js.map +1 -0
- package/dist/identity/marketplace/connect.d.ts +51 -0
- package/dist/identity/marketplace/connect.d.ts.map +1 -0
- package/dist/identity/marketplace/connect.js +88 -0
- package/dist/identity/marketplace/connect.js.map +1 -0
- package/dist/identity/marketplace/index.d.ts +9 -0
- package/dist/identity/marketplace/index.d.ts.map +1 -0
- package/dist/identity/marketplace/index.js +9 -0
- package/dist/identity/marketplace/index.js.map +1 -0
- package/dist/identity/microsoft/connect-http.d.ts +39 -0
- package/dist/identity/microsoft/connect-http.d.ts.map +1 -0
- package/dist/identity/microsoft/connect-http.js +60 -0
- package/dist/identity/microsoft/connect-http.js.map +1 -0
- package/dist/identity/microsoft/index.d.ts +7 -0
- package/dist/identity/microsoft/index.d.ts.map +1 -0
- package/dist/identity/microsoft/index.js +6 -0
- package/dist/identity/microsoft/index.js.map +1 -0
- package/dist/identity/microsoft/oauth.d.ts +24 -0
- package/dist/identity/microsoft/oauth.d.ts.map +1 -0
- package/dist/identity/microsoft/oauth.js +65 -0
- package/dist/identity/microsoft/oauth.js.map +1 -0
- package/dist/identity/oauth-tickets.d.ts +37 -0
- package/dist/identity/oauth-tickets.d.ts.map +1 -0
- package/dist/identity/oauth-tickets.js +114 -0
- package/dist/identity/oauth-tickets.js.map +1 -0
- package/dist/identity/options.d.ts +95 -0
- package/dist/identity/options.d.ts.map +1 -0
- package/dist/identity/options.js +175 -0
- package/dist/identity/options.js.map +1 -0
- package/dist/identity/slack/connect-http.d.ts +3 -3
- package/dist/identity/slack/connect-http.d.ts.map +1 -1
- package/dist/identity/slack/connect-http.js +23 -15
- package/dist/identity/slack/connect-http.js.map +1 -1
- package/dist/identity/slack/index.d.ts +1 -2
- package/dist/identity/slack/index.d.ts.map +1 -1
- package/dist/identity/slack/index.js +1 -2
- package/dist/identity/slack/index.js.map +1 -1
- package/dist/identity/slack/links.d.ts +15 -15
- package/dist/identity/slack/links.d.ts.map +1 -1
- package/dist/identity/slack/links.js +50 -53
- package/dist/identity/slack/links.js.map +1 -1
- package/dist/identity/slack/oauth.d.ts +2 -5
- package/dist/identity/slack/oauth.d.ts.map +1 -1
- package/dist/identity/slack/oauth.js +8 -63
- package/dist/identity/slack/oauth.js.map +1 -1
- package/dist/identity/supabase.js +9 -9
- package/dist/identity/supabase.js.map +1 -1
- package/dist/identity/types.d.ts +96 -38
- package/dist/identity/types.d.ts.map +1 -1
- package/dist/identity/x/connect-http.d.ts +39 -0
- package/dist/identity/x/connect-http.d.ts.map +1 -0
- package/dist/identity/x/connect-http.js +69 -0
- package/dist/identity/x/connect-http.js.map +1 -0
- package/dist/identity/x/index.d.ts +6 -0
- package/dist/identity/x/index.d.ts.map +1 -0
- package/dist/identity/x/index.js +5 -0
- package/dist/identity/x/index.js.map +1 -0
- package/dist/index.d.ts +14 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -12
- package/dist/index.js.map +1 -1
- package/dist/ingress/index.d.ts +54 -0
- package/dist/ingress/index.d.ts.map +1 -0
- package/dist/ingress/index.js +128 -0
- package/dist/ingress/index.js.map +1 -0
- package/dist/namespaces.d.ts +306 -0
- package/dist/namespaces.d.ts.map +1 -0
- package/dist/namespaces.js +127 -0
- package/dist/namespaces.js.map +1 -0
- package/dist/runtime/auth.d.ts +18 -14
- package/dist/runtime/auth.d.ts.map +1 -1
- package/dist/runtime/auth.js +88 -68
- package/dist/runtime/auth.js.map +1 -1
- package/dist/runtime/backend.d.ts +1 -1
- package/dist/runtime/backend.d.ts.map +1 -1
- package/dist/runtime/connector.d.ts +66 -23
- package/dist/runtime/connector.d.ts.map +1 -1
- package/dist/runtime/connector.js +63 -27
- package/dist/runtime/connector.js.map +1 -1
- package/dist/runtime/cors.d.ts +2 -3
- package/dist/runtime/cors.d.ts.map +1 -1
- package/dist/runtime/cors.js +2 -7
- package/dist/runtime/cors.js.map +1 -1
- package/dist/runtime/credentials.d.ts +2 -2
- package/dist/runtime/credentials.d.ts.map +1 -1
- package/dist/runtime/credentials.js +41 -16
- package/dist/runtime/credentials.js.map +1 -1
- package/dist/runtime/http.d.ts +47 -0
- package/dist/runtime/http.d.ts.map +1 -0
- package/dist/runtime/http.js +54 -0
- package/dist/runtime/http.js.map +1 -0
- package/dist/runtime/identity-http.d.ts +6 -16
- package/dist/runtime/identity-http.d.ts.map +1 -1
- package/dist/runtime/identity-http.js +112 -54
- package/dist/runtime/identity-http.js.map +1 -1
- package/dist/runtime/identity-runtime.d.ts +18 -17
- package/dist/runtime/identity-runtime.d.ts.map +1 -1
- package/dist/runtime/identity-runtime.js +55 -39
- package/dist/runtime/identity-runtime.js.map +1 -1
- package/dist/runtime/index.d.ts +85 -222
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +73 -34
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/memory/index.d.ts +1 -0
- package/dist/runtime/memory/index.d.ts.map +1 -1
- package/dist/runtime/memory/index.js +1 -0
- package/dist/runtime/memory/index.js.map +1 -1
- package/dist/runtime/memory/lazy-context-backend.d.ts +66 -0
- package/dist/runtime/memory/lazy-context-backend.d.ts.map +1 -0
- package/dist/runtime/memory/lazy-context-backend.js +154 -0
- package/dist/runtime/memory/lazy-context-backend.js.map +1 -0
- package/dist/runtime/memory/user-repo.js +3 -3
- package/dist/runtime/memory/user-repo.js.map +1 -1
- package/dist/runtime/recursion-limit.d.ts +22 -0
- package/dist/runtime/recursion-limit.d.ts.map +1 -0
- package/dist/runtime/recursion-limit.js +46 -0
- package/dist/runtime/recursion-limit.js.map +1 -0
- package/dist/runtime/sandbox-manager.d.ts +33 -0
- package/dist/runtime/sandbox-manager.d.ts.map +1 -1
- package/dist/runtime/sandbox-manager.js +173 -9
- package/dist/runtime/sandbox-manager.js.map +1 -1
- package/dist/runtime/sandbox-stream-retry.d.ts +16 -0
- package/dist/runtime/sandbox-stream-retry.d.ts.map +1 -0
- package/dist/runtime/sandbox-stream-retry.js +61 -0
- package/dist/runtime/sandbox-stream-retry.js.map +1 -0
- package/dist/runtime/setup-script.d.ts.map +1 -1
- package/dist/runtime/setup-script.js +4 -2
- package/dist/runtime/setup-script.js.map +1 -1
- package/dist/runtime/validated-token.d.ts +1 -1
- package/dist/runtime/validated-token.d.ts.map +1 -1
- package/dist/runtime/validated-token.js +75 -33
- package/dist/runtime/validated-token.js.map +1 -1
- package/dist/sandbox.d.ts +19 -22
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +20 -34
- package/dist/sandbox.js.map +1 -1
- package/dist/schedules.js +8 -9
- package/dist/schedules.js.map +1 -1
- package/package.json +19 -28
- package/dist/channels/collect.d.ts +0 -26
- package/dist/channels/collect.d.ts.map +0 -1
- package/dist/channels/collect.js +0 -42
- package/dist/channels/collect.js.map +0 -1
- package/dist/channels/github/adapter-core.d.ts +0 -6
- package/dist/channels/github/adapter-core.d.ts.map +0 -1
- package/dist/channels/github/adapter-core.js +0 -27
- package/dist/channels/github/adapter-core.js.map +0 -1
- package/dist/channels/github/adapter.d.ts +0 -16
- package/dist/channels/github/adapter.d.ts.map +0 -1
- package/dist/channels/github/adapter.js +0 -52
- package/dist/channels/github/adapter.js.map +0 -1
- package/dist/channels/github/define.d.ts.map +0 -1
- package/dist/channels/github/define.js +0 -166
- package/dist/channels/github/define.js.map +0 -1
- package/dist/channels/github/http.d.ts.map +0 -1
- package/dist/channels/github/http.js.map +0 -1
- package/dist/channels/github/index.d.ts +0 -12
- package/dist/channels/github/index.d.ts.map +0 -1
- package/dist/channels/github/index.js +0 -10
- package/dist/channels/github/index.js.map +0 -1
- package/dist/channels/github/normalize.d.ts.map +0 -1
- package/dist/channels/github/normalize.js.map +0 -1
- package/dist/channels/github/source-thread.d.ts.map +0 -1
- package/dist/channels/github/source-thread.js.map +0 -1
- package/dist/channels/github/transport.d.ts.map +0 -1
- package/dist/channels/github/transport.js.map +0 -1
- package/dist/channels/plugin.d.ts +0 -61
- package/dist/channels/plugin.d.ts.map +0 -1
- package/dist/channels/plugin.js +0 -80
- package/dist/channels/plugin.js.map +0 -1
- package/dist/channels/slack/adapter-core.d.ts.map +0 -1
- package/dist/channels/slack/adapter-core.js.map +0 -1
- package/dist/channels/slack/adapter.d.ts.map +0 -1
- package/dist/channels/slack/adapter.js.map +0 -1
- package/dist/channels/slack/define.d.ts +0 -74
- package/dist/channels/slack/define.d.ts.map +0 -1
- package/dist/channels/slack/define.js +0 -160
- package/dist/channels/slack/define.js.map +0 -1
- package/dist/channels/slack/http.d.ts.map +0 -1
- package/dist/channels/slack/http.js.map +0 -1
- package/dist/channels/slack/index.d.ts +0 -18
- package/dist/channels/slack/index.d.ts.map +0 -1
- package/dist/channels/slack/index.js +0 -13
- package/dist/channels/slack/index.js.map +0 -1
- package/dist/channels/slack/normalize.d.ts.map +0 -1
- package/dist/channels/slack/normalize.js.map +0 -1
- package/dist/channels/slack/source-thread.d.ts.map +0 -1
- package/dist/channels/slack/source-thread.js.map +0 -1
- package/dist/channels/slack/transport.d.ts.map +0 -1
- package/dist/channels/slack/transport.js.map +0 -1
- /package/dist/{channels → connectors}/github/source-thread.d.ts +0 -0
- /package/dist/{channels → connectors}/github/source-thread.js +0 -0
- /package/dist/{channels → connectors}/slack/adapter-core.js +0 -0
- /package/dist/{channels → connectors}/slack/source-thread.d.ts +0 -0
- /package/dist/{channels → connectors}/slack/source-thread.js +0 -0
|
@@ -1,11 +1,29 @@
|
|
|
1
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
1
2
|
import { hasSandboxConnectors, runConnectorSandboxHooks, } from "./connector.js";
|
|
2
3
|
import { runSetupScript } from "./setup-script.js";
|
|
4
|
+
import { isSandboxStreamError } from "./sandbox-stream-retry.js";
|
|
3
5
|
/**
|
|
4
6
|
* Created sandboxes, keyed by scope, reused for the lifetime of this runtime
|
|
5
7
|
* process. Storing the in-flight promise dedupes concurrent runs and guarantees
|
|
6
8
|
* `setup.sh` is executed only once per newly created sandbox.
|
|
7
9
|
*/
|
|
8
10
|
const managedSandboxes = new Map();
|
|
11
|
+
/**
|
|
12
|
+
* Separator between the deployment name and the identity digest in a managed
|
|
13
|
+
* sandbox name.
|
|
14
|
+
*
|
|
15
|
+
* Doubled so one deployment's prefix can never match another's name:
|
|
16
|
+
* `agent--<digest>` is not matched by the `agent-staging--` prefix. Mirrors the
|
|
17
|
+
* `--u--` / `--t--` convention used for Context Hub child repos, and must stay
|
|
18
|
+
* in sync with `SANDBOX_NAME_SEPARATOR` in the CLI.
|
|
19
|
+
*/
|
|
20
|
+
const SANDBOX_NAME_SEPARATOR = "--";
|
|
21
|
+
/** Hex characters of the identity digest kept in a sandbox name. */
|
|
22
|
+
const SANDBOX_DIGEST_LENGTH = 12;
|
|
23
|
+
/** Sandbox statuses that can be adopted as-is. */
|
|
24
|
+
const ADOPTABLE_STATUS = new Set(["ready", "running"]);
|
|
25
|
+
/** Sandbox status for one that is stopped but restartable. */
|
|
26
|
+
const STOPPED_STATUS = "stopped";
|
|
9
27
|
const defaultLangSmithSandboxClientLoader = async () => {
|
|
10
28
|
const dynamicImport = new Function("specifier", "return import(specifier)");
|
|
11
29
|
return (await dynamicImport("langsmith/sandbox"));
|
|
@@ -30,7 +48,7 @@ export function resolveManagedSandbox(sandbox, setupScript, config, options) {
|
|
|
30
48
|
syncChain: Promise.resolve(),
|
|
31
49
|
freshlyCreated: true,
|
|
32
50
|
ready: Promise.resolve().then(async () => {
|
|
33
|
-
const backend = await createLangSmithSandbox(sandbox, setupScript, config, options, "create");
|
|
51
|
+
const backend = await createLangSmithSandbox(sandbox, setupScript, config, options, "create", key);
|
|
34
52
|
created.syncedThreads.add(threadKey);
|
|
35
53
|
return backend;
|
|
36
54
|
}),
|
|
@@ -100,34 +118,84 @@ export function invalidateManagedSandbox(sandbox, config) {
|
|
|
100
118
|
}
|
|
101
119
|
/** True when a sandbox API error is worth invalidating + recreating once. */
|
|
102
120
|
export function isTransientSandboxError(error) {
|
|
121
|
+
// Never-started stream race is also recreate-safe (and retried in place first
|
|
122
|
+
// by executeWithStreamRetry during provision). Truncated HTTP bodies and
|
|
123
|
+
// peer-closed errors are recreate-only — do not replay in place.
|
|
124
|
+
if (isSandboxStreamError(error)) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
103
127
|
const message = error instanceof Error
|
|
104
128
|
? `${error.name}: ${error.message}`
|
|
105
129
|
: typeof error === "string"
|
|
106
130
|
? error
|
|
107
131
|
: String(error);
|
|
108
|
-
return /LangSmithSandboxError|HTTP 502|Bad Gateway|HTTP 503|HTTP 504|ECONNRESET|ETIMEDOUT|sandbox.*(not found|gone|unavailable|terminated)/i.test(message);
|
|
132
|
+
return /LangSmithSandboxError|HTTP 502|Bad Gateway|HTTP 503|HTTP 504|ECONNRESET|ETIMEDOUT|peer closed connection without sending complete message body|incomplete chunked read|sandbox.*(not found|gone|unavailable|terminated)/i.test(message);
|
|
109
133
|
}
|
|
110
134
|
/** Override the LangSmith SDK loader. Test-only. */
|
|
111
135
|
export function setLangSmithSandboxClientLoaderForTests(loader) {
|
|
112
136
|
langSmithSandboxClientLoader = loader ?? defaultLangSmithSandboxClientLoader;
|
|
113
137
|
}
|
|
114
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Deployment this runtime belongs to, used to name the sandboxes it creates so
|
|
140
|
+
* `mda delete` can find them again.
|
|
141
|
+
*
|
|
142
|
+
* `MDA_DEPLOYMENT_NAME` is injected by `mda deploy`; `LANGSMITH_DEPLOYMENT_NAME`
|
|
143
|
+
* is the platform's own value and is preferred when present. Undefined under
|
|
144
|
+
* local `mda dev`, where sandboxes stay unnamed and LangSmith generates a name.
|
|
145
|
+
*/
|
|
146
|
+
export function managedDeploymentName() {
|
|
147
|
+
return (stringOption(process.env.LANGSMITH_DEPLOYMENT_NAME) ??
|
|
148
|
+
stringOption(process.env.MDA_DEPLOYMENT_NAME));
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Deterministic sandbox name for a deployment, sandbox scope, and provisioning
|
|
152
|
+
* recipe.
|
|
153
|
+
*
|
|
154
|
+
* The inputs are digested rather than embedded because the scope key carries
|
|
155
|
+
* thread and assistant UUIDs; a short digest keeps the name clear of any length
|
|
156
|
+
* limit while staying stable across container restarts, which is what lets a
|
|
157
|
+
* restarted deployment re-adopt its sandbox instead of leaking it.
|
|
158
|
+
*
|
|
159
|
+
* Provisioning is part of the identity so that editing `setup.sh` or switching
|
|
160
|
+
* snapshots produces a different name. An adopted sandbox skips provisioning, so
|
|
161
|
+
* without this a redeploy would silently leave existing threads on the old
|
|
162
|
+
* environment.
|
|
163
|
+
*/
|
|
164
|
+
export function managedSandboxName(deployment, scopeKey, provisioning = {}) {
|
|
165
|
+
const digest = createHash("sha256")
|
|
166
|
+
.update(scopeKey)
|
|
167
|
+
.update("\0")
|
|
168
|
+
.update(provisioningFingerprint(provisioning))
|
|
169
|
+
.digest("hex")
|
|
170
|
+
.slice(0, SANDBOX_DIGEST_LENGTH);
|
|
171
|
+
return `${deployment}${SANDBOX_NAME_SEPARATOR}${digest}`;
|
|
172
|
+
}
|
|
173
|
+
/** Stable string for a provisioning recipe, insensitive to option ordering. */
|
|
174
|
+
function provisioningFingerprint(provisioning) {
|
|
175
|
+
const createOptions = Object.entries(provisioning.createOptions ?? {}).sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0));
|
|
176
|
+
return JSON.stringify([createOptions, provisioning.setupScript ?? ""]);
|
|
177
|
+
}
|
|
178
|
+
async function createLangSmithSandbox(sandbox, setupScript, config, options, mode, scopeKey) {
|
|
115
179
|
if (providerKey(sandbox.provider) !== "LangSmithSandbox") {
|
|
116
180
|
throw new Error("MDA only supports deepagents' LangSmithSandbox provider");
|
|
117
181
|
}
|
|
118
|
-
const backend = await createLangSmithSandboxBackend(sandbox);
|
|
182
|
+
const { backend, adopted } = await createLangSmithSandboxBackend(sandbox, scopeKey, setupScript);
|
|
119
183
|
await runConnectorSandboxHooks(options?.connectors, {
|
|
120
184
|
backend,
|
|
121
|
-
|
|
185
|
+
// An adopted sandbox already ran create-time provisioning in an earlier
|
|
186
|
+
// process, so treat it as a reuse for connector purposes.
|
|
187
|
+
mode: adopted ? "reuse" : mode,
|
|
122
188
|
config,
|
|
123
189
|
identity: options?.identity,
|
|
124
190
|
});
|
|
125
|
-
|
|
191
|
+
// Only a new sandbox needs `setup.sh`: an adopted one ran this exact script
|
|
192
|
+
// already, since a changed script yields a different sandbox name.
|
|
193
|
+
if (!adopted && setupScript && setupScript.trim().length > 0) {
|
|
126
194
|
await runSetupScript(backend, setupScript);
|
|
127
195
|
}
|
|
128
196
|
return backend;
|
|
129
197
|
}
|
|
130
|
-
async function createLangSmithSandboxBackend(sandbox) {
|
|
198
|
+
async function createLangSmithSandboxBackend(sandbox, scopeKey, setupScript) {
|
|
131
199
|
const { scope: _scope, apiKey = process.env.LANGSMITH_API_KEY, defaultTimeout, templateName, snapshotId, ...createSandboxOptions } = sandbox.options ?? {};
|
|
132
200
|
if (snapshotId && templateName) {
|
|
133
201
|
throw new Error("snapshotId and templateName are mutually exclusive. Pass only one creation source.");
|
|
@@ -141,9 +209,105 @@ async function createLangSmithSandboxBackend(sandbox) {
|
|
|
141
209
|
const { SandboxClient } = await langSmithSandboxClientLoader();
|
|
142
210
|
const sdkOptions = stringOption(apiKey);
|
|
143
211
|
const client = new SandboxClient(sdkOptions ? { apiKey: sdkOptions } : undefined);
|
|
144
|
-
const
|
|
212
|
+
const deployment = managedDeploymentName();
|
|
213
|
+
const { sandbox: langSmithSandbox, adopted } = await resolveSandboxInstance(client, createSandboxOptions, deployment
|
|
214
|
+
? managedSandboxName(deployment, scopeKey, {
|
|
215
|
+
createOptions: createSandboxOptions,
|
|
216
|
+
setupScript,
|
|
217
|
+
})
|
|
218
|
+
: undefined);
|
|
145
219
|
const Backend = sandbox.provider;
|
|
146
|
-
return
|
|
220
|
+
return {
|
|
221
|
+
backend: new Backend({ sandbox: langSmithSandbox, defaultTimeout }),
|
|
222
|
+
adopted,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Adopt this deployment's existing sandbox for `name`, or create it.
|
|
227
|
+
*
|
|
228
|
+
* Names are deterministic per scope, so a redeployed or restarted container
|
|
229
|
+
* finds the sandbox its predecessor created instead of stranding it until the
|
|
230
|
+
* idle TTL fires. When `name` is undefined (local dev) this is a plain create.
|
|
231
|
+
*/
|
|
232
|
+
async function resolveSandboxInstance(client, createSandboxOptions, name) {
|
|
233
|
+
if (!name) {
|
|
234
|
+
return {
|
|
235
|
+
sandbox: await client.createSandbox(createSandboxOptions),
|
|
236
|
+
adopted: false,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
const existing = await adoptSandbox(client, name);
|
|
240
|
+
if (existing !== undefined) {
|
|
241
|
+
return { sandbox: existing, adopted: true };
|
|
242
|
+
}
|
|
243
|
+
try {
|
|
244
|
+
return {
|
|
245
|
+
sandbox: await client.createSandbox({ ...createSandboxOptions, name }),
|
|
246
|
+
adopted: false,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
if (!isSandboxNameConflict(error)) {
|
|
251
|
+
throw error;
|
|
252
|
+
}
|
|
253
|
+
// Either a concurrent container won the create race, or an unusable sandbox
|
|
254
|
+
// (failed, mid-delete) still holds the name.
|
|
255
|
+
const winner = await adoptSandbox(client, name);
|
|
256
|
+
if (winner !== undefined) {
|
|
257
|
+
return { sandbox: winner, adopted: true };
|
|
258
|
+
}
|
|
259
|
+
// Keep the deployment prefix so teardown still finds this sandbox.
|
|
260
|
+
return {
|
|
261
|
+
sandbox: await client.createSandbox({
|
|
262
|
+
...createSandboxOptions,
|
|
263
|
+
name: `${name}-${sandboxNameSuffix()}`,
|
|
264
|
+
}),
|
|
265
|
+
adopted: false,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Return the existing sandbox for `name` when it is usable, else undefined.
|
|
271
|
+
*
|
|
272
|
+
* Best-effort by design: this runs on the sandbox hot path, so a lookup failure
|
|
273
|
+
* falls back to creating rather than failing the run.
|
|
274
|
+
*/
|
|
275
|
+
async function adoptSandbox(client, name) {
|
|
276
|
+
if (typeof client.getSandbox !== "function") {
|
|
277
|
+
return undefined;
|
|
278
|
+
}
|
|
279
|
+
let existing;
|
|
280
|
+
try {
|
|
281
|
+
existing = await client.getSandbox(name);
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
if (existing === undefined || existing === null) {
|
|
287
|
+
return undefined;
|
|
288
|
+
}
|
|
289
|
+
const status = stringOption(existing.status)?.toLowerCase();
|
|
290
|
+
// No status reported: assume the SDK handed back a usable sandbox.
|
|
291
|
+
if (status === undefined || ADOPTABLE_STATUS.has(status)) {
|
|
292
|
+
return existing;
|
|
293
|
+
}
|
|
294
|
+
if (status === STOPPED_STATUS && typeof client.startSandbox === "function") {
|
|
295
|
+
try {
|
|
296
|
+
return (await client.startSandbox(name)) ?? existing;
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
return undefined;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return undefined;
|
|
303
|
+
}
|
|
304
|
+
/** True when a create failed because the sandbox name is already taken. */
|
|
305
|
+
function isSandboxNameConflict(error) {
|
|
306
|
+
const message = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
307
|
+
return /409|conflict|already exists|already in use|duplicate/i.test(message);
|
|
308
|
+
}
|
|
309
|
+
function sandboxNameSuffix() {
|
|
310
|
+
return randomBytes(4).toString("hex");
|
|
147
311
|
}
|
|
148
312
|
function threadSyncKey(sandbox, config) {
|
|
149
313
|
const scope = sandbox.options?.scope ?? "thread";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-manager.js","sourceRoot":"","sources":["../../src/runtime/sandbox-manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sandbox-manager.js","sourceRoot":"","sources":["../../src/runtime/sandbox-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAMtD,OAAO,EACL,oBAAoB,EACpB,wBAAwB,GAEzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA+B,CAAC;AAgBhE;;;;;;;;GAQG;AACH,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAEpC,oEAAoE;AACpE,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;AAEvD,8DAA8D;AAC9D,MAAM,cAAc,GAAG,SAAS,CAAC;AAejC,MAAM,mCAAmC,GACvC,KAAK,IAAI,EAAE;IACT,MAAM,aAAa,GAAG,IAAI,QAAQ,CAChC,WAAW,EACX,0BAA0B,CACgB,CAAC;IAC7C,OAAO,CAAC,MAAM,aAAa,CAAC,mBAAmB,CAAC,CAE/C,CAAC;AACJ,CAAC,CAAC;AAEJ,IAAI,4BAA4B,GAAG,mCAAmC,CAAC;AAQvE;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAA0B,EAC1B,WAA+B,EAC/B,MAAoC,EACpC,OAAsC;IAEtC,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7C,MAAM,UAAU,GAAG,oBAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC7D,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC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E,cAAc,CAAC,IAAI,OAAO,CAAC;AACxD,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC;AAED,SAAS,WAAW,CAClB,MAAoC,EACpC,GAAW;IAEX,OAAO,CACL,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;QACrC,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC,CAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry sandbox `execute` when the command stream dies before start.
|
|
3
|
+
*
|
|
4
|
+
* LangSmith sandboxes can return HTTP 201 / accept uploads while the websocket
|
|
5
|
+
* command channel is not ready yet. The first `execute` then fails with
|
|
6
|
+
* `Command stream ended before 'started' message`. Cold GitHub provision and
|
|
7
|
+
* `setup.sh` hit this path immediately after create; retrying the same execute
|
|
8
|
+
* with backoff is cheaper (and more reliable) than throwing away the box.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isSandboxStreamError(error: unknown): boolean;
|
|
11
|
+
export declare function executeWithStreamRetry<T>(execute: (command: string) => Promise<T> | T, command: string, options?: {
|
|
12
|
+
attempts?: number;
|
|
13
|
+
baseDelayMs?: number;
|
|
14
|
+
sleep?: (ms: number) => Promise<void>;
|
|
15
|
+
}): Promise<T>;
|
|
16
|
+
//# sourceMappingURL=sandbox-stream-retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-stream-retry.d.ts","sourceRoot":"","sources":["../../src/runtime/sandbox-stream-retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAiBH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAoB5D;AAED,wBAAsB,sBAAsB,CAAC,CAAC,EAC5C,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAC5C,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IACP,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC,GACL,OAAO,CAAC,CAAC,CAAC,CAuBZ"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry sandbox `execute` when the command stream dies before start.
|
|
3
|
+
*
|
|
4
|
+
* LangSmith sandboxes can return HTTP 201 / accept uploads while the websocket
|
|
5
|
+
* command channel is not ready yet. The first `execute` then fails with
|
|
6
|
+
* `Command stream ended before 'started' message`. Cold GitHub provision and
|
|
7
|
+
* `setup.sh` hit this path immediately after create; retrying the same execute
|
|
8
|
+
* with backoff is cheaper (and more reliable) than throwing away the box.
|
|
9
|
+
*/
|
|
10
|
+
const STREAM_EXECUTE_ATTEMPTS = 6;
|
|
11
|
+
// Cold boxes often need several seconds after HTTP 201 before the websocket
|
|
12
|
+
// command channel is ready — a 1s base burned through attempts too quickly.
|
|
13
|
+
const STREAM_EXECUTE_BASE_DELAY_MS = 2_000;
|
|
14
|
+
// Only the "never started" race is safe to retry in place. Broader transport
|
|
15
|
+
// errors (bare SandboxOperationError, truncated HTTP bodies) can arrive after
|
|
16
|
+
// the command began or finished — those belong on the invalidate/recreate path.
|
|
17
|
+
const STREAM_NEVER_STARTED_RE = /Command stream ended before ['"]started['"] message/i;
|
|
18
|
+
const STREAM_NEVER_STARTED_NAMES = new Set([
|
|
19
|
+
"_StreamEndedBeforeStarted",
|
|
20
|
+
"StreamEndedBeforeStarted",
|
|
21
|
+
]);
|
|
22
|
+
export function isSandboxStreamError(error) {
|
|
23
|
+
if (error instanceof Error && STREAM_NEVER_STARTED_NAMES.has(error.name)) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
if (error !== null &&
|
|
27
|
+
typeof error === "object" &&
|
|
28
|
+
STREAM_NEVER_STARTED_NAMES.has(error.constructor?.name ?? "")) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
const message = error instanceof Error
|
|
32
|
+
? `${error.name}: ${error.message}`
|
|
33
|
+
: typeof error === "string"
|
|
34
|
+
? error
|
|
35
|
+
: String(error);
|
|
36
|
+
return STREAM_NEVER_STARTED_RE.test(message);
|
|
37
|
+
}
|
|
38
|
+
export async function executeWithStreamRetry(execute, command, options = {}) {
|
|
39
|
+
const attempts = options.attempts ?? STREAM_EXECUTE_ATTEMPTS;
|
|
40
|
+
const baseDelayMs = options.baseDelayMs ?? STREAM_EXECUTE_BASE_DELAY_MS;
|
|
41
|
+
const sleep = options.sleep ??
|
|
42
|
+
((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
43
|
+
if (attempts < 1) {
|
|
44
|
+
throw new Error("attempts must be >= 1");
|
|
45
|
+
}
|
|
46
|
+
let lastError;
|
|
47
|
+
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
48
|
+
try {
|
|
49
|
+
return await execute(command);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
lastError = error;
|
|
53
|
+
if (!isSandboxStreamError(error) || attempt >= attempts - 1) {
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
await sleep(baseDelayMs * 2 ** attempt);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
throw lastError;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=sandbox-stream-retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-stream-retry.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B,CAAC;IACxE,MAAM,KAAK,GACT,OAAO,CAAC,KAAK;QACb,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5E,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,SAAkB,CAAC;IACvB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC;QACpD,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,SAAS,GAAG,KAAK,CAAC;YAClB,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,IAAI,OAAO,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;gBAC5D,MAAM,KAAK,CAAC;YACd,CAAC;YACD,MAAM,KAAK,CAAC,WAAW,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IACD,MAAM,SAAS,CAAC;AAClB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-script.d.ts","sourceRoot":"","sources":["../../src/runtime/setup-script.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"setup-script.d.ts","sourceRoot":"","sources":["../../src/runtime/setup-script.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAO5E;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,wBAAwB,EACjC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAef;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,wBAAwB,EACjC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAIf;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,QAAQ,CAAC,GACnD,IAAI,CAON"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { executeWithStreamRetry } from "./sandbox-stream-retry.js";
|
|
1
2
|
/** Absolute path the provisioning script is uploaded to inside the sandbox. */
|
|
2
3
|
const SETUP_REMOTE_PATH = "/tmp/mda-setup.sh";
|
|
3
4
|
/**
|
|
@@ -12,7 +13,8 @@ export async function runSetupScript(backend, script) {
|
|
|
12
13
|
await backend.uploadFiles([
|
|
13
14
|
[SETUP_REMOTE_PATH, new TextEncoder().encode(script)],
|
|
14
15
|
]);
|
|
15
|
-
|
|
16
|
+
// Fresh sandboxes often reject the first websocket execute; retry in place.
|
|
17
|
+
assertSetupSucceeded(await executeWithStreamRetry((command) => backend.execute(command), `bash ${SETUP_REMOTE_PATH}`));
|
|
16
18
|
return;
|
|
17
19
|
}
|
|
18
20
|
await runSetupScriptInline(backend, script);
|
|
@@ -24,7 +26,7 @@ export async function runSetupScript(backend, script) {
|
|
|
24
26
|
* conform to the execute surface but do not expose upload support.
|
|
25
27
|
*/
|
|
26
28
|
export async function runSetupScriptInline(backend, script) {
|
|
27
|
-
assertSetupSucceeded(await backend.execute(script));
|
|
29
|
+
assertSetupSucceeded(await executeWithStreamRetry((command) => backend.execute(command), script));
|
|
28
30
|
}
|
|
29
31
|
export function assertSetupSucceeded(result) {
|
|
30
32
|
if (typeof result.exitCode === "number" && result.exitCode !== 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-script.js","sourceRoot":"","sources":["../../src/runtime/setup-script.ts"],"names":[],"mappings":"AAEA,+EAA+E;AAC/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,CAAC,EAAE,MAAM,CAAC,CAC5E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,MAAoD;IAEpD,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;QACjE,MAAM,MAAM,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CACb,0CAA0C,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAC1F,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type JWTPayload } from "jose";
|
|
2
|
-
import type
|
|
2
|
+
import { type IdentityConfig, type ValidatedTokenIngress, type ValidatedTokenProvider } from "../identity/index.js";
|
|
3
3
|
import type { ManagedUser } from "./auth.js";
|
|
4
4
|
/**
|
|
5
5
|
* Resolve the caller identity for the `validated_token` ingress mode: pick
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validated-token.d.ts","sourceRoot":"","sources":["../../src/runtime/validated-token.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,UAAU,EAGhB,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"validated-token.d.ts","sourceRoot":"","sources":["../../src/runtime/validated-token.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,UAAU,EAGhB,MAAM,MAAM,CAAC;AAEd,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAqB7C;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,cAAc,EACnB,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,WAAW,CAAC,CAWtB;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,sBAAsB,EAAE,EACnC,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,sBAAsB,CAAC,CAiBjC;AA4ED,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAQpD;AAkED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,sBAAsB,EAAE,EACnC,KAAK,EAAE,MAAM,GACZ,sBAAsB,CAoBxB;AAED,uFAAuF;AACvF,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,sBAAsB,EAChC,MAAM,EAAE,UAAU,GACjB,WAAW,CAuCb;AA8KD;;;GAGG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,sBAAsB,EAChC,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CAejB;AAYD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAU/C"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { HTTPException } from "@langchain/langgraph-sdk/auth";
|
|
2
2
|
import { createRemoteJWKSet, decodeJwt, jwtVerify, SignJWT, } from "jose";
|
|
3
|
+
import { normalizeGroups, organizationClaimName, userClaimName, } from "../identity/index.js";
|
|
4
|
+
import { AUTH_HTTP_TIMEOUT_MS, fetchWithTimeout, JWKS_HTTP_TIMEOUT_MS, } from "./http.js";
|
|
3
5
|
/** Issuer stamped on MDA-minted guest tokens, used to route them at selection. */
|
|
4
6
|
const GUEST_ISSUER = "mda:guest";
|
|
5
7
|
/** Deployment env var carrying the HS256 key MDA signs/verifies guest tokens with. */
|
|
@@ -24,7 +26,7 @@ export async function resolveValidatedTokenUser(cfg, ingress, request) {
|
|
|
24
26
|
const provider = await resolveProvider(ingress.providers, token);
|
|
25
27
|
const claims = await verifyProviderClaims(provider, token, request.headers);
|
|
26
28
|
const user = claimsToUser(provider, claims);
|
|
27
|
-
if (cfg.
|
|
29
|
+
if (cfg.organizations === "required" && !user.mda_organization_id) {
|
|
28
30
|
throw new HTTPException(401, {
|
|
29
31
|
message: "missing tenant for multi-tenant deployment",
|
|
30
32
|
});
|
|
@@ -78,13 +80,7 @@ async function discoverOidc(authBase) {
|
|
|
78
80
|
if (cachedIssuer && cachedJwks) {
|
|
79
81
|
return { issuer: cachedIssuer, jwks: cachedJwks };
|
|
80
82
|
}
|
|
81
|
-
const
|
|
82
|
-
if (!response.ok) {
|
|
83
|
-
throw new HTTPException(401, {
|
|
84
|
-
message: "failed to resolve OIDC configuration",
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
const config = (await response.json());
|
|
83
|
+
const config = await fetchOidcConfiguration(base);
|
|
88
84
|
if (!config.issuer) {
|
|
89
85
|
throw new HTTPException(401, {
|
|
90
86
|
message: "OIDC configuration has no issuer",
|
|
@@ -100,6 +96,30 @@ async function discoverOidc(authBase) {
|
|
|
100
96
|
discoverCache.set(config.issuer, config.jwks_uri);
|
|
101
97
|
return { issuer: config.issuer, jwks: config.jwks_uri };
|
|
102
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* `GET {base}/.well-known/openid-configuration`, bounded by
|
|
101
|
+
* {@link AUTH_HTTP_TIMEOUT_MS}. A hung, unreachable, or malformed IdP is an
|
|
102
|
+
* auth failure (401), never an unhandled 500 or an unbounded wait.
|
|
103
|
+
*/
|
|
104
|
+
async function fetchOidcConfiguration(base) {
|
|
105
|
+
try {
|
|
106
|
+
const response = await fetchWithTimeout(`${base}/.well-known/openid-configuration`, undefined, AUTH_HTTP_TIMEOUT_MS);
|
|
107
|
+
if (!response.ok) {
|
|
108
|
+
throw new HTTPException(401, {
|
|
109
|
+
message: "failed to resolve OIDC configuration",
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return (await response.json());
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (error instanceof HTTPException) {
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
throw new HTTPException(401, {
|
|
119
|
+
message: "failed to resolve OIDC configuration",
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
103
123
|
/** Extract the bearer token from the `Authorization` header, or 401. */
|
|
104
124
|
export function bearerToken(request) {
|
|
105
125
|
const header = request.headers.get("authorization") ?? "";
|
|
@@ -193,29 +213,42 @@ export function selectProvider(providers, token) {
|
|
|
193
213
|
}
|
|
194
214
|
/** Map verified token claims into the managed user envelope, per `provider.claims`. */
|
|
195
215
|
export function claimsToUser(provider, claims) {
|
|
196
|
-
const
|
|
197
|
-
if (
|
|
216
|
+
const userClaim = userClaimName(provider.claims);
|
|
217
|
+
if (!userClaim) {
|
|
218
|
+
throw new HTTPException(500, {
|
|
219
|
+
message: "validated_token provider maps no user claim",
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
const caller = claims[userClaim];
|
|
223
|
+
if (caller == null || caller === "") {
|
|
198
224
|
throw new HTTPException(401, {
|
|
199
|
-
message: `token missing
|
|
225
|
+
message: `token missing user claim "${userClaim}"`,
|
|
200
226
|
});
|
|
201
227
|
}
|
|
202
228
|
const user = {
|
|
203
|
-
identity: String(
|
|
229
|
+
identity: String(caller),
|
|
204
230
|
permissions: [],
|
|
205
|
-
|
|
231
|
+
mda_user_id: String(caller),
|
|
206
232
|
mda_claims: { ...claims },
|
|
207
233
|
};
|
|
208
|
-
const
|
|
209
|
-
|
|
234
|
+
const organizationClaim = organizationClaimName(provider.claims);
|
|
235
|
+
const organization = organizationClaim
|
|
236
|
+
? claims[organizationClaim]
|
|
210
237
|
: undefined;
|
|
211
|
-
if (
|
|
212
|
-
user.
|
|
238
|
+
if (organization != null && organization !== "") {
|
|
239
|
+
user.mda_organization_id = String(organization);
|
|
240
|
+
}
|
|
241
|
+
const groups = provider.claims.groups
|
|
242
|
+
? normalizeGroups(claims[provider.claims.groups])
|
|
243
|
+
: [];
|
|
244
|
+
if (groups.length > 0) {
|
|
245
|
+
user.mda_groups = groups;
|
|
213
246
|
}
|
|
214
247
|
const email = provider.claims.email
|
|
215
248
|
? claims[provider.claims.email]
|
|
216
249
|
: undefined;
|
|
217
250
|
if (email) {
|
|
218
|
-
user.
|
|
251
|
+
user.mda_user_email = String(email);
|
|
219
252
|
}
|
|
220
253
|
return user;
|
|
221
254
|
}
|
|
@@ -243,7 +276,7 @@ async function jwksVerifyClaims(provider, token) {
|
|
|
243
276
|
if (/no applicable key|JWKS|key set|kid/i.test(detail)) {
|
|
244
277
|
throw new HTTPException(401, {
|
|
245
278
|
message: "token JWKS verification failed (empty key set or unknown kid); " +
|
|
246
|
-
"legacy HS256 Supabase projects need
|
|
279
|
+
"legacy HS256 Supabase projects need auth.supabase(..., introspect: true)",
|
|
247
280
|
});
|
|
248
281
|
}
|
|
249
282
|
throw new HTTPException(401, {
|
|
@@ -255,7 +288,9 @@ async function providerKeySet(provider) {
|
|
|
255
288
|
const uri = await resolveJwksUri(provider);
|
|
256
289
|
let keySet = jwksCache.get(uri);
|
|
257
290
|
if (!keySet) {
|
|
258
|
-
keySet = createRemoteJWKSet(new URL(uri)
|
|
291
|
+
keySet = createRemoteJWKSet(new URL(uri), {
|
|
292
|
+
timeoutDuration: JWKS_HTTP_TIMEOUT_MS,
|
|
293
|
+
});
|
|
259
294
|
jwksCache.set(uri, keySet);
|
|
260
295
|
}
|
|
261
296
|
return keySet;
|
|
@@ -270,13 +305,7 @@ async function resolveJwksUri(provider) {
|
|
|
270
305
|
return cached;
|
|
271
306
|
}
|
|
272
307
|
const base = provider.issuer.replace(/\/$/, "");
|
|
273
|
-
const
|
|
274
|
-
if (!response.ok) {
|
|
275
|
-
throw new HTTPException(401, {
|
|
276
|
-
message: "failed to resolve OIDC configuration",
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
const config = (await response.json());
|
|
308
|
+
const config = await fetchOidcConfiguration(base);
|
|
280
309
|
if (!config.jwks_uri) {
|
|
281
310
|
throw new HTTPException(401, {
|
|
282
311
|
message: "OIDC configuration has no jwks_uri",
|
|
@@ -309,13 +338,26 @@ async function introspectClaims(provider, token, headers) {
|
|
|
309
338
|
}
|
|
310
339
|
// Expand `${ENV}` in the endpoint so region URLs can stay deployment-driven
|
|
311
340
|
// (e.g. `${SUPABASE_EU_URL}/auth/v1/user`) rather than baked in at authoring.
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
341
|
+
let body;
|
|
342
|
+
try {
|
|
343
|
+
const response = await fetchWithTimeout(expandEnv(target.url), { headers: requestHeaders }, AUTH_HTTP_TIMEOUT_MS);
|
|
344
|
+
if (!response.ok) {
|
|
345
|
+
throw new HTTPException(401, { message: "token introspection failed" });
|
|
346
|
+
}
|
|
347
|
+
// Read the body inside the same mapping: the deadline covers body
|
|
348
|
+
// consumption, so an endpoint that sends 200 headers and then stalls its
|
|
349
|
+
// body fails here rather than at the fetch.
|
|
350
|
+
body = await response.text();
|
|
351
|
+
}
|
|
352
|
+
catch (error) {
|
|
353
|
+
// A hung or unreachable introspection endpoint must fail closed rather than
|
|
354
|
+
// hold the request slot until the platform gateway gives up.
|
|
355
|
+
if (error instanceof HTTPException) {
|
|
356
|
+
throw error;
|
|
357
|
+
}
|
|
316
358
|
throw new HTTPException(401, { message: "token introspection failed" });
|
|
317
359
|
}
|
|
318
|
-
return
|
|
360
|
+
return JSON.parse(body);
|
|
319
361
|
}
|
|
320
362
|
/**
|
|
321
363
|
* Resolve the introspection endpoint (and any region-specific headers) for the
|
|
@@ -367,7 +409,7 @@ export async function issueGuestToken(provider, subject) {
|
|
|
367
409
|
message: "provider does not allow guest issuance",
|
|
368
410
|
});
|
|
369
411
|
}
|
|
370
|
-
const sub = `${guest.
|
|
412
|
+
const sub = `${guest.userPrefix ?? ""}${subject ?? crypto.randomUUID()}`;
|
|
371
413
|
return new SignJWT({})
|
|
372
414
|
.setProtectedHeader({ alg: "HS256" })
|
|
373
415
|
.setIssuer(GUEST_ISSUER)
|