@lloyal-labs/dev-tools 0.1.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 +107 -0
- package/README.md +19 -0
- package/dist/index.d.ts +313 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +534 -0
- package/dist/index.js.map +1 -0
- package/dist/ink.d.ts +14 -0
- package/dist/ink.d.ts.map +1 -0
- package/dist/ink.js +35 -0
- package/dist/ink.js.map +1 -0
- package/dist/node.d.ts +6 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +78 -0
- package/dist/node.js.map +1 -0
- package/dist/react.d.ts +14 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +899 -0
- package/dist/react.js.map +1 -0
- package/dist/store.d.ts +29 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +96 -0
- package/dist/store.js.map +1 -0
- package/package.json +67 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
/** Model perplexity over the lane's produced tokens — exp(mean surprisal),
|
|
2
|
+
* the same accumulator the pool's branch tracker harvests. The one number
|
|
3
|
+
* comparable ACROSS agents; null before any sample. */
|
|
4
|
+
export function lanePpl(lane) {
|
|
5
|
+
return lane.nllCount === 0 ? null : Math.exp(lane.nllSum / lane.nllCount);
|
|
6
|
+
}
|
|
7
|
+
export function createPaneModel() {
|
|
8
|
+
return {
|
|
9
|
+
runPhase: null,
|
|
10
|
+
runStartAt: null,
|
|
11
|
+
runEndedAt: null,
|
|
12
|
+
runContinuedAt: null,
|
|
13
|
+
dev: false,
|
|
14
|
+
facts: null,
|
|
15
|
+
config: null,
|
|
16
|
+
origin: null,
|
|
17
|
+
lastSavedTo: undefined,
|
|
18
|
+
lanes: new Map(),
|
|
19
|
+
retrievals: [],
|
|
20
|
+
pressure: [],
|
|
21
|
+
host: [],
|
|
22
|
+
interventions: [],
|
|
23
|
+
abilities: null,
|
|
24
|
+
plan: null,
|
|
25
|
+
clarifying: false,
|
|
26
|
+
t0: null,
|
|
27
|
+
eventCount: 0,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Cap kept generous: a full research run ticks a few thousand times; the
|
|
31
|
+
* strip renders a downsample anyway, and the pane must never grow without
|
|
32
|
+
* bound on a long-lived host. */
|
|
33
|
+
const MAX_PRESSURE_POINTS = 20_000;
|
|
34
|
+
const MAX_RETRIEVALS = 500;
|
|
35
|
+
const MAX_INTERVENTIONS = 200;
|
|
36
|
+
const MAX_EPISTEMICS = 4096;
|
|
37
|
+
const MAX_HOST = 600;
|
|
38
|
+
/**
|
|
39
|
+
* Fold one bus event into the model — MUTATING (the pane owns its model and
|
|
40
|
+
* re-renders on a version counter; an immutable fold would copy a Map per
|
|
41
|
+
* token). `now` is injected so the fold stays clock-free and testable.
|
|
42
|
+
*/
|
|
43
|
+
/** A new run begins: the timeline shows THE RUN, not wall-clock since page
|
|
44
|
+
* load — clear the run-scoped collections and anchor the axis. Idempotent
|
|
45
|
+
* (research emits `plan:start` then `query` back-to-back). */
|
|
46
|
+
function resetRun(m, now) {
|
|
47
|
+
// A clarify answer re-enters planning WITHIN the same run: the planner
|
|
48
|
+
// asked, the user answered, the cycle continues — mark the exchange
|
|
49
|
+
// answered and keep everything.
|
|
50
|
+
if (m.clarifying) {
|
|
51
|
+
m.clarifying = false;
|
|
52
|
+
m.runContinuedAt = now;
|
|
53
|
+
for (const lane of m.lanes.values()) {
|
|
54
|
+
if (lane.clarify && lane.clarify.answeredAt === null)
|
|
55
|
+
lane.clarify.answeredAt = now;
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// Idempotent across the back-to-back run-start pair (research emits
|
|
60
|
+
// `plan:start` then `query` within milliseconds) — one reset per run.
|
|
61
|
+
if (m.runStartAt !== null && (now - m.runStartAt < 1500 ||
|
|
62
|
+
(m.runContinuedAt !== null && now - m.runContinuedAt < 1500)))
|
|
63
|
+
return;
|
|
64
|
+
m.lanes = new Map();
|
|
65
|
+
m.retrievals = [];
|
|
66
|
+
m.pressure = [];
|
|
67
|
+
m.host = [];
|
|
68
|
+
m.interventions = [];
|
|
69
|
+
m.plan = null;
|
|
70
|
+
m.runStartAt = now;
|
|
71
|
+
m.runEndedAt = null;
|
|
72
|
+
}
|
|
73
|
+
/** The retrieval a mirrored trace event belongs to: by callId WITHIN the
|
|
74
|
+
* agent (callIds are per-agent counters — call_0 exists in every agent, so
|
|
75
|
+
* a global match attaches one agent's funnel to another's call), else the
|
|
76
|
+
* newest unsettled call of the agent. */
|
|
77
|
+
function findRetrieval(m, callId, agentId) {
|
|
78
|
+
if (callId)
|
|
79
|
+
return m.retrievals.find((x) => x.callId === callId && x.agentId === agentId);
|
|
80
|
+
for (let i = m.retrievals.length - 1; i >= 0; i--) {
|
|
81
|
+
const r = m.retrievals[i];
|
|
82
|
+
if (r.agentId === agentId && r.settledAt === null)
|
|
83
|
+
return r;
|
|
84
|
+
}
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
export function foldEvent(m, ev, now) {
|
|
88
|
+
m.eventCount++;
|
|
89
|
+
if (m.t0 === null)
|
|
90
|
+
m.t0 = now;
|
|
91
|
+
switch (ev.type) {
|
|
92
|
+
// ── run phases: the template's OWN markers tag spawns with roles ──
|
|
93
|
+
case 'plan:start': {
|
|
94
|
+
resetRun(m, now);
|
|
95
|
+
m.runPhase = 'planner';
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
case 'query': {
|
|
99
|
+
resetRun(m, now);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
case 'research:start': {
|
|
103
|
+
m.runPhase = 'research';
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
case 'synthesize:start': {
|
|
107
|
+
m.runPhase = 'synth';
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
case 'plan': {
|
|
111
|
+
const intent = typeof ev.intent === 'string' ? ev.intent : 'research';
|
|
112
|
+
if (intent === 'clarify') {
|
|
113
|
+
// The planner asked the USER instead of planning — it now waits on
|
|
114
|
+
// them, the same shape as an agent waiting on a tool. The run stays
|
|
115
|
+
// open; the answer's planning cycle continues it (see resetRun).
|
|
116
|
+
m.clarifying = true;
|
|
117
|
+
const questions = Array.isArray(ev.clarifyQuestions)
|
|
118
|
+
? ev.clarifyQuestions.filter((q) => typeof q === 'string')
|
|
119
|
+
: [];
|
|
120
|
+
for (const lane of m.lanes.values()) {
|
|
121
|
+
if (lane.role === 'planner')
|
|
122
|
+
lane.clarify = { questions, askedAt: now, answeredAt: null };
|
|
123
|
+
}
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
// The plan ARRIVED — the planner succeeded, whatever the pool's
|
|
127
|
+
// recovery mechanics said afterwards (recovery_skipped fires for an
|
|
128
|
+
// agent whose pool has nothing to salvage — the plan was already out).
|
|
129
|
+
if (Array.isArray(ev.tasks)) {
|
|
130
|
+
m.plan = {
|
|
131
|
+
intent,
|
|
132
|
+
tasks: ev.tasks.map((t) => typeof t === 'string' ? t
|
|
133
|
+
: typeof t?.description === 'string'
|
|
134
|
+
? t.description
|
|
135
|
+
: ''),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
for (const lane of m.lanes.values()) {
|
|
139
|
+
if (lane.role === 'planner') {
|
|
140
|
+
lane.outcome = 'done';
|
|
141
|
+
if (lane.doneAt === null)
|
|
142
|
+
lane.doneAt = now;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
case 'ready': {
|
|
148
|
+
const facts = ev.facts;
|
|
149
|
+
if (facts) {
|
|
150
|
+
m.facts = {
|
|
151
|
+
surface: typeof facts.surface === 'string' ? facts.surface : '',
|
|
152
|
+
model: facts.model ?? { id: '', sizeBytes: 0 },
|
|
153
|
+
abilities: Array.isArray(facts.abilities) ? facts.abilities : [],
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
case 'abilities:state': {
|
|
159
|
+
if (Array.isArray(ev.abilities)) {
|
|
160
|
+
m.abilities = ev.abilities
|
|
161
|
+
.filter((a) => !!a && typeof a.name === 'string')
|
|
162
|
+
.map((a) => ({ ...a, config: (a.config ?? {}) }));
|
|
163
|
+
}
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
case 'config:loaded':
|
|
167
|
+
case 'config:updated': {
|
|
168
|
+
if (ev.type === 'config:loaded' && ev.dev === true)
|
|
169
|
+
m.dev = true;
|
|
170
|
+
if (ev.config && typeof ev.config === 'object') {
|
|
171
|
+
m.config = ev.config;
|
|
172
|
+
}
|
|
173
|
+
if (ev.origin && typeof ev.origin === 'object') {
|
|
174
|
+
m.origin = ev.origin;
|
|
175
|
+
}
|
|
176
|
+
if (ev.type === 'config:updated' && 'savedTo' in ev) {
|
|
177
|
+
m.lastSavedTo = ev.savedTo ?? null;
|
|
178
|
+
}
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
case 'agent:spawn': {
|
|
182
|
+
const id = ev.agentId;
|
|
183
|
+
m.lanes.set(id, {
|
|
184
|
+
agentId: id,
|
|
185
|
+
parentAgentId: typeof ev.parentAgentId === 'number' ? ev.parentAgentId : null,
|
|
186
|
+
role: m.runPhase,
|
|
187
|
+
spawnedAt: now,
|
|
188
|
+
doneAt: null,
|
|
189
|
+
outcome: 'running',
|
|
190
|
+
tokenCount: 0,
|
|
191
|
+
inflightTool: null,
|
|
192
|
+
report: null,
|
|
193
|
+
reportSource: null,
|
|
194
|
+
prunedAt: null,
|
|
195
|
+
dropReason: null,
|
|
196
|
+
clarify: null,
|
|
197
|
+
epistemics: [],
|
|
198
|
+
nllSum: 0,
|
|
199
|
+
nllCount: 0,
|
|
200
|
+
});
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
case 'agent:produce': {
|
|
204
|
+
const lane = m.lanes.get(ev.agentId);
|
|
205
|
+
if (!lane)
|
|
206
|
+
return;
|
|
207
|
+
// tokenCount is CUMULATIVE on the wire — take the latest, never sum.
|
|
208
|
+
if (typeof ev.tokenCount === 'number')
|
|
209
|
+
lane.tokenCount = ev.tokenCount;
|
|
210
|
+
if (typeof ev.entropy === 'number' && Number.isFinite(ev.entropy)
|
|
211
|
+
&& typeof ev.surprisal === 'number' && Number.isFinite(ev.surprisal)) {
|
|
212
|
+
lane.epistemics.push({ at: now, h: ev.entropy, s: ev.surprisal });
|
|
213
|
+
lane.nllSum += ev.surprisal;
|
|
214
|
+
lane.nllCount += 1;
|
|
215
|
+
if (lane.epistemics.length >= MAX_EPISTEMICS) {
|
|
216
|
+
const e = lane.epistemics;
|
|
217
|
+
const half = [];
|
|
218
|
+
for (let i = 0; i + 1 < e.length; i += 2) {
|
|
219
|
+
half.push({
|
|
220
|
+
at: (e[i].at + e[i + 1].at) / 2,
|
|
221
|
+
h: (e[i].h + e[i + 1].h) / 2,
|
|
222
|
+
s: Math.max(e[i].s, e[i + 1].s),
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
lane.epistemics = half;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
case 'agent:done': {
|
|
231
|
+
const lane = m.lanes.get(ev.agentId);
|
|
232
|
+
if (lane) {
|
|
233
|
+
lane.doneAt = now;
|
|
234
|
+
if (lane.outcome === 'running')
|
|
235
|
+
lane.outcome = 'done';
|
|
236
|
+
}
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
case 'agent:return': {
|
|
240
|
+
const lane = m.lanes.get(ev.agentId);
|
|
241
|
+
if (lane && typeof ev.result === 'string') {
|
|
242
|
+
lane.report = ev.result;
|
|
243
|
+
lane.reportSource = 'voluntary';
|
|
244
|
+
}
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
case 'agent:recovered': {
|
|
248
|
+
const lane = m.lanes.get(ev.agentId);
|
|
249
|
+
if (lane) {
|
|
250
|
+
lane.outcome = 'recovered';
|
|
251
|
+
if (typeof ev.result === 'string') {
|
|
252
|
+
lane.report = ev.result;
|
|
253
|
+
lane.reportSource = 'recovery';
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
case 'agent:failed': {
|
|
259
|
+
const lane = m.lanes.get(ev.agentId);
|
|
260
|
+
if (lane) {
|
|
261
|
+
lane.failReason = typeof ev.reason === 'string' ? ev.reason : undefined;
|
|
262
|
+
// A planner whose plan already arrived stays `done` — the raw reason
|
|
263
|
+
// is kept for the detail pane, not painted as a run failure.
|
|
264
|
+
if (!(lane.role === 'planner' && lane.outcome === 'done')) {
|
|
265
|
+
lane.outcome = 'failed';
|
|
266
|
+
}
|
|
267
|
+
if (lane.doneAt === null)
|
|
268
|
+
lane.doneAt = now;
|
|
269
|
+
}
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
case 'agent:tool_call': {
|
|
273
|
+
const agentId = ev.agentId;
|
|
274
|
+
const lane = m.lanes.get(agentId);
|
|
275
|
+
const tool = typeof ev.tool === 'string' ? ev.tool : '';
|
|
276
|
+
if (lane)
|
|
277
|
+
lane.inflightTool = tool;
|
|
278
|
+
m.retrievals.push({
|
|
279
|
+
agentId,
|
|
280
|
+
tool,
|
|
281
|
+
args: typeof ev.args === 'string' ? ev.args : '',
|
|
282
|
+
dispatchedAt: now,
|
|
283
|
+
settledAt: null,
|
|
284
|
+
result: null,
|
|
285
|
+
contextAvailablePercent: null,
|
|
286
|
+
callId: null,
|
|
287
|
+
explore: null,
|
|
288
|
+
admission: null,
|
|
289
|
+
exploitChunks: null,
|
|
290
|
+
retry: null,
|
|
291
|
+
});
|
|
292
|
+
if (m.retrievals.length > MAX_RETRIEVALS)
|
|
293
|
+
m.retrievals.shift();
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
case 'agent:tool_result': {
|
|
297
|
+
const agentId = ev.agentId;
|
|
298
|
+
const tool = typeof ev.tool === 'string' ? ev.tool : '';
|
|
299
|
+
const lane = m.lanes.get(agentId);
|
|
300
|
+
// Clear only the matching in-flight marker — a late result for an
|
|
301
|
+
// earlier tool must not blank a newer call's state.
|
|
302
|
+
if (lane && lane.inflightTool === tool)
|
|
303
|
+
lane.inflightTool = null;
|
|
304
|
+
// Settle the OLDEST unsettled call for this agent+tool — dispatch is
|
|
305
|
+
// per-agent serial, so there is at most one.
|
|
306
|
+
const r = m.retrievals.find((x) => x.agentId === agentId && x.tool === tool && x.settledAt === null);
|
|
307
|
+
if (r) {
|
|
308
|
+
r.settledAt = now;
|
|
309
|
+
r.result = typeof ev.result === 'string' ? ev.result : null;
|
|
310
|
+
r.contextAvailablePercent =
|
|
311
|
+
typeof ev.contextAvailablePercent === 'number' ? ev.contextAvailablePercent : null;
|
|
312
|
+
}
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
case 'agent:trace': {
|
|
316
|
+
// The dev-gated tee: a trace event mirrored onto the bus, attributed.
|
|
317
|
+
// Only the types the pane renders are folded; everything else is
|
|
318
|
+
// ignored (the vocabulary can grow without breaking older panes).
|
|
319
|
+
const agentId = typeof ev.agentId === 'number' ? ev.agentId : -1;
|
|
320
|
+
const callId = typeof ev.callId === 'string' ? ev.callId : null;
|
|
321
|
+
const te = ev.event;
|
|
322
|
+
if (!te)
|
|
323
|
+
return;
|
|
324
|
+
switch (te.type) {
|
|
325
|
+
case 'pool:agentNudge': {
|
|
326
|
+
m.interventions.push({
|
|
327
|
+
kind: typeof te.guard === 'string' ? 'guard' : 'nudge',
|
|
328
|
+
agentId, at: now,
|
|
329
|
+
tool: typeof te.tool === 'string' ? te.tool : undefined,
|
|
330
|
+
args: typeof te.args === 'string' ? te.args : undefined,
|
|
331
|
+
guard: typeof te.guard === 'string' ? te.guard : undefined,
|
|
332
|
+
message: typeof te.message === 'string' ? te.message : undefined,
|
|
333
|
+
reason: typeof te.reason === 'string' ? te.reason : undefined,
|
|
334
|
+
});
|
|
335
|
+
if (m.interventions.length > MAX_INTERVENTIONS)
|
|
336
|
+
m.interventions.shift();
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
case 'tool:authReject': {
|
|
340
|
+
m.interventions.push({
|
|
341
|
+
kind: 'auth', agentId, at: now,
|
|
342
|
+
tool: typeof te.attemptedTool === 'string' ? te.attemptedTool : undefined,
|
|
343
|
+
});
|
|
344
|
+
if (m.interventions.length > MAX_INTERVENTIONS)
|
|
345
|
+
m.interventions.shift();
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
case 'pool:agentDrop': {
|
|
349
|
+
const lane = m.lanes.get(agentId);
|
|
350
|
+
if (lane && typeof te.reason === 'string')
|
|
351
|
+
lane.dropReason = te.reason;
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
case 'branch:prune': {
|
|
355
|
+
// agent ids ARE branch handles — the prune ends the hatched tail.
|
|
356
|
+
const handle = typeof te.branchHandle === 'number' ? te.branchHandle : agentId;
|
|
357
|
+
const lane = m.lanes.get(handle);
|
|
358
|
+
if (lane)
|
|
359
|
+
lane.prunedAt = now;
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
case 'tool:dispatch': {
|
|
363
|
+
// Keys the retrieval: newest unsettled call for this agent+tool
|
|
364
|
+
// gains the callId + explore mode the trace metadata hangs off.
|
|
365
|
+
const tool = typeof te.tool === 'string' ? te.tool : '';
|
|
366
|
+
for (let i = m.retrievals.length - 1; i >= 0; i--) {
|
|
367
|
+
const r = m.retrievals[i];
|
|
368
|
+
if (r.agentId === agentId && r.tool === tool && r.settledAt === null && r.callId === null) {
|
|
369
|
+
r.callId = typeof te.callId === 'string' ? te.callId : null;
|
|
370
|
+
r.explore = typeof te.explore === 'boolean' ? te.explore : null;
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
case 'rerank:end': {
|
|
377
|
+
const r = findRetrieval(m, callId, agentId);
|
|
378
|
+
if (r) {
|
|
379
|
+
r.admission = {
|
|
380
|
+
selectedPassageCount: typeof te.selectedPassageCount === 'number' ? te.selectedPassageCount : 0,
|
|
381
|
+
totalChars: typeof te.totalChars === 'number' ? te.totalChars : 0,
|
|
382
|
+
durationMs: typeof te.durationMs === 'number' ? te.durationMs : 0,
|
|
383
|
+
topResults: Array.isArray(te.topResults) ? te.topResults : [],
|
|
384
|
+
...(typeof te.topK === 'number' ? { topK: te.topK } : {}),
|
|
385
|
+
...(typeof te.tokenBudget === 'number' ? { tokenBudget: te.tokenBudget } : {}),
|
|
386
|
+
...(typeof te.admittedTokens === 'number' ? { admittedTokens: te.admittedTokens } : {}),
|
|
387
|
+
...(typeof te.threshold === 'number' ? { threshold: te.threshold } : {}),
|
|
388
|
+
...(typeof te.totalScored === 'number' ? { totalScored: te.totalScored } : {}),
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
case 'entailment:content:exploit': {
|
|
394
|
+
const r = findRetrieval(m, callId, agentId);
|
|
395
|
+
if (r && Array.isArray(te.chunks)) {
|
|
396
|
+
r.exploitChunks = te.chunks;
|
|
397
|
+
}
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
default:
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
case 'agent:tool_retry': {
|
|
405
|
+
const agentId = ev.agentId;
|
|
406
|
+
const tool = typeof ev.tool === 'string' ? ev.tool : '';
|
|
407
|
+
for (let i = m.retrievals.length - 1; i >= 0; i--) {
|
|
408
|
+
const r = m.retrievals[i];
|
|
409
|
+
if (r.agentId === agentId && r.tool === tool && r.settledAt === null) {
|
|
410
|
+
r.retry = {
|
|
411
|
+
at: now,
|
|
412
|
+
afterMs: typeof ev.retryAfterMs === 'number' ? ev.retryAfterMs : 0,
|
|
413
|
+
attempt: typeof ev.attempt === 'number' ? ev.attempt : 1,
|
|
414
|
+
};
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
case 'agent:tick': {
|
|
421
|
+
if (typeof ev.cellsUsed === 'number' && typeof ev.nCtx === 'number') {
|
|
422
|
+
m.pressure.push({ at: now, cellsUsed: ev.cellsUsed, nCtx: ev.nCtx });
|
|
423
|
+
if (m.pressure.length > MAX_PRESSURE_POINTS)
|
|
424
|
+
m.pressure.shift();
|
|
425
|
+
}
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
case 'answer': {
|
|
429
|
+
if (m.runStartAt !== null)
|
|
430
|
+
m.runEndedAt = now;
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
case 'host:resources': {
|
|
434
|
+
if (typeof ev.cpuPct !== 'number' || typeof ev.rssMb !== 'number')
|
|
435
|
+
return;
|
|
436
|
+
m.host.push({
|
|
437
|
+
at: now, cpu: ev.cpuPct, rssMb: ev.rssMb,
|
|
438
|
+
memUsedMb: typeof ev.sysMemUsedMb === 'number' ? ev.sysMemUsedMb : null,
|
|
439
|
+
memTotalMb: typeof ev.sysMemTotalMb === 'number' ? ev.sysMemTotalMb : 0,
|
|
440
|
+
});
|
|
441
|
+
if (m.host.length > MAX_HOST)
|
|
442
|
+
m.host.shift();
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
default:
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
/** Live when any lane is still open — the run is producing and the pane's
|
|
450
|
+
* clocks (elapsed, park countdowns) must keep advancing even between
|
|
451
|
+
* events. */
|
|
452
|
+
export function isLive(m) {
|
|
453
|
+
if (m.runStartAt !== null && m.runEndedAt === null)
|
|
454
|
+
return true;
|
|
455
|
+
for (const l of m.lanes.values())
|
|
456
|
+
if (l.doneAt === null)
|
|
457
|
+
return true;
|
|
458
|
+
return false;
|
|
459
|
+
}
|
|
460
|
+
/** The latest pressure reading as a 0–100 used percentage, or null before the
|
|
461
|
+
* first tick. */
|
|
462
|
+
export function pressurePercent(m) {
|
|
463
|
+
const last = m.pressure[m.pressure.length - 1];
|
|
464
|
+
if (!last || last.nCtx <= 0)
|
|
465
|
+
return null;
|
|
466
|
+
return Math.round((last.cellsUsed / last.nCtx) * 100);
|
|
467
|
+
}
|
|
468
|
+
/** Downsample the pressure series to at most `buckets` points for a strip
|
|
469
|
+
* chart — plotted against TIME (the tick rate slows as the context fills, so
|
|
470
|
+
* index-based plotting would stretch exactly the interesting part). */
|
|
471
|
+
export function pressureStrip(m, buckets) {
|
|
472
|
+
if (m.pressure.length === 0 || buckets <= 0)
|
|
473
|
+
return [];
|
|
474
|
+
const first = m.pressure[0].at;
|
|
475
|
+
const last = m.pressure[m.pressure.length - 1].at;
|
|
476
|
+
const span = Math.max(1, last - first);
|
|
477
|
+
const out = [];
|
|
478
|
+
let bi = -1;
|
|
479
|
+
for (const p of m.pressure) {
|
|
480
|
+
const b = Math.min(buckets - 1, Math.floor(((p.at - first) / span) * buckets));
|
|
481
|
+
const pct = p.nCtx > 0 ? (p.cellsUsed / p.nCtx) * 100 : 0;
|
|
482
|
+
if (b !== bi) {
|
|
483
|
+
out.push({ at: p.at, pct });
|
|
484
|
+
bi = b;
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
out[out.length - 1] = { at: p.at, pct };
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
return out;
|
|
491
|
+
}
|
|
492
|
+
const SPARK = '▁▂▃▄▅▆▇█';
|
|
493
|
+
/** A fixed-width unicode sparkline of the pressure series — pure, node-free
|
|
494
|
+
* (the ink overlay renders it; anything else may too). */
|
|
495
|
+
export function sparkline(m, width) {
|
|
496
|
+
const strip = pressureStrip(m, width);
|
|
497
|
+
if (strip.length === 0)
|
|
498
|
+
return '';
|
|
499
|
+
return strip.map((p) => SPARK[Math.min(7, Math.floor((p.pct / 100) * 8))]).join('');
|
|
500
|
+
}
|
|
501
|
+
/** Display order + one-clause meaning for each provenance rung — the six real
|
|
502
|
+
* values, nothing invented. */
|
|
503
|
+
export const PROVENANCE_RUNGS = [
|
|
504
|
+
{ rung: 'cli', means: 'a command-line flag' },
|
|
505
|
+
{ rung: 'env', means: 'an environment variable' },
|
|
506
|
+
{ rung: 'file', means: 'harness.json — your local overrides' },
|
|
507
|
+
{ rung: 'yml', means: 'harness.yml — the committed manifest' },
|
|
508
|
+
{ rung: 'session', means: 'this session only — no file remembers it' },
|
|
509
|
+
{ rung: 'default', means: 'nothing set it' },
|
|
510
|
+
];
|
|
511
|
+
export const KEY_TIERS = {
|
|
512
|
+
'sources.outputDir': 'session',
|
|
513
|
+
'defaults.effort': 'session',
|
|
514
|
+
'defaults.reasoningMode': 'session',
|
|
515
|
+
'model.path': 'reload',
|
|
516
|
+
'model.reranker': 'reload',
|
|
517
|
+
'model.gpu': 'reload',
|
|
518
|
+
'model.nCtx': 'boot',
|
|
519
|
+
'model.branches': 'boot',
|
|
520
|
+
'model.kvCache': 'boot',
|
|
521
|
+
};
|
|
522
|
+
/** Read a dotted config path off the live config object. */
|
|
523
|
+
export function readConfigPath(config, path) {
|
|
524
|
+
if (!config)
|
|
525
|
+
return undefined;
|
|
526
|
+
let node = config;
|
|
527
|
+
for (const seg of path.split('.')) {
|
|
528
|
+
if (node === null || typeof node !== 'object')
|
|
529
|
+
return undefined;
|
|
530
|
+
node = node[seg];
|
|
531
|
+
}
|
|
532
|
+
return node;
|
|
533
|
+
}
|
|
534
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA6HA;;wDAEwD;AACxD,MAAM,UAAU,OAAO,CAAC,IAAe;IACrC,OAAO,IAAI,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC5E,CAAC;AA0ID,MAAM,UAAU,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AI,EAAE,KAAK,EAAE,KAAK,EAAE,yBAAyB,EAAE;IACjD,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,qCAAqC,EAAE;IAC9D,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,sCAAsC,EAAE;IAC9D,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,0CAA0C,EAAE;IACtE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,gBAAgB,EAAE;CAC7C,CAAC;AAKF,MAAM,CAAC,MAAM,SAAS,GAAyC;IAC7D,mBAAmB,EAAE,SAAS;IAC9B,iBAAiB,EAAE,SAAS;IAC5B,wBAAwB,EAAE,SAAS;IACnC,YAAY,EAAE,QAAQ;IACtB,gBAAgB,EAAE,QAAQ;IAC1B,WAAW,EAAE,QAAQ;IACrB,YAAY,EAAE,MAAM;IACpB,gBAAgB,EAAE,MAAM;IACxB,eAAe,EAAE,MAAM;CACxB,CAAC;AAEF,4DAA4D;AAC5D,MAAM,UAAU,cAAc,CAC5B,MAAsC,EACtC,IAAY;IAEZ,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,IAAI,IAAI,GAAY,MAAM,CAAC;IAC3B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QAClC,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC;QAChE,IAAI,GAAI,IAAgC,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/ink.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { PaneModel } from './index.js';
|
|
3
|
+
export { sparkline } from './index.js';
|
|
4
|
+
export interface DevOverlayProps {
|
|
5
|
+
model: PaneModel;
|
|
6
|
+
/** Rows of event tail to show (bounded — default 5). */
|
|
7
|
+
tailRows?: number;
|
|
8
|
+
/** The most recent human-readable event lines, newest last — the VIEW
|
|
9
|
+
* formats these (it owns the template's event vocabulary); the overlay
|
|
10
|
+
* just bounds and prints them. */
|
|
11
|
+
tail?: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
export declare function DevOverlay({ model: m, tailRows, tail }: DevOverlayProps): ReactElement | null;
|
|
14
|
+
//# sourceMappingURL=ink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ink.d.ts","sourceRoot":"","sources":["../src/ink.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,SAAS,CAAC;IACjB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;uCAEmC;IACnC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B;AAMD,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAY,EAAE,IAAS,EAAE,EAAE,eAAe,GAAG,YAAY,GAAG,IAAI,CA+BtG"}
|
package/dist/ink.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* `<DevOverlay>` — the terminal dev overlay (ctrl+g in the cli view).
|
|
4
|
+
*
|
|
5
|
+
* BOUNDED height by contract: the cli view keeps finished work in Ink's
|
|
6
|
+
* `<Static>` and its dynamic frame under the terminal height — an overlay
|
|
7
|
+
* that grows past the frame makes Ink clear-and-repaint, wiping scrollback.
|
|
8
|
+
* This component renders a fixed number of rows (a pressure sparkline, one
|
|
9
|
+
* provenance line, a short event tail) and never more.
|
|
10
|
+
*
|
|
11
|
+
* The view owns the toggle: fold events into a `PaneModel` (`foldEvent`) and
|
|
12
|
+
* render `<DevOverlay model={m} />` when visible. Render nothing when the
|
|
13
|
+
* model says `dev: false` — the gate is the wire's, not the view's.
|
|
14
|
+
*
|
|
15
|
+
* @category DevTools
|
|
16
|
+
*/
|
|
17
|
+
import { Box, Text } from 'ink';
|
|
18
|
+
import { pressurePercent, sparkline } from './index.js';
|
|
19
|
+
export { sparkline } from './index.js';
|
|
20
|
+
/** The overlay is bounded BY CONTRACT (Ink wipes scrollback past the frame) —
|
|
21
|
+
* clamp the tail rows so no caller value can grow it. */
|
|
22
|
+
const MAX_TAIL_ROWS = 12;
|
|
23
|
+
export function DevOverlay({ model: m, tailRows = 5, tail = [] }) {
|
|
24
|
+
if (!m.dev)
|
|
25
|
+
return null;
|
|
26
|
+
const rows = Math.max(0, Math.min(MAX_TAIL_ROWS, Number.isFinite(tailRows) ? Math.floor(tailRows) : 5));
|
|
27
|
+
const pct = pressurePercent(m);
|
|
28
|
+
const origin = m.origin ?? {};
|
|
29
|
+
const originLine = Object.entries(origin)
|
|
30
|
+
.map(([k, v]) => `${k}:${v}`)
|
|
31
|
+
.join(' ');
|
|
32
|
+
const bounded = rows === 0 ? [] : tail.slice(-rows);
|
|
33
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "gray", paddingX: 1, children: [_jsxs(Box, { gap: 2, children: [_jsx(Text, { color: "blueBright", bold: true, children: "dev" }), _jsxs(Text, { dimColor: true, children: [m.eventCount, " events"] }), pct !== null && (_jsxs(Text, { children: [_jsx(Text, { color: "blueBright", children: sparkline(m, 24) }), _jsxs(Text, { children: [" ", pct, "%"] }), _jsx(Text, { dimColor: true, children: " \u00B7 attention cells" })] })), _jsx(Text, { dimColor: true, children: "ctrl+g close" })] }), originLine !== '' && (_jsx(Text, { dimColor: true, wrap: "truncate", children: originLine })), bounded.map((line, i) => (_jsx(Text, { wrap: "truncate", dimColor: true, children: line }, i)))] }));
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=ink.js.map
|
package/dist/ink.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ink.js","sourceRoot":"","sources":["../src/ink.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGxD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAYvC;0DAC0D;AAC1D,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,MAAM,UAAU,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,GAAG,CAAC,EAAE,IAAI,GAAG,EAAE,EAAmB;IAC/E,IAAI,CAAC,CAAC,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxG,MAAM,GAAG,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC;IAC9B,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;SACtC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;SAC5B,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,MAAM,OAAO,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;IACpD,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,WAAW,EAAC,OAAO,EAAC,WAAW,EAAC,MAAM,EAAC,QAAQ,EAAE,CAAC,aAC5E,MAAC,GAAG,IAAC,GAAG,EAAE,CAAC,aACT,KAAC,IAAI,IAAC,KAAK,EAAC,YAAY,EAAC,IAAI,0BAAW,EACxC,MAAC,IAAI,IAAC,QAAQ,mBAAE,CAAC,CAAC,UAAU,eAAe,EAC1C,GAAG,KAAK,IAAI,IAAI,CACf,MAAC,IAAI,eACH,KAAC,IAAI,IAAC,KAAK,EAAC,YAAY,YAAE,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,GAAQ,EAClD,MAAC,IAAI,oBAAG,GAAG,SAAS,EACpB,KAAC,IAAI,IAAC,QAAQ,8CAA0B,IACnC,CACR,EACD,KAAC,IAAI,IAAC,QAAQ,mCAAoB,IAC9B,EACL,UAAU,KAAK,EAAE,IAAI,CACpB,KAAC,IAAI,IAAC,QAAQ,QAAC,IAAI,EAAC,UAAU,YAAE,UAAU,GAAQ,CACnD,EACA,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CACxB,KAAC,IAAI,IAAS,IAAI,EAAC,UAAU,EAAC,QAAQ,kBAAE,IAAI,IAAjC,CAAC,CAAwC,CACrD,CAAC,IACE,CACP,CAAC;AACJ,CAAC"}
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HostResourcesEvent } from './index.js';
|
|
2
|
+
export type { HostResourcesEvent } from './index.js';
|
|
3
|
+
/** Start sampling; returns the stop function. The timer is unref'd so it
|
|
4
|
+
* never holds the process open. */
|
|
5
|
+
export declare function startHostResources(send: (ev: HostResourcesEvent) => void, intervalMs?: number): () => void;
|
|
6
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;oCACoC;AACpC,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,CAAC,EAAE,EAAE,kBAAkB,KAAK,IAAI,EACtC,UAAU,SAAO,GAChB,MAAM,IAAI,CA2BZ"}
|