@withgauge/cli 0.26.0 → 0.28.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/README.md +141 -13
- package/dist/batchWorker.js +1 -1
- package/dist/{chatApi-CLMRDLLS.js → chatApi-HF2R3SVR.js} +1 -1
- package/dist/{chunk-3I3IT3LG.js → chunk-AZKXHO6C.js} +1 -1
- package/dist/chunk-PMX3NOGH.js +2 -0
- package/dist/chunk-PUNARKS2.js +64 -0
- package/dist/chunk-PVTU7NGL.js +1 -0
- package/dist/chunk-TAFB66SK.js +6 -0
- package/dist/chunk-Y4Y2AKDY.js +1 -0
- package/dist/index.js +291 -112
- package/dist/{orgDirectory-QX23FAS2.js → orgDirectory-QCOOVF65.js} +1 -1
- package/dist/watch/app.js +576 -0
- package/dist/watch/favicon.svg +11 -0
- package/dist/watch/index.html +21 -0
- package/dist/watch/logo-for-dark.png +0 -0
- package/dist/watch/logo-for-light.png +0 -0
- package/dist/watch/style.css +133 -0
- package/dist/watchServer.js +1 -0
- package/package.json +1 -1
- package/dist/chunk-MAANSWGU.js +0 -2
- package/dist/chunk-NXOOFF5A.js +0 -69
- package/dist/chunk-QWDJLPRW.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createdOrganization,credentialKind,fetchDirectory,findOrganization,isUuid,keyOrganization,legacySelection,missingAgentsOrg,productsLabel,resolveOrgValue,resolveSelection}from"./chunk-
|
|
1
|
+
import{createdOrganization,credentialKind,fetchDirectory,findOrganization,isUuid,keyOrganization,legacySelection,missingAgentsOrg,productsLabel,resolveOrgValue,resolveSelection}from"./chunk-AZKXHO6C.js";import"./chunk-PMX3NOGH.js";import"./chunk-OIGVDK3F.js";import"./chunk-PSBF4TEK.js";export{createdOrganization,credentialKind,fetchDirectory,findOrganization,isUuid,keyOrganization,legacySelection,missingAgentsOrg,productsLabel,resolveOrgValue,resolveSelection};
|
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var STATUSES = [["all", "All"], ["running", "Running"], ["completed", "Completed"], ["failed", "Failed"], ["unavailable", "Unavailable"]];
|
|
3
|
+
var state = { sessions: [], filter: "all", query: "", selected: null, detail: null, tab: "trace",
|
|
4
|
+
events: [], inputs: [], lastSeq: -1, diff: null, diffOpen: {}, traceToken: 0, promptOpen: false, sessionsJson: "" };
|
|
5
|
+
|
|
6
|
+
function h(tag, attrs) {
|
|
7
|
+
var el = document.createElement(tag);
|
|
8
|
+
if (attrs) for (var k in attrs) {
|
|
9
|
+
if (k === "class") el.className = attrs[k];
|
|
10
|
+
else if (k === "text") el.textContent = attrs[k];
|
|
11
|
+
else if (k.slice(0, 2) === "on") el.addEventListener(k.slice(2), attrs[k]);
|
|
12
|
+
else el.setAttribute(k, attrs[k]);
|
|
13
|
+
}
|
|
14
|
+
for (var i = 2; i < arguments.length; i++) {
|
|
15
|
+
var c = arguments[i];
|
|
16
|
+
if (c == null || c === false) continue;
|
|
17
|
+
el.appendChild(typeof c === "string" ? document.createTextNode(c) : c);
|
|
18
|
+
}
|
|
19
|
+
return el;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function stamp(iso) {
|
|
23
|
+
if (!iso) return "";
|
|
24
|
+
var d = new Date(iso);
|
|
25
|
+
return d.toDateString() === new Date().toDateString()
|
|
26
|
+
? d.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })
|
|
27
|
+
: d.toLocaleDateString([], { month: "short", day: "numeric" });
|
|
28
|
+
}
|
|
29
|
+
function duration(ms) {
|
|
30
|
+
if (ms == null) return "";
|
|
31
|
+
var s = Math.round(ms / 1000);
|
|
32
|
+
return s < 60 ? s + "s" : Math.floor(s / 60) + "m " + (s % 60) + "s";
|
|
33
|
+
}
|
|
34
|
+
function turns(n) { return n + (n === 1 ? " turn" : " turns"); }
|
|
35
|
+
function clock(iso) { return iso ? new Date(iso).toLocaleTimeString() : ""; }
|
|
36
|
+
function stateClass(s) { return s.live ? "live" : s.state; }
|
|
37
|
+
function text(v) {
|
|
38
|
+
if (v == null) return "";
|
|
39
|
+
if (typeof v === "string") return v;
|
|
40
|
+
try { return JSON.stringify(v, null, 2); } catch (e) { return String(v); }
|
|
41
|
+
}
|
|
42
|
+
function clip(v, n) { v = text(v); return v.length > n ? v.slice(0, n) + "\n… (" + (v.length - n) + " more characters)" : v; }
|
|
43
|
+
|
|
44
|
+
async function get(path, type) {
|
|
45
|
+
var res = await fetch(path, { cache: "no-store" });
|
|
46
|
+
if (!res.ok) throw new Error(res.status + " " + path);
|
|
47
|
+
return type === "text" ? res.text() : res.json();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function icon(path, size) {
|
|
51
|
+
return '<svg width="' + size + '" height="' + size + '" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">' + path + '</svg>';
|
|
52
|
+
}
|
|
53
|
+
var FUNNEL = icon('<path d="M2 3h12l-4.5 5.5V13l-3 1.5v-6z"/>', 13);
|
|
54
|
+
var CHEVRON = icon('<path d="M4 6l4 4 4-4"/>', 12);
|
|
55
|
+
var SEARCH = icon('<circle cx="7" cy="7" r="4.5"/><path d="M10.5 10.5L14 14"/>', 14);
|
|
56
|
+
|
|
57
|
+
function params() {
|
|
58
|
+
var p = new URLSearchParams();
|
|
59
|
+
if (state.filter !== "all") p.set("status", state.filter);
|
|
60
|
+
if (state.query) p.set("q", state.query);
|
|
61
|
+
var q = p.toString();
|
|
62
|
+
return q ? "?" + q : "";
|
|
63
|
+
}
|
|
64
|
+
function go(path) { location.hash = path + params(); }
|
|
65
|
+
function syncUrl() { history.replaceState(null, "", "#" + (location.hash.slice(1).split("?")[0] || "/") + params()); }
|
|
66
|
+
|
|
67
|
+
function matches(s, status) {
|
|
68
|
+
if (status === "running") return s.live;
|
|
69
|
+
if (status === "completed") return s.state === "completed";
|
|
70
|
+
if (status === "unavailable") return s.state === "unavailable";
|
|
71
|
+
if (status === "failed") return s.state === "failed" || s.state === "interrupted" || s.state === "canceled";
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function renderFilters() {
|
|
76
|
+
var box = document.getElementById("filters");
|
|
77
|
+
if (!box.firstChild) {
|
|
78
|
+
var input = h("input", { id: "q", placeholder: "Search sessions" });
|
|
79
|
+
input.addEventListener("input", function () { state.query = input.value; syncUrl(); renderList(); });
|
|
80
|
+
var menu = h("div", { id: "status-menu", class: "menu", hidden: "" });
|
|
81
|
+
var button = h("button", { id: "status", title: "Filter by status", onclick: function (e) { e.stopPropagation(); menu.hidden = !menu.hidden; } });
|
|
82
|
+
document.addEventListener("click", function (e) { if (!menu.contains(e.target)) menu.hidden = true; });
|
|
83
|
+
document.addEventListener("keydown", function (e) { if (e.key === "Escape") menu.hidden = true; });
|
|
84
|
+
button.innerHTML = FUNNEL + '<span class="label"></span>' + CHEVRON;
|
|
85
|
+
var glass = h("span", { class: "glass" });
|
|
86
|
+
glass.innerHTML = SEARCH;
|
|
87
|
+
STATUSES.forEach(function (f) {
|
|
88
|
+
menu.appendChild(h("button", { "data-status": f[0], onclick: function () {
|
|
89
|
+
state.filter = f[0]; menu.hidden = true; syncUrl(); renderFilters(); renderList();
|
|
90
|
+
} }, h("span", { class: "check" }), f[1], h("span", { class: "count" })));
|
|
91
|
+
});
|
|
92
|
+
box.appendChild(h("div", { class: "search", onclick: function (e) { if (e.target === this) input.focus(); } }, glass, button, input, menu));
|
|
93
|
+
}
|
|
94
|
+
var q = document.getElementById("q");
|
|
95
|
+
if (q.value !== state.query) q.value = state.query;
|
|
96
|
+
var button = document.getElementById("status");
|
|
97
|
+
var active = STATUSES.find(function (f) { return f[0] === state.filter; });
|
|
98
|
+
button.className = "status-btn" + (state.filter !== "all" ? " on" : "");
|
|
99
|
+
button.querySelector(".label").textContent = state.filter === "all" ? "Status" : active[1];
|
|
100
|
+
document.querySelectorAll("#status-menu button").forEach(function (item) {
|
|
101
|
+
var status = item.dataset.status;
|
|
102
|
+
item.className = state.filter === status ? "on" : "";
|
|
103
|
+
item.querySelector(".check").textContent = state.filter === status ? "✓" : "";
|
|
104
|
+
item.querySelector(".count").textContent = String(state.sessions.filter(function (s) { return matches(s, status); }).length);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
var AGENTS = { CLAUDE_CODE: "Claude Code", CODEX_CLI: "Codex", OPENCODE: "OpenCode", PI: "Pi" };
|
|
109
|
+
function agentName(a) { return AGENTS[a] || a; }
|
|
110
|
+
|
|
111
|
+
function splitCase(path) {
|
|
112
|
+
path = (path || "").replace(/^gauge-cases\//, "").replace(/\.md$/, "");
|
|
113
|
+
var i = path.lastIndexOf("/");
|
|
114
|
+
return i < 0 ? ["", path] : [path.slice(0, i + 1), path.slice(i + 1)];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function visible() {
|
|
118
|
+
return state.sessions.filter(function (s) {
|
|
119
|
+
if (!matches(s, state.filter)) return false;
|
|
120
|
+
if (!state.query) return true;
|
|
121
|
+
return [s.case, s.agent, agentName(s.agent), s.model, s.id, s.batchId].join(" ").toLowerCase().indexOf(state.query.toLowerCase()) >= 0;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function renderList() {
|
|
126
|
+
var list = document.getElementById("list");
|
|
127
|
+
var scroll = list.scrollTop;
|
|
128
|
+
list.textContent = "";
|
|
129
|
+
var rows = visible();
|
|
130
|
+
if (!rows.length) {
|
|
131
|
+
list.appendChild(h("div", { class: "empty", style: "padding:24px" }, state.sessions.length ? "No sessions match." : "No sessions yet. Start one with gauge run."));
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
var batches = {}, order = [];
|
|
135
|
+
rows.forEach(function (s) {
|
|
136
|
+
if (!batches[s.batchId]) { batches[s.batchId] = []; order.push(s.batchId); }
|
|
137
|
+
batches[s.batchId].push(s);
|
|
138
|
+
});
|
|
139
|
+
order.forEach(function (batch) {
|
|
140
|
+
list.appendChild(h("div", { class: "batch" }, "Batch " + batch.slice(0, 8)));
|
|
141
|
+
batches[batch].forEach(function (s) { list.appendChild(renderRow(s)); });
|
|
142
|
+
});
|
|
143
|
+
list.scrollTop = scroll;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function renderRow(s) {
|
|
147
|
+
var name = s.case ? splitCase(s.case) : ["", s.id];
|
|
148
|
+
var stats = [s.state === "completed" ? null : s.state, s.turns ? turns(s.turns) : null, s.live ? null : duration(s.durationMs)].filter(Boolean).join(" · ");
|
|
149
|
+
var who = [agentName(s.agent), s.model].filter(Boolean).join(" · ");
|
|
150
|
+
return h("div", { class: "row" + (s.id === state.selected ? " sel" : ""), title: s.case || s.id, onclick: function () { go("#/session/" + s.id); } },
|
|
151
|
+
h("span", { class: "dot " + stateClass(s) }),
|
|
152
|
+
h("span", { class: "case" }, name[1]),
|
|
153
|
+
h("span", { class: "age", title: s.createdAt ? "Started " + new Date(s.createdAt).toLocaleString() : "" }, stamp(s.createdAt)),
|
|
154
|
+
h("span", { class: "meta" }, who || "\u00a0"),
|
|
155
|
+
h("span", { class: "meta" }, stats || "\u00a0"));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function usageTotals() {
|
|
159
|
+
var t = { input: 0, output: 0, seen: false };
|
|
160
|
+
state.events.forEach(function (e) {
|
|
161
|
+
var p = e.payload;
|
|
162
|
+
if (!p || p.type !== "usage") return;
|
|
163
|
+
t.seen = true;
|
|
164
|
+
t.input += (p.input_tokens || 0) + (p.cache_read_input_tokens || 0) + (p.cache_creation_input_tokens || 0);
|
|
165
|
+
t.output += p.output_tokens || 0;
|
|
166
|
+
});
|
|
167
|
+
return t;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function compact(n) { return n >= 1000 ? (n / 1000).toFixed(n >= 10000 ? 0 : 1) + "k" : String(n); }
|
|
171
|
+
|
|
172
|
+
function renderHead(view) {
|
|
173
|
+
var s = state.detail;
|
|
174
|
+
var name = s.case ? splitCase(s.case) : ["", s.id];
|
|
175
|
+
var u = usageTotals();
|
|
176
|
+
var fields = [
|
|
177
|
+
["State", s.state, stateClass(s)],
|
|
178
|
+
["Last known state", s.lastKnownState],
|
|
179
|
+
["Agent", agentName(s.agent)], ["Model", s.model], ["Turns", String(s.turns)],
|
|
180
|
+
["Duration", s.durationMs != null ? duration(s.durationMs) : null],
|
|
181
|
+
["Tokens", u.seen ? compact(u.input) + " in / " + compact(u.output) + " out" : s.inputTokens != null ? compact(s.inputTokens) + " in / " + compact(s.outputTokens || 0) + " out" : null],
|
|
182
|
+
["Measurement", s.measurement ? s.measurement.kind + " r" + s.measurement.revision : null],
|
|
183
|
+
["Sample", s.sample != null ? String(s.sample) : null],
|
|
184
|
+
["Started", s.createdAt ? new Date(s.createdAt).toLocaleString() : null],
|
|
185
|
+
["Run", s.id],
|
|
186
|
+
];
|
|
187
|
+
var grid = h("dl", { class: "meta-grid" });
|
|
188
|
+
fields.forEach(function (f) { if (f[1]) grid.appendChild(h("div", null, h("dt", null, f[0]), h("dd", { class: f[2] || "" }, f[1]))); });
|
|
189
|
+
view.appendChild(h("div", { class: "head" },
|
|
190
|
+
h("h2", null, h("span", { class: "dot " + stateClass(s) }), h("span", null, h("span", { class: "dir" }, name[0]), name[1])),
|
|
191
|
+
s.prompt ? h("div", { class: "prompt" + (state.promptOpen ? " open" : "") },
|
|
192
|
+
h("div", { class: "text" }, s.prompt),
|
|
193
|
+
h("button", { class: "more", onclick: function () { state.promptOpen = !state.promptOpen; renderView(); } }, state.promptOpen ? "Show less" : "Show more")) : null,
|
|
194
|
+
grid,
|
|
195
|
+
s.detail && !s.live && s.state !== "completed" ? h("div", { class: "detail" }, s.detail) : null));
|
|
196
|
+
var tabs = h("div", { class: "tabs" });
|
|
197
|
+
[["trace", "Trace"], ["task", "Task"], ["diff", "Diff"]].forEach(function (t) {
|
|
198
|
+
tabs.appendChild(h("button", { class: state.tab === t[0] ? "on" : "", onclick: function () { go("#/session/" + state.selected + "/" + t[0]); } }, t[1]));
|
|
199
|
+
});
|
|
200
|
+
view.appendChild(tabs);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
var WORKSPACE = /\/gauge\/session\/workspace\/?/g;
|
|
204
|
+
function short(v) { return String(v).replace(WORKSPACE, ""); }
|
|
205
|
+
|
|
206
|
+
function markdown(value) {
|
|
207
|
+
var root = h("div", { class: "t-msg" });
|
|
208
|
+
var lines = String(value || "").trim().split("\n");
|
|
209
|
+
var para = [], list = null, fence = null;
|
|
210
|
+
function flush() {
|
|
211
|
+
if (para.length) root.appendChild(inline(h("p"), para.join("\n")));
|
|
212
|
+
para = [];
|
|
213
|
+
list = null;
|
|
214
|
+
}
|
|
215
|
+
lines.forEach(function (line) {
|
|
216
|
+
if (fence) {
|
|
217
|
+
if (line.trim().slice(0, 3) === "```") { root.appendChild(h("pre", null, fence.join("\n"))); fence = null; }
|
|
218
|
+
else fence.push(line);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (line.trim().slice(0, 3) === "```") { flush(); fence = []; return; }
|
|
222
|
+
var bullet = /^\s*(?:[-*]|(\d+)[.)])\s+(.*)$/.exec(line);
|
|
223
|
+
if (bullet) {
|
|
224
|
+
if (para.length) flush();
|
|
225
|
+
var tag = bullet[1] ? "ol" : "ul";
|
|
226
|
+
if (!list || list.tagName.toLowerCase() !== tag) { list = h(tag); root.appendChild(list); }
|
|
227
|
+
list.appendChild(inline(h("li"), bullet[2]));
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
var heading = /^#{1,6}\s+(.*)$/.exec(line);
|
|
231
|
+
if (heading) { flush(); root.appendChild(inline(h("h4"), heading[1])); return; }
|
|
232
|
+
if (!line.trim()) { flush(); return; }
|
|
233
|
+
list = null;
|
|
234
|
+
para.push(line);
|
|
235
|
+
});
|
|
236
|
+
if (fence) root.appendChild(h("pre", null, fence.join("\n")));
|
|
237
|
+
flush();
|
|
238
|
+
return root;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function toolSummary(call) {
|
|
242
|
+
var input = call.input;
|
|
243
|
+
if (input && typeof input === "object") {
|
|
244
|
+
var v = input.command || input.cmd || input.file_path || input.path || input.url || input.query || input.pattern;
|
|
245
|
+
if (Array.isArray(v)) v = v.join(" ");
|
|
246
|
+
if (typeof v === "string") return short(v.split("\n")[0]);
|
|
247
|
+
}
|
|
248
|
+
return clip(input, 120).split("\n")[0];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function timeline() {
|
|
252
|
+
var results = {}, calls = {};
|
|
253
|
+
state.events.forEach(function (e) {
|
|
254
|
+
if (!e.payload) return;
|
|
255
|
+
if (e.payload.type === "tool_result") results[e.payload.tool_id] = e;
|
|
256
|
+
else if (e.payload.type === "tool_call") calls[e.payload.tool_id] = true;
|
|
257
|
+
});
|
|
258
|
+
var items = [];
|
|
259
|
+
state.inputs.forEach(function (i, n) {
|
|
260
|
+
if (n === 0 && state.detail && typeof i.text === "string" && i.text.trim() === (state.detail.prompt || "").trim()) return;
|
|
261
|
+
items.push({ at: i.observedAt, order: -1, input: i }); });
|
|
262
|
+
state.events.forEach(function (e) {
|
|
263
|
+
var p = e.payload || {};
|
|
264
|
+
if (p.type === "tool_result" && p.tool_id && calls[p.tool_id]) return;
|
|
265
|
+
items.push({ at: e.observedAt, order: e.seq, event: e, result: p.type === "tool_call" ? results[p.tool_id] : null });
|
|
266
|
+
});
|
|
267
|
+
items.sort(function (a, b) { return a.at < b.at ? -1 : a.at > b.at ? 1 : a.order - b.order; });
|
|
268
|
+
return items;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function inline(el, value) {
|
|
272
|
+
String(value || "").split(/(\*\*[^*\n]+\*\*|`[^`\n]+`)/).forEach(function (part) {
|
|
273
|
+
if (/^\*\*[^*]+\*\*$/.test(part)) el.appendChild(h("b", null, part.slice(2, -2)));
|
|
274
|
+
else if (/^`[^`]+`$/.test(part)) el.appendChild(h("code", null, part.slice(1, -1)));
|
|
275
|
+
else if (part) el.appendChild(document.createTextNode(part));
|
|
276
|
+
});
|
|
277
|
+
return el;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function firstLine(v) {
|
|
281
|
+
var lines = text(v).split("\n").filter(function (l) { return l.trim(); });
|
|
282
|
+
if (!lines.length) return "(no output)";
|
|
283
|
+
return short(lines[0]) + (lines.length > 1 ? " … +" + (lines.length - 1) + " lines" : "");
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function renderItem(item) {
|
|
287
|
+
if (item.input) {
|
|
288
|
+
var i = item.input;
|
|
289
|
+
var user = h("div", { class: "t-user" }, "› " + (i.text != null ? i.text : text(i.answer)));
|
|
290
|
+
return item.first ? user : h("div", null, h("div", { class: "t-turn" }, (i.text != null ? "Turn " : "Answer · turn ") + i.turn), user);
|
|
291
|
+
}
|
|
292
|
+
var e = item.event, p = e.payload || {};
|
|
293
|
+
if (p.type === "agent_message") return markdown(p.text);
|
|
294
|
+
if (p.type === "reasoning") {
|
|
295
|
+
var think = inline(h("div", { class: "t-think clamp", title: clock(e.observedAt) }), String(p.text || "").trim());
|
|
296
|
+
think.addEventListener("click", function () { think.classList.toggle("clamp"); });
|
|
297
|
+
return think;
|
|
298
|
+
}
|
|
299
|
+
if (p.type === "usage") return null;
|
|
300
|
+
if (p.type === "tool_call" || p.type === "tool_result") {
|
|
301
|
+
var r = item.result ? item.result.payload : p.type === "tool_result" ? p : null;
|
|
302
|
+
var err = r && r.is_error;
|
|
303
|
+
var dot = r ? (err ? "failed" : "completed") : state.detail.live ? "live" : "";
|
|
304
|
+
var box = h("div", { class: "t-tool" + (err ? " err" : "") },
|
|
305
|
+
h("div", { class: "call", title: clock(e.observedAt), onclick: function () { box.classList.toggle("open"); } },
|
|
306
|
+
h("span", { class: "dot " + dot }),
|
|
307
|
+
h("span", { class: "name" }, p.name || p.tool_kind || "tool"),
|
|
308
|
+
h("span", { class: "arg" }, toolSummary(p))),
|
|
309
|
+
h("div", { class: "out" }, "⎿ " + (r ? firstLine(r.output) : state.detail.live ? "running…" : state.detail.state === "unavailable" ? "(status unavailable)" : "(no result)")),
|
|
310
|
+
h("div", { class: "full" },
|
|
311
|
+
h("div", { class: "kv" }, "Input"), h("pre", null, clip(p.input, 20000)),
|
|
312
|
+
r ? h("div", { class: "kv" }, "Output" + (r.outputBytes ? " · " + r.outputBytes.toLocaleString() + " bytes" : "")) : null,
|
|
313
|
+
r ? h("pre", null, clip(r.output, 20000)) : null));
|
|
314
|
+
return box;
|
|
315
|
+
}
|
|
316
|
+
if (p.type === "harness_action") return h("div", { class: "t-err" }, "✕ " + p.action + ": " + (p.message || ""));
|
|
317
|
+
return h("pre", null, clip(p, 4000));
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function renderTrace(body, open) {
|
|
321
|
+
var items = timeline();
|
|
322
|
+
var root = h("div", { class: "trace" });
|
|
323
|
+
body.appendChild(root);
|
|
324
|
+
body = root;
|
|
325
|
+
var group = null;
|
|
326
|
+
items.forEach(function (item, n) {
|
|
327
|
+
item.first = n === 0;
|
|
328
|
+
var el = renderItem(item);
|
|
329
|
+
if (!el) return;
|
|
330
|
+
if (item.event) {
|
|
331
|
+
el.dataset.seq = item.event.seq;
|
|
332
|
+
if (open[item.event.seq]) el.classList.add("open");
|
|
333
|
+
}
|
|
334
|
+
if (el.classList.contains("t-tool")) {
|
|
335
|
+
if (!group) { group = h("div", { class: "t-tools" }); body.appendChild(group); }
|
|
336
|
+
group.appendChild(el);
|
|
337
|
+
} else {
|
|
338
|
+
group = null;
|
|
339
|
+
body.appendChild(el);
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
if (!items.length) body.appendChild(h("div", { class: "pending" }, state.detail.live ? "Waiting for the agent's first event…" : state.detail.state === "unavailable" ? "No trace events available yet. Session status is unavailable." : "This session recorded no trace events."));
|
|
343
|
+
else if (state.detail.live && !(body.lastChild && body.lastChild.querySelector(".dot.live"))) body.appendChild(h("div", { class: "pending" }, h("span", { class: "dot live" }), state.detail.state + "…"));
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function renderTask(body) {
|
|
347
|
+
var s = state.detail;
|
|
348
|
+
body = body.appendChild(h("div", { class: "task" }));
|
|
349
|
+
body.appendChild(h("div", { class: "kv" }, "Prompt"));
|
|
350
|
+
body.appendChild(h("pre", null, s.prompt || "(none)"));
|
|
351
|
+
if (Array.isArray(s.criteria) && s.criteria.length) {
|
|
352
|
+
body.appendChild(h("div", { class: "kv" }, "Criteria"));
|
|
353
|
+
var list = h("ol", { class: "criteria" });
|
|
354
|
+
s.criteria.forEach(function (c, n) {
|
|
355
|
+
var name = typeof c === "string" ? c : c.name || c.text || c.description || c.id || "";
|
|
356
|
+
var rubric = typeof c === "string" ? null : c.rubric || (c.name && c.text) || null;
|
|
357
|
+
list.appendChild(h("li", null, h("span", { class: "n" }, String(n + 1)), h("span", { class: "name" }, name), rubric ? h("span", { class: "rubric" }, rubric) : null));
|
|
358
|
+
});
|
|
359
|
+
body.appendChild(list);
|
|
360
|
+
}
|
|
361
|
+
if (s.preference) {
|
|
362
|
+
body.appendChild(h("div", { class: "kv" }, "Preference"));
|
|
363
|
+
body.appendChild(h("pre", null, text(s.preference)));
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
var LOCKFILES = /(^|\/)(package-lock\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?|Cargo\.lock|poetry\.lock|uv\.lock|go\.sum)$/;
|
|
368
|
+
|
|
369
|
+
function parseDiff(textValue) {
|
|
370
|
+
var files = [], file = null, oldNo = 0, newNo = 0;
|
|
371
|
+
textValue.split("\n").forEach(function (line) {
|
|
372
|
+
if (line.slice(0, 11) === "diff --git ") {
|
|
373
|
+
var m = /^diff --git a\/(.*) b\/(.*)$/.exec(line);
|
|
374
|
+
file = { path: m ? m[2] : line.slice(11), from: m ? m[1] : null, status: "", lines: [], add: 0, del: 0, binary: false };
|
|
375
|
+
files.push(file);
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (!file) return;
|
|
379
|
+
if (!file.lines.length) {
|
|
380
|
+
if (line.slice(0, 13) === "new file mode") { file.status = "new"; return; }
|
|
381
|
+
if (line.slice(0, 17) === "deleted file mode") { file.status = "deleted"; return; }
|
|
382
|
+
if (line.slice(0, 12) === "rename from ") { file.from = line.slice(12); file.status = "renamed"; return; }
|
|
383
|
+
if (line.slice(0, 10) === "rename to ") { file.path = line.slice(10); return; }
|
|
384
|
+
if (line.slice(0, 12) === "Binary files") { file.binary = true; return; }
|
|
385
|
+
if (line.slice(0, 4) === "--- " || line.slice(0, 4) === "+++ " || line.slice(0, 6) === "index " || /^(old|new) mode|^similarity index/.test(line)) return;
|
|
386
|
+
}
|
|
387
|
+
var hunk = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@(.*)$/.exec(line);
|
|
388
|
+
if (hunk) { oldNo = +hunk[1]; newNo = +hunk[2]; file.lines.push({ kind: "hunk", text: line }); return; }
|
|
389
|
+
if (!file.lines.length) return;
|
|
390
|
+
var c = line[0];
|
|
391
|
+
if (c === "+") { file.add++; file.lines.push({ kind: "add", newNo: newNo++, text: line.slice(1) }); }
|
|
392
|
+
else if (c === "-") { file.del++; file.lines.push({ kind: "del", oldNo: oldNo++, text: line.slice(1) }); }
|
|
393
|
+
else if (c === "\\") file.lines.push({ kind: "meta", text: line.slice(2) });
|
|
394
|
+
else if (c === " ") file.lines.push({ kind: "ctx", oldNo: oldNo++, newNo: newNo++, text: line.slice(1) });
|
|
395
|
+
});
|
|
396
|
+
return files;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function renderDiff(body) {
|
|
400
|
+
if (state.diff == null) return body.appendChild(h("div", { class: "pending" }, "Loading…"));
|
|
401
|
+
if (!state.diff) return body.appendChild(h("div", { class: "pending" }, state.detail.live ? "The diff is written when the session ends." : state.detail.state === "unavailable" ? "No diff available yet. Session status is unavailable." : "No diff."));
|
|
402
|
+
var files = parseDiff(state.diff);
|
|
403
|
+
if (!files.length) return body.appendChild(h("pre", null, state.diff));
|
|
404
|
+
var adds = 0, dels = 0;
|
|
405
|
+
files.forEach(function (f) { adds += f.add; dels += f.del; });
|
|
406
|
+
body.appendChild(h("div", { class: "d-summary" },
|
|
407
|
+
h("b", null, files.length + (files.length === 1 ? " file changed" : " files changed")),
|
|
408
|
+
h("span", { class: "d-add" }, "+" + adds), h("span", { class: "d-del" }, "−" + dels)));
|
|
409
|
+
files.forEach(function (f) {
|
|
410
|
+
var key = state.selected + ":" + f.path;
|
|
411
|
+
if (!(key in state.diffOpen)) state.diffOpen[key] = !LOCKFILES.test(f.path) && f.add + f.del <= 600;
|
|
412
|
+
var i = f.path.lastIndexOf("/");
|
|
413
|
+
var box = h("div", { class: "d-file" + (state.diffOpen[key] ? "" : " closed") });
|
|
414
|
+
box.appendChild(h("div", { class: "d-head", onclick: function () { state.diffOpen[key] = !state.diffOpen[key]; box.classList.toggle("closed"); } },
|
|
415
|
+
h("span", { class: "chev" }, "▾"),
|
|
416
|
+
h("span", { class: "path", title: f.path }, h("span", null, f.from && f.status === "renamed" ? f.from + " → " : f.path.slice(0, i + 1)), f.path.slice(i + 1)),
|
|
417
|
+
f.status ? h("span", { class: "badge" }, f.status) : null,
|
|
418
|
+
h("span", { class: "stats" }, f.add ? h("span", { class: "d-add" }, "+" + f.add) : null, f.del ? h("span", { class: "d-del" }, "−" + f.del) : null)));
|
|
419
|
+
var inner = h("div", { class: "d-body" });
|
|
420
|
+
if (f.binary) inner.appendChild(h("div", { class: "d-note" }, "Binary file not shown."));
|
|
421
|
+
else if (!f.lines.length) inner.appendChild(h("div", { class: "d-note" }, "No content changes."));
|
|
422
|
+
else {
|
|
423
|
+
var table = h("table", { class: "d-table" });
|
|
424
|
+
f.lines.forEach(function (l) {
|
|
425
|
+
if (l.kind === "hunk") return table.appendChild(h("tr", { class: "hunk" }, h("td", { colspan: "4" }, l.text)));
|
|
426
|
+
if (l.kind === "meta") return table.appendChild(h("tr", { class: "meta" }, h("td", { colspan: "4" }, l.text)));
|
|
427
|
+
table.appendChild(h("tr", { class: l.kind },
|
|
428
|
+
h("td", { class: "ln" }, l.oldNo != null ? String(l.oldNo) : ""),
|
|
429
|
+
h("td", { class: "ln" }, l.newNo != null ? String(l.newNo) : ""),
|
|
430
|
+
h("td", { class: "sign" }, l.kind === "add" ? "+" : l.kind === "del" ? "−" : " "),
|
|
431
|
+
h("td", null, l.text)));
|
|
432
|
+
});
|
|
433
|
+
inner.appendChild(table);
|
|
434
|
+
}
|
|
435
|
+
box.appendChild(inner);
|
|
436
|
+
body.appendChild(box);
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function renderView() {
|
|
441
|
+
var view = document.getElementById("view");
|
|
442
|
+
var old = view.querySelector(".body");
|
|
443
|
+
var atBottom = !old || old.scrollHeight - old.scrollTop - old.clientHeight < 40;
|
|
444
|
+
var scroll = old ? old.scrollTop : 0;
|
|
445
|
+
var open = {};
|
|
446
|
+
if (old) old.querySelectorAll(".t-tool.open").forEach(function (el) { open[el.dataset.seq] = 1; });
|
|
447
|
+
view.textContent = "";
|
|
448
|
+
if (!state.detail) {
|
|
449
|
+
view.appendChild(h("div", { class: "empty" }, state.selected ? "Loading…" : "Select a session. Running sessions update live."));
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
renderHead(view);
|
|
453
|
+
var prompt = view.querySelector(".prompt:not(.open) .text");
|
|
454
|
+
if (prompt && prompt.scrollHeight <= prompt.clientHeight + 1) view.querySelector(".prompt .more").remove();
|
|
455
|
+
var body = h("div", { class: "body" });
|
|
456
|
+
view.appendChild(body);
|
|
457
|
+
if (state.tab === "trace") renderTrace(body, open);
|
|
458
|
+
else if (state.tab === "task") renderTask(body);
|
|
459
|
+
else renderDiff(body);
|
|
460
|
+
body.scrollTop = state.tab === "trace" && state.detail.live && atBottom ? body.scrollHeight : scroll;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
async function loadDiff() {
|
|
464
|
+
if (!state.selected) return;
|
|
465
|
+
var id = state.selected;
|
|
466
|
+
try { var d = await get("/api/sessions/" + id + "/diff", "text"); if (id === state.selected) { state.diff = d; renderView(); } }
|
|
467
|
+
catch (e) { if (id === state.selected) { state.diff = ""; renderView(); } }
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
async function pollTrace() {
|
|
471
|
+
var id = state.selected, token = state.traceToken;
|
|
472
|
+
if (!id) return;
|
|
473
|
+
var t = await get("/api/sessions/" + id + "/trace?after=" + state.lastSeq);
|
|
474
|
+
if (id !== state.selected || token !== state.traceToken) return false;
|
|
475
|
+
var fresh = t.events.filter(function (e) { return e.seq > state.lastSeq; });
|
|
476
|
+
if (fresh.length) {
|
|
477
|
+
state.events = state.events.concat(fresh);
|
|
478
|
+
state.lastSeq = fresh[fresh.length - 1].seq;
|
|
479
|
+
}
|
|
480
|
+
var changed = fresh.length > 0 || t.inputs.length !== state.inputs.length;
|
|
481
|
+
state.inputs = t.inputs;
|
|
482
|
+
return changed;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
async function select(id) {
|
|
486
|
+
state.selected = id;
|
|
487
|
+
state.detail = null; state.promptOpen = false; state.events = []; state.inputs = []; state.lastSeq = -1; state.diff = null; state.traceToken++;
|
|
488
|
+
renderList(); renderView();
|
|
489
|
+
if (!id) return;
|
|
490
|
+
try {
|
|
491
|
+
var detail = await get("/api/sessions/" + id);
|
|
492
|
+
if (id !== state.selected) return;
|
|
493
|
+
state.detail = detail;
|
|
494
|
+
await pollTrace();
|
|
495
|
+
if (id !== state.selected) return;
|
|
496
|
+
if (state.tab === "diff") loadDiff();
|
|
497
|
+
} catch (e) {
|
|
498
|
+
if (id !== state.selected) return;
|
|
499
|
+
state.detail = null;
|
|
500
|
+
document.getElementById("view").textContent = "";
|
|
501
|
+
document.getElementById("view").appendChild(h("div", { class: "empty" }, "Session " + id + " was not found."));
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
renderView();
|
|
505
|
+
var body = document.querySelector(".body");
|
|
506
|
+
if (body && state.detail.live) body.scrollTop = body.scrollHeight;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
function route() {
|
|
510
|
+
var parts = location.hash.split("?");
|
|
511
|
+
var p = new URLSearchParams(parts[1] || "");
|
|
512
|
+
var status = p.get("status");
|
|
513
|
+
state.filter = STATUSES.some(function (f) { return f[0] === status; }) ? status : "all";
|
|
514
|
+
state.query = p.get("q") || "";
|
|
515
|
+
renderFilters(); renderList();
|
|
516
|
+
var m = /^#\/session\/([A-Za-z0-9_-]+)(?:\/(trace|task|diff))?$/.exec(parts[0]);
|
|
517
|
+
if (m && m[2]) state.tab = m[2];
|
|
518
|
+
if (m && m[1] === state.selected) { if (state.tab === "diff") loadDiff(); renderView(); return; }
|
|
519
|
+
select(m ? m[1] : null);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
async function tick() {
|
|
523
|
+
var conn = document.getElementById("conn");
|
|
524
|
+
try {
|
|
525
|
+
var raw = await get("/api/sessions", "text");
|
|
526
|
+
if (raw !== state.sessionsJson) {
|
|
527
|
+
state.sessionsJson = raw;
|
|
528
|
+
state.sessions = JSON.parse(raw).sessions;
|
|
529
|
+
var live = state.sessions.filter(function (s) { return s.live; }).length;
|
|
530
|
+
conn.textContent = state.sessions.length + (state.sessions.length === 1 ? " session" : " sessions") + (live ? " · " + live + " live" : "");
|
|
531
|
+
renderFilters();
|
|
532
|
+
listStale = true;
|
|
533
|
+
}
|
|
534
|
+
if (state.detail) {
|
|
535
|
+
var row = state.sessions.find(function (s) { return s.id === state.selected; });
|
|
536
|
+
var wasLive = state.detail.live;
|
|
537
|
+
var id = state.selected;
|
|
538
|
+
if (row && (row.live || wasLive || row.state === "unavailable" || state.detail.state === "unavailable")) {
|
|
539
|
+
var changed = await pollTrace();
|
|
540
|
+
if (id !== state.selected) return;
|
|
541
|
+
if (row.state !== state.detail.state || row.lastKnownState !== state.detail.lastKnownState || row.turns !== state.detail.turns || wasLive !== row.live) {
|
|
542
|
+
var detail = await get("/api/sessions/" + id);
|
|
543
|
+
if (id !== state.selected) return;
|
|
544
|
+
state.detail = detail;
|
|
545
|
+
changed = true;
|
|
546
|
+
}
|
|
547
|
+
if (row.state !== "unavailable" && !row.live && state.tab === "diff") loadDiff();
|
|
548
|
+
if (changed) stale = true;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
flush();
|
|
552
|
+
} catch (e) {
|
|
553
|
+
state.sessionsJson = "";
|
|
554
|
+
conn.textContent = "Disconnected. Run gauge watch again to restart the server.";
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
function flush() {
|
|
559
|
+
if (pressing) return;
|
|
560
|
+
if (listStale) { listStale = false; renderList(); }
|
|
561
|
+
if (stale) { stale = false; renderView(); }
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
async function poll() {
|
|
565
|
+
await tick();
|
|
566
|
+
setTimeout(poll, state.sessions.some(function (s) { return s.live; }) ? 3000 : 10000);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// Rebuilding the list between mousedown and mouseup swallows the click.
|
|
570
|
+
var pressing = false, stale = false, listStale = false;
|
|
571
|
+
document.addEventListener("mousedown", function () { pressing = true; }, true);
|
|
572
|
+
document.addEventListener("mouseup", function () { setTimeout(function () { pressing = false; flush(); }); }, true);
|
|
573
|
+
window.addEventListener("hashchange", route);
|
|
574
|
+
renderFilters();
|
|
575
|
+
route();
|
|
576
|
+
poll();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg width="269" height="269" viewBox="0 0 269 269" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect x="0.000976562" width="268.617" height="268.617" rx="134.309" fill="#BBE6F6"/>
|
|
3
|
+
<mask id="mask0_4873_304" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="269" height="269">
|
|
4
|
+
<rect width="268.617" height="268.617" rx="134.309" fill="#E8FF3F"/>
|
|
5
|
+
</mask>
|
|
6
|
+
<g mask="url(#mask0_4873_304)">
|
|
7
|
+
<path d="M-307.026 174.648L-119.639 223.471L-176.767 224.299L-274.56 370.582H-208.513C-175.605 325.783 -122.945 299.693 -67.3584 300.915C-50.3317 301.295 -31.9112 303.299 -12.0195 307.355L-37.7106 370.574H7.70959L74.8875 243.509L44.69 132.83L48.1356 129.904C14.6008 155.097 -30.9897 174.633 -91.772 174.633C-257.711 174.633 -303.016 174.277 -307.026 174.633V174.648Z" fill="#06222b"/>
|
|
8
|
+
<path d="M245.095 99.3298L199.187 98.997C199.187 98.997 200.565 67.9371 154.324 67.9371C154.324 67.9371 165.366 44.4855 130.166 19.6484C130.166 19.6484 111.978 75.2126 60.6266 119.802L42.9494 91.8222C42.9494 91.8222 32.1093 104.98 37.5294 117.364H25.1406C25.1406 117.364 25.1561 136.729 44.1186 132.851L51.9313 126.675L48.1295 129.91C52.4191 126.682 56.5151 123.37 60.4253 119.987H60.4176L60.6344 119.809C60.5647 119.871 60.495 119.933 60.4253 119.987L116.709 189.027C116.709 189.027 147.077 157.982 189.872 163.508C232.668 169.019 252.002 131.079 245.095 99.3376V99.3298ZM164.522 112.727C157.251 112.727 151.359 106.837 151.359 99.5698C151.359 92.3021 157.251 86.4121 164.522 86.4121C171.792 86.4121 177.685 92.3021 177.685 99.5698C177.685 106.837 171.792 112.727 164.522 112.727Z" fill="#06222b"/>
|
|
9
|
+
<rect x="149.61" y="101.928" width="31.0207" height="14.0332" fill="#06222b"/>
|
|
10
|
+
</g>
|
|
11
|
+
</svg>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>Gauge watch</title>
|
|
7
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
|
8
|
+
<link rel="stylesheet" href="/style.css">
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<header><img class="logo for-light" src="/logo-for-light.png" alt="Gauge"><img class="logo for-dark" src="/logo-for-dark.png" alt="Gauge"><span class="conn" id="conn">connecting…</span></header>
|
|
12
|
+
<main>
|
|
13
|
+
<aside>
|
|
14
|
+
<div class="filters" id="filters"></div>
|
|
15
|
+
<div class="list" id="list"></div>
|
|
16
|
+
</aside>
|
|
17
|
+
<section id="view"><div class="empty">Select a session.<br>Running sessions update live.</div></section>
|
|
18
|
+
</main>
|
|
19
|
+
<script src="/app.js"></script>
|
|
20
|
+
</body>
|
|
21
|
+
</html>
|
|
Binary file
|
|
Binary file
|