perchai-cli 2.4.37 → 2.4.40
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/perch.mjs +100 -10
- package/package.json +1 -1
package/dist/perch.mjs
CHANGED
|
@@ -86721,6 +86721,7 @@ function truncateHistoryLine(value, max2) {
|
|
|
86721
86721
|
}
|
|
86722
86722
|
var init_operatorTruth = __esm({
|
|
86723
86723
|
"features/perchTerminal/runtime/operatorTruth.ts"() {
|
|
86724
|
+
"use strict";
|
|
86724
86725
|
}
|
|
86725
86726
|
});
|
|
86726
86727
|
|
|
@@ -138640,7 +138641,6 @@ function offSandboxEvent(runId, handler) {
|
|
|
138640
138641
|
var LOCAL_WORKSPACE_ACCESS_UNAVAILABLE;
|
|
138641
138642
|
var init_bridge = __esm({
|
|
138642
138643
|
"features/perchTerminal/desktop/bridge.ts"() {
|
|
138643
|
-
"use strict";
|
|
138644
138644
|
LOCAL_WORKSPACE_ACCESS_UNAVAILABLE = "Local workspace access is unavailable. Open Perch Desktop or update the app.";
|
|
138645
138645
|
}
|
|
138646
138646
|
});
|
|
@@ -205515,13 +205515,13 @@ var init_spawnWorker = __esm({
|
|
|
205515
205515
|
if (workerId && customSpec && !resolveWorkerManifest(workerId)) {
|
|
205516
205516
|
workerId = "";
|
|
205517
205517
|
}
|
|
205518
|
-
let
|
|
205518
|
+
let displayTitle;
|
|
205519
205519
|
if (!workerId && customSpec) {
|
|
205520
205520
|
const { manifest, droppedTools } = buildAdhocWorkerManifest(customSpec);
|
|
205521
205521
|
registerWorkerManifest(manifest);
|
|
205522
205522
|
adhocManifestId = manifest.workerId;
|
|
205523
205523
|
adhocNickname = flockNicknameFor(manifest.workerId, 0);
|
|
205524
|
-
|
|
205524
|
+
displayTitle = `${manifest.name} \xB7 ${adhocNickname}`;
|
|
205525
205525
|
workerId = manifest.workerId;
|
|
205526
205526
|
if (droppedTools.length > 0 && ctx.onEvent) {
|
|
205527
205527
|
ctx.onEvent({
|
|
@@ -205540,6 +205540,14 @@ var init_spawnWorker = __esm({
|
|
|
205540
205540
|
errorCode: "worker_id_missing"
|
|
205541
205541
|
};
|
|
205542
205542
|
}
|
|
205543
|
+
if (!displayTitle) {
|
|
205544
|
+
const registeredManifest = resolveWorkerManifest(workerId);
|
|
205545
|
+
if (registeredManifest) {
|
|
205546
|
+
const runSeed = `${workerId}_${ctx.threadId ?? ""}_${Date.now().toString(36)}`;
|
|
205547
|
+
const nickname = flockNicknameFor(runSeed, 0);
|
|
205548
|
+
displayTitle = `${registeredManifest.name} \xB7 ${nickname}`;
|
|
205549
|
+
}
|
|
205550
|
+
}
|
|
205543
205551
|
const context = typeof args.context === "string" || typeof args.context === "object" && args.context !== null && !Array.isArray(args.context) ? args.context : void 0;
|
|
205544
205552
|
const lane = typeof args.lane === "string" ? args.lane : void 0;
|
|
205545
205553
|
const maxIterations = typeof args.maxIterations === "number" ? adhocManifestId ? Math.min(args.maxIterations, ADHOC_MAX_ITERATIONS) : args.maxIterations : void 0;
|
|
@@ -205576,7 +205584,7 @@ Proceed with the available context. If a missing fact is essential, ask the user
|
|
|
205576
205584
|
maxToolCalls: adhocManifestId ? ADHOC_MAX_TOOL_CALLS : void 0
|
|
205577
205585
|
},
|
|
205578
205586
|
{
|
|
205579
|
-
displayTitle
|
|
205587
|
+
displayTitle,
|
|
205580
205588
|
workspaceRoot: effectiveWorkspaceRoot(ctx),
|
|
205581
205589
|
desktopConnected: ctx.desktopConnected,
|
|
205582
205590
|
// CLI surface: children inherit the local bridge and server auth,
|
|
@@ -287195,7 +287203,8 @@ __export(perch_cli_exports, {
|
|
|
287195
287203
|
flockNicknameAccentColor: () => flockNicknameAccentColor,
|
|
287196
287204
|
parseInteractiveSlashCommand: () => parseInteractiveSlashCommand,
|
|
287197
287205
|
parsePerchCli: () => parsePerchCli,
|
|
287198
|
-
runPerchCli: () => runPerchCli
|
|
287206
|
+
runPerchCli: () => runPerchCli,
|
|
287207
|
+
workerEventToCliRow: () => workerEventToCliRow
|
|
287199
287208
|
});
|
|
287200
287209
|
import fs14 from "node:fs";
|
|
287201
287210
|
import { createHash as createHash4 } from "node:crypto";
|
|
@@ -287228,6 +287237,26 @@ function flockEventToCliRow(event) {
|
|
|
287228
287237
|
return null;
|
|
287229
287238
|
}
|
|
287230
287239
|
}
|
|
287240
|
+
function workerEventToCliRow(event) {
|
|
287241
|
+
switch (event.type) {
|
|
287242
|
+
case "worker_run_started":
|
|
287243
|
+
return {
|
|
287244
|
+
id: `worker-${event.workerRunId ?? event.workerId}`,
|
|
287245
|
+
text: `${event.title} \xB7 running`,
|
|
287246
|
+
tone: "muted"
|
|
287247
|
+
};
|
|
287248
|
+
case "worker_run_completed": {
|
|
287249
|
+
const status = event.ok ? event.usabilityStatus === "needs_user_input" ? "blocked" : "done" : "failed";
|
|
287250
|
+
return {
|
|
287251
|
+
id: `worker-${event.workerRunId ?? event.workerId}`,
|
|
287252
|
+
text: `${event.title} \xB7 ${FLOCK_STATUS_LABELS[status] ?? status}`,
|
|
287253
|
+
tone: status === "done" ? "success" : status === "failed" || status === "blocked" ? "danger" : "muted"
|
|
287254
|
+
};
|
|
287255
|
+
}
|
|
287256
|
+
default:
|
|
287257
|
+
return null;
|
|
287258
|
+
}
|
|
287259
|
+
}
|
|
287231
287260
|
async function runPerchCli(argv, writer = defaultWriter(), deps = {}) {
|
|
287232
287261
|
const parsed = parsePerchCli(argv);
|
|
287233
287262
|
if (!parsed.ok) {
|
|
@@ -287829,6 +287858,7 @@ async function runInkInteractivePerchCli(writer, deps, options) {
|
|
|
287829
287858
|
liveTextRef.current = "";
|
|
287830
287859
|
const toolNamesById = /* @__PURE__ */ new Map();
|
|
287831
287860
|
const flockWorkerNames = /* @__PURE__ */ new Map();
|
|
287861
|
+
const workerTitles = /* @__PURE__ */ new Map();
|
|
287832
287862
|
const flockLimitMeta = /* @__PURE__ */ new Map();
|
|
287833
287863
|
const aggregateToolIds = /* @__PURE__ */ new Map();
|
|
287834
287864
|
const aggregateToolMeta = /* @__PURE__ */ new Map();
|
|
@@ -287894,6 +287924,8 @@ async function runInkInteractivePerchCli(writer, deps, options) {
|
|
|
287894
287924
|
setWorkingText("recovering route");
|
|
287895
287925
|
break;
|
|
287896
287926
|
case "tool_call_started": {
|
|
287927
|
+
if (event.workerId) break;
|
|
287928
|
+
if (event.toolName === "spawn_worker") break;
|
|
287897
287929
|
const toolId = event.toolCallId ?? `${event.toolName}-${Date.now()}`;
|
|
287898
287930
|
const name = humanizeCliToolName(event.toolName);
|
|
287899
287931
|
const aggregateKind = cliToolAggregateKind(event.toolName);
|
|
@@ -287931,6 +287963,8 @@ async function runInkInteractivePerchCli(writer, deps, options) {
|
|
|
287931
287963
|
break;
|
|
287932
287964
|
}
|
|
287933
287965
|
case "tool_call_completed": {
|
|
287966
|
+
if (event.workerId) break;
|
|
287967
|
+
if (event.toolName === "spawn_worker") break;
|
|
287934
287968
|
const toolId = event.toolCallId ?? `${event.toolName}-${Date.now()}`;
|
|
287935
287969
|
const stored = toolInputsById.current.get(toolId);
|
|
287936
287970
|
const aggregateKind = aggregateToolIds.get(toolId);
|
|
@@ -287976,6 +288010,8 @@ async function runInkInteractivePerchCli(writer, deps, options) {
|
|
|
287976
288010
|
break;
|
|
287977
288011
|
}
|
|
287978
288012
|
case "tool_call_failed": {
|
|
288013
|
+
if (event.workerId) break;
|
|
288014
|
+
if (event.toolName === "spawn_worker") break;
|
|
287979
288015
|
const toolId = event.toolCallId ?? `${event.toolName}-${Date.now()}`;
|
|
287980
288016
|
const name = toolNamesById.get(toolId) ?? humanizeCliToolName(event.toolName);
|
|
287981
288017
|
const stored = toolInputsById.current.get(toolId);
|
|
@@ -288180,7 +288216,7 @@ async function runInkInteractivePerchCli(writer, deps, options) {
|
|
|
288180
288216
|
meta2.skipped += event.skippedCount ?? 0;
|
|
288181
288217
|
for (const toolName of event.toolNames ?? []) meta2.tools.add(toolName);
|
|
288182
288218
|
flockLimitMeta.set(limitKey, meta2);
|
|
288183
|
-
const who = event.workerId ? flockWorkerNames.get(event.workerId) ?? "A worker" : "The model";
|
|
288219
|
+
const who = event.workerId ? workerTitles.get(event.workerId) ?? flockWorkerNames.get(event.workerId) ?? "A worker" : "The model";
|
|
288184
288220
|
updateToolItem(limitKey, {
|
|
288185
288221
|
label: "flock",
|
|
288186
288222
|
text: `${who} hit its tool limit and is finishing from gathered evidence.`,
|
|
@@ -288196,6 +288232,25 @@ async function runInkInteractivePerchCli(writer, deps, options) {
|
|
|
288196
288232
|
});
|
|
288197
288233
|
break;
|
|
288198
288234
|
}
|
|
288235
|
+
case "worker_run_started":
|
|
288236
|
+
case "worker_run_completed": {
|
|
288237
|
+
if (event.type === "worker_run_started") {
|
|
288238
|
+
workerTitles.set(event.workerId, event.title);
|
|
288239
|
+
}
|
|
288240
|
+
const row = workerEventToCliRow(event);
|
|
288241
|
+
if (!row) break;
|
|
288242
|
+
if (row.id) {
|
|
288243
|
+
updateToolItem(row.id, { label: "worker", text: row.text, tone: row.tone });
|
|
288244
|
+
} else {
|
|
288245
|
+
addItem({ label: "worker", text: row.text, tone: row.tone });
|
|
288246
|
+
}
|
|
288247
|
+
if (event.type === "worker_run_started") {
|
|
288248
|
+
setWorkingText(event.title.split(" \xB7 ")[0] ?? event.title);
|
|
288249
|
+
} else {
|
|
288250
|
+
setWorkingText("thinking");
|
|
288251
|
+
}
|
|
288252
|
+
break;
|
|
288253
|
+
}
|
|
288199
288254
|
case "flock_run_started":
|
|
288200
288255
|
case "flock_plan_ready":
|
|
288201
288256
|
case "flock_worker_update":
|
|
@@ -288370,7 +288425,7 @@ async function runInkInteractivePerchCli(writer, deps, options) {
|
|
|
288370
288425
|
const renderFlockRow = (key, line, tone, showLabel) => {
|
|
288371
288426
|
const dotParts = line.split(" \xB7 ");
|
|
288372
288427
|
const limitMatch = dotParts.length < 2 ? line.match(/^(.+?) (hit its tool limit .*)$/) : null;
|
|
288373
|
-
if (dotParts.length < 2 && !limitMatch) {
|
|
288428
|
+
if (dotParts.length === 2 && WORKER_STATUS_WORDS.has(dotParts[1] ?? "") || dotParts.length < 2 && !limitMatch) {
|
|
288374
288429
|
return renderTranscriptRow(key, "flock", line, tone, showLabel);
|
|
288375
288430
|
}
|
|
288376
288431
|
if (limitMatch) {
|
|
@@ -288404,6 +288459,39 @@ async function runInkInteractivePerchCli(writer, deps, options) {
|
|
|
288404
288459
|
)
|
|
288405
288460
|
);
|
|
288406
288461
|
};
|
|
288462
|
+
const renderWorkerRow = (key, line, tone, showLabel) => {
|
|
288463
|
+
const dotParts = line.split(" \xB7 ");
|
|
288464
|
+
if (dotParts.length >= 3 && WORKER_STATUS_WORDS.has(dotParts[dotParts.length - 1] ?? "")) {
|
|
288465
|
+
const status = dotParts[dotParts.length - 1];
|
|
288466
|
+
const nickname = dotParts[dotParts.length - 2] ?? "";
|
|
288467
|
+
const name = dotParts.slice(0, dotParts.length - 2).join(" \xB7 ");
|
|
288468
|
+
return React11.createElement(
|
|
288469
|
+
Ink2.Box,
|
|
288470
|
+
{ key },
|
|
288471
|
+
React11.createElement(
|
|
288472
|
+
Ink2.Box,
|
|
288473
|
+
{ width: INK_LABEL_WIDTH, flexShrink: 0 },
|
|
288474
|
+
React11.createElement(
|
|
288475
|
+
Ink2.Text,
|
|
288476
|
+
{ color: colorForInkTone(tone) },
|
|
288477
|
+
showLabel ? renderInkSpeakerLabel("worker") : ""
|
|
288478
|
+
)
|
|
288479
|
+
),
|
|
288480
|
+
React11.createElement(
|
|
288481
|
+
Ink2.Box,
|
|
288482
|
+
{ flexGrow: 1 },
|
|
288483
|
+
React11.createElement(
|
|
288484
|
+
Ink2.Text,
|
|
288485
|
+
null,
|
|
288486
|
+
React11.createElement(Ink2.Text, { color: bodyColorForInkTone(tone) }, `${name} \xB7 `),
|
|
288487
|
+
React11.createElement(Ink2.Text, { color: flockNicknameAccentColor(nickname), bold: true }, nickname),
|
|
288488
|
+
React11.createElement(Ink2.Text, { color: bodyColorForInkTone(tone) }, ` \xB7 ${status}`)
|
|
288489
|
+
)
|
|
288490
|
+
)
|
|
288491
|
+
);
|
|
288492
|
+
}
|
|
288493
|
+
return renderTranscriptRow(key, "worker", line, tone, showLabel);
|
|
288494
|
+
};
|
|
288407
288495
|
const renderTranscriptItem = (item, index) => {
|
|
288408
288496
|
const lines = item.text.split(/\r?\n/);
|
|
288409
288497
|
const previous = items[index - 1];
|
|
@@ -288417,7 +288505,7 @@ async function runInkInteractivePerchCli(writer, deps, options) {
|
|
|
288417
288505
|
React11.createElement(Ink2.Box, { width: INK_LABEL_WIDTH, flexShrink: 0 }),
|
|
288418
288506
|
React11.createElement(Ink2.Text, { color: CLI_BRAND.divider }, INK_DIVIDER)
|
|
288419
288507
|
) : null,
|
|
288420
|
-
lines.map((line, lineIndex) => item.label === "flock" ? renderFlockRow(`${item.id}-${lineIndex}`, line, item.tone, lineIndex === 0) : renderTranscriptRow(
|
|
288508
|
+
lines.map((line, lineIndex) => item.label === "flock" ? renderFlockRow(`${item.id}-${lineIndex}`, line, item.tone, lineIndex === 0) : item.label === "worker" ? renderWorkerRow(`${item.id}-${lineIndex}`, line, item.tone, lineIndex === 0) : renderTranscriptRow(
|
|
288421
288509
|
`${item.id}-${lineIndex}`,
|
|
288422
288510
|
item.label,
|
|
288423
288511
|
line,
|
|
@@ -289920,7 +290008,7 @@ function defaultWriter() {
|
|
|
289920
290008
|
stderr: (text) => process.stderr.write(text)
|
|
289921
290009
|
};
|
|
289922
290010
|
}
|
|
289923
|
-
var execFileAsync3, DEFAULT_CLI_LOGIN_APP_URL, CLI_PACKAGE_VERSION, CLI_BRAND, ANSI2, HELP_TEXT, INTERACTIVE_HELP_TEXT, FLOCK_STATUS_LABELS, INK_LABEL_WIDTH, INK_ROW_LIMIT, INK_DETAIL_LINE_LIMIT, INK_DIVIDER, PERCH_MOTION_FRAMES, PERCH_SPLASH_WIDTH, PERCH_SPLASH_SCENE, PERCH_SPLASH_COMMANDS, FLOCK_NICKNAME_ACCENTS;
|
|
290011
|
+
var execFileAsync3, DEFAULT_CLI_LOGIN_APP_URL, CLI_PACKAGE_VERSION, CLI_BRAND, ANSI2, HELP_TEXT, INTERACTIVE_HELP_TEXT, FLOCK_STATUS_LABELS, WORKER_STATUS_WORDS, INK_LABEL_WIDTH, INK_ROW_LIMIT, INK_DETAIL_LINE_LIMIT, INK_DIVIDER, PERCH_MOTION_FRAMES, PERCH_SPLASH_WIDTH, PERCH_SPLASH_SCENE, PERCH_SPLASH_COMMANDS, FLOCK_NICKNAME_ACCENTS;
|
|
289924
290012
|
var init_perch_cli = __esm({
|
|
289925
290013
|
"scripts/perch-cli.ts"() {
|
|
289926
290014
|
"use strict";
|
|
@@ -290015,8 +290103,10 @@ Commands:
|
|
|
290015
290103
|
done: "done",
|
|
290016
290104
|
failed: "failed",
|
|
290017
290105
|
cancelled: "stopped",
|
|
290018
|
-
skipped: "skipped"
|
|
290106
|
+
skipped: "skipped",
|
|
290107
|
+
blocked: "blocked"
|
|
290019
290108
|
};
|
|
290109
|
+
WORKER_STATUS_WORDS = new Set(Object.values(FLOCK_STATUS_LABELS));
|
|
290020
290110
|
INK_LABEL_WIDTH = 12;
|
|
290021
290111
|
INK_ROW_LIMIT = 100;
|
|
290022
290112
|
INK_DETAIL_LINE_LIMIT = 80;
|