@personaai/react 0.7.9 → 0.7.10

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.cjs CHANGED
@@ -374,6 +374,37 @@ function parsePresentedFile(content) {
374
374
  return null;
375
375
  }
376
376
  }
377
+ function parseSandboxCommand(tc) {
378
+ let command = tc.args ?? "";
379
+ try {
380
+ const parsedArgs = JSON.parse(tc.args || "{}");
381
+ if (typeof parsedArgs.command === "string") command = parsedArgs.command;
382
+ } catch {
383
+ }
384
+ let output;
385
+ let exitCode;
386
+ if (tc.result) {
387
+ try {
388
+ const parsedResult = JSON.parse(tc.result);
389
+ if (typeof parsedResult.output === "string") {
390
+ output = parsedResult.output;
391
+ exitCode = typeof parsedResult.exitCode === "number" ? parsedResult.exitCode : null;
392
+ } else {
393
+ output = tc.result;
394
+ }
395
+ } catch {
396
+ output = tc.result;
397
+ }
398
+ }
399
+ return {
400
+ toolCallId: tc.toolCallId,
401
+ command,
402
+ output,
403
+ exitCode,
404
+ status: tc.isError ? "error" : tc.result ? "done" : "running",
405
+ seq: tc.seq
406
+ };
407
+ }
377
408
  function normalizeWorkspaceFiles(raw) {
378
409
  const normalized = {};
379
410
  for (const [path, file] of Object.entries(raw || {})) {
@@ -434,6 +465,15 @@ function useChat(options = {}) {
434
465
  const [files, setFiles] = (0, import_react2.useState)({});
435
466
  const [todos, setTodos] = (0, import_react2.useState)([]);
436
467
  const [presentedFile, setPresentedFile] = (0, import_react2.useState)(null);
468
+ const sandboxCommands = (0, import_react2.useMemo)(() => {
469
+ const commands = [];
470
+ for (const message of messages) {
471
+ for (const tc of message.toolCalls ?? []) {
472
+ if (tc.toolName === "execute") commands.push(parseSandboxCommand(tc));
473
+ }
474
+ }
475
+ return commands;
476
+ }, [messages]);
437
477
  const abortControllerRef = (0, import_react2.useRef)(null);
438
478
  const loadedThreadIdRef = (0, import_react2.useRef)(void 0);
439
479
  const voiceThreadRef = (0, import_react2.useRef)(threadId);
@@ -1109,6 +1149,7 @@ function useChat(options = {}) {
1109
1149
  presentedFile,
1110
1150
  dismissPresentedFile,
1111
1151
  openWorkspaceFile,
1152
+ sandboxCommands,
1112
1153
  stop,
1113
1154
  reload,
1114
1155
  clear,
@@ -2074,7 +2115,7 @@ function useMcp(options = {}) {
2074
2115
 
2075
2116
  // src/index.ts
2076
2117
  var import_logger2 = require("@personaai/logger");
2077
- var VERSION = "0.7.9";
2118
+ var VERSION = "0.7.10";
2078
2119
  // Annotate the CommonJS export names for ESM import in node:
2079
2120
  0 && (module.exports = {
2080
2121
  PersonaProvider,