@githolon/dsl 0.108.0 → 0.108.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.
- package/dart/CHANGELOG.md +5 -0
- package/dart/lib/src/application_framework_calls.dart +299 -0
- package/dart/lib/src/generated_call.dart +96 -0
- package/dart/lib/src/nms_generated_runtime.dart +29 -0
- package/dart/lib/src/node_runner_transport.dart +77 -1
- package/dart/lib/src/result_usda.dart +487 -0
- package/dart/lib/src/runner/node-entry.mjs +6401 -2102
- package/dart/lib/src/runner/offline-install.mjs +1538 -163
- package/dart/lib/src/runtime_v2_gateway.dart +54 -0
- package/dart/lib/src/runtime_v2_transport.dart +117 -0
- package/dart/lib/src/session_bound.dart +7 -2
- package/dart/lib/src/test_harness.dart +193 -112
- package/dart/lib/src/webview_bridge.dart +2120 -569
- package/dart/pubspec.yaml +2 -2
- package/dart/test/acquire_session_credentials_test.dart +1 -1
- package/dart/test/acquire_session_test.dart +68 -14
- package/dart/test/adv_realm_interference_test.dart +6 -4
- package/dart/test/cluster_births_test.dart +11 -8
- package/dart/test/cluster_local_autosync_test.dart +1 -1
- package/dart/test/cluster_scale_test.dart +3 -2
- package/dart/test/dlq_session_surface_test.dart +52 -35
- package/dart/test/first_app_gauntlet_test.dart +1 -1
- package/dart/test/local_sync_inert_test.dart +23 -26
- package/dart/test/offer_authentication_proof_test.dart +193 -0
- package/dart/test/result_usda_test.dart +49 -0
- package/dart/test/session_bound_test.dart +8 -11
- package/dart/test/stale_bundle_test.dart +18 -3
- package/dart/test/test_harness_test.dart +14 -27
- package/dart/test/webview_bridge_test.dart +504 -83
- package/dart_types/CHANGELOG.md +7 -0
- package/dart_types/lib/nomos_kernel_protocol.dart +3 -2
- package/dart_types/lib/src/custody.dart +64 -19
- package/dart_types/lib/src/local_work_rejected.dart +30 -45
- package/dart_types/lib/src/proto/nomos/custody/v1/snapshot.pb.dart +169 -0
- package/dart_types/lib/src/proto/nomos/custody/v1/snapshot.pbenum.dart +11 -0
- package/dart_types/lib/src/proto/nomos/kernel/v1/kernel.pb.dart +2021 -234
- package/dart_types/lib/src/proto/nomos/kernel/v1/kernel.pbenum.dart +175 -8
- package/dart_types/lib/src/proto/nomos/runtime/v2/runtime.pb.dart +8664 -0
- package/dart_types/lib/src/proto/nomos/runtime/v2/runtime.pbenum.dart +369 -0
- package/dart_types/lib/src/surfaced.dart +30 -25
- package/dart_types/pubspec.yaml +1 -1
- package/dart_types/test/surfaced_test.dart +2 -1
- package/package.json +1 -1
- package/runtime/generated-application-host.js +5736 -2047
- package/src/authoring.ts +3 -2
- package/src/births.ts +21 -0
- package/src/build_package.ts +30 -0
- package/src/business_birth.ts +39 -35
- package/src/codegen_call_usda.ts +1111 -0
- package/src/codegen_dart.ts +207 -282
- package/src/codegen_dart_application.ts +195 -252
- package/src/codegen_dart_client.ts +1978 -593
- package/src/codegen_dart_framework_calls.ts +291 -0
- package/src/codegen_dart_scenario.ts +7 -0
- package/src/codegen_proof.ts +3 -4
- package/src/codegen_provider_dart.ts +21 -7
- package/src/codegen_query_usda.ts +214 -0
- package/src/codegen_result_usda.ts +685 -0
- package/src/codegen_ts.ts +3945 -1111
- package/src/compile_package_main.ts +360 -32
- package/src/directive.ts +19 -4
- package/src/engine_entry.ts +45 -4
- package/src/framework/application_home.ts +2 -0
- package/src/framework/auth_provider_law.ts +262 -20
- package/src/framework/home.ts +32 -28
- package/src/framework/owned_custody.ts +19 -11
- package/src/framework/owned_custody_value.ts +51 -0
- package/src/framework/relations.ts +57 -21
- package/src/framework/signing_identity.ts +34 -0
- package/src/framework/workspaces.ts +31 -9
- package/src/framework_call_definitions.ts +53 -0
- package/src/framework_read_definitions.ts +45 -0
- package/src/identity_frontier.ts +58 -0
- package/src/index.ts +20 -1
- package/src/intent.ts +216 -16
- package/src/law_check.ts +19 -1
- package/src/law_graph.ts +57 -8
- package/src/law_graph_usda.ts +73 -5
- package/src/law_value_type.ts +106 -19
- package/src/read.ts +47 -0
- package/src/read_projection_namespace.ts +7 -0
- package/src/shape_compat.ts +38 -39
- package/src/stable_ids.ts +37 -2
- package/src/stable_ids_for_module.ts +64 -4
- package/src/test_call_usda.ts +83 -0
- package/src/wire.ts +36 -2
- package/src/wire_encode.ts +45 -1
- package/src/workspace_sharing.ts +27 -10
- package/dart_types/lib/src/proto/nomos/kernel/v1/kernel.pbjson.dart +0 -6096
- package/dart_types/lib/src/proto/nomos/kernel/v1/kernel.pbserver.dart +0 -50
- package/dart_types/lib/src/proto/nomos/kernel/v1/progress.pbjson.dart +0 -178
- package/dart_types/lib/src/proto/nomos/runtime/v1/runtime.pb.dart +0 -828
- package/dart_types/lib/src/proto/nomos/runtime/v1/runtime.pbenum.dart +0 -465
- package/dart_types/lib/src/proto/nomos/runtime/v1/runtime.pbjson.dart +0 -573
- package/dart_types/lib/src/proto/nomos/runtime/v1/runtime.pbserver.dart +0 -50
package/dart/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
## 0.65.1
|
|
2
|
+
|
|
3
|
+
- Publish the generated nominal application call and query surfaces required by current DSL output, so
|
|
4
|
+
Flutter consumers retain typed USDA calls instead of falling back to legacy generic boundaries.
|
|
5
|
+
|
|
1
6
|
## 0.65.0
|
|
2
7
|
|
|
3
8
|
- Consume the generated typed offer-admission ABI from `nomos_types` 0.9.0 and keep current birth
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
// AUTO-GENERATED by scripts/generate_framework_contracts.ts from authored DSL directives.
|
|
2
|
+
// Do not edit: implementations are emitted from each application's composed USDA graph.
|
|
3
|
+
import 'dart:convert' show utf8;
|
|
4
|
+
import 'dart:typed_data' show Uint8List;
|
|
5
|
+
import 'package:meta/meta.dart' show internal;
|
|
6
|
+
import 'package:nomos_types/nomos_types.dart' show Sha256Digest;
|
|
7
|
+
import 'package:nomos_types/nomos_kernel_protocol.dart' show BirthCertificate;
|
|
8
|
+
|
|
9
|
+
import 'generated_call.dart';
|
|
10
|
+
import 'result_usda.dart' show NmsUsdaLayer, NmsUsdaPrim;
|
|
11
|
+
|
|
12
|
+
/// Compiler-generated framework value 'OwnedCustody'.
|
|
13
|
+
/// Its canonical semantic representation is USDA; this class is the typed Dart view.
|
|
14
|
+
final class OwnedCustody {
|
|
15
|
+
final String ct;
|
|
16
|
+
final String hpkeEpk;
|
|
17
|
+
final String keyCommitment;
|
|
18
|
+
final String principalWrappingPublic;
|
|
19
|
+
final OwnedDeviceRequest request;
|
|
20
|
+
final int v;
|
|
21
|
+
|
|
22
|
+
const OwnedCustody({
|
|
23
|
+
required this.ct,
|
|
24
|
+
required this.hpkeEpk,
|
|
25
|
+
required this.keyCommitment,
|
|
26
|
+
required this.principalWrappingPublic,
|
|
27
|
+
required this.request,
|
|
28
|
+
required this.v,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
Uint8List encodeUsda() => Uint8List.fromList(utf8.encode(<String>[
|
|
32
|
+
'#usda 1.0',
|
|
33
|
+
'(',
|
|
34
|
+
' defaultPrim = "FrameworkValue"',
|
|
35
|
+
')',
|
|
36
|
+
'',
|
|
37
|
+
'def NomosFrameworkValue "FrameworkValue"',
|
|
38
|
+
'{',
|
|
39
|
+
" def NomosOwnedCustody \"OwnedCustody\"",
|
|
40
|
+
" {",
|
|
41
|
+
" custom string nomos:ct = ${NmsUsdaLayer.quote(this.ct)}",
|
|
42
|
+
" custom string nomos:hpkeEpk = ${NmsUsdaLayer.quote(this.hpkeEpk)}",
|
|
43
|
+
" custom string nomos:keyCommitment = ${NmsUsdaLayer.quote(this.keyCommitment)}",
|
|
44
|
+
" custom string nomos:principalWrappingPublic = ${NmsUsdaLayer.quote(this.principalWrappingPublic)}",
|
|
45
|
+
" def NomosOwnedDeviceRequest \"Request\"",
|
|
46
|
+
" {",
|
|
47
|
+
" custom string nomos:principal = ${NmsUsdaLayer.quote(this.request.principal)}",
|
|
48
|
+
" custom string nomos:scope = ${NmsUsdaLayer.quote(this.request.scope)}",
|
|
49
|
+
" custom string nomos:signature = ${NmsUsdaLayer.quote(this.request.signature)}",
|
|
50
|
+
" custom string nomos:signingPublic = ${NmsUsdaLayer.quote(this.request.signingPublic)}",
|
|
51
|
+
" custom uint nomos:v = ${this.request.v}",
|
|
52
|
+
" custom string nomos:workspace = ${NmsUsdaLayer.quote(this.request.workspace)}",
|
|
53
|
+
" custom string nomos:wrappingPublic = ${NmsUsdaLayer.quote(this.request.wrappingPublic)}",
|
|
54
|
+
" }",
|
|
55
|
+
" custom uint nomos:v = ${this.v}",
|
|
56
|
+
" }",
|
|
57
|
+
'}',
|
|
58
|
+
'',
|
|
59
|
+
].join('\n')));
|
|
60
|
+
|
|
61
|
+
factory OwnedCustody.decodeUsda(Uint8List bytes) {
|
|
62
|
+
final root = NmsUsdaLayer.parse(bytes);
|
|
63
|
+
if (root.typeName != 'NomosFrameworkValue' || root.name != 'FrameworkValue' || root.properties.isNotEmpty || root.children.length != 1) throw const FormatException('Invalid framework value USDA');
|
|
64
|
+
return _nmsDecodeOwnedCustodyUsdaPrim(_nmsFrameworkUsdaChild(root, "NomosOwnedCustody", "OwnedCustody", "OwnedCustody"));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/// Compiler-generated framework value 'OwnedDeviceRequest'.
|
|
69
|
+
/// Its canonical semantic representation is USDA; this class is the typed Dart view.
|
|
70
|
+
final class OwnedDeviceRequest {
|
|
71
|
+
final String principal;
|
|
72
|
+
final String scope;
|
|
73
|
+
final String signature;
|
|
74
|
+
final String signingPublic;
|
|
75
|
+
final int v;
|
|
76
|
+
final String workspace;
|
|
77
|
+
final String wrappingPublic;
|
|
78
|
+
|
|
79
|
+
const OwnedDeviceRequest({
|
|
80
|
+
required this.principal,
|
|
81
|
+
required this.scope,
|
|
82
|
+
required this.signature,
|
|
83
|
+
required this.signingPublic,
|
|
84
|
+
required this.v,
|
|
85
|
+
required this.workspace,
|
|
86
|
+
required this.wrappingPublic,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
Uint8List encodeUsda() => Uint8List.fromList(utf8.encode(<String>[
|
|
90
|
+
'#usda 1.0',
|
|
91
|
+
'(',
|
|
92
|
+
' defaultPrim = "FrameworkValue"',
|
|
93
|
+
')',
|
|
94
|
+
'',
|
|
95
|
+
'def NomosFrameworkValue "FrameworkValue"',
|
|
96
|
+
'{',
|
|
97
|
+
" def NomosOwnedDeviceRequest \"Request\"",
|
|
98
|
+
" {",
|
|
99
|
+
" custom string nomos:principal = ${NmsUsdaLayer.quote(this.principal)}",
|
|
100
|
+
" custom string nomos:scope = ${NmsUsdaLayer.quote(this.scope)}",
|
|
101
|
+
" custom string nomos:signature = ${NmsUsdaLayer.quote(this.signature)}",
|
|
102
|
+
" custom string nomos:signingPublic = ${NmsUsdaLayer.quote(this.signingPublic)}",
|
|
103
|
+
" custom uint nomos:v = ${this.v}",
|
|
104
|
+
" custom string nomos:workspace = ${NmsUsdaLayer.quote(this.workspace)}",
|
|
105
|
+
" custom string nomos:wrappingPublic = ${NmsUsdaLayer.quote(this.wrappingPublic)}",
|
|
106
|
+
" }",
|
|
107
|
+
'}',
|
|
108
|
+
'',
|
|
109
|
+
].join('\n')));
|
|
110
|
+
|
|
111
|
+
factory OwnedDeviceRequest.decodeUsda(Uint8List bytes) {
|
|
112
|
+
final root = NmsUsdaLayer.parse(bytes);
|
|
113
|
+
if (root.typeName != 'NomosFrameworkValue' || root.name != 'FrameworkValue' || root.properties.isNotEmpty || root.children.length != 1) throw const FormatException('Invalid framework value USDA');
|
|
114
|
+
return _nmsDecodeOwnedDeviceRequestUsdaPrim(_nmsFrameworkUsdaChild(root, "NomosOwnedDeviceRequest", "Request", "OwnedDeviceRequest"));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
NmsUsdaPrim _nmsFrameworkUsdaChild(NmsUsdaPrim prim, String typeName, String name, String path) {
|
|
119
|
+
final matches = prim.children.where((child) => child.typeName == typeName && child.name == name).toList(growable: false);
|
|
120
|
+
if (matches.length != 1) throw FormatException('$path must contain exactly one $typeName child');
|
|
121
|
+
return matches.single;
|
|
122
|
+
}
|
|
123
|
+
String _nmsFrameworkUsdaString(NmsUsdaPrim prim, String name, String path) { final value = prim.property(name); if (value is! String) throw FormatException('$path must be text'); return value; }
|
|
124
|
+
int _nmsFrameworkUsdaInteger(NmsUsdaPrim prim, String name, String path) { final value = prim.property(name); if (value is! int) throw FormatException('$path must be an exact integer'); return value; }
|
|
125
|
+
|
|
126
|
+
OwnedDeviceRequest _nmsDecodeOwnedDeviceRequestUsdaPrim(NmsUsdaPrim prim) {
|
|
127
|
+
if (prim.typeName != "NomosOwnedDeviceRequest" || prim.properties.length != 7 || prim.children.length != 0) throw const FormatException("Invalid OwnedDeviceRequest USDA");
|
|
128
|
+
return OwnedDeviceRequest(
|
|
129
|
+
principal: _nmsFrameworkUsdaString(prim, "nomos:principal", "OwnedDeviceRequest.principal"),
|
|
130
|
+
scope: _nmsFrameworkUsdaString(prim, "nomos:scope", "OwnedDeviceRequest.scope"),
|
|
131
|
+
signature: _nmsFrameworkUsdaString(prim, "nomos:signature", "OwnedDeviceRequest.signature"),
|
|
132
|
+
signingPublic: _nmsFrameworkUsdaString(prim, "nomos:signingPublic", "OwnedDeviceRequest.signingPublic"),
|
|
133
|
+
v: _nmsFrameworkUsdaInteger(prim, "nomos:v", "OwnedDeviceRequest.v"),
|
|
134
|
+
workspace: _nmsFrameworkUsdaString(prim, "nomos:workspace", "OwnedDeviceRequest.workspace"),
|
|
135
|
+
wrappingPublic: _nmsFrameworkUsdaString(prim, "nomos:wrappingPublic", "OwnedDeviceRequest.wrappingPublic"),
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
OwnedCustody _nmsDecodeOwnedCustodyUsdaPrim(NmsUsdaPrim prim) {
|
|
140
|
+
if (prim.typeName != "NomosOwnedCustody" || prim.properties.length != 5 || prim.children.length != 1) throw const FormatException("Invalid OwnedCustody USDA");
|
|
141
|
+
return OwnedCustody(
|
|
142
|
+
ct: _nmsFrameworkUsdaString(prim, "nomos:ct", "OwnedCustody.ct"),
|
|
143
|
+
hpkeEpk: _nmsFrameworkUsdaString(prim, "nomos:hpkeEpk", "OwnedCustody.hpkeEpk"),
|
|
144
|
+
keyCommitment: _nmsFrameworkUsdaString(prim, "nomos:keyCommitment", "OwnedCustody.keyCommitment"),
|
|
145
|
+
principalWrappingPublic: _nmsFrameworkUsdaString(prim, "nomos:principalWrappingPublic", "OwnedCustody.principalWrappingPublic"),
|
|
146
|
+
request: _nmsDecodeOwnedDeviceRequestUsdaPrim(_nmsFrameworkUsdaChild(prim, "NomosOwnedDeviceRequest", "Request", "OwnedCustody.request")),
|
|
147
|
+
v: _nmsFrameworkUsdaInteger(prim, "nomos:v", "OwnedCustody.v"),
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@internal
|
|
152
|
+
final class NmsInvitationMaterial {
|
|
153
|
+
final String source;
|
|
154
|
+
final String secret;
|
|
155
|
+
final String publicKey;
|
|
156
|
+
|
|
157
|
+
const NmsInvitationMaterial({
|
|
158
|
+
required this.source,
|
|
159
|
+
required this.secret,
|
|
160
|
+
required this.publicKey,
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
Uint8List encodeUsda() => Uint8List.fromList(utf8.encode(<String>[
|
|
164
|
+
'#usda 1.0',
|
|
165
|
+
'(',
|
|
166
|
+
' defaultPrim = "Invitation"',
|
|
167
|
+
')',
|
|
168
|
+
'def NomosInvitationMaterial "Invitation"',
|
|
169
|
+
'{',
|
|
170
|
+
' custom token nomos:format = ${NmsUsdaLayer.quote("nomos-invitation-v1")}',
|
|
171
|
+
' custom string nomos:source = ${NmsUsdaLayer.quote(source)}',
|
|
172
|
+
' custom string nomos:secret = ${NmsUsdaLayer.quote(secret)}',
|
|
173
|
+
' custom string nomos:publicKey = ${NmsUsdaLayer.quote(publicKey)}',
|
|
174
|
+
'}',
|
|
175
|
+
'',
|
|
176
|
+
].join('\n')));
|
|
177
|
+
|
|
178
|
+
factory NmsInvitationMaterial.decodeUsda(Uint8List bytes) {
|
|
179
|
+
final root = NmsUsdaLayer.parse(bytes);
|
|
180
|
+
if (root.typeName != 'NomosInvitationMaterial' || root.name != 'Invitation' || root.children.isNotEmpty || root.properties.length != 4) {
|
|
181
|
+
throw const FormatException('Invalid Nomos invitation material USDA');
|
|
182
|
+
}
|
|
183
|
+
String property(String name) {
|
|
184
|
+
final value = root.property(name);
|
|
185
|
+
if (value is! String || value.isEmpty) throw FormatException('Invalid invitation material property $name');
|
|
186
|
+
return value;
|
|
187
|
+
}
|
|
188
|
+
if (property('nomos:format') != "nomos-invitation-v1") {
|
|
189
|
+
throw const FormatException('Unsupported Nomos invitation format');
|
|
190
|
+
}
|
|
191
|
+
return NmsInvitationMaterial(
|
|
192
|
+
source: property('nomos:source'),
|
|
193
|
+
secret: property('nomos:secret'),
|
|
194
|
+
publicKey: property('nomos:publicKey'),
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
@internal
|
|
200
|
+
abstract interface class NmsApplicationFrameworkCalls {
|
|
201
|
+
String get applicationHomeDomain;
|
|
202
|
+
|
|
203
|
+
NmsGeneratedCall enrollFirstDevice({
|
|
204
|
+
required String domain,
|
|
205
|
+
required String workspace,
|
|
206
|
+
required String keyHash,
|
|
207
|
+
required String verifiedVia,
|
|
208
|
+
required int validFromEpoch,
|
|
209
|
+
required String grantedAt,
|
|
210
|
+
required String idpToken,
|
|
211
|
+
String? delegationCert,
|
|
212
|
+
BirthCertificate delegationCertificate,
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
NmsGeneratedCall enrollSigner({
|
|
216
|
+
required String domain,
|
|
217
|
+
required String workspace,
|
|
218
|
+
required String keyHash,
|
|
219
|
+
required String grantedBy,
|
|
220
|
+
required int grantedAt,
|
|
221
|
+
String? verifiedVia,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
NmsGeneratedCall birthReceivingGroup({
|
|
225
|
+
required String domain,
|
|
226
|
+
required String workspace,
|
|
227
|
+
required String owner,
|
|
228
|
+
required Sha256Digest frameworkHash,
|
|
229
|
+
required Sha256Digest lawHash,
|
|
230
|
+
required String bornAt,
|
|
231
|
+
bool? inheritAuthProvider,
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
NmsGeneratedCall seedBirthPolicy({
|
|
235
|
+
required String domain,
|
|
236
|
+
required String workspace,
|
|
237
|
+
required int maxBirthsPerPrincipal,
|
|
238
|
+
required String setBy,
|
|
239
|
+
required String setAt,
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
NmsGeneratedCall enrollDelegation({
|
|
243
|
+
required String domain,
|
|
244
|
+
required String workspace,
|
|
245
|
+
required String user,
|
|
246
|
+
required String deviceKey,
|
|
247
|
+
required BirthCertificate certificate,
|
|
248
|
+
required String enrolledAt,
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
NmsGeneratedCall seedBirthAttestation({
|
|
252
|
+
required String domain,
|
|
253
|
+
required String workspace,
|
|
254
|
+
required String child,
|
|
255
|
+
required String founder,
|
|
256
|
+
required String verified,
|
|
257
|
+
required String parentId,
|
|
258
|
+
required String parentKey,
|
|
259
|
+
required int epoch,
|
|
260
|
+
required List<BirthCertificate> links,
|
|
261
|
+
List<String>? parentWorkspaceRoles,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
NmsGeneratedCall seedGenesis({
|
|
265
|
+
required String domain,
|
|
266
|
+
required String workspace,
|
|
267
|
+
required String principal,
|
|
268
|
+
required String workspaceId,
|
|
269
|
+
required String bornAt,
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
NmsGeneratedCall seedReceivingGroupPolicy({
|
|
273
|
+
required String domain,
|
|
274
|
+
required String workspace,
|
|
275
|
+
required String setAt,
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
NmsGeneratedCall seedReceivingGroup({
|
|
279
|
+
required String domain,
|
|
280
|
+
required String workspace,
|
|
281
|
+
required String principal,
|
|
282
|
+
required String workspaceName,
|
|
283
|
+
required String bornAt,
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
NmsGeneratedCall redeemInvitation({
|
|
287
|
+
required String domain,
|
|
288
|
+
required String workspace,
|
|
289
|
+
required String directive,
|
|
290
|
+
required String orderId,
|
|
291
|
+
required String object,
|
|
292
|
+
required String relation,
|
|
293
|
+
required String invitationPublicKey,
|
|
294
|
+
required String invitationSignature,
|
|
295
|
+
required String invitationId,
|
|
296
|
+
required String redeemedAt,
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import 'dart:typed_data';
|
|
2
|
+
|
|
3
|
+
import 'package:meta/meta.dart' show internal;
|
|
4
|
+
|
|
5
|
+
/// One compiler-authored, nominal domain call.
|
|
6
|
+
///
|
|
7
|
+
/// Generated applications construct this directly from their typed input. The
|
|
8
|
+
/// host may carry it but cannot reinterpret its value; the kernel reopens the
|
|
9
|
+
/// canonical USDA and verifies that [domain] and [directive] resolve to the
|
|
10
|
+
/// exact identities embedded in [canonicalUsda].
|
|
11
|
+
@internal
|
|
12
|
+
abstract interface class NmsGeneratedCall {
|
|
13
|
+
String get domain;
|
|
14
|
+
String get directive;
|
|
15
|
+
Uint8List get canonicalUsda;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/// One compiler-authored nominal application query.
|
|
19
|
+
///
|
|
20
|
+
/// The public application method retains its generated Dart parameter types. This value is the
|
|
21
|
+
/// cross-language continuation of those types: canonical USDA relates the query and every
|
|
22
|
+
/// argument to the exact composed-law identities. Protobuf carries these bytes but does not
|
|
23
|
+
/// replace the application's type system with a generic object.
|
|
24
|
+
@internal
|
|
25
|
+
abstract interface class NmsGeneratedQuery {
|
|
26
|
+
String get domain;
|
|
27
|
+
String get query;
|
|
28
|
+
Uint8List get canonicalArgumentsUsda;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// Constructor namespace reserved for generated application code.
|
|
32
|
+
///
|
|
33
|
+
/// Keeping the three transport facts in one immutable value prevents generated
|
|
34
|
+
/// code from accidentally pairing bytes from one directive with routing hints
|
|
35
|
+
/// from another. Untrusted callers gain no authority by constructing one: the
|
|
36
|
+
/// kernel independently validates the USDA against admitted law.
|
|
37
|
+
@internal
|
|
38
|
+
abstract final class NmsInternalGeneratedCalls {
|
|
39
|
+
static NmsGeneratedCall create({
|
|
40
|
+
required String domain,
|
|
41
|
+
required String directive,
|
|
42
|
+
required Uint8List canonicalUsda,
|
|
43
|
+
}) {
|
|
44
|
+
if (domain.isEmpty || directive.isEmpty) {
|
|
45
|
+
throw ArgumentError('A generated Nomos call needs nominal routing identity.');
|
|
46
|
+
}
|
|
47
|
+
if (canonicalUsda.isEmpty) {
|
|
48
|
+
throw ArgumentError('A generated Nomos call needs canonical USDA.');
|
|
49
|
+
}
|
|
50
|
+
return _GeneratedCall(domain, directive, canonicalUsda);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/// Constructor namespace reserved for generated query code.
|
|
55
|
+
@internal
|
|
56
|
+
abstract final class NmsInternalGeneratedQueries {
|
|
57
|
+
static NmsGeneratedQuery create({
|
|
58
|
+
required String domain,
|
|
59
|
+
required String query,
|
|
60
|
+
required Uint8List canonicalArgumentsUsda,
|
|
61
|
+
}) {
|
|
62
|
+
if (domain.isEmpty || query.isEmpty) {
|
|
63
|
+
throw ArgumentError('A generated Nomos query needs nominal routing identity.');
|
|
64
|
+
}
|
|
65
|
+
if (canonicalArgumentsUsda.isEmpty) {
|
|
66
|
+
throw ArgumentError('A generated Nomos query needs canonical USDA arguments.');
|
|
67
|
+
}
|
|
68
|
+
return _GeneratedQuery(domain, query, canonicalArgumentsUsda);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
final class _GeneratedCall implements NmsGeneratedCall {
|
|
73
|
+
const _GeneratedCall(this.domain, this.directive, this.canonicalUsda);
|
|
74
|
+
|
|
75
|
+
@override
|
|
76
|
+
final String domain;
|
|
77
|
+
|
|
78
|
+
@override
|
|
79
|
+
final String directive;
|
|
80
|
+
|
|
81
|
+
@override
|
|
82
|
+
final Uint8List canonicalUsda;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
final class _GeneratedQuery implements NmsGeneratedQuery {
|
|
86
|
+
const _GeneratedQuery(this.domain, this.query, this.canonicalArgumentsUsda);
|
|
87
|
+
|
|
88
|
+
@override
|
|
89
|
+
final String domain;
|
|
90
|
+
|
|
91
|
+
@override
|
|
92
|
+
final String query;
|
|
93
|
+
|
|
94
|
+
@override
|
|
95
|
+
final Uint8List canonicalArgumentsUsda;
|
|
96
|
+
}
|
|
@@ -7,6 +7,14 @@ library;
|
|
|
7
7
|
import 'package:meta/meta.dart' show internal;
|
|
8
8
|
|
|
9
9
|
export 'package:nomos_types/nomos_types.dart';
|
|
10
|
+
export 'package:nomos_types/nomos_kernel_protocol.dart'
|
|
11
|
+
show
|
|
12
|
+
CustodyBreakDecision,
|
|
13
|
+
CustodyBreakResolved,
|
|
14
|
+
ModelDifferenceKind,
|
|
15
|
+
ModelLifecycleResponse,
|
|
16
|
+
ModelLifecycleStage,
|
|
17
|
+
WorkspaceSummary;
|
|
10
18
|
export 'package:nomos_types/src/nomos_ref.dart' show NmsInternalNomosRefs;
|
|
11
19
|
export 'package:nomos_types/src/versioned_nomos_ref.dart'
|
|
12
20
|
show NmsInternalVersionedNomosRefs;
|
|
@@ -29,3 +37,24 @@ export 'session_bound.dart';
|
|
|
29
37
|
export 'provider.dart';
|
|
30
38
|
export 'record_origin.dart';
|
|
31
39
|
export 'source_trust.dart';
|
|
40
|
+
export 'generated_call.dart'
|
|
41
|
+
show
|
|
42
|
+
NmsGeneratedCall,
|
|
43
|
+
NmsGeneratedQuery,
|
|
44
|
+
NmsInternalGeneratedCalls,
|
|
45
|
+
NmsInternalGeneratedQueries;
|
|
46
|
+
export 'application_framework_calls.dart' show OwnedCustody, OwnedDeviceRequest;
|
|
47
|
+
export 'result_usda.dart'
|
|
48
|
+
show
|
|
49
|
+
NmsUsdaPrim,
|
|
50
|
+
NmsUsdaResult,
|
|
51
|
+
NmsUsdaConflictResult,
|
|
52
|
+
NmsUsdaConflictCount,
|
|
53
|
+
NmsUsdaConflictSummaryResult;
|
|
54
|
+
export 'runtime_v2_transport.dart'
|
|
55
|
+
show
|
|
56
|
+
NomosKernelCallTransport,
|
|
57
|
+
NomosRuntimeV2Transport,
|
|
58
|
+
NomosRuntimeV2EventTransport,
|
|
59
|
+
NomosRuntimeV2KernelCalls,
|
|
60
|
+
NmsBufferedRuntimeEvents;
|
|
@@ -18,13 +18,26 @@ import 'dart:io';
|
|
|
18
18
|
|
|
19
19
|
import 'package:package_config/package_config.dart' show loadPackageConfigUri;
|
|
20
20
|
|
|
21
|
+
import 'package:nomos_types/nomos_kernel_protocol.dart' as nomos_protocol;
|
|
22
|
+
|
|
23
|
+
import 'runtime_v2_transport.dart'
|
|
24
|
+
show
|
|
25
|
+
NmsBufferedRuntimeEvents,
|
|
26
|
+
NomosRuntimeV2EventTransport,
|
|
27
|
+
NomosRuntimeV2KernelCalls,
|
|
28
|
+
NomosRuntimeV2Transport;
|
|
21
29
|
import 'webview_bridge.dart' show BridgeTransport;
|
|
22
30
|
|
|
23
|
-
class NodeRunnerTransport
|
|
31
|
+
class NodeRunnerTransport
|
|
32
|
+
with NomosRuntimeV2KernelCalls
|
|
33
|
+
implements BridgeTransport, NomosRuntimeV2Transport, NomosRuntimeV2EventTransport {
|
|
24
34
|
final Process _proc;
|
|
25
35
|
final StreamController<Map<String, Object?>> _incoming =
|
|
26
36
|
StreamController<Map<String, Object?>>.broadcast();
|
|
37
|
+
final NmsBufferedRuntimeEvents _runtimeEvents = NmsBufferedRuntimeEvents();
|
|
27
38
|
final void Function(String line)? _onDiagnostic;
|
|
39
|
+
final Map<int, Completer<nomos_protocol.RuntimeResponse>> _runtimeReplies =
|
|
40
|
+
{};
|
|
28
41
|
bool _disposed = false;
|
|
29
42
|
|
|
30
43
|
NodeRunnerTransport._(this._proc, this._onDiagnostic) {
|
|
@@ -32,6 +45,33 @@ class NodeRunnerTransport implements BridgeTransport {
|
|
|
32
45
|
(line) {
|
|
33
46
|
final s = line.trim();
|
|
34
47
|
if (s.isEmpty) return;
|
|
48
|
+
if (s.startsWith('runtime-v2:')) {
|
|
49
|
+
try {
|
|
50
|
+
final response = nomos_protocol.RuntimeResponse.fromBuffer(
|
|
51
|
+
base64Decode(s.substring('runtime-v2:'.length)),
|
|
52
|
+
);
|
|
53
|
+
_runtimeReplies
|
|
54
|
+
.remove(response.requestId.toInt())
|
|
55
|
+
?.complete(response);
|
|
56
|
+
} catch (error, stackTrace) {
|
|
57
|
+
_diag('[nomos-node-runner runtime-v2] $error');
|
|
58
|
+
for (final reply in _runtimeReplies.values) {
|
|
59
|
+
if (!reply.isCompleted) reply.completeError(error, stackTrace);
|
|
60
|
+
}
|
|
61
|
+
_runtimeReplies.clear();
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (s.startsWith('runtime-v2-event:')) {
|
|
66
|
+
try {
|
|
67
|
+
_runtimeEvents.add(nomos_protocol.RuntimeEvent.fromBuffer(
|
|
68
|
+
base64Decode(s.substring('runtime-v2-event:'.length)),
|
|
69
|
+
));
|
|
70
|
+
} catch (error, stackTrace) {
|
|
71
|
+
_runtimeEvents.addError(error, stackTrace);
|
|
72
|
+
}
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
35
75
|
Object? decoded;
|
|
36
76
|
try {
|
|
37
77
|
decoded = jsonDecode(s);
|
|
@@ -140,16 +180,51 @@ class NodeRunnerTransport implements BridgeTransport {
|
|
|
140
180
|
@override
|
|
141
181
|
Stream<Map<String, Object?>> get messages => _incoming.stream;
|
|
142
182
|
|
|
183
|
+
@override
|
|
184
|
+
Stream<nomos_protocol.RuntimeEvent> get runtimeEvents => _runtimeEvents.stream;
|
|
185
|
+
|
|
143
186
|
@override
|
|
144
187
|
void send(Map<String, Object?> message) {
|
|
145
188
|
if (_disposed) throw StateError('NodeRunnerTransport is disposed');
|
|
146
189
|
_proc.stdin.writeln(jsonEncode(message));
|
|
147
190
|
}
|
|
148
191
|
|
|
192
|
+
/// Exchange one exact generated Runtime v2 frame with the headless runner.
|
|
193
|
+
/// The line prefix/base64 is only stdio framing; the command and result are
|
|
194
|
+
/// protobuf and are never reconstructed as a JSON object or operation name.
|
|
195
|
+
@override
|
|
196
|
+
Future<nomos_protocol.RuntimeResponse> invokeRuntime(
|
|
197
|
+
nomos_protocol.RuntimeRequest request,
|
|
198
|
+
) {
|
|
199
|
+
if (_disposed) throw StateError('NodeRunnerTransport is disposed');
|
|
200
|
+
final id = request.requestId.toInt();
|
|
201
|
+
if (_runtimeReplies.containsKey(id)) {
|
|
202
|
+
throw StateError('Runtime v2 request $id is already pending');
|
|
203
|
+
}
|
|
204
|
+
final reply = Completer<nomos_protocol.RuntimeResponse>();
|
|
205
|
+
_runtimeReplies[id] = reply;
|
|
206
|
+
try {
|
|
207
|
+
_proc.stdin.writeln(
|
|
208
|
+
'runtime-v2:${base64Encode(request.writeToBuffer())}',
|
|
209
|
+
);
|
|
210
|
+
} catch (error, stackTrace) {
|
|
211
|
+
_runtimeReplies.remove(id);
|
|
212
|
+
reply.completeError(error, stackTrace);
|
|
213
|
+
}
|
|
214
|
+
return reply.future;
|
|
215
|
+
}
|
|
216
|
+
|
|
149
217
|
/// Tear down: stop the runner process and close the message stream.
|
|
150
218
|
Future<void> dispose() async {
|
|
151
219
|
if (_disposed) return;
|
|
152
220
|
_disposed = true;
|
|
221
|
+
final pendingRuntime = _runtimeReplies.values.toList(growable: false);
|
|
222
|
+
_runtimeReplies.clear();
|
|
223
|
+
for (final reply in pendingRuntime) {
|
|
224
|
+
if (!reply.isCompleted) {
|
|
225
|
+
reply.completeError(StateError('NodeRunnerTransport is disposed'));
|
|
226
|
+
}
|
|
227
|
+
}
|
|
153
228
|
try {
|
|
154
229
|
await _proc.stdin.close();
|
|
155
230
|
} catch (_) {}
|
|
@@ -159,5 +234,6 @@ class NodeRunnerTransport implements BridgeTransport {
|
|
|
159
234
|
return -9;
|
|
160
235
|
});
|
|
161
236
|
await _incoming.close();
|
|
237
|
+
await _runtimeEvents.close();
|
|
162
238
|
}
|
|
163
239
|
}
|