@hasna/oldpal 0.3.7 → 0.3.9
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 +232 -190
- package/dist/index.js.map +8 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28594,7 +28594,7 @@ var import_react20 = __toESM(require_react(), 1);
|
|
|
28594
28594
|
// node_modules/.pnpm/ink@5.2.1_@types+react@18.3.27_react-devtools-core@4.28.5_react@18.3.1/node_modules/ink/build/hooks/use-focus-manager.js
|
|
28595
28595
|
var import_react21 = __toESM(require_react(), 1);
|
|
28596
28596
|
// packages/terminal/src/components/App.tsx
|
|
28597
|
-
var
|
|
28597
|
+
var import_react26 = __toESM(require_react(), 1);
|
|
28598
28598
|
// packages/shared/src/utils.ts
|
|
28599
28599
|
import { randomUUID } from "crypto";
|
|
28600
28600
|
function generateId() {
|
|
@@ -30118,16 +30118,20 @@ class BuiltinCommands {
|
|
|
30118
30118
|
registerAll(loader) {
|
|
30119
30119
|
loader.register(this.helpCommand(loader));
|
|
30120
30120
|
loader.register(this.clearCommand());
|
|
30121
|
+
loader.register(this.newCommand());
|
|
30121
30122
|
loader.register(this.statusCommand());
|
|
30123
|
+
loader.register(this.tokensCommand());
|
|
30122
30124
|
loader.register(this.compactCommand());
|
|
30123
30125
|
loader.register(this.configCommand());
|
|
30124
30126
|
loader.register(this.initCommand());
|
|
30125
30127
|
loader.register(this.costCommand());
|
|
30126
30128
|
loader.register(this.modelCommand());
|
|
30129
|
+
loader.register(this.skillsCommand(loader));
|
|
30127
30130
|
loader.register(this.memoryCommand());
|
|
30128
30131
|
loader.register(this.bugCommand());
|
|
30129
30132
|
loader.register(this.prCommand());
|
|
30130
30133
|
loader.register(this.reviewCommand());
|
|
30134
|
+
loader.register(this.exitCommand());
|
|
30131
30135
|
}
|
|
30132
30136
|
updateTokenUsage(usage) {
|
|
30133
30137
|
Object.assign(this.tokenUsage, usage);
|
|
@@ -30203,6 +30207,117 @@ class BuiltinCommands {
|
|
|
30203
30207
|
}
|
|
30204
30208
|
};
|
|
30205
30209
|
}
|
|
30210
|
+
newCommand() {
|
|
30211
|
+
return {
|
|
30212
|
+
name: "new",
|
|
30213
|
+
description: "Start a new conversation",
|
|
30214
|
+
builtin: true,
|
|
30215
|
+
selfHandled: true,
|
|
30216
|
+
content: "",
|
|
30217
|
+
handler: async (args, context) => {
|
|
30218
|
+
context.clearMessages();
|
|
30219
|
+
this.tokenUsage.inputTokens = 0;
|
|
30220
|
+
this.tokenUsage.outputTokens = 0;
|
|
30221
|
+
this.tokenUsage.totalTokens = 0;
|
|
30222
|
+
context.emit("text", `Starting new conversation.
|
|
30223
|
+
`);
|
|
30224
|
+
context.emit("done");
|
|
30225
|
+
return { handled: true, clearConversation: true };
|
|
30226
|
+
}
|
|
30227
|
+
};
|
|
30228
|
+
}
|
|
30229
|
+
exitCommand() {
|
|
30230
|
+
return {
|
|
30231
|
+
name: "exit",
|
|
30232
|
+
description: "Exit oldpal",
|
|
30233
|
+
builtin: true,
|
|
30234
|
+
selfHandled: true,
|
|
30235
|
+
content: "",
|
|
30236
|
+
handler: async (args, context) => {
|
|
30237
|
+
context.emit("text", `Goodbye!
|
|
30238
|
+
`);
|
|
30239
|
+
context.emit("done");
|
|
30240
|
+
return { handled: true, exit: true };
|
|
30241
|
+
}
|
|
30242
|
+
};
|
|
30243
|
+
}
|
|
30244
|
+
tokensCommand() {
|
|
30245
|
+
return {
|
|
30246
|
+
name: "tokens",
|
|
30247
|
+
description: "Show token usage",
|
|
30248
|
+
builtin: true,
|
|
30249
|
+
selfHandled: true,
|
|
30250
|
+
content: "",
|
|
30251
|
+
handler: async (args, context) => {
|
|
30252
|
+
const usage = this.tokenUsage;
|
|
30253
|
+
const usedPercent = Math.round(usage.totalTokens / usage.maxContextTokens * 100);
|
|
30254
|
+
let message = `
|
|
30255
|
+
**Token Usage**
|
|
30256
|
+
|
|
30257
|
+
`;
|
|
30258
|
+
message += `Input: ${usage.inputTokens.toLocaleString()}
|
|
30259
|
+
`;
|
|
30260
|
+
message += `Output: ${usage.outputTokens.toLocaleString()}
|
|
30261
|
+
`;
|
|
30262
|
+
message += `Total: ${usage.totalTokens.toLocaleString()} / ${usage.maxContextTokens.toLocaleString()} (${usedPercent}%)
|
|
30263
|
+
`;
|
|
30264
|
+
const barLength = 30;
|
|
30265
|
+
const filledLength = Math.round(usedPercent / 100 * barLength);
|
|
30266
|
+
const bar = "\u2588".repeat(filledLength) + "\u2591".repeat(barLength - filledLength);
|
|
30267
|
+
message += `
|
|
30268
|
+
[${bar}] ${usedPercent}%
|
|
30269
|
+
`;
|
|
30270
|
+
context.emit("text", message);
|
|
30271
|
+
context.emit("done");
|
|
30272
|
+
return { handled: true };
|
|
30273
|
+
}
|
|
30274
|
+
};
|
|
30275
|
+
}
|
|
30276
|
+
skillsCommand(loader) {
|
|
30277
|
+
return {
|
|
30278
|
+
name: "skills",
|
|
30279
|
+
description: "List available skills",
|
|
30280
|
+
builtin: true,
|
|
30281
|
+
selfHandled: true,
|
|
30282
|
+
content: "",
|
|
30283
|
+
handler: async (args, context) => {
|
|
30284
|
+
let message = `
|
|
30285
|
+
**Available Skills**
|
|
30286
|
+
|
|
30287
|
+
`;
|
|
30288
|
+
message += `Skills are invoked with /skill-name [arguments]
|
|
30289
|
+
|
|
30290
|
+
`;
|
|
30291
|
+
message += `**Built-in Skills:**
|
|
30292
|
+
`;
|
|
30293
|
+
message += ` /brainstorm - Generate ideas on a topic
|
|
30294
|
+
`;
|
|
30295
|
+
message += ` /draft - Draft content (emails, docs, etc.)
|
|
30296
|
+
`;
|
|
30297
|
+
message += ` /research - Research a topic
|
|
30298
|
+
`;
|
|
30299
|
+
message += ` /summarize - Summarize text or content
|
|
30300
|
+
`;
|
|
30301
|
+
message += `
|
|
30302
|
+
**Connector Skills:**
|
|
30303
|
+
`;
|
|
30304
|
+
message += ` /calendar - Manage calendar events
|
|
30305
|
+
`;
|
|
30306
|
+
message += ` /email - Read and send emails
|
|
30307
|
+
`;
|
|
30308
|
+
message += ` /notes - Manage notes (Notion)
|
|
30309
|
+
`;
|
|
30310
|
+
message += ` /search - Search the web
|
|
30311
|
+
`;
|
|
30312
|
+
message += `
|
|
30313
|
+
Custom skills can be added in .oldpal/skills/
|
|
30314
|
+
`;
|
|
30315
|
+
context.emit("text", message);
|
|
30316
|
+
context.emit("done");
|
|
30317
|
+
return { handled: true };
|
|
30318
|
+
}
|
|
30319
|
+
};
|
|
30320
|
+
}
|
|
30206
30321
|
statusCommand() {
|
|
30207
30322
|
return {
|
|
30208
30323
|
name: "status",
|
|
@@ -30759,6 +30874,9 @@ class AgentLoop {
|
|
|
30759
30874
|
if (commandResult.clearConversation) {
|
|
30760
30875
|
this.context = new AgentContext;
|
|
30761
30876
|
}
|
|
30877
|
+
if (commandResult.exit) {
|
|
30878
|
+
this.emit({ type: "exit" });
|
|
30879
|
+
}
|
|
30762
30880
|
return;
|
|
30763
30881
|
}
|
|
30764
30882
|
if (commandResult.prompt) {
|
|
@@ -31259,10 +31377,19 @@ var jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
|
|
|
31259
31377
|
var COMMANDS = [
|
|
31260
31378
|
{ name: "/help", description: "show available commands" },
|
|
31261
31379
|
{ name: "/clear", description: "clear the conversation" },
|
|
31262
|
-
{ name: "/model", description: "change the AI model" },
|
|
31263
|
-
{ name: "/skills", description: "list available skills" },
|
|
31264
|
-
{ name: "/tokens", description: "show token usage" },
|
|
31265
31380
|
{ name: "/new", description: "start a new conversation" },
|
|
31381
|
+
{ name: "/status", description: "show session status" },
|
|
31382
|
+
{ name: "/tokens", description: "show token usage" },
|
|
31383
|
+
{ name: "/cost", description: "show estimated API cost" },
|
|
31384
|
+
{ name: "/model", description: "show model information" },
|
|
31385
|
+
{ name: "/skills", description: "list available skills" },
|
|
31386
|
+
{ name: "/config", description: "show configuration" },
|
|
31387
|
+
{ name: "/init", description: "initialize oldpal in project" },
|
|
31388
|
+
{ name: "/compact", description: "summarize to save context" },
|
|
31389
|
+
{ name: "/memory", description: "show what AI remembers" },
|
|
31390
|
+
{ name: "/bug", description: "analyze and fix a bug" },
|
|
31391
|
+
{ name: "/pr", description: "create a pull request" },
|
|
31392
|
+
{ name: "/review", description: "review code changes" },
|
|
31266
31393
|
{ name: "/exit", description: "exit oldpal" }
|
|
31267
31394
|
];
|
|
31268
31395
|
function Input({ onSubmit, isProcessing, queueLength = 0, commands }) {
|
|
@@ -31871,154 +31998,32 @@ function ProcessingIndicator({
|
|
|
31871
31998
|
}, undefined, true, undefined, this);
|
|
31872
31999
|
}
|
|
31873
32000
|
|
|
31874
|
-
// packages/terminal/src/components/ToolCallBox.tsx
|
|
31875
|
-
var import_react26 = __toESM(require_react(), 1);
|
|
31876
|
-
var jsx_dev_runtime7 = __toESM(require_jsx_dev_runtime(), 1);
|
|
31877
|
-
function ToolCallBox({
|
|
31878
|
-
entries,
|
|
31879
|
-
maxVisible = 3,
|
|
31880
|
-
isExpanded = false,
|
|
31881
|
-
onToggleExpand
|
|
31882
|
-
}) {
|
|
31883
|
-
if (entries.length === 0) {
|
|
31884
|
-
return null;
|
|
31885
|
-
}
|
|
31886
|
-
const visibleEntries = isExpanded ? entries : entries.slice(-maxVisible);
|
|
31887
|
-
const hiddenCount = entries.length - visibleEntries.length;
|
|
31888
|
-
return /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Box_default, {
|
|
31889
|
-
flexDirection: "column",
|
|
31890
|
-
borderStyle: "round",
|
|
31891
|
-
borderColor: "gray",
|
|
31892
|
-
paddingX: 1,
|
|
31893
|
-
marginY: 1,
|
|
31894
|
-
children: [
|
|
31895
|
-
/* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Box_default, {
|
|
31896
|
-
justifyContent: "space-between",
|
|
31897
|
-
children: [
|
|
31898
|
-
/* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
|
|
31899
|
-
dimColor: true,
|
|
31900
|
-
bold: true,
|
|
31901
|
-
children: [
|
|
31902
|
-
"Tools (",
|
|
31903
|
-
entries.length,
|
|
31904
|
-
")"
|
|
31905
|
-
]
|
|
31906
|
-
}, undefined, true, undefined, this),
|
|
31907
|
-
entries.length > maxVisible && /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
|
|
31908
|
-
dimColor: true,
|
|
31909
|
-
children: isExpanded ? "Ctrl+O to collapse" : "Ctrl+O to expand"
|
|
31910
|
-
}, undefined, false, undefined, this)
|
|
31911
|
-
]
|
|
31912
|
-
}, undefined, true, undefined, this),
|
|
31913
|
-
hiddenCount > 0 && !isExpanded && /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
|
|
31914
|
-
dimColor: true,
|
|
31915
|
-
children: [
|
|
31916
|
-
" +",
|
|
31917
|
-
hiddenCount,
|
|
31918
|
-
" more above..."
|
|
31919
|
-
]
|
|
31920
|
-
}, undefined, true, undefined, this),
|
|
31921
|
-
visibleEntries.map((entry, index) => /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ToolCallRow, {
|
|
31922
|
-
entry
|
|
31923
|
-
}, entry.toolCall.id, false, undefined, this))
|
|
31924
|
-
]
|
|
31925
|
-
}, undefined, true, undefined, this);
|
|
31926
|
-
}
|
|
31927
|
-
function ToolCallRow({ entry }) {
|
|
31928
|
-
const { toolCall, result } = entry;
|
|
31929
|
-
const statusIcon = result ? result.isError ? "\u2717" : "\u2713" : "\u25D0";
|
|
31930
|
-
const statusColor = result ? result.isError ? "red" : "green" : "yellow";
|
|
31931
|
-
return /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Box_default, {
|
|
31932
|
-
children: [
|
|
31933
|
-
/* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
|
|
31934
|
-
color: statusColor,
|
|
31935
|
-
children: [
|
|
31936
|
-
statusIcon,
|
|
31937
|
-
" "
|
|
31938
|
-
]
|
|
31939
|
-
}, undefined, true, undefined, this),
|
|
31940
|
-
/* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
|
|
31941
|
-
dimColor: true,
|
|
31942
|
-
children: formatToolCall2(toolCall)
|
|
31943
|
-
}, undefined, false, undefined, this)
|
|
31944
|
-
]
|
|
31945
|
-
}, undefined, true, undefined, this);
|
|
31946
|
-
}
|
|
31947
|
-
function formatToolCall2(toolCall) {
|
|
31948
|
-
const { name, input } = toolCall;
|
|
31949
|
-
switch (name) {
|
|
31950
|
-
case "bash":
|
|
31951
|
-
return `bash: ${truncate2(String(input.command || ""), 50)}`;
|
|
31952
|
-
case "curl":
|
|
31953
|
-
case "web_fetch":
|
|
31954
|
-
return `fetch: ${truncate2(String(input.url || ""), 50)}`;
|
|
31955
|
-
case "web_search":
|
|
31956
|
-
return `search: ${truncate2(String(input.query || ""), 50)}`;
|
|
31957
|
-
case "read":
|
|
31958
|
-
return `read: ${truncate2(String(input.path || input.file_path || ""), 50)}`;
|
|
31959
|
-
case "write":
|
|
31960
|
-
return `write: ${truncate2(String(input.path || input.file_path || ""), 50)}`;
|
|
31961
|
-
case "glob":
|
|
31962
|
-
return `glob: ${truncate2(String(input.pattern || ""), 50)}`;
|
|
31963
|
-
case "grep":
|
|
31964
|
-
return `grep: ${truncate2(String(input.pattern || ""), 50)}`;
|
|
31965
|
-
case "notion":
|
|
31966
|
-
return `notion: ${truncate2(String(input.command || input.action || ""), 50)}`;
|
|
31967
|
-
case "gmail":
|
|
31968
|
-
return `gmail: ${truncate2(String(input.command || input.action || ""), 50)}`;
|
|
31969
|
-
case "googledrive":
|
|
31970
|
-
return `drive: ${truncate2(String(input.command || input.action || ""), 50)}`;
|
|
31971
|
-
case "googlecalendar":
|
|
31972
|
-
return `calendar: ${truncate2(String(input.command || input.action || ""), 50)}`;
|
|
31973
|
-
case "linear":
|
|
31974
|
-
return `linear: ${truncate2(String(input.command || input.action || ""), 50)}`;
|
|
31975
|
-
case "slack":
|
|
31976
|
-
return `slack: ${truncate2(String(input.command || input.action || ""), 50)}`;
|
|
31977
|
-
default:
|
|
31978
|
-
return `${name}: ${truncate2(JSON.stringify(input), 40)}`;
|
|
31979
|
-
}
|
|
31980
|
-
}
|
|
31981
|
-
function truncate2(text, maxLength) {
|
|
31982
|
-
if (text.length <= maxLength)
|
|
31983
|
-
return text;
|
|
31984
|
-
return text.slice(0, maxLength - 3) + "...";
|
|
31985
|
-
}
|
|
31986
|
-
function useToolCallExpansion() {
|
|
31987
|
-
const [isExpanded, setIsExpanded] = import_react26.useState(false);
|
|
31988
|
-
use_input_default((input, key) => {
|
|
31989
|
-
if (key.ctrl && input === "o") {
|
|
31990
|
-
setIsExpanded((prev) => !prev);
|
|
31991
|
-
}
|
|
31992
|
-
});
|
|
31993
|
-
return { isExpanded, setIsExpanded };
|
|
31994
|
-
}
|
|
31995
|
-
|
|
31996
32001
|
// packages/terminal/src/components/WelcomeBanner.tsx
|
|
31997
|
-
var
|
|
32002
|
+
var jsx_dev_runtime7 = __toESM(require_jsx_dev_runtime(), 1);
|
|
31998
32003
|
function WelcomeBanner({ version, model, directory }) {
|
|
31999
32004
|
const homeDir = process.env.HOME || "";
|
|
32000
32005
|
const displayDir = directory.startsWith(homeDir) ? "~" + directory.slice(homeDir.length) : directory;
|
|
32001
|
-
return /* @__PURE__ */
|
|
32006
|
+
return /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Box_default, {
|
|
32002
32007
|
flexDirection: "column",
|
|
32003
32008
|
marginBottom: 1,
|
|
32004
32009
|
children: [
|
|
32005
|
-
/* @__PURE__ */
|
|
32010
|
+
/* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Box_default, {
|
|
32006
32011
|
children: [
|
|
32007
|
-
/* @__PURE__ */
|
|
32012
|
+
/* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
|
|
32008
32013
|
color: "cyan",
|
|
32009
32014
|
bold: true,
|
|
32010
32015
|
children: ">"
|
|
32011
32016
|
}, undefined, false, undefined, this),
|
|
32012
|
-
/* @__PURE__ */
|
|
32017
|
+
/* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
|
|
32013
32018
|
color: "cyan",
|
|
32014
32019
|
bold: true,
|
|
32015
32020
|
children: "_ "
|
|
32016
32021
|
}, undefined, false, undefined, this),
|
|
32017
|
-
/* @__PURE__ */
|
|
32022
|
+
/* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
|
|
32018
32023
|
bold: true,
|
|
32019
32024
|
children: "oldpal"
|
|
32020
32025
|
}, undefined, false, undefined, this),
|
|
32021
|
-
/* @__PURE__ */
|
|
32026
|
+
/* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
|
|
32022
32027
|
dimColor: true,
|
|
32023
32028
|
children: [
|
|
32024
32029
|
" (v",
|
|
@@ -32028,29 +32033,29 @@ function WelcomeBanner({ version, model, directory }) {
|
|
|
32028
32033
|
}, undefined, true, undefined, this)
|
|
32029
32034
|
]
|
|
32030
32035
|
}, undefined, true, undefined, this),
|
|
32031
|
-
/* @__PURE__ */
|
|
32036
|
+
/* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Box_default, {
|
|
32032
32037
|
marginTop: 1,
|
|
32033
32038
|
children: [
|
|
32034
|
-
/* @__PURE__ */
|
|
32039
|
+
/* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
|
|
32035
32040
|
dimColor: true,
|
|
32036
32041
|
children: "model: "
|
|
32037
32042
|
}, undefined, false, undefined, this),
|
|
32038
|
-
/* @__PURE__ */
|
|
32043
|
+
/* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
|
|
32039
32044
|
children: model
|
|
32040
32045
|
}, undefined, false, undefined, this),
|
|
32041
|
-
/* @__PURE__ */
|
|
32046
|
+
/* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
|
|
32042
32047
|
dimColor: true,
|
|
32043
32048
|
children: " /model to change"
|
|
32044
32049
|
}, undefined, false, undefined, this)
|
|
32045
32050
|
]
|
|
32046
32051
|
}, undefined, true, undefined, this),
|
|
32047
|
-
/* @__PURE__ */
|
|
32052
|
+
/* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Box_default, {
|
|
32048
32053
|
children: [
|
|
32049
|
-
/* @__PURE__ */
|
|
32054
|
+
/* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
|
|
32050
32055
|
dimColor: true,
|
|
32051
32056
|
children: "directory: "
|
|
32052
32057
|
}, undefined, false, undefined, this),
|
|
32053
|
-
/* @__PURE__ */
|
|
32058
|
+
/* @__PURE__ */ jsx_dev_runtime7.jsxDEV(Text, {
|
|
32054
32059
|
children: displayDir
|
|
32055
32060
|
}, undefined, false, undefined, this)
|
|
32056
32061
|
]
|
|
@@ -32060,30 +32065,53 @@ function WelcomeBanner({ version, model, directory }) {
|
|
|
32060
32065
|
}
|
|
32061
32066
|
|
|
32062
32067
|
// packages/terminal/src/components/App.tsx
|
|
32063
|
-
var
|
|
32068
|
+
var jsx_dev_runtime8 = __toESM(require_jsx_dev_runtime(), 1);
|
|
32069
|
+
function formatToolName(toolCall) {
|
|
32070
|
+
const { name, input } = toolCall;
|
|
32071
|
+
switch (name) {
|
|
32072
|
+
case "bash":
|
|
32073
|
+
return `bash`;
|
|
32074
|
+
case "read":
|
|
32075
|
+
const path = String(input.path || input.file_path || "");
|
|
32076
|
+
return `read ${path.split("/").pop() || ""}`;
|
|
32077
|
+
case "write":
|
|
32078
|
+
const writePath = String(input.path || input.file_path || "");
|
|
32079
|
+
return `write ${writePath.split("/").pop() || ""}`;
|
|
32080
|
+
case "glob":
|
|
32081
|
+
return `glob`;
|
|
32082
|
+
case "grep":
|
|
32083
|
+
return `grep`;
|
|
32084
|
+
case "web_search":
|
|
32085
|
+
return `search`;
|
|
32086
|
+
case "web_fetch":
|
|
32087
|
+
case "curl":
|
|
32088
|
+
return `fetch`;
|
|
32089
|
+
default:
|
|
32090
|
+
return name;
|
|
32091
|
+
}
|
|
32092
|
+
}
|
|
32064
32093
|
function App2({ cwd: cwd2 }) {
|
|
32065
32094
|
const { exit } = use_app_default();
|
|
32066
|
-
const [client, setClient] =
|
|
32067
|
-
const [messages, setMessages] =
|
|
32068
|
-
const [currentResponse, setCurrentResponse] =
|
|
32069
|
-
const [currentToolCall, setCurrentToolCall] =
|
|
32070
|
-
const [lastToolResult, setLastToolResult] =
|
|
32071
|
-
const [isProcessing, setIsProcessing] =
|
|
32072
|
-
const [isInitializing, setIsInitializing] =
|
|
32073
|
-
const [error, setError] =
|
|
32074
|
-
const [messageQueue, setMessageQueue] =
|
|
32075
|
-
const [activityLog, setActivityLog] =
|
|
32076
|
-
const [tokenUsage, setTokenUsage] =
|
|
32077
|
-
const [processingStartTime, setProcessingStartTime] =
|
|
32078
|
-
const [currentTurnTokens, setCurrentTurnTokens] =
|
|
32079
|
-
const [scrollOffset, setScrollOffset] =
|
|
32080
|
-
const [autoScroll, setAutoScroll] =
|
|
32081
|
-
const
|
|
32082
|
-
const
|
|
32083
|
-
const
|
|
32084
|
-
const
|
|
32085
|
-
const
|
|
32086
|
-
const processQueue = import_react27.useCallback(async () => {
|
|
32095
|
+
const [client, setClient] = import_react26.useState(null);
|
|
32096
|
+
const [messages, setMessages] = import_react26.useState([]);
|
|
32097
|
+
const [currentResponse, setCurrentResponse] = import_react26.useState("");
|
|
32098
|
+
const [currentToolCall, setCurrentToolCall] = import_react26.useState();
|
|
32099
|
+
const [lastToolResult, setLastToolResult] = import_react26.useState();
|
|
32100
|
+
const [isProcessing, setIsProcessing] = import_react26.useState(false);
|
|
32101
|
+
const [isInitializing, setIsInitializing] = import_react26.useState(true);
|
|
32102
|
+
const [error, setError] = import_react26.useState(null);
|
|
32103
|
+
const [messageQueue, setMessageQueue] = import_react26.useState([]);
|
|
32104
|
+
const [activityLog, setActivityLog] = import_react26.useState([]);
|
|
32105
|
+
const [tokenUsage, setTokenUsage] = import_react26.useState();
|
|
32106
|
+
const [processingStartTime, setProcessingStartTime] = import_react26.useState();
|
|
32107
|
+
const [currentTurnTokens, setCurrentTurnTokens] = import_react26.useState(0);
|
|
32108
|
+
const [scrollOffset, setScrollOffset] = import_react26.useState(0);
|
|
32109
|
+
const [autoScroll, setAutoScroll] = import_react26.useState(true);
|
|
32110
|
+
const responseRef = import_react26.useRef("");
|
|
32111
|
+
const clientRef = import_react26.useRef(null);
|
|
32112
|
+
const toolCallsRef = import_react26.useRef([]);
|
|
32113
|
+
const toolResultsRef = import_react26.useRef([]);
|
|
32114
|
+
const processQueue = import_react26.useCallback(async () => {
|
|
32087
32115
|
if (!clientRef.current || messageQueue.length === 0)
|
|
32088
32116
|
return;
|
|
32089
32117
|
const nextMessage = messageQueue[0];
|
|
@@ -32108,7 +32136,7 @@ function App2({ cwd: cwd2 }) {
|
|
|
32108
32136
|
setIsProcessing(true);
|
|
32109
32137
|
await clientRef.current.send(nextMessage);
|
|
32110
32138
|
}, [messageQueue]);
|
|
32111
|
-
|
|
32139
|
+
import_react26.useEffect(() => {
|
|
32112
32140
|
const initClient = async () => {
|
|
32113
32141
|
try {
|
|
32114
32142
|
const newClient = new EmbeddedClient(cwd2);
|
|
@@ -32157,6 +32185,8 @@ function App2({ cwd: cwd2 }) {
|
|
|
32157
32185
|
} else if (chunk.type === "error" && chunk.error) {
|
|
32158
32186
|
setError(chunk.error);
|
|
32159
32187
|
setIsProcessing(false);
|
|
32188
|
+
} else if (chunk.type === "exit") {
|
|
32189
|
+
exit();
|
|
32160
32190
|
} else if (chunk.type === "usage" && chunk.usage) {
|
|
32161
32191
|
setTokenUsage(chunk.usage);
|
|
32162
32192
|
setCurrentTurnTokens((prev) => prev + (chunk.usage?.outputTokens || 0));
|
|
@@ -32216,17 +32246,19 @@ function App2({ cwd: cwd2 }) {
|
|
|
32216
32246
|
};
|
|
32217
32247
|
initClient();
|
|
32218
32248
|
}, [cwd2]);
|
|
32219
|
-
|
|
32249
|
+
import_react26.useEffect(() => {
|
|
32220
32250
|
if (!isProcessing && messageQueue.length > 0) {
|
|
32221
32251
|
processQueue();
|
|
32222
32252
|
}
|
|
32223
32253
|
}, [isProcessing, messageQueue.length, processQueue]);
|
|
32224
|
-
|
|
32254
|
+
import_react26.useEffect(() => {
|
|
32225
32255
|
if (autoScroll) {
|
|
32226
32256
|
setScrollOffset(0);
|
|
32227
32257
|
}
|
|
32228
32258
|
}, [messages.length, autoScroll]);
|
|
32229
|
-
const
|
|
32259
|
+
const baseMaxVisible = 10;
|
|
32260
|
+
const toolCallsHeight = isProcessing ? Math.min(toolCallsRef.current.length, 5) : 0;
|
|
32261
|
+
const maxVisibleMessages = Math.max(3, baseMaxVisible - toolCallsHeight);
|
|
32230
32262
|
use_input_default((input, key) => {
|
|
32231
32263
|
if (key.ctrl && input === "c") {
|
|
32232
32264
|
if (isProcessing && client) {
|
|
@@ -32297,7 +32329,7 @@ function App2({ cwd: cwd2 }) {
|
|
|
32297
32329
|
setAutoScroll(true);
|
|
32298
32330
|
}
|
|
32299
32331
|
});
|
|
32300
|
-
const handleSubmit =
|
|
32332
|
+
const handleSubmit = import_react26.useCallback(async (input, mode = "normal") => {
|
|
32301
32333
|
if (!client || !input.trim())
|
|
32302
32334
|
return;
|
|
32303
32335
|
const trimmedInput = input.trim();
|
|
@@ -32346,10 +32378,10 @@ function App2({ cwd: cwd2 }) {
|
|
|
32346
32378
|
await client.send(trimmedInput);
|
|
32347
32379
|
}, [client, isProcessing]);
|
|
32348
32380
|
if (isInitializing) {
|
|
32349
|
-
return /* @__PURE__ */
|
|
32381
|
+
return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
|
|
32350
32382
|
flexDirection: "column",
|
|
32351
32383
|
padding: 1,
|
|
32352
|
-
children: /* @__PURE__ */
|
|
32384
|
+
children: /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Spinner2, {
|
|
32353
32385
|
label: "Initializing..."
|
|
32354
32386
|
}, undefined, false, undefined, this)
|
|
32355
32387
|
}, undefined, false, undefined, this);
|
|
@@ -32360,17 +32392,17 @@ function App2({ cwd: cwd2 }) {
|
|
|
32360
32392
|
});
|
|
32361
32393
|
const isThinking = isProcessing && !currentResponse && !currentToolCall && toolCallEntries.length === 0;
|
|
32362
32394
|
const showWelcome = messages.length === 0 && !isProcessing;
|
|
32363
|
-
return /* @__PURE__ */
|
|
32395
|
+
return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
|
|
32364
32396
|
flexDirection: "column",
|
|
32365
32397
|
padding: 1,
|
|
32366
32398
|
children: [
|
|
32367
|
-
showWelcome && /* @__PURE__ */
|
|
32368
|
-
version: "0.3.
|
|
32399
|
+
showWelcome && /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(WelcomeBanner, {
|
|
32400
|
+
version: "0.3.9",
|
|
32369
32401
|
model: "claude-sonnet-4-20250514",
|
|
32370
32402
|
directory: cwd2
|
|
32371
32403
|
}, undefined, false, undefined, this),
|
|
32372
|
-
scrollOffset > 0 && /* @__PURE__ */
|
|
32373
|
-
children: /* @__PURE__ */
|
|
32404
|
+
scrollOffset > 0 && /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
|
|
32405
|
+
children: /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
|
|
32374
32406
|
dimColor: true,
|
|
32375
32407
|
children: [
|
|
32376
32408
|
"\u2191 ",
|
|
@@ -32379,7 +32411,7 @@ function App2({ cwd: cwd2 }) {
|
|
|
32379
32411
|
]
|
|
32380
32412
|
}, undefined, true, undefined, this)
|
|
32381
32413
|
}, undefined, false, undefined, this),
|
|
32382
|
-
/* @__PURE__ */
|
|
32414
|
+
/* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Messages4, {
|
|
32383
32415
|
messages,
|
|
32384
32416
|
currentResponse: isProcessing ? currentResponse : undefined,
|
|
32385
32417
|
currentToolCall: undefined,
|
|
@@ -32388,14 +32420,24 @@ function App2({ cwd: cwd2 }) {
|
|
|
32388
32420
|
scrollOffset,
|
|
32389
32421
|
maxVisible: maxVisibleMessages
|
|
32390
32422
|
}, undefined, false, undefined, this),
|
|
32391
|
-
isProcessing && toolCallEntries.length > 0 && /* @__PURE__ */
|
|
32392
|
-
|
|
32393
|
-
|
|
32394
|
-
|
|
32423
|
+
isProcessing && toolCallEntries.length > 0 && /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
|
|
32424
|
+
marginY: 1,
|
|
32425
|
+
children: /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
|
|
32426
|
+
dimColor: true,
|
|
32427
|
+
children: [
|
|
32428
|
+
"\u2699 ",
|
|
32429
|
+
toolCallEntries.length,
|
|
32430
|
+
" tool",
|
|
32431
|
+
toolCallEntries.length > 1 ? "s" : "",
|
|
32432
|
+
" running",
|
|
32433
|
+
toolCallEntries.length > 0 && `: ${formatToolName(toolCallEntries[toolCallEntries.length - 1].toolCall)}`,
|
|
32434
|
+
toolCallEntries.length > 1 && ` (+${toolCallEntries.length - 1} more)`
|
|
32435
|
+
]
|
|
32436
|
+
}, undefined, true, undefined, this)
|
|
32395
32437
|
}, undefined, false, undefined, this),
|
|
32396
|
-
messageQueue.length > 0 && /* @__PURE__ */
|
|
32438
|
+
messageQueue.length > 0 && /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
|
|
32397
32439
|
marginY: 1,
|
|
32398
|
-
children: /* @__PURE__ */
|
|
32440
|
+
children: /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
|
|
32399
32441
|
dimColor: true,
|
|
32400
32442
|
children: [
|
|
32401
32443
|
messageQueue.length,
|
|
@@ -32405,9 +32447,9 @@ function App2({ cwd: cwd2 }) {
|
|
|
32405
32447
|
]
|
|
32406
32448
|
}, undefined, true, undefined, this)
|
|
32407
32449
|
}, undefined, false, undefined, this),
|
|
32408
|
-
error && /* @__PURE__ */
|
|
32450
|
+
error && /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
|
|
32409
32451
|
marginY: 1,
|
|
32410
|
-
children: /* @__PURE__ */
|
|
32452
|
+
children: /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
|
|
32411
32453
|
color: "red",
|
|
32412
32454
|
children: [
|
|
32413
32455
|
"Error: ",
|
|
@@ -32415,18 +32457,18 @@ function App2({ cwd: cwd2 }) {
|
|
|
32415
32457
|
]
|
|
32416
32458
|
}, undefined, true, undefined, this)
|
|
32417
32459
|
}, undefined, false, undefined, this),
|
|
32418
|
-
/* @__PURE__ */
|
|
32460
|
+
/* @__PURE__ */ jsx_dev_runtime8.jsxDEV(ProcessingIndicator, {
|
|
32419
32461
|
isProcessing,
|
|
32420
32462
|
startTime: processingStartTime,
|
|
32421
32463
|
tokenCount: currentTurnTokens,
|
|
32422
32464
|
isThinking
|
|
32423
32465
|
}, undefined, false, undefined, this),
|
|
32424
|
-
/* @__PURE__ */
|
|
32466
|
+
/* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Input, {
|
|
32425
32467
|
onSubmit: handleSubmit,
|
|
32426
32468
|
isProcessing,
|
|
32427
32469
|
queueLength: messageQueue.length
|
|
32428
32470
|
}, undefined, false, undefined, this),
|
|
32429
|
-
/* @__PURE__ */
|
|
32471
|
+
/* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Status, {
|
|
32430
32472
|
isProcessing,
|
|
32431
32473
|
cwd: cwd2,
|
|
32432
32474
|
queueLength: messageQueue.length,
|
|
@@ -32437,7 +32479,7 @@ function App2({ cwd: cwd2 }) {
|
|
|
32437
32479
|
}
|
|
32438
32480
|
|
|
32439
32481
|
// packages/terminal/src/index.tsx
|
|
32440
|
-
var
|
|
32482
|
+
var jsx_dev_runtime9 = __toESM(require_jsx_dev_runtime(), 1);
|
|
32441
32483
|
var args = process.argv.slice(2);
|
|
32442
32484
|
var options = {
|
|
32443
32485
|
cwd: process.cwd(),
|
|
@@ -32445,7 +32487,7 @@ var options = {
|
|
|
32445
32487
|
help: args.includes("--help") || args.includes("-h")
|
|
32446
32488
|
};
|
|
32447
32489
|
if (options.version) {
|
|
32448
|
-
console.log("oldpal v0.3.
|
|
32490
|
+
console.log("oldpal v0.3.9");
|
|
32449
32491
|
process.exit(0);
|
|
32450
32492
|
}
|
|
32451
32493
|
if (options.help) {
|
|
@@ -32469,11 +32511,11 @@ In interactive mode:
|
|
|
32469
32511
|
`);
|
|
32470
32512
|
process.exit(0);
|
|
32471
32513
|
}
|
|
32472
|
-
var { waitUntilExit } = render_default(/* @__PURE__ */
|
|
32514
|
+
var { waitUntilExit } = render_default(/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(App2, {
|
|
32473
32515
|
cwd: options.cwd
|
|
32474
32516
|
}, undefined, false, undefined, this));
|
|
32475
32517
|
waitUntilExit().then(() => {
|
|
32476
32518
|
process.exit(0);
|
|
32477
32519
|
});
|
|
32478
32520
|
|
|
32479
|
-
//# debugId=
|
|
32521
|
+
//# debugId=4B7AD4CD51004C7264756E2164756E21
|