@camstack/server 1.2.941 → 1.2.942

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 (154) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/api/trpc/generated-cap-mounts.js +19 -1
  3. package/dist/api/trpc/generated-cap-routers.js +676 -596
  4. package/package.json +27 -11
  5. package/system/dist/action-index-B1fgpQBt.mjs +9925 -0
  6. package/system/dist/action-index-B_cLRwXJ.js +9972 -0
  7. package/system/dist/alert-episode-Be--PngO.mjs +64 -0
  8. package/system/dist/alert-episode-Bqktmt-i.js +93 -0
  9. package/system/dist/{base-addon-Md14i7pe.mjs → base-addon-BcS6r1cT.mjs} +20 -7
  10. package/system/dist/{base-addon-DD5dIfcZ.js → base-addon-CRsXtYFG.js} +20 -7
  11. package/system/dist/{base-device-CH8rfD9j.js → base-device-DAdWzDOl.js} +138 -34
  12. package/system/dist/{base-device-BcGO6LTT.mjs → base-device-DJXF5eDN.mjs} +138 -34
  13. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  14. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  15. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  16. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  17. package/system/dist/builtins/alerts/alert-episode-policy.d.ts +9 -5
  18. package/system/dist/builtins/alerts/alerts.addon.js +30 -80
  19. package/system/dist/builtins/alerts/alerts.addon.mjs +18 -68
  20. package/system/dist/builtins/autotrack/index.js +2 -2
  21. package/system/dist/builtins/autotrack/index.mjs +2 -2
  22. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  23. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  24. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  25. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  26. package/system/dist/builtins/camera-grid/index.js +9 -9
  27. package/system/dist/builtins/camera-grid/index.mjs +6 -6
  28. package/system/dist/builtins/composer/composer.addon.js +99 -99
  29. package/system/dist/builtins/composer/composer.addon.mjs +11 -11
  30. package/system/dist/builtins/console-logging/index.js +1 -1
  31. package/system/dist/builtins/console-logging/index.mjs +1 -1
  32. package/system/dist/builtins/core-blocks/automation-template-instances.d.ts +14 -1
  33. package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +6 -0
  34. package/system/dist/builtins/core-blocks/core-blocks.addon.js +296 -193
  35. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +237 -134
  36. package/system/dist/builtins/core-blocks/link-contributions.d.ts +2 -0
  37. package/system/dist/builtins/core-notifier/core-notifier.addon.js +91 -18
  38. package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +91 -18
  39. package/system/dist/builtins/core-notifier/group-notification-output.d.ts +8 -16
  40. package/system/dist/builtins/device-history/device-history.addon.d.ts +8 -0
  41. package/system/dist/builtins/device-history/device-history.addon.js +580 -60
  42. package/system/dist/builtins/device-history/device-history.addon.mjs +569 -49
  43. package/system/dist/builtins/device-history/retention/device-raw-overrides.d.ts +16 -0
  44. package/system/dist/builtins/device-history/retention/retention-knobs.d.ts +14 -0
  45. package/system/dist/builtins/device-history/retention/retention.d.ts +21 -1
  46. package/system/dist/builtins/device-history/transitions/change-coalescing.d.ts +48 -0
  47. package/system/dist/builtins/device-history/transitions/derived-changes.d.ts +49 -0
  48. package/system/dist/builtins/device-history/transitions/history-change-port.d.ts +20 -0
  49. package/system/dist/builtins/device-history/transitions/transitions-service.d.ts +18 -3
  50. package/system/dist/builtins/device-manager/device-identity-index.d.ts +2 -2
  51. package/system/dist/builtins/device-manager/device-manager.addon.js +177 -479
  52. package/system/dist/builtins/device-manager/device-manager.addon.mjs +169 -471
  53. package/system/dist/builtins/device-manager/device-state-mirror.d.ts +0 -5
  54. package/system/dist/builtins/device-manager/identity-link-reconciler.d.ts +5 -0
  55. package/system/dist/builtins/device-manager/transitions/command-recorder.d.ts +38 -0
  56. package/system/dist/builtins/device-manager/transitions/transitions-wiring.d.ts +8 -9
  57. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  58. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  59. package/system/dist/builtins/keychain/index.js +2 -2
  60. package/system/dist/builtins/keychain/index.mjs +2 -2
  61. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +2 -2
  62. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +2 -2
  63. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  64. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  65. package/system/dist/builtins/local-network/address-book.d.ts +3 -1
  66. package/system/dist/builtins/local-network/local-network.addon.d.ts +26 -1
  67. package/system/dist/builtins/local-network/local-network.addon.js +66 -11
  68. package/system/dist/builtins/local-network/local-network.addon.mjs +66 -11
  69. package/system/dist/builtins/loki-logging/index.js +1 -1
  70. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  71. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  72. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  73. package/system/dist/builtins/platform-probe/index.js +1 -1
  74. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  75. package/system/dist/builtins/record-entries/index.js +1 -1
  76. package/system/dist/builtins/record-entries/index.mjs +1 -1
  77. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  78. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  79. package/system/dist/builtins/snapshot/index.js +4 -4
  80. package/system/dist/builtins/snapshot/index.mjs +4 -4
  81. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  82. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  83. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  84. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  85. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  86. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  87. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  88. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  89. package/system/dist/builtins/system-config/system-config.addon.js +1 -1
  90. package/system/dist/builtins/system-config/system-config.addon.mjs +1 -1
  91. package/system/dist/builtins/winston-logging/index.js +1 -1
  92. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  93. package/system/dist/{capture-engine-CUZ3W0oZ.mjs → capture-engine-B2MmoNND.mjs} +1 -1
  94. package/system/dist/{capture-engine-mtDXEBAq.js → capture-engine-D_1IJmMs.js} +1 -1
  95. package/system/dist/command-catalog-C29hVOOg.js +210 -0
  96. package/system/dist/command-catalog-xAeqxbZk.mjs +169 -0
  97. package/system/dist/{error.cap-DCwbIGEF.mjs → compile-OBMHlqD-.mjs} +97 -100
  98. package/system/dist/{error.cap-BxLEHP6z.js → compile-SpeAhaZ6.js} +107 -116
  99. package/system/dist/{composition-sources-B56CU8hi.mjs → composition-sources-C327LGFn.mjs} +2 -2
  100. package/system/dist/{composition-sources-D_Bfwji0.js → composition-sources-Do5qM6EB.js} +17 -17
  101. package/system/dist/{core-blocks.cap-xt5_fK5Z.js → core-blocks.cap-CdTGUKtr.js} +194 -10110
  102. package/system/dist/{core-blocks.cap-DDECcMeI.mjs → core-blocks.cap-DLkEfV5b.mjs} +54 -9910
  103. package/system/dist/{device-kind-BJ2pfsjw.mjs → device-kind-C37Ra2wd.mjs} +4 -2
  104. package/system/dist/{device-kind-CsSiv_YF.js → device-kind-FMhJg8uC.js} +4 -2
  105. package/system/dist/{device-manager.cap-DyHOIh5T.js → device-manager.cap-DJs8izI6.js} +13 -4
  106. package/system/dist/{device-manager.cap-DIBK62-r.mjs → device-manager.cap-eYrj1Ezp.mjs} +13 -4
  107. package/system/dist/{device-provider.cap-BKUGJSo0.js → device-provider.cap-CNlYBQ5D.js} +1 -1
  108. package/system/dist/{device-provider.cap-DU6HMUXH.mjs → device-provider.cap-D8mJllVM.mjs} +1 -1
  109. package/system/dist/{device-row-store-O4mNbp5q.js → device-row-store-C0P2H18h.js} +2 -2
  110. package/system/dist/{device-row-store-C-_R-h1Z.mjs → device-row-store-CTocYKqC.mjs} +2 -2
  111. package/system/dist/{device-type-CbQsnFdC.js → device-type-Cnc0NiSX.js} +13 -0
  112. package/system/dist/{device-type-DgEvK3ch.mjs → device-type-TUGqGmaI.mjs} +13 -0
  113. package/system/dist/error.cap-BuKbL3Ac.js +125 -0
  114. package/system/dist/error.cap-CU1FB6uE.mjs +102 -0
  115. package/system/dist/file-host-worker.js +1 -1
  116. package/system/dist/file-host-worker.mjs +1 -1
  117. package/system/dist/{history-catalog-BwTeQ4Mr.mjs → history-catalog-A_dzXNpv.mjs} +98 -3
  118. package/system/dist/{history-catalog-BKRarIL_.js → history-catalog-CiTMP3-E.js} +98 -3
  119. package/system/dist/index.js +28 -6
  120. package/system/dist/index.mjs +28 -6
  121. package/system/dist/kernel/addon-version-policy.d.ts +10 -0
  122. package/system/dist/{legacy-integration-rows-door-B1nzxxr5.js → legacy-integration-rows-door-CdqYAj-o.js} +1 -1
  123. package/system/dist/{legacy-integration-rows-door-nTvo_6jQ.mjs → legacy-integration-rows-door-LSgpClpX.mjs} +1 -1
  124. package/system/dist/{low-power-sleep.cap-B6mz6ojP.js → low-power-sleep.cap-BJWyAuUQ.js} +1 -1
  125. package/system/dist/{low-power-sleep.cap-C3Vi8Vxj.mjs → low-power-sleep.cap-D9Orx3LS.mjs} +1 -1
  126. package/system/dist/migrations/hub/2026-11-22-device-transitions-commands-only.d.ts +10 -0
  127. package/system/dist/{network-access.cap-BEN_uRVb.js → network-access.cap-CTQ2WQoi.js} +38 -12
  128. package/system/dist/{network-access.cap-Dy8FNNVs.mjs → network-access.cap-Dx5K0I5i.mjs} +33 -13
  129. package/system/dist/{notification-rules.cap-Drwz-A4n.js → notification-rules.cap-BJKUjizS.js} +45 -9
  130. package/system/dist/{notification-rules.cap-0vVvsxQ1.mjs → notification-rules.cap-BUIuYPlQ.mjs} +45 -9
  131. package/system/dist/{notification-targets-DR-D-vIt.mjs → notification-targets-4bGYH5J7.mjs} +2 -2
  132. package/system/dist/{notification-targets-Cc_3OBH9.js → notification-targets-DMW7xgR2.js} +2 -2
  133. package/system/dist/{prefix-walk-CCO_VZVo.js → prefix-walk-BFnw8NBu.js} +5 -5
  134. package/system/dist/{prefix-walk-BhT0ZoKl.mjs → prefix-walk-Mtij0NNT.mjs} +2 -2
  135. package/system/dist/{ptz-autotrack.cap-DOz0xL0O.js → ptz-autotrack.cap-B9eyZU8w.js} +1 -1
  136. package/system/dist/{ptz-autotrack.cap-CDF6FeTK.mjs → ptz-autotrack.cap-Dw2k-po9.mjs} +1 -1
  137. package/system/dist/{recording-archive.cap-RHAN45fa.mjs → recording-archive.cap-CTlm86R8.mjs} +1 -1
  138. package/system/dist/{recording-archive.cap-BPJ7kvnd.js → recording-archive.cap-Wo-hEZhz.js} +1 -1
  139. package/system/dist/{rename-composition-block-DWUkrazx.mjs → rename-composition-block-Cdh-dRmY.mjs} +395 -20
  140. package/system/dist/{rename-composition-block-CH2vRIW7.js → rename-composition-block-D9Uc1AF7.js} +406 -31
  141. package/system/dist/{retention-CUOVI1p7.mjs → retention-CQs8QR1B.mjs} +33 -3
  142. package/system/dist/{device-transitions.cap-DCXP3zwY.mjs → retention-source.cap-550kkyp5.mjs} +98 -21
  143. package/system/dist/{device-transitions.cap-zOGvAIHz.js → retention-source.cap-C6Hy0hlM.js} +103 -20
  144. package/system/dist/{retention-BcOSL6b9.js → retention-xcjk_k1w.js} +33 -3
  145. package/system/dist/{snapshot.cap-Cis6JRwn.js → snapshot.cap-CHm29hBs.js} +1 -1
  146. package/system/dist/{snapshot.cap-BkfHpJVO.mjs → snapshot.cap-CO68YvJU.mjs} +1 -1
  147. package/system/dist/{stream-catalog.cap-D8Y-uXcy.js → stream-catalog.cap-CjEQFknc.js} +2 -2
  148. package/system/dist/{stream-catalog.cap-D1Hy19Yc.mjs → stream-catalog.cap-DVniDdRD.mjs} +2 -2
  149. package/system/dist/{user-management.cap-Ctd4c_im.mjs → user-management.cap-4IEUCSdL.mjs} +2 -2
  150. package/system/dist/{user-management.cap-DyVb68rY.js → user-management.cap-DV9Jfsj3.js} +2 -2
  151. package/system/dist/{wal-maintenance-CjpslZUL.mjs → wal-maintenance-Bey5ChBb.mjs} +0 -0
  152. package/system/dist/{wal-maintenance-DKTXQ7UF.js → wal-maintenance-BgYiAy5b.js} +0 -0
  153. package/system/package.json +4 -1
  154. package/system/dist/builtins/device-manager/transitions/transition-correlator.d.ts +0 -81
@@ -31,8 +31,6 @@ export type ClaimsIndexView = {
31
31
  * under that number is the wrong device's state.
32
32
  */
33
33
  export type SeedMode = "fill" | "replace";
34
- /** Told of a native slice that changed: the slice before (if any) and the one stored now. */
35
- export type SliceChangeTap = (deviceId: number, capName: string, prior: Readonly<Record<string, unknown>> | undefined, slice: Readonly<Record<string, unknown>>) => void;
36
34
  /** Told of every native slice a provider reported, changed or not (D1062 push health). */
37
35
  export type SliceReportTap = (deviceId: number, capName: string) => void;
38
36
  export declare class DeviceStateMirror {
@@ -43,7 +41,6 @@ export declare class DeviceStateMirror {
43
41
  * Injectable so a spec can exercise the gate without the real cap set.
44
42
  */
45
43
  private readonly policyFor;
46
- private transitionTap;
47
44
  private reportTap;
48
45
  /**
49
46
  * Hub-side mirror of every device's cap-keyed NATIVE runtime state — what the
@@ -78,8 +75,6 @@ export declare class DeviceStateMirror {
78
75
  private readonly runningFlip;
79
76
  private readonly workloadTransitions;
80
77
  constructor(ctx: AddonContext, policyFor?: RuntimeStatePolicyLookup, schemaFor?: RuntimeStateSchemaLookup);
81
- /** Set once by the device-manager: told, after the mirror stored it, of every native slice that actually changed (D1022). */
82
- setTransitionTap(tap: SliceChangeTap | null): void;
83
78
  /** Set once by the device-manager: told of every native slice reported, before the no-change check (D1062). */
84
79
  setReportTap(tap: SliceReportTap | null): void;
85
80
  /**
@@ -8,6 +8,7 @@
8
8
  * | `proposal` candidate, no row | `proposed`, no event |
9
9
  * | `proposed` row, candidate now `auto` | `linked` / `auto`, created |
10
10
  * | `dismissed` row | stays dismissed: nothing re-proposes it |
11
+ * | `dismissed` row, operator Relink | `linked` / `operator`, created (evidence must still hold) |
11
12
  * | `linked`/`auto` row, evidence gone | row deleted, `identity-link.lost` evidence-gone |
12
13
  * | `linked`/`operator` row, evidence gone | kept, flagged `evidenceGone`, `lost` evidence-gone |
13
14
  * | `linked`/`operator` flagged, evidence back | flag cleared, `identity-link.created` |
@@ -50,6 +51,10 @@ export declare class IdentityLinkReconciler {
50
51
  confirm(linkId: string): Promise<IdentityLinkDecision>;
51
52
  dismiss(linkId: string): Promise<IdentityLinkDecision>;
52
53
  unlink(linkId: string): Promise<IdentityLinkDecision>;
54
+ /** Undo a dismissal: a `dismissed` link acts again, as the operator's decision.
55
+ * Refused `evidence-gone` when the current candidates no longer declare the pair
56
+ * (a relink of a pair nothing declares would only be flagged at the next pass). */
57
+ relink(linkId: string): Promise<IdentityLinkDecision>;
53
58
  /** The `identity-links` removal step (D864): every link naming the device goes. */
54
59
  removeDevice(deviceId: number): Promise<number>;
55
60
  /** One pass over every candidate and every stored link. */
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The command recorder of the device audit (D1022, D1084).
3
+ *
4
+ * A command is what the kernel saw leave its caller. It is written as ONE row,
5
+ * when the call completes: `ok` when it returned, `failed` when the caller saw it
6
+ * throw. Nothing waits for the device to obey and nothing is matched to a slice
7
+ * change: the change, when the device reports one, is read back from device-history
8
+ * on the Interactions read, beside the command row.
9
+ *
10
+ * Pure and clock-injected; it reads memory only (D49): the mirror's current slice,
11
+ * for the `from` value of a command that names an effect. What it produces is
12
+ * handed to `emit`, whose queue is bounded.
13
+ */
14
+ import { type DeviceCommandObservation, type DeviceTransition, type IScopedLogger, type TransitionValue } from "@camstack/types";
15
+ /** The field of a row whose command named none (a toggle, a press, a stop). */
16
+ export declare const NO_FIELD = "*";
17
+ export type CurrentSlice = (deviceId: number, capName: string) => Readonly<Record<string, unknown>> | undefined;
18
+ export interface RecorderDeps {
19
+ /** Optional: names the branch that writes nothing. */
20
+ readonly logger?: IScopedLogger;
21
+ readonly emit: (transition: DeviceTransition) => void;
22
+ readonly currentSlice: CurrentSlice;
23
+ /** The command's arguments as a row stores them: redacted by the input schema's secret paths and capped. */
24
+ readonly prepareArgs: (capName: string, method: string, args: Readonly<Record<string, unknown>>) => Record<string, unknown>;
25
+ }
26
+ /** A status value in the shape a transition stores: unknown is `null` (D393), an array is wrapped. */
27
+ export declare function toTransitionValue(value: unknown): TransitionValue;
28
+ export declare class CommandRecorder {
29
+ private readonly deps;
30
+ private seq;
31
+ constructor(deps: RecorderDeps);
32
+ /**
33
+ * A command left its caller. Where the seam can see the call settle (`obs.outcome`), the row is
34
+ * written when it does; where it cannot (the UDS parent and in-process clients report only the
35
+ * departure) the call is recorded as `ok` at once, since a throw there is not observable.
36
+ */
37
+ recordCommand(obs: DeviceCommandObservation): void;
38
+ }
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Starts the hub's device-transition audit (D1022): command observations and
3
- * mirror slice changes meet in the correlator, its rows ride a bounded queue to
4
- * device-history. Everything here is best-effort telemetry (D8): a failure
5
- * costs rows, never a command or a mirror write.
2
+ * Starts the hub's device command audit (D1022, D1084): command observations meet
3
+ * the recorder, its rows ride a bounded queue to device-history. Everything here is
4
+ * best-effort telemetry (D8): a failure costs rows, never a command or a mirror
5
+ * write.
6
6
  */
7
7
  import { type DeviceCommandSettledEvent, type DeviceTransition } from "@camstack/types";
8
8
  import type { IScopedLogger } from "@camstack/types";
@@ -11,20 +11,19 @@ export declare const TRANSITIONS_FLUSH_INTERVAL_MS = 2e3;
11
11
  /** Runs `fn` every `ms` until the returned function is called. */
12
12
  export type TransitionTicker = (fn: () => void, ms: number) => () => void;
13
13
  export interface DeviceTransitionsDeps {
14
+ /** Read for the value a command's effect field held when it was given. */
14
15
  readonly mirror: DeviceStateMirror;
15
16
  readonly logger: IScopedLogger;
16
17
  readonly record: (transitions: readonly DeviceTransition[]) => Promise<void>;
17
18
  /**
18
- * Told of each COMMAND the correlator settles (never a device's own change). Telemetry (D8):
19
- * a throw is logged and costs the notification, never the row.
19
+ * Told of each command that completed. Telemetry (D8): a throw is logged and costs the
20
+ * notification, never the row.
20
21
  */
21
22
  readonly onCommandSettled?: (event: DeviceCommandSettledEvent) => void;
22
- readonly now?: () => number;
23
23
  readonly ticker?: TransitionTicker;
24
24
  }
25
25
  export interface DeviceTransitionsHandle {
26
- forgetDevice(deviceId: number): void;
27
- /** Unsubscribe, stop the timers, send what is queued. */
26
+ /** Unsubscribe, stop the timer, send what is queued. */
28
27
  stop(): Promise<void>;
29
28
  }
30
29
  export declare function startDeviceTransitions(deps: DeviceTransitionsDeps): DeviceTransitionsHandle;
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_base_addon = require("../../base-addon-DD5dIfcZ.js");
6
+ const require_base_addon = require("../../base-addon-CRsXtYFG.js");
7
7
  const require_log_destination_cap = require("../../log-destination.cap-BzTWMj-T.js");
8
8
  const require_formatter = require("../../formatter-xbxeV4GD.js");
9
9
  //#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
@@ -1,4 +1,4 @@
1
- import { t as BaseAddon } from "../../base-addon-Md14i7pe.mjs";
1
+ import { t as BaseAddon } from "../../base-addon-BcS6r1cT.mjs";
2
2
  import { t as logDestinationCapability } from "../../log-destination.cap-QYMJPJwK.mjs";
3
3
  import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
4
4
  //#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
@@ -3,13 +3,13 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_base_addon = require("../../base-addon-DD5dIfcZ.js");
6
+ const require_base_addon = require("../../base-addon-CRsXtYFG.js");
7
7
  const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
8
8
  const require_record_kind = require("../../record-kind-DoBfYHCs.js");
9
9
  const require_keychain_admin_cap = require("../../keychain-admin.cap-DcRCRWtu.js");
10
10
  const require_device_ca = require("../../device-ca-C5kJE6mL.js");
11
11
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
12
- const require_legacy_integration_rows_door = require("../../legacy-integration-rows-door-B1nzxxr5.js");
12
+ const require_legacy_integration_rows_door = require("../../legacy-integration-rows-door-CdqYAj-o.js");
13
13
  const require_constants = require("../../constants-Ba3FTIHl.js");
14
14
  const require_platform_key_source = require("../../platform-key-source-Di7HrlGR.js");
15
15
  let node_crypto = require("node:crypto");
@@ -1,10 +1,10 @@
1
- import { b as EventCategory, t as BaseAddon } from "../../base-addon-Md14i7pe.mjs";
1
+ import { b as EventCategory, t as BaseAddon } from "../../base-addon-BcS6r1cT.mjs";
2
2
  import { C as normalizeSecretOwner, w as parseSecretRef, x as formatSecretScope } from "../../scoped-settings-DVWUIP7Z.mjs";
3
3
  import { s as defineRecordKinds } from "../../record-kind-ub6NXqfh.mjs";
4
4
  import { a as keychainCapability, i as keychainAdminCapability, n as KeychainAuditEntrySchema, r as KeychainResetRecordSchema, t as KEYCHAIN_RESET_TRIGGER_ACTOR } from "../../keychain-admin.cap-DOvL8TMG.mjs";
5
5
  import { d as JWT_SIGNING_KEY_REF, n as DEVICE_CA_KEY_REF, p as SYSTEM_SECRET_OWNER } from "../../device-ca-BLM6fccc.mjs";
6
6
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
7
- import { t as LEGACY_INTEGRATION_ROWS_TABLE } from "../../legacy-integration-rows-door-nTvo_6jQ.mjs";
7
+ import { t as LEGACY_INTEGRATION_ROWS_TABLE } from "../../legacy-integration-rows-door-LSgpClpX.mjs";
8
8
  import { a as MESH_CA_KEY_REF } from "../../constants-DB4piTD5.mjs";
9
9
  import { n as getPlatformKeychainKey } from "../../platform-key-source-BWlq0jjn.mjs";
10
10
  import { createCipheriv, createDecipheriv, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("../../chunk-Cek0wNdY.js");
3
- const require_base_addon = require("../../base-addon-DD5dIfcZ.js");
3
+ const require_base_addon = require("../../base-addon-CRsXtYFG.js");
4
4
  const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
5
- const require_recording_archive_cap = require("../../recording-archive.cap-BPJ7kvnd.js");
5
+ const require_recording_archive_cap = require("../../recording-archive.cap-Wo-hEZhz.js");
6
6
  const require_storage_location_mode = require("../../storage-location-mode-CS4sMzo-.js");
7
7
  let node_fs = require("node:fs");
8
8
  let node_path = require("node:path");
@@ -1,6 +1,6 @@
1
- import { b as EventCategory, p as createEvent, t as BaseAddon } from "../../base-addon-Md14i7pe.mjs";
1
+ import { b as EventCategory, p as createEvent, t as BaseAddon } from "../../base-addon-BcS6r1cT.mjs";
2
2
  import { Z as errMsg } from "../../scoped-settings-DVWUIP7Z.mjs";
3
- import { r as RECORDING_SOURCE_CAMSTACK_ADDON, t as RecordingStatusSchema } from "../../recording-archive.cap-RHAN45fa.mjs";
3
+ import { r as RECORDING_SOURCE_CAMSTACK_ADDON, t as RecordingStatusSchema } from "../../recording-archive.cap-CTlm86R8.mjs";
4
4
  import { o as mayWriteToLocation } from "../../storage-location-mode-B21UVRRX.mjs";
5
5
  import { constants } from "node:fs";
6
6
  import path from "node:path";
@@ -3,11 +3,11 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_base_addon = require("../../base-addon-DD5dIfcZ.js");
6
+ const require_base_addon = require("../../base-addon-CRsXtYFG.js");
7
7
  const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
8
8
  const require_camstack_error = require("../../camstack-error-DJ-TUAi1.js");
9
9
  const require_record_kind = require("../../record-kind-DoBfYHCs.js");
10
- const require_user_management_cap = require("../../user-management.cap-DyVb68rY.js");
10
+ const require_user_management_cap = require("../../user-management.cap-DV9Jfsj3.js");
11
11
  const require_device_certificate = require("../../device-certificate-CguVACQO.js");
12
12
  const require_safe_buffer$1 = require("../../safe-buffer-D3aoa-7X.js");
13
13
  const require_ms$1 = require("../../ms-LB3giGoU.js");
@@ -1,9 +1,9 @@
1
1
  import { i as __require, o as __toESM, t as __commonJSMin } from "../../chunk-CNf5ZN-e.mjs";
2
- import { t as BaseAddon } from "../../base-addon-Md14i7pe.mjs";
2
+ import { t as BaseAddon } from "../../base-addon-BcS6r1cT.mjs";
3
3
  import { K as makeSecretMarker, W as isSecretMarker } from "../../scoped-settings-DVWUIP7Z.mjs";
4
4
  import { t as userError } from "../../camstack-error-viZYfcj9.mjs";
5
5
  import { s as defineRecordKinds } from "../../record-kind-ub6NXqfh.mjs";
6
- import { a as authProviderCapability, c as TokenScopeSchema, i as deviceCredentialsCapability, l as UserRecordSchema, n as SsoBridgeClaimsSchema, o as MethodAccessSchema, s as ScopedTokenSchema, t as userManagementCapability, u as ViewerTokenScopeSchema } from "../../user-management.cap-Ctd4c_im.mjs";
6
+ import { a as authProviderCapability, c as TokenScopeSchema, i as deviceCredentialsCapability, l as UserRecordSchema, n as SsoBridgeClaimsSchema, o as MethodAccessSchema, s as ScopedTokenSchema, t as userManagementCapability, u as ViewerTokenScopeSchema } from "../../user-management.cap-4IEUCSdL.mjs";
7
7
  import { c as buildDeviceEnrollmentLink, l as buildDeviceSignatureMessage, n as DEVICE_NONCE_TTL_MS, t as DEVICE_ENROLLMENT_TTL_MS, u as formatDeviceRevoker } from "../../device-certificate-Cddm4Idn.mjs";
8
8
  import { t as require_safe_buffer } from "../../safe-buffer-B1OjL1I9.mjs";
9
9
  import { t as require_ms } from "../../ms-CgH2OFlD.mjs";
@@ -104,9 +104,11 @@ export interface AddressBookInputs {
104
104
  readonly appLinkHub: string | null;
105
105
  /** Where the hub's listeners answer (see {@link buildListenerOrigins}). */
106
106
  readonly listenerOrigins: readonly string[];
107
+ /** The remembered tunnel address `publicEndpoint` falls back to (D1085), or `null`. */
108
+ readonly rememberedPublicEndpoint?: string | null;
107
109
  }
108
110
  /** Every role's answer — the resolvers from `@camstack/types`, nothing else. */
109
- export declare function resolveRoles(state: AddressBookState, appPalette: readonly ConnectionEndpoint[], httpsPalette: readonly ConnectionEndpoint[]): HubAddressBook["roles"];
111
+ export declare function resolveRoles(state: AddressBookState, appPalette: readonly ConnectionEndpoint[], httpsPalette: readonly ConnectionEndpoint[], rememberedPublicEndpoint?: string | null): HubAddressBook["roles"];
110
112
  /** The Addresses table: app link, detected rows, then custom-only rows. */
111
113
  export declare function buildAddressBook(state: AddressBookState, inputs: AddressBookInputs): HubAddressBook;
112
114
  export interface ListenerOriginInputs {
@@ -68,6 +68,14 @@ interface LocalNetworkConfig {
68
68
  */
69
69
  readonly publicEndpointUrl: string;
70
70
  /**
71
+ * The tunnel address automatic `publicEndpoint` last resolved to, and the
72
+ * addon whose integration supplied it (D1085). Kept while that integration
73
+ * exists, so a boot with the tunnel's row absent does not answer the LAN.
74
+ * Empty = nothing remembered.
75
+ */
76
+ readonly rememberedPublicEndpointUrl: string;
77
+ readonly rememberedPublicEndpointAddon: string;
78
+ /**
71
79
  * Advertise this hub over mDNS (`_camstack._tcp`, D838) so `camstack login`
72
80
  * finds it. On by default; needs UDP 5353 multicast to reach the LAN.
73
81
  */
@@ -90,6 +98,8 @@ export declare class LocalNetworkAddon extends BaseAddon<LocalNetworkConfig> {
90
98
  private publicHostname;
91
99
  /** False for a Quick tunnel: shown in the palette, never picked automatically (D860). */
92
100
  private publicHostnameStable;
101
+ /** The addon whose `NetworkTunnelStarted` event named the hostname; empty = unknown (D1085). */
102
+ private publicHostnameAddon;
93
103
  /**
94
104
  * Mesh-reachable endpoint (Tailscale MagicDNS / 100.x), learned from
95
105
  * the `MeshNetworkChanged` event-tail and refreshed by a pull-reconcile
@@ -110,6 +120,21 @@ export declare class LocalNetworkAddon extends BaseAddon<LocalNetworkConfig> {
110
120
  private palettes;
111
121
  /** The stored address book, normalised against what is detected now. */
112
122
  private addressState;
123
+ /**
124
+ * The sticky automatic `publicEndpoint` (D1085). Remembers the tunnel address
125
+ * automatic resolves to while one integration supplies it, and returns the
126
+ * remembered address while that integration still exists. Removal of the
127
+ * integration (an ANSWERED, empty read) clears it; a read that failed changes
128
+ * nothing — unknown means "still exists" (D49).
129
+ */
130
+ private syncRememberedPublicEndpoint;
131
+ /**
132
+ * Persist the sticky pick. Not through `saveStored`: that re-announces over mDNS, and the
133
+ * advert reads the address book — a read that is already inside that announcement.
134
+ */
135
+ private saveRemembered;
136
+ /** Does the addon's integration exist (enabled or not)? `null` = the read did not answer. */
137
+ private integrationExists;
113
138
  /** The role flags alone — they do not depend on what is detected. */
114
139
  private storedFlags;
115
140
  /** `getAddresses`: the Addresses table and every role's answer. */
@@ -181,7 +206,7 @@ export declare class LocalNetworkAddon extends BaseAddon<LocalNetworkConfig> {
181
206
  * `onInitialize`. This setter exists for tests + future direct
182
207
  * callers; cleared by passing an empty string.
183
208
  */
184
- setPublicHostname(hostname: string, stable?: boolean): void;
209
+ setPublicHostname(hostname: string, stable?: boolean, addonId?: string): void;
185
210
  /**
186
211
  * Adopt a tunnel URL as the public hostname. Ignores the pre-FQDN placeholders a tunnel
187
212
  * reports before its real name is known, and a malformed URL (cache left as-is).
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("../../chunk-Cek0wNdY.js");
3
- const require_base_addon = require("../../base-addon-DD5dIfcZ.js");
3
+ const require_base_addon = require("../../base-addon-CRsXtYFG.js");
4
4
  const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
5
5
  const require_migration = require("../../migration-BOQlFZCN.js");
6
- const require_network_access_cap = require("../../network-access.cap-BEN_uRVb.js");
6
+ const require_network_access_cap = require("../../network-access.cap-CTQ2WQoi.js");
7
7
  const require_server_name = require("../../server-name-OALNvpqC.js");
8
8
  const require_dns_wire = require("../../dns-wire-B1BvF9Ao.js");
9
9
  const require_hub_identity = require("../../hub-identity-BMdR3Mw9.js");
@@ -322,8 +322,8 @@ function httpsTwinOf(endpoint, httpsPort) {
322
322
  };
323
323
  }
324
324
  /** Every role's answer — the resolvers from `@camstack/types`, nothing else. */
325
- function resolveRoles(state, appPalette, httpsPalette) {
326
- return require_network_access_cap.resolveHubAddressRoles(withAppConnectionCustomEndpoints(appPalette, state), httpsPalette, state.flags);
325
+ function resolveRoles(state, appPalette, httpsPalette, rememberedPublicEndpoint = null) {
326
+ return require_network_access_cap.resolveHubAddressRoles(withAppConnectionCustomEndpoints(appPalette, state), httpsPalette, state.flags, rememberedPublicEndpoint);
327
327
  }
328
328
  function flagsOn(state, baseUrl) {
329
329
  const out = [];
@@ -339,7 +339,7 @@ function inUseOn(roles, baseUrl) {
339
339
  }
340
340
  /** The Addresses table: app link, detected rows, then custom-only rows. */
341
341
  function buildAddressBook(state, inputs) {
342
- const roles = resolveRoles(state, inputs.rowsPalette, inputs.httpsPalette);
342
+ const roles = resolveRoles(state, inputs.rowsPalette, inputs.httpsPalette, inputs.rememberedPublicEndpoint ?? null);
343
343
  const customUrls = new Set(state.custom.map((c) => c.baseUrl));
344
344
  const detectedUrls = new Set(inputs.rowsPalette.map((e) => e.baseUrl));
345
345
  const row = (endpoint, detected) => ({
@@ -1660,6 +1660,8 @@ var LocalNetworkAddon = class extends require_base_addon.BaseAddon {
1660
1660
  publicHostname = "";
1661
1661
  /** False for a Quick tunnel: shown in the palette, never picked automatically (D860). */
1662
1662
  publicHostnameStable = true;
1663
+ /** The addon whose `NetworkTunnelStarted` event named the hostname; empty = unknown (D1085). */
1664
+ publicHostnameAddon = "";
1663
1665
  /**
1664
1666
  * Mesh-reachable endpoint (Tailscale MagicDNS / 100.x), learned from
1665
1667
  * the `MeshNetworkChanged` event-tail and refreshed by a pull-reconcile
@@ -1684,6 +1686,8 @@ var LocalNetworkAddon = class extends require_base_addon.BaseAddon {
1684
1686
  localHostname: "",
1685
1687
  internalUrl: "",
1686
1688
  publicEndpointUrl: "",
1689
+ rememberedPublicEndpointUrl: "",
1690
+ rememberedPublicEndpointAddon: "",
1687
1691
  mdnsAdvertise: true,
1688
1692
  passiveDiscovery: true,
1689
1693
  scanSubnets: []
@@ -1711,6 +1715,52 @@ var LocalNetworkAddon = class extends require_base_addon.BaseAddon {
1711
1715
  addressState(detected) {
1712
1716
  return normalizeAddressBook(this.config, new Set(detected.map((e) => e.baseUrl)));
1713
1717
  }
1718
+ /**
1719
+ * The sticky automatic `publicEndpoint` (D1085). Remembers the tunnel address
1720
+ * automatic resolves to while one integration supplies it, and returns the
1721
+ * remembered address while that integration still exists. Removal of the
1722
+ * integration (an ANSWERED, empty read) clears it; a read that failed changes
1723
+ * nothing — unknown means "still exists" (D49).
1724
+ */
1725
+ async syncRememberedPublicEndpoint(https) {
1726
+ const storedUrl = this.config.rememberedPublicEndpointUrl;
1727
+ const storedAddon = this.config.rememberedPublicEndpointAddon;
1728
+ const live = require_network_access_cap.livePublicTunnelAddress(https);
1729
+ if (live !== null && this.publicHostnameAddon !== "") {
1730
+ if (live === storedUrl && this.publicHostnameAddon === storedAddon) return null;
1731
+ if (await this.integrationExists(this.publicHostnameAddon) === true) await this.saveRemembered(live, this.publicHostnameAddon);
1732
+ return null;
1733
+ }
1734
+ if (storedUrl === "" || storedAddon === "") return null;
1735
+ if (await this.integrationExists(storedAddon) === false) {
1736
+ await this.saveRemembered("", "");
1737
+ return null;
1738
+ }
1739
+ return storedUrl;
1740
+ }
1741
+ /**
1742
+ * Persist the sticky pick. Not through `saveStored`: that re-announces over mDNS, and the
1743
+ * advert reads the address book — a read that is already inside that announcement.
1744
+ */
1745
+ async saveRemembered(url, addonId) {
1746
+ await this.state("rememberedPublicEndpointUrl", zod.z.string(), "").set(url);
1747
+ await this.state("rememberedPublicEndpointAddon", zod.z.string(), "").set(addonId);
1748
+ await this.resolveConfig();
1749
+ }
1750
+ /** Does the addon's integration exist (enabled or not)? `null` = the read did not answer. */
1751
+ async integrationExists(addonId) {
1752
+ const integrations = this.ctx.api?.integrations;
1753
+ if (integrations === void 0) return null;
1754
+ try {
1755
+ return (await integrations.listByAddon.query({ addonId })).length > 0;
1756
+ } catch (err) {
1757
+ this.ctx.logger.debug("local-network: integration existence read skipped", { meta: {
1758
+ addonId,
1759
+ error: err instanceof Error ? err.message : String(err)
1760
+ } });
1761
+ return null;
1762
+ }
1763
+ }
1714
1764
  /** The role flags alone — they do not depend on what is detected. */
1715
1765
  storedFlags() {
1716
1766
  return normalizeAddressBook(this.config, /* @__PURE__ */ new Set()).flags;
@@ -1721,6 +1771,7 @@ var LocalNetworkAddon = class extends require_base_addon.BaseAddon {
1721
1771
  const state = this.addressState([...httpWithTwins, ...httpsWithTwins]);
1722
1772
  const httpsPort = (await this.resolveAdvertisedListenPort(null)).port;
1723
1773
  return buildAddressBook(state, {
1774
+ rememberedPublicEndpoint: await this.syncRememberedPublicEndpoint(https),
1724
1775
  rowsPalette: scheme === "http" ? httpWithTwins : httpsWithTwins,
1725
1776
  httpsPalette: https,
1726
1777
  appLink: appLinkEndpoint(),
@@ -1770,7 +1821,7 @@ var LocalNetworkAddon = class extends require_base_addon.BaseAddon {
1770
1821
  const legacy = (r) => ({
1771
1822
  override: r.flagged,
1772
1823
  resolved: r.resolved,
1773
- source: r.source === "flagged" ? "override" : r.source
1824
+ source: r.source === "flagged" ? "override" : r.source === "none" ? "none" : "auto"
1774
1825
  });
1775
1826
  return {
1776
1827
  cluster: legacy(roles.internal),
@@ -2029,7 +2080,9 @@ var LocalNetworkAddon = class extends require_base_addon.BaseAddon {
2029
2080
  this.allowlistTimer.unref?.();
2030
2081
  this.ctx.eventBus?.subscribe({ category: require_base_addon.EventCategory.NetworkTunnelStarted }, (event) => {
2031
2082
  const parsed = require_network_access_cap.NetworkTunnelStartedDataSchema.safeParse(event.data ?? {});
2032
- if (parsed.success) this.adoptTunnelUrl(parsed.data.url, parsed.data.stable);
2083
+ if (!parsed.success) return;
2084
+ const addonId = event.source.type === "addon" && typeof event.source.id === "string" ? event.source.id : void 0;
2085
+ this.adoptTunnelUrl(parsed.data.url, parsed.data.stable, addonId);
2033
2086
  });
2034
2087
  this.ctx.eventBus?.subscribe({ category: require_base_addon.EventCategory.NetworkTunnelStopped }, () => this.setPublicHostname(""));
2035
2088
  this.ctx.eventBus?.subscribe({ category: require_base_addon.EventCategory.MeshNetworkChanged }, (event) => {
@@ -2220,10 +2273,12 @@ var LocalNetworkAddon = class extends require_base_addon.BaseAddon {
2220
2273
  * `onInitialize`. This setter exists for tests + future direct
2221
2274
  * callers; cleared by passing an empty string.
2222
2275
  */
2223
- setPublicHostname(hostname, stable = true) {
2224
- if (this.publicHostname === hostname && this.publicHostnameStable === stable) return;
2276
+ setPublicHostname(hostname, stable = true, addonId) {
2277
+ const addon = hostname === "" ? "" : addonId ?? this.publicHostnameAddon;
2278
+ if (this.publicHostname === hostname && this.publicHostnameStable === stable && this.publicHostnameAddon === addon) return;
2225
2279
  this.publicHostname = hostname;
2226
2280
  this.publicHostnameStable = stable;
2281
+ this.publicHostnameAddon = addon;
2227
2282
  this.ctx.logger.info("local-network: public hostname updated", { meta: {
2228
2283
  hostname: hostname || "(cleared)",
2229
2284
  stable
@@ -2233,10 +2288,10 @@ var LocalNetworkAddon = class extends require_base_addon.BaseAddon {
2233
2288
  * Adopt a tunnel URL as the public hostname. Ignores the pre-FQDN placeholders a tunnel
2234
2289
  * reports before its real name is known, and a malformed URL (cache left as-is).
2235
2290
  */
2236
- adoptTunnelUrl(url, stable) {
2291
+ adoptTunnelUrl(url, stable, addonId) {
2237
2292
  try {
2238
2293
  const hostname = new URL(url).hostname;
2239
- if (hostname && !hostname.endsWith(".placeholder") && !hostname.startsWith("pending.")) this.setPublicHostname(hostname, stable !== false);
2294
+ if (hostname && !hostname.endsWith(".placeholder") && !hostname.startsWith("pending.")) this.setPublicHostname(hostname, stable !== false, addonId);
2240
2295
  } catch {}
2241
2296
  }
2242
2297
  /**
@@ -1,7 +1,7 @@
1
- import { b as EventCategory, f as defineAddonMigrations, t as BaseAddon } from "../../base-addon-Md14i7pe.mjs";
1
+ import { b as EventCategory, f as defineAddonMigrations, t as BaseAddon } from "../../base-addon-BcS6r1cT.mjs";
2
2
  import { Z as errMsg } from "../../scoped-settings-DVWUIP7Z.mjs";
3
3
  import { u as preconditionOf } from "../../migration-DGAc6ywR.mjs";
4
- import { c as checkRoleAddress, d as resolveHubAddressRoles, f as resolveNotificationTapAddress, g as pickAppLinkHub, h as isAppLinkBase, l as isDefaultAppConnectionEndpoint, m as CAMSTACK_APP_LINK_ORIGIN, o as HUB_MDNS_SERVICE_TYPE, p as validateCustomAddress, r as localNetworkCapability, s as HUB_MDNS_TXT_KEYS, t as NetworkTunnelStartedDataSchema, u as resolveAppConnections } from "../../network-access.cap-Dy8FNNVs.mjs";
4
+ import { _ as pickAppLinkHub, c as checkRoleAddress, d as resolveAppConnections, f as resolveHubAddressRoles, g as isAppLinkBase, h as CAMSTACK_APP_LINK_ORIGIN, l as isDefaultAppConnectionEndpoint, m as validateCustomAddress, o as HUB_MDNS_SERVICE_TYPE, p as resolveNotificationTapAddress, r as localNetworkCapability, s as HUB_MDNS_TXT_KEYS, t as NetworkTunnelStartedDataSchema, u as livePublicTunnelAddress } from "../../network-access.cap-Dx5K0I5i.mjs";
5
5
  import { r as shortHostname } from "../../server-name-BIhLuHvX.mjs";
6
6
  import { a as emptyMdnsRecords, c as parseMdnsMessage, i as buildRecordQuery, l as parseMdnsRecords, n as MDNS_PORT, o as mergeMdnsRecords, r as buildPtrQuery, s as normalizeServiceType, t as MDNS_GROUP } from "../../dns-wire-Dm3H_7ST.mjs";
7
7
  import { i as loadOrCreateHubId, r as isAnnouncedHubId } from "../../hub-identity-DjMN9Ac2.mjs";
@@ -317,8 +317,8 @@ function httpsTwinOf(endpoint, httpsPort) {
317
317
  };
318
318
  }
319
319
  /** Every role's answer — the resolvers from `@camstack/types`, nothing else. */
320
- function resolveRoles(state, appPalette, httpsPalette) {
321
- return resolveHubAddressRoles(withAppConnectionCustomEndpoints(appPalette, state), httpsPalette, state.flags);
320
+ function resolveRoles(state, appPalette, httpsPalette, rememberedPublicEndpoint = null) {
321
+ return resolveHubAddressRoles(withAppConnectionCustomEndpoints(appPalette, state), httpsPalette, state.flags, rememberedPublicEndpoint);
322
322
  }
323
323
  function flagsOn(state, baseUrl) {
324
324
  const out = [];
@@ -334,7 +334,7 @@ function inUseOn(roles, baseUrl) {
334
334
  }
335
335
  /** The Addresses table: app link, detected rows, then custom-only rows. */
336
336
  function buildAddressBook(state, inputs) {
337
- const roles = resolveRoles(state, inputs.rowsPalette, inputs.httpsPalette);
337
+ const roles = resolveRoles(state, inputs.rowsPalette, inputs.httpsPalette, inputs.rememberedPublicEndpoint ?? null);
338
338
  const customUrls = new Set(state.custom.map((c) => c.baseUrl));
339
339
  const detectedUrls = new Set(inputs.rowsPalette.map((e) => e.baseUrl));
340
340
  const row = (endpoint, detected) => ({
@@ -1655,6 +1655,8 @@ var LocalNetworkAddon = class extends BaseAddon {
1655
1655
  publicHostname = "";
1656
1656
  /** False for a Quick tunnel: shown in the palette, never picked automatically (D860). */
1657
1657
  publicHostnameStable = true;
1658
+ /** The addon whose `NetworkTunnelStarted` event named the hostname; empty = unknown (D1085). */
1659
+ publicHostnameAddon = "";
1658
1660
  /**
1659
1661
  * Mesh-reachable endpoint (Tailscale MagicDNS / 100.x), learned from
1660
1662
  * the `MeshNetworkChanged` event-tail and refreshed by a pull-reconcile
@@ -1679,6 +1681,8 @@ var LocalNetworkAddon = class extends BaseAddon {
1679
1681
  localHostname: "",
1680
1682
  internalUrl: "",
1681
1683
  publicEndpointUrl: "",
1684
+ rememberedPublicEndpointUrl: "",
1685
+ rememberedPublicEndpointAddon: "",
1682
1686
  mdnsAdvertise: true,
1683
1687
  passiveDiscovery: true,
1684
1688
  scanSubnets: []
@@ -1706,6 +1710,52 @@ var LocalNetworkAddon = class extends BaseAddon {
1706
1710
  addressState(detected) {
1707
1711
  return normalizeAddressBook(this.config, new Set(detected.map((e) => e.baseUrl)));
1708
1712
  }
1713
+ /**
1714
+ * The sticky automatic `publicEndpoint` (D1085). Remembers the tunnel address
1715
+ * automatic resolves to while one integration supplies it, and returns the
1716
+ * remembered address while that integration still exists. Removal of the
1717
+ * integration (an ANSWERED, empty read) clears it; a read that failed changes
1718
+ * nothing — unknown means "still exists" (D49).
1719
+ */
1720
+ async syncRememberedPublicEndpoint(https) {
1721
+ const storedUrl = this.config.rememberedPublicEndpointUrl;
1722
+ const storedAddon = this.config.rememberedPublicEndpointAddon;
1723
+ const live = livePublicTunnelAddress(https);
1724
+ if (live !== null && this.publicHostnameAddon !== "") {
1725
+ if (live === storedUrl && this.publicHostnameAddon === storedAddon) return null;
1726
+ if (await this.integrationExists(this.publicHostnameAddon) === true) await this.saveRemembered(live, this.publicHostnameAddon);
1727
+ return null;
1728
+ }
1729
+ if (storedUrl === "" || storedAddon === "") return null;
1730
+ if (await this.integrationExists(storedAddon) === false) {
1731
+ await this.saveRemembered("", "");
1732
+ return null;
1733
+ }
1734
+ return storedUrl;
1735
+ }
1736
+ /**
1737
+ * Persist the sticky pick. Not through `saveStored`: that re-announces over mDNS, and the
1738
+ * advert reads the address book — a read that is already inside that announcement.
1739
+ */
1740
+ async saveRemembered(url, addonId) {
1741
+ await this.state("rememberedPublicEndpointUrl", z.string(), "").set(url);
1742
+ await this.state("rememberedPublicEndpointAddon", z.string(), "").set(addonId);
1743
+ await this.resolveConfig();
1744
+ }
1745
+ /** Does the addon's integration exist (enabled or not)? `null` = the read did not answer. */
1746
+ async integrationExists(addonId) {
1747
+ const integrations = this.ctx.api?.integrations;
1748
+ if (integrations === void 0) return null;
1749
+ try {
1750
+ return (await integrations.listByAddon.query({ addonId })).length > 0;
1751
+ } catch (err) {
1752
+ this.ctx.logger.debug("local-network: integration existence read skipped", { meta: {
1753
+ addonId,
1754
+ error: err instanceof Error ? err.message : String(err)
1755
+ } });
1756
+ return null;
1757
+ }
1758
+ }
1709
1759
  /** The role flags alone — they do not depend on what is detected. */
1710
1760
  storedFlags() {
1711
1761
  return normalizeAddressBook(this.config, /* @__PURE__ */ new Set()).flags;
@@ -1716,6 +1766,7 @@ var LocalNetworkAddon = class extends BaseAddon {
1716
1766
  const state = this.addressState([...httpWithTwins, ...httpsWithTwins]);
1717
1767
  const httpsPort = (await this.resolveAdvertisedListenPort(null)).port;
1718
1768
  return buildAddressBook(state, {
1769
+ rememberedPublicEndpoint: await this.syncRememberedPublicEndpoint(https),
1719
1770
  rowsPalette: scheme === "http" ? httpWithTwins : httpsWithTwins,
1720
1771
  httpsPalette: https,
1721
1772
  appLink: appLinkEndpoint(),
@@ -1765,7 +1816,7 @@ var LocalNetworkAddon = class extends BaseAddon {
1765
1816
  const legacy = (r) => ({
1766
1817
  override: r.flagged,
1767
1818
  resolved: r.resolved,
1768
- source: r.source === "flagged" ? "override" : r.source
1819
+ source: r.source === "flagged" ? "override" : r.source === "none" ? "none" : "auto"
1769
1820
  });
1770
1821
  return {
1771
1822
  cluster: legacy(roles.internal),
@@ -2024,7 +2075,9 @@ var LocalNetworkAddon = class extends BaseAddon {
2024
2075
  this.allowlistTimer.unref?.();
2025
2076
  this.ctx.eventBus?.subscribe({ category: EventCategory.NetworkTunnelStarted }, (event) => {
2026
2077
  const parsed = NetworkTunnelStartedDataSchema.safeParse(event.data ?? {});
2027
- if (parsed.success) this.adoptTunnelUrl(parsed.data.url, parsed.data.stable);
2078
+ if (!parsed.success) return;
2079
+ const addonId = event.source.type === "addon" && typeof event.source.id === "string" ? event.source.id : void 0;
2080
+ this.adoptTunnelUrl(parsed.data.url, parsed.data.stable, addonId);
2028
2081
  });
2029
2082
  this.ctx.eventBus?.subscribe({ category: EventCategory.NetworkTunnelStopped }, () => this.setPublicHostname(""));
2030
2083
  this.ctx.eventBus?.subscribe({ category: EventCategory.MeshNetworkChanged }, (event) => {
@@ -2215,10 +2268,12 @@ var LocalNetworkAddon = class extends BaseAddon {
2215
2268
  * `onInitialize`. This setter exists for tests + future direct
2216
2269
  * callers; cleared by passing an empty string.
2217
2270
  */
2218
- setPublicHostname(hostname, stable = true) {
2219
- if (this.publicHostname === hostname && this.publicHostnameStable === stable) return;
2271
+ setPublicHostname(hostname, stable = true, addonId) {
2272
+ const addon = hostname === "" ? "" : addonId ?? this.publicHostnameAddon;
2273
+ if (this.publicHostname === hostname && this.publicHostnameStable === stable && this.publicHostnameAddon === addon) return;
2220
2274
  this.publicHostname = hostname;
2221
2275
  this.publicHostnameStable = stable;
2276
+ this.publicHostnameAddon = addon;
2222
2277
  this.ctx.logger.info("local-network: public hostname updated", { meta: {
2223
2278
  hostname: hostname || "(cleared)",
2224
2279
  stable
@@ -2228,10 +2283,10 @@ var LocalNetworkAddon = class extends BaseAddon {
2228
2283
  * Adopt a tunnel URL as the public hostname. Ignores the pre-FQDN placeholders a tunnel
2229
2284
  * reports before its real name is known, and a malformed URL (cache left as-is).
2230
2285
  */
2231
- adoptTunnelUrl(url, stable) {
2286
+ adoptTunnelUrl(url, stable, addonId) {
2232
2287
  try {
2233
2288
  const hostname = new URL(url).hostname;
2234
- if (hostname && !hostname.endsWith(".placeholder") && !hostname.startsWith("pending.")) this.setPublicHostname(hostname, stable !== false);
2289
+ if (hostname && !hostname.endsWith(".placeholder") && !hostname.startsWith("pending.")) this.setPublicHostname(hostname, stable !== false, addonId);
2235
2290
  } catch {}
2236
2291
  }
2237
2292
  /**
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_base_addon = require("../../base-addon-DD5dIfcZ.js");
6
+ const require_base_addon = require("../../base-addon-CRsXtYFG.js");
7
7
  const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
8
8
  const require_entry_kind = require("../../entry-kind-cq90c--V.js");
9
9
  const require_migration = require("../../migration-BOQlFZCN.js");
@@ -1,4 +1,4 @@
1
- import { f as defineAddonMigrations, l as RecordIntegrationInstances, t as BaseAddon, v as isInstanceOn } from "../../base-addon-Md14i7pe.mjs";
1
+ import { f as defineAddonMigrations, l as RecordIntegrationInstances, t as BaseAddon, v as isInstanceOn } from "../../base-addon-BcS6r1cT.mjs";
2
2
  import { I as RevConflictError, U as isSecretFieldView, W as isSecretMarker } from "../../scoped-settings-DVWUIP7Z.mjs";
3
3
  import { t as defineEntryKind } from "../../entry-kind-D9MuVJCK.mjs";
4
4
  import { u as preconditionOf } from "../../migration-DGAc6ywR.mjs";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_base_addon = require("../../base-addon-DD5dIfcZ.js");
6
+ const require_base_addon = require("../../base-addon-CRsXtYFG.js");
7
7
  const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
8
8
  const require_metrics_provider_cap = require("../../metrics-provider.cap-BMKD5FH3.js");
9
9
  let node_fs = require("node:fs");