perchai-cli 2.4.4 → 2.4.6
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 +205 -43
- package/package.json +1 -1
package/dist/perch.mjs
CHANGED
|
@@ -222653,14 +222653,15 @@ async function connectCliModelProxy(input = {}) {
|
|
|
222653
222653
|
const usableStoredSession = isStoredCliAuthSessionUsable(storedSession) ? storedSession : null;
|
|
222654
222654
|
const appUrl = resolveCliAppUrl(input.appUrl, usableStoredSession?.appUrl ?? null);
|
|
222655
222655
|
if (!appUrl) return noCliModelConnection();
|
|
222656
|
+
if (!usableStoredSession?.accessToken) return noCliModelConnection(appUrl);
|
|
222656
222657
|
const fetchImpl = input.fetchImpl ?? globalThis.fetch;
|
|
222657
|
-
if (typeof fetchImpl !== "function") return noCliModelConnection();
|
|
222658
|
+
if (typeof fetchImpl !== "function") return noCliModelConnection(appUrl);
|
|
222658
222659
|
const selection = await fetchPublicModelDefaultSelection(
|
|
222659
222660
|
appUrl,
|
|
222660
222661
|
fetchImpl,
|
|
222661
222662
|
usableStoredSession?.accessToken ?? null
|
|
222662
222663
|
);
|
|
222663
|
-
if (!selection) return noCliModelConnection();
|
|
222664
|
+
if (!selection) return noCliModelConnection(appUrl);
|
|
222664
222665
|
const priorProxy = process.env[MODEL_PROXY_ENV];
|
|
222665
222666
|
const priorToken = process.env[MODEL_PROXY_TOKEN_ENV];
|
|
222666
222667
|
process.env[MODEL_PROXY_ENV] = appUrl;
|
|
@@ -222726,9 +222727,9 @@ async function fetchPublicModelDefaultSelection(appUrl, fetchImpl, accessToken)
|
|
|
222726
222727
|
clearTimeout(timeout);
|
|
222727
222728
|
}
|
|
222728
222729
|
}
|
|
222729
|
-
function noCliModelConnection() {
|
|
222730
|
+
function noCliModelConnection(appUrl = null) {
|
|
222730
222731
|
return {
|
|
222731
|
-
appUrl
|
|
222732
|
+
appUrl,
|
|
222732
222733
|
authenticated: false,
|
|
222733
222734
|
userId: null,
|
|
222734
222735
|
email: null,
|
|
@@ -277559,7 +277560,8 @@ async function runReadlineInteractivePerchCli(writer, deps, options) {
|
|
|
277559
277560
|
input: prompt,
|
|
277560
277561
|
state,
|
|
277561
277562
|
writer,
|
|
277562
|
-
reconnect
|
|
277563
|
+
reconnect,
|
|
277564
|
+
getConnection: () => connection
|
|
277563
277565
|
});
|
|
277564
277566
|
if (commandResult === "exit") break;
|
|
277565
277567
|
} catch (error) {
|
|
@@ -277626,21 +277628,22 @@ async function runInkInteractivePerchCli(writer, deps, options) {
|
|
|
277626
277628
|
const [workingText, setWorkingText] = React11.useState("ready");
|
|
277627
277629
|
const [pulse, setPulse] = React11.useState(0);
|
|
277628
277630
|
const [, refresh] = React11.useState(0);
|
|
277631
|
+
const liveTextRef = React11.useRef("");
|
|
277629
277632
|
React11.useEffect(() => {
|
|
277630
277633
|
if (!working) return void 0;
|
|
277631
|
-
const timer = setInterval(() => setPulse((value) =>
|
|
277634
|
+
const timer = setInterval(() => setPulse((value) => value + 1), 120);
|
|
277632
277635
|
return () => clearInterval(timer);
|
|
277633
277636
|
}, [working]);
|
|
277634
277637
|
const addItem = React11.useCallback((item) => {
|
|
277635
277638
|
setItems((current) => [
|
|
277636
277639
|
...current,
|
|
277637
277640
|
{ id: `cli-item-${Date.now()}-${current.length}`, ...item }
|
|
277638
|
-
].slice(-
|
|
277641
|
+
].slice(-INK_ROW_LIMIT));
|
|
277639
277642
|
}, []);
|
|
277640
277643
|
const updateToolItem = React11.useCallback((id, item) => {
|
|
277641
277644
|
setItems((current) => {
|
|
277642
277645
|
const index = current.findIndex((entry) => entry.id === id);
|
|
277643
|
-
if (index < 0) return [...current, { id, ...item }].slice(-
|
|
277646
|
+
if (index < 0) return [...current, { id, ...item }].slice(-INK_ROW_LIMIT);
|
|
277644
277647
|
const next = current.slice();
|
|
277645
277648
|
next[index] = { id, ...item };
|
|
277646
277649
|
return next;
|
|
@@ -277660,7 +277663,11 @@ async function runInkInteractivePerchCli(writer, deps, options) {
|
|
|
277660
277663
|
const commandWriter = {
|
|
277661
277664
|
stdout: (text) => {
|
|
277662
277665
|
const clean = text.trim();
|
|
277663
|
-
if (clean) addItem({
|
|
277666
|
+
if (clean) addItem({
|
|
277667
|
+
label: prompt === "/status" ? "status" : "system",
|
|
277668
|
+
text: clean,
|
|
277669
|
+
tone: "muted"
|
|
277670
|
+
});
|
|
277664
277671
|
},
|
|
277665
277672
|
stderr: (text) => {
|
|
277666
277673
|
const clean = text.trim();
|
|
@@ -277672,7 +277679,8 @@ async function runInkInteractivePerchCli(writer, deps, options) {
|
|
|
277672
277679
|
input: prompt,
|
|
277673
277680
|
state,
|
|
277674
277681
|
writer: commandWriter,
|
|
277675
|
-
reconnect
|
|
277682
|
+
reconnect,
|
|
277683
|
+
getConnection: () => connection
|
|
277676
277684
|
});
|
|
277677
277685
|
refresh((value) => value + 1);
|
|
277678
277686
|
if (result2 === "exit") {
|
|
@@ -277687,8 +277695,17 @@ async function runInkInteractivePerchCli(writer, deps, options) {
|
|
|
277687
277695
|
setWorking(true);
|
|
277688
277696
|
setWorkingText("thinking");
|
|
277689
277697
|
setLiveText("");
|
|
277698
|
+
liveTextRef.current = "";
|
|
277690
277699
|
const toolNamesById = /* @__PURE__ */ new Map();
|
|
277691
277700
|
try {
|
|
277701
|
+
if (!isCliModelConnectionReady(connection)) {
|
|
277702
|
+
addItem({
|
|
277703
|
+
label: "need",
|
|
277704
|
+
text: "Sign in with /login before chatting. Hosted model calls require an authenticated Perch session.",
|
|
277705
|
+
tone: "danger"
|
|
277706
|
+
});
|
|
277707
|
+
return;
|
|
277708
|
+
}
|
|
277692
277709
|
const result2 = await runTurn({
|
|
277693
277710
|
prompt,
|
|
277694
277711
|
cwd: state.cwd,
|
|
@@ -277704,13 +277721,14 @@ async function runInkInteractivePerchCli(writer, deps, options) {
|
|
|
277704
277721
|
switch (event.type) {
|
|
277705
277722
|
case "content_delta":
|
|
277706
277723
|
case "streaming_text":
|
|
277707
|
-
|
|
277724
|
+
liveTextRef.current += event.text;
|
|
277725
|
+
setLiveText(liveTextRef.current);
|
|
277708
277726
|
break;
|
|
277709
277727
|
case "assistant_preamble":
|
|
277710
277728
|
case "activity_delta":
|
|
277711
277729
|
case "workflow_narration":
|
|
277712
277730
|
if (event.text.trim()) {
|
|
277713
|
-
addItem({ label:
|
|
277731
|
+
addItem({ label: state.personaId, text: event.text.trim(), tone: "normal" });
|
|
277714
277732
|
}
|
|
277715
277733
|
break;
|
|
277716
277734
|
case "model_call_started":
|
|
@@ -277762,7 +277780,7 @@ async function runInkInteractivePerchCli(writer, deps, options) {
|
|
|
277762
277780
|
}
|
|
277763
277781
|
});
|
|
277764
277782
|
setLiveText("");
|
|
277765
|
-
const assistantText = result2.assistantText.trim() ||
|
|
277783
|
+
const assistantText = result2.assistantText.trim() || liveTextRef.current.trim();
|
|
277766
277784
|
if (assistantText) {
|
|
277767
277785
|
addItem({ label: state.personaId, text: assistantText, tone: "normal" });
|
|
277768
277786
|
}
|
|
@@ -277784,8 +277802,9 @@ async function runInkInteractivePerchCli(writer, deps, options) {
|
|
|
277784
277802
|
setWorking(false);
|
|
277785
277803
|
setWorkingText("ready");
|
|
277786
277804
|
setLiveText("");
|
|
277805
|
+
liveTextRef.current = "";
|
|
277787
277806
|
}
|
|
277788
|
-
}, [addItem, app,
|
|
277807
|
+
}, [addItem, app, reconnect, runTurn, updateToolItem, working]);
|
|
277789
277808
|
Ink2.useInput((input, key) => {
|
|
277790
277809
|
if (working) return;
|
|
277791
277810
|
if (key.return) {
|
|
@@ -277803,47 +277822,131 @@ async function runInkInteractivePerchCli(writer, deps, options) {
|
|
|
277803
277822
|
}
|
|
277804
277823
|
if (input && !key.escape) setDraft((value) => value + input);
|
|
277805
277824
|
});
|
|
277806
|
-
const pulseGlyph = working ? "P".slice(0, 1) : "P";
|
|
277807
277825
|
const pulseColor = pulse % 2 === 0 ? "#c45000" : "#8e857d";
|
|
277808
|
-
const
|
|
277809
|
-
|
|
277826
|
+
const spinnerGlyph = inkSpinnerFrame(pulse);
|
|
277827
|
+
const auth = renderCliAuthSummary(connection);
|
|
277828
|
+
const meta = `${state.personaId} \xB7 ${state.chatMode} \xB7 ${state.permissionMode}`;
|
|
277829
|
+
const route = connection.authenticated && connection.appUrl ? connection.appUrl.replace(/^https?:\/\//, "") : "run /login";
|
|
277830
|
+
const renderTranscriptRow = (key, label, line, tone, showLabel) => React11.createElement(
|
|
277810
277831
|
Ink2.Box,
|
|
277811
|
-
{
|
|
277832
|
+
{ key },
|
|
277812
277833
|
React11.createElement(
|
|
277813
277834
|
Ink2.Box,
|
|
277814
|
-
{
|
|
277815
|
-
React11.createElement(Ink2.Text, { color: "#c45000", bold: true }, "P"),
|
|
277816
|
-
React11.createElement(Ink2.Text, { bold: true }, "Perch | Terminal"),
|
|
277835
|
+
{ width: INK_LABEL_WIDTH, flexShrink: 0 },
|
|
277817
277836
|
React11.createElement(
|
|
277818
277837
|
Ink2.Text,
|
|
277819
|
-
{
|
|
277820
|
-
|
|
277838
|
+
{
|
|
277839
|
+
color: colorForInkTone(tone),
|
|
277840
|
+
bold: tone === "accent"
|
|
277841
|
+
},
|
|
277842
|
+
showLabel ? renderInkSpeakerLabel(label) : ""
|
|
277821
277843
|
)
|
|
277822
277844
|
),
|
|
277823
|
-
|
|
277824
|
-
|
|
277845
|
+
React11.createElement(
|
|
277846
|
+
Ink2.Box,
|
|
277847
|
+
{ flexGrow: 1 },
|
|
277848
|
+
React11.createElement(Ink2.Text, { color: bodyColorForInkTone(tone) }, line)
|
|
277849
|
+
)
|
|
277850
|
+
);
|
|
277851
|
+
const renderTranscriptItem = (item, index) => {
|
|
277852
|
+
const lines = item.text.split(/\r?\n/);
|
|
277853
|
+
const previous = items[index - 1];
|
|
277854
|
+
const separateFromUser = previous?.label === "you" && item.label !== "you" && item.tone !== "danger";
|
|
277855
|
+
return React11.createElement(
|
|
277856
|
+
Ink2.Box,
|
|
277857
|
+
{ key: item.id, flexDirection: "column", marginTop: separateFromUser ? 1 : 0 },
|
|
277858
|
+
separateFromUser ? React11.createElement(
|
|
277859
|
+
Ink2.Box,
|
|
277860
|
+
null,
|
|
277861
|
+
React11.createElement(Ink2.Box, { width: INK_LABEL_WIDTH, flexShrink: 0 }),
|
|
277862
|
+
React11.createElement(Ink2.Text, { color: "#2a211c" }, INK_DIVIDER)
|
|
277863
|
+
) : null,
|
|
277864
|
+
lines.map((line, lineIndex) => renderTranscriptRow(
|
|
277865
|
+
`${item.id}-${lineIndex}`,
|
|
277866
|
+
item.label,
|
|
277867
|
+
line,
|
|
277868
|
+
item.tone,
|
|
277869
|
+
lineIndex === 0
|
|
277870
|
+
))
|
|
277871
|
+
);
|
|
277872
|
+
};
|
|
277873
|
+
return React11.createElement(
|
|
277874
|
+
Ink2.Box,
|
|
277875
|
+
{ flexDirection: "column", width: "100%" },
|
|
277876
|
+
React11.createElement(
|
|
277877
|
+
Ink2.Box,
|
|
277878
|
+
{ flexDirection: "column", alignItems: "center", marginBottom: 1, paddingY: 1 },
|
|
277879
|
+
React11.createElement(
|
|
277825
277880
|
Ink2.Box,
|
|
277826
|
-
{
|
|
277827
|
-
React11.createElement(Ink2.Text, { color:
|
|
277828
|
-
React11.createElement(Ink2.Text, { color:
|
|
277881
|
+
{ width: PERCH_SPLASH_WIDTH, justifyContent: "space-between", marginBottom: 1 },
|
|
277882
|
+
React11.createElement(Ink2.Text, { color: "#7a6f66" }, "perch \xB7 field terminal"),
|
|
277883
|
+
React11.createElement(Ink2.Text, { color: "#7a6f66" }, `v${CLI_PACKAGE_VERSION}`)
|
|
277884
|
+
),
|
|
277885
|
+
...PERCH_SPLASH_SCENE.map(
|
|
277886
|
+
(line, index) => React11.createElement(
|
|
277887
|
+
Ink2.Box,
|
|
277888
|
+
{ key: `field-${index}`, width: PERCH_SPLASH_WIDTH },
|
|
277889
|
+
React11.createElement(
|
|
277890
|
+
Ink2.Text,
|
|
277891
|
+
{ color: working && index === 11 ? pulseColor : "#c45000", bold: true },
|
|
277892
|
+
line
|
|
277893
|
+
)
|
|
277894
|
+
)
|
|
277895
|
+
),
|
|
277896
|
+
React11.createElement(
|
|
277897
|
+
Ink2.Box,
|
|
277898
|
+
{ marginTop: 1 },
|
|
277899
|
+
React11.createElement(Ink2.Text, { color: "#c45000" }, "perched"),
|
|
277900
|
+
React11.createElement(Ink2.Text, { color: "#8e857d" }, " in "),
|
|
277901
|
+
React11.createElement(Ink2.Text, { color: "#fff8f0", bold: true }, shortCwd(state.cwd))
|
|
277902
|
+
),
|
|
277903
|
+
React11.createElement(
|
|
277904
|
+
Ink2.Text,
|
|
277905
|
+
{ color: "#8e857d", wrap: "truncate-middle" },
|
|
277906
|
+
`${auth} \xB7 ${meta}`
|
|
277907
|
+
),
|
|
277908
|
+
React11.createElement(
|
|
277909
|
+
Ink2.Box,
|
|
277910
|
+
{ flexDirection: "column", marginTop: 1 },
|
|
277911
|
+
...PERCH_SPLASH_COMMANDS.map(
|
|
277912
|
+
([command, description]) => React11.createElement(
|
|
277913
|
+
Ink2.Box,
|
|
277914
|
+
{ key: command },
|
|
277915
|
+
React11.createElement(Ink2.Box, { width: 16 }, React11.createElement(Ink2.Text, { color: "#c45000" }, command)),
|
|
277916
|
+
React11.createElement(Ink2.Text, { color: "#8e857d" }, description)
|
|
277917
|
+
)
|
|
277918
|
+
)
|
|
277919
|
+
),
|
|
277920
|
+
React11.createElement(
|
|
277921
|
+
Ink2.Text,
|
|
277922
|
+
{ color: "#5e554d", wrap: "truncate-middle" },
|
|
277923
|
+
route
|
|
277829
277924
|
)
|
|
277830
277925
|
),
|
|
277926
|
+
...items.map(renderTranscriptItem),
|
|
277831
277927
|
liveText ? React11.createElement(
|
|
277832
277928
|
Ink2.Box,
|
|
277833
277929
|
{ key: "live-text" },
|
|
277834
|
-
|
|
277835
|
-
React11.createElement(Ink2.Text, null, ` ${liveText}`)
|
|
277930
|
+
renderTranscriptRow("live-text-row", state.personaId, liveText, "normal", true)
|
|
277836
277931
|
) : null,
|
|
277837
277932
|
working ? React11.createElement(
|
|
277838
277933
|
Ink2.Box,
|
|
277839
277934
|
{ key: "working", marginTop: items.length || liveText ? 1 : 0 },
|
|
277840
|
-
React11.createElement(
|
|
277841
|
-
|
|
277935
|
+
React11.createElement(
|
|
277936
|
+
Ink2.Box,
|
|
277937
|
+
{ width: INK_LABEL_WIDTH, flexShrink: 0 },
|
|
277938
|
+
React11.createElement(Ink2.Text, { color: pulseColor, bold: true }, spinnerGlyph)
|
|
277939
|
+
),
|
|
277940
|
+
React11.createElement(
|
|
277941
|
+
Ink2.Text,
|
|
277942
|
+
{ color: "#8e857d" },
|
|
277943
|
+
`${state.personaId} \xB7 ${workingText}\u2026`
|
|
277944
|
+
)
|
|
277842
277945
|
) : null,
|
|
277843
277946
|
React11.createElement(
|
|
277844
277947
|
Ink2.Box,
|
|
277845
277948
|
{ key: "prompt", marginTop: 1 },
|
|
277846
|
-
React11.createElement(Ink2.Text, { color: "#c45000", bold: true },
|
|
277949
|
+
React11.createElement(Ink2.Text, { color: "#c45000", bold: true }, "you\u203A "),
|
|
277847
277950
|
React11.createElement(Ink2.Text, null, draft),
|
|
277848
277951
|
React11.createElement(Ink2.Text, { backgroundColor: "#c45000", color: "#100d0b" }, " ")
|
|
277849
277952
|
)
|
|
@@ -277872,7 +277975,7 @@ async function runInteractiveSlashCommand(input) {
|
|
|
277872
277975
|
return "continue";
|
|
277873
277976
|
case "status": {
|
|
277874
277977
|
const session = await readStoredCliAuthSession();
|
|
277875
|
-
input.writer.stdout(renderInteractiveStatus(input.state, null, session));
|
|
277978
|
+
input.writer.stdout(renderInteractiveStatus(input.state, input.getConnection?.() ?? null, session));
|
|
277876
277979
|
return "continue";
|
|
277877
277980
|
}
|
|
277878
277981
|
case "cwd":
|
|
@@ -278006,38 +278109,60 @@ function parseInteractiveSlashCommand(input) {
|
|
|
278006
278109
|
}
|
|
278007
278110
|
}
|
|
278008
278111
|
function renderInteractiveStatus(state, connection, session) {
|
|
278009
|
-
const
|
|
278112
|
+
const storedAuth = session === void 0 ? renderCliAuthSummary(connection) : isStoredCliAuthSessionUsable(session) ? `signed in${session.email ? ` as ${session.email}` : ""}` : "not signed in";
|
|
278113
|
+
const modelRoute = isCliModelConnectionReady(connection) ? `connected \xB7 ${connection.appUrl ?? "(unknown)"}` : "locked \xB7 run /login";
|
|
278010
278114
|
const color = shouldUseCliColor();
|
|
278011
278115
|
const lines = [
|
|
278012
278116
|
["cwd", state.cwd],
|
|
278117
|
+
["auth", storedAuth],
|
|
278118
|
+
["model-route", modelRoute],
|
|
278013
278119
|
["permission", state.permissionMode],
|
|
278014
278120
|
["mode", state.chatMode],
|
|
278015
278121
|
["persona", state.personaId],
|
|
278016
278122
|
["thread", state.threadId],
|
|
278017
278123
|
["local-tools", state.cliLocalTools ? "on" : "off"],
|
|
278018
|
-
["app-url", state.appUrl ?? connection?.appUrl ?? "(none)"]
|
|
278019
|
-
["auth", auth]
|
|
278124
|
+
["app-url", state.appUrl ?? connection?.appUrl ?? "(none)"]
|
|
278020
278125
|
];
|
|
278021
278126
|
return lines.map(([key, value]) => `${paint(key.padEnd(11), "muted", color)} ${value}`).join("\n") + "\n";
|
|
278022
278127
|
}
|
|
278023
278128
|
function renderInteractiveStartup(state, connection) {
|
|
278024
278129
|
const color = shouldUseCliColor();
|
|
278025
|
-
const auth = connection
|
|
278130
|
+
const auth = renderCliAuthSummary(connection);
|
|
278131
|
+
const route = connection.authenticated && connection.appUrl ? connection.appUrl.replace(/^https?:\/\//, "") : connection.appUrl ?? state.appUrl ?? "run /login";
|
|
278132
|
+
const commandLines = PERCH_SPLASH_COMMANDS.map(
|
|
278133
|
+
([command, description]) => ` ${paint(command.padEnd(13), "orange", color)}${paint(description, "muted", color)}`
|
|
278134
|
+
);
|
|
278026
278135
|
return [
|
|
278027
|
-
`${paint("
|
|
278028
|
-
|
|
278136
|
+
`${paint("perch \xB7 field terminal", "muted", color)}${" ".repeat(24)}${paint(`v${CLI_PACKAGE_VERSION}`, "muted", color)}`,
|
|
278137
|
+
"",
|
|
278138
|
+
...PERCH_SPLASH_SCENE.map((line) => paint(line, "orange", color)),
|
|
278139
|
+
"",
|
|
278140
|
+
` ${paint("perched", "orange", color)} ${paint("in", "muted", color)} ${paint(shortCwd(state.cwd), "cream", color)}`,
|
|
278141
|
+
` ${paint([auth, state.personaId, state.chatMode, state.permissionMode].join(" \xB7 "), "muted", color)}`,
|
|
278142
|
+
"",
|
|
278143
|
+
...commandLines,
|
|
278144
|
+
"",
|
|
278145
|
+
` ${paint(route, "muted", color)}`,
|
|
278029
278146
|
""
|
|
278030
278147
|
].join("\n");
|
|
278031
278148
|
}
|
|
278032
|
-
function renderInteractivePrompt(
|
|
278149
|
+
function renderInteractivePrompt(_state) {
|
|
278033
278150
|
const color = shouldUseCliColor();
|
|
278034
|
-
return `${paint(
|
|
278151
|
+
return `${paint("you", "orange", color)}${paint("\u203A", "orange", color)} `;
|
|
278035
278152
|
}
|
|
278036
278153
|
function writeModeLine(writer, key, value) {
|
|
278037
278154
|
const color = shouldUseCliColor();
|
|
278038
278155
|
writer.stdout(`${paint("mode".padEnd(7), "muted", color)} ${key} \u2192 ${value}
|
|
278039
278156
|
`);
|
|
278040
278157
|
}
|
|
278158
|
+
function inkSpinnerFrame(frame) {
|
|
278159
|
+
return INK_SPINNER_FRAMES[Math.abs(frame) % INK_SPINNER_FRAMES.length] ?? "\xB7";
|
|
278160
|
+
}
|
|
278161
|
+
function renderInkSpeakerLabel(label) {
|
|
278162
|
+
if (!label.trim()) return "";
|
|
278163
|
+
if (label === "tool" || label === "status" || label === "system") return `${label}\xB7`;
|
|
278164
|
+
return `${label}\u203A`;
|
|
278165
|
+
}
|
|
278041
278166
|
function createInteractiveCliState(options) {
|
|
278042
278167
|
return {
|
|
278043
278168
|
cwd: resolveExistingDirectory(options.cwd ?? process.cwd()),
|
|
@@ -278054,6 +278179,15 @@ function createInteractiveCliState(options) {
|
|
|
278054
278179
|
function humanizeCliToolName(name) {
|
|
278055
278180
|
return name.replace(/^mcp__/, "").replace(/_/g, " ");
|
|
278056
278181
|
}
|
|
278182
|
+
function isCliModelConnectionReady(connection) {
|
|
278183
|
+
return Boolean(connection?.authenticated && connection.founderModelSelection);
|
|
278184
|
+
}
|
|
278185
|
+
function renderCliAuthSummary(connection) {
|
|
278186
|
+
if (isCliModelConnectionReady(connection)) {
|
|
278187
|
+
return `signed in${connection.email ? ` as ${connection.email}` : ""}`;
|
|
278188
|
+
}
|
|
278189
|
+
return "not signed in";
|
|
278190
|
+
}
|
|
278057
278191
|
function errorMessage(error) {
|
|
278058
278192
|
return error instanceof Error ? error.message : String(error);
|
|
278059
278193
|
}
|
|
@@ -278372,7 +278506,7 @@ function defaultWriter() {
|
|
|
278372
278506
|
stderr: (text) => process.stderr.write(text)
|
|
278373
278507
|
};
|
|
278374
278508
|
}
|
|
278375
|
-
var execFileAsync3, DEFAULT_CLI_LOGIN_APP_URL, CLI_PACKAGE_VERSION, ANSI2, HELP_TEXT, INTERACTIVE_HELP_TEXT;
|
|
278509
|
+
var execFileAsync3, DEFAULT_CLI_LOGIN_APP_URL, CLI_PACKAGE_VERSION, ANSI2, HELP_TEXT, INTERACTIVE_HELP_TEXT, INK_LABEL_WIDTH, INK_ROW_LIMIT, INK_DIVIDER, INK_SPINNER_FRAMES, PERCH_SPLASH_WIDTH, PERCH_SPLASH_SCENE, PERCH_SPLASH_COMMANDS;
|
|
278376
278510
|
var init_perch_cli = __esm({
|
|
278377
278511
|
"scripts/perch-cli.ts"() {
|
|
278378
278512
|
"use strict";
|
|
@@ -278434,6 +278568,34 @@ Model connection:
|
|
|
278434
278568
|
/logout Clear saved CLI auth.
|
|
278435
278569
|
/exit Leave Perch CLI.
|
|
278436
278570
|
`;
|
|
278571
|
+
INK_LABEL_WIDTH = 12;
|
|
278572
|
+
INK_ROW_LIMIT = 100;
|
|
278573
|
+
INK_DIVIDER = "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500";
|
|
278574
|
+
INK_SPINNER_FRAMES = process.platform === "darwin" ? ["\xB7", "\u2722", "\u2733", "\u2736", "\u273B", "\u273D", "\u273B", "\u2736", "\u2733", "\u2722"] : ["\xB7", "\u2722", "*", "\u2736", "\u273B", "\u273D", "\u273B", "\u2736", "*", "\u2722"];
|
|
278575
|
+
PERCH_SPLASH_WIDTH = 76;
|
|
278576
|
+
PERCH_SPLASH_SCENE = [
|
|
278577
|
+
" \xB7 \xB7 ",
|
|
278578
|
+
" \xB7 ",
|
|
278579
|
+
" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 ",
|
|
278580
|
+
" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \xB7 ",
|
|
278581
|
+
" \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 ",
|
|
278582
|
+
" \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 ",
|
|
278583
|
+
" \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \xB7 ",
|
|
278584
|
+
" \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 ",
|
|
278585
|
+
" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 ",
|
|
278586
|
+
" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \xB7 ",
|
|
278587
|
+
" \u2588\u2588\u2588\u2588 ",
|
|
278588
|
+
" \u2588\u2588\u2588\u2588 <( o)> ",
|
|
278589
|
+
" \u2588\u2588\u2588\u2588 /|\\ ",
|
|
278590
|
+
" \u2588\u2588\u2588\u2588 / \\ ",
|
|
278591
|
+
" \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2588\u2588\u2588\u2588\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 "
|
|
278592
|
+
];
|
|
278593
|
+
PERCH_SPLASH_COMMANDS = [
|
|
278594
|
+
["/status", "show auth, route, tools, and thread"],
|
|
278595
|
+
["/persona", "swap saffron or quill"],
|
|
278596
|
+
["/permission", "change autonomy for the next turns"],
|
|
278597
|
+
["/login", "connect your Perch account"]
|
|
278598
|
+
];
|
|
278437
278599
|
if (!process.env.PERCH_CLI_BUNDLE_ENTRY && process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
278438
278600
|
runPerchCli(process.argv.slice(2)).then((code) => {
|
|
278439
278601
|
process.exitCode = code;
|