@hosty-sdk/app 0.46.0 → 0.47.0

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/README.md CHANGED
@@ -293,6 +293,11 @@ Select an app ID and interface key explicitly, use `list("speech-to-text")`, `sp
293
293
  and `transcribe(selected, wavBlob, { signal })` on the server. Never expose the app service token to
294
294
  a browser. Transcription accepts the provider's documented format; the v1 baseline is 16 kHz mono
295
295
  PCM16 WAV. Browser microphone consent is separate from Core permission.
296
+ `transcribe` defaults to a five-minute total deadline. Long-recording consumers can supply an integer
297
+ `timeoutMs` between 1 and 930,000 (fifteen minutes thirty seconds); cancellation still applies.
298
+ Speech transport uses a request-owned matching Undici fetch/dispatcher so its response-header and
299
+ body timeouts match the selected deadline. Other SDK operations and the global dispatcher retain
300
+ their existing behavior. Validate the selected provider's duration/byte capabilities before capture.
296
301
 
297
302
  `assistant(selected, getUserToken)` returns the existing `AssistantClient` with bounded provider
298
303
  credentials and the acting user's access. It does not expose general agent execution.
@@ -36,7 +36,8 @@ export declare class ProviderClient {
36
36
  speechCapabilities(provider: Pick<ProviderDescriptor, "appId" | "key">, signal?: AbortSignal): Promise<SpeechCapabilities>;
37
37
  transcribe(provider: Pick<ProviderDescriptor, "appId" | "key">, audio: Blob, options?: {
38
38
  language?: string;
39
- signal?: AbortSignal;
39
+ signal?: AbortSignal; /** Total deadline, 1–930000 ms; defaults to five minutes. */
40
+ timeoutMs?: number;
40
41
  }): Promise<SpeechResult>;
41
42
  translationCapabilities(provider: Pick<ProviderDescriptor, "appId" | "key">, signal?: AbortSignal): Promise<TranslationCapabilities>;
42
43
  /** Translate text or Markdown through the explicitly selected provider; never retries or falls back. */
@@ -1,4 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
+ import { Agent, fetch as speechFetch } from "undici";
2
3
  import { AssistantClient } from "@hosty-sdk/app/assistant";
3
4
  import { ProviderError } from "@hosty-sdk/app/providers";
4
5
  /** Server-only provider client. Its app service token must never be sent to a browser or provider. */
@@ -66,13 +67,30 @@ export class ProviderClient {
66
67
  return read(await fetch(`${binding.url}/capabilities`, { redirect: "error", signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(10_000)]) : AbortSignal.timeout(10_000), headers: { authorization: `Bearer ${binding.token}` } }));
67
68
  }
68
69
  async transcribe(provider, audio, options = {}) {
69
- const signal = options.signal ? AbortSignal.any([options.signal, AbortSignal.timeout(300_000)]) : AbortSignal.timeout(300_000);
70
+ const timeoutMs = options.timeoutMs ?? 300_000;
71
+ if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 930_000)
72
+ throw new ProviderError("speech_timeout_invalid", "Use a transcription timeout between 1 and 930000 milliseconds.", 400);
73
+ const deadline = AbortSignal.timeout(timeoutMs);
74
+ const signal = options.signal ? AbortSignal.any([options.signal, deadline]) : deadline;
70
75
  const binding = await this.connect({ ...provider, kind: "speech-to-text" }, signal);
71
76
  const url = new URL(`${binding.url}/transcriptions`);
72
77
  if (options.language)
73
78
  url.searchParams.set("language", options.language);
74
- return read(await fetch(url, { method: "POST", redirect: "error", signal,
75
- headers: { authorization: `Bearer ${binding.token}`, "content-type": audio.type || "audio/wav" }, body: audio }));
79
+ const body = new Uint8Array(await audio.arrayBuffer());
80
+ signal.throwIfAborted();
81
+ // Node fetch has an independent response-header timeout. A request-owned dispatcher keeps it
82
+ // aligned with the caller's bounded deadline without changing any other consumer's transport.
83
+ const dispatcher = new Agent({ headersTimeout: timeoutMs, bodyTimeout: timeoutMs });
84
+ const init = { method: "POST", redirect: "error", signal, dispatcher,
85
+ headers: { authorization: `Bearer ${binding.token}`, "content-type": audio.type || "audio/wav" }, body };
86
+ // Use fetch from the same Undici version as the dispatcher; Node's bundled fetch can expose
87
+ // a different handler ABI when an app upgrades its Undici dependency independently.
88
+ try {
89
+ return await read(await speechFetch(url, init));
90
+ }
91
+ finally {
92
+ await dispatcher.close();
93
+ }
76
94
  }
77
95
  async translationCapabilities(provider, signal) {
78
96
  const binding = await this.connect({ ...provider, kind: "translation" }, signal);
@@ -0,0 +1,4 @@
1
+ /** Panel manifests carry Lucide names, including legacy component-name spellings. */
2
+ export declare function UiPanelIcon({ name }: {
3
+ name: string | null;
4
+ }): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { DynamicIcon, iconNames } from "lucide-react/dynamic.mjs";
4
+ import { SdkIcon } from "./sdk-chrome.js";
5
+ const normalize = (name) => name.replace(/[-_\s]/g, "").toLowerCase();
6
+ const names = new Map(iconNames.map(name => [normalize(name), name]));
7
+ const fallback = () => _jsx(SdkIcon, { name: "tools" });
8
+ /** Panel manifests carry Lucide names, including legacy component-name spellings. */
9
+ export function UiPanelIcon({ name }) {
10
+ const icon = name ? names.get(normalize(name.trim())) : undefined;
11
+ return icon ? _jsx(DynamicIcon, { name: icon, fallback: fallback, className: "hosty-sdk-icon", "aria-hidden": "true", focusable: "false" }, icon) : fallback();
12
+ }
@@ -2,6 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { createContext, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
4
4
  import { SdkIcon } from "./sdk-chrome.js";
5
+ import { UiPanelIcon } from "./ui-panel-icon.js";
5
6
  import { UiHostContext } from "./ui-context.js";
6
7
  import { useHostyChrome, useHostyNavigation } from "./ui-navigation-react.js";
7
8
  import { StandaloneNavigationContext } from "./ui-standalone-context.js";
@@ -43,5 +44,5 @@ export function StandaloneHeader({ panels, selected, expanded, onSelect, onChoos
43
44
  const icon = app?.iconUrl && /^(https?:\/\/|\/(?!\/))/.test(app.iconUrl) ? app.iconUrl : null;
44
45
  const showNavigation = canNavigate && chrome.navigation === "show" && (navigation.status !== "ready" || navigation.entries.length > 0);
45
46
  const toolsVisible = chrome.tools.enabled && chrome.tools.launcher !== "hide";
46
- return _jsxs("header", { "data-hosty-sdk": true, className: "hosty-standalone-header", children: [_jsxs("div", { className: "hosty-standalone-identity", children: [showNavigation && nav && _jsx("button", { ref: nav.opener, type: "button", className: "hosty-standalone-navigation", disabled: !prefs.ready, "aria-label": nav.narrow ? nav.open ? "Hide navigation" : "Show navigation" : prefs.collapsed ? "Show navigation" : "Hide navigation", title: nav.narrow ? "Page navigation" : prefs.collapsed ? "Show navigation" : "Hide navigation", "aria-expanded": nav.narrow ? nav.open : !prefs.collapsed, onClick: () => nav.narrow ? nav.setOpen(!nav.open) : prefs.setCollapsed(!prefs.collapsed), children: _jsx(SdkIcon, { name: "sidebar" }) }), icon && icon !== failedIcon ? _jsx("img", { src: icon, alt: "", draggable: false, onError: () => setFailedIcon(icon) }) : _jsx(SdkIcon, { name: "app" }), _jsx("strong", { title: name, children: name })] }), toolsVisible && _jsxs("div", { className: "hosty-standalone-tools", children: [_jsx("nav", { className: "hosty-pinned-tools", "aria-label": "Pinned tools", children: prefs.pins.map(key => panels.find(panel => panelKey(panel.panel) === key)).filter((panel) => !!panel).map(panel => _jsxs("button", { type: "button", "aria-label": `Open ${panel.appName} — ${panel.label}`, title: `${panel.appName}: ${panel.label}`, "aria-expanded": expanded && selected === panelKey(panel.panel), onClick: () => onSelect(panel), children: [_jsx(SdkIcon, { name: "tools" }), _jsx("span", { children: panel.label }), attention(panel) && _jsx("span", { className: "hosty-panel-attention", "aria-label": "Needs attention", children: _jsx(SdkIcon, { name: "warning" }) })] }, panelKey(panel.panel))) }), _jsxs("button", { type: "button", "aria-label": "Tools", "aria-haspopup": "dialog", "aria-expanded": chooserOpen, onClick: onChoose, children: [_jsx(SdkIcon, { name: "tools" }), _jsx("span", { children: "Tools" }), _jsx(SdkIcon, { name: "chevron" })] })] })] });
47
+ return _jsxs("header", { "data-hosty-sdk": true, className: "hosty-standalone-header", children: [_jsxs("div", { className: "hosty-standalone-identity", children: [showNavigation && nav && _jsx("button", { ref: nav.opener, type: "button", className: "hosty-standalone-navigation", disabled: !prefs.ready, "aria-label": nav.narrow ? nav.open ? "Hide navigation" : "Show navigation" : prefs.collapsed ? "Show navigation" : "Hide navigation", title: nav.narrow ? "Page navigation" : prefs.collapsed ? "Show navigation" : "Hide navigation", "aria-expanded": nav.narrow ? nav.open : !prefs.collapsed, onClick: () => nav.narrow ? nav.setOpen(!nav.open) : prefs.setCollapsed(!prefs.collapsed), children: _jsx(SdkIcon, { name: "sidebar" }) }), icon && icon !== failedIcon ? _jsx("img", { src: icon, alt: "", draggable: false, onError: () => setFailedIcon(icon) }) : _jsx(SdkIcon, { name: "app" }), _jsx("strong", { title: name, children: name })] }), toolsVisible && _jsxs("div", { className: "hosty-standalone-tools", children: [_jsx("nav", { className: "hosty-pinned-tools", "aria-label": "Pinned tools", children: prefs.pins.map(key => panels.find(panel => panelKey(panel.panel) === key)).filter((panel) => !!panel).map(panel => _jsxs("button", { type: "button", "aria-label": `Open ${panel.appName} — ${panel.label}`, title: `${panel.appName}: ${panel.label}`, "aria-expanded": expanded && selected === panelKey(panel.panel), onClick: () => onSelect(panel), children: [_jsx(UiPanelIcon, { name: panel.icon }), _jsx("span", { children: panel.label }), attention(panel) && _jsx("span", { className: "hosty-panel-attention", "aria-label": "Needs attention", children: _jsx(SdkIcon, { name: "warning" }) })] }, panelKey(panel.panel))) }), _jsxs("button", { type: "button", "aria-label": "Tools", "aria-haspopup": "dialog", "aria-expanded": chooserOpen, onClick: onChoose, children: [_jsx(SdkIcon, { name: "tools" }), _jsx("span", { children: "Tools" }), _jsx(SdkIcon, { name: "chevron" })] })] })] });
47
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hosty-sdk/app",
3
- "version": "0.46.0",
3
+ "version": "0.47.0",
4
4
  "description": "Hosty app auth: session state machine, recovery bridge, Core revalidation, and the embedder responder.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -176,7 +176,9 @@
176
176
  },
177
177
  "dependencies": {
178
178
  "@noble/hashes": "^2.4.0",
179
- "server-only": "^0.0.1"
179
+ "lucide-react": "^1.55.0",
180
+ "server-only": "^0.0.1",
181
+ "undici": "^8.12.3"
180
182
  },
181
183
  "peerDependencies": {
182
184
  "next": "^16.4.0",