@athenaintel/react 0.32.0 → 0.36.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.
Files changed (167) hide show
  1. package/README.md +148 -9
  2. package/dist/agent-runtime/src/composer-markdown.cjs.map +1 -1
  3. package/dist/agent-runtime/src/composer-markdown.js.map +1 -1
  4. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs +2 -3
  5. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
  6. package/dist/agent-runtime/src/deep-agent-transport-recipe.js +3 -4
  7. package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
  8. package/dist/agent-runtime/src/edit-command.cjs.map +1 -1
  9. package/dist/agent-runtime/src/edit-command.js.map +1 -1
  10. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +4 -0
  11. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  12. package/dist/agent-runtime/src/generated/runconfig-contract.js +4 -0
  13. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  14. package/dist/agent-runtime/src/messages.cjs +57 -2
  15. package/dist/agent-runtime/src/messages.cjs.map +1 -1
  16. package/dist/agent-runtime/src/messages.js +57 -2
  17. package/dist/agent-runtime/src/messages.js.map +1 -1
  18. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +24 -3
  19. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
  20. package/dist/agent-runtime/src/quota-safe-local-storage-session.js +24 -3
  21. package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
  22. package/dist/agent-runtime/src/statewire-transport.cjs +4 -13
  23. package/dist/agent-runtime/src/statewire-transport.cjs.map +1 -1
  24. package/dist/agent-runtime/src/statewire-transport.js +5 -14
  25. package/dist/agent-runtime/src/statewire-transport.js.map +1 -1
  26. package/dist/agent-runtime/src/tool-metadata.cjs +12 -1
  27. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
  28. package/dist/agent-runtime/src/tool-metadata.js +12 -1
  29. package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
  30. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  31. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
  32. package/dist/assets/AthenaAssetEmbed.cjs +3 -1
  33. package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
  34. package/dist/assets/AthenaAssetEmbed.d.ts +7 -0
  35. package/dist/assets/AthenaAssetEmbed.js +4 -2
  36. package/dist/assets/AthenaAssetEmbed.js.map +1 -1
  37. package/dist/assets/use-asset-embed.cjs +71 -71
  38. package/dist/assets/use-asset-embed.cjs.map +1 -1
  39. package/dist/assets/use-asset-embed.d.ts +20 -7
  40. package/dist/assets/use-asset-embed.js +72 -72
  41. package/dist/assets/use-asset-embed.js.map +1 -1
  42. package/dist/catalog/agent-mode-menu.cjs +115 -0
  43. package/dist/catalog/agent-mode-menu.cjs.map +1 -0
  44. package/dist/catalog/agent-mode-menu.d.ts +101 -0
  45. package/dist/catalog/agent-mode-menu.js +115 -0
  46. package/dist/catalog/agent-mode-menu.js.map +1 -0
  47. package/dist/catalog/agent-model-options.cjs +122 -0
  48. package/dist/catalog/agent-model-options.cjs.map +1 -0
  49. package/dist/catalog/agent-model-options.d.ts +115 -0
  50. package/dist/catalog/agent-model-options.js +122 -0
  51. package/dist/catalog/agent-model-options.js.map +1 -0
  52. package/dist/catalog/chat-pickers.cjs +235 -4
  53. package/dist/catalog/chat-pickers.cjs.map +1 -1
  54. package/dist/catalog/chat-pickers.d.ts +55 -3
  55. package/dist/catalog/chat-pickers.js +238 -7
  56. package/dist/catalog/chat-pickers.js.map +1 -1
  57. package/dist/catalog/runtime-catalog.cjs +121 -3
  58. package/dist/catalog/runtime-catalog.cjs.map +1 -1
  59. package/dist/catalog/runtime-catalog.d.ts +120 -0
  60. package/dist/catalog/runtime-catalog.js +124 -6
  61. package/dist/catalog/runtime-catalog.js.map +1 -1
  62. package/dist/catalog/use-athena-chat-mode.cjs +139 -0
  63. package/dist/catalog/use-athena-chat-mode.cjs.map +1 -0
  64. package/dist/catalog/use-athena-chat-mode.d.ts +43 -0
  65. package/dist/catalog/use-athena-chat-mode.js +139 -0
  66. package/dist/catalog/use-athena-chat-mode.js.map +1 -0
  67. package/dist/chat/AthenaChat.cjs +2 -0
  68. package/dist/chat/AthenaChat.cjs.map +1 -1
  69. package/dist/chat/AthenaChat.d.ts +8 -7
  70. package/dist/chat/AthenaChat.js +2 -0
  71. package/dist/chat/AthenaChat.js.map +1 -1
  72. package/dist/chat/super-grouping/SuperGroupingCard.cjs +30 -3
  73. package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
  74. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +12 -9
  75. package/dist/chat/super-grouping/SuperGroupingCard.js +31 -4
  76. package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
  77. package/dist/chat/super-grouping/SuperGroupingTranscript.cjs.map +1 -1
  78. package/dist/chat/super-grouping/SuperGroupingTranscript.d.ts +8 -8
  79. package/dist/chat/super-grouping/SuperGroupingTranscript.js.map +1 -1
  80. package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
  81. package/dist/chat/super-grouping/activity-timeline.d.ts +4 -4
  82. package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
  83. package/dist/chat/super-grouping/index.d.ts +6 -5
  84. package/dist/chat/super-grouping/toolkit-map.cjs +3 -1
  85. package/dist/chat/super-grouping/toolkit-map.cjs.map +1 -1
  86. package/dist/chat/super-grouping/toolkit-map.js +3 -1
  87. package/dist/chat/super-grouping/toolkit-map.js.map +1 -1
  88. package/dist/chat-ui/index.cjs +1 -0
  89. package/dist/chat-ui/index.cjs.map +1 -1
  90. package/dist/chat-ui/index.d.ts +1 -1
  91. package/dist/chat-ui/index.js +2 -1
  92. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +33 -2
  93. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
  94. package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +14 -0
  95. package/dist/chat-ui/mentions/suggestions/data/api-client.js +33 -2
  96. package/dist/chat-ui/mentions/suggestions/data/api-client.js.map +1 -1
  97. package/dist/chat-ui/statewire.cjs +3 -0
  98. package/dist/chat-ui/statewire.cjs.map +1 -1
  99. package/dist/chat-ui/statewire.d.ts +4 -2
  100. package/dist/chat-ui/statewire.js +3 -0
  101. package/dist/chat-ui/statewire.js.map +1 -1
  102. package/dist/index.cjs +4 -0
  103. package/dist/index.cjs.map +1 -1
  104. package/dist/index.d.ts +7 -4
  105. package/dist/index.js +6 -2
  106. package/dist/index.js.map +1 -1
  107. package/dist/lib/use-athena-rest-query.cjs +4 -0
  108. package/dist/lib/use-athena-rest-query.cjs.map +1 -1
  109. package/dist/lib/use-athena-rest-query.d.ts +6 -0
  110. package/dist/lib/use-athena-rest-query.js +4 -0
  111. package/dist/lib/use-athena-rest-query.js.map +1 -1
  112. package/dist/provider/AthenaProvider.cjs +81 -9
  113. package/dist/provider/AthenaProvider.cjs.map +1 -1
  114. package/dist/provider/AthenaProvider.d.ts +25 -5
  115. package/dist/provider/AthenaProvider.js +83 -11
  116. package/dist/provider/AthenaProvider.js.map +1 -1
  117. package/dist/provider/agent-selection-context.cjs +6 -0
  118. package/dist/provider/agent-selection-context.cjs.map +1 -0
  119. package/dist/provider/agent-selection-context.d.ts +14 -0
  120. package/dist/provider/agent-selection-context.js +6 -0
  121. package/dist/provider/agent-selection-context.js.map +1 -0
  122. package/dist/provider/chat-mode-context.cjs +6 -0
  123. package/dist/provider/chat-mode-context.cjs.map +1 -0
  124. package/dist/provider/chat-mode-context.d.ts +35 -0
  125. package/dist/provider/chat-mode-context.js +6 -0
  126. package/dist/provider/chat-mode-context.js.map +1 -0
  127. package/dist/react/package.json.cjs +1 -1
  128. package/dist/react/package.json.js +1 -1
  129. package/dist/runtime/StatewireThreadConfigLaneSync.cjs +125 -0
  130. package/dist/runtime/StatewireThreadConfigLaneSync.cjs.map +1 -0
  131. package/dist/runtime/StatewireThreadConfigLaneSync.d.ts +54 -0
  132. package/dist/runtime/StatewireThreadConfigLaneSync.js +125 -0
  133. package/dist/runtime/StatewireThreadConfigLaneSync.js.map +1 -0
  134. package/dist/runtime/statewire-model-lane.cjs +0 -12
  135. package/dist/runtime/statewire-model-lane.cjs.map +1 -1
  136. package/dist/runtime/statewire-model-lane.d.ts +3 -1
  137. package/dist/runtime/statewire-model-lane.js +0 -12
  138. package/dist/runtime/statewire-model-lane.js.map +1 -1
  139. package/dist/runtime/statewire-run-config.cjs +10 -6
  140. package/dist/runtime/statewire-run-config.cjs.map +1 -1
  141. package/dist/runtime/statewire-run-config.d.ts +7 -0
  142. package/dist/runtime/statewire-run-config.js +10 -6
  143. package/dist/runtime/statewire-run-config.js.map +1 -1
  144. package/dist/runtime/statewire-server-lane-context.cjs.map +1 -1
  145. package/dist/runtime/statewire-server-lane-context.d.ts +2 -2
  146. package/dist/runtime/statewire-server-lane-context.js.map +1 -1
  147. package/dist/runtime/statewire-thread-config-lane.cjs +84 -0
  148. package/dist/runtime/statewire-thread-config-lane.cjs.map +1 -0
  149. package/dist/runtime/statewire-thread-config-lane.d.ts +94 -0
  150. package/dist/runtime/statewire-thread-config-lane.js +84 -0
  151. package/dist/runtime/statewire-thread-config-lane.js.map +1 -0
  152. package/dist/runtime/useAthenaStatewireRuntime.cjs +4 -2
  153. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  154. package/dist/runtime/useAthenaStatewireRuntime.d.ts +2 -0
  155. package/dist/runtime/useAthenaStatewireRuntime.js +4 -2
  156. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  157. package/dist/threads/use-athena-thread-model.cjs +11 -3
  158. package/dist/threads/use-athena-thread-model.cjs.map +1 -1
  159. package/dist/threads/use-athena-thread-model.d.ts +5 -0
  160. package/dist/threads/use-athena-thread-model.js +12 -4
  161. package/dist/threads/use-athena-thread-model.js.map +1 -1
  162. package/package.json +3 -3
  163. package/dist/runtime/StatewireModelLaneSync.cjs +0 -96
  164. package/dist/runtime/StatewireModelLaneSync.cjs.map +0 -1
  165. package/dist/runtime/StatewireModelLaneSync.d.ts +0 -45
  166. package/dist/runtime/StatewireModelLaneSync.js +0 -96
  167. package/dist/runtime/StatewireModelLaneSync.js.map +0 -1
@@ -1,15 +1,20 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { BotIcon, ChevronDownIcon, SparklesIcon, CheckIcon } from "lucide-react";
2
+ import { BotIcon, ChevronDownIcon, LayersIcon, CheckIcon, SparklesIcon } from "lucide-react";
3
3
  import { DropdownMenu } from "radix-ui";
4
- import { useState, useRef, useEffect } from "react";
4
+ import { useState, useRef, useEffect, useContext } from "react";
5
5
  import { usePortalContainer } from "../lib/owner-document.js";
6
6
  import { portalSurfaceStyle } from "../lib/portal-surface.js";
7
+ import { AthenaAgentSelectionContext } from "../provider/agent-selection-context.js";
7
8
  import { useAthenaThemeStyle } from "../provider/theme-style-context.js";
8
- import { useAthenaAgentCatalog, useAthenaModelCatalog, resolveCatalogModelId, groupModelsByProvider } from "./runtime-catalog.js";
9
+ import { agentAssetIdOf } from "./agent-model-options.js";
10
+ import { useAthenaAgentCatalog, useAgentModelChoices, useAthenaModelCatalog, resolveCatalogModelId, groupModelsByProvider } from "./runtime-catalog.js";
11
+ import { useAthenaChatMode } from "./use-athena-chat-mode.js";
9
12
  import { cn } from "cnfast";
10
13
  const CHIP_CLASS = "inline-flex h-7 max-w-[14rem] items-center gap-1 rounded-md px-2 text-xs text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50";
14
+ const STATIC_CHIP_CLASS = "inline-flex h-7 max-w-[14rem] items-center gap-1 rounded-md px-2 text-xs text-muted-foreground";
11
15
  const ITEM_CLASS = "relative flex w-full cursor-default select-none items-center gap-2 rounded-sm py-1.5 pl-2 pr-7 text-sm outline-none data-[highlighted]:bg-muted data-[state=checked]:font-medium";
12
16
  const AGENT_OWN_MODEL = "__agent_own_model__";
17
+ const AGENT_MODEL_LABEL = "Agent’s model";
13
18
  function PickerMenu({ label, children }) {
14
19
  const themeStyle = useAthenaThemeStyle();
15
20
  const container = usePortalContainer();
@@ -29,9 +34,16 @@ function PickerMenu({ label, children }) {
29
34
  }
30
35
  ) });
31
36
  }
32
- function PickerItem({ value, children }) {
37
+ function PickerItem({
38
+ value,
39
+ detail,
40
+ children
41
+ }) {
33
42
  return /* @__PURE__ */ jsxs(DropdownMenu.RadioItem, { value, className: ITEM_CLASS, children: [
34
- /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children }),
43
+ detail ? /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [
44
+ /* @__PURE__ */ jsx("span", { className: "truncate", children }),
45
+ /* @__PURE__ */ jsx("span", { className: "truncate text-xs font-normal text-muted-foreground", children: detail })
46
+ ] }) : /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children }),
35
47
  /* @__PURE__ */ jsx(DropdownMenu.ItemIndicator, { className: "absolute right-2 inline-flex", children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-3.5", "aria-hidden": true }) })
36
48
  ] });
37
49
  }
@@ -50,10 +62,93 @@ function ChatModelPicker({
50
62
  onChange,
51
63
  defaultModelId,
52
64
  agentSelected = false,
65
+ agent,
66
+ channel,
53
67
  disabled = false,
54
68
  className
55
69
  }) {
70
+ const providerSelection = useContext(AthenaAgentSelectionContext);
71
+ const agentAssetId = agent !== void 0 ? agentAssetIdOf(agent) : agentSelected ? (providerSelection == null ? void 0 : providerSelection.agentAssetId) ?? null : null;
72
+ if (agentAssetId !== null) {
73
+ const agentChannel = channel !== void 0 ? channel : (providerSelection == null ? void 0 : providerSelection.agentAssetId) === agentAssetId ? providerSelection.channel : null;
74
+ return /* @__PURE__ */ jsx(
75
+ AgentAwareModelPicker,
76
+ {
77
+ agentAssetId,
78
+ channel: agentChannel,
79
+ value,
80
+ onChange,
81
+ defaultModelId,
82
+ disabled,
83
+ className
84
+ }
85
+ );
86
+ }
87
+ return /* @__PURE__ */ jsx(
88
+ WorkspaceModelPicker,
89
+ {
90
+ value,
91
+ onChange,
92
+ defaultModelId,
93
+ agentSelected,
94
+ disabled,
95
+ className
96
+ }
97
+ );
98
+ }
99
+ function AgentAwareModelPicker({
100
+ agentAssetId,
101
+ channel,
102
+ value,
103
+ onChange,
104
+ defaultModelId,
105
+ disabled,
106
+ className
107
+ }) {
108
+ const { choices, modelLabel, catalog } = useAgentModelChoices({ agent: agentAssetId, channel });
109
+ if (choices.status === "ready" && !choices.allowAnyModel) {
110
+ return /* @__PURE__ */ jsx(
111
+ AgentModelMenu,
112
+ {
113
+ choices,
114
+ modelLabel,
115
+ value,
116
+ onChange,
117
+ disabled,
118
+ className
119
+ }
120
+ );
121
+ }
122
+ return /* @__PURE__ */ jsx(
123
+ WorkspaceModelMenu,
124
+ {
125
+ catalog,
126
+ value,
127
+ onChange,
128
+ defaultModelId,
129
+ agentSelected: true,
130
+ agentDefaultLabel: choices.defaultModel === null ? null : modelLabel(choices.defaultModel),
131
+ holdReplacement: choices.status === "loading",
132
+ disabled,
133
+ className
134
+ }
135
+ );
136
+ }
137
+ function WorkspaceModelPicker(props) {
56
138
  const catalog = useAthenaModelCatalog();
139
+ return /* @__PURE__ */ jsx(WorkspaceModelMenu, { catalog, ...props });
140
+ }
141
+ function WorkspaceModelMenu({
142
+ catalog,
143
+ value,
144
+ onChange,
145
+ defaultModelId,
146
+ agentSelected,
147
+ agentDefaultLabel = null,
148
+ holdReplacement = false,
149
+ disabled,
150
+ className
151
+ }) {
57
152
  const [open, setOpen] = useState(false);
58
153
  const models = catalog.data ?? [];
59
154
  const resolved = value === null && agentSelected ? null : resolveCatalogModelId({ stored: value, defaultModelId, models });
@@ -61,11 +156,12 @@ function ChatModelPicker({
61
156
  const label = resolved === null ? "Agent’s model" : (current == null ? void 0 : current.label) ?? resolved;
62
157
  const replacedRef = useRef(null);
63
158
  useEffect(() => {
159
+ if (holdReplacement) return;
64
160
  if (!catalog.isSuccess || value === null || resolved === null || resolved === value) return;
65
161
  if (models.some((model) => model.id === value) || replacedRef.current === value) return;
66
162
  replacedRef.current = value;
67
163
  onChange(resolved);
68
- }, [catalog.isSuccess, models, value, resolved, onChange]);
164
+ }, [holdReplacement, catalog.isSuccess, models, value, resolved, onChange]);
69
165
  return /* @__PURE__ */ jsxs(DropdownMenu.Root, { open, onOpenChange: setOpen, children: [
70
166
  /* @__PURE__ */ jsx(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs(
71
167
  "button",
@@ -87,7 +183,7 @@ function ChatModelPicker({
87
183
  value: resolved ?? AGENT_OWN_MODEL,
88
184
  onValueChange: (next) => onChange(next === AGENT_OWN_MODEL ? null : next),
89
185
  children: [
90
- agentSelected && /* @__PURE__ */ jsx(PickerItem, { value: AGENT_OWN_MODEL, children: "Agent’s own model" }),
186
+ agentSelected && /* @__PURE__ */ jsx(PickerItem, { value: AGENT_OWN_MODEL, detail: agentDefaultLabel, children: "Agent’s own model" }),
91
187
  catalog.isPending && /* @__PURE__ */ jsx(PickerNote, { children: "Loading models…" }),
92
188
  catalog.isError && /* @__PURE__ */ jsx(PickerNote, { alert: true, children: "Couldn’t load the models. Try again in a moment." }),
93
189
  groupModelsByProvider({ models }).map((group) => /* @__PURE__ */ jsxs(DropdownMenu.Group, { children: [
@@ -102,6 +198,91 @@ function ChatModelPicker({
102
198
  ) })
103
199
  ] });
104
200
  }
201
+ function AgentModelMenu({
202
+ choices,
203
+ modelLabel,
204
+ value,
205
+ onChange,
206
+ disabled,
207
+ className
208
+ }) {
209
+ const [open, setOpen] = useState(false);
210
+ const pinsDefault = value !== null && value === choices.defaultModel;
211
+ const items = choices.options.map((option) => {
212
+ const display = modelLabel(option.model);
213
+ return {
214
+ value: option.isDefault && !pinsDefault ? AGENT_OWN_MODEL : option.model,
215
+ label: option.label,
216
+ isDefault: option.isDefault,
217
+ detail: option.pinnedOutside ? "Set for this conversation outside the agent" : display === option.label ? null : display
218
+ };
219
+ });
220
+ if (value !== null && !choices.options.some((option) => option.model === value)) {
221
+ items.push({
222
+ value,
223
+ label: modelLabel(value),
224
+ isDefault: false,
225
+ detail: "Not one of the agent’s models"
226
+ });
227
+ }
228
+ if (pinsDefault) {
229
+ items.push({
230
+ value: AGENT_OWN_MODEL,
231
+ label: "Agent’s own model",
232
+ isDefault: false,
233
+ detail: "Follows the agent’s default"
234
+ });
235
+ }
236
+ const selectedValue = value ?? AGENT_OWN_MODEL;
237
+ const selected = items.find((item) => item.value === selectedValue) ?? null;
238
+ const label = (selected == null ? void 0 : selected.label) || AGENT_MODEL_LABEL;
239
+ if (items.length < 2) {
240
+ return /* @__PURE__ */ jsxs(
241
+ "span",
242
+ {
243
+ role: "img",
244
+ "aria-label": `Model: ${label}`,
245
+ title: selected ? `This agent runs ${label}` : "This agent runs its own model",
246
+ "data-slot": "chat-model-picker-label",
247
+ className: cn(STATIC_CHIP_CLASS, className),
248
+ children: [
249
+ /* @__PURE__ */ jsx(SparklesIcon, { className: "size-3.5 shrink-0", "aria-hidden": true }),
250
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: label })
251
+ ]
252
+ }
253
+ );
254
+ }
255
+ return /* @__PURE__ */ jsxs(DropdownMenu.Root, { open, onOpenChange: setOpen, children: [
256
+ /* @__PURE__ */ jsx(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs(
257
+ "button",
258
+ {
259
+ type: "button",
260
+ className: cn(CHIP_CLASS, className),
261
+ disabled,
262
+ "aria-label": `Model: ${label}`,
263
+ children: [
264
+ /* @__PURE__ */ jsx(SparklesIcon, { className: "size-3.5 shrink-0", "aria-hidden": true }),
265
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: label }),
266
+ /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-3 shrink-0", "aria-hidden": true })
267
+ ]
268
+ }
269
+ ) }),
270
+ /* @__PURE__ */ jsx(PickerMenu, { label: "Model", children: /* @__PURE__ */ jsxs(
271
+ DropdownMenu.RadioGroup,
272
+ {
273
+ value: selectedValue,
274
+ onValueChange: (next) => onChange(next === AGENT_OWN_MODEL ? null : next),
275
+ children: [
276
+ /* @__PURE__ */ jsx(DropdownMenu.Label, { className: "px-2 pb-0.5 pt-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: "Agent models" }),
277
+ items.map((item) => /* @__PURE__ */ jsxs(PickerItem, { value: item.value, detail: item.detail, children: [
278
+ item.label,
279
+ item.isDefault ? " (default)" : ""
280
+ ] }, item.value))
281
+ ]
282
+ }
283
+ ) })
284
+ ] });
285
+ }
105
286
  const NO_AGENT = "__athena__";
106
287
  function ChatAgentPicker({ value, onChange, disabled = false, className }) {
107
288
  var _a;
@@ -145,8 +326,58 @@ function ChatAgentPicker({ value, onChange, disabled = false, className }) {
145
326
  ) })
146
327
  ] });
147
328
  }
329
+ function ChatModePicker({
330
+ value,
331
+ options,
332
+ onChange,
333
+ valueLabel,
334
+ disabled = false,
335
+ disabledReason,
336
+ className
337
+ }) {
338
+ var _a;
339
+ const [open, setOpen] = useState(false);
340
+ const label = ((_a = options.find((option) => option.id === value)) == null ? void 0 : _a.label) ?? valueLabel ?? value;
341
+ return /* @__PURE__ */ jsxs(DropdownMenu.Root, { open, onOpenChange: setOpen, children: [
342
+ /* @__PURE__ */ jsx(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs(
343
+ "button",
344
+ {
345
+ type: "button",
346
+ className: cn(CHIP_CLASS, className),
347
+ disabled,
348
+ title: disabled ? disabledReason : void 0,
349
+ "aria-label": `Mode: ${label}`,
350
+ "data-slot": "chat-mode-picker",
351
+ children: [
352
+ /* @__PURE__ */ jsx(LayersIcon, { className: "size-3.5 shrink-0", "aria-hidden": true }),
353
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: label }),
354
+ /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-3 shrink-0", "aria-hidden": true })
355
+ ]
356
+ }
357
+ ) }),
358
+ /* @__PURE__ */ jsx(PickerMenu, { label: "Mode", children: /* @__PURE__ */ jsx(DropdownMenu.RadioGroup, { value, onValueChange: onChange, children: options.map((option) => /* @__PURE__ */ jsx(PickerItem, { value: option.id, children: option.label }, option.id)) }) })
359
+ ] });
360
+ }
361
+ function AthenaChatModeMenu({ className }) {
362
+ const mode = useAthenaChatMode();
363
+ if (mode.status !== "ready") return null;
364
+ return /* @__PURE__ */ jsx(
365
+ ChatModePicker,
366
+ {
367
+ value: mode.current,
368
+ valueLabel: mode.currentLabel,
369
+ options: mode.options,
370
+ onChange: mode.select,
371
+ disabled: !mode.canSwitch,
372
+ disabledReason: "This channel keeps each conversation in the mode it started in. Start a new conversation to pick another.",
373
+ className
374
+ }
375
+ );
376
+ }
148
377
  export {
378
+ AthenaChatModeMenu,
149
379
  ChatAgentPicker,
380
+ ChatModePicker,
150
381
  ChatModelPicker
151
382
  };
152
383
  //# sourceMappingURL=chat-pickers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chat-pickers.js","sources":["../../src/catalog/chat-pickers.tsx"],"sourcesContent":["import { BotIcon, CheckIcon, ChevronDownIcon, SparklesIcon } from 'lucide-react';\nimport { DropdownMenu } from 'radix-ui';\nimport { type ReactNode, useEffect, useRef, useState } from 'react';\nimport { usePortalContainer } from '../lib/owner-document';\nimport { portalSurfaceStyle } from '../lib/portal-surface';\nimport { cn } from '../lib/utils';\nimport { useAthenaThemeStyle } from '../provider/theme-style-context';\nimport {\n groupModelsByProvider,\n resolveCatalogModelId,\n useAthenaAgentCatalog,\n useAthenaModelCatalog,\n} from './runtime-catalog';\n\n/**\n * The composer's agent and model pickers: compact chips for `AthenaChat`'s `toolbarStart` slot\n * that open a menu, as ChatGPT's and Codex's composers do. They are controlled: the host keeps the\n * choice (and remembers it if it likes) and passes it to `AthenaProvider` as `model` and\n * `agent=\"collab_agent:<id>\"`. New messages run with the choice. The menus are Radix radio menus,\n * so arrow keys, typeahead, Escape and focus return work as in any native menu.\n */\n\nconst CHIP_CLASS =\n 'inline-flex h-7 max-w-[14rem] items-center gap-1 rounded-md px-2 text-xs text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50';\n\nconst ITEM_CLASS =\n 'relative flex w-full cursor-default select-none items-center gap-2 rounded-sm py-1.5 pl-2 pr-7 text-sm outline-none data-[highlighted]:bg-muted data-[state=checked]:font-medium';\n\n/** The \"Agent's own model\" item's value: a chosen agent runs the model its author set. */\nconst AGENT_OWN_MODEL = '__agent_own_model__';\n\n/** The menu body, portaled and themed like the SDK's popovers (it renders outside the provider). */\nfunction PickerMenu({ label, children }: { label: string; children: ReactNode }) {\n const themeStyle = useAthenaThemeStyle();\n const container = usePortalContainer();\n return (\n <DropdownMenu.Portal container={container}>\n <DropdownMenu.Content\n align=\"start\"\n sideOffset={4}\n collisionPadding={8}\n aria-label={label}\n // Its box and colours inline: no host stylesheet can take them away\n // (lib/portal-surface.ts).\n style={portalSurfaceStyle({ surface: 'popover', themeStyle })}\n className={cn(\n 'athena-sdk athena-sdk-chrome',\n 'z-50 block max-h-80 w-64 overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md outline-none',\n )}\n >\n {children}\n </DropdownMenu.Content>\n </DropdownMenu.Portal>\n );\n}\n\nfunction PickerItem({ value, children }: { value: string; children: ReactNode }) {\n return (\n <DropdownMenu.RadioItem value={value} className={ITEM_CLASS}>\n <span className=\"min-w-0 flex-1 truncate\">{children}</span>\n <DropdownMenu.ItemIndicator className=\"absolute right-2 inline-flex\">\n <CheckIcon className=\"size-3.5\" aria-hidden />\n </DropdownMenu.ItemIndicator>\n </DropdownMenu.RadioItem>\n );\n}\n\nfunction PickerNote({ children, alert = false }: { children: ReactNode; alert?: boolean }) {\n return (\n <p\n className={cn('px-2 py-1.5 text-xs', alert ? 'text-destructive' : 'text-muted-foreground')}\n role={alert ? 'alert' : undefined}\n >\n {children}\n </p>\n );\n}\n\nexport interface ChatModelPickerProps {\n /** The chosen model id; `null` lets a selected agent run its own model. */\n value: string | null;\n onChange: (modelId: string | null) => void;\n /** The model a person who chose nothing runs, e.g. `claude-opus-5-5`. */\n defaultModelId: string;\n /** A collab agent is chosen: offer \"Agent's own model\" (`null`). */\n agentSelected?: boolean;\n disabled?: boolean;\n className?: string;\n}\n\n/** Which model new messages run, from the models the workspace allows this person. */\nexport function ChatModelPicker({\n value,\n onChange,\n defaultModelId,\n agentSelected = false,\n disabled = false,\n className,\n}: ChatModelPickerProps) {\n const catalog = useAthenaModelCatalog();\n const [open, setOpen] = useState(false);\n const models = catalog.data ?? [];\n const resolved =\n value === null && agentSelected\n ? null\n : resolveCatalogModelId({ stored: value, defaultModelId, models });\n const current = models.find((model) => model.id === resolved);\n const label = resolved === null ? 'Agent’s model' : (current?.label ?? resolved);\n // The host's choice is no longer offered (retired, or the workspace stopped allowing it): hand\n // the host the model the chip shows, so new messages run it instead of the dropped id. Once per\n // choice, so a host that keeps the old value is not asked again on every render.\n const replacedRef = useRef<string | null>(null);\n useEffect(() => {\n if (!catalog.isSuccess || value === null || resolved === null || resolved === value) return;\n if (models.some((model) => model.id === value) || replacedRef.current === value) return;\n replacedRef.current = value;\n onChange(resolved);\n }, [catalog.isSuccess, models, value, resolved, onChange]);\n return (\n <DropdownMenu.Root open={open} onOpenChange={setOpen}>\n <DropdownMenu.Trigger asChild>\n <button\n type=\"button\"\n className={cn(CHIP_CLASS, className)}\n disabled={disabled}\n aria-label={`Model: ${label}`}\n >\n <SparklesIcon className=\"size-3.5 shrink-0\" aria-hidden />\n <span className=\"truncate\">{label}</span>\n <ChevronDownIcon className=\"size-3 shrink-0\" aria-hidden />\n </button>\n </DropdownMenu.Trigger>\n <PickerMenu label=\"Model\">\n <DropdownMenu.RadioGroup\n value={resolved ?? AGENT_OWN_MODEL}\n onValueChange={(next) => onChange(next === AGENT_OWN_MODEL ? null : next)}\n >\n {agentSelected && <PickerItem value={AGENT_OWN_MODEL}>Agent’s own model</PickerItem>}\n {catalog.isPending && <PickerNote>Loading models…</PickerNote>}\n {catalog.isError && <PickerNote alert>Couldn’t load the models. Try again in a moment.</PickerNote>}\n {groupModelsByProvider({ models }).map((group) => (\n <DropdownMenu.Group key={group.provider}>\n <DropdownMenu.Label className=\"px-2 pb-0.5 pt-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground\">\n {group.provider}\n </DropdownMenu.Label>\n {group.models.map((model) => (\n <PickerItem key={model.id} value={model.id}>\n {model.label}\n {model.status === 'LEGACY' ? ' (legacy)' : ''}\n </PickerItem>\n ))}\n </DropdownMenu.Group>\n ))}\n </DropdownMenu.RadioGroup>\n </PickerMenu>\n </DropdownMenu.Root>\n );\n}\n\nexport interface ChatAgentPickerProps {\n /** The chosen collab agent's asset id; `null` is Athena. */\n value: string | null;\n onChange: (agentId: string | null) => void;\n disabled?: boolean;\n className?: string;\n}\n\n/** The \"Athena\" item's value: no collab agent. */\nconst NO_AGENT = '__athena__';\n\n/** Who answers new messages: Athena, or a published collab agent the person can see. */\nexport function ChatAgentPicker({ value, onChange, disabled = false, className }: ChatAgentPickerProps) {\n const catalog = useAthenaAgentCatalog();\n const [open, setOpen] = useState(false);\n const agents = catalog.data ?? [];\n const label = value === null ? 'Athena' : (agents.find((agent) => agent.id === value)?.name ?? 'Agent');\n // The chosen agent is gone (unpublished, or no longer shared with this person): fall back to\n // Athena, so new messages do not target an agent they cannot reach. Once per choice.\n const clearedRef = useRef<string | null>(null);\n useEffect(() => {\n if (!catalog.isSuccess || value === null || clearedRef.current === value) return;\n if (agents.some((agent) => agent.id === value)) return;\n clearedRef.current = value;\n onChange(null);\n }, [catalog.isSuccess, agents, value, onChange]);\n return (\n <DropdownMenu.Root open={open} onOpenChange={setOpen}>\n <DropdownMenu.Trigger asChild>\n <button\n type=\"button\"\n className={cn(CHIP_CLASS, className)}\n disabled={disabled}\n aria-label={`Agent: ${label}`}\n >\n <BotIcon className=\"size-3.5 shrink-0\" aria-hidden />\n <span className=\"truncate\">{label}</span>\n <ChevronDownIcon className=\"size-3 shrink-0\" aria-hidden />\n </button>\n </DropdownMenu.Trigger>\n <PickerMenu label=\"Agent\">\n <DropdownMenu.RadioGroup\n value={value ?? NO_AGENT}\n onValueChange={(next) => onChange(next === NO_AGENT ? null : next)}\n >\n <PickerItem value={NO_AGENT}>Athena</PickerItem>\n {catalog.isError && <PickerNote alert>Couldn’t load the agents. Try again in a moment.</PickerNote>}\n {agents.map((agent) => (\n <PickerItem key={agent.id} value={agent.id}>\n {agent.name}\n </PickerItem>\n ))}\n </DropdownMenu.RadioGroup>\n </PickerMenu>\n </DropdownMenu.Root>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;AAsBA,MAAM,aACJ;AAEF,MAAM,aACJ;AAGF,MAAM,kBAAkB;AAGxB,SAAS,WAAW,EAAE,OAAO,YAAoD;AAC/E,QAAM,aAAa,oBAAA;AACnB,QAAM,YAAY,mBAAA;AAClB,SACE,oBAAC,aAAa,QAAb,EAAoB,WACnB,UAAA;AAAA,IAAC,aAAa;AAAA,IAAb;AAAA,MACC,OAAM;AAAA,MACN,YAAY;AAAA,MACZ,kBAAkB;AAAA,MAClB,cAAY;AAAA,MAGZ,OAAO,mBAAmB,EAAE,SAAS,WAAW,YAAY;AAAA,MAC5D,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MAAA;AAAA,MAGD;AAAA,IAAA;AAAA,EAAA,GAEL;AAEJ;AAEA,SAAS,WAAW,EAAE,OAAO,YAAoD;AAC/E,8BACG,aAAa,WAAb,EAAuB,OAAc,WAAW,YAC/C,UAAA;AAAA,IAAA,oBAAC,QAAA,EAAK,WAAU,2BAA2B,SAAA,CAAS;AAAA,IACpD,oBAAC,aAAa,eAAb,EAA2B,WAAU,gCACpC,UAAA,oBAAC,WAAA,EAAU,WAAU,YAAW,eAAW,KAAA,CAAC,EAAA,CAC9C;AAAA,EA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AM,KAAA,GADQ,MAAM,EAEvB,CACD;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA,EACH,CACF;AAAA,EAAA,GACF;AAEJ;"}
1
+ {"version":3,"file":"chat-pickers.js","sources":["../../src/catalog/chat-pickers.tsx"],"sourcesContent":["import { BotIcon, CheckIcon, ChevronDownIcon, LayersIcon, SparklesIcon } from 'lucide-react';\nimport { DropdownMenu } from 'radix-ui';\nimport { type ReactNode, useContext, useEffect, useRef, useState } from 'react';\nimport { usePortalContainer } from '../lib/owner-document';\nimport { portalSurfaceStyle } from '../lib/portal-surface';\nimport { cn } from '../lib/utils';\nimport { AthenaAgentSelectionContext } from '../provider/agent-selection-context';\nimport { useAthenaThemeStyle } from '../provider/theme-style-context';\nimport type { AthenaChatModeOption } from './agent-mode-menu';\nimport { agentAssetIdOf } from './agent-model-options';\nimport {\n type AthenaAgentModelOptions,\n groupModelsByProvider,\n resolveCatalogModelId,\n useAgentModelChoices,\n useAthenaAgentCatalog,\n useAthenaModelCatalog,\n} from './runtime-catalog';\nimport { useAthenaChatMode } from './use-athena-chat-mode';\n\n/**\n * The composer's agent and model pickers: compact chips for `AthenaChat`'s `toolbarStart` slot\n * that open a menu, as ChatGPT's and Codex's composers do. They are controlled: the host keeps the\n * choice (and remembers it if it likes) and passes it to `AthenaProvider` as `model` and\n * `agent=\"collab_agent:<id>\"`. New messages run with the choice. The menus are Radix radio menus,\n * so arrow keys, typeahead, Escape and focus return work as in any native menu.\n */\n\nconst CHIP_CLASS =\n 'inline-flex h-7 max-w-[14rem] items-center gap-1 rounded-md px-2 text-xs text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50';\n\n/** The chip without a menu: one choice, shown as a label. */\nconst STATIC_CHIP_CLASS =\n 'inline-flex h-7 max-w-[14rem] items-center gap-1 rounded-md px-2 text-xs text-muted-foreground';\n\nconst ITEM_CLASS =\n 'relative flex w-full cursor-default select-none items-center gap-2 rounded-sm py-1.5 pl-2 pr-7 text-sm outline-none data-[highlighted]:bg-muted data-[state=checked]:font-medium';\n\n/** The \"Agent's own model\" item's value: a chosen agent runs the model its author set. */\nconst AGENT_OWN_MODEL = '__agent_own_model__';\n\n/** What the chip says while a chosen agent's model is not known. */\nconst AGENT_MODEL_LABEL = 'Agent’s model';\n\n/** The menu body, portaled and themed like the SDK's popovers (it renders outside the provider). */\nfunction PickerMenu({ label, children }: { label: string; children: ReactNode }) {\n const themeStyle = useAthenaThemeStyle();\n const container = usePortalContainer();\n return (\n <DropdownMenu.Portal container={container}>\n <DropdownMenu.Content\n align=\"start\"\n sideOffset={4}\n collisionPadding={8}\n aria-label={label}\n // Its box and colours inline: no host stylesheet can take them away\n // (lib/portal-surface.ts).\n style={portalSurfaceStyle({ surface: 'popover', themeStyle })}\n className={cn(\n 'athena-sdk athena-sdk-chrome',\n 'z-50 block max-h-80 w-64 overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md outline-none',\n )}\n >\n {children}\n </DropdownMenu.Content>\n </DropdownMenu.Portal>\n );\n}\n\nfunction PickerItem({\n value,\n detail,\n children,\n}: {\n value: string;\n /** A second, muted line (the model behind an author's label, or why the item is listed). */\n detail?: ReactNode;\n children: ReactNode;\n}) {\n return (\n <DropdownMenu.RadioItem value={value} className={ITEM_CLASS}>\n {detail ? (\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <span className=\"truncate\">{children}</span>\n <span className=\"truncate text-xs font-normal text-muted-foreground\">{detail}</span>\n </span>\n ) : (\n <span className=\"min-w-0 flex-1 truncate\">{children}</span>\n )}\n <DropdownMenu.ItemIndicator className=\"absolute right-2 inline-flex\">\n <CheckIcon className=\"size-3.5\" aria-hidden />\n </DropdownMenu.ItemIndicator>\n </DropdownMenu.RadioItem>\n );\n}\n\nfunction PickerNote({ children, alert = false }: { children: ReactNode; alert?: boolean }) {\n return (\n <p\n className={cn('px-2 py-1.5 text-xs', alert ? 'text-destructive' : 'text-muted-foreground')}\n role={alert ? 'alert' : undefined}\n >\n {children}\n </p>\n );\n}\n\nexport interface ChatModelPickerProps {\n /** The chosen model id; `null` lets a selected agent run its own model. */\n value: string | null;\n onChange: (modelId: string | null) => void;\n /** The model a person who chose nothing runs, e.g. `claude-opus-5-5`. */\n defaultModelId: string;\n /**\n * A collab agent is chosen: the picker offers the workspace's models and\n * \"Agent's own model\" (`null`), as before, unless the agent restricts its\n * models (its \"Allow any workspace model\" switch is off), when it offers\n * exactly the agent's own (`useAthenaAgentModelOptions`). Which agent:\n * `agent`, else the one the surrounding `AthenaProvider` runs as.\n */\n agentSelected?: boolean;\n /**\n * The chosen collab agent, as its asset id or `collab_agent:<id>` (implies\n * `agentSelected`). `null` is no agent.\n */\n agent?: string | null;\n /**\n * The collab channel the chat runs on (its model override is the default\n * there). Defaults to the provider's `channel` when the agent is the\n * provider's.\n */\n channel?: string | null;\n disabled?: boolean;\n className?: string;\n}\n\n/**\n * Which model new messages run, from the models the workspace allows this\n * person; with an agent chosen, also \"Agent's own model\" (`null`), or exactly\n * the models its author listed when the agent restricts its models\n * (`allowAnyModel: false`, opt-in per agent). The host passes the choice to\n * `AthenaProvider` as `model`; a change reaches an open session too (the\n * provider writes it to the session's server config).\n */\nexport function ChatModelPicker({\n value,\n onChange,\n defaultModelId,\n agentSelected = false,\n agent,\n channel,\n disabled = false,\n className,\n}: ChatModelPickerProps) {\n const providerSelection = useContext(AthenaAgentSelectionContext);\n const agentAssetId =\n agent !== undefined\n ? agentAssetIdOf(agent)\n : agentSelected\n ? (providerSelection?.agentAssetId ?? null)\n : null;\n if (agentAssetId !== null) {\n const agentChannel =\n channel !== undefined\n ? channel\n : providerSelection?.agentAssetId === agentAssetId\n ? providerSelection.channel\n : null;\n return (\n <AgentAwareModelPicker\n agentAssetId={agentAssetId}\n channel={agentChannel}\n value={value}\n onChange={onChange}\n defaultModelId={defaultModelId}\n disabled={disabled}\n className={className}\n />\n );\n }\n return (\n <WorkspaceModelPicker\n value={value}\n onChange={onChange}\n defaultModelId={defaultModelId}\n agentSelected={agentSelected}\n disabled={disabled}\n className={className}\n />\n );\n}\n\n/**\n * The picker with a collab agent chosen. The agent is read first: one that\n * restricts its models gets {@link AgentModelMenu}; every other agent (the\n * default, and one this person cannot read) gets the workspace menu as before,\n * its \"Agent's own model\" naming the agent's default when known. Until the\n * read settles the workspace menu shows but replaces nothing on the host's\n * behalf, since the host's model may be one only the agent offers.\n */\nfunction AgentAwareModelPicker({\n agentAssetId,\n channel,\n value,\n onChange,\n defaultModelId,\n disabled,\n className,\n}: {\n agentAssetId: string;\n channel: string | null;\n value: string | null;\n onChange: (modelId: string | null) => void;\n defaultModelId: string;\n disabled: boolean;\n className?: string;\n}) {\n // One query client for the agent read and the catalog both menus name models from.\n const { choices, modelLabel, catalog } = useAgentModelChoices({ agent: agentAssetId, channel });\n if (choices.status === 'ready' && !choices.allowAnyModel) {\n return (\n <AgentModelMenu\n choices={choices}\n modelLabel={modelLabel}\n value={value}\n onChange={onChange}\n disabled={disabled}\n className={className}\n />\n );\n }\n return (\n <WorkspaceModelMenu\n catalog={catalog}\n value={value}\n onChange={onChange}\n defaultModelId={defaultModelId}\n agentSelected\n agentDefaultLabel={choices.defaultModel === null ? null : modelLabel(choices.defaultModel)}\n holdReplacement={choices.status === 'loading'}\n disabled={disabled}\n className={className}\n />\n );\n}\n\n/** The model picker over the workspace's catalog, with no agent chosen (or none it can name). */\nfunction WorkspaceModelPicker(props: {\n value: string | null;\n onChange: (modelId: string | null) => void;\n defaultModelId: string;\n agentSelected: boolean;\n disabled: boolean;\n className?: string;\n}) {\n const catalog = useAthenaModelCatalog();\n return <WorkspaceModelMenu catalog={catalog} {...props} />;\n}\n\n/** The workspace catalog's menu (the picker as it was before agents could restrict models). */\nfunction WorkspaceModelMenu({\n catalog,\n value,\n onChange,\n defaultModelId,\n agentSelected,\n agentDefaultLabel = null,\n holdReplacement = false,\n disabled,\n className,\n}: {\n catalog: ReturnType<typeof useAthenaModelCatalog>;\n value: string | null;\n onChange: (modelId: string | null) => void;\n defaultModelId: string;\n agentSelected: boolean;\n /** The chosen agent's default model (its channel's override when it has one), named under \"Agent's own model\". */\n agentDefaultLabel?: string | null;\n /** Replace no unoffered choice yet (the chosen agent is still being read). */\n holdReplacement?: boolean;\n disabled: boolean;\n className?: string;\n}) {\n const [open, setOpen] = useState(false);\n const models = catalog.data ?? [];\n const resolved =\n value === null && agentSelected\n ? null\n : resolveCatalogModelId({ stored: value, defaultModelId, models });\n const current = models.find((model) => model.id === resolved);\n const label = resolved === null ? 'Agent’s model' : (current?.label ?? resolved);\n // The host's choice is no longer offered (retired, or the workspace stopped allowing it): hand\n // the host the model the chip shows, so new messages run it instead of the dropped id. Once per\n // choice, so a host that keeps the old value is not asked again on every render.\n const replacedRef = useRef<string | null>(null);\n useEffect(() => {\n if (holdReplacement) return;\n if (!catalog.isSuccess || value === null || resolved === null || resolved === value) return;\n if (models.some((model) => model.id === value) || replacedRef.current === value) return;\n replacedRef.current = value;\n onChange(resolved);\n }, [holdReplacement, catalog.isSuccess, models, value, resolved, onChange]);\n return (\n <DropdownMenu.Root open={open} onOpenChange={setOpen}>\n <DropdownMenu.Trigger asChild>\n <button\n type=\"button\"\n className={cn(CHIP_CLASS, className)}\n disabled={disabled}\n aria-label={`Model: ${label}`}\n >\n <SparklesIcon className=\"size-3.5 shrink-0\" aria-hidden />\n <span className=\"truncate\">{label}</span>\n <ChevronDownIcon className=\"size-3 shrink-0\" aria-hidden />\n </button>\n </DropdownMenu.Trigger>\n <PickerMenu label=\"Model\">\n <DropdownMenu.RadioGroup\n value={resolved ?? AGENT_OWN_MODEL}\n onValueChange={(next) => onChange(next === AGENT_OWN_MODEL ? null : next)}\n >\n {agentSelected && (\n <PickerItem value={AGENT_OWN_MODEL} detail={agentDefaultLabel}>\n Agent’s own model\n </PickerItem>\n )}\n {catalog.isPending && <PickerNote>Loading models…</PickerNote>}\n {catalog.isError && <PickerNote alert>Couldn’t load the models. Try again in a moment.</PickerNote>}\n {groupModelsByProvider({ models }).map((group) => (\n <DropdownMenu.Group key={group.provider}>\n <DropdownMenu.Label className=\"px-2 pb-0.5 pt-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground\">\n {group.provider}\n </DropdownMenu.Label>\n {group.models.map((model) => (\n <PickerItem key={model.id} value={model.id}>\n {model.label}\n {model.status === 'LEGACY' ? ' (legacy)' : ''}\n </PickerItem>\n ))}\n </DropdownMenu.Group>\n ))}\n </DropdownMenu.RadioGroup>\n </PickerMenu>\n </DropdownMenu.Root>\n );\n}\n\n/** One item of the agent's model menu. */\ninterface AgentModelItem {\n /** The radio value: a model id, or {@link AGENT_OWN_MODEL} for \"the agent's default\" (`null`). */\n value: string;\n label: string;\n isDefault: boolean;\n detail: string | null;\n}\n\n/**\n * The menu of a chosen collab agent that restricts its models: exactly its own\n * (`useAthenaAgentModelOptions`), the default as `null`. One choice is a label;\n * two or more a menu. Nothing is replaced on the host's behalf: a host choice\n * the agent does not list (an older pick) is shown and listed as it is, as is\n * a model the session pins outside the agent's list. A host choice that names\n * the default model explicitly is a pin, which the agent's next default would\n * not follow, so the menu then also offers \"Agent's own model\" (`null`).\n */\nfunction AgentModelMenu({\n choices,\n modelLabel,\n value,\n onChange,\n disabled,\n className,\n}: {\n choices: AthenaAgentModelOptions;\n modelLabel: (model: string) => string;\n value: string | null;\n onChange: (modelId: string | null) => void;\n disabled: boolean;\n className?: string;\n}) {\n const [open, setOpen] = useState(false);\n const pinsDefault = value !== null && value === choices.defaultModel;\n const items: AgentModelItem[] = choices.options.map((option) => {\n const display = modelLabel(option.model);\n return {\n value: option.isDefault && !pinsDefault ? AGENT_OWN_MODEL : option.model,\n label: option.label,\n isDefault: option.isDefault,\n detail: option.pinnedOutside\n ? 'Set for this conversation outside the agent'\n : display === option.label\n ? null\n : display,\n };\n });\n if (value !== null && !choices.options.some((option) => option.model === value)) {\n items.push({\n value,\n label: modelLabel(value),\n isDefault: false,\n detail: 'Not one of the agent’s models',\n });\n }\n if (pinsDefault) {\n items.push({\n value: AGENT_OWN_MODEL,\n label: 'Agent’s own model',\n isDefault: false,\n detail: 'Follows the agent’s default',\n });\n }\n const selectedValue = value ?? AGENT_OWN_MODEL;\n const selected = items.find((item) => item.value === selectedValue) ?? null;\n const label = selected?.label || AGENT_MODEL_LABEL;\n\n if (items.length < 2) {\n return (\n <span\n role=\"img\"\n aria-label={`Model: ${label}`}\n title={selected ? `This agent runs ${label}` : 'This agent runs its own model'}\n data-slot=\"chat-model-picker-label\"\n className={cn(STATIC_CHIP_CLASS, className)}\n >\n <SparklesIcon className=\"size-3.5 shrink-0\" aria-hidden />\n <span className=\"truncate\">{label}</span>\n </span>\n );\n }\n return (\n <DropdownMenu.Root open={open} onOpenChange={setOpen}>\n <DropdownMenu.Trigger asChild>\n <button\n type=\"button\"\n className={cn(CHIP_CLASS, className)}\n disabled={disabled}\n aria-label={`Model: ${label}`}\n >\n <SparklesIcon className=\"size-3.5 shrink-0\" aria-hidden />\n <span className=\"truncate\">{label}</span>\n <ChevronDownIcon className=\"size-3 shrink-0\" aria-hidden />\n </button>\n </DropdownMenu.Trigger>\n <PickerMenu label=\"Model\">\n <DropdownMenu.RadioGroup\n value={selectedValue}\n onValueChange={(next) => onChange(next === AGENT_OWN_MODEL ? null : next)}\n >\n <DropdownMenu.Label className=\"px-2 pb-0.5 pt-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground\">\n Agent models\n </DropdownMenu.Label>\n {items.map((item) => (\n <PickerItem key={item.value} value={item.value} detail={item.detail}>\n {item.label}\n {item.isDefault ? ' (default)' : ''}\n </PickerItem>\n ))}\n </DropdownMenu.RadioGroup>\n </PickerMenu>\n </DropdownMenu.Root>\n );\n}\n\nexport interface ChatAgentPickerProps {\n /** The chosen collab agent's asset id; `null` is Athena. */\n value: string | null;\n onChange: (agentId: string | null) => void;\n disabled?: boolean;\n className?: string;\n}\n\n/** The \"Athena\" item's value: no collab agent. */\nconst NO_AGENT = '__athena__';\n\n/** Who answers new messages: Athena, or a published collab agent the person can see. */\nexport function ChatAgentPicker({ value, onChange, disabled = false, className }: ChatAgentPickerProps) {\n const catalog = useAthenaAgentCatalog();\n const [open, setOpen] = useState(false);\n const agents = catalog.data ?? [];\n const label = value === null ? 'Athena' : (agents.find((agent) => agent.id === value)?.name ?? 'Agent');\n // The chosen agent is gone (unpublished, or no longer shared with this person): fall back to\n // Athena, so new messages do not target an agent they cannot reach. Once per choice.\n const clearedRef = useRef<string | null>(null);\n useEffect(() => {\n if (!catalog.isSuccess || value === null || clearedRef.current === value) return;\n if (agents.some((agent) => agent.id === value)) return;\n clearedRef.current = value;\n onChange(null);\n }, [catalog.isSuccess, agents, value, onChange]);\n return (\n <DropdownMenu.Root open={open} onOpenChange={setOpen}>\n <DropdownMenu.Trigger asChild>\n <button\n type=\"button\"\n className={cn(CHIP_CLASS, className)}\n disabled={disabled}\n aria-label={`Agent: ${label}`}\n >\n <BotIcon className=\"size-3.5 shrink-0\" aria-hidden />\n <span className=\"truncate\">{label}</span>\n <ChevronDownIcon className=\"size-3 shrink-0\" aria-hidden />\n </button>\n </DropdownMenu.Trigger>\n <PickerMenu label=\"Agent\">\n <DropdownMenu.RadioGroup\n value={value ?? NO_AGENT}\n onValueChange={(next) => onChange(next === NO_AGENT ? null : next)}\n >\n <PickerItem value={NO_AGENT}>Athena</PickerItem>\n {catalog.isError && <PickerNote alert>Couldn’t load the agents. Try again in a moment.</PickerNote>}\n {agents.map((agent) => (\n <PickerItem key={agent.id} value={agent.id}>\n {agent.name}\n </PickerItem>\n ))}\n </DropdownMenu.RadioGroup>\n </PickerMenu>\n </DropdownMenu.Root>\n );\n}\n\nexport interface ChatModePickerProps {\n /** The mode the session runs in: `base` or a mode's id. */\n value: string;\n /** The modes to offer. */\n options: readonly AthenaChatModeOption[];\n onChange: (modeId: string) => void;\n /** The name of `value` when it is none of `options`. */\n valueLabel?: string;\n disabled?: boolean;\n /** Why the picker is disabled, shown as its tooltip. */\n disabledReason?: string;\n className?: string;\n}\n\n/**\n * Which of the agent's modes the chat runs in, as a chip with a radio menu\n * like the other composer pickers. Controlled: `useAthenaChatMode` gives the\n * options, the current mode and `select`, which `AthenaChat`'s built-in menu\n * ({@link AthenaChatModeMenu}) wires up for you.\n */\nexport function ChatModePicker({\n value,\n options,\n onChange,\n valueLabel,\n disabled = false,\n disabledReason,\n className,\n}: ChatModePickerProps) {\n const [open, setOpen] = useState(false);\n const label = options.find((option) => option.id === value)?.label ?? valueLabel ?? value;\n return (\n <DropdownMenu.Root open={open} onOpenChange={setOpen}>\n <DropdownMenu.Trigger asChild>\n <button\n type=\"button\"\n className={cn(CHIP_CLASS, className)}\n disabled={disabled}\n title={disabled ? disabledReason : undefined}\n aria-label={`Mode: ${label}`}\n data-slot=\"chat-mode-picker\"\n >\n <LayersIcon className=\"size-3.5 shrink-0\" aria-hidden />\n <span className=\"truncate\">{label}</span>\n <ChevronDownIcon className=\"size-3 shrink-0\" aria-hidden />\n </button>\n </DropdownMenu.Trigger>\n <PickerMenu label=\"Mode\">\n <DropdownMenu.RadioGroup value={value} onValueChange={onChange}>\n {options.map((option) => (\n <PickerItem key={option.id} value={option.id}>\n {option.label}\n </PickerItem>\n ))}\n </DropdownMenu.RadioGroup>\n </PickerMenu>\n </DropdownMenu.Root>\n );\n}\n\n/**\n * `AthenaChat`'s mode menu: {@link ChatModePicker} over `useAthenaChatMode`,\n * shown only while the provider's `modes` give the chat two or more modes.\n */\nexport function AthenaChatModeMenu({ className }: { className?: string }) {\n const mode = useAthenaChatMode();\n if (mode.status !== 'ready') return null;\n return (\n <ChatModePicker\n value={mode.current}\n valueLabel={mode.currentLabel}\n options={mode.options}\n onChange={mode.select}\n disabled={!mode.canSwitch}\n disabledReason=\"This channel keeps each conversation in the mode it started in. Start a new conversation to pick another.\"\n className={className}\n />\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AA4BA,MAAM,aACJ;AAGF,MAAM,oBACJ;AAEF,MAAM,aACJ;AAGF,MAAM,kBAAkB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apiClient = require("../chat-ui/mentions/suggestions/data/api-client.cjs");
7
7
  const AthenaContext = require("../provider/AthenaContext.cjs");
8
+ const useAthenaThreadModel = require("../threads/use-athena-thread-model.cjs");
9
+ const agentModelOptions = require("./agent-model-options.cjs");
8
10
  const MODEL_PROVIDER_LABELS = {
9
11
  ANTHROPIC: "Anthropic",
10
12
  OPENAI: "OpenAI",
@@ -136,9 +138,17 @@ function useCatalogQueryClient() {
136
138
  return host ?? own;
137
139
  }
138
140
  function useAthenaModelCatalog() {
139
- const auth = useCatalogAuth();
140
- const principal = useCatalogPrincipal();
141
- const queryClient = useCatalogQueryClient();
141
+ return useModelCatalogQuery({
142
+ auth: useCatalogAuth(),
143
+ principal: useCatalogPrincipal(),
144
+ queryClient: useCatalogQueryClient()
145
+ });
146
+ }
147
+ function useModelCatalogQuery({
148
+ auth,
149
+ principal,
150
+ queryClient
151
+ }) {
142
152
  return reactQuery.useQuery(
143
153
  {
144
154
  queryKey: ["athena-sdk", "catalog", "models", auth.backendUrl, principal],
@@ -168,14 +178,122 @@ function useAthenaAgentCatalog() {
168
178
  queryClient
169
179
  );
170
180
  }
181
+ const ATHENA_AGENT_MODELS_QUERY = `
182
+ query AthenaAgentModels($assetId: String!) {
183
+ getAssetById(assetId: $assetId, withMetadata: true) { athenaMetadata }
184
+ }
185
+ `;
186
+ const AGENT_READ_DENIAL_CODES = /* @__PURE__ */ new Set([
187
+ "UNAUTHORIZED",
188
+ "FORBIDDEN",
189
+ "WORKSPACE_MISMATCH"
190
+ ]);
191
+ const NO_AGENT_MODEL_OPTIONS = {
192
+ idle: { status: "idle", options: [], defaultModel: null, allowAnyModel: true },
193
+ loading: { status: "loading", options: [], defaultModel: null, allowAnyModel: true },
194
+ unavailable: { status: "unavailable", options: [], defaultModel: null, allowAnyModel: true },
195
+ error: { status: "error", options: [], defaultModel: null, allowAnyModel: true }
196
+ };
197
+ function isAgentReadDenial(error) {
198
+ return error instanceof apiClient.AthenaGraphQLError && error.code !== null && AGENT_READ_DENIAL_CODES.has(error.code);
199
+ }
200
+ function useAthenaAgentModelOptions({
201
+ agent,
202
+ channel = null
203
+ }) {
204
+ return useAgentModelChoices({ agent, channel }).choices;
205
+ }
206
+ const AGENT_MODELS_REFRESH_MS = 60 * 1e3;
207
+ function agentModelsRefetchInterval({
208
+ data
209
+ }) {
210
+ return data !== void 0 && !data.readable ? false : AGENT_MODELS_REFRESH_MS;
211
+ }
212
+ function useAgentModelChoices({
213
+ agent,
214
+ channel
215
+ }) {
216
+ const assetId = agentModelOptions.agentAssetIdOf(agent);
217
+ const auth = useCatalogAuth();
218
+ const principal = useCatalogPrincipal();
219
+ const queryClient = useCatalogQueryClient();
220
+ const read = reactQuery.useQuery(
221
+ {
222
+ queryKey: ["athena-sdk", "catalog", "agent-models", auth.backendUrl, principal, assetId],
223
+ queryFn: async () => {
224
+ try {
225
+ const data = await apiClient.fetchGraphQL(
226
+ auth,
227
+ ATHENA_AGENT_MODELS_QUERY,
228
+ { assetId }
229
+ );
230
+ if (data.getAssetById === null) return { readable: false };
231
+ return {
232
+ readable: true,
233
+ source: agentModelOptions.publishedAgentModelSource(data.getAssetById.athenaMetadata)
234
+ };
235
+ } catch (error) {
236
+ if (isAgentReadDenial(error)) return { readable: false };
237
+ throw error;
238
+ }
239
+ },
240
+ enabled: assetId !== null,
241
+ staleTime: AGENT_MODELS_REFRESH_MS,
242
+ refetchInterval: (query) => agentModelsRefetchInterval({ data: query.state.data })
243
+ },
244
+ queryClient
245
+ );
246
+ const catalog = useModelCatalogQuery({ auth, principal, queryClient });
247
+ const threadModel = useAthenaThreadModel.useOptionalAthenaThreadModel();
248
+ const pinnedModel = threadModel !== null && threadModel.ready && threadModel.configured ? threadModel.model : null;
249
+ const trimmedChannel = (channel == null ? void 0 : channel.trim()) || null;
250
+ const models = catalog.data;
251
+ const catalogPending = catalog.isPending;
252
+ const { isPending: readPending, data: readData } = read;
253
+ const modelLabel = react.useCallback(
254
+ (model) => {
255
+ var _a;
256
+ return ((_a = models == null ? void 0 : models.find((option) => option.id === model)) == null ? void 0 : _a.label) ?? model;
257
+ },
258
+ [models]
259
+ );
260
+ const choices = react.useMemo(() => {
261
+ if (assetId === null) return NO_AGENT_MODEL_OPTIONS.idle;
262
+ if (readData === void 0) {
263
+ return readPending ? NO_AGENT_MODEL_OPTIONS.loading : NO_AGENT_MODEL_OPTIONS.error;
264
+ }
265
+ if (!readData.readable || readData.source === null) return NO_AGENT_MODEL_OPTIONS.unavailable;
266
+ if (catalogPending) return NO_AGENT_MODEL_OPTIONS.loading;
267
+ return {
268
+ status: "ready",
269
+ ...agentModelOptions.buildAgentModelOptions({
270
+ source: readData.source,
271
+ channel: trimmedChannel,
272
+ pinnedModel,
273
+ modelLabel
274
+ }),
275
+ allowAnyModel: readData.source.allowAnyModel
276
+ };
277
+ }, [assetId, readPending, readData, catalogPending, modelLabel, trimmedChannel, pinnedModel]);
278
+ return react.useMemo(() => ({ choices, modelLabel, catalog }), [choices, modelLabel, catalog]);
279
+ }
280
+ exports.AGENT_MODELS_REFRESH_MS = AGENT_MODELS_REFRESH_MS;
171
281
  exports.ATHENA_AGENT_CATALOG_QUERY = ATHENA_AGENT_CATALOG_QUERY;
282
+ exports.ATHENA_AGENT_MODELS_QUERY = ATHENA_AGENT_MODELS_QUERY;
172
283
  exports.ATHENA_MODEL_CATALOG_QUERY = ATHENA_MODEL_CATALOG_QUERY;
173
284
  exports.MODEL_PROVIDER_LABELS = MODEL_PROVIDER_LABELS;
285
+ exports.agentModelsRefetchInterval = agentModelsRefetchInterval;
174
286
  exports.credentialFingerprint = credentialFingerprint;
175
287
  exports.groupModelsByProvider = groupModelsByProvider;
288
+ exports.isAgentReadDenial = isAgentReadDenial;
176
289
  exports.normalizeAgentCatalog = normalizeAgentCatalog;
177
290
  exports.normalizeModelCatalog = normalizeModelCatalog;
178
291
  exports.resolveCatalogModelId = resolveCatalogModelId;
292
+ exports.useAgentModelChoices = useAgentModelChoices;
179
293
  exports.useAthenaAgentCatalog = useAthenaAgentCatalog;
294
+ exports.useAthenaAgentModelOptions = useAthenaAgentModelOptions;
180
295
  exports.useAthenaModelCatalog = useAthenaModelCatalog;
296
+ exports.useCatalogAuth = useCatalogAuth;
297
+ exports.useCatalogPrincipal = useCatalogPrincipal;
298
+ exports.useCatalogQueryClient = useCatalogQueryClient;
181
299
  //# sourceMappingURL=runtime-catalog.cjs.map