@boardwalk-labs/workflow 0.1.0 → 0.1.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.
- package/README.md +3 -3
- package/dist/events.d.ts +5 -1
- package/dist/events.js +21 -1
- package/dist/extract.js +1 -0
- package/dist/host.js +1 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -3
- package/dist/manifest.js +1 -0
- package/dist/meta.js +1 -7
- package/dist/runtime.js +1 -0
- package/dist/types.d.ts +9 -1
- package/dist/types.js +1 -1
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -27,11 +27,11 @@ A workflow is **a script**: the `meta` export is a **pure literal** (engines der
|
|
|
27
27
|
|
|
28
28
|
| Import | What it is |
|
|
29
29
|
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
30
|
-
| `@boardwalk-labs/workflow` | The author API: `agent()`, `sleep()`, `workflows.call()`, `secrets.get()`, `artifacts.write()`, `parallel()`, `input` / `output()` / `config`, `
|
|
30
|
+
| `@boardwalk-labs/workflow` | The author API: `agent()`, `sleep()`, `workflows.call()`, `secrets.get()`, `artifacts.write()`, `parallel()`, `input` / `output()` / `config`, `phase()` — plus the manifest schema and run-event wire format |
|
|
31
31
|
| `@boardwalk-labs/workflow/runtime` | The **engine-facing** API: install a `WorkflowHost` before evaluating a program. Authors never import this |
|
|
32
32
|
| `@boardwalk-labs/workflow/extract` | Static `meta` → manifest extraction (AST-based, never executes the program). Used by engines and tooling |
|
|
33
33
|
|
|
34
|
-
## The primitives
|
|
34
|
+
## The primitives
|
|
35
35
|
|
|
36
36
|
- **`agent(prompt, opts?)`** — run an agent loop and get its final text (or `schema`-validated JSON). `model` is optional: name one explicitly, or let the engine resolve it. Loops can use **tools** (built-in or program-defined), **MCP servers**, **skills**, and **memory** — each brought **per call** on `agent()`; the manifest declares none of them.
|
|
37
37
|
- **`sleep(ms | { until })`** — durable wait; the run holds, locals survive.
|
|
@@ -42,7 +42,7 @@ A workflow is **a script**: the `meta` export is a **pure literal** (engines der
|
|
|
42
42
|
|
|
43
43
|
## Where workflows run
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
The same file runs on three engines: `boardwalk dev` (locally, no account), the self-hosted Boardwalk engine (your own server), or [the Boardwalk platform](https://boardwalk.sh) (`boardwalk deploy` — hosted, scheduled, with automatic model routing). The manifest schema and event stream are the same everywhere; engine differences are limited to documented resolution behavior.
|
|
46
46
|
|
|
47
47
|
The full authoring contract — every primitive, the manifest field inventory, and the run-event wire format — is in [`SPEC.md`](./SPEC.md).
|
|
48
48
|
|
package/dist/events.d.ts
CHANGED
|
@@ -64,13 +64,14 @@ export declare const runEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
64
64
|
seq: z.ZodNumber;
|
|
65
65
|
t: z.ZodNumber;
|
|
66
66
|
}, z.core.$strict>, z.ZodObject<{
|
|
67
|
+
agentId: z.ZodString;
|
|
68
|
+
agentName: z.ZodOptional<z.ZodString>;
|
|
67
69
|
kind: z.ZodLiteral<"turn_started">;
|
|
68
70
|
runId: z.ZodString;
|
|
69
71
|
turnId: z.ZodString;
|
|
70
72
|
seq: z.ZodNumber;
|
|
71
73
|
t: z.ZodNumber;
|
|
72
74
|
}, z.core.$strict>, z.ZodObject<{
|
|
73
|
-
kind: z.ZodLiteral<"turn_ended">;
|
|
74
75
|
reason: z.ZodEnum<{
|
|
75
76
|
error: "error";
|
|
76
77
|
cancelled: "cancelled";
|
|
@@ -87,6 +88,9 @@ export declare const runEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
87
88
|
code: z.ZodString;
|
|
88
89
|
message: z.ZodString;
|
|
89
90
|
}, z.core.$strict>>;
|
|
91
|
+
agentId: z.ZodString;
|
|
92
|
+
agentName: z.ZodOptional<z.ZodString>;
|
|
93
|
+
kind: z.ZodLiteral<"turn_ended">;
|
|
90
94
|
runId: z.ZodString;
|
|
91
95
|
turnId: z.ZodString;
|
|
92
96
|
seq: z.ZodNumber;
|
package/dist/events.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
1
2
|
// The run-event wire format — one typed, ordered stream per run, identical in every engine.
|
|
2
3
|
//
|
|
3
4
|
// Every event carries an envelope (runId, turnId, per-turn 1-based seq, server timestamp) and
|
|
@@ -96,10 +97,29 @@ const programOutputEvent = z.strictObject({
|
|
|
96
97
|
text: z.string(),
|
|
97
98
|
});
|
|
98
99
|
// -- agent channel ----------------------------------------------------------------
|
|
99
|
-
|
|
100
|
+
//
|
|
101
|
+
// `turn_started`/`turn_ended` bracket the turns of ONE `agent()` leaf and carry that leaf's
|
|
102
|
+
// identity: a stable, run-unique `agentId` (engine-assigned) and the author's optional
|
|
103
|
+
// `agentName` (from `AgentOptions.name`). The high-frequency frames in between (text/tool/
|
|
104
|
+
// reasoning) stay lean — a consumer attributes them to a leaf by their envelope `turnId`, which
|
|
105
|
+
// the bracketing `turn_started` maps to its `agentId`/`agentName`. This is what lets a viewer
|
|
106
|
+
// tell concurrent agents apart instead of seeing one interleaved blur.
|
|
107
|
+
/** Identity of the `agent()` leaf a turn belongs to (shared by its turn_started/turn_ended). */
|
|
108
|
+
const agentIdentityShape = {
|
|
109
|
+
/** Stable, run-unique id for the `agent()` call. Engine-assigned; same across all its turns. */
|
|
110
|
+
agentId: z.string().min(1),
|
|
111
|
+
/** The author's `AgentOptions.name`, if one was given. Display-only; absent otherwise. */
|
|
112
|
+
agentName: z.string().min(1).optional(),
|
|
113
|
+
};
|
|
114
|
+
const turnStarted = z.strictObject({
|
|
115
|
+
...envelopeShape,
|
|
116
|
+
kind: z.literal("turn_started"),
|
|
117
|
+
...agentIdentityShape,
|
|
118
|
+
});
|
|
100
119
|
const turnEnded = z.strictObject({
|
|
101
120
|
...envelopeShape,
|
|
102
121
|
kind: z.literal("turn_ended"),
|
|
122
|
+
...agentIdentityShape,
|
|
103
123
|
reason: z.enum(["complete", "cancelled", "error"]),
|
|
104
124
|
usage: tokenUsageSchema.optional(),
|
|
105
125
|
error: eventErrorSchema.optional(),
|
package/dist/extract.js
CHANGED
package/dist/host.js
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// `@boardwalk-labs/workflow` is a host-backed package: the hooks authors import (agent, sleep,
|
|
4
|
-
// workflows.call, secrets.get, input) are thin facades over a `WorkflowHost` the *engine*
|
|
5
|
-
// installs at runtime. hosted Boardwalk installs its hosted adapter; the local engine installs
|
|
6
|
-
// one backed by the developer's environment. The author's program is identical either way —
|
|
7
|
-
// explicit hooks instead of injected globals.
|
|
8
|
-
//
|
|
9
|
-
// State is a module-level singleton. Node ESM caches a module by resolved path, so the
|
|
10
|
-
// program (which imports the hooks) and the engine (which installs the host) share ONE
|
|
11
|
-
// instance of this module and therefore one host + one `input`.
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
12
2
|
let currentHost = null;
|
|
13
3
|
/**
|
|
14
4
|
* The trigger payload for the current run, exposed to the program as
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { AgentOptions, ArtifactBody, ArtifactRef, CallOptions, JsonValue, PhaseOptions, SleepArg } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Mark the current run phase for live-tail and run-log grouping. Everything after this call
|
|
4
|
-
* belongs to the named phase until the next `
|
|
4
|
+
* belongs to the named phase until the next `phase(...)` marker or the run ends. This is
|
|
5
5
|
* observability-only; it does not checkpoint or skip code on restart.
|
|
6
6
|
*/
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function phase(name: string, opts?: PhaseOptions): void;
|
|
8
8
|
/**
|
|
9
9
|
* Run an agent leaf to completion. Without `opts.schema`, resolves to the leaf's final text
|
|
10
10
|
* (`T` defaults to `string`); with a schema, resolves to the validated object — pass the
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
1
2
|
// @boardwalk-labs/workflow — the author-facing API a workflow program imports.
|
|
2
3
|
//
|
|
3
4
|
// import { agent, workflows, sleep, secrets, input, type WorkflowMeta } from "@boardwalk-labs/workflow"
|
|
@@ -13,13 +14,13 @@
|
|
|
13
14
|
import { requireHost, recordOutput } from "./host.js";
|
|
14
15
|
/**
|
|
15
16
|
* Mark the current run phase for live-tail and run-log grouping. Everything after this call
|
|
16
|
-
* belongs to the named phase until the next `
|
|
17
|
+
* belongs to the named phase until the next `phase(...)` marker or the run ends. This is
|
|
17
18
|
* observability-only; it does not checkpoint or skip code on restart.
|
|
18
19
|
*/
|
|
19
|
-
export function
|
|
20
|
+
export function phase(name, opts) {
|
|
20
21
|
const host = requireHost();
|
|
21
22
|
if (host.setPhase === undefined) {
|
|
22
|
-
throw new Error("
|
|
23
|
+
throw new Error("phase is not supported by the installed engine");
|
|
23
24
|
}
|
|
24
25
|
host.setPhase(name, opts);
|
|
25
26
|
}
|
package/dist/manifest.js
CHANGED
package/dist/meta.js
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// A workflow program declares `export const meta = { … } satisfies WorkflowMeta`. The
|
|
4
|
-
// `satisfies` operator is type-only and erased at compile time, so it does NOT break the
|
|
5
|
-
// pure-literal static extraction engines perform over the source (see extract.ts). This type
|
|
6
|
-
// is the author-facing typing; `workflowManifestSchema` (manifest.ts) is the validator of
|
|
7
|
-
// record — the two are kept faithful to each other.
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
8
2
|
export {};
|
package/dist/runtime.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -26,6 +26,14 @@ export interface ToolDef {
|
|
|
26
26
|
* declares none of them. A plain `agent(prompt)` is simple inference.
|
|
27
27
|
*/
|
|
28
28
|
export interface AgentOptions {
|
|
29
|
+
/**
|
|
30
|
+
* A human label for this leaf, echoed onto its `turn_started`/`turn_ended` events as
|
|
31
|
+
* `agentName`. Purely for display — it lets a stream consumer tell concurrent agents apart
|
|
32
|
+
* (e.g. a `reviewer` and a `summarizer` running under `parallel`). It is NOT an identifier and
|
|
33
|
+
* need not be unique; the engine always assigns a stable, run-unique `agentId` regardless.
|
|
34
|
+
* Defaults to none (consumers fall back to a generic label).
|
|
35
|
+
*/
|
|
36
|
+
name?: string;
|
|
29
37
|
/**
|
|
30
38
|
* The model, as an OPAQUE string passed VERBATIM to the provider — engines never parse,
|
|
31
39
|
* prefix, or rewrite it. Use whatever identifier your provider expects (e.g.
|
|
@@ -89,7 +97,7 @@ export type SleepArg = number | {
|
|
|
89
97
|
} | {
|
|
90
98
|
until: string | Date;
|
|
91
99
|
};
|
|
92
|
-
/** Options for {@link import("./index.js").
|
|
100
|
+
/** Options for {@link import("./index.js").phase}, the run-timeline marker. */
|
|
93
101
|
export interface PhaseOptions {
|
|
94
102
|
/**
|
|
95
103
|
* Optional stable identifier for the phase. Omit for the engine to assign one in marker order.
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
//
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
2
|
export {};
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boardwalk-labs/workflow",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Author Boardwalk workflows in TypeScript: agent(), sleep(), workflows.call(), secrets, the manifest schema, and the run-event wire format.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/boardwalk-labs/sdk.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/boardwalk-labs/sdk#readme",
|
|
6
11
|
"type": "module",
|
|
7
12
|
"engines": {
|
|
8
13
|
"node": ">=24"
|