@clemrig/factory 0.1.0 → 0.2.1
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 +6 -17
- package/dist/app/doctor.d.ts +2 -4
- package/dist/app/doctor.js +6 -4
- package/dist/app/doctor.js.map +1 -1
- package/dist/app/factory.d.ts +2 -0
- package/dist/app/factory.js +13 -2
- package/dist/app/factory.js.map +1 -1
- package/dist/app/init.d.ts +1 -5
- package/dist/app/init.js +1 -13
- package/dist/app/init.js.map +1 -1
- package/dist/app/options.d.ts +17 -0
- package/dist/app/options.js +78 -0
- package/dist/app/options.js.map +1 -0
- package/dist/app/run.d.ts +4 -20
- package/dist/app/run.js +22 -93
- package/dist/app/run.js.map +1 -1
- package/dist/app/runs.d.ts +4 -32
- package/dist/app/runs.js +9 -61
- package/dist/app/runs.js.map +1 -1
- package/dist/cli/application.d.ts +1 -1
- package/dist/cli/application.js +1 -1
- package/dist/cli/args.js +2 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/doctor.d.ts +1 -1
- package/dist/cli/doctor.js +1 -1
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/help.d.ts +1 -1
- package/dist/cli/help.js +1 -1
- package/dist/cli/init.d.ts +1 -1
- package/dist/cli/init.js +1 -1
- package/dist/cli/launcher.d.ts +1 -1
- package/dist/cli/launcher.js +4 -4
- package/dist/cli/launcher.js.map +1 -1
- package/dist/cli/reporter.d.ts +1 -1
- package/dist/cli/reporter.js +1 -2
- package/dist/cli/reporter.js.map +1 -1
- package/dist/cli/run.d.ts +1 -5
- package/dist/cli/run.js +24 -11
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/ui.d.ts +1 -1
- package/dist/cli/ui.js +10 -3
- package/dist/cli/ui.js.map +1 -1
- package/dist/index.d.ts +3 -7
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/dist/system/factory.d.ts +1 -1
- package/dist/system/factory.js +1 -1
- package/dist/system/factory.js.map +1 -1
- package/dist/system/npm.d.ts +5 -0
- package/dist/system/npm.js +14 -0
- package/dist/system/npm.js.map +1 -0
- package/dist/system/templates.d.ts +1 -1
- package/dist/system/templates.js +1 -1
- package/package.json +7 -17
- package/dist/engine/metrics.d.ts +0 -45
- package/dist/engine/metrics.js +0 -60
- package/dist/engine/metrics.js.map +0 -1
- package/dist/engine/primitives.d.ts +0 -34
- package/dist/engine/primitives.js +0 -81
- package/dist/engine/primitives.js.map +0 -1
- package/dist/engine/profiles.d.ts +0 -53
- package/dist/engine/profiles.js +0 -117
- package/dist/engine/profiles.js.map +0 -1
- package/dist/engine/runner.d.ts +0 -13
- package/dist/engine/runner.js +0 -157
- package/dist/engine/runner.js.map +0 -1
- package/dist/engine/types.d.ts +0 -194
- package/dist/engine/types.js +0 -2
- package/dist/engine/types.js.map +0 -1
- package/dist/engine/workflow.d.ts +0 -18
- package/dist/engine/workflow.js +0 -196
- package/dist/engine/workflow.js.map +0 -1
- package/dist/system/process.d.ts +0 -21
- package/dist/system/process.js +0 -238
- package/dist/system/process.js.map +0 -1
- package/dist/system/runtimes/adapter.d.ts +0 -90
- package/dist/system/runtimes/adapter.js +0 -20
- package/dist/system/runtimes/adapter.js.map +0 -1
- package/dist/system/runtimes/agent-runtime.d.ts +0 -45
- package/dist/system/runtimes/agent-runtime.js +0 -184
- package/dist/system/runtimes/agent-runtime.js.map +0 -1
- package/dist/system/runtimes/claude-code.d.ts +0 -10
- package/dist/system/runtimes/claude-code.js +0 -383
- package/dist/system/runtimes/claude-code.js.map +0 -1
- package/dist/system/runtimes/inspect.d.ts +0 -25
- package/dist/system/runtimes/inspect.js +0 -129
- package/dist/system/runtimes/inspect.js.map +0 -1
- package/dist/system/runtimes/pi.d.ts +0 -7
- package/dist/system/runtimes/pi.js +0 -235
- package/dist/system/runtimes/pi.js.map +0 -1
- package/dist/system/runtimes/protocol.d.ts +0 -9
- package/dist/system/runtimes/protocol.js +0 -38
- package/dist/system/runtimes/protocol.js.map +0 -1
- package/dist/system/runtimes/registry.d.ts +0 -5
- package/dist/system/runtimes/registry.js +0 -5
- package/dist/system/runtimes/registry.js.map +0 -1
- package/dist/system/store.d.ts +0 -20
- package/dist/system/store.js +0 -126
- package/dist/system/store.js.map +0 -1
- package/dist/ui/server.d.ts +0 -8
- package/dist/ui/server.js +0 -111
- package/dist/ui/server.js.map +0 -1
- package/dist/ui/static/dashboard.js +0 -266
- package/dist/ui/static/follow.js +0 -67
- package/dist/ui/static/index.html +0 -20
- package/dist/ui/static/style.css +0 -166
- package/dist/ui/static/timeline.js +0 -180
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
/**
|
|
3
|
-
* The dashboard's pure logic: a run's events grouped into one block per stage
|
|
4
|
-
* execution, and the formats of durations and costs. Served as is to the browser.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/** @typedef {import("../../engine/types.js").RunEvent} RunEvent */
|
|
8
|
-
/** @typedef {import("../../engine/types.js").AgentActivity} AgentActivity */
|
|
9
|
-
/** @typedef {import("../../engine/metrics.js").TokenCounts} TokenCounts */
|
|
10
|
-
/** @typedef {import("../../engine/metrics.js").AgentUsage} AgentUsage */
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @typedef {object} Call
|
|
14
|
-
* @property {string} [runtime]
|
|
15
|
-
* @property {string} [model]
|
|
16
|
-
* @property {string} [session]
|
|
17
|
-
* @property {"running" | "completed" | "failed"} status
|
|
18
|
-
* @property {AgentUsage} [usage] As the runtime announced it at the end of the call.
|
|
19
|
-
* @property {"call" | "session"} [scope] Whether `usage` is the call's own or its session's total.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @typedef {object} Tool
|
|
24
|
-
* @property {string} id
|
|
25
|
-
* @property {string} name
|
|
26
|
-
* @property {"running" | "completed" | "failed"} status
|
|
27
|
-
* @property {number} [durationMs]
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @typedef {object} Block
|
|
32
|
-
* @property {string} stage
|
|
33
|
-
* @property {string} kind
|
|
34
|
-
* @property {"running" | "passed" | "failed" | "completed"} status
|
|
35
|
-
* @property {string} startedAt
|
|
36
|
-
* @property {number | null} durationMs
|
|
37
|
-
* @property {{ verdict: string; reason: string; destination: string | null }} [decision]
|
|
38
|
-
* @property {{ key: string; count: number; max: number }} [retry]
|
|
39
|
-
* @property {string} [detail]
|
|
40
|
-
* @property {Call} [call]
|
|
41
|
-
* @property {Tool[]} tools
|
|
42
|
-
* @property {TokenCounts | null} tokens The call's responses so far.
|
|
43
|
-
* @property {boolean} provisional Whether `tokens` includes figures replaced at the end of the call.
|
|
44
|
-
* @property {string[]} warnings
|
|
45
|
-
* @property {{ at: string; message: string }[]} journal
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @param {string} stage
|
|
50
|
-
* @param {string} kind
|
|
51
|
-
* @param {string} at
|
|
52
|
-
* @returns {Block}
|
|
53
|
-
*/
|
|
54
|
-
const block = (stage, kind, at) => ({
|
|
55
|
-
stage,
|
|
56
|
-
kind,
|
|
57
|
-
status: "running",
|
|
58
|
-
startedAt: at,
|
|
59
|
-
durationMs: null,
|
|
60
|
-
tools: [],
|
|
61
|
-
tokens: null,
|
|
62
|
-
provisional: false,
|
|
63
|
-
warnings: [],
|
|
64
|
-
journal: [],
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* @param {Block} target
|
|
69
|
-
* @param {AgentActivity} activity
|
|
70
|
-
*/
|
|
71
|
-
function apply(target, activity) {
|
|
72
|
-
switch (activity.kind) {
|
|
73
|
-
case "call":
|
|
74
|
-
if (activity.status === "started") {
|
|
75
|
-
const { runtime, model, session } = activity;
|
|
76
|
-
target.call = { runtime, model, session, status: "running" };
|
|
77
|
-
} else
|
|
78
|
-
target.call = {
|
|
79
|
-
...target.call,
|
|
80
|
-
runtime: activity.runtime,
|
|
81
|
-
status: activity.status,
|
|
82
|
-
usage: activity.usage,
|
|
83
|
-
scope: activity.scope,
|
|
84
|
-
};
|
|
85
|
-
break;
|
|
86
|
-
case "tool": {
|
|
87
|
-
const tool = target.tools.find(({ id }) => id === activity.id);
|
|
88
|
-
const update =
|
|
89
|
-
activity.status === "started"
|
|
90
|
-
? { id: activity.id, name: activity.name, status: "running" }
|
|
91
|
-
: {
|
|
92
|
-
id: activity.id,
|
|
93
|
-
name: activity.name,
|
|
94
|
-
status: activity.status,
|
|
95
|
-
durationMs: activity.durationMs,
|
|
96
|
-
};
|
|
97
|
-
if (tool) Object.assign(tool, update);
|
|
98
|
-
else target.tools.push(/** @type {Tool} */ (update));
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
case "response": {
|
|
102
|
-
const sum = target.tokens ?? {
|
|
103
|
-
input: 0,
|
|
104
|
-
output: 0,
|
|
105
|
-
cacheRead: 0,
|
|
106
|
-
cacheWrite: 0,
|
|
107
|
-
};
|
|
108
|
-
for (const field of /** @type {const} */ ([
|
|
109
|
-
"input",
|
|
110
|
-
"output",
|
|
111
|
-
"cacheRead",
|
|
112
|
-
"cacheWrite",
|
|
113
|
-
]))
|
|
114
|
-
sum[field] += activity.tokens[field];
|
|
115
|
-
target.tokens = sum;
|
|
116
|
-
target.provisional ||= activity.provisional;
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
case "warning":
|
|
120
|
-
target.warnings.push(activity.message);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* One block per stage execution, in order: a stage's journal, agent activity
|
|
126
|
-
* and decision go to its latest block.
|
|
127
|
-
* @param {RunEvent[]} events
|
|
128
|
-
* @returns {Block[]}
|
|
129
|
-
*/
|
|
130
|
-
export function timeline(events) {
|
|
131
|
-
/** @type {Block[]} */
|
|
132
|
-
const blocks = [];
|
|
133
|
-
const latest = (/** @type {string} */ stage) =>
|
|
134
|
-
blocks.findLast((candidate) => candidate.stage === stage);
|
|
135
|
-
for (const event of events) {
|
|
136
|
-
if (event.type === "stage" && event.status === "started") {
|
|
137
|
-
blocks.push(block(event.stage, event.kind, event.at));
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
let target = latest(event.stage);
|
|
141
|
-
if (!target || (event.type === "stage" && target.status !== "running")) {
|
|
142
|
-
// A stage reported without a start, such as one failed by an interruption.
|
|
143
|
-
target = block(event.stage, event.kind, event.at);
|
|
144
|
-
blocks.push(target);
|
|
145
|
-
}
|
|
146
|
-
if (event.type === "stage") {
|
|
147
|
-
target.status = event.status === "started" ? "running" : event.status;
|
|
148
|
-
target.durationMs = Date.parse(event.at) - Date.parse(target.startedAt);
|
|
149
|
-
if (event.decision) target.decision = event.decision;
|
|
150
|
-
if (event.retry) target.retry = event.retry;
|
|
151
|
-
if (event.detail) target.detail = event.detail;
|
|
152
|
-
} else if (event.type === "log")
|
|
153
|
-
target.journal.push({ at: event.at, message: event.message });
|
|
154
|
-
else apply(target, event.activity);
|
|
155
|
-
}
|
|
156
|
-
return blocks;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* @param {number | null} ms
|
|
161
|
-
* @returns {string}
|
|
162
|
-
*/
|
|
163
|
-
export function duration(ms) {
|
|
164
|
-
if (ms === null) return "—";
|
|
165
|
-
const seconds = Math.floor(ms / 1000);
|
|
166
|
-
const hours = Math.floor(seconds / 3600);
|
|
167
|
-
const minutes = Math.floor((seconds % 3600) / 60);
|
|
168
|
-
return `${hours ? `${hours} h ` : ""}${minutes} min ${seconds % 60} s`;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* An estimated cost as the runtimes announced it; unknown without any measure.
|
|
173
|
-
* @param {number | null} usd
|
|
174
|
-
* @param {boolean} partial Some agent call announced no usage.
|
|
175
|
-
* @returns {string}
|
|
176
|
-
*/
|
|
177
|
-
export function cost(usd, partial) {
|
|
178
|
-
const value = usd === null ? "—" : `${usd.toFixed(4)} USD`;
|
|
179
|
-
return partial ? `${value} (partial)` : value;
|
|
180
|
-
}
|