@protobase/cli 0.100.2 → 0.100.4
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/dist/cli/package.js +1 -1
- package/package.json +8 -8
- package/skills/protobase/references/features/compatibility.md +1 -1
- package/skills/protobase/references/features/workflows.md +1 -0
- package/skills/protobase/references/reference/config/jobs-and-events.md +12 -1
- package/skills/protobase/references/reference/mcp.md +4 -4
- package/skills/protobase/references/reference/workflow-plugins.md +3 -3
- package/skills/protobase/references/reference/workflows.md +91 -7
package/dist/cli/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.100.
|
|
3
|
+
"version": "0.100.4",
|
|
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.
|
|
47
|
-
"@protobase/layout": "0.100.
|
|
48
|
-
"@protobase/query": "0.100.
|
|
49
|
-
"@protobase/schema": "0.100.
|
|
50
|
-
"@protobase/server": "0.100.
|
|
51
|
-
"@protobase/ui": "0.100.
|
|
52
|
-
"@protobase/workflows": "0.100.
|
|
46
|
+
"@protobase/config": "0.100.4",
|
|
47
|
+
"@protobase/layout": "0.100.4",
|
|
48
|
+
"@protobase/query": "0.100.4",
|
|
49
|
+
"@protobase/schema": "0.100.4",
|
|
50
|
+
"@protobase/server": "0.100.4",
|
|
51
|
+
"@protobase/ui": "0.100.4",
|
|
52
|
+
"@protobase/workflows": "0.100.4",
|
|
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",
|
|
@@ -16,7 +16,7 @@ Apps written for other systems that keep working on Protobase, and moving their
|
|
|
16
16
|
|
|
17
17
|
## AWS Step Functions
|
|
18
18
|
|
|
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
|
|
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, its HTTP tasks as `app:http` steps that send the same request and give the same result, and what does not run here exactly, its other service tasks included, is refused by name.
|
|
20
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.
|
|
21
21
|
|
|
22
22
|
## Template paths
|
|
@@ -35,6 +35,7 @@ Graphs of steps the server runs along their edges, written in a language a model
|
|
|
35
35
|
- [Record triggers](../reference/workflows.md#apprecord) (beta): A workflow starts once for each record that becomes ready, at once or when a time in it comes, read as the user who saved the enabled version.
|
|
36
36
|
- [Triggers turned on while the app runs](../reference/workflows.md#turning-a-trigger-on) (beta): Publishing a saved version registers its trigger on every server process, and turning the workflow off stops it, with no restart; a save goes live only once it is published.
|
|
37
37
|
- [Workflow plugins](../reference/workflow-plugins.md) (beta): A file of the app or a package adds trigger and step types through the same public interface the built-in types use.
|
|
38
|
+
- [Custom workflow steps](../reference/workflows.md#custom-workflow-steps) (in development): Keep a step type of your own as a record, a container built from a Dockerfile with its input and output as JSON Schema, each saved version a step type a workflow names and is checked against; they do not run yet.
|
|
38
39
|
- [Blocks](../reference/workflows.md#blocks) (beta): build your own step from other steps. A block runs once and is cached by what it reads, so a workflow that reaches it again, in this run or another, reuses its result, such as a file fetched from a link that expires.
|
|
39
40
|
- [Step cache](../reference/workflow-plugins.md#caching-results) (beta): A plugin's step reuses the result of an identical earlier call from any run or workflow, as its plugin decides, while secrets always come in with their current value; a workflow can force it on, and the graph marks a step forced on against its plugin's advice.
|
|
40
41
|
- [Guarded requests for plugins](../reference/workflow-plugins.md#sending-requests) (beta): A plugin's requests reach only public addresses, follow no redirect and read at most 10 MiB.
|
|
@@ -211,7 +211,7 @@ export default defineConfig(({ command }) => ({ webhooks: { allowPrivateAddresse
|
|
|
211
211
|
|
|
212
212
|
## workflows
|
|
213
213
|
|
|
214
|
-
- **Type:** `{ schema?: string; secrets?: string[]; allowPrivateAddresses?: boolean; plugins?: string[]; storage?: { root?: string; endpoints?: string[] } }`
|
|
214
|
+
- **Type:** `{ schema?: string; secrets?: string[]; allowPrivateAddresses?: boolean; plugins?: string[]; storage?: { root?: string; endpoints?: string[] }; customSteps?: boolean }`
|
|
215
215
|
- **Default:** off; `{}` turns them on
|
|
216
216
|
|
|
217
217
|
Workflows that people and models make in the app, kept with their versions, runs and steps in a schema of the app's database that `protobase migration` writes, and run by the `workflows.segment` job. Records steps act as each workflow's last editor, with the roles they hold now, read from the app's sign-in; a project that signs people in otherwise exports its own, `async ({ id, tenant }) => [...]`, as the default of `workflows/saved-by-roles.ts`. See [Workflows](../workflows.md).
|
|
@@ -275,6 +275,17 @@ Turns on [storage configurations](../workflows.md#storing-files), the named plac
|
|
|
275
275
|
export default defineConfig({ workflows: { storage: { root: './data/workflow-storage', endpoints: ['https://storage.example.com'] } } })
|
|
276
276
|
```
|
|
277
277
|
|
|
278
|
+
## workflows.customSteps
|
|
279
|
+
|
|
280
|
+
- **Type:** `boolean`
|
|
281
|
+
- **Default:** `false`
|
|
282
|
+
|
|
283
|
+
Turns on [custom steps](../workflows.md#custom-workflow-steps), step types the app's authors keep as records, each saved version a type of its own, `custom:<name>:<version>`. Their tables come with the next `protobase migration` after you turn them on. Any other value than `true` or `false` stops startup.
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
export default defineConfig({ workflows: { customSteps: true } })
|
|
287
|
+
```
|
|
288
|
+
|
|
278
289
|
## notifications
|
|
279
290
|
|
|
280
291
|
- **Type:** `{ ui?: boolean; schema?: string; devices?: { table?: string; columns?: Record<string, string> }; history?: { table?: string; columns?: Record<string, string> } }`
|
|
@@ -104,14 +104,14 @@ In an app with [workflows](workflows.md), the endpoint also offers tools to find
|
|
|
104
104
|
|
|
105
105
|
| Tool | What it does |
|
|
106
106
|
| --- | --- |
|
|
107
|
-
| `list_workflow_types` | The step types a Task names as its `Resource` and the triggers a definition holds, built-in and [plugin](workflow-plugins.md) ones alike, each by id with its label, description, input as JSON Schema and, when the type declares one, its output, the errors a step fails with, and whether the app can run it. |
|
|
107
|
+
| `list_workflow_types` | The step types a Task names as its `Resource` and the triggers a definition holds, built-in and [plugin](workflow-plugins.md) ones alike, with the [custom steps](workflows.md#custom-workflow-steps) of the person's tenant, each by id with its label, description, input as JSON Schema and, when the type declares one, its output, the errors a step fails with, and whether the app can run it. |
|
|
108
108
|
| `list_workflows` | A page of the workflows the person may read, newest change first, without their definitions: `filter` on `name`, `page_size` (20 by default, at most 100) and `page_token`. |
|
|
109
109
|
| `get_workflow` | One workflow with its whole definition and its ETag. |
|
|
110
|
-
| `validate_workflow` | Checks a `
|
|
110
|
+
| `validate_workflow` | Checks a `state_machine`, with its `trigger` and `execution_order`, or a workflow's `id` with an `edit` of its saved definition, as a save checks it, and saves nothing: `{ valid: true }`, or `{ valid: false, problems }`. A valid one may come with `warnings` in the same shape, which a save goes through with, such as a [Wait after a Block](workflows.md#blocks); `create_workflow` and `update_workflow` return them with what they saved. A record trigger is checked against the resources and fields the person may read, so a resource they cannot read is not a resource of the app. |
|
|
111
111
|
| `get_workflow_run` | A run's status, input, output, error and cause, with its steps in the order they ran, each with its state, scope, try, status, input, output, assigned variables, logs, error and cause; `state` reads one state's steps, a page of 20 by default. |
|
|
112
112
|
| `list_connections` | The person's own [connected accounts](workflows.md#connecting-an-account), by each connection the app's plugins declare: its key and label, and each account's `id`, scopes and `needs_sign_in`. A definition's `connections` binds an account by its `id`. It returns no token, and no one else's accounts. |
|
|
113
|
-
| `create_workflow` | Creates a workflow from its `name`, `description` and `
|
|
114
|
-
| `update_workflow` | Changes a workflow's definition by an `edit` or whole, as `
|
|
113
|
+
| `create_workflow` | Creates a workflow from its `name`, `description` and `state_machine`, with its `trigger` and `execution_order`, and returns its `id`, `version` and ETag. A state machine from Step Functions [imports](workflows.md#importing-from-step-functions) its HTTP tasks as `app:http` steps, with `connection_headers` naming each connection's header; `update_workflow` and `validate_workflow` import one the same way. |
|
|
114
|
+
| `update_workflow` | Changes a workflow's definition by an `edit` or whole, as `state_machine`, `trigger` and `execution_order`, and its `name` or `description`, and returns its `id`, new `version` and ETag. With the `etag` that `get_workflow` gave, it fails when someone changed the workflow since; an edit without one is saved against the version it was applied to. |
|
|
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. |
|
|
@@ -55,7 +55,7 @@ For a whole plugin to read, with a connection, a polling cursor, a refused token
|
|
|
55
55
|
- **The app's own:** the default export of `workflows/plugins/<name>.ts`, found by its path as jobs are. An [extension](config.md#extensions) adds its own from its folder.
|
|
56
56
|
- **From a package:** listed by name in [`workflows.plugins`](config/jobs-and-events.md#workflowsplugins), its default export the plugin. The package is a dependency of the app.
|
|
57
57
|
|
|
58
|
-
Two plugins of one name stop startup, naming both. The exception is an app's own plugin named like a [default plugin](#default-plugins) other than `app`, which takes that default's place, such as one that pins its own version. A plugin is server code that runs with the app's rights, like the app's own code: load only plugins you trust. The interface's version is `pluginApi`, `1`; releases add optional keys to it and never break it.
|
|
58
|
+
Two plugins of one name stop startup, naming both, and so does a plugin named `custom`, the name of the app's [custom steps](workflows.md#custom-workflow-steps). The exception is an app's own plugin named like a [default plugin](#default-plugins) other than `app`, which takes that default's place, such as one that pins its own version. A plugin is server code that runs with the app's rights, like the app's own code: load only plugins you trust. The interface's version is `pluginApi`, `1`; releases add optional keys to it and never break it.
|
|
59
59
|
|
|
60
60
|
## Step types
|
|
61
61
|
|
|
@@ -63,7 +63,7 @@ Two plugins of one name stop startup, naming both. The exception is an app's own
|
|
|
63
63
|
| --- | --- |
|
|
64
64
|
| `label`, `description` | What the type list shows, to a person and to a model. |
|
|
65
65
|
| `input` | The JSON Schema of the Task's `Arguments`, checked before `run`: arguments that do not fit fail the step as `<errorPrefix>.InvalidArguments`, naming the field. |
|
|
66
|
-
| `output` | The JSON Schema of what `run` returns, for the type list, which types the step's pins in the editor and what the save checks reading it. A property of an untitled object is a pin of its own, and an object with a `title` one pin a Break takes apart. `{ "x-record-of": "<argument>" }` is the record of the resource that argument names, and `{ "x-schema-of": "<argument>" }` the schema that argument holds, and `{ "x-one-or-many-of": "<argument>", "anyOf": [<one>, <list>] }` the one or the list as that argument holds an object or a list
|
|
66
|
+
| `output` | The JSON Schema of what `run` returns, for the type list, which types the step's pins in the editor and what the save checks reading it. A property of an untitled object is a pin of its own, and an object with a `title` one pin a Break takes apart. `{ "x-record-of": "<argument>" }` is the record of the resource that argument names, and `{ "x-schema-of": "<argument>" }` the schema that argument holds, and `{ "x-one-or-many-of": "<argument>", "anyOf": [<one>, <list>] }` the one or the list as that argument holds an object or a list, and `{ "x-file": true }` a [stored file](workflows.md#storing-files), keeping its own `title` and `description`; in `input`, `"x-record-use": "write"` beside `x-record-of` types the fields a write takes. |
|
|
67
67
|
| `errorPrefix`, `errors` | The prefix of its error names, `Step` by default, and the errors it fails with by name, each with what it means. |
|
|
68
68
|
| `connection` | The connection it signs in with, by the name the plugin declares it under. |
|
|
69
69
|
| `cache` | Reuses the result of an identical earlier call: see [Caching results](#caching-results). Without it the engine looks up and keeps nothing for the type, unless a workflow forces it on. |
|
|
@@ -293,4 +293,4 @@ A run's input is the mail:
|
|
|
293
293
|
|
|
294
294
|
## The type list
|
|
295
295
|
|
|
296
|
-
[`list_workflow_types`](mcp.md#workflows) over MCP lists every step and trigger type the app has, built-in and plugin ones alike, as their plugins declare them: id, label, description, input and output schemas, errors, connection, a step type's cache advice (`choice`, `default` and `disclaimer`) and whether it writes (`writes`: `true`, `false`, or `by_input` when that depends on its input), with `available: false` and a reason for a type the app cannot run. A save, and `validate_workflow`, check a definition against the same list.
|
|
296
|
+
[`list_workflow_types`](mcp.md#workflows) over MCP lists every step and trigger type the app has, built-in and plugin ones alike, as their plugins declare them: id, label, description, input and output schemas, errors, connection, a step type's cache advice (`choice`, `default` and `disclaimer`) and whether it writes (`writes`: `true`, `false`, or `by_input` when that depends on its input), with `available: false` and a reason for a type the app cannot run, and after them the caller's tenant's [custom steps](workflows.md#custom-workflow-steps). A save, and `validate_workflow`, check a definition against the same list.
|
|
@@ -28,7 +28,7 @@ It adds five resources, over a `workflows` schema that [`protobase migration`](c
|
|
|
28
28
|
| `workflow_triggers` | The trigger of each enabled workflow that has one besides `manual`: its type, status and last error. Read-only. |
|
|
29
29
|
| `workflow_resolutions` | Each time someone [marked a workflow resolved](#run-status), by whom and when. Created only. |
|
|
30
30
|
|
|
31
|
-
With `storage` it adds a sixth, `storage_configurations`, the places workflows [store files](#storing-files) in.
|
|
31
|
+
With `storage` it adds a sixth, `storage_configurations`, the places workflows [store files](#storing-files) in. With `customSteps` it adds `workflow_custom_steps` and `workflow_custom_step_versions`, the app's [custom steps](#custom-workflow-steps) and every version of each.
|
|
32
32
|
|
|
33
33
|
| `workflows` | |
|
|
34
34
|
| --- | --- |
|
|
@@ -38,6 +38,7 @@ With `storage` it adds a sixth, `storage_configurations`, the places workflows [
|
|
|
38
38
|
| `plugins` | Packages of [workflow plugins](workflow-plugins.md) to run, by name, beside the app's own in `workflows/plugins/<name>.ts`. |
|
|
39
39
|
| `trace` | Which runs keep a [trace](#traces): `all` (default), `failed` or `none`. Any other value stops startup. |
|
|
40
40
|
| `storage` | Turns on [storage configurations](#storing-files): `root`, the one folder local configurations live inside, and `endpoints`, the `https://` origins an S3-compatible configuration may name. Needs `PROTOBASE_ENCRYPTION_KEY`. |
|
|
41
|
+
| `customSteps` | `true` turns on [custom steps](#custom-workflow-steps). Default `false`; any other value stops startup. |
|
|
41
42
|
|
|
42
43
|
Runs keep their traces and the files steps store in the app's `private` [file provider](files.md), local disk under `data/files/private` unless `PROTOBASE_FILES_PRIVATE` names an S3 bucket, so an app with workflows needs a files secret: `secret`, `files.secret`, `PROTOBASE_FILES_SECRET` or `PROTOBASE_SECRET`.
|
|
43
44
|
|
|
@@ -132,10 +133,23 @@ A workflow switches order in the editor (see [The editor](#the-editor)), or by s
|
|
|
132
133
|
|
|
133
134
|
:::caution[Beta]
|
|
134
135
|
- <gap>A JSONPath state machine cannot import because converting JSONPath to JSONata is not implemented.</gap>
|
|
135
|
-
- <gap>A state machine with a service task
|
|
136
|
+
- <gap>A state machine with a service task other than the HTTP task, a `Parallel` or a distributed Map cannot import because running them is not implemented: write such a task with one of this app's step types.</gap>
|
|
137
|
+
- <gap>An HTTP task's connection cannot send more than one header, or a token it fetches itself, because importing a connection's other parameters and OAuth sign-in is not implemented: its other headers, query and body parameters go in the task's own `Headers`, `QueryParameters` and `RequestBody`.</gap>
|
|
138
|
+
- <gap>An HTTP task that waits for a task token (`http:invoke.waitForTaskToken`) cannot import because turning it into an `app:http.waitForTaskToken` step is not implemented: write it as one.</gap>
|
|
136
139
|
:::
|
|
137
140
|
|
|
138
|
-
A JSONata state machine exported from AWS Step Functions saves and runs as
|
|
141
|
+
A JSONata state machine exported from AWS Step Functions saves and runs as a workflow, in sequence order: `create_workflow` over MCP takes it as `state_machine`, with a manual trigger unless one is given, and `update_workflow` and `validate_workflow` import a state machine, or an edit of a saved one, the same way. 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 but the HTTP task (`arn:aws:...`, `.sync` and `.waitForTaskToken` included), Parallel, a distributed Map, `Credentials` and a whole-run `TimeoutSeconds`.
|
|
142
|
+
|
|
143
|
+
An HTTP task (`arn:aws:states:::http:invoke`), in a Map or a Block too, imports as an [`app:http`](#apphttp) step that sends the same request and gives the same result, or is refused by name:
|
|
144
|
+
|
|
145
|
+
| HTTP task | Imports as |
|
|
146
|
+
| --- | --- |
|
|
147
|
+
| `ApiEndpoint`, `Method`, `Headers`, `QueryParameters` | `url`, `method`, `headers`, `query` |
|
|
148
|
+
| `RequestBody` | `body`, with `body_encoding: "json"`, as Step Functions sends it as JSON whatever it holds |
|
|
149
|
+
| `Authentication` or `InvocationConfig` | the header `connection_headers` names for its `ConnectionArn`, holding a [secret](#secrets) |
|
|
150
|
+
| `$states.result` in `Output` and `Assign` | the HTTP task's result, `{ StatusCode, StatusText, Headers, ResponseBody }`, each header's values as a list; without `Output`, that is the step's output, so later states and variables read what they read in Step Functions |
|
|
151
|
+
|
|
152
|
+
A connection's credentials stay with Step Functions, so the call names, for each connection's ARN, the header it sends and a secret holding the header's whole value: `"connection_headers": { "arn:aws:events:...:connection/tickets/...": { "header": "Authorization", "secret": "TICKETS_TOKEN" } }`, with `TICKETS_TOKEN` such as `Bearer ...` and listed in `workflows.secrets`; `null` sends no header. The header takes the place of one of the same name in `Headers`, as a connection's does. Refused: `Arguments` written as one expression, any other argument (`Transform`, which encodes the body as a form, among them), headers or query values that are lists, `HEAD` and `OPTIONS`, which `app:http` does not send, a `GET` with a `RequestBody`, a connection with no header given or with more than its `ConnectionArn`, an `Output` or `Assign` that reads `$states.result` in a form the import does not rewrite, such as `$states . result`, or `$states` as a whole, and a retrier or catcher of `States.Http.StatusCode.<code>`, `States.Http.Socket`, `Events.ConnectionResource.*` or `States.TaskFailed`: `app:http` fails with `Http.Status` for every status outside 2xx and `Http.Network` when no answer comes, and `States.TaskFailed` here matches only an error a step type does not name. A method written as an expression is checked when the step runs.
|
|
139
153
|
|
|
140
154
|
### Triggers
|
|
141
155
|
|
|
@@ -296,7 +310,7 @@ A Task whose `Resource` is a step type followed by `.waitForTaskToken`, the Stat
|
|
|
296
310
|
|
|
297
311
|
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
312
|
- **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.
|
|
313
|
+
- **Its time.** `TimeoutSeconds` counts from the try's start, its hand-off included, as in Step Functions, 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
314
|
- **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
315
|
- **Where it may be read.** `$states.context.Task.Token` is read only in such a Task's `Arguments`.
|
|
302
316
|
- **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*.
|
|
@@ -409,12 +423,12 @@ One request to a URL built at run time:
|
|
|
409
423
|
| `method` | `GET` (default), `POST`, `PUT`, `PATCH` or `DELETE`. |
|
|
410
424
|
| `headers`, `query` | Objects of text values; `query` is added to the URL's query. |
|
|
411
425
|
| `body` | Text is sent as it is, a file value as its bytes with its type, any other value as JSON; a `GET` sends none. |
|
|
412
|
-
| `body_encoding` | `json` sends the body as JSON whatever it holds, a text as a JSON string, with `Content-Type: application/json` unless the headers give one. |
|
|
426
|
+
| `body_encoding` | `json` sends the body as JSON whatever it holds, a text as a JSON string, with `Content-Type: application/json` unless the headers give one; a `GET` with a body then fails with `Http.InvalidArguments` rather than leaving the body out. |
|
|
413
427
|
| `response` | How the answer's body is read: `json`, parsed (empty is `null`), `text`, or `file`, kept as a file of the run. Without it, by the answer's `Content-Type`: JSON for `application/json` and any `+json` type, text for `text/*` and other textual types (XML, JavaScript, YAML, TOML, NDJSON, form data), a file for any other type or none, and `null` for an empty body. |
|
|
414
428
|
| `body_schema` | The JSON Schema of the answer's body as it is read, such as `{ "type": "object", "properties": { "ip": { "type": "string" } } }`: a body that does not fit it fails the step with `Http.InvalidBody`, and the editor offers the body's fields by it. |
|
|
415
429
|
| `store` | `{ configuration, path? }`: streams the answer's body, of any size, into a [storage configuration](#storing-files), and gives the stored file as `body`. Takes no `response` or `body_schema`. |
|
|
416
430
|
|
|
417
|
-
A `GET` only reads; every other method is recorded. The result is `{ status, headers, body }`, without the cookies the answer sets. A status outside 2xx fails the step with `Http.Status`, whose cause names the status and holds at most the first 200 characters of the body, secrets blanked out first; a redirect is never followed. `Http.Network` is a request that got no answer. The step resolves the URL's host when it runs and refuses it with `Http.AddressRefused` unless every address is public, then connects to the very address it checked, so a URL built from a webhook's payload cannot reach the app's own network. It reads at most 10 MiB of the answer's body: a larger one fails the step with `Http.ResponseTooLarge`, rather than being cut short. With `store`, the body streams straight into the store, so its size is limited only by what the store takes, and the step is recorded, a `GET` too: a run taken up again keeps the stored file and does not fetch it again, from a link that may have expired by then.
|
|
431
|
+
A `GET` only reads; every other method is recorded. The result is `{ status, status_text, headers, body }`, `status_text` the reason phrase the server sent (empty when it sent none), without the cookies the answer sets. A status outside 2xx fails the step with `Http.Status`, whose cause names the status and holds at most the first 200 characters of the body, secrets blanked out first; a redirect is never followed. `Http.Network` is a request that got no answer. The step resolves the URL's host when it runs and refuses it with `Http.AddressRefused` unless every address is public, then connects to the very address it checked, so a URL built from a webhook's payload cannot reach the app's own network. It reads at most 10 MiB of the answer's body: a larger one fails the step with `Http.ResponseTooLarge`, rather than being cut short. With `store`, the body streams straight into the store, so its size is limited only by what the store takes, and the step is recorded, a `GET` too: a run taken up again keeps the stored file and does not fetch it again, from a link that may have expired by then.
|
|
418
432
|
|
|
419
433
|
### app:records
|
|
420
434
|
|
|
@@ -483,7 +497,7 @@ Steps store and read files with:
|
|
|
483
497
|
| --- | --- | --- |
|
|
484
498
|
| `app:storage.put` | `configuration`, `file`: a file of the run or a stored file, optional `path` | the stored file |
|
|
485
499
|
| `app:storage.get` | `file`: a stored file | a file of the run, up to 10 MiB, for steps that take one, such as mail attachments |
|
|
486
|
-
| `app:http` with `store` | `store: { configuration, path? }` | `{ status, headers, body }`, `body` the stored file |
|
|
500
|
+
| `app:http` with `store` | `store: { configuration, path? }` | `{ status, status_text, headers, body }`, `body` the stored file |
|
|
487
501
|
|
|
488
502
|
A stored file is `{ configuration, node, path, name, type, size }`: the configuration, the server that holds it for a local one, and its path there, never a folder, bucket or key. A `path` is relative: letters, digits, `.`, `_` and `-` in segments split by `/`, none starting with `.`; any other fails the step with `Storage.InvalidArguments` before anything is stored. Without a `path`, a step stores under a path of its own in its run, the same each time the step is tried, so a step a crash made run again replaces its file rather than leaving a second one. A put is recorded; a get only reads.
|
|
489
503
|
|
|
@@ -510,6 +524,72 @@ A step reads the configuration it names afresh each time, as the user who saved
|
|
|
510
524
|
|
|
511
525
|
A stored file is read from where its configuration points now. <gap>Changing a configuration cannot move the files already in it because moving stored files is not implemented.</gap> A local configuration's files are on one server. <gap>A run cannot be kept on the server that holds its local files because routing runs to a server is not implemented.</gap>
|
|
512
526
|
|
|
527
|
+
## Custom workflow steps
|
|
528
|
+
|
|
529
|
+
:::caution[In development]
|
|
530
|
+
A custom step is saved, listed and checked, but it does not run: a run that reaches one fails. It cannot yet be built, tested or given limits on its resources and network.
|
|
531
|
+
:::
|
|
532
|
+
|
|
533
|
+
A **custom step** is a step type the app's authors keep as a record: a container built from a Dockerfile, with the input it takes and the output it gives as JSON Schema. Each save that changes its manifest is a new version, and every version is a step type of its own, `custom:<name>:<version>`, such as `custom:invoice_pdf:2`, so changing a custom step never changes a workflow that names an earlier version.
|
|
534
|
+
|
|
535
|
+
Turn them on with `customSteps` in `workflows`:
|
|
536
|
+
|
|
537
|
+
```ts
|
|
538
|
+
export default defineConfig({ workflows: { customSteps: true } })
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
Their tables, `workflows.custom_steps` and `workflows.custom_step_versions`, come with the next [`protobase migration`](cli.md#migration) after you turn them on.
|
|
542
|
+
|
|
543
|
+
A custom step is a record of `workflow_custom_steps`, which you create and change on its standard pages, linked from each workflow's page, through the API or over MCP. Each save is checked, and refused with a 400 problem whose `problems` name each field, such as `container.dockerfile`:
|
|
544
|
+
|
|
545
|
+
| Field | |
|
|
546
|
+
| --- | --- |
|
|
547
|
+
| `name` | What a Task names it by: a lowercase letter, then lowercase letters, digits and `_`, at most 64. Unique in the tenant. It is set on create only, since every Task that calls the step holds it; a change is refused as `"name" is read-only`. |
|
|
548
|
+
| `label`, `description` | What the step picker and the type list show. |
|
|
549
|
+
| `kind` | `container`, the only kind there is. |
|
|
550
|
+
| `container` | `{ dockerfile, files, command }`. `dockerfile` is text of at most 64 KiB whose first instruction is `FROM`, after `ARG` lines and comments only. `files` are the files beside it, by a relative path that has no `..` segment, each with its text, at most 1 MiB together, `{}` for none. `command` is a list of non-empty texts, such as `["python", "main.py"]`, or left out for the image's own. |
|
|
551
|
+
| `input`, `output` | The JSON Schema of the step's arguments and of its result, each an object (`"type": "object"`) that compiles. `{ "x-file": true }` is a [stored file](#storing-files): in `input`, an argument that takes one, and in `output`, a file the step stores. `input` may not declare `store`. |
|
|
552
|
+
| `error_prefix`, `errors` | The prefix of its error names, `Custom` by default, and the errors it fails with by name, each with what it means, such as `{ "Refused": "the renderer refused the invoice" }`: the step fails as `Invoice.Refused`. Each is a capital, then letters and digits; the prefix is not `States`. |
|
|
553
|
+
| `version` | The version its last change made, which the save numbers. Read-only. |
|
|
554
|
+
|
|
555
|
+
```json
|
|
556
|
+
{
|
|
557
|
+
"name": "invoice_pdf",
|
|
558
|
+
"label": "Invoice PDF",
|
|
559
|
+
"description": "Renders an invoice as a PDF.",
|
|
560
|
+
"container": {
|
|
561
|
+
"dockerfile": "FROM python:3.13-slim\nCOPY main.py .",
|
|
562
|
+
"files": { "main.py": "..." },
|
|
563
|
+
"command": ["python", "main.py"]
|
|
564
|
+
},
|
|
565
|
+
"input": { "type": "object", "required": ["number"], "properties": { "number": { "type": "string" } } },
|
|
566
|
+
"output": { "type": "object", "properties": { "pdf": { "x-file": true }, "pages": { "type": "integer" } } },
|
|
567
|
+
"error_prefix": "Invoice",
|
|
568
|
+
"errors": { "Refused": "the renderer refused the invoice" }
|
|
569
|
+
}
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
Each version, its manifest whole with who saved it and when, is a record of `workflow_custom_step_versions`, read-only, listed on its custom step's page. Deleting a custom step keeps its versions, which are then no step types, and a custom step made again under its name goes on from its next version, so `custom:<name>:<version>` always names the one manifest it named first.
|
|
573
|
+
|
|
574
|
+
A Task names a version in its `Resource`:
|
|
575
|
+
|
|
576
|
+
```json
|
|
577
|
+
"Render": {
|
|
578
|
+
"Type": "Task",
|
|
579
|
+
"Resource": "custom:invoice_pdf:2",
|
|
580
|
+
"Arguments": { "number": "{% $states.context.Execution.Input.number %}", "store": { "configuration": "archive" } },
|
|
581
|
+
"Next": "Mail"
|
|
582
|
+
}
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
Its arguments are the manifest's `input` and `store`, `{ configuration, path? }`, the [storage configuration](#storing-files) it stores the files it gives in, as `app:http` takes it; a version whose `output` gives a file needs it. The save checks the arguments it needs and types its pins from the manifest, as it does any step type's, and its errors are `<error_prefix>.<Name>`. A `Resource` that names no version, such as `custom:invoice_pdf`, is refused, naming the latest: `"custom:invoice_pdf" names no version: write custom:invoice_pdf:2`. A version of another tenant's custom step, or one deleted, is refused as an unknown step type.
|
|
586
|
+
|
|
587
|
+
The editor's step picker lists each custom step at its latest version under *Custom steps*, and a Task's form takes any version, and `GET /api/workflows/types`, `list_workflow_types` and `validate_workflow` take them, each with the custom steps of the caller's tenant: whoever may read workflows reads them, as they do a plugin's types, and only creating, changing and deleting them is granted.
|
|
588
|
+
|
|
589
|
+
- <gap>A custom step cannot run because building its image and running its container are not implemented; a run that reaches one fails with `States.Runtime` and the cause `Custom steps do not run yet`.</gap>
|
|
590
|
+
- <gap>A custom step cannot limit its memory, CPU, time or network because those fields of its manifest are not implemented.</gap>
|
|
591
|
+
- <gap>A custom step cannot be saved or tested over MCP with tools of its own because those tools are not implemented; `create_record` and `update_record` save it.</gap>
|
|
592
|
+
|
|
513
593
|
## Runs and their steps
|
|
514
594
|
|
|
515
595
|
A run starts when it is created, through the API or the admin app, in the same transaction: `POST /api/v1/workflow_runs` with `{ "workflow_id": "...", "input": { ... } }`. The input is at most 256 KiB as JSON and nests at most 64 levels; a larger one is refused with `input-too-large` or `input-too-deep` and no run. From the app's own code, such as a job or a write hook, `startWorkflow(db, { workflow, input, tenant, startedBy, trace })` from `@protobase/server` starts one in `db`'s transaction, so it starts when the caller's writes commit, or not at all. With a `key`, such as `orders:42`, a workflow runs once per key: a start with a key it has a run for already, in this transaction or another, starts nothing and returns that run's id.
|
|
@@ -568,6 +648,8 @@ Each workflow has a status from its last 10 ended runs, so you see which ones ne
|
|
|
568
648
|
|
|
569
649
|
:::caution[Beta]
|
|
570
650
|
A re-run from a step needs the earlier run's trace, and a re-run from the failed step keeps in its trace only the steps it ran, so it cannot itself be re-run from a state before them.
|
|
651
|
+
|
|
652
|
+
<gap>A re-run from the failed step cannot apply an `Assign` of a step's whole result added since to a state that already ran because keeping each step's result in the checkpoints is not implemented: it goes on with the variables as they ran, and a re-run from that state applies it.</gap>
|
|
571
653
|
:::
|
|
572
654
|
|
|
573
655
|
A failed run keeps its [checkpoints](#how-a-run-is-run). `POST /api/v1/workflow_runs` with `{ "workflow_id": "...", "rerun_of": "..." }` starts a run that:
|
|
@@ -616,6 +698,8 @@ The workflow resources take only [named grants](access.md#resources-that-need-na
|
|
|
616
698
|
| `workflow_resolutions.read` | Read who marked which workflow resolved and when. Marking one needs no grant of its own: whoever may change the workflow may. |
|
|
617
699
|
| `storage_configurations.read` | Let workflows you save use the [storage configurations](#storing-files), and see them. Their keys are never shown. |
|
|
618
700
|
| `storage_configurations.create`, `storage_configurations.update`, `storage_configurations.delete` | Make, change and delete storage configurations. |
|
|
701
|
+
| `workflow_custom_steps.read`, `workflow_custom_step_versions.read` | Read the [custom steps](#custom-workflow-steps) and their versions. A workflow's author needs neither to use them: the step types are listed to whoever may read workflows. |
|
|
702
|
+
| `workflow_custom_steps.create`, `workflow_custom_steps.update`, `workflow_custom_steps.delete` | Make, change and delete custom steps. Each change of a manifest is a new version. |
|
|
619
703
|
|
|
620
704
|
```ts
|
|
621
705
|
defineRoles({
|