poe-code 3.0.216 → 3.0.218
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/dist/index.js +727 -372
- package/dist/index.js.map +4 -4
- package/dist/providers/claude-code.js +20 -11
- package/dist/providers/claude-code.js.map +4 -4
- package/dist/providers/codex.js +20 -11
- package/dist/providers/codex.js.map +4 -4
- package/dist/providers/goose.js +20 -11
- package/dist/providers/goose.js.map +4 -4
- package/dist/providers/kimi.js +20 -11
- package/dist/providers/kimi.js.map +4 -4
- package/dist/providers/opencode.js +20 -11
- package/dist/providers/opencode.js.map +4 -4
- package/dist/providers/poe-agent.js +569 -239
- package/dist/providers/poe-agent.js.map +4 -4
- package/package.json +3 -1
- package/packages/design-system/dist/dashboard/buffer.js +8 -1
- package/packages/design-system/dist/dashboard/keymap.d.ts +5 -0
- package/packages/design-system/dist/dashboard/keymap.js +146 -12
- package/packages/design-system/dist/dashboard/terminal.js +31 -0
- package/packages/design-system/dist/dashboard/types.d.ts +1 -0
- package/packages/design-system/dist/explorer/actions.d.ts +16 -0
- package/packages/design-system/dist/explorer/actions.js +39 -0
- package/packages/design-system/dist/explorer/demo.d.ts +13 -0
- package/packages/design-system/dist/explorer/demo.js +297 -0
- package/packages/design-system/dist/explorer/events.d.ts +61 -0
- package/packages/design-system/dist/explorer/events.js +1 -0
- package/packages/design-system/dist/explorer/filter.d.ts +10 -0
- package/packages/design-system/dist/explorer/filter.js +95 -0
- package/packages/design-system/dist/explorer/index.d.ts +8 -0
- package/packages/design-system/dist/explorer/index.js +8 -0
- package/packages/design-system/dist/explorer/jobs.d.ts +7 -0
- package/packages/design-system/dist/explorer/jobs.js +59 -0
- package/packages/design-system/dist/explorer/keymap.d.ts +21 -0
- package/packages/design-system/dist/explorer/keymap.js +363 -0
- package/packages/design-system/dist/explorer/layout.d.ts +20 -0
- package/packages/design-system/dist/explorer/layout.js +73 -0
- package/packages/design-system/dist/explorer/reducer.d.ts +9 -0
- package/packages/design-system/dist/explorer/reducer.js +704 -0
- package/packages/design-system/dist/explorer/render/detail.d.ts +4 -0
- package/packages/design-system/dist/explorer/render/detail.js +96 -0
- package/packages/design-system/dist/explorer/render/footer.d.ts +4 -0
- package/packages/design-system/dist/explorer/render/footer.js +49 -0
- package/packages/design-system/dist/explorer/render/header.d.ts +4 -0
- package/packages/design-system/dist/explorer/render/header.js +56 -0
- package/packages/design-system/dist/explorer/render/index.d.ts +8 -0
- package/packages/design-system/dist/explorer/render/index.js +61 -0
- package/packages/design-system/dist/explorer/render/list.d.ts +4 -0
- package/packages/design-system/dist/explorer/render/list.js +106 -0
- package/packages/design-system/dist/explorer/render/modal.d.ts +3 -0
- package/packages/design-system/dist/explorer/render/modal.js +91 -0
- package/packages/design-system/dist/explorer/render/test-fixtures.d.ts +8 -0
- package/packages/design-system/dist/explorer/render/test-fixtures.js +156 -0
- package/packages/design-system/dist/explorer/runtime.d.ts +2 -0
- package/packages/design-system/dist/explorer/runtime.js +282 -0
- package/packages/design-system/dist/explorer/runtime.test-helpers.d.ts +50 -0
- package/packages/design-system/dist/explorer/runtime.test-helpers.js +101 -0
- package/packages/design-system/dist/explorer/state.d.ts +130 -0
- package/packages/design-system/dist/explorer/state.js +87 -0
- package/packages/design-system/dist/explorer/theme.d.ts +27 -0
- package/packages/design-system/dist/explorer/theme.js +97 -0
- package/packages/design-system/dist/index.d.ts +3 -0
- package/packages/design-system/dist/index.js +3 -0
- package/packages/memory/dist/index.js +9 -0
- package/packages/memory/dist/index.js.map +3 -3
- package/packages/superintendent/dist/commands/builder-group.d.ts +16 -16
- package/packages/superintendent/dist/commands/complete.d.ts +6 -6
- package/packages/superintendent/dist/commands/inspector-group.d.ts +36 -36
- package/packages/superintendent/dist/commands/install.d.ts +6 -6
- package/packages/superintendent/dist/commands/plan-path.d.ts +2 -2
- package/packages/superintendent/dist/commands/run.d.ts +60 -60
- package/packages/superintendent/dist/commands/superintendent-group.d.ts +146 -146
|
@@ -6035,9 +6035,9 @@ function getOptionalGrepOutputMode(args, key2) {
|
|
|
6035
6035
|
function formatDisplayPath(cwd, filePath) {
|
|
6036
6036
|
return path11.relative(cwd, filePath) || path11.basename(filePath);
|
|
6037
6037
|
}
|
|
6038
|
-
async function sortPathsByModifiedTime(
|
|
6038
|
+
async function sortPathsByModifiedTime(matches, fs4) {
|
|
6039
6039
|
const entries = await Promise.all(
|
|
6040
|
-
|
|
6040
|
+
matches.map(async (match) => ({
|
|
6041
6041
|
path: match,
|
|
6042
6042
|
mtimeMs: (await fs4.stat(match)).mtimeMs
|
|
6043
6043
|
}))
|
|
@@ -6422,12 +6422,12 @@ var init_poe_agent_plugin_files = __esm({
|
|
|
6422
6422
|
allowedPaths,
|
|
6423
6423
|
getOptionalString(args, "path") ?? "."
|
|
6424
6424
|
);
|
|
6425
|
-
const
|
|
6425
|
+
const matches = await globFiles({
|
|
6426
6426
|
pattern: getRequiredString(args, "pattern"),
|
|
6427
6427
|
cwd: searchPath
|
|
6428
6428
|
});
|
|
6429
6429
|
const sortedMatches = await sortPathsByModifiedTime(
|
|
6430
|
-
|
|
6430
|
+
matches.map((match) => resolveAllowedPath(cwd, allowedPaths, match)),
|
|
6431
6431
|
fs4
|
|
6432
6432
|
);
|
|
6433
6433
|
if (sortedMatches.length === 0) {
|
|
@@ -23110,6 +23110,9 @@ function cellToAnsi(cell) {
|
|
|
23110
23110
|
if (style.dim) {
|
|
23111
23111
|
painter = painter.dim;
|
|
23112
23112
|
}
|
|
23113
|
+
if (style.underline) {
|
|
23114
|
+
painter = painter.underline;
|
|
23115
|
+
}
|
|
23113
23116
|
if (style.fg) {
|
|
23114
23117
|
painter = applyForegroundColor(painter, style.fg);
|
|
23115
23118
|
}
|
|
@@ -23142,13 +23145,16 @@ function normalizeStyle(style) {
|
|
|
23142
23145
|
if (style?.dim !== void 0) {
|
|
23143
23146
|
next.dim = style.dim;
|
|
23144
23147
|
}
|
|
23148
|
+
if (style?.underline !== void 0) {
|
|
23149
|
+
next.underline = style.underline;
|
|
23150
|
+
}
|
|
23145
23151
|
return next;
|
|
23146
23152
|
}
|
|
23147
23153
|
function normalizeSize(value) {
|
|
23148
23154
|
return Math.max(0, Math.floor(value));
|
|
23149
23155
|
}
|
|
23150
23156
|
function cellsEqual(left, right) {
|
|
23151
|
-
return left.ch === right.ch && left.style.fg === right.style.fg && left.style.bg === right.style.bg && left.style.bold === right.style.bold && left.style.dim === right.style.dim;
|
|
23157
|
+
return left.ch === right.ch && left.style.fg === right.style.fg && left.style.bg === right.style.bg && left.style.bold === right.style.bold && left.style.dim === right.style.dim && left.style.underline === right.style.underline;
|
|
23152
23158
|
}
|
|
23153
23159
|
function applyForegroundColor(instance, color) {
|
|
23154
23160
|
if (color.startsWith("#")) {
|
|
@@ -24158,24 +24164,60 @@ var init_stats_pane = __esm({
|
|
|
24158
24164
|
});
|
|
24159
24165
|
|
|
24160
24166
|
// packages/design-system/src/dashboard/keymap.ts
|
|
24161
|
-
function createKeymap(overrides) {
|
|
24167
|
+
function createKeymap(overrides, options) {
|
|
24168
|
+
const resolvedCommands = options?.commands ?? commands;
|
|
24169
|
+
const resolvedDefaults = options?.defaultBindings ?? defaultBindings;
|
|
24162
24170
|
const bindings = /* @__PURE__ */ new Map();
|
|
24163
|
-
|
|
24164
|
-
|
|
24165
|
-
|
|
24166
|
-
|
|
24167
|
-
|
|
24168
|
-
)
|
|
24171
|
+
const sequences = /* @__PURE__ */ new Set();
|
|
24172
|
+
let pendingSequence = "";
|
|
24173
|
+
for (const command of resolvedCommands) {
|
|
24174
|
+
const keys = overrides?.[command] ?? resolvedDefaults[command];
|
|
24175
|
+
const commandBindings = keys.map(parseBinding).filter((binding) => binding !== void 0);
|
|
24176
|
+
for (const binding of commandBindings) {
|
|
24177
|
+
if (binding.sequence !== void 0) {
|
|
24178
|
+
sequences.add(binding.sequence);
|
|
24179
|
+
}
|
|
24180
|
+
}
|
|
24181
|
+
bindings.set(command, commandBindings);
|
|
24169
24182
|
}
|
|
24170
24183
|
return (event) => {
|
|
24171
|
-
for (const command of
|
|
24184
|
+
for (const command of resolvedCommands) {
|
|
24172
24185
|
const commandBindings = bindings.get(command);
|
|
24173
|
-
if (commandBindings?.some((binding) =>
|
|
24186
|
+
if (commandBindings?.some((binding) => matchesSingleKey(binding, event))) {
|
|
24187
|
+
pendingSequence = "";
|
|
24174
24188
|
return command;
|
|
24175
24189
|
}
|
|
24176
24190
|
}
|
|
24191
|
+
const sequenceCommand = resolveSequence(event);
|
|
24192
|
+
if (sequenceCommand !== void 0) {
|
|
24193
|
+
return sequenceCommand;
|
|
24194
|
+
}
|
|
24177
24195
|
return void 0;
|
|
24178
24196
|
};
|
|
24197
|
+
function resolveSequence(event) {
|
|
24198
|
+
const token = eventToSequenceToken(event);
|
|
24199
|
+
if (token === void 0) {
|
|
24200
|
+
pendingSequence = "";
|
|
24201
|
+
return void 0;
|
|
24202
|
+
}
|
|
24203
|
+
pendingSequence = `${pendingSequence}${token}`;
|
|
24204
|
+
for (const command of resolvedCommands) {
|
|
24205
|
+
const commandBindings = bindings.get(command);
|
|
24206
|
+
if (commandBindings?.some((binding) => binding.sequence === pendingSequence)) {
|
|
24207
|
+
pendingSequence = "";
|
|
24208
|
+
return command;
|
|
24209
|
+
}
|
|
24210
|
+
}
|
|
24211
|
+
if (hasSequencePrefix(sequences, pendingSequence)) {
|
|
24212
|
+
return void 0;
|
|
24213
|
+
}
|
|
24214
|
+
pendingSequence = token;
|
|
24215
|
+
if (hasSequencePrefix(sequences, pendingSequence)) {
|
|
24216
|
+
return void 0;
|
|
24217
|
+
}
|
|
24218
|
+
pendingSequence = "";
|
|
24219
|
+
return void 0;
|
|
24220
|
+
}
|
|
24179
24221
|
}
|
|
24180
24222
|
function parseBinding(binding) {
|
|
24181
24223
|
const value = binding.trim();
|
|
@@ -24208,25 +24250,37 @@ function parseBinding(binding) {
|
|
|
24208
24250
|
continue;
|
|
24209
24251
|
}
|
|
24210
24252
|
}
|
|
24211
|
-
|
|
24253
|
+
const normalizedKey = normalizeKeyName(key2);
|
|
24254
|
+
if (parts.length === 1 && isShiftedCharacter(normalizedKey)) {
|
|
24212
24255
|
shift = true;
|
|
24213
24256
|
}
|
|
24214
|
-
if (
|
|
24257
|
+
if (normalizedKey.length === 1) {
|
|
24258
|
+
return {
|
|
24259
|
+
ch: normalizeBindingCharacter(normalizedKey, shift),
|
|
24260
|
+
ctrl,
|
|
24261
|
+
meta,
|
|
24262
|
+
shift
|
|
24263
|
+
};
|
|
24264
|
+
}
|
|
24265
|
+
if (!ctrl && !meta && !shift && !isNamedKey(normalizedKey) && isPrintableSequence(normalizedKey)) {
|
|
24215
24266
|
return {
|
|
24216
|
-
|
|
24267
|
+
sequence: normalizedKey,
|
|
24217
24268
|
ctrl,
|
|
24218
24269
|
meta,
|
|
24219
24270
|
shift
|
|
24220
24271
|
};
|
|
24221
24272
|
}
|
|
24222
24273
|
return {
|
|
24223
|
-
name:
|
|
24274
|
+
name: normalizedKey.toLowerCase(),
|
|
24224
24275
|
ctrl,
|
|
24225
24276
|
meta,
|
|
24226
24277
|
shift
|
|
24227
24278
|
};
|
|
24228
24279
|
}
|
|
24229
|
-
function
|
|
24280
|
+
function matchesSingleKey(binding, event) {
|
|
24281
|
+
if (binding.sequence !== void 0) {
|
|
24282
|
+
return false;
|
|
24283
|
+
}
|
|
24230
24284
|
if (binding.ctrl !== event.ctrl || binding.meta !== event.meta || binding.shift !== event.shift) {
|
|
24231
24285
|
return false;
|
|
24232
24286
|
}
|
|
@@ -24238,6 +24292,20 @@ function matches(binding, event) {
|
|
|
24238
24292
|
}
|
|
24239
24293
|
return false;
|
|
24240
24294
|
}
|
|
24295
|
+
function eventToSequenceToken(event) {
|
|
24296
|
+
if (event.ctrl || event.meta || event.ch === void 0) {
|
|
24297
|
+
return void 0;
|
|
24298
|
+
}
|
|
24299
|
+
return event.ch;
|
|
24300
|
+
}
|
|
24301
|
+
function hasSequencePrefix(sequences, prefix) {
|
|
24302
|
+
for (const sequence of sequences) {
|
|
24303
|
+
if (sequence.startsWith(prefix)) {
|
|
24304
|
+
return true;
|
|
24305
|
+
}
|
|
24306
|
+
}
|
|
24307
|
+
return false;
|
|
24308
|
+
}
|
|
24241
24309
|
function isShiftedCharacter(value) {
|
|
24242
24310
|
return value.length === 1 && value.toLowerCase() !== value && value.toUpperCase() === value;
|
|
24243
24311
|
}
|
|
@@ -24247,7 +24315,40 @@ function normalizeBindingCharacter(value, shift) {
|
|
|
24247
24315
|
}
|
|
24248
24316
|
return value.toUpperCase();
|
|
24249
24317
|
}
|
|
24250
|
-
|
|
24318
|
+
function normalizeKeyName(value) {
|
|
24319
|
+
if (value.toLowerCase() === "space") {
|
|
24320
|
+
return " ";
|
|
24321
|
+
}
|
|
24322
|
+
if (value === "\u2191") {
|
|
24323
|
+
return "up";
|
|
24324
|
+
}
|
|
24325
|
+
if (value === "\u2193") {
|
|
24326
|
+
return "down";
|
|
24327
|
+
}
|
|
24328
|
+
if (value === "\u2190") {
|
|
24329
|
+
return "left";
|
|
24330
|
+
}
|
|
24331
|
+
if (value === "\u2192") {
|
|
24332
|
+
return "right";
|
|
24333
|
+
}
|
|
24334
|
+
return value;
|
|
24335
|
+
}
|
|
24336
|
+
function isNamedKey(value) {
|
|
24337
|
+
return namedKeys.has(value.toLowerCase());
|
|
24338
|
+
}
|
|
24339
|
+
function isPrintableSequence(value) {
|
|
24340
|
+
if (Array.from(value).length <= 1) {
|
|
24341
|
+
return false;
|
|
24342
|
+
}
|
|
24343
|
+
for (const char of value) {
|
|
24344
|
+
const codePoint = char.codePointAt(0);
|
|
24345
|
+
if (codePoint === void 0 || codePoint < 32 || codePoint === 127) {
|
|
24346
|
+
return false;
|
|
24347
|
+
}
|
|
24348
|
+
}
|
|
24349
|
+
return true;
|
|
24350
|
+
}
|
|
24351
|
+
var commands, defaultBindings, namedKeys;
|
|
24251
24352
|
var init_keymap = __esm({
|
|
24252
24353
|
"packages/design-system/src/dashboard/keymap.ts"() {
|
|
24253
24354
|
"use strict";
|
|
@@ -24260,6 +24361,22 @@ var init_keymap = __esm({
|
|
|
24260
24361
|
retry: ["r"],
|
|
24261
24362
|
"view-log": ["l"]
|
|
24262
24363
|
};
|
|
24364
|
+
namedKeys = /* @__PURE__ */ new Set([
|
|
24365
|
+
"backspace",
|
|
24366
|
+
"delete",
|
|
24367
|
+
"down",
|
|
24368
|
+
"end",
|
|
24369
|
+
"enter",
|
|
24370
|
+
"escape",
|
|
24371
|
+
"home",
|
|
24372
|
+
"left",
|
|
24373
|
+
"pagedown",
|
|
24374
|
+
"pageup",
|
|
24375
|
+
"return",
|
|
24376
|
+
"right",
|
|
24377
|
+
"tab",
|
|
24378
|
+
"up"
|
|
24379
|
+
]);
|
|
24263
24380
|
}
|
|
24264
24381
|
});
|
|
24265
24382
|
|
|
@@ -24581,6 +24698,10 @@ function createTerminalDriver(opts) {
|
|
|
24581
24698
|
};
|
|
24582
24699
|
}
|
|
24583
24700
|
function toKeypressEvent(str, key2) {
|
|
24701
|
+
const controlCharacter = controlCharacterToKeypress(key2?.sequence);
|
|
24702
|
+
if (controlCharacter !== void 0) {
|
|
24703
|
+
return controlCharacter;
|
|
24704
|
+
}
|
|
24584
24705
|
const ctrl = key2?.ctrl ?? false;
|
|
24585
24706
|
const meta = key2?.meta ?? false;
|
|
24586
24707
|
const shift = key2?.shift ?? false;
|
|
@@ -24602,12 +24723,22 @@ function extractPrintableCharacter(str, sequence) {
|
|
|
24602
24723
|
if (isPrintableCharacter(str)) {
|
|
24603
24724
|
return str;
|
|
24604
24725
|
}
|
|
24726
|
+
if (isSinglePrintableSequence(sequence)) {
|
|
24727
|
+
return sequence;
|
|
24728
|
+
}
|
|
24605
24729
|
if (sequence === void 0 || sequence.length <= 1 || sequence[0] !== "\x1B") {
|
|
24606
24730
|
return void 0;
|
|
24607
24731
|
}
|
|
24608
24732
|
const candidate = sequence.slice(1);
|
|
24609
24733
|
return isPrintableCharacter(candidate) ? candidate : void 0;
|
|
24610
24734
|
}
|
|
24735
|
+
function isSinglePrintableSequence(value) {
|
|
24736
|
+
if (value === void 0 || Array.from(value).length !== 1) {
|
|
24737
|
+
return false;
|
|
24738
|
+
}
|
|
24739
|
+
const codePoint = value.codePointAt(0);
|
|
24740
|
+
return codePoint !== void 0 && codePoint >= 32 && codePoint !== 127;
|
|
24741
|
+
}
|
|
24611
24742
|
function isPrintableCharacter(value) {
|
|
24612
24743
|
if (value === void 0 || Array.from(value).length !== 1) {
|
|
24613
24744
|
return false;
|
|
@@ -24615,6 +24746,23 @@ function isPrintableCharacter(value) {
|
|
|
24615
24746
|
const codePoint = value.codePointAt(0);
|
|
24616
24747
|
return codePoint !== void 0 && codePoint >= 32 && codePoint !== 127;
|
|
24617
24748
|
}
|
|
24749
|
+
function controlCharacterToKeypress(sequence) {
|
|
24750
|
+
if (sequence === "") {
|
|
24751
|
+
return { ch: "/", ctrl: true, meta: false, shift: false };
|
|
24752
|
+
}
|
|
24753
|
+
if (sequence !== void 0 && sequence.length === 1) {
|
|
24754
|
+
const code = sequence.charCodeAt(0);
|
|
24755
|
+
if (code >= 1 && code <= 26 && code !== 9 && code !== 10 && code !== 13) {
|
|
24756
|
+
return {
|
|
24757
|
+
name: String.fromCharCode(code + 96),
|
|
24758
|
+
ctrl: true,
|
|
24759
|
+
meta: false,
|
|
24760
|
+
shift: false
|
|
24761
|
+
};
|
|
24762
|
+
}
|
|
24763
|
+
}
|
|
24764
|
+
return void 0;
|
|
24765
|
+
}
|
|
24618
24766
|
function cursorPositionAnsi(x, y) {
|
|
24619
24767
|
return `\x1B[${normalizeCoordinate(y) + 1};${normalizeCoordinate(x) + 1}H`;
|
|
24620
24768
|
}
|
|
@@ -24845,6 +24993,158 @@ var init_dashboard2 = __esm({
|
|
|
24845
24993
|
}
|
|
24846
24994
|
});
|
|
24847
24995
|
|
|
24996
|
+
// packages/design-system/src/explorer/jobs.ts
|
|
24997
|
+
var init_jobs2 = __esm({
|
|
24998
|
+
"packages/design-system/src/explorer/jobs.ts"() {
|
|
24999
|
+
"use strict";
|
|
25000
|
+
}
|
|
25001
|
+
});
|
|
25002
|
+
|
|
25003
|
+
// packages/design-system/src/explorer/layout.ts
|
|
25004
|
+
var init_layout2 = __esm({
|
|
25005
|
+
"packages/design-system/src/explorer/layout.ts"() {
|
|
25006
|
+
"use strict";
|
|
25007
|
+
}
|
|
25008
|
+
});
|
|
25009
|
+
|
|
25010
|
+
// packages/design-system/src/explorer/keymap.ts
|
|
25011
|
+
var init_keymap2 = __esm({
|
|
25012
|
+
"packages/design-system/src/explorer/keymap.ts"() {
|
|
25013
|
+
"use strict";
|
|
25014
|
+
}
|
|
25015
|
+
});
|
|
25016
|
+
|
|
25017
|
+
// packages/design-system/src/explorer/state.ts
|
|
25018
|
+
var REGION_HEADER, REGION_LIST, REGION_DETAIL, REGION_FOOTER, REGION_MODAL, REGION_TOAST, REGION_ALL;
|
|
25019
|
+
var init_state3 = __esm({
|
|
25020
|
+
"packages/design-system/src/explorer/state.ts"() {
|
|
25021
|
+
"use strict";
|
|
25022
|
+
init_keymap2();
|
|
25023
|
+
REGION_HEADER = 1 << 0;
|
|
25024
|
+
REGION_LIST = 1 << 1;
|
|
25025
|
+
REGION_DETAIL = 1 << 2;
|
|
25026
|
+
REGION_FOOTER = 1 << 3;
|
|
25027
|
+
REGION_MODAL = 1 << 4;
|
|
25028
|
+
REGION_TOAST = 1 << 5;
|
|
25029
|
+
REGION_ALL = REGION_HEADER | REGION_LIST | REGION_DETAIL | REGION_FOOTER | REGION_MODAL | REGION_TOAST;
|
|
25030
|
+
}
|
|
25031
|
+
});
|
|
25032
|
+
|
|
25033
|
+
// packages/design-system/src/explorer/theme.ts
|
|
25034
|
+
var init_theme = __esm({
|
|
25035
|
+
"packages/design-system/src/explorer/theme.ts"() {
|
|
25036
|
+
"use strict";
|
|
25037
|
+
}
|
|
25038
|
+
});
|
|
25039
|
+
|
|
25040
|
+
// packages/design-system/src/explorer/render/detail.ts
|
|
25041
|
+
var init_detail = __esm({
|
|
25042
|
+
"packages/design-system/src/explorer/render/detail.ts"() {
|
|
25043
|
+
"use strict";
|
|
25044
|
+
init_theme();
|
|
25045
|
+
}
|
|
25046
|
+
});
|
|
25047
|
+
|
|
25048
|
+
// packages/design-system/src/explorer/render/footer.ts
|
|
25049
|
+
var init_footer2 = __esm({
|
|
25050
|
+
"packages/design-system/src/explorer/render/footer.ts"() {
|
|
25051
|
+
"use strict";
|
|
25052
|
+
init_theme();
|
|
25053
|
+
}
|
|
25054
|
+
});
|
|
25055
|
+
|
|
25056
|
+
// packages/design-system/src/explorer/render/header.ts
|
|
25057
|
+
var init_header = __esm({
|
|
25058
|
+
"packages/design-system/src/explorer/render/header.ts"() {
|
|
25059
|
+
"use strict";
|
|
25060
|
+
init_theme();
|
|
25061
|
+
}
|
|
25062
|
+
});
|
|
25063
|
+
|
|
25064
|
+
// packages/design-system/src/explorer/render/list.ts
|
|
25065
|
+
var init_list = __esm({
|
|
25066
|
+
"packages/design-system/src/explorer/render/list.ts"() {
|
|
25067
|
+
"use strict";
|
|
25068
|
+
init_theme();
|
|
25069
|
+
}
|
|
25070
|
+
});
|
|
25071
|
+
|
|
25072
|
+
// packages/design-system/src/explorer/render/modal.ts
|
|
25073
|
+
var init_modal = __esm({
|
|
25074
|
+
"packages/design-system/src/explorer/render/modal.ts"() {
|
|
25075
|
+
"use strict";
|
|
25076
|
+
init_theme();
|
|
25077
|
+
}
|
|
25078
|
+
});
|
|
25079
|
+
|
|
25080
|
+
// packages/design-system/src/explorer/render/index.ts
|
|
25081
|
+
var init_render2 = __esm({
|
|
25082
|
+
"packages/design-system/src/explorer/render/index.ts"() {
|
|
25083
|
+
"use strict";
|
|
25084
|
+
init_layout2();
|
|
25085
|
+
init_state3();
|
|
25086
|
+
init_theme();
|
|
25087
|
+
init_detail();
|
|
25088
|
+
init_footer2();
|
|
25089
|
+
init_header();
|
|
25090
|
+
init_list();
|
|
25091
|
+
init_modal();
|
|
25092
|
+
init_detail();
|
|
25093
|
+
init_footer2();
|
|
25094
|
+
init_header();
|
|
25095
|
+
init_list();
|
|
25096
|
+
init_modal();
|
|
25097
|
+
}
|
|
25098
|
+
});
|
|
25099
|
+
|
|
25100
|
+
// packages/design-system/src/explorer/actions.ts
|
|
25101
|
+
var init_actions = __esm({
|
|
25102
|
+
"packages/design-system/src/explorer/actions.ts"() {
|
|
25103
|
+
"use strict";
|
|
25104
|
+
}
|
|
25105
|
+
});
|
|
25106
|
+
|
|
25107
|
+
// packages/design-system/src/explorer/filter.ts
|
|
25108
|
+
var init_filter = __esm({
|
|
25109
|
+
"packages/design-system/src/explorer/filter.ts"() {
|
|
25110
|
+
"use strict";
|
|
25111
|
+
}
|
|
25112
|
+
});
|
|
25113
|
+
|
|
25114
|
+
// packages/design-system/src/explorer/reducer.ts
|
|
25115
|
+
var init_reducer = __esm({
|
|
25116
|
+
"packages/design-system/src/explorer/reducer.ts"() {
|
|
25117
|
+
"use strict";
|
|
25118
|
+
init_actions();
|
|
25119
|
+
init_filter();
|
|
25120
|
+
init_state3();
|
|
25121
|
+
}
|
|
25122
|
+
});
|
|
25123
|
+
|
|
25124
|
+
// packages/design-system/src/explorer/runtime.ts
|
|
25125
|
+
var init_runtime3 = __esm({
|
|
25126
|
+
"packages/design-system/src/explorer/runtime.ts"() {
|
|
25127
|
+
"use strict";
|
|
25128
|
+
init_buffer();
|
|
25129
|
+
init_terminal();
|
|
25130
|
+
init_jobs2();
|
|
25131
|
+
init_layout2();
|
|
25132
|
+
init_render2();
|
|
25133
|
+
init_reducer();
|
|
25134
|
+
init_state3();
|
|
25135
|
+
}
|
|
25136
|
+
});
|
|
25137
|
+
|
|
25138
|
+
// packages/design-system/src/explorer/index.ts
|
|
25139
|
+
var init_explorer = __esm({
|
|
25140
|
+
"packages/design-system/src/explorer/index.ts"() {
|
|
25141
|
+
"use strict";
|
|
25142
|
+
init_runtime3();
|
|
25143
|
+
init_state3();
|
|
25144
|
+
init_keymap2();
|
|
25145
|
+
}
|
|
25146
|
+
});
|
|
25147
|
+
|
|
24848
25148
|
// packages/design-system/src/prompts/primitives/cancel.ts
|
|
24849
25149
|
import chalk9 from "chalk";
|
|
24850
25150
|
import { isCancel } from "@clack/prompts";
|
|
@@ -24936,7 +25236,7 @@ var init_prompts2 = __esm({
|
|
|
24936
25236
|
});
|
|
24937
25237
|
|
|
24938
25238
|
// packages/design-system/src/prompts/theme.ts
|
|
24939
|
-
var
|
|
25239
|
+
var init_theme2 = __esm({
|
|
24940
25240
|
"packages/design-system/src/prompts/theme.ts"() {
|
|
24941
25241
|
"use strict";
|
|
24942
25242
|
init_colors();
|
|
@@ -24983,9 +25283,11 @@ var init_src13 = __esm({
|
|
|
24983
25283
|
init_acp();
|
|
24984
25284
|
init_dashboard2();
|
|
24985
25285
|
init_dashboard2();
|
|
25286
|
+
init_explorer();
|
|
25287
|
+
init_explorer();
|
|
24986
25288
|
init_prompts2();
|
|
24987
25289
|
init_prompts2();
|
|
24988
|
-
|
|
25290
|
+
init_theme2();
|
|
24989
25291
|
init_static();
|
|
24990
25292
|
init_static();
|
|
24991
25293
|
init_terminal_markdown();
|
|
@@ -26680,8 +26982,8 @@ async function runServiceInstall(definition, context) {
|
|
|
26680
26982
|
return true;
|
|
26681
26983
|
}
|
|
26682
26984
|
const platformSteps = filterStepsByPlatform(definition.steps, context.platform);
|
|
26683
|
-
for (const
|
|
26684
|
-
await runInstallStep(
|
|
26985
|
+
for (const step2 of platformSteps) {
|
|
26986
|
+
await runInstallStep(step2, context);
|
|
26685
26987
|
}
|
|
26686
26988
|
await definition.check.run(checkContext);
|
|
26687
26989
|
if (definition.postChecks) {
|
|
@@ -26694,8 +26996,8 @@ async function runServiceInstall(definition, context) {
|
|
|
26694
26996
|
);
|
|
26695
26997
|
return true;
|
|
26696
26998
|
}
|
|
26697
|
-
function describeInstallCommand(
|
|
26698
|
-
return `[${
|
|
26999
|
+
function describeInstallCommand(step2) {
|
|
27000
|
+
return `[${step2.id}] ${formatCommand(step2.command, step2.args)}`;
|
|
26699
27001
|
}
|
|
26700
27002
|
function formatCommand(command, args) {
|
|
26701
27003
|
return [command, ...args.map(quoteIfNeeded)].join(" ");
|
|
@@ -26711,24 +27013,24 @@ function quoteIfNeeded(value) {
|
|
|
26711
27013
|
}
|
|
26712
27014
|
function filterStepsByPlatform(steps, platform) {
|
|
26713
27015
|
return steps.filter(
|
|
26714
|
-
(
|
|
27016
|
+
(step2) => !step2.platforms || step2.platforms.includes(platform)
|
|
26715
27017
|
);
|
|
26716
27018
|
}
|
|
26717
27019
|
function logInstallDryRun(definition, context) {
|
|
26718
27020
|
context.logger(`Dry run: would install ${definition.summary}.`);
|
|
26719
27021
|
const platformSteps = filterStepsByPlatform(definition.steps, context.platform);
|
|
26720
|
-
for (const
|
|
26721
|
-
context.logger(`Dry run: ${describeInstallCommand(
|
|
27022
|
+
for (const step2 of platformSteps) {
|
|
27023
|
+
context.logger(`Dry run: ${describeInstallCommand(step2)}`);
|
|
26722
27024
|
}
|
|
26723
27025
|
}
|
|
26724
|
-
async function runInstallStep(
|
|
26725
|
-
context.logger(`Running ${describeInstallCommand(
|
|
26726
|
-
const result = await context.runCommand(
|
|
27026
|
+
async function runInstallStep(step2, context) {
|
|
27027
|
+
context.logger(`Running ${describeInstallCommand(step2)}`);
|
|
27028
|
+
const result = await context.runCommand(step2.command, step2.args);
|
|
26727
27029
|
if (result.exitCode !== 0) {
|
|
26728
27030
|
const stderr = result.stderr.trim();
|
|
26729
27031
|
const suffix = stderr.length > 0 ? `: ${stderr}` : "";
|
|
26730
27032
|
throw new Error(
|
|
26731
|
-
`${describeInstallCommand(
|
|
27033
|
+
`${describeInstallCommand(step2)} failed with exit code ${result.exitCode}${suffix}`
|
|
26732
27034
|
);
|
|
26733
27035
|
}
|
|
26734
27036
|
}
|
|
@@ -29756,7 +30058,7 @@ function formatError(err) {
|
|
|
29756
30058
|
}
|
|
29757
30059
|
}
|
|
29758
30060
|
|
|
29759
|
-
// packages/
|
|
30061
|
+
// packages/acp-telemetry/src/redact.ts
|
|
29760
30062
|
var MAX_STRING_BYTES = 65536;
|
|
29761
30063
|
var MAX_JSON_BYTES = 262144;
|
|
29762
30064
|
var BINARY_SCAN_BYTES = 1024;
|
|
@@ -29795,6 +30097,220 @@ function redactLeaf(value) {
|
|
|
29795
30097
|
return value;
|
|
29796
30098
|
}
|
|
29797
30099
|
|
|
30100
|
+
// packages/acp-telemetry/src/trace.ts
|
|
30101
|
+
function acpToTrace(ctx) {
|
|
30102
|
+
const spawnCtx = ctx;
|
|
30103
|
+
return {
|
|
30104
|
+
root: {
|
|
30105
|
+
name: `agent:${ctx.agent}:${ctx.model ?? "?"}`,
|
|
30106
|
+
kind: "agent",
|
|
30107
|
+
input: redact({
|
|
30108
|
+
prompt: ctx.prompt,
|
|
30109
|
+
mode: ctx.mode,
|
|
30110
|
+
cwd: ctx.cwd
|
|
30111
|
+
}),
|
|
30112
|
+
output: redact(accumulateAgentOutput(ctx.events)),
|
|
30113
|
+
metadata: {
|
|
30114
|
+
sessionId: ctx.sessionId,
|
|
30115
|
+
threadId: ctx.threadId,
|
|
30116
|
+
...spawnCtx.metadata
|
|
30117
|
+
},
|
|
30118
|
+
metrics: buildMetrics(ctx),
|
|
30119
|
+
children: logToolSpans(ctx.events)
|
|
30120
|
+
}
|
|
30121
|
+
};
|
|
30122
|
+
}
|
|
30123
|
+
function logToolSpans(events) {
|
|
30124
|
+
const spans = [];
|
|
30125
|
+
for (const [index, event] of events.entries()) {
|
|
30126
|
+
const toolCall = asToolCall(event);
|
|
30127
|
+
if (toolCall === void 0) {
|
|
30128
|
+
continue;
|
|
30129
|
+
}
|
|
30130
|
+
const metadata = collectToolMeta(events, index, readString6(toolCall.toolCallId));
|
|
30131
|
+
spans.push({
|
|
30132
|
+
name: `tool_call:${readString6(toolCall.kind) ?? "unknown"}`,
|
|
30133
|
+
kind: "tool",
|
|
30134
|
+
input: redact(readToolInput(toolCall)),
|
|
30135
|
+
output: redact(assembleToolOutput(events, index, readString6(toolCall.toolCallId))),
|
|
30136
|
+
...metadata ? { metadata } : {},
|
|
30137
|
+
...readSpanTimestamps(metadata),
|
|
30138
|
+
children: []
|
|
30139
|
+
});
|
|
30140
|
+
}
|
|
30141
|
+
return spans;
|
|
30142
|
+
}
|
|
30143
|
+
function collectToolMeta(events, toolCallIndex, toolCallId) {
|
|
30144
|
+
const merged = {};
|
|
30145
|
+
const startMeta = asRecord2(asRecord2(events[toolCallIndex])?._meta);
|
|
30146
|
+
if (startMeta) {
|
|
30147
|
+
for (const [key2, value] of Object.entries(startMeta)) {
|
|
30148
|
+
merged[key2 === "ts" ? "startTs" : key2] = value;
|
|
30149
|
+
}
|
|
30150
|
+
}
|
|
30151
|
+
for (const event of events.slice(toolCallIndex + 1)) {
|
|
30152
|
+
const update = asToolCallUpdate(event);
|
|
30153
|
+
if (update === void 0) continue;
|
|
30154
|
+
if (toolCallId !== void 0 && update.toolCallId !== toolCallId) continue;
|
|
30155
|
+
const updateMeta = asRecord2(update._meta);
|
|
30156
|
+
if (!updateMeta) continue;
|
|
30157
|
+
for (const [key2, value] of Object.entries(updateMeta)) {
|
|
30158
|
+
merged[key2 === "ts" ? "endTs" : key2] = value;
|
|
30159
|
+
}
|
|
30160
|
+
}
|
|
30161
|
+
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
30162
|
+
}
|
|
30163
|
+
function accumulateAgentOutput(events) {
|
|
30164
|
+
let output = "";
|
|
30165
|
+
for (const event of events) {
|
|
30166
|
+
const record = asRecord2(event);
|
|
30167
|
+
if (record === void 0) {
|
|
30168
|
+
continue;
|
|
30169
|
+
}
|
|
30170
|
+
if (record.event === "agent_message") {
|
|
30171
|
+
output += readString6(record.text) ?? "";
|
|
30172
|
+
continue;
|
|
30173
|
+
}
|
|
30174
|
+
if (record.sessionUpdate === "agent_message_chunk") {
|
|
30175
|
+
output += readContentText(record.content);
|
|
30176
|
+
}
|
|
30177
|
+
}
|
|
30178
|
+
return output;
|
|
30179
|
+
}
|
|
30180
|
+
function assembleToolOutput(events, toolCallIndex, toolCallId) {
|
|
30181
|
+
const outputs = [];
|
|
30182
|
+
let text5 = "";
|
|
30183
|
+
for (const event of events.slice(toolCallIndex + 1)) {
|
|
30184
|
+
const update = asToolCallUpdate(event);
|
|
30185
|
+
if (update === void 0) {
|
|
30186
|
+
continue;
|
|
30187
|
+
}
|
|
30188
|
+
if (toolCallId !== void 0 && update.toolCallId !== toolCallId) {
|
|
30189
|
+
continue;
|
|
30190
|
+
}
|
|
30191
|
+
if (Object.hasOwn(update, "rawOutput")) {
|
|
30192
|
+
outputs.push(update.rawOutput);
|
|
30193
|
+
}
|
|
30194
|
+
const contentText = readContentText(update.content);
|
|
30195
|
+
if (contentText.length > 0) {
|
|
30196
|
+
text5 += contentText;
|
|
30197
|
+
}
|
|
30198
|
+
}
|
|
30199
|
+
if (outputs.length === 0) {
|
|
30200
|
+
return text5;
|
|
30201
|
+
}
|
|
30202
|
+
if (text5.length > 0) {
|
|
30203
|
+
outputs.push(text5);
|
|
30204
|
+
}
|
|
30205
|
+
return outputs.length === 1 ? outputs[0] : outputs;
|
|
30206
|
+
}
|
|
30207
|
+
function buildMetrics(ctx) {
|
|
30208
|
+
const usage = ctx.usage;
|
|
30209
|
+
const metrics = {};
|
|
30210
|
+
const promptTokens = readNumber(usage.prompt_tokens) ?? readNumber(usage.inputTokens);
|
|
30211
|
+
const completionTokens = readNumber(usage.completion_tokens) ?? readNumber(usage.outputTokens);
|
|
30212
|
+
addMetric(metrics, "prompt_tokens", promptTokens);
|
|
30213
|
+
addMetric(metrics, "completion_tokens", completionTokens);
|
|
30214
|
+
addMetric(
|
|
30215
|
+
metrics,
|
|
30216
|
+
"tokens",
|
|
30217
|
+
readNumber(usage.tokens) ?? sumIfPresent(promptTokens, completionTokens)
|
|
30218
|
+
);
|
|
30219
|
+
addMetric(
|
|
30220
|
+
metrics,
|
|
30221
|
+
"prompt_cached_tokens",
|
|
30222
|
+
readNumber(usage.prompt_cached_tokens) ?? readNumber(usage.cachedTokens)
|
|
30223
|
+
);
|
|
30224
|
+
addMetric(
|
|
30225
|
+
metrics,
|
|
30226
|
+
"prompt_cache_creation_tokens",
|
|
30227
|
+
readNumber(usage.prompt_cache_creation_tokens)
|
|
30228
|
+
);
|
|
30229
|
+
addMetric(metrics, "durationMs", readNumber(usage.durationMs));
|
|
30230
|
+
return metrics;
|
|
30231
|
+
}
|
|
30232
|
+
function asToolCall(event) {
|
|
30233
|
+
const record = asRecord2(event);
|
|
30234
|
+
return record?.sessionUpdate === "tool_call" ? record : void 0;
|
|
30235
|
+
}
|
|
30236
|
+
function asToolCallUpdate(event) {
|
|
30237
|
+
const record = asRecord2(event);
|
|
30238
|
+
return record?.sessionUpdate === "tool_call_update" ? record : void 0;
|
|
30239
|
+
}
|
|
30240
|
+
function readToolInput(toolCall) {
|
|
30241
|
+
if (Object.hasOwn(toolCall, "input")) {
|
|
30242
|
+
return toolCall.input;
|
|
30243
|
+
}
|
|
30244
|
+
return toolCall.rawInput;
|
|
30245
|
+
}
|
|
30246
|
+
function readContentText(value) {
|
|
30247
|
+
if (Array.isArray(value)) {
|
|
30248
|
+
return value.map(readContentText).join("");
|
|
30249
|
+
}
|
|
30250
|
+
const record = asRecord2(value);
|
|
30251
|
+
if (record === void 0 || record.type !== "text") {
|
|
30252
|
+
return "";
|
|
30253
|
+
}
|
|
30254
|
+
return readString6(record.text) ?? "";
|
|
30255
|
+
}
|
|
30256
|
+
function readSpanTimestamps(metadata) {
|
|
30257
|
+
if (metadata === void 0) {
|
|
30258
|
+
return {};
|
|
30259
|
+
}
|
|
30260
|
+
const startTs = readNumber(metadata.startTs);
|
|
30261
|
+
const endTs = readNumber(metadata.endTs);
|
|
30262
|
+
return {
|
|
30263
|
+
...startTs !== void 0 ? { startTs } : {},
|
|
30264
|
+
...endTs !== void 0 ? { endTs } : {}
|
|
30265
|
+
};
|
|
30266
|
+
}
|
|
30267
|
+
function asRecord2(value) {
|
|
30268
|
+
return typeof value === "object" && value !== null ? value : void 0;
|
|
30269
|
+
}
|
|
30270
|
+
function readString6(value) {
|
|
30271
|
+
return typeof value === "string" ? value : void 0;
|
|
30272
|
+
}
|
|
30273
|
+
function readNumber(value) {
|
|
30274
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
30275
|
+
}
|
|
30276
|
+
function addMetric(metrics, key2, value) {
|
|
30277
|
+
if (value !== void 0) {
|
|
30278
|
+
metrics[key2] = value;
|
|
30279
|
+
}
|
|
30280
|
+
}
|
|
30281
|
+
function sumIfPresent(left, right) {
|
|
30282
|
+
return left !== void 0 && right !== void 0 ? left + right : void 0;
|
|
30283
|
+
}
|
|
30284
|
+
|
|
30285
|
+
// packages/acp-telemetry/src/emit-braintrust.ts
|
|
30286
|
+
function emitToBraintrust(trace, parent) {
|
|
30287
|
+
const root = parent.startSpan({ name: trace.root.name, type: "task" });
|
|
30288
|
+
try {
|
|
30289
|
+
emitSpan(root, trace.root);
|
|
30290
|
+
} finally {
|
|
30291
|
+
root.end();
|
|
30292
|
+
}
|
|
30293
|
+
}
|
|
30294
|
+
function emitSpan(span, traceSpan) {
|
|
30295
|
+
span.log(toBraintrustLogEvent(traceSpan));
|
|
30296
|
+
for (const child of traceSpan.children) {
|
|
30297
|
+
const childSpan = span.startSpan({ name: child.name, type: "tool" });
|
|
30298
|
+
try {
|
|
30299
|
+
emitSpan(childSpan, child);
|
|
30300
|
+
} finally {
|
|
30301
|
+
childSpan.end();
|
|
30302
|
+
}
|
|
30303
|
+
}
|
|
30304
|
+
}
|
|
30305
|
+
function toBraintrustLogEvent(span) {
|
|
30306
|
+
return {
|
|
30307
|
+
...Object.hasOwn(span, "input") ? { input: span.input } : {},
|
|
30308
|
+
...Object.hasOwn(span, "output") ? { output: span.output } : {},
|
|
30309
|
+
...Object.hasOwn(span, "metadata") ? { metadata: span.metadata } : {},
|
|
30310
|
+
...Object.hasOwn(span, "metrics") ? { metrics: span.metrics } : {}
|
|
30311
|
+
};
|
|
30312
|
+
}
|
|
30313
|
+
|
|
29798
30314
|
// packages/braintrust/src/row-builder.ts
|
|
29799
30315
|
function makePipelineRowState(client) {
|
|
29800
30316
|
const rows = /* @__PURE__ */ new Map();
|
|
@@ -29950,8 +30466,8 @@ async function openCurrentChildSpan(client, args, ctx) {
|
|
|
29950
30466
|
}
|
|
29951
30467
|
}
|
|
29952
30468
|
function buildPipelineCompletionLog(started, completed) {
|
|
29953
|
-
const startRecord =
|
|
29954
|
-
const completeRecord =
|
|
30469
|
+
const startRecord = asRecord3(started) ?? {};
|
|
30470
|
+
const completeRecord = asRecord3(completed) ?? {};
|
|
29955
30471
|
return {
|
|
29956
30472
|
input: redact({
|
|
29957
30473
|
step_name: readPipelineStep(started),
|
|
@@ -29974,7 +30490,7 @@ function buildPipelineCompletionLog(started, completed) {
|
|
|
29974
30490
|
};
|
|
29975
30491
|
}
|
|
29976
30492
|
function buildSuperintendentLog(role, result) {
|
|
29977
|
-
const record =
|
|
30493
|
+
const record = asRecord3(result);
|
|
29978
30494
|
const event = {
|
|
29979
30495
|
input: redact(record?.input),
|
|
29980
30496
|
output: redact(record?.output ?? result)
|
|
@@ -29988,7 +30504,7 @@ function buildSuperintendentLog(role, result) {
|
|
|
29988
30504
|
return event;
|
|
29989
30505
|
}
|
|
29990
30506
|
function buildExperimentLog(row, entry) {
|
|
29991
|
-
const entryRecord =
|
|
30507
|
+
const entryRecord = asRecord3(entry) ?? {};
|
|
29992
30508
|
const scores = buildExperimentScores(row.baseline, entry.scores);
|
|
29993
30509
|
const metrics = { ...row.metrics };
|
|
29994
30510
|
if (Number.isFinite(entry.durationMs)) {
|
|
@@ -30017,12 +30533,12 @@ function buildPipelineMetrics(progress) {
|
|
|
30017
30533
|
const metrics = {};
|
|
30018
30534
|
const usage = progress.usage;
|
|
30019
30535
|
if (usage !== void 0) {
|
|
30020
|
-
|
|
30021
|
-
|
|
30022
|
-
|
|
30023
|
-
|
|
30536
|
+
addMetric2(metrics, "prompt_tokens", usage.inputTokens);
|
|
30537
|
+
addMetric2(metrics, "completion_tokens", usage.outputTokens);
|
|
30538
|
+
addMetric2(metrics, "tokens", usage.inputTokens + usage.outputTokens);
|
|
30539
|
+
addMetric2(metrics, "prompt_cached_tokens", usage.cachedTokens);
|
|
30024
30540
|
}
|
|
30025
|
-
|
|
30541
|
+
addMetric2(metrics, "durationMs", progress.durationMs);
|
|
30026
30542
|
return metrics;
|
|
30027
30543
|
}
|
|
30028
30544
|
function buildExperimentScores(baseline, scores) {
|
|
@@ -30099,7 +30615,7 @@ function asSpanParent(value) {
|
|
|
30099
30615
|
}
|
|
30100
30616
|
return span;
|
|
30101
30617
|
}
|
|
30102
|
-
function
|
|
30618
|
+
function asRecord3(value) {
|
|
30103
30619
|
return typeof value === "object" && value !== null ? value : void 0;
|
|
30104
30620
|
}
|
|
30105
30621
|
function readFirstString(record, keys) {
|
|
@@ -30114,7 +30630,7 @@ function readFirstValue(record, keys) {
|
|
|
30114
30630
|
}
|
|
30115
30631
|
return void 0;
|
|
30116
30632
|
}
|
|
30117
|
-
function
|
|
30633
|
+
function addMetric2(metrics, key2, value) {
|
|
30118
30634
|
if (value !== void 0 && Number.isFinite(value)) {
|
|
30119
30635
|
metrics[key2] = value;
|
|
30120
30636
|
}
|
|
@@ -30166,197 +30682,6 @@ function createPipelineCallbacks(client) {
|
|
|
30166
30682
|
};
|
|
30167
30683
|
}
|
|
30168
30684
|
|
|
30169
|
-
// packages/braintrust/src/span-builder.ts
|
|
30170
|
-
async function logSpawnSession(client, ctx) {
|
|
30171
|
-
try {
|
|
30172
|
-
const { currentSpan } = await import("braintrust");
|
|
30173
|
-
const agentSpan = asSpanParent2(currentSpan()).startSpan({
|
|
30174
|
-
name: `agent:${ctx.agent}:${ctx.model ?? "?"}`,
|
|
30175
|
-
type: "task"
|
|
30176
|
-
});
|
|
30177
|
-
try {
|
|
30178
|
-
logToolSpans(agentSpan, ctx.events);
|
|
30179
|
-
agentSpan.log({
|
|
30180
|
-
input: redact({
|
|
30181
|
-
prompt: ctx.prompt,
|
|
30182
|
-
mode: ctx.mode,
|
|
30183
|
-
cwd: ctx.cwd
|
|
30184
|
-
}),
|
|
30185
|
-
output: redact(accumulateAgentOutput(ctx.events)),
|
|
30186
|
-
metadata: {
|
|
30187
|
-
sessionId: ctx.sessionId,
|
|
30188
|
-
threadId: ctx.threadId,
|
|
30189
|
-
...ctx.metadata
|
|
30190
|
-
},
|
|
30191
|
-
metrics: buildMetrics(ctx)
|
|
30192
|
-
});
|
|
30193
|
-
} finally {
|
|
30194
|
-
agentSpan.end();
|
|
30195
|
-
}
|
|
30196
|
-
} catch (err) {
|
|
30197
|
-
client.recordError(err, "log spawn session");
|
|
30198
|
-
}
|
|
30199
|
-
}
|
|
30200
|
-
function logToolSpans(agentSpan, events) {
|
|
30201
|
-
for (const [index, event] of events.entries()) {
|
|
30202
|
-
const toolCall = asToolCall(event);
|
|
30203
|
-
if (toolCall === void 0) {
|
|
30204
|
-
continue;
|
|
30205
|
-
}
|
|
30206
|
-
const toolSpan = agentSpan.startSpan({
|
|
30207
|
-
name: `tool_call:${readString6(toolCall.kind) ?? "unknown"}`,
|
|
30208
|
-
type: "tool"
|
|
30209
|
-
});
|
|
30210
|
-
try {
|
|
30211
|
-
const metadata = collectToolMeta(events, index, readString6(toolCall.toolCallId));
|
|
30212
|
-
toolSpan.log({
|
|
30213
|
-
input: redact(readToolInput(toolCall)),
|
|
30214
|
-
output: redact(assembleToolOutput(events, index, readString6(toolCall.toolCallId))),
|
|
30215
|
-
...metadata ? { metadata } : {}
|
|
30216
|
-
});
|
|
30217
|
-
} finally {
|
|
30218
|
-
toolSpan.end();
|
|
30219
|
-
}
|
|
30220
|
-
}
|
|
30221
|
-
}
|
|
30222
|
-
function collectToolMeta(events, toolCallIndex, toolCallId) {
|
|
30223
|
-
const merged = {};
|
|
30224
|
-
const startMeta = asRecord3(asRecord3(events[toolCallIndex])?._meta);
|
|
30225
|
-
if (startMeta) {
|
|
30226
|
-
for (const [key2, value] of Object.entries(startMeta)) {
|
|
30227
|
-
merged[key2 === "ts" ? "startTs" : key2] = value;
|
|
30228
|
-
}
|
|
30229
|
-
}
|
|
30230
|
-
for (const event of events.slice(toolCallIndex + 1)) {
|
|
30231
|
-
const update = asToolCallUpdate(event);
|
|
30232
|
-
if (update === void 0) continue;
|
|
30233
|
-
if (toolCallId !== void 0 && update.toolCallId !== toolCallId) continue;
|
|
30234
|
-
const updateMeta = asRecord3(update._meta);
|
|
30235
|
-
if (!updateMeta) continue;
|
|
30236
|
-
for (const [key2, value] of Object.entries(updateMeta)) {
|
|
30237
|
-
merged[key2 === "ts" ? "endTs" : key2] = value;
|
|
30238
|
-
}
|
|
30239
|
-
}
|
|
30240
|
-
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
30241
|
-
}
|
|
30242
|
-
function accumulateAgentOutput(events) {
|
|
30243
|
-
let output = "";
|
|
30244
|
-
for (const event of events) {
|
|
30245
|
-
const record = asRecord3(event);
|
|
30246
|
-
if (record === void 0) {
|
|
30247
|
-
continue;
|
|
30248
|
-
}
|
|
30249
|
-
if (record.event === "agent_message") {
|
|
30250
|
-
output += readString6(record.text) ?? "";
|
|
30251
|
-
continue;
|
|
30252
|
-
}
|
|
30253
|
-
if (record.sessionUpdate === "agent_message_chunk") {
|
|
30254
|
-
output += readContentText(record.content);
|
|
30255
|
-
}
|
|
30256
|
-
}
|
|
30257
|
-
return output;
|
|
30258
|
-
}
|
|
30259
|
-
function assembleToolOutput(events, toolCallIndex, toolCallId) {
|
|
30260
|
-
const outputs = [];
|
|
30261
|
-
let text5 = "";
|
|
30262
|
-
for (const event of events.slice(toolCallIndex + 1)) {
|
|
30263
|
-
const update = asToolCallUpdate(event);
|
|
30264
|
-
if (update === void 0) {
|
|
30265
|
-
continue;
|
|
30266
|
-
}
|
|
30267
|
-
if (toolCallId !== void 0 && update.toolCallId !== toolCallId) {
|
|
30268
|
-
continue;
|
|
30269
|
-
}
|
|
30270
|
-
if (Object.hasOwn(update, "rawOutput")) {
|
|
30271
|
-
outputs.push(update.rawOutput);
|
|
30272
|
-
}
|
|
30273
|
-
const contentText = readContentText(update.content);
|
|
30274
|
-
if (contentText.length > 0) {
|
|
30275
|
-
text5 += contentText;
|
|
30276
|
-
}
|
|
30277
|
-
}
|
|
30278
|
-
if (outputs.length === 0) {
|
|
30279
|
-
return text5;
|
|
30280
|
-
}
|
|
30281
|
-
if (text5.length > 0) {
|
|
30282
|
-
outputs.push(text5);
|
|
30283
|
-
}
|
|
30284
|
-
return outputs.length === 1 ? outputs[0] : outputs;
|
|
30285
|
-
}
|
|
30286
|
-
function buildMetrics(ctx) {
|
|
30287
|
-
const usage = ctx.usage;
|
|
30288
|
-
const metrics = {};
|
|
30289
|
-
const promptTokens = readNumber(usage.prompt_tokens) ?? readNumber(usage.inputTokens);
|
|
30290
|
-
const completionTokens = readNumber(usage.completion_tokens) ?? readNumber(usage.outputTokens);
|
|
30291
|
-
addMetric2(metrics, "prompt_tokens", promptTokens);
|
|
30292
|
-
addMetric2(metrics, "completion_tokens", completionTokens);
|
|
30293
|
-
addMetric2(
|
|
30294
|
-
metrics,
|
|
30295
|
-
"tokens",
|
|
30296
|
-
readNumber(usage.tokens) ?? sumIfPresent(promptTokens, completionTokens)
|
|
30297
|
-
);
|
|
30298
|
-
addMetric2(
|
|
30299
|
-
metrics,
|
|
30300
|
-
"prompt_cached_tokens",
|
|
30301
|
-
readNumber(usage.prompt_cached_tokens) ?? readNumber(usage.cachedTokens)
|
|
30302
|
-
);
|
|
30303
|
-
addMetric2(
|
|
30304
|
-
metrics,
|
|
30305
|
-
"prompt_cache_creation_tokens",
|
|
30306
|
-
readNumber(usage.prompt_cache_creation_tokens)
|
|
30307
|
-
);
|
|
30308
|
-
addMetric2(metrics, "durationMs", readNumber(usage.durationMs));
|
|
30309
|
-
return metrics;
|
|
30310
|
-
}
|
|
30311
|
-
function asSpanParent2(value) {
|
|
30312
|
-
const span = value;
|
|
30313
|
-
if (span === void 0 || typeof span.startSpan !== "function") {
|
|
30314
|
-
throw new Error("Braintrust current span unavailable");
|
|
30315
|
-
}
|
|
30316
|
-
return span;
|
|
30317
|
-
}
|
|
30318
|
-
function asToolCall(event) {
|
|
30319
|
-
const record = asRecord3(event);
|
|
30320
|
-
return record?.sessionUpdate === "tool_call" ? record : void 0;
|
|
30321
|
-
}
|
|
30322
|
-
function asToolCallUpdate(event) {
|
|
30323
|
-
const record = asRecord3(event);
|
|
30324
|
-
return record?.sessionUpdate === "tool_call_update" ? record : void 0;
|
|
30325
|
-
}
|
|
30326
|
-
function readToolInput(toolCall) {
|
|
30327
|
-
if (Object.hasOwn(toolCall, "input")) {
|
|
30328
|
-
return toolCall.input;
|
|
30329
|
-
}
|
|
30330
|
-
return toolCall.rawInput;
|
|
30331
|
-
}
|
|
30332
|
-
function readContentText(value) {
|
|
30333
|
-
if (Array.isArray(value)) {
|
|
30334
|
-
return value.map(readContentText).join("");
|
|
30335
|
-
}
|
|
30336
|
-
const record = asRecord3(value);
|
|
30337
|
-
if (record === void 0 || record.type !== "text") {
|
|
30338
|
-
return "";
|
|
30339
|
-
}
|
|
30340
|
-
return readString6(record.text) ?? "";
|
|
30341
|
-
}
|
|
30342
|
-
function asRecord3(value) {
|
|
30343
|
-
return typeof value === "object" && value !== null ? value : void 0;
|
|
30344
|
-
}
|
|
30345
|
-
function readString6(value) {
|
|
30346
|
-
return typeof value === "string" ? value : void 0;
|
|
30347
|
-
}
|
|
30348
|
-
function readNumber(value) {
|
|
30349
|
-
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
30350
|
-
}
|
|
30351
|
-
function addMetric2(metrics, key2, value) {
|
|
30352
|
-
if (value !== void 0) {
|
|
30353
|
-
metrics[key2] = value;
|
|
30354
|
-
}
|
|
30355
|
-
}
|
|
30356
|
-
function sumIfPresent(left, right) {
|
|
30357
|
-
return left !== void 0 && right !== void 0 ? left + right : void 0;
|
|
30358
|
-
}
|
|
30359
|
-
|
|
30360
30685
|
// packages/braintrust/src/adapters/spawn.ts
|
|
30361
30686
|
function createSpawnMiddleware(client) {
|
|
30362
30687
|
return async (ctx, next) => {
|
|
@@ -30370,7 +30695,12 @@ function createSpawnMiddleware(client) {
|
|
|
30370
30695
|
};
|
|
30371
30696
|
throw err;
|
|
30372
30697
|
} finally {
|
|
30373
|
-
|
|
30698
|
+
try {
|
|
30699
|
+
const { currentSpan } = await import("braintrust");
|
|
30700
|
+
emitToBraintrust(acpToTrace(ctx), currentSpan());
|
|
30701
|
+
} catch (err) {
|
|
30702
|
+
client.recordError(err, "log spawn session");
|
|
30703
|
+
}
|
|
30374
30704
|
}
|
|
30375
30705
|
};
|
|
30376
30706
|
}
|
|
@@ -30401,7 +30731,7 @@ function createSuperintendentCallbacks(client) {
|
|
|
30401
30731
|
async function logFailedRole(client, role, error2, name) {
|
|
30402
30732
|
try {
|
|
30403
30733
|
const { currentSpan } = await import("braintrust");
|
|
30404
|
-
const span =
|
|
30734
|
+
const span = asSpanParent2(currentSpan()).startSpan({
|
|
30405
30735
|
name: name === void 0 ? `role:${role}:failed` : `role:${role}:${name}:failed`,
|
|
30406
30736
|
type: "task"
|
|
30407
30737
|
});
|
|
@@ -30423,7 +30753,7 @@ async function logFailedRole(client, role, error2, name) {
|
|
|
30423
30753
|
client.recordError(err, `superintendent ${role} failed`);
|
|
30424
30754
|
}
|
|
30425
30755
|
}
|
|
30426
|
-
function
|
|
30756
|
+
function asSpanParent2(value) {
|
|
30427
30757
|
const span = value;
|
|
30428
30758
|
if (span === void 0 || typeof span.startSpan !== "function") {
|
|
30429
30759
|
throw new Error("Braintrust current span unavailable");
|