@astrale-os/cli 1.0.0-beta.1 → 1.0.0-beta.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 (180) hide show
  1. package/README.md +7 -11
  2. package/dist/astrale.js +3737 -3523
  3. package/dist/public/connect-core.js +396 -392
  4. package/dist/public/keys/index.js +371 -378
  5. package/dist/public/paths/index.js +371 -378
  6. package/dist/types/lib/idp.d.ts +6 -0
  7. package/dist/types/lib/meta.d.ts +2 -2
  8. package/package.json +6 -4
  9. package/src/admin/binding.ts +168 -0
  10. package/src/admin/catalog/__tests__/client.test.ts +2 -2
  11. package/src/admin/catalog/client.ts +4 -9
  12. package/src/admin/instance/__tests__/client.test.ts +2 -2
  13. package/src/admin/instance/client.ts +6 -11
  14. package/src/commands/__tests__/auth-login.test.ts +54 -1
  15. package/src/commands/__tests__/call.test.ts +5 -1
  16. package/src/commands/__tests__/domain-install-operation.test.ts +23 -7
  17. package/src/commands/__tests__/domain-install-owned.test.ts +5 -1
  18. package/src/commands/__tests__/domain-list.test.ts +83 -4
  19. package/src/commands/__tests__/install-identity-override.test.ts +30 -19
  20. package/src/commands/__tests__/studio-descriptor.test.ts +22 -0
  21. package/src/commands/__tests__/update.test.ts +23 -16
  22. package/src/commands/domain/install.ts +11 -15
  23. package/src/commands/domain/list.ts +17 -12
  24. package/src/commands/studio.ts +20 -0
  25. package/src/commands/update.ts +9 -5
  26. package/src/connection/__tests__/errors.test.ts +16 -12
  27. package/src/connection/__tests__/exchange.test.ts +6 -5
  28. package/src/connection/exchange.ts +5 -4
  29. package/src/lib/__tests__/domain-publication.test.ts +144 -0
  30. package/src/lib/__tests__/idp-session.test.ts +22 -0
  31. package/src/lib/__tests__/idp.test.ts +2 -0
  32. package/src/lib/__tests__/instance.test.ts +6 -0
  33. package/src/lib/__tests__/studio-server-deps.test.ts +53 -16
  34. package/src/lib/__tests__/update.test.ts +12 -0
  35. package/src/lib/domain-publication.ts +102 -0
  36. package/src/lib/idp.ts +5 -1
  37. package/src/lib/instance.ts +6 -1
  38. package/src/lib/login-flow.ts +13 -3
  39. package/src/lib/meta.ts +2 -2
  40. package/src/lib/update.ts +4 -4
  41. package/src/program/__tests__/program.test.ts +1 -1
  42. package/studio/client/dist/assets/{elk-api-D2xgMJvi.js → elk-api-lwhFo7vB.js} +1 -1
  43. package/studio/client/dist/assets/index-B-c-smo9.js +8 -0
  44. package/studio/client/dist/assets/index-BckHuAWk.js +81 -0
  45. package/studio/client/dist/assets/index-C4aNQ6dz.css +1 -0
  46. package/studio/client/dist/index.html +2 -2
  47. package/studio/package.json +3 -1
  48. package/studio/server/agent/bridge/stdio.ts +8 -1
  49. package/studio/server/agent/conversation.test.ts +10 -5
  50. package/studio/server/agent/conversation.ts +56 -8
  51. package/studio/server/agent/harness/codex/loadout.ts +18 -21
  52. package/studio/server/agent/harness/gateway/config.ts +20 -18
  53. package/studio/server/agent/harness/selection.ts +9 -1
  54. package/studio/server/agent/prompts/system.ts +3 -2
  55. package/studio/server/agent/prompts/turn.ts +13 -4
  56. package/studio/server/agent/run/completion.ts +2 -2
  57. package/studio/server/agent/run/preparation.ts +6 -5
  58. package/studio/server/agent/run/transcript.test.ts +35 -1
  59. package/studio/server/agent/run/transcript.ts +169 -3
  60. package/studio/server/agent/run/usage.test.ts +24 -0
  61. package/studio/server/agent/run/usage.ts +26 -1
  62. package/studio/server/api/canvas.ts +44 -0
  63. package/studio/server/api/comments.ts +85 -0
  64. package/studio/server/api/context.ts +61 -0
  65. package/studio/server/api/deployment.ts +39 -0
  66. package/studio/server/api/documents.ts +55 -0
  67. package/studio/server/api/domain.ts +59 -0
  68. package/studio/server/api/http.ts +45 -0
  69. package/studio/server/api/project.ts +57 -0
  70. package/studio/server/api/schema.ts +12 -0
  71. package/studio/server/api/views.ts +57 -0
  72. package/studio/server/api/workspace.ts +60 -0
  73. package/studio/server/api.test.ts +147 -0
  74. package/studio/server/api.ts +20 -422
  75. package/studio/server/cache.test.ts +111 -0
  76. package/studio/server/cache.ts +163 -9
  77. package/studio/server/cli-consumers.test.ts +494 -0
  78. package/studio/server/cli.test.ts +88 -0
  79. package/studio/server/cli.ts +240 -0
  80. package/studio/server/client-package.ts +25 -1
  81. package/studio/server/domain.test.ts +30 -2
  82. package/studio/server/domain.ts +14 -2
  83. package/studio/server/environment/dotenv-preview.test.ts +39 -0
  84. package/studio/server/environment/dotenv-preview.ts +27 -0
  85. package/studio/server/environment/files.test.ts +53 -0
  86. package/studio/server/{state/env.ts → environment/files.ts} +7 -48
  87. package/studio/server/{state → handoff}/copy.ts +21 -6
  88. package/studio/server/handoff/service.test.ts +22 -0
  89. package/studio/server/{state/handoff.ts → handoff/service.ts} +21 -14
  90. package/studio/server/instances/active.ts +72 -0
  91. package/studio/server/instances/deploy-record.test.ts +31 -0
  92. package/studio/server/instances/deploy-record.ts +37 -0
  93. package/studio/server/instances/deploy.ts +56 -0
  94. package/studio/server/{state/instance.test.ts → instances/probe.test.ts} +25 -21
  95. package/studio/server/instances/probe.ts +67 -0
  96. package/studio/server/instances/status.test.ts +12 -0
  97. package/studio/server/instances/status.ts +49 -0
  98. package/studio/server/introspect/anatomy/client-tree.ts +57 -0
  99. package/studio/server/introspect/anatomy/env-fields.ts +66 -0
  100. package/studio/server/introspect/anatomy/schema-definition.ts +53 -0
  101. package/studio/server/introspect/anatomy/source.ts +181 -0
  102. package/studio/server/introspect/anatomy/views/legacy.ts +232 -0
  103. package/studio/server/introspect/anatomy/views/routes.ts +105 -0
  104. package/studio/server/introspect/anatomy/views.ts +58 -0
  105. package/studio/server/introspect/anatomy-extras.test.ts +91 -4
  106. package/studio/server/introspect/anatomy-extras.ts +7 -726
  107. package/studio/server/introspect/anatomy.ts +46 -19
  108. package/studio/server/introspect/bundle.ts +15 -6
  109. package/studio/server/introspect/canonical-schema.test.ts +79 -0
  110. package/studio/server/introspect/canonical-schema.ts +80 -18
  111. package/studio/server/introspect/config-preview.test.ts +32 -0
  112. package/studio/server/introspect/config-preview.ts +119 -0
  113. package/studio/server/introspect/diff.test.ts +7 -11
  114. package/studio/server/introspect/diff.ts +28 -37
  115. package/studio/server/introspect/extractor.ts +8 -6
  116. package/studio/server/introspect/hash.ts +5 -2
  117. package/studio/server/introspect/overlay-tsmorph.ts +7 -1305
  118. package/studio/server/introspect/revision.test.ts +54 -0
  119. package/studio/server/introspect/revision.ts +49 -0
  120. package/studio/server/introspect/runtime.test.ts +63 -5
  121. package/studio/server/introspect/runtime.ts +49 -3
  122. package/studio/server/introspect/schema-ir-json.ts +181 -0
  123. package/studio/server/introspect/source-overlay/annotations.ts +14 -0
  124. package/studio/server/introspect/source-overlay/handlers.ts +681 -0
  125. package/studio/server/introspect/source-overlay/kernel-calls.ts +49 -0
  126. package/studio/server/introspect/source-overlay/project.ts +248 -0
  127. package/studio/server/introspect/source-overlay/spans.ts +360 -0
  128. package/studio/server/json.ts +46 -0
  129. package/studio/server/lifecycle.ts +5 -1
  130. package/studio/server/sse.test.ts +26 -0
  131. package/studio/server/sse.ts +4 -1
  132. package/studio/server/state/baseline.test.ts +212 -1
  133. package/studio/server/state/baseline.ts +145 -29
  134. package/studio/server/state/comments.test.ts +66 -1
  135. package/studio/server/state/comments.ts +173 -10
  136. package/studio/server/state/context.ts +34 -2
  137. package/studio/server/state/documents.ts +42 -1
  138. package/studio/server/state/integrations.ts +27 -1
  139. package/studio/server/state/layout.test.ts +34 -0
  140. package/studio/server/state/layout.ts +44 -17
  141. package/studio/server/state/settings.ts +29 -22
  142. package/studio/server/state/store.test.ts +122 -0
  143. package/studio/server/state/store.ts +66 -17
  144. package/studio/server/state/visibility.ts +22 -7
  145. package/studio/server/views/model.test.ts +57 -0
  146. package/studio/server/views/model.ts +66 -0
  147. package/studio/server/views/runtime.ts +40 -0
  148. package/studio/server/views/selection-repository.test.ts +31 -0
  149. package/studio/server/views/selection-repository.ts +60 -0
  150. package/studio/server/views/session.test.ts +73 -0
  151. package/studio/server/views/session.ts +166 -0
  152. package/studio/server/{state/views.test.ts → views/target.test.ts} +8 -159
  153. package/studio/server/views/target.ts +248 -0
  154. package/studio/server/watch.ts +1 -1
  155. package/studio/server/workspace/catalog.test.ts +17 -0
  156. package/studio/server/workspace/catalog.ts +43 -0
  157. package/studio/server/{state → workspace}/create.test.ts +1 -1
  158. package/studio/server/{state → workspace}/create.ts +1 -1
  159. package/studio/server/{state → workspace}/git.ts +1 -1
  160. package/studio/server/workspace/updates.ts +83 -0
  161. package/studio/server/workspace-state.ts +1 -1
  162. package/studio/shared/contracts/README.md +16 -0
  163. package/studio/shared/contracts/agent.ts +270 -0
  164. package/studio/shared/contracts/runtime.ts +50 -0
  165. package/studio/shared/contracts/schema.ts +462 -0
  166. package/studio/shared/contracts/surface.test.ts +319 -0
  167. package/studio/shared/contracts/workspace.ts +274 -0
  168. package/studio/shared/layout.test.ts +116 -0
  169. package/studio/shared/schema/identity.test.ts +58 -0
  170. package/studio/shared/schema/identity.ts +82 -0
  171. package/studio/shared/types.ts +11 -1099
  172. package/studio/tsconfig.json +1 -1
  173. package/viewer/dist/main.js +35 -35
  174. package/studio/client/dist/assets/index-BMdnsIJA.css +0 -1
  175. package/studio/client/dist/assets/index-D-vRV8w7.js +0 -8
  176. package/studio/client/dist/assets/index-LGSWRrk8.js +0 -81
  177. package/studio/server/state/catalog.ts +0 -117
  178. package/studio/server/state/instance.ts +0 -280
  179. package/studio/server/state/updates.ts +0 -63
  180. package/studio/server/state/views.ts +0 -535
@@ -0,0 +1,462 @@
1
+ /**
2
+ * Shared schema and introspection contracts.
3
+ *
4
+ * Studio's IR remains a lossy render projection. Canonical reference identity
5
+ * is owned by `../schema/identity`; SDK admission owns schema semantics.
6
+ */
7
+
8
+ import type { IrDefinitionKey, IrDefinitionRef, IrSchemaRef } from '../schema/identity'
9
+
10
+ export interface JsonSchema {
11
+ type?: string | string[]
12
+ enum?: (string | number | boolean | null)[]
13
+ properties?: Record<string, JsonSchema>
14
+ required?: string[]
15
+ items?: JsonSchema
16
+ additionalProperties?: boolean
17
+ minimum?: number
18
+ maximum?: number
19
+ format?: string
20
+ description?: string
21
+ $nodeRef?: unknown
22
+ $dataRef?: unknown
23
+ [k: string]: unknown
24
+ }
25
+
26
+ export type MethodInheritance = 'default' | 'abstract' | 'sealed'
27
+
28
+ /** Portable form of the DSL-owned canonical schema revision. */
29
+ export type SchemaRevision = `sha256:${string}`
30
+
31
+ /** Wire-format check only; SDK admission remains the semantic proof. */
32
+ export function isSchemaRevision(value: unknown): value is SchemaRevision {
33
+ return typeof value === 'string' && /^sha256:[0-9a-f]{64}$/.test(value)
34
+ }
35
+
36
+ /**
37
+ * Version of Studio's lossy canonical-schema -> render-IR projection. Persisted
38
+ * baselines must match this value before their IR can be compared.
39
+ */
40
+ export const STUDIO_SCHEMA_PROJECTION_VERSION = 1
41
+
42
+ export type IrCallableAuth = 'anonymous' | 'authenticated' | 'authorized'
43
+
44
+ export type IrCallableOutput =
45
+ | { mode: 'value'; schema: JsonSchema }
46
+ | { mode: 'stream'; item: JsonSchema }
47
+ | { mode: 'binary' }
48
+
49
+ export interface IrMethod {
50
+ name: string
51
+ /** Canonical callable input. Legacy projections expose only `params`. */
52
+ input?: JsonSchema
53
+ params: Record<string, JsonSchema>
54
+ /** Names required by canonical `input.required`; absent on legacy Methods. */
55
+ requiredParams?: string[]
56
+ /** Canonical discriminated output. Legacy projections expose only `returns`. */
57
+ output?: IrCallableOutput
58
+ returns: JsonSchema
59
+ static: boolean
60
+ inheritance: MethodInheritance
61
+ description?: string
62
+ auth?: IrCallableAuth
63
+ policy?: unknown
64
+ }
65
+
66
+ /** Standalone Domain Function projected into the Studio's callable vocabulary. */
67
+ export interface IrFunction {
68
+ name: string
69
+ input: JsonSchema
70
+ params: Record<string, JsonSchema>
71
+ /** Names required by canonical `input.required`. */
72
+ requiredParams?: string[]
73
+ output: IrCallableOutput
74
+ returns: JsonSchema
75
+ /** Standalone Functions have no receiver; these legacy-compatible fields let
76
+ * existing callable renderers consume them alongside static Methods. */
77
+ static: true
78
+ inheritance: 'default'
79
+ description?: string
80
+ auth?: IrCallableAuth
81
+ policy?: unknown
82
+ }
83
+
84
+ export interface IrInterface {
85
+ type: 'interface'
86
+ name: string
87
+ /** Canonical declaration owner/family; absent on legacy projections. */
88
+ origin?: string
89
+ family?: 'node' | 'edge' | 'both'
90
+ ref?: IrSchemaRef
91
+ extends?: string[]
92
+ extendsRefs?: IrSchemaRef[]
93
+ properties: Record<string, JsonSchema>
94
+ /** Canonical `properties.required`; absence, unlike null, encodes optionality. */
95
+ required?: string[]
96
+ methods: Record<string, IrMethod>
97
+ endpoints?: IrEndpoint[]
98
+ orientation?: 'directed' | 'undirected'
99
+ constraints?: { noSelf?: true; acyclic?: true }
100
+ description?: string
101
+ propertyMetadata?: Record<string, unknown>
102
+ /** Canonical data declaration; `mediaType` is required and extensions stay lossless. */
103
+ data?: { mediaType: string; [key: string]: unknown }
104
+ }
105
+
106
+ export interface IrEndpoint {
107
+ name: string
108
+ types: string[]
109
+ /** Exact accepted Definition coordinates. `types` remains for existing UI consumers. */
110
+ refs?: IrSchemaRef[]
111
+ /** declared multiplicity for this end; max:null = unbounded ("many"). Absent ⇒ unconstrained. */
112
+ cardinality?: { min: number; max: number | null }
113
+ }
114
+
115
+ export interface IrClass {
116
+ type: 'node' | 'edge'
117
+ name: string
118
+ /** Canonical declaration owner/ref; absent on legacy projections. */
119
+ origin?: string
120
+ ref?: IrSchemaRef
121
+ implements?: string[]
122
+ implementsRefs?: IrSchemaRef[]
123
+ /** edges only: the two (source,target) endpoints with role names + allowed types */
124
+ endpoints?: IrEndpoint[]
125
+ orientation?: 'directed' | 'undirected'
126
+ constraints?: { noSelf?: true; acyclic?: true }
127
+ properties: Record<string, JsonSchema>
128
+ /** Canonical `properties.required`; absence, unlike null, encodes optionality. */
129
+ required?: string[]
130
+ methods: Record<string, IrMethod>
131
+ /** class-level icon: raw (lucide-style) SVG markup, `stroke="currentColor"` */
132
+ icon?: string
133
+ description?: string
134
+ propertyMetadata?: Record<string, unknown>
135
+ /** Canonical data declaration; `mediaType` is required and extensions stay lossless. */
136
+ data?: { mediaType: string; [key: string]: unknown }
137
+ policies?: Record<string, IrSchemaRef>
138
+ }
139
+
140
+ export interface IrImportDescriptor {
141
+ origin: string
142
+ definition: 'interface' | 'class'
143
+ ref?: IrDefinitionRef
144
+ /** Canonical qualified identity; absent on legacy import descriptors. */
145
+ key?: IrDefinitionKey
146
+ }
147
+
148
+ export type IrViewTarget = { kind: 'domain' } | { kind: 'definition'; definitions: IrSchemaRef[] }
149
+
150
+ export interface IrView {
151
+ name: string
152
+ target: IrViewTarget
153
+ auth: 'required' | 'optional' | 'public'
154
+ description?: string
155
+ }
156
+
157
+ export interface SchemaIR {
158
+ version: string
159
+ domain: string
160
+ /** Canonical document format; absent on legacy projections. */
161
+ format?: 'astrale.dsl'
162
+ types: Record<string, JsonSchema>
163
+ interfaces: Record<string, IrInterface>
164
+ classes: Record<string, IrClass>
165
+ imports: Record<string, IrImportDescriptor>
166
+ /**
167
+ * Canonical authoritative import index, keyed by `origin:kind.name`.
168
+ * `imports` remains the unambiguous short-name compatibility index.
169
+ */
170
+ importsByKey?: Record<IrDefinitionKey, IrImportDescriptor>
171
+ /** Exact imported Interface bodies under the same collision-free identity. */
172
+ importedInterfacesByKey?: Record<IrDefinitionKey, IrInterface>
173
+ /** Canonical V1 members absent from the legacy serializer projection. */
174
+ functions: Record<string, IrFunction>
175
+ views?: Record<string, IrView>
176
+ policies?: Record<string, unknown>
177
+ dependencies?: Array<{ origin: string; revision: string }>
178
+ /** Exact canonical genesis declaration; absent on legacy projections. */
179
+ core?: unknown
180
+ }
181
+
182
+ export interface HandlerLink {
183
+ owner: string
184
+ ownerKind: 'class' | 'interface' | 'function'
185
+ method: string
186
+ static: boolean
187
+ /** the legacy runtime registry or current implementation.ts wiring site */
188
+ wiringFile?: string
189
+ wiringLine?: number
190
+ /** the resolved handler file (followed from the `execute` import) */
191
+ handlerFile?: string
192
+ handlerLine?: number
193
+ /** kernel ops detected in the handler (::update, ::link, createNode, …) */
194
+ kernelCalls?: string[]
195
+ /** declared auth policy on the runtime config; absent ⇒ defaults to 'required'. */
196
+ auth?: 'public' | 'optional' | 'required'
197
+ /** Canonical V1 callable auth, when the handler comes from implementation.ts. */
198
+ callableAuth?: IrCallableAuth
199
+ /** authorize hook shape: 'absent' (none), 'noop' (allow-all), 'custom' (real check). */
200
+ authorize?: 'absent' | 'noop' | 'custom'
201
+ /** raw source of the authorize hook (for the hover preview). */
202
+ authorizeSnippet?: string
203
+ /** false ⇒ a todo()/NotImplemented stub → "contract-only" badge */
204
+ implemented: boolean
205
+ /** true ⇒ resolver could not link a file → "unlinked" badge */
206
+ unlinked?: boolean
207
+ }
208
+
209
+ export interface SourceSpan {
210
+ file: string
211
+ startLine: number
212
+ endLine: number
213
+ doc?: string
214
+ }
215
+
216
+ export interface SchemaAnnotation {
217
+ /** anchor ref key, e.g. 'class.Monitor.property.status' */
218
+ target: string
219
+ severity: 'warn' | 'info'
220
+ code: 'COMPILE_ERROR' | 'EDGE_PROP_TYPE_MISSING'
221
+ message: string
222
+ }
223
+
224
+ export interface CrossDomainImport {
225
+ name: string
226
+ origin: string
227
+ definition: 'interface' | 'class'
228
+ }
229
+
230
+ export interface SchemaOverlay {
231
+ origin: string
232
+ /** defineDomain({ requires }) — runtime domain dependencies */
233
+ requires: string[]
234
+ /** non-kernel ir.imports → true cross-domain imports */
235
+ crossDomainImports: CrossDomainImport[]
236
+ /** kernel-origin ir.imports → mixin interfaces (collapsed chip) */
237
+ mixins: CrossDomainImport[]
238
+ postInstall?: string
239
+ handlerLinks: HandlerLink[]
240
+ /** keyed by anchor ref (class.X / class.X.property.y / class.X.method.m / edge.e / interface.I…) */
241
+ sourceSpans: Record<string, SourceSpan>
242
+ annotations: SchemaAnnotation[]
243
+ }
244
+
245
+ export interface BundleError {
246
+ message: string
247
+ file?: string
248
+ }
249
+
250
+ export interface StudioSchemaBundle {
251
+ domainId: string
252
+ /** UI/cache identity only. This is not the DSL schema revision. */
253
+ renderFingerprint: string
254
+ schemaMode: 'canonical-admitted' | 'canonical-preview' | 'legacy' | 'unavailable'
255
+ /** DSL-owned revision, present only after cohort SDK admission. */
256
+ schemaRevision?: SchemaRevision
257
+ extractedBy: 'runtime-bun' | 'static-tsmorph-fallback'
258
+ depsInstalled: boolean
259
+ ir: SchemaIR | null
260
+ /**
261
+ * Portable canonical V1 document emitted by the domain. `schemaMode` records
262
+ * whether the cohort SDK admitted it or Studio is rendering it as a structural
263
+ * preview. Kept separate from the lossy render IR; absent for legacy domains.
264
+ */
265
+ schemaRoot?: unknown
266
+ overlay: SchemaOverlay
267
+ /**
268
+ * Unambiguous short-name aliases for imported Interface bodies, retained for
269
+ * legacy renderers. Canonical consumers use `ir.importedInterfacesByKey`, whose
270
+ * `origin:interface.Name` keys cannot collide. Empty when deps aren't installed.
271
+ */
272
+ importedInterfaces?: Record<string, IrInterface>
273
+ /** present when the runtime import failed to compile (render state, not a crash) */
274
+ error?: BundleError | null
275
+ extractedAt: string
276
+ }
277
+
278
+ export interface DomainOverview {
279
+ origin: string
280
+ /** Active SDK composition entry; `domain.ts` is retained for legacy projects. */
281
+ compositionFile?: 'implementation.ts' | 'domain.ts'
282
+ adapter: 'astrale' | 'cloudflare' | 'unknown'
283
+ prodTarget?: string
284
+ devSecrets?: string
285
+ postInstall?: string
286
+ requires: string[]
287
+ packageName?: string
288
+ packageVersion?: string
289
+ astraleDeps: Record<string, string>
290
+ schemaDir: string
291
+ client?: string
292
+ }
293
+
294
+ export interface ViewInfo {
295
+ slug: string
296
+ kind: 'inline-html' | 'spa' | 'unknown'
297
+ auth?: string
298
+ mount?: string
299
+ url?: string
300
+ /** the class(es) this view binds to via `viewFor: selfOf(Class)` (DSL allows an array);
301
+ * absent ⇒ unbound/global */
302
+ viewFor?: string | string[]
303
+ file?: string
304
+ description?: string
305
+ }
306
+
307
+ /** One node that can be supplied as a targeted view's `targetNodeId`. */
308
+ export interface ViewTargetCandidate {
309
+ id: string
310
+ ref: string
311
+ className: string
312
+ classOrigin: string
313
+ label: string
314
+ description?: string
315
+ status?: string
316
+ }
317
+
318
+ /** Small durable snapshot retained when a previously selected node disappears. */
319
+ export interface RememberedViewTarget {
320
+ id: string
321
+ className: string
322
+ classOrigin: string
323
+ label: string
324
+ }
325
+
326
+ export interface ViewTargetResult {
327
+ status: 'available' | 'unavailable'
328
+ items: ViewTargetCandidate[]
329
+ selected: ViewTargetCandidate | null
330
+ stale: RememberedViewTarget | null
331
+ truncated: boolean
332
+ reason?: string
333
+ }
334
+
335
+ /** Full launch context shown before Studio asks `astrale view` to resolve and open the View. */
336
+ export interface ViewRuntime {
337
+ slug: string
338
+ instance: string | null
339
+ targetRequired: boolean
340
+ targets: ViewTargetResult
341
+ }
342
+
343
+ export type ViewSessionResult =
344
+ | {
345
+ status: 'ready'
346
+ sessionId: string
347
+ pageUrl: string
348
+ viewUrl: string
349
+ target: ViewTargetCandidate | null
350
+ }
351
+ | { status: 'unavailable'; reason: string }
352
+
353
+ export interface ClientFeature {
354
+ name: string
355
+ files: string[]
356
+ }
357
+
358
+ export interface ClientTree {
359
+ shell: string[]
360
+ features: ClientFeature[]
361
+ routes: Record<string, string>
362
+ present: boolean
363
+ }
364
+
365
+ export interface EnvField {
366
+ name: string
367
+ optional: boolean
368
+ doc?: string
369
+ secret?: boolean
370
+ }
371
+
372
+ export type EnvName = 'dev' | 'prod'
373
+
374
+ /** One env var in the editor: the env.ts contract side (declared/optional/doc)
375
+ * merged with the `.env.<env>` file side (value). A row may be declared-only
376
+ * (in env.ts, not yet in the file), set, or an orphan (in the file, not env.ts). */
377
+ export interface EnvVarRow {
378
+ name: string
379
+ /** current value from `.env.<env>` ('' when unset or empty) */
380
+ value: string
381
+ /** declared as a fillable (non-binding) field in env.ts's Env interface */
382
+ declared: boolean
383
+ /** env.ts marks it optional (`?`). Only required (!optional) + empty raises the signal. */
384
+ optional: boolean
385
+ /** JSDoc on the env.ts field — the inline hint */
386
+ doc?: string
387
+ }
388
+
389
+ /** The editable env for one env name (dev|prod): the `.env.<env>` file reconciled
390
+ * against env.ts. The GUI is the read-only studio's one sanctioned writer of a
391
+ * domain file (the explicit exception). */
392
+ export interface EnvFileModel {
393
+ env: EnvName
394
+ /** the secrets file, relative to the domain root (e.g. '.env.dev') */
395
+ file: string
396
+ /** wired via `astrale.config.ts` (`secrets: '.env.<env>'`)? false ⇒ the file is used
397
+ * by convention but the adapter isn't pointed at it (e.g. managed prod). */
398
+ configured: boolean
399
+ exists: boolean
400
+ adapter: DomainOverview['adapter']
401
+ rows: EnvVarRow[]
402
+ /** declared && required && empty — the count the "needs values" signal shows */
403
+ requiredMissing: number
404
+ }
405
+
406
+ export interface DomainAnatomy {
407
+ overview: DomainOverview
408
+ views: ViewInfo[]
409
+ client: ClientTree
410
+ env: EnvField[]
411
+ depsContainer?: string
412
+ /** shallow readdir of integrations/ top-level dir names — a hint, NOT a parse */
413
+ detectedIntegrations: string[]
414
+ }
415
+
416
+ /** One materialized node instance in a domain's core graph. */
417
+ export interface StudioCoreNode {
418
+ /** canonical CoreRef identity, e.g. `/:big-shop.example.dev:core.acme` */
419
+ path: string
420
+ /** the IR class this node instantiates (keys into StudioSchemaBundle.ir.classes) */
421
+ className: string
422
+ /** the node's property values, keyed by (possibly owner-qualified) property name */
423
+ data: Record<string, unknown>
424
+ /** parent node's `path`, when nested under another node (absent for roots) */
425
+ parent?: string
426
+ }
427
+
428
+ /** One materialized edge instance wiring two core nodes. */
429
+ export interface StudioCoreEdge {
430
+ /** source Core path, owning Domain path, or a legacy meta-node endpoint */
431
+ from: string
432
+ /** target Core path, owning Domain path, or a legacy meta-node endpoint */
433
+ to: string
434
+ /** the IR edge class name (keys into StudioSchemaBundle.ir.classes, type:'edge') */
435
+ edgeName: string
436
+ /** edge property values, when the edge class carries data */
437
+ data?: Record<string, unknown>
438
+ }
439
+
440
+ /** A domain's core data: the concrete genesis node/edge instance graph. */
441
+ export interface StudioCore {
442
+ /** the domain origin this core graph belongs to (mirrors SchemaIR.domain) */
443
+ domain: string
444
+ nodes: StudioCoreNode[]
445
+ edges: StudioCoreEdge[]
446
+ /** set when extraction failed; null when extraction succeeded (including "no core defined") */
447
+ error?: { message: string } | null
448
+ extractedAt: string
449
+ }
450
+
451
+ /** Client-side rendering description derived from a JSON value schema. */
452
+ export type TypeDescriptor =
453
+ | { kind: 'string' | 'number' | 'integer' | 'boolean' | 'null' | 'unknown'; optional: boolean }
454
+ | { kind: 'enum'; values: (string | number | boolean | null)[]; optional: boolean }
455
+ | { kind: 'array'; items: TypeDescriptor; optional: boolean }
456
+ | {
457
+ kind: 'object'
458
+ fields: Record<string, TypeDescriptor>
459
+ required: string[]
460
+ optional: boolean
461
+ }
462
+ | { kind: 'ref'; target: string; refKind: 'node' | 'data'; optional: boolean }