@orgsdk/cli 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +122 -0
- package/README.md +81 -2
- package/bin/configuration.mjs +60 -0
- package/bin/options.mjs +122 -0
- package/bin/orgsdk.mjs +97 -0
- package/bin/supervision.mjs +157 -0
- package/dist/THIRD_PARTY_NOTICES.txt +278 -0
- package/dist/runtime/LICENSE +122 -0
- package/dist/runtime/PROVENANCE.md +15 -0
- package/dist/runtime/README.md +114 -0
- package/dist/runtime/cli-options.js +41 -0
- package/dist/runtime/cli.js +80 -0
- package/dist/runtime/client.js +116 -0
- package/dist/runtime/contract.js +102 -0
- package/dist/runtime/embedded-plugin-loader.mjs +56 -0
- package/dist/runtime/engine/plugins/namespace.js +157 -0
- package/dist/runtime/engine/plugins/types.js +0 -0
- package/dist/runtime/engine/retry.js +67 -0
- package/dist/runtime/engine/sandbox/context.js +115 -0
- package/dist/runtime/engine/sandbox/cpu-budget.js +16 -0
- package/dist/runtime/engine/sandbox/executor.js +196 -0
- package/dist/runtime/engine/sandbox/function-proxy.js +177 -0
- package/dist/runtime/engine/sandbox/index.js +6 -0
- package/dist/runtime/engine/sandbox/secret-refs.js +116 -0
- package/dist/runtime/engine/sandbox/trace.js +65 -0
- package/dist/runtime/engine/sandbox/transpile.js +51 -0
- package/dist/runtime/engine/sandbox/types.js +0 -0
- package/dist/runtime/engine/sandbox/validate.js +63 -0
- package/dist/runtime/engine/sandbox/webhook-handler.js +69 -0
- package/dist/runtime/engine/shared.js +14 -0
- package/dist/runtime/executor-configuration.js +44 -0
- package/dist/runtime/isolated-actions.js +188 -0
- package/dist/runtime/isolated-worker.js +232 -0
- package/dist/runtime/mcp/aliases.js +29 -0
- package/dist/runtime/mcp/client.js +239 -0
- package/dist/runtime/mcp/contract.js +57 -0
- package/dist/runtime/mcp/functions.js +40 -0
- package/dist/runtime/mcp/network.js +61 -0
- package/dist/runtime/mcp/schema-types.js +35 -0
- package/dist/runtime/mcp/transport.js +18 -0
- package/dist/runtime/package-dependencies.js +144 -0
- package/dist/runtime/package-plugin.js +151 -0
- package/dist/runtime/plugin-module.js +22 -0
- package/dist/runtime/plugin-store.js +159 -0
- package/dist/runtime/plugins.js +124 -0
- package/dist/runtime/process-runtime.js +72 -0
- package/dist/runtime/project-data.js +97 -0
- package/dist/runtime/project-files.js +259 -0
- package/dist/runtime/register-executor.js +23 -0
- package/dist/runtime/runner.js +239 -0
- package/dist/runtime/sdk-declarations.js +204 -0
- package/dist/runtime/session-job-contract.js +29 -0
- package/dist/runtime/session-job.js +256 -0
- package/dist/runtime/session-plugin-call.js +33 -0
- package/dist/runtime/sessions/cell-request.js +79 -0
- package/dist/runtime/sessions/compiler/analysis.js +86 -0
- package/dist/runtime/sessions/compiler/binding-pattern.js +35 -0
- package/dist/runtime/sessions/compiler/bindings.js +60 -0
- package/dist/runtime/sessions/compiler/emit.js +111 -0
- package/dist/runtime/sessions/compiler/references.js +62 -0
- package/dist/runtime/sessions/compiler/source-policy.js +62 -0
- package/dist/runtime/sessions/compiler.js +34 -0
- package/dist/runtime/sessions/configuration.js +68 -0
- package/dist/runtime/sessions/events.js +72 -0
- package/dist/runtime/sessions/execute-cell.js +80 -0
- package/dist/runtime/sessions/function-broker.js +78 -0
- package/dist/runtime/sessions/index.js +9 -0
- package/dist/runtime/sessions/journal.js +86 -0
- package/dist/runtime/sessions/kernel.js +142 -0
- package/dist/runtime/sessions/manager.js +155 -0
- package/dist/runtime/sessions/process.js +209 -0
- package/dist/runtime/sessions/records.js +61 -0
- package/dist/runtime/sessions/redaction.js +33 -0
- package/dist/runtime/sessions/scope.js +46 -0
- package/dist/runtime/sessions/session-runtime.js +155 -0
- package/dist/runtime/sessions/types.js +12 -0
- package/dist/runtime/sessions/values.js +40 -0
- package/dist/runtime/sessions/worker-guard.js +20 -0
- package/dist/runtime/sessions/worker.js +81 -0
- package/dist/runtime/spawn-job.js +69 -0
- package/dist/runtime/supervisor.js +224 -0
- package/dist/runtime/validate-code.js +114 -0
- package/dist/runtime/worker.js +57 -0
- package/dist/server/bun-driver-DTZUUCI3.js +20 -0
- package/dist/server/chunk-S5SFX3JM.js +709 -0
- package/dist/server/index.js +9830 -0
- package/dist/server/migrations/0000_initial.sql +436 -0
- package/dist/server/migrations/0001_queue_indexes.sql +3 -0
- package/dist/server/migrations/0002_trpc_transport.sql +1 -0
- package/dist/server/migrations/0003_remote-mcp.sql +17 -0
- package/dist/server/migrations/meta/0000_snapshot.json +3233 -0
- package/dist/server/migrations/meta/0001_snapshot.json +3260 -0
- package/dist/server/migrations/meta/0002_snapshot.json +3262 -0
- package/dist/server/migrations/meta/0003_snapshot.json +3395 -0
- package/dist/server/migrations/meta/_journal.json +34 -0
- package/dist/server/node-driver-HDJKKWXQ.js +25 -0
- package/dist/server/out/192.png +0 -0
- package/dist/server/out/404/index.html +1 -0
- package/dist/server/out/404.html +1 -0
- package/dist/server/out/512.png +0 -0
- package/dist/server/out/LICENSE.txt +122 -0
- package/dist/server/out/__next.!KHdvcmtzcGFjZSk.__PAGE__.txt +35 -0
- package/dist/server/out/__next._full.txt +29 -0
- package/dist/server/out/__next._tree.txt +4 -0
- package/dist/server/out/_next/static/-qfuCDzkIvBZY_UFsMHnB/_buildManifest.js +11 -0
- package/dist/server/out/_next/static/-qfuCDzkIvBZY_UFsMHnB/_clientMiddlewareManifest.js +1 -0
- package/dist/server/out/_next/static/-qfuCDzkIvBZY_UFsMHnB/_ssgManifest.js +1 -0
- package/dist/server/out/_next/static/chunks/0ay0b1lpy734z.js +1 -0
- package/dist/server/out/_next/static/chunks/0c-3k17txbh0-.js +1 -0
- package/dist/server/out/_next/static/chunks/0cwfl2xanfapu.js +1 -0
- package/dist/server/out/_next/static/chunks/0cz1d0mv5g_q7.js +1 -0
- package/dist/server/out/_next/static/chunks/0e7s8ie0wlk66.js +1 -0
- package/dist/server/out/_next/static/chunks/0ey-6hb0za4r_.js +1 -0
- package/dist/server/out/_next/static/chunks/0huhp5j8dlai8.js +1 -0
- package/dist/server/out/_next/static/chunks/0khjy8qh1ll42.js +1 -0
- package/dist/server/out/_next/static/chunks/0r0572w1rwpcv.js +1 -0
- package/dist/server/out/_next/static/chunks/0rlc9tihf4po6.css +1 -0
- package/dist/server/out/_next/static/chunks/0u_9k8f7709np.js +1 -0
- package/dist/server/out/_next/static/chunks/0w34iczo7r1v5.js +1 -0
- package/dist/server/out/_next/static/chunks/0y5lgqdwpeabb.js +402 -0
- package/dist/server/out/_next/static/chunks/0zfiikazg0_ga.js +1 -0
- package/dist/server/out/_next/static/chunks/1-75euysc3lin.js +22 -0
- package/dist/server/out/_next/static/chunks/10aam78qxauw0.js +1 -0
- package/dist/server/out/_next/static/chunks/12ro_nqb83zku.js +1 -0
- package/dist/server/out/_next/static/chunks/19ue6x5c3f_38.js +3 -0
- package/dist/server/out/_next/static/chunks/1c1ayx3fqtub5.js +31 -0
- package/dist/server/out/_next/static/chunks/1c2xcwifk3vhh.js +1 -0
- package/dist/server/out/_next/static/chunks/1dwr62uuyceq-.js +1 -0
- package/dist/server/out/_next/static/chunks/1fweh1ttncdlv.js +1 -0
- package/dist/server/out/_next/static/chunks/1iklteprcoims.js +1 -0
- package/dist/server/out/_next/static/chunks/1qaow7bdy3oid.js +1 -0
- package/dist/server/out/_next/static/chunks/1tnzhqkfwk7l8.js +1 -0
- package/dist/server/out/_next/static/chunks/1wn9ohqcnx8y8.js +3 -0
- package/dist/server/out/_next/static/chunks/1zieh-zxgxmcp.js +1 -0
- package/dist/server/out/_next/static/chunks/25qsan0t-_of0.js +1 -0
- package/dist/server/out/_next/static/chunks/26yareaaj1kyr.js +1 -0
- package/dist/server/out/_next/static/chunks/2bbfbmv0vf3j0.js +1 -0
- package/dist/server/out/_next/static/chunks/2bkkmnhngpacd.js +1 -0
- package/dist/server/out/_next/static/chunks/2e39uy7huhczu.js +1 -0
- package/dist/server/out/_next/static/chunks/2lxgam-nk-e9a.js +3 -0
- package/dist/server/out/_next/static/chunks/2navy2mx7--vk.js +55 -0
- package/dist/server/out/_next/static/chunks/2ngzwwqeitkk7.js +1 -0
- package/dist/server/out/_next/static/chunks/2rp65hq6bmpxv.js +1 -0
- package/dist/server/out/_next/static/chunks/2z60o39-yshg2.js +1 -0
- package/dist/server/out/_next/static/chunks/3_d6w25_b15kx.js +1 -0
- package/dist/server/out/_next/static/chunks/3d8gkwu9nszjk.js +1 -0
- package/dist/server/out/_next/static/chunks/3l-16g1y6k5rs.js +1 -0
- package/dist/server/out/_next/static/chunks/3obu_9-ka7u_h.js +1 -0
- package/dist/server/out/_next/static/chunks/3u7q5w03st-rs.js +1 -0
- package/dist/server/out/_next/static/chunks/3xs2ji0dgkbmc.js +1 -0
- package/dist/server/out/_next/static/chunks/turbopack-2u1d16houkiyo.js +1 -0
- package/dist/server/out/_not-found/__next._full.txt +21 -0
- package/dist/server/out/_not-found/__next._not-found.__PAGE__.txt +27 -0
- package/dist/server/out/_not-found/__next._tree.txt +4 -0
- package/dist/server/out/_not-found/index.html +1 -0
- package/dist/server/out/_not-found/index.txt +21 -0
- package/dist/server/out/accounts/2fa/__next._full.txt +26 -0
- package/dist/server/out/accounts/2fa/__next._tree.txt +5 -0
- package/dist/server/out/accounts/2fa/__next.accounts.2fa.__PAGE__.txt +33 -0
- package/dist/server/out/accounts/2fa/index.html +1 -0
- package/dist/server/out/accounts/2fa/index.txt +26 -0
- package/dist/server/out/accounts/email/__next._full.txt +26 -0
- package/dist/server/out/accounts/email/__next._tree.txt +5 -0
- package/dist/server/out/accounts/email/__next.accounts.email.__PAGE__.txt +33 -0
- package/dist/server/out/accounts/email/index.html +1 -0
- package/dist/server/out/accounts/email/index.txt +26 -0
- package/dist/server/out/accounts/login/__next._full.txt +26 -0
- package/dist/server/out/accounts/login/__next._tree.txt +5 -0
- package/dist/server/out/accounts/login/__next.accounts.login.__PAGE__.txt +33 -0
- package/dist/server/out/accounts/login/index.html +1 -0
- package/dist/server/out/accounts/login/index.txt +26 -0
- package/dist/server/out/accounts/logout/__next._full.txt +26 -0
- package/dist/server/out/accounts/logout/__next._tree.txt +5 -0
- package/dist/server/out/accounts/logout/__next.accounts.logout.__PAGE__.txt +33 -0
- package/dist/server/out/accounts/logout/index.html +1 -0
- package/dist/server/out/accounts/logout/index.txt +26 -0
- package/dist/server/out/accounts/password/change/__next._full.txt +27 -0
- package/dist/server/out/accounts/password/change/__next._tree.txt +6 -0
- package/dist/server/out/accounts/password/change/__next.accounts.password.change.__PAGE__.txt +35 -0
- package/dist/server/out/accounts/password/change/index.html +1 -0
- package/dist/server/out/accounts/password/change/index.txt +27 -0
- package/dist/server/out/accounts/password/reset/__next._full.txt +25 -0
- package/dist/server/out/accounts/password/reset/__next._tree.txt +6 -0
- package/dist/server/out/accounts/password/reset/__next.accounts.password.reset.__PAGE__.txt +33 -0
- package/dist/server/out/accounts/password/reset/index.html +1 -0
- package/dist/server/out/accounts/password/reset/index.txt +25 -0
- package/dist/server/out/accounts/signup/__next._full.txt +26 -0
- package/dist/server/out/accounts/signup/__next._tree.txt +5 -0
- package/dist/server/out/accounts/signup/__next.accounts.signup.__PAGE__.txt +33 -0
- package/dist/server/out/accounts/signup/index.html +1 -0
- package/dist/server/out/accounts/signup/index.txt +26 -0
- package/dist/server/out/actions/__next.!KHdvcmtzcGFjZSk.actions.__PAGE__.txt +44 -0
- package/dist/server/out/actions/__next._full.txt +37 -0
- package/dist/server/out/actions/__next._tree.txt +5 -0
- package/dist/server/out/actions/index.html +1 -0
- package/dist/server/out/actions/index.txt +37 -0
- package/dist/server/out/agents/__next.!KHdvcmtzcGFjZSk.agents.__PAGE__.txt +39 -0
- package/dist/server/out/agents/__next._full.txt +32 -0
- package/dist/server/out/agents/__next._tree.txt +5 -0
- package/dist/server/out/agents/index.html +1 -0
- package/dist/server/out/agents/index.txt +32 -0
- package/dist/server/out/app-icon.svg +7 -0
- package/dist/server/out/apple-touch-icon.png +0 -0
- package/dist/server/out/approvals/__next.!KHdvcmtzcGFjZSk.approvals.__PAGE__.txt +39 -0
- package/dist/server/out/approvals/__next._full.txt +32 -0
- package/dist/server/out/approvals/__next._tree.txt +5 -0
- package/dist/server/out/approvals/index.html +1 -0
- package/dist/server/out/approvals/index.txt +32 -0
- package/dist/server/out/artifacts/__next.!KHdvcmtzcGFjZSk.artifacts.__PAGE__.txt +41 -0
- package/dist/server/out/artifacts/__next._full.txt +34 -0
- package/dist/server/out/artifacts/__next._tree.txt +5 -0
- package/dist/server/out/artifacts/index.html +1 -0
- package/dist/server/out/artifacts/index.txt +34 -0
- package/dist/server/out/audit/__next.!KHdvcmtzcGFjZSk.audit.__PAGE__.txt +36 -0
- package/dist/server/out/audit/__next._full.txt +29 -0
- package/dist/server/out/audit/__next._tree.txt +5 -0
- package/dist/server/out/audit/index.html +1 -0
- package/dist/server/out/audit/index.txt +29 -0
- package/dist/server/out/brand/logo/README.md +92 -0
- package/dist/server/out/brand/logo/app-icon.svg +7 -0
- package/dist/server/out/brand/logo/favicon.svg +8 -0
- package/dist/server/out/brand/logo/fonts/Inter-Bold.ttf +0 -0
- package/dist/server/out/brand/logo/fonts/Inter-Regular.ttf +0 -0
- package/dist/server/out/brand/logo/lockup-dark.svg +11 -0
- package/dist/server/out/brand/logo/lockup-integrated.svg +14 -0
- package/dist/server/out/brand/logo/lockup-light.svg +11 -0
- package/dist/server/out/brand/logo/og-image.svg +20 -0
- package/dist/server/out/brand/logo/primary-solid.svg +6 -0
- package/dist/server/out/brand/logo/primary.svg +7 -0
- package/dist/server/out/brand/logo/raster/banner-1500x500.png +0 -0
- package/dist/server/out/brand/logo/raster/profile-1024.png +0 -0
- package/dist/server/out/brand/logo/raster/profile-512.png +0 -0
- package/dist/server/out/brand/logo/raster/square-1080.png +0 -0
- package/dist/server/out/brand/tokens.md +74 -0
- package/dist/server/out/chat/__next.!KHdvcmtzcGFjZSk.chat.__PAGE__.txt +35 -0
- package/dist/server/out/chat/__next._full.txt +28 -0
- package/dist/server/out/chat/__next._tree.txt +5 -0
- package/dist/server/out/chat/index.html +1 -0
- package/dist/server/out/chat/index.txt +28 -0
- package/dist/server/out/connections/__next.!KHdvcmtzcGFjZSk.connections.__PAGE__.txt +39 -0
- package/dist/server/out/connections/__next._full.txt +32 -0
- package/dist/server/out/connections/__next._tree.txt +5 -0
- package/dist/server/out/connections/index.html +1 -0
- package/dist/server/out/connections/index.txt +32 -0
- package/dist/server/out/credentials/__next.!KHdvcmtzcGFjZSk.credentials.__PAGE__.txt +40 -0
- package/dist/server/out/credentials/__next._full.txt +33 -0
- package/dist/server/out/credentials/__next._tree.txt +5 -0
- package/dist/server/out/credentials/index.html +1 -0
- package/dist/server/out/credentials/index.txt +33 -0
- package/dist/server/out/documents/__next.!KHdvcmtzcGFjZSk.documents.__PAGE__.txt +39 -0
- package/dist/server/out/documents/__next._full.txt +32 -0
- package/dist/server/out/documents/__next._tree.txt +5 -0
- package/dist/server/out/documents/index.html +1 -0
- package/dist/server/out/documents/index.txt +32 -0
- package/dist/server/out/favicon.ico +0 -0
- package/dist/server/out/favicon.svg +8 -0
- package/dist/server/out/index.html +1 -0
- package/dist/server/out/index.txt +29 -0
- package/dist/server/out/logo.svg +12 -0
- package/dist/server/out/monaco/vs/base/browser/ui/codicons/codicon/codicon.ttf +0 -0
- package/dist/server/out/monaco/vs/base/worker/workerMain.js +31 -0
- package/dist/server/out/monaco/vs/basic-languages/abap/abap.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/apex/apex.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/azcli/azcli.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/bat/bat.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/bicep/bicep.js +11 -0
- package/dist/server/out/monaco/vs/basic-languages/cameligo/cameligo.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/clojure/clojure.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/coffee/coffee.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/cpp/cpp.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/csharp/csharp.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/csp/csp.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/css/css.js +12 -0
- package/dist/server/out/monaco/vs/basic-languages/cypher/cypher.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/dart/dart.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/dockerfile/dockerfile.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/ecl/ecl.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/elixir/elixir.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/flow9/flow9.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/freemarker2/freemarker2.js +12 -0
- package/dist/server/out/monaco/vs/basic-languages/fsharp/fsharp.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/go/go.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/graphql/graphql.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/handlebars/handlebars.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/hcl/hcl.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/html/html.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/ini/ini.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/java/java.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/javascript/javascript.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/julia/julia.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/kotlin/kotlin.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/less/less.js +11 -0
- package/dist/server/out/monaco/vs/basic-languages/lexon/lexon.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/liquid/liquid.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/lua/lua.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/m3/m3.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/markdown/markdown.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/mdx/mdx.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/mips/mips.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/msdax/msdax.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/mysql/mysql.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/objective-c/objective-c.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/pascal/pascal.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/pascaligo/pascaligo.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/perl/perl.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/pgsql/pgsql.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/php/php.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/pla/pla.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/postiats/postiats.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/powerquery/powerquery.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/powershell/powershell.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/protobuf/protobuf.js +11 -0
- package/dist/server/out/monaco/vs/basic-languages/pug/pug.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/python/python.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/qsharp/qsharp.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/r/r.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/razor/razor.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/redis/redis.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/redshift/redshift.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/restructuredtext/restructuredtext.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/ruby/ruby.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/rust/rust.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/sb/sb.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/scala/scala.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/scheme/scheme.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/scss/scss.js +12 -0
- package/dist/server/out/monaco/vs/basic-languages/shell/shell.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/solidity/solidity.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/sophia/sophia.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/sparql/sparql.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/sql/sql.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/st/st.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/swift/swift.js +13 -0
- package/dist/server/out/monaco/vs/basic-languages/systemverilog/systemverilog.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/tcl/tcl.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/twig/twig.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/typescript/typescript.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/typespec/typespec.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/vb/vb.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/wgsl/wgsl.js +307 -0
- package/dist/server/out/monaco/vs/basic-languages/xml/xml.js +10 -0
- package/dist/server/out/monaco/vs/basic-languages/yaml/yaml.js +10 -0
- package/dist/server/out/monaco/vs/editor/editor.main.css +8 -0
- package/dist/server/out/monaco/vs/editor/editor.main.js +798 -0
- package/dist/server/out/monaco/vs/language/css/cssMode.js +13 -0
- package/dist/server/out/monaco/vs/language/css/cssWorker.js +77 -0
- package/dist/server/out/monaco/vs/language/html/htmlMode.js +13 -0
- package/dist/server/out/monaco/vs/language/html/htmlWorker.js +454 -0
- package/dist/server/out/monaco/vs/language/json/jsonMode.js +19 -0
- package/dist/server/out/monaco/vs/language/json/jsonWorker.js +42 -0
- package/dist/server/out/monaco/vs/language/typescript/tsMode.js +20 -0
- package/dist/server/out/monaco/vs/language/typescript/tsWorker.js +51328 -0
- package/dist/server/out/monaco/vs/loader.js +11 -0
- package/dist/server/out/monaco/vs/nls.messages.de.js +21 -0
- package/dist/server/out/monaco/vs/nls.messages.es.js +21 -0
- package/dist/server/out/monaco/vs/nls.messages.fr.js +19 -0
- package/dist/server/out/monaco/vs/nls.messages.it.js +19 -0
- package/dist/server/out/monaco/vs/nls.messages.ja.js +21 -0
- package/dist/server/out/monaco/vs/nls.messages.ko.js +19 -0
- package/dist/server/out/monaco/vs/nls.messages.ru.js +21 -0
- package/dist/server/out/monaco/vs/nls.messages.zh-cn.js +21 -0
- package/dist/server/out/monaco/vs/nls.messages.zh-tw.js +19 -0
- package/dist/server/out/og-image.png +0 -0
- package/dist/server/out/people/__next.!KHdvcmtzcGFjZSk.people.__PAGE__.txt +39 -0
- package/dist/server/out/people/__next._full.txt +32 -0
- package/dist/server/out/people/__next._tree.txt +5 -0
- package/dist/server/out/people/index.html +1 -0
- package/dist/server/out/people/index.txt +32 -0
- package/dist/server/out/plugins/__next.!KHdvcmtzcGFjZSk.plugins.__PAGE__.txt +42 -0
- package/dist/server/out/plugins/__next._full.txt +35 -0
- package/dist/server/out/plugins/__next._tree.txt +5 -0
- package/dist/server/out/plugins/index.html +1 -0
- package/dist/server/out/plugins/index.txt +35 -0
- package/dist/server/out/projects/__next.!KHdvcmtzcGFjZSk.projects.__PAGE__.txt +39 -0
- package/dist/server/out/projects/__next._full.txt +32 -0
- package/dist/server/out/projects/__next._tree.txt +5 -0
- package/dist/server/out/projects/index.html +1 -0
- package/dist/server/out/projects/index.txt +32 -0
- package/dist/server/out/runs/__next.!KHdvcmtzcGFjZSk.runs.__PAGE__.txt +41 -0
- package/dist/server/out/runs/__next._full.txt +34 -0
- package/dist/server/out/runs/__next._tree.txt +5 -0
- package/dist/server/out/runs/index.html +1 -0
- package/dist/server/out/runs/index.txt +34 -0
- package/dist/server/out/schedules/__next.!KHdvcmtzcGFjZSk.schedules.__PAGE__.txt +41 -0
- package/dist/server/out/schedules/__next._full.txt +34 -0
- package/dist/server/out/schedules/__next._tree.txt +5 -0
- package/dist/server/out/schedules/index.html +1 -0
- package/dist/server/out/schedules/index.txt +34 -0
- package/dist/server/out/settings/__next.!KHdvcmtzcGFjZSk.settings.__PAGE__.txt +39 -0
- package/dist/server/out/settings/__next._full.txt +32 -0
- package/dist/server/out/settings/__next._tree.txt +5 -0
- package/dist/server/out/settings/index.html +1 -0
- package/dist/server/out/settings/index.txt +32 -0
- package/dist/server/out/setup/__next._full.txt +28 -0
- package/dist/server/out/setup/__next._tree.txt +4 -0
- package/dist/server/out/setup/__next.setup.__PAGE__.txt +34 -0
- package/dist/server/out/setup/index.html +1 -0
- package/dist/server/out/setup/index.txt +28 -0
- package/dist/server/out/tables/__next.!KHdvcmtzcGFjZSk.tables.__PAGE__.txt +36 -0
- package/dist/server/out/tables/__next._full.txt +29 -0
- package/dist/server/out/tables/__next._tree.txt +5 -0
- package/dist/server/out/tables/index.html +1 -0
- package/dist/server/out/tables/index.txt +29 -0
- package/dist/server/out/webhooks/__next.!KHdvcmtzcGFjZSk.webhooks.__PAGE__.txt +39 -0
- package/dist/server/out/webhooks/__next._full.txt +32 -0
- package/dist/server/out/webhooks/__next._tree.txt +5 -0
- package/dist/server/out/webhooks/index.html +1 -0
- package/dist/server/out/webhooks/index.txt +32 -0
- package/dist/server/out/workspaces/invite/__next._full.txt +29 -0
- package/dist/server/out/workspaces/invite/__next._tree.txt +5 -0
- package/dist/server/out/workspaces/invite/__next.workspaces.invite.__PAGE__.txt +36 -0
- package/dist/server/out/workspaces/invite/index.html +1 -0
- package/dist/server/out/workspaces/invite/index.txt +29 -0
- package/docs/browser-sessions.md +85 -0
- package/docs/npm-distribution.md +78 -0
- package/docs/remote-mcp.md +51 -0
- package/package.json +112 -4
- package/runtime/LICENSE +122 -0
- package/runtime/README.md +114 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// src/mcp/client.ts
|
|
2
|
+
import { httpTransport } from "./transport.js";
|
|
3
|
+
import {
|
|
4
|
+
Client,
|
|
5
|
+
discoverOAuthProtectedResourceMetadata
|
|
6
|
+
} from "@modelcontextprotocol/client";
|
|
7
|
+
import Ajv from "ajv/dist/2020.js";
|
|
8
|
+
import AjvDraft7 from "ajv";
|
|
9
|
+
import Ajv2019 from "ajv/dist/2019.js";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import {
|
|
12
|
+
connectionSchema,
|
|
13
|
+
discoverySchema,
|
|
14
|
+
remoteToolSchema
|
|
15
|
+
} from "./contract.js";
|
|
16
|
+
import { endpointFetch, redactMcp } from "./network.js";
|
|
17
|
+
var argumentsSchema = z.record(z.string(), z.unknown());
|
|
18
|
+
var McpRuntime = class {
|
|
19
|
+
constructor(connection, credentials, signal, transportFactory = httpTransport) {
|
|
20
|
+
this.credentials = credentials;
|
|
21
|
+
this.transportFactory = transportFactory;
|
|
22
|
+
this.connection = connectionSchema.parse(connection);
|
|
23
|
+
this.signal = AbortSignal.any([signal, this.controller.signal]);
|
|
24
|
+
this.signal.addEventListener("abort", this.onAbort, { once: true });
|
|
25
|
+
}
|
|
26
|
+
credentials;
|
|
27
|
+
transportFactory;
|
|
28
|
+
client;
|
|
29
|
+
opening;
|
|
30
|
+
closing;
|
|
31
|
+
onAbort = () => {
|
|
32
|
+
void this.close();
|
|
33
|
+
};
|
|
34
|
+
headers = {};
|
|
35
|
+
secrets = /* @__PURE__ */ new Set();
|
|
36
|
+
lastStatus = 0;
|
|
37
|
+
challenge;
|
|
38
|
+
selected = "streamable-http";
|
|
39
|
+
controller = new AbortController();
|
|
40
|
+
validators = /* @__PURE__ */ new Map();
|
|
41
|
+
signal;
|
|
42
|
+
connection;
|
|
43
|
+
async open() {
|
|
44
|
+
this.signal.throwIfAborted();
|
|
45
|
+
this.headers = await this.credentials();
|
|
46
|
+
for (const value of Object.values(this.headers)) this.secrets.add(value);
|
|
47
|
+
this.signal.throwIfAborted();
|
|
48
|
+
const fetcher = async (input, init) => {
|
|
49
|
+
this.headers = await this.credentials();
|
|
50
|
+
for (const value of Object.values(this.headers)) this.secrets.add(value);
|
|
51
|
+
const response = await endpointFetch(
|
|
52
|
+
this.connection.endpoint,
|
|
53
|
+
this.signal,
|
|
54
|
+
this.headers
|
|
55
|
+
)(input, init);
|
|
56
|
+
this.lastStatus = response.status;
|
|
57
|
+
if ([401, 403].includes(response.status))
|
|
58
|
+
this.challenge = response.headers.get("www-authenticate") ?? void 0;
|
|
59
|
+
return response;
|
|
60
|
+
};
|
|
61
|
+
const connect = async (transport) => {
|
|
62
|
+
this.selected = transport;
|
|
63
|
+
this.lastStatus = 0;
|
|
64
|
+
this.client = new Client(
|
|
65
|
+
{ name: "orgsdk-executor", version: "0.1.1" },
|
|
66
|
+
{
|
|
67
|
+
versionNegotiation: { mode: transport === "sse" ? "legacy" : "auto" }
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
await this.client.connect(
|
|
71
|
+
this.transportFactory(this.connection.endpoint, transport, fetcher),
|
|
72
|
+
{ timeout: 15e3, signal: this.signal }
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
try {
|
|
76
|
+
await connect(
|
|
77
|
+
this.connection.transport === "sse" ? "sse" : "streamable-http"
|
|
78
|
+
);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
const fallback = this.connection.transport === "auto" && [404, 405].includes(this.lastStatus);
|
|
81
|
+
await this.client?.close();
|
|
82
|
+
if (!fallback) throw error;
|
|
83
|
+
await connect("sse");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async ready() {
|
|
87
|
+
this.opening ??= this.open();
|
|
88
|
+
await this.opening;
|
|
89
|
+
this.signal.throwIfAborted();
|
|
90
|
+
if (!this.client) throw new Error("MCP connection unavailable");
|
|
91
|
+
return this.client;
|
|
92
|
+
}
|
|
93
|
+
async connect() {
|
|
94
|
+
await this.ready();
|
|
95
|
+
}
|
|
96
|
+
async discover() {
|
|
97
|
+
const timer = setTimeout(
|
|
98
|
+
() => this.controller.abort(new Error("MCP discovery timed out")),
|
|
99
|
+
6e4
|
|
100
|
+
);
|
|
101
|
+
try {
|
|
102
|
+
const client = await this.ready();
|
|
103
|
+
const tools = [];
|
|
104
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
105
|
+
const names = /* @__PURE__ */ new Set();
|
|
106
|
+
let cursor;
|
|
107
|
+
do {
|
|
108
|
+
const page = await client.request(
|
|
109
|
+
{
|
|
110
|
+
method: "tools/list",
|
|
111
|
+
params: cursor !== void 0 ? { cursor } : {}
|
|
112
|
+
},
|
|
113
|
+
{ signal: this.signal, timeout: 15e3 }
|
|
114
|
+
);
|
|
115
|
+
for (const value of page.tools) {
|
|
116
|
+
const tool = remoteToolSchema.parse(value);
|
|
117
|
+
if (names.has(tool.name))
|
|
118
|
+
throw new Error("MCP server returned duplicate tool names");
|
|
119
|
+
names.add(tool.name);
|
|
120
|
+
tools.push(tool);
|
|
121
|
+
}
|
|
122
|
+
if (tools.length > 1e3 || JSON.stringify(tools).length > 5e5)
|
|
123
|
+
throw new Error("MCP tool catalogue exceeds the supported size");
|
|
124
|
+
cursor = page.nextCursor;
|
|
125
|
+
if (cursor !== void 0 && cursors.has(cursor))
|
|
126
|
+
throw new Error("MCP server repeated a discovery cursor");
|
|
127
|
+
if (cursor !== void 0) cursors.add(cursor);
|
|
128
|
+
if (cursors.size >= 100)
|
|
129
|
+
throw new Error("MCP discovery exceeded 100 pages");
|
|
130
|
+
} while (cursor !== void 0);
|
|
131
|
+
return discoverySchema.parse(
|
|
132
|
+
redactMcp({ tools, transport: this.selected }, this.redactionHeaders())
|
|
133
|
+
);
|
|
134
|
+
} catch (error) {
|
|
135
|
+
if (![401, 403].includes(this.lastStatus)) throw this.safeError(error);
|
|
136
|
+
const metadataUrl = /resource_metadata="([^"]+)"/.exec(
|
|
137
|
+
this.challenge ?? ""
|
|
138
|
+
)?.[1];
|
|
139
|
+
const resourceMetadata = await discoverOAuthProtectedResourceMetadata(
|
|
140
|
+
this.connection.endpoint,
|
|
141
|
+
{
|
|
142
|
+
...metadataUrl ? { resourceMetadataUrl: new URL(metadataUrl) } : {}
|
|
143
|
+
},
|
|
144
|
+
endpointFetch(
|
|
145
|
+
this.connection.endpoint,
|
|
146
|
+
AbortSignal.any([this.signal, AbortSignal.timeout(15e3)])
|
|
147
|
+
)
|
|
148
|
+
).catch(() => void 0);
|
|
149
|
+
return discoverySchema.parse(
|
|
150
|
+
redactMcp(
|
|
151
|
+
{
|
|
152
|
+
tools: [],
|
|
153
|
+
transport: this.selected,
|
|
154
|
+
authRequired: true,
|
|
155
|
+
resourceMetadata
|
|
156
|
+
},
|
|
157
|
+
this.redactionHeaders()
|
|
158
|
+
)
|
|
159
|
+
);
|
|
160
|
+
} finally {
|
|
161
|
+
clearTimeout(timer);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
inputValidator(tool) {
|
|
165
|
+
const cached = this.validators.get(tool.alias);
|
|
166
|
+
if (cached) {
|
|
167
|
+
return cached;
|
|
168
|
+
}
|
|
169
|
+
const dialect = String(tool.inputSchema.$schema);
|
|
170
|
+
const validatorClass = dialect.includes("draft-07") ? AjvDraft7 : dialect.includes("2019-09") ? Ajv2019 : Ajv;
|
|
171
|
+
const validate = new validatorClass({
|
|
172
|
+
strict: false,
|
|
173
|
+
validateFormats: false,
|
|
174
|
+
allErrors: false
|
|
175
|
+
}).compile(tool.inputSchema);
|
|
176
|
+
this.validators.set(tool.alias, validate);
|
|
177
|
+
return validate;
|
|
178
|
+
}
|
|
179
|
+
async call(alias, args) {
|
|
180
|
+
const tool = this.connection.tools.find(
|
|
181
|
+
(candidate) => candidate.alias === alias
|
|
182
|
+
);
|
|
183
|
+
if (!tool) throw new Error("Tool is outside the approved MCP catalogue");
|
|
184
|
+
try {
|
|
185
|
+
if (!this.inputValidator(tool)(args))
|
|
186
|
+
throw new Error("Arguments do not match the MCP tool input schema");
|
|
187
|
+
const client = await this.ready();
|
|
188
|
+
const result = await client.callTool(
|
|
189
|
+
{
|
|
190
|
+
name: tool.name,
|
|
191
|
+
arguments: argumentsSchema.parse(args)
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
signal: this.signal,
|
|
195
|
+
timeout: 6e4,
|
|
196
|
+
toolDefinition: {
|
|
197
|
+
...tool,
|
|
198
|
+
inputSchema: { ...tool.inputSchema, type: "object" }
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
const clean = redactMcp(result, this.redactionHeaders());
|
|
203
|
+
if (JSON.stringify(clean).length > 1e6)
|
|
204
|
+
throw new Error("MCP result exceeds the supported size");
|
|
205
|
+
if (result.isError)
|
|
206
|
+
throw new Error(
|
|
207
|
+
`Remote MCP tool failed: ${JSON.stringify(clean).slice(0, 1500)}`
|
|
208
|
+
);
|
|
209
|
+
return clean;
|
|
210
|
+
} catch (error) {
|
|
211
|
+
throw this.safeError(error);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
redactionHeaders() {
|
|
215
|
+
return Object.fromEntries(
|
|
216
|
+
[...this.secrets].map((secret, index) => [String(index), secret])
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
safeError(error) {
|
|
220
|
+
return new Error(
|
|
221
|
+
String(
|
|
222
|
+
redactMcp(
|
|
223
|
+
error instanceof Error ? error.message : "MCP request failed",
|
|
224
|
+
this.redactionHeaders()
|
|
225
|
+
)
|
|
226
|
+
).slice(0, 2e3)
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
async close() {
|
|
230
|
+
if (this.closing) return this.closing;
|
|
231
|
+
this.signal.removeEventListener("abort", this.onAbort);
|
|
232
|
+
this.controller.abort();
|
|
233
|
+
this.closing = this.client?.close().catch(() => void 0) ?? Promise.resolve();
|
|
234
|
+
return this.closing;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
export {
|
|
238
|
+
McpRuntime
|
|
239
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// src/mcp/contract.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var jsonObject = z.record(z.string(), z.json());
|
|
4
|
+
var endpointSchema = z.string().url().max(2e3).refine((value) => {
|
|
5
|
+
const url = new URL(value);
|
|
6
|
+
return ["https:", "http:"].includes(url.protocol) && !url.username && !url.password && !url.hash;
|
|
7
|
+
}, "Use an HTTP(S) URL without embedded credentials or a fragment");
|
|
8
|
+
var transportSchema = z.enum(["auto", "streamable-http", "sse"]);
|
|
9
|
+
var remoteToolSchema = z.object({
|
|
10
|
+
name: z.string().min(1).max(256),
|
|
11
|
+
description: z.string().max(1e4).optional(),
|
|
12
|
+
inputSchema: jsonObject,
|
|
13
|
+
outputSchema: jsonObject.optional(),
|
|
14
|
+
annotations: jsonObject.optional()
|
|
15
|
+
}).strip();
|
|
16
|
+
var approvedToolSchema = remoteToolSchema.extend({
|
|
17
|
+
alias: z.string().regex(/^[a-z][a-zA-Z0-9]*$/).max(100)
|
|
18
|
+
});
|
|
19
|
+
var connectionSchema = z.object({
|
|
20
|
+
id: z.string().uuid(),
|
|
21
|
+
endpoint: endpointSchema,
|
|
22
|
+
transport: transportSchema,
|
|
23
|
+
revision: z.number().int().nonnegative(),
|
|
24
|
+
tools: z.array(approvedToolSchema).max(1e3)
|
|
25
|
+
});
|
|
26
|
+
var discoverySchema = z.object({
|
|
27
|
+
tools: z.array(remoteToolSchema).max(1e3),
|
|
28
|
+
transport: z.enum(["streamable-http", "sse"]),
|
|
29
|
+
authRequired: z.boolean().default(false),
|
|
30
|
+
resourceMetadata: jsonObject.optional()
|
|
31
|
+
});
|
|
32
|
+
var headerSchema = z.record(
|
|
33
|
+
z.string().regex(/^[!#$%&'*+.^_`|~0-9a-z-]+$/i),
|
|
34
|
+
z.string().max(8e3).refine((value) => !/[\r\n]/.test(value))
|
|
35
|
+
).refine(
|
|
36
|
+
(headers) => Object.keys(headers).length <= 20 && Object.keys(headers).every(
|
|
37
|
+
(name) => ![
|
|
38
|
+
"host",
|
|
39
|
+
"connection",
|
|
40
|
+
"content-length",
|
|
41
|
+
"content-type",
|
|
42
|
+
"accept",
|
|
43
|
+
"mcp-session-id",
|
|
44
|
+
"mcp-protocol-version"
|
|
45
|
+
].includes(name.toLowerCase())
|
|
46
|
+
),
|
|
47
|
+
"Unsupported authentication header"
|
|
48
|
+
);
|
|
49
|
+
export {
|
|
50
|
+
approvedToolSchema,
|
|
51
|
+
connectionSchema,
|
|
52
|
+
discoverySchema,
|
|
53
|
+
endpointSchema,
|
|
54
|
+
headerSchema,
|
|
55
|
+
remoteToolSchema,
|
|
56
|
+
transportSchema
|
|
57
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/mcp/functions.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { McpRuntime } from "./client.js";
|
|
4
|
+
import { connectionSchema, headerSchema } from "./contract.js";
|
|
5
|
+
var executionSecretSchema = z.object({
|
|
6
|
+
headers: z.unknown(),
|
|
7
|
+
expires_at: z.number().optional()
|
|
8
|
+
});
|
|
9
|
+
function mcpPlugin(plugin, client, signal) {
|
|
10
|
+
const connection = connectionSchema.parse(plugin.mcp);
|
|
11
|
+
let cached;
|
|
12
|
+
const runtime = new McpRuntime(
|
|
13
|
+
connection,
|
|
14
|
+
async () => {
|
|
15
|
+
if (!plugin.credential_id) return {};
|
|
16
|
+
if (cached && cached.expiresAt > Date.now() + 6e4)
|
|
17
|
+
return cached.headers;
|
|
18
|
+
const secret = executionSecretSchema.parse(
|
|
19
|
+
await client.secret(plugin.credential_id)
|
|
20
|
+
);
|
|
21
|
+
cached = {
|
|
22
|
+
headers: headerSchema.parse(secret.headers),
|
|
23
|
+
expiresAt: secret.expires_at ?? Number.POSITIVE_INFINITY
|
|
24
|
+
};
|
|
25
|
+
return cached.headers;
|
|
26
|
+
},
|
|
27
|
+
signal
|
|
28
|
+
);
|
|
29
|
+
const functions = connection.tools.map((tool) => ({
|
|
30
|
+
name: tool.alias,
|
|
31
|
+
category: plugin.slug,
|
|
32
|
+
calling: "named",
|
|
33
|
+
description: tool.description ?? "",
|
|
34
|
+
handler: (args) => runtime.call(tool.alias, args)
|
|
35
|
+
}));
|
|
36
|
+
return { runtime, functions };
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
mcpPlugin
|
|
40
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// src/mcp/network.ts
|
|
2
|
+
import { endpointSchema } from "./contract.js";
|
|
3
|
+
function endpointFetch(endpoint, signal, headers = {}, limit = 1e6) {
|
|
4
|
+
const origin = new URL(endpointSchema.parse(endpoint)).origin;
|
|
5
|
+
return async (input, init) => {
|
|
6
|
+
const request = new Request(input, init);
|
|
7
|
+
const url = new URL(request.url);
|
|
8
|
+
if (url.origin !== origin)
|
|
9
|
+
throw new Error(
|
|
10
|
+
"MCP request changed origin; configure the destination explicitly"
|
|
11
|
+
);
|
|
12
|
+
const authenticated = new Headers(request.headers);
|
|
13
|
+
for (const [name, value] of Object.entries(headers))
|
|
14
|
+
authenticated.set(name, value);
|
|
15
|
+
const response = await fetch(request, {
|
|
16
|
+
headers: authenticated,
|
|
17
|
+
redirect: "error",
|
|
18
|
+
signal: AbortSignal.any([signal, request.signal])
|
|
19
|
+
});
|
|
20
|
+
if (!response.body) return response;
|
|
21
|
+
let bytes = 0;
|
|
22
|
+
const body = response.body.pipeThrough(
|
|
23
|
+
new TransformStream({
|
|
24
|
+
transform(chunk, controller) {
|
|
25
|
+
bytes += chunk.byteLength;
|
|
26
|
+
if (bytes > limit)
|
|
27
|
+
throw new Error("MCP response exceeds the supported size");
|
|
28
|
+
controller.enqueue(chunk);
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
return new Response(body, {
|
|
33
|
+
status: response.status,
|
|
34
|
+
statusText: response.statusText,
|
|
35
|
+
headers: response.headers
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function redactMcp(value, headers) {
|
|
40
|
+
const secrets = Object.values(headers).flatMap((header) => [header, header.replace(/^Bearer /i, "")]).filter(Boolean);
|
|
41
|
+
const text = (input) => secrets.reduce(
|
|
42
|
+
(result, secret) => result.split(secret).join("[REDACTED]"),
|
|
43
|
+
input
|
|
44
|
+
);
|
|
45
|
+
const visit = (input) => {
|
|
46
|
+
if (typeof input === "string") return text(input);
|
|
47
|
+
if (typeof input === "number" && secrets.includes(String(input)))
|
|
48
|
+
return "[REDACTED]";
|
|
49
|
+
if (Array.isArray(input)) return input.map(visit);
|
|
50
|
+
if (input !== null && typeof input === "object")
|
|
51
|
+
return Object.fromEntries(
|
|
52
|
+
Object.entries(input).map(([key, item]) => [text(key), visit(item)])
|
|
53
|
+
);
|
|
54
|
+
return input;
|
|
55
|
+
};
|
|
56
|
+
return visit(value);
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
endpointFetch,
|
|
60
|
+
redactMcp
|
|
61
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/mcp/schema-types.ts
|
|
2
|
+
function schemaType(value, depth = 0) {
|
|
3
|
+
if (depth > 8 || !value || typeof value !== "object" || Array.isArray(value))
|
|
4
|
+
return "unknown";
|
|
5
|
+
const schema = value;
|
|
6
|
+
if (schema.$ref || schema.allOf || schema.not || schema.if) return "unknown";
|
|
7
|
+
if (Array.isArray(schema.enum) && schema.enum.length <= 50)
|
|
8
|
+
return schema.enum.map(
|
|
9
|
+
(item) => typeof item === "string" || typeof item === "boolean" || typeof item === "number" || item === null ? JSON.stringify(item) : "unknown"
|
|
10
|
+
).join(" | ") || "never";
|
|
11
|
+
const variants = schema.anyOf ?? schema.oneOf;
|
|
12
|
+
if (Array.isArray(variants))
|
|
13
|
+
return variants.length > 30 ? "unknown" : variants.map((item) => schemaType(item, depth + 1)).join(" | ") || "unknown";
|
|
14
|
+
if (Array.isArray(schema.type))
|
|
15
|
+
return schema.type.map((type) => schemaType({ ...schema, type }, depth + 1)).join(" | ");
|
|
16
|
+
if (["string", "boolean", "number", "null"].includes(String(schema.type)))
|
|
17
|
+
return String(schema.type);
|
|
18
|
+
if (schema.type === "integer") return "number";
|
|
19
|
+
if (schema.type === "array")
|
|
20
|
+
return `Array<${schemaType(schema.items, depth + 1)}>`;
|
|
21
|
+
if (schema.type === "object" || schema.properties) {
|
|
22
|
+
if (!schema.properties || typeof schema.properties !== "object" || Array.isArray(schema.properties))
|
|
23
|
+
return "Record<string, unknown>";
|
|
24
|
+
const required = new Set(
|
|
25
|
+
Array.isArray(schema.required) ? schema.required : []
|
|
26
|
+
);
|
|
27
|
+
const properties = Object.entries(schema.properties);
|
|
28
|
+
if (properties.length > 100) return "Record<string, unknown>";
|
|
29
|
+
return `{${properties.map(([key, child]) => `${JSON.stringify(key)}${required.has(key) ? "" : "?"}: ${schemaType(child, depth + 1)}`).join("; ")}${schema.additionalProperties === false ? "" : "; [key: string]: unknown"}}`;
|
|
30
|
+
}
|
|
31
|
+
return "unknown";
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
schemaType
|
|
35
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/mcp/transport.ts
|
|
2
|
+
import {
|
|
3
|
+
StreamableHTTPClientTransport,
|
|
4
|
+
SSEClientTransport
|
|
5
|
+
} from "@modelcontextprotocol/client";
|
|
6
|
+
var httpTransport = (endpoint, kind, fetcher) => kind === "sse" ? new SSEClientTransport(new URL(endpoint), { fetch: fetcher }) : new StreamableHTTPClientTransport(new URL(endpoint), {
|
|
7
|
+
fetch: fetcher,
|
|
8
|
+
reconnectionOptions: {
|
|
9
|
+
maxRetries: 0,
|
|
10
|
+
initialReconnectionDelay: 1e3,
|
|
11
|
+
maxReconnectionDelay: 1e3,
|
|
12
|
+
reconnectionDelayGrowFactor: 1
|
|
13
|
+
},
|
|
14
|
+
onInsufficientScope: "throw"
|
|
15
|
+
});
|
|
16
|
+
export {
|
|
17
|
+
httpTransport
|
|
18
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// src/package-dependencies.ts
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { readdir, readFile, realpath } from "node:fs/promises";
|
|
5
|
+
import { dirname, join, relative, sep } from "node:path";
|
|
6
|
+
import { gzipSync } from "node:zlib";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
var packageSchema = z.object({
|
|
9
|
+
name: z.string(),
|
|
10
|
+
version: z.string().optional(),
|
|
11
|
+
license: z.string().optional(),
|
|
12
|
+
dependencies: z.record(z.string(), z.string()).optional(),
|
|
13
|
+
optionalDependencies: z.record(z.string(), z.string()).optional()
|
|
14
|
+
});
|
|
15
|
+
async function packageDirectory(name, from) {
|
|
16
|
+
const require2 = createRequire(join(from, "package.json"));
|
|
17
|
+
let entry;
|
|
18
|
+
try {
|
|
19
|
+
return await realpath(dirname(require2.resolve(`${name}/package.json`)));
|
|
20
|
+
} catch {
|
|
21
|
+
entry = require2.resolve(name);
|
|
22
|
+
}
|
|
23
|
+
let directory = dirname(entry);
|
|
24
|
+
while (true) {
|
|
25
|
+
try {
|
|
26
|
+
const metadata = packageSchema.parse(
|
|
27
|
+
JSON.parse(await readFile(join(directory, "package.json"), "utf8"))
|
|
28
|
+
);
|
|
29
|
+
if (metadata.name === name) return realpath(directory);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
if (error.code !== "ENOENT") throw error;
|
|
32
|
+
}
|
|
33
|
+
const parent = dirname(directory);
|
|
34
|
+
if (parent === directory) throw new Error(`Cannot locate package ${name}`);
|
|
35
|
+
directory = parent;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async function packageFiles(directory) {
|
|
39
|
+
const files = [];
|
|
40
|
+
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
41
|
+
if (entry.name === "node_modules") continue;
|
|
42
|
+
const path = join(directory, entry.name);
|
|
43
|
+
if (entry.isSymbolicLink())
|
|
44
|
+
throw new Error(`Cannot embed a symbolic link: ${path}`);
|
|
45
|
+
if (entry.isDirectory()) files.push(...await packageFiles(path));
|
|
46
|
+
else if (entry.isFile()) files.push(path);
|
|
47
|
+
}
|
|
48
|
+
return files;
|
|
49
|
+
}
|
|
50
|
+
async function dependencyDirectories(checkout, names) {
|
|
51
|
+
const dependencies = /* @__PURE__ */ new Map();
|
|
52
|
+
const collect = async (name, from) => {
|
|
53
|
+
if (!/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+$/i.test(name))
|
|
54
|
+
throw new Error("Embedded dependency must be an npm package name");
|
|
55
|
+
const directory = await packageDirectory(name, from);
|
|
56
|
+
if (dependencies.has(directory)) return;
|
|
57
|
+
const path = relative(join(checkout, "node_modules"), directory);
|
|
58
|
+
if (path.startsWith("..") || path.startsWith(sep))
|
|
59
|
+
throw new Error(
|
|
60
|
+
"Embedded dependencies must be installed inside the plugin checkout"
|
|
61
|
+
);
|
|
62
|
+
dependencies.set(directory, join("node_modules", path));
|
|
63
|
+
const metadata = packageSchema.parse(
|
|
64
|
+
JSON.parse(await readFile(join(directory, "package.json"), "utf8"))
|
|
65
|
+
);
|
|
66
|
+
for (const dependency of Object.keys(metadata.dependencies ?? {}))
|
|
67
|
+
await collect(dependency, directory);
|
|
68
|
+
for (const dependency of Object.keys(metadata.optionalDependencies ?? {})) {
|
|
69
|
+
try {
|
|
70
|
+
await packageDirectory(dependency, directory);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
if (error.code === "MODULE_NOT_FOUND")
|
|
73
|
+
continue;
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
await collect(dependency, directory);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
for (const name of names) await collect(name, checkout);
|
|
80
|
+
return dependencies;
|
|
81
|
+
}
|
|
82
|
+
async function dependencyNotices(checkout) {
|
|
83
|
+
const metadata = packageSchema.parse(
|
|
84
|
+
JSON.parse(await readFile(join(checkout, "package.json"), "utf8"))
|
|
85
|
+
);
|
|
86
|
+
const dependencies = await dependencyDirectories(
|
|
87
|
+
checkout,
|
|
88
|
+
Object.keys(metadata.dependencies ?? {})
|
|
89
|
+
);
|
|
90
|
+
const notices = [];
|
|
91
|
+
for (const directory of [...dependencies.keys()].sort()) {
|
|
92
|
+
const pkg = packageSchema.parse(
|
|
93
|
+
JSON.parse(await readFile(join(directory, "package.json"), "utf8"))
|
|
94
|
+
);
|
|
95
|
+
const files = (await readdir(directory)).filter((name) => /^(licen[sc]e|notice|copying)([.-]|$)/i.test(name)).sort();
|
|
96
|
+
notices.push(
|
|
97
|
+
`${pkg.name}@${pkg.version ?? "unknown"} (${pkg.license ?? "see accompanying notices"})`
|
|
98
|
+
);
|
|
99
|
+
for (const file of files)
|
|
100
|
+
notices.push(await readFile(join(directory, file), "utf8"));
|
|
101
|
+
if (!files.length) {
|
|
102
|
+
const readme = await readFile(join(directory, "README.md"), "utf8").catch(
|
|
103
|
+
() => ""
|
|
104
|
+
);
|
|
105
|
+
if (!readme.includes("Permission is hereby granted"))
|
|
106
|
+
throw new Error(`Missing dependency license text: ${pkg.name}`);
|
|
107
|
+
notices.push(readme);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return notices.join("\n\n");
|
|
111
|
+
}
|
|
112
|
+
async function embedPluginDependencies(checkout, entry, names) {
|
|
113
|
+
const dependencies = await dependencyDirectories(checkout, names);
|
|
114
|
+
const files = [];
|
|
115
|
+
const add = (path, bytes) => {
|
|
116
|
+
files.push([
|
|
117
|
+
path.split(sep).join("/"),
|
|
118
|
+
Buffer.from(bytes).toString("base64"),
|
|
119
|
+
createHash("sha256").update(bytes).digest("hex")
|
|
120
|
+
]);
|
|
121
|
+
};
|
|
122
|
+
add("entry.mjs", entry);
|
|
123
|
+
for (const [directory, target] of dependencies) {
|
|
124
|
+
for (const path of await packageFiles(directory))
|
|
125
|
+
add(join(target, relative(directory, path)), await readFile(path));
|
|
126
|
+
}
|
|
127
|
+
files.sort(([left], [right]) => left.localeCompare(right, "en"));
|
|
128
|
+
const payload = gzipSync(JSON.stringify(files), { level: 9 }).toString(
|
|
129
|
+
"base64"
|
|
130
|
+
);
|
|
131
|
+
const loader = await readFile(
|
|
132
|
+
new URL("./embedded-plugin-loader.mjs", import.meta.url),
|
|
133
|
+
"utf8"
|
|
134
|
+
);
|
|
135
|
+
return new TextEncoder().encode(
|
|
136
|
+
`${loader}
|
|
137
|
+
export default await loadEmbeddedPlugin(${JSON.stringify(payload)}, import.meta.url);
|
|
138
|
+
`
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
dependencyNotices,
|
|
143
|
+
embedPluginDependencies
|
|
144
|
+
};
|