@iota-uz/sdk 0.4.26 → 0.4.27

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.
@@ -1830,7 +1830,11 @@ function readReasoningEffortOptionsFromGlobalContext() {
1830
1830
  if (!Array.isArray(opts) || opts.length === 0) {
1831
1831
  return void 0;
1832
1832
  }
1833
- return opts.filter((o) => typeof o === "string");
1833
+ const filtered = opts.filter((o) => typeof o === "string");
1834
+ if (filtered.length === 0) {
1835
+ return void 0;
1836
+ }
1837
+ return filtered;
1834
1838
  }
1835
1839
 
1836
1840
  // ui/src/bichat/machine/selectors.ts
@@ -1849,6 +1853,7 @@ function deriveSessionSnapshot(state, methods) {
1849
1853
  sessionDebugUsage: getSessionDebugUsage(state.messaging.turns),
1850
1854
  debugLimits: state.session.debugLimits,
1851
1855
  reasoningEffort: state.session.reasoningEffort,
1856
+ reasoningEffortOptions: state.session.reasoningEffortOptions,
1852
1857
  setError: methods.setError,
1853
1858
  retryFetchSession: methods.retryFetchSession,
1854
1859
  setReasoningEffort: methods.setReasoningEffort
@@ -2042,6 +2047,7 @@ var ChatMachine = class {
2042
2047
  this.fetchCancelled = false;
2043
2048
  this.disposed = false;
2044
2049
  this.reasoningEffortOptions = null;
2050
+ this.reasoningEffortOptionSet = null;
2045
2051
  /** Memoized sessionDebugUsage — avoids unnecessary session re-renders during streaming. */
2046
2052
  this.lastSessionDebugUsage = null;
2047
2053
  /** Interval handle for passive polling when another tab has an active stream. */
@@ -2129,6 +2135,7 @@ var ChatMachine = class {
2129
2135
  this.rateLimiter = config.rateLimiter;
2130
2136
  this.onSessionCreated = config.onSessionCreated;
2131
2137
  this.reasoningEffortOptions = this.buildReasoningEffortOptions();
2138
+ this.reasoningEffortOptionSet = this.reasoningEffortOptions ? new Set(this.reasoningEffortOptions) : null;
2132
2139
  const initialReasoningEffort = this.sanitizeReasoningEffort(loadReasoningEffort() || void 0);
2133
2140
  if (!initialReasoningEffort) {
2134
2141
  clearReasoningEffort();
@@ -2142,7 +2149,8 @@ var ChatMachine = class {
2142
2149
  errorRetryable: false,
2143
2150
  debugModeBySession: {},
2144
2151
  debugLimits: readDebugLimitsFromGlobalContext(),
2145
- reasoningEffort: initialReasoningEffort
2152
+ reasoningEffort: initialReasoningEffort,
2153
+ reasoningEffortOptions: this.reasoningEffortOptions ?? void 0
2146
2154
  },
2147
2155
  messaging: {
2148
2156
  turns: [],
@@ -2191,14 +2199,14 @@ var ChatMachine = class {
2191
2199
  if (!options || options.length === 0) {
2192
2200
  return null;
2193
2201
  }
2194
- return new Set(options);
2202
+ return options;
2195
2203
  }
2196
2204
  // Keep outbound payloads constrained to server-declared options.
2197
2205
  sanitizeReasoningEffort(effort) {
2198
- if (!effort || !this.reasoningEffortOptions || this.reasoningEffortOptions.size === 0) {
2206
+ if (!effort || !this.reasoningEffortOptionSet || this.reasoningEffortOptionSet.size === 0) {
2199
2207
  return void 0;
2200
2208
  }
2201
- return this.reasoningEffortOptions.has(effort) ? effort : void 0;
2209
+ return this.reasoningEffortOptionSet.has(effort) ? effort : void 0;
2202
2210
  }
2203
2211
  // =====================================================================
2204
2212
  // Lifecycle
@@ -7165,21 +7173,15 @@ function calculateContextUsagePercent(promptTokens, effectiveMaxTokens) {
7165
7173
  }
7166
7174
  return promptTokens / effectiveMaxTokens * 100;
7167
7175
  }
7168
- function CopyPill({ text }) {
7176
+ function useCopyFeedback() {
7169
7177
  const [copied, setCopied] = React.useState(false);
7170
7178
  const timerRef = React.useRef(null);
7171
- React.useEffect(() => () => {
7172
- if (timerRef.current !== null) {
7173
- clearTimeout(timerRef.current);
7174
- }
7175
- }, []);
7176
- const handleCopy = async (e) => {
7177
- e.stopPropagation();
7179
+ const copy = React.useCallback(async (text) => {
7178
7180
  try {
7179
7181
  await navigator.clipboard.writeText(text);
7180
7182
  setCopied(true);
7181
7183
  if (timerRef.current !== null) {
7182
- clearTimeout(timerRef.current);
7184
+ window.clearTimeout(timerRef.current);
7183
7185
  }
7184
7186
  timerRef.current = window.setTimeout(() => {
7185
7187
  setCopied(false);
@@ -7188,6 +7190,19 @@ function CopyPill({ text }) {
7188
7190
  } catch (err) {
7189
7191
  console.error("Copy failed:", err);
7190
7192
  }
7193
+ }, []);
7194
+ React.useEffect(() => () => {
7195
+ if (timerRef.current !== null) {
7196
+ window.clearTimeout(timerRef.current);
7197
+ }
7198
+ }, []);
7199
+ return { copied, copy };
7200
+ }
7201
+ function CopyPill({ text }) {
7202
+ const { copied, copy } = useCopyFeedback();
7203
+ const handleCopy = async (e) => {
7204
+ e.stopPropagation();
7205
+ await copy(text);
7191
7206
  };
7192
7207
  return /* @__PURE__ */ jsxRuntime.jsxs(
7193
7208
  "button",
@@ -7206,28 +7221,10 @@ function CopyPill({ text }) {
7206
7221
  );
7207
7222
  }
7208
7223
  function InlineCopyButton({ text }) {
7209
- const [copied, setCopied] = React.useState(false);
7210
- const timerRef = React.useRef(null);
7211
- React.useEffect(() => () => {
7212
- if (timerRef.current !== null) {
7213
- clearTimeout(timerRef.current);
7214
- }
7215
- }, []);
7224
+ const { copied, copy } = useCopyFeedback();
7216
7225
  const handleCopy = async (e) => {
7217
7226
  e.stopPropagation();
7218
- try {
7219
- await navigator.clipboard.writeText(text);
7220
- setCopied(true);
7221
- if (timerRef.current !== null) {
7222
- clearTimeout(timerRef.current);
7223
- }
7224
- timerRef.current = window.setTimeout(() => {
7225
- setCopied(false);
7226
- timerRef.current = null;
7227
- }, 2e3);
7228
- } catch (err) {
7229
- console.error("Copy failed:", err);
7230
- }
7227
+ await copy(text);
7231
7228
  };
7232
7229
  return /* @__PURE__ */ jsxRuntime.jsx(
7233
7230
  "button",
@@ -9490,6 +9487,16 @@ var MessageInput = React.forwardRef(
9490
9487
  const canSubmit = !disabled && (message.trim() || attachments.length > 0);
9491
9488
  const visibleError = error || commandError;
9492
9489
  const visibleErrorText = visibleError ? t(visibleError) : "";
9490
+ const resolvedReasoningEffort = reasoningEffortOptions && reasoningEffortOptions.length > 0 ? reasoningEffortOptions.includes(reasoningEffort ?? "") ? reasoningEffort : reasoningEffortOptions[1] || reasoningEffortOptions[0] : void 0;
9491
+ React.useEffect(() => {
9492
+ if (!onReasoningEffortChange || !reasoningEffortOptions?.length) {
9493
+ return;
9494
+ }
9495
+ if (!resolvedReasoningEffort || resolvedReasoningEffort === reasoningEffort) {
9496
+ return;
9497
+ }
9498
+ onReasoningEffortChange(resolvedReasoningEffort);
9499
+ }, [reasoningEffort, onReasoningEffortChange, reasoningEffortOptions, resolvedReasoningEffort]);
9493
9500
  const defaultContainerClassName = "shrink-0 px-4 pt-4 pb-6";
9494
9501
  return /* @__PURE__ */ jsxRuntime.jsx(
9495
9502
  "div",
@@ -9616,7 +9623,7 @@ var MessageInput = React.forwardRef(
9616
9623
  ReasoningEffortSelector,
9617
9624
  {
9618
9625
  options: reasoningEffortOptions,
9619
- value: reasoningEffort,
9626
+ value: resolvedReasoningEffort,
9620
9627
  onChange: onReasoningEffortChange,
9621
9628
  disabled: disabled || loading
9622
9629
  }
@@ -11822,7 +11829,8 @@ function ChatSessionCore({
11822
11829
  setError,
11823
11830
  retryFetchSession,
11824
11831
  reasoningEffort,
11825
- setReasoningEffort
11832
+ setReasoningEffort,
11833
+ reasoningEffortOptions
11826
11834
  } = useChatSession();
11827
11835
  const {
11828
11836
  turns,
@@ -11850,7 +11858,6 @@ function ChatSessionCore({
11850
11858
  const accessReadOnly = session?.access ? !session.access.canWrite : false;
11851
11859
  const effectiveReadOnly = Boolean(readOnly ?? isReadOnly) || isArchived || accessReadOnly;
11852
11860
  const [restoring, setRestoring] = React.useState(false);
11853
- const [reasoningEffortOptions] = React.useState(() => readReasoningEffortOptionsFromGlobalContext());
11854
11861
  const handleRestore = React.useCallback(async () => {
11855
11862
  if (!session?.id) {
11856
11863
  return;