@sanoma-ai/workflows 0.11.15 → 0.11.17

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.
Files changed (117) hide show
  1. package/README.md +14 -3
  2. package/dist/app-steps.d.ts +17 -0
  3. package/dist/app-steps.js +43 -0
  4. package/dist/app-steps.js.map +1 -0
  5. package/dist/app-workflows.d.ts +170 -0
  6. package/dist/app-workflows.js +107 -0
  7. package/dist/app-workflows.js.map +1 -0
  8. package/dist/apply-steps.js +3 -9
  9. package/dist/apply-steps.js.map +1 -1
  10. package/dist/approvals.d.ts +1 -1
  11. package/dist/approvals.js +3 -0
  12. package/dist/approvals.js.map +1 -1
  13. package/dist/call.d.ts +2 -1
  14. package/dist/call.js +2 -1
  15. package/dist/call.js.map +1 -1
  16. package/dist/change-steps.js +11 -17
  17. package/dist/change-steps.js.map +1 -1
  18. package/dist/chat-steps.d.ts +5 -0
  19. package/dist/chat-steps.js +107 -0
  20. package/dist/chat-steps.js.map +1 -0
  21. package/dist/chat-workflow.d.ts +43 -0
  22. package/dist/chat-workflow.js +47 -0
  23. package/dist/chat-workflow.js.map +1 -0
  24. package/dist/chats.d.ts +23 -4
  25. package/dist/chats.js +54 -7
  26. package/dist/chats.js.map +1 -1
  27. package/dist/client.d.ts +42 -31
  28. package/dist/client.js +118 -105
  29. package/dist/client.js.map +1 -1
  30. package/dist/config.d.ts +20 -0
  31. package/dist/config.js +55 -4
  32. package/dist/config.js.map +1 -1
  33. package/dist/db/company.d.ts +259 -2
  34. package/dist/db/company.js +32 -1
  35. package/dist/db/company.js.map +1 -1
  36. package/dist/db.d.ts +15 -0
  37. package/dist/db.js +42 -2
  38. package/dist/db.js.map +1 -1
  39. package/dist/description.d.ts +6 -3
  40. package/dist/description.js +4 -3
  41. package/dist/description.js.map +1 -1
  42. package/dist/follow-steps.d.ts +8 -0
  43. package/dist/follow-steps.js +113 -0
  44. package/dist/follow-steps.js.map +1 -0
  45. package/dist/follow-workflow.d.ts +56 -0
  46. package/dist/follow-workflow.js +50 -0
  47. package/dist/follow-workflow.js.map +1 -0
  48. package/dist/index.d.ts +10 -5
  49. package/dist/index.js +9 -4
  50. package/dist/index.js.map +1 -1
  51. package/dist/local-sandbox.d.ts +10 -0
  52. package/dist/local-sandbox.js +130 -0
  53. package/dist/local-sandbox.js.map +1 -0
  54. package/dist/op.d.ts +9 -2
  55. package/dist/op.js.map +1 -1
  56. package/dist/paths.d.ts +9 -0
  57. package/dist/paths.js +20 -4
  58. package/dist/paths.js.map +1 -1
  59. package/dist/resource.d.ts +7 -1
  60. package/dist/resource.js +5 -1
  61. package/dist/resource.js.map +1 -1
  62. package/dist/run.d.ts +39 -0
  63. package/dist/run.js +15 -0
  64. package/dist/run.js.map +1 -1
  65. package/dist/sandbox-contract.d.ts +100 -0
  66. package/dist/sandbox-contract.js +26 -0
  67. package/dist/sandbox-contract.js.map +1 -0
  68. package/dist/sandbox.d.ts +10 -0
  69. package/dist/sandbox.js +42 -4
  70. package/dist/sandbox.js.map +1 -1
  71. package/dist/scenario.d.ts +19 -0
  72. package/dist/scenario.js.map +1 -1
  73. package/dist/schedules.d.ts +11 -3
  74. package/dist/schedules.js +15 -3
  75. package/dist/schedules.js.map +1 -1
  76. package/dist/seal.d.ts +7 -0
  77. package/dist/seal.js +14 -2
  78. package/dist/seal.js.map +1 -1
  79. package/dist/shared.d.ts +34 -2
  80. package/dist/shared.js +39 -2
  81. package/dist/shared.js.map +1 -1
  82. package/dist/worker.d.ts +8 -0
  83. package/dist/worker.js +116 -10
  84. package/dist/worker.js.map +1 -1
  85. package/drizzle/company/0002_runs_tell_the_app.sql +27 -0
  86. package/drizzle/company/meta/0002_snapshot.json +819 -0
  87. package/drizzle/company/meta/_journal.json +7 -0
  88. package/package.json +1 -1
  89. package/src/app-steps.ts +67 -0
  90. package/src/app-workflows.ts +251 -0
  91. package/src/apply-steps.ts +3 -9
  92. package/src/approvals.ts +3 -1
  93. package/src/call.ts +2 -1
  94. package/src/change-steps.ts +10 -17
  95. package/src/chat-steps.ts +117 -0
  96. package/src/chat-workflow.ts +69 -0
  97. package/src/chats.ts +80 -14
  98. package/src/client.ts +154 -109
  99. package/src/config.ts +66 -3
  100. package/src/db/company.ts +49 -2
  101. package/src/db.ts +51 -3
  102. package/src/description.ts +4 -3
  103. package/src/follow-steps.ts +129 -0
  104. package/src/follow-workflow.ts +88 -0
  105. package/src/index.ts +32 -3
  106. package/src/local-sandbox.ts +132 -0
  107. package/src/op.ts +9 -2
  108. package/src/paths.ts +22 -4
  109. package/src/resource.ts +16 -2
  110. package/src/run.ts +41 -0
  111. package/src/sandbox-contract.ts +114 -0
  112. package/src/sandbox.ts +41 -4
  113. package/src/scenario.ts +17 -0
  114. package/src/schedules.ts +19 -4
  115. package/src/seal.ts +16 -2
  116. package/src/shared.ts +47 -2
  117. package/src/worker.ts +149 -10
package/README.md CHANGED
@@ -61,7 +61,7 @@ A model connector attaches a model half, as `model`: `withSetup(connector, { mod
61
61
 
62
62
  A git host's connector attaches a remote half, as `remote`: `withSetup(connector, { remote: () => half })`, a `RemoteHalf` made once per resolved config and kept in `ResolvedConfig.remotes` by vendor; `remoteFor(remotes, url)` finds the one whose `matches` reads a clone URL, with the repository. `open(repo, { secrets })` gives a `SourceHost`: the repository's pull requests (find, open, squash-merge at a head, close), the `sanoma` commit status, and `enforcement(base)`, whether the host refuses a change to the branch that is not a merge (`HostEnforcement`); its `token(prefer)` is what a push signs in with. `webhook(request, { secrets })` verifies a delivery and says what happened (`RemoteEvent`: a branch pushed, a pull request closed); `owners({ secrets })` lists the accounts the company's app on the host is installed on, and `permissions({ secrets })` what that app may do, as the host lists it (both optional, undefined or empty without the app's keys). It reads its tokens through `secrets` when called, as a model half does. One vendor's connectors attach one `remote`. [`@sanoma-ai/connector-github`](https://www.npmjs.com/package/@sanoma-ai/connector-github#remote-half) is one.
63
63
 
64
- `SanomaClient.remoteEvent(event, { by })` does what a webhook says happened (the app's `POST /webhooks/<vendor>` calls it for each event), for the repository of the client's `source` (`SanomaClient.connect(config, { source })`, as the worker's): an event of another repository, or with no source, is ignored. A push to `main` starts apply on the declared hosts (`ResolvedConfig.hosts()`) as the runtime's agent `host-check`, as the run `deploy:<head>`, so a merge made outside Sanoma deploys too: nothing without a host, nor while a change is merging or deploying, which applies `main` itself, nor when the checkout cannot follow `main` first (warned: a redelivery deploys it). A push to `draft/<id>` while the change of `id` is open brings the host's commits into the draft (`Source.follow` on its branch, a fast-forward) and tells the change `commits`; a closed pull request of `draft/<id>` tells it `merged` (with the merge commit) or `closed`, as `by`. The change run checks a merge or a close on the host before it believes it. A delivery repeated does nothing more: the run id, a draft already at the head, and the event's key (`changeEvent`'s `key`, an idempotency key of its message) see to it. `by` is not the Publish approval's approver, so it withdraws nothing: a change waiting on Publish reads the event when Publish is decided.
64
+ `SanomaClient.follow(event)` starts the built-in `follow` workflow on what a webhook says happened (the app's `POST /webhooks/<vendor>` calls it for each event it verified), as the runtime's agent `host-check`, with the run id `follow:<sha256 of the event>`: one run per event, however often it is delivered, and `start` refuses a `follow` under another id or actor. The worker runs it over its repository (`WorkerOptions.source`): an event of another repository, or on a worker with none, is ignored (the run's output says why). A push to `main` fast-forwards the checkout, then starts apply on the declared hosts (`ResolvedConfig.hosts()`) as `host-check`, as the run `deploy:<head>`, so a merge made outside Sanoma deploys too: nothing without a host, nor while a change is merging or deploying, which applies `main` itself; when the checkout cannot follow `main`, the run fails, saying why, and deploys nothing. A push to `draft/<id>` while the change of `id` is open brings the host's commits into the draft (`Source.follow` on its branch, a fast-forward) and tells the change `commits`; a closed pull request of `draft/<id>` tells it `merged` (with the merge commit) or `closed`. The change run checks a merge or a close on the host before it believes it. A delivery repeated does nothing more: the run id, a draft already at the head, and the event's key (`changeEvent`'s `key`, an idempotency key of its message) see to it. `host-check` is not the Publish approval's approver, so it withdraws nothing: a change waiting on Publish reads the event when Publish is decided.
65
65
 
66
66
  A config names the connectors, and the workflows when no launcher finds them (`sanoma` imports every file of `workflows/` and of each [app's](#apps), so a company's config lists none; one it lists is kept, once):
67
67
 
@@ -80,7 +80,7 @@ That is the whole config; the rest is convention, from its `root` (`defineConfig
80
80
  - **The [scenarios](#scenarios-and-sandbox-runs)** are the `.feature` files of `<root>/scenarios/` and of each [app's](#apps) `scenarios/`, named by their path from the root (`scenarios/x.feature`, `apps/crm/scenarios/y.feature`); without any such directory the config has none.
81
81
  - **The [policy](#policies)** is `<root>/policies/**/*.cedar` and each [app's](#apps) `policies/**/*.cedar`, decided as the [people](#people) the data files declare; without any, every call and start is allowed (`allowAll`).
82
82
 
83
- The [data files](#data-files) are `resources/` in the root and in each [app](#apps). `ledger` and `databaseUrl` configure persistence; `secrets`, `connections` and `connectionRules` configure [credential storage and account identity](#credentials). `drivers`, `fakes`, `appName`, `scenarios` and `policy` are typed `never` on `SanomaConfig`, each deprecated with where it went, so the compiler and the editor say so; an untyped config that still names `drivers` or `fakes` is refused at run time rather than run live on what it no longer reads, and one that names `policy` rather than run allowing everything.
83
+ The [data files](#data-files) are `resources/` in the root and in each [app](#apps). `ledger` and `databaseUrl` configure persistence; `secrets`, `connections` and `connectionRules` configure [credential storage and account identity](#credentials). `drivers`, `fakes`, `appName`, `scenarios` and `policy` are typed `never` on `SanomaConfig`, each deprecated with where it went, so the compiler and the editor say so; an untyped config that still names `drivers` or `fakes` is refused at run time rather than run live on what it no longer reads, and one that names `policy` rather than run allowing everything. A worker looks for queued runs every second, DBOS's default; `SANOMA_QUEUE_POLL_MS` sets that in milliseconds, as this repository's tests do.
84
84
 
85
85
  The audit record goes to the ledger, by default `postgresLedger(databaseUrl)` on the config's database (see [Ledger](#ledger)); `ledger: jsonlLedger(dir)` keeps it in files instead, and `memoryLedger()` in this process only, for tests. `resolveConfig(config)` checks a config and derives what the runtime uses from it: the app name, database, version and queue (`sanoma:<appName>`, for every run, [sandbox runs](#scenarios-and-sandbox-runs) included), the operations by id, the driver each vendor's connector attaches, made once for the resolution (`driversByVendor`, in `connectors` order, and their functions by operation id, `drivers`), the makers of their fakes (`fakes`, by vendor), the scenarios directory, the policy (`policy`, the policies it is made from as `policies`, and what is wrong in them as `policyProblems`), and the config's `ledger` when it gives one; it opens nothing and reads no file outside the root: its `package.json`, whether `scenarios/` is a directory, and the policies with the people files. It throws, with one message, whatever the worker would refuse: a workflow or driver naming an operation the `connectors` don't declare, a workflow redeclaring an operation with another effect, an operation with no driver (`` `shop.order.refund` has no driver: the connector package must attach one ``), two different drivers or fakes for one vendor, two workflows with one name, a `ledger` that is not a store, a `drivers`, `fakes` or `policy` an untyped config still names. `startWorker`, `SanomaClient.connect` and `describeConfig` all call it, so they fail the same way. It adds the built-in [`drift`](#drift) and [`apply`](#apply) workflows when the connectors declare resource types, and [`call`](#direct-calls) when an operation may be called directly. The worker takes each operation's effect, schemas and retry setting from `connectors`, never from the workflow.
86
86
 
@@ -208,7 +208,7 @@ The approver is a person's id (`"finance-lead"`), or `{ group: "finance" }` for
208
208
 
209
209
  A policy hold's approval also carries the held call: its `op`, its parsed `input`, `opSeq`, the ledger `seq` of the call's `op.called` record, so a UI can show the hold on the call it held, and `reasons`, the ids of the policies that held it.
210
210
 
211
- The policy decides a run's start too, as the action `workflow:<name>` with the input as its context, before `client.start` queues it (the built-in `call`, `apply` and `drift` are not asked; their calls are). A deny throws `policy_denied` and starts nothing; a hold starts the run, which waits on the approval (`op: "workflow:<name>"`, no `opSeq`) before its body runs, and fails if it is rejected.
211
+ The policy decides a run's start too, as the action `workflow:<name>` with the input as its context, before `client.start` queues it (the built-ins, `call`, `apply`, `drift` and the app's actions among them, are not asked; their calls are, and a visitor starts none but `call`). A deny throws `policy_denied` and starts nothing; a hold starts the run, which waits on the approval (`op: "workflow:<name>"`, no `opSeq`) before its body runs, and fails if it is rejected.
212
212
 
213
213
  `client.decide(runId, { decision, by, note? }, approvalId?, { timeoutSeconds? })` refuses without sending when the approval is decided already (`already_decided`), when the run has finished, failed or been cancelled (`run_ended`: no run would read the decision), when there is nothing pending (`no_pending_approval`, `run_not_found`) or when `by` may not decide (`not_approver`, naming the approver or group). Otherwise it sends the decision and waits for the run to read it, then returns the approval as decided: the run publishes it on the event `decisionEventOf(approvalId)`. If another decision reached the run first (someone else's, or another of yours), it throws `already_decided` with who decided and how: each message carries an `id` (a new one unless `message.id` is given), and the approval records the one it was decided with as `decidedWith`. The id is also the send's idempotency key, scoped to the approval, so a retried send queues one message. If the run does not read the decision within `timeoutSeconds` (30 by default), for instance because no worker is running, it returns the approval still `pending`; the decision stays queued and the run reads it when it next runs. The run checks the sender again and records anything it refuses as `approval.refused`; when it refuses this decision, `decide` throws `not_approver` rather than returning the approval pending.
214
214
 
@@ -227,6 +227,12 @@ A change is how an edit to the company's repository goes live once the repositor
227
227
  - **Who publishes.** A change to the rules (a policy, the root's or an app's, a people file, or a helper one imports) waits for `admin` whatever the policies say ([Policies](#policies)). A new company's `policies/changes.cedar` holds every other change for `admin` too; replace it with rules on the change's facts when another group should own part of the repository.
228
228
  - **The Permissions line.** Under the Permissions grid the app says what the repository's host enforces on `main` (`SourceHost.enforcement`): a pull request, and the `sanoma` check. Where it enforces neither (a private repository on GitHub Free), a push to `main` that does not go through Sanoma is neither reviewed nor decided by the policy.
229
229
 
230
+ ### The app's actions
231
+
232
+ What the app does to the company's repository is a run of a built-in workflow, never a write in the app's own process, so it works wherever the app is served (a Node process, a Cloudflare Worker) as long as a worker runs: `adopt` (a drifted field's value at the vendor written into its data file), `patch` (a form's Save), `go-live` and `go-live-host` (`infra.ts` written, then `main` pushed) and `connect-existing` (their names are `@sanoma-ai/workflows/shared`'s `ADOPT_WORKFLOW` and the rest). `resolveConfig` adds them to every config, so a company workflow may not take their names, and `describeConfig` lists them with `builtin: true`. Each takes a zod input (`AdoptInput`, `PatchInput`, `GoLiveInput`, `GoLiveHostInput`, `ConnectExistingInput`), refused at the start, and its run is a step: the app's page starts it and polls its `.result`.
233
+
234
+ What each does is the app's, given to the worker as `AppSteps` (`startWorker(config, { app, source })`; `sanoma serve` and `sanoma worker` give theirs, `@sanoma-ai/app/steps`). The run calls its step in a DBOS step of its own (`app:<name>`) with an `AppStepContext`: the worker's own `SanomaClient` (connected on first use, closed when the worker stops), its `source` and `serially`, the worker's one lock on it, which a step holds around reading, writing and committing the checkout, the config and its resolution, who started the run (`by`) and the run's id. A step refuses by throwing: a `SanomaError` whose code and data the page reads (`invalid_input` with its `issues` or a `field`, `not_approver`), else an error whose message the run fails with. A step that applies after its write answers what to apply (`{ apply }`), which the run starts as its child, `<run>:apply`, as its own actor, and answers that run's id without waiting for it: an apply may wait for its plan's approval in the Inbox. On a worker without app steps each run fails, saying so. The pages call them through `api`, typed as `AppApi`.
235
+
230
236
  ### Calls run one at a time
231
237
 
232
238
  A run's ctx calls run one at a time, in program order. Even inside `Promise.all`, each call waits for the one before it to settle, so two calls a policy holds for approval are asked for one after the other. DBOS matches a replayed call to its recorded result by the order calls reach it, so calls left to race would replay out of step. A call that fails rejects its caller. The calls queued after it still run only if the workflow catches the failure and goes on; otherwise the body has ended, and each queued call is refused with `run_ended` (the run has ended, so the call is never made) instead of reaching its vendor, an approver or a sleep. Write calls one after another, as the workflow means them, and a fan-out with `ctx.all`.
@@ -673,6 +679,10 @@ A database is a resource type that holds the company's database (a Neon project,
673
679
 
674
680
  `databaseUrlSecret` converts camel-case exports to uppercase words (`mainStore` → `SANOMA_DATABASE_URL_MAIN_STORE`) and preserves exports that are already uppercase, including digits and underscores (`CLOUD_ACME_97F9` → `SANOMA_DATABASE_URL_CLOUD_ACME_97F9`). Use the same export when storing, binding and retiring its URL.
675
681
 
682
+ ### Sandboxes
683
+
684
+ A sandbox is a resource type whose boxes a coding agent works in (an Agent37 instance): `defineResource({ …, writable: true, sandbox })`, where `sandbox` (`SandboxSpec`) says what its boxes can do (`capabilities: { snapshot, pause, port }`: their files survive a stop; a stopped box keeps its memory; a port is reachable from outside), where it takes a box's image and its size in vCPUs, by dotted path into its fields (`inputs: { image, size }`), and how its state reads (`outputs(state) → { id, healthy }`). The vendor's own facts (region, machine type) are fields of the resource, never the environment. Its connector attaches the backend (`withSetup(connector, { sandbox: ({ secrets }) => backend })`): `open({ name, image, size })` gives the box `name`, made, woken or started as it needs, and `discard({ name })` deletes it and all the vendor kept. A `Box` runs `bash -c` (`run(command, { cwd, env, stdin, signal })` → a `Process` of web streams, `wait()` and `kill()`), reads and writes files (a relative path is under its home), exposes a port (`expose(port)` → `{ url, headers? }`) and stops. `localBackend(dir, env?)` is the backend on this machine: a box is the directory `<dir>/<name>`, its commands children in process groups of their own (`LOCAL_SANDBOX`: it snapshots and exposes ports on loopback). `ResolvedConfig.sandboxes()` names the declared ones. `defineResource` refuses a `sandbox` that breaks any of that. Its conformance kit is [`@sanoma-ai/testing/sandbox`](../testing/README.md#a-sandboxs-conformance).
685
+
676
686
  ### Secrets
677
687
 
678
688
  Never put a secret in a workflow's input or an operation's input or output. They are persisted verbatim: DBOS keeps every step's input and output in Postgres, the ledger records each call's input and output, an approval a policy asks for carries the held call's input, and the app shows all of it to anyone who can reach it. A driver reads its credentials when it is called (from the environment or a secret store), and an operation that creates a secret (an API key, a password reset link) returns a reference to where it is stored, not the secret.
@@ -841,6 +851,7 @@ Start a sandbox run with `client.start(workflow, input, { startedBy, sandbox: "<
841
851
  - calls its own fakes, never a driver, under the same policy and approvals as a live run.
842
852
  - does not wait on `ctx.sleep`: it still records `sleep.started` with the real `until`, and goes straight on.
843
853
  - runs it on the app's queue, as any run: sandbox runs share no fakes, so several run at once, and one waiting on an approval holds up no other.
854
+ - checks it against its scenario as it starts to wait on an approval and once it ends (its outcome recorded, before DBOS records it): Cucumber runs the scenario's `Then` steps over the feature file as it reads then, against the ledger so far, and the answers (`RunChecks`: each `Check` with whether it is `settled`, or why there are none) go to the runtime's table, which `client.runChecks(runId)` reads. No step and no ledger record: what the run does never depends on them.
844
855
  - prints nothing of it through DBOS's log: none of DBOS's warnings from inside it (a step's failed try among them: a fake's `fails once` is on purpose), nor the error the run fails with. Its ledger and its status say what happened; a live run's tries and failures print as ever.
845
856
 
846
857
  A sandbox run does not survive a worker restart: its fakes keep their state in the worker's memory, so a run whose seeding DBOS replays from its checkpoint (after a restart, or in a fork) fails with `invalid_input`, "Sandbox run … was interrupted by a worker restart and the fakes' state is gone; start the scenario again", rather than going on against fakes in some other state.
@@ -0,0 +1,17 @@
1
+ import type { AppRunner, AppStepContext, AppSteps } from "./app-workflows.ts";
2
+ import type { ResolvedConfig, SanomaConfig } from "./config.ts";
3
+ import { type Run } from "./run.ts";
4
+ /** What a worker started with the app's steps keeps for them (`WorkerState.appSteps`). */
5
+ export interface WorkerApp {
6
+ steps: AppSteps;
7
+ config: SanomaConfig;
8
+ resolved: ResolvedConfig;
9
+ }
10
+ /** What a worker started without the app's steps answers a run of one of the app's built-ins. */
11
+ export declare const NO_APP_STEPS = "This worker runs none of the app's actions: start it with the app's steps (`WorkerOptions.app`), as `sanoma serve` and `sanoma worker` do";
12
+ /** The app's steps the run's worker was given; thrown, saying `missing`, when it was given none. */
13
+ export declare function appStepsOf(run: Run, missing: string): WorkerApp;
14
+ /** What the run's app step is given (`AppStepContext`): the worker's own client, connected on first use, and what the worker has. */
15
+ export declare function stepContext(run: Run, { config, resolved }: WorkerApp): Promise<AppStepContext>;
16
+ /** The runner the app's built-ins run their work through. */
17
+ export declare const appRunner: AppRunner;
@@ -0,0 +1,43 @@
1
+ import { DBOS } from "@dbos-inc/dbos-sdk";
2
+ import { runNow } from "./run.js";
3
+ import { APPLY_WORKFLOW } from "./shared.js";
4
+ /** What a worker started without the app's steps answers a run of one of the app's built-ins. */
5
+ export const NO_APP_STEPS = "This worker runs none of the app's actions: start it with the app's steps (`WorkerOptions.app`), as `sanoma serve` and `sanoma worker` do";
6
+ /** The app's steps the run's worker was given; thrown, saying `missing`, when it was given none. */
7
+ export function appStepsOf(run, missing) {
8
+ const app = run.state.appSteps;
9
+ if (!app)
10
+ throw new Error(missing);
11
+ return app;
12
+ }
13
+ /** What the run's app step is given (`AppStepContext`): the worker's own client, connected on first use, and what the worker has. */
14
+ export async function stepContext(run, { config, resolved }) {
15
+ const { state } = run;
16
+ return {
17
+ client: await state.client(),
18
+ ...(state.source && { source: state.source }),
19
+ serially: state.serially,
20
+ config,
21
+ resolved,
22
+ by: run.actor,
23
+ runId: run.id,
24
+ };
25
+ }
26
+ /** The app's step `name` with `input`, in a DBOS step of the run's (`app:<name>`). */
27
+ function step(run, name, input) {
28
+ const app = appStepsOf(run, NO_APP_STEPS);
29
+ return DBOS.runStep(async () => app.steps[name](await stepContext(run, app), input), { name: `app:${name}` });
30
+ }
31
+ /** The runner the app's built-ins run their work through. */
32
+ export const appRunner = {
33
+ step: (name, input) => step(runNow("An app step"), name, input),
34
+ async stepThenApply(name, input) {
35
+ const run = runNow("An app step");
36
+ const { apply, ...rest } = await step(run, name, input);
37
+ // Its child, as its own actor, not waited for: an apply may wait for its plan's approval.
38
+ const runId = `${run.id}:apply`;
39
+ await run.state.startRun(APPLY_WORKFLOW, runId, { input: apply, startedBy: run.actor });
40
+ return { ...rest, runId };
41
+ },
42
+ };
43
+ //# sourceMappingURL=app-steps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-steps.js","sourceRoot":"","sources":["../src/app-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,OAAO,EAAY,MAAM,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAa7C,iGAAiG;AACjG,MAAM,CAAC,MAAM,YAAY,GACvB,2IAA2I,CAAC;AAE9I,oGAAoG;AACpG,MAAM,UAAU,UAAU,CAAC,GAAQ,EAAE,OAAe;IAClD,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC/B,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IACnC,OAAO,GAAG,CAAC;AACb,CAAC;AAED,qIAAqI;AACrI,MAAM,CAAC,KAAK,UAAU,WAAW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AAE,QAAQ,CAAC;QAChC,MAAM,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;QACxF,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF,CAAC"}
@@ -0,0 +1,170 @@
1
+ import { z } from "zod";
2
+ import type { ApplyInput } from "./apply.ts";
3
+ import type { ChatTurnInput, ChatTurnOutput } from "./chat-workflow.ts";
4
+ import type { ResolvedConfig, SanomaConfig } from "./config.ts";
5
+ import type { SanomaClient } from "./client.ts";
6
+ import { type Principal, type WorkflowDefinition } from "./define.ts";
7
+ import type { WorkflowFn } from "./shared.ts";
8
+ import type { Source } from "./source.ts";
9
+ /** Adopt's input: a drift run, a resource it found drifted, and the fields whose value at the vendor to write into the resource's data file. */
10
+ export declare const AdoptInput: z.ZodObject<{
11
+ runId: z.ZodString;
12
+ id: z.ZodString;
13
+ paths: z.ZodArray<z.ZodString>;
14
+ }, z.core.$strip>;
15
+ export type AdoptInput = z.infer<typeof AdoptInput>;
16
+ /**
17
+ * A form's Save: a declaration the description names (a resource, a collection, a site or an
18
+ * app, by its `at`), and the fields to set in it, by dotted path as `setFields` takes them, each
19
+ * to a JSON value.
20
+ */
21
+ export declare const PatchInput: z.ZodObject<{
22
+ at: z.ZodObject<{
23
+ file: z.ZodString;
24
+ export: z.ZodString;
25
+ }, z.core.$strict>;
26
+ fields: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
27
+ }, z.core.$strip>;
28
+ export type PatchInput = z.infer<typeof PatchInput>;
29
+ /**
30
+ * What going live chooses: who holds the repository, the database's region (and size, when it
31
+ * takes one), Supabase's organization for a Supabase project, the host's port.
32
+ */
33
+ export declare const GoLiveInput: z.ZodObject<{
34
+ owner: z.ZodString;
35
+ name: z.ZodString;
36
+ organization: z.ZodOptional<z.ZodString>;
37
+ region: z.ZodString;
38
+ size: z.ZodOptional<z.ZodString>;
39
+ database: z.ZodOptional<z.ZodString>;
40
+ host: z.ZodOptional<z.ZodString>;
41
+ port: z.ZodNumber;
42
+ }, z.core.$strip>;
43
+ export type GoLiveInput = z.infer<typeof GoLiveInput>;
44
+ /** Going live's second half takes nothing: what it pushes and applies is in `infra.ts`. */
45
+ export declare const GoLiveHostInput: z.ZodObject<{}, z.core.$strict>;
46
+ export type GoLiveHostInput = z.infer<typeof GoLiveHostInput>;
47
+ /** An existing GitHub repository (`owner/name`: the owner is always written) and a Supabase project's ref, either or both. */
48
+ export declare const ConnectExistingInput: z.ZodObject<{
49
+ repository: z.ZodOptional<z.ZodString>;
50
+ project: z.ZodOptional<z.ZodString>;
51
+ }, z.core.$strip>;
52
+ export type ConnectExistingInput = z.infer<typeof ConnectExistingInput>;
53
+ /** A data file written, relative to the root, and its commit, when the worker has a repository. */
54
+ export interface Written {
55
+ file: string;
56
+ revision?: string;
57
+ }
58
+ /** What a Save lands as: the change opened for review (its run id), when the repository has a remote; otherwise the file written. */
59
+ export type PatchOutput = {
60
+ change: string;
61
+ } | Written;
62
+ /** What going live's runs answer: the apply run each started (`<run>:apply`), which the page follows. */
63
+ export interface GoLiveOutput {
64
+ runId: string;
65
+ }
66
+ /**
67
+ * What connecting answers: the data file it wrote and its text; its commit, on `branch` (with its
68
+ * `diff`) when the repository has a remote and the change waits for a person to merge it; and the
69
+ * apply run that binds what it declares.
70
+ */
71
+ export interface ConnectExistingOutput extends Written {
72
+ text: string;
73
+ branch?: string;
74
+ diff?: string;
75
+ runId: string;
76
+ }
77
+ /**
78
+ * What an app step is given: the worker's own client (connected on first use, closed when the
79
+ * worker stops), its repository (`WorkerOptions.source`) and the lock its writes there take, the
80
+ * config and its resolution, who started the run (`by`, as `SanomaClient.start` admitted them)
81
+ * and the run's id.
82
+ */
83
+ export interface AppStepContext {
84
+ client: SanomaClient;
85
+ source?: Source;
86
+ /**
87
+ * Runs `write` once the worker's write before it has settled (`WorkerState.serially`): what a step
88
+ * holds around reading and writing the checkout and committing, so two never write one file.
89
+ */
90
+ serially<T>(write: () => Promise<T>): Promise<T>;
91
+ config: SanomaConfig;
92
+ resolved: ResolvedConfig;
93
+ by: Principal;
94
+ runId: string;
95
+ }
96
+ /**
97
+ * What a chat turn's step is given besides an app step's: when to stop (a new message came, or the
98
+ * worker stopped), a way to take the sign-in codes the person pastes for this turn, and whether
99
+ * the turn had begun before, on a worker that restarted under it.
100
+ */
101
+ export interface ChatTurnContext extends AppStepContext {
102
+ signal: AbortSignal;
103
+ /** Hands each code pasted for this turn (`SanomaClient.turnCode`) to `listener`, until the function it returns is called. */
104
+ onCode(listener: (code: string) => void): () => void;
105
+ /** The turn had begun (`Chats.begin`) before the worker restarted: it settles what it left, and runs nothing again. */
106
+ resumed: boolean;
107
+ }
108
+ /**
109
+ * The app's own actions, which a worker runs (`WorkerOptions.app`): one method per built-in
110
+ * workflow of the app's, each called in a DBOS step of its run, its writes to the checkout under
111
+ * `AppStepContext.serially`. A step refuses by throwing: a `SanomaError` with the code the page
112
+ * branches on (`invalid_input` with its `issues`, or a `field`; `not_approver`), else an error
113
+ * whose message the page shows. What a step returns is checkpointed, so it is JSON. One that
114
+ * applies after its write returns what apply plans (`apply`), which its run starts as a child.
115
+ */
116
+ export interface AppSteps {
117
+ /** Adopt: what the vendor holds for drifted fields, by the drift run's report, into their data file, committed. */
118
+ adopt(step: AppStepContext, input: AdoptInput): Promise<Written>;
119
+ /** A form's Save: the fields set in the declaration's file, as a change for review with a remote, else written and committed. */
120
+ patch(step: AppStepContext, input: PatchInput): Promise<PatchOutput>;
121
+ /** Going live's first half: `infra.ts` written for the choices and committed; what apply makes first. */
122
+ goLive(step: AppStepContext, input: GoLiveInput): Promise<{
123
+ apply: ApplyInput;
124
+ }>;
125
+ /** Going live's second half: `main` pushed to the repository apply made; the host (and its wakeup) to apply. */
126
+ goLiveHost(step: AppStepContext, input: GoLiveHostInput): Promise<{
127
+ apply: ApplyInput;
128
+ }>;
129
+ /** An existing repository and/or project declared in `infra.ts` and committed; the apply that only binds them. */
130
+ connectExisting(step: AppStepContext, input: ConnectExistingInput): Promise<Omit<ConnectExistingOutput, "runId"> & {
131
+ apply: ApplyInput;
132
+ }>;
133
+ /**
134
+ * A chat turn: the reply to the person's message, by the chat's engine, written to the chat's
135
+ * transcript and, as it streams, to its chunks (`Chats.append`, then `Chats.end`). It writes its
136
+ * own draft, not the checkout.
137
+ */
138
+ chat(step: ChatTurnContext, input: ChatTurnInput): Promise<ChatTurnOutput>;
139
+ }
140
+ /** The app's steps an action's run calls (`AppRunner`): all but the chat's turn, which its own workflow runs. */
141
+ export type AppAction = Exclude<keyof AppSteps, "chat">;
142
+ /** The actions whose step answers what to apply after its write. */
143
+ type Applying = {
144
+ [K in AppAction]: Awaited<ReturnType<AppSteps[K]>> extends {
145
+ apply: ApplyInput;
146
+ } ? K : never;
147
+ }[AppAction];
148
+ /** What a built-in of the app's runs its work through (`appRunner`, in `app-steps.ts`). */
149
+ export interface AppRunner {
150
+ /** The app's step `name` with `input`, in a DBOS step of this run; refused when the worker runs no app steps. */
151
+ step<K extends AppAction>(name: K, input: Parameters<AppSteps[K]>[1]): ReturnType<AppSteps[K]>;
152
+ /**
153
+ * The step, then the apply it answers started as a child run of this one (`<run>:apply`), as its
154
+ * own actor, without waiting for it: what the step answered besides, with that run's id.
155
+ */
156
+ stepThenApply<K extends Applying>(name: K, input: Parameters<AppSteps[K]>[1]): Promise<Omit<Awaited<ReturnType<AppSteps[K]>>, "apply"> & {
157
+ runId: string;
158
+ }>;
159
+ }
160
+ /** The app's built-ins as its pages call them, by api name (`apiNameOf`): started, then their `.result` polled. */
161
+ export interface AppApi {
162
+ adopt: WorkflowFn<AdoptInput, Written>;
163
+ patch: WorkflowFn<PatchInput, PatchOutput>;
164
+ goLive: WorkflowFn<GoLiveInput, GoLiveOutput>;
165
+ goLiveHost: WorkflowFn<GoLiveHostInput, GoLiveOutput>;
166
+ connectExisting: WorkflowFn<ConnectExistingInput, ConnectExistingOutput>;
167
+ }
168
+ /** The built-in workflows of the app's actions, over `runner`: `resolveConfig` adds them to every config. */
169
+ export declare function appWorkflows(runner: AppRunner): WorkflowDefinition<any, any>[];
170
+ export {};
@@ -0,0 +1,107 @@
1
+ import { z } from "zod";
2
+ import { defineWorkflow } from "./define.js";
3
+ import { AtSchema } from "./description.js";
4
+ // The app's own actions on the company's repository, as built-in workflows: the app starts each
5
+ // (its pages through `api.<name>`, polling `.result`) and the worker runs it, since only the
6
+ // worker has the checkout. What each does is the app's, given to the worker as `AppSteps`
7
+ // (`WorkerOptions.app`, `@sanoma-ai/app/steps`), and each is called in a step of its own run
8
+ // (`app-steps.ts`), its writes to the checkout one at a time per worker. Workflows like any other, held to
9
+ // the same lint: no DBOS here, and no operation, so nothing goes through `ctx`.
10
+ /** Adopt's input: a drift run, a resource it found drifted, and the fields whose value at the vendor to write into the resource's data file. */
11
+ export const AdoptInput = z.object({
12
+ runId: z.string().min(1),
13
+ id: z.string().min(1),
14
+ paths: z.array(z.string().min(1)).min(1),
15
+ });
16
+ /**
17
+ * A form's Save: a declaration the description names (a resource, a collection, a site or an
18
+ * app, by its `at`), and the fields to set in it, by dotted path as `setFields` takes them, each
19
+ * to a JSON value.
20
+ */
21
+ export const PatchInput = z.object({
22
+ at: AtSchema,
23
+ fields: z.record(z.string().min(1), z.json()).refine((fields) => Object.keys(fields).length > 0, "Set a field"),
24
+ });
25
+ /**
26
+ * What going live chooses: who holds the repository, the database's region (and size, when it
27
+ * takes one), Supabase's organization for a Supabase project, the host's port.
28
+ */
29
+ export const GoLiveInput = z.object({
30
+ owner: z.string().regex(/^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$/, "Choose a GitHub account or organization"),
31
+ /** The repository's name, and the database's and the host's. */
32
+ name: z
33
+ .string()
34
+ .regex(/^[a-z0-9][a-z0-9-]{0,62}$/, "Lower case letters, digits and hyphens, starting with a letter or digit"),
35
+ organization: z.string().min(1, "Choose a Supabase organization").optional(),
36
+ region: z.string().min(1, "Choose a region"),
37
+ size: z.string().min(1).optional(),
38
+ /** The database type the page showed (`GoLiveChoices.database`): refused when going live would now choose another. */
39
+ database: z.string().min(1).optional(),
40
+ /** The host type the page showed (`GoLiveChoices.host`): refused when going live would now choose another. */
41
+ host: z.string().min(1).optional(),
42
+ port: z.number().int().min(1024, "A port from 1024").max(65535, "A port up to 65535"),
43
+ });
44
+ /** Going live's second half takes nothing: what it pushes and applies is in `infra.ts`. */
45
+ export const GoLiveHostInput = z.strictObject({});
46
+ /** An existing GitHub repository (`owner/name`: the owner is always written) and a Supabase project's ref, either or both. */
47
+ export const ConnectExistingInput = z
48
+ .object({
49
+ repository: z
50
+ .string()
51
+ .trim()
52
+ .regex(/^[\w-]+\/(?!\.\.?$)[\w.-]+$/, "Enter a repository as owner/name")
53
+ .optional(),
54
+ project: z
55
+ .string()
56
+ .trim()
57
+ .regex(/^[a-z0-9]+$/, "Enter a project's ref: lowercase letters and digits")
58
+ .optional(),
59
+ })
60
+ .refine((r) => r.repository || r.project, { message: "Enter a repository, a project's ref, or both" });
61
+ /** The built-in workflows of the app's actions, over `runner`: `resolveConfig` adds them to every config. */
62
+ export function appWorkflows(runner) {
63
+ return [
64
+ defineWorkflow({
65
+ // The literal, held to the one name: the outline finds a workflow by a string, or a const of its own file.
66
+ name: "adopt",
67
+ title: "Adopt a vendor's value",
68
+ trigger: "manual",
69
+ input: AdoptInput,
70
+ uses: [],
71
+ run: async (_ctx, input) => runner.step("adopt", input),
72
+ }),
73
+ defineWorkflow({
74
+ name: "patch",
75
+ title: "Save a declaration",
76
+ trigger: "manual",
77
+ input: PatchInput,
78
+ uses: [],
79
+ run: async (_ctx, input) => runner.step("patch", input),
80
+ }),
81
+ defineWorkflow({
82
+ name: "go-live",
83
+ title: "Go live",
84
+ trigger: "manual",
85
+ input: GoLiveInput,
86
+ uses: [],
87
+ run: async (_ctx, input) => runner.stepThenApply("goLive", input),
88
+ }),
89
+ defineWorkflow({
90
+ name: "go-live-host",
91
+ title: "Push and run the host",
92
+ trigger: "manual",
93
+ input: GoLiveHostInput,
94
+ uses: [],
95
+ run: async (_ctx, input) => runner.stepThenApply("goLiveHost", input),
96
+ }),
97
+ defineWorkflow({
98
+ name: "connect-existing",
99
+ title: "Connect an existing repository or database",
100
+ trigger: "manual",
101
+ input: ConnectExistingInput,
102
+ uses: [],
103
+ run: async (_ctx, input) => runner.stepThenApply("connectExisting", input),
104
+ }),
105
+ ];
106
+ }
107
+ //# sourceMappingURL=app-workflows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-workflows.js","sourceRoot":"","sources":["../src/app-workflows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAE,cAAc,EAA2C,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAW5C,gGAAgG;AAChG,6FAA6F;AAC7F,0FAA0F;AAC1F,6FAA6F;AAC7F,2GAA2G;AAC3G,gFAAgF;AAEhF,gJAAgJ;AAChJ,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CACzC,CAAC,CAAC;AAGH;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,EAAE,EAAE,QAAQ;IACZ,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,C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,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAyB,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC;SACzF,CAAC;QACF,cAAc,CAAC;YACb,IAAI,EAAE,cAAqD;YAC3D,KAAK,EAAE,uBAAuB;YAC9B,OAAO,EAAE,QAAQ;YACjB,KAAK,EAAE,eAAe;YACtB,IAAI,EAAE,EAAE;YACR,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAyB,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,EAAE,KAAK,CAAC;SAC7F,CAAC;QACF,cAAc,CAAC;YACb,IAAI,EAAE,kBAA6D;YACnE,KAAK,EAAE,4CAA4C;YACnD,OAAO,EAAE,QAAQ;YACjB,KAAK,EAAE,oBAAoB;YAC3B,IAAI,EAAE,EAAE;YACR,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAkC,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,iBAAiB,EAAE,KAAK,CAAC;SAC3G,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -2,7 +2,7 @@ import { join, relative, sep } from "node:path";
2
2
  import { DBOS } from "@dbos-inc/dbos-sdk";
3
3
  import { decide } from "./call.js";
4
4
  import { diffLockfiles, LOCKFILE, readLockfile, writeLockfile } from "./lockfile.js";
5
- import { currentRun } from "./run.js";
5
+ import { runNow } from "./run.js";
6
6
  import { APPLY_WORKFLOW } from "./shared.js";
7
7
  // The apply workflow's steps that call no vendor: reading the data files, asking the policy
8
8
  // ahead, and writing the lockfile. Here, not in apply.ts, which is held to the workflow lint and
@@ -11,12 +11,6 @@ import { APPLY_WORKFLOW } from "./shared.js";
11
11
  const WRITE_STEP = "apply:lockfile";
12
12
  /** How many of the latest apply runs are searched for the lockfile one last wrote. */
13
13
  const RUNS_SEARCHED = 100;
14
- const runNow = () => {
15
- const run = currentRun.getStore();
16
- if (!run)
17
- throw new Error("An apply step ran outside its run");
18
- return run;
19
- };
20
14
  /**
21
15
  * The bindings the latest apply run that wrote the lockfile wrote last, from its steps; undefined
22
16
  * when none of the latest `RUNS_SEARCHED` did. A sandbox run writes none.
@@ -52,7 +46,7 @@ export function applySteps(appName, root, read) {
52
46
  }, { name: "apply:data-files" }),
53
47
  // The policy asked as each call would ask it, now, so one approval can cover them all.
54
48
  holds: (calls) => DBOS.runStep(async () => {
55
- const run = runNow();
49
+ const run = runNow("An apply step");
56
50
  for (const { op: id, input, connection } of calls) {
57
51
  const op = run.state.ops.get(id);
58
52
  // Parsed as the call will be, so the policy sees the same input with its defaults.
@@ -70,7 +64,7 @@ export function applySteps(appName, root, read) {
70
64
  // step whose output is what it wrote. A sandbox run keeps its lockfile in memory: the run's
71
65
  // report has it.
72
66
  write: async (key, binding, message, moved) => {
73
- const run = runNow();
67
+ const run = runNow("An apply step");
74
68
  if (run.sandbox !== undefined || root === undefined)
75
69
  return { written: false };
76
70
  const { source } = run.state;
@@ -1 +1 @@
1
- {"version":3,"file":"apply-steps.js","sourceRoot":"","sources":["../src/apply-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,EAA+B,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAClH,OAAO,EAAE,UAAU,EAAY,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,4FAA4F;AAC5F,iGAAiG;AACjG,yDAAyD;AAEzD,0GAA0G;AAC1G,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAEpC,sFAAsF;AACtF,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,MAAM,MAAM,GAAG,GAAQ,EAAE;IAC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1,7 @@
1
1
  import { z } from "zod";
2
2
  import { type ApprovalRequest, type ApprovalResult, type ApprovalState, Principal } from "./define.ts";
3
3
  import type { Placed } from "./call.ts";
4
- import type { Run } from "./run.ts";
4
+ import { type Run } from "./run.ts";
5
5
  /** The DBOS event a run publishes its approvals on, as `ApprovalState[]`. */
6
6
  export declare const APPROVALS_EVENT = "approvals";
7
7
  /** The `recv` topic a decision on an approval is sent to. */
package/dist/approvals.js CHANGED
@@ -4,6 +4,7 @@ import { Principal } from "./define.js";
4
4
  import { RejectedError, WithdrawnError } from "./errors.js";
5
5
  import { entry, write } from "./ledger.js";
6
6
  import { warn } from "./log.js";
7
+ import { recordSandboxChecks } from "./run.js";
7
8
  import { readPeople } from "./resources.js";
8
9
  import { approverLabel, isVisitor, OWN_CHANGE, refusalOf } from "./shared.js";
9
10
  // The wire contract between a run waiting on approvals and whoever decides them. The client
@@ -94,6 +95,8 @@ export async function awaitApproval(run, title, req, place, held) {
94
95
  covers,
95
96
  ...(held && { op: held.op, ...heldOf(held) }),
96
97
  }, { key: state.id, at: state.requestedAt }));
98
+ // A sandbox run's checks as it starts to wait, for the app: awaited, since Cucumber runs one at a time in a process.
99
+ await recordSandboxChecks(run);
97
100
  for (;;) {
98
101
  // A decision comes from a request (`SanomaClient.decide`), which wakes a stopped worker: no deadline.
99
102
  const raw = await run.state.deadlines.waiting(run.id, { kind: "approval" }, () => DBOS.recv(topicOf(state.id), { timeoutSeconds: 24 * 60 * 60 }));
@@ -1 +1 @@
1
- {"version":3,"file":"approvals.js","sourceRoot":"","sources":["../src/approvals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAiE,SAAS,EAAE,MAAM,aAAa,CAAC;AACvG,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,KAAK,EAA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AAE,EAAE,IAAI,EAAE,oBAAoB,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAClH,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,SAAS;QAAE,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC3E,CAAC"}
package/dist/call.d.ts CHANGED
@@ -9,7 +9,8 @@ import type { Run, StartHold, WorkerState } from "./run.ts";
9
9
  * cancelled the run or another process took it over, or the run's worker is stopping and the
10
10
  * error has none of our codes. `stop()` marks the worker stopped before DBOS shuts down, so from
11
11
  * then on whatever fails without a code (DBOS's "system database has been shut down", pg's
12
- * closed pool) is the shutdown, and the run recovered on the next worker records how it ends.
12
+ * closed pool) is the shutdown. `runWorkflow` then keeps DBOS from recording it, so the run
13
+ * recovered on the next worker records how it ends.
13
14
  * A coded failure then (a driver's final answer, a denial, a rejection) is still the outcome:
14
15
  * DBOS records the run's error and never runs it again, so the ledger records it too. Narrower
15
16
  * than `isRunControlError`: DBOS's other errors (a run that is not deterministic) end the run
package/dist/call.js CHANGED
@@ -19,7 +19,8 @@ const takenByDbos = (err) => causes(err).some((e) => e instanceof DBOSErrors.DBO
19
19
  * cancelled the run or another process took it over, or the run's worker is stopping and the
20
20
  * error has none of our codes. `stop()` marks the worker stopped before DBOS shuts down, so from
21
21
  * then on whatever fails without a code (DBOS's "system database has been shut down", pg's
22
- * closed pool) is the shutdown, and the run recovered on the next worker records how it ends.
22
+ * closed pool) is the shutdown. `runWorkflow` then keeps DBOS from recording it, so the run
23
+ * recovered on the next worker records how it ends.
23
24
  * A coded failure then (a driver's final answer, a denial, a rejection) is still the outcome:
24
25
  * DBOS records the run's error and never runs it again, so the ledger records it too. Narrower
25
26
  * than `isRunControlError`: DBOS's other errors (a run that is not deterministic) end the run