@astrale-os/cli 0.8.0-alpha.0 → 0.8.1-alpha.2

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 (317) hide show
  1. package/README.md +4 -1
  2. package/dist/astrale.js +62968 -41240
  3. package/dist/public/connect-core.js +55030 -0
  4. package/dist/public/keys/index.js +45631 -0
  5. package/dist/public/paths/index.js +43990 -0
  6. package/dist/types/admin/instance/model.d.ts +40 -0
  7. package/dist/types/connect-core.d.ts +22 -0
  8. package/dist/types/connection/auth.d.ts +33 -0
  9. package/dist/types/errors.d.ts +23 -0
  10. package/dist/types/identity/registry.d.ts +25 -0
  11. package/dist/types/keys/algorithm.d.ts +6 -0
  12. package/dist/types/keys/credential.d.ts +21 -0
  13. package/dist/types/keys/index.d.ts +4 -0
  14. package/dist/types/keys/pair.d.ts +34 -0
  15. package/dist/types/lib/admin-target.d.ts +74 -0
  16. package/dist/types/lib/ca-fetch.d.ts +2 -0
  17. package/dist/types/lib/config.d.ts +71 -0
  18. package/dist/types/lib/format.d.ts +1 -0
  19. package/dist/types/lib/idp-session.d.ts +33 -0
  20. package/dist/types/lib/idp.d.ts +397 -0
  21. package/dist/types/lib/instance-target.d.ts +36 -0
  22. package/dist/types/lib/instance.d.ts +186 -0
  23. package/dist/types/lib/log.d.ts +30 -0
  24. package/dist/types/lib/login-flow.d.ts +49 -0
  25. package/dist/types/lib/meta.d.ts +36 -0
  26. package/dist/types/lib/output.d.ts +83 -0
  27. package/dist/types/lib/table.d.ts +18 -0
  28. package/dist/types/lib/validation.d.ts +11 -0
  29. package/dist/types/paths/index.d.ts +2 -0
  30. package/dist/types/state/exchange-credentials.d.ts +25 -0
  31. package/dist/types/state/files.d.ts +9 -0
  32. package/dist/types/state/identities.d.ts +42 -0
  33. package/dist/types/state/index.d.ts +8 -0
  34. package/dist/types/state/paths.d.ts +32 -0
  35. package/package.json +30 -8
  36. package/src/admin/.spec/api.d.ts +3 -0
  37. package/src/admin/.spec/architecture.md +15 -0
  38. package/src/admin/.spec/icon.svg +3 -0
  39. package/src/admin/.spec/layout.ts +6 -0
  40. package/src/admin/catalog/.spec/api.d.ts +65 -0
  41. package/src/admin/catalog/.spec/architecture.md +6 -0
  42. package/src/admin/catalog/.spec/icon.svg +3 -0
  43. package/src/admin/catalog/.spec/layout.ts +6 -0
  44. package/src/admin/catalog/__tests__/client.test.ts +171 -0
  45. package/src/admin/catalog/client.ts +214 -0
  46. package/src/admin/catalog/index.ts +13 -0
  47. package/src/admin/catalog/model.ts +42 -0
  48. package/src/admin/catalog/tsconfig.json +8 -0
  49. package/src/admin/graph/.spec/api.d.ts +28 -0
  50. package/src/admin/graph/.spec/architecture.md +5 -0
  51. package/src/admin/graph/.spec/icon.svg +3 -0
  52. package/src/admin/graph/.spec/layout.ts +3 -0
  53. package/src/admin/graph/index.ts +6 -0
  54. package/src/admin/graph/nodes.ts +56 -0
  55. package/src/admin/index.ts +2 -0
  56. package/src/admin/instance/.spec/api.d.ts +66 -0
  57. package/src/admin/instance/.spec/architecture.md +10 -0
  58. package/src/admin/instance/.spec/icon.svg +3 -0
  59. package/src/admin/instance/.spec/layout.ts +6 -0
  60. package/src/admin/instance/__tests__/client.test.ts +289 -0
  61. package/src/admin/instance/client.ts +298 -0
  62. package/src/admin/instance/index.ts +16 -0
  63. package/src/admin/instance/model.ts +65 -0
  64. package/src/admin/instance/tsconfig.json +8 -0
  65. package/src/commands/__tests__/admin-instance.test.ts +3 -36
  66. package/src/commands/__tests__/call.test.ts +21 -68
  67. package/src/commands/__tests__/domain-install-owned.test.ts +26 -27
  68. package/src/commands/__tests__/domain-list.test.ts +2 -6
  69. package/src/commands/__tests__/logs.test.ts +50 -98
  70. package/src/commands/__tests__/ls.test.ts +21 -17
  71. package/src/commands/__tests__/read-commands.test.ts +171 -101
  72. package/src/commands/__tests__/view.test.ts +100 -51
  73. package/src/commands/admin/status.ts +3 -3
  74. package/src/commands/admin/use.ts +29 -6
  75. package/src/commands/auth/login.ts +1 -1
  76. package/src/commands/auth/logout.ts +4 -2
  77. package/src/commands/auth/status.ts +2 -2
  78. package/src/commands/auth/token.ts +2 -2
  79. package/src/commands/browser.ts +1 -1
  80. package/src/commands/call.ts +55 -91
  81. package/src/commands/describe.ts +52 -147
  82. package/src/commands/domain/install.ts +81 -50
  83. package/src/commands/domain/list.ts +4 -8
  84. package/src/commands/domain/publish.ts +9 -31
  85. package/src/commands/get.ts +32 -65
  86. package/src/commands/identity/__tests__/register.test.ts +93 -0
  87. package/src/commands/identity/create.ts +2 -2
  88. package/src/commands/identity/delete.ts +2 -2
  89. package/src/commands/identity/export.ts +7 -33
  90. package/src/commands/identity/import.ts +21 -70
  91. package/src/commands/identity/list.ts +2 -2
  92. package/src/commands/identity/register.ts +148 -117
  93. package/src/commands/identity/sync.ts +2 -2
  94. package/src/commands/identity/unsync.ts +2 -2
  95. package/src/commands/identity/use.ts +2 -2
  96. package/src/commands/identity/whoami.ts +2 -2
  97. package/src/commands/idp/add.ts +1 -1
  98. package/src/commands/idp/list.ts +1 -1
  99. package/src/commands/idp/refresh.ts +1 -1
  100. package/src/commands/idp/remove.ts +2 -2
  101. package/src/commands/idp/show.ts +1 -1
  102. package/src/commands/instance/active.ts +2 -2
  103. package/src/commands/instance/bookmark.ts +8 -2
  104. package/src/commands/instance/create.ts +1 -1
  105. package/src/commands/instance/delete.ts +4 -10
  106. package/src/commands/instance/forget.ts +1 -1
  107. package/src/commands/instance/list.ts +3 -3
  108. package/src/commands/instance/status.ts +5 -7
  109. package/src/commands/instance/use.ts +3 -3
  110. package/src/commands/logs.ts +152 -279
  111. package/src/commands/ls.ts +78 -204
  112. package/src/commands/mutate.ts +70 -139
  113. package/src/commands/query.ts +100 -278
  114. package/src/commands/session/analyze.ts +1 -1
  115. package/src/commands/session/list.ts +1 -1
  116. package/src/commands/setup.ts +1 -1
  117. package/src/commands/status.ts +1 -1
  118. package/src/commands/studio.ts +1 -1
  119. package/src/commands/token.ts +26 -21
  120. package/src/commands/update.ts +1 -1
  121. package/src/commands/use.ts +2 -3
  122. package/src/commands/view-serve.ts +1 -1
  123. package/src/commands/view.ts +67 -109
  124. package/src/connect-core.test.ts +38 -0
  125. package/src/connect-core.ts +42 -0
  126. package/src/connection/.spec/api.d.ts +111 -0
  127. package/src/connection/.spec/architecture.md +41 -0
  128. package/src/connection/.spec/capabilities/connection.ts +13 -0
  129. package/src/connection/.spec/examples/call.ts +7 -0
  130. package/src/connection/.spec/flows/command.ts +20 -0
  131. package/src/connection/.spec/flows/session.ts +61 -0
  132. package/src/connection/.spec/laws/connection.ts +181 -0
  133. package/src/connection/.spec/layout.ts +19 -0
  134. package/src/{kernel → connection}/__tests__/auth.test.ts +26 -2
  135. package/src/connection/__tests__/ca-fetch.test.ts +53 -0
  136. package/src/connection/__tests__/call.test.ts +17 -0
  137. package/src/connection/__tests__/credential.test.ts +109 -0
  138. package/src/connection/__tests__/errors.test.ts +96 -0
  139. package/src/connection/__tests__/exchange.test.ts +224 -0
  140. package/src/connection/__tests__/fixtures/localhost-cert.pem +19 -0
  141. package/src/connection/__tests__/fixtures/localhost-key.base64 +1 -0
  142. package/src/connection/__tests__/managed.test.ts +39 -0
  143. package/src/connection/__tests__/self.test.ts +51 -0
  144. package/src/connection/__tests__/session.test.ts +140 -0
  145. package/src/connection/__tests__/target.test.ts +93 -0
  146. package/src/{kernel → connection}/auth.ts +8 -8
  147. package/src/connection/call.ts +7 -0
  148. package/src/{kernel/run.ts → connection/command.ts} +22 -13
  149. package/src/connection/credential.ts +114 -0
  150. package/src/{kernel → connection}/errors.ts +32 -9
  151. package/src/connection/exchange.ts +274 -0
  152. package/src/connection/index.ts +8 -0
  153. package/src/connection/self.ts +120 -0
  154. package/src/connection/session.ts +176 -0
  155. package/src/connection/target.ts +111 -0
  156. package/src/connection/tsconfig.json +6 -0
  157. package/src/graph/.spec/api.d.ts +34 -0
  158. package/src/graph/.spec/laws/documents.ts +24 -0
  159. package/src/graph/.spec/laws/projection.ts +13 -0
  160. package/src/graph/.spec/layout.ts +6 -0
  161. package/src/graph/__tests__/mutation.test.ts +43 -0
  162. package/src/graph/__tests__/projection.test.ts +22 -0
  163. package/src/graph/__tests__/query.test.ts +154 -0
  164. package/src/graph/index.ts +3 -0
  165. package/src/graph/mutation.ts +18 -0
  166. package/src/graph/projection.ts +21 -0
  167. package/src/graph/query.ts +108 -0
  168. package/src/graph/tsconfig.json +6 -0
  169. package/src/identity/.history/ard/bootstrap-root-transfer.md +57 -0
  170. package/src/identity/.history/ard/domain-mediated-registration.md +36 -0
  171. package/src/identity/.spec/api.d.ts +124 -0
  172. package/src/identity/.spec/architecture.md +33 -0
  173. package/src/identity/.spec/capabilities/identity.ts +7 -0
  174. package/src/identity/.spec/flows/bootstrap-root.ts +79 -0
  175. package/src/identity/.spec/flows/domain-mediated-registration.ts +51 -0
  176. package/src/identity/.spec/flows/import.ts +29 -0
  177. package/src/identity/.spec/laws/identity.ts +56 -0
  178. package/src/identity/.spec/layout.ts +13 -0
  179. package/src/identity/.spec/schemas/identity-export-v1.schema.json +25 -0
  180. package/src/identity/__tests__/fixtures/registry-journey.ts +53 -0
  181. package/src/identity/__tests__/registration.test.ts +64 -0
  182. package/src/identity/__tests__/registry.test.ts +70 -0
  183. package/src/identity/__tests__/transfer.test.ts +198 -0
  184. package/src/identity/index.ts +23 -0
  185. package/src/identity/registration.ts +72 -0
  186. package/src/identity/registry.ts +172 -0
  187. package/src/identity/transfer.ts +187 -0
  188. package/src/identity/tsconfig.json +6 -0
  189. package/src/index.ts +1 -0
  190. package/src/keys/.spec/api.d.ts +74 -0
  191. package/src/keys/.spec/architecture.md +13 -0
  192. package/src/keys/.spec/laws/keys.ts +43 -0
  193. package/src/keys/.spec/layout.ts +6 -0
  194. package/src/keys/__tests__/algorithm.test.ts +39 -0
  195. package/src/keys/__tests__/keys.test.ts +168 -0
  196. package/src/keys/algorithm.ts +33 -0
  197. package/src/keys/credential.ts +112 -0
  198. package/src/keys/index.ts +14 -0
  199. package/src/keys/pair.ts +219 -0
  200. package/src/keys/tsconfig.json +6 -0
  201. package/src/lib/__tests__/admin-target.test.ts +67 -7
  202. package/src/lib/__tests__/binary.test.ts +2 -3
  203. package/src/lib/__tests__/command-dx.test.ts +2 -2
  204. package/src/lib/__tests__/config.test.ts +3 -2
  205. package/src/lib/__tests__/idp.test.ts +4 -6
  206. package/src/lib/__tests__/instance-target.test.ts +7 -4
  207. package/src/lib/__tests__/local-status.test.ts +1 -1
  208. package/src/lib/__tests__/log.test.ts +31 -0
  209. package/src/lib/__tests__/meta.test.ts +55 -0
  210. package/src/lib/__tests__/sdk-deps.test.ts +1 -1
  211. package/src/lib/__tests__/self.test.ts +8 -230
  212. package/src/lib/__tests__/use-target.test.ts +1 -1
  213. package/src/lib/__tests__/view-open-intent.test.ts +78 -104
  214. package/src/lib/__tests__/view-session.test.ts +99 -0
  215. package/src/lib/admin-domain.ts +39 -25
  216. package/src/lib/admin-instance.ts +38 -43
  217. package/src/lib/admin-target.ts +67 -13
  218. package/src/lib/binary.ts +13 -34
  219. package/src/lib/browser.ts +1 -1
  220. package/src/{kernel → lib}/ca-fetch.ts +35 -27
  221. package/src/lib/config.ts +1 -1
  222. package/src/lib/idp-session.ts +1 -1
  223. package/src/lib/idp.ts +3 -8
  224. package/src/lib/instance-target.ts +12 -8
  225. package/src/lib/instance.ts +34 -2
  226. package/src/lib/local-status.ts +2 -2
  227. package/src/lib/log.ts +3 -1
  228. package/src/lib/login-flow.ts +32 -5
  229. package/src/lib/meta.ts +15 -11
  230. package/src/lib/provision-instance.ts +4 -12
  231. package/src/lib/self.ts +5 -147
  232. package/src/lib/update.ts +1 -1
  233. package/src/lib/use-target.ts +1 -1
  234. package/src/lib/validation.ts +2 -2
  235. package/src/lib/view/open-intent.ts +7 -37
  236. package/src/lib/view/port-allocation.ts +1 -1
  237. package/src/lib/view/resolve.ts +52 -45
  238. package/src/lib/view/server.ts +16 -33
  239. package/src/lib/view/session.ts +51 -22
  240. package/src/paths/.spec/api.d.ts +13 -0
  241. package/src/paths/.spec/architecture.md +5 -0
  242. package/src/paths/.spec/layout.ts +3 -0
  243. package/src/paths/index.ts +13 -0
  244. package/src/program/.spec/api.d.ts +42 -0
  245. package/src/program/.spec/architecture.md +18 -0
  246. package/src/program/.spec/laws/program.ts +29 -0
  247. package/src/program/.spec/layout.ts +14 -0
  248. package/src/program/__tests__/program.test.ts +359 -0
  249. package/src/program/build.ts +190 -0
  250. package/src/program/command.ts +42 -0
  251. package/src/program/index.ts +2 -0
  252. package/src/program/options.ts +40 -0
  253. package/src/{registry.ts → program/registry.ts} +5 -1
  254. package/src/program/tsconfig.json +6 -0
  255. package/src/setup/steps/admin.ts +18 -3
  256. package/src/setup/steps/instance.ts +1 -1
  257. package/src/state/.spec/api.d.ts +133 -0
  258. package/src/state/.spec/architecture.md +31 -0
  259. package/src/state/.spec/capabilities/state.ts +7 -0
  260. package/src/state/.spec/flows/identity-update.ts +22 -0
  261. package/src/state/.spec/laws/state.ts +73 -0
  262. package/src/state/.spec/layout.ts +14 -0
  263. package/src/state/__tests__/exchange-credentials.test.ts +188 -0
  264. package/src/state/__tests__/files.test.ts +113 -0
  265. package/src/state/__tests__/fixtures/identity-transition.ts +37 -0
  266. package/src/state/__tests__/identities.test.ts +142 -0
  267. package/src/state/__tests__/paths.test.ts +27 -0
  268. package/src/state/exchange-credentials.ts +219 -0
  269. package/src/state/files.ts +129 -0
  270. package/src/state/identities.ts +236 -0
  271. package/src/state/index.ts +29 -0
  272. package/src/state/paths.ts +61 -0
  273. package/src/state/tsconfig.json +6 -0
  274. package/src/telemetry/__tests__/redact.test.ts +3 -3
  275. package/src/telemetry/__tests__/trigger.test.ts +1 -1
  276. package/src/telemetry/settings.ts +1 -1
  277. package/src/telemetry/store.ts +1 -1
  278. package/src/test-utils.ts +1 -1
  279. package/studio/client/dist/assets/elk-api-D0cBetPW.js +1 -0
  280. package/studio/client/dist/assets/elk-worker.min-C9JGDOE-.js +6312 -0
  281. package/studio/client/dist/assets/index-BQnJ5sgd.css +1 -0
  282. package/studio/client/dist/assets/index-ChOr3yP0.css +1 -0
  283. package/studio/client/dist/assets/index-Dspir4w7.js +81 -0
  284. package/studio/client/dist/assets/index-bVD2KJgz.js +8 -0
  285. package/studio/client/dist/index.html +2 -2
  286. package/studio/package.json +10 -1
  287. package/studio/server/introspect/extractor.ts +1 -1
  288. package/studio/server/state/views.test.ts +3 -7
  289. package/studio/server/state/views.ts +23 -30
  290. package/studio/tsconfig.json +23 -0
  291. package/tsconfig.json +1 -1
  292. package/viewer/dist/main.js +65 -39
  293. package/viewer/tsconfig.json +13 -0
  294. package/src/command.ts +0 -42
  295. package/src/commands/__tests__/help-contract.test.ts +0 -164
  296. package/src/kernel/__tests__/client-owned-lookup.test.ts +0 -51
  297. package/src/kernel/__tests__/errors.test.ts +0 -43
  298. package/src/kernel/__tests__/expand.test.ts +0 -123
  299. package/src/kernel/client.ts +0 -214
  300. package/src/kernel/expand.ts +0 -192
  301. package/src/kernel/graph.ts +0 -96
  302. package/src/kernel/index.ts +0 -29
  303. package/src/kernel/options.ts +0 -22
  304. package/src/kernel/types.ts +0 -14
  305. package/src/lib/__tests__/domain-identity.test.ts +0 -60
  306. package/src/lib/__tests__/fs-atomic.test.ts +0 -104
  307. package/src/lib/__tests__/identity.test.ts +0 -79
  308. package/src/lib/__tests__/keys.test.ts +0 -129
  309. package/src/lib/domain-identity.ts +0 -49
  310. package/src/lib/env.ts +0 -49
  311. package/src/lib/fs-atomic.ts +0 -126
  312. package/src/lib/identity.ts +0 -256
  313. package/src/lib/keys.ts +0 -294
  314. package/src/lib/paths.ts +0 -11
  315. package/src/program.ts +0 -213
  316. package/studio/client/dist/assets/index-BaqEuIQJ.js +0 -109
  317. package/studio/client/dist/assets/index-jRdExahh.css +0 -1
@@ -0,0 +1,397 @@
1
+ import { type JWTPayload } from 'jose';
2
+ import { z } from 'zod';
3
+ /**
4
+ * Thrown when a refresh succeeds but the IdP mints an access token whose `aud`
5
+ * does not match the one the caller requested. Distinct from a transport/grant
6
+ * failure: the session is *healthy*, the IdP simply will not issue that
7
+ * audience (e.g. WorkOS AuthKit ignores the `audience` param and stamps a fixed
8
+ * API audience per environment). Re-login does not help — callers must target
9
+ * an instance whose audience equals `actual`, or reconfigure the IdP/bookmark.
10
+ */
11
+ export declare class IdpAudienceMismatchError extends Error {
12
+ readonly requested: string;
13
+ readonly actual: string | undefined;
14
+ constructor(requested: string, actual: string | undefined);
15
+ }
16
+ /**
17
+ * A token-endpoint request that the IdP answered with an OAuth error (or that
18
+ * failed at the HTTP layer). Carries the structured OAuth `error` code so
19
+ * callers can tell a definitively dead grant (`invalid_grant`) from a
20
+ * transient outage — the message string alone cannot.
21
+ */
22
+ export declare class OAuthTokenError extends Error {
23
+ /** OAuth `error` code, e.g. `invalid_grant`. */
24
+ readonly code?: string;
25
+ /** OAuth `error_description`. */
26
+ readonly description?: string;
27
+ /** HTTP status of the token response. */
28
+ readonly status?: number;
29
+ constructor(args: {
30
+ code?: string;
31
+ description?: string;
32
+ status?: number;
33
+ });
34
+ }
35
+ export type RefreshFailureKind = 'session-ended' | 'org-rejected' | 'transient' | 'unknown';
36
+ /**
37
+ * Classify a `refreshSession` failure so callers only demand a re-login when
38
+ * the grant is actually dead. `org-rejected` = healthy session, wrong/stale
39
+ * org scope (re-login can't fix it); 5xx/429 and fetch-layer failures are
40
+ * transient — the cached session is likely still valid.
41
+ */
42
+ export declare function classifyRefreshFailure(e: unknown): RefreshFailureKind;
43
+ export declare const OidcMetadataSchema: z.ZodObject<{
44
+ issuer: z.ZodString;
45
+ authorization_endpoint: z.ZodOptional<z.ZodString>;
46
+ token_endpoint: z.ZodString;
47
+ jwks_uri: z.ZodString;
48
+ device_authorization_endpoint: z.ZodOptional<z.ZodString>;
49
+ revocation_endpoint: z.ZodOptional<z.ZodString>;
50
+ scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
51
+ grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
52
+ response_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
53
+ code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
54
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
55
+ issuer: z.ZodString;
56
+ authorization_endpoint: z.ZodOptional<z.ZodString>;
57
+ token_endpoint: z.ZodString;
58
+ jwks_uri: z.ZodString;
59
+ device_authorization_endpoint: z.ZodOptional<z.ZodString>;
60
+ revocation_endpoint: z.ZodOptional<z.ZodString>;
61
+ scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
62
+ grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
63
+ response_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
64
+ code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
65
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
66
+ issuer: z.ZodString;
67
+ authorization_endpoint: z.ZodOptional<z.ZodString>;
68
+ token_endpoint: z.ZodString;
69
+ jwks_uri: z.ZodString;
70
+ device_authorization_endpoint: z.ZodOptional<z.ZodString>;
71
+ revocation_endpoint: z.ZodOptional<z.ZodString>;
72
+ scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
73
+ grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
74
+ response_types_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
75
+ code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
76
+ }, z.ZodTypeAny, "passthrough">>;
77
+ export type OidcMetadata = z.infer<typeof OidcMetadataSchema>;
78
+ export declare const IdpClientConfigSchema: z.ZodObject<{
79
+ client_id: z.ZodOptional<z.ZodString>;
80
+ client_secret_env: z.ZodOptional<z.ZodString>;
81
+ redirect_uris: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
82
+ scope: z.ZodOptional<z.ZodString>;
83
+ public: z.ZodOptional<z.ZodBoolean>;
84
+ token_response: z.ZodOptional<z.ZodEnum<["oauth", "workos-authkit"]>>;
85
+ token_request_format: z.ZodOptional<z.ZodEnum<["form", "json"]>>;
86
+ workos_application_id: z.ZodOptional<z.ZodString>;
87
+ workos_application_type: z.ZodOptional<z.ZodEnum<["oauth", "m2m"]>>;
88
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
89
+ client_id: z.ZodOptional<z.ZodString>;
90
+ client_secret_env: z.ZodOptional<z.ZodString>;
91
+ redirect_uris: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
92
+ scope: z.ZodOptional<z.ZodString>;
93
+ public: z.ZodOptional<z.ZodBoolean>;
94
+ token_response: z.ZodOptional<z.ZodEnum<["oauth", "workos-authkit"]>>;
95
+ token_request_format: z.ZodOptional<z.ZodEnum<["form", "json"]>>;
96
+ workos_application_id: z.ZodOptional<z.ZodString>;
97
+ workos_application_type: z.ZodOptional<z.ZodEnum<["oauth", "m2m"]>>;
98
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
99
+ client_id: z.ZodOptional<z.ZodString>;
100
+ client_secret_env: z.ZodOptional<z.ZodString>;
101
+ redirect_uris: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
102
+ scope: z.ZodOptional<z.ZodString>;
103
+ public: z.ZodOptional<z.ZodBoolean>;
104
+ token_response: z.ZodOptional<z.ZodEnum<["oauth", "workos-authkit"]>>;
105
+ token_request_format: z.ZodOptional<z.ZodEnum<["form", "json"]>>;
106
+ workos_application_id: z.ZodOptional<z.ZodString>;
107
+ workos_application_type: z.ZodOptional<z.ZodEnum<["oauth", "m2m"]>>;
108
+ }, z.ZodTypeAny, "passthrough">>;
109
+ export type IdpClientConfig = z.infer<typeof IdpClientConfigSchema>;
110
+ export declare const IdpIndexEntrySchema: z.ZodObject<{
111
+ issuer: z.ZodString;
112
+ builtIn: z.ZodOptional<z.ZodBoolean>;
113
+ createdAt: z.ZodString;
114
+ updatedAt: z.ZodString;
115
+ }, "strip", z.ZodTypeAny, {
116
+ issuer: string;
117
+ builtIn?: boolean | undefined;
118
+ createdAt: string;
119
+ updatedAt: string;
120
+ }, {
121
+ issuer: string;
122
+ builtIn?: boolean | undefined;
123
+ createdAt: string;
124
+ updatedAt: string;
125
+ }>;
126
+ export declare const IdpStoreSchema: z.ZodObject<{
127
+ idps: z.ZodRecord<z.ZodString, z.ZodObject<{
128
+ issuer: z.ZodString;
129
+ builtIn: z.ZodOptional<z.ZodBoolean>;
130
+ createdAt: z.ZodString;
131
+ updatedAt: z.ZodString;
132
+ }, "strip", z.ZodTypeAny, {
133
+ issuer: string;
134
+ builtIn?: boolean | undefined;
135
+ createdAt: string;
136
+ updatedAt: string;
137
+ }, {
138
+ issuer: string;
139
+ builtIn?: boolean | undefined;
140
+ createdAt: string;
141
+ updatedAt: string;
142
+ }>>;
143
+ }, "strip", z.ZodTypeAny, {
144
+ idps: Record<string, {
145
+ issuer: string;
146
+ builtIn?: boolean | undefined;
147
+ createdAt: string;
148
+ updatedAt: string;
149
+ }>;
150
+ }, {
151
+ idps: Record<string, {
152
+ issuer: string;
153
+ builtIn?: boolean | undefined;
154
+ createdAt: string;
155
+ updatedAt: string;
156
+ }>;
157
+ }>;
158
+ export type IdpStore = z.infer<typeof IdpStoreSchema>;
159
+ export type IdpIndexEntry = z.infer<typeof IdpIndexEntrySchema>;
160
+ export declare const IdpSessionSchema: z.ZodObject<{
161
+ identity: z.ZodString;
162
+ idp: z.ZodString;
163
+ issuer: z.ZodString;
164
+ subject: z.ZodString;
165
+ audience: z.ZodOptional<z.ZodString>;
166
+ organizationId: z.ZodOptional<z.ZodString>;
167
+ access_token: z.ZodString;
168
+ id_token: z.ZodOptional<z.ZodString>;
169
+ refresh_token: z.ZodOptional<z.ZodString>;
170
+ token_type: z.ZodOptional<z.ZodString>;
171
+ scope: z.ZodOptional<z.ZodString>;
172
+ expires_at: z.ZodOptional<z.ZodString>;
173
+ claims: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
174
+ /**
175
+ * Access tokens by audience. WorkOS mints one `aud` per token, so a
176
+ * session juggling several instances would otherwise burn a (single-use)
177
+ * refresh-token rotation on every instance flip. The top-level
178
+ * `access_token`/`expires_at` stay the most recently minted token for
179
+ * back-compat with older CLI builds.
180
+ */
181
+ tokens: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
182
+ access_token: z.ZodString;
183
+ expires_at: z.ZodOptional<z.ZodString>;
184
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
185
+ access_token: z.ZodString;
186
+ expires_at: z.ZodOptional<z.ZodString>;
187
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
188
+ access_token: z.ZodString;
189
+ expires_at: z.ZodOptional<z.ZodString>;
190
+ }, z.ZodTypeAny, "passthrough">>>>;
191
+ updatedAt: z.ZodString;
192
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
193
+ identity: z.ZodString;
194
+ idp: z.ZodString;
195
+ issuer: z.ZodString;
196
+ subject: z.ZodString;
197
+ audience: z.ZodOptional<z.ZodString>;
198
+ organizationId: z.ZodOptional<z.ZodString>;
199
+ access_token: z.ZodString;
200
+ id_token: z.ZodOptional<z.ZodString>;
201
+ refresh_token: z.ZodOptional<z.ZodString>;
202
+ token_type: z.ZodOptional<z.ZodString>;
203
+ scope: z.ZodOptional<z.ZodString>;
204
+ expires_at: z.ZodOptional<z.ZodString>;
205
+ claims: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
206
+ /**
207
+ * Access tokens by audience. WorkOS mints one `aud` per token, so a
208
+ * session juggling several instances would otherwise burn a (single-use)
209
+ * refresh-token rotation on every instance flip. The top-level
210
+ * `access_token`/`expires_at` stay the most recently minted token for
211
+ * back-compat with older CLI builds.
212
+ */
213
+ tokens: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
214
+ access_token: z.ZodString;
215
+ expires_at: z.ZodOptional<z.ZodString>;
216
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
217
+ access_token: z.ZodString;
218
+ expires_at: z.ZodOptional<z.ZodString>;
219
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
220
+ access_token: z.ZodString;
221
+ expires_at: z.ZodOptional<z.ZodString>;
222
+ }, z.ZodTypeAny, "passthrough">>>>;
223
+ updatedAt: z.ZodString;
224
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
225
+ identity: z.ZodString;
226
+ idp: z.ZodString;
227
+ issuer: z.ZodString;
228
+ subject: z.ZodString;
229
+ audience: z.ZodOptional<z.ZodString>;
230
+ organizationId: z.ZodOptional<z.ZodString>;
231
+ access_token: z.ZodString;
232
+ id_token: z.ZodOptional<z.ZodString>;
233
+ refresh_token: z.ZodOptional<z.ZodString>;
234
+ token_type: z.ZodOptional<z.ZodString>;
235
+ scope: z.ZodOptional<z.ZodString>;
236
+ expires_at: z.ZodOptional<z.ZodString>;
237
+ claims: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
238
+ /**
239
+ * Access tokens by audience. WorkOS mints one `aud` per token, so a
240
+ * session juggling several instances would otherwise burn a (single-use)
241
+ * refresh-token rotation on every instance flip. The top-level
242
+ * `access_token`/`expires_at` stay the most recently minted token for
243
+ * back-compat with older CLI builds.
244
+ */
245
+ tokens: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
246
+ access_token: z.ZodString;
247
+ expires_at: z.ZodOptional<z.ZodString>;
248
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
249
+ access_token: z.ZodString;
250
+ expires_at: z.ZodOptional<z.ZodString>;
251
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
252
+ access_token: z.ZodString;
253
+ expires_at: z.ZodOptional<z.ZodString>;
254
+ }, z.ZodTypeAny, "passthrough">>>>;
255
+ updatedAt: z.ZodString;
256
+ }, z.ZodTypeAny, "passthrough">>;
257
+ export type IdpSession = z.infer<typeof IdpSessionSchema>;
258
+ export type TokenResponse = {
259
+ access_token?: string;
260
+ accessToken?: string;
261
+ id_token?: string;
262
+ idToken?: string;
263
+ refresh_token?: string;
264
+ refreshToken?: string;
265
+ token_type?: string;
266
+ scope?: string;
267
+ expires_in?: number;
268
+ expiresIn?: number;
269
+ user?: {
270
+ id?: string;
271
+ [key: string]: unknown;
272
+ };
273
+ organization_id?: string;
274
+ authentication_method?: string;
275
+ error?: string;
276
+ error_description?: string;
277
+ [key: string]: unknown;
278
+ };
279
+ export type DeviceAuthorizationResponse = {
280
+ device_code: string;
281
+ user_code?: string;
282
+ verification_uri?: string;
283
+ verification_uri_complete?: string;
284
+ expires_in: number;
285
+ interval?: number;
286
+ message?: string;
287
+ [key: string]: unknown;
288
+ };
289
+ export type IdpConfig = {
290
+ name: string;
291
+ entry: IdpIndexEntry;
292
+ metadata: OidcMetadata;
293
+ client: IdpClientConfig;
294
+ };
295
+ export declare const BUILTIN_WORKOS_IDP_NAME = "workos";
296
+ export declare function idpDir(name: string): string;
297
+ export declare function idpMetadataPath(name: string): string;
298
+ export declare function idpClientPath(name: string): string;
299
+ export declare function idpSessionPath(identityName: string): string;
300
+ export declare function readIdpStore(): Promise<IdpStore>;
301
+ export declare function writeIdpStore(store: IdpStore): Promise<void>;
302
+ export declare function readIdpConfig(name: string): Promise<IdpConfig>;
303
+ export declare function readIdpConfigOrBuiltin(name: string, opts?: {
304
+ clientId?: string;
305
+ persist?: boolean;
306
+ }): Promise<IdpConfig>;
307
+ export declare function listIdpConfigs(): Promise<IdpConfig[]>;
308
+ export declare function upsertIdpConfig(args: {
309
+ name: string;
310
+ metadata: OidcMetadata;
311
+ client?: IdpClientConfig;
312
+ builtIn?: boolean;
313
+ }): Promise<IdpConfig>;
314
+ export declare function removeIdpConfig(name: string): Promise<void>;
315
+ export declare function fetchOidcMetadata(issuer: string): Promise<OidcMetadata>;
316
+ export declare function workosAuthKitMetadata(apiHost?: string, clientId?: string): OidcMetadata;
317
+ export declare function builtinIdpConfig(name: string, clientIdOverride?: string, env?: NodeJS.ProcessEnv): IdpConfig | null;
318
+ export declare function workosClientIdFromEnv(env?: NodeJS.ProcessEnv): string | undefined;
319
+ export declare function postForm(url: string, params: URLSearchParams): Promise<TokenResponse>;
320
+ export declare function postJson(url: string, bodyInput: Record<string, string>): Promise<TokenResponse>;
321
+ export declare function tokenExpiresAt(token: TokenResponse): string | undefined;
322
+ export declare function decodeTokenClaims(token: string | undefined): JWTPayload | undefined;
323
+ export declare function tokenAudienceMatches(token: string | undefined, audience: string): boolean;
324
+ export declare function subjectFromToken(token: TokenResponse, fallback: string): string;
325
+ export declare function issuerFromToken(token: TokenResponse, fallback: string): string;
326
+ export declare function normalizeTokenResponse(token: TokenResponse): TokenResponse;
327
+ export declare function identityNameFromClaims(claims: JWTPayload | undefined, fallback: string): string;
328
+ export declare function saveIdpSession(session: IdpSession): Promise<void>;
329
+ export declare function readIdpSession(identityName: string): Promise<IdpSession | null>;
330
+ export declare function deleteIdpSession(identityName: string): Promise<void>;
331
+ export declare function listIdpSessions(): Promise<IdpSession[]>;
332
+ export declare function isSessionExpired(session: Pick<IdpSession, 'expires_at'> & {
333
+ access_token?: string;
334
+ }, skewMs?: number): boolean;
335
+ /**
336
+ * A still-fresh access token usable for `audience`, or undefined when a
337
+ * refresh is needed. Checks the per-audience `tokens` map first, then the
338
+ * top-level token's own `aud` claim. Without an `audience`, freshness of the
339
+ * top-level token is the only requirement.
340
+ */
341
+ export declare function accessTokenForAudience(session: IdpSession, audience?: string): string | undefined;
342
+ /**
343
+ * Fold a freshly minted access token into the per-audience map under every
344
+ * `aud` it carries, dropping entries that have already expired.
345
+ */
346
+ export declare function withCachedToken(tokens: IdpSession['tokens'], accessToken: string, expiresAt: string | undefined): IdpSession['tokens'];
347
+ export declare function requireClientId(idp: IdpConfig, override?: string): string;
348
+ export declare function resolveClientSecret(idp: IdpConfig, overrideEnv?: string): string | undefined;
349
+ export declare function refreshSession(identityName: string, session: IdpSession, opts?: {
350
+ readonly audience?: string;
351
+ readonly organizationId?: string;
352
+ }): Promise<IdpSession>;
353
+ export declare function requestClientCredentials(args: {
354
+ idp: IdpConfig;
355
+ clientId?: string;
356
+ clientSecretEnv?: string;
357
+ scope?: string;
358
+ audience?: string;
359
+ }): Promise<TokenResponse>;
360
+ export declare function requestDeviceAuthorization(args: {
361
+ idp: IdpConfig;
362
+ clientId?: string;
363
+ scope?: string;
364
+ audience?: string;
365
+ }): Promise<DeviceAuthorizationResponse>;
366
+ export declare function pollDeviceToken(args: {
367
+ idp: IdpConfig;
368
+ deviceCode: string;
369
+ clientId?: string;
370
+ clientSecretEnv?: string;
371
+ intervalSec?: number;
372
+ expiresInSec: number;
373
+ }): Promise<TokenResponse>;
374
+ export declare function exchangeAuthorizationCode(args: {
375
+ idp: IdpConfig;
376
+ code: string;
377
+ redirectUri: string;
378
+ codeVerifier?: string;
379
+ clientId?: string;
380
+ clientSecretEnv?: string;
381
+ }): Promise<TokenResponse>;
382
+ export type WorkosApplication = {
383
+ id: string;
384
+ client_id?: string;
385
+ name?: string;
386
+ application_type?: 'oauth' | 'm2m';
387
+ scopes?: string[];
388
+ redirect_uris?: Array<{
389
+ uri?: string;
390
+ default?: boolean;
391
+ }>;
392
+ uses_pkce?: boolean;
393
+ };
394
+ export declare function fetchWorkosApplication(args: {
395
+ apiKeyEnv: string;
396
+ app: string;
397
+ }): Promise<WorkosApplication>;
@@ -0,0 +1,36 @@
1
+ import type { InstanceInfo } from '../admin/instance/model';
2
+ import type { AstraleConfig } from './config';
3
+ import { type AdminTargetCommandOpts, type ResolvedAdminTarget } from './admin-target';
4
+ import { type InstanceStore } from './instance';
5
+ export type InstanceTargetRequest = {
6
+ source: 'active';
7
+ } | {
8
+ source: 'name';
9
+ name: string;
10
+ } | {
11
+ source: 'admin';
12
+ } | {
13
+ source: 'url';
14
+ url: string;
15
+ name?: string;
16
+ kernelIssuer?: string;
17
+ };
18
+ export type ResolvedInstanceTarget = {
19
+ name?: string;
20
+ source: 'bookmark' | 'managed' | 'admin' | 'url';
21
+ url: string;
22
+ kernelIssuer: string;
23
+ domainIssuer?: string;
24
+ defaultIdentity?: string;
25
+ caFile?: string;
26
+ };
27
+ export type ResolveInstanceTargetOpts = {
28
+ config: AstraleConfig;
29
+ instances?: InstanceStore;
30
+ admin?: AdminTargetCommandOpts;
31
+ managed?: (slug: string) => Promise<InstanceInfo>;
32
+ };
33
+ export declare function resolveInstanceTarget(request: InstanceTargetRequest, opts: ResolveInstanceTargetOpts): Promise<ResolvedInstanceTarget>;
34
+ export declare function couldBeConfiguredAdminInstance(identifier: string, config: AstraleConfig): boolean;
35
+ export declare function adminTargetToInstance(target: ResolvedAdminTarget): ResolvedInstanceTarget;
36
+ export declare function isManagedInstanceNotFound(error: unknown): boolean;
@@ -0,0 +1,186 @@
1
+ import { z } from 'zod';
2
+ import type { AstraleConfig } from './config';
3
+ import { type RegistryMode } from './validation';
4
+ export declare const InstanceKindSchema: z.ZodEnum<["bookmark"]>;
5
+ export type InstanceKind = z.infer<typeof InstanceKindSchema>;
6
+ export declare const InstanceEntrySchema: z.ZodObject<{
7
+ url: z.ZodOptional<z.ZodString>;
8
+ issuer: z.ZodOptional<z.ZodString>;
9
+ domainIssuer: z.ZodOptional<z.ZodString>;
10
+ createdAt: z.ZodOptional<z.ZodString>;
11
+ slug: z.ZodOptional<z.ZodString>;
12
+ name: z.ZodOptional<z.ZodString>;
13
+ kind: z.ZodOptional<z.ZodEnum<["bookmark"]>>;
14
+ mode: z.ZodOptional<z.ZodEnum<["local", "remote"]>>;
15
+ defaultIdentity: z.ZodOptional<z.ZodString>;
16
+ caFile: z.ZodOptional<z.ZodString>;
17
+ organizationId: z.ZodOptional<z.ZodString>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ url?: string | undefined;
20
+ issuer?: string | undefined;
21
+ domainIssuer?: string | undefined;
22
+ createdAt?: string | undefined;
23
+ slug?: string | undefined;
24
+ name?: string | undefined;
25
+ kind?: "bookmark" | undefined;
26
+ mode?: "local" | "remote" | undefined;
27
+ defaultIdentity?: string | undefined;
28
+ caFile?: string | undefined;
29
+ organizationId?: string | undefined;
30
+ }, {
31
+ url?: string | undefined;
32
+ issuer?: string | undefined;
33
+ domainIssuer?: string | undefined;
34
+ createdAt?: string | undefined;
35
+ slug?: string | undefined;
36
+ name?: string | undefined;
37
+ kind?: "bookmark" | undefined;
38
+ mode?: "local" | "remote" | undefined;
39
+ defaultIdentity?: string | undefined;
40
+ caFile?: string | undefined;
41
+ organizationId?: string | undefined;
42
+ }>;
43
+ export declare const InstanceStoreSchema: z.ZodObject<{
44
+ active: z.ZodString;
45
+ instances: z.ZodRecord<z.ZodString, z.ZodObject<{
46
+ url: z.ZodOptional<z.ZodString>;
47
+ issuer: z.ZodOptional<z.ZodString>;
48
+ domainIssuer: z.ZodOptional<z.ZodString>;
49
+ createdAt: z.ZodOptional<z.ZodString>;
50
+ slug: z.ZodOptional<z.ZodString>;
51
+ name: z.ZodOptional<z.ZodString>;
52
+ kind: z.ZodOptional<z.ZodEnum<["bookmark"]>>;
53
+ mode: z.ZodOptional<z.ZodEnum<["local", "remote"]>>;
54
+ defaultIdentity: z.ZodOptional<z.ZodString>;
55
+ caFile: z.ZodOptional<z.ZodString>;
56
+ organizationId: z.ZodOptional<z.ZodString>;
57
+ }, "strip", z.ZodTypeAny, {
58
+ url?: string | undefined;
59
+ issuer?: string | undefined;
60
+ domainIssuer?: string | undefined;
61
+ createdAt?: string | undefined;
62
+ slug?: string | undefined;
63
+ name?: string | undefined;
64
+ kind?: "bookmark" | undefined;
65
+ mode?: "local" | "remote" | undefined;
66
+ defaultIdentity?: string | undefined;
67
+ caFile?: string | undefined;
68
+ organizationId?: string | undefined;
69
+ }, {
70
+ url?: string | undefined;
71
+ issuer?: string | undefined;
72
+ domainIssuer?: string | undefined;
73
+ createdAt?: string | undefined;
74
+ slug?: string | undefined;
75
+ name?: string | undefined;
76
+ kind?: "bookmark" | undefined;
77
+ mode?: "local" | "remote" | undefined;
78
+ defaultIdentity?: string | undefined;
79
+ caFile?: string | undefined;
80
+ organizationId?: string | undefined;
81
+ }>>;
82
+ }, "strip", z.ZodTypeAny, {
83
+ active: string;
84
+ instances: Record<string, {
85
+ url?: string | undefined;
86
+ issuer?: string | undefined;
87
+ domainIssuer?: string | undefined;
88
+ createdAt?: string | undefined;
89
+ slug?: string | undefined;
90
+ name?: string | undefined;
91
+ kind?: "bookmark" | undefined;
92
+ mode?: "local" | "remote" | undefined;
93
+ defaultIdentity?: string | undefined;
94
+ caFile?: string | undefined;
95
+ organizationId?: string | undefined;
96
+ }>;
97
+ }, {
98
+ active: string;
99
+ instances: Record<string, {
100
+ url?: string | undefined;
101
+ issuer?: string | undefined;
102
+ domainIssuer?: string | undefined;
103
+ createdAt?: string | undefined;
104
+ slug?: string | undefined;
105
+ name?: string | undefined;
106
+ kind?: "bookmark" | undefined;
107
+ mode?: "local" | "remote" | undefined;
108
+ defaultIdentity?: string | undefined;
109
+ caFile?: string | undefined;
110
+ organizationId?: string | undefined;
111
+ }>;
112
+ }>;
113
+ export type InstanceEntry = z.infer<typeof InstanceEntrySchema>;
114
+ export type InstanceStore = z.infer<typeof InstanceStoreSchema>;
115
+ export type AddInstanceOpts = {
116
+ url?: string;
117
+ slug?: string;
118
+ name?: string;
119
+ kind?: InstanceKind;
120
+ mode?: RegistryMode;
121
+ issuer?: string;
122
+ domainIssuer?: string;
123
+ defaultIdentity?: string;
124
+ caFile?: string;
125
+ organizationId?: string;
126
+ };
127
+ export type ResolvedInstance = {
128
+ name: string;
129
+ kind: InstanceKind | 'managed';
130
+ url: string;
131
+ issuer?: string;
132
+ domainIssuer?: string;
133
+ createdAt?: string;
134
+ defaultIdentity?: string;
135
+ caFile?: string;
136
+ mode?: RegistryMode;
137
+ status?: string;
138
+ };
139
+ export declare function sanitizeStore(store: InstanceStore): {
140
+ store: InstanceStore;
141
+ changed: boolean;
142
+ };
143
+ /**
144
+ * Invalidate the one-process bookmark snapshot. Long-lived compatibility
145
+ * consumers call this before a read so CLI writes made by another process are
146
+ * observable; one-shot commands normally never need it.
147
+ */
148
+ export declare function resetInstancesMemo(): void;
149
+ export declare function readInstances(_config?: AstraleConfig, opts?: {
150
+ persist?: boolean;
151
+ }): Promise<InstanceStore>;
152
+ export declare function writeInstances(store: InstanceStore): Promise<void>;
153
+ export declare function assertNoCollision(store: InstanceStore, identifiers: string[], ignoreKey?: string): void;
154
+ export declare function resolveInstanceKey(store: InstanceStore, identifier: string): string | null;
155
+ export declare function addInstance(key: string, opts?: AddInstanceOpts): Promise<InstanceEntry>;
156
+ export declare function upsertInstance(key: string, opts?: AddInstanceOpts): Promise<{
157
+ entry: InstanceEntry;
158
+ created: boolean;
159
+ }>;
160
+ /**
161
+ * Bookmark an admin-managed instance under `key` (url = issuer = the
162
+ * normalized kernel URL). Reports the previous URL when an existing
163
+ * bookmark was repointed to a different kernel so callers can warn.
164
+ */
165
+ export declare function upsertManagedBookmark(key: string, slug: string, rawUrl: string, organizationId?: string): Promise<{
166
+ entry: InstanceEntry;
167
+ repointedFrom?: string;
168
+ }>;
169
+ export declare function removeInstance(key: string): Promise<void>;
170
+ export declare function setActive(identifier: string): Promise<string>;
171
+ export declare function clearActive(identifier: string): Promise<void>;
172
+ export declare function getActive(config?: AstraleConfig): Promise<InstanceEntry & {
173
+ name: string;
174
+ }>;
175
+ export declare function resolveInstance(identifier: string, config?: AstraleConfig): Promise<ResolvedInstance>;
176
+ export declare function resolveKernelUrl(opts: {
177
+ url?: string;
178
+ instance?: string;
179
+ }, config: AstraleConfig): Promise<string>;
180
+ /**
181
+ * The bookmarked org id for the instance matching `audience`'s origin —
182
+ * consulted before the router's eventually-consistent `/auth/org`.
183
+ */
184
+ export declare function orgIdForAudience(audience: string): Promise<string | undefined>;
185
+ export declare function normalizeInstanceKernelUrl(url: string): string;
186
+ export declare function normalizeIssuerUrl(url: string): string;
@@ -0,0 +1,30 @@
1
+ import { type Ora } from 'ora';
2
+ import { type RawOutputOpts } from './output';
3
+ export declare const log: {
4
+ info: (msg: string) => void;
5
+ success: (msg: string) => void;
6
+ warn: (msg: string) => void;
7
+ error: (msg: string) => void;
8
+ step: (msg: string) => void;
9
+ dim: (msg: string) => void;
10
+ };
11
+ /** Report an error with hint (when present) and exit. Commands that carry
12
+ * RawOutputOpts should pass them so machine consumers (--json/--raw/piped)
13
+ * get one structured JSON line on stderr instead of the pretty ✖ view. */
14
+ export declare function fatal(e: unknown, opts?: RawOutputOpts): never;
15
+ /** Shortcut for stub commands that aren't wired in v1 (§15). */
16
+ export declare function fatalNotImplemented(feature: string, hint?: string): never;
17
+ /**
18
+ * Run an async operation behind a spinner. Pass `enabled: false` for
19
+ * machine-readable output modes. Errors are rethrown after the spinner is
20
+ * stopped (✖ label failed).
21
+ *
22
+ * On success the spinner line is cleared — commands print their own result.
23
+ * Pass `opts.success` to instead persist a single final line
24
+ * (✔ <success text> <elapsed>) so a command ends on one line, not a
25
+ * spinner line + result line pair.
26
+ */
27
+ export declare function withSpinner<T>(label: string, enabled: boolean, fn: () => Promise<T>, opts?: {
28
+ success?: (result: T) => string;
29
+ }): Promise<T>;
30
+ export declare function spinner(text: string): Ora;