@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,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");
|
|
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
|
+
`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.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
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// src/sessions/scope.ts
|
|
2
|
+
var SessionBindings = class {
|
|
3
|
+
values = /* @__PURE__ */ Object.create(null);
|
|
4
|
+
initializers = /* @__PURE__ */ Object.create(null);
|
|
5
|
+
bindings = /* @__PURE__ */ new Map();
|
|
6
|
+
declare(definitions) {
|
|
7
|
+
for (const { name, kind } of definitions) {
|
|
8
|
+
if (this.bindings.has(name)) continue;
|
|
9
|
+
const binding = {
|
|
10
|
+
kind,
|
|
11
|
+
initialized: kind === "var",
|
|
12
|
+
value: void 0
|
|
13
|
+
};
|
|
14
|
+
this.bindings.set(name, binding);
|
|
15
|
+
Object.defineProperty(this.values, name, {
|
|
16
|
+
get() {
|
|
17
|
+
if (!binding.initialized)
|
|
18
|
+
throw new ReferenceError(
|
|
19
|
+
`Cannot access '${name}' before initialization`
|
|
20
|
+
);
|
|
21
|
+
return binding.value;
|
|
22
|
+
},
|
|
23
|
+
set(value) {
|
|
24
|
+
if (!binding.initialized)
|
|
25
|
+
throw new ReferenceError(
|
|
26
|
+
`Cannot access '${name}' before initialization`
|
|
27
|
+
);
|
|
28
|
+
if (binding.kind === "const")
|
|
29
|
+
throw new TypeError(`Assignment to constant variable '${name}'`);
|
|
30
|
+
binding.value = value;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(this.initializers, name, {
|
|
34
|
+
set(value) {
|
|
35
|
+
if (binding.initialized && binding.kind === "const")
|
|
36
|
+
throw new TypeError(`Duplicate initialization of '${name}'`);
|
|
37
|
+
binding.value = value;
|
|
38
|
+
binding.initialized = true;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
SessionBindings
|
|
46
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// src/sessions/session-runtime.ts
|
|
2
|
+
import { mkdir } from "node:fs/promises";
|
|
3
|
+
import {
|
|
4
|
+
cellContext
|
|
5
|
+
} from "./function-broker.js";
|
|
6
|
+
import { SessionProcess } from "./process.js";
|
|
7
|
+
import { interruptCell, isTerminal } from "./records.js";
|
|
8
|
+
import { errorText } from "./values.js";
|
|
9
|
+
var SessionRuntime = class {
|
|
10
|
+
constructor(events, workspaceDirectory, services) {
|
|
11
|
+
this.events = events;
|
|
12
|
+
this.workspaceDirectory = workspaceDirectory;
|
|
13
|
+
this.services = services;
|
|
14
|
+
}
|
|
15
|
+
events;
|
|
16
|
+
workspaceDirectory;
|
|
17
|
+
services;
|
|
18
|
+
worker;
|
|
19
|
+
active;
|
|
20
|
+
finishing;
|
|
21
|
+
idle;
|
|
22
|
+
cells = Promise.resolve();
|
|
23
|
+
get history() {
|
|
24
|
+
return this.events.history;
|
|
25
|
+
}
|
|
26
|
+
save() {
|
|
27
|
+
return this.services.journal.save(this.history);
|
|
28
|
+
}
|
|
29
|
+
enqueueCell(work) {
|
|
30
|
+
const pending = this.cells.then(work);
|
|
31
|
+
this.cells = pending.catch(() => void 0);
|
|
32
|
+
return pending;
|
|
33
|
+
}
|
|
34
|
+
async drainCells() {
|
|
35
|
+
await this.cells;
|
|
36
|
+
}
|
|
37
|
+
async start(event) {
|
|
38
|
+
const { options, limits, broker } = this.services;
|
|
39
|
+
const { history } = this;
|
|
40
|
+
try {
|
|
41
|
+
await mkdir(this.workspaceDirectory, { recursive: true, mode: 448 });
|
|
42
|
+
await this.save();
|
|
43
|
+
this.worker = new SessionProcess(
|
|
44
|
+
{
|
|
45
|
+
id: history.id,
|
|
46
|
+
generation: history.generation,
|
|
47
|
+
mode: options.mode ?? "docker",
|
|
48
|
+
workspaceDirectory: this.workspaceDirectory,
|
|
49
|
+
image: options.image,
|
|
50
|
+
sourceDirectory: options.sourceDirectory
|
|
51
|
+
},
|
|
52
|
+
this.workerHooks()
|
|
53
|
+
);
|
|
54
|
+
const identity = await this.worker.initialize(
|
|
55
|
+
broker.names(),
|
|
56
|
+
limits.startTimeoutMs
|
|
57
|
+
);
|
|
58
|
+
history.worker = { ...identity, mode: options.mode ?? "docker" };
|
|
59
|
+
this.events.append(null, event, { worker: history.worker });
|
|
60
|
+
await this.save();
|
|
61
|
+
this.armIdle();
|
|
62
|
+
} catch (error) {
|
|
63
|
+
const message = errorText(error);
|
|
64
|
+
await this.finish(
|
|
65
|
+
"lost",
|
|
66
|
+
event === "session.opened" ? `Session startup failed: ${message}` : message
|
|
67
|
+
);
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
workerHooks() {
|
|
72
|
+
const generation = this.history.generation;
|
|
73
|
+
return {
|
|
74
|
+
event: (cellId, kind, data) => {
|
|
75
|
+
if (this.history.generation !== generation || this.active?.record.id !== cellId)
|
|
76
|
+
return;
|
|
77
|
+
if (!this.events.append(cellId, kind, data, true)) return;
|
|
78
|
+
void this.save().catch(() => this.finish("lost", "Session history storage failed")).catch(() => void 0);
|
|
79
|
+
},
|
|
80
|
+
call: async (cellId, name, args) => {
|
|
81
|
+
const context = cellContext(
|
|
82
|
+
this.history,
|
|
83
|
+
this.active,
|
|
84
|
+
cellId,
|
|
85
|
+
generation
|
|
86
|
+
);
|
|
87
|
+
return this.services.broker.call(
|
|
88
|
+
context,
|
|
89
|
+
this.workspaceDirectory,
|
|
90
|
+
name,
|
|
91
|
+
args
|
|
92
|
+
);
|
|
93
|
+
},
|
|
94
|
+
exit: () => {
|
|
95
|
+
if (this.history.generation === generation && !isTerminal(this.history.status))
|
|
96
|
+
void this.finish("lost", "Session worker exited").catch(
|
|
97
|
+
() => void 0
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
beginCell(record, capability) {
|
|
103
|
+
clearTimeout(this.idle);
|
|
104
|
+
this.history.cells.push(record);
|
|
105
|
+
this.history.status = "executing";
|
|
106
|
+
this.active = { record, controller: new AbortController(), capability };
|
|
107
|
+
this.events.redactor.remember(capability);
|
|
108
|
+
this.events.append(record.id, "cell.started", {
|
|
109
|
+
sequence: record.sequence
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
async releaseCell() {
|
|
113
|
+
if (this.finishing) await this.finishing;
|
|
114
|
+
this.active?.controller.abort();
|
|
115
|
+
this.active = void 0;
|
|
116
|
+
await this.save();
|
|
117
|
+
this.armIdle();
|
|
118
|
+
}
|
|
119
|
+
armIdle() {
|
|
120
|
+
clearTimeout(this.idle);
|
|
121
|
+
if (isTerminal(this.history.status)) return;
|
|
122
|
+
this.idle = setTimeout(() => {
|
|
123
|
+
void this.finish("expired", "Session idle timeout").catch(
|
|
124
|
+
() => void 0
|
|
125
|
+
);
|
|
126
|
+
}, this.services.limits.idleTimeoutMs);
|
|
127
|
+
this.idle.unref();
|
|
128
|
+
}
|
|
129
|
+
finish(status, reason) {
|
|
130
|
+
if (this.finishing) return this.finishing;
|
|
131
|
+
if (isTerminal(this.history.status)) return Promise.resolve();
|
|
132
|
+
this.history.status = status;
|
|
133
|
+
reason = errorText(this.events.redactor.redact(reason));
|
|
134
|
+
this.history.reason = reason;
|
|
135
|
+
clearTimeout(this.idle);
|
|
136
|
+
this.active?.controller.abort();
|
|
137
|
+
this.finishing = (async () => {
|
|
138
|
+
await this.worker?.stop();
|
|
139
|
+
this.worker = void 0;
|
|
140
|
+
if (this.active) interruptCell(this.active.record, reason, this.events);
|
|
141
|
+
this.history.closedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
142
|
+
this.events.append(null, `session.${status}`, { reason });
|
|
143
|
+
await this.save();
|
|
144
|
+
this.services.release(this);
|
|
145
|
+
})();
|
|
146
|
+
return this.finishing;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
export {
|
|
150
|
+
SessionRuntime
|
|
151
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/sessions/values.ts
|
|
2
|
+
import { traceValue } from "../engine/sandbox/trace.js";
|
|
3
|
+
var MAX_VALUE_BYTES = 2e5;
|
|
4
|
+
function jsonValue(value, limit = MAX_VALUE_BYTES) {
|
|
5
|
+
const text = JSON.stringify(value ?? null, (key, item) => {
|
|
6
|
+
if (!key.isWellFormed() || key.includes("\0") || typeof item === "string" && (!item.isWellFormed() || item.includes("\0")))
|
|
7
|
+
throw new Error("JSON text must contain well-formed Unicode without NUL");
|
|
8
|
+
return item;
|
|
9
|
+
});
|
|
10
|
+
if (text === void 0 || Buffer.byteLength(text) > limit)
|
|
11
|
+
throw new Error(
|
|
12
|
+
`Value must be JSON serializable within ${limit} UTF-8 bytes`
|
|
13
|
+
);
|
|
14
|
+
return JSON.parse(text);
|
|
15
|
+
}
|
|
16
|
+
function canonicalJson(value) {
|
|
17
|
+
return JSON.stringify(value, (_key, item) => {
|
|
18
|
+
if (item && typeof item === "object" && !Array.isArray(item))
|
|
19
|
+
return Object.fromEntries(
|
|
20
|
+
Object.entries(item).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)
|
|
21
|
+
);
|
|
22
|
+
return item;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function errorText(error) {
|
|
26
|
+
return (error instanceof Error ? error.message : String(error)).slice(
|
|
27
|
+
0,
|
|
28
|
+
4096
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
function traceData(value) {
|
|
32
|
+
return traceValue(value);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
MAX_VALUE_BYTES,
|
|
36
|
+
canonicalJson,
|
|
37
|
+
errorText,
|
|
38
|
+
jsonValue,
|
|
39
|
+
traceData
|
|
40
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// src/sessions/worker.ts
|
|
2
|
+
import { hostname } from "node:os";
|
|
3
|
+
import { createInterface } from "node:readline";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { SessionKernel } from "./kernel.js";
|
|
6
|
+
import { errorText, jsonValue } from "./values.js";
|
|
7
|
+
var command = z.discriminatedUnion("type", [
|
|
8
|
+
z.object({
|
|
9
|
+
type: z.literal("initialize"),
|
|
10
|
+
requestId: z.string(),
|
|
11
|
+
functions: z.array(z.string())
|
|
12
|
+
}),
|
|
13
|
+
z.object({
|
|
14
|
+
type: z.literal("execute"),
|
|
15
|
+
requestId: z.string(),
|
|
16
|
+
cellId: z.string(),
|
|
17
|
+
source: z.string(),
|
|
18
|
+
inputs: z.record(z.string(), z.unknown())
|
|
19
|
+
}),
|
|
20
|
+
z.object({
|
|
21
|
+
type: z.literal("toolResult"),
|
|
22
|
+
callId: z.string(),
|
|
23
|
+
value: z.unknown().optional(),
|
|
24
|
+
error: z.string().optional()
|
|
25
|
+
})
|
|
26
|
+
]);
|
|
27
|
+
var pending = /* @__PURE__ */ new Map();
|
|
28
|
+
var send = (message) => {
|
|
29
|
+
process.stdout.write(JSON.stringify(message) + "\n");
|
|
30
|
+
};
|
|
31
|
+
var kernel;
|
|
32
|
+
for await (const line of createInterface({
|
|
33
|
+
input: process.stdin,
|
|
34
|
+
crlfDelay: Infinity
|
|
35
|
+
})) {
|
|
36
|
+
try {
|
|
37
|
+
if (Buffer.byteLength(line) > 1e6)
|
|
38
|
+
throw new Error("Session command exceeds limit");
|
|
39
|
+
const data = command.parse(JSON.parse(line));
|
|
40
|
+
if (data.type === "toolResult") {
|
|
41
|
+
const call = pending.get(data.callId);
|
|
42
|
+
pending.delete(data.callId);
|
|
43
|
+
if (data.error) call?.reject(new Error(data.error));
|
|
44
|
+
else call?.resolve(data.value);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (data.type === "initialize") {
|
|
48
|
+
if (kernel) throw new Error("Session already initialized");
|
|
49
|
+
kernel = new SessionKernel(data.functions, {
|
|
50
|
+
emit: (cellId, kind, value) => send({ type: "event", cellId, kind, data: value }),
|
|
51
|
+
call: (cellId, name, args) => new Promise((resolve, reject) => {
|
|
52
|
+
const callId = crypto.randomUUID();
|
|
53
|
+
pending.set(callId, { resolve, reject });
|
|
54
|
+
send({ type: "call", callId, cellId, name, args });
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
send({
|
|
58
|
+
type: "result",
|
|
59
|
+
requestId: data.requestId,
|
|
60
|
+
value: { pid: process.pid, hostname: hostname() }
|
|
61
|
+
});
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (!kernel) throw new Error("Session is not initialized");
|
|
65
|
+
void kernel.execute(data.cellId, data.source, data.inputs).then(
|
|
66
|
+
(value) => send({
|
|
67
|
+
type: "result",
|
|
68
|
+
requestId: data.requestId,
|
|
69
|
+
value: jsonValue(value)
|
|
70
|
+
}),
|
|
71
|
+
(error) => send({
|
|
72
|
+
type: "result",
|
|
73
|
+
requestId: data.requestId,
|
|
74
|
+
error: errorText(error)
|
|
75
|
+
})
|
|
76
|
+
);
|
|
77
|
+
} catch {
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
process.exit(0);
|