@camstack/system 1.2.455 → 1.2.456

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/{agent-https-CLWrOO3o.mjs → agent-https-fm4AR8XL.mjs} +32 -5
  2. package/dist/{agent-https-CCvlRQKV.js → agent-https-yjxdfJDA.js} +37 -4
  3. package/dist/auth/auth-manager.d.ts +9 -0
  4. package/dist/auth/legacy-token-tables.d.ts +16 -0
  5. package/dist/auth/user-management-internal.d.ts +9 -28
  6. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  7. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  8. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  9. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  10. package/dist/builtins/alerts/alerts.addon.js +2 -2
  11. package/dist/builtins/alerts/alerts.addon.mjs +2 -2
  12. package/dist/builtins/autotrack/index.js +1 -1
  13. package/dist/builtins/autotrack/index.mjs +1 -1
  14. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  15. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  16. package/dist/builtins/calendars/calendars.addon.js +1 -1
  17. package/dist/builtins/calendars/calendars.addon.mjs +1 -1
  18. package/dist/builtins/camera-grid/index.js +1 -1
  19. package/dist/builtins/camera-grid/index.mjs +1 -1
  20. package/dist/builtins/composer/composer.addon.js +2 -2
  21. package/dist/builtins/composer/composer.addon.mjs +2 -2
  22. package/dist/builtins/console-logging/index.js +1 -1
  23. package/dist/builtins/console-logging/index.mjs +1 -1
  24. package/dist/builtins/core-blocks/core-blocks.addon.js +2 -2
  25. package/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
  26. package/dist/builtins/device-history/device-history.addon.js +1 -1
  27. package/dist/builtins/device-history/device-history.addon.mjs +1 -1
  28. package/dist/builtins/device-manager/device-manager.addon.js +1 -1
  29. package/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  30. package/dist/builtins/hub-forwarder/index.js +1 -1
  31. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  32. package/dist/builtins/keychain/index.js +4 -4
  33. package/dist/builtins/keychain/index.mjs +4 -4
  34. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  35. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  36. package/dist/builtins/local-auth/auth-schema.d.ts +4 -7
  37. package/dist/builtins/local-auth/local-auth.addon.d.ts +7 -8
  38. package/dist/builtins/local-auth/local-auth.addon.js +1086 -1329
  39. package/dist/builtins/local-auth/local-auth.addon.mjs +1085 -1326
  40. package/dist/builtins/local-auth/preferences-record-kinds.d.ts +27 -0
  41. package/dist/builtins/local-auth/record-kinds.d.ts +4 -3
  42. package/dist/builtins/local-auth/user-preferences-store.d.ts +56 -0
  43. package/dist/builtins/local-network/local-network.addon.d.ts +8 -0
  44. package/dist/builtins/local-network/local-network.addon.js +30 -5
  45. package/dist/builtins/local-network/local-network.addon.mjs +30 -5
  46. package/dist/builtins/loki-logging/index.js +1 -1
  47. package/dist/builtins/loki-logging/index.mjs +1 -1
  48. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  49. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  50. package/dist/builtins/platform-probe/index.js +1 -1
  51. package/dist/builtins/platform-probe/index.mjs +1 -1
  52. package/dist/builtins/record-entries/index.js +1 -1
  53. package/dist/builtins/record-entries/index.mjs +1 -1
  54. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  55. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  56. package/dist/builtins/snapshot/index.js +1 -1
  57. package/dist/builtins/snapshot/index.mjs +1 -1
  58. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  59. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  60. package/dist/builtins/sqlite-storage/index.js +1 -1
  61. package/dist/builtins/sqlite-storage/index.mjs +1 -1
  62. package/dist/builtins/sqlite-storage/records/records-engine-types.d.ts +1 -0
  63. package/dist/builtins/sqlite-storage/records/records-provider.d.ts +13 -0
  64. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +52 -6
  65. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +52 -6
  66. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  67. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  68. package/dist/builtins/system-config/system-config.addon.js +3 -3
  69. package/dist/builtins/system-config/system-config.addon.mjs +3 -3
  70. package/dist/builtins/winston-logging/index.js +1 -1
  71. package/dist/builtins/winston-logging/index.mjs +1 -1
  72. package/dist/{composition-sources-CSzD5_qX.mjs → composition-sources-Ds0Vr6eD.mjs} +1 -1
  73. package/dist/{composition-sources-BxUkLNSo.js → composition-sources-gB4coDJR.js} +1 -1
  74. package/dist/{constants-DruwCkfp.js → constants-CavyKfHZ.js} +1 -1
  75. package/dist/{constants-DOlYt1t1.mjs → constants-i5oD_gLB.mjs} +1 -1
  76. package/dist/{device-ca-QPBgfqVY.js → device-ca-bpoEr0zG.js} +1 -1
  77. package/dist/{device-ca-uFbTyY_o.mjs → device-ca-qz1Pmeu1.mjs} +1 -1
  78. package/dist/{dist-BpSENkRJ.mjs → dist-BSF_C8W2.mjs} +216 -109
  79. package/dist/{dist-DjQ8C-ku.js → dist-BpqA2CT0.js} +251 -108
  80. package/dist/file-host-worker.js +1 -1
  81. package/dist/file-host-worker.mjs +1 -1
  82. package/dist/{hub-mdns-ciao-DlgkFJVY.mjs → hub-mdns-ciao-CHaGDzyz.mjs} +20 -13
  83. package/dist/{hub-mdns-ciao-Bkrvgnma.js → hub-mdns-ciao-CZlZRxxA.js} +20 -13
  84. package/dist/index.d.ts +2 -4
  85. package/dist/index.js +17 -11
  86. package/dist/index.mjs +17 -9
  87. package/dist/{phase6-declare-gate-JQUqgQgq.mjs → phase6-declare-gate-B4yfsf2n.mjs} +1 -1
  88. package/dist/{phase6-declare-gate-DrmTtz7F.js → phase6-declare-gate-n-IZRklX.js} +1 -1
  89. package/dist/{restore-archive-4OP0EYg6.js → restore-archive-B4QG7XmX.js} +1 -1
  90. package/dist/{restore-archive-YFSJRtKy.mjs → restore-archive-BGUM4FKf.mjs} +1 -1
  91. package/dist/tls/cert-issue.d.ts +16 -1
  92. package/dist/tls/cert-manager.d.ts +6 -0
  93. package/dist/tls/index.d.ts +1 -1
  94. package/dist/{wal-maintenance-TyuOEVy1.mjs → wal-maintenance-AerF4XE6.mjs} +0 -0
  95. package/dist/{wal-maintenance-Bl0ZKjVR.js → wal-maintenance-CNEs_I94.js} +0 -0
  96. package/package.json +1 -1
  97. package/dist/auth/admin-token-manager.d.ts +0 -51
  98. package/dist/auth/scoped-token-manager.d.ts +0 -25
@@ -745,7 +745,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
745
745
  return EventCategory;
746
746
  }({});
747
747
  //#endregion
748
- //#region ../types/dist/sleep-BxjU_fJM.mjs
748
+ //#region ../types/dist/sleep-yKL5gfrH.mjs
749
749
  /**
750
750
  * The audio chunk plane's byte format, and the ONE expansion from a coded
751
751
  * window to float samples (D455).
@@ -3258,9 +3258,9 @@ function normalizeAddonInitResult(result) {
3258
3258
  */
3259
3259
  var DATAPLANE_SECRET_HEADER = "x-camstack-dataplane-secret";
3260
3260
  /**
3261
- * The share-view scope kinds a `csv_*` share token can carry. The hub mints
3262
- * and validates them (`share-token.service.ts` builds its enum from this
3263
- * list); a data plane names the kinds it ACCEPTS in `share`.
3261
+ * The share-view scope kinds a share-link token can carry. The hub mints
3262
+ * and validates them (`ShareViewGrantSchema` builds its
3263
+ * enum from this list); a data plane names the kinds it ACCEPTS in `share`.
3264
3264
  */
3265
3265
  var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
3266
3266
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
@@ -10420,7 +10420,7 @@ function scopesAllowAddon(scopes, addonId, access) {
10420
10420
  * `super_admin` — collapsed onto the single boolean because every
10421
10421
  * non-admin caller is governed by the same scope-check rules; the
10422
10422
  * distinction was only ever used to route role-specific procedures
10423
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
10423
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
10424
10424
  * with `isAdmin: false` + an explicit scope list.
10425
10425
  */
10426
10426
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -10609,24 +10609,117 @@ var AddonRoutesScopeSchema = zod.z.object({
10609
10609
  type: zod.z.literal("addon-routes"),
10610
10610
  access: zod.z.array(MethodAccessSchema).min(1)
10611
10611
  });
10612
+ var PreferencesSelfScopeSchema = zod.z.object({ type: zod.z.literal("preferences-self") });
10612
10613
  var CredentialScopeSchema = zod.z.union([
10613
10614
  zod.z.literal("*"),
10614
10615
  ShareViewScopeSchema,
10615
10616
  AddonRoutesScopeSchema,
10617
+ PreferencesSelfScopeSchema,
10616
10618
  TokenScopeSchema
10617
10619
  ]);
10618
10620
  /**
10621
+ * The `kind` claim of a unified token. It names the TOKEN FAMILY (so every
10622
+ * older gate that classifies a hub JWT refuses it — `classifyBearerPrincipal`
10623
+ * treats any `kind` it does not know as not-a-credential), never what the
10624
+ * token may do: that is its `scopes`, and only its `scopes`.
10625
+ */
10626
+ var CREDENTIAL_TOKEN_KIND = "credential";
10627
+ /**
10628
+ * The `aud` claim every minted token is signed with (D895). The hub's raw JWT
10629
+ * verify (`AuthManager.verifyToken`, used by every surface that wants a LOGIN
10630
+ * session — the OAuth consent page, the session cookie, health, backups)
10631
+ * refuses a token carrying it, so a minted token — a share link above all —
10632
+ * can never be replayed as a person's session. Only the credential verifier's
10633
+ * own door (`verifyCredentialToken`) accepts it.
10634
+ */
10635
+ var CREDENTIAL_TOKEN_AUDIENCE = "camstack:credential";
10636
+ /** Does a verified JWT payload belong to the minted-token family? */
10637
+ function isCredentialTokenPayload(payload) {
10638
+ if (payload === null || typeof payload !== "object") return false;
10639
+ const kind = Reflect.get(payload, "kind");
10640
+ const aud = Reflect.get(payload, "aud");
10641
+ return kind === "credential" || aud === "camstack:credential" || Array.isArray(aud) && aud.includes("camstack:credential");
10642
+ }
10643
+ /**
10619
10644
  * The claims of a unified token (`auth.mintToken`). It carries no `exp`: its
10620
10645
  * row (looked up by `jti` on every verify, for revocation) holds the ONE
10621
10646
  * expiry, so a share link can be extended and a JWT clock can never disagree
10622
10647
  * with the row.
10623
10648
  */
10624
10649
  var CredentialTokenClaimsSchema = zod.z.object({
10625
- kind: zod.z.literal("credential"),
10650
+ kind: zod.z.literal(CREDENTIAL_TOKEN_KIND),
10626
10651
  sub: zod.z.string().min(1),
10627
10652
  jti: zod.z.string().min(16),
10628
10653
  scopes: zod.z.array(CredentialScopeSchema).min(1)
10629
10654
  });
10655
+ /**
10656
+ * Per-user ACCOUNT preferences (D894): the hub-side half of the viewer's two
10657
+ * settings levels.
10658
+ *
10659
+ * - DEVICE settings never leave the phone.
10660
+ * - ACCOUNT settings live here: one row per `(user, namespace)`, private to
10661
+ * that user, synced across every device signed in as them, last write wins
10662
+ * unless the writer sends the revision it based its edit on.
10663
+ *
10664
+ * A setting lives in exactly ONE level; there are no overrides. The caller
10665
+ * never names a user: the hub stamps the principal's own id, admin included.
10666
+ *
10667
+ * The contract the client codes against is the `preferences.*` tRPC router
10668
+ * (`server/backend/src/api/core/preferences.router.ts`).
10669
+ */
10670
+ /** `viewer.app`, `viewer.cameras`, `viewer.grids` … — lowercase, dot/dash separated. */
10671
+ var PREFERENCES_NAMESPACE_PATTERN = /^[a-z][a-z0-9.-]{0,63}$/;
10672
+ /** One row's value, measured as UTF-8 JSON. */
10673
+ var PREFERENCES_MAX_VALUE_BYTES = 256 * 1024;
10674
+ var PreferenceNamespaceSchema = zod.z.string().regex(PREFERENCES_NAMESPACE_PATTERN);
10675
+ /** A namespace's value: a JSON object, opaque to the hub. */
10676
+ var PreferenceValueSchema = zod.z.record(zod.z.string(), zod.z.unknown());
10677
+ var PreferenceDeviceIdSchema = zod.z.string().min(1).max(64);
10678
+ /** A stored row, as the owner reads it. */
10679
+ var PreferenceRowSchema = zod.z.object({
10680
+ namespace: PreferenceNamespaceSchema,
10681
+ value: PreferenceValueSchema,
10682
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
10683
+ revision: zod.z.number().int().positive(),
10684
+ updatedAt: zod.z.number().int(),
10685
+ /** The client id the last writer sent; `null` when it sent none. */
10686
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
10687
+ });
10688
+ zod.z.object({
10689
+ /** Absent: every namespace the caller holds. */
10690
+ namespaces: zod.z.array(PreferenceNamespaceSchema).max(32).optional() });
10691
+ zod.z.object({ rows: zod.z.array(PreferenceRowSchema) });
10692
+ zod.z.object({
10693
+ namespace: PreferenceNamespaceSchema,
10694
+ value: PreferenceValueSchema,
10695
+ /**
10696
+ * The revision the edit was based on. Absent: last write wins. `0`: the
10697
+ * namespace must not exist yet. Any other value that is not the current
10698
+ * revision answers `conflict` and writes nothing.
10699
+ */
10700
+ baseRevision: zod.z.number().int().nonnegative().optional(),
10701
+ deviceId: PreferenceDeviceIdSchema.optional()
10702
+ });
10703
+ zod.z.discriminatedUnion("status", [zod.z.object({
10704
+ status: zod.z.literal("saved"),
10705
+ row: PreferenceRowSchema
10706
+ }), zod.z.object({
10707
+ status: zod.z.literal("conflict"),
10708
+ current: PreferenceRowSchema.nullable()
10709
+ })]);
10710
+ zod.z.object({ namespace: PreferenceNamespaceSchema });
10711
+ zod.z.object({
10712
+ /** `false` when the namespace did not exist. */
10713
+ deleted: zod.z.boolean() });
10714
+ zod.z.object({
10715
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
10716
+ revisionByNamespace: zod.z.record(PreferenceNamespaceSchema, zod.z.number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
10717
+ zod.z.object({
10718
+ /** Every row whose revision differs from the client's, and every row it did not list. */
10719
+ rows: zod.z.array(PreferenceRowSchema),
10720
+ /** Namespaces the client listed that no longer exist. */
10721
+ deleted: zod.z.array(PreferenceNamespaceSchema)
10722
+ });
10630
10723
  zod.z.enum(["new-session", "step-up"]);
10631
10724
  /** The languages the hub's app landing pages are written in (D858). */
10632
10725
  var AppPageLangSchema = zod.z.enum(["en", "it"]);
@@ -42223,38 +42316,37 @@ var llmRuntimeCapability = {
42223
42316
  })
42224
42317
  }
42225
42318
  };
42319
+ var LlmProfileKindSchema = zod.z.string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
42320
+ /** What a model (or, by default, every model of a kind) can do. */
42321
+ var LlmModelFeaturesSchema = zod.z.object({
42322
+ vision: zod.z.boolean(),
42323
+ tools: zod.z.boolean(),
42324
+ streaming: zod.z.boolean()
42325
+ });
42326
+ /** One model a provider offers. `features` overrides the kind's defaults, per field. */
42327
+ var LlmModelInfoSchema = zod.z.object({
42328
+ id: zod.z.string(),
42329
+ label: zod.z.string().optional(),
42330
+ contextLength: zod.z.number().int().positive().optional(),
42331
+ features: LlmModelFeaturesSchema.partial().optional()
42332
+ });
42226
42333
  /**
42227
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
42228
- * methods concat-fan across providers; single-row methods route to ONE
42229
- * provider by the `addonId` in the call input (the notification-output
42230
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
42231
- * (hub-placed); the cap stays open for future providers.
42232
- *
42233
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
42234
- * `apiKey` is a password field — providers REDACT it on read and merge on
42235
- * write; a stored key NEVER round-trips to a client.
42236
- */
42237
- var LlmProfileKindSchema = zod.z.enum([
42238
- "openai-compatible",
42239
- "openai",
42240
- "anthropic",
42241
- "google",
42242
- "managed-local",
42243
- "apple-foundation"
42244
- ]);
42334
+ * The provider-specific part of a profile, validated by the provider that owns
42335
+ * the kind (`upsertProfile` refuses what it does not accept). A field its
42336
+ * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
42337
+ * keychain, never in the row, and reads back as the redaction marker.
42338
+ */
42339
+ var LlmProviderConfigSchema = zod.z.record(zod.z.string(), zod.z.unknown());
42245
42340
  var LlmProfileSchema = zod.z.object({
42246
42341
  id: zod.z.string(),
42247
42342
  name: zod.z.string(),
42343
+ /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
42248
42344
  kind: LlmProfileKindSchema,
42249
42345
  /** Stamped by the provider — keeps the fanned catalog routable. */
42250
42346
  addonId: zod.z.string(),
42251
42347
  enabled: zod.z.boolean(),
42252
42348
  /** Vendor model id, or the managed runtime's loaded model. */
42253
42349
  model: zod.z.string(),
42254
- /** Required for openai-compatible; override for cloud kinds. */
42255
- baseUrl: zod.z.string().optional(),
42256
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
42257
- apiKey: zod.z.string().optional(),
42258
42350
  /** Vision on/off. A vision call against a `false` profile is REFUSED, never
42259
42351
  * degraded to text — that shipped once and produced a confident answer to a
42260
42352
  * question about a picture nobody sent. */
@@ -42262,15 +42354,11 @@ var LlmProfileSchema = zod.z.object({
42262
42354
  temperature: zod.z.number().min(0).max(2).optional(),
42263
42355
  /** Nucleus sampling. Every wire we speak has it. */
42264
42356
  topP: zod.z.number().min(0).max(1).optional(),
42265
- /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
42266
- * wire does, and the client drops it there (measured: the request body gets
42267
- * `top_p` and no `top_k`). The profile editor hides the field wherever it
42268
- * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
42357
+ /** Top-k sampling. Carried only by the wires that have it — a kind offers the
42358
+ * field in its editor only when its descriptor lists it in `profileFields`. */
42269
42359
  topK: zod.z.number().int().positive().optional(),
42270
42360
  maxTokens: zod.z.number().int().positive().optional(),
42271
- /** Prompt context window. Advisory for cloud kinds (they enforce their own);
42272
- * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
42273
- * the model with, so it is the one field that changes a PROCESS. */
42361
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
42274
42362
  contextLength: zod.z.number().int().positive().optional(),
42275
42363
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
42276
42364
  * two system prompts fighting is worse than either alone). */
@@ -42296,16 +42384,37 @@ var LlmProfileSchema = zod.z.object({
42296
42384
  * library; the REGISTRY of callable tools is ours and is empty in v1, so a
42297
42385
  * `true` here buys the wiring, not behaviour, until tools are registered. */
42298
42386
  toolsEnabled: zod.z.boolean().default(false),
42299
- extraHeaders: zod.z.record(zod.z.string(), zod.z.string()).optional(),
42300
- /** kind === 'managed-local' only (spec §4). */
42301
- runtime: ManagedRuntimeConfigSchema.optional(),
42302
- /**
42303
- * kind === 'apple-foundation' only: WHERE it runs — the only thing there is
42304
- * to configure (no key, no URL, no download; `model` is `apple-system`).
42305
- * `supportsVision` on such a row is stamped by the provider from the node's
42306
- * reported `imageInput`, never taken from the operator (D62).
42307
- */
42308
- appleFoundation: zod.z.object({ nodeId: zod.z.string() }).optional()
42387
+ /** Everything the kind's provider owns (endpoint, key, node, runtime…). */
42388
+ providerConfig: LlmProviderConfigSchema.default({})
42389
+ });
42390
+ /**
42391
+ * The common profile fields a kind's editor offers. The editor owns how each
42392
+ * one is drawn; the provider says which of them mean something on its wire.
42393
+ */
42394
+ var LlmProfileFieldSchema = zod.z.enum([
42395
+ "temperature",
42396
+ "topP",
42397
+ "topK",
42398
+ "maxTokens",
42399
+ "contextLength",
42400
+ "systemPrompt",
42401
+ "timeoutMs",
42402
+ "connectTimeoutMs",
42403
+ "firstTokenTimeoutMs",
42404
+ "idleTimeoutMs",
42405
+ "retry",
42406
+ "toolsEnabled"
42407
+ ]);
42408
+ /**
42409
+ * A provider-drawn part of the editor, by a generic widget id the admin UI
42410
+ * registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
42411
+ * picker: that widget owns the model choice.
42412
+ */
42413
+ var LlmProviderWidgetSchema = zod.z.object({
42414
+ id: zod.z.string(),
42415
+ placement: zod.z.enum(["connection", "model"]),
42416
+ /** `providerConfig` keys this widget must fill before the profile can be saved. */
42417
+ requires: zod.z.array(zod.z.string()).optional()
42309
42418
  });
42310
42419
  /** ConfigUISchema tree passed through untyped on the wire (the
42311
42420
  * notification-output `ConfigSchemaPassthrough` precedent at
@@ -42314,11 +42423,56 @@ var ConfigSchemaPassthrough$3 = zod.z.unknown();
42314
42423
  var LlmProfileKindDescriptorSchema = zod.z.object({
42315
42424
  kind: LlmProfileKindSchema,
42316
42425
  label: zod.z.string(),
42426
+ /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
42317
42427
  icon: zod.z.string(),
42318
42428
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
42319
42429
  addonId: zod.z.string(),
42320
- configSchema: ConfigSchemaPassthrough$3
42430
+ /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
42431
+ connectionSchema: ConfigSchemaPassthrough$3,
42432
+ /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
42433
+ advancedSchema: ConfigSchemaPassthrough$3.optional(),
42434
+ /** The kind's defaults; a model from `listModels` may override any of them. */
42435
+ features: LlmModelFeaturesSchema,
42436
+ /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
42437
+ visionEditable: zod.z.boolean(),
42438
+ /** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
42439
+ modelCatalog: zod.z.enum([
42440
+ "fetch",
42441
+ "static",
42442
+ "none"
42443
+ ]),
42444
+ staticModels: zod.z.array(LlmModelInfoSchema).optional(),
42445
+ /** The common fields that mean something on this kind's wire. */
42446
+ profileFields: zod.z.array(LlmProfileFieldSchema),
42447
+ providerWidgets: zod.z.array(LlmProviderWidgetSchema).optional()
42448
+ });
42449
+ /**
42450
+ * `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
42451
+ * (the editor's form); with `profileId` too, a secret the draft leaves
42452
+ * untouched (absent or the redaction marker) is resolved server-side from the
42453
+ * stored profile — the browser never receives it.
42454
+ */
42455
+ var LlmListModelsInputSchema = zod.z.object({
42456
+ addonId: zod.z.string(),
42457
+ kind: LlmProfileKindSchema,
42458
+ profileId: zod.z.string().optional(),
42459
+ connection: LlmProviderConfigSchema.optional()
42321
42460
  });
42461
+ var LlmListModelsErrorCodeSchema = zod.z.enum([
42462
+ "auth",
42463
+ "network",
42464
+ "unsupported",
42465
+ "invalid"
42466
+ ]);
42467
+ /** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
42468
+ var LlmListModelsResultSchema = zod.z.discriminatedUnion("ok", [zod.z.object({
42469
+ ok: zod.z.literal(true),
42470
+ models: zod.z.array(LlmModelInfoSchema)
42471
+ }), zod.z.object({
42472
+ ok: zod.z.literal(false),
42473
+ code: LlmListModelsErrorCodeSchema,
42474
+ message: zod.z.string()
42475
+ })]);
42322
42476
  var LlmDefaultSelectorSchema = zod.z.union([zod.z.object({ consumer: zod.z.string() }), zod.z.object({ purpose: zod.z.enum(["text", "vision"]) })]);
42323
42477
  var LlmDefaultSchema = zod.z.object({
42324
42478
  selector: LlmDefaultSelectorSchema,
@@ -42449,8 +42603,17 @@ var llmCapability = {
42449
42603
  auth: "admin",
42450
42604
  timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
42451
42605
  }),
42452
- /** Live vendor enumeration (GET /models etc.). */
42453
- listModels: method(ProfileRefInputSchema, zod.z.array(zod.z.string())),
42606
+ /**
42607
+ * The models a kind offers, for a SAVED profile or an unsaved draft
42608
+ * (`connection`). A mutation, not a query: a draft may carry a key, and a
42609
+ * query's input travels in the URL. Admin: it dials whatever endpoint the
42610
+ * draft names and may resolve a stored key to do it. The answer never
42611
+ * carries a secret — failures are a typed result, never a throw.
42612
+ */
42613
+ listModels: method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
42614
+ kind: "mutation",
42615
+ auth: "admin"
42616
+ }),
42454
42617
  getDefaults: method(zod.z.object({}), zod.z.array(LlmDefaultSchema)),
42455
42618
  setDefault: method(zod.z.object({
42456
42619
  selector: LlmDefaultSelectorSchema,
@@ -71343,26 +71506,6 @@ var ApiKeySummarySchema = zod.z.object({
71343
71506
  createdAt: zod.z.number(),
71344
71507
  lastUsedAt: zod.z.number().optional()
71345
71508
  });
71346
- var ScopedTokenSummarySchema = zod.z.object({
71347
- id: zod.z.string(),
71348
- userId: zod.z.string(),
71349
- name: zod.z.string(),
71350
- tokenPrefix: zod.z.string(),
71351
- scopes: zod.z.array(TokenScopeSchema),
71352
- expiresAt: zod.z.number().nullish(),
71353
- lastUsedAt: zod.z.number().nullish(),
71354
- createdAt: zod.z.number()
71355
- });
71356
- var CreateScopedTokenInputSchema = zod.z.object({
71357
- userId: zod.z.string(),
71358
- name: zod.z.string(),
71359
- scopes: zod.z.array(TokenScopeSchema),
71360
- expiresAt: zod.z.number().optional()
71361
- });
71362
- var CreateScopedTokenResultSchema = zod.z.object({
71363
- token: zod.z.string(),
71364
- record: ScopedTokenSummarySchema
71365
- });
71366
71509
  var OauthSessionSummarySchema = zod.z.object({
71367
71510
  id: zod.z.string(),
71368
71511
  userId: zod.z.string(),
@@ -71384,11 +71527,11 @@ var TotpStatusSchema = zod.z.object({
71384
71527
  confirmedAt: zod.z.number().nullable()
71385
71528
  });
71386
71529
  /**
71387
- * user-management — singleton capability for user accounts, API keys,
71388
- * and scoped tokens.
71530
+ * user-management — singleton capability for user accounts and the
71531
+ * legacy API-key rows.
71389
71532
  *
71390
71533
  * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
71391
- * — the subset check on `setUserScopes` / `createScopedToken` is moot
71534
+ * — the subset check on `setUserScopes` is moot
71392
71535
  * because non-admins never reach these. If/when we open non-admin
71393
71536
  * delegation, structural caller-scope subset check goes inside the
71394
71537
  * provider.
@@ -71459,18 +71602,6 @@ var userManagementCapability = {
71459
71602
  auth: "admin",
71460
71603
  access: "delete"
71461
71604
  }),
71462
- createScopedToken: method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
71463
- kind: "mutation",
71464
- auth: "admin",
71465
- access: "create"
71466
- }),
71467
- revokeScopedToken: method(zod.z.object({ id: zod.z.string() }), zod.z.object({ success: zod.z.literal(true) }), {
71468
- kind: "mutation",
71469
- auth: "admin",
71470
- access: "delete"
71471
- }),
71472
- validateScopedToken: method(zod.z.object({ token: zod.z.string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }),
71473
- listScopedTokens: method(zod.z.object({ userId: zod.z.string() }), zod.z.array(ScopedTokenSummarySchema), { auth: "admin" }),
71474
71605
  setupTotp: method(zod.z.object({ userId: zod.z.string() }), TotpSetupResultSchema, {
71475
71606
  kind: "mutation",
71476
71607
  auth: "admin",
@@ -77959,7 +78090,7 @@ var METHOD_ACCESS_MAP = Object.freeze({
77959
78090
  capName: "llm",
77960
78091
  capScope: "system",
77961
78092
  addonId: null,
77962
- access: "view"
78093
+ access: "create"
77963
78094
  },
77964
78095
  "llm.listNodeModels": {
77965
78096
  capName: "llm",
@@ -82623,12 +82754,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
82623
82754
  addonId: null,
82624
82755
  access: "create"
82625
82756
  },
82626
- "userManagement.createScopedToken": {
82627
- capName: "user-management",
82628
- capScope: "system",
82629
- addonId: null,
82630
- access: "create"
82631
- },
82632
82757
  "userManagement.createUser": {
82633
82758
  capName: "user-management",
82634
82759
  capScope: "system",
@@ -82677,12 +82802,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
82677
82802
  addonId: null,
82678
82803
  access: "view"
82679
82804
  },
82680
- "userManagement.listScopedTokens": {
82681
- capName: "user-management",
82682
- capScope: "system",
82683
- addonId: null,
82684
- access: "view"
82685
- },
82686
82805
  "userManagement.listUsers": {
82687
82806
  capName: "user-management",
82688
82807
  capScope: "system",
@@ -82737,12 +82856,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
82737
82856
  addonId: null,
82738
82857
  access: "delete"
82739
82858
  },
82740
- "userManagement.revokeScopedToken": {
82741
- capName: "user-management",
82742
- capScope: "system",
82743
- addonId: null,
82744
- access: "delete"
82745
- },
82746
82859
  "userManagement.setupTotp": {
82747
82860
  capName: "user-management",
82748
82861
  capScope: "system",
@@ -82773,12 +82886,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
82773
82886
  addonId: null,
82774
82887
  access: "view"
82775
82888
  },
82776
- "userManagement.validateScopedToken": {
82777
- capName: "user-management",
82778
- capScope: "system",
82779
- addonId: null,
82780
- access: "view"
82781
- },
82782
82889
  "userManagement.verifyTotp": {
82783
82890
  capName: "user-management",
82784
82891
  capScope: "system",
@@ -88477,6 +88584,12 @@ Object.defineProperty(exports, "CORE_BLOCK_ADDON_PREFIX", {
88477
88584
  return CORE_BLOCK_ADDON_PREFIX;
88478
88585
  }
88479
88586
  });
88587
+ Object.defineProperty(exports, "CREDENTIAL_TOKEN_AUDIENCE", {
88588
+ enumerable: true,
88589
+ get: function() {
88590
+ return CREDENTIAL_TOKEN_AUDIENCE;
88591
+ }
88592
+ });
88480
88593
  Object.defineProperty(exports, "CalendarPreferencesSchema", {
88481
88594
  enumerable: true,
88482
88595
  get: function() {
@@ -88759,12 +88872,36 @@ Object.defineProperty(exports, "NoCallerError", {
88759
88872
  return NoCallerError;
88760
88873
  }
88761
88874
  });
88875
+ Object.defineProperty(exports, "PREFERENCES_MAX_VALUE_BYTES", {
88876
+ enumerable: true,
88877
+ get: function() {
88878
+ return PREFERENCES_MAX_VALUE_BYTES;
88879
+ }
88880
+ });
88762
88881
  Object.defineProperty(exports, "PlaintextSecretError", {
88763
88882
  enumerable: true,
88764
88883
  get: function() {
88765
88884
  return PlaintextSecretError;
88766
88885
  }
88767
88886
  });
88887
+ Object.defineProperty(exports, "PreferenceDeviceIdSchema", {
88888
+ enumerable: true,
88889
+ get: function() {
88890
+ return PreferenceDeviceIdSchema;
88891
+ }
88892
+ });
88893
+ Object.defineProperty(exports, "PreferenceNamespaceSchema", {
88894
+ enumerable: true,
88895
+ get: function() {
88896
+ return PreferenceNamespaceSchema;
88897
+ }
88898
+ });
88899
+ Object.defineProperty(exports, "PreferenceValueSchema", {
88900
+ enumerable: true,
88901
+ get: function() {
88902
+ return PreferenceValueSchema;
88903
+ }
88904
+ });
88768
88905
  Object.defineProperty(exports, "RECORDING_SOURCE_CAMSTACK_ADDON", {
88769
88906
  enumerable: true,
88770
88907
  get: function() {
@@ -89509,6 +89646,12 @@ Object.defineProperty(exports, "isCollectionArrayMethod", {
89509
89646
  return isCollectionArrayMethod;
89510
89647
  }
89511
89648
  });
89649
+ Object.defineProperty(exports, "isCredentialTokenPayload", {
89650
+ enumerable: true,
89651
+ get: function() {
89652
+ return isCredentialTokenPayload;
89653
+ }
89654
+ });
89512
89655
  Object.defineProperty(exports, "isDefaultAppConnectionEndpoint", {
89513
89656
  enumerable: true,
89514
89657
  get: function() {
@@ -1,5 +1,5 @@
1
1
  require("./chunk-Cek0wNdY.js");
2
- const require_wal_maintenance = require("./wal-maintenance-Bl0ZKjVR.js");
2
+ const require_wal_maintenance = require("./wal-maintenance-CNEs_I94.js");
3
3
  let node_worker_threads = require("node:worker_threads");
4
4
  //#region src/builtins/sqlite-storage/file-host-worker.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { C as RecordsEngine, D as callVector, E as callRecords, O as controlTargetOf, T as callData, _ as collectTransferables, a as WalMaintenance, b as isFileHostWorkerData, h as serializeError, l as SqliteSettingsBackend, o as createVectorIndex, s as vectorProviderOf, w as callControl, x as trustInput, y as isFileHostRequest } from "./wal-maintenance-TyuOEVy1.mjs";
1
+ import { C as RecordsEngine, D as callVector, E as callRecords, O as controlTargetOf, T as callData, _ as collectTransferables, a as WalMaintenance, b as isFileHostWorkerData, h as serializeError, l as SqliteSettingsBackend, o as createVectorIndex, s as vectorProviderOf, w as callControl, x as trustInput, y as isFileHostRequest } from "./wal-maintenance-AerF4XE6.mjs";
2
2
  import { parentPort, threadId, workerData } from "node:worker_threads";
3
3
  //#region src/builtins/sqlite-storage/file-host-worker.ts
4
4
  /**
@@ -1,7 +1,7 @@
1
1
  import { o as __toESM } from "./chunk-CNf5ZN-e.mjs";
2
- import { _a as userError } from "./dist-BpSENkRJ.mjs";
2
+ import { Ca as userError } from "./dist-BSF_C8W2.mjs";
3
3
  import { f as X509Certificate$1 } from "./x509.es-DK__ETIe.mjs";
4
- import { A as isConstrainedCa, E as reasonRequiresNewCa, M as permitsIdentity, P as readNameConstraints, T as evaluateExistingCert, _ as issueLeaf, g as generateCa, v as loadCa, y as collectCertIdentity } from "./agent-https-CLWrOO3o.mjs";
4
+ import { D as reasonRequiresNewCa, E as evaluateExistingCert, F as readNameConstraints, N as permitsIdentity, _ as issueLeaf, b as collectCertIdentity, g as generateCa, j as isConstrainedCa, v as loadCa, y as localCaCommonName } from "./agent-https-fm4AR8XL.mjs";
5
5
  import { X509Certificate, createPrivateKey } from "node:crypto";
6
6
  import { writeOwnerOnlyFileSync } from "@camstack/types/node";
7
7
  import { mkdir, writeFile } from "node:fs/promises";
@@ -204,7 +204,13 @@ async function ensureTlsCert(dataDir, options) {
204
204
  mkdirSync(tlsDir, { recursive: true });
205
205
  let dropped = [];
206
206
  try {
207
- dropped = await regenerate(paths, rawIdentity, commonName, validDays, caRotated, reason);
207
+ dropped = await regenerate(paths, rawIdentity, {
208
+ commonName,
209
+ caCommonName: localCaCommonName(options?.hubName),
210
+ validDays,
211
+ newCa: caRotated,
212
+ reason
213
+ });
208
214
  } catch (err) {
209
215
  const message = err instanceof Error ? err.message : String(err);
210
216
  if (!canKeepServing(paths)) throw err;
@@ -234,7 +240,13 @@ async function reissueTlsLeaf(dataDir, options) {
234
240
  });
235
241
  const previousFingerprint = readFingerprint(paths.certPath);
236
242
  mkdirSync(tlsDir, { recursive: true });
237
- return describe(paths, true, "san-coverage-gap", false, previousFingerprint, null, await regenerate(paths, identity, commonName, validDays, false, null));
243
+ return describe(paths, true, "san-coverage-gap", false, previousFingerprint, null, await regenerate(paths, identity, {
244
+ commonName,
245
+ caCommonName: localCaCommonName(options?.hubName),
246
+ validDays,
247
+ newCa: false,
248
+ reason: null
249
+ }));
238
250
  }
239
251
  /**
240
252
  * Uploaded mode keeps a generated CA beside the upload (agents' leaves are still signed
@@ -260,7 +272,7 @@ async function replaceUnconstrainedLocalCa(dataDir, options) {
260
272
  extraSans: options?.extraSans ?? [],
261
273
  ...options?.hostFacts === void 0 ? {} : { hostFacts: options.hostFacts }
262
274
  });
263
- const ca = await generateCa(/* @__PURE__ */ new Date(), identity.dnsNames);
275
+ const ca = await generateCa(/* @__PURE__ */ new Date(), identity.dnsNames, localCaCommonName(options?.hubName));
264
276
  archivePreviousCa(paths, ca);
265
277
  await writeFile(`${paths.caCertPath}.new`, ca.certPem, "utf-8");
266
278
  writeOwnerOnlyFileSync(`${paths.caKeyPath}.new`, ca.keyPem);
@@ -297,15 +309,10 @@ function decideRegeneration(paths, identity) {
297
309
  return "unreadable";
298
310
  }
299
311
  }
300
- /**
301
- * Build every byte in memory, then move the files into place. A crash
302
- * mid-way leaves the previous material untouched; a crash between the
303
- * moves leaves a key/certificate mismatch, which the evaluator reports as
304
- * `key-mismatch` and heals on the next boot.
305
- */
306
- async function regenerate(paths, rawIdentity, commonName, validDays, newCa, reason) {
312
+ async function regenerate(paths, rawIdentity, params) {
313
+ const { commonName, caCommonName, validDays, newCa, reason } = params;
307
314
  const now = /* @__PURE__ */ new Date();
308
- const ca = newCa ? await generateCa(now, rawIdentity.dnsNames) : await loadCa(readFileSync(paths.caCertPath, "utf-8"), readFileSync(paths.caKeyPath, "utf-8"));
315
+ const ca = newCa ? await generateCa(now, rawIdentity.dnsNames, caCommonName) : await loadCa(readFileSync(paths.caCertPath, "utf-8"), readFileSync(paths.caKeyPath, "utf-8"));
309
316
  const constraints = readNameConstraints(ca.cert);
310
317
  const { identity, dropped } = constraints === null ? {
311
318
  identity: rawIdentity,