@camstack/addon-admin-ui 1.2.352 → 1.2.354
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/assets/Addons-BK4doplV.js +4 -0
- package/dist/assets/{AdminTabs-CZPAmhas.js → AdminTabs-BhOeTpzS.js} +1 -1
- package/dist/assets/AiProfiles-LwSpryE9.js +3 -0
- package/dist/assets/{BrokerForm-CHyLrgZU.js → BrokerForm-BcIi7X-k.js} +1 -1
- package/dist/assets/Build-lkz9i41s.js +40 -0
- package/dist/assets/{Calendars-Bp7O4Q0e.js → Calendars-B0fN7lOZ.js} +1 -1
- package/dist/assets/{Capabilities-BwrQQsWg.js → Capabilities-DT5AfeU6.js} +1 -1
- package/dist/assets/Cluster-BU-IW9ia.js +11 -0
- package/dist/assets/ClusterStepModel-CV8nR3LE.js +1 -0
- package/dist/assets/CompositionEditor-CRGXdz6W.js +1 -0
- package/dist/assets/{CompositionEditorPage-B6M-10Ch.js → CompositionEditorPage-vZmTGOZa.js} +1 -1
- package/dist/assets/Data-Devgvo7R.js +1 -0
- package/dist/assets/DetectionIntelligence-BNouaDPB.js +1 -0
- package/dist/assets/DeviceDetail-Bwdzgfsp.js +2 -0
- package/dist/assets/{DeviceDoActionFields-rqWve7Cc.js → DeviceDoActionFields-ByplmFm2.js} +1 -1
- package/dist/assets/{Devices-KcQPMfTP.js → Devices-CzY-IKW4.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-jqACjBI1.js → EmbedPlayerPage-DWY9Lhk4.js} +1 -1
- package/dist/assets/Events-BgvUDZye.js +1 -0
- package/dist/assets/Identity-CVki_J0y.js +1 -0
- package/dist/assets/IntegrationDetail-CFe1KUYl.js +1 -0
- package/dist/assets/IntegrationHub-DPnXLm5X.js +1 -0
- package/dist/assets/Integrations-D_Q4Q2Tu.js +1 -0
- package/dist/assets/Integrations-a2p57lhh.js +1 -0
- package/dist/assets/Locations-Bi-vKJNZ.js +3 -0
- package/dist/assets/{Logs-DRTuZa-s.js → Logs-D9Z3ttJa.js} +1 -1
- package/dist/assets/{MotionZonesSettings-BWlY0uhl.js → MotionZonesSettings-DLDLTjEm.js} +1 -1
- package/dist/assets/MyAccess-Bwn4T2qP.js +2 -0
- package/dist/assets/Network-WFS_m89k.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-DaKtOtU5.js → NodeAddonsSettingsPanel-DIsYvw9n.js} +1 -1
- package/dist/assets/Notifications-DWRse6RT.js +1 -0
- package/dist/assets/Plates-Dt0TJWJz.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-z1qT12AK.js → PrivacyMaskSettings-Duop0Nv-.js} +1 -1
- package/dist/assets/Recordings-C9pif7GZ.js +1 -0
- package/dist/assets/ScanNetworkModal-DED--MPT.js +1 -0
- package/dist/assets/{SceneMonitorEditor-DqvGdipD.js → SceneMonitorEditor-DW0CWVpI.js} +1 -1
- package/dist/assets/{Scenes-_7asi5eD.js → Scenes-uql5nKII.js} +1 -1
- package/dist/assets/{Settings-FlIRnDpv.js → Settings-D9iP6dNh.js} +1 -1
- package/dist/assets/{Showroom-DBp7iZ0G.js → Showroom-tad-iI89.js} +1 -1
- package/dist/assets/{Terminal-K34D1Ywo.js → Terminal-CNbcxFd6.js} +3 -3
- package/dist/assets/{Viewer-BYJtbGy9.js → Viewer-CFDK9NZ7.js} +1 -1
- package/dist/assets/{__vite-browser-external-Cc3gW-QT.js → __vite-browser-external-DF8Eb0aa.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-VirN8RQI.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-IsYcVs88.js} +1 -1
- package/dist/assets/{archive-BCuy69tM.js → archive-DNJAWP0V.js} +1 -1
- package/dist/assets/{authed-media-C08zoxUE.js → authed-media-D6G9zhfa.js} +1 -1
- package/dist/assets/{boxes-Co2Q90CO.js → boxes-BvyAsUqS.js} +1 -1
- package/dist/assets/circle-slash-L3gtCdUp.js +1 -0
- package/dist/assets/client-B39fb-5f.js +357 -0
- package/dist/assets/crop-9Uo16aZV.js +1 -0
- package/dist/assets/{debounced-invalidate-4bQv6974.js → debounced-invalidate-B9MDA5Pm.js} +1 -1
- package/dist/assets/{device-integration-icon-DMx3ZoRE.js → device-integration-icon-5QFgnyqj.js} +1 -1
- package/dist/assets/device-picker-model-CFoBiQlw.js +1 -0
- package/dist/assets/{dist-CupfglO0.js → dist-Bb5UmIgC.js} +1 -1
- package/dist/assets/dist-CaF0IBF0.js +357 -0
- package/dist/assets/{face-bbox-UX05kDZA.js → face-bbox-BnhKQ-DD.js} +1 -1
- package/dist/assets/{hard-drive-download-gfGmt8d5.js → hard-drive-download-DPC7ldA-.js} +1 -1
- package/dist/assets/{hostInit-BKiqkTOp.js → hostInit-vIPYIM3V.js} +1 -1
- package/dist/assets/index-4T59f71F.js +4 -0
- package/dist/assets/{layers-DOEpCuQZ.js → layers-CT9pfE_S.js} +1 -1
- package/dist/assets/{location-owned-usage-BLkNLXfg.js → location-owned-usage-Bf05xmeX.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-72b0f0d1.js → mf-entry-bootstrap-0-8000e3a6.js} +2 -2
- package/dist/assets/mount-CFoBiQlw.js +1 -0
- package/dist/assets/notification-schedule-field-DwaGi1xB.js +1 -0
- package/dist/assets/{player-overlays-BFYAtS6k.js → player-overlays-BOmyWZfG.js} +1 -1
- package/dist/assets/remoteEntry-D2ZsmuAM.js +1 -0
- package/dist/assets/{send-CYjwgPvF.js → send-CDRgtlhp.js} +1 -1
- package/dist/assets/{settings-2-DzUYHDiK.js → settings-2-921DSlZF.js} +1 -1
- package/dist/assets/src-Dj3kqlvn.js +67 -0
- package/dist/assets/unlink-D-XpELXi.js +1 -0
- package/dist/assets/{use-scenes-feed--Nza8Rhx.js → use-scenes-feed-DLhiAewy.js} +1 -1
- package/dist/assets/{use-stationary-objects-CJwD3-xc.js → use-stationary-objects-VZzKIBwG.js} +1 -1
- package/dist/assets/useEventInvalidation-CFoBiQlw.js +1 -0
- package/dist/assets/{useNodeUrlSelection-DKxGlIbc.js → useNodeUrlSelection-Bip3BpQO.js} +1 -1
- package/dist/assets/user-round-BRSQ0WPK.js +1 -0
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-MXxx-qLy.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BTr5fMW1.js} +2 -2
- package/dist/index.html +8 -8
- package/dist/server/addon.js +186 -8
- package/package.json +1 -1
- package/dist/assets/Addons-CGDc3MCi.js +0 -4
- package/dist/assets/AiProfiles-Cb885xLi.js +0 -3
- package/dist/assets/Build-Cq1iHbS5.js +0 -40
- package/dist/assets/Cluster-BxZqJz_z.js +0 -11
- package/dist/assets/ClusterStepModel-BXQrb9-2.js +0 -1
- package/dist/assets/CompositionEditor-CWseh3e4.js +0 -1
- package/dist/assets/Data-8_oyAAFm.js +0 -1
- package/dist/assets/DetectionIntelligence-ZAxkWwsC.js +0 -1
- package/dist/assets/DeviceDetail-CZeHFThw.js +0 -2
- package/dist/assets/Events-BF592qf_.js +0 -1
- package/dist/assets/Identity-Cts1UzJ3.js +0 -1
- package/dist/assets/IntegrationDetail-CPXel_5q.js +0 -1
- package/dist/assets/IntegrationHub-P7DZLhMu.js +0 -1
- package/dist/assets/Integrations-BkAo2E4O.js +0 -1
- package/dist/assets/Integrations-COJxgwuo.js +0 -1
- package/dist/assets/Locations-CHSHPbFF.js +0 -3
- package/dist/assets/MyAccess-C4ubGrSr.js +0 -2
- package/dist/assets/Network-BOzx7hn8.js +0 -1
- package/dist/assets/Notifications-D_GaC55O.js +0 -1
- package/dist/assets/Plates-Di4sfAWp.js +0 -1
- package/dist/assets/Recordings-BmNingKf.js +0 -1
- package/dist/assets/ScanNetworkModal-ByV68CCf.js +0 -1
- package/dist/assets/circle-slash-0LfB3qk4.js +0 -1
- package/dist/assets/client-Diiyoh60.js +0 -357
- package/dist/assets/crop--L-amBAa.js +0 -1
- package/dist/assets/device-picker-model-D073lAZn.js +0 -1
- package/dist/assets/dist-Lw8PosIF.js +0 -357
- package/dist/assets/index-cOBEaAEQ.js +0 -4
- package/dist/assets/mount-D073lAZn.js +0 -1
- package/dist/assets/notification-schedule-field-B8_FhM0a.js +0 -1
- package/dist/assets/remoteEntry-BY-9rdAo.js +0 -1
- package/dist/assets/src-CPNx7Cnt.js +0 -67
- package/dist/assets/useEventInvalidation-D073lAZn.js +0 -1
- package/dist/assets/user-round-BfNCEGcF.js +0 -1
package/dist/server/addon.js
CHANGED
|
@@ -5371,7 +5371,7 @@ var ZodIssueCode = {
|
|
|
5371
5371
|
var ZodFirstPartyTypeKind;
|
|
5372
5372
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5373
5373
|
//#endregion
|
|
5374
|
-
//#region ../types/dist/sleep-
|
|
5374
|
+
//#region ../types/dist/sleep-B0JG7-_F.mjs
|
|
5375
5375
|
/**
|
|
5376
5376
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5377
5377
|
* window to float samples (D455).
|
|
@@ -14794,6 +14794,10 @@ var DeviceInfoSchema = object({
|
|
|
14794
14794
|
isCamera: boolean(),
|
|
14795
14795
|
/** Current config values — serializable snapshot */
|
|
14796
14796
|
config: record(string(), unknown()),
|
|
14797
|
+
/** Paths inside `config` the device's schema declares secret (D783) —
|
|
14798
|
+
* what the non-admin redaction withholds. Paths, never values. Absent
|
|
14799
|
+
* when the owning runner has not reported them. */
|
|
14800
|
+
secretConfigPaths: array(string()).optional(),
|
|
14797
14801
|
/** Hardware + identity blob (manufacturer / model / firmware / sn /
|
|
14798
14802
|
* uid / mac / …). Populated by drivers; editable via setMetadata. */
|
|
14799
14803
|
metadata: record(string(), unknown()).nullable().optional(),
|
|
@@ -14999,7 +15003,13 @@ var DeviceRegisterPayloadSchema = object({
|
|
|
14999
15003
|
* call (workers re-register on init), so probe-driven updates
|
|
15000
15004
|
* (e.g. PTZ flag flipping after the abilities probe) propagate. */
|
|
15001
15005
|
features: array(string()).optional(),
|
|
15002
|
-
config: record(string(), unknown())
|
|
15006
|
+
config: record(string(), unknown()),
|
|
15007
|
+
/** Config paths the device's own schema DECLARES secret
|
|
15008
|
+
* (`.meta({ secret: true })` — dotted, `[]` for array items, e.g.
|
|
15009
|
+
* `connection.password`). Re-published on every register; the non-admin
|
|
15010
|
+
* redaction withholds them at any depth (D783). Optional: an older runner
|
|
15011
|
+
* omits it and the keyword backstop applies. */
|
|
15012
|
+
secretConfigPaths: array(string()).optional()
|
|
15003
15013
|
});
|
|
15004
15014
|
var DeviceRemovePayloadSchema = object({ deviceId: number() });
|
|
15005
15015
|
var DevicePersistConfigPayloadSchema = object({
|
|
@@ -16658,7 +16668,14 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
|
|
|
16658
16668
|
icon: string().optional(),
|
|
16659
16669
|
/** Addon-owned HTTP route the button navigates to (GET). */
|
|
16660
16670
|
startUrl: string(),
|
|
16661
|
-
stage: LoginStageEnum
|
|
16671
|
+
stage: LoginStageEnum,
|
|
16672
|
+
/**
|
|
16673
|
+
* The provider names an external identity a signed-in user can link to
|
|
16674
|
+
* their own account (D782): `auth.listLinkableProviders` /
|
|
16675
|
+
* `beginExternalLink` offer exactly the redirect methods that set this,
|
|
16676
|
+
* whatever their id. Absent / false — a login button only (magic-link).
|
|
16677
|
+
*/
|
|
16678
|
+
linkable: boolean().optional()
|
|
16662
16679
|
}),
|
|
16663
16680
|
object({
|
|
16664
16681
|
kind: literal("widget"),
|
|
@@ -22055,7 +22072,13 @@ var RetrainFrameSchema = object({
|
|
|
22055
22072
|
sizeBytes: number().int(),
|
|
22056
22073
|
width: number().int(),
|
|
22057
22074
|
height: number().int(),
|
|
22058
|
-
copiedAt: number()
|
|
22075
|
+
copiedAt: number(),
|
|
22076
|
+
/** When the CAMERA captured the frame. Absent on a copy taken before D785. */
|
|
22077
|
+
capturedAt: number().optional(),
|
|
22078
|
+
/** The operator's "every subject in this frame is boxed". Detector
|
|
22079
|
+
* evaluation keeps only complete frames: an unboxed subject would count as
|
|
22080
|
+
* a false positive. */
|
|
22081
|
+
complete: boolean()
|
|
22059
22082
|
});
|
|
22060
22083
|
/** Why a copy-on-select could not be honoured — named, never a silent skip. */
|
|
22061
22084
|
var RetrainCopyRefusalSchema = _enum([
|
|
@@ -22076,6 +22099,51 @@ var RetrainFrameListSchema = object({
|
|
|
22076
22099
|
/** What the page pre-selects — the native key frame when one survives. */
|
|
22077
22100
|
autoPickMediaId: number().int().optional()
|
|
22078
22101
|
});
|
|
22102
|
+
/**
|
|
22103
|
+
* Which frames an annotated export carries. Every field narrows; an empty
|
|
22104
|
+
* filter is every annotated copy. A dataset VERSION is a frozen `frameIds`
|
|
22105
|
+
* list owned by whoever trains (the training orchestrator), so `frameIds` is
|
|
22106
|
+
* the primitive a version export uses; `batchId` re-selects what an earlier
|
|
22107
|
+
* export carried (`exportedInBatch`).
|
|
22108
|
+
*/
|
|
22109
|
+
var RetrainExportFilterSchema = object({
|
|
22110
|
+
deviceIds: array(number()).optional(),
|
|
22111
|
+
frameIds: array(string()).max(2e4).optional(),
|
|
22112
|
+
batchId: string().optional(),
|
|
22113
|
+
/** Only frames the operator marked complete (all subjects boxed). */
|
|
22114
|
+
completeOnly: boolean().optional()
|
|
22115
|
+
});
|
|
22116
|
+
/**
|
|
22117
|
+
* `frames`: the full frame copies, boxes in `annotations.json`.
|
|
22118
|
+
* `crops`: additionally one JPEG per subject, cut with the runtime detail-crop
|
|
22119
|
+
* convention — the classifier layout.
|
|
22120
|
+
*/
|
|
22121
|
+
var RetrainExportLayoutSchema = _enum(["frames", "crops"]);
|
|
22122
|
+
/**
|
|
22123
|
+
* Where `writeRetrainArchive` streams the tar: one HTTP request whose body is
|
|
22124
|
+
* the archive, sent chunk by chunk. Covers a presigned PUT and a provider
|
|
22125
|
+
* addon's data-plane upload route alike. Headers are sent verbatim and never
|
|
22126
|
+
* logged.
|
|
22127
|
+
*/
|
|
22128
|
+
var RetrainArchiveTargetSchema = object({
|
|
22129
|
+
kind: literal("http"),
|
|
22130
|
+
method: _enum(["PUT", "POST"]),
|
|
22131
|
+
url: string().url(),
|
|
22132
|
+
headers: record(string(), string()).optional()
|
|
22133
|
+
});
|
|
22134
|
+
var RetrainArchiveResultSchema = object({
|
|
22135
|
+
batchId: string(),
|
|
22136
|
+
frames: number().int(),
|
|
22137
|
+
crops: number().int(),
|
|
22138
|
+
annotations: number().int(),
|
|
22139
|
+
/** Frames planned but not shipped (unreadable copy, path too long). */
|
|
22140
|
+
missing: number().int(),
|
|
22141
|
+
bytes: number().int(),
|
|
22142
|
+
/** sha256 of the exact bytes sent. */
|
|
22143
|
+
sha256: string(),
|
|
22144
|
+
/** The target's HTTP status. */
|
|
22145
|
+
status: number().int()
|
|
22146
|
+
});
|
|
22079
22147
|
/** What the operator asked the assist to look for. */
|
|
22080
22148
|
var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
|
|
22081
22149
|
kind: literal("package"),
|
|
@@ -22870,9 +22938,25 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
22870
22938
|
}), RetrainTransitionResultSchema, {
|
|
22871
22939
|
kind: "mutation",
|
|
22872
22940
|
auth: "admin"
|
|
22873
|
-
}), method(
|
|
22941
|
+
}), method(RetrainExportFilterSchema.extend({ layout: RetrainExportLayoutSchema.optional() }), object({ url: string() }), {
|
|
22874
22942
|
kind: "query",
|
|
22875
22943
|
auth: "admin"
|
|
22944
|
+
}), method(object({
|
|
22945
|
+
deviceId: number(),
|
|
22946
|
+
trackId: string(),
|
|
22947
|
+
frameId: string(),
|
|
22948
|
+
complete: boolean()
|
|
22949
|
+
}), RetrainFrameSchema, {
|
|
22950
|
+
kind: "mutation",
|
|
22951
|
+
auth: "admin"
|
|
22952
|
+
}), method(object({
|
|
22953
|
+
filter: RetrainExportFilterSchema,
|
|
22954
|
+
layout: RetrainExportLayoutSchema,
|
|
22955
|
+
target: RetrainArchiveTargetSchema
|
|
22956
|
+
}), RetrainArchiveResultSchema, {
|
|
22957
|
+
kind: "mutation",
|
|
22958
|
+
auth: "admin",
|
|
22959
|
+
timeoutMs: 60 * 6e4
|
|
22876
22960
|
}), method(object({
|
|
22877
22961
|
/** Which of the three event tables owns the row. */
|
|
22878
22962
|
ownerType: EventOwnerTypeSchema,
|
|
@@ -26162,7 +26246,19 @@ var SsoBridgeClaimsSchema = object({
|
|
|
26162
26246
|
* editing a descriptor must not retroactively extend or shorten a link the
|
|
26163
26247
|
* operator already consented to.
|
|
26164
26248
|
*/
|
|
26165
|
-
refreshTtl: union([number().int().positive(), literal("never")]).optional()
|
|
26249
|
+
refreshTtl: union([number().int().positive(), literal("never")]).optional(),
|
|
26250
|
+
/**
|
|
26251
|
+
* Opaque handle of a hub-side LINK intent (D782). Set by an OIDC callback
|
|
26252
|
+
* that was started from a signed-in user's "Link" button: the finish then
|
|
26253
|
+
* links this identity to the intent's user instead of signing anyone in.
|
|
26254
|
+
* The handle carries no user id — the hub resolves it, single-use.
|
|
26255
|
+
*/
|
|
26256
|
+
linkIntent: string().optional(),
|
|
26257
|
+
/**
|
|
26258
|
+
* Verified `iss` of the id_token behind an OIDC login bridge (D782). A
|
|
26259
|
+
* subject is unique only per issuer, so a link is bound to it.
|
|
26260
|
+
*/
|
|
26261
|
+
issuer: string().optional()
|
|
26166
26262
|
});
|
|
26167
26263
|
method(object({
|
|
26168
26264
|
claims: SsoBridgeClaimsSchema,
|
|
@@ -36127,6 +36223,32 @@ var TotpStatusSchema = object({
|
|
|
36127
36223
|
/** Null when no row exists OR the row is still pending confirmation. */
|
|
36128
36224
|
confirmedAt: number().nullable()
|
|
36129
36225
|
});
|
|
36226
|
+
/**
|
|
36227
|
+
* user-management — singleton capability for user accounts, API keys,
|
|
36228
|
+
* and scoped tokens.
|
|
36229
|
+
*
|
|
36230
|
+
* v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
|
|
36231
|
+
* — the subset check on `setUserScopes` / `createScopedToken` is moot
|
|
36232
|
+
* because non-admins never reach these. If/when we open non-admin
|
|
36233
|
+
* delegation, structural caller-scope subset check goes inside the
|
|
36234
|
+
* provider.
|
|
36235
|
+
*/
|
|
36236
|
+
var ExternalIdentitySchema = object({
|
|
36237
|
+
/** Login-method id of the provider instance, e.g. `auth-oidc/authentik`. */
|
|
36238
|
+
provider: string(),
|
|
36239
|
+
/** The IdP's stable subject (`sub`) for this account. */
|
|
36240
|
+
subject: string(),
|
|
36241
|
+
/** The verified `iss` of the IdP the identity was linked under — `sub` is unique only per issuer. */
|
|
36242
|
+
issuer: string(),
|
|
36243
|
+
userId: string(),
|
|
36244
|
+
/** What the IdP called the account at link time (username / email) — display only. */
|
|
36245
|
+
label: string().optional(),
|
|
36246
|
+
linkedAt: number()
|
|
36247
|
+
});
|
|
36248
|
+
var ExternalIdentityKeySchema = object({
|
|
36249
|
+
provider: string().min(1),
|
|
36250
|
+
subject: string().min(1)
|
|
36251
|
+
});
|
|
36130
36252
|
method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserInputSchema, UserSummarySchema, {
|
|
36131
36253
|
kind: "mutation",
|
|
36132
36254
|
auth: "admin",
|
|
@@ -36240,7 +36362,22 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
|
|
|
36240
36362
|
userId: string(),
|
|
36241
36363
|
username: string(),
|
|
36242
36364
|
scopes: array(TokenScopeSchema)
|
|
36243
|
-
}).nullable(), { access: "view" }), method(
|
|
36365
|
+
}).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
|
|
36366
|
+
userId: string(),
|
|
36367
|
+
issuer: string()
|
|
36368
|
+
}).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
|
|
36369
|
+
userId: string(),
|
|
36370
|
+
issuer: string().min(1),
|
|
36371
|
+
label: string().optional()
|
|
36372
|
+
}), object({ success: literal(true) }), {
|
|
36373
|
+
kind: "mutation",
|
|
36374
|
+
auth: "admin",
|
|
36375
|
+
access: "create"
|
|
36376
|
+
}), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
|
|
36377
|
+
kind: "mutation",
|
|
36378
|
+
auth: "admin",
|
|
36379
|
+
access: "delete"
|
|
36380
|
+
}), method(_void(), array(OauthSessionSummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: boolean() }), {
|
|
36244
36381
|
kind: "mutation",
|
|
36245
36382
|
auth: "admin",
|
|
36246
36383
|
access: "delete"
|
|
@@ -41046,6 +41183,12 @@ Object.freeze({
|
|
|
41046
41183
|
addonId: null,
|
|
41047
41184
|
access: "create"
|
|
41048
41185
|
},
|
|
41186
|
+
"pipelineAnalytics.setRetrainFrameComplete": {
|
|
41187
|
+
capName: "pipeline-analytics",
|
|
41188
|
+
capScope: "device",
|
|
41189
|
+
addonId: null,
|
|
41190
|
+
access: "create"
|
|
41191
|
+
},
|
|
41049
41192
|
"pipelineAnalytics.setTrackFlags": {
|
|
41050
41193
|
capName: "pipeline-analytics",
|
|
41051
41194
|
capScope: "device",
|
|
@@ -41082,6 +41225,12 @@ Object.freeze({
|
|
|
41082
41225
|
addonId: null,
|
|
41083
41226
|
access: "delete"
|
|
41084
41227
|
},
|
|
41228
|
+
"pipelineAnalytics.writeRetrainArchive": {
|
|
41229
|
+
capName: "pipeline-analytics",
|
|
41230
|
+
capScope: "device",
|
|
41231
|
+
addonId: null,
|
|
41232
|
+
access: "create"
|
|
41233
|
+
},
|
|
41085
41234
|
"pipelineExecutor.cacheFrameInPool": {
|
|
41086
41235
|
capName: "pipeline-executor",
|
|
41087
41236
|
capScope: "system",
|
|
@@ -43434,18 +43583,36 @@ Object.freeze({
|
|
|
43434
43583
|
addonId: null,
|
|
43435
43584
|
access: "delete"
|
|
43436
43585
|
},
|
|
43586
|
+
"userManagement.findUserByExternalIdentity": {
|
|
43587
|
+
capName: "user-management",
|
|
43588
|
+
capScope: "system",
|
|
43589
|
+
addonId: null,
|
|
43590
|
+
access: "view"
|
|
43591
|
+
},
|
|
43437
43592
|
"userManagement.getTotpStatus": {
|
|
43438
43593
|
capName: "user-management",
|
|
43439
43594
|
capScope: "system",
|
|
43440
43595
|
addonId: null,
|
|
43441
43596
|
access: "view"
|
|
43442
43597
|
},
|
|
43598
|
+
"userManagement.linkExternalIdentity": {
|
|
43599
|
+
capName: "user-management",
|
|
43600
|
+
capScope: "system",
|
|
43601
|
+
addonId: null,
|
|
43602
|
+
access: "create"
|
|
43603
|
+
},
|
|
43443
43604
|
"userManagement.listApiKeys": {
|
|
43444
43605
|
capName: "user-management",
|
|
43445
43606
|
capScope: "system",
|
|
43446
43607
|
addonId: null,
|
|
43447
43608
|
access: "view"
|
|
43448
43609
|
},
|
|
43610
|
+
"userManagement.listExternalIdentities": {
|
|
43611
|
+
capName: "user-management",
|
|
43612
|
+
capScope: "system",
|
|
43613
|
+
addonId: null,
|
|
43614
|
+
access: "view"
|
|
43615
|
+
},
|
|
43449
43616
|
"userManagement.listOauthSessions": {
|
|
43450
43617
|
capName: "user-management",
|
|
43451
43618
|
capScope: "system",
|
|
@@ -43524,6 +43691,12 @@ Object.freeze({
|
|
|
43524
43691
|
addonId: null,
|
|
43525
43692
|
access: "create"
|
|
43526
43693
|
},
|
|
43694
|
+
"userManagement.unlinkExternalIdentity": {
|
|
43695
|
+
capName: "user-management",
|
|
43696
|
+
capScope: "system",
|
|
43697
|
+
addonId: null,
|
|
43698
|
+
access: "delete"
|
|
43699
|
+
},
|
|
43527
43700
|
"userManagement.updateUser": {
|
|
43528
43701
|
capName: "user-management",
|
|
43529
43702
|
capScope: "system",
|
|
@@ -46863,6 +47036,11 @@ Object.freeze({
|
|
|
46863
47036
|
form: "single",
|
|
46864
47037
|
optional: false
|
|
46865
47038
|
}],
|
|
47039
|
+
"pipelineAnalytics.setRetrainFrameComplete": [{
|
|
47040
|
+
name: "deviceId",
|
|
47041
|
+
form: "single",
|
|
47042
|
+
optional: false
|
|
47043
|
+
}],
|
|
46866
47044
|
"pipelineAnalytics.setTrackFlags": [{
|
|
46867
47045
|
name: "deviceId",
|
|
46868
47046
|
form: "single",
|
|
@@ -48932,7 +49110,7 @@ var AdminUIAddon = class extends BaseAddon {
|
|
|
48932
49110
|
capability: adminUiCapability,
|
|
48933
49111
|
provider: {
|
|
48934
49112
|
getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
|
|
48935
|
-
getVersion: async () => ({ version: "1.2.
|
|
49113
|
+
getVersion: async () => ({ version: "1.2.354" })
|
|
48936
49114
|
}
|
|
48937
49115
|
}];
|
|
48938
49116
|
}
|
package/package.json
CHANGED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,R as r,S as i,W as a,b as o,o as s,q as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as d,gt as f,st as p,vt as m}from"./player-overlays-BFYAtS6k.js";import{Ar as h,Au as g,Bd as _,Br as v,Bu as y,Cr as b,Dr as x,Er as S,F as C,Fr as w,G as T,Hd as E,Hl as ee,Hr as te,Io as D,Ir as ne,Kl as O,Ku as re,Ld as ie,Lr as k,Lu as A,Md as j,Mr as M,Nr as ae,Ou as N,Rr as oe,Sr as P,St as F,Td as I,Tr as L,Uu as se,Vr as R,Xn as ce,Zn as z,iu as B,jr as le,ju as V,kr as H,rd as U,su as W,wr as ue,xr as G,xt as de,xu as K,yr as fe,zl as pe}from"./src-CPNx7Cnt.js";import{oi as q}from"./client-Diiyoh60.js";import"./mount-D073lAZn.js";import{H as me,W as J,Y}from"./index-cOBEaAEQ.js";import{t as X}from"./AdminPage-BSFohA3i.js";import{t as Z}from"./NodeAddonsSettingsPanel-DaKtOtU5.js";import{r as he,t as ge}from"./useNodeUrlSelection-DKxGlIbc.js";var _e=m(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]);n();var ve={queued:{icon:j,bg:`bg-muted text-foreground-subtle`,label:`queued`},updating:{icon:U,bg:`bg-primary/10 text-primary`,label:`updating`,spin:!0},"done-pending-restart":{icon:A,bg:`bg-amber-500/10 text-amber-700`,label:`pending restart`},done:{icon:E,bg:`bg-success/10 text-success`,label:`done`},failed:{icon:_e,bg:`bg-danger/10 text-danger`,label:`failed`}};function ye({item:e}){let t=ve[e.status],n=t.icon;return i(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${t.bg}`,title:e.error,children:[l(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label]})}var be=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),Q=new Set([`done`,`failed`,`skipped`]);function xe(e){return!Q.has(e.phase)&&!be.has(e.jobState)}function Se(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=be.has(e.state);for(let i of e.tasks)r&&i.finishedAtMs!==null&&t-i.finishedAtMs>6e4||n.set(i.packageName,{jobId:e.jobId,packageName:i.packageName,phase:i.phase,fromVersion:i.fromVersion,toVersion:i.toVersion,error:i.error,jobState:e.state,finishedAtMs:i.finishedAtMs})}return n}function Ce(){let{data:e}=h({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=ee(q.AddonsJobProgress,e=>e.job.jobId);return a(()=>{let n=new Map;for(let t of e??[])n.set(t.jobId,t);for(let[e,r]of t)n.set(e,r.job);return Se([...n.values()],Date.now())},[e,t])}var we={queued:{icon:j,cls:`bg-muted text-foreground-subtle`,label:`queued`},fetching:{icon:U,cls:`bg-primary/10 text-primary`,label:`fetching`,spin:!0},staged:{icon:U,cls:`bg-primary/10 text-primary`,label:`staged`,spin:!0},validating:{icon:U,cls:`bg-primary/10 text-primary`,label:`validating`,spin:!0},applying:{icon:U,cls:`bg-primary/10 text-primary`,label:`applying`,spin:!0},restarting:{icon:U,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,label:`restarting`,spin:!0},applied:{icon:U,cls:`bg-primary/10 text-primary`,label:`finalizing`,spin:!0},done:{icon:E,cls:`bg-success/10 text-success`,label:`updated`},failed:{icon:_e,cls:`bg-danger/10 text-danger`,label:`failed`},skipped:{icon:K,cls:`bg-muted text-foreground-subtle`,label:`skipped`}};function Te({progress:e}){let t=we[e.phase],n=t.icon,r=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return i(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${t.cls}`,title:r,children:[l(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label,i(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function Ee(e,t){return e.filter(e=>e.packageName===t).slice().sort((e,t)=>e.isHub===t.isHub?e.nodeName.localeCompare(t.nodeName):e.isHub?-1:1)}function De(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function Oe(e,t,n){let r=[`${e} will be uninstalled from ${t.length} node(s). Its runners stop, its capabilities are deregistered and its code is deleted:`,...t.map(De)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
|
|
2
|
-
`)}function ke(e,t,n){let r=[`${e} will be uninstalled from ${t}: its runners stop and its code is deleted.`];return n.length>0&&r.push(`It stays installed on: ${n.map(e=>e.nodeName).join(`, `)}. Use "Everywhere" to remove it from every node.`),r.push(`This cannot be undone.`),r.join(`
|
|
3
|
-
`)}var Ae={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function je(e,t){let n=[];for(let r of e.results){let e=r.runnersStopped.length>0?` (stopped ${r.runnersStopped.join(`, `)})`:``;n.push(`${t(r.nodeId)}: ${Ae[r.outcome]}${e}`),r.error!==void 0&&n.push(` ${r.error}`);for(let e of r.warnings)n.push(` ${e}`)}return n.join(`
|
|
4
|
-
`)}var Me={},Ne=3e4,Pe=`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-red-400 hover:border-red-500/30 hover:bg-red-500/10 disabled:opacity-50 transition-colors`;function Fe({packageName:e,displayName:t,selectedNode:n,hideNodeAction:r,disabled:a}){let o=s(),c=z(),u=ce(),d=H(Me,{staleTime:Ne}),f=d.data?.installations??[],m=(d.data?.unreachable??[]).map(e=>e.nodeId),h=Ee(f,e),g=e=>h.find(t=>t.nodeId===e)?.nodeName??(e===n.id?n.name:e),_=R({onSettled:()=>{o.invalidateQueries({queryKey:[[`addons`]]}),o.invalidateQueries({queryKey:[[`addonPages`]]}),o.invalidateQueries({queryKey:[[`capabilities`]]}),o.invalidateQueries({queryKey:[[`nodes`]]})}}),v=async e=>{await u({title:e.success?`${t} uninstalled`:`${t}: not every node was cleaned`,message:je(e,g),variant:e.success?`default`:`danger`})},y=async n=>{try{await v(await _.mutateAsync({packageName:e,...n}))}catch(e){await u({title:`Uninstall ${t} failed`,message:e instanceof Error?e.message:String(e),variant:`danger`})}},b=async()=>{let e=h.filter(e=>e.nodeId!==n.id);await c({title:`Uninstall ${t} from ${n.name}?`,message:ke(t,n.name,e),confirmLabel:`Uninstall`,variant:`danger`})&&await y(n.isHub?{}:{nodeId:n.id})},x=async()=>{let n=(await d.refetch()).data;if(n===void 0){await u({title:`Cannot list the nodes`,message:`The hub did not answer which nodes have this package — nothing was removed.`,variant:`danger`});return}let r=Ee(n.installations,e);await c({title:`Uninstall ${t} everywhere?`,message:Oe(t,r,n.unreachable.map(e=>e.nodeId)),confirmLabel:`Uninstall from ${r.length} node(s)`,variant:`danger`})&&await y({everywhere:!0})},S=_.isPending||a===!0;return i(`div`,{className:`flex items-center gap-1.5`,children:[r!==!0&&i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),b()},disabled:S,className:Pe,title:`Uninstall from ${n.name}`,children:[l(p,{className:`h-3 w-3`}),_.isPending?`Removing...`:`Uninstall`]}),(h.length>1||r===!0||m.length>0)&&i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),x()},disabled:S,className:Pe,title:`Uninstall from every node that has it`,children:[l(Y,{className:`h-3 w-3`}),`Everywhere`,h.length>0?` (${h.length})`:``]})]})}function Ie({packageName:e,currentVersion:t,installSource:n,onInstall:r,onClose:a,onSelect:s,selectedVersion:c}){let u=n===`upload`||n===`local`,{data:d,isLoading:f}=L({name:e});return i(`div`,{className:`fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,style:{top:`auto`,bottom:`auto`},ref:e=>{if(!e)return;let t=e.parentElement?.getBoundingClientRect();if(!t)return;let n=window.innerHeight-t.bottom,r=t.top;n<280&&r>n?(e.style.bottom=`${window.innerHeight-t.top+4}px`,e.style.top=`auto`):(e.style.top=`${t.bottom+4}px`,e.style.bottom=`auto`),e.style.right=`${window.innerWidth-t.right}px`},onClick:e=>e.stopPropagation(),children:[i(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[l(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:`Versions`}),l(`button`,{type:`button`,onClick:a,className:`text-foreground-subtle hover:text-foreground`,children:l(O,{className:`h-3 w-3`})})]}),u&&i(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[l(B,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),i(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[i(`span`,{className:`font-semibold`,children:[n===`upload`?`Uploaded copy`:`Local copy`,` in place.`]}),` `,`Re-install `,l(`span`,{className:`font-mono`,children:t}),` from npm to track upstream releases again.`]})]}),f&&i(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[l(U,{className:`h-3.5 w-3.5 animate-spin`}),`Loading versions...`]}),d&&l(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:d.map(e=>{let n=e.version===t,a=s!==void 0&&e.version===c,d=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),f=i(o,{children:[l(`span`,{className:`font-mono flex-1 text-left ${n?`text-primary font-semibold`:d?`text-amber-400`:`text-foreground`}`,children:e.version}),n&&l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:`current`}),e.distTags.map(e=>l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),e.deprecated&&l(`span`,{className:`text-[9px] text-red-400 line-through`,children:`deprecated`}),l(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return s?i(`button`,{type:`button`,"aria-label":`Select ${e.version}`,onClick:()=>s(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${a?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,a?l(E,{className:`h-3 w-3 text-primary shrink-0`}):l(`span`,{className:`w-3 shrink-0`})]},e.version):i(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${n?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,n&&!u?l(E,{className:`h-3 w-3 text-primary shrink-0`}):l(`button`,{type:`button`,onClick:()=>r(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:n?`Re-install ${e.version} from npm`:`Install ${e.version}`,children:l(I,{className:`h-3 w-3`})})]},e.version)})}),d&&d.length===0&&l(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:`No versions found`})]})}n();var Le=`device-export`;function Re(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===Le)}function ze({isBundle:e,installSource:t,addonId:n,iconPath:r,color:a}){let[o,s]=c(!1),u=a?{backgroundColor:`${a.startsWith(`#`)?a:`#${a}`}26`}:void 0,f=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,p=n&&r?d(`/api/addon-assets/${n}/${r}`):null,m=!!p&&!o;return i(`div`,{className:`relative flex-shrink-0`,children:[l(`div`,{className:`h-9 w-9 rounded-lg flex items-center justify-center ${u?``:f}`,style:u,children:m?l(`img`,{src:p,alt:n,className:`h-5 w-5`,onError:()=>s(!0)}):l(e?re:y,{className:`h-4 w-4`})}),t===`local`&&l(`span`,{className:`absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm`,children:`DEV`}),t===`npm`&&l(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:l(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:l(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),t===`upload`&&l(`span`,{className:`absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm`,children:l(B,{className:`h-2.5 w-2.5 text-white`})})]})}function Be({version:e,availableUpdate:t,selectedVersion:n,isUpdating:r,installSource:a,disabled:o,onUpdate:s,onOpenPicker:c,children:u}){if(r)return i(`span`,{className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400 shrink-0`,children:[l(U,{className:`h-3 w-3 animate-spin`}),`Updating…`]});if(t){let r=n??t;return i(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[s&&i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:o,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-semibold border border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:`Update to ${r}`,children:[l(I,{className:`h-3 w-3`}),`Update`]}),i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:o,"aria-label":`Select version to install`,title:`Installed ${e} — update available. Selected ${r}; tap to choose another version.`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-bold font-mono border border-amber-500/40 bg-amber-500/15 text-amber-500 hover:bg-amber-500/25 animate-pulse disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[l(`span`,{className:`font-normal opacity-70`,children:e}),l(`span`,{className:`font-normal opacity-70`,children:`→`}),r,l(f,{className:`h-3 w-3`})]}),u]})}return i(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:o,className:[`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,a===`local`?`border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20`].join(` `),title:`Version ${e} — tap to view all versions`,children:[e,l(f,{className:`h-3 w-3 opacity-50`})]}),u]})}function Ve({addonId:e}){let t=s(),{data:n=`inherit`}=P({addonId:e}),r=k({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return l(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>l(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}var He={id:`hub`,name:`Hub`,isHub:!0};function Ue({addon:e,agents:t=[],clusterStatus:n,hideVersion:r,availableUpdate:a,onUpdate:d,isUpdating:p,jobProgress:m,bundle:h,bulkItem:g,disabledByBulk:v,isSystem:y,selectedNode:b}){let[x,C]=c(!1),[E,ee]=c(!1),[te,D]=c(!1),[ne,ie]=c(null);u(()=>{ie(null)},[a]);let k=ne??a,[j,M]=c(!1),[oe,P]=c(!1),[I,L]=c(`logs`),R=s(),ce=me(),{manifest:z}=e,B=e.installedOn??[],le=!h&&!z.protected&&z.removable!==!1,H=!!h,U=h?.displayName??z.name,W=h?.packageName??z.packageName,ue=h?.version??z.packageVersion??z.version,G=h?.installSource??e.installSource,K=h?h.bundle?.description??h.addons[0]?.manifest.description:z.description,fe=ae({onSuccess:()=>{R.invalidateQueries({queryKey:[[`addons`]]})}}),pe=S({onSuccess:()=>{R.invalidateQueries({queryKey:[[`addons`]]}),R.invalidateQueries({queryKey:[[`addonPages`]]}),R.invalidateQueries({queryKey:[[`capabilities`]]}),R.invalidateQueries({queryKey:[[`integrations`]]})}}),q=w({onSuccess:()=>{R.invalidateQueries({queryKey:[[`addons`]]}),R.invalidateQueries({queryKey:[[`alerts`]]})}}),J=e.health,Y=J?.phase===`failed`&&!J.inGracePeriod,X=Y&&J?.nextRetryAt&&!J.retrying;return i(`div`,{className:`rounded-lg border bg-surface overflow-hidden ${Y?`border-red-500/50`:`border-border`}`,children:[Y&&J&&i(`div`,{className:`bg-danger/10 border-b border-danger/30 px-4 py-2.5 flex items-start gap-2.5`,children:[l(_e,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`text-xs font-semibold text-danger`,children:[`Failed to load (attempt #`,J.retryCount,`)`]}),l(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:J.lastError?.message??`Unknown error`}),X&&J.nextRetryAt&&i(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:[`Auto-retry at `,new Date(J.nextRetryAt).toLocaleTimeString()]})]}),i(`button`,{type:`button`,disabled:q.isPending||J.retrying,onClick:e=>{e.stopPropagation(),q.mutate({packageName:W})},className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0`,title:`Reset retry counter and force immediate reload`,children:[l(A,{className:`h-3 w-3 ${q.isPending||J.retrying?`animate-spin`:``}`}),`Retry now`]})]}),i(`div`,{className:`flex items-start gap-3 px-4 py-3`,children:[l(ze,{isBundle:H||!!z.components&&z.components.length>1,installSource:G,addonId:H?h.addons[0]?.manifest.id:z.id,iconPath:H?h.bundle?.icon??h.addons[0]?.manifest.icon:z.icon,color:H?h.addons[0]?.manifest.color:z.color}),i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`flex items-start justify-between gap-2`,children:[l(`span`,{className:`text-sm font-semibold text-foreground truncate min-w-0`,children:U}),!r&&l(Be,{version:ue,availableUpdate:a,...k===void 0?{}:{selectedVersion:k},isUpdating:p,installSource:G,disabled:v,...d&&k!==void 0?{onUpdate:()=>d(k)}:{},onOpenPicker:()=>D(e=>!e),children:te&&l(Ie,{packageName:W,currentVersion:ue,...G?{installSource:G}:{},...a!==void 0&&k!==void 0?{selectedVersion:k,onSelect:e=>{ie(e),D(!1)}}:{},onInstall:e=>{D(!1),pe.mutate({packageName:W,version:e})},onClose:()=>D(!1)})})]}),i(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[W!==U&&l(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:W}),H&&i(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,children:[l(re,{className:`h-3 w-3`}),h.addons.length]}),y&&i(`span`,{className:`text-[10px] rounded-full bg-amber-500/15 text-amber-700 dark:text-amber-300 px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,title:`System package — updating restarts the hub`,children:[l(A,{className:`h-3 w-3`}),`System`]}),g!=null&&l(ye,{item:g}),m!=null&&l(Te,{progress:m})]}),K&&l(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:K}),!H&&e.process&&i(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode===`forked`?`bg-blue-500/15 text-blue-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.mode===`forked`?`forked`:`in-process`}),e.process.pid!=null&&i(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state===`running`?`bg-emerald-500/15 text-emerald-400`:e.process.state===`crashed`||e.process.state===`failed`?`bg-red-500/15 text-red-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.state})]})]})]}),!H&&i(`div`,{className:`flex items-center gap-1 px-4 py-1.5 border-t border-border/50 bg-surface-hover/20`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),fe.mutate({addonId:z.id})},disabled:fe.isPending||v,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors`,children:[l(A,{className:`h-3 w-3 ${fe.isPending?`animate-spin`:``}`}),`Restart`]}),i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),M(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${j?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[l(V,{className:`h-3 w-3`}),`Logs`]}),!H&&i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),P(!0)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${oe?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[l(N,{className:`h-3 w-3`}),`Settings`]}),l(`div`,{className:`flex-1`}),le&&l(Fe,{packageName:z.packageName,displayName:z.name,selectedNode:b??He,disabled:v})]}),n&&n.nodes.length>1&&!H&&i(`div`,{className:`border-t border-border px-4 py-2 bg-muted/10`,children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:`Cluster Deployment`}),l(`div`,{className:`space-y-1`,children:n.nodes.map(e=>i(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[l(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`offline`?`bg-muted-foreground/30`:e.synced?`bg-success`:`bg-amber-500`}`}),l(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),l(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:`outdated`}),e.status===`offline`&&l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:`offline`}),e.synced&&e.status!==`offline`&&l(`span`,{className:`text-[9px] text-success`,children:`synced`})]},e.nodeId))})]}),j&&!H&&i(`div`,{className:`border-t border-border`,children:[i(`div`,{className:`flex items-center px-4 py-1 bg-surface-hover/20 border-b border-border/50`,children:[i(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[l(`button`,{type:`button`,onClick:()=>L(`logs`),className:`px-2 py-0.5 transition-colors ${I===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Logs`}),l(`button`,{type:`button`,onClick:()=>L(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${I===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Events`})]}),l(`div`,{className:`flex-1`}),l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),M(!1)},className:`text-foreground-subtle hover:text-foreground`,children:l(O,{className:`h-3.5 w-3.5`})})]}),I===`logs`&&l(F,{addonId:z.id,maxHeight:`max-h-64`,showFilters:!1}),I===`events`&&l(de,{addonId:z.id,category:`addon.*`,maxHeight:`max-h-64`})]}),H&&i(o,{children:[l(`button`,{type:`button`,onClick:()=>C(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:l(x?_:f,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),x&&l(`div`,{className:`border-t border-border px-3 py-2 space-y-2`,children:h.addons.map(e=>l(Ue,{addon:e,agents:t,hideVersion:!0},e.manifest.id))})]}),oe&&!H&&l(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4`,onClick:()=>P(!1),children:i(`div`,{className:`w-full max-w-lg max-h-[80vh] rounded-xl border border-border bg-surface shadow-2xl flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[i(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-border flex-shrink-0`,children:[i(`div`,{className:`flex items-center gap-2`,children:[l(N,{className:`h-4 w-4 text-primary`}),i(`h2`,{className:`text-sm font-semibold text-foreground`,children:[U,` Settings`]})]}),l(`button`,{onClick:()=>P(!1),className:`text-foreground-subtle hover:text-foreground transition-colors p-1 rounded`,children:l(O,{className:`h-4 w-4`})})]}),i(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[l(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`}),l(Z,{nodeId:null,addonIds:[z.id],level:`global`,fieldScope:`cluster`,emptyMessage:`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`}),Re(z)&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Device export`}),l(T,{addonId:z.id,onOpenDevice:e=>ce(`/devices/${e}`)})]}),G===`npm`&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Auto-Update`}),l(Ve,{addonId:z.id})]}),z.components&&z.components.length>0&&i(`div`,{children:[i(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Components (`,z.components.length,`)`]}),l(`div`,{className:`flex flex-wrap gap-1`,children:z.components.map(e=>l(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]}),t.length>=2&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Installed on`}),i(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[B.length===0&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Hub (local)`}),B.map(e=>l(`span`,{className:`rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle`,children:e},e)),i(`div`,{className:`relative`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ee(e=>!e)},className:`inline-flex items-center gap-1 rounded-full border border-dashed border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground hover:border-primary transition-colors`,title:`Install on more agents`,children:[l(se,{className:`h-3 w-3`}),`Add agent`]}),E&&i(`div`,{className:`absolute left-0 top-full mt-1 z-10 min-w-[160px] rounded-md border border-border bg-surface shadow-lg overflow-hidden`,children:[t.filter(e=>!e.isHub&&!B.includes(e.name)).map(e=>l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ee(!1)},className:`w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors`,children:e.name},e.id)),t.filter(e=>!e.isHub&&!B.includes(e.name)).length===0&&l(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle`,children:`No available agents`})]})]})]})]})]}),l(`div`,{className:`flex items-center justify-end px-5 py-3 border-t border-border flex-shrink-0`,children:l(`button`,{type:`button`,onClick:()=>P(!1),className:`rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:`Close`})})]})})]})}n();var We=`.tgz,.tar.gz,.zip`;function Ge({onUploadSuccess:n}){let[r,a]=c(!1),s=t(null),u=e(async e=>{a(!0);let t=new FormData;t.append(`file`,e);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(d(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:t})).json()).success&&n()}finally{a(!1)}},[n]);return i(o,{children:[l(`input`,{ref:s,type:`file`,accept:We,onChange:e(e=>{let t=e.target.files?.[0];t&&u(t),e.target.value=``},[u]),className:`hidden`}),i(`button`,{type:`button`,onClick:()=>s.current?.click(),disabled:r,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[r?l(U,{className:`w-3.5 h-3.5 animate-spin`}):l(B,{className:`w-3.5 h-3.5`}),r?`Uploading...`:`Upload`]})]})}var Ke=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/ui-library`,`@camstack/addon-agent-ui`]);function qe(e,t){let n=new Map;for(let r of e){if(r.isHub||r.onHub||Ke.has(r.packageName)||!t.isHub&&r.nodeId!==t.id)continue;let e=n.get(r.packageName)??[];e.push(r),n.set(r.packageName,e)}return[...n].map(([e,t])=>({packageName:e,rows:t})).sort((e,t)=>e.packageName.localeCompare(t.packageName))}function Je({selectedNode:e}){let{data:t}=H(Me,{staleTime:Ne});if(t===void 0)return null;let n=qe(t.installations,e),r=t.unreachable.filter(t=>e.isHub||t.nodeId===e.id);return n.length===0&&r.length===0?null:i(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2.5 space-y-2`,children:[i(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-foreground`,children:[l(W,{className:`h-3.5 w-3.5 text-warning`}),e.isHub?`Installed on agents but not on the hub`:`Installed on ${e.name} but not on the hub`]}),r.length>0&&i(`div`,{className:`text-[10px] text-foreground-subtle`,children:[`Could not ask `,r.map(e=>e.nodeId).join(`, `),` — its packages are not listed.`]}),n.map(t=>i(`div`,{className:`flex items-center justify-between gap-3 flex-wrap rounded-md border border-border bg-surface px-3 py-2`,children:[i(`div`,{className:`min-w-0`,children:[l(`div`,{className:`text-xs font-mono text-foreground break-all`,children:t.packageName}),l(`div`,{className:`text-[10px] text-foreground-subtle`,children:t.rows.map(e=>`${e.nodeName}${e.version===null?``:` ${e.version}`}${e.isOnline?``:` (offline)`}`).join(` · `)})]}),l(Fe,{packageName:t.packageName,displayName:t.packageName,selectedNode:e,hideNodeAction:e.isHub})]},t.packageName))]})}n();var Ye=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],Xe=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/shm-ring`,`@camstack/ui-library`]);function Ze(e){return e!==void 0&&Xe.has(e)}var Qe={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function $e(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function et(e){let t=e;if(!t?.manifest)return null;let n={...t.manifest,name:t.manifest.name??t.manifest.id,version:t.manifest.version??`0.0.0`,capabilities:t.manifest.capabilities??[]},r=t.process,i=r?{pid:r.pid,mode:r.mode===`forked`?`forked`:`in-process`,state:r.state??`unknown`}:void 0,a=t.health,o=t.declaration?.execution,s=t.manifest.execution,c=o?.placement??s?.placement;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...i?{process:i}:{},hasBackup:t.hasBackup,...a?{health:a}:{},...c?{placement:c}:{}}}function tt(e){let t=new Map,n=[];for(let r of e){let e=r.manifest.packageName;if(!e){n.push(r);continue}let i=t.get(e);if(i)i.addons.push(r);else{let n=r.manifest.bundle,i={packageName:e,displayName:n?.displayName??r.manifest.packageDisplayName??r.manifest.name,version:r.manifest.packageVersion,addons:[r],...r.installSource===void 0?{}:{installSource:r.installSource},...n===void 0?{}:{bundle:n}};t.set(e,i)}}let r=[];for(let e of t.values())e.bundle!==void 0||e.addons.length>=2?r.push({bundle:e,representative:e.addons[0]}):r.push(e.addons[0]);return r.push(...n),r}function $(e){return`bundle`in e}function nt({addons:n,clusterStatus:o,selectedNode:d,onRefresh:f,isRefreshing:p}){let m=s(),[h,_]=c(``),y=r(h),[x,C]=c(!1),w=t(null);u(()=>{if(!x)return;let e=e=>{w.current&&!w.current.contains(e.target)&&C(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[x]);let{data:T}=le({nodeId:d.id}),ee=a(()=>{let e=new Map;for(let t of T??[])e.set(t.name,t.latestVersion);return e},[T]),D=a(()=>(T??[]).filter(e=>!e.isSystem).length,[T]),[O,re]=c(()=>new Set),[k,j]=c(()=>new Map),M=e(e=>{re(t=>new Set(t).add(e))},[]),ae=e(e=>{re(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),N=e((e,t)=>{j(n=>new Map(n).set(e,t))},[]),P=e(e=>{j(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),F=te({onMutate:e=>{M(e.name),P(e.name)},onSuccess:(e,t)=>{ae(t.name);let n=e;if(n&&n.success===!1){N(t.name,n.error??`Update failed (no error message returned by server)`);return}m.invalidateQueries({queryKey:[[`addons`]]}),m.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{ae(t.name),N(t.name,e instanceof Error?e.message:String(e))}}),L=Ce(),se=t(new Set);u(()=>{let e=new Set;for(let[t,n]of L)xe(n)&&e.add(t);let t=[...se.current].some(t=>!e.has(t));se.current=e,t&&(m.invalidateQueries({queryKey:[[`addons`]]}),m.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[L,m]);let{data:R}=b(void 0),ce=fe({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),B=oe({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:V,isFetching:H}=ne({query:y||void 0},{enabled:x}),W=v(),{data:G}=ue(void 0),de=G?.requestedAt,[K,pe]=c(null),[q,me]=c(!1);u(()=>{if(G?.kind===`framework-bulk-update`&&G.requestedAt!==K){pe(G.requestedAt),me(!0);let e=window.setTimeout(()=>me(!1),6e3);return()=>window.clearTimeout(e)}},[de,K,G]),z();let Y=e(async()=>{let e=(T??[]).filter(e=>!e.isSystem);if(e.length!==0){if(!d.isHub){for(let t of e)await F.mutateAsync({name:t.name,version:t.latestVersion,nodeId:d.id});return}await W.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[d.id]})}},[T,d.id,d.isHub,W,F]),X=S({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`]]}),m.invalidateQueries({queryKey:[[`addonPages`]]}),m.invalidateQueries({queryKey:[[`capabilities`]]}),m.invalidateQueries({queryKey:[[`integrations`]]})}}),[Z,he]=c(`type`),[ge,_e]=c(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),ve=e=>{_e(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[ye,be]=J(),Q=ye.get(`capability`),Se=a(()=>{let e=n.filter(e=>!Ze(e.manifest.packageName));return d.isHub||(e=e.filter(e=>$e(e.placement,d.isHub))),Q&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===Q))),e},[n,d.isHub,Q]),we=()=>{let e=new URLSearchParams(ye);e.delete(`capability`),be(e,{replace:!0})},Te=ge===`flat`?Se:tt(Se),Ee=a(()=>{let e=[...Te];switch(Z){case`type`:e.sort((e,t)=>{let n=+!$(e),r=+!$(t);if(n!==r)return n-r;let i=$(e)?e.bundle.displayName:e.manifest.name,a=$(t)?t.bundle.displayName:t.manifest.name;return i.localeCompare(a)});break;case`name`:e.sort((e,t)=>{let n=$(e)?e.bundle.displayName:e.manifest.name,r=$(t)?t.bundle.displayName:t.manifest.name;return n.localeCompare(r)});break;case`source`:e.sort((e,t)=>{let n=$(e)?e.bundle.installSource??``:e.installSource??``,r=$(t)?t.bundle.installSource??``:t.installSource??``;return n.localeCompare(r)});break}return e},[Te,Z]);return i(`div`,{className:`space-y-4`,children:[[...k.entries()].map(([e,t])=>l(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px]`,children:i(`div`,{className:`flex items-start justify-between gap-3`,children:[i(`div`,{className:`space-y-0.5`,children:[i(`div`,{className:`font-medium text-danger`,children:[`Failed to update `,e]}),l(`div`,{className:`text-foreground-subtle font-mono`,children:t})]}),l(`button`,{type:`button`,onClick:()=>P(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:`dismiss`})]})},e)),i(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[i(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Sort:`}),i(`select`,{value:Z,onChange:e=>he(e.target.value),className:`rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] text-foreground focus:outline-none focus:border-primary/50`,children:[l(`option`,{value:`type`,children:`Bundles first`}),l(`option`,{value:`name`,children:`Name`}),l(`option`,{value:`source`,children:`Install source`})]})]}),i(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`View:`}),l(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>l(`button`,{type:`button`,onClick:()=>ve(e),className:`px-2.5 py-1.5 transition-colors capitalize ${ge===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?`Group multi-addon packages into a bundle card`:`Show every addon as its own card`,children:e},e))})]}),d.isHub&&i(`div`,{className:`flex items-center gap-1.5`,children:[l(A,{className:`h-3 w-3 text-foreground-subtle`}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Auto-Update:`}),l(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>l(`button`,{type:`button`,onClick:()=>ce.mutate({channel:e}),disabled:ce.isPending,className:`px-2.5 py-1.5 transition-colors capitalize ${R?.channel===e?e===`off`?`bg-gray-700 text-gray-200`:e===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${e===`off`?``:`border-l border-border`}`,children:e},e))})]}),d.isHub&&i(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Check every:`}),l(`select`,{className:`rounded-md border border-border bg-transparent px-1.5 py-1 text-[10px] font-medium text-foreground-subtle`,value:R?.updateCheckIntervalSeconds??21600,disabled:B.isPending||R===void 0,onChange:e=>{R!==void 0&&B.mutate({channel:R.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:Ye.map(e=>l(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),D>0&&i(`button`,{type:`button`,onClick:()=>void Y(),disabled:W.isPending,className:`flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 border border-blue-500/30 disabled:opacity-50 transition-colors font-medium`,children:[W.isPending?l(U,{className:`w-3 h-3 animate-spin`}):l(I,{className:`w-3 h-3`}),W.isPending?`Updating…`:`Update All (${D})`]}),i(`button`,{type:`button`,onClick:f,disabled:p||W.isPending,className:`flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[l(A,{className:`w-3 h-3 ${p?`animate-spin`:``}`}),`Refresh`]})]}),i(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[i(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:w,children:[l(g,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),l(`input`,{type:`text`,value:h,onChange:e=>{_(e.target.value),C(!0)},onFocus:()=>C(!0),placeholder:`Search addons on npm...`,disabled:W.isPending,className:`w-full rounded-lg border border-border bg-background pl-9 pr-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 disabled:cursor-not-allowed`}),H&&l(U,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin`}),x&&V&&V.length>0&&i(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,children:[V.length>0&&i(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[`npm results (`,V.length,`)`]}),V&&V.length>0&&l(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:V.map(e=>i(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[l(`div`,{className:`w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0`,children:e.name.replace(`@camstack/addon-`,``).charAt(0).toUpperCase()}),i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[l(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),i(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),l(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&l(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?i(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md border border-emerald-500/30 bg-emerald-500/10 text-emerald-400 shrink-0`,children:[l(E,{className:`h-3 w-3`}),e.installedVersion??`Installed`]}):i(`button`,{type:`button`,onClick:()=>X.mutate({packageName:e.name}),disabled:X.isPending,className:`inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0`,children:[X.isPending?l(U,{className:`h-3 w-3 animate-spin`}):l(I,{className:`h-3 w-3`}),`Install`]})]},e.name))})]})]}),l(Ge,{onUploadSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`]]}),f()}})]}),Q&&i(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-primary/10 border border-primary/30 text-sm`,children:[l(`span`,{className:`text-foreground-subtle`,children:`Filtering by capability:`}),l(`span`,{className:`font-mono text-primary font-semibold`,children:Q}),l(`button`,{type:`button`,onClick:we,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:`Clear`})]}),q&&i(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg backdrop-blur-sm max-w-sm pointer-events-auto`,children:[l(ie,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),i(`div`,{children:[l(`div`,{className:`text-[11px] font-semibold text-foreground`,children:`Bulk update completed`}),l(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:`System packages updated — hub restarted successfully.`})]})]}),Se.length===0&&l(`div`,{className:`text-xs text-foreground-subtle`,children:n.length===0?`No addons installed`:Q?`No installed addons declare the "${Q}" capability. Browse the npm catalog above to find a compatible addon.`:`No addons compatible with ${d.name} (placement filter active)`}),l(`div`,{className:`space-y-2`,children:Ee.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=ee.get(t),r=$(e)?e.representative:e,i=n?e=>F.mutate({name:t,version:e,nodeId:d.id}):void 0,a=L.get(t)??null,s=a!==null&&xe(a);return l(Ue,{addon:r,clusterStatus:o?.[r.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,isUpdating:O.has(t)||s,jobProgress:a,onUpdate:i,disabledByBulk:W.isPending,selectedNode:d},$(e)?t:e.manifest.id)})})]})}function rt(){let e=s(),{data:n,isLoading:r,isError:a}=x(),{data:o}=D(void 0),{nodes:c}=pe(),{selection:d,selectNode:f,requestedNodeId:p}=ge(c.length>0?c:[Qe]),m=d.node??Qe,h=m.id,g=c.length>0?d.staleNodeId:null,_=G(),v=M(),y=_.isPending||v.isPending,b=async()=>{await _.mutateAsync({nodeId:h}),await v.mutateAsync(),e.invalidateQueries({queryKey:[[`addons`]]})},S=t(_);S.current=_;let w=t(p??`hub`);u(()=>{S.current.mutate({nodeId:w.current})},[]);let T=(n??[]).map(et).filter(e=>e!==null);return i(X,{children:[i(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[l(C,{selectedNodeId:h,onSelect:f}),i(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[!r&&!a&&i(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:[T.length,` installed`]}),i(`button`,{type:`button`,onClick:()=>void b(),disabled:y,className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,title:`Re-fetch addons + check npm for new versions`,children:[l(A,{className:`w-3 h-3 ${y?`animate-spin`:``}`}),`Check for updates`]})]})]}),l(he,{staleNodeId:g,shownNodeName:m.name}),!m.isHub&&i(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle`,children:[`Showing only addons compatible with`,` `,l(`span`,{className:`font-medium text-foreground`,children:m.name}),` — agents only run`,` `,l(`code`,{className:`font-mono`,children:`agent-only`}),` and`,` `,l(`code`,{className:`font-mono`,children:`any-node`}),` addons. Installs are hub-driven and agents auto-sync from the hub; `,l(`span`,{className:`font-medium text-foreground`,children:`Uninstall`}),` on a card removes the package from this node only,`,` `,l(`span`,{className:`font-medium text-foreground`,children:`Everywhere`}),` from every node.`]}),l(Je,{selectedNode:m}),r&&l(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading…`}),a&&l(`div`,{className:`text-xs text-danger`,children:`Failed to load addons`}),!r&&!a&&l(nt,{addons:T,clusterStatus:o,selectedNode:m,onRefresh:()=>void b(),isRefreshing:y})]})}export{rt as AddonsPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,W as i,a,b as o,q as s,t as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{W as d,Z as f,_t as p,at as m,ct as h,st as g,vt as _}from"./player-overlays-BFYAtS6k.js";import{Ad as v,Au as y,Bn as b,Dn as x,F as S,Gu as C,Hu as w,Kl as T,Ln as E,Od as D,Pn as O,Rt as k,Td as A,Uu as ee,an as j,ar as M,cn as N,da as te,fn as P,gd as ne,gu as re,hd as F,in as I,ku as L,ln as R,qd as z,rd as B,rn as V,sn as H,un as U,zn as ie,zt as W}from"./src-CPNx7Cnt.js";import{t as ae}from"./boxes-Co2Q90CO.js";import{t as oe}from"./send-CYjwgPvF.js";import{Un as G}from"./client-Diiyoh60.js";import{t as K}from"./useTranslation-Bc5yH9V9.js";import"./mount-D073lAZn.js";import{t as q}from"./AdminPage-BSFohA3i.js";import{t as se}from"./AdminTabs-CZPAmhas.js";var ce=_(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]);n();var le=[`llm`,`listProfiles`],ue=[`llm`,`listProfileKinds`],de=[`llm`,`getDefaults`],J=[`llm`,`listRuntimeNodes`],fe=[`llm`,`listModelCatalog`],pe=[`llm`,`getUsage`],me=[{purpose:`vision`,visionOnly:!0},{purpose:`text`,visionOnly:!1}],he=new Map(Object.entries({openai:v,anthropic:v,google:v,"openai-compatible":w,"managed-local":D,"apple-foundation":D}));function ge(e){return he.get(e)??null}function Y(e){return typeof e==`string`&&e.length>0?e:void 0}function X(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 Z(e){return e===!0}function _e(e){return{model:e.model,baseUrl:e.baseUrl,apiKey:e.apiKey,supportsVision:e.supportsVision,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,contextSize:e.runtime?.contextSize,gpuLayers:e.runtime?.gpuLayers,threads:e.runtime?.threads,parallel:e.runtime?.parallel,idleStopMinutes:e.runtime?.idleStopMinutes,batchSize:e.runtime?.batchSize,ubatchSize:e.runtime?.ubatchSize,flashAttention:e.runtime?.flashAttention,mlock:e.runtime?.mlock,noMmap:e.runtime?.noMmap,cacheTypeK:e.runtime?.cacheTypeK,cacheTypeV:e.runtime?.cacheTypeV,extraArgs:xe(e.runtime?.extraArgs??[])}}var ve=[`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`];function ye(e){return typeof e==`string`&&ve.includes(e)?e:void 0}function be(e){let t=[],n=``,r=null;for(let i of e){if(r!==null){i===r?r=null:n+=i;continue}if(i===`"`||i===`'`){r=i;continue}if(/\s/.test(i)){n!==``&&t.push(n),n=``;continue}n+=i}return n!==``&&t.push(n),t}function xe(e){return e.map(e=>/\s/.test(e)?`"${e}"`:e).join(` `)}var Se=[`--jinja`,`--cont-batching`];function Ce(e,t,n){let r=X(e.threads),i=X(e.batchSize),a=X(e.ubatchSize),o=ye(e.cacheTypeK),s=ye(e.cacheTypeV);return{nodeId:t,engine:`llama-cpp`,model:n,extraArgs:[...be(Y(e.extraArgs)??``)],contextSize:X(e.contextSize)??4096,gpuLayers:X(e.gpuLayers)??0,...r===void 0?{}:{threads:r},parallel:X(e.parallel)??1,...i===void 0?{}:{batchSize:i},...a===void 0?{}:{ubatchSize:a},flashAttention:Z(e.flashAttention),mlock:Z(e.mlock),noMmap:Z(e.noMmap),...o===void 0?{}:{cacheTypeK:o},...s===void 0?{}:{cacheTypeV:s},autoStart:Z(e.autoStart),idleStopMinutes:X(e.idleStopMinutes)??30}}function we(e,t,n,r,i){let a={id:n?.id??crypto.randomUUID(),name:t,kind:e,addonId:`ai`,enabled:n?.enabled??!0,model:Y(r.model)??n?.model??``,supportsVision:i?.supportsVision??Z(r.supportsVision),timeoutMs:X(r.timeoutMs)??G.totalMs,connectTimeoutMs:X(r.connectTimeoutMs)??G.connectMs,firstTokenTimeoutMs:X(r.firstTokenTimeoutMs)??G.firstTokenMs,idleTimeoutMs:X(r.idleTimeoutMs)??G.idleMs,retry:{enabled:Z(r.retryEnabled),maxAttempts:X(r.retryMaxAttempts)??1},toolsEnabled:Z(r.toolsEnabled)},o=Y(r.baseUrl),s=Y(r.apiKey),c=X(r.temperature),l=X(r.topP),u=X(r.topK),d=X(r.maxTokens),f=X(r.contextLength),p=Y(r.systemPrompt);return{...a,...o===void 0?{}:{baseUrl:o},...s===void 0?{}:{apiKey:s},...c===void 0?{}:{temperature:c},...l===void 0?{}:{topP:l},...u===void 0?{}:{topK:u},...d===void 0?{}:{maxTokens:d},...f===void 0?{}:{contextLength:f},...p===void 0?{}:{systemPrompt:p},...i===void 0?{}:{model:i.modelId,runtime:Ce(r,i.nodeId,i.model)}}}function Te(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 Ee=`apple-system`;function De(e,t,n,r){return{...we(`apple-foundation`,e,t,n),model:Ee,supportsVision:!1,appleFoundation:{nodeId:r}}}var Oe={deviceNotEligible:{key:`ai.appleNotEligible`,text:`not eligible`,tone:`default`},appleIntelligenceNotEnabled:{key:`ai.appleIntelligenceOff`,text:`Apple Intelligence off`,tone:`warning`},modelNotReady:{key:`ai.appleModelNotReady`,text:`model downloading`,tone:`warning`},osTooOld:{key:`ai.appleOsTooOld`,text:`macOS too old`,tone:`default`},helperMissing:{key:`ai.appleHelperMissing`,text:`helper missing`,tone:`danger`},helperCrashed:{key:`ai.appleHelperCrashed`,text:`helper crashed`,tone:`danger`}};function ke(e){let t=t=>({nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleUnknown`,labelDefault:`unknown`,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:`available`,detail:`macOS ${n.osVersion} · ${n.imageInput?`text + images`:`text only`}`,tone:`success`};case`unavailable`:{let t=Oe[n.reason];return{nodeId:e.nodeId,selectable:!1,labelKey:t.key,labelDefault:t.text,detail:n.detail,tone:t.tone}}case`unsupported-platform`:return{nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleNotMac`,labelDefault:`not a Mac`,detail:n.platform,tone:`default`};case`unknown`:return t(n.error)}}var Ae=2e3;function Q(e){return`${(e/1e9).toFixed(2)} GB`}function je(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function Me({nodeId:e,value:t,onChange:n}){let{t:o}=K(),u=m(),[d,f]=s(``),[p,h]=s(null),[g,_]=s(!1),v=a({queryKey:fe,queryFn:()=>u.trpcClient.llm.listModelCatalog.query({})}),x=a({queryKey:[`llm`,`listNodeModels`,e],queryFn:()=>u.trpcClient.llm.listNodeModels.query({nodeId:e})}),S=c({mutationFn:e=>u.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{h(e),_(!1),e.ok&&n({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),C=c({mutationFn:t=>u.trpcClient.llm.installModel.mutate({nodeId:e,model:t}),onSuccess:()=>{_(!0),x.refetch()}}),w=a({queryKey:J,enabled:C.isPending,refetchInterval:C.isPending?Ae:!1,queryFn:()=>u.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(t=>t.nodeId===e)?.status?.download,T=i(()=>{let t=(v.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${Q(e.sizeBytes)}`})),n=(x.data??[]).filter(e=>e.catalogId===void 0&&e.path!==void 0).map(t=>({value:`node:${t.file}`,label:o(`ai.onNode`,`{{file}} · {{size}} · on {{node}}`,{file:t.file,size:Q(t.sizeBytes),node:e})})),r=p?.ok===!0?[{value:`custom`,label:`${p.label} · ${Q(p.totalBytes)}`}]:[];return[{value:``,label:o(`ai.selectModel`,`Select a model…`)},...t,...n,...r]},[v.data,x.data,p,e,o]),E=e=>{if(e===``){n(null);return}if(e===`custom`){if(p?.ok!==!0)return;n({model:p.model,modelId:p.label,supportsVision:p.purpose===`vision`});return}if(e.startsWith(`catalog:`)){let t=e.slice(8),r=v.data?.find(e=>e.id===t);n({model:{kind:`catalog`,catalogId:t},modelId:t,supportsVision:r?.purpose===`vision`});return}let t=e.slice(5),r=x.data?.find(e=>e.file===t);r?.path!==void 0&&n({model:{kind:`path`,path:r.path},modelId:t,supportsVision:!1})},D=e=>{d.trim()!==``&&S.mutate({ref:d.trim(),...e===void 0?{}:{maxBytes:e}})};return r(`div`,{className:`space-y-2`,children:[r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-model`,children:o(`ai.model`,`Model`)}),l(ie,{id:`ai-model`,value:je(t),options:T,onChange:e=>E(e.target.value)})]}),r(`div`,{className:`rounded-md border border-border bg-surface-subtle px-3 py-2.5`,children:[l(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:o(`ai.hfTitle`,`Add a model from Hugging Face`)}),l(`p`,{className:`mb-2 text-[10px] leading-relaxed text-foreground-subtle`,children:o(`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.`)}),r(`div`,{className:`flex gap-2`,children:[l(P,{value:d,onChange:e=>f(e.target.value),placeholder:`unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M`,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),D())}}),r(b,{size:`sm`,variant:`secondary`,type:`button`,disabled:d.trim()===``||S.isPending,onClick:()=>D(),children:[S.isPending?l(B,{className:`h-3.5 w-3.5 animate-spin`}):l(y,{className:`h-3.5 w-3.5`}),o(`ai.hfCheck`,`Check`)]})]}),S.isError&&l(`p`,{className:`mt-2 text-[11px] text-danger`,children:S.error instanceof Error?S.error.message:o(`common.error`,`Error`)}),p?.ok===!1&&r(`div`,{className:`mt-2 rounded-md border border-danger/40 bg-danger/10 px-2.5 py-2`,children:[l(`p`,{className:`text-[11px] text-danger`,children:p.message}),p.candidates!==void 0&&p.candidates.length>0&&l(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:p.candidates.map(e=>l(`button`,{type:`button`,className:`rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] text-foreground hover:border-primary/50`,onClick:()=>{let t=`${d.trim().split(`:`)[0]??``}:${e}`;f(t),S.mutate({ref:t})},children:e},e))}),p.requiredBytes!==void 0&&l(b,{size:`sm`,variant:`secondary`,type:`button`,className:`mt-2`,onClick:()=>D(p.requiredBytes),children:o(`ai.hfOverride`,`Install anyway ({{size}})`,{size:Q(p.requiredBytes)})})]}),p?.ok===!0&&r(`div`,{className:`mt-2 rounded-md border border-border bg-surface px-2.5 py-2`,children:[r(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[l(`span`,{className:`text-[11px] font-medium text-foreground`,children:p.label}),l(M,{variant:p.purpose===`vision`?`info`:`default`,children:p.purpose}),l(M,{variant:`default`,children:Q(p.totalBytes)})]}),p.extraFilenames.length>0&&l(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:o(`ai.hfExtras`,`Also downloads: {{files}}`,{files:p.extraFilenames.join(`, `)})}),r(`div`,{className:`mt-2 flex items-center gap-2`,children:[r(b,{size:`sm`,type:`button`,disabled:C.isPending||g,onClick:()=>C.mutate(p.model),children:[C.isPending?l(B,{className:`h-3.5 w-3.5 animate-spin`}):l(A,{className:`h-3.5 w-3.5`}),g?o(`ai.hfInstalled`,`Downloaded`):o(`ai.hfInstall`,`Download to {{node}}`,{node:e})]}),w!==void 0&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:w.phase===`verifying`?o(`ai.hfVerifying`,`verifying {{file}}…`,{file:w.file}):o(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:w.file,index:w.fileIndex,count:w.fileCount,done:Q(w.downloadedBytes),total:w.totalBytes===void 0?``:` / ${Q(w.totalBytes)}`})})]}),C.isError&&l(`p`,{className:`mt-1.5 text-[11px] text-danger`,children:C.error instanceof Error?C.error.message:o(`common.error`,`Error`)})]})]})]})}function Ne({value:e,onChange:t}){let{t:n}=K(),i=m(),o=a({queryKey:J,queryFn:()=>i.trpcClient.llm.listRuntimeNodes.query({})});return r(`div`,{children:[l(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:n(`ai.appleNode`,`Mac that runs it`)}),o.isPending&&r(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[l(B,{className:`h-3.5 w-3.5 animate-spin`}),n(`ai.appleAsking`,`Asking the nodes…`)]}),o.isError&&l(`p`,{className:`text-[11px] text-danger`,children:o.error instanceof Error?o.error.message:n(`ai.runtimesFailed`,`Failed to read runtime nodes`)}),o.isSuccess&&o.data.length===0&&l(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}),o.isSuccess&&o.data.length>0&&l(`div`,{role:`radiogroup`,className:`space-y-1.5`,children:o.data.map(i=>{let a=ke(i),o=a.nodeId===e;return r(`button`,{type:`button`,role:`radio`,"aria-checked":o,disabled:!a.selectable&&!o,onClick:()=>t(a.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 ${o?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[r(`span`,{className:`min-w-0`,children:[l(`span`,{className:`block font-medium text-foreground`,children:a.nodeId}),a.detail!==null&&l(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:a.detail})]}),l(M,{variant:a.tone,children:n(a.labelKey,a.labelDefault)})]},a.nodeId)})}),l(`p`,{className:`mt-1.5 text-[10px] leading-relaxed text-foreground-subtle`,children:n(`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.`)})]})}n();function Pe({kind:e,className:t}){let n=ge(e.kind);return n===null?l(`span`,{className:t,children:e.icon}):l(n,{className:t})}function Fe({kinds:e,onPick:t,onCancel:n}){let{t:a}=K(),o=i(()=>Te(e),[e]);return l(V,{open:!0,onOpenChange:e=>!e&&n(),children:r(j,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[l(N,{children:l(R,{children:a(`ai.chooseKind`,`Choose a profile type`)})}),r(I,{className:`space-y-4 pr-1`,children:[o.length===0&&l(`p`,{className:`text-xs text-foreground-subtle`,children:a(`ai.noKinds`,`No AI provider is installed.`)}),o.map(e=>r(`div`,{children:[l(`div`,{className:`mb-1.5 text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:e.addonId}),l(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:e.kinds.map(n=>r(`button`,{type:`button`,onClick:()=>t(n),className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-xs transition-colors hover:border-primary/50 hover:bg-surface-hover`,children:[l(Pe,{kind:n,className:`h-5 w-5 text-foreground-subtle`}),l(`span`,{className:`font-medium text-foreground`,children:n.label})]},`${e.addonId}:${n.kind}`))})]},e.addonId))]}),l(H,{children:l(b,{size:`sm`,variant:`secondary`,type:`button`,onClick:n,children:a(`common.cancel`,`Cancel`)})})]})})}function Ie({kind:e,existing:t,onSave:n,onCancel:a,saving:c,error:u}){let{t:d}=K(),f=e.kind===`managed-local`,p=e.kind===`apple-foundation`,[m,h]=s(t?.appleFoundation?.nodeId??null),[g,_]=s(t?.name??e.label),[v,y]=s(()=>t===null?{}:_e(t)),[C,w]=s(t?.runtime?.nodeId??`hub`),[T,E]=s(()=>t?.runtime===void 0?null:{model:t.runtime.model,modelId:t.model,supportsVision:t.supportsVision}),D=i(()=>be(Y(v.extraArgs)??``),[v.extraArgs]),O=()=>{if(p){if(m===null)return;n(De(g,t,v,m));return}if(!f){n(we(e.kind,g,t,v));return}T!==null&&n(we(e.kind,g,t,v,{nodeId:C,model:T.model,modelId:T.modelId,supportsVision:T.supportsVision}))},k=c||g.trim()===``||f&&T===null||p&&m===null;return l(V,{open:!0,onOpenChange:e=>!e&&a(),children:r(j,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[l(N,{children:r(R,{className:`flex items-center gap-2`,children:[l(Pe,{kind:e,className:`h-4 w-4 text-foreground-subtle`}),t===null?d(`ai.newProfile`,`New {{kind}} profile`,{kind:e.label}):d(`ai.editProfile`,`Edit {{name}}`,{name:t.name})]})}),r(I,{className:`space-y-3 pr-1`,children:[u!==null&&l(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:u}),r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-profile-name`,children:d(`ai.name`,`Name`)}),l(P,{id:`ai-profile-name`,value:g,onChange:e=>_(e.target.value),placeholder:e.label})]}),f&&r(o,{children:[l(S,{selectedNodeId:C,onSelect:w,label:d(`ai.runtimeNode`,`Runtime node`),alwaysShow:!0}),l(Me,{nodeId:C,value:T,onChange:E}),r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-extra-args`,children:d(`ai.extraArgs`,`Additional llama-server arguments`)}),l(P,{id:`ai-extra-args`,value:Y(v.extraArgs)??``,onChange:e=>y({...v,extraArgs:e.target.value}),placeholder:Se.join(` `)}),D.length>0&&l(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:D.map((e,t)=>l(M,{variant:`default`,children:e},`${e}-${String(t)}`))}),l(`p`,{className:`mt-1 text-[10px] leading-relaxed text-foreground-subtle`,children:d(`ai.extraArgsHint`,`Flags this form does not already own. Vision models generally need --jinja; some language-only models do not like it. Context size, GPU layers, parallel slots, flash attention and the KV-cache types are set in the fields below — repeating one here is rejected at start.`)})]})]}),p&&l(Ne,{value:m,onChange:h}),l(x,{schema:e.configSchema,values:v,onChange:y}),t!==null&&l(`p`,{className:`text-[10px] text-foreground-subtle`,children:d(`ai.secretHint`,`A stored API key is never shown. Leave it as-is to keep it; type a new value to replace it.`)})]}),r(H,{children:[f&&T===null&&l(M,{variant:`warning`,children:d(`ai.pickModelFirst`,`pick a model`)}),p&&m===null&&l(M,{variant:`warning`,children:d(`ai.pickAppleNodeFirst`,`pick a Mac`)}),l(b,{size:`sm`,variant:`secondary`,type:`button`,onClick:a,children:d(`common.cancel`,`Cancel`)}),r(b,{size:`sm`,type:`button`,disabled:k,onClick:O,children:[c&&l(B,{className:`h-3.5 w-3.5 animate-spin`}),t===null?d(`ai.createProfile`,`Create profile`):d(`ai.saveChanges`,`Save changes`)]})]})]})})}n();function Le(e){return[{key:`name`,header:e.t(`ai.colProfile`,`Profile`),render:t=>{let n=e.kindByName.get(t.kind);return r(`span`,{className:`flex items-center gap-2`,children:[l(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface`,title:n?.label??t.kind,children:n===void 0?l(`span`,{className:`text-xs text-foreground-subtle`,children:`?`}):l(Pe,{kind:n,className:`h-4 w-4 text-foreground-subtle`})}),r(`span`,{className:`min-w-0`,children:[l(`span`,{className:`block truncate text-sm font-medium text-foreground`,children:t.name}),e.testResult?.id===t.id&&l(`span`,{className:`block truncate text-[10px] ${e.testResult.ok?`text-success`:`text-danger`}`,children:e.testResult.text})]})]})}},{key:`kind`,header:e.t(`ai.colKind`,`Kind`),nowrap:!0,render:t=>l(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.kindByName.get(t.kind)?.label??t.kind})},{key:`model`,header:e.t(`ai.colModel`,`Model`),render:e=>l(`span`,{className:`text-[11px] text-foreground`,children:e.model})},{key:`vision`,header:e.t(`ai.colVision`,`Vision`),align:`center`,nowrap:!0,render:t=>t.supportsVision?l(M,{variant:`info`,style:`outline`,children:e.t(`ai.vision`,`vision`)}):l(`span`,{className:`text-[11px] text-foreground-subtle`,children:`—`})},{key:`node`,header:e.t(`ai.colNode`,`Node`),nowrap:!0,render:e=>e.runtime===void 0?l(`span`,{className:`text-[11px] text-foreground-subtle`,children:`—`}):l(M,{variant:`default`,children:e.runtime.nodeId})},{key:`enabled`,header:e.t(`ai.colOn`,`On`),align:`center`,nowrap:!0,render:t=>l(U,{checked:t.enabled,onCheckedChange:()=>e.onToggle(t),"aria-label":`toggle ${t.name}`})},{key:`actions`,header:``,align:`right`,nowrap:!0,render:t=>r(`span`,{className:`flex items-center justify-end gap-1`,children:[l(b,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onTest(t),title:e.t(`ai.test`,`Test`),children:e.testingId===t.id?l(B,{className:`h-3.5 w-3.5 animate-spin`}):l(oe,{className:`h-3.5 w-3.5`})}),l(b,{size:`sm`,variant:`ghost`,type:`button`,disabled:!e.kindByName.has(t.kind),onClick:()=>e.onEdit(t),title:e.t(`common.edit`,`Edit`),children:l(C,{className:`h-3.5 w-3.5`})}),l(b,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onDelete(t),title:e.t(`common.delete`,`Delete`),children:l(g,{className:`h-3.5 w-3.5 text-danger`})})]})}]}function Re(){let{t:e}=K(),t=m(),[n,o]=s({mode:`closed`}),[u,d]=s(null),[f,p]=s(null),h=a({queryKey:le,queryFn:()=>t.trpcClient.llm.listProfiles.query({})}),g=a({queryKey:ue,queryFn:async()=>(await t.trpcClient.llm.listProfileKinds.query({})).map(e=>({...e,configSchema:e.configSchema}))}),_=()=>{h.refetch()},v=c({mutationFn:e=>t.trpcClient.llm.upsertProfile.mutate({profile:e}),onSuccess:()=>{o({mode:`closed`}),p(null),_()},onError:t=>p(t instanceof Error?t.message:e(`ai.saveFailed`,`Save failed`))}),y=c({mutationFn:e=>t.trpcClient.llm.deleteProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:_}),x=c({mutationFn:e=>t.trpcClient.llm.testProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:(e,t)=>d({id:t.id,ok:e.ok,text:e.ok?`${e.text} (${String(e.usage.outputTokens)} tok, ${String(e.latencyMs)}ms)`:`${e.code}: ${e.message}`})}),S=h.data??[],C=i(()=>g.data??[],[g.data]),w=i(()=>{let e=new Map;for(let t of C)e.set(t.kind,t);return e},[C]);return r(q,{icon:re,title:e(`ai.profilesTitle`,`AI profiles`),subtitle:e(`ai.profilesSubtitle`,`One row = one usable model endpoint. The defaults below decide who answers when a feature names no profile.`),actions:r(b,{size:`sm`,type:`button`,onClick:()=>{p(null),o({mode:`pick-kind`})},children:[l(ee,{className:`h-3.5 w-3.5`}),e(`ai.addProfile`,`Add profile`)]}),children:[h.isError&&l(E,{title:e(`ai.loadFailed`,`Failed to load profiles`),message:h.error instanceof Error?h.error.message:e(`common.error`,`Error`),onRetry:()=>void h.refetch()}),l(ze,{profiles:S}),h.isLoading&&l(`div`,{className:`flex items-center justify-center py-16`,children:l(B,{className:`h-6 w-6 animate-spin text-primary`})}),!h.isLoading&&S.length===0&&l(`div`,{className:`py-16 text-center text-xs text-foreground-subtle`,children:e(`ai.noProfiles`,`No AI profiles yet. Click "Add profile" to configure one.`)}),S.length>0&&l(O,{children:l(k,{columns:Le({kindByName:w,testResult:u,testingId:x.isPending?x.variables?.id??null:null,t:e,onToggle:e=>v.mutate({...e,enabled:!e.enabled,apiKey:`__redacted__`}),onTest:e=>x.mutate(e),onEdit:e=>{let t=w.get(e.kind);t!==void 0&&(p(null),o({mode:`form`,kind:t,profile:e}))},onDelete:e=>y.mutate(e)}),rows:S,rowKey:e=>e.id,minWidthPx:760,bordered:!1,mobileMode:`scroll`,maxBodyHeight:`max-h-[60vh]`})}),n.mode===`pick-kind`&&l(Fe,{kinds:C,onCancel:()=>o({mode:`closed`}),onPick:e=>o({mode:`form`,kind:e,profile:null})}),n.mode===`form`&&l(Ie,{kind:n.kind,existing:n.profile,saving:v.isPending,error:f,onSave:e=>v.mutate(e),onCancel:()=>o({mode:`closed`})})]})}function ze({profiles:e}){let{t}=K(),n=m(),i=a({queryKey:de,queryFn:()=>n.trpcClient.llm.getDefaults.query({})}),o=c({mutationFn:e=>n.trpcClient.llm.setDefault.mutate({selector:{purpose:e.purpose},profileId:e.profileId}),onSuccess:()=>{i.refetch()}}),s=e=>(i.data??[]).find(t=>`purpose`in t.selector&&t.selector.purpose===e)?.profileId??``,u=e=>e===`vision`?t(`ai.defaultVision`,`Default vision profile`):t(`ai.defaultText`,`Default text profile`);return l(O,{children:l(`div`,{className:`grid gap-4 p-4 sm:grid-cols-2`,children:me.map(({purpose:n,visionOnly:i})=>{let a=i?e.filter(e=>e.supportsVision):e,c=s(n),d=e.find(e=>e.id===c);return r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`llm-default-${n}`,children:u(n)}),r(`select`,{id:`llm-default-${n}`,"aria-label":u(n),className:`h-7 w-full rounded-md border border-border bg-surface px-2.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,value:c,onChange:e=>o.mutate({purpose:n,profileId:e.target.value===``?null:e.target.value}),children:[l(`option`,{value:``,children:t(`ai.none`,`None`)}),c!==``&&!a.some(e=>e.id===c)&&l(`option`,{value:c,children:d?.name??c}),a.map(e=>r(`option`,{value:e.id,children:[e.name,` · `,e.model]},e.id))]}),c!==``&&d===void 0&&l(`p`,{className:`mt-1 text-[10px] text-danger`,children:t(`ai.defaultMissing`,`This default names a profile that no longer exists.`)}),d!==void 0&&!d.enabled&&l(`p`,{className:`mt-1 text-[10px] text-warning`,children:t(`ai.defaultDisabled`,`This default profile is disabled — callers resolve to no profile.`)}),o.error!=null&&l(`p`,{className:`mt-1 text-[10px] text-danger`,children:String(o.error)})]},n)})})})}n();var Be=5e3;function Ve(e){return`${(e/1e9).toFixed(1)} GB`}function He(){let{t:e}=K(),t=m(),n=a({queryKey:J,refetchInterval:Be,queryFn:()=>t.trpcClient.llm.listRuntimeNodes.query({})}),o=i(()=>[{key:`node`,header:e(`ai.colNode`,`Node`),render:e=>l(`span`,{className:`text-sm font-medium text-foreground`,children:e.nodeId})},{key:`state`,header:e(`ai.colState`,`State`),nowrap:!0,render:t=>r(`span`,{className:`flex items-center gap-1.5`,children:[l(M,{variant:t.reachable?`success`:`danger`,children:t.reachable?t.status?.state??e(`ai.ready`,`ready`):e(`ai.unreachable`,`unreachable`)}),t.status?.downloadProgress!==void 0&&l(M,{variant:`info`,children:`${String(Math.round(t.status.downloadProgress*100))}%`})]})},{key:`model`,header:e(`ai.colModel`,`Model`),render:e=>l(`span`,{className:`text-[11px] text-foreground`,children:e.status?.modelId??`—`})},{key:`disk`,header:e(`ai.colDisk`,`On disk`),align:`right`,nowrap:!0,render:e=>l(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.disk===void 0?`—`:Ve(e.disk.modelsBytes)})},{key:`apple`,header:e(`ai.colApple`,`Apple on-device`),render:t=>{let n=ke(t);return r(`span`,{className:`flex flex-col items-start gap-0.5`,children:[l(M,{variant:n.tone,children:e(n.labelKey,n.labelDefault)}),n.detail!==null&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n.detail})]})}},{key:`error`,header:e(`ai.colError`,`Error`),render:e=>e.error===void 0?l(`span`,{className:`text-[11px] text-foreground-subtle`,children:`—`}):l(`span`,{className:`text-[11px] text-danger`,children:e.error})}],[e]),s=n.data??[];return r(q,{icon:L,title:e(`ai.runtimesTitle`,`Managed runtimes`),subtitle:e(`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.`),children:[n.isError&&l(E,{title:e(`ai.runtimesFailed`,`Failed to read runtime nodes`),message:n.error instanceof Error?n.error.message:e(`common.error`,`Error`),onRetry:()=>void n.refetch()}),s.length===0?l(`div`,{className:`py-16 text-center text-xs text-foreground-subtle`,children:e(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):l(O,{children:l(k,{columns:o,rows:s,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,mobileMode:`scroll`,maxBodyHeight:W})})]})}var Ue=f(`/addon/ai/test-chat`),We=f(`/addon/ai/test-chat/chats`),Ge=6e5;function Ke(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),Ge)}function qe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Je(e){if(!qe(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 Ye=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function Xe(e){let t;try{t=JSON.parse(e)}catch{return null}if(!qe(t))return null;switch(t.kind){case`status`:{let e=Ye.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:Je(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:`the provider returned an error`};default:return null}}async function*Ze(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=Xe(e);t!==null&&(yield t)}a=r.indexOf(`
|
|
3
|
-
`)}}let e=r.trim();if(e.length>0){let t=Xe(e);t!==null&&(yield t)}}finally{t.releaseLock()}}function Qe(e){return e.filter(e=>e.failed!==!0&&e.content.length>0).map(e=>({role:e.role,content:e.content}))}function $e(e){return e.thumbnailBase64===void 0||e.thumbnailBase64.length===0?null:`data:${e.mimeType};base64,${e.thumbnailBase64}`}function et(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 tt(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 nt(e,t){switch(e){case`resolving-image`:return`fetching the picture…`;case`connecting`:return`connecting to the provider…`;case`first-token-wait`:return t>0?`the model is loading / thinking — a cold load can take minutes (up to ${String(Math.round(t/1e3))}s)`:`the model is loading / thinking — a cold load can take minutes`;case`streaming`:return`answering…`}}n();var rt=[`pipelineAnalytics`,`listRecentTracks`,`ai-test`],it=360*60*1e3,at=40,ot=160,$={phase:`connecting`,firstTokenTimeoutMs:0,text:``,mediaSent:null};function st(){let{t:n}=K(),o=m(),[c,d]=s(``),[f,_]=s(``),[v,y]=s(``),[x,S]=s([]),[C,w]=s(null),[D,k]=s(`none`),[A,ee]=s(`throwaway`),[j,M]=s(null),[N,te]=s([]),[re,F]=s(null),[I,L]=s(null),R=t(null);u(()=>()=>R.current?.abort(),[]);let B=e(async()=>{let e=await fetch(We,{credentials:`same-origin`});e.ok&&te((await e.json()).chats??[])},[]);u(()=>{A===`persistent`&&B()},[A,B]);let V=a({queryKey:le,queryFn:()=>o.trpcClient.llm.listProfiles.query({})}),H=i(()=>(V.data??[]).filter(e=>e.enabled),[V.data]),U=H.find(e=>e.id===c)??null,W=I!==null,ae=e(async(e,t)=>{let r=new AbortController;R.current=r,F(null);let i=Ke(U??{});L({...$,firstTokenTimeoutMs:i??0});let a=``,o=null,s,l=null,u=null,d;try{let n=await fetch(Ue,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,signal:r.signal,body:JSON.stringify({profileId:c,messages:e,...f.trim()===``?{}:{system:f.trim()},...t===void 0?{}:{attachment:t},...i===void 0?{}:{firstTokenTimeoutMs:i},...A===`persistent`?{persist:!0,...j===null?{}:{conversationId:j}}:{}})});if(!n.ok||n.body===null){let e=await n.text().catch(()=>``);throw Error(e.length>0?e:`HTTP ${String(n.status)}`)}for await(let e of Ze(n.body))switch(e.kind){case`status`:L(t=>({...t??$,phase:e.phase}));break;case`meta`:o=e.mediaSent,s=e.model,L(t=>({...t??$,firstTokenTimeoutMs:e.firstTokenTimeoutMs,mediaSent:e.mediaSent}));break;case`token`:a+=e.text,L(e=>({...e??$,text:a}));break;case`done`:u={outputTokens:e.outputTokens,latencyMs:e.latencyMs},d=e.conversationId;break;case`error`:l=`${e.code}: ${e.message}`;break}}catch(e){r.signal.aborted||F(e instanceof Error?e.message:n(`common.error`,`Error`))}finally{R.current=null,L(null)}d!==void 0&&(M(d),B());let p=r.signal.aborted&&a.length>0;l===null&&a.length===0&&!p||S(e=>[...e,{id:`a-${String(Date.now())}`,role:`assistant`,content:l??a,...l===null?{}:{failed:!0},...o===null?{}:{attachment:o},...s!==void 0&&l===null?{model:s}:{},...u===null?{}:u}])},[A,j,U,c,B,f,n]),G=e(()=>{let e=v.trim();if(e===``||c===``||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),y(``);let r=C?.ref;w(null),k(`none`),ae(A===`persistent`&&j!==null?[{role:`user`,content:e}]:Qe(n),r)},[A,j,v,C,c,ae,W,x]),se=()=>R.current?.abort(),ue=()=>{R.current?.abort(),S([]),w(null),y(``),F(null),L(null),M(null)},de=async e=>{R.current?.abort();let t=await fetch(`${We}/${e}`,{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();M(e),S(et(n)),L(null),F(null)};return r(q,{icon:ne,title:n(`ai.testTitle`,`Test chat`),subtitle:n(A===`persistent`?`ai.testSubtitlePersistent`:`ai.testSubtitle`,A===`persistent`?`Conversations are saved for you and can be reopened. Throwaway mode is still available.`:`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.`),actions:r(b,{size:`sm`,variant:`secondary`,type:`button`,disabled:x.length===0&&C===null,onClick:ue,children:[l(g,{className:`h-3.5 w-3.5`}),n(`ai.clearChat`,`Clear`)]}),children:[r(O,{className:`space-y-3 p-4`,children:[r(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-test-profile`,children:n(`ai.profile`,`Profile`)}),l(ie,{id:`ai-test-profile`,value:c,onChange:e=>d(e.target.value),options:[{value:``,label:n(`ai.selectProfile`,`Select a profile…`)},...H.map(e=>({value:e.id,label:`${e.name} · ${e.model}${e.supportsVision?` · vision`:``}`}))]}),H.length===0&&!V.isLoading&&l(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:n(`ai.noEnabledProfiles`,`No enabled profile. Add one on the Profiles tab.`)})]}),r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-test-system`,children:n(`ai.systemPrompt`,`System prompt (optional)`)}),l(P,{id:`ai-test-system`,value:f,onChange:e=>_(e.target.value),placeholder:n(`ai.systemPlaceholder`,`Answer in one short sentence.`)})]})]}),r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[l(b,{size:`sm`,variant:A===`throwaway`?`primary`:`outline`,type:`button`,onClick:()=>{ee(`throwaway`),M(null)},children:n(`ai.throwawayMode`,`Throwaway`)}),l(b,{size:`sm`,variant:A===`persistent`?`primary`:`outline`,type:`button`,onClick:()=>ee(`persistent`),children:n(`ai.saveConversation`,`Save conversation`)})]}),A===`persistent`&&r(`div`,{className:`space-y-2`,children:[l(`div`,{className:`flex items-center gap-2`,children:r(b,{size:`sm`,variant:`secondary`,type:`button`,onClick:ue,children:[l(ce,{className:`h-3.5 w-3.5`}),n(`ai.newChat`,`New chat`)]})}),N.length>0&&l(`div`,{className:`max-h-36 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:N.map(e=>l(`button`,{type:`button`,onClick:()=>void de(e.id),className:`flex w-full px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover ${e.id===j?`bg-primary/10`:``}`,children:l(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.title})},e.id))})]}),l(`p`,{className:`text-[10px] text-foreground-subtle`,children:n(`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&&l(`p`,{className:`text-[10px] text-warning`,children:n(`ai.notVision`,`This profile is not vision-capable — an attached image will be refused before anything is read.`)})]}),re!==null&&l(E,{title:n(`ai.chatFailed`,`The test call failed`),message:re}),l(ct,{turns:x,live:I}),r(O,{className:`space-y-2 p-3`,children:[C!==null&&r(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-surface px-2.5 py-1.5`,children:[C.ref.kind===`snapshot`?l(p,{className:`h-3.5 w-3.5 text-foreground-subtle`}):l(z,{className:`h-3.5 w-3.5 text-foreground-subtle`}),l(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-foreground`,children:C.label}),l(b,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>w(null),children:l(T,{className:`h-3.5 w-3.5`})})]}),r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(b,{size:`sm`,variant:D===`snapshot`?`primary`:`outline`,type:`button`,onClick:()=>k(D===`snapshot`?`none`:`snapshot`),children:[l(p,{className:`h-3.5 w-3.5`}),n(`ai.attachSnapshot`,`Camera snapshot`)]}),r(b,{size:`sm`,variant:D===`track`?`primary`:`outline`,type:`button`,onClick:()=>k(D===`track`?`none`:`track`),children:[l(z,{className:`h-3.5 w-3.5`}),n(`ai.attachTrack`,`Recent track`)]})]}),D===`snapshot`&&l(dt,{onPick:e=>{w({ref:{kind:`snapshot`,deviceId:e.id},label:n(`ai.snapshotOf`,`Snapshot of {{name}}`,{name:e.name})}),k(`none`)}}),D===`track`&&l(pt,{onPick:(e,t)=>{w({ref:{kind:`track`,trackId:e.trackId,deviceId:e.deviceId},label:n(`ai.trackOf`,`{{class}} on {{name}}`,{class:e.label??e.className,name:t})}),k(`none`)}}),r(`div`,{className:`flex items-center gap-2`,children:[l(P,{value:v,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),G())},placeholder:n(`ai.messagePlaceholder`,`Ask the model something…`),"aria-label":n(`ai.message`,`Message`)}),W?r(b,{size:`sm`,variant:`secondary`,type:`button`,onClick:se,children:[l(h,{className:`h-3.5 w-3.5`}),n(`ai.stop`,`Stop`)]}):r(b,{size:`sm`,type:`button`,disabled:v.trim()===``||c===``,onClick:G,children:[l(oe,{className:`h-3.5 w-3.5`}),n(`ai.send`,`Send`)]})]})]})]})}function ct({turns:e,live:t}){let{t:n}=K();return e.length===0&&t===null?l(`div`,{className:`py-12 text-center text-xs text-foreground-subtle`,children:n(`ai.chatEmpty`,`Pick a profile, optionally attach a camera snapshot or a recent track, and send a message. Nothing here is saved.`)}):l(O,{children:r(`div`,{className:`max-h-[50vh] space-y-2 overflow-y-auto p-3`,children:[e.map(e=>l(lt,{turn:e},e.id)),t!==null&&r(`div`,{className:`space-y-1`,children:[t.mediaSent!==null&&l(ut,{attachment:t.mediaSent}),t.text.length>0&&l(lt,{turn:{id:`live`,role:`assistant`,content:t.text},streaming:!0}),r(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[l(B,{className:`h-3.5 w-3.5 animate-spin`}),nt(t.phase,t.firstTokenTimeoutMs)]})]})]})})}function lt({turn:e,streaming:t=!1}){let n=e.role===`user`,i=e.failed===!0?`border-danger/40 bg-danger/10`:`border-border bg-surface`;return l(`div`,{className:`flex ${n?`justify-end`:`justify-start`}`,children:r(`div`,{className:`max-w-[85%] rounded-lg border px-3 py-2 ${n?`border-primary/40 bg-primary/10`:i}`,children:[r(`p`,{className:`whitespace-pre-wrap break-words text-xs text-foreground`,children:[e.content,t&&l(`span`,{className:`ml-0.5 animate-pulse text-primary`,children:`▌`})]}),e.attachment!==void 0&&l(ut,{attachment:e.attachment}),e.attachmentLabel!==void 0&&r(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[e.attachmentKind===`track`?l(z,{className:`h-3 w-3`}):l(p,{className:`h-3 w-3`}),e.attachmentLabel]}),e.attachment!==void 0&&r(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[e.attachment.kind===`snapshot`?l(p,{className:`h-3 w-3`}):l(z,{className:`h-3 w-3`}),tt(e.attachment)]}),e.model!==void 0&&l(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:`${e.model} · ${String(e.outputTokens??0)} tok · ${String(e.latencyMs??0)} ms`})]})})}function ut({attachment:e}){let t=$e(e);return t===null?null:l(`img`,{src:t,alt:`sent to the model`,className:`mt-1 max-h-32 rounded-md border border-border object-contain`})}function dt({onPick:e}){let{t}=K(),n=te({isCamera:!0,projection:`slim`}),r=(n.data??[]).filter(e=>!e.disabled);return n.isLoading?l(B,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r.length===0?l(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noCameras`,`No camera found.`)}):l(`div`,{className:`grid max-h-56 grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-4`,children:r.map(t=>l(ft,{device:t,onPick:e},t.id))})}function ft({device:e,onPick:t}){let{src:n}=d(e.id,{width:ot});return r(`button`,{type:`button`,onClick:()=>t(e),className:`overflow-hidden rounded-md border border-border bg-surface text-left transition-colors hover:border-primary/50`,children:[l(`span`,{className:`block aspect-video w-full bg-background-elevated`,children:n!==null&&l(`img`,{src:n,alt:``,className:`h-full w-full object-cover`,loading:`lazy`})}),r(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[!e.online&&l(M,{variant:`warning`,children:`off`}),l(`span`,{className:`truncate text-[10px] text-foreground`,children:e.name})]})]})}function pt({onPick:e}){let{t}=K(),n=m(),o=te({isCamera:!0,projection:`slim`}),s=i(()=>(o.data??[]).map(e=>e.id),[o.data]),c=i(()=>{let e=new Map;for(let t of o.data??[])e.set(t.id,t.name);return e},[o.data]),u=a({queryKey:[...rt,s.length],enabled:s.length>0,queryFn:()=>n.trpcClient.pipelineAnalytics.listRecentTracks.query({deviceIds:[...s],since:Date.now()-it,limit:at,projection:`slim`})});if(o.isLoading||u.isLoading)return l(B,{className:`h-4 w-4 animate-spin text-foreground-subtle`});let d=u.data?.tracks??[];return d.length===0?l(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noTracks`,`No track in the last 6 hours.`)}):l(`div`,{className:`max-h-56 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:d.map(t=>r(`button`,{type:`button`,onClick:()=>e(t,c.get(t.deviceId)??String(t.deviceId)),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover`,children:[l(z,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),l(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:t.label??t.className}),l(`span`,{className:`shrink-0 text-foreground-subtle`,children:c.get(t.deviceId)??t.deviceId}),l(`span`,{className:`shrink-0 text-foreground-subtle`,children:new Date(t.lastSeen).toLocaleTimeString()})]},t.trackId))})}n();var mt=1440*60*1e3,ht=[1,7,30,90];function gt(){let{t:e}=K(),t=m(),[n,o]=s(7),c=i(()=>{let e=new Date;return e.setHours(0,0,0,0),e.getTime()-(n-1)*mt},[n]),u=a({queryKey:le,queryFn:()=>t.trpcClient.llm.listProfiles.query({})}),d=a({queryKey:[...pe,n],queryFn:()=>t.trpcClient.llm.getUsage.query({since:c})}),f=i(()=>{let e=new Map;for(let t of u.data??[])e.set(t.id,t.name);return e},[u.data]),p=i(()=>[{key:`day`,header:e(`ai.colDay`,`Day`),nowrap:!0,render:e=>e.day},{key:`consumer`,header:e(`ai.colConsumer`,`Consumer`),nowrap:!0,render:e=>l(`span`,{className:`text-[11px] text-foreground`,children:e.consumer})},{key:`profile`,header:e(`ai.colProfile`,`Profile`),render:e=>l(`span`,{className:`text-[11px] text-foreground`,children:f.get(e.profileId)??e.profileId})},{key:`calls`,header:e(`ai.colCalls`,`Calls`),align:`right`,nowrap:!0,render:e=>String(e.calls)},{key:`okErr`,header:e(`ai.colOkErr`,`OK / err`),align:`right`,nowrap:!0,render:e=>l(`span`,{className:e.errorCalls>0?`text-danger`:void 0,children:`${String(e.okCalls)} / ${String(e.errorCalls)}`})},{key:`tokens`,header:e(`ai.colTokens`,`In / out tok`),align:`right`,nowrap:!0,render:e=>`${String(e.inputTokens)} / ${String(e.outputTokens)}`},{key:`latency`,header:e(`ai.colAvgMs`,`Avg ms`),align:`right`,nowrap:!0,render:e=>String(Math.round(e.avgLatencyMs))}],[f,e]),h=d.data??[];return r(q,{icon:F,title:e(`ai.usageTitle`,`Usage`),subtitle:e(`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.`),actions:l(`div`,{className:`w-40`,children:l(ie,{"aria-label":e(`ai.window`,`Window`),value:String(n),options:ht.map(t=>({value:String(t),label:e(`ai.lastDays`,`Last {{days}} days`,{days:t})})),onChange:e=>o(Number(e.target.value))})}),children:[d.isError&&l(E,{title:e(`ai.usageFailed`,`Failed to read usage`),message:d.error instanceof Error?d.error.message:e(`common.error`,`Error`),onRetry:()=>void d.refetch()}),h.length===0?l(`div`,{className:`py-16 text-center text-xs text-foreground-subtle`,children:e(`ai.noUsage`,`No AI calls in this window.`)}):l(O,{children:l(k,{columns:p,rows:h,rowKey:e=>`${e.day}|${e.consumer}|${e.profileId}`,minWidthPx:720,bordered:!1,mobileMode:`scroll`,maxBodyHeight:W})})]})}function _t(){let{t:e}=K();return l(`div`,{className:`flex flex-col p-4`,children:l(se,{tabs:[{id:`profiles`,label:e(`ai.tabProfiles`,`Profiles`),icon:ae,content:l(Re,{})},{id:`runtimes`,label:e(`ai.tabRuntimes`,`Runtimes`),icon:L,content:l(He,{})},{id:`usage`,label:e(`ai.tabUsage`,`Usage`),icon:F,content:l(gt,{})},{id:`test`,label:e(`ai.tabTest`,`Test`),icon:ne,content:l(st,{})}]})})}export{_t as AiProfilesPage,_t as default};
|