@jr2/orchestrator 0.3.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -2
- package/bin/server.ts +7 -4
- package/console/canvas.ts +27 -14
- package/console/components/app.ts +12 -1
- package/console/components/fleet.ts +52 -6
- package/console/components/machine-pane.ts +128 -2
- package/console/components/nav.ts +1 -1
- package/console/components/schema-form.ts +12 -4
- package/console/json-field.ts +23 -0
- package/console/main.ts +122 -39
- package/console/store.ts +321 -21
- package/console/style.css +111 -0
- package/docs/agents-block.md +5 -0
- package/docs/concepts/agents-and-turns.md +442 -0
- package/docs/concepts/architecture.md +230 -0
- package/docs/concepts/charts.md +143 -0
- package/docs/concepts/composition.md +357 -0
- package/docs/concepts/converge.md +254 -0
- package/docs/concepts/durable-runs.md +189 -0
- package/docs/concepts/effects.md +603 -0
- package/docs/concepts/gates.md +208 -0
- package/docs/concepts/machines-and-workflows.md +289 -0
- package/docs/concepts/pools-and-sources.md +230 -0
- package/docs/concepts/secrets-and-trust.md +222 -0
- package/docs/concepts/the-menu.md +378 -0
- package/docs/concepts/workspaces.md +678 -0
- package/docs/get-started/a-model-decides.md +563 -0
- package/docs/get-started/an-agent-in-a-sandbox.md +381 -0
- package/docs/get-started/connect-a-model.md +248 -0
- package/docs/get-started/create-an-instance.md +194 -0
- package/docs/get-started/have-your-assistant-write-a-machine.md +922 -0
- package/docs/get-started/install.md +126 -0
- package/docs/guides/add-tools-to-the-sandbox.md +295 -0
- package/docs/guides/answer-a-gate.md +304 -0
- package/docs/guides/bind-open-parts.md +223 -0
- package/docs/guides/cancel-a-run.md +146 -0
- package/docs/guides/clean-up.md +206 -0
- package/docs/guides/fix-a-failed-converge.md +361 -0
- package/docs/guides/give-the-cluster-git-credentials.md +222 -0
- package/docs/guides/iterate-on-a-machine-on-kind.md +190 -0
- package/docs/guides/let-an-agent-write-a-chart.md +226 -0
- package/docs/guides/look-inside-a-sandbox.md +174 -0
- package/docs/guides/mirror-the-kit-images.md +176 -0
- package/docs/guides/move-from-kind-to-a-shared-cluster.md +302 -0
- package/docs/guides/open-the-console.md +91 -0
- package/docs/guides/publish-a-machine-as-an-npm-package.md +350 -0
- package/docs/guides/push-and-sign-a-branch.md +486 -0
- package/docs/guides/run-a-chart-by-name.md +270 -0
- package/docs/guides/run-a-command-or-call-a-url.md +544 -0
- package/docs/guides/run-one-worker-per-item.md +321 -0
- package/docs/guides/set-an-agents-access-and-dials.md +375 -0
- package/docs/guides/size-a-workspace.md +204 -0
- package/docs/guides/start-a-run-from-a-run.md +237 -0
- package/docs/guides/start-a-run.md +207 -0
- package/docs/guides/upgrade-the-kit-version.md +240 -0
- package/docs/guides/use-a-hosted-provider.md +208 -0
- package/docs/guides/use-a-local-model.md +313 -0
- package/docs/guides/watch-a-run.md +326 -0
- package/docs/guides/write-a-workflow.md +318 -0
- package/docs/index.md +44 -0
- package/docs/llms.txt +216 -0
- package/docs/reference/authoring-surface/agent.md +128 -0
- package/docs/reference/authoring-surface/answer.md +140 -0
- package/docs/reference/authoring-surface/arg.md +60 -0
- package/docs/reference/authoring-surface/basic.md +62 -0
- package/docs/reference/authoring-surface/bearer.md +53 -0
- package/docs/reference/authoring-surface/chartschema.md +23 -0
- package/docs/reference/authoring-surface/chartschemafor.md +48 -0
- package/docs/reference/authoring-surface/command.md +191 -0
- package/docs/reference/authoring-surface/customize.md +64 -0
- package/docs/reference/authoring-surface/defineconfig.md +41 -0
- package/docs/reference/authoring-surface/defineevent.md +114 -0
- package/docs/reference/authoring-surface/dispatch.md +126 -0
- package/docs/reference/authoring-surface/fail.md +83 -0
- package/docs/reference/authoring-surface/file.md +122 -0
- package/docs/reference/authoring-surface/frompick.md +277 -0
- package/docs/reference/authoring-surface/http.md +159 -0
- package/docs/reference/authoring-surface/isfailure.md +58 -0
- package/docs/reference/authoring-surface/jr2setup.md +237 -0
- package/docs/reference/authoring-surface/open.md +74 -0
- package/docs/reference/authoring-surface/openbody.md +86 -0
- package/docs/reference/authoring-surface/paramsof.md +125 -0
- package/docs/reference/authoring-surface/pool.md +186 -0
- package/docs/reference/authoring-surface/push.md +112 -0
- package/docs/reference/authoring-surface/secret.md +118 -0
- package/docs/reference/authoring-surface/sentby.md +83 -0
- package/docs/reference/authoring-surface/source.md +51 -0
- package/docs/reference/authoring-surface/text.md +62 -0
- package/docs/reference/authoring-surface/type-agentdeclaration.md +27 -0
- package/docs/reference/authoring-surface/type-agentdefinition.md +80 -0
- package/docs/reference/authoring-surface/type-agentlogic.md +15 -0
- package/docs/reference/authoring-surface/type-agentslots.md +12 -0
- package/docs/reference/authoring-surface/type-answeraction.md +12 -0
- package/docs/reference/authoring-surface/type-arg.md +19 -0
- package/docs/reference/authoring-surface/type-argnames.md +12 -0
- package/docs/reference/authoring-surface/type-binding.md +62 -0
- package/docs/reference/authoring-surface/type-bindingof.md +12 -0
- package/docs/reference/authoring-surface/type-bodyacceptsdoor.md +15 -0
- package/docs/reference/authoring-surface/type-bodyacceptsslots.md +17 -0
- package/docs/reference/authoring-surface/type-ceilings.md +41 -0
- package/docs/reference/authoring-surface/type-chainlink.md +19 -0
- package/docs/reference/authoring-surface/type-chartaction.md +46 -0
- package/docs/reference/authoring-surface/type-chartagent.md +28 -0
- package/docs/reference/authoring-surface/type-chartevent.md +20 -0
- package/docs/reference/authoring-surface/type-chartguard.md +20 -0
- package/docs/reference/authoring-surface/type-chartinvoke.md +28 -0
- package/docs/reference/authoring-surface/type-chartjson.md +14 -0
- package/docs/reference/authoring-surface/type-chartstate.md +46 -0
- package/docs/reference/authoring-surface/type-charttext.md +40 -0
- package/docs/reference/authoring-surface/type-charttransition.md +22 -0
- package/docs/reference/authoring-surface/type-charttransitions.md +14 -0
- package/docs/reference/authoring-surface/type-chartvalue.md +15 -0
- package/docs/reference/authoring-surface/type-childat.md +12 -0
- package/docs/reference/authoring-surface/type-childslots.md +12 -0
- package/docs/reference/authoring-surface/type-commandenv.md +15 -0
- package/docs/reference/authoring-surface/type-commandinput.md +19 -0
- package/docs/reference/authoring-surface/type-commandoptions.md +78 -0
- package/docs/reference/authoring-surface/type-commandoutput.md +104 -0
- package/docs/reference/authoring-surface/type-customize.md +109 -0
- package/docs/reference/authoring-surface/type-dispatchdefinition.md +39 -0
- package/docs/reference/authoring-surface/type-dispatchinput.md +14 -0
- package/docs/reference/authoring-surface/type-dispatchopenparts.md +14 -0
- package/docs/reference/authoring-surface/type-dispatchoutput.md +65 -0
- package/docs/reference/authoring-surface/type-duration.md +15 -0
- package/docs/reference/authoring-surface/type-effectbinding.md +93 -0
- package/docs/reference/authoring-surface/type-effectlogic.md +12 -0
- package/docs/reference/authoring-surface/type-envopenparts.md +14 -0
- package/docs/reference/authoring-surface/type-eventaudience.md +27 -0
- package/docs/reference/authoring-surface/type-eventdef.md +45 -0
- package/docs/reference/authoring-surface/type-eventfrom.md +16 -0
- package/docs/reference/authoring-surface/type-eventsemantics.md +26 -0
- package/docs/reference/authoring-surface/type-execoutcome.md +34 -0
- package/docs/reference/authoring-surface/type-failslot.md +14 -0
- package/docs/reference/authoring-surface/type-failure.md +19 -0
- package/docs/reference/authoring-surface/type-failureinput.md +20 -0
- package/docs/reference/authoring-surface/type-filebody.md +41 -0
- package/docs/reference/authoring-surface/type-frominput.md +14 -0
- package/docs/reference/authoring-surface/type-hostinjectedinput.md +58 -0
- package/docs/reference/authoring-surface/type-httpdefinition.md +101 -0
- package/docs/reference/authoring-surface/type-httpinput.md +12 -0
- package/docs/reference/authoring-surface/type-httpmethod.md +14 -0
- package/docs/reference/authoring-surface/type-httpopenparts.md +12 -0
- package/docs/reference/authoring-surface/type-httpoutput.md +89 -0
- package/docs/reference/authoring-surface/type-httprequestparts.md +33 -0
- package/docs/reference/authoring-surface/type-jr2config.md +126 -0
- package/docs/reference/authoring-surface/type-lends.md +38 -0
- package/docs/reference/authoring-surface/type-logicat.md +12 -0
- package/docs/reference/authoring-surface/type-markedif.md +12 -0
- package/docs/reference/authoring-surface/type-mergedactors.md +12 -0
- package/docs/reference/authoring-surface/type-namedsecret.md +25 -0
- package/docs/reference/authoring-surface/type-noslotspec.md +26 -0
- package/docs/reference/authoring-surface/type-noslotworkspaceoptions.md +32 -0
- package/docs/reference/authoring-surface/type-openbodydeclaration.md +40 -0
- package/docs/reference/authoring-surface/type-openbodylogic.md +14 -0
- package/docs/reference/authoring-surface/type-openbodyoutput.md +42 -0
- package/docs/reference/authoring-surface/type-openbodyslot.md +18 -0
- package/docs/reference/authoring-surface/type-opencommandinput.md +17 -0
- package/docs/reference/authoring-surface/type-openeffect.md +12 -0
- package/docs/reference/authoring-surface/type-openeffectslots.md +12 -0
- package/docs/reference/authoring-surface/type-openof.md +12 -0
- package/docs/reference/authoring-surface/type-opensecret.md +23 -0
- package/docs/reference/authoring-surface/type-opensecretmark.md +12 -0
- package/docs/reference/authoring-surface/type-permissivenoslotworkspaceoptions.md +31 -0
- package/docs/reference/authoring-surface/type-permissiveworkspaceoptions.md +32 -0
- package/docs/reference/authoring-surface/type-poolmachine.md +28 -0
- package/docs/reference/authoring-surface/type-poolspec.md +60 -0
- package/docs/reference/authoring-surface/type-pushinput.md +15 -0
- package/docs/reference/authoring-surface/type-pushoptions.md +79 -0
- package/docs/reference/authoring-surface/type-pushoutput.md +124 -0
- package/docs/reference/authoring-surface/type-pushwireoutput.md +12 -0
- package/docs/reference/authoring-surface/type-quantity.md +14 -0
- package/docs/reference/authoring-surface/type-reached.md +12 -0
- package/docs/reference/authoring-surface/type-reposlot.md +70 -0
- package/docs/reference/authoring-surface/type-reposlotsof.md +16 -0
- package/docs/reference/authoring-surface/type-sandboxoptions.md +77 -0
- package/docs/reference/authoring-surface/type-secret.md +25 -0
- package/docs/reference/authoring-surface/type-sender.md +19 -0
- package/docs/reference/authoring-surface/type-sentbyguards.md +12 -0
- package/docs/reference/authoring-surface/type-size.md +85 -0
- package/docs/reference/authoring-surface/type-slothandles.md +32 -0
- package/docs/reference/authoring-surface/type-sourcenextresult.md +17 -0
- package/docs/reference/authoring-surface/type-sourcespec.md +44 -0
- package/docs/reference/authoring-surface/type-syncstate.md +12 -0
- package/docs/reference/authoring-surface/type-text.md +19 -0
- package/docs/reference/authoring-surface/type-textpart.md +24 -0
- package/docs/reference/authoring-surface/type-thinkinglevel.md +39 -0
- package/docs/reference/authoring-surface/type-toparameterizedobject.md +14 -0
- package/docs/reference/authoring-surface/type-toprovidedactor.md +14 -0
- package/docs/reference/authoring-surface/type-unknown.md +21 -0
- package/docs/reference/authoring-surface/type-usercontainer.md +77 -0
- package/docs/reference/authoring-surface/type-withoutemptyindex.md +20 -0
- package/docs/reference/authoring-surface/type-workflowevent.md +46 -0
- package/docs/reference/authoring-surface/type-workspaceaccess.md +16 -0
- package/docs/reference/authoring-surface/type-workspaced.md +94 -0
- package/docs/reference/authoring-surface/type-workspacehandles.md +23 -0
- package/docs/reference/authoring-surface/type-workspacemachine.md +29 -0
- package/docs/reference/authoring-surface/type-workspaceof.md +13 -0
- package/docs/reference/authoring-surface/type-workspaceoptions.md +39 -0
- package/docs/reference/authoring-surface/type-workspacespec.md +37 -0
- package/docs/reference/authoring-surface/workspace.md +259 -0
- package/docs/reference/authoring-surface.md +197 -0
- package/docs/reference/cli.md +433 -0
- package/docs/reference/config.md +756 -0
- package/docs/reference/decisions/0001-operator-owned-generic-sandbox.md +113 -0
- package/docs/reference/decisions/0002-duplex-streaming-actor.md +110 -0
- package/docs/reference/decisions/0004-worktree-provisioning-model.md +124 -0
- package/docs/reference/decisions/0005-sandbox-pod-composition.md +230 -0
- package/docs/reference/decisions/0006-agent-control-surface.md +47 -0
- package/docs/reference/decisions/0007-durable-machine-state.md +109 -0
- package/docs/reference/decisions/0008-orchestrator-as-deployed-app.md +60 -0
- package/docs/reference/decisions/0009-cli-and-instance-interface.md +275 -0
- package/docs/reference/decisions/0010-bdd-acceptance-tests.md +160 -0
- package/docs/reference/decisions/0011-workflow-defined-events.md +141 -0
- package/docs/reference/decisions/0012-workspace-wrapper-machine.md +103 -0
- package/docs/reference/decisions/0013-the-agent-reaches-its-machine-through-a-container-it-cannot-read.md +157 -0
- package/docs/reference/decisions/0014-observation-is-open-run-state-is-not.md +95 -0
- package/docs/reference/decisions/0015-authoring-surface-absorbs-the-mechanism.md +265 -0
- package/docs/reference/decisions/0016-agent-turn-mechanics-are-internal.md +124 -0
- package/docs/reference/decisions/0017-pool-over-a-source-port.md +69 -0
- package/docs/reference/decisions/0018-instance-agents-are-definitions-jr2-assembles-the-harness.md +111 -0
- package/docs/reference/decisions/0019-one-converging-command-against-the-current-context.md +275 -0
- package/docs/reference/decisions/0020-private-ca-trust-is-a-named-concept.md +60 -0
- package/docs/reference/decisions/0021-workspace-continuity-is-a-lease-that-answers-back.md +100 -0
- package/docs/reference/decisions/0022-observation-is-a-level-triggered-feed.md +103 -0
- package/docs/reference/decisions/0023-the-harness-prints-the-conversation.md +176 -0
- package/docs/reference/decisions/0024-an-agents-turn-ends-with-the-state-that-asked-for-it.md +439 -0
- package/docs/reference/decisions/0025-cancel-ends-a-run-stop-parks-it.md +65 -0
- package/docs/reference/decisions/0026-a-turn-that-is-over-is-never-prompted.md +62 -0
- package/docs/reference/decisions/0027-the-harness-is-jr2s-own-server-flue-retires-the-wire-stays.md +237 -0
- package/docs/reference/decisions/0028-what-an-agent-may-do-to-the-workspace-is-part-of-its-definition.md +89 -0
- package/docs/reference/decisions/0029-a-menu-is-fixed-for-a-conversation-and-a-turn-is-told-its-allowed-picks.md +154 -0
- package/docs/reference/decisions/0030-a-snapshot-names-the-machine-it-was-written-under.md +100 -0
- package/docs/reference/decisions/0031-menu-only-agents-run-on-the-instance-harness.md +190 -0
- package/docs/reference/decisions/0032-the-console-unlocks-with-the-instance-token.md +61 -0
- package/docs/reference/decisions/0033-a-machine-declares-the-input-that-starts-it.md +127 -0
- package/docs/reference/decisions/0034-the-console-renders-with-preact-and-the-server-erases-the-types.md +57 -0
- package/docs/reference/decisions/0035-a-runaway-turn-is-ended-rerolled-once-then-a-fault.md +92 -0
- package/docs/reference/decisions/0036-a-turn-compacts-its-own-context-mid-flight.md +138 -0
- package/docs/reference/decisions/0037-an-instance-builds-its-sandbox-images-jr2-injects-the-harness.md +196 -0
- package/docs/reference/decisions/0038-jr2-up-builds-every-image-it-deploys.md +170 -0
- package/docs/reference/decisions/0039-image-garbage-collects-by-reachability.md +115 -0
- package/docs/reference/decisions/0041-a-build-the-host-already-holds-is-not-spent-again.md +64 -0
- package/docs/reference/decisions/0042-ready-is-not-routable-an-admission-retries-its-connection.md +142 -0
- package/docs/reference/decisions/0043-the-kit-is-tested-as-installed-a-local-registry-stands-in-for-npm.md +170 -0
- package/docs/reference/decisions/0044-kit-images-live-at-a-canonical-home-a-self-host-mirrors-it.md +85 -0
- package/docs/reference/decisions/0045-the-platform-joins-the-image-address-and-the-cluster-chooses-it.md +82 -0
- package/docs/reference/decisions/0046-a-converge-failure-carries-its-diagnosis.md +34 -0
- package/docs/reference/decisions/0047-the-git-ssh-key-source-is-the-users-choice.md +47 -0
- package/docs/reference/decisions/0048-the-orchestrator-boots-without-its-repos.md +36 -0
- package/docs/reference/decisions/0049-a-machine-carries-its-parts-and-composes-by-invoke.md +126 -0
- package/docs/reference/decisions/0050-what-code-names-config-declares-what-the-cli-names-discovery-finds.md +73 -0
- package/docs/reference/decisions/0051-a-repo-is-a-slot-on-the-workspace-and-a-cache-on-the-node.md +227 -0
- package/docs/reference/decisions/0052-a-sandbox-lands-where-an-ordinary-pod-lands-and-the-cache-follows-it.md +81 -0
- package/docs/reference/decisions/0053-a-fetch-inside-the-pod-asks-the-node-cache-and-the-cache-asks-the-remote.md +111 -0
- package/docs/reference/decisions/0054-the-kit-ships-machines-and-a-shipped-machine-leaves-its-parts-open.md +126 -0
- package/docs/reference/decisions/0055-a-release-is-a-pushed-tag-and-the-publish-guard-is-the-credential.md +107 -0
- package/docs/reference/decisions/0056-a-global-jr2-hands-off-to-the-instances-own-and-an-instance-has-one-kit-version.md +62 -0
- package/docs/reference/decisions/0057-a-turn-is-its-frame-its-dials-and-whether-it-continues.md +152 -0
- package/docs/reference/decisions/0058-a-harness-answers-the-orchestrator-alone.md +106 -0
- package/docs/reference/decisions/0059-a-harness-holds-stand-ins-and-the-custodian-holds-the-keys.md +384 -0
- package/docs/reference/decisions/0060-a-workspace-states-its-size-and-jr2-reserves-all-of-it.md +111 -0
- package/docs/reference/decisions/0061-a-memory-kill-ends-the-agents-processes-not-the-harness.md +83 -0
- package/docs/reference/decisions/0062-jr2-briefs-the-agent-on-its-seat-never-on-its-task.md +212 -0
- package/docs/reference/decisions/0063-the-orchestrator-watches-the-cluster.md +83 -0
- package/docs/reference/decisions/0064-a-workspace-waits-for-capacity.md +79 -0
- package/docs/reference/decisions/0065-a-persist-survives-a-crash-and-history-is-a-week.md +65 -0
- package/docs/reference/decisions/0066-a-model-tier-runs-a-real-model-and-a-change-to-what-it-reads-runs-the-tier.md +550 -0
- package/docs/reference/decisions/0067-an-effect-is-an-actor-slot-and-runs-at-most-once-unless-marked-idempotent.md +430 -0
- package/docs/reference/decisions/0068-an-effector-holds-an-effects-secrets-and-signs-its-wire.md +464 -0
- package/docs/reference/decisions/0069-the-orchestrator-is-a-kit-image-and-an-instance-publishes-its-assembly.md +180 -0
- package/docs/reference/decisions/0070-a-machine-lends-its-parts-to-a-chart.md +323 -0
- package/docs/reference/decisions/0071-a-run-starts-a-run-through-a-dispatch-effect.md +183 -0
- package/docs/reference/decisions/0072-the-docs-ship-inside-the-kit-and-an-instances-agents-md-indexes-them.md +144 -0
- package/docs/reference/decisions/0073-a-machine-fails-a-run-with-fail-and-an-uncaught-failure-ends-it-failed.md +122 -0
- package/docs/reference/decisions/0074-an-unrouted-mechanism-event-is-refused-at-load-and-faults-the-run.md +76 -0
- package/docs/reference/decisions.md +83 -0
- package/docs/reference/glossary.md +648 -0
- package/docs/reference/http-api.md +1348 -0
- package/docs/reference/machines.md +190 -0
- package/docs/reference/mechanism-events.md +72 -0
- package/docs/why.md +206 -0
- package/package.json +6 -4
- package/src/actor.ts +976 -61
- package/src/agent.ts +114 -38
- package/src/ambient.ts +4 -1
- package/src/assembly-checks.ts +347 -0
- package/src/assembly-tar.ts +494 -0
- package/src/assembly.ts +721 -0
- package/src/cause.ts +234 -0
- package/src/chart.ts +2182 -0
- package/src/charts.ts +748 -0
- package/src/config.ts +520 -162
- package/src/content-hash.ts +105 -0
- package/src/custodian.lua +6 -5
- package/src/custodian.ts +143 -39
- package/src/customize.ts +388 -55
- package/src/dispatch-effect.ts +945 -0
- package/src/door-compat.ts +217 -0
- package/src/durability.ts +11 -4
- package/src/effect-checks.ts +557 -0
- package/src/effect.ts +1202 -0
- package/src/effector-wire.ts +674 -0
- package/src/fail.ts +209 -0
- package/src/fingerprint.ts +4 -3
- package/src/gate.ts +8 -0
- package/src/git-clone.ts +65 -0
- package/src/git-push.ts +336 -0
- package/src/harness-client.ts +764 -48
- package/src/held-secrets.ts +82 -26
- package/src/holds.ts +156 -0
- package/src/http-effect.ts +1423 -0
- package/src/http.ts +916 -113
- package/src/images.ts +47 -21
- package/src/index.ts +62 -43
- package/src/instance.ts +505 -59
- package/src/internal.ts +84 -0
- package/src/kube-client.ts +333 -0
- package/src/machine-doc.ts +106 -6
- package/src/mechanism-routes.ts +168 -0
- package/src/model-keys.generated.ts +53 -0
- package/src/model-keys.ts +18 -58
- package/src/mount-digest.ts +53 -0
- package/src/names.ts +66 -8
- package/src/notices.ts +141 -0
- package/src/open-body.ts +1580 -0
- package/src/open-effect.ts +217 -0
- package/src/open.ts +59 -6
- package/src/parts.ts +709 -41
- package/src/party.ts +534 -0
- package/src/pick.ts +761 -0
- package/src/pool.ts +248 -37
- package/src/registration.ts +382 -19
- package/src/repo-fetch.ts +60 -85
- package/src/repos.ts +65 -75
- package/src/rest.ts +133 -0
- package/src/run-host.ts +2383 -115
- package/src/run-output.ts +38 -0
- package/src/sandbox-effect.ts +1126 -0
- package/src/sandbox-effector.ts +111 -0
- package/src/sandbox-kube.ts +1721 -0
- package/src/sandbox-watch.ts +260 -0
- package/src/secret-placement.ts +529 -0
- package/src/server.ts +284 -84
- package/src/setup.ts +819 -117
- package/src/size.ts +454 -0
- package/src/snapshot-store.ts +115 -20
- package/src/stub-harness.ts +49 -16
- package/src/sync-client.ts +54 -0
- package/src/timers.ts +191 -0
- package/src/tokens.ts +35 -4
- package/src/vocabulary.ts +135 -15
- package/src/wire.ts +238 -10
- package/src/workspace.ts +1195 -338
- package/src/sandbox-kubectl.ts +0 -1108
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: PoolSpec
|
|
3
|
+
description: "What you pass to `pool()`: where the items come from, how many workers run at once, and what each worker gets."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `PoolSpec`
|
|
7
|
+
|
|
8
|
+
Type, in `@jr2/orchestrator/src/pool.ts`. The signature of an export, or a type that it names, names this type. The [Authoring surface](../authoring-surface.md) page lists each export. This type is not an export of `@jr2/orchestrator`, so a workflow module does not import it by name.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
type PoolSpec<T, TInput = unknown> = {
|
|
12
|
+
id?: string;
|
|
13
|
+
input?: z.ZodObject;
|
|
14
|
+
source: SourceSpec<T>;
|
|
15
|
+
itemId: (item: T) => string;
|
|
16
|
+
cap?: number | ((args: { input: TInput }) => number);
|
|
17
|
+
itemInput?: (item: T, args: { input: TInput }) => unknown;
|
|
18
|
+
onDrained?: "final";
|
|
19
|
+
failures?: "fail" | "report";
|
|
20
|
+
};
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
What you pass to `pool()`: where the items come from, how many workers run at once, and what
|
|
24
|
+
each worker gets.
|
|
25
|
+
|
|
26
|
+
**Fields**
|
|
27
|
+
|
|
28
|
+
- `id` (optional): `string`
|
|
29
|
+
|
|
30
|
+
The Machine id: the name of the Pool in the Console. Default: `"pool"`.
|
|
31
|
+
- `input` (optional): `z.ZodObject`
|
|
32
|
+
|
|
33
|
+
The run input of the Pool, as a zod object: what a caller sends to start a run. `cap` and
|
|
34
|
+
`itemInput` read it, typed by it. A worker never gets it: each worker gets its item. Default:
|
|
35
|
+
none, and then their `input` is `unknown`.
|
|
36
|
+
- `source`: `SourceSpec<T>`
|
|
37
|
+
|
|
38
|
+
Where the items come from. Make it with [`source`](source.md).
|
|
39
|
+
- `itemId`: `(item: T) => string`
|
|
40
|
+
|
|
41
|
+
The id of an item. The Pool uses it as the id of the item's worker and in the `active` list
|
|
42
|
+
that `next` gets. It is also the key of that worker's output in `items`. Give each item an id
|
|
43
|
+
of its own, and the same id every time.
|
|
44
|
+
- `cap` (optional): `number | ((args: { input: TInput; }) => number)`
|
|
45
|
+
|
|
46
|
+
The most workers that run at once: a number, or a function of the run input. Default: `1`.
|
|
47
|
+
- `itemInput` (optional): `(item: T, args: { input: TInput; }) => unknown`
|
|
48
|
+
|
|
49
|
+
Make a worker's input from its item and the run input. Default: the item itself.
|
|
50
|
+
- `onDrained` (optional): `"final"`
|
|
51
|
+
|
|
52
|
+
What the Pool does when the Source has no more items and every worker has settled. Only
|
|
53
|
+
`"final"`: the run ends. Default: `"final"`.
|
|
54
|
+
- `failures` (optional): `"fail" | "report"`
|
|
55
|
+
|
|
56
|
+
What the Pool does at the end when one or more workers failed. The Pool catches each worker's
|
|
57
|
+
Failure either way, so one failed item does not stop the other workers. `"fail"`: when the Pool
|
|
58
|
+
ends with failures, `drained` or `deadlocked`, it fails the run with the reason
|
|
59
|
+
`"<n> of <m> items failed"` and the detail `{ status, items, failures }`. `"report"`: the Pool
|
|
60
|
+
ends `done`, with the failures in its output. Default: `"fail"`.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: PushInput
|
|
3
|
+
description: "The input of a `push` Effect: `{ sha }` with `pin`, and `{ message }` with `squash`."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `PushInput`
|
|
7
|
+
|
|
8
|
+
Type, in `@jr2/orchestrator/src/sandbox-effect.ts`. The signature of an export, or a type that it names, names this type. The [Authoring surface](../authoring-surface.md) page lists each export. This type is not an export of `@jr2/orchestrator`, so a workflow module does not import it by name.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
type PushInput<O extends PushOptions> = (O["pin"] extends true ? { sha: string } : unknown) &
|
|
12
|
+
(O["squash"] extends true ? { message: string } : unknown);
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The input of a `push` Effect: `{ sha }` with `pin`, and `{ message }` with `squash`.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: PushOptions
|
|
3
|
+
description: The options of `push()`.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `PushOptions`
|
|
7
|
+
|
|
8
|
+
Type, in `@jr2/orchestrator/src/sandbox-effect.ts`. The signature of an export, or a type that it names, names this type. The [Authoring surface](../authoring-surface.md) page lists each export. This type is not an export of `@jr2/orchestrator`, so a workflow module does not import it by name.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
type PushOptions = {
|
|
12
|
+
pin?: boolean;
|
|
13
|
+
sign?: boolean;
|
|
14
|
+
squash?: boolean;
|
|
15
|
+
force?: boolean;
|
|
16
|
+
slot?: string;
|
|
17
|
+
timeout?: Duration;
|
|
18
|
+
};
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The options of `push()`.
|
|
22
|
+
|
|
23
|
+
**Fields**
|
|
24
|
+
|
|
25
|
+
- `pin` (optional): `boolean`
|
|
26
|
+
|
|
27
|
+
`true`: the input of the Effect names the commit to push (`{ sha }`, a full commit id, for
|
|
28
|
+
example one that a Gate approved). Default: the tip of the Agent's branch when the Effect
|
|
29
|
+
starts. When the Agent removed that commit from its branch, the remote refuses the push. jr2
|
|
30
|
+
never pushes another commit in its place.
|
|
31
|
+
|
|
32
|
+
When it starts, it refuses a `sha` that is not a full commit id: `push({ pin: true }): its
|
|
33
|
+
input's sha is not a full commit id (got <sha>)`.
|
|
34
|
+
- `sign` (optional): `boolean`
|
|
35
|
+
|
|
36
|
+
`true`: push signed copies of the commits. The `sign` field of the `git.credentials` entry that
|
|
37
|
+
the Binding matches names the key. Default `false`.
|
|
38
|
+
|
|
39
|
+
At `jr2 up`, it refuses an entry with no `sign` field: `<push> signed, and git.credentials
|
|
40
|
+
entry "<match>" holds no sign field — add sign: { sshKey: "<a Secret with identity>", name:
|
|
41
|
+
"<committer name>", email: "<committer email>" } to it; the email must belong to the forge
|
|
42
|
+
account that holds the key (ADR-0051, ADR-0067)`. `<push>` names the push: `workflow
|
|
43
|
+
"<workflow>": push "<slot>" pushes Repo Slot "<name>" (<url>)`.
|
|
44
|
+
- `squash` (optional): `boolean`
|
|
45
|
+
|
|
46
|
+
`true`: push one commit that holds all the changes. The input of the Effect gives its message
|
|
47
|
+
(`{ message }`). Signed, its committer is the signer. Unsigned, it is the `committer` of the
|
|
48
|
+
`git.credentials` entry that the Binding matches. Default `false`.
|
|
49
|
+
|
|
50
|
+
When it starts, it refuses an input with no message: `push({ squash: true }): its input
|
|
51
|
+
carries no message`.
|
|
52
|
+
|
|
53
|
+
At `jr2 up`, it refuses an unsigned squash whose entry has no `sign` and no `committer`:
|
|
54
|
+
`<push> squashed without sign, and git.credentials entry "<match>" holds neither sign nor
|
|
55
|
+
committer — the squashed commit is new and needs a committer; add committer: { name:
|
|
56
|
+
"<committer name>", email: "<committer email>" } to it, or sign the push — push({ squash:
|
|
57
|
+
true, sign: true }) — and add sign: { sshKey: "<a Secret with identity>", name: "<committer
|
|
58
|
+
name>", email: "<committer email>" } to it (ADR-0051, ADR-0067)`.
|
|
59
|
+
- `force` (optional): `boolean`
|
|
60
|
+
|
|
61
|
+
`true`: replace what the remote branch holds. Default `false`.
|
|
62
|
+
- `slot` (optional): `string`
|
|
63
|
+
|
|
64
|
+
The Repo Slot to push. Write it only when the Workspace has more than one.
|
|
65
|
+
|
|
66
|
+
When it starts, it refuses:
|
|
67
|
+
- no `slot` under a Workspace with more than one Repo Slot: `push "<slot>" runs under a
|
|
68
|
+
Workspace carrying more than one Repo Slot (<slots>) — say which: { slot: "<slot>" }
|
|
69
|
+
(ADR-0051)`
|
|
70
|
+
- a `slot` that the Workspace does not have: `push "<slot>" names Repo Slot "<name>", which
|
|
71
|
+
its Workspace does not carry (<slots>)`
|
|
72
|
+
- a Workspace with no Repo Slot: `push "<slot>" runs under a Workspace with no Repo Slot: a
|
|
73
|
+
push publishes a Repo Slot's branch, and there is none — declare one: repos: { app: "<url>" }
|
|
74
|
+
(ADR-0051)`. `jr2 up` refuses it first, with the same reason.
|
|
75
|
+
- `timeout` (optional): [`Duration`](type-duration.md)
|
|
76
|
+
|
|
77
|
+
How long jr2 waits for the push: a number and a unit, such as `"90s"` or `"5m"`. Default
|
|
78
|
+
`"5m"`. With no answer in that time, the output is `unknown`. It refuses a value that is not a
|
|
79
|
+
positive duration: `timeout "<timeout>" is not a positive duration (like "30s", "5m")`.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: PushOutput
|
|
3
|
+
description: "The output of a `push` Effect: what the `onDone` of its state gets as `event.output`."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `PushOutput`
|
|
7
|
+
|
|
8
|
+
Type, in `@jr2/orchestrator/src/sandbox-effect.ts`. It is an export of `@jr2/orchestrator`, on the [Authoring surface](../authoring-surface.md) page, in Effects.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
type PushOutput =
|
|
12
|
+
| Exclude<PushWireOutput, { outcome: "pushed" }>
|
|
13
|
+
| (Omit<Extract<PushWireOutput, { outcome: "pushed" }>, "bundle"> & { sync: SyncState; syncReason?: string });
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The output of a `push` Effect: what the `onDone` of its state gets as `event.output`. Every
|
|
17
|
+
outcome is output, so route on `outcome`:
|
|
18
|
+
|
|
19
|
+
- `pushed`: the remote has the commit. `published` is the commit on the remote, and `source` is
|
|
20
|
+
the Agent's commit that it comes from. They are the same commit, unless the push was signed or
|
|
21
|
+
squashed. `previous` is what the remote had before, and `unchanged` is `true` when the remote
|
|
22
|
+
had the commit already. `squashed` is `signed` or `unsigned` when the commit on the remote is
|
|
23
|
+
one squashed commit. `via` tells how jr2 found the new commits after a signed push:
|
|
24
|
+
`ancestry`, `pair`, `cherry` or `force`.
|
|
25
|
+
- `rejected`: git or the remote refused the push. `stage` tells where, `reason` tells why, and
|
|
26
|
+
`detail` has the words of git.
|
|
27
|
+
- `diverged`: the commit on the remote is not in the history of the Agent's branch, and jr2
|
|
28
|
+
could not pair it with a commit there. Nothing was pushed. `reason` tells why, and `published`
|
|
29
|
+
and `source` name the two commits.
|
|
30
|
+
- `unknown`: jr2 cannot tell what the push did. `reason` tells why.
|
|
31
|
+
|
|
32
|
+
Beside `pushed`, `sync` tells what jr2 did to the Agent's branch after the push:
|
|
33
|
+
|
|
34
|
+
- `synced`: the commit on the remote is not the Agent's own, and jr2 moved the branch to the
|
|
35
|
+
published commits.
|
|
36
|
+
- `already`: the branch has the published commit already.
|
|
37
|
+
- `skipped`: the remote has the Agent's own commit, so the branch does not move.
|
|
38
|
+
- `busy`: a rebase, merge, cherry-pick or revert of the branch is in progress. Nothing changed.
|
|
39
|
+
- `not-synced`: the branch did not move.
|
|
40
|
+
|
|
41
|
+
With `busy` or `not-synced`, `syncReason` tells why, and jr2 tries again before the next push.
|
|
42
|
+
|
|
43
|
+
**Forms**: it is one of these objects.
|
|
44
|
+
|
|
45
|
+
- Form 1: `outcome`, `stage`, `reason`, `detail`
|
|
46
|
+
|
|
47
|
+
- `outcome`: `"rejected"`
|
|
48
|
+
- `stage`: `string`
|
|
49
|
+
- `reason`: `string`
|
|
50
|
+
- `detail` (optional): `string`
|
|
51
|
+
- Form 2: `outcome`, `reason`, `published`, `source`
|
|
52
|
+
|
|
53
|
+
- `outcome`: `"diverged"`
|
|
54
|
+
- `reason`: `string`
|
|
55
|
+
- `published`: `string`
|
|
56
|
+
- `source`: `string`
|
|
57
|
+
- Form 3: `outcome`, `reason`
|
|
58
|
+
|
|
59
|
+
- `outcome`: `"unknown"`
|
|
60
|
+
- `reason`: `string`
|
|
61
|
+
- Form 4: `outcome`, `published`, `source`, `previous`, `via`, `unchanged`, `newCommits`, `squashed`, `sync`, `syncReason`
|
|
62
|
+
|
|
63
|
+
- `outcome`: `"pushed"`
|
|
64
|
+
- `published`: `string`
|
|
65
|
+
- `source`: `string`
|
|
66
|
+
- `previous` (optional): `string`
|
|
67
|
+
- `via` (optional): `string`
|
|
68
|
+
- `unchanged` (optional): `boolean`
|
|
69
|
+
- `newCommits` (optional): `number`
|
|
70
|
+
- `squashed` (optional): `"signed" | "unsigned"`
|
|
71
|
+
- `sync`: [`SyncState`](type-syncstate.md)
|
|
72
|
+
- `syncReason` (optional): `string`
|
|
73
|
+
|
|
74
|
+
**Example**
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import { fail, jr2Setup, push, type PushOutput, workspace, type Workspaced } from "@jr2/orchestrator";
|
|
78
|
+
|
|
79
|
+
type Input = Workspaced<{ sha: string }, "app">;
|
|
80
|
+
|
|
81
|
+
// A push that did not happen (`rejected` or `diverged`) is a different problem from one jr2
|
|
82
|
+
// cannot see (`unknown`).
|
|
83
|
+
const notPushed = (output: PushOutput): boolean =>
|
|
84
|
+
output.outcome === "rejected" || output.outcome === "diverged";
|
|
85
|
+
|
|
86
|
+
const body = jr2Setup({
|
|
87
|
+
types: {} as { context: Input; input: Input },
|
|
88
|
+
actors: { publish: push({ pin: true }), fail: fail() },
|
|
89
|
+
}).createMachine({
|
|
90
|
+
id: "release",
|
|
91
|
+
context: ({ input }) => input,
|
|
92
|
+
on: { "workspace.lost": ".lost" },
|
|
93
|
+
initial: "publishing",
|
|
94
|
+
states: {
|
|
95
|
+
publishing: {
|
|
96
|
+
invoke: {
|
|
97
|
+
src: "publish",
|
|
98
|
+
input: ({ context }) => ({ sha: context.sha }),
|
|
99
|
+
onDone: [
|
|
100
|
+
{ guard: ({ event }) => event.output.outcome === "pushed", target: "published" },
|
|
101
|
+
{ guard: ({ event }) => notPushed(event.output), target: "notPushed" },
|
|
102
|
+
{ target: "unknown" },
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
published: { type: "final" },
|
|
107
|
+
// Not final states: each one fails the run, with its own reason.
|
|
108
|
+
notPushed: { invoke: { src: "fail", input: { reason: "the remote refused the push" } } },
|
|
109
|
+
unknown: { invoke: { src: "fail", input: { reason: "jr2 cannot tell if the push happened" } } },
|
|
110
|
+
lost: { invoke: { src: "fail", input: { reason: "the Sandbox is gone" } } },
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
export const machine = workspace(body, {
|
|
115
|
+
repos: { app: { url: "https://github.com/you/app.git" } },
|
|
116
|
+
spec: () => ({ branch: "release" }),
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**See also**
|
|
121
|
+
|
|
122
|
+
- [Push and sign a branch](../../guides/push-and-sign-a-branch.md)
|
|
123
|
+
- [Effects](../../concepts/effects.md)
|
|
124
|
+
- [ADR-0067: An Effect is an actor slot, and runs at most once unless marked idempotent](../decisions/0067-an-effect-is-an-actor-slot-and-runs-at-most-once-unless-marked-idempotent.md)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: PushWireOutput
|
|
3
|
+
description: A type that the Authoring surface names.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `PushWireOutput`
|
|
7
|
+
|
|
8
|
+
Type, in `@jr2/orchestrator/src/effector-wire.ts`. It is type plumbing: it computes a type from the types of a Machine or of its parts, and a workflow module does not write it. The signature of an export, or a type that it names, names this type, so its declaration is here. The [Authoring surface](../authoring-surface.md) page lists each export.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
type PushWireOutput = z.infer<typeof PushOutputShape>;
|
|
12
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Quantity
|
|
3
|
+
description: "A Kubernetes quantity: `\"2Gi\"`, `\"1500m\"`, `\"2\"`, or a plain number (`2` cpus, bytes of memory)."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `Quantity`
|
|
7
|
+
|
|
8
|
+
Type, in `@jr2/orchestrator/src/size.ts`. The signature of an export, or a type that it names, names this type. The [Authoring surface](../authoring-surface.md) page lists each export. This type is not an export of `@jr2/orchestrator`, so a workflow module does not import it by name.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
type Quantity = string | number;
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
A Kubernetes quantity: `"2Gi"`, `"1500m"`, `"2"`, or a plain number (`2` cpus, bytes of memory).
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Reached
|
|
3
|
+
description: A type that the Authoring surface names.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `Reached`
|
|
7
|
+
|
|
8
|
+
Type, in `@jr2/orchestrator/src/customize.ts`. It is type plumbing: it computes a type from the types of a Machine or of its parts, and a workflow module does not write it. The signature of an export, or a type that it names, names this type, so its declaration is here. The [Authoring surface](../authoring-surface.md) page lists each export.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
type Reached<M extends AnyStateMachine> = M extends JR2Wrapper<infer TBody> ? Reached<TBody> : M;
|
|
12
|
+
```
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: RepoSlot
|
|
3
|
+
description: The value of one Repo Slot in `workspace({ repos })`.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `RepoSlot`
|
|
7
|
+
|
|
8
|
+
Type, in `@jr2/orchestrator/src/parts.ts`. It is an export of `@jr2/orchestrator`, on the [Authoring surface](../authoring-surface.md) page, in Workspaces and Repos.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
type RepoSlot<TInput = unknown> =
|
|
12
|
+
| typeof open
|
|
13
|
+
| string
|
|
14
|
+
| Binding
|
|
15
|
+
| ((args: { input: TInput }) => string | Binding);
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The value of one Repo Slot in `workspace({ repos })`. One of:
|
|
19
|
+
- a url, or a [`Binding`](type-binding.md) `{ url, ref }`: the Machine names the Repo.
|
|
20
|
+
- [`open`](open.md): the Instance that registers the Machine binds it with `customize()`. `jr2 up`
|
|
21
|
+
refuses a Workflow that leaves it open: ``refusing: workflow "<name>" leaves Repo Slot
|
|
22
|
+
"<slot>" open — bind it where the Machine is registered: export const machine =
|
|
23
|
+
customize(<import>, …) (ADR-0051)``, with the whole `customize` line to paste.
|
|
24
|
+
- a function of the run input, `({ input }) => url` or a [`Binding`](type-binding.md): each run chooses. The
|
|
25
|
+
url must match an entry of `git.credentials` in `jr2.config.ts`, or the run cannot use it.
|
|
26
|
+
|
|
27
|
+
The key of the slot is a directory name under `/work`. It starts with a letter, and
|
|
28
|
+
`workspace()` and `customize()` refuse a key that does not: ``<where>: Repo Slot key "<key>" is
|
|
29
|
+
not a directory name — a slot becomes `/work/<slot>` and its order matters, so it starts with a
|
|
30
|
+
letter and matches /^[A-Za-z][A-Za-z0-9._-]*$/ (ADR-0051).`` They refuse a value of another
|
|
31
|
+
shape: ``<where>: Repo Slot "<slot>" is <what> — a slot is `open`, a url, `{ url, ref? }`, or a
|
|
32
|
+
mapper `({ input }) => url | { url, ref? }` over the door (ADR-0051).``
|
|
33
|
+
|
|
34
|
+
**Example**
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { z } from "zod";
|
|
38
|
+
import { jr2Setup, open, workspace, type RepoSlot, type Workspaced } from "@jr2/orchestrator";
|
|
39
|
+
|
|
40
|
+
const runInput = z.object({ service: z.string() });
|
|
41
|
+
type RunInput = z.infer<typeof runInput>;
|
|
42
|
+
|
|
43
|
+
const service: RepoSlot<RunInput> = ({ input }) => `https://github.com/you/${input.service}.git`;
|
|
44
|
+
|
|
45
|
+
const body = jr2Setup({
|
|
46
|
+
types: {} as { input: Workspaced<RunInput, "service" | "docs" | "config"> },
|
|
47
|
+
}).createMachine({
|
|
48
|
+
id: "body",
|
|
49
|
+
initial: "done",
|
|
50
|
+
states: { done: { type: "final" } },
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// A Machine for a package: the Instance that registers it binds `config`.
|
|
54
|
+
export const deploy = workspace(body, {
|
|
55
|
+
input: runInput,
|
|
56
|
+
repos: {
|
|
57
|
+
service,
|
|
58
|
+
docs: "https://github.com/you/docs.git",
|
|
59
|
+
config: open,
|
|
60
|
+
},
|
|
61
|
+
spec: ({ input }) => ({ branch: `deploy/${input.service}` }),
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**See also**
|
|
66
|
+
|
|
67
|
+
- [Workspaces](../../concepts/workspaces.md)
|
|
68
|
+
- [Bind a shipped Machine's Open parts](../../guides/bind-open-parts.md)
|
|
69
|
+
- [Give the cluster git credentials](../../guides/give-the-cluster-git-credentials.md)
|
|
70
|
+
- [ADR-0051: A Repo is a slot on the `workspace()` and a cache on the node](../decisions/0051-a-repo-is-a-slot-on-the-workspace-and-a-cache-on-the-node.md)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: RepoSlotsOf
|
|
3
|
+
description: A type that the Authoring surface names.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `RepoSlotsOf`
|
|
7
|
+
|
|
8
|
+
Type, in `@jr2/orchestrator/src/customize.ts`. It is type plumbing: it computes a type from the types of a Machine or of its parts, and a workflow module does not write it. The signature of an export, or a type that it names, names this type, so its declaration is here. The [Authoring surface](../authoring-surface.md) page lists each export.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
type RepoSlotsOf<M extends AnyStateMachine> = [WorkspaceOf<M>] extends [never]
|
|
12
|
+
? never
|
|
13
|
+
: WorkspaceOf<M> extends JR2Repos<infer TSlots>
|
|
14
|
+
? TSlots
|
|
15
|
+
: never;
|
|
16
|
+
```
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: SandboxOptions
|
|
3
|
+
description: The options of a `workspace()` that say what its Sandbox is made of and which Repos it clones.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `SandboxOptions`
|
|
7
|
+
|
|
8
|
+
Type, in `@jr2/orchestrator/src/workspace.ts`. The signature of an export, or a type that it names, names this type. The [Authoring surface](../authoring-surface.md) page lists each export. This type is not an export of `@jr2/orchestrator`, so a workflow module does not import it by name.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
type SandboxOptions<TSlots extends string, TInput = unknown> = {
|
|
12
|
+
image?: string;
|
|
13
|
+
user?: string | UserContainer;
|
|
14
|
+
resources?: Size;
|
|
15
|
+
repos: Record<TSlots, RepoSlot<TInput>> | typeof open;
|
|
16
|
+
secrets?: readonly string[];
|
|
17
|
+
effector?: { image: string };
|
|
18
|
+
};
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The options of a `workspace()` that say what its Sandbox is made of and which Repos it
|
|
22
|
+
clones. They are the same for each run.
|
|
23
|
+
|
|
24
|
+
**Fields**
|
|
25
|
+
|
|
26
|
+
- `image` (optional): `string`
|
|
27
|
+
|
|
28
|
+
The Sandbox Image: the image of the container where the Agent's Working tools and
|
|
29
|
+
`command` Effects run. A `file:` URL to a docker context that your module ships
|
|
30
|
+
(`import.meta.resolve("./image")`), which `jr2 up` builds, or a registry ref. Its floor is
|
|
31
|
+
glibc and git; jr2 adds its own runtime at `/opt/jr2`. Default: the Instance's
|
|
32
|
+
`images/default`, then jr2's Harness image.
|
|
33
|
+
- `user` (optional): `string | UserContainer`
|
|
34
|
+
|
|
35
|
+
The User Container: a third container in the Sandbox, for a service that must run beside the
|
|
36
|
+
Agent, such as an sshd. Its image, in the same two forms as `image`, or `{ image, resources }`
|
|
37
|
+
to give it a part of the Size. It runs its own entrypoint, with `/work` mounted. jr2 adds
|
|
38
|
+
nothing to it. Default: none. Without `resources`, it has no limit of its own and shares the
|
|
39
|
+
Size of the Sandbox.
|
|
40
|
+
- `resources` (optional): [`Size`](type-size.md)
|
|
41
|
+
|
|
42
|
+
The Size: the memory and cpu limit of the whole Sandbox, `{ limits: { memory, cpu } }`, such as
|
|
43
|
+
`{ limits: { memory: "4Gi", cpu: "2" } }`. jr2 reserves all of it on the node: each request
|
|
44
|
+
equals its limit. jr2 also enforces the cpu limit. Only `limits`,
|
|
45
|
+
and in it only `memory` and `cpu`, are accepted. Default: the Instance's `sandbox.resources`,
|
|
46
|
+
then 2Gi and 1 cpu. Under a Size that you give, a field you leave out takes the kit's value,
|
|
47
|
+
not the Instance's. The Instance that registers the Machine can change it with
|
|
48
|
+
`customize(machine, { resources })`.
|
|
49
|
+
- `repos`: `Record<TSlots, RepoSlot<TInput>> | typeof open`
|
|
50
|
+
|
|
51
|
+
The Repo Slots: the repositories that the Sandbox clones, each under a name of your Machine's
|
|
52
|
+
choice. The name is the key of `workspace.repos` in the body and the directory under `/work`.
|
|
53
|
+
At least one slot. Leave `repos` out for a Workspace with no Repo Slot (see
|
|
54
|
+
[`NoSlotWorkspaceOptions`](type-noslotworkspaceoptions.md)). Each value is one of:
|
|
55
|
+
- a url, or `{ url, ref }`, where `ref` is the branch or commit that the Worktree starts from
|
|
56
|
+
(default: the Repo's default branch);
|
|
57
|
+
- `open`, for the Instance that registers the Machine to bind with `customize()`;
|
|
58
|
+
- a function of the run input, `({ input }) => url` or `{ url, ref }`, when each run chooses.
|
|
59
|
+
|
|
60
|
+
Or `repos: open` for the whole map: the Machine names no slot, and the Instance that registers
|
|
61
|
+
it names each one with `customize()`. The body's input is then `Workspaced<RunInput, string>`.
|
|
62
|
+
- `secrets` (optional): `readonly string[]`
|
|
63
|
+
|
|
64
|
+
The Held secrets that this Sandbox can use: names from the `secrets` list in `jr2.config.ts`.
|
|
65
|
+
The Sandbox's Custodian holds each value and puts it into requests to the hosts of that Held
|
|
66
|
+
secret. The Agent sees only a Stand-in. You need not list the model key of an Agent that runs
|
|
67
|
+
here: its provider claims it. Each name once.
|
|
68
|
+
- `effector` (optional): `object`
|
|
69
|
+
|
|
70
|
+
The image of the Sandbox Effector. This container runs three kinds of Effect for this
|
|
71
|
+
Workspace: a `push`, an `http` Effect with a Worktree file as its body, and a `command` with an
|
|
72
|
+
Effect secret in its `env`. It gets the Effect secrets that those Effects name. Give an image
|
|
73
|
+
when those Effects need tools or credentials that you keep out of the Sandbox Image, such as
|
|
74
|
+
`terraform`. A `file:` URL or a registry ref, as for `image`. Default: the Sandbox Image,
|
|
75
|
+
which already holds `git`.
|
|
76
|
+
|
|
77
|
+
- `image`: `string`
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Secret
|
|
3
|
+
description: "What `secret(\"name\")` gives: an Effect secret, by its name in the `secrets` list of `jr2.config.ts`."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `Secret`
|
|
7
|
+
|
|
8
|
+
Type, in `@jr2/orchestrator/src/http-effect.ts`. The signature of an export, or a type that it names, names this type. The [Authoring surface](../authoring-surface.md) page lists each export. This type is not an export of `@jr2/orchestrator`, so a workflow module does not import it by name.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
type Secret = { readonly secret: string; readonly path: { readonly secret: string; readonly path: true } };
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
What `secret("name")` gives: an Effect secret, by its name in the `secrets` list of
|
|
15
|
+
`jr2.config.ts`. Put it in an Effect's `auth`, a header, a `text` or a command's `env`. Its
|
|
16
|
+
`.path` is the path of a file that holds the value. The value stays in the Effector, so the
|
|
17
|
+
Machine and the Agent never see it.
|
|
18
|
+
|
|
19
|
+
**Fields**
|
|
20
|
+
|
|
21
|
+
- `secret`: `string`
|
|
22
|
+
- `path`: `object`
|
|
23
|
+
|
|
24
|
+
- `secret`: `string`
|
|
25
|
+
- `path`: `true`
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Sender
|
|
3
|
+
description: "Who delivered an event: an Agent by its slot, or a Gate by its invoke id (ADR-0015)."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `Sender`
|
|
7
|
+
|
|
8
|
+
Type, in `src/define-event.ts` of `@jr2/agent-protocol`, a dependency of `@jr2/orchestrator`. The signature of an export, or a type that it names, names this type. The [Authoring surface](../authoring-surface.md) page lists each export. This type is not an export of `@jr2/orchestrator`, so a workflow module does not import it by name.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
type Sender = { readonly party: "agent" | "gate"; readonly id: string };
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Who delivered an event: an Agent by its slot, or a Gate by its invoke id ([ADR-0015](../decisions/0015-authoring-surface-absorbs-the-mechanism.md)).
|
|
15
|
+
|
|
16
|
+
**Fields**
|
|
17
|
+
|
|
18
|
+
- `party`: `"agent" | "gate"`
|
|
19
|
+
- `id`: `string`
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: SentByGuards
|
|
3
|
+
description: A type that the Authoring surface names.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `SentByGuards`
|
|
7
|
+
|
|
8
|
+
Type, in `@jr2/orchestrator/src/setup.ts`. It is type plumbing: it computes a type from the types of a Machine or of its parts, and a workflow module does not write it. The signature of an export, or a type that it names, names this type, so its declaration is here. The [Authoring surface](../authoring-surface.md) page lists each export.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
type SentByGuards = { [SENT_BY]: { id: string } };
|
|
12
|
+
```
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Size
|
|
3
|
+
description: "The Size of a Workspace: the most memory and cpu that its whole Sandbox can use."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `Size`
|
|
7
|
+
|
|
8
|
+
Type, in `@jr2/orchestrator/src/size.ts`. It is an export of `@jr2/orchestrator`, on the [Authoring surface](../authoring-surface.md) page, in Composition.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
type Size = {
|
|
12
|
+
limits: {
|
|
13
|
+
memory?: Quantity;
|
|
14
|
+
cpu?: Quantity;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The Size of a Workspace: the most memory and cpu that its whole Sandbox can use. jr2 reserves
|
|
20
|
+
all of it on the node. Thus a Sandbox never gets less than its Size and never uses more.
|
|
21
|
+
|
|
22
|
+
Write it as `{ limits: { memory, cpu } }`. You can write it in three places: the `resources`
|
|
23
|
+
option of `workspace()`, `customize(machine, { resources })`, and `sandbox.resources` in
|
|
24
|
+
`jr2.config.ts`. The Size is a fact of the Machine. The Instance's `sandbox.resources` applies
|
|
25
|
+
only to a Workspace that states no Size. A field that neither states comes from the kit default:
|
|
26
|
+
memory `2Gi`, cpu `1`.
|
|
27
|
+
|
|
28
|
+
The same shape is the User Container's part of the Size, in `user: { image, resources }`. There,
|
|
29
|
+
a field you leave out gives the User Container no limit of its own: it shares the pod's budget.
|
|
30
|
+
|
|
31
|
+
It refuses any key but `limits.memory` and `limits.cpu`, where you write it. The message names
|
|
32
|
+
the field: `<where>` is where you wrote the Size, for example `workspace(): resources`.
|
|
33
|
+
|
|
34
|
+
- `<where>.requests is not accepted — jr2 reserves the whole Size, so every request equals its
|
|
35
|
+
limit — a Size is { limits: { memory?, cpu? } } and nothing else — Agent Substrate's template
|
|
36
|
+
size (ADR-0060)`
|
|
37
|
+
- `<where>.<key> is not accepted — a Size is { limits: { memory?, cpu? } } and nothing else —
|
|
38
|
+
Agent Substrate's template size (ADR-0060)`
|
|
39
|
+
- `<where>.limits.<key> is not accepted — a Size is { limits: { memory?, cpu? } } and nothing
|
|
40
|
+
else — Agent Substrate's template size (ADR-0060)`
|
|
41
|
+
- `<where>.limits.memory: <value> is not a positive quantity (e.g. "2Gi", "512Mi")`, and for
|
|
42
|
+
cpu, `<where>.limits.cpu: <value> is not a positive quantity (e.g. "2", "1500m")`
|
|
43
|
+
|
|
44
|
+
`jr2 up` also refuses a Size that leaves the Harness container less than its floor. The message
|
|
45
|
+
starts with `the Size leaves the Harness container <memory> memory, below its 256Mi floor:` or
|
|
46
|
+
with `the Size leaves the Harness container no cpu:`. The text that follows names each number
|
|
47
|
+
and where it came from.
|
|
48
|
+
|
|
49
|
+
**Fields**
|
|
50
|
+
|
|
51
|
+
- `limits`: `object`
|
|
52
|
+
|
|
53
|
+
The two limits. Write `limits: {}` to state no field: each field then comes from the next
|
|
54
|
+
source.
|
|
55
|
+
|
|
56
|
+
- `memory` (optional): [`Quantity`](type-quantity.md)
|
|
57
|
+
|
|
58
|
+
The memory limit, as a Kubernetes quantity: `"4Gi"`, `"512Mi"`, or a number of bytes.
|
|
59
|
+
It must be more than zero. When you leave it out, it comes from the next source, as above.
|
|
60
|
+
- `cpu` (optional): [`Quantity`](type-quantity.md)
|
|
61
|
+
|
|
62
|
+
The cpu limit, as a Kubernetes quantity: `"2"`, `"1500m"`, or a number of cpus. It must be
|
|
63
|
+
more than zero. jr2 enforces it. When you leave it out, it comes from the next source, as
|
|
64
|
+
above.
|
|
65
|
+
|
|
66
|
+
**Example**
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { customize, type Size } from "@jr2/orchestrator";
|
|
70
|
+
import { task } from "@jr2/machines";
|
|
71
|
+
|
|
72
|
+
const size: Size = { limits: { memory: "4Gi", cpu: "2" } };
|
|
73
|
+
|
|
74
|
+
export const machine = customize(task, {
|
|
75
|
+
repos: { app: { url: "https://github.com/you/app.git" } },
|
|
76
|
+
agents: { coder: { model: "anthropic/claude-haiku-5-5" } },
|
|
77
|
+
resources: size,
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**See also**
|
|
82
|
+
|
|
83
|
+
- [Size a Workspace](../../guides/size-a-workspace.md)
|
|
84
|
+
- [Workspaces](../../concepts/workspaces.md)
|
|
85
|
+
- [ADR-0060: A Workspace states its Size, and jr2 reserves all of it](../decisions/0060-a-workspace-states-its-size-and-jr2-reserves-all-of-it.md)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: SlotHandles
|
|
3
|
+
description: The handles of a Workspace that declares Repo Slots.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `SlotHandles`
|
|
7
|
+
|
|
8
|
+
Type, in `@jr2/orchestrator/src/workspace.ts`. The signature of an export, or a type that it names, names this type. The [Authoring surface](../authoring-surface.md) page lists each export. This type is not an export of `@jr2/orchestrator`, so a workflow module does not import it by name.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
type SlotHandles<TSlots extends string> = {
|
|
12
|
+
repos: Record<TSlots, string>;
|
|
13
|
+
branch: string;
|
|
14
|
+
review?: Partial<Record<TSlots, string>>;
|
|
15
|
+
};
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The handles of a Workspace that declares Repo Slots. @internal
|
|
19
|
+
|
|
20
|
+
**Fields**
|
|
21
|
+
|
|
22
|
+
- `repos`: `Record<TSlots, string>`
|
|
23
|
+
|
|
24
|
+
The absolute path of each Repo Slot's Worktree, `/work/<slot>/<branch>`, in the order that
|
|
25
|
+
`repos` declares the slots. Give one to an Agent's Turn as its `cwd`.
|
|
26
|
+
- `branch`: `string`
|
|
27
|
+
|
|
28
|
+
The branch that the Workspace works on: the `branch` of the spec.
|
|
29
|
+
- `review` (optional): `Partial<Record<TSlots, string>>`
|
|
30
|
+
|
|
31
|
+
The path of each Repo Slot's review Worktree. Present only when the spec has `reviewSha`.
|
|
32
|
+
Give one to a reviewer's Turn as its `cwd`.
|