@iota-uz/sdk 0.4.31 → 0.4.32

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.
@@ -1854,9 +1854,11 @@ function deriveSessionSnapshot(state, methods) {
1854
1854
  debugLimits: state.session.debugLimits,
1855
1855
  reasoningEffort: state.session.reasoningEffort,
1856
1856
  reasoningEffortOptions: state.session.reasoningEffortOptions,
1857
+ model: state.session.model,
1857
1858
  setError: methods.setError,
1858
1859
  retryFetchSession: methods.retryFetchSession,
1859
- setReasoningEffort: methods.setReasoningEffort
1860
+ setReasoningEffort: methods.setReasoningEffort,
1861
+ setModel: methods.setModel
1860
1862
  };
1861
1863
  }
1862
1864
  function deriveMessagingSnapshot(state, methods) {
@@ -2137,7 +2139,8 @@ var ChatMachine = class {
2137
2139
  this.cachedSessionSnapshot = deriveSessionSnapshot(this.state, {
2138
2140
  setError: this.setError,
2139
2141
  retryFetchSession: this.retryFetchSession,
2140
- setReasoningEffort: this.setReasoningEffort
2142
+ setReasoningEffort: this.setReasoningEffort,
2143
+ setModel: this.setModel
2141
2144
  });
2142
2145
  this.lastSessionSnapshotVersion = this.sessionSnapshotVersion;
2143
2146
  }
@@ -2209,7 +2212,8 @@ var ChatMachine = class {
2209
2212
  debugModeBySession: {},
2210
2213
  debugLimits: readDebugLimitsFromGlobalContext(),
2211
2214
  reasoningEffort: initialReasoningEffort,
2212
- reasoningEffortOptions: this.reasoningEffortOptions ?? void 0
2215
+ reasoningEffortOptions: this.reasoningEffortOptions ?? void 0,
2216
+ model: void 0
2213
2217
  },
2214
2218
  messaging: {
2215
2219
  turns: [],
@@ -2252,6 +2256,7 @@ var ChatMachine = class {
2252
2256
  this.removeQueueItem = this._removeQueueItem.bind(this);
2253
2257
  this.updateQueueItem = this._updateQueueItem.bind(this);
2254
2258
  this.setReasoningEffort = this._setReasoningEffort.bind(this);
2259
+ this.setModel = this._setModel.bind(this);
2255
2260
  }
2256
2261
  buildReasoningEffortOptions() {
2257
2262
  const options = readReasoningEffortOptionsFromGlobalContext();
@@ -2395,6 +2400,9 @@ var ChatMachine = class {
2395
2400
  }
2396
2401
  clearReasoningEffort();
2397
2402
  }
2403
+ _setModel(model) {
2404
+ this._updateSession({ model });
2405
+ }
2398
2406
  // =====================================================================
2399
2407
  // Private — session fetch
2400
2408
  // =====================================================================
@@ -2869,6 +2877,7 @@ var ChatMachine = class {
2869
2877
  debugMode,
2870
2878
  replaceFromMessageID,
2871
2879
  reasoningEffort,
2880
+ model,
2872
2881
  tempTurnId
2873
2882
  } = params;
2874
2883
  let accumulatedContent = "";
@@ -2884,7 +2893,8 @@ var ChatMachine = class {
2884
2893
  {
2885
2894
  debugMode,
2886
2895
  replaceFromMessageID,
2887
- reasoningEffort
2896
+ reasoningEffort,
2897
+ model
2888
2898
  }
2889
2899
  )) {
2890
2900
  if (this.abortController?.signal.aborted) {
@@ -3034,7 +3044,7 @@ var ChatMachine = class {
3034
3044
  if (this.disposed) {
3035
3045
  return;
3036
3046
  }
3037
- if (!content.trim() || this.state.messaging.loading) {
3047
+ if (!content.trim() || this.state.messaging.loading || isOpenQuestionStatus(this.state.messaging.pendingQuestion?.status)) {
3038
3048
  return;
3039
3049
  }
3040
3050
  const trimmedContent = content.trim();
@@ -3091,6 +3101,7 @@ var ChatMachine = class {
3091
3101
  reasoningEffort: this.sanitizeReasoningEffort(
3092
3102
  this.state.session.reasoningEffort
3093
3103
  ),
3104
+ model: this.state.session.model,
3094
3105
  tempTurnId: tempTurn.id
3095
3106
  });
3096
3107
  if (stopped) {
@@ -3129,7 +3140,7 @@ var ChatMachine = class {
3129
3140
  this.sendingSessionId = null;
3130
3141
  if (shouldDrainQueue) {
3131
3142
  const queue = this.state.input.messageQueue;
3132
- if (queue.length > 0) {
3143
+ if (queue.length > 0 && !isOpenQuestionStatus(this.state.messaging.pendingQuestion?.status)) {
3133
3144
  const next = queue[0];
3134
3145
  this._updateInput({ messageQueue: queue.slice(1) });
3135
3146
  setTimeout(() => {
@@ -8038,6 +8049,7 @@ function AssistantMessage({
8038
8049
  actionsSlotProps,
8039
8050
  /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
8040
8051
  !hideTimestamp && /* @__PURE__ */ jsxRuntime.jsx("span", { className: classes.timestamp, children: timestamp }),
8052
+ showDebug && turn.debug?.attempts?.[0]?.model && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[10px] font-medium leading-none text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-800", children: turn.debug.attempts[0].model }),
8041
8053
  /* @__PURE__ */ jsxRuntime.jsx(
8042
8054
  "button",
8043
8055
  {
@@ -12141,6 +12153,7 @@ function ChatSessionCore({
12141
12153
  welcomeSlot,
12142
12154
  logoSlot,
12143
12155
  actionsSlot,
12156
+ inputHeaderSlot,
12144
12157
  onBack,
12145
12158
  thinkingVerbs,
12146
12159
  onSessionRestored,
@@ -12173,7 +12186,8 @@ function ChatSessionCore({
12173
12186
  streamErrorRetryable,
12174
12187
  isCompacting,
12175
12188
  retryLastMessage,
12176
- clearStreamError
12189
+ clearStreamError,
12190
+ pendingQuestion
12177
12191
  } = useChatMessaging();
12178
12192
  const {
12179
12193
  inputError,
@@ -12189,6 +12203,7 @@ function ChatSessionCore({
12189
12203
  const isArchived = session?.status === "archived";
12190
12204
  const accessReadOnly = session?.access ? !session.access.canWrite : false;
12191
12205
  const effectiveReadOnly = Boolean(readOnly ?? isReadOnly) || isArchived || accessReadOnly;
12206
+ const composerDisabled = isOpenQuestionStatus(pendingQuestion?.status);
12192
12207
  const [restoring, setRestoring] = React.useState(false);
12193
12208
  const handleRestore = React.useCallback(async () => {
12194
12209
  if (!session?.id) {
@@ -12427,7 +12442,7 @@ function ChatSessionCore({
12427
12442
  className: "relative flex min-h-0 flex-1 overflow-hidden",
12428
12443
  children: [
12429
12444
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col", children: showWelcome ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 items-center justify-center px-4 py-8", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full max-w-5xl", children: [
12430
- welcomeSlot || /* @__PURE__ */ jsxRuntime.jsx(WelcomeContent_default, { onPromptSelect: handlePromptSelect, disabled: loading }),
12445
+ welcomeSlot || /* @__PURE__ */ jsxRuntime.jsx(WelcomeContent_default, { onPromptSelect: handlePromptSelect, disabled: loading || composerDisabled }),
12431
12446
  streamError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-6 pt-4", children: /* @__PURE__ */ jsxRuntime.jsx(
12432
12447
  StreamError,
12433
12448
  {
@@ -12437,6 +12452,7 @@ function ChatSessionCore({
12437
12452
  onDismiss: clearStreamError
12438
12453
  }
12439
12454
  ) }),
12455
+ !effectiveReadOnly && inputHeaderSlot,
12440
12456
  !effectiveReadOnly && /* @__PURE__ */ jsxRuntime.jsx(
12441
12457
  MessageInput,
12442
12458
  {
@@ -12458,6 +12474,7 @@ function ChatSessionCore({
12458
12474
  onCancelStreaming: cancel,
12459
12475
  containerClassName: "pt-6 px-6",
12460
12476
  formClassName: "mx-auto",
12477
+ disabled: composerDisabled,
12461
12478
  reasoningEffortOptions,
12462
12479
  reasoningEffort,
12463
12480
  onReasoningEffortChange: setReasoningEffort
@@ -12498,6 +12515,7 @@ function ChatSessionCore({
12498
12515
  onDismiss: clearStreamError
12499
12516
  }
12500
12517
  ) }),
12518
+ !effectiveReadOnly && inputHeaderSlot,
12501
12519
  !effectiveReadOnly && /* @__PURE__ */ jsxRuntime.jsx(
12502
12520
  MessageInput,
12503
12521
  {
@@ -12517,6 +12535,7 @@ function ChatSessionCore({
12517
12535
  onRemoveQueueItem: removeQueueItem,
12518
12536
  onUpdateQueueItem: updateQueueItem,
12519
12537
  onCancelStreaming: cancel,
12538
+ disabled: composerDisabled,
12520
12539
  reasoningEffortOptions,
12521
12540
  reasoningEffort,
12522
12541
  onReasoningEffortChange: setReasoningEffort
@@ -12637,6 +12656,67 @@ function ChatSession(props) {
12637
12656
  }
12638
12657
  );
12639
12658
  }
12659
+ init_IotaContext();
12660
+ function ModelSelector() {
12661
+ const { model, setModel } = useChatSession();
12662
+ const context = useIotaContext();
12663
+ const models = React.useMemo(
12664
+ () => context.extensions?.llm?.models ?? [],
12665
+ [context.extensions?.llm?.models]
12666
+ );
12667
+ const defaultModel = models.find((m) => m.default) ?? models[0];
12668
+ const currentModel = model ?? defaultModel?.id;
12669
+ React.useEffect(() => {
12670
+ if (!model && defaultModel) {
12671
+ setModel(defaultModel.id);
12672
+ }
12673
+ }, [model, defaultModel, setModel]);
12674
+ const rotateModel = React.useCallback(() => {
12675
+ const currentIndex = models.findIndex((m) => m.id === currentModel);
12676
+ const nextIndex = (currentIndex + 1) % models.length;
12677
+ setModel(models[nextIndex].id);
12678
+ }, [currentModel, models, setModel]);
12679
+ React.useEffect(() => {
12680
+ const handler = (e) => {
12681
+ if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key === "m") {
12682
+ e.preventDefault();
12683
+ rotateModel();
12684
+ }
12685
+ };
12686
+ document.addEventListener("keydown", handler);
12687
+ return () => document.removeEventListener("keydown", handler);
12688
+ }, [rotateModel]);
12689
+ if (models.length < 2) {
12690
+ return null;
12691
+ }
12692
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 pt-3 pb-1", children: [
12693
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "inline-flex rounded-lg bg-gray-100 p-0.5 dark:bg-gray-800", children: models.map((m) => {
12694
+ const isActive = m.id === currentModel;
12695
+ const isFast = m.label === "Fast";
12696
+ return /* @__PURE__ */ jsxRuntime.jsxs(
12697
+ "button",
12698
+ {
12699
+ type: "button",
12700
+ onClick: () => setModel(m.id),
12701
+ className: `
12702
+ flex items-center gap-1 rounded-md px-2.5 py-1 text-xs font-medium transition-all duration-150
12703
+ ${isActive ? isFast ? "bg-white text-amber-600 shadow-sm dark:bg-gray-700 dark:text-amber-400" : "bg-white text-blue-600 shadow-sm dark:bg-gray-700 dark:text-blue-400" : "text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"}
12704
+ `,
12705
+ children: [
12706
+ isFast ? /* @__PURE__ */ jsxRuntime.jsx(react.Lightning, { size: 13, weight: "fill" }) : /* @__PURE__ */ jsxRuntime.jsx(react.Brain, { size: 13, weight: "fill" }),
12707
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: m.label })
12708
+ ]
12709
+ },
12710
+ m.id
12711
+ );
12712
+ }) }),
12713
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "hidden select-none text-[10px] text-gray-400 sm:block dark:text-gray-500", children: [
12714
+ navigator.platform.includes("Mac") ? "\u2318" : "Ctrl",
12715
+ "\u21E7",
12716
+ "M"
12717
+ ] })
12718
+ ] });
12719
+ }
12640
12720
 
12641
12721
  // ui/src/bichat/index.ts
12642
12722
  init_MarkdownRenderer();
@@ -19156,6 +19236,9 @@ async function* sendMessage(deps, sessionId, content, attachments = [], signal,
19156
19236
  if (options?.reasoningEffort) {
19157
19237
  payload.reasoningEffort = options.reasoningEffort;
19158
19238
  }
19239
+ if (options?.model) {
19240
+ payload.model = options.model;
19241
+ }
19159
19242
  const timeoutMs = deps.streamConnectTimeoutMs ?? 0;
19160
19243
  if (timeoutMs > 0) {
19161
19244
  connectionTimeoutID = setTimeout(() => {
@@ -19702,6 +19785,7 @@ exports.MessageActions = MessageActions;
19702
19785
  exports.MessageInput = MessageInput;
19703
19786
  exports.MessageList = MessageList;
19704
19787
  exports.MessageRole = MessageRole;
19788
+ exports.ModelSelector = ModelSelector;
19705
19789
  exports.PermissionGuard = PermissionGuard;
19706
19790
  exports.QuestionForm = QuestionForm;
19707
19791
  exports.QuestionStep = QuestionStep;