@camstack/types 1.2.264 → 1.2.266
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.
- package/dist/automation/recipe.d.ts +1 -1
- package/dist/capabilities/composer.cap.d.ts +328 -0
- package/dist/capabilities/control.cap.d.ts +4 -4
- package/dist/capabilities/core-blocks.cap.d.ts +2339 -0
- package/dist/capabilities/custom-model-registry.cap.d.ts +4 -2
- package/dist/capabilities/day-night.cap.d.ts +8 -8
- package/dist/capabilities/device-extension.cap.d.ts +8 -8
- package/dist/capabilities/index.d.ts +4 -2
- package/dist/capabilities/model-convert.cap.d.ts +4 -3
- package/dist/capabilities/model-distributor.cap.d.ts +4 -2
- package/dist/capabilities/notification-rules.cap.d.ts +74 -74
- package/dist/capabilities/osd-manager.cap.d.ts +13 -13
- package/dist/capabilities/pipeline-executor.cap.d.ts +5 -0
- package/dist/composition/composition-graph.d.ts +36 -0
- package/dist/composition/composition-report.d.ts +264 -0
- package/dist/composition/composition.d.ts +362 -0
- package/dist/composition/evaluate-field.d.ts +63 -0
- package/dist/composition/examples.d.ts +10 -0
- package/dist/composition/expression-kinds.d.ts +36 -0
- package/dist/composition/index.d.ts +12 -0
- package/dist/composition/state-fields.d.ts +19 -0
- package/dist/composition/validate-composition.d.ts +46 -0
- package/dist/device/schema-fields.d.ts +3 -0
- package/dist/expression/builtins.d.ts +30 -2
- package/dist/generated/addon-api.d.ts +57 -0
- package/dist/generated/capability-router-map.d.ts +5 -2
- package/dist/generated/method-access-map.d.ts +1 -1
- package/dist/generated/system-proxy.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1350 -80
- package/dist/index.mjs +1278 -81
- package/dist/notification/rule-kinds.d.ts +3 -2
- package/dist/types/models.d.ts +5 -3
- package/dist/types/pipeline-step.d.ts +6 -1
- package/package.json +1 -1
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the validator says about a composition and what the composer says about
|
|
3
|
+
* a running one: the wire shapes the API returns (D659).
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
export declare const CompositionProblemCodeSchema: z.ZodEnum<{
|
|
7
|
+
"source-missing": "source-missing";
|
|
8
|
+
"reserved-variant": "reserved-variant";
|
|
9
|
+
"unknown-capability": "unknown-capability";
|
|
10
|
+
"not-composable": "not-composable";
|
|
11
|
+
"wrong-device-type": "wrong-device-type";
|
|
12
|
+
"has-commands": "has-commands";
|
|
13
|
+
"unknown-field": "unknown-field";
|
|
14
|
+
"nested-field": "nested-field";
|
|
15
|
+
"missing-field": "missing-field";
|
|
16
|
+
"kind-mismatch": "kind-mismatch";
|
|
17
|
+
"may-be-null": "may-be-null";
|
|
18
|
+
"source-unreadable": "source-unreadable";
|
|
19
|
+
"source-capability-missing": "source-capability-missing";
|
|
20
|
+
"source-field-unknown": "source-field-unknown";
|
|
21
|
+
"expression-invalid": "expression-invalid";
|
|
22
|
+
cycle: "cycle";
|
|
23
|
+
"duplicate-target": "duplicate-target";
|
|
24
|
+
}>;
|
|
25
|
+
export type CompositionProblemCode = z.infer<typeof CompositionProblemCodeSchema>;
|
|
26
|
+
/** One refusal, named (D391). `path` points into the composition, e.g. `features[0].fields.celsius`. */
|
|
27
|
+
export declare const CompositionProblemSchema: z.ZodObject<{
|
|
28
|
+
code: z.ZodEnum<{
|
|
29
|
+
"source-missing": "source-missing";
|
|
30
|
+
"reserved-variant": "reserved-variant";
|
|
31
|
+
"unknown-capability": "unknown-capability";
|
|
32
|
+
"not-composable": "not-composable";
|
|
33
|
+
"wrong-device-type": "wrong-device-type";
|
|
34
|
+
"has-commands": "has-commands";
|
|
35
|
+
"unknown-field": "unknown-field";
|
|
36
|
+
"nested-field": "nested-field";
|
|
37
|
+
"missing-field": "missing-field";
|
|
38
|
+
"kind-mismatch": "kind-mismatch";
|
|
39
|
+
"may-be-null": "may-be-null";
|
|
40
|
+
"source-unreadable": "source-unreadable";
|
|
41
|
+
"source-capability-missing": "source-capability-missing";
|
|
42
|
+
"source-field-unknown": "source-field-unknown";
|
|
43
|
+
"expression-invalid": "expression-invalid";
|
|
44
|
+
cycle: "cycle";
|
|
45
|
+
"duplicate-target": "duplicate-target";
|
|
46
|
+
}>;
|
|
47
|
+
path: z.ZodString;
|
|
48
|
+
message: z.ZodString;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export type CompositionProblem = z.infer<typeof CompositionProblemSchema>;
|
|
51
|
+
export declare const CompositionFieldKindSchema: z.ZodEnum<{
|
|
52
|
+
string: "string";
|
|
53
|
+
number: "number";
|
|
54
|
+
boolean: "boolean";
|
|
55
|
+
enum: "enum";
|
|
56
|
+
}>;
|
|
57
|
+
export type CompositionFieldKind = z.infer<typeof CompositionFieldKindSchema>;
|
|
58
|
+
/** How a field says "unavailable": `null` when its schema allows it, else the device goes offline (D393). */
|
|
59
|
+
export declare const CompositionUnavailableModeSchema: z.ZodEnum<{
|
|
60
|
+
null: "null";
|
|
61
|
+
offline: "offline";
|
|
62
|
+
}>;
|
|
63
|
+
export type CompositionUnavailableMode = z.infer<typeof CompositionUnavailableModeSchema>;
|
|
64
|
+
/**
|
|
65
|
+
* `derived` reads a source · `clock` reads only `now`, recomputed when a sibling
|
|
66
|
+
* field of its cap changes value · `constant` reads nothing, computed once.
|
|
67
|
+
*/
|
|
68
|
+
export declare const CompositionFieldRoleSchema: z.ZodEnum<{
|
|
69
|
+
derived: "derived";
|
|
70
|
+
clock: "clock";
|
|
71
|
+
constant: "constant";
|
|
72
|
+
}>;
|
|
73
|
+
export type CompositionFieldRole = z.infer<typeof CompositionFieldRoleSchema>;
|
|
74
|
+
export declare const CompositionFieldPlanSchema: z.ZodObject<{
|
|
75
|
+
cap: z.ZodString;
|
|
76
|
+
path: z.ZodString;
|
|
77
|
+
featureIndex: z.ZodNumber;
|
|
78
|
+
kind: z.ZodEnum<{
|
|
79
|
+
string: "string";
|
|
80
|
+
number: "number";
|
|
81
|
+
boolean: "boolean";
|
|
82
|
+
enum: "enum";
|
|
83
|
+
}>;
|
|
84
|
+
nullable: z.ZodBoolean;
|
|
85
|
+
required: z.ZodBoolean;
|
|
86
|
+
unavailable: z.ZodEnum<{
|
|
87
|
+
null: "null";
|
|
88
|
+
offline: "offline";
|
|
89
|
+
}>;
|
|
90
|
+
role: z.ZodEnum<{
|
|
91
|
+
derived: "derived";
|
|
92
|
+
clock: "clock";
|
|
93
|
+
constant: "constant";
|
|
94
|
+
}>;
|
|
95
|
+
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
96
|
+
source: z.ZodObject<{
|
|
97
|
+
addonId: z.ZodString;
|
|
98
|
+
stableId: z.ZodString;
|
|
99
|
+
}, z.core.$strip>;
|
|
100
|
+
cap: z.ZodString;
|
|
101
|
+
fieldPath: z.ZodString;
|
|
102
|
+
kind: z.ZodLiteral<"from">;
|
|
103
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
104
|
+
kind: z.ZodLiteral<"expression">;
|
|
105
|
+
expr: z.ZodString;
|
|
106
|
+
bindings: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
107
|
+
source: z.ZodObject<{
|
|
108
|
+
addonId: z.ZodString;
|
|
109
|
+
stableId: z.ZodString;
|
|
110
|
+
}, z.core.$strip>;
|
|
111
|
+
cap: z.ZodString;
|
|
112
|
+
fieldPath: z.ZodString;
|
|
113
|
+
kind: z.ZodLiteral<"from">;
|
|
114
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
115
|
+
kind: z.ZodLiteral<"literal">;
|
|
116
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
117
|
+
}, z.core.$strip>], "kind">>;
|
|
118
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
119
|
+
kind: z.ZodLiteral<"code">;
|
|
120
|
+
code: z.ZodString;
|
|
121
|
+
}, z.core.$strip>], "kind">;
|
|
122
|
+
reads: z.ZodArray<z.ZodObject<{
|
|
123
|
+
source: z.ZodObject<{
|
|
124
|
+
addonId: z.ZodString;
|
|
125
|
+
stableId: z.ZodString;
|
|
126
|
+
}, z.core.$strip>;
|
|
127
|
+
cap: z.ZodString;
|
|
128
|
+
fieldPath: z.ZodString;
|
|
129
|
+
}, z.core.$strip>>;
|
|
130
|
+
}, z.core.$strip>;
|
|
131
|
+
export type CompositionFieldPlan = z.infer<typeof CompositionFieldPlanSchema>;
|
|
132
|
+
export declare const CompositionValidationSchema: z.ZodObject<{
|
|
133
|
+
ok: z.ZodBoolean;
|
|
134
|
+
problems: z.ZodArray<z.ZodObject<{
|
|
135
|
+
code: z.ZodEnum<{
|
|
136
|
+
"source-missing": "source-missing";
|
|
137
|
+
"reserved-variant": "reserved-variant";
|
|
138
|
+
"unknown-capability": "unknown-capability";
|
|
139
|
+
"not-composable": "not-composable";
|
|
140
|
+
"wrong-device-type": "wrong-device-type";
|
|
141
|
+
"has-commands": "has-commands";
|
|
142
|
+
"unknown-field": "unknown-field";
|
|
143
|
+
"nested-field": "nested-field";
|
|
144
|
+
"missing-field": "missing-field";
|
|
145
|
+
"kind-mismatch": "kind-mismatch";
|
|
146
|
+
"may-be-null": "may-be-null";
|
|
147
|
+
"source-unreadable": "source-unreadable";
|
|
148
|
+
"source-capability-missing": "source-capability-missing";
|
|
149
|
+
"source-field-unknown": "source-field-unknown";
|
|
150
|
+
"expression-invalid": "expression-invalid";
|
|
151
|
+
cycle: "cycle";
|
|
152
|
+
"duplicate-target": "duplicate-target";
|
|
153
|
+
}>;
|
|
154
|
+
path: z.ZodString;
|
|
155
|
+
message: z.ZodString;
|
|
156
|
+
}, z.core.$strip>>;
|
|
157
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
158
|
+
cap: z.ZodString;
|
|
159
|
+
path: z.ZodString;
|
|
160
|
+
featureIndex: z.ZodNumber;
|
|
161
|
+
kind: z.ZodEnum<{
|
|
162
|
+
string: "string";
|
|
163
|
+
number: "number";
|
|
164
|
+
boolean: "boolean";
|
|
165
|
+
enum: "enum";
|
|
166
|
+
}>;
|
|
167
|
+
nullable: z.ZodBoolean;
|
|
168
|
+
required: z.ZodBoolean;
|
|
169
|
+
unavailable: z.ZodEnum<{
|
|
170
|
+
null: "null";
|
|
171
|
+
offline: "offline";
|
|
172
|
+
}>;
|
|
173
|
+
role: z.ZodEnum<{
|
|
174
|
+
derived: "derived";
|
|
175
|
+
clock: "clock";
|
|
176
|
+
constant: "constant";
|
|
177
|
+
}>;
|
|
178
|
+
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
179
|
+
source: z.ZodObject<{
|
|
180
|
+
addonId: z.ZodString;
|
|
181
|
+
stableId: z.ZodString;
|
|
182
|
+
}, z.core.$strip>;
|
|
183
|
+
cap: z.ZodString;
|
|
184
|
+
fieldPath: z.ZodString;
|
|
185
|
+
kind: z.ZodLiteral<"from">;
|
|
186
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
187
|
+
kind: z.ZodLiteral<"expression">;
|
|
188
|
+
expr: z.ZodString;
|
|
189
|
+
bindings: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
190
|
+
source: z.ZodObject<{
|
|
191
|
+
addonId: z.ZodString;
|
|
192
|
+
stableId: z.ZodString;
|
|
193
|
+
}, z.core.$strip>;
|
|
194
|
+
cap: z.ZodString;
|
|
195
|
+
fieldPath: z.ZodString;
|
|
196
|
+
kind: z.ZodLiteral<"from">;
|
|
197
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
198
|
+
kind: z.ZodLiteral<"literal">;
|
|
199
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
200
|
+
}, z.core.$strip>], "kind">>;
|
|
201
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
202
|
+
kind: z.ZodLiteral<"code">;
|
|
203
|
+
code: z.ZodString;
|
|
204
|
+
}, z.core.$strip>], "kind">;
|
|
205
|
+
reads: z.ZodArray<z.ZodObject<{
|
|
206
|
+
source: z.ZodObject<{
|
|
207
|
+
addonId: z.ZodString;
|
|
208
|
+
stableId: z.ZodString;
|
|
209
|
+
}, z.core.$strip>;
|
|
210
|
+
cap: z.ZodString;
|
|
211
|
+
fieldPath: z.ZodString;
|
|
212
|
+
}, z.core.$strip>>;
|
|
213
|
+
}, z.core.$strip>>;
|
|
214
|
+
}, z.core.$strip>;
|
|
215
|
+
export type CompositionValidation = z.infer<typeof CompositionValidationSchema>;
|
|
216
|
+
/** Mirrors `CoreBlockStatus`, pinned by `core-blocks-source.spec.ts` (Task 11). */
|
|
217
|
+
export declare const CompositionRunStatusSchema: z.ZodEnum<{
|
|
218
|
+
running: "running";
|
|
219
|
+
failed: "failed";
|
|
220
|
+
stopped: "stopped";
|
|
221
|
+
starting: "starting";
|
|
222
|
+
}>;
|
|
223
|
+
export type CompositionRunStatus = z.infer<typeof CompositionRunStatusSchema>;
|
|
224
|
+
export declare const CompositionFieldStateKindSchema: z.ZodEnum<{
|
|
225
|
+
unavailable: "unavailable";
|
|
226
|
+
fresh: "fresh";
|
|
227
|
+
stale: "stale";
|
|
228
|
+
}>;
|
|
229
|
+
export type CompositionFieldStateKind = z.infer<typeof CompositionFieldStateKindSchema>;
|
|
230
|
+
export declare const CompositionFieldStateSchema: z.ZodObject<{
|
|
231
|
+
cap: z.ZodString;
|
|
232
|
+
path: z.ZodString;
|
|
233
|
+
state: z.ZodEnum<{
|
|
234
|
+
unavailable: "unavailable";
|
|
235
|
+
fresh: "fresh";
|
|
236
|
+
stale: "stale";
|
|
237
|
+
}>;
|
|
238
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
239
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
240
|
+
}, z.core.$strip>;
|
|
241
|
+
export type CompositionFieldState = z.infer<typeof CompositionFieldStateSchema>;
|
|
242
|
+
export declare const CompositionBlockStateSchema: z.ZodObject<{
|
|
243
|
+
blockId: z.ZodString;
|
|
244
|
+
deviceId: z.ZodNullable<z.ZodNumber>;
|
|
245
|
+
status: z.ZodEnum<{
|
|
246
|
+
running: "running";
|
|
247
|
+
failed: "failed";
|
|
248
|
+
stopped: "stopped";
|
|
249
|
+
starting: "starting";
|
|
250
|
+
}>;
|
|
251
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
252
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
253
|
+
cap: z.ZodString;
|
|
254
|
+
path: z.ZodString;
|
|
255
|
+
state: z.ZodEnum<{
|
|
256
|
+
unavailable: "unavailable";
|
|
257
|
+
fresh: "fresh";
|
|
258
|
+
stale: "stale";
|
|
259
|
+
}>;
|
|
260
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
261
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
262
|
+
}, z.core.$strip>>;
|
|
263
|
+
}, z.core.$strip>;
|
|
264
|
+
export type CompositionBlockState = z.infer<typeof CompositionBlockStateSchema>;
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A COMPOSITION: a device assembled from other devices' state (D659).
|
|
3
|
+
*
|
|
4
|
+
* The data half of the composed-devices spec §1. A composition is stored inside
|
|
5
|
+
* a core block (`CoreBlock.source.kind === 'composition'`) and run by the shared
|
|
6
|
+
* `composer` runner. It names a TARGET and, for each capability of the target, a
|
|
7
|
+
* FIELD MAP: every state field has exactly one source.
|
|
8
|
+
*
|
|
9
|
+
* Sources are keyed by `(addonId, stableId)`, NEVER by numeric device id. A
|
|
10
|
+
* resync reissues numeric ids, and a composition that stored them would be
|
|
11
|
+
* orphaned by the first re-adoption (the linked-devices lesson). A `stableId` is
|
|
12
|
+
* unique only within its owning addon, so the owner travels with it.
|
|
13
|
+
*
|
|
14
|
+
* Later slices EXTEND these unions and do not reshape them. The variants a later
|
|
15
|
+
* slice implements are already in the wire shape, and `validateComposition`
|
|
16
|
+
* refuses them BY NAME until then:
|
|
17
|
+
* target `existing` → slice 2 · feature `passthrough` → slice 3 ·
|
|
18
|
+
* `commands` (`forward`) → slice 3 · source `code` → slice 4.
|
|
19
|
+
*/
|
|
20
|
+
import { z } from 'zod';
|
|
21
|
+
import { DeviceRole, DeviceType } from '../device/device-type.js';
|
|
22
|
+
/** The owner of every composed device: the `composer` builtin. */
|
|
23
|
+
export declare const COMPOSER_ADDON_ID = "composer";
|
|
24
|
+
/** A composed device's stableId is this prefix plus the block id. */
|
|
25
|
+
export declare const COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
|
|
26
|
+
/** A device with more capabilities than this is two devices. */
|
|
27
|
+
export declare const MAX_COMPOSITION_FEATURES = 16;
|
|
28
|
+
export declare const MAX_COMPOSITION_FIELDS_PER_FEATURE = 32;
|
|
29
|
+
/** Longest snippet a `code` source may carry (slice 4). */
|
|
30
|
+
export declare const MAX_COMPOSITION_CODE_LENGTH = 20000;
|
|
31
|
+
export declare const CompositionSourceRefSchema: z.ZodObject<{
|
|
32
|
+
addonId: z.ZodString;
|
|
33
|
+
stableId: z.ZodString;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export type CompositionSourceRef = z.infer<typeof CompositionSourceRefSchema>;
|
|
36
|
+
/** One field of one capability of one source device. */
|
|
37
|
+
export declare const CompositionFieldReadSchema: z.ZodObject<{
|
|
38
|
+
source: z.ZodObject<{
|
|
39
|
+
addonId: z.ZodString;
|
|
40
|
+
stableId: z.ZodString;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
cap: z.ZodString;
|
|
43
|
+
fieldPath: z.ZodString;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
export type CompositionFieldRead = z.infer<typeof CompositionFieldReadSchema>;
|
|
46
|
+
/** `from`: copy one source field verbatim. It is also an expression's `from` binding. */
|
|
47
|
+
export declare const CompositionFromSourceSchema: z.ZodObject<{
|
|
48
|
+
source: z.ZodObject<{
|
|
49
|
+
addonId: z.ZodString;
|
|
50
|
+
stableId: z.ZodString;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
cap: z.ZodString;
|
|
53
|
+
fieldPath: z.ZodString;
|
|
54
|
+
kind: z.ZodLiteral<"from">;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
export type CompositionFromSource = z.infer<typeof CompositionFromSourceSchema>;
|
|
57
|
+
/** A constant binding. No device is read. */
|
|
58
|
+
export declare const CompositionLiteralBindingSchema: z.ZodObject<{
|
|
59
|
+
kind: z.ZodLiteral<"literal">;
|
|
60
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
export type CompositionLiteralBinding = z.infer<typeof CompositionLiteralBindingSchema>;
|
|
63
|
+
export declare const CompositionBindingSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
64
|
+
source: z.ZodObject<{
|
|
65
|
+
addonId: z.ZodString;
|
|
66
|
+
stableId: z.ZodString;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
cap: z.ZodString;
|
|
69
|
+
fieldPath: z.ZodString;
|
|
70
|
+
kind: z.ZodLiteral<"from">;
|
|
71
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
72
|
+
kind: z.ZodLiteral<"literal">;
|
|
73
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
74
|
+
}, z.core.$strip>], "kind">;
|
|
75
|
+
export type CompositionBinding = z.infer<typeof CompositionBindingSchema>;
|
|
76
|
+
/**
|
|
77
|
+
* `expression`: a formula over named bindings, in the salvaged expression
|
|
78
|
+
* engine. Validated at parse by the SAME function every other consumer runs,
|
|
79
|
+
* so the editor and the store cannot disagree.
|
|
80
|
+
*/
|
|
81
|
+
export declare const CompositionExpressionSourceSchema: z.ZodObject<{
|
|
82
|
+
kind: z.ZodLiteral<"expression">;
|
|
83
|
+
expr: z.ZodString;
|
|
84
|
+
bindings: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
85
|
+
source: z.ZodObject<{
|
|
86
|
+
addonId: z.ZodString;
|
|
87
|
+
stableId: z.ZodString;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
cap: z.ZodString;
|
|
90
|
+
fieldPath: z.ZodString;
|
|
91
|
+
kind: z.ZodLiteral<"from">;
|
|
92
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
93
|
+
kind: z.ZodLiteral<"literal">;
|
|
94
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
95
|
+
}, z.core.$strip>], "kind">>;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
export type CompositionExpressionSource = z.infer<typeof CompositionExpressionSourceSchema>;
|
|
98
|
+
/** `code`: RESERVED for slice 4 (own runner, one-way eject). */
|
|
99
|
+
export declare const CompositionCodeSourceSchema: z.ZodObject<{
|
|
100
|
+
kind: z.ZodLiteral<"code">;
|
|
101
|
+
code: z.ZodString;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
export type CompositionCodeSource = z.infer<typeof CompositionCodeSourceSchema>;
|
|
104
|
+
export declare const CompositionFieldSourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
105
|
+
source: z.ZodObject<{
|
|
106
|
+
addonId: z.ZodString;
|
|
107
|
+
stableId: z.ZodString;
|
|
108
|
+
}, z.core.$strip>;
|
|
109
|
+
cap: z.ZodString;
|
|
110
|
+
fieldPath: z.ZodString;
|
|
111
|
+
kind: z.ZodLiteral<"from">;
|
|
112
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
113
|
+
kind: z.ZodLiteral<"expression">;
|
|
114
|
+
expr: z.ZodString;
|
|
115
|
+
bindings: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
116
|
+
source: z.ZodObject<{
|
|
117
|
+
addonId: z.ZodString;
|
|
118
|
+
stableId: z.ZodString;
|
|
119
|
+
}, z.core.$strip>;
|
|
120
|
+
cap: z.ZodString;
|
|
121
|
+
fieldPath: z.ZodString;
|
|
122
|
+
kind: z.ZodLiteral<"from">;
|
|
123
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
124
|
+
kind: z.ZodLiteral<"literal">;
|
|
125
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
126
|
+
}, z.core.$strip>], "kind">>;
|
|
127
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
128
|
+
kind: z.ZodLiteral<"code">;
|
|
129
|
+
code: z.ZodString;
|
|
130
|
+
}, z.core.$strip>], "kind">;
|
|
131
|
+
export type CompositionFieldSource = z.infer<typeof CompositionFieldSourceSchema>;
|
|
132
|
+
/** `forward`: RESERVED for slice 3. Argument mapping arrives there as an additive optional `args`. */
|
|
133
|
+
export declare const CompositionForwardCommandSchema: z.ZodObject<{
|
|
134
|
+
kind: z.ZodLiteral<"forward">;
|
|
135
|
+
source: z.ZodObject<{
|
|
136
|
+
addonId: z.ZodString;
|
|
137
|
+
stableId: z.ZodString;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
cap: z.ZodString;
|
|
140
|
+
method: z.ZodString;
|
|
141
|
+
}, z.core.$strip>;
|
|
142
|
+
export type CompositionForwardCommand = z.infer<typeof CompositionForwardCommandSchema>;
|
|
143
|
+
export declare const CompositionCommandTargetSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
144
|
+
kind: z.ZodLiteral<"forward">;
|
|
145
|
+
source: z.ZodObject<{
|
|
146
|
+
addonId: z.ZodString;
|
|
147
|
+
stableId: z.ZodString;
|
|
148
|
+
}, z.core.$strip>;
|
|
149
|
+
cap: z.ZodString;
|
|
150
|
+
method: z.ZodString;
|
|
151
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
152
|
+
kind: z.ZodLiteral<"code">;
|
|
153
|
+
code: z.ZodString;
|
|
154
|
+
}, z.core.$strip>], "kind">;
|
|
155
|
+
export type CompositionCommandTarget = z.infer<typeof CompositionCommandTargetSchema>;
|
|
156
|
+
export declare const CompositionFieldsFeatureSchema: z.ZodObject<{
|
|
157
|
+
kind: z.ZodLiteral<"fields">;
|
|
158
|
+
cap: z.ZodString;
|
|
159
|
+
fields: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
160
|
+
source: z.ZodObject<{
|
|
161
|
+
addonId: z.ZodString;
|
|
162
|
+
stableId: z.ZodString;
|
|
163
|
+
}, z.core.$strip>;
|
|
164
|
+
cap: z.ZodString;
|
|
165
|
+
fieldPath: z.ZodString;
|
|
166
|
+
kind: z.ZodLiteral<"from">;
|
|
167
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
168
|
+
kind: z.ZodLiteral<"expression">;
|
|
169
|
+
expr: z.ZodString;
|
|
170
|
+
bindings: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
171
|
+
source: z.ZodObject<{
|
|
172
|
+
addonId: z.ZodString;
|
|
173
|
+
stableId: z.ZodString;
|
|
174
|
+
}, z.core.$strip>;
|
|
175
|
+
cap: z.ZodString;
|
|
176
|
+
fieldPath: z.ZodString;
|
|
177
|
+
kind: z.ZodLiteral<"from">;
|
|
178
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
179
|
+
kind: z.ZodLiteral<"literal">;
|
|
180
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
181
|
+
}, z.core.$strip>], "kind">>;
|
|
182
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
183
|
+
kind: z.ZodLiteral<"code">;
|
|
184
|
+
code: z.ZodString;
|
|
185
|
+
}, z.core.$strip>], "kind">>;
|
|
186
|
+
commands: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
187
|
+
kind: z.ZodLiteral<"forward">;
|
|
188
|
+
source: z.ZodObject<{
|
|
189
|
+
addonId: z.ZodString;
|
|
190
|
+
stableId: z.ZodString;
|
|
191
|
+
}, z.core.$strip>;
|
|
192
|
+
cap: z.ZodString;
|
|
193
|
+
method: z.ZodString;
|
|
194
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
195
|
+
kind: z.ZodLiteral<"code">;
|
|
196
|
+
code: z.ZodString;
|
|
197
|
+
}, z.core.$strip>], "kind">>>;
|
|
198
|
+
}, z.core.$strip>;
|
|
199
|
+
export type CompositionFieldsFeature = z.infer<typeof CompositionFieldsFeatureSchema>;
|
|
200
|
+
/** RESERVED for slice 3: a media / data-plane cap, whole, from one source. */
|
|
201
|
+
export declare const CompositionPassthroughFeatureSchema: z.ZodObject<{
|
|
202
|
+
kind: z.ZodLiteral<"passthrough">;
|
|
203
|
+
cap: z.ZodString;
|
|
204
|
+
source: z.ZodObject<{
|
|
205
|
+
addonId: z.ZodString;
|
|
206
|
+
stableId: z.ZodString;
|
|
207
|
+
}, z.core.$strip>;
|
|
208
|
+
}, z.core.$strip>;
|
|
209
|
+
export type CompositionPassthroughFeature = z.infer<typeof CompositionPassthroughFeatureSchema>;
|
|
210
|
+
export declare const CompositionFeatureSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
211
|
+
kind: z.ZodLiteral<"fields">;
|
|
212
|
+
cap: z.ZodString;
|
|
213
|
+
fields: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
214
|
+
source: z.ZodObject<{
|
|
215
|
+
addonId: z.ZodString;
|
|
216
|
+
stableId: z.ZodString;
|
|
217
|
+
}, z.core.$strip>;
|
|
218
|
+
cap: z.ZodString;
|
|
219
|
+
fieldPath: z.ZodString;
|
|
220
|
+
kind: z.ZodLiteral<"from">;
|
|
221
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
222
|
+
kind: z.ZodLiteral<"expression">;
|
|
223
|
+
expr: z.ZodString;
|
|
224
|
+
bindings: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
225
|
+
source: z.ZodObject<{
|
|
226
|
+
addonId: z.ZodString;
|
|
227
|
+
stableId: z.ZodString;
|
|
228
|
+
}, z.core.$strip>;
|
|
229
|
+
cap: z.ZodString;
|
|
230
|
+
fieldPath: z.ZodString;
|
|
231
|
+
kind: z.ZodLiteral<"from">;
|
|
232
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
233
|
+
kind: z.ZodLiteral<"literal">;
|
|
234
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
235
|
+
}, z.core.$strip>], "kind">>;
|
|
236
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
237
|
+
kind: z.ZodLiteral<"code">;
|
|
238
|
+
code: z.ZodString;
|
|
239
|
+
}, z.core.$strip>], "kind">>;
|
|
240
|
+
commands: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
241
|
+
kind: z.ZodLiteral<"forward">;
|
|
242
|
+
source: z.ZodObject<{
|
|
243
|
+
addonId: z.ZodString;
|
|
244
|
+
stableId: z.ZodString;
|
|
245
|
+
}, z.core.$strip>;
|
|
246
|
+
cap: z.ZodString;
|
|
247
|
+
method: z.ZodString;
|
|
248
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
249
|
+
kind: z.ZodLiteral<"code">;
|
|
250
|
+
code: z.ZodString;
|
|
251
|
+
}, z.core.$strip>], "kind">>>;
|
|
252
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
253
|
+
kind: z.ZodLiteral<"passthrough">;
|
|
254
|
+
cap: z.ZodString;
|
|
255
|
+
source: z.ZodObject<{
|
|
256
|
+
addonId: z.ZodString;
|
|
257
|
+
stableId: z.ZodString;
|
|
258
|
+
}, z.core.$strip>;
|
|
259
|
+
}, z.core.$strip>], "kind">;
|
|
260
|
+
export type CompositionFeature = z.infer<typeof CompositionFeatureSchema>;
|
|
261
|
+
/**
|
|
262
|
+
* A NEW device. It has no `name` of its own: the block's name IS the device's
|
|
263
|
+
* name (2026-08-08). A second copy here would be a second writer of one string (D62).
|
|
264
|
+
*/
|
|
265
|
+
export declare const CompositionNewTargetSchema: z.ZodObject<{
|
|
266
|
+
kind: z.ZodLiteral<"new">;
|
|
267
|
+
type: z.ZodEnum<typeof DeviceType>;
|
|
268
|
+
role: z.ZodOptional<z.ZodEnum<typeof DeviceRole>>;
|
|
269
|
+
}, z.core.$strip>;
|
|
270
|
+
export type CompositionNewTarget = z.infer<typeof CompositionNewTargetSchema>;
|
|
271
|
+
/** RESERVED for slice 2: customize an existing device. */
|
|
272
|
+
export declare const CompositionExistingTargetSchema: z.ZodObject<{
|
|
273
|
+
kind: z.ZodLiteral<"existing">;
|
|
274
|
+
device: z.ZodObject<{
|
|
275
|
+
addonId: z.ZodString;
|
|
276
|
+
stableId: z.ZodString;
|
|
277
|
+
}, z.core.$strip>;
|
|
278
|
+
}, z.core.$strip>;
|
|
279
|
+
export type CompositionExistingTarget = z.infer<typeof CompositionExistingTargetSchema>;
|
|
280
|
+
export declare const CompositionTargetSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
281
|
+
kind: z.ZodLiteral<"new">;
|
|
282
|
+
type: z.ZodEnum<typeof DeviceType>;
|
|
283
|
+
role: z.ZodOptional<z.ZodEnum<typeof DeviceRole>>;
|
|
284
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
285
|
+
kind: z.ZodLiteral<"existing">;
|
|
286
|
+
device: z.ZodObject<{
|
|
287
|
+
addonId: z.ZodString;
|
|
288
|
+
stableId: z.ZodString;
|
|
289
|
+
}, z.core.$strip>;
|
|
290
|
+
}, z.core.$strip>], "kind">;
|
|
291
|
+
export type CompositionTarget = z.infer<typeof CompositionTargetSchema>;
|
|
292
|
+
export declare const CompositionSchema: z.ZodObject<{
|
|
293
|
+
target: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
294
|
+
kind: z.ZodLiteral<"new">;
|
|
295
|
+
type: z.ZodEnum<typeof DeviceType>;
|
|
296
|
+
role: z.ZodOptional<z.ZodEnum<typeof DeviceRole>>;
|
|
297
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
298
|
+
kind: z.ZodLiteral<"existing">;
|
|
299
|
+
device: z.ZodObject<{
|
|
300
|
+
addonId: z.ZodString;
|
|
301
|
+
stableId: z.ZodString;
|
|
302
|
+
}, z.core.$strip>;
|
|
303
|
+
}, z.core.$strip>], "kind">;
|
|
304
|
+
features: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
305
|
+
kind: z.ZodLiteral<"fields">;
|
|
306
|
+
cap: z.ZodString;
|
|
307
|
+
fields: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
308
|
+
source: z.ZodObject<{
|
|
309
|
+
addonId: z.ZodString;
|
|
310
|
+
stableId: z.ZodString;
|
|
311
|
+
}, z.core.$strip>;
|
|
312
|
+
cap: z.ZodString;
|
|
313
|
+
fieldPath: z.ZodString;
|
|
314
|
+
kind: z.ZodLiteral<"from">;
|
|
315
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
316
|
+
kind: z.ZodLiteral<"expression">;
|
|
317
|
+
expr: z.ZodString;
|
|
318
|
+
bindings: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
319
|
+
source: z.ZodObject<{
|
|
320
|
+
addonId: z.ZodString;
|
|
321
|
+
stableId: z.ZodString;
|
|
322
|
+
}, z.core.$strip>;
|
|
323
|
+
cap: z.ZodString;
|
|
324
|
+
fieldPath: z.ZodString;
|
|
325
|
+
kind: z.ZodLiteral<"from">;
|
|
326
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
327
|
+
kind: z.ZodLiteral<"literal">;
|
|
328
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
329
|
+
}, z.core.$strip>], "kind">>;
|
|
330
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
331
|
+
kind: z.ZodLiteral<"code">;
|
|
332
|
+
code: z.ZodString;
|
|
333
|
+
}, z.core.$strip>], "kind">>;
|
|
334
|
+
commands: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
335
|
+
kind: z.ZodLiteral<"forward">;
|
|
336
|
+
source: z.ZodObject<{
|
|
337
|
+
addonId: z.ZodString;
|
|
338
|
+
stableId: z.ZodString;
|
|
339
|
+
}, z.core.$strip>;
|
|
340
|
+
cap: z.ZodString;
|
|
341
|
+
method: z.ZodString;
|
|
342
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
343
|
+
kind: z.ZodLiteral<"code">;
|
|
344
|
+
code: z.ZodString;
|
|
345
|
+
}, z.core.$strip>], "kind">>>;
|
|
346
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
347
|
+
kind: z.ZodLiteral<"passthrough">;
|
|
348
|
+
cap: z.ZodString;
|
|
349
|
+
source: z.ZodObject<{
|
|
350
|
+
addonId: z.ZodString;
|
|
351
|
+
stableId: z.ZodString;
|
|
352
|
+
}, z.core.$strip>;
|
|
353
|
+
}, z.core.$strip>], "kind">>;
|
|
354
|
+
}, z.core.$strip>;
|
|
355
|
+
export type Composition = z.infer<typeof CompositionSchema>;
|
|
356
|
+
export declare function compositionSourceKey(ref: CompositionSourceRef): string;
|
|
357
|
+
export declare function compositionSliceKey(ref: CompositionSourceRef, cap: string): string;
|
|
358
|
+
export declare function compositionReadKey(read: CompositionFieldRead): string;
|
|
359
|
+
export declare function composedDeviceStableId(blockId: string): string;
|
|
360
|
+
export declare function composedDeviceRef(blockId: string): CompositionSourceRef;
|
|
361
|
+
/** Every device field a source reads: `from` is one read, an expression is its `from` bindings. */
|
|
362
|
+
export declare function fieldReads(source: CompositionFieldSource): readonly CompositionFieldRead[];
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One composed field, evaluated from what its sources say NOW (D659).
|
|
3
|
+
*
|
|
4
|
+
* Pure. The composer calls it on every source change, and the slice-5 editor
|
|
5
|
+
* will call it for its live preview, so both see the same answer.
|
|
6
|
+
*
|
|
7
|
+
* The rules (spec §2):
|
|
8
|
+
* - a source that is offline or unreadable keeps its last value and is marked
|
|
9
|
+
* STALE; the field is stale and keeps computing (D49);
|
|
10
|
+
* - a source that is GONE makes the field UNAVAILABLE, `fatal`, and never a
|
|
11
|
+
* plausible number (D393);
|
|
12
|
+
* - a source that is unavailable but NOT gone (e.g. a cap unregistered at
|
|
13
|
+
* runtime, R7b) makes the field UNAVAILABLE, non-fatal, `value: null`: it
|
|
14
|
+
* may come back on its own, no block failure is raised for it;
|
|
15
|
+
* - an expression that fails on a value makes the field unavailable for that
|
|
16
|
+
* value, and NOT fatal: the next value may compute.
|
|
17
|
+
*
|
|
18
|
+
* When an expression has more than one unavailable binding, a FATAL one always
|
|
19
|
+
* wins the outcome, regardless of position: every binding is scanned before
|
|
20
|
+
* the field is judged, so an earlier non-fatal binding (e.g. a cap that is
|
|
21
|
+
* momentarily unregistered) can never hide a later fatal one (a deleted
|
|
22
|
+
* source) behind an early return.
|
|
23
|
+
*/
|
|
24
|
+
import type { ExpressionValue } from '../expression/ast.js';
|
|
25
|
+
import { type CompositionFieldRead, type CompositionFieldSource } from './composition.js';
|
|
26
|
+
export interface SourceFreshReading {
|
|
27
|
+
readonly state: 'fresh';
|
|
28
|
+
readonly value: ExpressionValue;
|
|
29
|
+
}
|
|
30
|
+
export interface SourceStaleReading {
|
|
31
|
+
readonly state: 'stale';
|
|
32
|
+
readonly value: ExpressionValue;
|
|
33
|
+
readonly reason: string;
|
|
34
|
+
}
|
|
35
|
+
export interface SourceUnavailableReading {
|
|
36
|
+
readonly state: 'unavailable';
|
|
37
|
+
readonly reason: string;
|
|
38
|
+
/** True when the source is GONE: device or cap missing, two reads agreed. */
|
|
39
|
+
readonly fatal: boolean;
|
|
40
|
+
}
|
|
41
|
+
export type SourceReading = SourceFreshReading | SourceStaleReading | SourceUnavailableReading;
|
|
42
|
+
export type SourceReader = (read: CompositionFieldRead) => SourceReading;
|
|
43
|
+
export interface FieldValueOutcome {
|
|
44
|
+
readonly state: 'fresh' | 'stale';
|
|
45
|
+
readonly value: ExpressionValue;
|
|
46
|
+
readonly reason: string | null;
|
|
47
|
+
/** When a windowed builtin's answer flips on its own; null when nothing will. */
|
|
48
|
+
readonly deadline: number | null;
|
|
49
|
+
}
|
|
50
|
+
export interface FieldUnavailableOutcome {
|
|
51
|
+
readonly state: 'unavailable';
|
|
52
|
+
/** Always `null` — an unavailable field is never a stand-in value (D393). */
|
|
53
|
+
readonly value: null;
|
|
54
|
+
readonly reason: string;
|
|
55
|
+
readonly fatal: boolean;
|
|
56
|
+
}
|
|
57
|
+
export type FieldOutcome = FieldValueOutcome | FieldUnavailableOutcome;
|
|
58
|
+
export interface EvaluateCompositionFieldInput {
|
|
59
|
+
readonly source: CompositionFieldSource;
|
|
60
|
+
readonly read: SourceReader;
|
|
61
|
+
readonly now: number;
|
|
62
|
+
}
|
|
63
|
+
export declare function evaluateCompositionField(input: EvaluateCompositionFieldInput): FieldOutcome;
|