@cleocode/core 2026.9.25 → 2026.10.1

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 (236) hide show
  1. package/dist/admin/import-tasks.d.ts.map +1 -1
  2. package/dist/admin/import-tasks.js +5 -2
  3. package/dist/admin/import-tasks.js.map +1 -1
  4. package/dist/admin/import.d.ts.map +1 -1
  5. package/dist/admin/import.js +7 -2
  6. package/dist/admin/import.js.map +1 -1
  7. package/dist/build-provenance.json +2 -2
  8. package/dist/cloud/index.d.ts +1 -0
  9. package/dist/cloud/index.d.ts.map +1 -1
  10. package/dist/cloud/index.js +1 -0
  11. package/dist/cloud/index.js.map +1 -1
  12. package/dist/cloud/nexus-attach.d.ts +94 -0
  13. package/dist/cloud/nexus-attach.d.ts.map +1 -0
  14. package/dist/cloud/nexus-attach.js +192 -0
  15. package/dist/cloud/nexus-attach.js.map +1 -0
  16. package/dist/cloud/nexus-auth.d.ts +41 -4
  17. package/dist/cloud/nexus-auth.d.ts.map +1 -1
  18. package/dist/cloud/nexus-auth.js +151 -38
  19. package/dist/cloud/nexus-auth.js.map +1 -1
  20. package/dist/cloud/nexus-cloud-status.d.ts +132 -0
  21. package/dist/cloud/nexus-cloud-status.d.ts.map +1 -0
  22. package/dist/cloud/nexus-cloud-status.js +440 -0
  23. package/dist/cloud/nexus-cloud-status.js.map +1 -0
  24. package/dist/cloud/nexus-cloud.d.ts +179 -0
  25. package/dist/cloud/nexus-cloud.d.ts.map +1 -0
  26. package/dist/cloud/nexus-cloud.js +296 -0
  27. package/dist/cloud/nexus-cloud.js.map +1 -0
  28. package/dist/cloud/nexus-credentials.js +2 -2
  29. package/dist/cloud/nexus-credentials.js.map +1 -1
  30. package/dist/cloud/nexus-device.d.ts +834 -0
  31. package/dist/cloud/nexus-device.d.ts.map +1 -0
  32. package/dist/cloud/nexus-device.js +1727 -0
  33. package/dist/cloud/nexus-device.js.map +1 -0
  34. package/dist/cloud/nexus-enrol.d.ts +241 -0
  35. package/dist/cloud/nexus-enrol.d.ts.map +1 -0
  36. package/dist/cloud/nexus-enrol.js +1163 -0
  37. package/dist/cloud/nexus-enrol.js.map +1 -0
  38. package/dist/cloud/nexus-link.d.ts +10 -0
  39. package/dist/cloud/nexus-link.d.ts.map +1 -1
  40. package/dist/cloud/nexus-link.js +172 -11
  41. package/dist/cloud/nexus-link.js.map +1 -1
  42. package/dist/cloud/nexus-logout.d.ts +114 -0
  43. package/dist/cloud/nexus-logout.d.ts.map +1 -0
  44. package/dist/cloud/nexus-logout.js +429 -0
  45. package/dist/cloud/nexus-logout.js.map +1 -0
  46. package/dist/cloud/signing.d.ts +20 -0
  47. package/dist/cloud/signing.d.ts.map +1 -1
  48. package/dist/cloud/signing.js +14 -0
  49. package/dist/cloud/signing.js.map +1 -1
  50. package/dist/crypto/credentials.d.ts +61 -0
  51. package/dist/crypto/credentials.d.ts.map +1 -1
  52. package/dist/crypto/credentials.js +154 -58
  53. package/dist/crypto/credentials.js.map +1 -1
  54. package/dist/docs/export-document.js +1072 -227
  55. package/dist/docs/export-document.js.map +3 -3
  56. package/dist/doctor/dependency-cycles.d.ts +41 -0
  57. package/dist/doctor/dependency-cycles.d.ts.map +1 -0
  58. package/dist/doctor/dependency-cycles.js +39 -0
  59. package/dist/doctor/dependency-cycles.js.map +1 -0
  60. package/dist/doctor/index.d.ts +2 -0
  61. package/dist/doctor/index.d.ts.map +1 -1
  62. package/dist/doctor/index.js +1 -0
  63. package/dist/doctor/index.js.map +1 -1
  64. package/dist/doctor/row-identity.d.ts +11 -0
  65. package/dist/doctor/row-identity.d.ts.map +1 -1
  66. package/dist/doctor/row-identity.js +67 -9
  67. package/dist/doctor/row-identity.js.map +1 -1
  68. package/dist/error-catalog.d.ts.map +1 -1
  69. package/dist/error-catalog.js +4 -0
  70. package/dist/error-catalog.js.map +1 -1
  71. package/dist/error-registry.d.ts.map +1 -1
  72. package/dist/error-registry.js +8 -0
  73. package/dist/error-registry.js.map +1 -1
  74. package/dist/llm/plugin-facade.js +1200 -355
  75. package/dist/llm/plugin-facade.js.map +3 -3
  76. package/dist/nexus/workspace.d.ts.map +1 -1
  77. package/dist/nexus/workspace.js +54 -4
  78. package/dist/nexus/workspace.js.map +1 -1
  79. package/dist/orchestrate/lifecycle-ops.js +1 -1
  80. package/dist/orchestrate/lifecycle-ops.js.map +1 -1
  81. package/dist/orchestrate/pivot.d.ts.map +1 -1
  82. package/dist/orchestrate/pivot.js +4 -2
  83. package/dist/orchestrate/pivot.js.map +1 -1
  84. package/dist/orchestrate/query-ops.d.ts.map +1 -1
  85. package/dist/orchestrate/query-ops.js +3 -3
  86. package/dist/orchestrate/query-ops.js.map +1 -1
  87. package/dist/orchestrate/spawn-ops.js +1 -1
  88. package/dist/orchestrate/spawn-ops.js.map +1 -1
  89. package/dist/orchestration/index.js +1 -1
  90. package/dist/orchestration/index.js.map +1 -1
  91. package/dist/orchestration/lead-rollup.d.ts.map +1 -1
  92. package/dist/orchestration/lead-rollup.js +3 -3
  93. package/dist/orchestration/lead-rollup.js.map +1 -1
  94. package/dist/orchestration/parallel.js +1 -1
  95. package/dist/orchestration/parallel.js.map +1 -1
  96. package/dist/orchestration/wave-topic.d.ts +4 -2
  97. package/dist/orchestration/wave-topic.d.ts.map +1 -1
  98. package/dist/orchestration/wave-topic.js +6 -4
  99. package/dist/orchestration/wave-topic.js.map +1 -1
  100. package/dist/orchestration/waves.d.ts +2 -1
  101. package/dist/orchestration/waves.d.ts.map +1 -1
  102. package/dist/orchestration/waves.js +4 -3
  103. package/dist/orchestration/waves.js.map +1 -1
  104. package/dist/phases/index.d.ts.map +1 -1
  105. package/dist/phases/index.js +4 -2
  106. package/dist/phases/index.js.map +1 -1
  107. package/dist/selfimprove/fix-gen.js +1203 -358
  108. package/dist/selfimprove/fix-gen.js.map +3 -3
  109. package/dist/session/engine-ops.d.ts.map +1 -1
  110. package/dist/session/engine-ops.js +77 -49
  111. package/dist/session/engine-ops.js.map +1 -1
  112. package/dist/sessions/focus-state-store.d.ts +69 -23
  113. package/dist/sessions/focus-state-store.d.ts.map +1 -1
  114. package/dist/sessions/focus-state-store.js +113 -27
  115. package/dist/sessions/focus-state-store.js.map +1 -1
  116. package/dist/sessions/handoff.js +1 -1
  117. package/dist/sessions/handoff.js.map +1 -1
  118. package/dist/sessions/index.d.ts.map +1 -1
  119. package/dist/sessions/index.js +24 -13
  120. package/dist/sessions/index.js.map +1 -1
  121. package/dist/sessions/terminal-identity.d.ts +165 -17
  122. package/dist/sessions/terminal-identity.d.ts.map +1 -1
  123. package/dist/sessions/terminal-identity.js +341 -32
  124. package/dist/sessions/terminal-identity.js.map +1 -1
  125. package/dist/setup/sections/nexus-account.d.ts +8 -6
  126. package/dist/setup/sections/nexus-account.d.ts.map +1 -1
  127. package/dist/setup/sections/nexus-account.js +53 -9
  128. package/dist/setup/sections/nexus-account.js.map +1 -1
  129. package/dist/skills/orchestrator/startup.js +2 -2
  130. package/dist/skills/orchestrator/startup.js.map +1 -1
  131. package/dist/snapshot/index.d.ts +4 -0
  132. package/dist/snapshot/index.d.ts.map +1 -1
  133. package/dist/snapshot/index.js +50 -3
  134. package/dist/snapshot/index.js.map +1 -1
  135. package/dist/store/db-helpers.d.ts +15 -2
  136. package/dist/store/db-helpers.d.ts.map +1 -1
  137. package/dist/store/db-helpers.js +84 -3
  138. package/dist/store/db-helpers.js.map +1 -1
  139. package/dist/store/dependency-cycles.d.ts +164 -0
  140. package/dist/store/dependency-cycles.d.ts.map +1 -0
  141. package/dist/store/dependency-cycles.js +360 -0
  142. package/dist/store/dependency-cycles.js.map +1 -0
  143. package/dist/store/display-id-alias.d.ts +93 -37
  144. package/dist/store/display-id-alias.d.ts.map +1 -1
  145. package/dist/store/display-id-alias.js +590 -115
  146. package/dist/store/display-id-alias.js.map +1 -1
  147. package/dist/store/dual-scope-db.d.ts.map +1 -1
  148. package/dist/store/dual-scope-db.js +34 -7
  149. package/dist/store/dual-scope-db.js.map +1 -1
  150. package/dist/store/exodus/migrate.d.ts.map +1 -1
  151. package/dist/store/exodus/migrate.js +8 -1
  152. package/dist/store/exodus/migrate.js.map +1 -1
  153. package/dist/store/global-salt.d.ts +35 -0
  154. package/dist/store/global-salt.d.ts.map +1 -1
  155. package/dist/store/global-salt.js +136 -16
  156. package/dist/store/global-salt.js.map +1 -1
  157. package/dist/store/migration-sqlite.d.ts.map +1 -1
  158. package/dist/store/migration-sqlite.js +19 -11
  159. package/dist/store/migration-sqlite.js.map +1 -1
  160. package/dist/store/portable-bundle-scan.d.ts.map +1 -1
  161. package/dist/store/portable-bundle-scan.js +6 -0
  162. package/dist/store/portable-bundle-scan.js.map +1 -1
  163. package/dist/store/row-identity-registry.d.ts.map +1 -1
  164. package/dist/store/row-identity-registry.js +11 -3
  165. package/dist/store/row-identity-registry.js.map +1 -1
  166. package/dist/store/row-identity.d.ts +91 -1
  167. package/dist/store/row-identity.d.ts.map +1 -1
  168. package/dist/store/row-identity.js +276 -7
  169. package/dist/store/row-identity.js.map +1 -1
  170. package/dist/store/safety-data-accessor.d.ts +3 -2
  171. package/dist/store/safety-data-accessor.d.ts.map +1 -1
  172. package/dist/store/safety-data-accessor.js +5 -2
  173. package/dist/store/safety-data-accessor.js.map +1 -1
  174. package/dist/store/session-store.d.ts +63 -3
  175. package/dist/store/session-store.d.ts.map +1 -1
  176. package/dist/store/session-store.js +121 -8
  177. package/dist/store/session-store.js.map +1 -1
  178. package/dist/store/split-brain-import.d.ts.map +1 -1
  179. package/dist/store/split-brain-import.js +36 -0
  180. package/dist/store/split-brain-import.js.map +1 -1
  181. package/dist/store/sqlite-data-accessor.d.ts +50 -3
  182. package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
  183. package/dist/store/sqlite-data-accessor.js +246 -13
  184. package/dist/store/sqlite-data-accessor.js.map +1 -1
  185. package/dist/store/sync/replica.d.ts +34 -3
  186. package/dist/store/sync/replica.d.ts.map +1 -1
  187. package/dist/store/sync/replica.js +39 -2
  188. package/dist/store/sync/replica.js.map +1 -1
  189. package/dist/store/sync/schema.d.ts +6 -3
  190. package/dist/store/sync/schema.d.ts.map +1 -1
  191. package/dist/store/sync/schema.js +6 -3
  192. package/dist/store/sync/schema.js.map +1 -1
  193. package/dist/store/tasks-sqlite.d.ts.map +1 -1
  194. package/dist/store/tasks-sqlite.js +14 -2
  195. package/dist/store/tasks-sqlite.js.map +1 -1
  196. package/dist/store/umbrella-data-accessor.d.ts +3 -2
  197. package/dist/store/umbrella-data-accessor.d.ts.map +1 -1
  198. package/dist/store/umbrella-data-accessor.js +5 -2
  199. package/dist/store/umbrella-data-accessor.js.map +1 -1
  200. package/dist/system/health.d.ts +2 -0
  201. package/dist/system/health.d.ts.map +1 -1
  202. package/dist/system/health.js +54 -0
  203. package/dist/system/health.js.map +1 -1
  204. package/dist/task-work/index.d.ts.map +1 -1
  205. package/dist/task-work/index.js +9 -6
  206. package/dist/task-work/index.js.map +1 -1
  207. package/dist/tasks/analyze.d.ts.map +1 -1
  208. package/dist/tasks/analyze.js +3 -2
  209. package/dist/tasks/analyze.js.map +1 -1
  210. package/dist/tasks/evidence.d.ts +19 -1
  211. package/dist/tasks/evidence.d.ts.map +1 -1
  212. package/dist/tasks/evidence.js +79 -18
  213. package/dist/tasks/evidence.js.map +1 -1
  214. package/dist/tasks/infer-add-params.js +1 -1
  215. package/dist/tasks/infer-add-params.js.map +1 -1
  216. package/dist/tasks/task-context.d.ts.map +1 -1
  217. package/dist/tasks/task-context.js +3 -1
  218. package/dist/tasks/task-context.js.map +1 -1
  219. package/dist/tasks/task-import.d.ts.map +1 -1
  220. package/dist/tasks/task-import.js +11 -3
  221. package/dist/tasks/task-import.js.map +1 -1
  222. package/dist/tasks/task-next.d.ts +5 -1
  223. package/dist/tasks/task-next.d.ts.map +1 -1
  224. package/dist/tasks/task-next.js +7 -2
  225. package/dist/tasks/task-next.js.map +1 -1
  226. package/dist/validation/engine-ops.d.ts.map +1 -1
  227. package/dist/validation/engine-ops.js +3 -2
  228. package/dist/validation/engine-ops.js.map +1 -1
  229. package/dist/workgraph/scaffold-apply.d.ts.map +1 -1
  230. package/dist/workgraph/scaffold-apply.js +14 -5
  231. package/dist/workgraph/scaffold-apply.js.map +1 -1
  232. package/migrations/drizzle-cleo-project/20260930160000_t12886-dependency-cycle-guard/migration.sql +76 -0
  233. package/migrations/drizzle-cleo-project/20260930160000_t12886-dependency-cycle-guard/revert.sql +7 -0
  234. package/package.json +13 -13
  235. package/templates/CLEO-INJECTION.md +2 -2
  236. package/templates/CLEO-REFERENCE.md +1 -1
@@ -0,0 +1,440 @@
1
+ /**
2
+ * `cleo cloud status`: the agent's single verification call (cleo-nexus
3
+ * device contract v2.15, §4.4, E3 `GET /v1/status`, §3.7).
4
+ *
5
+ * It reads local facts first (the device credential, the project, its
6
+ * `.cleo/nexus-link.json` entry, the store's replica id), then asks E3, and
7
+ * returns `{ verdict, summary, local, remote, warnings }`:
8
+ *
9
+ * - no credential: verdict `not-signed-in`, and no network call is made;
10
+ * - the server's verdict is downgraded to `not-linked` when the current
11
+ * project has no local link entry or no bound replica;
12
+ * - unreachable: `E_NEXUS_UNREACHABLE`, its `publicDetails` (the envelope's `error.details`) carrying `local` and a
13
+ * summary whose remote fields are null ({@link NexusCloudOfflineError});
14
+ * - outside a project (or `--project` naming an unknown id) the device and
15
+ * account parts are still reported and the verdict comes from the device
16
+ * checks only.
17
+ *
18
+ * Every request is a GET. Getting the credential may still upgrade a 9.24
19
+ * session (E1) and retry unsettled logouts (E9/E10), as every device-credential
20
+ * command does (§3.4, §3.5). The replica id is read through
21
+ * `activeReplica(db, 'project')` on a read-only snapshot handle
22
+ * (`openCleoDbSnapshot`, no migrations, no pragmas): this command never binds
23
+ * a replica or writes `cleo.db`. When the store cannot be read that way,
24
+ * `replicaId` is `null` with `W_NEXUS_REPLICA_UNREADABLE` and the verdict is
25
+ * `attention`, never `not-linked`: unknown is not unbound.
26
+ *
27
+ * A server without E3 (404 `E_NOT_FOUND` on `/v1/status`) gets the same
28
+ * `NexusStatus` shape composed client-side from E2, E14 and E15 with the
29
+ * contract's check and verdict rules, plus a `W_NEXUS_STATUS_COMPOSED`
30
+ * warning.
31
+ *
32
+ * TODO(T12905): `cleo cloud status --report` (send presence before E3) is not
33
+ * implemented here; it is the one write this command will gain.
34
+ *
35
+ * @task T12871
36
+ * @epic T12323
37
+ */
38
+ import { accessSync, existsSync, constants as fsConstants } from 'node:fs';
39
+ import { join } from 'node:path';
40
+ import { NEXUS_PRESENCE_FRESH_SECONDS, nexusCloudProjectDetailSchema, nexusCloudStatusSchema, nexusCloudWhoamiSchema, } from '@cleocode/contracts';
41
+ import { resolveCleoDir } from '../paths.js';
42
+ import { NexusAccountError, resolveNexusApiUrl } from './nexus-auth.js';
43
+ import { assertNexusCloudDeviceMode, connectNexusCloud, currentNexusCloudProject, listNexusCloudReplicas, nexusQueryPath, } from './nexus-cloud.js';
44
+ import { FileNexusTokenStore, nexusOriginKey } from './nexus-credentials.js';
45
+ import { NexusDeviceStore, UnreadableNexusDevice } from './nexus-device.js';
46
+ /** Warning: the server has no E3, so the status was composed from E2, E14 and E15. */
47
+ export const W_NEXUS_STATUS_COMPOSED = 'W_NEXUS_STATUS_COMPOSED';
48
+ /** Warning: the current project has no `.cleo/nexus-link.json` entry for the origin. */
49
+ export const W_NEXUS_NOT_LINKED_LOCALLY = 'W_NEXUS_NOT_LINKED_LOCALLY';
50
+ /** Warning: the current project's store has no bound replica (or none could be read). */
51
+ export const W_NEXUS_NO_REPLICA = 'W_NEXUS_NO_REPLICA';
52
+ /** Warning: the store exists but could not be read read-only, so `replicaId` is null. */
53
+ export const W_NEXUS_REPLICA_UNREADABLE = 'W_NEXUS_REPLICA_UNREADABLE';
54
+ /** Warning: `--project` names an id the server does not show; only the device was checked. */
55
+ export const W_NEXUS_PROJECT_UNKNOWN = 'W_NEXUS_PROJECT_UNKNOWN';
56
+ /**
57
+ * `E_NEXUS_UNREACHABLE` from `cleo cloud status`, carrying the local facts
58
+ * (§4.4 "Offline"). Holds no secret.
59
+ */
60
+ export class NexusCloudOfflineError extends NexusAccountError {
61
+ /**
62
+ * Local state, a summary with every remote field null, and the warnings
63
+ * collected so far. Named `publicDetails`: the CLI forwards only this
64
+ * explicitly secret-free field into the error envelope.
65
+ */
66
+ publicDetails;
67
+ /**
68
+ * @param message - Human message.
69
+ * @param publicDetails - Local state, summary and warnings.
70
+ * @param fix - Remedy.
71
+ */
72
+ constructor(message, publicDetails, fix) {
73
+ super('E_NEXUS_UNREACHABLE', message, fix);
74
+ this.name = 'NexusCloudOfflineError';
75
+ this.publicDetails = publicDetails;
76
+ }
77
+ }
78
+ /**
79
+ * The verdict of a set of checks (E3 rules, §4.2): the first matching rule wins.
80
+ *
81
+ * @param checks - The checks that apply.
82
+ * @returns `not-registered`, `not-linked`, `attention` or `ok`.
83
+ */
84
+ export function nexusStatusVerdict(checks) {
85
+ const failed = (id) => checks.some((c) => c.id === id && !c.ok);
86
+ if (failed('device.registered') || failed('device.active'))
87
+ return 'not-registered';
88
+ if (failed('project.registered') || failed('replica.attached'))
89
+ return 'not-linked';
90
+ if (checks.some((c) => c.required && !c.ok))
91
+ return 'attention';
92
+ return 'ok';
93
+ }
94
+ /** The device and credential checks only (for "outside a project"). */
95
+ function deviceOnly(checks) {
96
+ return checks.filter((c) => c.id.startsWith('credential.') || c.id.startsWith('device.'));
97
+ }
98
+ /** An unreadable-store result with its warning. */
99
+ function unreadableStore(reason) {
100
+ return {
101
+ replicaId: null,
102
+ unreadable: true,
103
+ warning: {
104
+ code: W_NEXUS_REPLICA_UNREADABLE,
105
+ message: `could not read the project store read-only, so the replica id is unknown: ${reason}`,
106
+ },
107
+ };
108
+ }
109
+ /**
110
+ * The active replica id of a project store, read-only: a snapshot handle with
111
+ * no migrations and no pragmas, closed before returning. Never binds and never
112
+ * writes a row.
113
+ *
114
+ * SQLite side effect: a read-only open of a WAL-mode store needs the `-wal`
115
+ * and `-shm` sidecars, and SQLite creates them (empty) when they are missing
116
+ * and the directory is writable. Run as another user (for example under
117
+ * `sudo`), those sidecars would be left owned by that user, so when the store
118
+ * has no `-wal` and the directory is not writable by the caller the open is
119
+ * skipped and the store reported unreadable instead.
120
+ *
121
+ * @param projectRoot - Project root.
122
+ * @returns The replica id, whether the store was unreadable, and a warning.
123
+ */
124
+ export async function readNexusLocalReplicaId(projectRoot) {
125
+ // The project store path, as resolveDualScopeDbPath('project', root) builds it.
126
+ const dir = resolveCleoDir(projectRoot);
127
+ const path = join(dir, 'cleo.db');
128
+ if (!existsSync(path))
129
+ return { replicaId: null, unreadable: false, warning: null };
130
+ if (!existsSync(`${path}-wal`) && !isWritable(dir)) {
131
+ return unreadableStore('the store has no -wal file and its directory is not writable, so a read-only open would fail or leave sidecars behind');
132
+ }
133
+ const { openCleoDbSnapshot } = await import('../store/open-cleo-db.js');
134
+ const { activeReplica } = await import('../store/sync/replica.js');
135
+ let snap;
136
+ try {
137
+ snap = openCleoDbSnapshot(path, { readOnly: true, applyPragmas: false });
138
+ const replicaId = activeReplica(snap.db, 'project')?.replicaId ?? null;
139
+ return { replicaId, unreadable: false, warning: null };
140
+ }
141
+ catch (err) {
142
+ return unreadableStore(err instanceof Error ? err.message : String(err));
143
+ }
144
+ finally {
145
+ snap?.close();
146
+ }
147
+ }
148
+ /** True when the caller may write into `dir`. */
149
+ function isWritable(dir) {
150
+ try {
151
+ accessSync(dir, fsConstants.W_OK);
152
+ return true;
153
+ }
154
+ catch {
155
+ return false;
156
+ }
157
+ }
158
+ /** True when a device credential (or a 9.24 session to upgrade) is stored for the origin. */
159
+ async function hasLocalCredential(apiUrl, devices, sessions) {
160
+ const origin = nexusOriginKey(apiUrl);
161
+ for (const d of await devices.list()) {
162
+ if (d instanceof UnreadableNexusDevice || d.origin !== origin)
163
+ continue;
164
+ if (d.currentBearer() !== null || d.unseal().raceCandidate)
165
+ return true;
166
+ }
167
+ return (await sessions.get(apiUrl)) !== null;
168
+ }
169
+ /** A summary with no remote facts. */
170
+ function emptySummary(local) {
171
+ return {
172
+ signedIn: local.signedIn,
173
+ registered: false,
174
+ profile: local.profile,
175
+ linked: false,
176
+ replicaAttached: false,
177
+ devices: 0,
178
+ lastPresenceAt: null,
179
+ lastSyncAt: null,
180
+ headSeq: null,
181
+ openConflicts: null,
182
+ };
183
+ }
184
+ /** One check. */
185
+ function check(id, ok, required, detail) {
186
+ return { id, ok, required, detail };
187
+ }
188
+ /** E2's device and credential checks. */
189
+ function deviceChecks(whoami) {
190
+ const d = whoami.device;
191
+ const out = [
192
+ check('credential.valid', true, true, `${whoami.credential.kind} credential accepted`),
193
+ check('device.registered', d !== null, true, d ? `device ${d.deviceId}` : 'no device'),
194
+ check('device.active', d?.state === 'active', true, `state ${d?.state ?? 'none'}`),
195
+ ];
196
+ if (d && d.certificate !== undefined) {
197
+ out.push(check('device.certified', d.certificate !== null, false, 'device certificate'));
198
+ }
199
+ return out;
200
+ }
201
+ /** The replica row of `replicaId`, from E14's list or, when that was cut, from E15. */
202
+ async function findReplica(conn, projectId, replicaId, listed, truncated) {
203
+ const hit = listed.find((r) => r.replicaId === replicaId);
204
+ if (hit || !truncated)
205
+ return hit ?? null;
206
+ const all = await listNexusCloudReplicas(conn, projectId);
207
+ return all.replicas.find((r) => r.replicaId === replicaId) ?? null;
208
+ }
209
+ /**
210
+ * The `NexusStatus` of E3, composed from E2, E14 and E15 with the contract's
211
+ * check rules (§4.2 E3), for a server without E3.
212
+ *
213
+ * @param conn - Connection.
214
+ * @param projectId - Project to check, or `null`.
215
+ * @param replicaId - Replica to check, or `null`.
216
+ * @param now - Clock for presence freshness.
217
+ * @returns The composed status.
218
+ */
219
+ export async function composeNexusStatus(conn, projectId, replicaId, now = () => new Date()) {
220
+ const whoami = await conn.get('/v1/whoami', nexusCloudWhoamiSchema);
221
+ const checks = deviceChecks(whoami);
222
+ const base = { user: whoami.user, credential: whoami.credential, device: whoami.device };
223
+ if (projectId === null) {
224
+ return {
225
+ ...base,
226
+ project: null,
227
+ replica: null,
228
+ stream: null,
229
+ checks,
230
+ verdict: nexusStatusVerdict(checks),
231
+ };
232
+ }
233
+ const detail = await conn.find(`/v1/projects/${encodeURIComponent(projectId)}`, nexusCloudProjectDetailSchema);
234
+ checks.push(check('project.registered', detail !== null, true, detail ? 'visible' : 'not visible'));
235
+ if (detail === null) {
236
+ const project = {
237
+ projectId,
238
+ registered: false,
239
+ organizationId: null,
240
+ organizationName: null,
241
+ role: null,
242
+ };
243
+ return {
244
+ ...base,
245
+ project,
246
+ replica: null,
247
+ stream: null,
248
+ checks,
249
+ verdict: nexusStatusVerdict(checks),
250
+ };
251
+ }
252
+ const writable = detail.role === 'writer' || detail.role === 'owner';
253
+ const writeRequired = whoami.credential.kind === 'device' && whoami.credential.profile === 'device';
254
+ checks.push(check('project.writable', writable, writeRequired, `role ${detail.role}`));
255
+ let replica = null;
256
+ if (replicaId !== null) {
257
+ const row = await findReplica(conn, projectId, replicaId, detail.replicas, detail.truncated);
258
+ const mine = row !== null && row.deviceId === whoami.device?.deviceId;
259
+ replica = {
260
+ replicaId,
261
+ attached: mine,
262
+ attachedElsewhere: row !== null && !mine,
263
+ attachedAt: row?.attachedAt ?? null,
264
+ lastSyncAt: row?.lastSyncAt ?? null,
265
+ presenceAt: row?.presenceAt ?? null,
266
+ lastReplicaSeq: null,
267
+ };
268
+ const fresh = replica.presenceAt !== null &&
269
+ now().getTime() - Date.parse(replica.presenceAt) <= NEXUS_PRESENCE_FRESH_SECONDS * 1000;
270
+ const syncOn = row?.presence?.sync?.enabled === true;
271
+ checks.push(check('replica.attached', mine, true, mine ? 'attached from this device' : row ? 'attached from another device' : 'not attached'), check('presence.fresh', fresh, false, replica.presenceAt ?? 'no presence'), check('replica.synced', replica.lastSyncAt !== null, syncOn, replica.lastSyncAt ?? 'never synced'));
272
+ }
273
+ checks.push(check('conflicts.none', detail.openConflicts === 0, true, `${detail.openConflicts} open`));
274
+ return {
275
+ ...base,
276
+ project: {
277
+ projectId,
278
+ registered: true,
279
+ organizationId: detail.project.organizationId,
280
+ organizationName: detail.project.organizationName ?? null,
281
+ role: detail.role,
282
+ },
283
+ replica,
284
+ stream: detail.stream
285
+ ? { ...detail.stream, openConflicts: detail.openConflicts, devices: detail.devices }
286
+ : null,
287
+ checks,
288
+ verdict: nexusStatusVerdict(checks),
289
+ };
290
+ }
291
+ /** E3, or the composed status when the server has no E3. */
292
+ async function remoteStatus(conn, projectId, replicaId, now, warnings) {
293
+ const path = nexusQueryPath('/v1/status', {
294
+ projectId: projectId ?? undefined,
295
+ // E3 refuses a replicaId without a projectId.
296
+ replicaId: projectId !== null && replicaId !== null ? replicaId : undefined,
297
+ });
298
+ const status = await conn.find(path, nexusCloudStatusSchema);
299
+ if (status !== null)
300
+ return status;
301
+ warnings.push({
302
+ code: W_NEXUS_STATUS_COMPOSED,
303
+ message: 'the server has no GET /v1/status yet; the status was composed from /v1/whoami and the project reads',
304
+ });
305
+ return composeNexusStatus(conn, projectId, replicaId, now);
306
+ }
307
+ /** Apply the local downgrades (§4.4) to the remote verdict. */
308
+ function localVerdict(remote, project, isLocal, replica, warnings) {
309
+ if (remote.project !== null && !remote.project.registered && !isLocal) {
310
+ warnings.push({
311
+ code: W_NEXUS_PROJECT_UNKNOWN,
312
+ message: `project ${remote.project.projectId} is not registered or not visible; only the device was checked`,
313
+ });
314
+ return nexusStatusVerdict(deviceOnly(remote.checks));
315
+ }
316
+ if (!isLocal || project === null || (remote.verdict !== 'ok' && remote.verdict !== 'attention')) {
317
+ return remote.verdict;
318
+ }
319
+ if (project.link === null) {
320
+ warnings.push({
321
+ code: W_NEXUS_NOT_LINKED_LOCALLY,
322
+ message: 'this project has no .cleo/nexus-link.json entry for the origin; run `cleo project link`',
323
+ });
324
+ return 'not-linked';
325
+ }
326
+ if (replica.unreadable) {
327
+ // Unknown is not unbound: never conclude not-linked from an unreadable
328
+ // store (W_NEXUS_REPLICA_UNREADABLE already says why).
329
+ return 'attention';
330
+ }
331
+ if (replica.replicaId === null) {
332
+ warnings.push({
333
+ code: W_NEXUS_NO_REPLICA,
334
+ message: "this project's store has no bound replica; run `cleo project link`",
335
+ });
336
+ return 'not-linked';
337
+ }
338
+ return remote.verdict;
339
+ }
340
+ /** The summary of a remote status. */
341
+ function summaryOf(remote, local, project, isLocal) {
342
+ const ok = (id) => remote.checks.some((c) => c.id === id && c.ok);
343
+ const registeredRemotely = remote.project?.registered === true;
344
+ return {
345
+ signedIn: true,
346
+ registered: ok('device.registered') && ok('device.active'),
347
+ profile: remote.credential.profile ?? local.profile,
348
+ linked: registeredRemotely && (!isLocal || (project?.link ?? null) !== null),
349
+ replicaAttached: remote.replica?.attached === true,
350
+ devices: remote.stream?.devices.active ?? 0,
351
+ lastPresenceAt: remote.replica?.presenceAt ?? null,
352
+ lastSyncAt: remote.replica?.lastSyncAt ?? null,
353
+ headSeq: remote.stream?.headSeq ?? null,
354
+ openConflicts: remote.stream?.openConflicts ?? null,
355
+ };
356
+ }
357
+ /**
358
+ * `cleo cloud status [--project <id>]`.
359
+ *
360
+ * @param opts - Project, API URL, stores and test overrides.
361
+ * @returns The verdict, summary, local and remote facts, and warnings.
362
+ * @throws {NexusCloudOfflineError} `E_NEXUS_UNREACHABLE` when the server does not answer.
363
+ * @throws {NexusAccountError} `E_NEXUS_DEVICE_REQUIRED`, `E_NEXUS_ACCOUNT_AMBIGUOUS`,
364
+ * or a mapped API refusal (§4.0.4).
365
+ */
366
+ export async function getNexusCloudStatus(opts = {}) {
367
+ assertNexusCloudDeviceMode();
368
+ const apiUrl = resolveNexusApiUrl(opts.apiUrl);
369
+ const devices = opts.deviceStore ?? new NexusDeviceStore();
370
+ const sessions = opts.store ?? new FileNexusTokenStore();
371
+ const warnings = [];
372
+ const project = currentNexusCloudProject(apiUrl, opts.projectRoot);
373
+ const projectHere = project ? (project.link?.remoteProjectId ?? project.projectId) : null;
374
+ const isLocal = project !== null &&
375
+ (opts.projectId === undefined ||
376
+ opts.projectId === project.projectId ||
377
+ opts.projectId === project.link?.remoteProjectId);
378
+ // The current project (bare, or named by its local or remote id) is asked
379
+ // about by its linked remote id, like the bare command.
380
+ const projectId = isLocal ? projectHere : (opts.projectId ?? null);
381
+ let replica = { replicaId: null, unreadable: false, warning: null };
382
+ if (isLocal && project !== null) {
383
+ replica = await readNexusLocalReplicaId(project.root);
384
+ if (replica.warning)
385
+ warnings.push(replica.warning);
386
+ }
387
+ const replicaId = replica.replicaId;
388
+ const local = {
389
+ apiUrl,
390
+ signedIn: false,
391
+ nexusDeviceId: null,
392
+ profile: null,
393
+ projectId,
394
+ replicaId,
395
+ linkPath: isLocal && project?.link ? project.linkPath : null,
396
+ credentialsPath: devices.location,
397
+ };
398
+ const notSignedIn = () => ({
399
+ verdict: 'not-signed-in',
400
+ summary: emptySummary(local),
401
+ local,
402
+ remote: null,
403
+ warnings,
404
+ });
405
+ if (!(await hasLocalCredential(apiUrl, devices, sessions)))
406
+ return notSignedIn();
407
+ try {
408
+ const conn = await connectNexusCloud({
409
+ ...opts,
410
+ apiUrl,
411
+ deviceStore: devices,
412
+ store: sessions,
413
+ });
414
+ warnings.push(...conn.warnings);
415
+ local.signedIn = true;
416
+ local.nexusDeviceId = conn.device.deviceId;
417
+ local.profile = conn.device.unseal().current?.profile ?? null;
418
+ const remote = await remoteStatus(conn, projectId, replicaId, opts.now, warnings);
419
+ const verdict = localVerdict(remote, project, isLocal, replica, warnings);
420
+ return {
421
+ verdict,
422
+ summary: summaryOf(remote, local, project, isLocal),
423
+ local,
424
+ remote,
425
+ warnings,
426
+ };
427
+ }
428
+ catch (err) {
429
+ if (err instanceof NexusAccountError &&
430
+ err.code === 'E_NEXUS_NOT_SIGNED_IN' &&
431
+ !local.signedIn) {
432
+ return notSignedIn();
433
+ }
434
+ if (err instanceof NexusAccountError && err.code === 'E_NEXUS_UNREACHABLE') {
435
+ throw new NexusCloudOfflineError(err.message, { local, summary: emptySummary(local), warnings }, err.fix);
436
+ }
437
+ throw err;
438
+ }
439
+ }
440
+ //# sourceMappingURL=nexus-cloud-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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the
3
+ * device credential (cleo-nexus device contract v2.15, §4.2 E2, E5, E13, E14,
4
+ * E15; CLI mapping §4.4).
5
+ *
6
+ * - Every request is a `GET`. Nothing here writes to the server or to a
7
+ * project store. The one side effect is the one every device-credential
8
+ * command has: {@link ensureNexusDeviceCredential} retries unsettled
9
+ * logouts and upgrades a 9.24 session once (§3.4, §3.5).
10
+ * - Lists follow `nextCursor` (§4.0.3) with the largest page the server takes,
11
+ * up to a page budget, and report the server's `truncated` flags.
12
+ * - Failures are mapped by {@link nexusApiErrorToAccountError}, whose table
13
+ * lives in `@cleocode/contracts` (§4.0.4).
14
+ *
15
+ * No function here logs, and no result or error carries a token.
16
+ *
17
+ * @task T12871
18
+ * @epic T12323
19
+ */
20
+ import { type CloudDevicesResult, type CloudPaging, type CloudProjectShowResult, type CloudProjectsResult, type CloudWarning, type CloudWhoamiResult, type NexusCloudReplica, type NexusDeviceListState, type NexusProjectLink } from '@cleocode/contracts';
21
+ import { type ResponseSchema } from './http.js';
22
+ import { NexusDeviceStore, type SealedNexusDevice } from './nexus-device.js';
23
+ import { type NexusDeviceCredentialOptions } from './nexus-enrol.js';
24
+ /** Timeout of one `cleo cloud` request. */
25
+ export declare const NEXUS_CLOUD_TIMEOUT_MS = 15000;
26
+ /** Warning code for a non-fatal problem met while getting the device credential. */
27
+ export declare const W_NEXUS_CREDENTIAL = "W_NEXUS_CREDENTIAL";
28
+ /** Warning code: a list stopped at its page budget while the server had more. */
29
+ export declare const W_NEXUS_PAGE_LIMIT = "W_NEXUS_PAGE_LIMIT";
30
+ /** Warning code: a server ceiling cut a list (§4.0.3 `truncated`). */
31
+ export declare const W_NEXUS_TRUNCATED = "W_NEXUS_TRUNCATED";
32
+ /** Options shared by every `cleo cloud` read; all optional (tests inject them). */
33
+ export interface NexusCloudOptions extends NexusDeviceCredentialOptions {
34
+ /** Project root; defaults to the current project (when there is one). */
35
+ projectRoot?: string;
36
+ /** Per-request timeout; default {@link NEXUS_CLOUD_TIMEOUT_MS}. */
37
+ timeoutMs?: number;
38
+ /** Most pages a list follows; default {@link NEXUS_CLOUD_MAX_PAGES}. */
39
+ maxPages?: number;
40
+ /** Page size sent as `limit`; default {@link NEXUS_PAGE_LIMIT_MAX}. */
41
+ pageLimit?: number;
42
+ }
43
+ /** A signed-in, read-only connection to the API. Holds the bearer inside {@link Http} only. */
44
+ export interface NexusCloudConnection {
45
+ /** API origin. */
46
+ readonly apiUrl: string;
47
+ /** The device entry whose credential the requests carry. */
48
+ readonly device: SealedNexusDevice;
49
+ /** Warnings from getting the credential. */
50
+ readonly warnings: CloudWarning[];
51
+ /** `GET path`, parsed against `schema`; failures mapped per §4.0.4. */
52
+ get<T>(path: string, schema: ResponseSchema<T>): Promise<T>;
53
+ /** {@link NexusCloudConnection.get}, but a 404 `E_NOT_FOUND` answers `null`. */
54
+ find<T>(path: string, schema: ResponseSchema<T>): Promise<T | null>;
55
+ }
56
+ /** The current CLEO project, as far as the cloud reads need it. */
57
+ export interface NexusCloudProject {
58
+ /** Project root. */
59
+ readonly root: string;
60
+ /** The tracked project id (`.cleo/project.json`, legacy `.cleo/project-id`). */
61
+ readonly projectId: string;
62
+ /** The `.cleo/nexus-link.json` entry for the origin, if any. */
63
+ readonly link: NexusProjectLink | null;
64
+ /** Path of `.cleo/nexus-link.json` (whether or not it exists). */
65
+ readonly linkPath: string;
66
+ }
67
+ /**
68
+ * Refuse with `E_NEXUS_DEVICE_REQUIRED` when device credentials are off
69
+ * (`CLEO_NEXUS_DEVICE=0`): the cloud reads never fall back to a 9.24 session.
70
+ *
71
+ * @throws {NexusAccountError} `E_NEXUS_DEVICE_REQUIRED`.
72
+ */
73
+ export declare function assertNexusCloudDeviceMode(): void;
74
+ /** Wrap credential warnings (plain strings) as envelope warnings. */
75
+ export declare function nexusCredentialWarnings(warnings: readonly string[]): CloudWarning[];
76
+ /**
77
+ * Open a read-only connection with this machine's device credential.
78
+ *
79
+ * @param opts - API URL, account, stores and test overrides.
80
+ * @returns The connection.
81
+ * @throws {NexusAccountError} `E_NEXUS_DEVICE_REQUIRED`, `E_NEXUS_NOT_SIGNED_IN`,
82
+ * `E_NEXUS_ACCOUNT_AMBIGUOUS`, or an upgrade failure.
83
+ */
84
+ export declare function connectNexusCloud(opts?: NexusCloudOptions): Promise<NexusCloudConnection>;
85
+ /** A path with its query string; `undefined` values are left out. */
86
+ export declare function nexusQueryPath(path: string, query: Readonly<Record<string, string | number | undefined>>): string;
87
+ /** One page of a cursor-paged list. */
88
+ interface Page {
89
+ readonly nextCursor: string | null;
90
+ readonly truncated: boolean;
91
+ }
92
+ /**
93
+ * Follow `nextCursor` until the server has no more or the budget is spent.
94
+ *
95
+ * @param fetchPage - Fetch the page after `cursor` (`null` for the first).
96
+ * @param maxPages - Page budget (at least 1).
97
+ * @returns Every page fetched and the paging facts.
98
+ */
99
+ export declare function followNexusPages<P extends Page>(fetchPage: (cursor: string | null) => Promise<P>, maxPages: number): Promise<{
100
+ pages: P[];
101
+ paging: CloudPaging;
102
+ }>;
103
+ /** The warnings a list's paging facts call for. */
104
+ export declare function nexusPagingWarnings(what: string, paging: CloudPaging): CloudWarning[];
105
+ /**
106
+ * The current CLEO project, or `null` outside one (or without a project id).
107
+ *
108
+ * @param apiUrl - API origin whose link entry to read.
109
+ * @param projectRoot - Explicit project root; defaults to the current one.
110
+ * @returns The project, its id and link entry, or `null`.
111
+ */
112
+ export declare function currentNexusCloudProject(apiUrl: string, projectRoot?: string): NexusCloudProject | null;
113
+ /**
114
+ * `cleo cloud whoami`: E2 `GET /v1/whoami`.
115
+ *
116
+ * @param opts - API URL, account, stores and test overrides.
117
+ * @returns Who is calling: user, organizations, credential and device.
118
+ */
119
+ export declare function nexusCloudWhoami(opts?: NexusCloudOptions): Promise<CloudWhoamiResult>;
120
+ /** Options for {@link listNexusCloudDevices}. */
121
+ export interface NexusCloudDevicesOptions extends NexusCloudOptions {
122
+ /** `--state`; the server's default (`active` for device callers) when absent. */
123
+ state?: NexusDeviceListState;
124
+ }
125
+ /**
126
+ * `cleo cloud devices`: E5 `GET /v1/devices`, every page.
127
+ *
128
+ * @param opts - State filter, paging and test overrides.
129
+ * @returns Every device, newest first, with paging facts.
130
+ */
131
+ export declare function listNexusCloudDevices(opts?: NexusCloudDevicesOptions): Promise<CloudDevicesResult>;
132
+ /** Options for {@link listNexusCloudProjects}. */
133
+ export interface NexusCloudProjectsOptions extends NexusCloudOptions {
134
+ /** `--org`: only this organization's projects. */
135
+ organizationId?: string;
136
+ }
137
+ /**
138
+ * `cleo cloud projects`: E13 `GET /v1/projects`, every page.
139
+ *
140
+ * @param opts - Organization filter, paging and test overrides.
141
+ * @returns Every visible project, newest first, with paging facts.
142
+ */
143
+ export declare function listNexusCloudProjects(opts?: NexusCloudProjectsOptions): Promise<CloudProjectsResult>;
144
+ /**
145
+ * Every replica of a project from E15, following its cursors.
146
+ *
147
+ * @param conn - Connection.
148
+ * @param projectId - Project id.
149
+ * @param opts - Paging overrides.
150
+ * @returns The replicas, oldest attachment first, and the paging facts.
151
+ */
152
+ export declare function listNexusCloudReplicas(conn: NexusCloudConnection, projectId: string, opts?: Pick<NexusCloudOptions, 'maxPages' | 'pageLimit'>): Promise<{
153
+ replicas: NexusCloudReplica[];
154
+ paging: CloudPaging;
155
+ }>;
156
+ /** Options for {@link showNexusCloudProject}. */
157
+ export interface NexusCloudProjectShowOptions extends NexusCloudOptions {
158
+ /** The project; defaults to the current project. */
159
+ projectId?: string;
160
+ }
161
+ /**
162
+ * `cleo cloud projects show [<id>]`: E14 `GET /v1/projects/:projectId`. When
163
+ * E14 cut its replica list at 50, the full list is read from E15.
164
+ *
165
+ * @param opts - Project id (default: the current project), paging and test overrides.
166
+ * @returns The project detail.
167
+ * @throws {NexusAccountError} `E_NEXUS_NOT_A_PROJECT` with no id outside a
168
+ * project; `E_NEXUS_REQUEST_FAILED` for an unknown or invisible project.
169
+ */
170
+ export declare function showNexusCloudProject(opts?: NexusCloudProjectShowOptions): Promise<CloudProjectShowResult>;
171
+ /**
172
+ * The device credential store's location, for reports (never its contents).
173
+ *
174
+ * @param store - The store in use, if injected.
175
+ * @returns Absolute path of `nexus-device.json`.
176
+ */
177
+ export declare function nexusCloudCredentialsPath(store?: NexusDeviceStore): string;
178
+ export {};
179
+ //# sourceMappingURL=nexus-cloud.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nexus-cloud.d.ts","sourceRoot":"","sources":["../../src/cloud/nexus-cloud.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EAGtB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAMtB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAoC,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAElF,OAAO,EAAwB,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACnG,OAAO,EAEL,KAAK,4BAA4B,EAElC,MAAM,kBAAkB,CAAC;AAG1B,2CAA2C;AAC3C,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C,oFAAoF;AACpF,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD,iFAAiF;AACjF,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAErD,mFAAmF;AACnF,MAAM,WAAW,iBAAkB,SAAQ,4BAA4B;IACrE,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,+FAA+F;AA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