@protobase/cli 0.100.3 → 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.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.100.3";
2
+ var version = "0.100.4";
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.3",
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.3",
47
- "@protobase/layout": "0.100.3",
48
- "@protobase/query": "0.100.3",
49
- "@protobase/schema": "0.100.3",
50
- "@protobase/server": "0.100.3",
51
- "@protobase/ui": "0.100.3",
52
- "@protobase/workflows": "0.100.3",
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",
@@ -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,7 +104,7 @@ 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
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. |
@@ -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; in `input`, `"x-record-use": "write"` beside `x-record-of` types the fields a write takes. |
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
 
@@ -309,7 +310,7 @@ A Task whose `Resource` is a step type followed by `.waitForTaskToken`, the Stat
309
310
 
310
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.
311
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.
312
- - **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.
313
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.
314
315
  - **Where it may be read.** `$states.context.Task.Token` is read only in such a Task's `Arguments`.
315
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*.
@@ -523,6 +524,72 @@ A step reads the configuration it names afresh each time, as the user who saved
523
524
 
524
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>
525
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
+
526
593
  ## Runs and their steps
527
594
 
528
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.
@@ -631,6 +698,8 @@ The workflow resources take only [named grants](access.md#resources-that-need-na
631
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. |
632
699
  | `storage_configurations.read` | Let workflows you save use the [storage configurations](#storing-files), and see them. Their keys are never shown. |
633
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. |
634
703
 
635
704
  ```ts
636
705
  defineRoles({