@camstack/addon-admin-ui 1.2.506 → 1.2.508

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 (123) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/assets/{AddonAssetIcon-yupvha_q.js → AddonAssetIcon-BI2lRuoS.js} +1 -1
  3. package/dist/assets/{Addons-DEhaHLOi.js → Addons-TpOqhnVb.js} +1 -1
  4. package/dist/assets/{AdminPage-DMHrS9HJ.js → AdminPage-CoK_jJGS.js} +1 -1
  5. package/dist/assets/{AdminSectionedPage-DGqPqOoU.js → AdminSectionedPage-DSGzoNMN.js} +1 -1
  6. package/dist/assets/AiProfiles-BAjucqPT.js +3 -0
  7. package/dist/assets/{BrokerEditorDialog-CheeYfYU.js → BrokerEditorDialog-B89FOzdO.js} +1 -1
  8. package/dist/assets/Build-CFHVjKTp.js +40 -0
  9. package/dist/assets/{Calendars-ceEemqRa.js → Calendars-B_klJh9f.js} +1 -1
  10. package/dist/assets/{Cluster-hqHOAQXg.js → Cluster-D4aPF2Mc.js} +1 -1
  11. package/dist/assets/{CompositionBlockEditor-_O9DNoBW.js → CompositionBlockEditor--2eeDknC.js} +1 -1
  12. package/dist/assets/{CompositionEditorPage-CGNkRlyK.js → CompositionEditorPage-CdQhA7kv.js} +1 -1
  13. package/dist/assets/{Data-5tz0F7PG.js → Data-CZwL53Hx.js} +1 -1
  14. package/dist/assets/DeviceDetail-SKPy4rTC.js +2 -0
  15. package/dist/assets/{DeviceDoActionFields-DxYzh731.js → DeviceDoActionFields-B33Gsegz.js} +1 -1
  16. package/dist/assets/{Devices-BlAOG0xt.js → Devices-Rkjf5xy8.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-o6I5hVgx.js → EmbedPlayerPage-CIhSpElZ.js} +1 -1
  18. package/dist/assets/HelperWizard-CbDck6HU.js +2 -0
  19. package/dist/assets/{History-BuRME6da.js → History-DDDOyHZ5.js} +1 -1
  20. package/dist/assets/{Identity-BcfkuFx9.js → Identity-r8ch-lOQ.js} +1 -1
  21. package/dist/assets/{IntegrationDetail-C8Lw0bsZ.js → IntegrationDetail-DtLleJdm.js} +1 -1
  22. package/dist/assets/{IntegrationHub-DBbbBmLY.js → IntegrationHub-CySfaOMq.js} +1 -1
  23. package/dist/assets/{Integrations-DSd8p3br.js → Integrations-DfhZYAU6.js} +1 -1
  24. package/dist/assets/{Integrations-y5Nc_JAx.js → Integrations-DgKqVXik.js} +1 -1
  25. package/dist/assets/{Library-nVzatksw.js → Library-DS1N1jEN.js} +1 -1
  26. package/dist/assets/{Locations-BK6kCKHY.js → Locations-DeBnLLF-.js} +1 -1
  27. package/dist/assets/{Logs-D8PXiira.js → Logs-CHh39x1m.js} +1 -1
  28. package/dist/assets/{MaskShapeCanvas-DnJ8OyvO.js → MaskShapeCanvas-Bc_okYTu.js} +1 -1
  29. package/dist/assets/{MotionZonesSettings-BZ-C5Bpc.js → MotionZonesSettings-C-3oW42G.js} +1 -1
  30. package/dist/assets/{MyAccess-DGVkvAxD.js → MyAccess-C3LJW2D-.js} +1 -1
  31. package/dist/assets/{Network-DSQc_pqf.js → Network-DUpU_-CN.js} +1 -1
  32. package/dist/assets/{NodeAddonsSettingsPanel-CLAxe4U2.js → NodeAddonsSettingsPanel-DtuYEwYa.js} +1 -1
  33. package/dist/assets/{Notifications-DwoTLFJ3.js → Notifications-Co9i2XjT.js} +1 -1
  34. package/dist/assets/{Pipeline-CqlPPxWL.js → Pipeline-q5F5QN1u.js} +1 -1
  35. package/dist/assets/{PrivacyMaskSettings-CwqJt7F1.js → PrivacyMaskSettings-BOI5MbOP.js} +1 -1
  36. package/dist/assets/{Recordings-CD6opqPW.js → Recordings-Ce7zfDAZ.js} +1 -1
  37. package/dist/assets/{ScanNetworkModal-B3LgRM_M.js → ScanNetworkModal-B6Qw9qG5.js} +1 -1
  38. package/dist/assets/{SceneMonitorEditor-_eTUV0Nt.js → SceneMonitorEditor-BP10OuX_.js} +1 -1
  39. package/dist/assets/{SessionsList-_QUI2Xh7.js → SessionsList-LaUTUXTI.js} +1 -1
  40. package/dist/assets/{Showroom-CetOrzt6.js → Showroom-Dq8K9w28.js} +1 -1
  41. package/dist/assets/{System-CDF2Viiw.js → System-BXnin0ZR.js} +1 -1
  42. package/dist/assets/{Terminal-8GV3vS9c.js → Terminal-B-yYnFAl.js} +1 -1
  43. package/dist/assets/{Viewer-eewPaOSJ.js → Viewer-CDe6m77J.js} +1 -1
  44. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-WhCBiEKH.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DmDesblz.js} +1 -1
  45. package/dist/assets/{addon-icons-context-Cx238XZl.js → addon-icons-context-C1MOrZ0k.js} +1 -1
  46. package/dist/assets/{archive-8x-tu1s7.js → archive-DfRpKbmd.js} +1 -1
  47. package/dist/assets/{assignment-candidates-C2zDE5Xk.js → assignment-candidates-XVSaMNWE.js} +1 -1
  48. package/dist/assets/{authed-media-tj-FKp7U.js → authed-media-acRzkBVq.js} +1 -1
  49. package/dist/assets/{bell-off-DMfxbtq4.js → bell-off-BDtTHYf7.js} +1 -1
  50. package/dist/assets/{board-model-CXq_5fWu.js → board-model-D3K1Oad0.js} +1 -1
  51. package/dist/assets/{boxes-BWAGJm1O.js → boxes-Dg0SsuKi.js} +1 -1
  52. package/dist/assets/circle-slash-vr6zT4n3.js +1 -0
  53. package/dist/assets/client-BRyxs6lT.js +674 -0
  54. package/dist/assets/{cloud-upload-CKs-pNsZ.js → cloud-upload-D5gzNxtI.js} +1 -1
  55. package/dist/assets/crop-CGtgnf44.js +1 -0
  56. package/dist/assets/{device-integration-icon-DuQ8oBNS.js → device-integration-icon-DMlXMoep.js} +1 -1
  57. package/dist/assets/device-picker-model-D0GfTZgv.js +1 -0
  58. package/dist/assets/dist-CPWJTJFO.js +674 -0
  59. package/dist/assets/{dist-D1lJ0amf.js → dist-DU6BvfF_.js} +1 -1
  60. package/dist/assets/{eraser-Dboyt7DT.js → eraser-DatAKBqr.js} +1 -1
  61. package/dist/assets/{format-B5-jpJTT.js → format-C5OjHr2B.js} +1 -1
  62. package/dist/assets/{hard-drive-download-9FzNEeA3.js → hard-drive-download-BMn4pcLF.js} +1 -1
  63. package/dist/assets/{hostInit-N_3XvXlw.js → hostInit-SgUIaQcR.js} +1 -1
  64. package/dist/assets/i18n-DH8y-VcL.js +1 -0
  65. package/dist/assets/{icons-BHZk-0vK.js → icons-CfQXaR2o.js} +1 -1
  66. package/dist/assets/{index-BCi8sk-d.js → index-BCZXKpVN.js} +3 -3
  67. package/dist/assets/{key-DsZMsE3B.js → key-0qodB2RW.js} +1 -1
  68. package/dist/assets/{key-round-DP5HddQT.js → key-round-EDiKxWDb.js} +1 -1
  69. package/dist/assets/{layers-Ce8hM9RV.js → layers-BuqS0QUs.js} +1 -1
  70. package/dist/assets/{linked-devices-model-C9qgt7DW.js → linked-devices-model-EpVtXJ1y.js} +1 -1
  71. package/dist/assets/{list-ordered-Bok3LKqI.js → list-ordered-5xX0c-4M.js} +1 -1
  72. package/dist/assets/{location-owned-usage-DdnXC5X1.js → location-owned-usage-DYyj5DnK.js} +1 -1
  73. package/dist/assets/{log-in-Dy7V-B3B.js → log-in-DfGAqbts.js} +1 -1
  74. package/dist/assets/{memory-stick-B1MtzV7u.js → memory-stick-Cw-HmXQN.js} +1 -1
  75. package/dist/assets/{message-square-plus-B8tlaZRC.js → message-square-plus-Cimd4hIM.js} +1 -1
  76. package/dist/assets/{mf-entry-bootstrap-0-7a4052ce.js → mf-entry-bootstrap-0-f0aece97.js} +2 -2
  77. package/dist/assets/{mic-off-BoPPgEuI.js → mic-off-BaeJlMpU.js} +1 -1
  78. package/dist/assets/{monitor-off-NYPljllc.js → monitor-off-B5ZegpCN.js} +1 -1
  79. package/dist/assets/{monitor-smartphone-BjvCzSKA.js → monitor-smartphone-GrRvroYr.js} +1 -1
  80. package/dist/assets/mount-D0GfTZgv.js +1 -0
  81. package/dist/assets/{player-overlays-DkX009EX.js → player-overlays-CzZYPO2s.js} +1 -1
  82. package/dist/assets/{recycle-DGYdB0Wq.js → recycle-C0Za7XIk.js} +1 -1
  83. package/dist/assets/remoteEntry-BNJLevTL.js +1 -0
  84. package/dist/assets/{scan-eye-Ch-0lhIO.js → scan-eye-DBcVKkv9.js} +1 -1
  85. package/dist/assets/{scissors-B6VydNaF.js → scissors-ClBtIo8F.js} +1 -1
  86. package/dist/assets/{search-x-BdKhxUyE.js → search-x-vzCWLMzU.js} +1 -1
  87. package/dist/assets/{send-bQSpRVGI.js → send-C2xLiGxd.js} +1 -1
  88. package/dist/assets/{settings-2-D6b4Y6jH.js → settings-2-CE18osa2.js} +1 -1
  89. package/dist/assets/{sigma-DwkLhkfK.js → sigma-BzZ_sr1s.js} +1 -1
  90. package/dist/assets/{speaker-zhX4f3kb.js → speaker-DPhQgEkP.js} +1 -1
  91. package/dist/assets/src-DytYtgEw.js +67 -0
  92. package/dist/assets/{step-inspector-model-ot7c_tyh.js → step-inspector-model-CjRD_PYM.js} +1 -1
  93. package/dist/assets/{table-2-CkdRK3-h.js → table-2-Ca1maW_p.js} +1 -1
  94. package/dist/assets/{timer-reset-GRtPzP8x.js → timer-reset-DLwEAlTU.js} +1 -1
  95. package/dist/assets/{unlink--JN-bzY3.js → unlink-Bdb8-xwF.js} +1 -1
  96. package/dist/assets/{usb-DVsgUDG3.js → usb-DxqbvFPc.js} +1 -1
  97. package/dist/assets/{use-scenes-feed-Da_YBwU2.js → use-scenes-feed-YVkY4_qr.js} +1 -1
  98. package/dist/assets/{use-stationary-objects-BiyKUNTC.js → use-stationary-objects-FD4-OqJN.js} +1 -1
  99. package/dist/assets/useEventInvalidation-D0GfTZgv.js +1 -0
  100. package/dist/assets/{useNodeUrlSelection-BPwgVKpc.js → useNodeUrlSelection-D8YOlTNk.js} +1 -1
  101. package/dist/assets/user-round-D5DJkFym.js +1 -0
  102. package/dist/assets/{user-x-CpK7WtDd.js → user-x-BQ6msuOU.js} +1 -1
  103. package/dist/assets/{variable-CTjWqiYN.js → variable-mkIJuabT.js} +1 -1
  104. package/dist/assets/{video-DP_1jY7p.js → video-O02NyJP7.js} +1 -1
  105. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BUrWR9UZ.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CVBjsL5d.js} +2 -2
  106. package/dist/index.html +9 -9
  107. package/dist/server/addon.js +127 -6
  108. package/package.json +1 -1
  109. package/dist/assets/AiProfiles-RXUasr_c.js +0 -3
  110. package/dist/assets/Build-Caonc3pq.js +0 -40
  111. package/dist/assets/DeviceDetail-Clwe2rvJ.js +0 -2
  112. package/dist/assets/HelperWizard-CJ-s_iG4.js +0 -2
  113. package/dist/assets/circle-slash-C5LGZ7Jt.js +0 -1
  114. package/dist/assets/client-DXl30Qia.js +0 -674
  115. package/dist/assets/crop-CKoE-7yI.js +0 -1
  116. package/dist/assets/device-picker-model-DEGEE_Ai.js +0 -1
  117. package/dist/assets/dist-pI3sPmA5.js +0 -674
  118. package/dist/assets/i18n-S-ozFyAm.js +0 -1
  119. package/dist/assets/mount-DEGEE_Ai.js +0 -1
  120. package/dist/assets/remoteEntry-B9p0yUOj.js +0 -1
  121. package/dist/assets/src-doqoedCm.js +0 -67
  122. package/dist/assets/useEventInvalidation-DEGEE_Ai.js +0 -1
  123. package/dist/assets/user-round-DkmA2RnU.js +0 -1
@@ -5448,7 +5448,7 @@ var ZodIssueCode = {
5448
5448
  var ZodFirstPartyTypeKind;
5449
5449
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5450
5450
  //#endregion
5451
- //#region ../types/dist/sleep-Crlmu_tO.mjs
5451
+ //#region ../types/dist/sleep-BAvUCi_2.mjs
5452
5452
  /**
5453
5453
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5454
5454
  * window to float samples (D455).
@@ -8600,6 +8600,7 @@ var CAP_NAMES = Object.freeze([
8600
8600
  "image-settings",
8601
8601
  "integrations",
8602
8602
  "intercom",
8603
+ "ir-transmitter",
8603
8604
  "keychain",
8604
8605
  "keychain-admin",
8605
8606
  "lawn-mower-control",
@@ -9847,6 +9848,11 @@ Object.freeze({
9847
9848
  "path": "batteryPower",
9848
9849
  "valueType": "number"
9849
9850
  },
9851
+ {
9852
+ "path": "powerSource",
9853
+ "valueType": "enum",
9854
+ "enumValues": ["mains", "battery"]
9855
+ },
9850
9856
  {
9851
9857
  "path": "desiccantLeftDays",
9852
9858
  "valueType": "number"
@@ -10430,7 +10436,7 @@ object({
10430
10436
  params: record(string(), union([string(), number()])).optional()
10431
10437
  });
10432
10438
  //#endregion
10433
- //#region ../types/dist/err-msg-DIorGYeC.mjs
10439
+ //#region ../types/dist/err-msg-BCdlR2Li.mjs
10434
10440
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
10435
10441
  DeviceType["Camera"] = "camera";
10436
10442
  DeviceType["Hub"] = "hub";
@@ -10776,10 +10782,13 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
10776
10782
  /** Fallback when the notifier service name doesn't match a known
10777
10783
  * pattern. */
10778
10784
  DeviceRole["GenericNotifier"] = "generic-notifier";
10785
+ /** Emits a pulse train (infrared or RF) on request — the `ir-transmitter`
10786
+ * cap. A `DeviceType.Generic` device. */
10787
+ DeviceRole["IrTransmitter"] = "ir-transmitter";
10779
10788
  return DeviceRole;
10780
10789
  }({});
10781
10790
  //#endregion
10782
- //#region ../types/dist/composition-DwA0uVW5.mjs
10791
+ //#region ../types/dist/composition-DpFv_J6D.mjs
10783
10792
  /**
10784
10793
  * The ffmpeg build every CamStack node downloads, per platform and arch.
10785
10794
  *
@@ -42977,6 +42986,17 @@ var LlmProfileSchema = object({
42977
42986
  * field in its editor only when its descriptor lists it in `profileFields`. */
42978
42987
  topK: number().int().positive().optional(),
42979
42988
  maxTokens: number().int().positive().optional(),
42989
+ /** How hard the model "thinks" before it answers. Omitted = the model's own
42990
+ * default. `off` matters for structured output: a thinking model can spend
42991
+ * the whole completion on reasoning and return an empty `content`. Carried
42992
+ * only by the wires that have it — a kind offers the field in its editor
42993
+ * only when its descriptor lists it in `profileFields`. */
42994
+ reasoningEffort: _enum([
42995
+ "off",
42996
+ "low",
42997
+ "medium",
42998
+ "high"
42999
+ ]).optional(),
42980
43000
  /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
42981
43001
  contextLength: number().int().positive().optional(),
42982
43002
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
@@ -43015,6 +43035,7 @@ var LlmProfileFieldSchema = _enum([
43015
43035
  "topP",
43016
43036
  "topK",
43017
43037
  "maxTokens",
43038
+ "reasoningEffort",
43018
43039
  "contextLength",
43019
43040
  "systemPrompt",
43020
43041
  "timeoutMs",
@@ -57335,6 +57356,56 @@ DeviceType.Button, method(object({ deviceId: number().int().nonnegative() }), _v
57335
57356
  auth: "protected"
57336
57357
  });
57337
57358
  /**
57359
+ * A pulse train in signed microseconds: mark (+) first, then space (-), strictly
57360
+ * alternating, no zeros, 2..1024 entries.
57361
+ */
57362
+ var IrTimingsSchema = array(number().int()).min(2).max(1024).superRefine((timings, ctx) => {
57363
+ timings.forEach((value, index) => {
57364
+ const expectMark = index % 2 === 0;
57365
+ if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
57366
+ code: "custom",
57367
+ message: `timing ${index} must be a non-zero ${expectMark ? "mark (positive)" : "space (negative)"}`,
57368
+ path: [index]
57369
+ });
57370
+ });
57371
+ });
57372
+ /** Per-command transmit options. Every key is optional; a transmitter applies what it can. */
57373
+ var TransmitSettingsSchema = object({
57374
+ carrierHz: number().int().positive().optional(),
57375
+ dutyCyclePercent: number().int().min(1).max(100).optional(),
57376
+ repeat: number().int().min(0).max(20).optional(),
57377
+ repeatDelayMs: number().int().min(0).optional()
57378
+ });
57379
+ /** The setting keys a transmitter may declare as settable (`getInfo.settable`). */
57380
+ var TransmitSettingKeySchema = _enum([
57381
+ "carrierHz",
57382
+ "dutyCyclePercent",
57383
+ "repeat",
57384
+ "repeatDelayMs"
57385
+ ]);
57386
+ var IrMediumSchema = _enum(["ir", "rf"]);
57387
+ var IrSendResultSchema = object({
57388
+ ok: literal(true),
57389
+ /** Settings the transmitter could not apply; the train was still sent. */
57390
+ ignoredSettings: array(string())
57391
+ });
57392
+ var IrTransmitterInfoSchema = object({
57393
+ media: array(IrMediumSchema),
57394
+ settable: array(TransmitSettingKeySchema),
57395
+ maxTimings: number().int().positive()
57396
+ });
57397
+ DeviceType.Generic, method(object({
57398
+ deviceId: number().int().nonnegative(),
57399
+ timings: IrTimingsSchema,
57400
+ settings: TransmitSettingsSchema.optional()
57401
+ }), IrSendResultSchema, {
57402
+ kind: "mutation",
57403
+ auth: "protected"
57404
+ }), method(object({ deviceId: number().int().nonnegative() }), IrTransmitterInfoSchema, {
57405
+ kind: "query",
57406
+ auth: "protected"
57407
+ });
57408
+ /**
57338
57409
  * `calendar-source` — collection cap exposing per-provider calendars and
57339
57410
  * their events. Every addon that contributes calendars (Home Assistant,
57340
57411
  * a future Google Calendar addon, …) registers a provider here. The hub
@@ -61437,9 +61508,14 @@ object({
61437
61508
  * (`device_class: problem`, on = low). True when the tank reports empty,
61438
61509
  * or, on a dual-hopper model, when EITHER hopper is empty. */
61439
61510
  lowFood: boolean(),
61440
- /** Battery charge 0..100 (%). Null on mains-powered models or when the
61441
- * device has no battery reading. */
61511
+ /** Battery charge 0..100 (%). On a feeder running on `mains` this is the
61512
+ * BACKUP battery's charge, not the power source. Null when the device has
61513
+ * no battery reading. */
61442
61514
  batteryPower: number().min(0).max(100).nullable().meta(readingMeta("percentage")),
61515
+ /** What the feeder is powered from right now: `mains` (plugged in, the
61516
+ * battery is only a backup) or `battery`. Null when the device does not
61517
+ * report it. */
61518
+ powerSource: _enum(["mains", "battery"]).nullable(),
61443
61519
  /**
61444
61520
  * Desiccant life remaining, stored in seconds (duration base, D944).
61445
61521
  * Providers convert from the days the feeder reports. Null when the
@@ -69715,6 +69791,20 @@ Object.freeze({
69715
69791
  access: "create",
69716
69792
  role: "viewer"
69717
69793
  },
69794
+ "irTransmitter.getInfo": {
69795
+ capName: "ir-transmitter",
69796
+ capScope: "device",
69797
+ addonId: null,
69798
+ access: "view",
69799
+ role: "viewer"
69800
+ },
69801
+ "irTransmitter.send": {
69802
+ capName: "ir-transmitter",
69803
+ capScope: "device",
69804
+ addonId: null,
69805
+ access: "create",
69806
+ role: "viewer"
69807
+ },
69718
69808
  "keychain.delete": {
69719
69809
  capName: "keychain",
69720
69810
  capScope: "system",
@@ -77338,6 +77428,11 @@ var ACTUATOR_CAP_VOCABULARY = {
77338
77428
  icon: "circle-dot"
77339
77429
  }]
77340
77430
  },
77431
+ "ir-transmitter": {
77432
+ scope: "device",
77433
+ noun: t("IR / RF transmitter", "Trasmettitore IR / RF"),
77434
+ notOperatorFacing: { send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it" }
77435
+ },
77341
77436
  control: {
77342
77437
  scope: "device",
77343
77438
  noun: t("Control", "Controllo"),
@@ -81057,6 +81152,16 @@ Object.freeze({
81057
81152
  form: "single",
81058
81153
  optional: false
81059
81154
  }],
81155
+ "irTransmitter.getInfo": [{
81156
+ name: "deviceId",
81157
+ form: "single",
81158
+ optional: false
81159
+ }],
81160
+ "irTransmitter.send": [{
81161
+ name: "deviceId",
81162
+ form: "single",
81163
+ optional: false
81164
+ }],
81060
81165
  "keychain.deleteDeviceScope": [{
81061
81166
  name: "deviceId",
81062
81167
  form: "single",
@@ -84090,6 +84195,22 @@ DEFAULT_NATIVE_LEASE_SETTINGS.admission;
84090
84195
  String.raw`(?<=^|["'(\s>,\[{])`;
84091
84196
  var MB = 1024 * 1024;
84092
84197
  1024 * MB, 3072 * MB;
84198
+ discriminatedUnion("kind", [object({
84199
+ kind: literal("raw"),
84200
+ timings: array(number().int()),
84201
+ settings: TransmitSettingsSchema.optional()
84202
+ }), object({
84203
+ kind: literal("pronto"),
84204
+ code: string()
84205
+ })]);
84206
+ object({
84207
+ manufacturer: string().optional(),
84208
+ supportedModels: array(string()).optional(),
84209
+ supportedController: string().optional(),
84210
+ commandsEncoding: string(),
84211
+ delay: number().nonnegative().optional(),
84212
+ commands: record(string(), unknown())
84213
+ });
84093
84214
  //#endregion
84094
84215
  //#region src/server/addon.ts
84095
84216
  var __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -84109,7 +84230,7 @@ var AdminUIAddon = class extends BaseAddon {
84109
84230
  capability: adminUiCapability,
84110
84231
  provider: {
84111
84232
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
84112
- getVersion: async () => ({ version: "1.2.506" })
84233
+ getVersion: async () => ({ version: "1.2.508" })
84113
84234
  }
84114
84235
  }];
84115
84236
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.506",
3
+ "version": "1.2.508",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -1,3 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,t as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as d,En as f,Fn as p,G as m,Ht as h,L as g,Li as _,Ni as v,Pn as y,Pr as b,Q as x,Ri as S,Vn as C,Xr as w,_n as T,ai as E,dt as D,fr as O,gt as ee,na as k,ni as A,rn as j,st as te,tn as M,vn as N}from"./player-overlays-DkX009EX.js";import{Hr as P,Vr as F,ro as I}from"./client-DXl30Qia.js";import{n as L,t as R}from"./send-bQSpRVGI.js";import{t as ne}from"./message-square-plus-B8tlaZRC.js";import{Cn as z,Do as B,Dr as V,Er as H,Fr as U,Hn as W,Or as G,Qn as re,Sn as ie,Tr as K,Wn as ae,Yr as q,_d as oe,bn as J,bt as se,dd as Y,ft as ce,gd as le,mt as ue,or as de,ri as X,rt as fe,xt as pe}from"./src-doqoedCm.js";import{t as Z}from"./i18n-S-ozFyAm.js";import{t as Q}from"./useTranslation-BJr-n0es.js";import"./mount-DEGEE_Ai.js";import{T as me,yr as he}from"./index-BCi8sk-d.js";import{t as ge}from"./AdminSectionedPage-DGqPqOoU.js";import{t as _e}from"./AdminPage-DMHrS9HJ.js";c();var ve=`__redacted__`,ye=[`llm`,`listProfiles`],be=[`llm`,`listProfileKinds`],xe=[`llm`,`getDefaults`],Se=[`llm`,`listRuntimeNodes`],Ce=[`llm`,`listModelCatalog`],we=[`llm`,`getUsage`],Te=[{purpose:`vision`,visionOnly:!0},{purpose:`text`,visionOnly:!1}],Ee=new Map([[`cloud`,E],[`plug`,y],[`cpu`,A],[`server`,T],[`sparkles`,j]]);function De(e){return Ee.get(e)??S}function Oe(e){return typeof e==`string`&&e.length>0?e:void 0}function ke(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:void 0}}function Ae(e){return e===!0}function je(e){let t=new Map;for(let n of e){let e=t.get(n.addonId)??[];e.push(n),t.set(n.addonId,e)}return[...t.entries()].map(([e,t])=>({addonId:e,kinds:t}))}var Me={deviceNotEligible:{key:`ai.appleNotEligible`,tone:`default`},appleIntelligenceNotEnabled:{key:`ai.appleIntelligenceOff`,tone:`warning`},modelNotReady:{key:`ai.appleModelNotReady`,tone:`warning`},osTooOld:{key:`ai.appleOsTooOld`,tone:`default`},helperMissing:{key:`ai.appleHelperMissing`,tone:`danger`},helperCrashed:{key:`ai.appleHelperCrashed`,tone:`danger`}};function Ne(e){let t=t=>({nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleUnknown`,labelDefault:Z.t(`ai.appleUnknown`),detail:t,tone:`default`});if(!e.reachable)return t(e.error??null);let n=e.apple;if(n===void 0)return t(null);switch(n.state){case`available`:return{nodeId:e.nodeId,selectable:!0,labelKey:`ai.appleAvailable`,labelDefault:Z.t(`ai.appleAvailable`),detail:Z.t(n.imageInput?`helpers.aiPage.appleDetailImages`:`helpers.aiPage.appleDetailText`,{version:n.osVersion}),tone:`success`};case`unavailable`:{let t=Me[n.reason];return{nodeId:e.nodeId,selectable:!1,labelKey:t.key,labelDefault:Z.t(t.key),detail:n.detail,tone:t.tone}}case`unsupported-platform`:return{nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleNotMac`,labelDefault:Z.t(`ai.appleNotMac`),detail:n.platform,tone:`default`};case`unknown`:return t(n.error)}}var Pe={ready:`success`,downloading:`info`,starting:`info`,stopped:`danger`,crashed:`danger`,failed:`danger`},Fe={ready:`ai.stateReady`,downloading:`ai.stateDownloading`,starting:`ai.stateStarting`,stopped:`ai.stateStopped`,crashed:`ai.stateCrashed`,failed:`ai.stateFailed`};function Ie(e){return e.reachable?e.status===void 0?`ai.stateReady`:Fe[e.status.state]:`ai.unreachable`}function Le(e){return e.reachable?e.status===void 0?`success`:Pe[e.status.state]:`danger`}function Re(e){if(!e.reachable)return[];let t=[],n=e.apple;if(n?.state===`available`)t.push({id:`apple`,labelKey:`ai.featureApple`,tone:`success`,detail:Ne(e).detail}),n.imageInput&&t.push({id:`apple-images`,labelKey:`ai.featureAppleImages`,tone:`success`,detail:null});else if(n?.state===`unavailable`){let n=Ne(e);t.push({id:`apple`,labelKey:`ai.featureApple`,tone:n.tone,detail:n.labelDefault})}let r=e.status?.vramBytes;return r!==void 0&&r>0&&t.push({id:`gpu`,labelKey:`ai.featureGpu`,tone:`info`,detail:null}),t}function ze(){return{temperature:[{type:`slider`,key:`temperature`,label:Z.t(`helpers.aiProfileForm.temperature`),min:0,max:2,step:.1,showValue:!0,showStepper:!0,nullable:!0,nullLabel:`Provider default`,description:Z.t(`helpers.aiProfileForm.temperatureHint`)}],topP:[{type:`slider`,key:`topP`,label:Z.t(`helpers.aiProfileForm.topP`),min:0,max:1,step:.05,showValue:!0,showStepper:!0,nullable:!0,nullLabel:`Provider default`}],topK:[{type:`number`,key:`topK`,label:Z.t(`helpers.aiProfileForm.topK`),min:1}],maxTokens:[{type:`number`,key:`maxTokens`,label:Z.t(`helpers.aiProfileForm.maxTokens`),min:1}],contextLength:[{type:`number`,key:`contextLength`,label:Z.t(`helpers.aiProfileForm.contextLength`),min:512,unit:`tokens`,description:Z.t(`helpers.aiProfileForm.contextLengthHint`)}],systemPrompt:[{type:`textarea`,key:`systemPrompt`,label:Z.t(`helpers.aiProfileForm.systemPrompt`),rows:4,maxLength:4e3,span:2,description:Z.t(`helpers.aiProfileForm.systemPromptHint`)}],timeoutMs:[{type:`number`,key:`timeoutMs`,label:Z.t(`helpers.aiProfileForm.timeoutTotal`),min:1e3,default:P.totalMs,unit:`ms`,description:Z.t(`helpers.aiProfileForm.timeoutTotalHint`)}],connectTimeoutMs:[{type:`number`,key:`connectTimeoutMs`,label:Z.t(`helpers.aiProfileForm.timeoutConnect`),min:500,default:P.connectMs,unit:`ms`,description:Z.t(`helpers.aiProfileForm.timeoutConnectHint`)}],firstTokenTimeoutMs:[{type:`number`,key:`firstTokenTimeoutMs`,label:Z.t(`helpers.aiProfileForm.timeoutFirstToken`),min:1e3,default:P.firstTokenMs,unit:`ms`,description:Z.t(`helpers.aiProfileForm.timeoutFirstTokenHint`)}],idleTimeoutMs:[{type:`number`,key:`idleTimeoutMs`,label:Z.t(`helpers.aiProfileForm.timeoutIdle`),min:1e3,default:P.idleMs,unit:`ms`,description:Z.t(`helpers.aiProfileForm.timeoutIdleHint`)}],retry:[{type:`boolean`,key:`retryEnabled`,label:Z.t(`helpers.aiProfileForm.retry`),description:Z.t(`helpers.aiProfileForm.retryHint`)},{type:`number`,key:`retryMaxAttempts`,label:Z.t(`helpers.aiProfileForm.retryMaxAttempts`),min:1,max:5,default:1,showWhen:{field:`retryEnabled`,equals:!0}}],toolsEnabled:[{type:`boolean`,key:`toolsEnabled`,label:Z.t(`helpers.aiProfileForm.toolsEnabled`),description:Z.t(`helpers.aiProfileForm.toolsEnabledHint`)}]}}var Be=[`temperature`,`topP`,`topK`,`maxTokens`,`contextLength`,`systemPrompt`],Ve=[`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`];function He(e,t){let n=ze();return t.filter(t=>e.includes(t)).flatMap(e=>n[e])}function Ue(e){let t=He(e,Be);return t.length===0?null:{sections:[{id:`generation`,title:Z.t(`helpers.aiProfileForm.generation`),fields:t}]}}function We(e){let t=He(e,Ve);return t.length===0?null:{sections:[{id:`bounds`,title:Z.t(`helpers.aiProfileForm.bounds`),fields:t}]}}function Ge(e){return e===null?{}:{temperature:e.temperature,topP:e.topP,topK:e.topK,maxTokens:e.maxTokens,contextLength:e.contextLength,systemPrompt:e.systemPrompt,timeoutMs:e.timeoutMs,connectTimeoutMs:e.connectTimeoutMs,firstTokenTimeoutMs:e.firstTokenTimeoutMs,idleTimeoutMs:e.idleTimeoutMs,retryEnabled:e.retry.enabled,retryMaxAttempts:e.retry.maxAttempts,toolsEnabled:e.toolsEnabled}}function Ke(e,t){return{...e.features,...t?.features}}function qe(e,t){return t===null?e.modelCatalog===`static`?e.staticModels??[]:[]:t}function Je(e,t,n){let r=e.profileFields,i=n.common,a=(e,t,n)=>r.includes(e)?ke(i[e])??t:n??t,o=e=>r.includes(e)?ke(i[e]):t?.[e],s=o(`temperature`),c=o(`topP`),l=o(`topK`),u=o(`maxTokens`),d=o(`contextLength`),f=r.includes(`systemPrompt`)?Oe(i.systemPrompt):t?.systemPrompt;return{id:t?.id??crypto.randomUUID(),name:n.name,kind:e.kind,addonId:e.addonId.length>0?e.addonId:`ai`,enabled:t?.enabled??!0,model:n.model,supportsVision:n.supportsVision,timeoutMs:a(`timeoutMs`,P.totalMs,t?.timeoutMs),connectTimeoutMs:a(`connectTimeoutMs`,P.connectMs,t?.connectTimeoutMs),firstTokenTimeoutMs:a(`firstTokenTimeoutMs`,P.firstTokenMs,t?.firstTokenTimeoutMs),idleTimeoutMs:a(`idleTimeoutMs`,P.idleMs,t?.idleTimeoutMs),retry:r.includes(`retry`)?{enabled:Ae(i.retryEnabled),maxAttempts:ke(i.retryMaxAttempts)??1}:t?.retry??{enabled:!1,maxAttempts:1},toolsEnabled:r.includes(`toolsEnabled`)?Ae(i.toolsEnabled):t?.toolsEnabled??!1,...s===void 0?{}:{temperature:s},...c===void 0?{}:{topP:c},...l===void 0?{}:{topK:l},...u===void 0?{}:{maxTokens:u},...d===void 0?{}:{contextLength:d},...f===void 0?{}:{systemPrompt:f},providerConfig:n.providerConfig}}var Ye=2e3;function $(e){return Z.t(`system.aiModelPicker.sizeGb`,{value:(e/1e9).toFixed(2)})}function Xe(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function Ze({nodeId:t,value:r,onChange:a}){let{t:c}=Q(),u=D(),[d,f]=o(``),[p,m]=o(null),[h,g]=o(!1),_=s({queryKey:Ce,queryFn:()=>u.trpcClient.llm.listModelCatalog.query({})}),v=s({queryKey:[`llm`,`listNodeModels`,t],queryFn:()=>u.trpcClient.llm.listNodeModels.query({nodeId:t})}),y=l({mutationFn:e=>u.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{m(e),g(!1),e.ok&&a({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),b=l({mutationFn:e=>u.trpcClient.llm.installModel.mutate({nodeId:t,model:e}),onSuccess:()=>{g(!0),v.refetch()}}),x=s({queryKey:Se,enabled:b.isPending,refetchInterval:b.isPending?Ye:!1,queryFn:()=>u.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(e=>e.nodeId===t)?.status?.download,S=n(()=>{let e=(_.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${$(e.sizeBytes)}`})),n=(v.data??[]).filter(e=>e.catalogId===void 0&&e.path!==void 0).map(e=>({value:`node:${e.file}`,label:c(`ai.onNode`,`{{file}} · {{size}} · on {{node}}`,{file:e.file,size:$(e.sizeBytes),node:t})})),r=p?.ok===!0?[{value:`custom`,label:`${p.label} · ${$(p.totalBytes)}`}]:[];return[{value:``,label:c(`ai.selectModel`,`Select a model…`)},...e,...n,...r]},[_.data,v.data,p,t,c]),C=e=>{if(e===``){a(null);return}if(e===`custom`){if(p?.ok!==!0)return;a({model:p.model,modelId:p.label,supportsVision:p.purpose===`vision`});return}if(e.startsWith(`catalog:`)){let t=e.slice(8),n=_.data?.find(e=>e.id===t);a({model:{kind:`catalog`,catalogId:t},modelId:t,supportsVision:n?.purpose===`vision`});return}let t=e.slice(5),n=v.data?.find(e=>e.file===t);n?.path!==void 0&&a({model:{kind:`path`,path:n.path},modelId:t,supportsVision:!1})},T=e=>{d.trim()!==``&&y.mutate({ref:d.trim(),...e===void 0?{}:{maxBytes:e}})};return e(`div`,{className:`space-y-3`,children:[i(pe,{label:c(`ai.model`,`Model`),required:!0,children:i(Y,{id:`ai-model`,"aria-label":c(`ai.model`,`Model`),value:Xe(r),options:S,onChange:e=>C(e.target.value)})}),i(pe,{label:c(`ai.hfTitle`,`Add a model from Hugging Face`),description:c(`ai.hfHint`,`Paste a GGUF file URL, or type org/repo — add :QUANT (e.g. unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M) when the repo publishes more than one quantization.`),children:e(`div`,{className:`flex gap-2`,children:[i(le,{"aria-label":c(`ai.hfTitle`,`Add a model from Hugging Face`),value:d,onChange:e=>f(e.target.value),placeholder:c(`system.aiModelPicker.unslothQwen3635bA3b`,`unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M`),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())}}),e(q,{size:`sm`,variant:`secondary`,type:`button`,disabled:d.trim()===``||y.isPending,onClick:()=>T(),children:[y.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):i(N,{className:`h-3.5 w-3.5`}),c(`ai.hfCheck`,`Check`)]})]})}),y.isError&&i(K,{message:y.error instanceof Error?y.error.message:c(`common.error`,`Error`)}),p?.ok===!1&&i(K,{message:p.message,action:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(p.candidates??[]).map(e=>i(q,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{let t=`${d.trim().split(`:`)[0]??``}:${e}`;f(t),y.mutate({ref:t})},children:e},e)),p.requiredBytes!==void 0&&i(q,{size:`sm`,variant:`secondary`,type:`button`,onClick:()=>T(p.requiredBytes),children:c(`ai.hfOverride`,`Install anyway ({{size}})`,{size:$(p.requiredBytes)})})]})}),p?.ok===!0&&e(`div`,{className:`space-y-2 rounded-md border border-border bg-surface p-2.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`span`,{className:`text-[11px] font-medium text-foreground`,children:p.label}),i(X,{variant:p.purpose===`vision`?`info`:`default`,children:p.purpose}),i(X,{variant:`default`,children:$(p.totalBytes)})]}),p.extraFilenames.length>0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:c(`ai.hfExtras`,`Also downloads: {{files}}`,{files:p.extraFilenames.join(`, `)})}),e(`div`,{className:`flex items-center gap-2`,children:[e(q,{size:`sm`,type:`button`,disabled:b.isPending||h,onClick:()=>b.mutate(p.model),children:[b.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):i(w,{className:`h-3.5 w-3.5`}),h?c(`ai.hfInstalled`,`Downloaded`):c(`ai.hfInstall`,`Download to {{node}}`,{node:t})]}),x!==void 0&&i(`span`,{className:`text-[10px] text-foreground-subtle`,children:x.phase===`verifying`?c(`ai.hfVerifying`,`verifying {{file}}…`,{file:x.file}):c(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:x.file,index:x.fileIndex,count:x.fileCount,done:$(x.downloadedBytes),total:x.totalBytes===void 0?``:` / ${$(x.totalBytes)}`})})]}),b.isError&&i(K,{message:b.error instanceof Error?b.error.message:c(`common.error`,`Error`)})]})]})}function Qe({value:t,onChange:n}){let{t:r}=Q(),a=D(),o=s({queryKey:Se,queryFn:()=>a.trpcClient.llm.listRuntimeNodes.query({})});return e(`div`,{children:[i(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:r(`ai.appleNode`,`Mac that runs it`)}),o.isPending&&e(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(O,{className:`h-3.5 w-3.5 animate-spin`}),r(`ai.appleAsking`,`Asking the nodes…`)]}),o.isError&&i(`p`,{className:`text-[11px] text-danger`,children:o.error instanceof Error?o.error.message:r(`ai.runtimesFailed`,`Failed to read runtime nodes`)}),o.isSuccess&&o.data.length===0&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}),o.isSuccess&&o.data.length>0&&i(`div`,{role:`radiogroup`,className:`space-y-1.5`,children:o.data.map(a=>{let o=Ne(a),s=o.nodeId===t;return e(`button`,{type:`button`,role:`radio`,"aria-checked":s,disabled:!o.selectable&&!s,onClick:()=>n(o.nodeId),className:`flex w-full items-center justify-between gap-2 rounded-md border px-3 py-2 text-left text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-60 ${s?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[e(`span`,{className:`min-w-0`,children:[i(`span`,{className:`block font-medium text-foreground`,children:o.nodeId}),o.detail!==null&&i(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:o.detail})]}),i(X,{variant:o.tone,children:r(o.labelKey,o.labelDefault)})]},o.nodeId)})}),i(`p`,{className:`mt-1.5 text-[10px] leading-relaxed text-foreground-subtle`,children:r(`ai.appleHint`,`Text only for now — notification titles and summaries. Apple refuses prompts framed as surveillance; when it does, the next profile in the chain answers instead.`)})]})}function $e(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function et({providerConfig:e,onProviderConfigChange:t}){return i(Qe,{value:$e(e,`nodeId`),onChange:n=>t({...e,nodeId:n})})}function tt({providerConfig:e,onProviderConfigChange:t,model:n,onModelChange:r}){let a=F.safeParse(e.model),o=a.success?{model:a.data,modelId:n.id,supportsVision:n.supportsVision}:null;return i(Ze,{nodeId:$e(e,`nodeId`)??`hub`,value:o,onChange:n=>{if(n===null){let{model:n,...i}=e;t(i),r({id:``,supportsVision:!1});return}t({...e,model:n.model}),r({id:n.modelId,supportsVision:n.supportsVision})}})}var nt=new Map([[`ai/apple-node`,et],[`ai/managed-model`,tt]]);function rt(e){return nt.get(e)??null}c();function it({kind:e,className:t}){return i(De(e.icon),{className:t,"aria-hidden":!0})}function at({kinds:e,onPick:t,onCancel:r}){let{t:a}=Q(),o=n(()=>je(e),[e]),s=n(()=>new Map(e.map(e=>[`${e.addonId}:${e.kind}`,e])),[e]);return i(ue,{open:!0,onClose:r,title:a(`ai.chooseKind`,`Choose a profile type`),width:`lg`,testId:`ai-kind-picker`,children:i(se,{emptyMessage:a(`ai.noKinds`,`No AI provider is installed.`),onPick:e=>{let n=s.get(e);n!==void 0&&t(n)},groups:o.map(e=>({id:e.addonId,label:e.addonId,tiles:e.kinds.map(t=>({key:`${e.addonId}:${t.kind}`,label:t.label,testId:`ai-kind-${t.kind}`,icon:i(it,{kind:t,className:`h-5 w-5 text-foreground-subtle`})}))}))})})}function ot(e){return(e?.sections??[]).flatMap(e=>e.fields)}function st(...e){let t={};for(let n of e)for(let e of ot(n))`default`in e&&e.default!==void 0&&(t[e.key]=e.default);return t}function ct(e){return e==null?!1:typeof e==`string`?e.trim().length>0:!0}function lt(e,t){return ot(e).filter(e=>`required`in e&&e.required===!0&&!ct(t[e.key])).map(e=>`label`in e&&typeof e.label==`string`?e.label:e.key)}var ut={auth:{key:`ai.listAuth`,fallback:`Credentials refused`},network:{key:`ai.listNetwork`,fallback:`Endpoint unreachable`},unsupported:{key:`ai.listUnsupported`,fallback:`No model list`},invalid:{key:`ai.listInvalid`,fallback:`Connection incomplete`}};function dt(e,t){if(t!==null)return{id:t.model,supportsVision:t.supportsVision};let n=e.modelCatalog===`static`&&e.staticModels?.length===1?e.staticModels?.[0]:void 0;return{id:n?.id??``,supportsVision:Ke(e,n).vision}}function ft({kind:t,existing:r,onSave:s,onCancel:c,onChangeKind:p,saving:m,error:h}){let{t:_}=Q(),v=D(),[y,b]=o(r?.name??t.label),[x,S]=o(()=>r===null?st(t.connectionSchema,t.advancedSchema):{...r.providerConfig}),[C,w]=o(()=>Ge(r)),[T,E]=o(()=>dt(t,r)),[ee,A]=o(!1),j=t.providerWidgets??[],te=j.filter(e=>e.placement===`connection`),M=j.find(e=>e.placement===`model`)??null,N=n(()=>[...I(t.connectionSchema)].some(e=>r?.providerConfig[e]===ve),[r,t.connectionSchema]),P=l({mutationFn:()=>v.trpcClient.llm.listModels.mutate({addonId:t.addonId,kind:t.kind,connection:x,...r===null?{}:{profileId:r.id}}),onSuccess:e=>{e.ok&&E(n=>{let r=e.models.find(e=>e.id===n.id);return r===void 0?n:{id:n.id,supportsVision:Ke(t,r).vision}})}}),F=qe(t,P.data?.ok===!0?P.data.models:null),L=F.find(e=>e.id===T.id),R=Ke(t,L),ne=Ue(t.profileFields),z=We(t.profileFields),B=lt(t.connectionSchema,x),V=j.some(e=>(e.requires??[]).some(e=>!ct(x[e]))),H=t.modelCatalog===`fetch`&&M===null,U=ot(t.connectionSchema).length>0||te.length>0,G=r!==null&&H&&B.length===0;a(()=>{G&&P.mutate()},[]);let ie=e=>{E({id:e,supportsVision:Ke(t,F.find(t=>t.id===e)).vision})},ae=m||y.trim()===``||T.id.trim()===``||B.length>0||V,oe=()=>{s(Je(t,r,{name:y.trim(),model:T.id.trim(),supportsVision:t.visionEditable?T.supportsVision:!1,common:C,providerConfig:x}))},se=r===null?_(`ai.newProfile`,`New {{kind}} profile`,{kind:t.label}):_(`ai.editProfile`,`Edit {{name}}`,{name:r.name}),ce=e=>{let n=rt(e);return n===null?i(K,{variant:`warning`,message:_(`ai.unknownWidget`,`This provider needs an editor part this build does not have ({{id}}).`,{id:e})}):i(n,{descriptor:t,providerConfig:x,onProviderConfigChange:S,model:T,onModelChange:E},e)};return i(ue,{open:!0,onClose:c,title:se,error:h,width:`lg`,testId:`ai-profile-editor`,footer:e(u,{children:[B.length>0&&i(X,{variant:`warning`,children:_(`ai.missingRequired`,`required: {{fields}}`,{fields:B.join(`, `)})}),B.length===0&&V&&i(X,{variant:`warning`,children:_(`ai.completeProvider`,`complete the provider settings`)}),B.length===0&&!V&&T.id.trim()===``&&i(X,{variant:`warning`,children:_(`ai.pickModelFirst`,`pick a model`)}),e(q,{size:`sm`,type:`button`,disabled:ae,onClick:oe,children:[m&&i(O,{className:`h-3.5 w-3.5 animate-spin`}),r===null?_(`ai.createProfile`,`Create profile`):_(`ai.saveChanges`,`Save changes`)]})]}),children:e(`div`,{className:g,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`ai-editor-provider`,children:[i(it,{kind:t,className:`h-4 w-4 text-foreground-subtle`}),i(`span`,{className:`text-xs font-medium text-foreground`,children:t.label}),i(X,{variant:`neutral`,children:t.addonId}),p!==void 0&&e(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:p,children:[i(k,{className:`h-3.5 w-3.5`}),_(`ai.changeKind`,`Change type`)]})]}),i(pe,{label:_(`ai.name`,`Name`),required:!0,children:i(le,{id:`ai-profile-name`,"aria-label":_(`ai.name`,`Name`),value:y,onChange:e=>b(e.target.value),placeholder:t.label})}),U&&i(J,{headingId:`ai-editor-connection`,title:_(`ai.sectionConnection`,`Connection`),actions:H?e(q,{size:`sm`,variant:`secondary`,type:`button`,disabled:P.isPending,onClick:()=>P.mutate(),"data-testid":`ai-verify-models`,children:[P.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):i(f,{className:`h-3.5 w-3.5`}),_(`ai.verifyModels`,`Verify & load models`)]}):void 0,children:e(`div`,{className:`p-2 sm:p-3 lg:p-4 space-y-3`,children:[ot(t.connectionSchema).length>0&&i(de,{bare:!0,schema:t.connectionSchema,values:x,onChange:S}),te.map(e=>ce(e.id)),N&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:_(`ai.secretHint`,`A stored API key is never shown. Leave it as-is to keep it; type a new value to replace it.`)}),P.data?.ok===!0&&i(X,{variant:`success`,"data-testid":`ai-models-found`,children:_(`ai.modelsFound`,`{{count}} models found`,{count:P.data.models.length})}),P.data?.ok===!1&&i(K,{title:_(ut[P.data.code]?.key??`ai.listNetwork`,ut[P.data.code]?.fallback??`Endpoint unreachable`),message:P.data.message}),P.isError&&i(K,{message:P.error instanceof Error?P.error.message:_(`common.error`,`Error`)})]})}),i(J,{headingId:`ai-editor-model`,title:_(`ai.sectionModel`,`Model`),children:e(`div`,{className:`${d} space-y-3`,children:[M===null?e(u,{children:[F.length>0&&i(Y,{id:`ai-model-pick`,"aria-label":_(`ai.selectModel`,`Select a model…`),value:L===void 0?``:L.id,options:[{value:``,label:_(`ai.selectModel`,`Select a model…`)},...F.map(e=>({value:e.id,label:e.label??e.id}))],onChange:e=>{e.target.value!==``&&ie(e.target.value)}}),i(pe,{label:_(`ai.customModel`,`Model id`),description:_(`ai.customModelHint`,`Pick one from the list, or type any model id the provider accepts.`),required:!0,children:i(le,{id:`ai-model-id`,"aria-label":_(`ai.customModel`,`Model id`),value:T.id,onChange:e=>{let n=F.find(t=>t.id===e.target.value);E(n===void 0?{...T,id:e.target.value}:{id:e.target.value,supportsVision:Ke(t,n).vision})},placeholder:F[0]?.id??`model-id`})})]}):ce(M.id),e(`div`,{className:`flex flex-wrap items-center gap-1.5`,"data-testid":`ai-model-features`,children:[(T.supportsVision||!t.visionEditable&&R.vision)&&i(X,{variant:`info`,children:_(`ai.featureVision`,`vision`)}),R.tools&&i(X,{variant:`neutral`,children:_(`ai.featureTools`,`tools`)}),R.streaming&&i(X,{variant:`neutral`,children:_(`ai.featureStreaming`,`streaming`)})]}),t.visionEditable&&i(pe,{orientation:`horizontal`,label:_(`ai.supportsVision`,`Supports vision`),description:_(`ai.supportsVisionHint`,`A vision call against a text-only profile is refused, never downgraded.`),children:i(W,{checked:T.supportsVision,onCheckedChange:e=>E({...T,supportsVision:e}),"aria-label":_(`ai.supportsVision`,`Supports vision`)})})]})}),ne!==null&&i(J,{headingId:`ai-editor-generation`,title:_(`ai.sectionGeneration`,`Generation`),children:i(`div`,{className:`p-2 sm:p-3 lg:p-4`,children:i(de,{bare:!0,schema:ne,values:C,onChange:w})})}),(z!==null||t.advancedSchema!==void 0)&&i(re,{expanded:ee,onExpandedChange:A,header:i(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:_(`ai.sectionAdvanced`,`Advanced`)}),children:e(`div`,{className:`p-2 sm:p-3 lg:p-4 space-y-3`,children:[z!==null&&i(de,{bare:!0,schema:z,values:C,onChange:w}),t.advancedSchema!==void 0&&i(de,{bare:!0,schema:t.advancedSchema,values:x,onChange:S})]})})]})})}c();function pt(t){return[{key:`name`,header:t.t(`ai.colProfile`,`Profile`),render:n=>{let r=t.kindByName.get(n.kind);return e(`span`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface`,title:r?.label??n.kind,children:r===void 0?i(`span`,{className:`text-xs text-foreground-subtle`,children:`?`}):i(it,{kind:r,className:`h-4 w-4 text-foreground-subtle`})}),e(`span`,{className:`min-w-0`,children:[i(`span`,{className:`block truncate font-medium text-foreground`,children:n.name}),t.testResult?.id===n.id&&i(`span`,{className:`block truncate ${t.testResult.ok?`text-success`:`text-danger`}`,children:t.testResult.text})]})]})}},{key:`kind`,header:t.t(`ai.colKind`,`Kind`),nowrap:!0,render:e=>i(`span`,{className:`text-foreground-muted`,children:t.kindByName.get(e.kind)?.label??e.kind})},{key:`model`,header:t.t(`ai.colModel`,`Model`),render:e=>i(`span`,{className:`text-foreground`,children:e.model})},{key:`vision`,header:t.t(`ai.colVision`,`Vision`),align:`center`,nowrap:!0,render:e=>e.supportsVision?i(X,{variant:`info`,style:`outline`,children:t.t(`ai.vision`,`vision`)}):i(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`node`,header:t.t(`ai.colNode`,`Node`),nowrap:!0,render:e=>typeof e.providerConfig.nodeId==`string`?i(X,{variant:`default`,children:e.providerConfig.nodeId}):i(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`enabled`,header:t.t(`ai.colOn`,`On`),align:`center`,nowrap:!0,render:e=>i(W,{checked:e.enabled,onCheckedChange:()=>t.onToggle(e),"aria-label":Z.t(`system.aiProfilesTab.toggle`,`toggle {{name}}`,{name:e.name})})},{key:`actions`,header:``,align:`right`,nowrap:!0,render:n=>e(`span`,{className:`flex items-center justify-end gap-1`,children:[i(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>t.onTest(n),"aria-label":t.t(`ai.test`,`Test`),title:t.t(`ai.test`,`Test`),children:t.testingId===n.id?i(O,{className:`h-3.5 w-3.5 animate-spin`}):i(R,{className:`h-3.5 w-3.5`})}),i(q,{size:`sm`,variant:`ghost`,type:`button`,disabled:!t.kindByName.has(n.kind),onClick:()=>t.onEdit(n),"aria-label":t.t(`common.edit`,`Edit`),title:t.t(`common.edit`,`Edit`),children:i(C,{className:`h-3.5 w-3.5`})}),i(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>t.onDelete(n),"aria-label":t.t(`common.delete`,`Delete`),title:t.t(`common.delete`,`Delete`),children:i(h,{className:`h-3.5 w-3.5 text-danger`})})]})}]}function mt(){let{t}=Q(),c=D(),{state:u,openEdit:f,close:p}=ce(),m=te(),[h,_]=o(null),[v,y]=o(null),[b,x]=o(null),S=s({queryKey:ye,queryFn:()=>c.trpcClient.llm.listProfiles.query({})}),C=s({queryKey:be,queryFn:async()=>(await c.trpcClient.llm.listProfileKinds.query({})).map(({connectionSchema:e,advancedSchema:t,...n})=>({...n,connectionSchema:e,...t===void 0?{}:{advancedSchema:t}}))}),w=()=>{S.refetch()},T=r(()=>{_(null),x(null),p()},[p]);a(()=>{u.mode===`closed`&&_(null)},[u.mode]);let E=l({mutationFn:e=>c.trpcClient.llm.upsertProfile.mutate({profile:e}),onSuccess:()=>{T(),w()},onError:e=>x(e instanceof Error?e.message:t(`ai.saveFailed`,`Save failed`))}),O=l({mutationFn:e=>c.trpcClient.llm.deleteProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:w}),ee=l({mutationFn:e=>c.trpcClient.llm.testProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:(e,t)=>y({id:t.id,ok:e.ok,text:e.ok?Z.t(`system.aiProfilesTab.testOk`,{text:e.text,tokens:e.usage.outputTokens,ms:e.latencyMs}):`${e.code}: ${e.message}`})}),k=S.data??[],A=n(()=>C.data??[],[C.data]),M=n(()=>{let e=new Map;for(let t of A)e.set(t.kind,t);return e},[A]),N=u.mode===`edit`?k.find(e=>e.id===u.id)??null:null,P=N===null?null:M.get(N.kind)??null,F=u.mode===`new`&&h===null,I=u.mode===`new`?h:P,L=u.mode===`edit`?N:null,R=I!==null&&(u.mode===`new`||L!==null),ne=async e=>{await m({title:t(`ai.deleteProfileTitle`,`Delete profile?`),message:t(`ai.deleteProfileMessage`,`Delete "{{name}}". Features that name it will no longer get an answer from it.`,{name:e.name}),confirmLabel:t(`common.delete`,`Delete`),variant:`danger`})&&O.mutate(e)};return e(`div`,{className:g,children:[i(ht,{profiles:k}),i(J,{headingId:`ai-profiles-list`,title:t(`ai.profilesList`,`Profiles`),children:S.isPending?e(`div`,{className:`${d} space-y-2`,"data-testid":`ai-profiles-loading`,children:[i(G,{className:`h-8 w-full`}),i(G,{className:`h-8 w-full`}),i(G,{className:`h-8 w-full`})]}):S.isError?i(`div`,{className:d,children:i(K,{title:t(`ai.loadFailed`,`Failed to load profiles`),message:S.error instanceof Error?S.error.message:t(`common.error`,`Error`),onRetry:()=>void S.refetch()})}):k.length===0?i(H,{icon:j,title:t(`ai.noProfilesTitle`,`No AI profiles yet`),description:t(`ai.noProfiles`,`No AI profiles yet. Click "Add profile" to configure one.`)}):i(ie,{columns:pt({kindByName:M,testResult:v,testingId:ee.isPending?ee.variables?.id??null:null,t,onToggle:e=>E.mutate({...e,enabled:!e.enabled}),onTest:e=>ee.mutate(e),onEdit:e=>{M.has(e.kind)&&(x(null),_(null),f(e.id))},onDelete:e=>void ne(e)}),rows:k,rowKey:e=>e.id,minWidthPx:760,bordered:!1,maxBodyHeight:z})}),F&&i(at,{kinds:A,onCancel:T,onPick:e=>{x(null),_(e)}}),R&&I!==null&&i(ft,{kind:I,existing:L,saving:E.isPending,error:b,onSave:e=>E.mutate(e),onCancel:T,...u.mode===`new`?{onChangeKind:()=>{x(null),_(null)}}:{}})]})}function ht({profiles:t}){let{t:n}=Q(),r=D(),a=s({queryKey:xe,queryFn:()=>r.trpcClient.llm.getDefaults.query({})}),o=l({mutationFn:e=>r.trpcClient.llm.setDefault.mutate({selector:{purpose:e.purpose},profileId:e.profileId}),onSuccess:()=>{a.refetch()}}),c=e=>(a.data??[]).find(t=>`purpose`in t.selector&&t.selector.purpose===e)?.profileId??``,u=e=>e===`vision`?n(`ai.defaultVision`,`Default vision profile`):n(`ai.defaultText`,`Default text profile`);return i(J,{headingId:`ai-profiles-defaults`,title:n(`ai.defaultsTitle`,`Defaults`),children:i(`div`,{className:`${d} grid gap-4 sm:grid-cols-2`,children:Te.map(({purpose:r,visionOnly:a})=>{let s=a?t.filter(e=>e.supportsVision):t,l=c(r),d=t.find(e=>e.id===l);return e(`div`,{children:[i(ae,{className:`mb-1 block`,htmlFor:`llm-default-${r}`,children:u(r)}),i(Y,{id:`llm-default-${r}`,"aria-label":u(r),value:l,onChange:e=>o.mutate({purpose:r,profileId:e.target.value===``?null:e.target.value}),options:[{value:``,label:n(`ai.none`,`None`)},...l!==``&&!s.some(e=>e.id===l)?[{value:l,label:d?.name??l}]:[],...s.map(e=>({value:e.id,label:`${e.name} · ${e.model}`}))]}),l!==``&&d===void 0&&i(`p`,{className:`mt-1 text-xs text-danger`,children:n(`ai.defaultMissing`,`This default names a profile that no longer exists.`)}),d!==void 0&&!d.enabled&&i(`p`,{className:`mt-1 text-xs text-warning`,children:n(`ai.defaultDisabled`,`This default profile is disabled — callers resolve to no profile.`)}),o.error!=null&&i(`p`,{className:`mt-1 text-xs text-danger`,children:String(o.error)})]},r)})})})}c();var gt=5e3;function _t(e){return Z.t(`system.aiRuntimes.sizeGb`,{value:(e/1e9).toFixed(1)})}function vt(){let{t}=Q(),r=D(),a=s({queryKey:Se,refetchInterval:gt,queryFn:()=>r.trpcClient.llm.listRuntimeNodes.query({})}),o=n(()=>[{key:`node`,header:t(`ai.colNode`,`Node`),render:e=>i(`span`,{className:`font-medium text-foreground`,children:e.nodeId})},{key:`state`,header:t(`ai.colState`,`State`),nowrap:!0,render:n=>e(`span`,{className:`flex items-center gap-1.5`,children:[i(X,{variant:Le(n),children:t(Ie(n))}),n.status?.downloadProgress!==void 0&&i(X,{variant:`info`,children:`${String(Math.round(n.status.downloadProgress*100))}%`})]})},{key:`model`,header:t(`ai.colModel`,`Model`),render:e=>i(`span`,{className:`text-foreground`,children:e.status?.modelId??`—`})},{key:`disk`,header:t(`ai.colDisk`,`On disk`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums text-foreground-muted`,children:e.disk===void 0?`—`:_t(e.disk.modelsBytes)})},{key:`features`,header:t(`ai.colFeature`,`Feature`),render:n=>{let r=Re(n);if(r.length===0)return i(`span`,{className:`text-foreground-subtle`,children:`—`});let a=r.flatMap(e=>e.detail===null?[]:[e.detail]);return e(`span`,{className:`flex flex-col items-start gap-0.5`,children:[i(`span`,{className:`flex flex-wrap gap-1`,children:r.map(e=>i(X,{variant:e.tone,children:t(e.labelKey)},e.id))}),a.length>0&&i(`span`,{className:`text-foreground-subtle`,children:a.join(` · `)})]})}},{key:`error`,header:t(`ai.colError`,`Error`),render:e=>e.error===void 0?i(`span`,{className:`text-foreground-subtle`,children:`—`}):i(`span`,{className:`text-danger`,children:e.error})}],[t]),c=a.data??[];return i(J,{headingId:`ai-runtimes-list`,title:t(`ai.runtimesList`,`Nodes`),children:a.isPending?e(`div`,{className:`${d} space-y-2`,"data-testid":`ai-runtimes-loading`,children:[i(G,{className:`h-8 w-full`}),i(G,{className:`h-8 w-full`})]}):a.isError?i(`div`,{className:d,children:i(K,{title:t(`ai.runtimesFailed`,`Failed to read runtime nodes`),message:a.error instanceof Error?a.error.message:t(`common.error`,`Error`),onRetry:()=>void a.refetch()})}):c.length===0?i(H,{icon:T,title:t(`ai.noRuntimesTitle`,`No runtime nodes`),description:t(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):i(ie,{columns:o,rows:c,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,maxBodyHeight:z})})}var yt=x(`/addon/ai/test-chat`),bt=x(`/addon/ai/test-chat/chats`),xt=6e5;function St(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),xt)}function Ct(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function wt(e){if(!Ct(e))return null;let t=e.kind;return t!==`snapshot`&&t!==`track`||typeof e.mimeType!=`string`||typeof e.sizeBytes!=`number`?null:{kind:t,mimeType:e.mimeType,sizeBytes:e.sizeBytes,...typeof e.mediaKind==`string`?{mediaKind:e.mediaKind}:{},...typeof e.capturedAt==`number`?{capturedAt:e.capturedAt}:{},...typeof e.thumbnailBase64==`string`?{thumbnailBase64:e.thumbnailBase64}:{}}}var Tt=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function Et(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Ct(t))return null;switch(t.kind){case`status`:{let e=Tt.find(e=>e===t.phase);return e===void 0?null:{kind:`status`,phase:e}}case`meta`:return typeof t.profileName!=`string`||typeof t.model!=`string`?null:{kind:`meta`,profileName:t.profileName,model:t.model,mediaSent:wt(t.mediaSent),streamed:t.streamed===!0,firstTokenTimeoutMs:typeof t.firstTokenTimeoutMs==`number`?t.firstTokenTimeoutMs:0};case`token`:return typeof t.text==`string`?{kind:`token`,text:t.text}:null;case`done`:return{kind:`done`,inputTokens:typeof t.inputTokens==`number`?t.inputTokens:0,outputTokens:typeof t.outputTokens==`number`?t.outputTokens:0,latencyMs:typeof t.latencyMs==`number`?t.latencyMs:0,truncated:t.truncated===!0,...typeof t.conversationId==`string`?{conversationId:t.conversationId}:{}};case`error`:return{kind:`error`,code:typeof t.code==`string`?t.code:`adapter-error`,message:typeof t.message==`string`?t.message:Z.t(`helpers.aiTestChat.providerError`)};default:return null}}async function*Dt(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.indexOf(`
2
- `);for(;a>=0;){let e=r.slice(0,a).trim();if(r=r.slice(a+1),e.length>0){let t=Et(e);t!==null&&(yield t)}a=r.indexOf(`
3
- `)}}let e=r.trim();if(e.length>0){let t=Et(e);t!==null&&(yield t)}}finally{t.releaseLock()}}function Ot(e){return e.filter(e=>e.failed!==!0&&e.content.length>0).map(e=>({role:e.role,content:e.content}))}function kt(e){return e.thumbnailBase64===void 0||e.thumbnailBase64.length===0?null:`data:${e.mimeType};base64,${e.thumbnailBase64}`}function At(e){return e.messages.map((t,n)=>{let r=t.mediaSent??void 0;return{id:`${e.id}-${String(n)}`,role:t.role,content:t.content,...t.attachment===void 0?{}:{attachmentRef:t.attachment,attachmentKind:t.attachment.kind},...r===void 0?{}:{attachment:r}}})}function jt(e){let t=e.sizeBytes<1024*1024?`${(e.sizeBytes/1024).toFixed(0)} KB`:`${(e.sizeBytes/(1024*1024)).toFixed(1)} MB`,n=[e.kind===`snapshot`?`camera snapshot`:`track best-shot`,t];return e.mediaKind!==void 0&&n.push(e.mediaKind),e.capturedAt!==void 0&&n.push(new Date(e.capturedAt).toLocaleTimeString()),n.join(` · `)}function Mt(e,t){switch(e){case`resolving-image`:return Z.t(`helpers.aiTestChat.phaseImage`);case`connecting`:return Z.t(`helpers.aiTestChat.phaseConnecting`);case`first-token-wait`:return t>0?Z.t(`helpers.aiTestChat.phaseWaitUpTo`,{seconds:Math.round(t/1e3)}):Z.t(`helpers.aiTestChat.phaseWait`);case`streaming`:return Z.t(`helpers.aiTestChat.phaseAnswering`)}}c();var Nt=[`pipelineAnalytics`,`listRecentTracks`,`ai-test`],Pt=360*60*1e3,Ft=40,It=160,Lt={phase:`connecting`,firstTokenTimeoutMs:0,text:``,mediaSent:null};function Rt(){let{t:c}=Q(),l=D(),[u,f]=o(``),[p,m]=o(``),[y,b]=o(``),[x,S]=o([]),[C,w]=o(null),[T,E]=o(`none`),[O,k]=o(`throwaway`),[A,j]=o(null),[te,N]=o([]),[P,F]=o(null),[I,L]=o(null),z=t(null);a(()=>()=>z.current?.abort(),[]);let B=r(async()=>{let e=await fetch(bt,{credentials:`same-origin`});e.ok&&N((await e.json()).chats??[])},[]);a(()=>{O===`persistent`&&B()},[O,B]);let V=s({queryKey:ye,queryFn:()=>l.trpcClient.llm.listProfiles.query({})}),H=n(()=>(V.data??[]).filter(e=>e.enabled),[V.data]),U=H.find(e=>e.id===u)??null,W=I!==null,G=r(async(e,t)=>{let n=new AbortController;z.current=n,F(null);let r=St(U??{});L({...Lt,firstTokenTimeoutMs:r??0});let i=``,a=null,o,s=null,l=null,d;try{let c=await fetch(yt,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,signal:n.signal,body:JSON.stringify({profileId:u,messages:e,...p.trim()===``?{}:{system:p.trim()},...t===void 0?{}:{attachment:t},...r===void 0?{}:{firstTokenTimeoutMs:r},...O===`persistent`?{persist:!0,...A===null?{}:{conversationId:A}}:{}})});if(!c.ok||c.body===null){let e=await c.text().catch(()=>``);throw Error(e.length>0?e:`HTTP ${String(c.status)}`)}for await(let e of Dt(c.body))switch(e.kind){case`status`:L(t=>({...t??Lt,phase:e.phase}));break;case`meta`:a=e.mediaSent,o=e.model,L(t=>({...t??Lt,firstTokenTimeoutMs:e.firstTokenTimeoutMs,mediaSent:e.mediaSent}));break;case`token`:i+=e.text,L(e=>({...e??Lt,text:i}));break;case`done`:l={outputTokens:e.outputTokens,latencyMs:e.latencyMs},d=e.conversationId;break;case`error`:s=`${e.code}: ${e.message}`;break}}catch(e){n.signal.aborted||F(e instanceof Error?e.message:c(`common.error`,`Error`))}finally{z.current=null,L(null)}d!==void 0&&(j(d),B());let f=n.signal.aborted&&i.length>0;s===null&&i.length===0&&!f||S(e=>[...e,{id:`a-${String(Date.now())}`,role:`assistant`,content:s??i,...s===null?{}:{failed:!0},...a===null?{}:{attachment:a},...o!==void 0&&s===null?{model:o}:{},...l===null?{}:l}])},[O,A,U,u,B,p,c]),re=r(()=>{let e=y.trim();if(e===``||u===``||W)return;let t={id:`u-${String(Date.now())}`,role:`user`,content:e,...C===null?{}:{attachmentLabel:C.label,attachmentKind:C.ref.kind}},n=[...x,t];S(n),b(``);let r=C?.ref;w(null),E(`none`),G(O===`persistent`&&A!==null?[{role:`user`,content:e}]:Ot(n),r)},[O,A,y,C,u,G,W,x]),ie=()=>z.current?.abort(),se=()=>{z.current?.abort(),S([]),w(null),b(``),F(null),L(null),j(null)},ce=async e=>{z.current?.abort();let t=await fetch(`${bt}/${e}`,{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();j(e),S(At(n)),L(null),F(null)};return e(`div`,{className:g,children:[i(J,{headingId:`ai-test-setup`,title:c(`ai.testSetup`,`Setup`),children:e(`div`,{className:`${d} space-y-3`,children:[e(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[e(`div`,{children:[i(ae,{className:`mb-1 block`,htmlFor:`ai-test-profile`,children:c(`ai.profile`,`Profile`)}),i(Y,{id:`ai-test-profile`,value:u,onChange:e=>f(e.target.value),options:[{value:``,label:c(`ai.selectProfile`,`Select a profile…`)},...H.map(e=>({value:e.id,label:`${e.name} · ${e.model}${e.supportsVision?` · vision`:``}`}))]}),H.length===0&&!V.isLoading&&i(`p`,{className:`mt-1 text-xs text-foreground-subtle`,children:c(`ai.noEnabledProfiles`,`No enabled profile. Add one on the Profiles tab.`)})]}),e(`div`,{children:[i(ae,{className:`mb-1 block`,htmlFor:`ai-test-system`,children:c(`ai.systemPrompt`,`System prompt (optional)`)}),i(le,{id:`ai-test-system`,value:p,onChange:e=>m(e.target.value),placeholder:c(`ai.systemPlaceholder`,`Answer in one short sentence.`)})]})]}),i(fe,{label:c(`ai.chatMode`,`Conversation mode`),value:O,options:[{value:`throwaway`,label:c(`ai.throwawayMode`,`Throwaway`)},{value:`persistent`,label:c(`ai.saveConversation`,`Save conversation`)}],onChange:e=>{k(e),e===`throwaway`&&j(null)}}),O===`persistent`&&e(`div`,{className:`space-y-2`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:c(`ai.testSubtitlePersistent`,`Conversations are saved for you and can be reopened. Throwaway mode is still available.`)}),e(q,{size:`sm`,variant:`secondary`,type:`button`,onClick:se,children:[i(ne,{className:`h-3.5 w-3.5`}),c(`ai.newChat`,`New chat`)]}),te.length>0&&i(`div`,{className:`max-h-36 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:te.map(e=>i(`button`,{type:`button`,onClick:()=>void ce(e.id),className:`flex w-full px-2.5 py-1.5 text-left text-xs hover:bg-surface-hover ${e.id===A?`bg-primary/10`:``}`,children:i(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.title})},e.id))})]}),i(`p`,{className:`text-xs text-foreground-subtle`,children:c(`ai.streamNote`,`The answer streams as the model produces it. A cold model can take a while to load — the status line says which phase it is in.`)}),U!==null&&!U.supportsVision&&i(`p`,{className:`text-xs text-warning`,children:c(`ai.notVision`,`This profile is not vision-capable — an attached image will be refused before anything is read.`)})]})}),P!==null&&i(K,{title:c(`ai.chatFailed`,`The test call failed`),message:P}),e(J,{headingId:`ai-test-conversation`,title:c(`ai.testConversation`,`Conversation`),actions:e(q,{size:`sm`,variant:`ghost`,type:`button`,disabled:x.length===0&&C===null,onClick:se,children:[i(h,{className:`h-3.5 w-3.5`}),c(`ai.clearChat`,`Clear`)]}),children:[i(zt,{turns:x,live:I}),e(`div`,{className:`${d} space-y-2 border-t border-border`,children:[C!==null&&e(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5`,children:[C.ref.kind===`snapshot`?i(v,{className:`h-3.5 w-3.5 text-foreground-subtle`}):i(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:C.label}),i(oe,{size:`sm`,variant:`ghost`,type:`button`,icon:ee,"aria-label":c(`ai.removeAttachment`,`Remove attachment`),onClick:()=>w(null)})]}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(q,{size:`sm`,variant:T===`snapshot`?`primary`:`outline`,type:`button`,onClick:()=>E(T===`snapshot`?`none`:`snapshot`),children:[i(v,{className:`h-3.5 w-3.5`}),c(`ai.attachSnapshot`,`Camera snapshot`)]}),e(q,{size:`sm`,variant:T===`track`?`primary`:`outline`,type:`button`,onClick:()=>E(T===`track`?`none`:`track`),children:[i(_,{className:`h-3.5 w-3.5`}),c(`ai.attachTrack`,`Recent track`)]})]}),T===`snapshot`&&i(Ht,{onPick:(e,t)=>{w({ref:{kind:`snapshot`,deviceId:e.id},label:c(`ai.snapshotOf`,`Snapshot of {{name}}`,{name:t})}),E(`none`)}}),T===`track`&&i(Wt,{onPick:(e,t)=>{w({ref:{kind:`track`,trackId:e.trackId,deviceId:e.deviceId},label:c(`ai.trackOf`,`{{class}} on {{name}}`,{class:e.label??e.className,name:t})}),E(`none`)}}),e(`div`,{className:`flex items-center gap-2`,children:[i(le,{value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),re())},placeholder:c(`ai.messagePlaceholder`,`Ask the model something…`),"aria-label":c(`ai.message`,`Message`)}),W?e(q,{size:`sm`,variant:`secondary`,type:`button`,onClick:ie,children:[i(M,{className:`h-3.5 w-3.5`}),c(`ai.stop`,`Stop`)]}):e(q,{size:`sm`,type:`button`,disabled:y.trim()===``||u===``,onClick:re,children:[i(R,{className:`h-3.5 w-3.5`}),c(`ai.send`,`Send`)]})]})]})]})]})}function zt({turns:t,live:n}){let{t:r}=Q();return t.length===0&&n===null?i(H,{icon:L,title:r(`ai.chatEmptyTitle`,`No messages yet`),description:r(`ai.chatEmpty`,`Pick a profile, optionally attach a camera snapshot or a recent track, and send a message. Nothing here is saved.`)}):e(`div`,{className:`max-h-[50vh] space-y-2 overflow-y-auto ${d}`,children:[t.map(e=>i(Bt,{turn:e},e.id)),n!==null&&e(`div`,{className:`space-y-1`,children:[n.mediaSent!==null&&i(Vt,{attachment:n.mediaSent}),n.text.length>0&&i(Bt,{turn:{id:`live`,role:`assistant`,content:n.text},streaming:!0}),e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(O,{className:`h-3.5 w-3.5 animate-spin`}),Mt(n.phase,n.firstTokenTimeoutMs)]})]})]})}function Bt({turn:t,streaming:n=!1}){let{t:r}=Q(),a=t.role===`user`,o=t.failed===!0?`border-danger/40 bg-danger/10`:`border-border bg-surface`;return i(`div`,{className:`flex ${a?`justify-end`:`justify-start`}`,children:e(`div`,{className:`max-w-[85%] rounded-lg border px-3 py-2 ${a?`border-primary/40 bg-primary/10`:o}`,children:[e(`p`,{className:`whitespace-pre-wrap break-words text-xs text-foreground`,children:[t.content,n&&i(`span`,{className:`ml-0.5 animate-pulse text-primary`,children:`▌`})]}),t.attachment!==void 0&&i(Vt,{attachment:t.attachment}),t.attachmentLabel!==void 0&&e(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[t.attachmentKind===`track`?i(_,{className:`h-3 w-3`}):i(v,{className:`h-3 w-3`}),t.attachmentLabel]}),t.attachment!==void 0&&e(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[t.attachment.kind===`snapshot`?i(v,{className:`h-3 w-3`}):i(_,{className:`h-3 w-3`}),jt(t.attachment)]}),t.model!==void 0&&i(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:r(`system.aiTestChat.tokMs`,`{{model}} · {{value2}} tok · {{value3}} ms`,{model:t.model,value2:String(t.outputTokens??0),value3:String(t.latencyMs??0)})})]})})}function Vt({attachment:e}){let{t}=Q(),n=kt(e);return n===null?null:i(`img`,{src:n,alt:t(`system.aiTestChat.sentToTheModel`,`sent to the model`),className:`mt-1 max-h-32 rounded-md border border-border object-contain`})}function Ht({onPick:e}){let{t}=Q(),n=B({isCamera:!0,projection:`slim`}),r=(n.data??[]).filter(e=>!e.disabled);return n.isLoading?i(O,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noCameras`,`No camera found.`)}):i(`div`,{className:`grid max-h-56 grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-4`,children:r.map(t=>i(Ut,{device:t,onPick:e},t.id))})}function Ut({device:t,onPick:n}){let{t:r}=Q(),a=U(t,`compact`),{src:o}=m(t.id,{width:It});return e(`button`,{type:`button`,onClick:()=>n(t,a),className:`overflow-hidden rounded-md border border-border bg-surface text-left transition-colors hover:border-primary/50`,children:[i(`span`,{className:`block aspect-video w-full bg-background-elevated`,children:o!==null&&i(`img`,{src:o,alt:``,className:`h-full w-full object-cover`,loading:`lazy`})}),e(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[!t.online&&i(X,{variant:`warning`,children:r(`common.off`)}),i(`span`,{className:`truncate text-[10px] text-foreground`,children:a})]})]})}function Wt({onPick:t}){let{t:r}=Q(),a=D(),o=B({isCamera:!0,projection:`slim`}),c=n(()=>(o.data??[]).map(e=>e.id),[o.data]),l=n(()=>{let e=new Map;for(let t of o.data??[])e.set(t.id,t.name);return e},[o.data]),u=s({queryKey:[...Nt,c.length],enabled:c.length>0,queryFn:()=>a.trpcClient.pipelineAnalytics.listRecentTracks.query({deviceIds:[...c],since:Date.now()-Pt,limit:Ft,projection:`slim`})});if(o.isLoading||u.isLoading)return i(O,{className:`h-4 w-4 animate-spin text-foreground-subtle`});let d=u.data?.tracks??[];return d.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`ai.noTracks`,`No track in the last 6 hours.`)}):i(`div`,{className:`max-h-56 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:d.map(n=>e(`button`,{type:`button`,onClick:()=>t(n,l.get(n.deviceId)??String(n.deviceId)),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover`,children:[i(_,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:n.label??n.className}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:l.get(n.deviceId)??n.deviceId}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:new Date(n.lastSeen).toLocaleTimeString()})]},n.trackId))})}c();var Gt=1440*60*1e3,Kt=[1,7,30,90];function qt(){let{t}=Q(),r=D(),[a,c]=o(7),l=n(()=>{let e=new Date;return e.setHours(0,0,0,0),e.getTime()-(a-1)*Gt},[a]),u=s({queryKey:ye,queryFn:()=>r.trpcClient.llm.listProfiles.query({})}),f=s({queryKey:[...we,a],queryFn:()=>r.trpcClient.llm.getUsage.query({since:l})}),p=n(()=>{let e=new Map;for(let t of u.data??[])e.set(t.id,t.name);return e},[u.data]),m=n(()=>[{key:`day`,header:t(`ai.colDay`,`Day`),nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:e.day})},{key:`consumer`,header:t(`ai.colConsumer`,`Consumer`),nowrap:!0,render:e=>i(`span`,{className:`text-foreground`,children:e.consumer})},{key:`profile`,header:t(`ai.colProfile`,`Profile`),render:e=>i(`span`,{className:`text-foreground`,children:p.get(e.profileId)??e.profileId})},{key:`calls`,header:t(`ai.colCalls`,`Calls`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:String(e.calls)})},{key:`okErr`,header:t(`ai.colOkErr`,`OK / err`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums ${e.errorCalls>0?`text-danger`:``}`,children:`${String(e.okCalls)} / ${String(e.errorCalls)}`})},{key:`tokens`,header:t(`ai.colTokens`,`In / out tok`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:`${String(e.inputTokens)} / ${String(e.outputTokens)}`})},{key:`latency`,header:t(`ai.colAvgMs`,`Avg ms`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:String(Math.round(e.avgLatencyMs))})}],[p,t]),h=f.data??[],g=i(`div`,{className:`w-36`,children:i(Y,{"aria-label":t(`ai.window`,`Window`),value:String(a),options:Kt.map(e=>({value:String(e),label:t(`ai.lastDays`,`Last {{days}} days`,{days:e})})),onChange:e=>c(Number(e.target.value))})});return i(J,{headingId:`ai-usage-list`,title:t(`ai.usageList`,`Rollup`),actions:g,children:f.isPending?e(`div`,{className:`${d} space-y-2`,"data-testid":`ai-usage-loading`,children:[i(G,{className:`h-8 w-full`}),i(G,{className:`h-8 w-full`}),i(G,{className:`h-8 w-full`})]}):f.isError?i(`div`,{className:d,children:i(K,{title:t(`ai.usageFailed`,`Failed to read usage`),message:f.error instanceof Error?f.error.message:t(`common.error`,`Error`),onRetry:()=>void f.refetch()})}):h.length===0?i(H,{icon:b,title:t(`ai.noUsage`,`No AI calls in this window.`)}):i(ie,{columns:m,rows:h,rowKey:e=>`${e.day}|${e.consumer}|${e.profileId}`,minWidthPx:720,bordered:!1,maxBodyHeight:z})})}var Jt=`llm`,Yt=[`profiles`,`runtimes`,`usage`,`test`],Xt=[`new`,`edit`];function Zt(e){return Yt.some(t=>t===e)}function Qt(){let{t}=Q(),n=V(Jt),[r]=he(),{openNew:a}=ce(),o=me(`/system/ai`,{t,isAdmin:!0})??{icon:j,title:t(`system.ai`,`AI`)};if(n!==`present`)return i(_e,{icon:o.icon,title:o.title,children:i($t,{presence:n})});let s=r.get(`tab`),c=Zt(s)?s:`profiles`,l={profiles:t(`ai.profilesSubtitle`,`One row = one usable model endpoint. The defaults below decide who answers when a feature names no profile.`),runtimes:t(`ai.runtimesSubtitle`,`Nodes advertising the llm-runtime capability: what each has loaded, what it is downloading, and how much model data sits on its disk.`),usage:t(`ai.usageSubtitle`,`Server-side rollup per day, consumer and profile — never raw call rows. Errors are counted, so a profile that always fails is visible here before a feature reports it.`),test:t(`ai.testSubtitle`,`A throwaway conversation with one profile. Attach a live camera snapshot or a recent track to check the model can actually read a picture. Nothing is saved — only the usage row.`)},u=c===`profiles`?e(q,{size:`sm`,type:`button`,"data-testid":`ai-add-profile`,onClick:a,children:[i(p,{className:`h-3.5 w-3.5`}),t(`ai.addProfile`,`Add profile`)]}):void 0;return i(ge,{icon:o.icon,title:o.title,subtitle:l[c],actions:u,defaultSection:`profiles`,sectionsLabel:`${o.title} sections`,sections:[{id:`profiles`,label:t(`ai.tabProfiles`,`Profiles`),content:i(mt,{}),ownedParams:Xt},{id:`runtimes`,label:t(`ai.tabRuntimes`,`Runtimes`),content:i(vt,{})},{id:`usage`,label:t(`ai.tabUsage`,`Usage`),content:i(qt,{})},{id:`test`,label:t(`ai.tabTest`,`Test`),content:i(Rt,{})}]})}function $t({presence:t}){let{t:n}=Q();return t===`pending`?e(`div`,{className:`space-y-3`,"data-testid":`ai-presence-pending`,children:[i(G,{className:`h-8 w-64`}),i(G,{className:`h-40 w-full`})]}):t===`unknown`?i(K,{title:n(`ai.presenceUnknownTitle`,`Could not check whether AI is installed`),message:n(`ai.presenceUnknown`,`The hub did not answer the capability check. Reload the page to try again.`)}):i(H,{icon:j,title:n(`ai.absentTitle`,`AI is not installed`),description:n(`ai.absentDescription`,`Install the AI addon from System → Addons to add model profiles.`)})}export{Qt as AiProfilesPage,Qt as default};