@hasna/oldpal 0.1.2 → 0.1.3
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 +22 -38
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -87387,13 +87387,15 @@ function App2({ cwd: cwd2 }) {
|
|
|
87387
87387
|
const [isInitializing, setIsInitializing] = import_react25.useState(true);
|
|
87388
87388
|
const [error, setError] = import_react25.useState(null);
|
|
87389
87389
|
const [toolStatus, setToolStatus] = import_react25.useState(null);
|
|
87390
|
+
const responseRef = import_react25.useRef("");
|
|
87390
87391
|
import_react25.useEffect(() => {
|
|
87391
87392
|
const initClient = async () => {
|
|
87392
87393
|
try {
|
|
87393
87394
|
const newClient = new EmbeddedClient(cwd2);
|
|
87394
87395
|
newClient.onChunk((chunk) => {
|
|
87395
87396
|
if (chunk.type === "text" && chunk.content) {
|
|
87396
|
-
|
|
87397
|
+
responseRef.current += chunk.content;
|
|
87398
|
+
setCurrentResponse(responseRef.current);
|
|
87397
87399
|
} else if (chunk.type === "tool_use" && chunk.toolCall) {
|
|
87398
87400
|
setToolStatus(`Running: ${chunk.toolCall.name}`);
|
|
87399
87401
|
} else if (chunk.type === "tool_result") {
|
|
@@ -87402,6 +87404,19 @@ function App2({ cwd: cwd2 }) {
|
|
|
87402
87404
|
setError(chunk.error);
|
|
87403
87405
|
setIsProcessing(false);
|
|
87404
87406
|
} else if (chunk.type === "done") {
|
|
87407
|
+
if (responseRef.current) {
|
|
87408
|
+
setMessages((prev) => [
|
|
87409
|
+
...prev,
|
|
87410
|
+
{
|
|
87411
|
+
id: generateId(),
|
|
87412
|
+
role: "assistant",
|
|
87413
|
+
content: responseRef.current,
|
|
87414
|
+
timestamp: now()
|
|
87415
|
+
}
|
|
87416
|
+
]);
|
|
87417
|
+
setCurrentResponse("");
|
|
87418
|
+
responseRef.current = "";
|
|
87419
|
+
}
|
|
87405
87420
|
setIsProcessing(false);
|
|
87406
87421
|
}
|
|
87407
87422
|
});
|
|
@@ -87441,49 +87456,18 @@ function App2({ cwd: cwd2 }) {
|
|
|
87441
87456
|
};
|
|
87442
87457
|
setMessages((prev) => [...prev, userMessage]);
|
|
87443
87458
|
setCurrentResponse("");
|
|
87459
|
+
responseRef.current = "";
|
|
87444
87460
|
setError(null);
|
|
87445
87461
|
setIsProcessing(true);
|
|
87446
87462
|
await client.send(trimmedInput);
|
|
87447
|
-
|
|
87448
|
-
const assistantMessage = {
|
|
87449
|
-
id: generateId(),
|
|
87450
|
-
role: "assistant",
|
|
87451
|
-
content: currentResponse,
|
|
87452
|
-
timestamp: now()
|
|
87453
|
-
};
|
|
87454
|
-
return [...prev, assistantMessage];
|
|
87455
|
-
});
|
|
87456
|
-
}, [client, isProcessing, currentResponse]);
|
|
87457
|
-
import_react25.useEffect(() => {
|
|
87458
|
-
if (!isProcessing && currentResponse) {
|
|
87459
|
-
setMessages((prev) => {
|
|
87460
|
-
const last = prev[prev.length - 1];
|
|
87461
|
-
if (last?.role === "assistant") {
|
|
87462
|
-
return [
|
|
87463
|
-
...prev.slice(0, -1),
|
|
87464
|
-
{ ...last, content: currentResponse }
|
|
87465
|
-
];
|
|
87466
|
-
}
|
|
87467
|
-
return [
|
|
87468
|
-
...prev,
|
|
87469
|
-
{
|
|
87470
|
-
id: generateId(),
|
|
87471
|
-
role: "assistant",
|
|
87472
|
-
content: currentResponse,
|
|
87473
|
-
timestamp: now()
|
|
87474
|
-
}
|
|
87475
|
-
];
|
|
87476
|
-
});
|
|
87477
|
-
setCurrentResponse("");
|
|
87478
|
-
}
|
|
87479
|
-
}, [isProcessing, currentResponse]);
|
|
87463
|
+
}, [client, isProcessing]);
|
|
87480
87464
|
if (isInitializing) {
|
|
87481
87465
|
return /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
|
|
87482
87466
|
flexDirection: "column",
|
|
87483
87467
|
padding: 1,
|
|
87484
87468
|
children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
|
|
87485
87469
|
children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Spinner2, {
|
|
87486
|
-
label: "Initializing
|
|
87470
|
+
label: "Initializing..."
|
|
87487
87471
|
}, undefined, false, undefined, this)
|
|
87488
87472
|
}, undefined, false, undefined, this)
|
|
87489
87473
|
}, undefined, false, undefined, this);
|
|
@@ -87494,7 +87478,7 @@ function App2({ cwd: cwd2 }) {
|
|
|
87494
87478
|
children: [
|
|
87495
87479
|
/* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Messages4, {
|
|
87496
87480
|
messages,
|
|
87497
|
-
currentResponse
|
|
87481
|
+
currentResponse: isProcessing ? currentResponse : undefined
|
|
87498
87482
|
}, undefined, false, undefined, this),
|
|
87499
87483
|
toolStatus && /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
|
|
87500
87484
|
marginY: 1,
|
|
@@ -87512,7 +87496,7 @@ function App2({ cwd: cwd2 }) {
|
|
|
87512
87496
|
]
|
|
87513
87497
|
}, undefined, true, undefined, this)
|
|
87514
87498
|
}, undefined, false, undefined, this),
|
|
87515
|
-
isProcessing && !toolStatus && /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
|
|
87499
|
+
isProcessing && !toolStatus && !currentResponse && /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
|
|
87516
87500
|
marginY: 1,
|
|
87517
87501
|
children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Spinner2, {
|
|
87518
87502
|
label: "Thinking..."
|
|
@@ -87570,4 +87554,4 @@ waitUntilExit().then(() => {
|
|
|
87570
87554
|
process.exit(0);
|
|
87571
87555
|
});
|
|
87572
87556
|
|
|
87573
|
-
//# debugId=
|
|
87557
|
+
//# debugId=247F96E7A96FC18464756E2164756E21
|