@protobase/cli 0.100.0 → 0.100.2

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.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.100.0";
2
+ var version = "0.100.2";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.100.0",
3
+ "version": "0.100.2",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -43,13 +43,13 @@
43
43
  "dependencies": {
44
44
  "@better-auth/core": "^1.7.12",
45
45
  "@hono/node-server": "^2.1.3",
46
- "@protobase/config": "0.100.0",
47
- "@protobase/layout": "0.100.0",
48
- "@protobase/query": "0.100.0",
49
- "@protobase/schema": "0.100.0",
50
- "@protobase/server": "0.100.0",
51
- "@protobase/ui": "0.100.0",
52
- "@protobase/workflows": "0.100.0",
46
+ "@protobase/config": "0.100.2",
47
+ "@protobase/layout": "0.100.2",
48
+ "@protobase/query": "0.100.2",
49
+ "@protobase/schema": "0.100.2",
50
+ "@protobase/server": "0.100.2",
51
+ "@protobase/ui": "0.100.2",
52
+ "@protobase/workflows": "0.100.2",
53
53
  "@react-email/render": "^2.1.0",
54
54
  "@scalar/hono-api-reference": "^0.12.10",
55
55
  "@sentry/vite-plugin": "^11.10.0",
@@ -17,6 +17,7 @@ Apps written for other systems that keep working on Protobase, and moving their
17
17
  ## AWS Step Functions
18
18
 
19
19
  - [Step Functions import](../reference/workflows.md#importing-from-step-functions) (beta): A JSONata state machine exported from AWS Step Functions saves and runs as a workflow as it is, and what does not run here, its service tasks included, is refused by name.
20
+ - [Task callbacks](../reference/workflows.md#waiting-for-an-outside-result) (beta): A step that waits for an outside result takes the SendTaskSuccess, SendTaskFailure and SendTaskHeartbeat calls a caller written for AWS Step Functions sends, unchanged.
20
21
 
21
22
  ## Template paths
22
23
 
@@ -15,6 +15,7 @@ Graphs of steps the server runs along their edges, written in a language a model
15
15
  - [Build on the graph](../reference/workflows.md#the-workflows-page) (beta): Click a step's handle to add a step right there, or drag from it to another step to connect them; the wheel and a pinch zoom the graph, and dragging pans it.
16
16
  - [Branches, steps per item and retries](../reference/workflows.md#states) (beta): Choices, a step per item with their results merged, waits, and per-step retries, timeouts and error paths.
17
17
  - [Order from the data](../reference/workflows.md#execution-order-from-the-data) (beta): A workflow in data order runs each step once the steps it reads from have ended, steps that read nothing of each other at once, with a Condition on any step and skips that pass on; switch a workflow between data order and the States Language's own sequence in the editor.
18
+ - [Waiting for an outside result](../reference/workflows.md#waiting-for-an-outside-result) (beta): A step hands its work off with a token and the run waits, holding nothing, until an approver, a job elsewhere or a service sends the token back with a result, a failure or a heartbeat, through the app's API or over MCP, failing with `States.Timeout` or `States.HeartbeatTimeout` when it does not come in time.
18
19
  - [HTTP request step](../reference/workflows.md#apphttp) (beta): Calls a URL built at run time through the outgoing-address guard, only at public addresses unless the config allows private ones, reading at most 10 MiB of the answer as JSON, text or a file, by its Content-Type unless the step says which. It can send its body as JSON whatever it holds, and check the answer's body against a JSON Schema, whose fields the editor then offers.
19
20
  - [Records steps](../reference/workflows.md#apprecords) (beta): Create, update, get and list records as the workflow's last editor, with the roles they hold now.
20
21
  - [Mail step](../reference/workflows.md#appmailsend) (beta): Sends mail, with files the run downloaded attached, from the app's own sender.
@@ -115,6 +115,7 @@ In an app with [workflows](workflows.md), the endpoint also offers tools to find
115
115
  | `run_workflow` | Starts a run of a workflow's version saved last, or of the `version` it names, with an `input`, and returns its `run_id` and `status`. With `rerun_of`, a failed run's id, it [re-runs](workflows.md#re-running-a-failed-run) that run from its last checkpoint instead, on its input, and with `rerun_from` any ended run that kept its trace from that state; with `replay: true` too, it [replays](workflows.md#replaying-a-run) any ended run of the workflow on its current version, with that run's input, sending none of its outside writes. |
116
116
  | `enable_workflow` | Publishes the saved `version` it names (`enabled: true`), which puts the workflow's trigger on it, or turns the workflow off, and returns its `enabled_version`. A save never goes live by itself. One that uses a [connected account](workflows.md#connecting-an-account) is turned on only by the account's owner in the admin app: the tool answers `own-sign-in-only` and says so. |
117
117
  | `new_webhook_url` | Issues a new URL and secret for a workflow that starts from a [webhook trigger](workflows.md#appwebhook), keeping a `secret` the sender makes when given one, and returns `{ url, secret }`, shown this once; the old URL stops. |
118
+ | `send_task_success`, `send_task_failure`, `send_task_heartbeat` | Answer a Task that [waits for an outside result](workflows.md#waiting-for-an-outside-result) with the `task_token` it handed off: its result, `output`, a string of JSON; its failure, `error` and `cause`; or a heartbeat. Each returns `{ run }`, or `{ error, message }` with the error Step Functions gives, such as `TaskTimedOut`. Only a caller who may read the run can answer it; to anyone else the token is unknown. |
118
119
 
119
120
  An `edit` is a [JSON Merge Patch](https://www.rfc-editor.org/rfc/rfc7396) of the saved definition: only what changes, at its place in the document. An object merges into the object there, `null` removes a member, and any other value, a list included, replaces it. Changing one argument of one state:
120
121
 
@@ -124,7 +125,7 @@ An `edit` is a [JSON Merge Patch](https://www.rfc-editor.org/rfc/rfc7396) of the
124
125
 
125
126
  A definition the save check refuses comes back as `{ "error": "invalid-workflow", "message": ..., "problems": [...] }`, each problem `{ state, field, message }` naming the state, the field and what was expected, as `validate_workflow` gives them; nothing is saved. A run goes on in the background on the app's jobs, so `run_workflow` returns while it is queued: the client reads it with `get_workflow_run` until it has `succeeded` or `failed`, fixes the step that failed and re-runs the run from that step.
126
127
 
127
- `create_workflow`, `update_workflow`, `run_workflow`, `enable_workflow` and `new_webhook_url` come with [writes](#writes), and the person approves each first, as any write, unless they hold one of the [roles without approval](#writes-without-approval); with writes limited to some resources, they save, turn on and issue URLs on `workflows` and run on `workflow_runs` only when the list names them. A run does what its steps do, such as requests, mail and record writes, as the workflow's last editor.
128
+ `create_workflow`, `update_workflow`, `run_workflow`, `enable_workflow`, `new_webhook_url` and the `send_task_*` answers come with [writes](#writes), and the person approves each first, as any write, unless they hold one of the [roles without approval](#writes-without-approval); with writes limited to some resources, they save, turn on and issue URLs on `workflows` and run on `workflow_runs` only when the list names them. A run does what its steps do, such as requests, mail and record writes, as the workflow's last editor.
128
129
 
129
130
  ### SQL for admins
130
131
 
@@ -82,7 +82,7 @@ What `run` gets, and nothing more:
82
82
  | `mail` | `send(message)` from the app's own sender; `undefined` when the app sends no mail. |
83
83
  | `connection` | `accessToken()` of the connection the step declares, or `undefined`. |
84
84
  | `mailbox` | `send(message)` from the [own mailbox](email.md#from-someones-own-mailbox) of the person who turned on the version the run runs, signed in as themselves, while they may still change the workflow; otherwise it fails `not_linked` and sends nothing. `undefined` when the app links no mailboxes. |
85
- | `runId`, `idempotencyKey` | The run, and a key that every retry of this visit of the step shares, while a later visit of the same state, such as in a loop, gets a new one: send it where the receiver deduplicates. |
85
+ | `runId`, `idempotencyKey` | The run, and a key that every retry of this visit of the step shares, while a later visit of the same state, such as in a loop, gets a new one: send it where the receiver deduplicates. A step that [waits for an outside result](workflows.md#waiting-for-an-outside-result) gets a new one with each token it hands off, so a receiver never drops the only token that can still answer. |
86
86
  | `signal` | Aborted at the step's timeout, or when the worker stops; pass it on to `fetch`. |
87
87
  | `log(message)`, `redact(text)` | A line in the step's logs, and the text with the app's secrets blanked out, both as the runner records them. |
88
88
  | `earlier`, `reuse(output)` | For a type whose cache offers hits: the earlier call's result, as [Caching results](#caching-results) says. |
@@ -135,7 +135,7 @@ A workflow switches order in the editor (see [The editor](#the-editor)), or by s
135
135
  - <gap>A state machine with a service task, the HTTP task (`arn:aws:states:::http:invoke`) included, a `Parallel` or a distributed Map cannot import because running them, or turning an HTTP task into an `app:http` step, is not implemented: write such a task with one of this app's step types, such as `app:http`.</gap>
136
136
  :::
137
137
 
138
- A JSONata state machine exported from AWS Step Functions saves and runs as it is, in sequence order: `create_workflow` over MCP takes it as `state_machine`, with a manual trigger unless one is given. Refused, each by name: a JSONPath state machine (`QueryLanguage` missing or `JSONPath`, or a state with `InputPath`, `Parameters`, `ResultSelector`, `ResultPath`, `OutputPath` or `ItemsPath`), every service task (`arn:aws:...`, the HTTP task, `.sync` and `.waitForTaskToken` included), Parallel, a distributed Map, `HeartbeatSeconds`, `Credentials` and a whole-run `TimeoutSeconds`.
138
+ A JSONata state machine exported from AWS Step Functions saves and runs as it is, in sequence order: `create_workflow` over MCP takes it as `state_machine`, with a manual trigger unless one is given. Refused, each by name: a JSONPath state machine (`QueryLanguage` missing or `JSONPath`, or a state with `InputPath`, `Parameters`, `ResultSelector`, `ResultPath`, `OutputPath` or `ItemsPath`), every service task (`arn:aws:...`, the HTTP task, `.sync` and `.waitForTaskToken` included), Parallel, a distributed Map, `Credentials` and a whole-run `TimeoutSeconds`.
139
139
 
140
140
  ### Triggers
141
141
 
@@ -251,7 +251,7 @@ A save refuses a Task that leaves out an argument its step type needs, as [the e
251
251
 
252
252
  | Type | |
253
253
  | --- | --- |
254
- | `Task` | Runs a step type, its `Resource`, with its `Arguments`; `TimeoutSeconds`, `Retry` and `Catch`. `Cache` reuses the result of an identical earlier call: `true` forces it on, `false` turns it off, and without it the step type decides, as [Caching results](workflow-plugins.md#caching-results) says. |
254
+ | `Task` | Runs a step type, its `Resource`, with its `Arguments`; `TimeoutSeconds`, `Retry` and `Catch`. A `Resource` ending in `.waitForTaskToken` hands the work off and waits for an outside result, with `HeartbeatSeconds`, as [Waiting for an outside result](#waiting-for-an-outside-result) says. `Cache` reuses the result of an identical earlier call: `true` forces it on, `false` turns it off, and without it the step type decides, as [Caching results](workflow-plugins.md#caching-results) says. |
255
255
  | `Pass` | Shapes values with `Output` and `Assign`, and goes on. |
256
256
  | `Choice` | Goes to the `Next` of the first of its `Choices` whose `Condition` is true, else to its `Default`; with neither it fails with `States.NoChoiceMatched`. A rule may carry its own `Output` and `Assign`. |
257
257
  | `Wait` | Waits `Seconds`, or until a `Timestamp` (ISO 8601), as a number or an expression. |
@@ -264,7 +264,42 @@ A state's output is its `Output`, else its result (a Task or Map) or the input i
264
264
 
265
265
  ### Errors and retries
266
266
 
267
- A failing Task or Map fails with an error name: a step type's own, such as `Http.Status`, `States.Timeout` when it ran past its timeout, `States.TaskFailed` for any other error it threw, and `States.QueryEvaluationError` for an expression that did not evaluate or ran past its limits. The first retrier whose `ErrorEquals` names it tries the state again after `IntervalSeconds` (default 1), times `BackoffRate` (default 2) for each earlier retry, up to `MaxDelaySeconds`; `MaxAttempts` counts the retries after the first try (default 3, 0 for none). Without `Retry` a failure is not retried. Once no retry is left, the first catcher that names it goes on to its `Next`; without one the run fails. `States.ALL` names every error but `States.DataLimitExceeded` and `States.Runtime`, which end the run even where a retrier or catcher names them.
267
+ A failing Task or Map fails with an error name: a step type's own, such as `Http.Status`, `States.Timeout` when it ran past its timeout, `States.HeartbeatTimeout` when a waiting Task's heartbeat was overdue, the error an outside failure names, `States.TaskFailed` for any other error it threw, and `States.QueryEvaluationError` for an expression that did not evaluate or ran past its limits. The first retrier whose `ErrorEquals` names it tries the state again after `IntervalSeconds` (default 1), times `BackoffRate` (default 2) for each earlier retry, up to `MaxDelaySeconds`; `MaxAttempts` counts the retries after the first try (default 3, 0 for none). Without `Retry` a failure is not retried. Once no retry is left, the first catcher that names it goes on to its `Next`; without one the run fails. `States.ALL` names every error but `States.DataLimitExceeded` and `States.Runtime`, which end the run even where a retrier or catcher names them.
268
+
269
+ ### Waiting for an outside result
270
+
271
+ A Task whose `Resource` is a step type followed by `.waitForTaskToken`, the States Language's own suffix for it, hands its work off to someone or something outside the app and waits for the result: an approver, a job on another machine, a service that calls back. Its step type runs once with `Arguments` that pass on the try's token, `$states.context.Task.Token`; then the run waits, holding no worker, until that token comes back with a result, a failure, or not in time.
272
+
273
+ ```json
274
+ "Approve": {
275
+ "Type": "Task",
276
+ "Resource": "app:http.waitForTaskToken",
277
+ "Arguments": {
278
+ "url": "https://approvals.example.com/ask",
279
+ "method": "POST",
280
+ "body": { "question": "{% 'Ship ' & $states.context.Execution.Input.version & '?' %}", "token": "{% $states.context.Task.Token %}" }
281
+ },
282
+ "TimeoutSeconds": 86400,
283
+ "HeartbeatSeconds": 3600,
284
+ "Assign": { "approval": "{% $states.result %}" },
285
+ "Next": "Ship"
286
+ }
287
+ ```
288
+
289
+ - **Sending the result back.** Whoever holds the token answers with one of three calls, `SendTaskSuccess`, `SendTaskFailure` and `SendTaskHeartbeat`, whose bodies are the ones a States Language runtime takes, so an existing caller works unchanged ([compatibility](../features/compatibility.md#aws-step-functions)). They need no sign-in: the token is the proof, as a [webhook's](#appwebhook) address is.
290
+
291
+ | Call | Body | Does |
292
+ | --- | --- | --- |
293
+ | `POST /api/workflows/tasks/success` | `{ "taskToken": "...", "output": "{\"approved\": true}" }` | Ends the Task with `output`, a string of JSON up to 256 KiB, which `Output` and `Assign` read parsed as `$states.result`. |
294
+ | `POST /api/workflows/tasks/failure` | `{ "taskToken": "...", "error": "Approval.Refused", "cause": "Not on a Friday" }` | Fails the Task with that error (`States.TaskFailed` without one) and cause, which `Retry` and `Catch` take as any failure. |
295
+ | `POST /api/workflows/tasks/heartbeat` | `{ "taskToken": "..." }` | Says the work goes on, so `HeartbeatSeconds` counts again from now. |
296
+
297
+ Each answers `200 {}`, or a problem whose title names the error as those callers know it: `InvalidToken` (400, not a token), `InvalidOutput` (400, an `output` that is not JSON, too large or too deep, or an error or cause over 256 and 32,768 characters), `TaskDoesNotExist` (404, no Task was given this token) or `TaskTimedOut` (409, the Task already ended, by an answer, its time or its run). Over MCP, `send_task_success`, `send_task_failure` and `send_task_heartbeat` do the same for a caller who may read the run.
298
+ - **Its token.** Each try gets its own: a retry hands the work off again with a new one, and the old one answers nothing. A token settles its Task once, by a success or a failure, and expires with the wait. The app keeps only its SHA-256, and blanks the token out of the step's input, logs and every trace.
299
+ - **Its time.** `TimeoutSeconds` counts from the hand-off and may be up to 366 days, its default; past it the Task fails with `States.Timeout`. `HeartbeatSeconds`, less than `TimeoutSeconds`, fails it with `States.HeartbeatTimeout` when no heartbeat came in that time since the hand-off or the last one. The step type's own call still ends within 300 seconds.
300
+ - **Once only.** The hand-off happens once per try: a run that stops after it, as when its worker restarts, only waits again; one that stops before it was marked hands off again with a new token, under a new idempotency key, so a receiver that drops repeated keys still gets it. An answer that comes while the hand-off is still running counts, even if the hand-off then fails. A [replay](#replaying-a-run) hands nothing off and goes on with what the replayed run was sent. A Task that waits caches nothing, so `Cache` is refused on it.
301
+ - **Where it may be read.** `$states.context.Task.Token` is read only in such a Task's `Arguments`.
302
+ - **In the editor.** A Task's form has *Wait for an outside result*, which adds `.waitForTaskToken`, with *Wait at most* (`TimeoutSeconds`) and *Heartbeat within* (`HeartbeatSeconds`); its node is named for its step type, *then waits*.
268
303
 
269
304
  ### Blocks
270
305
 
@@ -612,7 +647,7 @@ Every limit fails closed: a run or step that passes one fails, rather than going
612
647
  | --- | --- |
613
648
  | A definition | 256 KiB as JSON, 100 states, Maps included; an expression 4,096 characters. |
614
649
  | An expression's evaluation | 1 second, and 300 levels deep; beyond, `States.QueryEvaluationError`. |
615
- | A Task's `TimeoutSeconds` | 300 by default, and at most. |
650
+ | A Task's `TimeoutSeconds` | 300 by default, and at most; for a Task that [waits for an outside result](#waiting-for-an-outside-result), 366 days. |
616
651
  | A retrier's `MaxAttempts` | 19. |
617
652
  | The wait before a retry | 1 day, however `BackoffRate` grows it. |
618
653
  | A Map's items | 10,000; beyond, the Map fails with `States.DataLimitExceeded` before any item runs. |