@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,86 @@
|
|
|
1
|
+
// src/sessions/journal.ts
|
|
2
|
+
import { mkdir, open, readFile, rename, unlink } from "node:fs/promises";
|
|
3
|
+
import { join, isAbsolute } from "node:path";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { SessionError } from "./types.js";
|
|
6
|
+
var SessionJournal = class {
|
|
7
|
+
constructor(directory) {
|
|
8
|
+
this.directory = directory;
|
|
9
|
+
if (!isAbsolute(directory))
|
|
10
|
+
throw new SessionError(
|
|
11
|
+
"invalid_directory",
|
|
12
|
+
"History directory must be absolute"
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
directory;
|
|
16
|
+
writes = /* @__PURE__ */ new Map();
|
|
17
|
+
path(id) {
|
|
18
|
+
if (!z.uuid().safeParse(id).success)
|
|
19
|
+
throw new SessionError("not_found", "Session not found");
|
|
20
|
+
return join(this.directory, `${id}.json`);
|
|
21
|
+
}
|
|
22
|
+
async load(id) {
|
|
23
|
+
try {
|
|
24
|
+
const history = JSON.parse(
|
|
25
|
+
await readFile(this.path(id), "utf8")
|
|
26
|
+
);
|
|
27
|
+
if (history.version !== 1 || history.id !== id || !Array.isArray(history.cells) || !Array.isArray(history.events))
|
|
28
|
+
throw new Error("Invalid session history");
|
|
29
|
+
return history;
|
|
30
|
+
} catch (error) {
|
|
31
|
+
if (error.code === "ENOENT")
|
|
32
|
+
throw new SessionError("not_found", "Session not found");
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
save(history) {
|
|
37
|
+
const path = this.path(history.id);
|
|
38
|
+
const existing = this.writes.get(history.id);
|
|
39
|
+
if (existing?.accepting) {
|
|
40
|
+
existing.history = history;
|
|
41
|
+
existing.revision++;
|
|
42
|
+
return existing.promise;
|
|
43
|
+
}
|
|
44
|
+
const write = {
|
|
45
|
+
history,
|
|
46
|
+
revision: 1,
|
|
47
|
+
accepting: true,
|
|
48
|
+
promise: Promise.resolve()
|
|
49
|
+
};
|
|
50
|
+
this.writes.set(history.id, write);
|
|
51
|
+
write.promise = (async () => {
|
|
52
|
+
await Promise.resolve();
|
|
53
|
+
while (true) {
|
|
54
|
+
const revision = write.revision;
|
|
55
|
+
await this.replace(path, JSON.stringify(write.history));
|
|
56
|
+
if (write.revision === revision) {
|
|
57
|
+
write.accepting = false;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
})().finally(() => {
|
|
62
|
+
write.accepting = false;
|
|
63
|
+
if (this.writes.get(history.id) === write) this.writes.delete(history.id);
|
|
64
|
+
});
|
|
65
|
+
return write.promise;
|
|
66
|
+
}
|
|
67
|
+
async replace(path, text) {
|
|
68
|
+
await mkdir(this.directory, { recursive: true, mode: 448 });
|
|
69
|
+
const temporary = `${path}.${crypto.randomUUID()}.tmp`;
|
|
70
|
+
try {
|
|
71
|
+
const file = await open(temporary, "wx", 384);
|
|
72
|
+
try {
|
|
73
|
+
await file.writeFile(text);
|
|
74
|
+
await file.sync();
|
|
75
|
+
} finally {
|
|
76
|
+
await file.close();
|
|
77
|
+
}
|
|
78
|
+
await rename(temporary, path);
|
|
79
|
+
} finally {
|
|
80
|
+
await unlink(temporary).catch(() => void 0);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
export {
|
|
85
|
+
SessionJournal
|
|
86
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// src/sessions/kernel.ts
|
|
2
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
|
+
import vm from "node:vm";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { traceString, traceText } from "../engine/sandbox/trace.js";
|
|
6
|
+
import { BINDINGS_GLOBAL, compileCell } from "./compiler.js";
|
|
7
|
+
import { SessionBindings } from "./scope.js";
|
|
8
|
+
import { errorText, jsonValue, traceData } from "./values.js";
|
|
9
|
+
var SessionKernel = class {
|
|
10
|
+
constructor(functions, hooks) {
|
|
11
|
+
this.functions = functions;
|
|
12
|
+
this.hooks = hooks;
|
|
13
|
+
const globals = /* @__PURE__ */ Object.create(null);
|
|
14
|
+
Object.defineProperty(globals, BINDINGS_GLOBAL, { value: this.bindings });
|
|
15
|
+
Object.defineProperty(globals, "actionParams", {
|
|
16
|
+
get: () => this.current().inputs
|
|
17
|
+
});
|
|
18
|
+
globals.z = z;
|
|
19
|
+
globals.defineParams = (schema) => schema.parse(this.current().inputs);
|
|
20
|
+
globals.console = Object.freeze(
|
|
21
|
+
Object.fromEntries(
|
|
22
|
+
["log", "info", "warn", "error", "debug"].map((level) => [
|
|
23
|
+
level,
|
|
24
|
+
(...values) => {
|
|
25
|
+
const current = this.invocation.getStore();
|
|
26
|
+
if (!current?.active) return;
|
|
27
|
+
this.hooks.emit(current.id, "execution.log", {
|
|
28
|
+
level,
|
|
29
|
+
message: traceString(
|
|
30
|
+
values.slice(0, 32).map(traceText).join(" ")
|
|
31
|
+
)
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
])
|
|
35
|
+
)
|
|
36
|
+
);
|
|
37
|
+
for (const name of functions) {
|
|
38
|
+
const parts = name.split(".");
|
|
39
|
+
if (parts.length === 1)
|
|
40
|
+
globals[name] = (...args) => this.call(name, args);
|
|
41
|
+
else {
|
|
42
|
+
const namespace = globals[parts[0]] ??= /* @__PURE__ */ Object.create(null);
|
|
43
|
+
namespace[parts[1]] = (...args) => this.call(name, args);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
for (const name of functions.filter((name2) => name2.includes(".")).map((name2) => name2.split(".")[0]))
|
|
47
|
+
Object.freeze(globals[name]);
|
|
48
|
+
this.context = vm.createContext(globals, {
|
|
49
|
+
codeGeneration: { strings: false, wasm: false }
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
functions;
|
|
53
|
+
hooks;
|
|
54
|
+
bindings = new SessionBindings();
|
|
55
|
+
context;
|
|
56
|
+
invocation = new AsyncLocalStorage();
|
|
57
|
+
sources = [];
|
|
58
|
+
executing = false;
|
|
59
|
+
current() {
|
|
60
|
+
const current = this.invocation.getStore();
|
|
61
|
+
if (!current?.active) throw new Error("No active cell authority");
|
|
62
|
+
return current;
|
|
63
|
+
}
|
|
64
|
+
call(name, args) {
|
|
65
|
+
const current = this.current();
|
|
66
|
+
const started = Date.now();
|
|
67
|
+
const pending = (async () => {
|
|
68
|
+
try {
|
|
69
|
+
const result = await this.hooks.call(
|
|
70
|
+
current.id,
|
|
71
|
+
name,
|
|
72
|
+
jsonValue(args)
|
|
73
|
+
);
|
|
74
|
+
if (!current.active) throw new Error("Cell authority expired");
|
|
75
|
+
this.hooks.emit(current.id, "execution.step", {
|
|
76
|
+
step: ++current.steps,
|
|
77
|
+
name,
|
|
78
|
+
args: traceData(args),
|
|
79
|
+
result: traceData(result),
|
|
80
|
+
durationMs: Date.now() - started
|
|
81
|
+
});
|
|
82
|
+
return result;
|
|
83
|
+
} catch (error) {
|
|
84
|
+
if (current.active)
|
|
85
|
+
this.hooks.emit(current.id, "execution.step", {
|
|
86
|
+
step: ++current.steps,
|
|
87
|
+
name,
|
|
88
|
+
args: traceData(args),
|
|
89
|
+
error: errorText(error),
|
|
90
|
+
durationMs: Date.now() - started
|
|
91
|
+
});
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
})();
|
|
95
|
+
current.pending.add(pending);
|
|
96
|
+
void pending.then(
|
|
97
|
+
() => current.pending.delete(pending),
|
|
98
|
+
() => current.pending.delete(pending)
|
|
99
|
+
);
|
|
100
|
+
return pending;
|
|
101
|
+
}
|
|
102
|
+
async execute(id, source, inputs) {
|
|
103
|
+
if (this.executing) throw new Error("A cell is already executing");
|
|
104
|
+
this.executing = true;
|
|
105
|
+
let current;
|
|
106
|
+
try {
|
|
107
|
+
const compiled = compileCell(this.sources, source, this.functions);
|
|
108
|
+
if (compiled.diagnostics.length)
|
|
109
|
+
return {
|
|
110
|
+
status: "rejected",
|
|
111
|
+
diagnostics: compiled.diagnostics,
|
|
112
|
+
error: compiled.diagnostics[0].message
|
|
113
|
+
};
|
|
114
|
+
this.bindings.declare(compiled.definitions);
|
|
115
|
+
this.sources.push(source);
|
|
116
|
+
current = { id, inputs, active: true, pending: /* @__PURE__ */ new Set(), steps: 0 };
|
|
117
|
+
const invocation = current;
|
|
118
|
+
return await this.invocation.run(invocation, async () => {
|
|
119
|
+
try {
|
|
120
|
+
const result = await vm.runInContext(
|
|
121
|
+
compiled.javascript,
|
|
122
|
+
this.context,
|
|
123
|
+
{ filename: `cell-${id}.js` }
|
|
124
|
+
);
|
|
125
|
+
while (invocation.pending.size)
|
|
126
|
+
await Promise.allSettled([...invocation.pending]);
|
|
127
|
+
return { status: "succeeded", result: jsonValue(result) };
|
|
128
|
+
} catch (error) {
|
|
129
|
+
while (invocation.pending.size)
|
|
130
|
+
await Promise.allSettled([...invocation.pending]);
|
|
131
|
+
return { status: "failed", error: errorText(error) };
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
} finally {
|
|
135
|
+
if (current) current.active = false;
|
|
136
|
+
this.executing = false;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
export {
|
|
141
|
+
SessionKernel
|
|
142
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// src/sessions/manager.ts
|
|
2
|
+
import { prepareCell } from "./cell-request.js";
|
|
3
|
+
import {
|
|
4
|
+
sessionLimits,
|
|
5
|
+
validateOpen,
|
|
6
|
+
validateReset
|
|
7
|
+
} from "./configuration.js";
|
|
8
|
+
import { SessionEvents } from "./events.js";
|
|
9
|
+
import { executeCell } from "./execute-cell.js";
|
|
10
|
+
import { FunctionBroker } from "./function-broker.js";
|
|
11
|
+
import { SessionJournal } from "./journal.js";
|
|
12
|
+
import { newHistory, recoverHistory } from "./records.js";
|
|
13
|
+
import { SessionRedactor } from "./redaction.js";
|
|
14
|
+
import { SessionRuntime } from "./session-runtime.js";
|
|
15
|
+
import {
|
|
16
|
+
SessionError
|
|
17
|
+
} from "./types.js";
|
|
18
|
+
var projectKey = (scope) => JSON.stringify([scope.workspaceId, scope.projectId]);
|
|
19
|
+
var sameOwner = (a, b) => a.workspaceId === b.workspaceId && a.projectId === b.projectId && a.ownerId === b.ownerId;
|
|
20
|
+
var SessionManager = class {
|
|
21
|
+
constructor(options) {
|
|
22
|
+
this.options = options;
|
|
23
|
+
this.journal = new SessionJournal(options.historyDirectory);
|
|
24
|
+
this.limits = sessionLimits(options);
|
|
25
|
+
this.broker = new FunctionBroker(options.functions);
|
|
26
|
+
}
|
|
27
|
+
options;
|
|
28
|
+
journal;
|
|
29
|
+
broker;
|
|
30
|
+
limits;
|
|
31
|
+
sessions = /* @__PURE__ */ new Map();
|
|
32
|
+
projects = /* @__PURE__ */ new Map();
|
|
33
|
+
runtime(history, directory, events, functions) {
|
|
34
|
+
events ??= new SessionEvents(
|
|
35
|
+
history,
|
|
36
|
+
this.limits,
|
|
37
|
+
new SessionRedactor(this.options.redact)
|
|
38
|
+
);
|
|
39
|
+
return new SessionRuntime(events, directory, {
|
|
40
|
+
journal: this.journal,
|
|
41
|
+
broker: functions ? new FunctionBroker([...this.options.functions ?? [], ...functions]) : this.broker,
|
|
42
|
+
limits: this.limits,
|
|
43
|
+
options: this.options,
|
|
44
|
+
release: (session) => {
|
|
45
|
+
if (this.sessions.get(history.id) !== session) return;
|
|
46
|
+
this.projects.delete(projectKey(history.scope));
|
|
47
|
+
this.sessions.delete(history.id);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
assertAvailable(scope, currentId) {
|
|
52
|
+
const resident = this.projects.get(projectKey(scope));
|
|
53
|
+
if (resident && resident !== currentId)
|
|
54
|
+
throw new SessionError(
|
|
55
|
+
"project_busy",
|
|
56
|
+
"This project already has a discovery session"
|
|
57
|
+
);
|
|
58
|
+
if (!resident && this.projects.size >= this.limits.maxSessions)
|
|
59
|
+
throw new SessionError("capacity", "Session residency limit reached");
|
|
60
|
+
}
|
|
61
|
+
reserve(session) {
|
|
62
|
+
this.assertAvailable(session.history.scope);
|
|
63
|
+
this.projects.set(projectKey(session.history.scope), session.history.id);
|
|
64
|
+
this.sessions.set(session.history.id, session);
|
|
65
|
+
}
|
|
66
|
+
async open(request) {
|
|
67
|
+
validateOpen(request, this.journal.directory);
|
|
68
|
+
const scope = {
|
|
69
|
+
workspaceId: request.workspaceId,
|
|
70
|
+
projectId: request.projectId,
|
|
71
|
+
ownerId: request.ownerId
|
|
72
|
+
};
|
|
73
|
+
const session = this.runtime(
|
|
74
|
+
newHistory(scope, request.configurationRevision),
|
|
75
|
+
request.workspaceDirectory,
|
|
76
|
+
void 0,
|
|
77
|
+
request.functions
|
|
78
|
+
);
|
|
79
|
+
this.reserve(session);
|
|
80
|
+
await session.start("session.opened");
|
|
81
|
+
return structuredClone(session.history);
|
|
82
|
+
}
|
|
83
|
+
async resolve(id, scope) {
|
|
84
|
+
const resident = this.sessions.get(id);
|
|
85
|
+
const history = resident?.history ?? await this.journal.load(id);
|
|
86
|
+
if (!sameOwner(history.scope, scope))
|
|
87
|
+
throw new SessionError("not_found", "Session not found");
|
|
88
|
+
if (resident) return resident;
|
|
89
|
+
const archived = this.runtime(history, "");
|
|
90
|
+
if (recoverHistory(archived.events)) await archived.save();
|
|
91
|
+
return archived;
|
|
92
|
+
}
|
|
93
|
+
async inspect(id, scope) {
|
|
94
|
+
const session = await this.resolve(id, scope);
|
|
95
|
+
if (session.finishing) await session.finishing;
|
|
96
|
+
return structuredClone(session.history);
|
|
97
|
+
}
|
|
98
|
+
async readEvents(id, scope, query = {}) {
|
|
99
|
+
return (await this.resolve(id, scope)).events.page(query);
|
|
100
|
+
}
|
|
101
|
+
async execute(id, scope, request) {
|
|
102
|
+
const session = await this.resolve(id, scope);
|
|
103
|
+
const prepared = prepareCell(request);
|
|
104
|
+
return session.enqueueCell(
|
|
105
|
+
() => executeCell(session, prepared, this.limits)
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
async close(id, scope, reason = "Session deliberately closed") {
|
|
109
|
+
const session = await this.resolve(id, scope);
|
|
110
|
+
await session.finish("closed", reason.slice(0, 4096));
|
|
111
|
+
return structuredClone(session.history);
|
|
112
|
+
}
|
|
113
|
+
async invalidate(id, scope, reason) {
|
|
114
|
+
const session = await this.resolve(id, scope);
|
|
115
|
+
await session.finish("lost", reason.slice(0, 4096));
|
|
116
|
+
return structuredClone(session.history);
|
|
117
|
+
}
|
|
118
|
+
async reset(id, scope, request) {
|
|
119
|
+
const previous = await this.resolve(id, scope);
|
|
120
|
+
validateReset(request, previous.history.generation, this.journal.directory);
|
|
121
|
+
this.assertAvailable(scope, id);
|
|
122
|
+
if (previous.history.generation >= 128)
|
|
123
|
+
throw new SessionError(
|
|
124
|
+
"history_limit",
|
|
125
|
+
"Session generation limit reached"
|
|
126
|
+
);
|
|
127
|
+
await previous.finish("closed", "Session deliberately reset");
|
|
128
|
+
await previous.drainCells();
|
|
129
|
+
this.assertAvailable(scope);
|
|
130
|
+
const history = previous.history;
|
|
131
|
+
history.generation++;
|
|
132
|
+
history.configurationRevision = request.configurationRevision;
|
|
133
|
+
history.status = "idle";
|
|
134
|
+
delete history.closedAt;
|
|
135
|
+
delete history.reason;
|
|
136
|
+
const next = this.runtime(
|
|
137
|
+
history,
|
|
138
|
+
request.workspaceDirectory,
|
|
139
|
+
previous.events
|
|
140
|
+
);
|
|
141
|
+
this.reserve(next);
|
|
142
|
+
await next.start("session.reset");
|
|
143
|
+
return structuredClone(history);
|
|
144
|
+
}
|
|
145
|
+
async dispose() {
|
|
146
|
+
await Promise.all(
|
|
147
|
+
[...this.sessions.values()].map(
|
|
148
|
+
(session) => session.finish("closed", "Session manager shut down")
|
|
149
|
+
)
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
export {
|
|
154
|
+
SessionManager
|
|
155
|
+
};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// src/sessions/process.ts
|
|
2
|
+
import {
|
|
3
|
+
spawnProcess,
|
|
4
|
+
stopHostProcess,
|
|
5
|
+
workerCommand
|
|
6
|
+
} from "../process-runtime.js";
|
|
7
|
+
import { isAbsolute } from "node:path";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { errorText, jsonValue } from "./values.js";
|
|
10
|
+
import { SessionError } from "./types.js";
|
|
11
|
+
function sessionCommand(options) {
|
|
12
|
+
if (options.mode === "host")
|
|
13
|
+
return workerCommand(import.meta.url, "./worker-guard");
|
|
14
|
+
for (const path of [
|
|
15
|
+
options.workspaceDirectory,
|
|
16
|
+
options.sourceDirectory
|
|
17
|
+
].filter((path2) => path2 !== void 0))
|
|
18
|
+
if (!isAbsolute(path) || /[,\r\n]/.test(path))
|
|
19
|
+
throw new Error(
|
|
20
|
+
"Session mount paths must be absolute without commas or newlines"
|
|
21
|
+
);
|
|
22
|
+
return [
|
|
23
|
+
"docker",
|
|
24
|
+
"run",
|
|
25
|
+
"--rm",
|
|
26
|
+
"-i",
|
|
27
|
+
"--name",
|
|
28
|
+
`orgsdk-session-${options.id}-${options.generation}`,
|
|
29
|
+
"--network=none",
|
|
30
|
+
"--read-only",
|
|
31
|
+
"--tmpfs",
|
|
32
|
+
"/tmp:rw,noexec,nosuid,size=128m",
|
|
33
|
+
"--cap-drop=ALL",
|
|
34
|
+
"--security-opt=no-new-privileges",
|
|
35
|
+
"--pids-limit=128",
|
|
36
|
+
"--memory=512m",
|
|
37
|
+
"--cpus=1",
|
|
38
|
+
"--user",
|
|
39
|
+
`${process.getuid?.() || 1e3}:${process.getgid?.() || 1e3}`,
|
|
40
|
+
"--mount",
|
|
41
|
+
options.workspaceVolume ? `type=volume,src=${options.workspaceVolume.name},dst=/project/workspace,volume-subpath=${options.workspaceVolume.subpath}` : `type=bind,src=${options.workspaceDirectory},dst=/project/workspace`,
|
|
42
|
+
...options.sourceDirectory ? [
|
|
43
|
+
"--mount",
|
|
44
|
+
`type=bind,src=${options.sourceDirectory},dst=/executor/src,readonly`
|
|
45
|
+
] : [],
|
|
46
|
+
"--workdir",
|
|
47
|
+
"/project/workspace",
|
|
48
|
+
"--entrypoint",
|
|
49
|
+
"bun",
|
|
50
|
+
options.image ?? process.env.EXECUTOR_IMAGE ?? "orgsdk-job:dev",
|
|
51
|
+
"--no-env-file",
|
|
52
|
+
"/executor/src/sessions/worker-guard.ts"
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
var messageSchema = z.discriminatedUnion("type", [
|
|
56
|
+
z.object({
|
|
57
|
+
type: z.literal("result"),
|
|
58
|
+
requestId: z.string(),
|
|
59
|
+
value: z.unknown().optional(),
|
|
60
|
+
error: z.string().optional()
|
|
61
|
+
}),
|
|
62
|
+
z.object({
|
|
63
|
+
type: z.literal("event"),
|
|
64
|
+
cellId: z.string(),
|
|
65
|
+
kind: z.enum(["execution.log", "execution.step"]),
|
|
66
|
+
data: z.unknown()
|
|
67
|
+
}),
|
|
68
|
+
z.object({
|
|
69
|
+
type: z.literal("call"),
|
|
70
|
+
callId: z.string(),
|
|
71
|
+
cellId: z.string(),
|
|
72
|
+
name: z.string(),
|
|
73
|
+
args: z.array(z.unknown())
|
|
74
|
+
})
|
|
75
|
+
]);
|
|
76
|
+
var SessionProcess = class {
|
|
77
|
+
constructor(options, hooks) {
|
|
78
|
+
this.options = options;
|
|
79
|
+
const child = spawnProcess(sessionCommand(options), {
|
|
80
|
+
cwd: options.workspaceDirectory,
|
|
81
|
+
detached: options.mode === "host" && process.platform !== "win32",
|
|
82
|
+
env: {
|
|
83
|
+
PATH: process.env.PATH ?? "",
|
|
84
|
+
HOME: options.mode === "host" ? options.workspaceDirectory : "/tmp"
|
|
85
|
+
},
|
|
86
|
+
stdout: "pipe",
|
|
87
|
+
stderr: "ignore"
|
|
88
|
+
});
|
|
89
|
+
this.child = child;
|
|
90
|
+
this.reading = (async () => {
|
|
91
|
+
let buffer = "";
|
|
92
|
+
const decoder = new TextDecoder();
|
|
93
|
+
for await (const chunk of child.stdout) {
|
|
94
|
+
buffer += decoder.decode(chunk, { stream: true });
|
|
95
|
+
if (Buffer.byteLength(buffer) > 1e6)
|
|
96
|
+
throw new Error("Session worker output exceeds limit");
|
|
97
|
+
let end;
|
|
98
|
+
while ((end = buffer.indexOf("\n")) >= 0) {
|
|
99
|
+
const message = messageSchema.parse(JSON.parse(buffer.slice(0, end)));
|
|
100
|
+
buffer = buffer.slice(end + 1);
|
|
101
|
+
if (message.type === "result") {
|
|
102
|
+
const pending = this.pending.get(message.requestId);
|
|
103
|
+
this.pending.delete(message.requestId);
|
|
104
|
+
if (message.error) pending?.reject(new Error(message.error));
|
|
105
|
+
else pending?.resolve(message.value);
|
|
106
|
+
} else if (message.type === "event")
|
|
107
|
+
hooks.event(message.cellId, message.kind, message.data);
|
|
108
|
+
else
|
|
109
|
+
void hooks.call(message.cellId, message.name, message.args).then((value) => jsonValue(value)).then(
|
|
110
|
+
(value) => this.send({
|
|
111
|
+
type: "toolResult",
|
|
112
|
+
callId: message.callId,
|
|
113
|
+
value
|
|
114
|
+
}),
|
|
115
|
+
(error) => this.send({
|
|
116
|
+
type: "toolResult",
|
|
117
|
+
callId: message.callId,
|
|
118
|
+
error: errorText(error)
|
|
119
|
+
})
|
|
120
|
+
).catch(() => void 0);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
})().catch(() => {
|
|
124
|
+
void this.stop().catch(() => void 0);
|
|
125
|
+
});
|
|
126
|
+
const finished = async (error) => {
|
|
127
|
+
this.failure = error instanceof Error ? error : new Error("Session worker exited");
|
|
128
|
+
await this.reading;
|
|
129
|
+
for (const pending of this.pending.values()) pending.reject(this.failure);
|
|
130
|
+
this.pending.clear();
|
|
131
|
+
hooks.exit();
|
|
132
|
+
};
|
|
133
|
+
void this.child.exited.then(() => finished(), finished).catch(() => void 0);
|
|
134
|
+
}
|
|
135
|
+
options;
|
|
136
|
+
child;
|
|
137
|
+
reading;
|
|
138
|
+
pending = /* @__PURE__ */ new Map();
|
|
139
|
+
stopped;
|
|
140
|
+
failure;
|
|
141
|
+
send(message) {
|
|
142
|
+
this.child.stdin.write(JSON.stringify(message) + "\n");
|
|
143
|
+
}
|
|
144
|
+
request(type, data) {
|
|
145
|
+
if (this.failure) return Promise.reject(this.failure);
|
|
146
|
+
return new Promise((resolve, reject) => {
|
|
147
|
+
const requestId = crypto.randomUUID();
|
|
148
|
+
this.pending.set(requestId, { resolve, reject });
|
|
149
|
+
try {
|
|
150
|
+
this.send({ ...data, type, requestId });
|
|
151
|
+
} catch (error) {
|
|
152
|
+
this.pending.delete(requestId);
|
|
153
|
+
reject(error);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
async initialize(functions, timeoutMs = 3e4) {
|
|
158
|
+
let timer;
|
|
159
|
+
try {
|
|
160
|
+
const identity = await Promise.race([
|
|
161
|
+
this.request("initialize", { functions }),
|
|
162
|
+
new Promise((_, reject) => {
|
|
163
|
+
timer = setTimeout(
|
|
164
|
+
() => reject(
|
|
165
|
+
new SessionError(
|
|
166
|
+
"startup_timeout",
|
|
167
|
+
"Session worker startup timed out"
|
|
168
|
+
)
|
|
169
|
+
),
|
|
170
|
+
timeoutMs
|
|
171
|
+
);
|
|
172
|
+
})
|
|
173
|
+
]);
|
|
174
|
+
return z.object({ pid: z.number().int(), hostname: z.string() }).parse(identity);
|
|
175
|
+
} finally {
|
|
176
|
+
clearTimeout(timer);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async execute(cellId, source, inputs) {
|
|
180
|
+
return await this.request("execute", {
|
|
181
|
+
cellId,
|
|
182
|
+
source,
|
|
183
|
+
inputs
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
stop() {
|
|
187
|
+
this.stopped ??= (async () => {
|
|
188
|
+
if (this.options.mode === "docker") {
|
|
189
|
+
await spawnProcess(
|
|
190
|
+
[
|
|
191
|
+
"docker",
|
|
192
|
+
"rm",
|
|
193
|
+
"-f",
|
|
194
|
+
`orgsdk-session-${this.options.id}-${this.options.generation}`
|
|
195
|
+
],
|
|
196
|
+
{ stdout: "ignore", stderr: "ignore" }
|
|
197
|
+
).exited.catch(() => void 0);
|
|
198
|
+
this.child.kill("SIGKILL");
|
|
199
|
+
} else stopHostProcess(this.child);
|
|
200
|
+
await this.child.exited.catch(() => void 0);
|
|
201
|
+
await this.reading;
|
|
202
|
+
})();
|
|
203
|
+
return this.stopped;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
export {
|
|
207
|
+
SessionProcess,
|
|
208
|
+
sessionCommand
|
|
209
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// src/sessions/records.ts
|
|
2
|
+
import { errorText } from "./values.js";
|
|
3
|
+
function isTerminal(status) {
|
|
4
|
+
return status === "closed" || status === "expired" || status === "lost";
|
|
5
|
+
}
|
|
6
|
+
function newHistory(scope, configurationRevision) {
|
|
7
|
+
return {
|
|
8
|
+
version: 1,
|
|
9
|
+
id: crypto.randomUUID(),
|
|
10
|
+
scope,
|
|
11
|
+
configurationRevision,
|
|
12
|
+
generation: 1,
|
|
13
|
+
status: "idle",
|
|
14
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
15
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
16
|
+
cells: [],
|
|
17
|
+
events: [],
|
|
18
|
+
cursor: 0,
|
|
19
|
+
outputTruncated: false
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function completeCell(cell, evaluation, events) {
|
|
23
|
+
cell.status = evaluation.status;
|
|
24
|
+
cell.result = events.redactor.redact(evaluation.result);
|
|
25
|
+
cell.error = evaluation.error ? errorText(events.redactor.redact(evaluation.error)) : void 0;
|
|
26
|
+
cell.diagnostics = events.redactor.redact(
|
|
27
|
+
evaluation.diagnostics
|
|
28
|
+
);
|
|
29
|
+
cell.finishedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
30
|
+
events.append(cell.id, `cell.${cell.status}`, {
|
|
31
|
+
result: cell.result,
|
|
32
|
+
error: cell.error,
|
|
33
|
+
diagnostics: cell.diagnostics
|
|
34
|
+
});
|
|
35
|
+
cell.endCursor = events.history.cursor;
|
|
36
|
+
}
|
|
37
|
+
function interruptCell(cell, reason, events) {
|
|
38
|
+
if (cell.status !== "running") return;
|
|
39
|
+
cell.status = "interrupted";
|
|
40
|
+
cell.error = reason;
|
|
41
|
+
cell.finishedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
42
|
+
events.append(cell.id, "cell.interrupted", { error: reason });
|
|
43
|
+
cell.endCursor = events.history.cursor;
|
|
44
|
+
}
|
|
45
|
+
function recoverHistory(events) {
|
|
46
|
+
const { history } = events;
|
|
47
|
+
if (isTerminal(history.status)) return false;
|
|
48
|
+
history.status = "lost";
|
|
49
|
+
history.reason = "Supervisor restarted; live memory is unavailable";
|
|
50
|
+
history.closedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
51
|
+
for (const cell of history.cells) interruptCell(cell, history.reason, events);
|
|
52
|
+
events.append(null, "session.lost", { reason: history.reason });
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
completeCell,
|
|
57
|
+
interruptCell,
|
|
58
|
+
isTerminal,
|
|
59
|
+
newHistory,
|
|
60
|
+
recoverHistory
|
|
61
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/sessions/redaction.ts
|
|
2
|
+
var SessionRedactor = class {
|
|
3
|
+
constructor(redactInstallationSecrets) {
|
|
4
|
+
this.redactInstallationSecrets = redactInstallationSecrets;
|
|
5
|
+
}
|
|
6
|
+
redactInstallationSecrets;
|
|
7
|
+
capabilities = /* @__PURE__ */ new Set();
|
|
8
|
+
remember(capability) {
|
|
9
|
+
if (capability) this.capabilities.add(capability);
|
|
10
|
+
}
|
|
11
|
+
text(input) {
|
|
12
|
+
for (const capability of this.capabilities)
|
|
13
|
+
input = input.replaceAll(capability, "[redacted]");
|
|
14
|
+
return input;
|
|
15
|
+
}
|
|
16
|
+
redact(value) {
|
|
17
|
+
if (value === void 0) return void 0;
|
|
18
|
+
const protectedValue = JSON.parse(
|
|
19
|
+
JSON.stringify(value, (_key, item) => {
|
|
20
|
+
if (typeof item === "string") return this.text(item);
|
|
21
|
+
if (item && typeof item === "object" && !Array.isArray(item))
|
|
22
|
+
return Object.fromEntries(
|
|
23
|
+
Object.entries(item).map(([key, entry]) => [this.text(key), entry])
|
|
24
|
+
);
|
|
25
|
+
return item;
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
return this.redactInstallationSecrets ? this.redactInstallationSecrets(protectedValue) : protectedValue;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
SessionRedactor
|
|
33
|
+
};
|