ai-engineering-loop 1.9.3 → 1.9.4
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/.agents/workflows/ai-engineering-loop.md +2 -2
- package/.claude/skills/ai-engineering-loop/SKILL.md +3 -1
- package/.gemini/skills/ai-engineering-loop/SKILL.md +3 -1
- package/.grok/skills/ai-engineering-loop/SKILL.md +3 -1
- package/bin/ai-engineering-loop.js +248 -0
- package/lib/goal-runtime.js +149 -15
- package/lib/run-lifecycle.js +164 -0
- package/lib/studio-server.js +90 -4
- package/lib/workflow-runtime.js +5 -4
- package/package.json +1 -1
- package/studio/app.js +213 -18
- package/studio/index.html +1 -0
- package/studio/styles.css +4 -2
package/studio/app.js
CHANGED
|
@@ -29,11 +29,18 @@ let layoutTimer;
|
|
|
29
29
|
let spacePressed = false;
|
|
30
30
|
let pendingConnectionSource;
|
|
31
31
|
let runs = [];
|
|
32
|
-
let goal = { text: '', version: 1, frozen: false };
|
|
32
|
+
let goal = { text: '', version: 1, frozen: false, draftRevision: 0, draftHash: null };
|
|
33
33
|
let activeRunId;
|
|
34
34
|
let pendingImport;
|
|
35
35
|
let hydratedGoalKey;
|
|
36
36
|
let selectedCheckoutRun;
|
|
37
|
+
let lifecycleRunId;
|
|
38
|
+
let lifecycleSequence = 0;
|
|
39
|
+
let lifecycleEvents = [];
|
|
40
|
+
let agentPresence = { status: 'UNKNOWN', lastHeartbeatAt: null };
|
|
41
|
+
let followExecution = true;
|
|
42
|
+
let lastFollowedNode;
|
|
43
|
+
let lifecycleStream;
|
|
37
44
|
|
|
38
45
|
const DISPLAY_NAME_MAX = 80;
|
|
39
46
|
const ROOT_TYPES = new Set(['goal-contract', 'trigger']);
|
|
@@ -295,7 +302,16 @@ function renderEdges() {
|
|
|
295
302
|
if (!from || !to) return;
|
|
296
303
|
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
297
304
|
path.setAttribute('d', edgePath(from, to));
|
|
298
|
-
|
|
305
|
+
const fromState = catalog.live?.nodes?.[edge.from]?.status;
|
|
306
|
+
const toState = catalog.live?.nodes?.[edge.to]?.status;
|
|
307
|
+
const liveNodeId = activeLifecycleNodeId();
|
|
308
|
+
const active = liveNodeId === edge.to && ['PASSED', 'SKIPPED'].includes(fromState);
|
|
309
|
+
const completed = ['PASSED', 'SKIPPED'].includes(fromState) &&
|
|
310
|
+
['PASSED', 'SKIPPED', 'RUNNING'].includes(toState);
|
|
311
|
+
path.setAttribute(
|
|
312
|
+
'class',
|
|
313
|
+
`edge${active ? ' active' : ''}${completed ? ' completed' : ''}${selectedEdgeId === edge.id ? ' selected' : ''}`
|
|
314
|
+
);
|
|
299
315
|
path.setAttribute('marker-end', 'url(#arrow)');
|
|
300
316
|
path.dataset.edgeId = edge.id;
|
|
301
317
|
group.append(path);
|
|
@@ -364,6 +380,9 @@ function renderEdges() {
|
|
|
364
380
|
|
|
365
381
|
function nodeMarkup(node, index) {
|
|
366
382
|
const runtimeNode = catalog.live?.nodes?.[node.id];
|
|
383
|
+
const lifecycleActivity = activeLifecycleNodeId() === node.id
|
|
384
|
+
? activeLifecycleEvent()?.message
|
|
385
|
+
: '';
|
|
367
386
|
const outgoing = draft.edges.some((edge) => edge.from === node.id);
|
|
368
387
|
const root = rootCandidates().length === 1 && rootCandidates()[0].id === node.id;
|
|
369
388
|
return `
|
|
@@ -372,13 +391,34 @@ function nodeMarkup(node, index) {
|
|
|
372
391
|
<button class="node-title" title="Double-click to edit Display Name">${escapeHtml(displayName(node))}</button>
|
|
373
392
|
<span class="technical-id">${escapeHtml(node.id)}</span>
|
|
374
393
|
<span class="status">● ${escapeHtml(runtimeNode?.status || 'DRAFT')}</span>
|
|
375
|
-
${runtimeNode?.activity ? `<p class="node-activity">${escapeHtml(runtimeNode
|
|
394
|
+
${runtimeNode?.activity || lifecycleActivity ? `<p class="node-activity">${escapeHtml(runtimeNode?.activity || lifecycleActivity)}</p>` : ''}
|
|
376
395
|
<button class="port port-out" aria-label="Connect from ${escapeHtml(node.id)}" tabindex="-1"></button>
|
|
377
396
|
${outgoing ? '' : `<button class="output-add" title="Add connected node" aria-label="Add node connected after ${escapeHtml(displayName(node))}">+</button>`}
|
|
378
397
|
${root ? `<div class="execute-pod"><input class="task-input" aria-label="Task for this run" placeholder="Describe this run’s task" value="${escapeHtml(catalog.live?.run?.task || '')}"><button class="execute-trigger">${goal.frozen ? 'Execute' : 'Set Goal'}</button><span class="execute-hint">${goal.frozen ? 'Local runtime only' : 'Freeze Goal first'}</span></div>` : ''}
|
|
379
398
|
`;
|
|
380
399
|
}
|
|
381
400
|
|
|
401
|
+
function activeLifecycleEvent() {
|
|
402
|
+
const latest = lifecycleEvents.at(-1) || null;
|
|
403
|
+
if (!latest || ['NODE_COMPLETED', 'RUN_COMPLETED'].includes(latest.type)) return null;
|
|
404
|
+
return latest;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function activeLifecycleNodeId() {
|
|
408
|
+
const event = activeLifecycleEvent();
|
|
409
|
+
if (event?.nodeId) return event.nodeId;
|
|
410
|
+
if (event?.phase) {
|
|
411
|
+
const scopedNode = draft?.nodes.find((node) =>
|
|
412
|
+
node.id === event.phase || node.type === event.phase || node.legacyGate === event.phase
|
|
413
|
+
);
|
|
414
|
+
if (scopedNode) return scopedNode.id;
|
|
415
|
+
}
|
|
416
|
+
if (event?.phase === 'goal' || event?.type?.startsWith('GOAL_')) {
|
|
417
|
+
return draft?.nodes.find((node) => node.type === 'goal-contract')?.id || null;
|
|
418
|
+
}
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
|
|
382
422
|
function renderGraph() {
|
|
383
423
|
ensurePositions();
|
|
384
424
|
renderLoopGroups();
|
|
@@ -389,7 +429,9 @@ function renderGraph() {
|
|
|
389
429
|
const runtimeNode = catalog.live?.nodes?.[node.id];
|
|
390
430
|
const element = document.createElement('article');
|
|
391
431
|
element.dataset.nodeId = node.id;
|
|
392
|
-
|
|
432
|
+
const lifecycleActive = activeLifecycleNodeId() === node.id &&
|
|
433
|
+
!['DISCONNECTED', 'UNKNOWN'].includes(agentPresence.status);
|
|
434
|
+
element.className = `node ${runtimeNode?.status.toLowerCase() || ''} ${lifecycleActive ? 'agent-active' : ''} ${selectedIds.has(node.id) ? 'selected' : ''}`;
|
|
393
435
|
element.style.left = `${position.x}px`;
|
|
394
436
|
element.style.top = `${position.y}px`;
|
|
395
437
|
element.innerHTML = nodeMarkup(node, index);
|
|
@@ -409,17 +451,27 @@ function updateRuntimePresentation() {
|
|
|
409
451
|
for (const element of document.querySelectorAll('.node')) {
|
|
410
452
|
const nodeId = element.dataset.nodeId;
|
|
411
453
|
const runtimeNode = catalog.live?.nodes?.[nodeId];
|
|
412
|
-
element.classList.remove('running', 'passed', 'failed', 'blocked', 'ready', 'pending', 'skipped');
|
|
454
|
+
element.classList.remove('running', 'passed', 'failed', 'blocked', 'ready', 'pending', 'skipped', 'agent-active', 'agent-idle', 'agent-disconnected');
|
|
413
455
|
if (runtimeNode?.status) element.classList.add(runtimeNode.status.toLowerCase());
|
|
456
|
+
if (activeLifecycleNodeId() === nodeId) {
|
|
457
|
+
if (agentPresence.status === 'WORKING') element.classList.add('agent-active');
|
|
458
|
+
if (agentPresence.status === 'IDLE') element.classList.add('agent-idle');
|
|
459
|
+
if (agentPresence.status === 'DISCONNECTED') element.classList.add('agent-disconnected');
|
|
460
|
+
}
|
|
414
461
|
element.querySelector('.status').textContent = `● ${runtimeNode?.status || 'DRAFT'}`;
|
|
415
462
|
const existingActivity = element.querySelector('.node-activity');
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
463
|
+
const lifecycleActivity = activeLifecycleNodeId() === nodeId
|
|
464
|
+
? activeLifecycleEvent()?.message
|
|
465
|
+
: '';
|
|
466
|
+
const activity = runtimeNode?.activity || lifecycleActivity;
|
|
467
|
+
if (activity) {
|
|
468
|
+
if (existingActivity) existingActivity.textContent = activity;
|
|
469
|
+
else element.querySelector('.status').insertAdjacentHTML('afterend', `<p class="node-activity">${escapeHtml(activity)}</p>`);
|
|
419
470
|
} else {
|
|
420
471
|
existingActivity?.remove();
|
|
421
472
|
}
|
|
422
473
|
}
|
|
474
|
+
renderLoopGroups();
|
|
423
475
|
renderEdges();
|
|
424
476
|
}
|
|
425
477
|
|
|
@@ -882,6 +934,7 @@ function renderPalette() {
|
|
|
882
934
|
function beginNodeInteraction(event) {
|
|
883
935
|
if (event.button !== 0 || event.target.closest('.port,.output-add,.execute-pod,.node-title,.inline-rename')) return;
|
|
884
936
|
event.stopPropagation();
|
|
937
|
+
setFollowExecution(false);
|
|
885
938
|
const element = event.currentTarget;
|
|
886
939
|
const nodeId = element.dataset.nodeId;
|
|
887
940
|
if (event.shiftKey) {
|
|
@@ -908,6 +961,7 @@ function beginNodeInteraction(event) {
|
|
|
908
961
|
function beginPan(event) {
|
|
909
962
|
if (event.button !== 0 && event.button !== 1) return;
|
|
910
963
|
event.preventDefault();
|
|
964
|
+
setFollowExecution(false);
|
|
911
965
|
interaction = {
|
|
912
966
|
type: 'pan',
|
|
913
967
|
pointerId: event.pointerId,
|
|
@@ -1007,6 +1061,7 @@ function finishConnection(event) {
|
|
|
1007
1061
|
}
|
|
1008
1062
|
|
|
1009
1063
|
function beginLasso(event) {
|
|
1064
|
+
setFollowExecution(false);
|
|
1010
1065
|
const start = screenToWorld(event.clientX, event.clientY);
|
|
1011
1066
|
interaction = { type: 'lasso', pointerId: event.pointerId, start, current: start, additive: event.shiftKey };
|
|
1012
1067
|
const marquee = byId('selection-marquee');
|
|
@@ -1185,11 +1240,22 @@ async function saveGoalFromForm() {
|
|
|
1185
1240
|
const runId = await ensureStudioRun();
|
|
1186
1241
|
if (!runId) return null;
|
|
1187
1242
|
const contract = goalContractFromForm(runId);
|
|
1188
|
-
await api(`/api/runs/${encodeURIComponent(runId)}/goal`, {
|
|
1243
|
+
const saved = await api(`/api/runs/${encodeURIComponent(runId)}/goal`, {
|
|
1189
1244
|
method: 'PUT',
|
|
1190
|
-
body: JSON.stringify({
|
|
1245
|
+
body: JSON.stringify({
|
|
1246
|
+
goal: contract,
|
|
1247
|
+
actor: 'studio-user',
|
|
1248
|
+
expectedRevision: goal.draftRevision
|
|
1249
|
+
})
|
|
1191
1250
|
});
|
|
1192
|
-
goal = {
|
|
1251
|
+
goal = {
|
|
1252
|
+
text: contract.objective,
|
|
1253
|
+
criteria: contract.acceptanceCriteria,
|
|
1254
|
+
version: goal.version,
|
|
1255
|
+
frozen: false,
|
|
1256
|
+
draftRevision: saved.draft.metadata.revision,
|
|
1257
|
+
draftHash: saved.draft.metadata.contentHash
|
|
1258
|
+
};
|
|
1193
1259
|
byId('goal-validation').textContent = '';
|
|
1194
1260
|
notify('Goal draft saved. It is not frozen yet.');
|
|
1195
1261
|
byId('goal-dialog').close();
|
|
@@ -1235,7 +1301,11 @@ async function freezeGoalFromForm() {
|
|
|
1235
1301
|
try {
|
|
1236
1302
|
const result = await api(`/api/runs/${encodeURIComponent(activeRunId)}/goal/freeze`, {
|
|
1237
1303
|
method: 'POST',
|
|
1238
|
-
body: JSON.stringify({
|
|
1304
|
+
body: JSON.stringify({
|
|
1305
|
+
actor: 'studio-user',
|
|
1306
|
+
expectedRevision: goal.draftRevision,
|
|
1307
|
+
expectedHash: goal.draftHash
|
|
1308
|
+
})
|
|
1239
1309
|
});
|
|
1240
1310
|
catalog.live = catalog.live || {};
|
|
1241
1311
|
catalog.live.run = result.run;
|
|
@@ -1280,8 +1350,16 @@ async function unfreezeGoalFromForm() {
|
|
|
1280
1350
|
|
|
1281
1351
|
function syncGoalFromLive() {
|
|
1282
1352
|
const liveGoal = catalog.live?.run?.goal;
|
|
1283
|
-
|
|
1284
|
-
if (
|
|
1353
|
+
const nextRunId = catalog.live?.run?.runId || null;
|
|
1354
|
+
if (activeRunId !== nextRunId) {
|
|
1355
|
+
goal = { text: '', version: 1, frozen: false, draftRevision: 0, draftHash: null };
|
|
1356
|
+
hydratedGoalKey = null;
|
|
1357
|
+
}
|
|
1358
|
+
activeRunId = nextRunId;
|
|
1359
|
+
if (!liveGoal) {
|
|
1360
|
+
renderGoalState();
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1285
1363
|
goal.version = liveGoal.version || 1;
|
|
1286
1364
|
goal.frozen = liveGoal.frozen === true;
|
|
1287
1365
|
if (catalog.live.run.task) byId('goal-task').value = catalog.live.run.task;
|
|
@@ -1290,6 +1368,100 @@ function syncGoalFromLive() {
|
|
|
1290
1368
|
renderGoalState();
|
|
1291
1369
|
}
|
|
1292
1370
|
|
|
1371
|
+
async function refreshGoalDraft(runId) {
|
|
1372
|
+
if (!runId || goal.frozen) return;
|
|
1373
|
+
const result = await api(`/api/runs/${encodeURIComponent(runId)}/goal`);
|
|
1374
|
+
const draftEnvelope = result.draft;
|
|
1375
|
+
if (!draftEnvelope || draftEnvelope.metadata.revision === goal.draftRevision) return;
|
|
1376
|
+
goal.draftRevision = draftEnvelope.metadata.revision;
|
|
1377
|
+
goal.draftHash = draftEnvelope.metadata.contentHash;
|
|
1378
|
+
goal.text = draftEnvelope.contract.objective || '';
|
|
1379
|
+
goal.criteria = draftEnvelope.contract.acceptanceCriteria || [];
|
|
1380
|
+
if (!byId('goal-form').contains(document.activeElement)) {
|
|
1381
|
+
byId('goal-text').value = goal.text;
|
|
1382
|
+
byId('goal-criteria').value = goal.criteria.map((criterion) => (
|
|
1383
|
+
`${criterion.statement} | ${criterion.evidenceRequired} | ${(criterion.failureCases || []).join(' | ')}`
|
|
1384
|
+
)).join('\n');
|
|
1385
|
+
}
|
|
1386
|
+
renderGoalState();
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
async function refreshLifecycle(runId) {
|
|
1390
|
+
if (!runId) {
|
|
1391
|
+
lifecycleStream?.close();
|
|
1392
|
+
lifecycleStream = null;
|
|
1393
|
+
lifecycleRunId = null;
|
|
1394
|
+
lifecycleSequence = 0;
|
|
1395
|
+
lifecycleEvents = [];
|
|
1396
|
+
agentPresence = { status: 'UNKNOWN', lastHeartbeatAt: null };
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1399
|
+
if (lifecycleRunId !== runId) {
|
|
1400
|
+
lifecycleStream?.close();
|
|
1401
|
+
lifecycleStream = null;
|
|
1402
|
+
lifecycleRunId = runId;
|
|
1403
|
+
lifecycleSequence = 0;
|
|
1404
|
+
lifecycleEvents = [];
|
|
1405
|
+
startLifecycleStream(runId);
|
|
1406
|
+
}
|
|
1407
|
+
try {
|
|
1408
|
+
const result = await api(
|
|
1409
|
+
`/api/runs/${encodeURIComponent(runId)}/lifecycle?after=${lifecycleSequence}&limit=100`
|
|
1410
|
+
);
|
|
1411
|
+
lifecycleEvents = lifecycleEvents.concat(
|
|
1412
|
+
result.lifecycle.events.filter((event) => event.sequence > lifecycleSequence)
|
|
1413
|
+
).slice(-100);
|
|
1414
|
+
lifecycleSequence = result.lifecycle.nextSequence;
|
|
1415
|
+
agentPresence = result.presence;
|
|
1416
|
+
} catch {
|
|
1417
|
+
agentPresence = { status: 'UNKNOWN', lastHeartbeatAt: null };
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
function startLifecycleStream(runId) {
|
|
1422
|
+
if (!window.EventSource || !runId) return;
|
|
1423
|
+
lifecycleStream = new window.EventSource(
|
|
1424
|
+
`/api/runs/${encodeURIComponent(runId)}/lifecycle/stream?after=${lifecycleSequence}`
|
|
1425
|
+
);
|
|
1426
|
+
lifecycleStream.onmessage = (message) => {
|
|
1427
|
+
try {
|
|
1428
|
+
const result = JSON.parse(message.data);
|
|
1429
|
+
lifecycleEvents = lifecycleEvents.concat(
|
|
1430
|
+
result.lifecycle.events.filter((event) => event.sequence > lifecycleSequence)
|
|
1431
|
+
).slice(-100);
|
|
1432
|
+
lifecycleSequence = Math.max(lifecycleSequence, result.lifecycle.nextSequence);
|
|
1433
|
+
agentPresence = result.presence;
|
|
1434
|
+
renderLive();
|
|
1435
|
+
} catch {
|
|
1436
|
+
// The regular cursor poll remains the recovery path.
|
|
1437
|
+
}
|
|
1438
|
+
};
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
function setFollowExecution(enabled) {
|
|
1442
|
+
followExecution = enabled;
|
|
1443
|
+
const button = byId('follow-execution');
|
|
1444
|
+
button.classList.toggle('active', enabled);
|
|
1445
|
+
button.setAttribute('aria-pressed', String(enabled));
|
|
1446
|
+
button.textContent = enabled ? 'Following' : 'Follow execution';
|
|
1447
|
+
if (enabled) {
|
|
1448
|
+
lastFollowedNode = null;
|
|
1449
|
+
followActiveNode();
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
function followActiveNode() {
|
|
1454
|
+
const nodeId = activeLifecycleNodeId();
|
|
1455
|
+
if (!followExecution || !nodeId || nodeId === lastFollowedNode || interaction) return;
|
|
1456
|
+
const position = positions.get(nodeId);
|
|
1457
|
+
if (!position) return;
|
|
1458
|
+
const canvas = byId('canvas').getBoundingClientRect();
|
|
1459
|
+
viewport.x = canvas.width / 2 - (position.x + NODE_WIDTH / 2) * viewport.scale;
|
|
1460
|
+
viewport.y = canvas.height / 2 - (position.y + 54) * viewport.scale;
|
|
1461
|
+
lastFollowedNode = nodeId;
|
|
1462
|
+
applyViewport();
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1293
1465
|
async function hydrateGoalFromLive() {
|
|
1294
1466
|
const run = catalog.live?.run;
|
|
1295
1467
|
const artifactPath = run?.artifacts?.goalContract?.path;
|
|
@@ -1706,6 +1878,7 @@ function zoomAt(nextScale, clientX, clientY) {
|
|
|
1706
1878
|
|
|
1707
1879
|
function handleWheel(event) {
|
|
1708
1880
|
event.preventDefault();
|
|
1881
|
+
setFollowExecution(false);
|
|
1709
1882
|
if (event.ctrlKey || event.metaKey) {
|
|
1710
1883
|
zoomAt(viewport.scale * Math.exp(-event.deltaY * 0.002), event.clientX, event.clientY);
|
|
1711
1884
|
} else {
|
|
@@ -1822,25 +1995,42 @@ function renderLive() {
|
|
|
1822
1995
|
byId('events').innerHTML = '';
|
|
1823
1996
|
byId('budget').textContent = '—';
|
|
1824
1997
|
byId('meter').style.width = '0';
|
|
1998
|
+
byId('agent-presence').textContent = 'Agent unavailable';
|
|
1999
|
+
byId('agent-presence').className = 'agent-presence unknown';
|
|
1825
2000
|
updateRuntimePresentation();
|
|
1826
2001
|
return;
|
|
1827
2002
|
}
|
|
1828
|
-
const
|
|
2003
|
+
const lifecycleNodeId = activeLifecycleNodeId();
|
|
2004
|
+
const active = live.plan.nodes.find((node) => node.id === lifecycleNodeId)
|
|
2005
|
+
|| live.plan.nodes.find((node) => live.nodes[node.id].status === 'RUNNING')
|
|
1829
2006
|
|| live.plan.nodes.find((node) => live.nodes[node.id].status === 'READY');
|
|
1830
2007
|
const runtimeNode = active ? live.nodes[active.id] : null;
|
|
2008
|
+
const lifecycle = activeLifecycleEvent();
|
|
1831
2009
|
byId('run-summary').textContent = active ? `${active.id} · ${runtimeNode.status}` : `Run ${live.run.state}`;
|
|
1832
2010
|
byId('active-stage').textContent = active?.id || 'Run complete';
|
|
1833
|
-
byId('activity').textContent =
|
|
2011
|
+
byId('activity').textContent = lifecycle?.message ||
|
|
2012
|
+
(active ? runtimeNode.activity || `${runtimeNode.status} · attempt ${runtimeNode.attempts}` : `Final state: ${live.run.state}`);
|
|
2013
|
+
const presenceLabel = {
|
|
2014
|
+
WORKING: 'Agent working',
|
|
2015
|
+
IDLE: 'Agent appears idle',
|
|
2016
|
+
DISCONNECTED: 'Agent disconnected',
|
|
2017
|
+
UNKNOWN: 'Waiting for Agent'
|
|
2018
|
+
}[agentPresence.status] || 'Waiting for Agent';
|
|
2019
|
+
byId('agent-presence').textContent = presenceLabel;
|
|
2020
|
+
byId('agent-presence').className = `agent-presence ${agentPresence.status.toLowerCase()}`;
|
|
1834
2021
|
const spent = live.budget.spentThisRun;
|
|
1835
2022
|
const limit = live.budget.perRunTokenLimit;
|
|
1836
2023
|
byId('meter').style.width = `${Math.min(100, limit ? (spent / limit) * 100 : 0)}%`;
|
|
1837
2024
|
byId('budget').textContent = `${spent.toLocaleString()} / ${limit.toLocaleString()} TOKENS`;
|
|
1838
|
-
byId('events').innerHTML =
|
|
2025
|
+
byId('events').innerHTML = lifecycleEvents.slice(-7).reverse().map((event) => `
|
|
1839
2026
|
<p class="${event.type === 'NODE_ACTIVITY' || event.type.includes('START') ? 'event-active' : ''}">
|
|
1840
|
-
${escapeHtml(event.at.slice(11, 19))} · ${escapeHtml(event.type)} · ${escapeHtml(event.
|
|
2027
|
+
${escapeHtml(event.at.slice(11, 19))} · ${escapeHtml(event.type)} · ${escapeHtml(event.message)}
|
|
1841
2028
|
</p>
|
|
2029
|
+
`).join('') || live.events.slice(-7).reverse().map((event) => `
|
|
2030
|
+
<p>${escapeHtml(event.at.slice(11, 19))} · ${escapeHtml(event.type)}</p>
|
|
1842
2031
|
`).join('');
|
|
1843
2032
|
updateRuntimePresentation();
|
|
2033
|
+
followActiveNode();
|
|
1844
2034
|
}
|
|
1845
2035
|
|
|
1846
2036
|
async function refreshLive() {
|
|
@@ -1848,6 +2038,8 @@ async function refreshLive() {
|
|
|
1848
2038
|
const result = await api('/api/live');
|
|
1849
2039
|
catalog.live = result.live;
|
|
1850
2040
|
syncGoalFromLive();
|
|
2041
|
+
await refreshLifecycle(catalog.live?.run?.runId);
|
|
2042
|
+
await refreshGoalDraft(catalog.live?.run?.runId);
|
|
1851
2043
|
await hydrateGoalFromLive();
|
|
1852
2044
|
renderLive();
|
|
1853
2045
|
await refreshSelectedCheckout();
|
|
@@ -1929,6 +2121,8 @@ function bindCanvas() {
|
|
|
1929
2121
|
byId('zoom-out').onclick = () => zoomAt(viewport.scale / 1.2);
|
|
1930
2122
|
byId('undo').onclick = () => restoreHistory(historyIndex - 1);
|
|
1931
2123
|
byId('redo').onclick = () => restoreHistory(historyIndex + 1);
|
|
2124
|
+
byId('follow-execution').onclick = () => setFollowExecution(!followExecution);
|
|
2125
|
+
setFollowExecution(followExecution);
|
|
1932
2126
|
}
|
|
1933
2127
|
|
|
1934
2128
|
function editableTarget(target) {
|
|
@@ -2155,6 +2349,7 @@ async function initialize() {
|
|
|
2155
2349
|
byId('toggle-execution').onclick = () => byId('execution-panel').classList.toggle('open');
|
|
2156
2350
|
byId('close-execution').onclick = () => byId('execution-panel').classList.remove('open');
|
|
2157
2351
|
await loadRecipe();
|
|
2352
|
+
await refreshLive();
|
|
2158
2353
|
clearInterval(liveTimer);
|
|
2159
2354
|
liveTimer = setInterval(refreshLive, 1800);
|
|
2160
2355
|
}
|
package/studio/index.html
CHANGED
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
|
|
106
106
|
<aside class="execution-panel" id="execution-panel">
|
|
107
107
|
<div class="panel-head"><div><small>LIVE EXECUTION</small><h2 id="active-stage">No active run</h2></div><button id="close-execution" aria-label="Close">×</button></div>
|
|
108
|
+
<div class="live-controls"><span id="agent-presence" class="agent-presence unknown">Agent unavailable</span><button id="follow-execution" type="button" aria-pressed="true">Follow execution</button></div>
|
|
108
109
|
<p id="activity">Waiting for a recipe-bound workflow.</p>
|
|
109
110
|
<div class="budget-line"><span>Context budget</span><span class="mono" id="budget">—</span></div>
|
|
110
111
|
<div class="meter"><i id="meter"></i></div>
|
package/studio/styles.css
CHANGED
|
@@ -23,14 +23,15 @@ small,label{display:block;color:var(--muted);font-size:11px;margin:4px 0 6px}
|
|
|
23
23
|
#palette{padding:10px}.palette-item{display:flex;align-items:center;justify-content:space-between;width:100%;padding:13px;margin:0 0 6px;background:transparent;border-color:transparent;text-align:left}.palette-item:hover{background:var(--raised)}.palette-item b{font-weight:550}.palette-item small{margin:0;font-size:10px}
|
|
24
24
|
.canvas-toolbar{position:absolute;z-index:10;left:14px;bottom:14px;display:flex;align-items:center;gap:3px;padding:5px;background:#29292edb;border:1px solid var(--line);border-radius:8px;box-shadow:0 8px 24px #0006}.canvas-toolbar button{border:0;background:transparent;padding:7px 9px}.canvas-toolbar button:hover{background:#3a3a40}.canvas-toolbar span{height:20px;width:1px;background:var(--line);margin:0 4px}.canvas-toolbar output{width:44px;text-align:center;color:var(--muted);font-size:11px}
|
|
25
25
|
#scene{position:absolute;inset:0;transform-origin:0 0;will-change:transform}#nodes,#edges,#loop-groups{position:absolute;inset:0;width:1px;height:1px;overflow:visible}
|
|
26
|
-
.node{position:absolute;width:224px;min-height:104px;padding:16px 18px;background:#303036f5;border:1px solid #4a4a52;border-radius:9px;cursor:grab;z-index:2;user-select:none;box-shadow:0 7px 18px #0005;transition:border-color .12s,box-shadow .12s}.node:hover{border-color:#777781}.node.selected{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent),0 12px 28px #0008}.node.dragging{cursor:grabbing;transition:none}.node.running{border:2px solid var(--accent);box-shadow:0 0
|
|
26
|
+
.node{position:absolute;width:224px;min-height:104px;padding:16px 18px;background:#303036f5;border:1px solid #4a4a52;border-radius:9px;cursor:grab;z-index:2;user-select:none;box-shadow:0 7px 18px #0005;transition:border-color .12s,box-shadow .12s}.node:hover{border-color:#777781}.node.selected{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent),0 12px 28px #0008}.node.dragging{cursor:grabbing;transition:none}.node.running,.node.agent-active{border:2px solid var(--accent);box-shadow:0 0 0 4px #28ad0018,0 0 28px #28ad0055;animation:agent-pulse 1.8s ease-in-out infinite}.node.agent-idle{border-color:var(--warning);box-shadow:0 0 0 2px #e4a85322}.node.agent-disconnected{border-color:var(--danger);border-style:dashed}.node.passed{border-left:4px solid var(--ok)}.node.failed{border-color:var(--danger)}.node.blocked{opacity:.58}
|
|
27
27
|
.node h3{margin:11px 0 9px;font-size:14px}.node small{font-size:9px;margin:0;color:#aaaab3}.status{font:10px ui-monospace,monospace;color:var(--muted)}.running .status{color:var(--accent)}.passed .status{color:var(--ok)}.failed .status{color:var(--danger)}.node-activity{margin:9px 0 0;color:#91dc7c;font:10px/1.4 ui-monospace,monospace}
|
|
28
28
|
.port{position:absolute;top:31px;width:44px;height:44px;padding:0;border:0;border-radius:50%;background:transparent;z-index:8}.port::before{content:"";position:absolute;inset:15px;border:2px solid #8a8a95;border-radius:50%;background:#303036}.port:hover::before,.port:focus-visible::before{border-color:var(--accent);background:var(--accent)}.port-in{left:-23px}.port-out{right:-23px;cursor:crosshair;touch-action:none}.port-out::after{content:"•••";position:absolute;left:13px;top:11px;color:#fff;font-size:6px;letter-spacing:-1px;pointer-events:none}
|
|
29
|
-
#edges{pointer-events:none}#arrow path{fill:#777780}.edge{fill:none;stroke:#777780;stroke-width:2;vector-effect:non-scaling-stroke;pointer-events:stroke;cursor:pointer}.edge.active{stroke:var(--accent);stroke-width:3;stroke-dasharray:9 11;animation:flow .8s linear infinite;filter:drop-shadow(0 0 4px var(--accent))}#preview-edge{display:none;fill:none;stroke:var(--accent);stroke-width:2;stroke-dasharray:6 5;vector-effect:non-scaling-stroke}@keyframes flow{to{stroke-dashoffset:-20}}
|
|
29
|
+
#edges{pointer-events:none}#arrow path{fill:#777780}.edge{fill:none;stroke:#777780;stroke-width:2;vector-effect:non-scaling-stroke;pointer-events:stroke;cursor:pointer}.edge.completed{stroke:var(--ok)}.edge.active{stroke:var(--accent);stroke-width:3;stroke-dasharray:9 11;animation:flow .8s linear infinite;filter:drop-shadow(0 0 4px var(--accent))}#preview-edge{display:none;fill:none;stroke:var(--accent);stroke-width:2;stroke-dasharray:6 5;vector-effect:non-scaling-stroke}@keyframes flow{to{stroke-dashoffset:-20}}@keyframes agent-pulse{50%{box-shadow:0 0 0 8px #28ad0008,0 0 38px #28ad0070}}
|
|
30
30
|
.canvas-help{position:absolute;bottom:20px;left:50%;transform:translateX(-50%);color:#8a8a94;font-size:10px;pointer-events:none}.canvas-help kbd{border:1px solid #505058;border-radius:3px;padding:2px 4px;font:inherit}
|
|
31
31
|
#details{padding:18px}#details input,#details textarea,#details select,.execution-panel input,.execution-panel textarea{width:100%;padding:10px 11px;margin:0 0 14px;border:1px solid var(--line);border-radius:6px;background:#1d1d21}#details textarea,.execution-panel textarea{min-height:72px;resize:vertical}#details select[multiple]{height:76px}
|
|
32
32
|
#details details,.execution-panel details{border-top:1px solid var(--line);margin:15px 0;padding-top:14px}summary{cursor:pointer;color:#d5d5da}.settings-body{padding-top:14px}.source-line{display:flex;justify-content:space-between;color:var(--muted);font-size:11px;margin-bottom:16px}.hint{border-left:2px solid var(--accent);padding:8px 10px;color:#b5b5bd;line-height:1.45}.button-row{display:flex;gap:7px}.button-row button{flex:1}.danger{color:#ff9999}
|
|
33
33
|
.adapter-controls{margin:12px 0}.budget-line{display:flex;justify-content:space-between;margin-top:20px;color:var(--muted)}.meter{height:6px;background:#38383e;border-radius:5px;margin:9px 0 15px}.meter i{display:block;height:100%;width:0;background:var(--accent);border-radius:5px}.mono,#events{font:10px/1.8 ui-monospace,monospace;color:var(--muted)}#events p{margin:2px 0}.event-active{color:var(--accent)}
|
|
34
|
+
.agent-presence{display:inline-flex;align-items:center;gap:7px;margin:8px 0;color:var(--muted);font-size:11px}.agent-presence::before{content:"";width:7px;height:7px;border-radius:50%;background:#777}.agent-presence.working::before{background:var(--accent);box-shadow:0 0 12px var(--accent);animation:presence-pulse 1.2s ease-in-out infinite}.agent-presence.idle::before{background:var(--warning)}.agent-presence.disconnected::before{background:var(--danger)}#follow-execution.active{border-color:var(--accent);background:var(--accent-soft);color:#a7ee93}@keyframes presence-pulse{50%{opacity:.35}}
|
|
34
35
|
#message{position:absolute;z-index:40;right:20px;bottom:20px;max-width:380px;background:#333339;border:1px solid var(--line);border-left:3px solid var(--accent);border-radius:6px;padding:12px 15px;box-shadow:0 12px 36px #0008;display:none}
|
|
35
36
|
dialog{border:1px solid #505057;border-radius:4px;background:var(--panel);color:var(--text);width:560px;padding:28px;box-shadow:14px 14px 0 #0d0d0f;line-height:1.55}dialog::backdrop{background:#000b}dialog pre{max-height:320px;overflow:auto;background:#161619;padding:16px;border:1px solid var(--line);border-radius:3px;color:#d2d2d7;font-size:12px;line-height:1.65}dialog button{float:right;margin-left:8px}.resizable-dialog{resize:both;overflow:auto;min-width:min(520px,calc(100vw - 24px));min-height:420px;max-width:calc(100vw - 24px);max-height:calc(100vh - 24px)}dialog.maximized{width:calc(100vw - 32px)!important;height:calc(100vh - 32px)!important;max-width:none;max-height:none}.dialog-actions{display:flex;gap:4px}.dialog-actions button{float:none;margin:0}.dialog-maximize{font-size:16px!important}
|
|
36
37
|
.workspace-tabs{display:flex;gap:2px;margin-left:4px}.workspace-tab{border:0;background:transparent;color:var(--muted)}.workspace-tab.active{background:var(--raised);color:var(--text)}.workflow-context{display:flex;align-items:center;gap:6px}
|
|
@@ -38,6 +39,7 @@ dialog{border:1px solid #505057;border-radius:4px;background:var(--panel);color:
|
|
|
38
39
|
.output-add{position:absolute;right:-62px;top:39px;width:30px;height:30px;padding:0;border-radius:50%;border-color:var(--accent);background:var(--accent);color:#fff;font-size:20px;opacity:0;z-index:5;transform:scale(.8);transition:.12s}.node:hover .output-add,.output-add:focus{opacity:1;transform:scale(1)}
|
|
39
40
|
#edge-controls{position:absolute;inset:0;width:1px;height:1px;z-index:5}.edge-delete{position:absolute;width:24px;height:24px;padding:0;transform:translate(-50%,-50%) scale(.75);border-radius:50%;border-color:#696972;background:#29292e;color:#fff;opacity:0;transition:.12s}.edge-delete:hover,.edge-delete.selected,.edge-delete.visible{opacity:1;transform:translate(-50%,-50%) scale(1);border-color:var(--danger);background:var(--danger)}.edge.selected{stroke:var(--accent);stroke-width:3}
|
|
40
41
|
.execute-pod{position:absolute;left:0;top:calc(100% + 12px);width:224px;padding:8px;background:#25252a;border:1px solid var(--line);border-radius:8px;display:grid;grid-template-columns:1fr auto;gap:6px}.execute-pod input{min-width:0;padding:7px;border:1px solid var(--line);background:#19191c;border-radius:5px}.execute-pod button{background:var(--accent);border-color:var(--accent);color:#fff}.execute-hint{grid-column:1/-1;color:var(--muted);font-size:9px}
|
|
42
|
+
@media (prefers-reduced-motion:reduce){*,*::before,*::after{scroll-behavior:auto!important;animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important}.edge.active{stroke-dasharray:none}.node.running,.node.agent-active{box-shadow:0 0 0 2px var(--accent)}}
|
|
41
43
|
.selection-actions{position:absolute;z-index:12;left:50%;top:14px;transform:translateX(-50%);padding:6px;background:#29292e;border:1px solid var(--line);border-radius:8px}.selection-actions span{margin:0 8px;color:var(--muted)}#selection-marquee{position:absolute;display:none;border:1px solid var(--accent);background:#28ad0018;pointer-events:none}
|
|
42
44
|
.loop-group{position:absolute;z-index:1;border:1px dashed #28ad0099;border-radius:12px;background:#28ad000a;pointer-events:none}.loop-group>header{position:absolute;left:14px;top:-16px;height:31px;display:flex;align-items:center;gap:10px;padding:4px 5px 4px 10px;border:1px solid #28ad006e;border-radius:5px;background:#1b2818;pointer-events:auto}.loop-group header span{display:flex;align-items:center;gap:8px;white-space:nowrap}.loop-group header b{font-size:10px;text-transform:uppercase;letter-spacing:.08em}.loop-group header small{margin:0;color:#91dc7c;font:9px ui-monospace,monospace}.loop-group header button{padding:3px 7px;border:0;background:transparent;color:var(--muted);font-size:9px}.loop-group.blocked{border-color:var(--warning);background:#e4a8530a}.loop-group.exited{opacity:.72}.loop-return{stroke:#28ad00;stroke-dasharray:7 6}.edge-label{position:absolute;z-index:6;transform:translate(-50%,-50%);padding:3px 6px;border:1px solid #4d4d54;border-radius:4px;background:#202024;color:#d6d6da;font:9px ui-monospace,monospace;white-space:nowrap;pointer-events:none}.loop-label{border-color:#28ad007a;color:#91dc7c}
|
|
43
45
|
.custom-node-action{width:calc(100% - 20px);margin:4px 10px 14px;border-color:var(--accent);color:#91dc7c}
|