@ottocode/web-sdk 0.1.291 → 0.1.292

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.
@@ -1 +1 @@
1
- {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAGA,KAAK,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAM9B,wBAAgB,QAAQ;;0BAqBV,KAAK;;EAclB;AAED,YAAY,EAAE,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAGA,KAAK,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAM9B,wBAAgB,QAAQ;;0BA6BV,KAAK;;EAwBlB;AAED,YAAY,EAAE,KAAK,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -1372,6 +1372,8 @@ function normalizeApiBaseUrl(value) {
1372
1372
  function getStoredApiBaseUrl() {
1373
1373
  if (typeof window === "undefined")
1374
1374
  return;
1375
+ if (isPlatformDesktop())
1376
+ return;
1375
1377
  try {
1376
1378
  return window.localStorage.getItem(RUNTIME_API_BASE_URL_STORAGE_KEY) ?? undefined;
1377
1379
  } catch {
@@ -1403,9 +1405,11 @@ function setRuntimeApiBaseUrl(value) {
1403
1405
  if (typeof window !== "undefined") {
1404
1406
  const win = window;
1405
1407
  win.OTTO_SERVER_URL = baseUrl;
1406
- try {
1407
- window.localStorage.setItem(RUNTIME_API_BASE_URL_STORAGE_KEY, baseUrl);
1408
- } catch {}
1408
+ if (!isPlatformDesktop()) {
1409
+ try {
1410
+ window.localStorage.setItem(RUNTIME_API_BASE_URL_STORAGE_KEY, baseUrl);
1411
+ } catch {}
1412
+ }
1409
1413
  }
1410
1414
  return baseUrl;
1411
1415
  }
@@ -12990,9 +12994,10 @@ function DebugRenderer({
12990
12994
  import { jsx as jsx55, jsxs as jsxs46 } from "react/jsx-runtime";
12991
12995
  function ProgressUpdateRenderer({ contentJson }) {
12992
12996
  const result = contentJson.result || {};
12993
- const message = String(result.message || "Processing...");
12994
- const stage = result.stage ? String(result.stage) : undefined;
12995
- const pct = result.pct ? Number(result.pct) : undefined;
12997
+ const args = contentJson.args || {};
12998
+ const message = String(result.message || args.message || "Processing...");
12999
+ const stage = result.stage ? String(result.stage) : args.stage ? String(args.stage) : undefined;
13000
+ const pct = result.pct ? Number(result.pct) : args.pct ? Number(args.pct) : undefined;
12996
13001
  return /* @__PURE__ */ jsxs46("div", {
12997
13002
  className: "flex min-h-5 items-start gap-2 text-sm leading-5 text-violet-700 dark:text-violet-300 animate-pulse",
12998
13003
  children: [
@@ -19330,28 +19335,55 @@ function parseToolResultContent(part) {
19330
19335
  function isTodoStatus(status) {
19331
19336
  return status === "pending" || status === "in_progress" || status === "completed" || status === "cancelled";
19332
19337
  }
19333
- function getTodoToolName(part, content) {
19334
- const name = part.toolName ?? content?.name;
19335
- return typeof name === "string" ? name : null;
19338
+ function asRecord(value) {
19339
+ return value && typeof value === "object" && !Array.isArray(value) ? value : null;
19336
19340
  }
19337
- function parseTodoSnapshot(content) {
19338
- const rawResult = content.result;
19339
- const result = rawResult && typeof rawResult === "object" && !Array.isArray(rawResult) ? rawResult : content;
19340
- const rawItems = result.items;
19341
+ function normalizeTodoItems(rawItems) {
19341
19342
  if (!Array.isArray(rawItems))
19342
19343
  return null;
19343
19344
  const items = rawItems.flatMap((item) => {
19344
- if (!item || typeof item !== "object" || Array.isArray(item)) {
19345
- return [];
19345
+ if (typeof item === "string") {
19346
+ const step2 = item.trim();
19347
+ return step2 ? [{ step: step2, status: "pending" }] : [];
19346
19348
  }
19347
- const record = item;
19348
- if (typeof record.step !== "string" || !isTodoStatus(record.status)) {
19349
+ const record = asRecord(item);
19350
+ if (!record)
19349
19351
  return [];
19350
- }
19351
- return [{ step: record.step, status: record.status }];
19352
+ const rawStep = typeof record.step === "string" ? record.step : typeof record.description === "string" ? record.description : "";
19353
+ const step = rawStep.trim();
19354
+ if (!step)
19355
+ return [];
19356
+ return [
19357
+ {
19358
+ step,
19359
+ status: isTodoStatus(record.status) ? record.status : "pending"
19360
+ }
19361
+ ];
19352
19362
  });
19353
- const note = typeof result.note === "string" ? result.note : undefined;
19354
- return { items, note };
19363
+ return items.length > 0 ? items : null;
19364
+ }
19365
+ function getTodoToolName(part, content) {
19366
+ const name = part.toolName ?? content?.name;
19367
+ return typeof name === "string" ? name : null;
19368
+ }
19369
+ function parseTodoSnapshot(content) {
19370
+ const result = asRecord(content.result) ?? content;
19371
+ const args = asRecord(content.args);
19372
+ const sources = [
19373
+ { rawItems: result.items, note: result.note },
19374
+ { rawItems: content.items, note: content.note },
19375
+ { rawItems: args?.todos, note: args?.note }
19376
+ ];
19377
+ for (const source of sources) {
19378
+ const items = normalizeTodoItems(source.rawItems);
19379
+ if (items) {
19380
+ return {
19381
+ items,
19382
+ note: typeof source.note === "string" ? source.note : undefined
19383
+ };
19384
+ }
19385
+ }
19386
+ return null;
19355
19387
  }
19356
19388
  function isTodoSnapshotDone(snapshot) {
19357
19389
  return snapshot.items.length > 0 && snapshot.items.every((item) => item.status === "completed" || item.status === "cancelled");
@@ -37715,14 +37747,21 @@ function useClientEvents(activeSessionId) {
37715
37747
  return buildClientEventsStreamUrl({ baseUrl: getBaseUrl() });
37716
37748
  }
37717
37749
  // src/hooks/useTheme.ts
37718
- import { useCallback as useCallback43, useEffect as useEffect68, useMemo as useMemo36 } from "react";
37750
+ import { useCallback as useCallback43, useEffect as useEffect68, useMemo as useMemo36, useState as useState59 } from "react";
37719
37751
  function normalizeTheme(theme) {
37720
37752
  return theme === "light" ? "light" : "dark";
37721
37753
  }
37722
37754
  function useTheme() {
37723
37755
  const { data: config2 } = useConfig();
37724
37756
  const updateDefaults = useUpdateDefaults();
37725
- const theme = normalizeTheme(config2?.defaults?.theme);
37757
+ const configTheme = normalizeTheme(config2?.defaults?.theme);
37758
+ const [optimisticTheme, setOptimisticTheme] = useState59(null);
37759
+ const theme = optimisticTheme ?? configTheme;
37760
+ useEffect68(() => {
37761
+ if (optimisticTheme === configTheme) {
37762
+ setOptimisticTheme(null);
37763
+ }
37764
+ }, [configTheme, optimisticTheme]);
37726
37765
  useEffect68(() => {
37727
37766
  if (typeof document === "undefined")
37728
37767
  return;
@@ -37737,7 +37776,12 @@ function useTheme() {
37737
37776
  }
37738
37777
  }, [theme]);
37739
37778
  const setTheme = useCallback43((nextTheme) => {
37740
- updateDefaults.mutate({ theme: nextTheme, scope: "global" });
37779
+ setOptimisticTheme(nextTheme);
37780
+ updateDefaults.mutate({ theme: nextTheme, scope: "global" }, {
37781
+ onError: () => {
37782
+ setOptimisticTheme((currentTheme) => currentTheme === nextTheme ? null : currentTheme);
37783
+ }
37784
+ });
37741
37785
  }, [updateDefaults]);
37742
37786
  const toggleTheme = useCallback43(() => {
37743
37787
  setTheme(theme === "dark" ? "light" : "dark");
@@ -37745,10 +37789,10 @@ function useTheme() {
37745
37789
  return useMemo36(() => ({ theme, setTheme, toggleTheme }), [theme, setTheme, toggleTheme]);
37746
37790
  }
37747
37791
  // src/hooks/useWorkingDirectory.ts
37748
- import { useEffect as useEffect69, useState as useState59 } from "react";
37792
+ import { useEffect as useEffect69, useState as useState60 } from "react";
37749
37793
  import { getCwd } from "@ottocode/api";
37750
37794
  function useWorkingDirectory() {
37751
- const [dirName, setDirName] = useState59(null);
37795
+ const [dirName, setDirName] = useState60(null);
37752
37796
  useEffect69(() => {
37753
37797
  const fetchWorkingDirectory = async () => {
37754
37798
  try {
@@ -38091,7 +38135,7 @@ function useKeyboardShortcuts({
38091
38135
  }
38092
38136
  // src/hooks/useImageUpload.ts
38093
38137
  import {
38094
- useState as useState60,
38138
+ useState as useState61,
38095
38139
  useCallback as useCallback45,
38096
38140
  useEffect as useEffect71
38097
38141
  } from "react";
@@ -38121,9 +38165,9 @@ async function fileToPreview2(file) {
38121
38165
  }
38122
38166
  function useImageUpload(options = {}) {
38123
38167
  const { maxImages = 5, maxSizeMB = 5, pageWide = true } = options;
38124
- const [images, setImages] = useState60([]);
38125
- const [isDragging, setIsDragging] = useState60(false);
38126
- const [error, setError] = useState60(null);
38168
+ const [images, setImages] = useState61([]);
38169
+ const [isDragging, setIsDragging] = useState61(false);
38170
+ const [error, setError] = useState61(null);
38127
38171
  const maxSizeBytes = maxSizeMB * 1024 * 1024;
38128
38172
  const validateFile = useCallback45((file) => {
38129
38173
  if (!SUPPORTED_TYPES.includes(file.type)) {
@@ -38660,4 +38704,4 @@ export {
38660
38704
  API_BASE_URL
38661
38705
  };
38662
38706
 
38663
- //# debugId=976BF87DC78E3DCF64756E2164756E21
38707
+ //# debugId=EF889705B19F428E64756E2164756E21