@orgsdk/cli 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +122 -0
- package/README.md +67 -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/runtime/LICENSE +122 -0
- package/dist/runtime/PROVENANCE.md +15 -0
- package/dist/runtime/README.md +112 -0
- package/dist/runtime/cli-options.js +41 -0
- package/dist/runtime/cli.js +81 -0
- package/dist/runtime/client.js +54 -0
- package/dist/runtime/contract.js +69 -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/generated/schema.d.ts +6443 -0
- package/dist/runtime/isolated-actions.js +189 -0
- package/dist/runtime/isolated-worker.js +227 -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/runner.js +233 -0
- package/dist/runtime/sdk-declarations.js +197 -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 +153 -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 +151 -0
- package/dist/runtime/sessions/types.js +12 -0
- package/dist/runtime/sessions/values.js +40 -0
- package/dist/runtime/sessions/worker.js +81 -0
- package/dist/runtime/supervisor.js +268 -0
- package/dist/runtime/validate-code.js +114 -0
- package/dist/runtime/worker.js +54 -0
- package/dist/server/bun-driver-JKOGHIVX.js +20 -0
- package/dist/server/chunk-WCVBLUNL.js +685 -0
- package/dist/server/index.js +8432 -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/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/_journal.json +27 -0
- package/dist/server/node-driver-FRDSYDBU.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/THIRD_PARTY_NOTICES.md +13 -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/F49bfPs3jKhcIuc95hqZh/_buildManifest.js +11 -0
- package/dist/server/out/_next/static/F49bfPs3jKhcIuc95hqZh/_clientMiddlewareManifest.js +1 -0
- package/dist/server/out/_next/static/F49bfPs3jKhcIuc95hqZh/_ssgManifest.js +1 -0
- package/dist/server/out/_next/static/chunks/016glzdsa3q5_.js +1 -0
- package/dist/server/out/_next/static/chunks/05i1qq0mw887k.js +1 -0
- package/dist/server/out/_next/static/chunks/06tt8wiyre1ez.js +1 -0
- package/dist/server/out/_next/static/chunks/0cm9i2msjsy--.js +1 -0
- package/dist/server/out/_next/static/chunks/0cz1d0mv5g_q7.js +1 -0
- package/dist/server/out/_next/static/chunks/0hq5dvj7fy64b.js +1 -0
- package/dist/server/out/_next/static/chunks/0ma4vl-fj0tmu.js +1 -0
- package/dist/server/out/_next/static/chunks/0noal-jqjivtf.js +1 -0
- package/dist/server/out/_next/static/chunks/0spckmsiek0gd.js +1 -0
- package/dist/server/out/_next/static/chunks/103sekujf0rxr.js +1 -0
- package/dist/server/out/_next/static/chunks/10h8kpcnjfe_v.js +1 -0
- package/dist/server/out/_next/static/chunks/16_aurf9162_6.js +1 -0
- package/dist/server/out/_next/static/chunks/1c48yx15nlt6w.js +1 -0
- package/dist/server/out/_next/static/chunks/1jp827_2p_wkf.js +1 -0
- package/dist/server/out/_next/static/chunks/1kdk-viqnjs3j.js +1 -0
- package/dist/server/out/_next/static/chunks/1mlfee105fhl7.js +1 -0
- package/dist/server/out/_next/static/chunks/1q9jpzm9b6zy9.js +1 -0
- package/dist/server/out/_next/static/chunks/1v0-a7pehktp9.js +22 -0
- package/dist/server/out/_next/static/chunks/24qxhh2dqvhaa.js +1 -0
- package/dist/server/out/_next/static/chunks/253gnn8ai3i89.js +1 -0
- package/dist/server/out/_next/static/chunks/27umf0z4povug.js +1 -0
- package/dist/server/out/_next/static/chunks/280w168xxgtwt.js +402 -0
- package/dist/server/out/_next/static/chunks/2a_c2xcjy62fq.css +1 -0
- package/dist/server/out/_next/static/chunks/2bbfbmv0vf3j0.js +1 -0
- package/dist/server/out/_next/static/chunks/2mvlvogrl6o0u.js +1 -0
- package/dist/server/out/_next/static/chunks/2xzrcwr9q6195.js +1 -0
- package/dist/server/out/_next/static/chunks/2yi6lq56xoijl.js +31 -0
- package/dist/server/out/_next/static/chunks/30g0jo299pr8e.js +1 -0
- package/dist/server/out/_next/static/chunks/36tf56rgybjz0.js +3 -0
- package/dist/server/out/_next/static/chunks/39dofrhzg_uju.js +1 -0
- package/dist/server/out/_next/static/chunks/3a8aanmz3kfof.js +1 -0
- package/dist/server/out/_next/static/chunks/3bd3k15tx3lj1.js +1 -0
- package/dist/server/out/_next/static/chunks/3d34pxerfr389.js +1 -0
- package/dist/server/out/_next/static/chunks/3dx108d0g6032.js +55 -0
- package/dist/server/out/_next/static/chunks/3elab9vgx7_ok.js +1 -0
- package/dist/server/out/_next/static/chunks/3gvae9c-5pi5z.js +1 -0
- package/dist/server/out/_next/static/chunks/3hzia782sc9pf.js +1 -0
- package/dist/server/out/_next/static/chunks/3jl4k-15i8847.js +1 -0
- package/dist/server/out/_next/static/chunks/3lb23el6qno6s.js +1 -0
- package/dist/server/out/_next/static/chunks/3prum3lr5470i.js +3 -0
- package/dist/server/out/_next/static/chunks/3prwkrciuqwjg.js +1 -0
- package/dist/server/out/_next/static/chunks/3txmqtuo5xgfd.js +3 -0
- package/dist/server/out/_next/static/chunks/3u7q5w03st-rs.js +1 -0
- package/dist/server/out/_next/static/chunks/turbopack-3-ry682tkyiqk.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/third-party-licenses/monaco-editor.txt +21 -0
- package/dist/server/out/third-party-licenses/zod.txt +21 -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/npm-distribution.md +76 -0
- package/package.json +79 -4
- package/runtime/LICENSE +122 -0
- package/runtime/README.md +112 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// src/sessions/execute-cell.ts
|
|
2
|
+
import {
|
|
3
|
+
existingCell,
|
|
4
|
+
newCell,
|
|
5
|
+
validateAppend
|
|
6
|
+
} from "./cell-request.js";
|
|
7
|
+
import { completeCell, isTerminal } from "./records.js";
|
|
8
|
+
import { errorText } from "./values.js";
|
|
9
|
+
import { SessionError } from "./types.js";
|
|
10
|
+
function reply(session, cell, request) {
|
|
11
|
+
return {
|
|
12
|
+
sessionId: session.history.id,
|
|
13
|
+
cell: structuredClone(cell),
|
|
14
|
+
...session.events.page({
|
|
15
|
+
after: request.after ?? cell.startCursor,
|
|
16
|
+
limit: request.limit
|
|
17
|
+
})
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
async function dispatchCell(session, cell) {
|
|
21
|
+
if (isTerminal(session.history.status)) return;
|
|
22
|
+
const evaluation = await session.worker.execute(
|
|
23
|
+
cell.id,
|
|
24
|
+
cell.source,
|
|
25
|
+
cell.inputs
|
|
26
|
+
);
|
|
27
|
+
if (isTerminal(session.history.status)) return;
|
|
28
|
+
completeCell(cell, evaluation, session.events);
|
|
29
|
+
session.history.status = "idle";
|
|
30
|
+
}
|
|
31
|
+
async function executeCell(session, request, limits) {
|
|
32
|
+
const { history, events } = session;
|
|
33
|
+
if (request.generation !== history.generation)
|
|
34
|
+
throw new SessionError(
|
|
35
|
+
"stale_generation",
|
|
36
|
+
"Session generation changed; inspect before submitting"
|
|
37
|
+
);
|
|
38
|
+
if (request.configurationRevision !== void 0 && request.configurationRevision !== history.configurationRevision) {
|
|
39
|
+
await session.finish("lost", "Session configuration changed");
|
|
40
|
+
throw new SessionError(
|
|
41
|
+
"configuration_changed",
|
|
42
|
+
"Open or reset a session for the current configuration"
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
const previous = existingCell(history, request);
|
|
46
|
+
if (previous) return reply(session, previous, request);
|
|
47
|
+
const timeoutMs = validateAppend(
|
|
48
|
+
history,
|
|
49
|
+
session.worker !== void 0,
|
|
50
|
+
request,
|
|
51
|
+
limits
|
|
52
|
+
);
|
|
53
|
+
events.page({ after: request.after, limit: request.limit });
|
|
54
|
+
request.signal?.throwIfAborted();
|
|
55
|
+
const cell = newCell(history, request);
|
|
56
|
+
session.beginCell(cell, request.capability);
|
|
57
|
+
const abort = () => {
|
|
58
|
+
void session.finish("lost", "Cell cancelled").catch(() => void 0);
|
|
59
|
+
};
|
|
60
|
+
const timer = setTimeout(() => {
|
|
61
|
+
void session.finish("expired", "Cell execution deadline exceeded").catch(() => void 0);
|
|
62
|
+
}, timeoutMs);
|
|
63
|
+
request.signal?.addEventListener("abort", abort, { once: true });
|
|
64
|
+
try {
|
|
65
|
+
await session.save();
|
|
66
|
+
if (request.signal?.aborted) abort();
|
|
67
|
+
await dispatchCell(session, cell);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (!isTerminal(history.status))
|
|
70
|
+
await session.finish("lost", errorText(error));
|
|
71
|
+
} finally {
|
|
72
|
+
clearTimeout(timer);
|
|
73
|
+
request.signal?.removeEventListener("abort", abort);
|
|
74
|
+
await session.releaseCell();
|
|
75
|
+
}
|
|
76
|
+
return reply(session, cell, request);
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
executeCell
|
|
80
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// src/sessions/function-broker.ts
|
|
2
|
+
import { projectFileFunctions } from "../project-files.js";
|
|
3
|
+
import {
|
|
4
|
+
RESERVED_NAMESPACE_IDENTIFIERS,
|
|
5
|
+
RESERVED_FUNCTION_KEYS
|
|
6
|
+
} from "../engine/plugins/namespace.js";
|
|
7
|
+
import { isTerminal } from "./records.js";
|
|
8
|
+
import { jsonValue } from "./values.js";
|
|
9
|
+
import {
|
|
10
|
+
SessionError
|
|
11
|
+
} from "./types.js";
|
|
12
|
+
var fileNames = ["readFile", "writeFile", "listFiles", "removeFile"];
|
|
13
|
+
function cellContext(history, active, cellId, generation) {
|
|
14
|
+
if (!active || active.record.id !== cellId || active.record.generation !== generation || active.controller.signal.aborted || isTerminal(history.status))
|
|
15
|
+
throw new SessionError("no_authority", "No active cell authority");
|
|
16
|
+
return {
|
|
17
|
+
...history.scope,
|
|
18
|
+
sessionId: history.id,
|
|
19
|
+
cellId,
|
|
20
|
+
generation,
|
|
21
|
+
inputs: structuredClone(active.record.inputs),
|
|
22
|
+
capability: active.capability,
|
|
23
|
+
signal: active.controller.signal
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
var FunctionBroker = class {
|
|
27
|
+
functions = /* @__PURE__ */ new Map();
|
|
28
|
+
constructor(functions = []) {
|
|
29
|
+
const roots = /* @__PURE__ */ new Map();
|
|
30
|
+
for (const fn of functions) {
|
|
31
|
+
const parts = fn.name.split(".");
|
|
32
|
+
const [root, member] = parts;
|
|
33
|
+
const invalid = parts.length > 2 || parts.some(
|
|
34
|
+
(part) => !/^[a-z][a-zA-Z0-9]*$/.test(part) || RESERVED_FUNCTION_KEYS.has(part)
|
|
35
|
+
);
|
|
36
|
+
if (invalid || RESERVED_NAMESPACE_IDENTIFIERS.has(root) || fileNames.includes(root) || this.functions.has(fn.name))
|
|
37
|
+
throw new SessionError(
|
|
38
|
+
"invalid_function",
|
|
39
|
+
`Invalid or reserved session function '${fn.name}'`
|
|
40
|
+
);
|
|
41
|
+
const kind = member ? "namespace" : "flat";
|
|
42
|
+
if (roots.has(root) && roots.get(root) !== kind)
|
|
43
|
+
throw new SessionError(
|
|
44
|
+
"invalid_function",
|
|
45
|
+
"Function and namespace names overlap"
|
|
46
|
+
);
|
|
47
|
+
roots.set(root, kind);
|
|
48
|
+
this.functions.set(fn.name, fn);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
names() {
|
|
52
|
+
return [...fileNames, ...this.functions.keys()];
|
|
53
|
+
}
|
|
54
|
+
async call(context, workspaceDirectory, name, args) {
|
|
55
|
+
let value;
|
|
56
|
+
if (fileNames.includes(name)) {
|
|
57
|
+
const functions = projectFileFunctions(
|
|
58
|
+
workspaceDirectory,
|
|
59
|
+
context.signal
|
|
60
|
+
);
|
|
61
|
+
value = await functions.find((fn) => fn.name === name).handler(...args);
|
|
62
|
+
} else {
|
|
63
|
+
const fn = this.functions.get(name);
|
|
64
|
+
if (!fn)
|
|
65
|
+
throw new SessionError(
|
|
66
|
+
"unknown_function",
|
|
67
|
+
"Function is outside this session configuration"
|
|
68
|
+
);
|
|
69
|
+
value = await fn.handler(args, context);
|
|
70
|
+
}
|
|
71
|
+
context.signal.throwIfAborted();
|
|
72
|
+
return jsonValue(value);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
export {
|
|
76
|
+
FunctionBroker,
|
|
77
|
+
cellContext
|
|
78
|
+
};
|
|
@@ -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,153 @@
|
|
|
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) {
|
|
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: 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
|
+
);
|
|
77
|
+
this.reserve(session);
|
|
78
|
+
await session.start("session.opened");
|
|
79
|
+
return structuredClone(session.history);
|
|
80
|
+
}
|
|
81
|
+
async resolve(id, scope) {
|
|
82
|
+
const resident = this.sessions.get(id);
|
|
83
|
+
const history = resident?.history ?? await this.journal.load(id);
|
|
84
|
+
if (!sameOwner(history.scope, scope))
|
|
85
|
+
throw new SessionError("not_found", "Session not found");
|
|
86
|
+
if (resident) return resident;
|
|
87
|
+
const archived = this.runtime(history, "");
|
|
88
|
+
if (recoverHistory(archived.events)) await archived.save();
|
|
89
|
+
return archived;
|
|
90
|
+
}
|
|
91
|
+
async inspect(id, scope) {
|
|
92
|
+
const session = await this.resolve(id, scope);
|
|
93
|
+
if (session.finishing) await session.finishing;
|
|
94
|
+
return structuredClone(session.history);
|
|
95
|
+
}
|
|
96
|
+
async readEvents(id, scope, query = {}) {
|
|
97
|
+
return (await this.resolve(id, scope)).events.page(query);
|
|
98
|
+
}
|
|
99
|
+
async execute(id, scope, request) {
|
|
100
|
+
const session = await this.resolve(id, scope);
|
|
101
|
+
const prepared = prepareCell(request);
|
|
102
|
+
return session.enqueueCell(
|
|
103
|
+
() => executeCell(session, prepared, this.limits)
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
async close(id, scope, reason = "Session deliberately closed") {
|
|
107
|
+
const session = await this.resolve(id, scope);
|
|
108
|
+
await session.finish("closed", reason.slice(0, 4096));
|
|
109
|
+
return structuredClone(session.history);
|
|
110
|
+
}
|
|
111
|
+
async invalidate(id, scope, reason) {
|
|
112
|
+
const session = await this.resolve(id, scope);
|
|
113
|
+
await session.finish("lost", reason.slice(0, 4096));
|
|
114
|
+
return structuredClone(session.history);
|
|
115
|
+
}
|
|
116
|
+
async reset(id, scope, request) {
|
|
117
|
+
const previous = await this.resolve(id, scope);
|
|
118
|
+
validateReset(request, previous.history.generation, this.journal.directory);
|
|
119
|
+
this.assertAvailable(scope, id);
|
|
120
|
+
if (previous.history.generation >= 128)
|
|
121
|
+
throw new SessionError(
|
|
122
|
+
"history_limit",
|
|
123
|
+
"Session generation limit reached"
|
|
124
|
+
);
|
|
125
|
+
await previous.finish("closed", "Session deliberately reset");
|
|
126
|
+
await previous.drainCells();
|
|
127
|
+
this.assertAvailable(scope);
|
|
128
|
+
const history = previous.history;
|
|
129
|
+
history.generation++;
|
|
130
|
+
history.configurationRevision = request.configurationRevision;
|
|
131
|
+
history.status = "idle";
|
|
132
|
+
delete history.closedAt;
|
|
133
|
+
delete history.reason;
|
|
134
|
+
const next = this.runtime(
|
|
135
|
+
history,
|
|
136
|
+
request.workspaceDirectory,
|
|
137
|
+
previous.events
|
|
138
|
+
);
|
|
139
|
+
this.reserve(next);
|
|
140
|
+
await next.start("session.reset");
|
|
141
|
+
return structuredClone(history);
|
|
142
|
+
}
|
|
143
|
+
async dispose() {
|
|
144
|
+
await Promise.all(
|
|
145
|
+
[...this.sessions.values()].map(
|
|
146
|
+
(session) => session.finish("closed", "Session manager shut down")
|
|
147
|
+
)
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
export {
|
|
152
|
+
SessionManager
|
|
153
|
+
};
|