@smithers-orchestrator/protocol 0.16.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 William Cory
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@smithers-orchestrator/protocol",
3
+ "version": "0.16.0",
4
+ "description": "Shared Smithers contracts, errors, and small value types",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "exports": {
8
+ ".": {
9
+ "types": "./src/index.d.ts"
10
+ },
11
+ "./errors": {
12
+ "types": "./src/index.d.ts"
13
+ },
14
+ "./*": {
15
+ "types": "./src/index.d.ts",
16
+ "import": "./src/*.js",
17
+ "default": "./src/*.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "src/"
22
+ ],
23
+ "dependencies": {
24
+ "effect": "^3.21.0",
25
+ "zod": "^4.3.6"
26
+ },
27
+ "devDependencies": {
28
+ "@types/bun": "latest",
29
+ "typescript": "~5.9.3"
30
+ },
31
+ "scripts": {
32
+ "build": "tsup --dts-only",
33
+ "typecheck": "tsc -p tsconfig.json --noEmit"
34
+ }
35
+ }
@@ -0,0 +1,8 @@
1
+ import type { DevToolsDeltaOp } from "./DevToolsDeltaOp.ts";
2
+
3
+ export type DevToolsDelta = {
4
+ version: 1;
5
+ baseSeq: number;
6
+ seq: number;
7
+ ops: DevToolsDeltaOp[];
8
+ };
@@ -0,0 +1,8 @@
1
+ import type { DevToolsNode } from "./DevToolsNode.ts";
2
+
3
+ export type DevToolsDeltaOp =
4
+ | { op: "addNode"; parentId: number; index: number; node: DevToolsNode }
5
+ | { op: "removeNode"; id: number }
6
+ | { op: "updateProps"; id: number; props: Record<string, unknown> }
7
+ | { op: "updateTask"; id: number; task: DevToolsNode["task"] }
8
+ | { op: "replaceRoot"; node: DevToolsNode };
@@ -0,0 +1,14 @@
1
+ import type { DevToolsSnapshot } from "./DevToolsSnapshot.ts";
2
+ import type { DevToolsDelta } from "./DevToolsDelta.ts";
3
+
4
+ export type DevToolsEvent =
5
+ | {
6
+ version: 1;
7
+ kind: "snapshot";
8
+ snapshot: DevToolsSnapshot;
9
+ }
10
+ | {
11
+ version: 1;
12
+ kind: "delta";
13
+ delta: DevToolsDelta;
14
+ };
@@ -0,0 +1,18 @@
1
+ import type { DevToolsNodeType } from "./DevToolsNodeType.ts";
2
+
3
+ export type DevToolsNode = {
4
+ id: number;
5
+ type: DevToolsNodeType;
6
+ name: string;
7
+ props: Record<string, unknown>;
8
+ task?: {
9
+ nodeId: string;
10
+ kind: "agent" | "compute" | "static";
11
+ agent?: string;
12
+ label?: string;
13
+ outputTableName?: string;
14
+ iteration?: number;
15
+ };
16
+ children: DevToolsNode[];
17
+ depth: number;
18
+ };
@@ -0,0 +1,17 @@
1
+ export type DevToolsNodeType =
2
+ | "workflow"
3
+ | "task"
4
+ | "sequence"
5
+ | "parallel"
6
+ | "merge-queue"
7
+ | "branch"
8
+ | "loop"
9
+ | "worktree"
10
+ | "approval"
11
+ | "timer"
12
+ | "subflow"
13
+ | "wait-for-event"
14
+ | "saga"
15
+ | "try-catch"
16
+ | "fragment"
17
+ | "unknown";
@@ -0,0 +1,9 @@
1
+ import type { DevToolsNode } from "./DevToolsNode.ts";
2
+
3
+ export type DevToolsSnapshot = {
4
+ version: 1;
5
+ runId: string;
6
+ frameNo: number;
7
+ seq: number;
8
+ root: DevToolsNode;
9
+ };
@@ -0,0 +1,10 @@
1
+ // @smithers-type-exports-begin
2
+ /** @typedef {import("./devtools/DevToolsDelta.ts").DevToolsDelta} DevToolsDelta */
3
+ /** @typedef {import("./devtools/DevToolsDeltaOp.ts").DevToolsDeltaOp} DevToolsDeltaOp */
4
+ /** @typedef {import("./devtools/DevToolsEvent.ts").DevToolsEvent} DevToolsEvent */
5
+ /** @typedef {import("./devtools/DevToolsNode.ts").DevToolsNode} DevToolsNode */
6
+ /** @typedef {import("./devtools/DevToolsNodeType.ts").DevToolsNodeType} DevToolsNodeType */
7
+ /** @typedef {import("./devtools/DevToolsSnapshot.ts").DevToolsSnapshot} DevToolsSnapshot */
8
+ // @smithers-type-exports-end
9
+
10
+ export const DEVTOOLS_PROTOCOL_VERSION = /** @type {1} */ (1);
@@ -0,0 +1,8 @@
1
+ export type DevToolsErrorCode =
2
+ | "RunNotFound"
3
+ | "InvalidRunId"
4
+ | "FrameOutOfRange"
5
+ | "SeqOutOfRange"
6
+ | "BackpressureDisconnect"
7
+ | "Unauthorized"
8
+ | "InvalidDelta";
@@ -0,0 +1,12 @@
1
+ export type JumpToFrameErrorCode =
2
+ | "InvalidRunId"
3
+ | "InvalidFrameNo"
4
+ | "RunNotFound"
5
+ | "FrameOutOfRange"
6
+ | "ConfirmationRequired"
7
+ | "Busy"
8
+ | "UnsupportedSandbox"
9
+ | "VcsError"
10
+ | "RewindFailed"
11
+ | "RateLimited"
12
+ | "Unauthorized";
@@ -0,0 +1,11 @@
1
+ export type NodeDiffErrorCode =
2
+ | "InvalidRunId"
3
+ | "InvalidNodeId"
4
+ | "InvalidIteration"
5
+ | "RunNotFound"
6
+ | "NodeNotFound"
7
+ | "AttemptNotFound"
8
+ | "AttemptNotFinished"
9
+ | "VcsError"
10
+ | "WorkingTreeDirty"
11
+ | "DiffTooLarge";
@@ -0,0 +1,11 @@
1
+ export type NodeOutputErrorCode =
2
+ | "InvalidRunId"
3
+ | "InvalidNodeId"
4
+ | "InvalidIteration"
5
+ | "RunNotFound"
6
+ | "NodeNotFound"
7
+ | "IterationNotFound"
8
+ | "NodeHasNoOutput"
9
+ | "SchemaConversionError"
10
+ | "MalformedOutputRow"
11
+ | "PayloadTooLarge";
@@ -0,0 +1,10 @@
1
+ import type { DevToolsErrorCode } from "./DevToolsErrorCode.ts";
2
+ import type { NodeOutputErrorCode } from "./NodeOutputErrorCode.ts";
3
+ import type { NodeDiffErrorCode } from "./NodeDiffErrorCode.ts";
4
+ import type { JumpToFrameErrorCode } from "./JumpToFrameErrorCode.ts";
5
+
6
+ export type ProtocolError = {
7
+ code: DevToolsErrorCode | NodeOutputErrorCode | NodeDiffErrorCode | JumpToFrameErrorCode | string;
8
+ message: string;
9
+ hint?: string;
10
+ };
@@ -0,0 +1,54 @@
1
+ // @smithers-type-exports-begin
2
+ /** @typedef {import("./DevToolsErrorCode.ts").DevToolsErrorCode} DevToolsErrorCode */
3
+ /** @typedef {import("./JumpToFrameErrorCode.ts").JumpToFrameErrorCode} JumpToFrameErrorCode */
4
+ /** @typedef {import("./NodeDiffErrorCode.ts").NodeDiffErrorCode} NodeDiffErrorCode */
5
+ /** @typedef {import("./NodeOutputErrorCode.ts").NodeOutputErrorCode} NodeOutputErrorCode */
6
+ /** @typedef {import("./ProtocolError.ts").ProtocolError} ProtocolError */
7
+ // @smithers-type-exports-end
8
+
9
+ export const DEVTOOLS_ERROR_CODES = [
10
+ "RunNotFound",
11
+ "InvalidRunId",
12
+ "FrameOutOfRange",
13
+ "SeqOutOfRange",
14
+ "BackpressureDisconnect",
15
+ "Unauthorized",
16
+ "InvalidDelta",
17
+ ];
18
+ export const NODE_OUTPUT_ERROR_CODES = [
19
+ "InvalidRunId",
20
+ "InvalidNodeId",
21
+ "InvalidIteration",
22
+ "RunNotFound",
23
+ "NodeNotFound",
24
+ "IterationNotFound",
25
+ "NodeHasNoOutput",
26
+ "SchemaConversionError",
27
+ "MalformedOutputRow",
28
+ "PayloadTooLarge",
29
+ ];
30
+ export const NODE_DIFF_ERROR_CODES = [
31
+ "InvalidRunId",
32
+ "InvalidNodeId",
33
+ "InvalidIteration",
34
+ "RunNotFound",
35
+ "NodeNotFound",
36
+ "AttemptNotFound",
37
+ "AttemptNotFinished",
38
+ "VcsError",
39
+ "WorkingTreeDirty",
40
+ "DiffTooLarge",
41
+ ];
42
+ export const JUMP_TO_FRAME_ERROR_CODES = [
43
+ "InvalidRunId",
44
+ "InvalidFrameNo",
45
+ "RunNotFound",
46
+ "FrameOutOfRange",
47
+ "ConfirmationRequired",
48
+ "Busy",
49
+ "UnsupportedSandbox",
50
+ "VcsError",
51
+ "RewindFailed",
52
+ "RateLimited",
53
+ "Unauthorized",
54
+ ];
package/src/errors.ts ADDED
@@ -0,0 +1,55 @@
1
+ export const DEVTOOLS_ERROR_CODES = [
2
+ "RunNotFound",
3
+ "InvalidRunId",
4
+ "FrameOutOfRange",
5
+ "SeqOutOfRange",
6
+ "BackpressureDisconnect",
7
+ "Unauthorized",
8
+ "InvalidDelta",
9
+ ] as const;
10
+ export type DevToolsErrorCode = (typeof DEVTOOLS_ERROR_CODES)[number];
11
+ export const NODE_OUTPUT_ERROR_CODES = [
12
+ "InvalidRunId",
13
+ "InvalidNodeId",
14
+ "InvalidIteration",
15
+ "RunNotFound",
16
+ "NodeNotFound",
17
+ "IterationNotFound",
18
+ "NodeHasNoOutput",
19
+ "SchemaConversionError",
20
+ "MalformedOutputRow",
21
+ "PayloadTooLarge",
22
+ ] as const;
23
+ export type NodeOutputErrorCode = (typeof NODE_OUTPUT_ERROR_CODES)[number];
24
+ export const NODE_DIFF_ERROR_CODES = [
25
+ "InvalidRunId",
26
+ "InvalidNodeId",
27
+ "InvalidIteration",
28
+ "RunNotFound",
29
+ "NodeNotFound",
30
+ "AttemptNotFound",
31
+ "AttemptNotFinished",
32
+ "VcsError",
33
+ "WorkingTreeDirty",
34
+ "DiffTooLarge",
35
+ ] as const;
36
+ export type NodeDiffErrorCode = (typeof NODE_DIFF_ERROR_CODES)[number];
37
+ export const JUMP_TO_FRAME_ERROR_CODES = [
38
+ "InvalidRunId",
39
+ "InvalidFrameNo",
40
+ "RunNotFound",
41
+ "FrameOutOfRange",
42
+ "ConfirmationRequired",
43
+ "Busy",
44
+ "UnsupportedSandbox",
45
+ "VcsError",
46
+ "RewindFailed",
47
+ "RateLimited",
48
+ "Unauthorized",
49
+ ] as const;
50
+ export type JumpToFrameErrorCode = (typeof JUMP_TO_FRAME_ERROR_CODES)[number];
51
+ export type ProtocolError = {
52
+ code: DevToolsErrorCode | NodeOutputErrorCode | NodeDiffErrorCode | JumpToFrameErrorCode | string;
53
+ message: string;
54
+ hint?: string;
55
+ };
package/src/index.d.ts ADDED
@@ -0,0 +1,106 @@
1
+ type DevToolsNodeType = "workflow" | "task" | "sequence" | "parallel" | "merge-queue" | "branch" | "loop" | "worktree" | "approval" | "timer" | "subflow" | "wait-for-event" | "saga" | "try-catch" | "fragment" | "unknown";
2
+
3
+ type DevToolsNode = {
4
+ id: number;
5
+ type: DevToolsNodeType;
6
+ name: string;
7
+ props: Record<string, unknown>;
8
+ task?: {
9
+ nodeId: string;
10
+ kind: "agent" | "compute" | "static";
11
+ agent?: string;
12
+ label?: string;
13
+ outputTableName?: string;
14
+ iteration?: number;
15
+ };
16
+ children: DevToolsNode[];
17
+ depth: number;
18
+ };
19
+
20
+ type DevToolsSnapshot = {
21
+ version: 1;
22
+ runId: string;
23
+ frameNo: number;
24
+ seq: number;
25
+ root: DevToolsNode;
26
+ };
27
+
28
+ type DevToolsDeltaOp = {
29
+ op: "addNode";
30
+ parentId: number;
31
+ index: number;
32
+ node: DevToolsNode;
33
+ } | {
34
+ op: "removeNode";
35
+ id: number;
36
+ } | {
37
+ op: "updateProps";
38
+ id: number;
39
+ props: Record<string, unknown>;
40
+ } | {
41
+ op: "updateTask";
42
+ id: number;
43
+ task: DevToolsNode["task"];
44
+ } | {
45
+ op: "replaceRoot";
46
+ node: DevToolsNode;
47
+ };
48
+
49
+ type DevToolsDelta = {
50
+ version: 1;
51
+ baseSeq: number;
52
+ seq: number;
53
+ ops: DevToolsDeltaOp[];
54
+ };
55
+
56
+ type DevToolsEvent = {
57
+ version: 1;
58
+ kind: "snapshot";
59
+ snapshot: DevToolsSnapshot;
60
+ } | {
61
+ version: 1;
62
+ kind: "delta";
63
+ delta: DevToolsDelta;
64
+ };
65
+
66
+ /** @typedef {import("./devtools/DevToolsDelta.ts").DevToolsDelta} DevToolsDelta */
67
+ /** @typedef {import("./devtools/DevToolsDeltaOp.ts").DevToolsDeltaOp} DevToolsDeltaOp */
68
+ /** @typedef {import("./devtools/DevToolsEvent.ts").DevToolsEvent} DevToolsEvent */
69
+ /** @typedef {import("./devtools/DevToolsNode.ts").DevToolsNode} DevToolsNode */
70
+ /** @typedef {import("./devtools/DevToolsNodeType.ts").DevToolsNodeType} DevToolsNodeType */
71
+ /** @typedef {import("./devtools/DevToolsSnapshot.ts").DevToolsSnapshot} DevToolsSnapshot */
72
+ declare const DEVTOOLS_PROTOCOL_VERSION: 1;
73
+
74
+ type OutputSchemaFieldType = "string" | "number" | "boolean" | "object" | "array" | "null" | "unknown";
75
+ type OutputSchemaDescriptor = {
76
+ fields: Array<{
77
+ name: string;
78
+ type: OutputSchemaFieldType;
79
+ optional: boolean;
80
+ nullable: boolean;
81
+ description?: string;
82
+ enum?: readonly unknown[];
83
+ }>;
84
+ };
85
+ type NodeOutputResponse = {
86
+ status: "produced" | "pending" | "failed";
87
+ row: Record<string, unknown> | null;
88
+ schema: OutputSchemaDescriptor | null;
89
+ partial?: Record<string, unknown> | null;
90
+ };
91
+
92
+ declare const DEVTOOLS_ERROR_CODES: readonly ["RunNotFound", "InvalidRunId", "FrameOutOfRange", "SeqOutOfRange", "BackpressureDisconnect", "Unauthorized", "InvalidDelta"];
93
+ type DevToolsErrorCode = (typeof DEVTOOLS_ERROR_CODES)[number];
94
+ declare const NODE_OUTPUT_ERROR_CODES: readonly ["InvalidRunId", "InvalidNodeId", "InvalidIteration", "RunNotFound", "NodeNotFound", "IterationNotFound", "NodeHasNoOutput", "SchemaConversionError", "MalformedOutputRow", "PayloadTooLarge"];
95
+ type NodeOutputErrorCode = (typeof NODE_OUTPUT_ERROR_CODES)[number];
96
+ declare const NODE_DIFF_ERROR_CODES: readonly ["InvalidRunId", "InvalidNodeId", "InvalidIteration", "RunNotFound", "NodeNotFound", "AttemptNotFound", "AttemptNotFinished", "VcsError", "WorkingTreeDirty", "DiffTooLarge"];
97
+ type NodeDiffErrorCode = (typeof NODE_DIFF_ERROR_CODES)[number];
98
+ declare const JUMP_TO_FRAME_ERROR_CODES: readonly ["InvalidRunId", "InvalidFrameNo", "RunNotFound", "FrameOutOfRange", "ConfirmationRequired", "Busy", "UnsupportedSandbox", "VcsError", "RewindFailed", "RateLimited", "Unauthorized"];
99
+ type JumpToFrameErrorCode = (typeof JUMP_TO_FRAME_ERROR_CODES)[number];
100
+ type ProtocolError = {
101
+ code: DevToolsErrorCode | NodeOutputErrorCode | NodeDiffErrorCode | JumpToFrameErrorCode | string;
102
+ message: string;
103
+ hint?: string;
104
+ };
105
+
106
+ export { DEVTOOLS_ERROR_CODES, DEVTOOLS_PROTOCOL_VERSION, type DevToolsDelta, type DevToolsDeltaOp, type DevToolsErrorCode, type DevToolsEvent, type DevToolsNode, type DevToolsNodeType, type DevToolsSnapshot, JUMP_TO_FRAME_ERROR_CODES, type JumpToFrameErrorCode, NODE_DIFF_ERROR_CODES, NODE_OUTPUT_ERROR_CODES, type NodeDiffErrorCode, type NodeOutputErrorCode, type NodeOutputResponse, type OutputSchemaDescriptor, type OutputSchemaFieldType, type ProtocolError };
package/src/index.ts ADDED
@@ -0,0 +1,23 @@
1
+ export { DEVTOOLS_PROTOCOL_VERSION } from "./devtools.js";
2
+ export type { DevToolsNodeType } from "./devtools/DevToolsNodeType.ts";
3
+ export type { DevToolsNode } from "./devtools/DevToolsNode.ts";
4
+ export type { DevToolsSnapshot } from "./devtools/DevToolsSnapshot.ts";
5
+ export type { DevToolsDeltaOp } from "./devtools/DevToolsDeltaOp.ts";
6
+ export type { DevToolsDelta } from "./devtools/DevToolsDelta.ts";
7
+ export type { DevToolsEvent } from "./devtools/DevToolsEvent.ts";
8
+ export {
9
+ type OutputSchemaFieldType,
10
+ type OutputSchemaDescriptor,
11
+ type NodeOutputResponse,
12
+ } from "./outputs.ts";
13
+ export {
14
+ DEVTOOLS_ERROR_CODES,
15
+ type DevToolsErrorCode,
16
+ NODE_OUTPUT_ERROR_CODES,
17
+ type NodeOutputErrorCode,
18
+ NODE_DIFF_ERROR_CODES,
19
+ type NodeDiffErrorCode,
20
+ JUMP_TO_FRAME_ERROR_CODES,
21
+ type JumpToFrameErrorCode,
22
+ type ProtocolError,
23
+ } from "./errors.ts";
package/src/outputs.ts ADDED
@@ -0,0 +1,19 @@
1
+ export type OutputSchemaFieldType = "string" | "number" | "boolean" | "object" | "array" | "null" | "unknown";
2
+
3
+ export type OutputSchemaDescriptor = {
4
+ fields: Array<{
5
+ name: string;
6
+ type: OutputSchemaFieldType;
7
+ optional: boolean;
8
+ nullable: boolean;
9
+ description?: string;
10
+ enum?: readonly unknown[];
11
+ }>;
12
+ };
13
+
14
+ export type NodeOutputResponse = {
15
+ status: "produced" | "pending" | "failed";
16
+ row: Record<string, unknown> | null;
17
+ schema: OutputSchemaDescriptor | null;
18
+ partial?: Record<string, unknown> | null;
19
+ };