@smithers-orchestrator/devtools 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 +21 -0
- package/package.json +31 -0
- package/src/DevToolsDelta.ts +8 -0
- package/src/DevToolsDeltaOp.ts +8 -0
- package/src/DevToolsEngineEvent.ts +98 -0
- package/src/DevToolsEventBus.ts +9 -0
- package/src/DevToolsEventHandler.ts +6 -0
- package/src/DevToolsNode.ts +23 -0
- package/src/DevToolsRunStore.js +232 -0
- package/src/DevToolsRunStoreOptions.ts +6 -0
- package/src/DevToolsSnapshot.ts +48 -0
- package/src/DevToolsSnapshotV1.ts +9 -0
- package/src/InvalidDeltaError.js +11 -0
- package/src/RunExecutionState.ts +18 -0
- package/src/SMITHERS_NODE_ICONS.js +21 -0
- package/src/SNAPSHOT_SERIALIZER_DEFAULT_MAX_DEPTH.js +2 -0
- package/src/SmithersDevToolsCore.js +146 -0
- package/src/SmithersDevToolsOptions.ts +11 -0
- package/src/SmithersNodeType.ts +17 -0
- package/src/SnapshotSerializerOptions.ts +7 -0
- package/src/SnapshotSerializerWarning.ts +9 -0
- package/src/TaskExecutionState.ts +21 -0
- package/src/applyDelta.js +115 -0
- package/src/buildSnapshot.js +15 -0
- package/src/collectTasks.js +15 -0
- package/src/countNodes.js +16 -0
- package/src/diffSnapshots.js +211 -0
- package/src/findNodeById.js +17 -0
- package/src/index.d.ts +550 -0
- package/src/index.js +30 -0
- package/src/printTree.js +35 -0
- package/src/snapshotSerializer.js +143 -0
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,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@smithers-orchestrator/devtools",
|
|
3
|
+
"version": "0.16.0",
|
|
4
|
+
"description": "Devtools and debugging utilities for Smithers workflow inspection",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./src/index.d.ts",
|
|
10
|
+
"import": "./src/index.js",
|
|
11
|
+
"default": "./src/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./*": {
|
|
14
|
+
"types": "./src/index.d.ts",
|
|
15
|
+
"import": "./src/*.js",
|
|
16
|
+
"default": "./src/*.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"src/"
|
|
21
|
+
],
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/bun": "latest",
|
|
24
|
+
"typescript": "~5.9.3"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsup --dts-only",
|
|
28
|
+
"test": "bun test tests",
|
|
29
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -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,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discriminated union of Smithers engine events that {@link DevToolsRunStore}
|
|
3
|
+
* understands when reducing engine state. Any other `type` value flows through
|
|
4
|
+
* the open-ended tail so future event kinds can be added without changes to
|
|
5
|
+
* consumers.
|
|
6
|
+
*/
|
|
7
|
+
export type DevToolsEngineEvent =
|
|
8
|
+
| RunStartedEvent
|
|
9
|
+
| RunFinishedEvent
|
|
10
|
+
| RunFailedEvent
|
|
11
|
+
| RunCancelledEvent
|
|
12
|
+
| FrameCommittedEvent
|
|
13
|
+
| NodePendingEvent
|
|
14
|
+
| NodeStartedEvent
|
|
15
|
+
| NodeFinishedEvent
|
|
16
|
+
| NodeFailedEvent
|
|
17
|
+
| NodeCancelledEvent
|
|
18
|
+
| NodeSkippedEvent
|
|
19
|
+
| NodeRetryingEvent
|
|
20
|
+
| NodeWaitingApprovalEvent
|
|
21
|
+
| NodeWaitingEventEvent
|
|
22
|
+
| NodeWaitingTimerEvent
|
|
23
|
+
| ToolCallStartedEvent
|
|
24
|
+
| ToolCallFinishedEvent
|
|
25
|
+
| UnknownEngineEvent;
|
|
26
|
+
|
|
27
|
+
type RunEventBase = {
|
|
28
|
+
runId: string;
|
|
29
|
+
timestampMs: number;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type NodeEventBase = RunEventBase & {
|
|
33
|
+
nodeId: string;
|
|
34
|
+
iteration: number;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type RunStartedEvent = RunEventBase & { type: "RunStarted" };
|
|
38
|
+
export type RunFinishedEvent = RunEventBase & { type: "RunFinished" };
|
|
39
|
+
export type RunFailedEvent = RunEventBase & { type: "RunFailed"; error?: unknown };
|
|
40
|
+
export type RunCancelledEvent = RunEventBase & { type: "RunCancelled" };
|
|
41
|
+
|
|
42
|
+
export type FrameCommittedEvent = RunEventBase & {
|
|
43
|
+
type: "FrameCommitted";
|
|
44
|
+
frameNo: number;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type NodePendingEvent = NodeEventBase & { type: "NodePending" };
|
|
48
|
+
export type NodeStartedEvent = NodeEventBase & {
|
|
49
|
+
type: "NodeStarted";
|
|
50
|
+
attempt: number;
|
|
51
|
+
};
|
|
52
|
+
export type NodeFinishedEvent = NodeEventBase & {
|
|
53
|
+
type: "NodeFinished";
|
|
54
|
+
attempt: number;
|
|
55
|
+
};
|
|
56
|
+
export type NodeFailedEvent = NodeEventBase & {
|
|
57
|
+
type: "NodeFailed";
|
|
58
|
+
attempt: number;
|
|
59
|
+
error?: unknown;
|
|
60
|
+
};
|
|
61
|
+
export type NodeCancelledEvent = NodeEventBase & { type: "NodeCancelled" };
|
|
62
|
+
export type NodeSkippedEvent = NodeEventBase & { type: "NodeSkipped" };
|
|
63
|
+
export type NodeRetryingEvent = NodeEventBase & {
|
|
64
|
+
type: "NodeRetrying";
|
|
65
|
+
attempt: number;
|
|
66
|
+
};
|
|
67
|
+
export type NodeWaitingApprovalEvent = NodeEventBase & {
|
|
68
|
+
type: "NodeWaitingApproval";
|
|
69
|
+
};
|
|
70
|
+
export type NodeWaitingEventEvent = NodeEventBase & {
|
|
71
|
+
type: "NodeWaitingEvent";
|
|
72
|
+
};
|
|
73
|
+
export type NodeWaitingTimerEvent = NodeEventBase & {
|
|
74
|
+
type: "NodeWaitingTimer";
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export type ToolCallStartedEvent = NodeEventBase & {
|
|
78
|
+
type: "ToolCallStarted";
|
|
79
|
+
toolName: string;
|
|
80
|
+
seq: number;
|
|
81
|
+
};
|
|
82
|
+
export type ToolCallFinishedEvent = NodeEventBase & {
|
|
83
|
+
type: "ToolCallFinished";
|
|
84
|
+
toolName: string;
|
|
85
|
+
seq: number;
|
|
86
|
+
status?: string;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Open tail: any future engine event with the minimal shape we require
|
|
91
|
+
* (`type` + `runId` + `timestampMs`). The store ignores unknown `type`s but
|
|
92
|
+
* still records them in `run.events`.
|
|
93
|
+
*/
|
|
94
|
+
export type UnknownEngineEvent = {
|
|
95
|
+
type: string;
|
|
96
|
+
runId: string;
|
|
97
|
+
timestampMs: number;
|
|
98
|
+
} & Record<string, unknown>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DevToolsEngineEvent } from "./DevToolsEngineEvent.ts";
|
|
2
|
+
|
|
3
|
+
export type DevToolsEventBus = {
|
|
4
|
+
on: (event: "event", handler: (e: DevToolsEngineEvent) => void) => void;
|
|
5
|
+
removeListener: (
|
|
6
|
+
event: "event",
|
|
7
|
+
handler: (e: DevToolsEngineEvent) => void,
|
|
8
|
+
) => void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SmithersNodeType } from "./SmithersNodeType.ts";
|
|
2
|
+
|
|
3
|
+
export type DevToolsNode = {
|
|
4
|
+
id: number;
|
|
5
|
+
/** Smithers-level type: "workflow" | "task" | "sequence" | etc. */
|
|
6
|
+
type: SmithersNodeType;
|
|
7
|
+
/** Display name (component function name or host tag) */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Props snapshot (serializable subset) */
|
|
10
|
+
props: Record<string, unknown>;
|
|
11
|
+
/** Task-specific fields extracted from renderer raw props */
|
|
12
|
+
task?: {
|
|
13
|
+
nodeId: string;
|
|
14
|
+
kind: "agent" | "compute" | "static";
|
|
15
|
+
agent?: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
outputTableName?: string;
|
|
18
|
+
iteration?: number;
|
|
19
|
+
};
|
|
20
|
+
children: DevToolsNode[];
|
|
21
|
+
/** Depth in the Smithers tree (not renderer tree depth) */
|
|
22
|
+
depth: number;
|
|
23
|
+
};
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/** @typedef {import("./DevToolsEngineEvent.ts").DevToolsEngineEvent} DevToolsEngineEvent */
|
|
2
|
+
/** @typedef {import("./DevToolsEventBus.ts").DevToolsEventBus} DevToolsEventBus */
|
|
3
|
+
/** @typedef {import("./DevToolsRunStoreOptions.ts").DevToolsRunStoreOptions} DevToolsRunStoreOptions */
|
|
4
|
+
/** @typedef {import("./RunExecutionState.ts").RunExecutionState} RunExecutionState */
|
|
5
|
+
/** @typedef {import("./TaskExecutionState.ts").TaskExecutionState} TaskExecutionState */
|
|
6
|
+
|
|
7
|
+
export class DevToolsRunStore {
|
|
8
|
+
/** @type {DevToolsRunStoreOptions} */
|
|
9
|
+
options;
|
|
10
|
+
/** @type {Map<string, RunExecutionState>} */
|
|
11
|
+
_runs = new Map();
|
|
12
|
+
/** @type {Array<{ bus: DevToolsEventBus; handler: (event: DevToolsEngineEvent) => void }>} */
|
|
13
|
+
_eventBusListeners = [];
|
|
14
|
+
/**
|
|
15
|
+
* @param {DevToolsRunStoreOptions} [options]
|
|
16
|
+
*/
|
|
17
|
+
constructor(options = {}) {
|
|
18
|
+
this.options = options;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Attach to a Smithers EventBus-like source.
|
|
22
|
+
* @param {DevToolsEventBus} bus
|
|
23
|
+
* @returns {this}
|
|
24
|
+
*/
|
|
25
|
+
attachEventBus(bus) {
|
|
26
|
+
/**
|
|
27
|
+
* @param {DevToolsEngineEvent} event
|
|
28
|
+
*/
|
|
29
|
+
const handler = (event) => this.processEngineEvent(event);
|
|
30
|
+
bus.on("event", handler);
|
|
31
|
+
this._eventBusListeners.push({ bus, handler });
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Detach all EventBus listeners registered by this store.
|
|
36
|
+
* @returns {void}
|
|
37
|
+
*/
|
|
38
|
+
detachEventBuses() {
|
|
39
|
+
for (const { bus, handler } of this._eventBusListeners) {
|
|
40
|
+
bus.removeListener("event", handler);
|
|
41
|
+
}
|
|
42
|
+
this._eventBusListeners = [];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get execution state for a specific run.
|
|
46
|
+
* @param {string} runId
|
|
47
|
+
* @returns {RunExecutionState | undefined}
|
|
48
|
+
*/
|
|
49
|
+
getRun(runId) {
|
|
50
|
+
return this._runs.get(runId);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get all tracked runs.
|
|
54
|
+
* @returns {Map<string, RunExecutionState>}
|
|
55
|
+
*/
|
|
56
|
+
get runs() {
|
|
57
|
+
return this._runs;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get task execution state by nodeId within a run. Searches all iterations.
|
|
61
|
+
* @param {string} runId
|
|
62
|
+
* @param {string} nodeId
|
|
63
|
+
* @param {number} [iteration]
|
|
64
|
+
* @returns {TaskExecutionState | undefined}
|
|
65
|
+
*/
|
|
66
|
+
getTaskState(runId, nodeId, iteration) {
|
|
67
|
+
const run = this._runs.get(runId);
|
|
68
|
+
if (!run)
|
|
69
|
+
return undefined;
|
|
70
|
+
if (typeof iteration === "number") {
|
|
71
|
+
return run.tasks.get(`${nodeId}::${iteration}`);
|
|
72
|
+
}
|
|
73
|
+
for (const task of run.tasks.values()) {
|
|
74
|
+
if (task.nodeId === nodeId)
|
|
75
|
+
return task;
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* @param {DevToolsEngineEvent} event
|
|
81
|
+
* @returns {void}
|
|
82
|
+
*/
|
|
83
|
+
processEngineEvent(event) {
|
|
84
|
+
if (!event || !event.type || !event.runId)
|
|
85
|
+
return;
|
|
86
|
+
const run = this.ensureRun(event.runId);
|
|
87
|
+
run.events.push(event);
|
|
88
|
+
const verbose = this.options.verbose ?? false;
|
|
89
|
+
switch (event.type) {
|
|
90
|
+
case "RunStarted":
|
|
91
|
+
run.status = "running";
|
|
92
|
+
run.startedAt = event.timestampMs;
|
|
93
|
+
break;
|
|
94
|
+
case "RunFinished":
|
|
95
|
+
run.status = "finished";
|
|
96
|
+
run.finishedAt = event.timestampMs;
|
|
97
|
+
break;
|
|
98
|
+
case "RunFailed":
|
|
99
|
+
run.status = "failed";
|
|
100
|
+
run.finishedAt = event.timestampMs;
|
|
101
|
+
break;
|
|
102
|
+
case "RunCancelled":
|
|
103
|
+
run.status = "cancelled";
|
|
104
|
+
run.finishedAt = event.timestampMs;
|
|
105
|
+
break;
|
|
106
|
+
case "FrameCommitted":
|
|
107
|
+
run.frameNo = event.frameNo;
|
|
108
|
+
break;
|
|
109
|
+
case "NodePending": {
|
|
110
|
+
const task = this.ensureTask(run, event.nodeId, event.iteration);
|
|
111
|
+
task.status = "pending";
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
case "NodeStarted": {
|
|
115
|
+
const task = this.ensureTask(run, event.nodeId, event.iteration);
|
|
116
|
+
task.status = "started";
|
|
117
|
+
task.attempt = event.attempt;
|
|
118
|
+
task.startedAt = event.timestampMs;
|
|
119
|
+
if (verbose) {
|
|
120
|
+
console.log(`▶️ [smithers-devtools] Task started: ${event.nodeId} (attempt ${event.attempt})`);
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
case "NodeFinished": {
|
|
125
|
+
const task = this.ensureTask(run, event.nodeId, event.iteration);
|
|
126
|
+
task.status = "finished";
|
|
127
|
+
task.attempt = event.attempt;
|
|
128
|
+
task.finishedAt = event.timestampMs;
|
|
129
|
+
if (verbose) {
|
|
130
|
+
console.log(`✅ [smithers-devtools] Task finished: ${event.nodeId}`);
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
case "NodeFailed": {
|
|
135
|
+
const task = this.ensureTask(run, event.nodeId, event.iteration);
|
|
136
|
+
task.status = "failed";
|
|
137
|
+
task.attempt = event.attempt;
|
|
138
|
+
task.finishedAt = event.timestampMs;
|
|
139
|
+
task.error = event.error;
|
|
140
|
+
if (verbose) {
|
|
141
|
+
console.log(`❌ [smithers-devtools] Task failed: ${event.nodeId}`);
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
case "NodeCancelled": {
|
|
146
|
+
const task = this.ensureTask(run, event.nodeId, event.iteration);
|
|
147
|
+
task.status = "cancelled";
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
case "NodeSkipped": {
|
|
151
|
+
const task = this.ensureTask(run, event.nodeId, event.iteration);
|
|
152
|
+
task.status = "skipped";
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
case "NodeRetrying": {
|
|
156
|
+
const task = this.ensureTask(run, event.nodeId, event.iteration);
|
|
157
|
+
task.status = "retrying";
|
|
158
|
+
task.attempt = event.attempt;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
case "NodeWaitingApproval": {
|
|
162
|
+
const task = this.ensureTask(run, event.nodeId, event.iteration);
|
|
163
|
+
task.status = "waiting-approval";
|
|
164
|
+
run.status = "waiting-approval";
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
case "NodeWaitingEvent": {
|
|
168
|
+
const task = this.ensureTask(run, event.nodeId, event.iteration);
|
|
169
|
+
task.status = "waiting-event";
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
case "NodeWaitingTimer": {
|
|
173
|
+
const task = this.ensureTask(run, event.nodeId, event.iteration);
|
|
174
|
+
task.status = "waiting-timer";
|
|
175
|
+
run.status = "waiting-timer";
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
case "ToolCallStarted": {
|
|
179
|
+
const task = this.ensureTask(run, event.nodeId, event.iteration);
|
|
180
|
+
task.toolCalls.push({ name: event.toolName, seq: event.seq });
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
case "ToolCallFinished": {
|
|
184
|
+
const task = this.ensureTask(run, event.nodeId, event.iteration);
|
|
185
|
+
const tc = task.toolCalls.find((t) => t.name === event.toolName && t.seq === event.seq);
|
|
186
|
+
if (tc)
|
|
187
|
+
tc.status = event.status;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
this.options.onEngineEvent?.(event);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* @param {string} runId
|
|
195
|
+
* @returns {RunExecutionState}
|
|
196
|
+
*/
|
|
197
|
+
ensureRun(runId) {
|
|
198
|
+
let run = this._runs.get(runId);
|
|
199
|
+
if (!run) {
|
|
200
|
+
run = {
|
|
201
|
+
runId,
|
|
202
|
+
status: "running",
|
|
203
|
+
frameNo: 0,
|
|
204
|
+
tasks: new Map(),
|
|
205
|
+
events: [],
|
|
206
|
+
};
|
|
207
|
+
this._runs.set(runId, run);
|
|
208
|
+
}
|
|
209
|
+
return run;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* @param {RunExecutionState} run
|
|
213
|
+
* @param {string} nodeId
|
|
214
|
+
* @param {number} iteration
|
|
215
|
+
* @returns {TaskExecutionState}
|
|
216
|
+
*/
|
|
217
|
+
ensureTask(run, nodeId, iteration) {
|
|
218
|
+
const key = `${nodeId}::${iteration}`;
|
|
219
|
+
let task = run.tasks.get(key);
|
|
220
|
+
if (!task) {
|
|
221
|
+
task = {
|
|
222
|
+
nodeId,
|
|
223
|
+
iteration,
|
|
224
|
+
status: "pending",
|
|
225
|
+
attempt: 0,
|
|
226
|
+
toolCalls: [],
|
|
227
|
+
};
|
|
228
|
+
run.tasks.set(key, task);
|
|
229
|
+
}
|
|
230
|
+
return task;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { DevToolsNode } from "./DevToolsNode.ts";
|
|
2
|
+
|
|
3
|
+
type RunState =
|
|
4
|
+
| "running"
|
|
5
|
+
| "waiting-approval"
|
|
6
|
+
| "waiting-event"
|
|
7
|
+
| "waiting-timer"
|
|
8
|
+
| "recovering"
|
|
9
|
+
| "stale"
|
|
10
|
+
| "orphaned"
|
|
11
|
+
| "failed"
|
|
12
|
+
| "cancelled"
|
|
13
|
+
| "succeeded"
|
|
14
|
+
| "unknown";
|
|
15
|
+
|
|
16
|
+
type ReasonBlocked =
|
|
17
|
+
| { kind: "approval"; nodeId: string; requestedAt: string }
|
|
18
|
+
| { kind: "event"; nodeId: string; correlationKey: string }
|
|
19
|
+
| { kind: "timer"; nodeId: string; wakeAt: string }
|
|
20
|
+
| {
|
|
21
|
+
kind: "provider";
|
|
22
|
+
nodeId: string;
|
|
23
|
+
code: "rate-limit" | "auth" | "timeout";
|
|
24
|
+
}
|
|
25
|
+
| { kind: "tool"; nodeId: string; toolName: string; code: string };
|
|
26
|
+
|
|
27
|
+
type ReasonUnhealthy =
|
|
28
|
+
| { kind: "engine-heartbeat-stale"; lastHeartbeatAt: string }
|
|
29
|
+
| { kind: "ui-heartbeat-stale"; lastSeenAt: string }
|
|
30
|
+
| { kind: "db-lock" }
|
|
31
|
+
| { kind: "sandbox-unreachable" }
|
|
32
|
+
| { kind: "supervisor-backoff"; attempt: number; nextAt: string };
|
|
33
|
+
|
|
34
|
+
export type RunStateView = {
|
|
35
|
+
runId: string;
|
|
36
|
+
state: RunState;
|
|
37
|
+
blocked?: ReasonBlocked;
|
|
38
|
+
unhealthy?: ReasonUnhealthy;
|
|
39
|
+
computedAt: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type DevToolsSnapshot = {
|
|
43
|
+
tree: DevToolsNode | null;
|
|
44
|
+
nodeCount: number;
|
|
45
|
+
taskCount: number;
|
|
46
|
+
timestamp: number;
|
|
47
|
+
runState?: RunStateView;
|
|
48
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TaskExecutionState } from "./TaskExecutionState.ts";
|
|
2
|
+
|
|
3
|
+
/** Execution state for a run, aggregated from SmithersEvent stream */
|
|
4
|
+
export type RunExecutionState = {
|
|
5
|
+
runId: string;
|
|
6
|
+
status:
|
|
7
|
+
| "running"
|
|
8
|
+
| "finished"
|
|
9
|
+
| "failed"
|
|
10
|
+
| "cancelled"
|
|
11
|
+
| "waiting-approval"
|
|
12
|
+
| "waiting-timer";
|
|
13
|
+
frameNo: number;
|
|
14
|
+
tasks: Map<string, TaskExecutionState>;
|
|
15
|
+
events: Array<{ type: string; timestampMs: number; [key: string]: unknown }>;
|
|
16
|
+
startedAt?: number;
|
|
17
|
+
finishedAt?: number;
|
|
18
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** @typedef {import("./SmithersNodeType.ts").SmithersNodeType} SmithersNodeType */
|
|
2
|
+
|
|
3
|
+
/** @type {Record<SmithersNodeType, string>} */
|
|
4
|
+
export const SMITHERS_NODE_ICONS = {
|
|
5
|
+
workflow: "📋",
|
|
6
|
+
task: "⚡",
|
|
7
|
+
sequence: "➡️",
|
|
8
|
+
parallel: "⚡",
|
|
9
|
+
"merge-queue": "🔀",
|
|
10
|
+
branch: "🌿",
|
|
11
|
+
loop: "🔁",
|
|
12
|
+
worktree: "🌳",
|
|
13
|
+
approval: "✋",
|
|
14
|
+
timer: "⏱️",
|
|
15
|
+
subflow: "🔗",
|
|
16
|
+
"wait-for-event": "📡",
|
|
17
|
+
saga: "🔄",
|
|
18
|
+
"try-catch": "🛡️",
|
|
19
|
+
fragment: "📦",
|
|
20
|
+
unknown: "❓",
|
|
21
|
+
};
|