@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.
- package/dist/ai.cjs +48 -3
- package/dist/ai.cjs.map +1 -1
- package/dist/ai.js +46 -1
- package/dist/ai.js.map +1 -1
- package/dist/components/DateField.d.ts +1 -1
- package/dist/components/DatePicker.d.ts +1 -1
- package/dist/components/DateTimePicker.d.ts +1 -1
- package/dist/components/mdx-editor-callout-model.d.ts +1 -1
- package/dist/data/MarkdownEditor.model.d.ts +1 -1
- package/dist/data/ai/ChatWindow.catalogs.cjs +11 -5
- package/dist/data/ai/ChatWindow.catalogs.cjs.map +1 -1
- package/dist/data/ai/ChatWindow.catalogs.d.ts +2 -1
- package/dist/data/ai/ChatWindow.catalogs.d.ts.map +1 -1
- package/dist/data/ai/ChatWindow.catalogs.js +11 -5
- package/dist/data/ai/ChatWindow.catalogs.js.map +1 -1
- package/dist/data/ai/ChatWindow.cjs +1 -0
- package/dist/data/ai/ChatWindow.cjs.map +1 -1
- package/dist/data/ai/ChatWindow.d.ts.map +1 -1
- package/dist/data/ai/ChatWindow.js +1 -0
- package/dist/data/ai/ChatWindow.js.map +1 -1
- package/dist/data/ai/PromptRunEditor/VariablesField.cjs +79 -0
- package/dist/data/ai/PromptRunEditor/VariablesField.cjs.map +1 -0
- package/dist/data/ai/PromptRunEditor/VariablesField.d.ts +8 -0
- package/dist/data/ai/PromptRunEditor/VariablesField.d.ts.map +1 -0
- package/dist/data/ai/PromptRunEditor/VariablesField.js +79 -0
- package/dist/data/ai/PromptRunEditor/VariablesField.js.map +1 -0
- package/dist/data/ai/PromptRunEditor/index.cjs +61 -69
- package/dist/data/ai/PromptRunEditor/index.cjs.map +1 -1
- package/dist/data/ai/PromptRunEditor/index.d.ts +11 -1
- package/dist/data/ai/PromptRunEditor/index.d.ts.map +1 -1
- package/dist/data/ai/PromptRunEditor/index.js +61 -69
- package/dist/data/ai/PromptRunEditor/index.js.map +1 -1
- package/dist/data/ai/PromptRunEditor/model.cjs.map +1 -1
- package/dist/data/ai/PromptRunEditor/model.d.ts +2 -0
- package/dist/data/ai/PromptRunEditor/model.d.ts.map +1 -1
- package/dist/data/ai/PromptRunEditor/model.js.map +1 -1
- package/dist/data/ai/SpecRuntimeEditor/ModelSection.cjs +4 -3
- package/dist/data/ai/SpecRuntimeEditor/ModelSection.cjs.map +1 -1
- package/dist/data/ai/SpecRuntimeEditor/ModelSection.d.ts.map +1 -1
- package/dist/data/ai/SpecRuntimeEditor/ModelSection.js +2 -1
- package/dist/data/ai/SpecRuntimeEditor/ModelSection.js.map +1 -1
- package/dist/data/ai/SpecRuntimeEditor/PermissionModeField.cjs +2 -2
- package/dist/data/ai/SpecRuntimeEditor/PermissionModeField.cjs.map +1 -1
- package/dist/data/ai/SpecRuntimeEditor/PermissionModeField.js +1 -1
- package/dist/data/ai/SpecRuntimeEditor/index.cjs +4 -3
- package/dist/data/ai/SpecRuntimeEditor/index.cjs.map +1 -1
- package/dist/data/ai/SpecRuntimeEditor/index.d.ts.map +1 -1
- package/dist/data/ai/SpecRuntimeEditor/index.js +2 -1
- package/dist/data/ai/SpecRuntimeEditor/index.js.map +1 -1
- package/dist/data/ai/index.d.ts +3 -2
- package/dist/data/ai/index.d.ts.map +1 -1
- package/dist/data/ai/runtime-profile.cjs.map +1 -1
- package/dist/data/ai/runtime-profile.d.ts +9 -7
- package/dist/data/ai/runtime-profile.d.ts.map +1 -1
- package/dist/data/ai/runtime-profile.js.map +1 -1
- package/dist/data/ai/runtime-profiles/OrderedPresetSelect.cjs +111 -0
- package/dist/data/ai/runtime-profiles/OrderedPresetSelect.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/OrderedPresetSelect.d.ts +7 -0
- package/dist/data/ai/runtime-profiles/OrderedPresetSelect.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/OrderedPresetSelect.js +111 -0
- package/dist/data/ai/runtime-profiles/OrderedPresetSelect.js.map +1 -0
- package/dist/data/ai/runtime-profiles/PermissionStrategiesEditor.cjs +313 -0
- package/dist/data/ai/runtime-profiles/PermissionStrategiesEditor.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/PermissionStrategiesEditor.d.ts +8 -0
- package/dist/data/ai/runtime-profiles/PermissionStrategiesEditor.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/PermissionStrategiesEditor.js +313 -0
- package/dist/data/ai/runtime-profiles/PermissionStrategiesEditor.js.map +1 -0
- package/dist/data/ai/runtime-profiles/PermissionStrategyConditionRow.cjs +98 -0
- package/dist/data/ai/runtime-profiles/PermissionStrategyConditionRow.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/PermissionStrategyConditionRow.d.ts +11 -0
- package/dist/data/ai/runtime-profiles/PermissionStrategyConditionRow.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/PermissionStrategyConditionRow.js +98 -0
- package/dist/data/ai/runtime-profiles/PermissionStrategyConditionRow.js.map +1 -0
- package/dist/data/ai/runtime-profiles/PresetSpecEditor.cjs +35 -0
- package/dist/data/ai/runtime-profiles/PresetSpecEditor.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/PresetSpecEditor.d.ts +11 -0
- package/dist/data/ai/runtime-profiles/PresetSpecEditor.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/PresetSpecEditor.js +35 -0
- package/dist/data/ai/runtime-profiles/PresetSpecEditor.js.map +1 -0
- package/dist/data/ai/runtime-profiles/PresetWorkspace.cjs +179 -0
- package/dist/data/ai/runtime-profiles/PresetWorkspace.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/PresetWorkspace.d.ts +22 -0
- package/dist/data/ai/runtime-profiles/PresetWorkspace.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/PresetWorkspace.js +179 -0
- package/dist/data/ai/runtime-profiles/PresetWorkspace.js.map +1 -0
- package/dist/data/ai/runtime-profiles/ProfileSpecEditor.cjs +57 -0
- package/dist/data/ai/runtime-profiles/ProfileSpecEditor.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/ProfileSpecEditor.d.ts +18 -0
- package/dist/data/ai/runtime-profiles/ProfileSpecEditor.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/ProfileSpecEditor.js +57 -0
- package/dist/data/ai/runtime-profiles/ProfileSpecEditor.js.map +1 -0
- package/dist/data/ai/runtime-profiles/ProfileWorkspace.cjs +135 -0
- package/dist/data/ai/runtime-profiles/ProfileWorkspace.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/ProfileWorkspace.d.ts +23 -0
- package/dist/data/ai/runtime-profiles/ProfileWorkspace.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/ProfileWorkspace.js +135 -0
- package/dist/data/ai/runtime-profiles/ProfileWorkspace.js.map +1 -0
- package/dist/data/ai/runtime-profiles/ResolutionInspector.cjs +85 -0
- package/dist/data/ai/runtime-profiles/ResolutionInspector.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/ResolutionInspector.d.ts +7 -0
- package/dist/data/ai/runtime-profiles/ResolutionInspector.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/ResolutionInspector.js +85 -0
- package/dist/data/ai/runtime-profiles/ResolutionInspector.js.map +1 -0
- package/dist/data/ai/runtime-profiles/ResolutionTrace.cjs +42 -0
- package/dist/data/ai/runtime-profiles/ResolutionTrace.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/ResolutionTrace.d.ts +6 -0
- package/dist/data/ai/runtime-profiles/ResolutionTrace.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/ResolutionTrace.js +42 -0
- package/dist/data/ai/runtime-profiles/ResolutionTrace.js.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimeLibraryList.cjs +93 -0
- package/dist/data/ai/runtime-profiles/RuntimeLibraryList.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimeLibraryList.d.ts +18 -0
- package/dist/data/ai/runtime-profiles/RuntimeLibraryList.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimeLibraryList.js +93 -0
- package/dist/data/ai/runtime-profiles/RuntimeLibraryList.js.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimePersistenceBar.cjs +44 -0
- package/dist/data/ai/runtime-profiles/RuntimePersistenceBar.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimePersistenceBar.d.ts +6 -0
- package/dist/data/ai/runtime-profiles/RuntimePersistenceBar.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimePersistenceBar.js +44 -0
- package/dist/data/ai/runtime-profiles/RuntimePersistenceBar.js.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.cjs +198 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.d.ts +12 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.js +198 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.js.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.model.cjs +97 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.model.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.model.d.ts +26 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.model.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.model.js +97 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilePicker.model.js.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.cjs +143 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.d.ts +25 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.js +143 -0
- package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.js.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimeStatusNotice.cjs +41 -0
- package/dist/data/ai/runtime-profiles/RuntimeStatusNotice.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimeStatusNotice.d.ts +8 -0
- package/dist/data/ai/runtime-profiles/RuntimeStatusNotice.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/RuntimeStatusNotice.js +41 -0
- package/dist/data/ai/runtime-profiles/RuntimeStatusNotice.js.map +1 -0
- package/dist/data/ai/runtime-profiles/index.d.ts +20 -0
- package/dist/data/ai/runtime-profiles/index.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/types.d.ts +50 -0
- package/dist/data/ai/runtime-profiles/types.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/use-permission-catalog.cjs +37 -0
- package/dist/data/ai/runtime-profiles/use-permission-catalog.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/use-permission-catalog.d.ts +5 -0
- package/dist/data/ai/runtime-profiles/use-permission-catalog.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/use-permission-catalog.js +37 -0
- package/dist/data/ai/runtime-profiles/use-permission-catalog.js.map +1 -0
- package/dist/data/ai/runtime-profiles/use-resolution.cjs +43 -0
- package/dist/data/ai/runtime-profiles/use-resolution.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/use-resolution.d.ts +4 -0
- package/dist/data/ai/runtime-profiles/use-resolution.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/use-resolution.js +43 -0
- package/dist/data/ai/runtime-profiles/use-resolution.js.map +1 -0
- package/dist/data/ai/runtime-profiles/use-runtime-families.cjs +38 -0
- package/dist/data/ai/runtime-profiles/use-runtime-families.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/use-runtime-families.d.ts +3 -0
- package/dist/data/ai/runtime-profiles/use-runtime-families.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/use-runtime-families.js +38 -0
- package/dist/data/ai/runtime-profiles/use-runtime-families.js.map +1 -0
- package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.cjs +107 -0
- package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.cjs.map +1 -0
- package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.d.ts +35 -0
- package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.d.ts.map +1 -0
- package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.js +107 -0
- package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.js.map +1 -0
- package/dist/data/ai/use-session-scroll.cjs.map +1 -1
- package/dist/data/ai/use-session-scroll.d.ts +2 -2
- package/dist/data/ai/use-session-scroll.d.ts.map +1 -1
- package/dist/data/ai/use-session-scroll.js.map +1 -1
- package/dist/data/badge-variants.d.ts +1 -1
- package/dist/data/runtime/RuntimeBar.cjs +3 -2
- package/dist/data/runtime/RuntimeBar.cjs.map +1 -1
- package/dist/data/runtime/RuntimeBar.d.ts.map +1 -1
- package/dist/data/runtime/RuntimeBar.js +3 -2
- package/dist/data/runtime/RuntimeBar.js.map +1 -1
- package/dist/data/runtime/runtime-field-support.cjs +3 -3
- package/dist/data/runtime/runtime-field-support.cjs.map +1 -1
- package/dist/data/runtime/runtime-field-support.js +1 -1
- package/dist/data/runtime/runtime-mode.cjs +14 -47
- package/dist/data/runtime/runtime-mode.cjs.map +1 -1
- package/dist/data/runtime/runtime-mode.d.ts +5 -7
- package/dist/data/runtime/runtime-mode.d.ts.map +1 -1
- package/dist/data/runtime/runtime-mode.js +7 -39
- package/dist/data/runtime/runtime-mode.js.map +1 -1
- package/dist/data/version-info.cjs +3 -3
- package/dist/data/version-info.js +3 -3
- package/dist/index.cjs +52 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/permission-strategies.cjs +155 -0
- package/dist/lib/permission-strategies.cjs.map +1 -0
- package/dist/lib/permission-strategies.d.ts +35 -0
- package/dist/lib/permission-strategies.d.ts.map +1 -0
- package/dist/lib/permission-strategies.js +155 -0
- package/dist/lib/permission-strategies.js.map +1 -0
- package/dist/lib/runtime-family.cjs +51 -0
- package/dist/lib/runtime-family.cjs.map +1 -0
- package/dist/lib/runtime-family.d.ts +25 -0
- package/dist/lib/runtime-family.d.ts.map +1 -0
- package/dist/lib/runtime-family.js +51 -0
- package/dist/lib/runtime-family.js.map +1 -0
- package/dist/lib/runtime-profile-model.cjs +129 -0
- package/dist/lib/runtime-profile-model.cjs.map +1 -0
- package/dist/lib/runtime-profile-model.d.ts +30 -0
- package/dist/lib/runtime-profile-model.d.ts.map +1 -0
- package/dist/lib/runtime-profile-model.js +129 -0
- package/dist/lib/runtime-profile-model.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/utils.cjs +52 -0
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +5 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +53 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-mode.js","sources":["../../../src/data/runtime/runtime-mode.ts"],"sourcesContent":["import type { StaticIconComponent } from \"../Icon\";\nimport { UiCloud, UiColumns, UiRobotAi, UiTerminal } from \"../../icons\";\nimport type { JsonSchemaProperty } from \"../../components/json-schema-form-types\";\nimport type { ChatModel, RuntimeAvailability } from \"../chat/types\";\nimport {\n availabilityText,\n isSelectableModel,\n isUnavailable,\n unsupportedAvailability,\n} from \"./availability\";\n\n// A runtime has two independent axes: the model selects a provider family and\n// `spec.mode` selects api | agent | cli | cmux. The mode never contains a\n// provider name. This file used to call that axis `backend`, which is also what\n// captain called the composite adapter id it once served — so a value read from\n// one and posted back as the other type-checked and ran the wrong runtime.\n\nexport const SPEC_RUNTIME_MODES = [\"api\", \"agent\", \"cli\", \"cmux\"] as const;\nexport type SpecRuntimeMode = (typeof SPEC_RUNTIME_MODES)[number];\n\nexport function isSpecRuntimeMode(\n value: string | undefined,\n): value is SpecRuntimeMode {\n return SPEC_RUNTIME_MODES.some((mode) => mode === value);\n}\n\nexport function runtimeModeFromModel(\n model: string | undefined,\n): SpecRuntimeMode | undefined {\n const [prefix] = (model ?? \"\").trim().toLowerCase().split(\":\");\n return isSpecRuntimeMode(prefix) ? prefix : undefined;\n}\n\nexport function runtimeModelError(\n model: string | undefined,\n): string | undefined {\n for (const raw of (model ?? \"\").split(\",\")) {\n const compact = raw.trim();\n if (!compact || !compact.includes(\":\")) continue;\n const parts = compact.split(\":\").map((part) => part.trim());\n const [mode, name, effort] = parts;\n if (!isSpecRuntimeMode(mode)) {\n return `Invalid model configuration: mode ${JSON.stringify(mode)} in model ${JSON.stringify(compact)}. Expected api, agent, cli, or cmux.`;\n }\n if (!name || parts.length > 3) {\n return `Invalid model configuration: model ${JSON.stringify(compact)}. Expected mode:model[:effort].`;\n }\n if (\n effort !== undefined &&\n ![\"low\", \"medium\", \"high\", \"xhigh\", \"max\", \"ultra\"].includes(effort)\n ) {\n return `Invalid model configuration: effort ${JSON.stringify(effort)} in model ${JSON.stringify(compact)}.`;\n }\n }\n return undefined;\n}\n\nexport function runtimeModeError(\n families: SpecRuntimeFamily[],\n mode: string | undefined,\n familyId?: string | undefined,\n): string | undefined {\n if (!mode) return undefined;\n if (!isSpecRuntimeMode(mode)) {\n return `Invalid model configuration: mode ${JSON.stringify(mode)}. Expected api, agent, cli, or cmux.`;\n }\n const family = familyId\n ? families.find((entry) => entry.id === familyId)\n : undefined;\n if (family && !family.modes.some((entry) => entry.id === mode)) {\n return `Invalid model configuration: mode ${JSON.stringify(mode)} is not available for ${family.label}.`;\n }\n if (!families.some((entry) => entry.modes.some((m) => m.id === mode))) {\n return `Invalid model configuration: mode ${JSON.stringify(mode)} is missing from the runtime catalog.`;\n }\n return undefined;\n}\n\nexport type SpecRuntimeModeOption = {\n /** The canonical `spec.mode`: api | agent | cli | cmux. */\n id: string;\n label: string;\n icon?: StaticIconComponent | undefined;\n title?: string | undefined;\n provider?: string | undefined;\n defaultModel?: string | undefined;\n availability?: RuntimeAvailability | undefined;\n permissions?: RuntimePermissionCapabilities | undefined;\n schema?: RuntimeSpecSchema | undefined;\n};\n\nexport type RuntimeArgumentImplementation = \"mapped\" | \"managed\";\n\nexport type RuntimeArgumentMapping = {\n name: string;\n implementation: RuntimeArgumentImplementation;\n description?: string | undefined;\n};\n\nexport type RuntimeSpecSchema = JsonSchemaProperty & {\n \"x-clicky-arguments\"?: RuntimeArgumentMapping[] | undefined;\n \"x-clicky-managed-arguments\"?: RuntimeArgumentMapping[] | undefined;\n};\n\nexport type RuntimePermissionSupportKind =\n | \"native\"\n | \"approximated\"\n | \"requires-broker\"\n | \"unsupported\";\n\nexport type RuntimePermissionSupport = {\n kind: RuntimePermissionSupportKind;\n effects?:\n | {\n flag?: string | undefined;\n sandbox?: string | undefined;\n approval?: string | undefined;\n note?: string | undefined;\n }\n | undefined;\n};\n\nexport type RuntimePermissionCapabilities = {\n modes: Record<string, RuntimePermissionSupport>;\n toolPolicies: Record<string, Record<string, RuntimePermissionSupport>>;\n resources: Record<string, Record<string, RuntimePermissionSupport>>;\n tools?: string[] | undefined;\n};\n\nexport type SpecRuntimeFamily = {\n id: string;\n label: string;\n /** The model-catalog provider (`ChatModel.provider`) whose models this family runs. */\n provider: string;\n modes: SpecRuntimeModeOption[];\n};\n\n// Offline catalog for stories and tests. Live hosts should pass Captain's\n// registry projection; both use the same provider + mode structure.\nexport const SPEC_RUNTIME_FAMILIES: SpecRuntimeFamily[] = [\n {\n id: \"claude\",\n label: \"Claude\",\n provider: \"anthropic\",\n modes: [\n {\n id: \"api\",\n label: \"API\",\n icon: UiCloud,\n title: \"Anthropic API\",\n provider: \"anthropic\",\n },\n {\n id: \"agent\",\n label: \"Agent\",\n icon: UiRobotAi,\n title: \"Claude Agent SDK\",\n provider: \"anthropic\",\n },\n {\n id: \"cli\",\n label: \"CLI\",\n icon: UiTerminal,\n title: \"Claude Code CLI\",\n provider: \"anthropic\",\n },\n {\n id: \"cmux\",\n label: \"cmux\",\n icon: UiColumns,\n title: \"Claude multiplexer\",\n provider: \"anthropic\",\n },\n ],\n },\n {\n id: \"codex\",\n label: \"Codex\",\n provider: \"openai\",\n modes: [\n {\n id: \"api\",\n label: \"API\",\n icon: UiCloud,\n title: \"OpenAI API\",\n provider: \"openai\",\n },\n {\n id: \"agent\",\n label: \"Agent\",\n icon: UiRobotAi,\n title: \"Codex agent\",\n provider: \"openai\",\n },\n {\n id: \"cli\",\n label: \"CLI\",\n icon: UiTerminal,\n title: \"Codex CLI\",\n provider: \"openai\",\n },\n {\n id: \"cmux\",\n label: \"cmux\",\n icon: UiColumns,\n title: \"Codex multiplexer\",\n provider: \"openai\",\n },\n ],\n },\n {\n id: \"gemini\",\n label: \"Gemini\",\n provider: \"googleai\",\n modes: [\n { id: \"api\", label: \"API\", icon: UiCloud, title: \"Gemini API\" },\n { id: \"cli\", label: \"CLI\", icon: UiTerminal, title: \"Gemini CLI\" },\n ],\n },\n {\n id: \"deepseek\",\n label: \"DeepSeek\",\n provider: \"deepseek\",\n modes: [{ id: \"api\", label: \"API\", icon: UiCloud, title: \"DeepSeek API\" }],\n },\n];\n\n// One provider×mode cell as captain serves it (`/whoami`.runtimes and the prompt\n// schema document's `runtimes`), projected from its model registry. It carries\n// ids, not display text: `claude`/`api` are enough to render both, and a served\n// label would be a second place for presentation to drift.\nexport type RuntimeCatalogMode = {\n /** The canonical `spec.mode`: api | agent | cli | cmux. */\n mode: SpecRuntimeMode;\n /** \"api\" (remote, in-process) or \"cli\" (supervised local binary). */\n kind?: string | undefined;\n /** Rides the local CLI's own login; never consults an API key. */\n keyless?: boolean | undefined;\n /** The model id a picker should seed this mode with. */\n defaultModel?: string | undefined;\n /** The user switched this off in `~/.captain.yaml`. */\n disabled?: boolean | undefined;\n disabledReason?: string | undefined;\n /** Model-catalog provider used by this exact mode. */\n catalogProvider?: string | undefined;\n availability?: RuntimeAvailability | undefined;\n permissions?: RuntimePermissionCapabilities | undefined;\n /** Supported Spec fields, annotated with native CLI and protocol bindings. */\n schema: RuntimeSpecSchema;\n};\n\nexport type RuntimeCatalogFamily = {\n /** The coding-agent name: claude | codex | gemini | deepseek. */\n family: string;\n /** The canonical provider key: anthropic | openai | google | deepseek. */\n provider: string;\n /** The namespace this provider's model ids carry (`ChatModel.provider`). */\n catalogPrefix: string;\n modes: RuntimeCatalogMode[];\n};\n\nconst MODE_ICONS: Record<string, StaticIconComponent> = {\n api: UiCloud,\n agent: UiRobotAi,\n cli: UiTerminal,\n cmux: UiColumns,\n};\n\n// Mode ids are lowercase tokens; only the acronyms and the lowercase brand\n// \"cmux\" need spelling out. `agent` falls through to plain title case.\nconst MODE_LABELS: Record<string, string> = {\n api: \"API\",\n cli: \"CLI\",\n cmux: \"cmux\",\n};\n\n// Tooltip text, so \"Claude cmux\" reads as \"Claude multiplexer\".\nconst MODE_TITLES: Record<string, string> = {\n api: \"API\",\n agent: \"Agent SDK\",\n cli: \"CLI\",\n cmux: \"multiplexer\",\n};\n\n// The one brand whose title case is not just an initial capital.\nconst FAMILY_LABELS: Record<string, string> = { deepseek: \"DeepSeek\" };\n\nfunction titleCase(token: string): string {\n return token ? token.charAt(0).toUpperCase() + token.slice(1) : token;\n}\n\n// Turns the served catalog into the shared family list. Unavailable entries\n// stay present for Provider Status while runtime controls filter them out.\n//\n// The registry has one provider per family, so Claude's API mode sits beside its\n// Agent/CLI/cmux modes here rather than in a separate \"Anthropic\" family the way\n// SPEC_RUNTIME_FAMILIES splits them.\nexport function familiesFromRuntimeCatalog(\n catalog: RuntimeCatalogFamily[] | undefined,\n): SpecRuntimeFamily[] {\n if (!catalog?.length) return SPEC_RUNTIME_FAMILIES;\n const families: SpecRuntimeFamily[] = [];\n for (const entry of catalog) {\n const label = FAMILY_LABELS[entry.family] ?? titleCase(entry.family);\n const modes = entry.modes.map((mode) => ({\n id: mode.mode,\n label: MODE_LABELS[mode.mode] ?? titleCase(mode.mode),\n icon: MODE_ICONS[mode.mode],\n title: `${label} ${MODE_TITLES[mode.mode] ?? titleCase(mode.mode)}`,\n provider: mode.catalogProvider ?? entry.catalogPrefix,\n ...(mode.defaultModel ? { defaultModel: mode.defaultModel } : {}),\n ...(mode.permissions ? { permissions: mode.permissions } : {}),\n ...(mode.schema ? { schema: mode.schema } : {}),\n ...(mode.availability\n ? { availability: mode.availability }\n : mode.disabled\n ? {\n availability: {\n state: \"disabled\" as const,\n reason: `Disabled by ${\n mode.disabledReason ?? mode.mode\n } in Captain configuration.`,\n remediation: `Enable ${\n mode.disabledReason ?? mode.mode\n } on the Whoami page, then refresh.`,\n },\n }\n : {}),\n }));\n families.push({\n id: entry.family,\n label,\n provider: entry.catalogPrefix,\n modes,\n });\n }\n return families.length ? families : SPEC_RUNTIME_FAMILIES;\n}\n\nexport function familyById(\n families: SpecRuntimeFamily[],\n id: string,\n): SpecRuntimeFamily {\n const match = families.find((family) => family.id === id);\n if (match) return match;\n const first = families[0];\n if (!first) throw new Error(\"SpecRuntimeFamily catalog must not be empty\");\n return first;\n}\n\nexport function firstMode(family: SpecRuntimeFamily): SpecRuntimeModeOption {\n const mode =\n family.modes.find((candidate) => !isUnavailable(candidate.availability)) ??\n family.modes[0];\n if (!mode) {\n throw new Error(\n `SpecRuntimeFamily \"${family.id}\" must have at least one mode`,\n );\n }\n return mode;\n}\n\n// Every mode id in the catalog, first-seen order. The entry returned for an id\n// belongs to the family that declared it first, so its presentation fields may\n// differ from another family's — the id itself is family-independent.\nexport function runtimeModeOptions(\n families: SpecRuntimeFamily[],\n): SpecRuntimeModeOption[] {\n const modes = new Map<string, SpecRuntimeModeOption>();\n for (const family of families) {\n for (const mode of family.modes) {\n if (!modes.has(mode.id)) modes.set(mode.id, mode);\n }\n }\n return [...modes.values()];\n}\n\n// One phrasing for \"this family does not offer that mode\", shared by every\n// runtime presentation so the same state never reads two ways.\nexport function unsupportedModeTitle(family: SpecRuntimeFamily): string {\n return availabilityText(\n unsupportedAvailability(\n family.label,\n \"this\",\n family.modes\n .filter((mode) => !isUnavailable(mode.availability))\n .map((mode) => mode.label),\n ),\n )!;\n}\n\nexport function unsupportedModeAvailability(\n family: SpecRuntimeFamily,\n mode: SpecRuntimeModeOption,\n): RuntimeAvailability {\n return unsupportedAvailability(\n family.label,\n mode.label,\n family.modes\n .filter((candidate) => !isUnavailable(candidate.availability))\n .map((candidate) => candidate.label),\n );\n}\n\n// The mode a family will actually run for a requested id, falling back to its\n// first available one. The answer is a `spec.mode` value.\nexport function modeForFamily(\n families: SpecRuntimeFamily[],\n familyId: string,\n modeId: string,\n): string {\n const family = familyById(families, familyId);\n const requested = family.modes.find((candidate) => candidate.id === modeId);\n const mode =\n requested && !isUnavailable(requested.availability)\n ? requested\n : firstMode(family);\n if (isUnavailable(mode.availability)) {\n throw new Error(\n `SpecRuntimeFamily \"${family.id}\" has no available runtime modes`,\n );\n }\n return mode.id;\n}\n\nexport function selectionForMode(\n families: SpecRuntimeFamily[],\n mode: string | undefined,\n preferredFamily?: string | undefined,\n): { family: string; mode: string } {\n const target = (mode ?? \"\").toLowerCase();\n const preferred = families.find((family) => family.id === preferredFamily);\n const preferredMode = preferred?.modes.find(\n (entry) => entry.id.toLowerCase() === target,\n );\n if (preferred && preferredMode) {\n return { family: preferred.id, mode: preferredMode.id };\n }\n for (const family of families) {\n for (const entry of family.modes) {\n if (entry.id.toLowerCase() === target) {\n return { family: family.id, mode: entry.id };\n }\n }\n }\n const first = familyById(families, \"\");\n return { family: first.id, mode: firstMode(first).id };\n}\n\nexport function familyForModel(\n families: SpecRuntimeFamily[],\n models: ChatModel[],\n modelId: string | undefined,\n): SpecRuntimeFamily | undefined {\n if (!modelId) return undefined;\n const selected = models.find(\n (model) =>\n model.id === modelId ||\n model.runtime?.model === modelId ||\n model.runtime?.id === modelId,\n );\n if (!selected) return undefined;\n return families.find(\n (family) =>\n family.provider === selected.provider ||\n family.modes.some((mode) => mode.provider === selected.provider),\n );\n}\n\nexport function selectionForRuntime(\n families: SpecRuntimeFamily[],\n mode: string | undefined,\n modelId: string | undefined,\n models: ChatModel[],\n preferredFamily?: string | undefined,\n): { family: string; mode: string } {\n return selectionForMode(\n families,\n mode,\n familyForModel(families, models, modelId)?.id ?? preferredFamily,\n );\n}\n\nexport function familyForMode(\n families: SpecRuntimeFamily[],\n mode: string | undefined,\n preferredFamily?: string | undefined,\n): SpecRuntimeFamily | undefined {\n if (preferredFamily) {\n const family = families.find((entry) => entry.id === preferredFamily);\n if (family?.modes.some((entry) => entry.id === mode)) return family;\n }\n const target = (mode ?? \"\").toLowerCase();\n return families.find((family) =>\n family.modes.some((entry) => entry.id.toLowerCase() === target),\n );\n}\n\n// The mode option a `spec.mode` names, or undefined when the catalog does not\n// declare it. Unlike `selectionForMode` this does not fall back to the first\n// family, so a summary can stay silent about a runtime it cannot identify.\nexport function modeOptionFor(\n families: SpecRuntimeFamily[],\n mode: string | undefined,\n preferredFamily?: string | undefined,\n): SpecRuntimeModeOption | undefined {\n const target = (mode ?? \"\").toLowerCase();\n if (!target) return undefined;\n const ordered = preferredFamily\n ? [\n ...families.filter((family) => family.id === preferredFamily),\n ...families.filter((family) => family.id !== preferredFamily),\n ]\n : families;\n for (const family of ordered) {\n const entry = family.modes.find(\n (candidate) => candidate.id.toLowerCase() === target,\n );\n if (entry) return entry;\n }\n return undefined;\n}\n\n// `mode` is provider-independent, so a family is needed for a full label.\nexport function labelForMode(\n mode: string | undefined,\n families: SpecRuntimeFamily[] = SPEC_RUNTIME_FAMILIES,\n): string {\n const target = (mode ?? \"\").toLowerCase();\n for (const family of families) {\n for (const entry of family.modes) {\n if (entry.id.toLowerCase() === target) {\n return `${family.label} ${entry.label}`;\n }\n }\n }\n return \"Prompt default\";\n}\n\n/** Lists selectable models for one provider family. */\nexport function modelsForFamily(\n models: ChatModel[],\n family: SpecRuntimeFamily | undefined,\n mode?: string | undefined,\n): ChatModel[] {\n if (!family) return models.filter(isSelectableModel);\n const provider =\n family.modes.find((entry) => entry.id === mode)?.provider ??\n family.provider;\n return models.filter(\n (model) => isSelectableModel(model) && model.provider === provider,\n );\n}\n\n/** Reports whether the first matching catalog identity belongs to the target family. */\nexport function modelBelongsToFamily(\n modelId: string | undefined,\n models: ChatModel[],\n family: SpecRuntimeFamily | undefined,\n mode?: string | undefined,\n): boolean {\n if (!modelId) return true;\n const selected = models.find(\n (model) =>\n isSelectableModel(model) &&\n (model.id === modelId ||\n model.runtime?.model === modelId ||\n model.runtime?.id === modelId),\n );\n if (!selected) return false;\n const provider =\n family?.modes.find((entry) => entry.id === mode)?.provider ??\n family?.provider;\n return (\n (!provider || selected.provider === provider) &&\n (!selected.runtime?.mode || selected.runtime.mode === mode)\n );\n}\n\n/** Resolves a target mode row, using a sole shared row as fallback. */\nexport function modelForFamily(\n modelId: string | undefined,\n models: ChatModel[],\n family: SpecRuntimeFamily | undefined,\n mode?: string | undefined,\n): ChatModel | undefined {\n if (!modelId) return undefined;\n const matches = modelsForFamily(models, family, mode).filter(\n (model) =>\n model.id === modelId ||\n model.runtime?.model === modelId ||\n model.runtime?.id === modelId,\n );\n return (\n matches.find(\n (model) => !mode || !model.runtime?.mode || model.runtime.mode === mode,\n ) ?? (matches.length === 1 ? matches[0] : undefined)\n );\n}\n"],"names":["_a","_b"],"mappings":";;;;;AAiBO,MAAM,qBAAqB,CAAC,OAAO,SAAS,OAAO,MAAM;AAGzD,SAAS,kBACd,OAC0B;AAC1B,SAAO,mBAAmB,KAAK,CAAC,SAAS,SAAS,KAAK;AACzD;AAEO,SAAS,qBACd,OAC6B;AAC7B,QAAM,CAAC,MAAM,KAAK,SAAS,IAAI,OAAO,YAAA,EAAc,MAAM,GAAG;AAC7D,SAAO,kBAAkB,MAAM,IAAI,SAAS;AAC9C;AAEO,SAAS,kBACd,OACoB;AACpB,aAAW,QAAQ,SAAS,IAAI,MAAM,GAAG,GAAG;AAC1C,UAAM,UAAU,IAAI,KAAA;AACpB,QAAI,CAAC,WAAW,CAAC,QAAQ,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src/data/runtime/runtime-mode.ts"],"sourcesContent":["import type { StaticIconComponent } from \"../Icon\";\nimport { UiCloud, UiColumns, UiRobotAi, UiTerminal } from \"../../icons\";\nimport type { JsonSchemaProperty } from \"../../components/json-schema-form-types\";\nimport type { ChatModel, RuntimeAvailability } from \"../chat/types\";\nimport {\n availabilityText,\n isSelectableModel,\n isUnavailable,\n unsupportedAvailability,\n} from \"./availability\";\nimport {\n familyForModel,\n isSpecRuntimeMode,\n type SpecRuntimeMode,\n} from \"../../lib/runtime-family\";\nexport {\n familyForModel,\n isSpecRuntimeMode,\n modeOptionFor,\n runtimeModeFromModel,\n SPEC_RUNTIME_MODES,\n type SpecRuntimeMode,\n} from \"../../lib/runtime-family\";\n\n// A runtime has two independent axes: the model selects a provider family and\n// `spec.mode` selects api | agent | cli | cmux. The mode never contains a\n// provider name. This file used to call that axis `backend`, which is also what\n// captain called the composite adapter id it once served — so a value read from\n// one and posted back as the other type-checked and ran the wrong runtime.\n\nexport function runtimeModelError(\n model: string | undefined,\n): string | undefined {\n for (const raw of (model ?? \"\").split(\",\")) {\n const compact = raw.trim();\n if (!compact || !compact.includes(\":\")) continue;\n const parts = compact.split(\":\").map((part) => part.trim());\n const [mode, name, effort] = parts;\n if (!isSpecRuntimeMode(mode)) {\n return `Invalid model configuration: mode ${JSON.stringify(mode)} in model ${JSON.stringify(compact)}. Expected api, agent, cli, or cmux.`;\n }\n if (!name || parts.length > 3) {\n return `Invalid model configuration: model ${JSON.stringify(compact)}. Expected mode:model[:effort].`;\n }\n if (\n effort !== undefined &&\n ![\"low\", \"medium\", \"high\", \"xhigh\", \"max\", \"ultra\"].includes(effort)\n ) {\n return `Invalid model configuration: effort ${JSON.stringify(effort)} in model ${JSON.stringify(compact)}.`;\n }\n }\n return undefined;\n}\n\nexport function runtimeModeError(\n families: SpecRuntimeFamily[],\n mode: string | undefined,\n familyId?: string | undefined,\n): string | undefined {\n if (!mode) return undefined;\n if (!isSpecRuntimeMode(mode)) {\n return `Invalid model configuration: mode ${JSON.stringify(mode)}. Expected api, agent, cli, or cmux.`;\n }\n const family = familyId\n ? families.find((entry) => entry.id === familyId)\n : undefined;\n if (family && !family.modes.some((entry) => entry.id === mode)) {\n return `Invalid model configuration: mode ${JSON.stringify(mode)} is not available for ${family.label}.`;\n }\n if (!families.some((entry) => entry.modes.some((m) => m.id === mode))) {\n return `Invalid model configuration: mode ${JSON.stringify(mode)} is missing from the runtime catalog.`;\n }\n return undefined;\n}\n\nexport type SpecRuntimeModeOption = {\n /** The canonical `spec.mode`: api | agent | cli | cmux. */\n id: string;\n label: string;\n icon?: StaticIconComponent | undefined;\n title?: string | undefined;\n provider?: string | undefined;\n defaultModel?: string | undefined;\n availability?: RuntimeAvailability | undefined;\n permissions?: RuntimePermissionCapabilities | undefined;\n schema?: RuntimeSpecSchema | undefined;\n};\n\nexport type RuntimeArgumentImplementation = \"mapped\" | \"managed\";\n\nexport type RuntimeArgumentMapping = {\n name: string;\n implementation: RuntimeArgumentImplementation;\n description?: string | undefined;\n};\n\nexport type RuntimeSpecSchema = JsonSchemaProperty & {\n \"x-clicky-arguments\"?: RuntimeArgumentMapping[] | undefined;\n \"x-clicky-managed-arguments\"?: RuntimeArgumentMapping[] | undefined;\n};\n\nexport type RuntimePermissionSupportKind =\n | \"native\"\n | \"approximated\"\n | \"requires-broker\"\n | \"unsupported\";\n\nexport type RuntimePermissionSupport = {\n kind: RuntimePermissionSupportKind;\n effects?:\n | {\n flag?: string | undefined;\n sandbox?: string | undefined;\n approval?: string | undefined;\n note?: string | undefined;\n }\n | undefined;\n};\n\nexport type RuntimePermissionCapabilities = {\n modes: Record<string, RuntimePermissionSupport>;\n toolPolicies: Record<string, Record<string, RuntimePermissionSupport>>;\n resources: Record<string, Record<string, RuntimePermissionSupport>>;\n tools?: string[] | undefined;\n};\n\nexport type SpecRuntimeFamily = {\n id: string;\n label: string;\n /** The model-catalog provider (`ChatModel.provider`) whose models this family runs. */\n provider: string;\n /** Namespace used by fully-qualified model ids when it differs from provider. */\n catalogPrefix?: string | undefined;\n modes: SpecRuntimeModeOption[];\n};\n\n// Offline catalog for stories and tests. Live hosts should pass Captain's\n// registry projection; both use the same provider + mode structure.\nexport const SPEC_RUNTIME_FAMILIES: SpecRuntimeFamily[] = [\n {\n id: \"claude\",\n label: \"Claude\",\n provider: \"anthropic\",\n modes: [\n {\n id: \"api\",\n label: \"API\",\n icon: UiCloud,\n title: \"Anthropic API\",\n provider: \"anthropic\",\n },\n {\n id: \"agent\",\n label: \"Agent\",\n icon: UiRobotAi,\n title: \"Claude Agent SDK\",\n provider: \"anthropic\",\n },\n {\n id: \"cli\",\n label: \"CLI\",\n icon: UiTerminal,\n title: \"Claude Code CLI\",\n provider: \"anthropic\",\n },\n {\n id: \"cmux\",\n label: \"cmux\",\n icon: UiColumns,\n title: \"Claude multiplexer\",\n provider: \"anthropic\",\n },\n ],\n },\n {\n id: \"codex\",\n label: \"Codex\",\n provider: \"openai\",\n modes: [\n {\n id: \"api\",\n label: \"API\",\n icon: UiCloud,\n title: \"OpenAI API\",\n provider: \"openai\",\n },\n {\n id: \"agent\",\n label: \"Agent\",\n icon: UiRobotAi,\n title: \"Codex agent\",\n provider: \"openai\",\n },\n {\n id: \"cli\",\n label: \"CLI\",\n icon: UiTerminal,\n title: \"Codex CLI\",\n provider: \"openai\",\n },\n {\n id: \"cmux\",\n label: \"cmux\",\n icon: UiColumns,\n title: \"Codex multiplexer\",\n provider: \"openai\",\n },\n ],\n },\n {\n id: \"gemini\",\n label: \"Gemini\",\n provider: \"google\",\n catalogPrefix: \"googleai\",\n modes: [\n { id: \"api\", label: \"API\", icon: UiCloud, title: \"Gemini API\" },\n { id: \"cli\", label: \"CLI\", icon: UiTerminal, title: \"Gemini CLI\" },\n ],\n },\n {\n id: \"deepseek\",\n label: \"DeepSeek\",\n provider: \"deepseek\",\n modes: [{ id: \"api\", label: \"API\", icon: UiCloud, title: \"DeepSeek API\" }],\n },\n];\n\n// One provider×mode cell as captain serves it (`/whoami`.runtimes and the prompt\n// schema document's `runtimes`), projected from its model registry. It carries\n// ids, not display text: `claude`/`api` are enough to render both, and a served\n// label would be a second place for presentation to drift.\nexport type RuntimeCatalogMode = {\n /** The canonical `spec.mode`: api | agent | cli | cmux. */\n mode: SpecRuntimeMode;\n /** \"api\" (remote, in-process) or \"cli\" (supervised local binary). */\n kind?: string | undefined;\n /** Rides the local CLI's own login; never consults an API key. */\n keyless?: boolean | undefined;\n /** The model id a picker should seed this mode with. */\n defaultModel?: string | undefined;\n /** The user switched this off in `~/.captain.yaml`. */\n disabled?: boolean | undefined;\n disabledReason?: string | undefined;\n /** Model-catalog provider used by this exact mode. */\n catalogProvider?: string | undefined;\n availability?: RuntimeAvailability | undefined;\n permissions?: RuntimePermissionCapabilities | undefined;\n /** Supported Spec fields, annotated with native CLI and protocol bindings. */\n schema: RuntimeSpecSchema;\n};\n\nexport type RuntimeCatalogFamily = {\n /** The coding-agent name: claude | codex | gemini | deepseek. */\n family: string;\n /** The canonical provider key: anthropic | openai | google | deepseek. */\n provider: string;\n /** The namespace used in fully-qualified model ids. */\n catalogPrefix: string;\n modes: RuntimeCatalogMode[];\n};\n\nconst MODE_ICONS: Record<string, StaticIconComponent> = {\n api: UiCloud,\n agent: UiRobotAi,\n cli: UiTerminal,\n cmux: UiColumns,\n};\n\n// Mode ids are lowercase tokens; only the acronyms and the lowercase brand\n// \"cmux\" need spelling out. `agent` falls through to plain title case.\nconst MODE_LABELS: Record<string, string> = {\n api: \"API\",\n cli: \"CLI\",\n cmux: \"cmux\",\n};\n\n// Tooltip text, so \"Claude cmux\" reads as \"Claude multiplexer\".\nconst MODE_TITLES: Record<string, string> = {\n api: \"API\",\n agent: \"Agent SDK\",\n cli: \"CLI\",\n cmux: \"multiplexer\",\n};\n\n// The one brand whose title case is not just an initial capital.\nconst FAMILY_LABELS: Record<string, string> = { deepseek: \"DeepSeek\" };\n\nfunction titleCase(token: string): string {\n return token ? token.charAt(0).toUpperCase() + token.slice(1) : token;\n}\n\n// Turns the served catalog into the shared family list. Unavailable entries\n// stay present for Provider Status while runtime controls filter them out.\n//\n// The registry has one provider per family, so Claude's API mode sits beside its\n// Agent/CLI/cmux modes here rather than in a separate \"Anthropic\" family the way\n// SPEC_RUNTIME_FAMILIES splits them.\nexport function familiesFromRuntimeCatalog(\n catalog: RuntimeCatalogFamily[] | undefined,\n): SpecRuntimeFamily[] {\n if (!catalog?.length) return SPEC_RUNTIME_FAMILIES;\n const families: SpecRuntimeFamily[] = [];\n for (const entry of catalog) {\n const label = FAMILY_LABELS[entry.family] ?? titleCase(entry.family);\n const modes = entry.modes.map((mode) => ({\n id: mode.mode,\n label: MODE_LABELS[mode.mode] ?? titleCase(mode.mode),\n icon: MODE_ICONS[mode.mode],\n title: `${label} ${MODE_TITLES[mode.mode] ?? titleCase(mode.mode)}`,\n provider: mode.catalogProvider ?? entry.provider,\n ...(mode.defaultModel ? { defaultModel: mode.defaultModel } : {}),\n ...(mode.permissions ? { permissions: mode.permissions } : {}),\n ...(mode.schema ? { schema: mode.schema } : {}),\n ...(mode.availability\n ? { availability: mode.availability }\n : mode.disabled\n ? {\n availability: {\n state: \"disabled\" as const,\n reason: `Disabled by ${\n mode.disabledReason ?? mode.mode\n } in Captain configuration.`,\n remediation: `Enable ${\n mode.disabledReason ?? mode.mode\n } on the Whoami page, then refresh.`,\n },\n }\n : {}),\n }));\n families.push({\n id: entry.family,\n label,\n provider: entry.provider,\n catalogPrefix: entry.catalogPrefix,\n modes,\n });\n }\n return families.length ? families : SPEC_RUNTIME_FAMILIES;\n}\n\nexport function familyById(\n families: SpecRuntimeFamily[],\n id: string,\n): SpecRuntimeFamily {\n const match = families.find((family) => family.id === id);\n if (match) return match;\n const first = families[0];\n if (!first) throw new Error(\"SpecRuntimeFamily catalog must not be empty\");\n return first;\n}\n\nexport function firstMode(family: SpecRuntimeFamily): SpecRuntimeModeOption {\n const mode =\n family.modes.find((candidate) => !isUnavailable(candidate.availability)) ??\n family.modes[0];\n if (!mode) {\n throw new Error(\n `SpecRuntimeFamily \"${family.id}\" must have at least one mode`,\n );\n }\n return mode;\n}\n\n// Every mode id in the catalog, first-seen order. The entry returned for an id\n// belongs to the family that declared it first, so its presentation fields may\n// differ from another family's — the id itself is family-independent.\nexport function runtimeModeOptions(\n families: SpecRuntimeFamily[],\n): SpecRuntimeModeOption[] {\n const modes = new Map<string, SpecRuntimeModeOption>();\n for (const family of families) {\n for (const mode of family.modes) {\n if (!modes.has(mode.id)) modes.set(mode.id, mode);\n }\n }\n return [...modes.values()];\n}\n\n// One phrasing for \"this family does not offer that mode\", shared by every\n// runtime presentation so the same state never reads two ways.\nexport function unsupportedModeTitle(family: SpecRuntimeFamily): string {\n return availabilityText(\n unsupportedAvailability(\n family.label,\n \"this\",\n family.modes\n .filter((mode) => !isUnavailable(mode.availability))\n .map((mode) => mode.label),\n ),\n )!;\n}\n\nexport function unsupportedModeAvailability(\n family: SpecRuntimeFamily,\n mode: SpecRuntimeModeOption,\n): RuntimeAvailability {\n return unsupportedAvailability(\n family.label,\n mode.label,\n family.modes\n .filter((candidate) => !isUnavailable(candidate.availability))\n .map((candidate) => candidate.label),\n );\n}\n\n// The mode a family will actually run for a requested id, falling back to its\n// first available one. The answer is a `spec.mode` value.\nexport function modeForFamily(\n families: SpecRuntimeFamily[],\n familyId: string,\n modeId: string,\n): string {\n const family = familyById(families, familyId);\n const requested = family.modes.find((candidate) => candidate.id === modeId);\n const mode =\n requested && !isUnavailable(requested.availability)\n ? requested\n : firstMode(family);\n if (isUnavailable(mode.availability)) {\n throw new Error(\n `SpecRuntimeFamily \"${family.id}\" has no available runtime modes`,\n );\n }\n return mode.id;\n}\n\nexport function selectionForMode(\n families: SpecRuntimeFamily[],\n mode: string | undefined,\n preferredFamily?: string | undefined,\n): { family: string; mode: string } {\n const target = (mode ?? \"\").toLowerCase();\n const preferred = families.find((family) => family.id === preferredFamily);\n const preferredMode = preferred?.modes.find(\n (entry) => entry.id.toLowerCase() === target,\n );\n if (preferred && preferredMode) {\n return { family: preferred.id, mode: preferredMode.id };\n }\n for (const family of families) {\n for (const entry of family.modes) {\n if (entry.id.toLowerCase() === target) {\n return { family: family.id, mode: entry.id };\n }\n }\n }\n const first = familyById(families, \"\");\n return { family: first.id, mode: firstMode(first).id };\n}\n\nexport function selectionForRuntime(\n families: SpecRuntimeFamily[],\n mode: string | undefined,\n modelId: string | undefined,\n models: ChatModel[],\n preferredFamily?: string | undefined,\n): { family: string; mode: string } {\n return selectionForMode(\n families,\n mode,\n familyForModel(families, models, modelId)?.id ?? preferredFamily,\n );\n}\n\nexport function familyForMode(\n families: SpecRuntimeFamily[],\n mode: string | undefined,\n preferredFamily?: string | undefined,\n): SpecRuntimeFamily | undefined {\n if (preferredFamily) {\n const family = families.find((entry) => entry.id === preferredFamily);\n if (family?.modes.some((entry) => entry.id === mode)) return family;\n }\n const target = (mode ?? \"\").toLowerCase();\n return families.find((family) =>\n family.modes.some((entry) => entry.id.toLowerCase() === target),\n );\n}\n\n// The mode option a `spec.mode` names, or undefined when the catalog does not\n// declare it. Unlike `selectionForMode` this does not fall back to the first\n// family, so a summary can stay silent about a runtime it cannot identify.\n// `mode` is provider-independent, so a family is needed for a full label.\nexport function labelForMode(\n mode: string | undefined,\n families: SpecRuntimeFamily[] = SPEC_RUNTIME_FAMILIES,\n): string {\n const target = (mode ?? \"\").toLowerCase();\n for (const family of families) {\n for (const entry of family.modes) {\n if (entry.id.toLowerCase() === target) {\n return `${family.label} ${entry.label}`;\n }\n }\n }\n return \"Prompt default\";\n}\n\n/** Lists selectable models for one provider family. */\nexport function modelsForFamily(\n models: ChatModel[],\n family: SpecRuntimeFamily | undefined,\n mode?: string | undefined,\n): ChatModel[] {\n if (!family) return models.filter(isSelectableModel);\n const provider =\n family.modes.find((entry) => entry.id === mode)?.provider ??\n family.provider;\n return models.filter(\n (model) => isSelectableModel(model) && model.provider === provider,\n );\n}\n\n/** Reports whether the first matching catalog identity belongs to the target family. */\nexport function modelBelongsToFamily(\n modelId: string | undefined,\n models: ChatModel[],\n family: SpecRuntimeFamily | undefined,\n mode?: string | undefined,\n): boolean {\n if (!modelId) return true;\n const selected = models.find(\n (model) =>\n isSelectableModel(model) &&\n (model.id === modelId ||\n model.runtime?.model === modelId ||\n model.runtime?.id === modelId),\n );\n if (!selected) return false;\n const provider =\n family?.modes.find((entry) => entry.id === mode)?.provider ??\n family?.provider;\n return (\n (!provider || selected.provider === provider) &&\n (!selected.runtime?.mode || selected.runtime.mode === mode)\n );\n}\n\n/** Resolves a target mode row, using a sole shared row as fallback. */\nexport function modelForFamily(\n modelId: string | undefined,\n models: ChatModel[],\n family: SpecRuntimeFamily | undefined,\n mode?: string | undefined,\n): ChatModel | undefined {\n if (!modelId) return undefined;\n const matches = modelsForFamily(models, family, mode).filter(\n (model) =>\n model.id === modelId ||\n model.runtime?.model === modelId ||\n model.runtime?.id === modelId,\n );\n return (\n matches.find(\n (model) => !mode || !model.runtime?.mode || model.runtime.mode === mode,\n ) ?? (matches.length === 1 ? matches[0] : undefined)\n );\n}\n"],"names":["_a","_b"],"mappings":";;;;;;;AA8BO,SAAS,kBACd,OACoB;AACpB,aAAW,QAAQ,SAAS,IAAI,MAAM,GAAG,GAAG;AAC1C,UAAM,UAAU,IAAI,KAAA;AACpB,QAAI,CAAC,WAAW,CAAC,QAAQ,SAAS,GAAG,EAAG;AACxC,UAAM,QAAQ,QAAQ,MAAM,GAAG,EAAE,IAAI,CAAC,SAAS,KAAK,MAAM;AAC1D,UAAM,CAAC,MAAM,MAAM,MAAM,IAAI;AAC7B,QAAI,CAAC,kBAAkB,IAAI,GAAG;AAC5B,aAAO,qCAAqC,KAAK,UAAU,IAAI,CAAC,aAAa,KAAK,UAAU,OAAO,CAAC;AAAA,IACtG;AACA,QAAI,CAAC,QAAQ,MAAM,SAAS,GAAG;AAC7B,aAAO,sCAAsC,KAAK,UAAU,OAAO,CAAC;AAAA,IACtE;AACA,QACE,WAAW,UACX,CAAC,CAAC,OAAO,UAAU,QAAQ,SAAS,OA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15,9 +15,9 @@ function detectMode() {
|
|
|
15
15
|
}
|
|
16
16
|
function getVersionInfo() {
|
|
17
17
|
return {
|
|
18
|
-
commit: read(() => "
|
|
19
|
-
tag: read(() => "clicky-ui@0.3.
|
|
20
|
-
date: read(() => "2026-09-
|
|
18
|
+
commit: read(() => "433d3b71", ""),
|
|
19
|
+
tag: read(() => "clicky-ui@0.3.29", ""),
|
|
20
|
+
date: read(() => "2026-09-02T12:51:00.362Z", ""),
|
|
21
21
|
dirty: read(() => true, false),
|
|
22
22
|
mode: detectMode()
|
|
23
23
|
};
|
|
@@ -13,9 +13,9 @@ function detectMode() {
|
|
|
13
13
|
}
|
|
14
14
|
function getVersionInfo() {
|
|
15
15
|
return {
|
|
16
|
-
commit: read(() => "
|
|
17
|
-
tag: read(() => "clicky-ui@0.3.
|
|
18
|
-
date: read(() => "2026-09-
|
|
16
|
+
commit: read(() => "433d3b71", ""),
|
|
17
|
+
tag: read(() => "clicky-ui@0.3.29", ""),
|
|
18
|
+
date: read(() => "2026-09-02T12:50:30.786Z", ""),
|
|
19
19
|
dirty: read(() => true, false),
|
|
20
20
|
mode: detectMode()
|
|
21
21
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -4,6 +4,11 @@ const utils = require("./lib/utils.cjs");
|
|
|
4
4
|
const collections = require("./lib/collections.cjs");
|
|
5
5
|
const palette = require("./lib/palette.cjs");
|
|
6
6
|
const size = require("./lib/size.cjs");
|
|
7
|
+
const combobox = require("./lib/combobox.cjs");
|
|
8
|
+
const comboboxValues = require("./lib/combobox-values.cjs");
|
|
9
|
+
const runtimeFamily = require("./lib/runtime-family.cjs");
|
|
10
|
+
const runtimeProfileModel = require("./lib/runtime-profile-model.cjs");
|
|
11
|
+
const permissionStrategies = require("./lib/permission-strategies.cjs");
|
|
7
12
|
const pathTree = require("./lib/path-tree.cjs");
|
|
8
13
|
const format = require("./lib/format.cjs");
|
|
9
14
|
const useTheme = require("./hooks/use-theme.cjs");
|
|
@@ -626,6 +631,53 @@ exports.fnv1a32 = palette.fnv1a32;
|
|
|
626
631
|
exports.paletteClass = palette.paletteClass;
|
|
627
632
|
exports.SIZE_TOKENS = size.SIZE_TOKENS;
|
|
628
633
|
exports.resolveSize = size.resolveSize;
|
|
634
|
+
exports.COMBOBOX_MENU_MAX_HEIGHT_PX = combobox.COMBOBOX_MENU_MAX_HEIGHT_PX;
|
|
635
|
+
exports.COMBOBOX_MENU_MAX_WIDTH_PX = combobox.COMBOBOX_MENU_MAX_WIDTH_PX;
|
|
636
|
+
exports.COMBOBOX_MOBILE_QUERY = combobox.COMBOBOX_MOBILE_QUERY;
|
|
637
|
+
exports.calculateComboboxMenuPosition = combobox.calculateComboboxMenuPosition;
|
|
638
|
+
exports.comboboxLabelPadding = comboboxValues.comboboxLabelPadding;
|
|
639
|
+
exports.createComboboxCustomEntry = comboboxValues.createComboboxCustomEntry;
|
|
640
|
+
exports.multipleComboboxLabel = comboboxValues.multipleComboboxLabel;
|
|
641
|
+
exports.splitOnComboboxSeparators = comboboxValues.splitOnComboboxSeparators;
|
|
642
|
+
exports.withSelectedComboboxOptions = comboboxValues.withSelectedComboboxOptions;
|
|
643
|
+
exports.SPEC_RUNTIME_MODES = runtimeFamily.SPEC_RUNTIME_MODES;
|
|
644
|
+
exports.familyForModel = runtimeFamily.familyForModel;
|
|
645
|
+
exports.isSpecRuntimeMode = runtimeFamily.isSpecRuntimeMode;
|
|
646
|
+
exports.modeOptionFor = runtimeFamily.modeOptionFor;
|
|
647
|
+
exports.runtimeModeFromModel = runtimeFamily.runtimeModeFromModel;
|
|
648
|
+
exports.authoredRuntimeSpec = runtimeProfileModel.authoredRuntimeSpec;
|
|
649
|
+
exports.duplicateName = runtimeProfileModel.duplicateName;
|
|
650
|
+
exports.duplicateRecord = runtimeProfileModel.duplicateRecord;
|
|
651
|
+
exports.mergeRuntimeSpec = runtimeProfileModel.mergeRuntimeSpec;
|
|
652
|
+
exports.newPresetRecord = runtimeProfileModel.newPresetRecord;
|
|
653
|
+
exports.newProfileRecord = runtimeProfileModel.newProfileRecord;
|
|
654
|
+
exports.nextNewName = runtimeProfileModel.nextNewName;
|
|
655
|
+
exports.permissionTarget = runtimeProfileModel.permissionTarget;
|
|
656
|
+
exports.presetForRef = runtimeProfileModel.presetForRef;
|
|
657
|
+
exports.presetsOf = runtimeProfileModel.presetsOf;
|
|
658
|
+
exports.referencedBy = runtimeProfileModel.referencedBy;
|
|
659
|
+
exports.reorderProfilePresets = runtimeProfileModel.reorderProfilePresets;
|
|
660
|
+
exports.selectionAfterDelete = runtimeProfileModel.selectionAfterDelete;
|
|
661
|
+
exports.uniqueName = runtimeProfileModel.uniqueName;
|
|
662
|
+
exports.HINT_FIELDS = permissionStrategies.HINT_FIELDS;
|
|
663
|
+
exports.MATCH_FIELDS = permissionStrategies.MATCH_FIELDS;
|
|
664
|
+
exports.MATCH_FIELD_OPTIONS = permissionStrategies.MATCH_FIELD_OPTIONS;
|
|
665
|
+
exports.PATTERN_FIELDS = permissionStrategies.PATTERN_FIELDS;
|
|
666
|
+
exports.STRATEGY_PRESETS = permissionStrategies.STRATEGY_PRESETS;
|
|
667
|
+
exports.activeMatchFields = permissionStrategies.activeMatchFields;
|
|
668
|
+
exports.addCondition = permissionStrategies.addCondition;
|
|
669
|
+
exports.applyStrategyPreset = permissionStrategies.applyStrategyPreset;
|
|
670
|
+
exports.conditionText = permissionStrategies.conditionText;
|
|
671
|
+
exports.isHintField = permissionStrategies.isHintField;
|
|
672
|
+
exports.matchingTools = permissionStrategies.matchingTools;
|
|
673
|
+
exports.patternValues = permissionStrategies.patternValues;
|
|
674
|
+
exports.patternsText = permissionStrategies.patternsText;
|
|
675
|
+
exports.removeCondition = permissionStrategies.removeCondition;
|
|
676
|
+
exports.replaceMatchField = permissionStrategies.replaceMatchField;
|
|
677
|
+
exports.strategyPreset = permissionStrategies.strategyPreset;
|
|
678
|
+
exports.toolFieldSuggestions = permissionStrategies.toolFieldSuggestions;
|
|
679
|
+
exports.updateCondition = permissionStrategies.updateCondition;
|
|
680
|
+
exports.updatePatternCondition = permissionStrategies.updatePatternCondition;
|
|
629
681
|
exports.PATH_SEPARATOR = pathTree.PATH_SEPARATOR;
|
|
630
682
|
exports.buildPathTree = pathTree.buildPathTree;
|
|
631
683
|
exports.foldersFirst = pathTree.foldersFirst;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,11 @@ import { cn } from "./lib/utils.js";
|
|
|
2
2
|
import { duplicateIndex, isPlainObject, moveItem, removeIndex, setIndex } from "./lib/collections.js";
|
|
3
3
|
import { AVATAR_PALETTE, fnv1a32, paletteClass } from "./lib/palette.js";
|
|
4
4
|
import { SIZE_TOKENS, resolveSize } from "./lib/size.js";
|
|
5
|
+
import { COMBOBOX_MENU_MAX_HEIGHT_PX, COMBOBOX_MENU_MAX_WIDTH_PX, COMBOBOX_MOBILE_QUERY, calculateComboboxMenuPosition } from "./lib/combobox.js";
|
|
6
|
+
import { comboboxLabelPadding, createComboboxCustomEntry, multipleComboboxLabel, splitOnComboboxSeparators, withSelectedComboboxOptions } from "./lib/combobox-values.js";
|
|
7
|
+
import { SPEC_RUNTIME_MODES, familyForModel, isSpecRuntimeMode, modeOptionFor, runtimeModeFromModel } from "./lib/runtime-family.js";
|
|
8
|
+
import { authoredRuntimeSpec, duplicateName, duplicateRecord, mergeRuntimeSpec, newPresetRecord, newProfileRecord, nextNewName, permissionTarget, presetForRef, presetsOf, referencedBy, reorderProfilePresets, selectionAfterDelete, uniqueName } from "./lib/runtime-profile-model.js";
|
|
9
|
+
import { HINT_FIELDS, MATCH_FIELDS, MATCH_FIELD_OPTIONS, PATTERN_FIELDS, STRATEGY_PRESETS, activeMatchFields, addCondition, applyStrategyPreset, conditionText, isHintField, matchingTools, patternValues, patternsText, removeCondition, replaceMatchField, strategyPreset, toolFieldSuggestions, updateCondition, updatePatternCondition } from "./lib/permission-strategies.js";
|
|
5
10
|
import { PATH_SEPARATOR, buildPathTree, foldersFirst, isPathTreeFolder, splitPath } from "./lib/path-tree.js";
|
|
6
11
|
import { CLICKY_COLUMN_FORMAT_OPTIONS, CLICKY_COLUMN_UNIT_OPTIONS, formatBytes, formatBytesPerSecond, formatDuration, formatShort, formatUnit } from "./lib/format.js";
|
|
7
12
|
import { useOptionalTheme, useResolvedTheme, useTheme } from "./hooks/use-theme.js";
|
|
@@ -631,6 +636,9 @@ export {
|
|
|
631
636
|
CLICKY_COLUMN_FORMAT_OPTIONS,
|
|
632
637
|
CLICKY_COLUMN_UNIT_OPTIONS,
|
|
633
638
|
CLICKY_FORMAT_OPTIONS,
|
|
639
|
+
COMBOBOX_MENU_MAX_HEIGHT_PX,
|
|
640
|
+
COMBOBOX_MENU_MAX_WIDTH_PX,
|
|
641
|
+
COMBOBOX_MOBILE_QUERY,
|
|
634
642
|
CONNECTION_LOG_LEVELS,
|
|
635
643
|
COUNTRY_OPTIONS,
|
|
636
644
|
CacheAdapterRegistry,
|
|
@@ -719,6 +727,7 @@ export {
|
|
|
719
727
|
GitDiffPanel,
|
|
720
728
|
GitFileList,
|
|
721
729
|
GroupedComments,
|
|
730
|
+
HINT_FIELDS,
|
|
722
731
|
HarPanel,
|
|
723
732
|
HoverCard,
|
|
724
733
|
Icon,
|
|
@@ -749,6 +758,8 @@ export {
|
|
|
749
758
|
MARKDOWN_EDITOR_PREVIEW_FORMATS,
|
|
750
759
|
MARKDOWN_SYNTAX_DOCUMENT,
|
|
751
760
|
MARKDOWN_SYNTAX_SECTIONS,
|
|
761
|
+
MATCH_FIELDS,
|
|
762
|
+
MATCH_FIELD_OPTIONS,
|
|
752
763
|
MAX_INLINE_SELECTION_ACTIONS,
|
|
753
764
|
Markdown,
|
|
754
765
|
MarkdownEditor,
|
|
@@ -769,6 +780,7 @@ export {
|
|
|
769
780
|
OperationResultView,
|
|
770
781
|
OperationsApiClientError,
|
|
771
782
|
PATH_SEPARATOR,
|
|
783
|
+
PATTERN_FIELDS,
|
|
772
784
|
Panel,
|
|
773
785
|
PrettyStackTrace,
|
|
774
786
|
ProgressBar,
|
|
@@ -783,8 +795,10 @@ export {
|
|
|
783
795
|
RangeSlider,
|
|
784
796
|
RouterProvider,
|
|
785
797
|
SIZE_TOKENS,
|
|
798
|
+
SPEC_RUNTIME_MODES,
|
|
786
799
|
STATUS_LABELS,
|
|
787
800
|
STATUS_TOKEN_GROUPS,
|
|
801
|
+
STRATEGY_PRESETS,
|
|
788
802
|
SchemaActionForm,
|
|
789
803
|
SchemaViewer as SchemaBrowser,
|
|
790
804
|
SchemaFieldMetaPanel,
|
|
@@ -1464,6 +1478,8 @@ export {
|
|
|
1464
1478
|
WorkloadCard,
|
|
1465
1479
|
WorkloadPicker,
|
|
1466
1480
|
Workspace,
|
|
1481
|
+
activeMatchFields,
|
|
1482
|
+
addCondition,
|
|
1467
1483
|
aggregateStatusCounts,
|
|
1468
1484
|
allGroupsTerminal,
|
|
1469
1485
|
annotateRoutePaths,
|
|
@@ -1474,9 +1490,11 @@ export {
|
|
|
1474
1490
|
applyFixtureFrontmatterRaw,
|
|
1475
1491
|
applyFixtureFrontmatterState,
|
|
1476
1492
|
applyPostExtensions,
|
|
1493
|
+
applyStrategyPreset,
|
|
1477
1494
|
assertCalloutValue,
|
|
1478
1495
|
assignAxes,
|
|
1479
1496
|
authorDisplayName,
|
|
1497
|
+
authoredRuntimeSpec,
|
|
1480
1498
|
badgeVariants,
|
|
1481
1499
|
bucketTasks,
|
|
1482
1500
|
buildCommandHref,
|
|
@@ -1491,6 +1509,7 @@ export {
|
|
|
1491
1509
|
buildThreadListHandlers,
|
|
1492
1510
|
buttonVariants,
|
|
1493
1511
|
cacheQueryKeys,
|
|
1512
|
+
calculateComboboxMenuPosition,
|
|
1494
1513
|
calloutVariantStyles,
|
|
1495
1514
|
changeIconAliases,
|
|
1496
1515
|
chooseTimestampFormat,
|
|
@@ -1500,9 +1519,11 @@ export {
|
|
|
1500
1519
|
cn,
|
|
1501
1520
|
collapseSingleChildChains,
|
|
1502
1521
|
collectFrameworks,
|
|
1522
|
+
comboboxLabelPadding,
|
|
1503
1523
|
commentCountForPrefix,
|
|
1504
1524
|
compactStackPath,
|
|
1505
1525
|
computeLineDiff,
|
|
1526
|
+
conditionText,
|
|
1506
1527
|
contextItemFromEntityRow,
|
|
1507
1528
|
copyText,
|
|
1508
1529
|
countGoroutinesByState,
|
|
@@ -1513,6 +1534,7 @@ export {
|
|
|
1513
1534
|
createCacheClient,
|
|
1514
1535
|
createCacheRegistry,
|
|
1515
1536
|
createChecklistMarkdown,
|
|
1537
|
+
createComboboxCustomEntry,
|
|
1516
1538
|
createFenceMarkdown,
|
|
1517
1539
|
createLazyJSONPathTree,
|
|
1518
1540
|
createOperationsApiClient,
|
|
@@ -1531,6 +1553,8 @@ export {
|
|
|
1531
1553
|
detectDumpFormat,
|
|
1532
1554
|
dottedAnchorResolver,
|
|
1533
1555
|
duplicateIndex,
|
|
1556
|
+
duplicateName,
|
|
1557
|
+
duplicateRecord,
|
|
1534
1558
|
effectiveProperties,
|
|
1535
1559
|
emptyCommentFilters,
|
|
1536
1560
|
emptyLogTailBuffer,
|
|
@@ -1539,6 +1563,7 @@ export {
|
|
|
1539
1563
|
encodeTailParams,
|
|
1540
1564
|
entityContextItemID,
|
|
1541
1565
|
exactAnchorResolver,
|
|
1566
|
+
familyForModel,
|
|
1542
1567
|
filterOperationsByDomain,
|
|
1543
1568
|
filterStateToRecord,
|
|
1544
1569
|
filterTests,
|
|
@@ -1591,6 +1616,7 @@ export {
|
|
|
1591
1616
|
isCountryCode,
|
|
1592
1617
|
isFailedOrWarn,
|
|
1593
1618
|
isGroupCollapsedByDefault,
|
|
1619
|
+
isHintField,
|
|
1594
1620
|
isLeaf,
|
|
1595
1621
|
isNearTop,
|
|
1596
1622
|
isOpenStringMap,
|
|
@@ -1599,6 +1625,7 @@ export {
|
|
|
1599
1625
|
isPlainObject,
|
|
1600
1626
|
isPositionalParam,
|
|
1601
1627
|
isRuntimeFrame,
|
|
1628
|
+
isSpecRuntimeMode,
|
|
1602
1629
|
isTerminalSessionState,
|
|
1603
1630
|
isTerminalStatus,
|
|
1604
1631
|
isTourFinished,
|
|
@@ -1614,12 +1641,19 @@ export {
|
|
|
1614
1641
|
matchMentionsInBody,
|
|
1615
1642
|
matchesFilterState,
|
|
1616
1643
|
matchesIf,
|
|
1644
|
+
matchingTools,
|
|
1617
1645
|
memoryTourStorage,
|
|
1646
|
+
mergeRuntimeSpec,
|
|
1618
1647
|
mergeSeries,
|
|
1619
1648
|
mockMarkdownPreview,
|
|
1649
|
+
modeOptionFor,
|
|
1620
1650
|
modeToFormat,
|
|
1621
1651
|
moveItem,
|
|
1652
|
+
multipleComboboxLabel,
|
|
1653
|
+
newPresetRecord,
|
|
1654
|
+
newProfileRecord,
|
|
1622
1655
|
nextChecklistStatus,
|
|
1656
|
+
nextNewName,
|
|
1623
1657
|
nextTriState,
|
|
1624
1658
|
normalizeErrorDiagnostics,
|
|
1625
1659
|
normalizeLogsTableRows,
|
|
@@ -1648,17 +1682,26 @@ export {
|
|
|
1648
1682
|
parseUnitAwareValue,
|
|
1649
1683
|
parseWorkloadKey,
|
|
1650
1684
|
pathParamNames,
|
|
1685
|
+
patternValues,
|
|
1686
|
+
patternsText,
|
|
1687
|
+
permissionTarget,
|
|
1651
1688
|
preferredEndpointPort,
|
|
1652
1689
|
prefixAdapter,
|
|
1690
|
+
presetForRef,
|
|
1691
|
+
presetsOf,
|
|
1653
1692
|
processLabel,
|
|
1654
1693
|
processStateColor,
|
|
1655
1694
|
processStateIcon,
|
|
1656
1695
|
pruneNullNodes,
|
|
1657
1696
|
readPreferences,
|
|
1658
1697
|
recordToFilterState,
|
|
1698
|
+
referencedBy,
|
|
1659
1699
|
registerDebugConsole,
|
|
1660
1700
|
rehydrateRefs,
|
|
1701
|
+
removeCondition,
|
|
1661
1702
|
removeIndex,
|
|
1703
|
+
reorderProfilePresets,
|
|
1704
|
+
replaceMatchField,
|
|
1662
1705
|
resolveBreakdown,
|
|
1663
1706
|
resolveControl,
|
|
1664
1707
|
resolveFacetOption,
|
|
@@ -1669,10 +1712,12 @@ export {
|
|
|
1669
1712
|
resolveSize,
|
|
1670
1713
|
resolveStatusConfig,
|
|
1671
1714
|
revealDebugConsole,
|
|
1715
|
+
runtimeModeFromModel,
|
|
1672
1716
|
schemaKeys,
|
|
1673
1717
|
segment,
|
|
1674
1718
|
selectAnchorThreads,
|
|
1675
1719
|
selectUnresolvedThreads,
|
|
1720
|
+
selectionAfterDelete,
|
|
1676
1721
|
serializeEndpointValue,
|
|
1677
1722
|
serializeMultiFilterValue,
|
|
1678
1723
|
serializeSecretRef,
|
|
@@ -1690,12 +1735,14 @@ export {
|
|
|
1690
1735
|
slugify,
|
|
1691
1736
|
sortReplies,
|
|
1692
1737
|
splitCommaValues,
|
|
1738
|
+
splitOnComboboxSeparators,
|
|
1693
1739
|
splitPath,
|
|
1694
1740
|
splitSelectionActions,
|
|
1695
1741
|
splitTagToken,
|
|
1696
1742
|
statusIconFor,
|
|
1697
1743
|
statusToneFor,
|
|
1698
1744
|
stopLogSession,
|
|
1745
|
+
strategyPreset,
|
|
1699
1746
|
strictAnchorResolver,
|
|
1700
1747
|
stringifyFixtureYaml,
|
|
1701
1748
|
submitValue,
|
|
@@ -1717,9 +1764,13 @@ export {
|
|
|
1717
1764
|
templateValuePre,
|
|
1718
1765
|
testStatus,
|
|
1719
1766
|
toneToBadgeTone,
|
|
1767
|
+
toolFieldSuggestions,
|
|
1720
1768
|
totalDuration,
|
|
1721
1769
|
truncatePlain,
|
|
1770
|
+
uniqueName,
|
|
1771
|
+
updateCondition,
|
|
1722
1772
|
updateFilterSelection,
|
|
1773
|
+
updatePatternCondition,
|
|
1723
1774
|
useBrowserRouter,
|
|
1724
1775
|
useClickyExport,
|
|
1725
1776
|
useCommentAnchorActionsOptional,
|
|
@@ -1760,6 +1811,7 @@ export {
|
|
|
1760
1811
|
useTourLayer,
|
|
1761
1812
|
visibleConnectionLogEvents,
|
|
1762
1813
|
withBasePath,
|
|
1814
|
+
withSelectedComboboxOptions,
|
|
1763
1815
|
workloadKey,
|
|
1764
1816
|
workloadKindLabel,
|
|
1765
1817
|
workloadStatusLabel,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const toolPolicy = require("../data/chat/tool-policy.cjs");
|
|
4
|
+
const PATTERN_FIELDS = [
|
|
5
|
+
"name",
|
|
6
|
+
"group",
|
|
7
|
+
"parent",
|
|
8
|
+
"entity",
|
|
9
|
+
"action",
|
|
10
|
+
"verb",
|
|
11
|
+
"method",
|
|
12
|
+
"scope"
|
|
13
|
+
];
|
|
14
|
+
const HINT_FIELDS = ["readOnly", "destructive", "idempotent"];
|
|
15
|
+
const MATCH_FIELDS = [...PATTERN_FIELDS, ...HINT_FIELDS];
|
|
16
|
+
const STRATEGY_PRESETS = [
|
|
17
|
+
{
|
|
18
|
+
value: "all",
|
|
19
|
+
label: "All tools",
|
|
20
|
+
description: "Match every tool in the catalog."
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
value: "read-only",
|
|
24
|
+
label: "Read-only tools",
|
|
25
|
+
description: "Match tools explicitly marked read-only."
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
value: "destructive",
|
|
29
|
+
label: "Destructive tools",
|
|
30
|
+
description: "Match tools explicitly marked destructive."
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
value: "idempotent",
|
|
34
|
+
label: "Idempotent tools",
|
|
35
|
+
description: "Match tools safe to repeat."
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
value: "custom",
|
|
39
|
+
label: "Custom conditions",
|
|
40
|
+
description: "Combine tool metadata and safety annotations."
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
const MATCH_FIELD_OPTIONS = [
|
|
44
|
+
{ value: "name", label: "Tool name" },
|
|
45
|
+
{ value: "group", label: "Group" },
|
|
46
|
+
{ value: "parent", label: "Parent" },
|
|
47
|
+
{ value: "entity", label: "Entity" },
|
|
48
|
+
{ value: "action", label: "Action" },
|
|
49
|
+
{ value: "verb", label: "Verb" },
|
|
50
|
+
{ value: "method", label: "HTTP method" },
|
|
51
|
+
{ value: "scope", label: "Scope" },
|
|
52
|
+
{ value: "readOnly", label: "Read only" },
|
|
53
|
+
{ value: "destructive", label: "Destructive" },
|
|
54
|
+
{ value: "idempotent", label: "Idempotent" }
|
|
55
|
+
];
|
|
56
|
+
function strategyPreset(rule) {
|
|
57
|
+
const fields = activeMatchFields(rule);
|
|
58
|
+
if (fields.length !== 1) return "custom";
|
|
59
|
+
if (fields[0] === "name" && patternsText(rule.name) === "*") return "all";
|
|
60
|
+
if (fields[0] === "readOnly" && rule.readOnly === true) return "read-only";
|
|
61
|
+
if (fields[0] === "destructive" && rule.destructive === true) {
|
|
62
|
+
return "destructive";
|
|
63
|
+
}
|
|
64
|
+
if (fields[0] === "idempotent" && rule.idempotent === true) {
|
|
65
|
+
return "idempotent";
|
|
66
|
+
}
|
|
67
|
+
return "custom";
|
|
68
|
+
}
|
|
69
|
+
function applyStrategyPreset(rule, preset) {
|
|
70
|
+
if (preset === "all") return { name: "*", policy: rule.policy };
|
|
71
|
+
if (preset === "read-only") return { readOnly: true, policy: rule.policy };
|
|
72
|
+
if (preset === "destructive")
|
|
73
|
+
return { destructive: true, policy: rule.policy };
|
|
74
|
+
return { idempotent: true, policy: rule.policy };
|
|
75
|
+
}
|
|
76
|
+
function activeMatchFields(rule) {
|
|
77
|
+
return MATCH_FIELDS.filter((field) => rule[field] !== void 0);
|
|
78
|
+
}
|
|
79
|
+
function patternsText(value) {
|
|
80
|
+
return typeof value === "string" ? value : (value ?? []).join(", ");
|
|
81
|
+
}
|
|
82
|
+
function patternValues(value) {
|
|
83
|
+
return typeof value === "string" ? value ? [value] : [] : value ?? [];
|
|
84
|
+
}
|
|
85
|
+
function updatePatternCondition({
|
|
86
|
+
rule,
|
|
87
|
+
field,
|
|
88
|
+
value
|
|
89
|
+
}) {
|
|
90
|
+
return { ...rule, [field]: value };
|
|
91
|
+
}
|
|
92
|
+
function conditionText(rule, field) {
|
|
93
|
+
if (isHintField(field)) return String(rule[field]);
|
|
94
|
+
return patternsText(rule[field]);
|
|
95
|
+
}
|
|
96
|
+
function replaceMatchField(rule, current, next) {
|
|
97
|
+
if (current === next) return rule;
|
|
98
|
+
const match = { ...rule };
|
|
99
|
+
const previous = match[current];
|
|
100
|
+
delete match[current];
|
|
101
|
+
match[next] = isHintField(next) ? typeof previous === "boolean" ? previous : true : typeof previous === "string" || Array.isArray(previous) ? previous : "*";
|
|
102
|
+
return match;
|
|
103
|
+
}
|
|
104
|
+
function updateCondition(rule, field, value) {
|
|
105
|
+
if (isHintField(field)) return { ...rule, [field]: value === "true" };
|
|
106
|
+
const patterns = value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
107
|
+
return {
|
|
108
|
+
...rule,
|
|
109
|
+
[field]: patterns.length <= 1 ? patterns[0] ?? "" : patterns
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function removeCondition(rule, field) {
|
|
113
|
+
const next = { ...rule };
|
|
114
|
+
delete next[field];
|
|
115
|
+
if (activeMatchFields(next).length === 0) next.name = "*";
|
|
116
|
+
return next;
|
|
117
|
+
}
|
|
118
|
+
function addCondition(rule, field) {
|
|
119
|
+
if (rule[field] !== void 0) return rule;
|
|
120
|
+
return { ...rule, [field]: isHintField(field) ? true : "*" };
|
|
121
|
+
}
|
|
122
|
+
function isHintField(field) {
|
|
123
|
+
return HINT_FIELDS.includes(field);
|
|
124
|
+
}
|
|
125
|
+
function matchingTools(rule, tools) {
|
|
126
|
+
return tools.filter((tool) => toolPolicy.matchesTool(rule, tool));
|
|
127
|
+
}
|
|
128
|
+
function toolFieldSuggestions(tools, field) {
|
|
129
|
+
const values = /* @__PURE__ */ new Set();
|
|
130
|
+
for (const tool of tools) {
|
|
131
|
+
const value = tool[field === "name" ? "name" : field];
|
|
132
|
+
if (typeof value === "string" && value.trim()) values.add(value);
|
|
133
|
+
}
|
|
134
|
+
return Array.from(values).sort((left, right) => left.localeCompare(right));
|
|
135
|
+
}
|
|
136
|
+
exports.HINT_FIELDS = HINT_FIELDS;
|
|
137
|
+
exports.MATCH_FIELDS = MATCH_FIELDS;
|
|
138
|
+
exports.MATCH_FIELD_OPTIONS = MATCH_FIELD_OPTIONS;
|
|
139
|
+
exports.PATTERN_FIELDS = PATTERN_FIELDS;
|
|
140
|
+
exports.STRATEGY_PRESETS = STRATEGY_PRESETS;
|
|
141
|
+
exports.activeMatchFields = activeMatchFields;
|
|
142
|
+
exports.addCondition = addCondition;
|
|
143
|
+
exports.applyStrategyPreset = applyStrategyPreset;
|
|
144
|
+
exports.conditionText = conditionText;
|
|
145
|
+
exports.isHintField = isHintField;
|
|
146
|
+
exports.matchingTools = matchingTools;
|
|
147
|
+
exports.patternValues = patternValues;
|
|
148
|
+
exports.patternsText = patternsText;
|
|
149
|
+
exports.removeCondition = removeCondition;
|
|
150
|
+
exports.replaceMatchField = replaceMatchField;
|
|
151
|
+
exports.strategyPreset = strategyPreset;
|
|
152
|
+
exports.toolFieldSuggestions = toolFieldSuggestions;
|
|
153
|
+
exports.updateCondition = updateCondition;
|
|
154
|
+
exports.updatePatternCondition = updatePatternCondition;
|
|
155
|
+
//# sourceMappingURL=permission-strategies.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-strategies.cjs","sources":["../../src/lib/permission-strategies.ts"],"sourcesContent":["import {\n matchesTool,\n type MatchPatterns,\n type PermissionRule,\n} from \"../data/chat/tool-policy\";\nimport type { ToolMeta } from \"../data/chat/types\";\n\nexport const PATTERN_FIELDS = [\n \"name\",\n \"group\",\n \"parent\",\n \"entity\",\n \"action\",\n \"verb\",\n \"method\",\n \"scope\",\n] as const;\nexport const HINT_FIELDS = [\"readOnly\", \"destructive\", \"idempotent\"] as const;\nexport const MATCH_FIELDS = [...PATTERN_FIELDS, ...HINT_FIELDS] as const;\n\nexport type MatchField = (typeof MATCH_FIELDS)[number];\nexport type StrategyPreset =\n | \"all\"\n | \"read-only\"\n | \"destructive\"\n | \"idempotent\"\n | \"custom\";\n\nexport const STRATEGY_PRESETS: Array<{\n value: StrategyPreset;\n label: string;\n description: string;\n}> = [\n {\n value: \"all\",\n label: \"All tools\",\n description: \"Match every tool in the catalog.\",\n },\n {\n value: \"read-only\",\n label: \"Read-only tools\",\n description: \"Match tools explicitly marked read-only.\",\n },\n {\n value: \"destructive\",\n label: \"Destructive tools\",\n description: \"Match tools explicitly marked destructive.\",\n },\n {\n value: \"idempotent\",\n label: \"Idempotent tools\",\n description: \"Match tools safe to repeat.\",\n },\n {\n value: \"custom\",\n label: \"Custom conditions\",\n description: \"Combine tool metadata and safety annotations.\",\n },\n];\n\nexport const MATCH_FIELD_OPTIONS: Array<{ value: MatchField; label: string }> =\n [\n { value: \"name\", label: \"Tool name\" },\n { value: \"group\", label: \"Group\" },\n { value: \"parent\", label: \"Parent\" },\n { value: \"entity\", label: \"Entity\" },\n { value: \"action\", label: \"Action\" },\n { value: \"verb\", label: \"Verb\" },\n { value: \"method\", label: \"HTTP method\" },\n { value: \"scope\", label: \"Scope\" },\n { value: \"readOnly\", label: \"Read only\" },\n { value: \"destructive\", label: \"Destructive\" },\n { value: \"idempotent\", label: \"Idempotent\" },\n ];\n\nexport function strategyPreset(rule: PermissionRule): StrategyPreset {\n const fields = activeMatchFields(rule);\n if (fields.length !== 1) return \"custom\";\n if (fields[0] === \"name\" && patternsText(rule.name) === \"*\") return \"all\";\n if (fields[0] === \"readOnly\" && rule.readOnly === true) return \"read-only\";\n if (fields[0] === \"destructive\" && rule.destructive === true) {\n return \"destructive\";\n }\n if (fields[0] === \"idempotent\" && rule.idempotent === true) {\n return \"idempotent\";\n }\n return \"custom\";\n}\n\nexport function applyStrategyPreset(\n rule: PermissionRule,\n preset: Exclude<StrategyPreset, \"custom\">,\n): PermissionRule {\n if (preset === \"all\") return { name: \"*\", policy: rule.policy };\n if (preset === \"read-only\") return { readOnly: true, policy: rule.policy };\n if (preset === \"destructive\")\n return { destructive: true, policy: rule.policy };\n return { idempotent: true, policy: rule.policy };\n}\n\nexport function activeMatchFields(rule: PermissionRule): MatchField[] {\n return MATCH_FIELDS.filter((field) => rule[field] !== undefined);\n}\n\nexport function patternsText(value: MatchPatterns | undefined): string {\n return typeof value === \"string\" ? value : (value ?? []).join(\", \");\n}\n\nexport function patternValues(value: MatchPatterns | undefined): string[] {\n return typeof value === \"string\" ? (value ? [value] : []) : (value ?? []);\n}\n\nexport function updatePatternCondition({\n rule,\n field,\n value,\n}: {\n rule: PermissionRule;\n field: (typeof PATTERN_FIELDS)[number];\n value: MatchPatterns;\n}): PermissionRule {\n return { ...rule, [field]: value };\n}\n\nexport function conditionText(rule: PermissionRule, field: MatchField): string {\n if (isHintField(field)) return String(rule[field]);\n return patternsText(rule[field]);\n}\n\nexport function replaceMatchField(\n rule: PermissionRule,\n current: MatchField,\n next: MatchField,\n): PermissionRule {\n if (current === next) return rule;\n const match = { ...rule } as Record<string, unknown>;\n const previous = match[current];\n delete match[current];\n match[next] = isHintField(next)\n ? typeof previous === \"boolean\"\n ? previous\n : true\n : typeof previous === \"string\" || Array.isArray(previous)\n ? previous\n : \"*\";\n return match as PermissionRule;\n}\n\nexport function updateCondition(\n rule: PermissionRule,\n field: MatchField,\n value: string,\n): PermissionRule {\n if (isHintField(field)) return { ...rule, [field]: value === \"true\" };\n const patterns = value\n .split(\",\")\n .map((item) => item.trim())\n .filter(Boolean);\n return {\n ...rule,\n [field]: patterns.length <= 1 ? (patterns[0] ?? \"\") : patterns,\n };\n}\n\nexport function removeCondition(\n rule: PermissionRule,\n field: MatchField,\n): PermissionRule {\n const next = { ...rule } as Record<string, unknown>;\n delete next[field];\n if (activeMatchFields(next as PermissionRule).length === 0) next.name = \"*\";\n return next as PermissionRule;\n}\n\nexport function addCondition(\n rule: PermissionRule,\n field: MatchField,\n): PermissionRule {\n if (rule[field] !== undefined) return rule;\n return { ...rule, [field]: isHintField(field) ? true : \"*\" };\n}\n\nexport function isHintField(\n field: MatchField,\n): field is (typeof HINT_FIELDS)[number] {\n return (HINT_FIELDS as readonly MatchField[]).includes(field);\n}\n\nexport function matchingTools(rule: PermissionRule, tools: ToolMeta[]) {\n return tools.filter((tool) => matchesTool(rule, tool));\n}\n\nexport function toolFieldSuggestions(\n tools: ToolMeta[],\n field: Exclude<MatchField, (typeof HINT_FIELDS)[number]>,\n) {\n const values = new Set<string>();\n for (const tool of tools) {\n const value = tool[field === \"name\" ? \"name\" : field];\n if (typeof value === \"string\" && value.trim()) values.add(value);\n }\n return Array.from(values).sort((left, right) => left.localeCompare(right));\n}\n"],"names":["matches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