@ottocode/web-sdk 0.1.259 → 0.1.261

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":"GitDiffViewer.d.ts","sourceRoot":"","sources":["../../../src/components/git/GitDiffViewer.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAoBvD,UAAU,kBAAkB;IAC3B,IAAI,EAAE,eAAe,CAAC;CACtB;AA0DD,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,EAAE,kBAAkB,2CAgUzD"}
1
+ {"version":3,"file":"GitDiffViewer.d.ts","sourceRoot":"","sources":["../../../src/components/git/GitDiffViewer.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAoBvD,UAAU,kBAAkB;IAC3B,IAAI,EAAE,eAAe,CAAC;CACtB;AA0DD,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,EAAE,kBAAkB,2CAoUzD"}
@@ -361,6 +361,7 @@ function Toaster() {
361
361
  }
362
362
  // src/components/ui/ToolApprovalDialog.tsx
363
363
  import { useCallback as useCallback2, useState as useState3 } from "react";
364
+ import { resolveApproval } from "@ottocode/api";
364
365
 
365
366
  // src/stores/toolApprovalStore.ts
366
367
  import { create as create3 } from "zustand";
@@ -403,12 +404,12 @@ function ToolApprovalDialog({
403
404
  const handleApproval = useCallback2(async (callId, approved) => {
404
405
  setProcessingId(callId);
405
406
  try {
406
- const response = await fetch(`${baseUrl}/v1/sessions/${sessionId}/approval`, {
407
- method: "POST",
408
- headers: { "Content-Type": "application/json" },
409
- body: JSON.stringify({ callId, approved })
407
+ const response = await resolveApproval({
408
+ baseURL: baseUrl,
409
+ path: { id: sessionId },
410
+ body: { callId, approved }
410
411
  });
411
- if (response.ok) {
412
+ if (!response.error) {
412
413
  removePendingApproval(callId);
413
414
  }
414
415
  } catch (error) {
@@ -797,7 +798,8 @@ import {
797
798
  updateSession as apiUpdateSession,
798
799
  getSessionQueue as apiGetSessionQueue,
799
800
  removeFromQueue as apiRemoveFromQueue,
800
- retryMessage as apiRetryMessage
801
+ retryMessage as apiRetryMessage,
802
+ buildSessionStreamUrl
801
803
  } from "@ottocode/api";
802
804
 
803
805
  // src/lib/api-client/utils.ts
@@ -979,7 +981,7 @@ var sessionsMixin = {
979
981
  return response.data;
980
982
  },
981
983
  getStreamUrl(sessionId) {
982
- return `${getBaseUrl()}/v1/sessions/${sessionId}/stream`;
984
+ return buildSessionStreamUrl({ baseUrl: getBaseUrl(), sessionId });
983
985
  },
984
986
  async retryMessage(sessionId, messageId) {
985
987
  const response = await apiRetryMessage({
@@ -1141,6 +1143,7 @@ import {
1141
1143
  getConfig as apiGetConfig,
1142
1144
  getProviderModels as apiGetProviderModels,
1143
1145
  getAllModels as apiGetAllModels,
1146
+ discoverProviderModels as apiDiscoverProviderModels,
1144
1147
  updateDefaults as apiUpdateDefaults,
1145
1148
  updateProviderSettings as apiUpdateProviderSettings,
1146
1149
  deleteProviderSettings as apiDeleteProviderSettings
@@ -1167,15 +1170,12 @@ var configMixin = {
1167
1170
  return response.data;
1168
1171
  },
1169
1172
  async discoverProviderModels(data) {
1170
- const response = await fetch(`${getBaseUrl()}/v1/config/providers/discover-models`, {
1171
- method: "POST",
1172
- headers: { "content-type": "application/json" },
1173
- body: JSON.stringify(data)
1173
+ const response = await apiDiscoverProviderModels({
1174
+ body: data
1174
1175
  });
1175
- const payload = await response.json();
1176
- if (!response.ok)
1177
- throw new Error(extractErrorMessage(payload));
1178
- return payload;
1176
+ if (response.error)
1177
+ throw new Error(extractErrorMessage(response.error));
1178
+ return response.data;
1179
1179
  },
1180
1180
  async updateProviderSettings(provider, data) {
1181
1181
  const response = await apiUpdateProviderSettings({
@@ -17224,6 +17224,7 @@ import {
17224
17224
  prism as prism9,
17225
17225
  vscDarkPlus as vscDarkPlus9
17226
17226
  } from "react-syntax-highlighter/dist/esm/styles/prism";
17227
+ import { client as client2 } from "@ottocode/api";
17227
17228
  import { jsx as jsx72, jsxs as jsxs64, Fragment as Fragment31 } from "react/jsx-runtime";
17228
17229
  var IMAGE_EXTENSIONS = new Set([
17229
17230
  "png",
@@ -17358,7 +17359,11 @@ function GitDiffViewer({ diff }) {
17358
17359
  }
17359
17360
  if (diff.isBinary) {
17360
17361
  const isImage = isImageFile(diff.file);
17361
- const imageUrl = isImage ? `${getRuntimeApiBaseUrl()}/v1/files/raw?path=${encodeURIComponent(diff.file)}` : null;
17362
+ const imageUrl = isImage ? client2.buildUrl({
17363
+ baseURL: getRuntimeApiBaseUrl(),
17364
+ url: "/v1/files/raw",
17365
+ query: { path: diff.file }
17366
+ }) : null;
17362
17367
  return /* @__PURE__ */ jsxs64("div", {
17363
17368
  className: "flex flex-col h-full bg-background",
17364
17369
  children: [
@@ -19084,7 +19089,7 @@ var TerminalTabBar = memo23(function TerminalTabBar2({
19084
19089
  // src/components/terminals/TerminalViewer.tsx
19085
19090
  import { useEffect as useEffect31, useRef as useRef20, useState as useState36, useCallback as useCallback23 } from "react";
19086
19091
  import { init, Terminal as Terminal7, FitAddon } from "ghostty-web";
19087
- import { client as client2 } from "@ottocode/api";
19092
+ import { client as client3 } from "@ottocode/api";
19088
19093
  import { jsx as jsx80, jsxs as jsxs72 } from "react/jsx-runtime";
19089
19094
  var FONT_FAMILY = '"JetBrainsMono NFM", monospace';
19090
19095
  var WS_RECONNECT_DELAY = 1500;
@@ -19151,7 +19156,7 @@ async function loadEmbeddedFont() {
19151
19156
  fontsLoaded2 = true;
19152
19157
  }
19153
19158
  function resolveApiBaseUrl() {
19154
- const config2 = client2.getConfig?.();
19159
+ const config2 = client3.getConfig?.();
19155
19160
  if (config2 && typeof config2.baseURL === "string" && config2.baseURL.length > 0) {
19156
19161
  return config2.baseURL;
19157
19162
  }
@@ -20511,74 +20516,56 @@ import {
20511
20516
 
20512
20517
  // src/hooks/useResearch.ts
20513
20518
  import { useQuery as useQuery11, useMutation as useMutation7, useQueryClient as useQueryClient13 } from "@tanstack/react-query";
20519
+ import {
20520
+ createResearchSession as apiCreateResearchSession,
20521
+ deleteResearchSession as apiDeleteResearchSession,
20522
+ exportResearchSession as apiExportResearchSession,
20523
+ injectResearchContext as apiInjectResearchContext,
20524
+ listResearchSessions as apiListResearchSessions
20525
+ } from "@ottocode/api";
20514
20526
  class ResearchApiClient {
20515
- get baseUrl() {
20516
- const win = window;
20517
- if (win.OTTO_SERVER_URL) {
20518
- return win.OTTO_SERVER_URL;
20519
- }
20520
- if (import.meta.env?.VITE_API_BASE_URL) {
20521
- return import.meta.env.VITE_API_BASE_URL;
20522
- }
20523
- return API_BASE_URL;
20524
- }
20525
20527
  async listResearchSessions(parentSessionId) {
20526
- const response = await fetch(`${this.baseUrl}/v1/sessions/${parentSessionId}/research`, {
20527
- method: "GET",
20528
- headers: { "Content-Type": "application/json" }
20528
+ const response = await apiListResearchSessions({
20529
+ path: { parentId: parentSessionId }
20529
20530
  });
20530
- if (!response.ok) {
20531
- const error = await response.json().catch(() => ({ error: "Failed to fetch research sessions" }));
20532
- throw new Error(error.error || "Failed to fetch research sessions");
20533
- }
20534
- return response.json();
20531
+ if (response.error)
20532
+ throw new Error(JSON.stringify(response.error));
20533
+ return response.data;
20535
20534
  }
20536
20535
  async createResearchSession(parentSessionId, data) {
20537
- const response = await fetch(`${this.baseUrl}/v1/sessions/${parentSessionId}/research`, {
20538
- method: "POST",
20539
- headers: { "Content-Type": "application/json" },
20540
- body: JSON.stringify(data)
20536
+ const response = await apiCreateResearchSession({
20537
+ path: { parentId: parentSessionId },
20538
+ body: data
20541
20539
  });
20542
- if (!response.ok) {
20543
- const error = await response.json().catch(() => ({ error: "Failed to create research session" }));
20544
- throw new Error(error.error || "Failed to create research session");
20545
- }
20546
- return response.json();
20540
+ if (response.error)
20541
+ throw new Error(JSON.stringify(response.error));
20542
+ return response.data;
20547
20543
  }
20548
20544
  async deleteResearchSession(researchId) {
20549
- const response = await fetch(`${this.baseUrl}/v1/research/${researchId}`, {
20550
- method: "DELETE",
20551
- headers: { "Content-Type": "application/json" }
20545
+ const response = await apiDeleteResearchSession({
20546
+ path: { researchId }
20552
20547
  });
20553
- if (!response.ok) {
20554
- const error = await response.json().catch(() => ({ error: "Failed to delete research session" }));
20555
- throw new Error(error.error || "Failed to delete research session");
20556
- }
20557
- return response.json();
20548
+ if (response.error)
20549
+ throw new Error(JSON.stringify(response.error));
20550
+ return response.data;
20558
20551
  }
20559
20552
  async injectContext(parentSessionId, researchSessionId, label) {
20560
- const response = await fetch(`${this.baseUrl}/v1/sessions/${parentSessionId}/inject`, {
20561
- method: "POST",
20562
- headers: { "Content-Type": "application/json" },
20563
- body: JSON.stringify({ researchSessionId, label })
20553
+ const response = await apiInjectResearchContext({
20554
+ path: { parentId: parentSessionId },
20555
+ body: { researchSessionId, label }
20564
20556
  });
20565
- if (!response.ok) {
20566
- const error = await response.json().catch(() => ({ error: "Failed to inject context" }));
20567
- throw new Error(error.error || "Failed to inject context");
20568
- }
20569
- return response.json();
20557
+ if (response.error)
20558
+ throw new Error(JSON.stringify(response.error));
20559
+ return response.data;
20570
20560
  }
20571
20561
  async exportToNewSession(researchId, data) {
20572
- const response = await fetch(`${this.baseUrl}/v1/research/${researchId}/export`, {
20573
- method: "POST",
20574
- headers: { "Content-Type": "application/json" },
20575
- body: JSON.stringify(data ?? {})
20562
+ const response = await apiExportResearchSession({
20563
+ path: { researchId },
20564
+ body: data ?? {}
20576
20565
  });
20577
- if (!response.ok) {
20578
- const error = await response.json().catch(() => ({ error: "Failed to export to session" }));
20579
- throw new Error(error.error || "Failed to export to session");
20580
- }
20581
- return response.json();
20566
+ if (response.error)
20567
+ throw new Error(JSON.stringify(response.error));
20568
+ return response.data;
20582
20569
  }
20583
20570
  }
20584
20571
  var researchApi = new ResearchApiClient;
@@ -22738,30 +22725,38 @@ import { QRCodeSVG as QRCodeSVG2 } from "qrcode.react";
22738
22725
  // src/hooks/useTunnel.ts
22739
22726
  import { useQuery as useQuery12, useMutation as useMutation9, useQueryClient as useQueryClient16 } from "@tanstack/react-query";
22740
22727
  import { useEffect as useEffect38, useCallback as useCallback28, useRef as useRef27 } from "react";
22728
+ import {
22729
+ client as client4,
22730
+ getTunnelQr,
22731
+ getTunnelStatus,
22732
+ startTunnel as apiStartTunnel,
22733
+ stopTunnel as apiStopTunnel
22734
+ } from "@ottocode/api";
22741
22735
  async function fetchTunnelStatus() {
22742
- const response = await fetch(`${API_BASE_URL}/v1/tunnel/status`);
22743
- if (!response.ok) {
22744
- throw new Error("Failed to fetch tunnel status");
22745
- }
22746
- return response.json();
22736
+ const response = await getTunnelStatus();
22737
+ if (response.error)
22738
+ throw new Error(JSON.stringify(response.error));
22739
+ return response.data;
22747
22740
  }
22748
22741
  async function startTunnel() {
22749
- const response = await fetch(`${API_BASE_URL}/v1/tunnel/start`, {
22750
- method: "POST",
22751
- headers: { "Content-Type": "application/json" },
22752
- body: JSON.stringify({})
22742
+ const response = await apiStartTunnel({
22743
+ body: {}
22753
22744
  });
22754
- return response.json();
22745
+ if (response.error)
22746
+ throw new Error(JSON.stringify(response.error));
22747
+ return response.data;
22755
22748
  }
22756
22749
  async function stopTunnel() {
22757
- const response = await fetch(`${API_BASE_URL}/v1/tunnel/stop`, {
22758
- method: "POST"
22759
- });
22760
- return response.json();
22750
+ const response = await apiStopTunnel();
22751
+ if (response.error)
22752
+ throw new Error(JSON.stringify(response.error));
22753
+ return response.data;
22761
22754
  }
22762
22755
  async function fetchTunnelQr() {
22763
- const response = await fetch(`${API_BASE_URL}/v1/tunnel/qr`);
22764
- return response.json();
22756
+ const response = await getTunnelQr();
22757
+ if (response.error)
22758
+ throw new Error(JSON.stringify(response.error));
22759
+ return response.data;
22765
22760
  }
22766
22761
  function useTunnelStatus() {
22767
22762
  const setStatus = useTunnelStore((s) => s.setStatus);
@@ -22850,7 +22845,7 @@ function useTunnelStream() {
22850
22845
  if (eventSourceRef.current) {
22851
22846
  eventSourceRef.current.close();
22852
22847
  }
22853
- const es = new EventSource(`${API_BASE_URL}/v1/tunnel/stream`);
22848
+ const es = new EventSource(client4.buildUrl({ baseURL: API_BASE_URL, url: "/v1/tunnel/stream" }));
22854
22849
  eventSourceRef.current = es;
22855
22850
  es.onmessage = (event) => {
22856
22851
  try {
@@ -27561,4 +27556,4 @@ export {
27561
27556
  AssistantMessageGroup
27562
27557
  };
27563
27558
 
27564
- //# debugId=D7B8A4AB823B4C9664756E2164756E21
27559
+ //# debugId=C2BE4DA33C4E63B064756E2164756E21