openmeld 0.3.222 → 0.3.224

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 (177) hide show
  1. package/dist/{add-me-membership-Wc69O6rA.js → add-me-membership-CGISMRPF.js} +2 -2
  2. package/dist/{add-me-membership-Wc69O6rA.js.map → add-me-membership-CGISMRPF.js.map} +1 -1
  3. package/dist/{agents-B8zhQnGw.js → agents-CR7BebgO.js} +12 -12
  4. package/dist/{agents-B8zhQnGw.js.map → agents-CR7BebgO.js.map} +1 -1
  5. package/dist/{api-client-foundation-DTiFoGpI.js → api-client-foundation-CqbIn_de.js} +1 -1
  6. package/dist/{api-client-foundation-DnJ_JYli.js → api-client-foundation-DpVwrgh-.js} +3 -3
  7. package/dist/{api-client-foundation-DnJ_JYli.js.map → api-client-foundation-DpVwrgh-.js.map} +1 -1
  8. package/dist/auth-session-BJfKu74u.js +4 -0
  9. package/dist/{auth-session-nhS8jyux.js → auth-session-uEk_Tx6T.js} +8 -8
  10. package/dist/auth-session-uEk_Tx6T.js.map +1 -0
  11. package/dist/{base-url-CMBApK1J.js → base-url-DXrUiSMI.js} +1 -1
  12. package/dist/{base-url-D7uE_xTo.js → base-url-DvjOkKPs.js} +2 -2
  13. package/dist/{base-url-D7uE_xTo.js.map → base-url-DvjOkKPs.js.map} +1 -1
  14. package/dist/{channel-ggx0o_aG.js → channel-B2fD2_be.js} +4 -4
  15. package/dist/{channel-ggx0o_aG.js.map → channel-B2fD2_be.js.map} +1 -1
  16. package/dist/{cli-binary-manifest-DiUulkp0.js → cli-binary-manifest-CT5X05lk.js} +30 -4
  17. package/dist/cli-binary-manifest-CT5X05lk.js.map +1 -0
  18. package/dist/{command-Bz9x7V2T.js → command-CQ9XRwqf.js} +22 -165
  19. package/dist/command-CQ9XRwqf.js.map +1 -0
  20. package/dist/{computer-connection-M3N6plkj.js → computer-connection-Dm7iTnRK.js} +2 -2
  21. package/dist/{computer-connection-M3N6plkj.js.map → computer-connection-Dm7iTnRK.js.map} +1 -1
  22. package/dist/{computer-connection-review-DY5BK_27.js → computer-connection-review-RHAoddSS.js} +6 -6
  23. package/dist/{computer-connection-review-DY5BK_27.js.map → computer-connection-review-RHAoddSS.js.map} +1 -1
  24. package/dist/{computer-disconnect-DR1WDSPK.js → computer-disconnect-BWRsge_2.js} +10 -10
  25. package/dist/{computer-disconnect-DR1WDSPK.js.map → computer-disconnect-BWRsge_2.js.map} +1 -1
  26. package/dist/{computer-setup-continuation-2gs8z-nB.js → computer-setup-continuation-BOCRH0qq.js} +4 -4
  27. package/dist/{computer-setup-continuation-2gs8z-nB.js.map → computer-setup-continuation-BOCRH0qq.js.map} +1 -1
  28. package/dist/context-Bdh3nAzw.js +162 -0
  29. package/dist/context-Bdh3nAzw.js.map +1 -0
  30. package/dist/{control-plane-e3W6PD2M.js → control-plane-rTE2rHZ5.js} +2 -2
  31. package/dist/{control-plane-e3W6PD2M.js.map → control-plane-rTE2rHZ5.js.map} +1 -1
  32. package/dist/{daemon-device-id-DWO9_QW6.js → daemon-device-id-B1Af2Zmn.js} +344 -36
  33. package/dist/daemon-device-id-B1Af2Zmn.js.map +1 -0
  34. package/dist/{daemon-frame-transport-D2-tazuK.js → daemon-frame-transport-WiB73yhT.js} +519 -12
  35. package/dist/daemon-frame-transport-WiB73yhT.js.map +1 -0
  36. package/dist/{daemon-lifecycle-journal-DyKx1xzm.js → daemon-lifecycle-journal-CDZLWgMj.js} +11 -11
  37. package/dist/daemon-lifecycle-journal-CDZLWgMj.js.map +1 -0
  38. package/dist/{daemon-runtime-lease-BUr4qsLo.js → daemon-runtime-lease-1LMeZ6IS.js} +2 -2
  39. package/dist/{daemon-runtime-lease-BUr4qsLo.js.map → daemon-runtime-lease-1LMeZ6IS.js.map} +1 -1
  40. package/dist/{daemon-runtime-lease-C9X8xV_F.js → daemon-runtime-lease-Bz0ucJj3.js} +1 -1
  41. package/dist/{daemon-service-contract-BpOBMGX0.js → daemon-service-contract-GLmAxsq-.js} +4 -4
  42. package/dist/{daemon-service-contract-BpOBMGX0.js.map → daemon-service-contract-GLmAxsq-.js.map} +1 -1
  43. package/dist/{daemon-service-manager-HL4VKbIU.js → daemon-service-manager-C8RUCMDo.js} +9 -7
  44. package/dist/daemon-service-manager-C8RUCMDo.js.map +1 -0
  45. package/dist/{daemon-service-manager-B-QrDe5p.js → daemon-service-manager-CU-79a4z.js} +1 -1
  46. package/dist/{daemon-service-runtime-bKt0YjC7.js → daemon-service-runtime-CBJtgM4P.js} +397 -51
  47. package/dist/daemon-service-runtime-CBJtgM4P.js.map +1 -0
  48. package/dist/{daemon-service-update-coordinator-D8O1uTtu.js → daemon-service-update-coordinator-0LB_XGVZ.js} +48 -33
  49. package/dist/daemon-service-update-coordinator-0LB_XGVZ.js.map +1 -0
  50. package/dist/{daemon-state-B44aq2nm.js → daemon-state-Ca0WK5x0.js} +3 -3
  51. package/dist/{daemon-state-B44aq2nm.js.map → daemon-state-Ca0WK5x0.js.map} +1 -1
  52. package/dist/{dist-B07ziN_u.js → dist-BeJcIdCZ.js} +25 -17
  53. package/dist/dist-BeJcIdCZ.js.map +1 -0
  54. package/dist/dist-C32frPV2.js +4 -0
  55. package/dist/{dist-B2EauBG6.js → dist-YbTZ-Y-2.js} +16 -12
  56. package/dist/dist-YbTZ-Y-2.js.map +1 -0
  57. package/dist/{elapsed-time-Ooo4IC25.js → elapsed-time-q8lSPcfm.js} +6 -6
  58. package/dist/{elapsed-time-Ooo4IC25.js.map → elapsed-time-q8lSPcfm.js.map} +1 -1
  59. package/dist/{entry-DeIRMCiW.js → entry-CpS6tnIk.js} +12 -12
  60. package/dist/{entry-DeIRMCiW.js.map → entry-CpS6tnIk.js.map} +1 -1
  61. package/dist/{installation-inventory-DThnBEhV.js → installation-inventory-C5FsAvrf.js} +5 -5
  62. package/dist/{installation-inventory-DThnBEhV.js.map → installation-inventory-C5FsAvrf.js.map} +1 -1
  63. package/dist/{installer-D2bWZT88.js → installer-054NLJg6.js} +2 -2
  64. package/dist/{installer-D2bWZT88.js.map → installer-054NLJg6.js.map} +1 -1
  65. package/dist/io-DT66typ4.js +16 -0
  66. package/dist/io-DT66typ4.js.map +1 -0
  67. package/dist/{local-components-B6SCXZf9.js → local-components-DleLEzSU.js} +2 -1
  68. package/dist/local-components-DleLEzSU.js.map +1 -0
  69. package/dist/{lock-Bsl_ElWy.js → lock-iue1J2xy.js} +8 -5
  70. package/dist/lock-iue1J2xy.js.map +1 -0
  71. package/dist/{cli-space-api-CQtKu9Zt.js → meta-api-B1k3mwHN.js} +203 -19
  72. package/dist/meta-api-B1k3mwHN.js.map +1 -0
  73. package/dist/{openmeld-BQy0nMox.js → openmeld-BFO3sfC_.js} +93 -1027
  74. package/dist/openmeld-BFO3sfC_.js.map +1 -0
  75. package/dist/openmeld-dev.js +1 -1
  76. package/dist/{openmeld-environment-target-B6HqY0_a.js → openmeld-environment-target-BBn5Ko6p.js} +3 -3
  77. package/dist/{openmeld-environment-target-B6HqY0_a.js.map → openmeld-environment-target-BBn5Ko6p.js.map} +1 -1
  78. package/dist/{openmeld-maintenance-worker-BSODPHbn.js → openmeld-maintenance-worker-Ce4ehQ-c.js} +15 -14
  79. package/dist/openmeld-maintenance-worker-Ce4ehQ-c.js.map +1 -0
  80. package/dist/{openmeld-tools-update-join-BfY0GnDs.js → openmeld-tools-update-join-D24llJ9L.js} +4 -4
  81. package/dist/{openmeld-tools-update-join-BfY0GnDs.js.map → openmeld-tools-update-join-D24llJ9L.js.map} +1 -1
  82. package/dist/{openmeld-tools-update-process-frame-B-XB4dmO.js → openmeld-tools-update-process-frame-BtFKp70p.js} +2 -2
  83. package/dist/{openmeld-tools-update-process-frame-B-XB4dmO.js.map → openmeld-tools-update-process-frame-BtFKp70p.js.map} +1 -1
  84. package/dist/{openmeld-tools-update-process-frame-j-RXwFsK.js → openmeld-tools-update-process-frame-DbEZ3fEh.js} +1 -1
  85. package/dist/openmeld.js +9 -5
  86. package/dist/openmeld.js.map +1 -1
  87. package/dist/{prepare-provider-runtime-CWZcuMF6.js → prepare-provider-runtime-MB-BxOgt.js} +3342 -1327
  88. package/dist/prepare-provider-runtime-MB-BxOgt.js.map +1 -0
  89. package/dist/{prepare-session-executor-CkDxstsf.js → prepare-session-executor-zvSZ6jqy.js} +29 -28
  90. package/dist/prepare-session-executor-zvSZ6jqy.js.map +1 -0
  91. package/dist/{presenter-BcxiQyJg.js → presenter-MJ5YgsOT.js} +3 -13
  92. package/dist/presenter-MJ5YgsOT.js.map +1 -0
  93. package/dist/{process-channel-BQwtOlRc.js → process-channel-CgbduFCz.js} +2 -2
  94. package/dist/{process-channel-BQwtOlRc.js.map → process-channel-CgbduFCz.js.map} +1 -1
  95. package/dist/process-environment-BWSFeUu6.js +49 -0
  96. package/dist/process-environment-BWSFeUu6.js.map +1 -0
  97. package/dist/process-identity-BQLdaZdB.js +190 -0
  98. package/dist/process-identity-BQLdaZdB.js.map +1 -0
  99. package/dist/process-launch-B0pHlkV_.js +173 -0
  100. package/dist/process-launch-B0pHlkV_.js.map +1 -0
  101. package/dist/{published-production-safety-dp-fOmmB.js → published-production-safety-C40hKrBA.js} +2 -2
  102. package/dist/{published-production-safety-dp-fOmmB.js.map → published-production-safety-C40hKrBA.js.map} +1 -1
  103. package/dist/{runtime-BYaFkkLK.js → runtime-D6jItuQ-.js} +155 -702
  104. package/dist/runtime-D6jItuQ-.js.map +1 -0
  105. package/dist/{runtime-agent-controller-reporting-submission-BUUub9_1.js → runtime-agent-controller-reporting-submission-D9ysbi7R.js} +9 -9
  106. package/dist/{runtime-agent-controller-reporting-submission-BUUub9_1.js.map → runtime-agent-controller-reporting-submission-D9ysbi7R.js.map} +1 -1
  107. package/dist/{runtime-reporting-health-state-BgwfrH7f.js → runtime-reporting-health-state-DA-_vW-n.js} +2210 -60
  108. package/dist/runtime-reporting-health-state-DA-_vW-n.js.map +1 -0
  109. package/dist/{runtime-transport-Cc_RN-PL.js → runtime-transport-YIYHSJPn.js} +99 -14
  110. package/dist/runtime-transport-YIYHSJPn.js.map +1 -0
  111. package/dist/{service-CfO38_a-.js → service-Dz2MsvGr.js} +126 -550
  112. package/dist/service-Dz2MsvGr.js.map +1 -0
  113. package/dist/{service-account-admission-Dy2W3n3_.js → service-account-admission-BfdJ-kKR.js} +18 -10
  114. package/dist/service-account-admission-BfdJ-kKR.js.map +1 -0
  115. package/dist/{service-account-authorization-DKpIpxXo.js → service-account-authorization-DZbUOD29.js} +6 -6
  116. package/dist/{service-account-authorization-DKpIpxXo.js.map → service-account-authorization-DZbUOD29.js.map} +1 -1
  117. package/dist/{service-account-control-CCPQAZzn.js → service-account-control-DCMOKXDT.js} +16 -16
  118. package/dist/service-account-control-DCMOKXDT.js.map +1 -0
  119. package/dist/{service-control-capabilities-C9UHSMPz.js → service-control-capabilities-3_bdeHXu.js} +1 -1
  120. package/dist/{service-control-capabilities-xGylBNoH.js → service-control-capabilities-Bb738e_d.js} +19 -15
  121. package/dist/service-control-capabilities-Bb738e_d.js.map +1 -0
  122. package/dist/{service-control-carrier-capability-DDNyE5cB.js → service-control-carrier-capability-gMk5gMKU.js} +11 -4
  123. package/dist/service-control-carrier-capability-gMk5gMKU.js.map +1 -0
  124. package/dist/{state-CQG3k9eh.js → state-GxF_KAM1.js} +4 -4
  125. package/dist/{state-CQG3k9eh.js.map → state-GxF_KAM1.js.map} +1 -1
  126. package/dist/{upgrade-D5FxGbh1.js → upgrade-DfJwCD5H.js} +52 -32
  127. package/dist/upgrade-DfJwCD5H.js.map +1 -0
  128. package/dist/upgrade-DgmYWeNu.js +4 -0
  129. package/dist/windows/openmeld-windows-process.exe +0 -0
  130. package/dist/windows-artifact-DJ9DKjfc.js +16 -0
  131. package/dist/windows-artifact-DJ9DKjfc.js.map +1 -0
  132. package/dist/windows-task-command-COu_6Ke3.js +74 -0
  133. package/dist/windows-task-command-COu_6Ke3.js.map +1 -0
  134. package/dist/windows-task-entry-CtRpUbiK.js +50 -0
  135. package/dist/windows-task-entry-CtRpUbiK.js.map +1 -0
  136. package/dist/{windows-user-task-Bx2yYnOM.js → windows-user-task-B8NcRg_u.js} +1 -1
  137. package/dist/{windows-user-task-CRGbKggi.js → windows-user-task-Io5QuEVR.js} +108 -51
  138. package/dist/windows-user-task-Io5QuEVR.js.map +1 -0
  139. package/package.json +12 -12
  140. package/skills/openmeld-cli/playbooks/space-ops.md +9 -3
  141. package/skills/openmeld-cli/references/commands.md +0 -1
  142. package/dist/auth-session-D8dbMpaK.js +0 -4
  143. package/dist/auth-session-nhS8jyux.js.map +0 -1
  144. package/dist/cli-binary-manifest-DiUulkp0.js.map +0 -1
  145. package/dist/cli-space-api-CQtKu9Zt.js.map +0 -1
  146. package/dist/command-Bz9x7V2T.js.map +0 -1
  147. package/dist/context-l_31Mn4X.js +0 -473
  148. package/dist/context-l_31Mn4X.js.map +0 -1
  149. package/dist/daemon-device-id-DWO9_QW6.js.map +0 -1
  150. package/dist/daemon-frame-transport-D2-tazuK.js.map +0 -1
  151. package/dist/daemon-lifecycle-journal-DyKx1xzm.js.map +0 -1
  152. package/dist/daemon-service-manager-HL4VKbIU.js.map +0 -1
  153. package/dist/daemon-service-runtime-bKt0YjC7.js.map +0 -1
  154. package/dist/daemon-service-update-coordinator-D8O1uTtu.js.map +0 -1
  155. package/dist/dist-B07ziN_u.js.map +0 -1
  156. package/dist/dist-B2EauBG6.js.map +0 -1
  157. package/dist/dist-DhWI1iyi.js +0 -4
  158. package/dist/local-components-B6SCXZf9.js.map +0 -1
  159. package/dist/lock-Bsl_ElWy.js.map +0 -1
  160. package/dist/openmeld-BQy0nMox.js.map +0 -1
  161. package/dist/openmeld-maintenance-worker-BSODPHbn.js.map +0 -1
  162. package/dist/prepare-provider-runtime-CWZcuMF6.js.map +0 -1
  163. package/dist/prepare-session-executor-CkDxstsf.js.map +0 -1
  164. package/dist/presenter-BcxiQyJg.js.map +0 -1
  165. package/dist/process-identity-CNus0e6E.js +0 -146
  166. package/dist/process-identity-CNus0e6E.js.map +0 -1
  167. package/dist/runtime-BYaFkkLK.js.map +0 -1
  168. package/dist/runtime-reporting-health-state-BgwfrH7f.js.map +0 -1
  169. package/dist/runtime-transport-Cc_RN-PL.js.map +0 -1
  170. package/dist/service-CfO38_a-.js.map +0 -1
  171. package/dist/service-account-admission-Dy2W3n3_.js.map +0 -1
  172. package/dist/service-account-control-CCPQAZzn.js.map +0 -1
  173. package/dist/service-control-capabilities-xGylBNoH.js.map +0 -1
  174. package/dist/service-control-carrier-capability-DDNyE5cB.js.map +0 -1
  175. package/dist/upgrade-D5FxGbh1.js.map +0 -1
  176. package/dist/upgrade-DhFEu0k6.js +0 -4
  177. package/dist/windows-user-task-CRGbKggi.js.map +0 -1
@@ -1,473 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { J as normalizeOpenMeldProfileId, N as accountProfileViewPath, _ as resolveCliContext, et as openMeldRootDir, ft as runtimeDir, g as readCliContextState, h as listCliContextStates, y as writeCliContextState } from "./lock-Bsl_ElWy.js";
4
- import { ci as openMeldProfileIdSchema } from "./runtime-transport-Cc_RN-PL.js";
5
- import { d as getAuthSessionState } from "./auth-session-nhS8jyux.js";
6
- import { G as resolveOpenMeldProfile, K as resolveOpenMeldProfileByIdOrName, it as resolveAuthenticationGuidanceFromError, ot as resolveAuthenticationReasonFromState, st as resolveCurrentOpenMeldAccountContext, tt as createAuthenticationError } from "./daemon-device-id-DWO9_QW6.js";
7
- import { _ as getConfiguredViewCustomization } from "./base-url-D7uE_xTo.js";
8
- import { t as formatInlineOpenMeldCliCommands } from "./cli-entry-command-CR_9QU1i.js";
9
- import { createHash } from "node:crypto";
10
- import { dirname, join } from "node:path";
11
- import { mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
12
- //#region src/config/profile-view.ts
13
- async function getProfileDefaultView(openMeldProfileId) {
14
- const normalizedOpenMeldProfileId = normalizeOpenMeldProfileId(openMeldProfileId);
15
- const path = await resolveAccountProfileViewPath(normalizedOpenMeldProfileId);
16
- const raw = await readFile(path, "utf8").catch(() => null);
17
- if (!raw) return "auto";
18
- try {
19
- const parsed = JSON.parse(raw);
20
- if (parsed.v !== 1) return "auto";
21
- const normalizedStoredProfileView = normalizeStoredProfileView(parsed);
22
- if (!normalizedStoredProfileView) return "auto";
23
- if (normalizedStoredProfileView.payload.openMeldProfileId !== normalizedOpenMeldProfileId) {
24
- await rm(path, { force: true });
25
- return "auto";
26
- }
27
- if (normalizedStoredProfileView.needsRewrite) await writeProfileViewFile(path, normalizedStoredProfileView.payload);
28
- return normalizedStoredProfileView.payload.defaultView;
29
- } catch {
30
- return "auto";
31
- }
32
- }
33
- async function setProfileDefaultView(input) {
34
- const openMeldProfileId = normalizeOpenMeldProfileId(input.openMeldProfileId);
35
- const path = await resolveAccountProfileViewPath(openMeldProfileId);
36
- if (input.view === "auto") {
37
- await rm(path, { force: true });
38
- return;
39
- }
40
- await writeProfileViewFile(path, {
41
- v: 1,
42
- openMeldProfileId,
43
- defaultView: input.view,
44
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
45
- });
46
- }
47
- async function writeProfileViewFile(path, payload) {
48
- await mkdir(dirname(path), { recursive: true });
49
- const tempPath = `${path}.tmp-${process.pid}-${Date.now()}`;
50
- await writeFile(tempPath, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
51
- try {
52
- await rename(tempPath, path);
53
- } catch (error) {
54
- await rm(tempPath, { force: true }).catch(() => void 0);
55
- throw error;
56
- }
57
- }
58
- async function resolveAccountProfileViewPath(openMeldProfileId) {
59
- return accountProfileViewPath((await resolveCurrentOpenMeldAccountContext()).key, openMeldProfileId);
60
- }
61
- function normalizeStoredProfileView(input) {
62
- const openMeldProfileId = normalizeOptionalOpenMeldProfileId(input.openMeldProfileId);
63
- const legacyProfile = normalizeOptionalOpenMeldProfileId(input.profile);
64
- const resolvedOpenMeldProfileId = openMeldProfileId ?? legacyProfile;
65
- if (!resolvedOpenMeldProfileId) return null;
66
- const defaultView = normalizeStoredDefaultView(input.defaultView);
67
- if (!defaultView) return null;
68
- const updatedAt = normalizeStoredUpdatedAt(input.updatedAt);
69
- return {
70
- needsRewrite: openMeldProfileId !== resolvedOpenMeldProfileId || input.profile !== void 0 || input.updatedAt !== updatedAt,
71
- payload: {
72
- v: 1,
73
- openMeldProfileId: resolvedOpenMeldProfileId,
74
- defaultView,
75
- updatedAt
76
- }
77
- };
78
- }
79
- function normalizeStoredDefaultView(value) {
80
- if (value === "human" || value === "agent") return value;
81
- return null;
82
- }
83
- function normalizeStoredUpdatedAt(value) {
84
- if (typeof value === "string") {
85
- const trimmedValue = value.trim();
86
- if (trimmedValue.length > 0 && !Number.isNaN(Date.parse(trimmedValue))) return trimmedValue;
87
- }
88
- return (/* @__PURE__ */ new Date()).toISOString();
89
- }
90
- function normalizeOptionalOpenMeldProfileId(value) {
91
- if (typeof value !== "string") return null;
92
- try {
93
- return normalizeOpenMeldProfileId(value);
94
- } catch {
95
- return null;
96
- }
97
- }
98
- //#endregion
99
- //#region src/config/openmeld-profile-selection.ts
100
- const SESSION_FILE_HASH_LENGTH = 8;
101
- const SESSION_FILE_MAX_LENGTH = 128;
102
- const FALLBACK_SELECTION_SESSION_ID = "global-default";
103
- const FALLBACK_SELECTION_SOURCE = "fallback:no_runtime_session";
104
- async function setSelectedOpenMeldProfileId(openMeldProfileId) {
105
- const normalized = normalizeRequiredString(openMeldProfileId, "openMeldProfileId");
106
- await rm(legacySelectionPath(), { force: true }).catch(() => void 0);
107
- const cliContext = resolveCliContext();
108
- if (!cliContext) {
109
- await writeFallbackSelectionPayload(normalized);
110
- return {
111
- persistent: true,
112
- cliContextSource: FALLBACK_SELECTION_SOURCE
113
- };
114
- }
115
- await writeCliContextState({ selectedOpenMeldProfileId: normalized });
116
- await rm(selectionPath(cliContext.cliContextId), { force: true }).catch(() => void 0);
117
- return {
118
- persistent: true,
119
- cliContextSource: cliContext.source
120
- };
121
- }
122
- async function getSelectedOpenMeldProfileId() {
123
- const cliContext = resolveCliContext();
124
- if (!cliContext) return await readFallbackSelectionPayload();
125
- const sessionState = await readCliContextState();
126
- if (sessionState?.selectedOpenMeldProfileId) return sessionState.selectedOpenMeldProfileId;
127
- const legacySelection = await readLegacySelectionPayload(cliContext.cliContextId);
128
- if (!legacySelection?.openMeldProfileId) return null;
129
- await writeCliContextState({
130
- sessionId: legacySelection.sessionId,
131
- sessionSource: legacySelection.sessionSource,
132
- openMeldProfileId: legacySelection.openMeldProfileId
133
- });
134
- await rm(selectionPath(cliContext.cliContextId), { force: true }).catch(() => void 0);
135
- return legacySelection.openMeldProfileId;
136
- }
137
- async function clearSelectedOpenMeldProfileId() {
138
- const cliContext = resolveCliContext();
139
- if (!cliContext) {
140
- await rm(fallbackSelectionPath(), { force: true }).catch(() => void 0);
141
- await rm(legacySelectionPath(), { force: true }).catch(() => void 0);
142
- return;
143
- }
144
- await writeCliContextState({ selectedOpenMeldProfileId: null });
145
- await rm(selectionPath(cliContext.cliContextId), { force: true });
146
- await rm(legacySelectionPath(), { force: true }).catch(() => void 0);
147
- }
148
- async function clearAllSelectedOpenMeldProfileIds() {
149
- const sessionStates = await listCliContextStates();
150
- let clearedSessionSelections = 0;
151
- const failedSessionIds = [];
152
- for (const sessionState of sessionStates) {
153
- if (!sessionState.selectedOpenMeldProfileId) continue;
154
- try {
155
- if (await writeCliContextState({
156
- sessionId: sessionState.sessionId,
157
- sessionSource: sessionState.cliContextSource,
158
- selectedOpenMeldProfileId: null
159
- })) {
160
- clearedSessionSelections += 1;
161
- continue;
162
- }
163
- } catch {}
164
- failedSessionIds.push(sessionState.sessionId);
165
- }
166
- const removedFallbackSelection = await removeFileIfPresent(fallbackSelectionPath());
167
- const removedLegacySelectionFile = await removeFileIfPresent(legacySelectionPath());
168
- const removedLegacySessionSelectionDirectory = await removeDirectoryIfPresent(sessionSelectionDir());
169
- return {
170
- clearedSessionSelections,
171
- failedSessionIds,
172
- removedFallbackSelection,
173
- removedLegacySelectionFile,
174
- removedLegacySessionSelectionDirectory
175
- };
176
- }
177
- async function alignSelectedOpenMeldProfileStorage() {
178
- let migratedSessionSelections = 0;
179
- const entryNames = await readdir(sessionSelectionDir()).catch(() => []);
180
- for (const entryName of entryNames) {
181
- if (!entryName.endsWith(".selected-profile.json")) continue;
182
- const raw = await readFile(join(sessionSelectionDir(), entryName), "utf8").catch(() => null);
183
- if (!raw) continue;
184
- const parsed = parseLegacySelectionPayload(raw);
185
- if (!parsed) continue;
186
- if (await writeCliContextState({
187
- sessionId: parsed.sessionId,
188
- sessionSource: parsed.sessionSource,
189
- selectedOpenMeldProfileId: parsed.openMeldProfileId
190
- })) migratedSessionSelections += 1;
191
- }
192
- const legacyDirectoryExists = entryNames.length > 0;
193
- if (legacyDirectoryExists) await rm(sessionSelectionDir(), {
194
- recursive: true,
195
- force: true
196
- });
197
- await migrateLegacyFallbackSelection();
198
- const removedLegacySelectionFile = await removeLegacySelectionFile();
199
- return {
200
- migratedSessionSelections,
201
- removedLegacyDirectory: legacyDirectoryExists,
202
- removedLegacySelectionFile
203
- };
204
- }
205
- function selectionPath(sessionId) {
206
- return join(sessionSelectionDir(), `${toSafeSessionFile(sessionId)}.selected-profile.json`);
207
- }
208
- function sessionSelectionDir() {
209
- return join(runtimeDir(), "selected-openmeld-profiles");
210
- }
211
- function legacySelectionPath() {
212
- return join(openMeldRootDir(), "auth", "selected-profile.json");
213
- }
214
- function fallbackSelectionPath() {
215
- return join(runtimeDir(), "selected-profile-fallback.json");
216
- }
217
- async function readLegacySelectionPayload(sessionId) {
218
- const raw = await readFile(selectionPath(sessionId), "utf8").catch(() => null);
219
- if (!raw) return null;
220
- return parseLegacySelectionPayload(raw);
221
- }
222
- async function readFallbackSelectionPayload() {
223
- const raw = await readFile(fallbackSelectionPath(), "utf8").catch(() => null);
224
- if (!raw) {
225
- const legacyFallback = await readLegacyFallbackSelection();
226
- if (!legacyFallback) return null;
227
- await writeFallbackSelectionPayload(legacyFallback.openMeldProfileId);
228
- await rm(legacySelectionPath(), { force: true }).catch(() => void 0);
229
- return legacyFallback.openMeldProfileId;
230
- }
231
- return parseLegacySelectionPayload(raw)?.openMeldProfileId ?? null;
232
- }
233
- async function writeFallbackSelectionPayload(openMeldProfileId) {
234
- await mkdir(runtimeDir(), { recursive: true });
235
- const payload = {
236
- v: 1,
237
- sessionId: FALLBACK_SELECTION_SESSION_ID,
238
- sessionSource: FALLBACK_SELECTION_SOURCE,
239
- openMeldProfileId,
240
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
241
- };
242
- await writeFile(fallbackSelectionPath(), `${JSON.stringify(payload, null, 2)}\n`, "utf8");
243
- }
244
- function parseLegacySelectionPayload(raw) {
245
- try {
246
- const payload = JSON.parse(raw);
247
- if (payload.v !== 1) return null;
248
- const sessionId = normalizeOptionalString$2(payload.sessionId);
249
- const openMeldProfileId = normalizeOptionalString$2(payload.openMeldProfileId);
250
- if (!(sessionId && openMeldProfileId)) return null;
251
- return {
252
- v: 1,
253
- sessionId,
254
- sessionSource: normalizeOptionalString$2(payload.sessionSource) ?? "manual",
255
- openMeldProfileId,
256
- updatedAt: normalizeOptionalString$2(payload.updatedAt) ?? (/* @__PURE__ */ new Date(0)).toISOString()
257
- };
258
- } catch {
259
- return null;
260
- }
261
- }
262
- async function readLegacyFallbackSelection() {
263
- const raw = await readFile(legacySelectionPath(), "utf8").catch(() => null);
264
- if (!raw) return null;
265
- const parsed = parseLegacySelectionPayload(raw);
266
- if (parsed?.sessionSource !== FALLBACK_SELECTION_SOURCE) return null;
267
- return parsed;
268
- }
269
- async function migrateLegacyFallbackSelection() {
270
- const legacyFallback = await readLegacyFallbackSelection();
271
- if (!legacyFallback) return;
272
- if (!await readFile(fallbackSelectionPath(), "utf8").catch(() => null)) await writeFallbackSelectionPayload(legacyFallback.openMeldProfileId);
273
- }
274
- async function removeLegacySelectionFile() {
275
- if (!await readFile(legacySelectionPath(), "utf8").catch(() => null)) return false;
276
- await rm(legacySelectionPath(), { force: true }).catch(() => void 0);
277
- return true;
278
- }
279
- function toSafeSessionFile(value) {
280
- const hash = createHash("sha1").update(value, "utf8").digest("hex").slice(0, SESSION_FILE_HASH_LENGTH);
281
- const safeBaseRaw = value.replace(/[^a-zA-Z0-9._-]+/g, "_");
282
- const safeBase = safeBaseRaw.length > 0 ? safeBaseRaw : "session";
283
- const maxBaseLength = Math.max(1, SESSION_FILE_MAX_LENGTH - SESSION_FILE_HASH_LENGTH - 1);
284
- return `${safeBase.slice(0, maxBaseLength)}-${hash}`;
285
- }
286
- function normalizeOptionalString$2(value) {
287
- const normalized = String(value ?? "").trim();
288
- return normalized.length > 0 ? normalized : null;
289
- }
290
- function normalizeRequiredString(value, field) {
291
- const normalized = normalizeOptionalString$2(value);
292
- if (!normalized) throw new Error(`${field} is required`);
293
- return normalized;
294
- }
295
- async function removeFileIfPresent(path) {
296
- if (await readFile(path, "utf8").catch(() => null) === null) return false;
297
- await rm(path, { force: true }).catch(() => void 0);
298
- return true;
299
- }
300
- async function removeDirectoryIfPresent(path) {
301
- if (!(await stat(path).catch(() => null))?.isDirectory()) return false;
302
- await rm(path, {
303
- recursive: true,
304
- force: true
305
- }).catch(() => void 0);
306
- return true;
307
- }
308
- //#endregion
309
- //#region src/config/resolve-openmeld-profile.ts
310
- const PROFILE_REQUIRED_ERROR_ROOT = "no OpenMeld profile is selected for this terminal session yet";
311
- const PROFILE_REQUIRED_ERROR_MESSAGE = `${PROFILE_REQUIRED_ERROR_ROOT}; run \`openmeld start\` to choose one, or pass \`--profile <id>\`.`;
312
- const SERVICE_TRACE_PROFILE_REQUIRED_ERROR_MESSAGE = `${PROFILE_REQUIRED_ERROR_ROOT}; dispatch trace needs an acting profile. Run \`openmeld profile set <profile-id>\` once, or pass \`--profile <profile-id>\` with this trace command. \`--target-profile\` only identifies the agent being traced.`;
313
- const PROFILE_REQUIRED_ERROR_PREFIX = "no OpenMeld profile is selected for this terminal session yet; run `";
314
- const PROFILE_REQUIRED_ERROR_SUFFIX = " start` to choose one, or pass `--profile <id>`.";
315
- function isSelectedOpenMeldProfileRequiredError(error) {
316
- if (!(error instanceof Error)) return false;
317
- if (error.message === PROFILE_REQUIRED_ERROR_MESSAGE) return true;
318
- if (error.message.includes(PROFILE_REQUIRED_ERROR_ROOT) && error.message.includes("--profile <")) return true;
319
- return error.message.startsWith(PROFILE_REQUIRED_ERROR_PREFIX) && error.message.endsWith(PROFILE_REQUIRED_ERROR_SUFFIX);
320
- }
321
- async function resolveOpenMeldProfileOrNull(input = {}) {
322
- const explicitOpenMeldProfileId = normalizeOptionalString$1(input.openMeldProfileId);
323
- if (explicitOpenMeldProfileId) return await resolveExplicitOpenMeldProfile(explicitOpenMeldProfileId, {
324
- profileKind: input.profileKind,
325
- allowUnauthenticated: input.allowUnauthenticated === true,
326
- persistSelection: input.persistSelection !== false
327
- });
328
- const selectedOpenMeldProfileId = await getSelectedOpenMeldProfileId();
329
- if (selectedOpenMeldProfileId) {
330
- const selectedProfile = await resolveSelectedOpenMeldProfile(selectedOpenMeldProfileId, {
331
- profileKind: input.profileKind,
332
- allowUnauthenticated: input.allowUnauthenticated === true
333
- });
334
- if (selectedProfile) return selectedProfile;
335
- }
336
- if (input.allowUnauthenticated === true) {
337
- if ((await getAuthSessionState({ validateRemote: false })).state !== "valid") return null;
338
- }
339
- if (input.allowDefaultFallback !== true) return null;
340
- let fallbackProfile;
341
- try {
342
- fallbackProfile = await resolveOpenMeldProfile({ profileKind: input.profileKind });
343
- } catch (error) {
344
- if (input.allowUnauthenticated === true && isAuthRequiredError(error)) return null;
345
- throw error;
346
- }
347
- if (input.persistSelection !== false) await setSelectedOpenMeldProfileId(fallbackProfile.openMeldProfileId);
348
- return fallbackProfile;
349
- }
350
- async function resolveExplicitOpenMeldProfile(openMeldProfileId, input) {
351
- try {
352
- const profile = await resolveOpenMeldProfileByIdOrName({
353
- profileIdentifier: openMeldProfileId,
354
- profileKind: input.profileKind
355
- });
356
- if (input.persistSelection) await setSelectedOpenMeldProfileId(profile.openMeldProfileId);
357
- return profile;
358
- } catch (error) {
359
- if (isAuthRequiredError(error) && input.allowUnauthenticated) return null;
360
- throw error;
361
- }
362
- }
363
- async function requireOpenMeldProfile(input = {}) {
364
- const profile = await resolveOpenMeldProfileOrNull(input);
365
- if (profile) return profile;
366
- const authState = await getAuthSessionState({ validateRemote: false });
367
- if (authState.state === "valid") throw new Error(formatInlineOpenMeldCliCommands(resolveProfileRequiredErrorMessage(input.authAction)));
368
- throw createAuthenticationError({
369
- reason: resolveAuthenticationReasonFromState(authState.state) ?? "required",
370
- action: input.authAction
371
- });
372
- }
373
- function resolveProfileRequiredErrorMessage(authAction) {
374
- if (authAction === "reading a dispatch trace") return SERVICE_TRACE_PROFILE_REQUIRED_ERROR_MESSAGE;
375
- return PROFILE_REQUIRED_ERROR_MESSAGE;
376
- }
377
- async function resolveSelectedOpenMeldProfile(selectedOpenMeldProfileId, input) {
378
- try {
379
- return await resolveOpenMeldProfile({
380
- openMeldProfileId: selectedOpenMeldProfileId,
381
- profileKind: input.profileKind
382
- });
383
- } catch (error) {
384
- if (isAuthRequiredError(error)) {
385
- if (input.allowUnauthenticated) return null;
386
- throw error;
387
- }
388
- if (isProfileMissingError(error)) {
389
- await clearSelectedOpenMeldProfileId();
390
- return null;
391
- }
392
- throw error;
393
- }
394
- }
395
- function normalizeOptionalString$1(value) {
396
- const normalized = String(value ?? "").trim();
397
- return normalized.length > 0 ? normalized : null;
398
- }
399
- function isAuthRequiredError(error) {
400
- return resolveAuthenticationGuidanceFromError(error) !== null;
401
- }
402
- function isProfileMissingError(error) {
403
- if ((error && typeof error === "object" && "code" in error ? String(error.code ?? "") : "") === "profile.not_found") return true;
404
- return (error instanceof Error ? error.message : String(error ?? "")).includes("profile not found");
405
- }
406
- //#endregion
407
- //#region src/config/view-profile-key.ts
408
- async function resolveViewProfileKey(inputProfile) {
409
- const explicit = normalizeOptionalString(inputProfile);
410
- if (explicit) {
411
- const profileId = openMeldProfileIdSchema.safeParse(explicit);
412
- if (profileId.success) return profileId.data;
413
- return (await resolveOpenMeldProfileByIdOrName({ profileIdentifier: explicit }).catch(() => null))?.openMeldProfileId ?? explicit;
414
- }
415
- const selected = await getSelectedOpenMeldProfileId();
416
- if (selected) return selected;
417
- return null;
418
- }
419
- function normalizeOptionalString(value) {
420
- const normalized = String(value ?? "").trim();
421
- return normalized.length > 0 ? normalized : null;
422
- }
423
- //#endregion
424
- //#region src/runtime/context.ts
425
- async function resolveRuntimeContext(input) {
426
- const viewOpenMeldProfileId = await resolveViewProfileKey(input?.profile);
427
- const configuredViewMode = await readConfiguredDefaultView(viewOpenMeldProfileId);
428
- const viewMode = parseCliViewMode(input?.view ?? configuredViewMode);
429
- const interactive = input?.interactive ?? isInteractiveSession();
430
- const viewCustomization = await readViewCustomization();
431
- if (viewMode === "human" || viewMode === "agent") return {
432
- viewMode,
433
- resolvedView: viewMode,
434
- interactive,
435
- ...viewOpenMeldProfileId ? { openMeldProfileId: viewOpenMeldProfileId } : {},
436
- ...viewCustomization ? { viewCustomization } : {}
437
- };
438
- const openMeldProfile = await resolveOpenMeldProfileOrNull({
439
- openMeldProfileId: input?.profile,
440
- allowUnauthenticated: true,
441
- persistSelection: false,
442
- allowDefaultFallback: false
443
- }).catch(() => null);
444
- const resolvedView = openMeldProfile?.profileKind === "agent" ? "agent" : "human";
445
- const resolvedOpenMeldProfileId = openMeldProfile ? openMeldProfile.openMeldProfileId : viewOpenMeldProfileId;
446
- return {
447
- viewMode,
448
- resolvedView,
449
- interactive,
450
- ...resolvedOpenMeldProfileId ? { openMeldProfileId: resolvedOpenMeldProfileId } : {},
451
- ...openMeldProfile?.profileKind ? { profileKind: openMeldProfile.profileKind } : {},
452
- ...viewCustomization ? { viewCustomization } : {}
453
- };
454
- }
455
- function parseCliViewMode(value) {
456
- const normalized = String(value ?? "auto").trim().toLowerCase();
457
- if (normalized === "auto" || normalized === "human" || normalized === "agent") return normalized;
458
- throw new Error(`invalid --view value: ${normalized} (use auto|human|agent)`);
459
- }
460
- function readViewCustomization() {
461
- return getConfiguredViewCustomization().catch(() => null);
462
- }
463
- function readConfiguredDefaultView(openMeldProfileId) {
464
- if (!openMeldProfileId) return Promise.resolve("auto");
465
- return getProfileDefaultView(openMeldProfileId).catch(() => "auto");
466
- }
467
- function isInteractiveSession() {
468
- return Boolean(process.stdin.isTTY && process.stdout.isTTY);
469
- }
470
- //#endregion
471
- export { requireOpenMeldProfile as a, clearAllSelectedOpenMeldProfileIds as c, setSelectedOpenMeldProfileId as d, getProfileDefaultView as f, isSelectedOpenMeldProfileRequiredError as i, clearSelectedOpenMeldProfileId as l, resolveRuntimeContext as n, resolveOpenMeldProfileOrNull as o, setProfileDefaultView as p, resolveViewProfileKey as r, alignSelectedOpenMeldProfileStorage as s, parseCliViewMode as t, getSelectedOpenMeldProfileId as u };
472
-
473
- //# sourceMappingURL=context-l_31Mn4X.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-l_31Mn4X.js","names":["normalizeOptionalString","normalizeOptionalString"],"sources":["../src/config/profile-view.ts","../src/config/openmeld-profile-selection.ts","../src/config/resolve-openmeld-profile.ts","../src/config/view-profile-key.ts","../src/runtime/context.ts"],"sourcesContent":["import { mkdir, readFile, rename, rm, writeFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport { resolveCurrentOpenMeldAccountContext } from \"./account-context\";\nimport {\n accountProfileViewPath,\n normalizeOpenMeldProfileId,\n type OpenMeldProfileId,\n} from \"./paths\";\n\nexport type ProfileDefaultView = \"auto\" | \"human\" | \"agent\";\n\ntype ProfileViewV1 = {\n v: 1;\n openMeldProfileId: OpenMeldProfileId;\n defaultView: Exclude<ProfileDefaultView, \"auto\">;\n updatedAt: string;\n};\n\ntype StoredProfileViewInput = Partial<ProfileViewV1> & { profile?: string };\n\ntype NormalizedStoredProfileView = {\n needsRewrite: boolean;\n payload: ProfileViewV1;\n};\n\nexport async function getProfileDefaultView(\n openMeldProfileId: string\n): Promise<ProfileDefaultView> {\n const normalizedOpenMeldProfileId =\n normalizeOpenMeldProfileId(openMeldProfileId);\n const path = await resolveAccountProfileViewPath(normalizedOpenMeldProfileId);\n const raw = await readFile(path, \"utf8\").catch(() => null);\n if (!raw) {\n return \"auto\";\n }\n\n try {\n const parsed = JSON.parse(raw) as StoredProfileViewInput;\n if (parsed.v !== 1) {\n return \"auto\";\n }\n const normalizedStoredProfileView = normalizeStoredProfileView(parsed);\n if (!normalizedStoredProfileView) {\n return \"auto\";\n }\n if (\n normalizedStoredProfileView.payload.openMeldProfileId !==\n normalizedOpenMeldProfileId\n ) {\n await rm(path, { force: true });\n return \"auto\";\n }\n if (normalizedStoredProfileView.needsRewrite) {\n await writeProfileViewFile(path, normalizedStoredProfileView.payload);\n }\n return normalizedStoredProfileView.payload.defaultView;\n } catch {\n return \"auto\";\n }\n}\n\nexport async function setProfileDefaultView(input: {\n openMeldProfileId: string;\n view: ProfileDefaultView;\n}): Promise<void> {\n const openMeldProfileId = normalizeOpenMeldProfileId(input.openMeldProfileId);\n const path = await resolveAccountProfileViewPath(openMeldProfileId);\n\n if (input.view === \"auto\") {\n await rm(path, { force: true });\n return;\n }\n\n await writeProfileViewFile(path, {\n v: 1,\n openMeldProfileId,\n defaultView: input.view,\n updatedAt: new Date().toISOString(),\n });\n}\n\nasync function writeProfileViewFile(\n path: string,\n payload: ProfileViewV1\n): Promise<void> {\n await mkdir(dirname(path), { recursive: true });\n const tempPath = `${path}.tmp-${process.pid}-${Date.now()}`;\n await writeFile(tempPath, `${JSON.stringify(payload, null, 2)}\\n`, \"utf8\");\n try {\n await rename(tempPath, path);\n } catch (error) {\n await rm(tempPath, { force: true }).catch(() => undefined);\n throw error;\n }\n}\n\nasync function resolveAccountProfileViewPath(\n openMeldProfileId: OpenMeldProfileId\n): Promise<string> {\n const accountContext = await resolveCurrentOpenMeldAccountContext();\n return accountProfileViewPath(accountContext.key, openMeldProfileId);\n}\n\nfunction normalizeStoredProfileView(\n input: StoredProfileViewInput\n): NormalizedStoredProfileView | null {\n const openMeldProfileId = normalizeOptionalOpenMeldProfileId(\n input.openMeldProfileId\n );\n const legacyProfile = normalizeOptionalOpenMeldProfileId(input.profile);\n const resolvedOpenMeldProfileId = openMeldProfileId ?? legacyProfile;\n if (!resolvedOpenMeldProfileId) {\n return null;\n }\n const defaultView = normalizeStoredDefaultView(input.defaultView);\n if (!defaultView) {\n return null;\n }\n const updatedAt = normalizeStoredUpdatedAt(input.updatedAt);\n return {\n needsRewrite:\n openMeldProfileId !== resolvedOpenMeldProfileId ||\n input.profile !== undefined ||\n input.updatedAt !== updatedAt,\n payload: {\n v: 1,\n openMeldProfileId: resolvedOpenMeldProfileId,\n defaultView,\n updatedAt,\n },\n };\n}\n\nfunction normalizeStoredDefaultView(\n value: unknown\n): Exclude<ProfileDefaultView, \"auto\"> | null {\n if (value === \"human\" || value === \"agent\") {\n return value;\n }\n return null;\n}\n\nfunction normalizeStoredUpdatedAt(value: unknown): string {\n if (typeof value === \"string\") {\n const trimmedValue = value.trim();\n if (trimmedValue.length > 0 && !Number.isNaN(Date.parse(trimmedValue))) {\n return trimmedValue;\n }\n }\n return new Date().toISOString();\n}\n\nfunction normalizeOptionalOpenMeldProfileId(\n value: unknown\n): OpenMeldProfileId | null {\n if (typeof value !== \"string\") {\n return null;\n }\n try {\n return normalizeOpenMeldProfileId(value);\n } catch {\n return null;\n }\n}\n","import { createHash } from \"node:crypto\";\nimport {\n mkdir,\n readdir,\n readFile,\n rm,\n stat,\n writeFile,\n} from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { openMeldRootDir, runtimeDir } from \"./paths\";\nimport {\n listCliContextStates,\n readCliContextState,\n resolveCliContext,\n writeCliContextState,\n} from \"./session-profile\";\n\ntype SelectedOpenMeldProfileV1 = {\n v: 1;\n sessionId: string;\n sessionSource: string;\n openMeldProfileId: string;\n updatedAt: string;\n};\n\nexport type SetSelectedOpenMeldProfileResult = {\n persistent: boolean;\n cliContextSource?: string;\n};\n\nexport type ClearAllSelectedOpenMeldProfileIdsResult = {\n clearedSessionSelections: number;\n failedSessionIds: string[];\n removedFallbackSelection: boolean;\n removedLegacySelectionFile: boolean;\n removedLegacySessionSelectionDirectory: boolean;\n};\n\nconst SESSION_FILE_HASH_LENGTH = 8;\nconst SESSION_FILE_MAX_LENGTH = 128;\nconst FALLBACK_SELECTION_SESSION_ID = \"global-default\";\nconst FALLBACK_SELECTION_SOURCE = \"fallback:no_runtime_session\";\n\nexport async function setSelectedOpenMeldProfileId(\n openMeldProfileId: string\n): Promise<SetSelectedOpenMeldProfileResult> {\n const normalized = normalizeRequiredString(\n openMeldProfileId,\n \"openMeldProfileId\"\n );\n await rm(legacySelectionPath(), { force: true }).catch(() => undefined);\n\n const cliContext = resolveCliContext();\n if (!cliContext) {\n await writeFallbackSelectionPayload(normalized);\n return {\n persistent: true,\n cliContextSource: FALLBACK_SELECTION_SOURCE,\n };\n }\n\n await writeCliContextState({\n selectedOpenMeldProfileId: normalized,\n });\n await rm(selectionPath(cliContext.cliContextId), {\n force: true,\n }).catch(() => undefined);\n return {\n persistent: true,\n cliContextSource: cliContext.source,\n };\n}\n\nexport async function getSelectedOpenMeldProfileId(): Promise<string | null> {\n const cliContext = resolveCliContext();\n if (!cliContext) {\n return await readFallbackSelectionPayload();\n }\n\n const sessionState = await readCliContextState();\n if (sessionState?.selectedOpenMeldProfileId) {\n return sessionState.selectedOpenMeldProfileId;\n }\n\n const legacySelection = await readLegacySelectionPayload(\n cliContext.cliContextId\n );\n if (!legacySelection?.openMeldProfileId) {\n return null;\n }\n await writeCliContextState({\n sessionId: legacySelection.sessionId,\n sessionSource: legacySelection.sessionSource,\n openMeldProfileId: legacySelection.openMeldProfileId,\n });\n await rm(selectionPath(cliContext.cliContextId), {\n force: true,\n }).catch(() => undefined);\n return legacySelection.openMeldProfileId;\n}\n\nexport async function clearSelectedOpenMeldProfileId(): Promise<void> {\n const cliContext = resolveCliContext();\n if (!cliContext) {\n await rm(fallbackSelectionPath(), { force: true }).catch(() => undefined);\n await rm(legacySelectionPath(), { force: true }).catch(() => undefined);\n return;\n }\n\n await writeCliContextState({\n selectedOpenMeldProfileId: null,\n });\n await rm(selectionPath(cliContext.cliContextId), { force: true });\n await rm(legacySelectionPath(), { force: true }).catch(() => undefined);\n}\n\nexport async function clearAllSelectedOpenMeldProfileIds(): Promise<ClearAllSelectedOpenMeldProfileIdsResult> {\n const sessionStates = await listCliContextStates();\n let clearedSessionSelections = 0;\n const failedSessionIds: string[] = [];\n\n for (const sessionState of sessionStates) {\n if (!sessionState.selectedOpenMeldProfileId) {\n continue;\n }\n try {\n const written = await writeCliContextState({\n sessionId: sessionState.sessionId,\n sessionSource: sessionState.cliContextSource,\n selectedOpenMeldProfileId: null,\n });\n if (written) {\n clearedSessionSelections += 1;\n continue;\n }\n } catch {\n // Best-effort cleanup: skip unwritable session state and continue logout.\n }\n failedSessionIds.push(sessionState.sessionId);\n }\n\n const removedFallbackSelection = await removeFileIfPresent(\n fallbackSelectionPath()\n );\n const removedLegacySelectionFile = await removeFileIfPresent(\n legacySelectionPath()\n );\n const removedLegacySessionSelectionDirectory = await removeDirectoryIfPresent(\n sessionSelectionDir()\n );\n\n return {\n clearedSessionSelections,\n failedSessionIds,\n removedFallbackSelection,\n removedLegacySelectionFile,\n removedLegacySessionSelectionDirectory,\n };\n}\n\nexport async function alignSelectedOpenMeldProfileStorage(): Promise<{\n migratedSessionSelections: number;\n removedLegacyDirectory: boolean;\n removedLegacySelectionFile: boolean;\n}> {\n let migratedSessionSelections = 0;\n const entryNames = await readdir(sessionSelectionDir()).catch(() => []);\n for (const entryName of entryNames) {\n if (!entryName.endsWith(\".selected-profile.json\")) {\n continue;\n }\n const raw = await readFile(\n join(sessionSelectionDir(), entryName),\n \"utf8\"\n ).catch(() => null);\n if (!raw) {\n continue;\n }\n const parsed = parseLegacySelectionPayload(raw);\n if (!parsed) {\n continue;\n }\n const written = await writeCliContextState({\n sessionId: parsed.sessionId,\n sessionSource: parsed.sessionSource,\n selectedOpenMeldProfileId: parsed.openMeldProfileId,\n });\n if (written) {\n migratedSessionSelections += 1;\n }\n }\n\n const legacyDirectoryExists = entryNames.length > 0;\n if (legacyDirectoryExists) {\n await rm(sessionSelectionDir(), { recursive: true, force: true });\n }\n await migrateLegacyFallbackSelection();\n const removedLegacySelectionFile = await removeLegacySelectionFile();\n return {\n migratedSessionSelections,\n removedLegacyDirectory: legacyDirectoryExists,\n removedLegacySelectionFile,\n };\n}\n\nfunction selectionPath(sessionId: string): string {\n return join(\n sessionSelectionDir(),\n `${toSafeSessionFile(sessionId)}.selected-profile.json`\n );\n}\n\nfunction sessionSelectionDir(): string {\n return join(runtimeDir(), \"selected-openmeld-profiles\");\n}\n\nfunction legacySelectionPath(): string {\n return join(openMeldRootDir(), \"auth\", \"selected-profile.json\");\n}\n\nfunction fallbackSelectionPath(): string {\n return join(runtimeDir(), \"selected-profile-fallback.json\");\n}\n\nasync function readLegacySelectionPayload(\n sessionId: string\n): Promise<SelectedOpenMeldProfileV1 | null> {\n const raw = await readFile(selectionPath(sessionId), \"utf8\").catch(\n () => null\n );\n if (!raw) {\n return null;\n }\n return parseLegacySelectionPayload(raw);\n}\n\nasync function readFallbackSelectionPayload(): Promise<string | null> {\n const raw = await readFile(fallbackSelectionPath(), \"utf8\").catch(() => null);\n if (!raw) {\n const legacyFallback = await readLegacyFallbackSelection();\n if (!legacyFallback) {\n return null;\n }\n await writeFallbackSelectionPayload(legacyFallback.openMeldProfileId);\n await rm(legacySelectionPath(), { force: true }).catch(() => undefined);\n return legacyFallback.openMeldProfileId;\n }\n return parseLegacySelectionPayload(raw)?.openMeldProfileId ?? null;\n}\n\nasync function writeFallbackSelectionPayload(\n openMeldProfileId: string\n): Promise<void> {\n await mkdir(runtimeDir(), { recursive: true });\n const payload: SelectedOpenMeldProfileV1 = {\n v: 1,\n sessionId: FALLBACK_SELECTION_SESSION_ID,\n sessionSource: FALLBACK_SELECTION_SOURCE,\n openMeldProfileId,\n updatedAt: new Date().toISOString(),\n };\n await writeFile(\n fallbackSelectionPath(),\n `${JSON.stringify(payload, null, 2)}\\n`,\n \"utf8\"\n );\n}\n\nfunction parseLegacySelectionPayload(\n raw: string\n): SelectedOpenMeldProfileV1 | null {\n try {\n const payload = JSON.parse(raw) as Partial<SelectedOpenMeldProfileV1>;\n if (payload.v !== 1) {\n return null;\n }\n const sessionId = normalizeOptionalString(payload.sessionId);\n const openMeldProfileId = normalizeOptionalString(\n payload.openMeldProfileId\n );\n if (!(sessionId && openMeldProfileId)) {\n return null;\n }\n return {\n v: 1,\n sessionId,\n sessionSource: normalizeOptionalString(payload.sessionSource) ?? \"manual\",\n openMeldProfileId,\n updatedAt:\n normalizeOptionalString(payload.updatedAt) ?? new Date(0).toISOString(),\n };\n } catch {\n return null;\n }\n}\n\nasync function readLegacyFallbackSelection(): Promise<SelectedOpenMeldProfileV1 | null> {\n const raw = await readFile(legacySelectionPath(), \"utf8\").catch(() => null);\n if (!raw) {\n return null;\n }\n const parsed = parseLegacySelectionPayload(raw);\n if (parsed?.sessionSource !== FALLBACK_SELECTION_SOURCE) {\n return null;\n }\n return parsed;\n}\n\nasync function migrateLegacyFallbackSelection(): Promise<void> {\n const legacyFallback = await readLegacyFallbackSelection();\n if (!legacyFallback) {\n return;\n }\n const existingFallback = await readFile(\n fallbackSelectionPath(),\n \"utf8\"\n ).catch(() => null);\n if (!existingFallback) {\n await writeFallbackSelectionPayload(legacyFallback.openMeldProfileId);\n }\n}\n\nasync function removeLegacySelectionFile(): Promise<boolean> {\n const raw = await readFile(legacySelectionPath(), \"utf8\").catch(() => null);\n if (!raw) {\n return false;\n }\n await rm(legacySelectionPath(), { force: true }).catch(() => undefined);\n return true;\n}\n\nfunction toSafeSessionFile(value: string): string {\n const hash = createHash(\"sha1\")\n .update(value, \"utf8\")\n .digest(\"hex\")\n .slice(0, SESSION_FILE_HASH_LENGTH);\n const safeBaseRaw = value.replace(/[^a-zA-Z0-9._-]+/g, \"_\");\n const safeBase = safeBaseRaw.length > 0 ? safeBaseRaw : \"session\";\n const maxBaseLength = Math.max(\n 1,\n SESSION_FILE_MAX_LENGTH - SESSION_FILE_HASH_LENGTH - 1\n );\n const truncatedBase = safeBase.slice(0, maxBaseLength);\n return `${truncatedBase}-${hash}`;\n}\n\nfunction normalizeOptionalString(value: unknown): string | null {\n const normalized = String(value ?? \"\").trim();\n return normalized.length > 0 ? normalized : null;\n}\n\nfunction normalizeRequiredString(value: unknown, field: string): string {\n const normalized = normalizeOptionalString(value);\n if (!normalized) {\n throw new Error(`${field} is required`);\n }\n return normalized;\n}\n\nasync function removeFileIfPresent(path: string): Promise<boolean> {\n const raw = await readFile(path, \"utf8\").catch(() => null);\n if (raw === null) {\n return false;\n }\n await rm(path, { force: true }).catch(() => undefined);\n return true;\n}\n\nasync function removeDirectoryIfPresent(path: string): Promise<boolean> {\n const directory = await stat(path).catch(() => null);\n if (!directory?.isDirectory()) {\n return false;\n }\n await rm(path, { recursive: true, force: true }).catch(() => undefined);\n return true;\n}\n","import {\n createAuthenticationError,\n resolveAuthenticationGuidanceFromError,\n resolveAuthenticationReasonFromState,\n} from \"../auth/auth-guidance\";\nimport { formatInlineOpenMeldCliCommands } from \"../runtime/cli-entry-command\";\nimport { getAuthSessionState } from \"./auth-session\";\nimport {\n clearSelectedOpenMeldProfileId,\n getSelectedOpenMeldProfileId,\n setSelectedOpenMeldProfileId,\n} from \"./openmeld-profile-selection\";\nimport {\n type OpenMeldProfile,\n type OpenMeldProfileKind,\n resolveOpenMeldProfile,\n resolveOpenMeldProfileByIdOrName,\n} from \"./openmeld-profiles-api\";\n\nexport type ResolveOpenMeldProfileInput = {\n openMeldProfileId?: string;\n profileKind?: OpenMeldProfileKind;\n allowUnauthenticated?: boolean;\n persistSelection?: boolean;\n allowDefaultFallback?: boolean;\n authAction?: string;\n};\n\nconst PROFILE_REQUIRED_ERROR_ROOT =\n \"no OpenMeld profile is selected for this terminal session yet\";\nconst PROFILE_REQUIRED_ERROR_MESSAGE = `${PROFILE_REQUIRED_ERROR_ROOT}; run \\`openmeld start\\` to choose one, or pass \\`--profile <id>\\`.`;\nconst SERVICE_TRACE_PROFILE_REQUIRED_ERROR_MESSAGE = `${PROFILE_REQUIRED_ERROR_ROOT}; dispatch trace needs an acting profile. Run \\`openmeld profile set <profile-id>\\` once, or pass \\`--profile <profile-id>\\` with this trace command. \\`--target-profile\\` only identifies the agent being traced.`;\nconst PROFILE_REQUIRED_ERROR_PREFIX =\n \"no OpenMeld profile is selected for this terminal session yet; run `\";\nconst PROFILE_REQUIRED_ERROR_SUFFIX =\n \" start` to choose one, or pass `--profile <id>`.\";\n\nexport function isSelectedOpenMeldProfileRequiredError(\n error: unknown\n): boolean {\n if (!(error instanceof Error)) {\n return false;\n }\n\n if (error.message === PROFILE_REQUIRED_ERROR_MESSAGE) {\n return true;\n }\n\n if (\n error.message.includes(PROFILE_REQUIRED_ERROR_ROOT) &&\n error.message.includes(\"--profile <\")\n ) {\n return true;\n }\n\n return (\n error.message.startsWith(PROFILE_REQUIRED_ERROR_PREFIX) &&\n error.message.endsWith(PROFILE_REQUIRED_ERROR_SUFFIX)\n );\n}\n\nexport async function resolveOpenMeldProfileOrNull(\n input: ResolveOpenMeldProfileInput = {}\n): Promise<OpenMeldProfile | null> {\n const explicitOpenMeldProfileId = normalizeOptionalString(\n input.openMeldProfileId\n );\n if (explicitOpenMeldProfileId) {\n return await resolveExplicitOpenMeldProfile(explicitOpenMeldProfileId, {\n profileKind: input.profileKind,\n allowUnauthenticated: input.allowUnauthenticated === true,\n persistSelection: input.persistSelection !== false,\n });\n }\n\n const selectedOpenMeldProfileId = await getSelectedOpenMeldProfileId();\n if (selectedOpenMeldProfileId) {\n const selectedProfile = await resolveSelectedOpenMeldProfile(\n selectedOpenMeldProfileId,\n {\n profileKind: input.profileKind,\n allowUnauthenticated: input.allowUnauthenticated === true,\n }\n );\n if (selectedProfile) {\n return selectedProfile;\n }\n }\n\n if (input.allowUnauthenticated === true) {\n const authState = await getAuthSessionState({\n validateRemote: false,\n });\n if (authState.state !== \"valid\") {\n return null;\n }\n }\n\n if (input.allowDefaultFallback !== true) {\n return null;\n }\n\n let fallbackProfile: OpenMeldProfile;\n try {\n fallbackProfile = await resolveOpenMeldProfile({\n profileKind: input.profileKind,\n });\n } catch (error) {\n if (input.allowUnauthenticated === true && isAuthRequiredError(error)) {\n return null;\n }\n throw error;\n }\n if (input.persistSelection !== false) {\n await setSelectedOpenMeldProfileId(fallbackProfile.openMeldProfileId);\n }\n return fallbackProfile;\n}\n\nasync function resolveExplicitOpenMeldProfile(\n openMeldProfileId: string,\n input: {\n profileKind?: OpenMeldProfileKind;\n allowUnauthenticated: boolean;\n persistSelection: boolean;\n }\n): Promise<OpenMeldProfile | null> {\n try {\n const profile = await resolveOpenMeldProfileByIdOrName({\n profileIdentifier: openMeldProfileId,\n profileKind: input.profileKind,\n });\n if (input.persistSelection) {\n await setSelectedOpenMeldProfileId(profile.openMeldProfileId);\n }\n return profile;\n } catch (error) {\n if (isAuthRequiredError(error) && input.allowUnauthenticated) {\n return null;\n }\n throw error;\n }\n}\n\nexport async function requireOpenMeldProfile(\n input: ResolveOpenMeldProfileInput = {}\n): Promise<OpenMeldProfile> {\n const profile = await resolveOpenMeldProfileOrNull(input);\n if (profile) {\n return profile;\n }\n\n const authState = await getAuthSessionState({\n validateRemote: false,\n });\n if (authState.state === \"valid\") {\n throw new Error(\n formatInlineOpenMeldCliCommands(\n resolveProfileRequiredErrorMessage(input.authAction)\n )\n );\n }\n const reason = resolveAuthenticationReasonFromState(authState.state);\n throw createAuthenticationError({\n reason: reason ?? \"required\",\n action: input.authAction,\n });\n}\n\nfunction resolveProfileRequiredErrorMessage(authAction?: string): string {\n if (authAction === \"reading a dispatch trace\") {\n return SERVICE_TRACE_PROFILE_REQUIRED_ERROR_MESSAGE;\n }\n\n return PROFILE_REQUIRED_ERROR_MESSAGE;\n}\n\nasync function resolveSelectedOpenMeldProfile(\n selectedOpenMeldProfileId: string,\n input: {\n profileKind?: OpenMeldProfileKind;\n allowUnauthenticated: boolean;\n }\n): Promise<OpenMeldProfile | null> {\n try {\n return await resolveOpenMeldProfile({\n openMeldProfileId: selectedOpenMeldProfileId,\n profileKind: input.profileKind,\n });\n } catch (error) {\n if (isAuthRequiredError(error)) {\n if (input.allowUnauthenticated) {\n return null;\n }\n throw error;\n }\n\n if (isProfileMissingError(error)) {\n await clearSelectedOpenMeldProfileId();\n return null;\n }\n\n throw error;\n }\n}\n\nfunction normalizeOptionalString(value: unknown): string | null {\n const normalized = String(value ?? \"\").trim();\n return normalized.length > 0 ? normalized : null;\n}\n\nfunction isAuthRequiredError(error: unknown): boolean {\n return resolveAuthenticationGuidanceFromError(error) !== null;\n}\n\nfunction isProfileMissingError(error: unknown): boolean {\n const code =\n error && typeof error === \"object\" && \"code\" in error\n ? String((error as { code?: unknown }).code ?? \"\")\n : \"\";\n if (code === \"profile.not_found\") {\n return true;\n }\n\n const message = error instanceof Error ? error.message : String(error ?? \"\");\n return message.includes(\"profile not found\");\n}\n","import { openMeldProfileIdSchema } from \"@openmeld/schemas\";\nimport { getSelectedOpenMeldProfileId } from \"./openmeld-profile-selection\";\nimport { resolveOpenMeldProfileByIdOrName } from \"./openmeld-profiles-api\";\n\nexport async function resolveViewProfileKey(\n inputProfile?: string\n): Promise<string | null> {\n const explicit = normalizeOptionalString(inputProfile);\n if (explicit) {\n const profileId = openMeldProfileIdSchema.safeParse(explicit);\n if (profileId.success) {\n return profileId.data;\n }\n const profile = await resolveOpenMeldProfileByIdOrName({\n profileIdentifier: explicit,\n }).catch(() => null);\n return profile?.openMeldProfileId ?? explicit;\n }\n\n const selected = await getSelectedOpenMeldProfileId();\n if (selected) {\n return selected;\n }\n\n return null;\n}\n\nfunction normalizeOptionalString(value: unknown): string | null {\n const normalized = String(value ?? \"\").trim();\n return normalized.length > 0 ? normalized : null;\n}\n","import { getProfileDefaultView } from \"../config/profile-view\";\nimport { resolveOpenMeldProfileOrNull } from \"../config/resolve-openmeld-profile\";\nimport {\n getConfiguredViewCustomization,\n type RuntimeViewCustomization,\n} from \"../config/runtime-config\";\nimport { resolveViewProfileKey } from \"../config/view-profile-key\";\nimport type { CliViewMode, RuntimeContext } from \"./types\";\n\nexport type { CliViewMode, RuntimeContext } from \"./types\";\n\nexport async function resolveRuntimeContext(input?: {\n view?: string;\n profile?: string;\n interactive?: boolean;\n}): Promise<RuntimeContext> {\n const viewOpenMeldProfileId = await resolveViewProfileKey(input?.profile);\n const configuredViewMode = await readConfiguredDefaultView(\n viewOpenMeldProfileId\n );\n const viewMode = parseCliViewMode(input?.view ?? configuredViewMode);\n const interactive = input?.interactive ?? isInteractiveSession();\n const viewCustomization = await readViewCustomization();\n\n if (viewMode === \"human\" || viewMode === \"agent\") {\n return {\n viewMode,\n resolvedView: viewMode,\n interactive,\n ...(viewOpenMeldProfileId\n ? { openMeldProfileId: viewOpenMeldProfileId }\n : {}),\n ...(viewCustomization ? { viewCustomization } : {}),\n };\n }\n\n const openMeldProfile = await resolveOpenMeldProfileOrNull({\n openMeldProfileId: input?.profile,\n allowUnauthenticated: true,\n persistSelection: false,\n allowDefaultFallback: false,\n }).catch(() => null);\n const resolvedView =\n openMeldProfile?.profileKind === \"agent\" ? \"agent\" : \"human\";\n const resolvedOpenMeldProfileId = openMeldProfile\n ? openMeldProfile.openMeldProfileId\n : viewOpenMeldProfileId;\n\n return {\n viewMode,\n resolvedView,\n interactive,\n ...(resolvedOpenMeldProfileId\n ? { openMeldProfileId: resolvedOpenMeldProfileId }\n : {}),\n ...(openMeldProfile?.profileKind\n ? { profileKind: openMeldProfile.profileKind }\n : {}),\n ...(viewCustomization ? { viewCustomization } : {}),\n };\n}\n\nexport function parseCliViewMode(value?: string): CliViewMode {\n const normalized = String(value ?? \"auto\")\n .trim()\n .toLowerCase();\n if (\n normalized === \"auto\" ||\n normalized === \"human\" ||\n normalized === \"agent\"\n ) {\n return normalized;\n }\n\n throw new Error(`invalid --view value: ${normalized} (use auto|human|agent)`);\n}\n\nfunction readViewCustomization(): Promise<RuntimeViewCustomization | null> {\n return getConfiguredViewCustomization().catch(() => null);\n}\n\nfunction readConfiguredDefaultView(\n openMeldProfileId?: string | null\n): Promise<CliViewMode> {\n if (!openMeldProfileId) {\n return Promise.resolve(\"auto\");\n }\n return getProfileDefaultView(openMeldProfileId).catch(() => \"auto\");\n}\n\nfunction isInteractiveSession(): boolean {\n return Boolean(process.stdin.isTTY && process.stdout.isTTY);\n}\n"],"mappings":";;;;;;;;;;;;AAyBA,eAAsB,sBACpB,mBAC6B;CAC7B,MAAM,8BACJ,2BAA2B,iBAAiB;CAC9C,MAAM,OAAO,MAAM,8BAA8B,2BAA2B;CAC5E,MAAM,MAAM,MAAM,SAAS,MAAM,MAAM,CAAC,CAAC,YAAY,IAAI;CACzD,IAAI,CAAC,KACH,OAAO;CAGT,IAAI;EACF,MAAM,SAAS,KAAK,MAAM,GAAG;EAC7B,IAAI,OAAO,MAAM,GACf,OAAO;EAET,MAAM,8BAA8B,2BAA2B,MAAM;EACrE,IAAI,CAAC,6BACH,OAAO;EAET,IACE,4BAA4B,QAAQ,sBACpC,6BACA;GACA,MAAM,GAAG,MAAM,EAAE,OAAO,KAAK,CAAC;GAC9B,OAAO;EACT;EACA,IAAI,4BAA4B,cAC9B,MAAM,qBAAqB,MAAM,4BAA4B,OAAO;EAEtE,OAAO,4BAA4B,QAAQ;CAC7C,QAAQ;EACN,OAAO;CACT;AACF;AAEA,eAAsB,sBAAsB,OAG1B;CAChB,MAAM,oBAAoB,2BAA2B,MAAM,iBAAiB;CAC5E,MAAM,OAAO,MAAM,8BAA8B,iBAAiB;CAElE,IAAI,MAAM,SAAS,QAAQ;EACzB,MAAM,GAAG,MAAM,EAAE,OAAO,KAAK,CAAC;EAC9B;CACF;CAEA,MAAM,qBAAqB,MAAM;EAC/B,GAAG;EACH;EACA,aAAa,MAAM;EACnB,4BAAW,IAAI,KAAK,EAAA,CAAE,YAAY;CACpC,CAAC;AACH;AAEA,eAAe,qBACb,MACA,SACe;CACf,MAAM,MAAM,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;CAC9C,MAAM,WAAW,GAAG,KAAK,OAAO,QAAQ,IAAI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