@flanksource/clicky-ui 0.3.29 → 0.3.30

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 (224) hide show
  1. package/dist/ai.cjs +48 -3
  2. package/dist/ai.cjs.map +1 -1
  3. package/dist/ai.js +46 -1
  4. package/dist/ai.js.map +1 -1
  5. package/dist/components/DateField.d.ts +1 -1
  6. package/dist/components/DatePicker.d.ts +1 -1
  7. package/dist/components/DateTimePicker.d.ts +1 -1
  8. package/dist/components/mdx-editor-callout-model.d.ts +1 -1
  9. package/dist/data/MarkdownEditor.model.d.ts +1 -1
  10. package/dist/data/ai/ChatWindow.catalogs.cjs +11 -5
  11. package/dist/data/ai/ChatWindow.catalogs.cjs.map +1 -1
  12. package/dist/data/ai/ChatWindow.catalogs.d.ts +2 -1
  13. package/dist/data/ai/ChatWindow.catalogs.d.ts.map +1 -1
  14. package/dist/data/ai/ChatWindow.catalogs.js +11 -5
  15. package/dist/data/ai/ChatWindow.catalogs.js.map +1 -1
  16. package/dist/data/ai/ChatWindow.cjs +1 -0
  17. package/dist/data/ai/ChatWindow.cjs.map +1 -1
  18. package/dist/data/ai/ChatWindow.d.ts.map +1 -1
  19. package/dist/data/ai/ChatWindow.js +1 -0
  20. package/dist/data/ai/ChatWindow.js.map +1 -1
  21. package/dist/data/ai/PromptRunEditor/VariablesField.cjs +79 -0
  22. package/dist/data/ai/PromptRunEditor/VariablesField.cjs.map +1 -0
  23. package/dist/data/ai/PromptRunEditor/VariablesField.d.ts +8 -0
  24. package/dist/data/ai/PromptRunEditor/VariablesField.d.ts.map +1 -0
  25. package/dist/data/ai/PromptRunEditor/VariablesField.js +79 -0
  26. package/dist/data/ai/PromptRunEditor/VariablesField.js.map +1 -0
  27. package/dist/data/ai/PromptRunEditor/index.cjs +61 -69
  28. package/dist/data/ai/PromptRunEditor/index.cjs.map +1 -1
  29. package/dist/data/ai/PromptRunEditor/index.d.ts +11 -1
  30. package/dist/data/ai/PromptRunEditor/index.d.ts.map +1 -1
  31. package/dist/data/ai/PromptRunEditor/index.js +61 -69
  32. package/dist/data/ai/PromptRunEditor/index.js.map +1 -1
  33. package/dist/data/ai/PromptRunEditor/model.cjs.map +1 -1
  34. package/dist/data/ai/PromptRunEditor/model.d.ts +2 -0
  35. package/dist/data/ai/PromptRunEditor/model.d.ts.map +1 -1
  36. package/dist/data/ai/PromptRunEditor/model.js.map +1 -1
  37. package/dist/data/ai/SpecRuntimeEditor/ModelSection.cjs +4 -3
  38. package/dist/data/ai/SpecRuntimeEditor/ModelSection.cjs.map +1 -1
  39. package/dist/data/ai/SpecRuntimeEditor/ModelSection.d.ts.map +1 -1
  40. package/dist/data/ai/SpecRuntimeEditor/ModelSection.js +2 -1
  41. package/dist/data/ai/SpecRuntimeEditor/ModelSection.js.map +1 -1
  42. package/dist/data/ai/SpecRuntimeEditor/PermissionModeField.cjs +2 -2
  43. package/dist/data/ai/SpecRuntimeEditor/PermissionModeField.cjs.map +1 -1
  44. package/dist/data/ai/SpecRuntimeEditor/PermissionModeField.js +1 -1
  45. package/dist/data/ai/SpecRuntimeEditor/index.cjs +4 -3
  46. package/dist/data/ai/SpecRuntimeEditor/index.cjs.map +1 -1
  47. package/dist/data/ai/SpecRuntimeEditor/index.d.ts.map +1 -1
  48. package/dist/data/ai/SpecRuntimeEditor/index.js +2 -1
  49. package/dist/data/ai/SpecRuntimeEditor/index.js.map +1 -1
  50. package/dist/data/ai/index.d.ts +3 -2
  51. package/dist/data/ai/index.d.ts.map +1 -1
  52. package/dist/data/ai/runtime-profile.cjs.map +1 -1
  53. package/dist/data/ai/runtime-profile.d.ts +9 -7
  54. package/dist/data/ai/runtime-profile.d.ts.map +1 -1
  55. package/dist/data/ai/runtime-profile.js.map +1 -1
  56. package/dist/data/ai/runtime-profiles/OrderedPresetSelect.cjs +111 -0
  57. package/dist/data/ai/runtime-profiles/OrderedPresetSelect.cjs.map +1 -0
  58. package/dist/data/ai/runtime-profiles/OrderedPresetSelect.d.ts +7 -0
  59. package/dist/data/ai/runtime-profiles/OrderedPresetSelect.d.ts.map +1 -0
  60. package/dist/data/ai/runtime-profiles/OrderedPresetSelect.js +111 -0
  61. package/dist/data/ai/runtime-profiles/OrderedPresetSelect.js.map +1 -0
  62. package/dist/data/ai/runtime-profiles/PermissionStrategiesEditor.cjs +313 -0
  63. package/dist/data/ai/runtime-profiles/PermissionStrategiesEditor.cjs.map +1 -0
  64. package/dist/data/ai/runtime-profiles/PermissionStrategiesEditor.d.ts +8 -0
  65. package/dist/data/ai/runtime-profiles/PermissionStrategiesEditor.d.ts.map +1 -0
  66. package/dist/data/ai/runtime-profiles/PermissionStrategiesEditor.js +313 -0
  67. package/dist/data/ai/runtime-profiles/PermissionStrategiesEditor.js.map +1 -0
  68. package/dist/data/ai/runtime-profiles/PermissionStrategyConditionRow.cjs +98 -0
  69. package/dist/data/ai/runtime-profiles/PermissionStrategyConditionRow.cjs.map +1 -0
  70. package/dist/data/ai/runtime-profiles/PermissionStrategyConditionRow.d.ts +11 -0
  71. package/dist/data/ai/runtime-profiles/PermissionStrategyConditionRow.d.ts.map +1 -0
  72. package/dist/data/ai/runtime-profiles/PermissionStrategyConditionRow.js +98 -0
  73. package/dist/data/ai/runtime-profiles/PermissionStrategyConditionRow.js.map +1 -0
  74. package/dist/data/ai/runtime-profiles/PresetSpecEditor.cjs +35 -0
  75. package/dist/data/ai/runtime-profiles/PresetSpecEditor.cjs.map +1 -0
  76. package/dist/data/ai/runtime-profiles/PresetSpecEditor.d.ts +11 -0
  77. package/dist/data/ai/runtime-profiles/PresetSpecEditor.d.ts.map +1 -0
  78. package/dist/data/ai/runtime-profiles/PresetSpecEditor.js +35 -0
  79. package/dist/data/ai/runtime-profiles/PresetSpecEditor.js.map +1 -0
  80. package/dist/data/ai/runtime-profiles/PresetWorkspace.cjs +179 -0
  81. package/dist/data/ai/runtime-profiles/PresetWorkspace.cjs.map +1 -0
  82. package/dist/data/ai/runtime-profiles/PresetWorkspace.d.ts +22 -0
  83. package/dist/data/ai/runtime-profiles/PresetWorkspace.d.ts.map +1 -0
  84. package/dist/data/ai/runtime-profiles/PresetWorkspace.js +179 -0
  85. package/dist/data/ai/runtime-profiles/PresetWorkspace.js.map +1 -0
  86. package/dist/data/ai/runtime-profiles/ProfileSpecEditor.cjs +57 -0
  87. package/dist/data/ai/runtime-profiles/ProfileSpecEditor.cjs.map +1 -0
  88. package/dist/data/ai/runtime-profiles/ProfileSpecEditor.d.ts +18 -0
  89. package/dist/data/ai/runtime-profiles/ProfileSpecEditor.d.ts.map +1 -0
  90. package/dist/data/ai/runtime-profiles/ProfileSpecEditor.js +57 -0
  91. package/dist/data/ai/runtime-profiles/ProfileSpecEditor.js.map +1 -0
  92. package/dist/data/ai/runtime-profiles/ProfileWorkspace.cjs +135 -0
  93. package/dist/data/ai/runtime-profiles/ProfileWorkspace.cjs.map +1 -0
  94. package/dist/data/ai/runtime-profiles/ProfileWorkspace.d.ts +23 -0
  95. package/dist/data/ai/runtime-profiles/ProfileWorkspace.d.ts.map +1 -0
  96. package/dist/data/ai/runtime-profiles/ProfileWorkspace.js +135 -0
  97. package/dist/data/ai/runtime-profiles/ProfileWorkspace.js.map +1 -0
  98. package/dist/data/ai/runtime-profiles/ResolutionInspector.cjs +85 -0
  99. package/dist/data/ai/runtime-profiles/ResolutionInspector.cjs.map +1 -0
  100. package/dist/data/ai/runtime-profiles/ResolutionInspector.d.ts +7 -0
  101. package/dist/data/ai/runtime-profiles/ResolutionInspector.d.ts.map +1 -0
  102. package/dist/data/ai/runtime-profiles/ResolutionInspector.js +85 -0
  103. package/dist/data/ai/runtime-profiles/ResolutionInspector.js.map +1 -0
  104. package/dist/data/ai/runtime-profiles/ResolutionTrace.cjs +42 -0
  105. package/dist/data/ai/runtime-profiles/ResolutionTrace.cjs.map +1 -0
  106. package/dist/data/ai/runtime-profiles/ResolutionTrace.d.ts +6 -0
  107. package/dist/data/ai/runtime-profiles/ResolutionTrace.d.ts.map +1 -0
  108. package/dist/data/ai/runtime-profiles/ResolutionTrace.js +42 -0
  109. package/dist/data/ai/runtime-profiles/ResolutionTrace.js.map +1 -0
  110. package/dist/data/ai/runtime-profiles/RuntimeLibraryList.cjs +93 -0
  111. package/dist/data/ai/runtime-profiles/RuntimeLibraryList.cjs.map +1 -0
  112. package/dist/data/ai/runtime-profiles/RuntimeLibraryList.d.ts +18 -0
  113. package/dist/data/ai/runtime-profiles/RuntimeLibraryList.d.ts.map +1 -0
  114. package/dist/data/ai/runtime-profiles/RuntimeLibraryList.js +93 -0
  115. package/dist/data/ai/runtime-profiles/RuntimeLibraryList.js.map +1 -0
  116. package/dist/data/ai/runtime-profiles/RuntimePersistenceBar.cjs +44 -0
  117. package/dist/data/ai/runtime-profiles/RuntimePersistenceBar.cjs.map +1 -0
  118. package/dist/data/ai/runtime-profiles/RuntimePersistenceBar.d.ts +6 -0
  119. package/dist/data/ai/runtime-profiles/RuntimePersistenceBar.d.ts.map +1 -0
  120. package/dist/data/ai/runtime-profiles/RuntimePersistenceBar.js +44 -0
  121. package/dist/data/ai/runtime-profiles/RuntimePersistenceBar.js.map +1 -0
  122. package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.cjs +198 -0
  123. package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.cjs.map +1 -0
  124. package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.d.ts +12 -0
  125. package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.d.ts.map +1 -0
  126. package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.js +198 -0
  127. package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.js.map +1 -0
  128. package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.model.cjs +97 -0
  129. package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.model.cjs.map +1 -0
  130. package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.model.d.ts +26 -0
  131. package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.model.d.ts.map +1 -0
  132. package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.model.js +97 -0
  133. package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.model.js.map +1 -0
  134. package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.cjs +143 -0
  135. package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.cjs.map +1 -0
  136. package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.d.ts +25 -0
  137. package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.d.ts.map +1 -0
  138. package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.js +143 -0
  139. package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.js.map +1 -0
  140. package/dist/data/ai/runtime-profiles/RuntimeStatusNotice.cjs +41 -0
  141. package/dist/data/ai/runtime-profiles/RuntimeStatusNotice.cjs.map +1 -0
  142. package/dist/data/ai/runtime-profiles/RuntimeStatusNotice.d.ts +8 -0
  143. package/dist/data/ai/runtime-profiles/RuntimeStatusNotice.d.ts.map +1 -0
  144. package/dist/data/ai/runtime-profiles/RuntimeStatusNotice.js +41 -0
  145. package/dist/data/ai/runtime-profiles/RuntimeStatusNotice.js.map +1 -0
  146. package/dist/data/ai/runtime-profiles/index.d.ts +20 -0
  147. package/dist/data/ai/runtime-profiles/index.d.ts.map +1 -0
  148. package/dist/data/ai/runtime-profiles/types.d.ts +50 -0
  149. package/dist/data/ai/runtime-profiles/types.d.ts.map +1 -0
  150. package/dist/data/ai/runtime-profiles/use-permission-catalog.cjs +37 -0
  151. package/dist/data/ai/runtime-profiles/use-permission-catalog.cjs.map +1 -0
  152. package/dist/data/ai/runtime-profiles/use-permission-catalog.d.ts +5 -0
  153. package/dist/data/ai/runtime-profiles/use-permission-catalog.d.ts.map +1 -0
  154. package/dist/data/ai/runtime-profiles/use-permission-catalog.js +37 -0
  155. package/dist/data/ai/runtime-profiles/use-permission-catalog.js.map +1 -0
  156. package/dist/data/ai/runtime-profiles/use-resolution.cjs +43 -0
  157. package/dist/data/ai/runtime-profiles/use-resolution.cjs.map +1 -0
  158. package/dist/data/ai/runtime-profiles/use-resolution.d.ts +4 -0
  159. package/dist/data/ai/runtime-profiles/use-resolution.d.ts.map +1 -0
  160. package/dist/data/ai/runtime-profiles/use-resolution.js +43 -0
  161. package/dist/data/ai/runtime-profiles/use-resolution.js.map +1 -0
  162. package/dist/data/ai/runtime-profiles/use-runtime-families.cjs +38 -0
  163. package/dist/data/ai/runtime-profiles/use-runtime-families.cjs.map +1 -0
  164. package/dist/data/ai/runtime-profiles/use-runtime-families.d.ts +3 -0
  165. package/dist/data/ai/runtime-profiles/use-runtime-families.d.ts.map +1 -0
  166. package/dist/data/ai/runtime-profiles/use-runtime-families.js +38 -0
  167. package/dist/data/ai/runtime-profiles/use-runtime-families.js.map +1 -0
  168. package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.cjs +107 -0
  169. package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.cjs.map +1 -0
  170. package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.d.ts +35 -0
  171. package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.d.ts.map +1 -0
  172. package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.js +107 -0
  173. package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.js.map +1 -0
  174. package/dist/data/ai/use-session-scroll.cjs.map +1 -1
  175. package/dist/data/ai/use-session-scroll.d.ts +2 -2
  176. package/dist/data/ai/use-session-scroll.d.ts.map +1 -1
  177. package/dist/data/ai/use-session-scroll.js.map +1 -1
  178. package/dist/data/badge-variants.d.ts +1 -1
  179. package/dist/data/runtime/RuntimeBar.cjs +3 -2
  180. package/dist/data/runtime/RuntimeBar.cjs.map +1 -1
  181. package/dist/data/runtime/RuntimeBar.d.ts.map +1 -1
  182. package/dist/data/runtime/RuntimeBar.js +3 -2
  183. package/dist/data/runtime/RuntimeBar.js.map +1 -1
  184. package/dist/data/runtime/runtime-field-support.cjs +3 -3
  185. package/dist/data/runtime/runtime-field-support.cjs.map +1 -1
  186. package/dist/data/runtime/runtime-field-support.js +1 -1
  187. package/dist/data/runtime/runtime-mode.cjs +14 -47
  188. package/dist/data/runtime/runtime-mode.cjs.map +1 -1
  189. package/dist/data/runtime/runtime-mode.d.ts +5 -7
  190. package/dist/data/runtime/runtime-mode.d.ts.map +1 -1
  191. package/dist/data/runtime/runtime-mode.js +7 -39
  192. package/dist/data/runtime/runtime-mode.js.map +1 -1
  193. package/dist/data/version-info.cjs +3 -3
  194. package/dist/data/version-info.js +3 -3
  195. package/dist/index.cjs +52 -0
  196. package/dist/index.cjs.map +1 -1
  197. package/dist/index.js +52 -0
  198. package/dist/index.js.map +1 -1
  199. package/dist/lib/permission-strategies.cjs +155 -0
  200. package/dist/lib/permission-strategies.cjs.map +1 -0
  201. package/dist/lib/permission-strategies.d.ts +35 -0
  202. package/dist/lib/permission-strategies.d.ts.map +1 -0
  203. package/dist/lib/permission-strategies.js +155 -0
  204. package/dist/lib/permission-strategies.js.map +1 -0
  205. package/dist/lib/runtime-family.cjs +51 -0
  206. package/dist/lib/runtime-family.cjs.map +1 -0
  207. package/dist/lib/runtime-family.d.ts +25 -0
  208. package/dist/lib/runtime-family.d.ts.map +1 -0
  209. package/dist/lib/runtime-family.js +51 -0
  210. package/dist/lib/runtime-family.js.map +1 -0
  211. package/dist/lib/runtime-profile-model.cjs +129 -0
  212. package/dist/lib/runtime-profile-model.cjs.map +1 -0
  213. package/dist/lib/runtime-profile-model.d.ts +30 -0
  214. package/dist/lib/runtime-profile-model.d.ts.map +1 -0
  215. package/dist/lib/runtime-profile-model.js +129 -0
  216. package/dist/lib/runtime-profile-model.js.map +1 -0
  217. package/dist/styles.css +1 -1
  218. package/dist/utils.cjs +52 -0
  219. package/dist/utils.cjs.map +1 -1
  220. package/dist/utils.d.ts +5 -0
  221. package/dist/utils.d.ts.map +1 -1
  222. package/dist/utils.js +53 -1
  223. package/dist/utils.js.map +1 -1
  224. package/package.json +1 -1
@@ -0,0 +1,12 @@
1
+ import { ResolvedRuntimeSpec, RuntimePreset, RuntimeProfile } from '../runtime-profile';
2
+ import { AISpecRuntimeSpec } from '../SpecRuntimeEditor.model';
3
+ import { RuntimeProfilePickerController } from './use-runtime-profile-picker';
4
+ export type RuntimeProfilePickerProps = {
5
+ controller: RuntimeProfilePickerController;
6
+ profiles: RuntimeProfile[];
7
+ presets: RuntimePreset[];
8
+ resolution?: ResolvedRuntimeSpec | undefined;
9
+ effectiveRuntime: Pick<AISpecRuntimeSpec, "model" | "mode">;
10
+ };
11
+ export declare function RuntimeProfilePicker({ controller, profiles, presets, resolution, effectiveRuntime, }: RuntimeProfilePickerProps): import("react").JSX.Element;
12
+ //# sourceMappingURL=RuntimeProfilePicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuntimeProfilePicker.d.ts","sourceRoot":"","sources":["../../../../src/data/ai/runtime-profiles/RuntimeProfilePicker.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,cAAc,EACf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAKpE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AAInF,MAAM,MAAM,yBAAyB,GAAG;IACtC,UAAU,EAAE,8BAA8B,CAAC;IAC3C,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;IAC7C,gBAAgB,EAAE,IAAI,CAAC,iBAAiB,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC;CAC7D,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,EACnC,UAAU,EACV,QAAQ,EACR,OAAO,EACP,UAAU,EACV,gBAAgB,GACjB,EAAE,yBAAyB,+BA8J3B"}
@@ -0,0 +1,198 @@
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ import { Button } from "../../../components/button.js";
4
+ import { Combobox } from "../../../components/Combobox.js";
5
+ import { Field } from "../../../components/Field.js";
6
+ import { InputField } from "../../../components/InputField.js";
7
+ import { SegmentedControl } from "../../../components/SegmentedControl.js";
8
+ import { Icon } from "../../Icon.js";
9
+ import { Disclosure } from "../SpecRuntimeEditor/fields.js";
10
+ import { uniqueName } from "../../../lib/runtime-profile-model.js";
11
+ import { OrderedPresetSelect } from "./OrderedPresetSelect.js";
12
+ import { ResolutionTrace } from "./ResolutionTrace.js";
13
+ import { UiLayers } from "../../../icons/components/UiLayers.js";
14
+ import { UiSave } from "../../../icons/components/UiSave.js";
15
+ import { UiFilePlus } from "../../../icons/components/UiFilePlus.js";
16
+ import { UiGitMerge } from "../../../icons/components/UiGitMerge.js";
17
+ const NONE = "__clicky_runtime_profile_none__";
18
+ function RuntimeProfilePicker({
19
+ controller,
20
+ profiles,
21
+ presets,
22
+ resolution,
23
+ effectiveRuntime
24
+ }) {
25
+ var _a;
26
+ const { state } = controller;
27
+ const { draft } = state;
28
+ const nameId = useId();
29
+ const pendingProfile = profiles.find(
30
+ (profile) => {
31
+ var _a2;
32
+ return profile.id === ((_a2 = state.draft) == null ? void 0 : _a2.id);
33
+ }
34
+ );
35
+ const layers = [
36
+ { id: "run", label: "This run" },
37
+ { id: "profile", label: `Profile «${(draft == null ? void 0 : draft.name) ?? ""}»` }
38
+ ];
39
+ const nameTaken = draft ? !uniqueName(draft.name, draft.id, profiles) : false;
40
+ return /* @__PURE__ */ jsxs(
41
+ "section",
42
+ {
43
+ "aria-label": "Runtime profile",
44
+ className: "mb-density-3 space-y-density-2 rounded-lg border border-border bg-card p-density-3",
45
+ children: [
46
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-density-2", children: [
47
+ /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: [
48
+ /* @__PURE__ */ jsx(Icon, { icon: UiLayers, className: "size-3.5" }),
49
+ "Runtime profile"
50
+ ] }),
51
+ /* @__PURE__ */ jsx(
52
+ Combobox,
53
+ {
54
+ ariaLabel: "Runtime profile",
55
+ value: ((_a = state.draft) == null ? void 0 : _a.id) ?? NONE,
56
+ options: [
57
+ { value: NONE, label: "None" },
58
+ ...profiles.map((profile) => ({
59
+ value: profile.id,
60
+ label: profile.name,
61
+ ...profile.description ? { description: profile.description } : {}
62
+ }))
63
+ ],
64
+ onChange: (next) => controller.select(next === NONE ? void 0 : next),
65
+ allowCustomValue: false,
66
+ required: true,
67
+ className: "min-w-56 flex-1"
68
+ }
69
+ )
70
+ ] }),
71
+ controller.pending && /* @__PURE__ */ jsxs(
72
+ "div",
73
+ {
74
+ role: "alert",
75
+ className: "flex flex-wrap items-center gap-density-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-density-3 py-density-2 text-xs",
76
+ children: [
77
+ /* @__PURE__ */ jsxs("span", { className: "flex-1", children: [
78
+ "Discard changes to «",
79
+ (pendingProfile == null ? void 0 : pendingProfile.name) ?? (draft == null ? void 0 : draft.name),
80
+ "»?"
81
+ ] }),
82
+ /* @__PURE__ */ jsx(
83
+ Button,
84
+ {
85
+ size: "sm",
86
+ variant: "outline",
87
+ onClick: controller.cancelPending,
88
+ children: "Keep editing"
89
+ }
90
+ ),
91
+ /* @__PURE__ */ jsx(
92
+ Button,
93
+ {
94
+ size: "sm",
95
+ variant: "destructive",
96
+ onClick: controller.confirmPending,
97
+ children: "Discard"
98
+ }
99
+ )
100
+ ]
101
+ }
102
+ ),
103
+ draft && /* @__PURE__ */ jsxs(Fragment, { children: [
104
+ /* @__PURE__ */ jsx(
105
+ SegmentedControl,
106
+ {
107
+ "aria-label": "Editing layer",
108
+ size: "sm",
109
+ value: state.layer,
110
+ options: layers,
111
+ onChange: controller.setLayer
112
+ }
113
+ ),
114
+ state.layer === "profile" && /* @__PURE__ */ jsxs("div", { className: "space-y-density-2", children: [
115
+ /* @__PURE__ */ jsx(
116
+ Field,
117
+ {
118
+ label: "Profile name",
119
+ htmlFor: nameId,
120
+ labelClassName: "text-xs",
121
+ error: nameTaken ? "A unique profile name is required." : void 0,
122
+ children: /* @__PURE__ */ jsx(
123
+ InputField,
124
+ {
125
+ id: nameId,
126
+ value: draft.name,
127
+ invalid: nameTaken,
128
+ onChange: (name) => controller.editDraft({ ...draft, name })
129
+ }
130
+ )
131
+ }
132
+ ),
133
+ /* @__PURE__ */ jsx(
134
+ OrderedPresetSelect,
135
+ {
136
+ presets,
137
+ value: draft.presets,
138
+ onChange: (next) => controller.editDraft({ ...draft, presets: next })
139
+ }
140
+ )
141
+ ] }),
142
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-density-2", children: [
143
+ /* @__PURE__ */ jsxs(
144
+ Button,
145
+ {
146
+ size: "sm",
147
+ disabled: !controller.canSave || !controller.dirty || nameTaken || Boolean(controller.busy),
148
+ onClick: () => void controller.save(),
149
+ children: [
150
+ /* @__PURE__ */ jsx(Icon, { icon: UiSave, className: "size-3.5" }),
151
+ "Save profile"
152
+ ]
153
+ }
154
+ ),
155
+ /* @__PURE__ */ jsxs(
156
+ Button,
157
+ {
158
+ size: "sm",
159
+ variant: "outline",
160
+ disabled: !controller.canCreate || Boolean(controller.busy),
161
+ onClick: () => void controller.saveAsNew(),
162
+ children: [
163
+ /* @__PURE__ */ jsx(Icon, { icon: UiFilePlus, className: "size-3.5" }),
164
+ "Save as new"
165
+ ]
166
+ }
167
+ ),
168
+ /* @__PURE__ */ jsxs(
169
+ Button,
170
+ {
171
+ size: "sm",
172
+ variant: "outline",
173
+ disabled: Boolean(controller.busy),
174
+ onClick: () => void controller.detach(),
175
+ children: [
176
+ /* @__PURE__ */ jsx(Icon, { icon: UiGitMerge, className: "size-3.5" }),
177
+ "Detach"
178
+ ]
179
+ }
180
+ ),
181
+ controller.busy && /* @__PURE__ */ jsx("span", { role: "status", className: "text-xs text-muted-foreground", children: controller.busy === "detach" ? "Resolving…" : "Saving…" })
182
+ ] })
183
+ ] }),
184
+ controller.error && /* @__PURE__ */ jsx("p", { role: "alert", className: "text-xs text-destructive", children: controller.error }),
185
+ controller.notice && /* @__PURE__ */ jsx("p", { role: "status", className: "text-xs text-muted-foreground", children: controller.notice }),
186
+ /* @__PURE__ */ jsx(Disclosure, { label: "Resolution", hint: effectiveLabel(effectiveRuntime), children: /* @__PURE__ */ jsx(ResolutionTrace, { trace: (resolution == null ? void 0 : resolution.trace) ?? [] }) })
187
+ ]
188
+ }
189
+ );
190
+ }
191
+ function effectiveLabel(runtime) {
192
+ const parts = [runtime.model, runtime.mode].filter(Boolean);
193
+ return parts.length > 0 ? parts.join(" · ") : "inherits prompt defaults";
194
+ }
195
+ export {
196
+ RuntimeProfilePicker
197
+ };
198
+ //# sourceMappingURL=RuntimeProfilePicker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuntimeProfilePicker.js","sources":["../../../../src/data/ai/runtime-profiles/RuntimeProfilePicker.tsx"],"sourcesContent":["import { useId } from \"react\";\nimport { Button } from \"../../../components/button\";\nimport { Combobox } from \"../../../components/Combobox\";\nimport { Field } from \"../../../components/Field\";\nimport { InputField } from \"../../../components/InputField\";\nimport {\n SegmentedControl,\n type SegmentedOption,\n} from \"../../../components/SegmentedControl\";\nimport { UiFilePlus, UiGitMerge, UiLayers, UiSave } from \"../../../icons\";\nimport { Icon } from \"../../Icon\";\nimport type {\n ResolvedRuntimeSpec,\n RuntimePreset,\n RuntimeProfile,\n} from \"../runtime-profile\";\nimport { Disclosure } from \"../SpecRuntimeEditor/fields\";\nimport type { AISpecRuntimeSpec } from \"../SpecRuntimeEditor.model\";\nimport { uniqueName } from \"../../../lib/runtime-profile-model\";\nimport { OrderedPresetSelect } from \"./OrderedPresetSelect\";\nimport { ResolutionTrace } from \"./ResolutionTrace\";\nimport type { RuntimeProfileLayer } from \"./RuntimeProfilePicker.model\";\nimport type { RuntimeProfilePickerController } from \"./use-runtime-profile-picker\";\n\nconst NONE = \"__clicky_runtime_profile_none__\";\n\nexport type RuntimeProfilePickerProps = {\n controller: RuntimeProfilePickerController;\n profiles: RuntimeProfile[];\n presets: RuntimePreset[];\n resolution?: ResolvedRuntimeSpec | undefined;\n effectiveRuntime: Pick<AISpecRuntimeSpec, \"model\" | \"mode\">;\n};\n\nexport function RuntimeProfilePicker({\n controller,\n profiles,\n presets,\n resolution,\n effectiveRuntime,\n}: RuntimeProfilePickerProps) {\n const { state } = controller;\n const { draft } = state;\n const nameId = useId();\n const pendingProfile = profiles.find(\n (profile) => profile.id === state.draft?.id,\n );\n const layers: SegmentedOption<RuntimeProfileLayer>[] = [\n { id: \"run\", label: \"This run\" },\n { id: \"profile\", label: `Profile «${draft?.name ?? \"\"}»` },\n ];\n const nameTaken = draft ? !uniqueName(draft.name, draft.id, profiles) : false;\n\n return (\n <section\n aria-label=\"Runtime profile\"\n className=\"mb-density-3 space-y-density-2 rounded-lg border border-border bg-card p-density-3\"\n >\n <div className=\"flex flex-wrap items-center gap-density-2\">\n <span className=\"inline-flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground\">\n <Icon icon={UiLayers} className=\"size-3.5\" />\n Runtime profile\n </span>\n <Combobox\n ariaLabel=\"Runtime profile\"\n value={state.draft?.id ?? NONE}\n options={[\n { value: NONE, label: \"None\" },\n ...profiles.map((profile) => ({\n value: profile.id,\n label: profile.name,\n ...(profile.description\n ? { description: profile.description }\n : {}),\n })),\n ]}\n onChange={(next) =>\n controller.select(next === NONE ? undefined : next)\n }\n allowCustomValue={false}\n required\n className=\"min-w-56 flex-1\"\n />\n </div>\n {controller.pending && (\n <div\n role=\"alert\"\n className=\"flex flex-wrap items-center gap-density-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-density-3 py-density-2 text-xs\"\n >\n <span className=\"flex-1\">\n Discard changes to «{pendingProfile?.name ?? draft?.name}»?\n </span>\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={controller.cancelPending}\n >\n Keep editing\n </Button>\n <Button\n size=\"sm\"\n variant=\"destructive\"\n onClick={controller.confirmPending}\n >\n Discard\n </Button>\n </div>\n )}\n {draft && (\n <>\n <SegmentedControl\n aria-label=\"Editing layer\"\n size=\"sm\"\n value={state.layer}\n options={layers}\n onChange={controller.setLayer}\n />\n {state.layer === \"profile\" && (\n <div className=\"space-y-density-2\">\n <Field\n label=\"Profile name\"\n htmlFor={nameId}\n labelClassName=\"text-xs\"\n error={\n nameTaken ? \"A unique profile name is required.\" : undefined\n }\n >\n <InputField\n id={nameId}\n value={draft.name}\n invalid={nameTaken}\n onChange={(name) => controller.editDraft({ ...draft, name })}\n />\n </Field>\n <OrderedPresetSelect\n presets={presets}\n value={draft.presets}\n onChange={(next) =>\n controller.editDraft({ ...draft, presets: next })\n }\n />\n </div>\n )}\n <div className=\"flex flex-wrap items-center gap-density-2\">\n <Button\n size=\"sm\"\n disabled={\n !controller.canSave ||\n !controller.dirty ||\n nameTaken ||\n Boolean(controller.busy)\n }\n onClick={() => void controller.save()}\n >\n <Icon icon={UiSave} className=\"size-3.5\" />\n Save profile\n </Button>\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={!controller.canCreate || Boolean(controller.busy)}\n onClick={() => void controller.saveAsNew()}\n >\n <Icon icon={UiFilePlus} className=\"size-3.5\" />\n Save as new\n </Button>\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={Boolean(controller.busy)}\n onClick={() => void controller.detach()}\n >\n <Icon icon={UiGitMerge} className=\"size-3.5\" />\n Detach\n </Button>\n {controller.busy && (\n <span role=\"status\" className=\"text-xs text-muted-foreground\">\n {controller.busy === \"detach\" ? \"Resolving…\" : \"Saving…\"}\n </span>\n )}\n </div>\n </>\n )}\n {controller.error && (\n <p role=\"alert\" className=\"text-xs text-destructive\">\n {controller.error}\n </p>\n )}\n {controller.notice && (\n <p role=\"status\" className=\"text-xs text-muted-foreground\">\n {controller.notice}\n </p>\n )}\n <Disclosure label=\"Resolution\" hint={effectiveLabel(effectiveRuntime)}>\n <ResolutionTrace trace={resolution?.trace ?? []} />\n </Disclosure>\n </section>\n );\n}\n\nfunction effectiveLabel(runtime: Pick<AISpecRuntimeSpec, \"model\" | \"mode\">) {\n const parts = [runtime.model, runtime.mode].filter(Boolean);\n return parts.length > 0 ? parts.join(\" · \") : \"inherits prompt defaults\";\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAM,OAAO;AAUN,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA8B;;AAC5B,QAAM,EAAE,UAAU;AAClB,QAAM,EAAE,UAAU;AAClB,QAAM,SAAS,MAAA;AACf,QAAM,iBAAiB,SAAS;AAAA,IAC9B,CAAC,YAAA;;AAAY,qBAAQ,SAAOA,MAAA,MAAM,UAAN,gBAAAA,IAAa;AAAA;AAAA,EAAA;AAE3C,QAAM,SAAiD;AAAA,IACrD,EAAE,IAAI,OAAO,OAAO,WAAA;AAAA,IACpB,EAAE,IAAI,WAAW,OAAO,aAAY,+BAAO,SAAQ,EAAE,IAAA;AAAA,EAAI;AAE3D,QAAM,YAAY,QAAQ,CAAC,WAAW,MAAM,MAAM,MAAM,IAAI,QAAQ,IAAI;AAExE,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,cAAW;AAAA,MACX,WAAU;AAAA,MAEV,UAAA;AAAA,QAAA,qBAAC,OAAA,EAAI,WAAU,6CACb,UAAA;AAAA,UAAA,qBAAC,QAAA,EAAK,WAAU,wGACd,UAAA;AAAA,YAAA,oBAAC,MAAA,EAAK,MAAM,UAAU,WAAU,YAAW;AAAA,YAAE;AAAA,UAAA,GAE/C;AAAA,UACA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAU;AAAA,cACV,SAAO,WAAM,UAAN,mBAAa,OAAM;AAAA,cAC1B,SAAS;AAAA,gBACP,EAAE,OAAO,MAAM,OAAO,OAAA;AAAA,gBACtB,GAAG,SAAS,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AA,gBACjC,SAAS,MAAM,KAAK,WAAW,OAAA;AAAA,gBAE/B,UAAA;AAAA,kBAAA,oBAAC,MAAA,EAAK,MAAM,YAAY,WAAU,YAAW;AAAA,kBAAE;AAAA,gBAAA;AAAA,cAAA;AAAA,YAAA;AAAA,YAGhD,WAAW,QACV,oBAAC,QAAA,EAAK,MAAK,UAAS,WAAU,iCAC3B,UAAA,WAAW,SAAS,WAAW,eAAe,UAAA,CACjD;AAAA,UAAA,EAAA,CAEJ;AAAA,QAAA,GACF;AAAA,QAED,WAAW,SACV,oBAAC,KAAA,EAAE,MAAK,SAAQ,WAAU,4BACvB,UAAA,WAAW,MAAA,CACd;AAAA,QAED,WAAW,UACV,oBAAC,KAAA,EAAE,MAAK,UAAS,WAAU,iCACxB,UAAA,WAAW,OAAA,CACd;AAAA,QAEF,oBAAC,YAAA,EAAW,OAAM,cAAa,MAAM,eAAe,gBAAgB,GAClE,UAAA,oBAAC,mBAAgB,QAAO,yCAAY,UAAS,CAAA,GAAI,EAAA,CACnD;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;AAEA,SAAS,eAAe,SAAoD;AAC1E,QAAM,QAAQ,CAAC,QAAQ,OAAO,QAAQ,IAAI,EAAE,OAAO,OAAO;AAC1D,SAAO,MAAM,SAAS,IAAI,MAAM,KAAK,KAAK,IAAI;AAChD;"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const runtimeProfileModel = require("../../../lib/runtime-profile-model.cjs");
4
+ function profileForRef(ref, profiles) {
5
+ if (!ref) return void 0;
6
+ const name = ref.trim().toLowerCase();
7
+ return profiles.find((profile) => profile.id === ref) ?? profiles.find((profile) => profile.name.trim().toLowerCase() === name);
8
+ }
9
+ function pickerStateFor(value, profiles) {
10
+ const profile = profileForRef(value.runtimeProfile, profiles);
11
+ return {
12
+ selectedRef: value.runtimeProfile,
13
+ draft: profile ? structuredClone(profile) : void 0,
14
+ layer: "run"
15
+ };
16
+ }
17
+ function selectProfile(value, profile) {
18
+ const next = { ...value };
19
+ if (profile) next.runtimeProfile = profile.id;
20
+ else delete next.runtimeProfile;
21
+ return next;
22
+ }
23
+ function editDraft(state, draft) {
24
+ return { ...state, draft };
25
+ }
26
+ function isDraftDirty(state, profiles) {
27
+ if (!state.draft) return false;
28
+ const saved = profiles.find((profile) => {
29
+ var _a;
30
+ return profile.id === ((_a = state.draft) == null ? void 0 : _a.id);
31
+ });
32
+ if (!saved) return true;
33
+ return stableJson(saved) !== stableJson(state.draft);
34
+ }
35
+ function afterSave(value, state, saved) {
36
+ const ref = value.runtimeProfile;
37
+ const stillReferenced = ref === saved.id || (ref == null ? void 0 : ref.trim().toLowerCase()) === saved.name.trim().toLowerCase();
38
+ const nextValue = stillReferenced ? value : selectProfile(value, saved);
39
+ return {
40
+ value: nextValue,
41
+ state: {
42
+ ...state,
43
+ selectedRef: nextValue.runtimeProfile,
44
+ draft: structuredClone(saved)
45
+ }
46
+ };
47
+ }
48
+ function detachedValue(value, resolved) {
49
+ const overlay = value.spec ?? {};
50
+ const next = { ...value, spec: runtimeProfileModel.mergeRuntimeSpec(resolved, overlay) };
51
+ delete next.runtimeProfile;
52
+ return next;
53
+ }
54
+ function inheritedRuntime({
55
+ draft,
56
+ presets,
57
+ resolution
58
+ }) {
59
+ var _a, _b;
60
+ const authored = runtimeProfileModel.authoredRuntimeSpec(draft, presets);
61
+ const runtime = {};
62
+ const model = ((_a = resolution == null ? void 0 : resolution.spec.model) == null ? void 0 : _a.trim()) ? resolution.spec.model : authored.model;
63
+ const mode = ((_b = resolution == null ? void 0 : resolution.spec.mode) == null ? void 0 : _b.trim()) ? resolution.spec.mode : authored.mode;
64
+ if (model) runtime.model = model;
65
+ if (mode) runtime.mode = mode;
66
+ return runtime;
67
+ }
68
+ function saveAsNewDraft(draft, profiles, id) {
69
+ return {
70
+ ...structuredClone(draft),
71
+ id,
72
+ name: runtimeProfileModel.duplicateName(
73
+ draft.name,
74
+ profiles.map((profile) => profile.name)
75
+ )
76
+ };
77
+ }
78
+ function stableJson(value) {
79
+ return JSON.stringify(
80
+ value,
81
+ (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(
82
+ Object.entries(item).sort(
83
+ ([a], [b]) => a.localeCompare(b)
84
+ )
85
+ ) : item
86
+ );
87
+ }
88
+ exports.afterSave = afterSave;
89
+ exports.detachedValue = detachedValue;
90
+ exports.editDraft = editDraft;
91
+ exports.inheritedRuntime = inheritedRuntime;
92
+ exports.isDraftDirty = isDraftDirty;
93
+ exports.pickerStateFor = pickerStateFor;
94
+ exports.profileForRef = profileForRef;
95
+ exports.saveAsNewDraft = saveAsNewDraft;
96
+ exports.selectProfile = selectProfile;
97
+ //# sourceMappingURL=RuntimeProfilePicker.model.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuntimeProfilePicker.model.cjs","sources":["../../../../src/data/ai/runtime-profiles/RuntimeProfilePicker.model.ts"],"sourcesContent":["import type {\n AIPromptRunSpec,\n AIPromptRunValue,\n} from \"../PromptRunEditor/model\";\nimport type {\n ResolvedRuntimeSpec,\n RuntimePreset,\n RuntimeProfile,\n} from \"../runtime-profile\";\nimport type { AISpecRuntimeSpec } from \"../SpecRuntimeEditor.model\";\nimport {\n authoredRuntimeSpec,\n duplicateName,\n mergeRuntimeSpec,\n} from \"../../../lib/runtime-profile-model\";\n\nexport type RuntimeProfileLayer = \"run\" | \"profile\";\n\nexport type RuntimeProfilePickerState = {\n selectedRef: string | undefined;\n draft: RuntimeProfile | undefined;\n layer: RuntimeProfileLayer;\n};\n\nexport function profileForRef(\n ref: string | undefined,\n profiles: RuntimeProfile[],\n): RuntimeProfile | undefined {\n if (!ref) return undefined;\n const name = ref.trim().toLowerCase();\n return (\n profiles.find((profile) => profile.id === ref) ??\n profiles.find((profile) => profile.name.trim().toLowerCase() === name)\n );\n}\n\nexport function pickerStateFor(\n value: AIPromptRunValue,\n profiles: RuntimeProfile[],\n): RuntimeProfilePickerState {\n const profile = profileForRef(value.runtimeProfile, profiles);\n return {\n selectedRef: value.runtimeProfile,\n draft: profile ? structuredClone(profile) : undefined,\n layer: \"run\",\n };\n}\n\nexport function selectProfile(\n value: AIPromptRunValue,\n profile: RuntimeProfile | undefined,\n): AIPromptRunValue {\n const next = { ...value };\n if (profile) next.runtimeProfile = profile.id;\n else delete next.runtimeProfile;\n return next;\n}\n\nexport function editDraft(\n state: RuntimeProfilePickerState,\n draft: RuntimeProfile,\n): RuntimeProfilePickerState {\n return { ...state, draft };\n}\n\nexport function isDraftDirty(\n state: RuntimeProfilePickerState,\n profiles: RuntimeProfile[],\n): boolean {\n if (!state.draft) return false;\n const saved = profiles.find((profile) => profile.id === state.draft?.id);\n if (!saved) return true;\n return stableJson(saved) !== stableJson(state.draft);\n}\n\nexport function afterSave(\n value: AIPromptRunValue,\n state: RuntimeProfilePickerState,\n saved: RuntimeProfile,\n): { value: AIPromptRunValue; state: RuntimeProfilePickerState } {\n const ref = value.runtimeProfile;\n const stillReferenced =\n ref === saved.id ||\n ref?.trim().toLowerCase() === saved.name.trim().toLowerCase();\n const nextValue = stillReferenced ? value : selectProfile(value, saved);\n return {\n value: nextValue,\n state: {\n ...state,\n selectedRef: nextValue.runtimeProfile,\n draft: structuredClone(saved),\n },\n };\n}\n\nexport function detachedValue(\n value: AIPromptRunValue,\n resolved: AISpecRuntimeSpec,\n): AIPromptRunValue {\n const overlay: AIPromptRunSpec = value.spec ?? {};\n const next = { ...value, spec: mergeRuntimeSpec(resolved, overlay) };\n delete next.runtimeProfile;\n return next;\n}\n\nexport function inheritedRuntime({\n draft,\n presets,\n resolution,\n}: {\n draft: RuntimeProfile | undefined;\n presets: RuntimePreset[];\n resolution?: ResolvedRuntimeSpec | undefined;\n}): Pick<AISpecRuntimeSpec, \"model\" | \"mode\"> {\n const authored = authoredRuntimeSpec(draft, presets);\n const runtime: Pick<AISpecRuntimeSpec, \"model\" | \"mode\"> = {};\n const model = resolution?.spec.model?.trim()\n ? resolution.spec.model\n : authored.model;\n const mode = resolution?.spec.mode?.trim()\n ? resolution.spec.mode\n : authored.mode;\n if (model) runtime.model = model;\n if (mode) runtime.mode = mode;\n return runtime;\n}\n\nexport function saveAsNewDraft(\n draft: RuntimeProfile,\n profiles: RuntimeProfile[],\n id: string,\n): RuntimeProfile {\n return {\n ...structuredClone(draft),\n id,\n name: duplicateName(\n draft.name,\n profiles.map((profile) => profile.name),\n ),\n };\n}\n\nfunction stableJson(value: unknown): string {\n return JSON.stringify(value, (_key, item: unknown) =>\n item && typeof item === \"object\" && !Array.isArray(item)\n ? Object.fromEntries(\n Object.entries(item as Record<string, unknown>).sort(([a], [b]) =>\n a.localeCompare(b),\n ),\n )\n : item,\n );\n}\n"],"names":["mergeRuntimeSpec","authoredRuntimeSpec","duplicateName"],"mappings":";;;AAwBO,SAAS,cACd,KACA,UAC4B;AAC5B,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,OAAO,IAAI,KAAA,EAAO,YAAA;AACxB,SACE,SAAS,KAAK,CAAC,YAAY,QAAQ,OAAO,GAAG,KAC7C,SAAS,KAAK,CAAC,YAAY,QAAQ,KAAK,OAAO,YAAA,MAAkB,IAAI;AAEzE;AAEO,SAAS,eACd,OACA,UAC2B;AAC3B,QAAM,UAAU,cAAc,MAAM,gBAAgB,QAAQ;AAC5D,SAAO;AAAA,IACL,aAAa,MAAM;AAAA,IACnB,OAAO,UAAU,gBAAgB,OAAO,IAAI;AAAA,IAC5C,OAAO;AAAA,EAAA;AAEX;AAEO,SAAS,cACd,OACA,SACkB;AAClB,QAAM,OAAO,EAAE,GAAG,MAAA;AAClB,MAAI,QAAS,MAAK,iBAAiB,QAAQ;AAAA,cAC/B,KAAK;AACjB,SAAO;AACT;AAEO,SAAS,UACd,OACA,OAC2B;AAC3B,SAAO,EAAE,GAAG,OAAO,MAAA;AACrB;AAEO,SAAS,aACd,OACA,UACS;AACT,MAAI,CAAC,MAAM,MAAO,QAAO;AACzB,QAAM,QA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A,IAAA;AAAA,EACxC;AAEJ;AAEA,SAAS,WAAW,OAAwB;AAC1C,SAAO,KAAK;AAAA,IAAU;AAAA,IAAO,CAAC,MAAM,SAClC,QAAQ,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI,IACnD,OAAO;AAAA,MACL,OAAO,QAAQ,IAA+B,EAAE;AAAA,QAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAC3D,EAAE,cAAc,CAAC;AAAA,MAAA;AAAA,IACnB,IAEF;AAAA,EAAA;AAER;;;;;;;;;;"}
@@ -0,0 +1,26 @@
1
+ import { AIPromptRunValue } from '../PromptRunEditor/model';
2
+ import { ResolvedRuntimeSpec, RuntimePreset, RuntimeProfile } from '../runtime-profile';
3
+ import { AISpecRuntimeSpec } from '../SpecRuntimeEditor.model';
4
+ export type RuntimeProfileLayer = "run" | "profile";
5
+ export type RuntimeProfilePickerState = {
6
+ selectedRef: string | undefined;
7
+ draft: RuntimeProfile | undefined;
8
+ layer: RuntimeProfileLayer;
9
+ };
10
+ export declare function profileForRef(ref: string | undefined, profiles: RuntimeProfile[]): RuntimeProfile | undefined;
11
+ export declare function pickerStateFor(value: AIPromptRunValue, profiles: RuntimeProfile[]): RuntimeProfilePickerState;
12
+ export declare function selectProfile(value: AIPromptRunValue, profile: RuntimeProfile | undefined): AIPromptRunValue;
13
+ export declare function editDraft(state: RuntimeProfilePickerState, draft: RuntimeProfile): RuntimeProfilePickerState;
14
+ export declare function isDraftDirty(state: RuntimeProfilePickerState, profiles: RuntimeProfile[]): boolean;
15
+ export declare function afterSave(value: AIPromptRunValue, state: RuntimeProfilePickerState, saved: RuntimeProfile): {
16
+ value: AIPromptRunValue;
17
+ state: RuntimeProfilePickerState;
18
+ };
19
+ export declare function detachedValue(value: AIPromptRunValue, resolved: AISpecRuntimeSpec): AIPromptRunValue;
20
+ export declare function inheritedRuntime({ draft, presets, resolution, }: {
21
+ draft: RuntimeProfile | undefined;
22
+ presets: RuntimePreset[];
23
+ resolution?: ResolvedRuntimeSpec | undefined;
24
+ }): Pick<AISpecRuntimeSpec, "model" | "mode">;
25
+ export declare function saveAsNewDraft(draft: RuntimeProfile, profiles: RuntimeProfile[], id: string): RuntimeProfile;
26
+ //# sourceMappingURL=RuntimeProfilePicker.model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuntimeProfilePicker.model.d.ts","sourceRoot":"","sources":["../../../../src/data/ai/runtime-profiles/RuntimeProfilePicker.model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,cAAc,EACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAOpE,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,SAAS,CAAC;AAEpD,MAAM,MAAM,yBAAyB,GAAG;IACtC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,KAAK,EAAE,cAAc,GAAG,SAAS,CAAC;IAClC,KAAK,EAAE,mBAAmB,CAAC;CAC5B,CAAC;AAEF,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,QAAQ,EAAE,cAAc,EAAE,GACzB,cAAc,GAAG,SAAS,CAO5B;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,cAAc,EAAE,GACzB,yBAAyB,CAO3B;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,cAAc,GAAG,SAAS,GAClC,gBAAgB,CAKlB;AAED,wBAAgB,SAAS,CACvB,KAAK,EAAE,yBAAyB,EAChC,KAAK,EAAE,cAAc,GACpB,yBAAyB,CAE3B;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,yBAAyB,EAChC,QAAQ,EAAE,cAAc,EAAE,GACzB,OAAO,CAKT;AAED,wBAAgB,SAAS,CACvB,KAAK,EAAE,gBAAgB,EACvB,KAAK,EAAE,yBAAyB,EAChC,KAAK,EAAE,cAAc,GACpB;IAAE,KAAK,EAAE,gBAAgB,CAAC;IAAC,KAAK,EAAE,yBAAyB,CAAA;CAAE,CAc/D;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,iBAAiB,GAC1B,gBAAgB,CAKlB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,OAAO,EACP,UAAU,GACX,EAAE;IACD,KAAK,EAAE,cAAc,GAAG,SAAS,CAAC;IAClC,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;CAC9C,GAAG,IAAI,CAAC,iBAAiB,EAAE,OAAO,GAAG,MAAM,CAAC,CAY5C;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,cAAc,EAAE,EAC1B,EAAE,EAAE,MAAM,GACT,cAAc,CAShB"}
@@ -0,0 +1,97 @@
1
+ import { authoredRuntimeSpec, mergeRuntimeSpec, duplicateName } from "../../../lib/runtime-profile-model.js";
2
+ function profileForRef(ref, profiles) {
3
+ if (!ref) return void 0;
4
+ const name = ref.trim().toLowerCase();
5
+ return profiles.find((profile) => profile.id === ref) ?? profiles.find((profile) => profile.name.trim().toLowerCase() === name);
6
+ }
7
+ function pickerStateFor(value, profiles) {
8
+ const profile = profileForRef(value.runtimeProfile, profiles);
9
+ return {
10
+ selectedRef: value.runtimeProfile,
11
+ draft: profile ? structuredClone(profile) : void 0,
12
+ layer: "run"
13
+ };
14
+ }
15
+ function selectProfile(value, profile) {
16
+ const next = { ...value };
17
+ if (profile) next.runtimeProfile = profile.id;
18
+ else delete next.runtimeProfile;
19
+ return next;
20
+ }
21
+ function editDraft(state, draft) {
22
+ return { ...state, draft };
23
+ }
24
+ function isDraftDirty(state, profiles) {
25
+ if (!state.draft) return false;
26
+ const saved = profiles.find((profile) => {
27
+ var _a;
28
+ return profile.id === ((_a = state.draft) == null ? void 0 : _a.id);
29
+ });
30
+ if (!saved) return true;
31
+ return stableJson(saved) !== stableJson(state.draft);
32
+ }
33
+ function afterSave(value, state, saved) {
34
+ const ref = value.runtimeProfile;
35
+ const stillReferenced = ref === saved.id || (ref == null ? void 0 : ref.trim().toLowerCase()) === saved.name.trim().toLowerCase();
36
+ const nextValue = stillReferenced ? value : selectProfile(value, saved);
37
+ return {
38
+ value: nextValue,
39
+ state: {
40
+ ...state,
41
+ selectedRef: nextValue.runtimeProfile,
42
+ draft: structuredClone(saved)
43
+ }
44
+ };
45
+ }
46
+ function detachedValue(value, resolved) {
47
+ const overlay = value.spec ?? {};
48
+ const next = { ...value, spec: mergeRuntimeSpec(resolved, overlay) };
49
+ delete next.runtimeProfile;
50
+ return next;
51
+ }
52
+ function inheritedRuntime({
53
+ draft,
54
+ presets,
55
+ resolution
56
+ }) {
57
+ var _a, _b;
58
+ const authored = authoredRuntimeSpec(draft, presets);
59
+ const runtime = {};
60
+ const model = ((_a = resolution == null ? void 0 : resolution.spec.model) == null ? void 0 : _a.trim()) ? resolution.spec.model : authored.model;
61
+ const mode = ((_b = resolution == null ? void 0 : resolution.spec.mode) == null ? void 0 : _b.trim()) ? resolution.spec.mode : authored.mode;
62
+ if (model) runtime.model = model;
63
+ if (mode) runtime.mode = mode;
64
+ return runtime;
65
+ }
66
+ function saveAsNewDraft(draft, profiles, id) {
67
+ return {
68
+ ...structuredClone(draft),
69
+ id,
70
+ name: duplicateName(
71
+ draft.name,
72
+ profiles.map((profile) => profile.name)
73
+ )
74
+ };
75
+ }
76
+ function stableJson(value) {
77
+ return JSON.stringify(
78
+ value,
79
+ (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(
80
+ Object.entries(item).sort(
81
+ ([a], [b]) => a.localeCompare(b)
82
+ )
83
+ ) : item
84
+ );
85
+ }
86
+ export {
87
+ afterSave,
88
+ detachedValue,
89
+ editDraft,
90
+ inheritedRuntime,
91
+ isDraftDirty,
92
+ pickerStateFor,
93
+ profileForRef,
94
+ saveAsNewDraft,
95
+ selectProfile
96
+ };
97
+ //# sourceMappingURL=RuntimeProfilePicker.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuntimeProfilePicker.model.js","sources":["../../../../src/data/ai/runtime-profiles/RuntimeProfilePicker.model.ts"],"sourcesContent":["import type {\n AIPromptRunSpec,\n AIPromptRunValue,\n} from \"../PromptRunEditor/model\";\nimport type {\n ResolvedRuntimeSpec,\n RuntimePreset,\n RuntimeProfile,\n} from \"../runtime-profile\";\nimport type { AISpecRuntimeSpec } from \"../SpecRuntimeEditor.model\";\nimport {\n authoredRuntimeSpec,\n duplicateName,\n mergeRuntimeSpec,\n} from \"../../../lib/runtime-profile-model\";\n\nexport type RuntimeProfileLayer = \"run\" | \"profile\";\n\nexport type RuntimeProfilePickerState = {\n selectedRef: string | undefined;\n draft: RuntimeProfile | undefined;\n layer: RuntimeProfileLayer;\n};\n\nexport function profileForRef(\n ref: string | undefined,\n profiles: RuntimeProfile[],\n): RuntimeProfile | undefined {\n if (!ref) return undefined;\n const name = ref.trim().toLowerCase();\n return (\n profiles.find((profile) => profile.id === ref) ??\n profiles.find((profile) => profile.name.trim().toLowerCase() === name)\n );\n}\n\nexport function pickerStateFor(\n value: AIPromptRunValue,\n profiles: RuntimeProfile[],\n): RuntimeProfilePickerState {\n const profile = profileForRef(value.runtimeProfile, profiles);\n return {\n selectedRef: value.runtimeProfile,\n draft: profile ? structuredClone(profile) : undefined,\n layer: \"run\",\n };\n}\n\nexport function selectProfile(\n value: AIPromptRunValue,\n profile: RuntimeProfile | undefined,\n): AIPromptRunValue {\n const next = { ...value };\n if (profile) next.runtimeProfile = profile.id;\n else delete next.runtimeProfile;\n return next;\n}\n\nexport function editDraft(\n state: RuntimeProfilePickerState,\n draft: RuntimeProfile,\n): RuntimeProfilePickerState {\n return { ...state, draft };\n}\n\nexport function isDraftDirty(\n state: RuntimeProfilePickerState,\n profiles: RuntimeProfile[],\n): boolean {\n if (!state.draft) return false;\n const saved = profiles.find((profile) => profile.id === state.draft?.id);\n if (!saved) return true;\n return stableJson(saved) !== stableJson(state.draft);\n}\n\nexport function afterSave(\n value: AIPromptRunValue,\n state: RuntimeProfilePickerState,\n saved: RuntimeProfile,\n): { value: AIPromptRunValue; state: RuntimeProfilePickerState } {\n const ref = value.runtimeProfile;\n const stillReferenced =\n ref === saved.id ||\n ref?.trim().toLowerCase() === saved.name.trim().toLowerCase();\n const nextValue = stillReferenced ? value : selectProfile(value, saved);\n return {\n value: nextValue,\n state: {\n ...state,\n selectedRef: nextValue.runtimeProfile,\n draft: structuredClone(saved),\n },\n };\n}\n\nexport function detachedValue(\n value: AIPromptRunValue,\n resolved: AISpecRuntimeSpec,\n): AIPromptRunValue {\n const overlay: AIPromptRunSpec = value.spec ?? {};\n const next = { ...value, spec: mergeRuntimeSpec(resolved, overlay) };\n delete next.runtimeProfile;\n return next;\n}\n\nexport function inheritedRuntime({\n draft,\n presets,\n resolution,\n}: {\n draft: RuntimeProfile | undefined;\n presets: RuntimePreset[];\n resolution?: ResolvedRuntimeSpec | undefined;\n}): Pick<AISpecRuntimeSpec, \"model\" | \"mode\"> {\n const authored = authoredRuntimeSpec(draft, presets);\n const runtime: Pick<AISpecRuntimeSpec, \"model\" | \"mode\"> = {};\n const model = resolution?.spec.model?.trim()\n ? resolution.spec.model\n : authored.model;\n const mode = resolution?.spec.mode?.trim()\n ? resolution.spec.mode\n : authored.mode;\n if (model) runtime.model = model;\n if (mode) runtime.mode = mode;\n return runtime;\n}\n\nexport function saveAsNewDraft(\n draft: RuntimeProfile,\n profiles: RuntimeProfile[],\n id: string,\n): RuntimeProfile {\n return {\n ...structuredClone(draft),\n id,\n name: duplicateName(\n draft.name,\n profiles.map((profile) => profile.name),\n ),\n };\n}\n\nfunction stableJson(value: unknown): string {\n return JSON.stringify(value, (_key, item: unknown) =>\n item && typeof item === \"object\" && !Array.isArray(item)\n ? Object.fromEntries(\n Object.entries(item as Record<string, unknown>).sort(([a], [b]) =>\n a.localeCompare(b),\n ),\n )\n : item,\n );\n}\n"],"names":[],"mappings":";AAwBO,SAAS,cACd,KACA,UAC4B;AAC5B,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,OAAO,IAAI,KAAA,EAAO,YAAA;AACxB,SACE,SAAS,KAAK,CAAC,YAAY,QAAQ,OAAO,GAAG,KAC7C,SAAS,KAAK,CAAC,YAAY,QAAQ,KAAK,OAAO,YAAA,MAAkB,IAAI;AAEzE;AAEO,SAAS,eACd,OACA,UAC2B;AAC3B,QAAM,UAAU,cAAc,MAAM,gBAAgB,QAAQ;AAC5D,SAAO;AAAA,IACL,aAAa,MAAM;AAAA,IACnB,OAAO,UAAU,gBAAgB,OAAO,IAAI;AAAA,IAC5C,OAAO;AAAA,EAAA;AAEX;AAEO,SAAS,cACd,OACA,SACkB;AAClB,QAAM,OAAO,EAAE,GAAG,MAAA;AAClB,MAAI,QAAS,MAAK,iBAAiB,QAAQ;AAAA,cAC/B,KAAK;AACjB,SAAO;AACT;AAEO,SAAS,UACd,OACA,OAC2B;AAC3B,SAAO,EAAE,GAAG,OAAO,MAAA;AACrB;AAEO,SAAS,aACd,OACA,UACS;AACT,MAAI,CAAC,MAAM,MAAO,QAAO;AACzB,QAAM,QAAQ,SAAS,KAAK,CAAC;;AAAY,mBAAQ,SAAO,WAAM,UAAN,mBAAa;AAAA,GAAE;AACvE,MAAI,CAAC,MAAO,QAAO;AACnB,SAAO,WAAW,KAAK,MAAM,WAAW,MAAM,KAAK;AACrD;AAEO,SAAS,UACd,OACA,OACA,OAC+D;AAC/D,QAAM,MAAM,MAAM;AAClB,QAAM,kBACJ,QAAQ,MAAM,OACd,2BAAK,OAAO,mBAAkB,MAAM,KAAK,KAAA,EAAO,YAAA;AAClD,QAAM,YAAY,kBAAkB,QAAQ,cAAc,OAAO,KAAK;A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ty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const SegmentedControl = require("../../../components/SegmentedControl.cjs");
5
+ const utils = require("../../../lib/utils.cjs");
6
+ const runtimeProfileModel = require("../../../lib/runtime-profile-model.cjs");
7
+ const PresetWorkspace = require("./PresetWorkspace.cjs");
8
+ const ProfileWorkspace = require("./ProfileWorkspace.cjs");
9
+ const RuntimePersistenceBar = require("./RuntimePersistenceBar.cjs");
10
+ const RuntimeStatusNotice = require("./RuntimeStatusNotice.cjs");
11
+ const usePermissionCatalog = require("./use-permission-catalog.cjs");
12
+ const useResolution = require("./use-resolution.cjs");
13
+ const VIEW_OPTIONS = [
14
+ { id: "profiles", label: "Profiles" },
15
+ { id: "presets", label: "Presets" }
16
+ ];
17
+ function RuntimeProfilesWorkspace({
18
+ presets,
19
+ profiles,
20
+ view,
21
+ onViewChange,
22
+ selectedPresetId,
23
+ selectedProfileId,
24
+ onSelectPreset,
25
+ onSelectProfile,
26
+ store,
27
+ client,
28
+ families,
29
+ sandboxCatalog,
30
+ secretSelector,
31
+ persistence,
32
+ recordMeta,
33
+ newId = () => crypto.randomUUID(),
34
+ className
35
+ }) {
36
+ var _a, _b, _c;
37
+ const selectedProfile = profiles.find(
38
+ (profile) => profile.id === selectedProfileId
39
+ );
40
+ const resolution = useResolution.useRuntimeProfileResolution(
41
+ client,
42
+ selectedProfile,
43
+ presets
44
+ );
45
+ const effectiveRuntime = ((_a = resolution.result) == null ? void 0 : _a.resolved.spec) ?? runtimeProfileModel.authoredRuntimeSpec(selectedProfile, presets);
46
+ const permissionCatalog = usePermissionCatalog.useRuntimePermissionCatalog(
47
+ client,
48
+ effectiveRuntime,
49
+ families
50
+ );
51
+ const addProfile = (profile) => {
52
+ store.createProfile(profile);
53
+ onSelectProfile(profile.id);
54
+ };
55
+ const addPreset = (preset) => {
56
+ store.createPreset(preset);
57
+ onSelectPreset(preset.id);
58
+ };
59
+ const deletePreset = (id) => {
60
+ const preset = presets.find((item) => item.id === id);
61
+ const references = preset ? runtimeProfileModel.referencedBy(preset, profiles) : [];
62
+ if (references.length > 0) {
63
+ throw new Error(`cannot delete preset used by ${references.join(", ")}`);
64
+ }
65
+ store.deletePreset(id);
66
+ onSelectPreset(runtimeProfileModel.selectionAfterDelete(presets, id, selectedPresetId));
67
+ };
68
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: utils.cn("space-y-4", className), children: [
69
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-density-3", children: [
70
+ /* @__PURE__ */ jsxRuntime.jsx(
71
+ SegmentedControl.SegmentedControl,
72
+ {
73
+ "aria-label": "Runtime library view",
74
+ value: view,
75
+ options: VIEW_OPTIONS,
76
+ onChange: onViewChange
77
+ }
78
+ ),
79
+ persistence && /* @__PURE__ */ jsxRuntime.jsx(
80
+ RuntimePersistenceBar.RuntimePersistenceBar,
81
+ {
82
+ persistence,
83
+ className: "ml-auto"
84
+ }
85
+ )
86
+ ] }),
87
+ /* @__PURE__ */ jsxRuntime.jsx(
88
+ RuntimeStatusNotice.RuntimeStatusNotice,
89
+ {
90
+ status: permissionCatalog.status,
91
+ loadingText: "Loading Tool, MCP, Plugin, and Skill permissions from Captain…",
92
+ error: permissionCatalog.error,
93
+ onRetry: permissionCatalog.retry,
94
+ retryLabel: "Retry permissions"
95
+ }
96
+ ),
97
+ view === "profiles" ? /* @__PURE__ */ jsxRuntime.jsx(
98
+ ProfileWorkspace.ProfileWorkspace,
99
+ {
100
+ presets,
101
+ profiles,
102
+ selectedId: selectedProfileId,
103
+ resolution,
104
+ effectiveRuntime,
105
+ permissionCatalog: permissionCatalog.catalog,
106
+ families,
107
+ sandboxCatalog,
108
+ secretSelector,
109
+ recordMeta,
110
+ onSelect: onSelectProfile,
111
+ onCreate: () => addProfile(runtimeProfileModel.newProfileRecord(profiles, newId())),
112
+ onDuplicate: (id) => addProfile(runtimeProfileModel.duplicateRecord(profiles, id, newId())),
113
+ onDelete: (id) => {
114
+ store.deleteProfile(id);
115
+ onSelectProfile(
116
+ runtimeProfileModel.selectionAfterDelete(profiles, id, selectedProfileId)
117
+ );
118
+ },
119
+ onChange: store.updateProfile
120
+ }
121
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
122
+ PresetWorkspace.PresetWorkspace,
123
+ {
124
+ presets,
125
+ profiles,
126
+ selectedId: selectedPresetId,
127
+ tools: ((_b = resolution.result) == null ? void 0 : _b.tools) ?? [],
128
+ effectivePermissions: ((_c = resolution.result) == null ? void 0 : _c.permissions) ?? {},
129
+ families,
130
+ sandboxCatalog,
131
+ secretSelector,
132
+ recordMeta,
133
+ onSelect: onSelectPreset,
134
+ onCreate: () => addPreset(runtimeProfileModel.newPresetRecord(presets, newId())),
135
+ onDuplicate: (id) => addPreset(runtimeProfileModel.duplicateRecord(presets, id, newId())),
136
+ onDelete: deletePreset,
137
+ onChange: store.updatePreset
138
+ }
139
+ )
140
+ ] });
141
+ }
142
+ exports.RuntimeProfilesWorkspace = RuntimeProfilesWorkspace;
143
+ //# sourceMappingURL=RuntimeProfilesWorkspace.cjs.map