@xemahq/composed-process-host 0.0.0-stage → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +175 -0
- package/bin/xema-composed-process.cjs +3 -0
- package/dist/bin/xema-composed-process.d.ts +3 -0
- package/dist/bin/xema-composed-process.d.ts.map +1 -0
- package/dist/bin/xema-composed-process.js +40 -0
- package/dist/bin/xema-composed-process.js.map +1 -0
- package/dist/biome-host-registry.d.ts +4 -0
- package/dist/biome-host-registry.d.ts.map +1 -0
- package/dist/biome-host-registry.js +48 -0
- package/dist/biome-host-registry.js.map +1 -0
- package/dist/composed-process-host.d.ts +24 -0
- package/dist/composed-process-host.d.ts.map +1 -0
- package/dist/composed-process-host.js +138 -0
- package/dist/composed-process-host.js.map +1 -0
- package/dist/event-hub-command-stream.d.ts +23 -0
- package/dist/event-hub-command-stream.d.ts.map +1 -0
- package/dist/event-hub-command-stream.js +28 -0
- package/dist/event-hub-command-stream.js.map +1 -0
- package/dist/generation-entry.d.ts +3 -0
- package/dist/generation-entry.d.ts.map +1 -0
- package/dist/generation-entry.js +26 -0
- package/dist/generation-entry.js.map +1 -0
- package/dist/host-platform.d.ts +7 -0
- package/dist/host-platform.d.ts.map +1 -0
- package/dist/host-platform.js +29 -0
- package/dist/host-platform.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/oci-bundle-store.d.ts +14 -0
- package/dist/oci-bundle-store.d.ts.map +1 -0
- package/dist/oci-bundle-store.js +46 -0
- package/dist/oci-bundle-store.js.map +1 -0
- package/dist/pack-bundle-reader.d.ts +3 -0
- package/dist/pack-bundle-reader.d.ts.map +1 -0
- package/dist/pack-bundle-reader.js +21 -0
- package/dist/pack-bundle-reader.js.map +1 -0
- package/dist/seed-closure.d.ts +33 -0
- package/dist/seed-closure.d.ts.map +1 -0
- package/dist/seed-closure.js +81 -0
- package/dist/seed-closure.js.map +1 -0
- package/dist/seed-closure.json +239 -0
- package/dist/seed-platform-registration.d.ts +17 -0
- package/dist/seed-platform-registration.d.ts.map +1 -0
- package/dist/seed-platform-registration.js +44 -0
- package/dist/seed-platform-registration.js.map +1 -0
- package/dist/seed-processes.d.ts +22 -0
- package/dist/seed-processes.d.ts.map +1 -0
- package/dist/seed-processes.js +123 -0
- package/dist/seed-processes.js.map +1 -0
- package/package.json +71 -4
- package/scripts/write-seed-closure.mjs +25 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Xema Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
License text copyright (c) 2020 MariaDB Corporation Ab, All Rights Reserved.
|
|
4
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
5
|
+
|
|
6
|
+
-----------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
Parameters
|
|
9
|
+
|
|
10
|
+
Licensor: Neuralchowder Inc.
|
|
11
|
+
|
|
12
|
+
Licensed Work: Xema. The Licensed Work is (c) 2026 Neuralchowder Inc.
|
|
13
|
+
|
|
14
|
+
The Licensed Work includes, without limitation, Xema Core, Xema Runtime,
|
|
15
|
+
Xema Kernel, Xema control plane, Xema application runtime, Xema biome
|
|
16
|
+
runtime, Xema biome registry, Xema store services, Xema orchestration
|
|
17
|
+
services, Xema agents, Xema skills, Xema memory services, Xema APIs, Xema
|
|
18
|
+
user interfaces, Xema command-line tools, Xema deployment artifacts, Xema
|
|
19
|
+
templates, Xema specifications, Xema schemas, Xema manifests, Xema
|
|
20
|
+
documentation, Xema examples, and all source code, object code, binaries,
|
|
21
|
+
packages, modules, configuration files, manifests, schemas, examples,
|
|
22
|
+
templates, documentation, and derivative works included in or distributed
|
|
23
|
+
as part of the Xema software project.
|
|
24
|
+
|
|
25
|
+
The Licensed Work does not include any third-party software, libraries,
|
|
26
|
+
dependencies, packages, assets, or components that are distributed with the
|
|
27
|
+
Licensed Work but are governed by their own separate license terms. Such
|
|
28
|
+
third-party materials remain subject to their respective licenses.
|
|
29
|
+
|
|
30
|
+
A specific file, package, component, or directory may state that it is
|
|
31
|
+
governed by a different license. In that case, that specific file, package,
|
|
32
|
+
component, or directory is governed by the license expressly stated therein.
|
|
33
|
+
|
|
34
|
+
Additional Use Grant:
|
|
35
|
+
|
|
36
|
+
You may make production use of the Licensed Work, provided that your use
|
|
37
|
+
does not include offering, providing, making available, distributing,
|
|
38
|
+
hosting, managing, embedding, reselling, white-labeling, sublicensing,
|
|
39
|
+
commercializing, or otherwise making the Licensed Work, or any modified
|
|
40
|
+
version or derivative work of the Licensed Work, available to Third Parties
|
|
41
|
+
as part of a Competitive Offering.
|
|
42
|
+
|
|
43
|
+
The following definitions and clarifications form part of, and govern
|
|
44
|
+
the interpretation of, the Additional Use Grant set out above.
|
|
45
|
+
|
|
46
|
+
1. "Production Use" means any use of the Licensed Work other than for
|
|
47
|
+
development, testing, evaluation, demonstration, experimentation,
|
|
48
|
+
benchmarking, or other non-production purposes.
|
|
49
|
+
|
|
50
|
+
2. "Affiliate" means any entity that, directly or indirectly,
|
|
51
|
+
controls, is controlled by, or is under common control with you,
|
|
52
|
+
where "control" means ownership of more than fifty percent (50%) of
|
|
53
|
+
the voting interests of the entity, or the power to direct its
|
|
54
|
+
management.
|
|
55
|
+
|
|
56
|
+
3. "Third Party" means any natural person or legal entity other than
|
|
57
|
+
you and your Affiliates.
|
|
58
|
+
|
|
59
|
+
4. "Competitive Offering" means any product or service, made available
|
|
60
|
+
to one or more Third Parties for a fee or other consideration
|
|
61
|
+
(including without limitation on a paid, subscription,
|
|
62
|
+
advertising-supported, hosted, or managed-service basis), that is
|
|
63
|
+
offered or marketed as, or that competes with, a software platform,
|
|
64
|
+
runtime, orchestration system, agent or automation system,
|
|
65
|
+
extension or distribution marketplace, or other software system
|
|
66
|
+
that provides, in substantial part, the same or substantially
|
|
67
|
+
similar capabilities as those provided by the Licensed Work. A
|
|
68
|
+
product or service is a Competitive Offering whether the Licensed
|
|
69
|
+
Work is provided in whole or in part, alone or bundled with other
|
|
70
|
+
software, and whether modified or unmodified.
|
|
71
|
+
|
|
72
|
+
5. Providing, hosting, or managing the Licensed Work for a Third Party,
|
|
73
|
+
or otherwise making the Licensed Work available to a Third Party as
|
|
74
|
+
a hosted or managed service such that the Third Party obtains the
|
|
75
|
+
principal value or functionality of the Licensed Work, is a
|
|
76
|
+
Competitive Offering and is not permitted by the Additional Use
|
|
77
|
+
Grant.
|
|
78
|
+
|
|
79
|
+
6. Subject to the foregoing, the Additional Use Grant permits you to
|
|
80
|
+
make Production Use of the Licensed Work for your own internal
|
|
81
|
+
business purposes and to build, operate, and provide your own
|
|
82
|
+
products and services to Third Parties, provided that the Licensed
|
|
83
|
+
Work itself (whether modified or unmodified) is not the product or
|
|
84
|
+
service, and is not a Competitive Offering, made available to those
|
|
85
|
+
Third Parties.
|
|
86
|
+
|
|
87
|
+
7. You may modify the Licensed Work and create derivative works for
|
|
88
|
+
any purpose permitted by this License. Any Production Use of such
|
|
89
|
+
modified or derivative works remains subject to the same
|
|
90
|
+
restrictions as the Licensed Work, including the prohibition on
|
|
91
|
+
Competitive Offerings.
|
|
92
|
+
|
|
93
|
+
8. Use of the Licensed Work by your own employees, contractors, and
|
|
94
|
+
agents, acting on your behalf and for your benefit, is not by
|
|
95
|
+
itself making the Licensed Work available to a Third Party.
|
|
96
|
+
|
|
97
|
+
9. Embedding or distributing the Licensed Work as a component of your
|
|
98
|
+
own product or service is permitted only where the Licensed Work
|
|
99
|
+
does not constitute the principal value of that product or service
|
|
100
|
+
and the product or service is not a Competitive Offering.
|
|
101
|
+
|
|
102
|
+
10. Nothing in this Additional Use Grant grants any right to use any
|
|
103
|
+
name, trademark, service mark, or logo of the Licensor or its
|
|
104
|
+
Affiliates, except as reasonably required for customary
|
|
105
|
+
attribution.
|
|
106
|
+
|
|
107
|
+
11. The rights stated in this Additional Use Grant are the maximum
|
|
108
|
+
rights granted for Production Use prior to the Change Date. Any
|
|
109
|
+
Production Use not expressly permitted requires a separate
|
|
110
|
+
commercial license from the Licensor.
|
|
111
|
+
|
|
112
|
+
12. If any provision of this Additional Use Grant is held invalid or
|
|
113
|
+
unenforceable, that provision shall be limited or eliminated to
|
|
114
|
+
the minimum extent necessary so that the remainder of this
|
|
115
|
+
Additional Use Grant, and of this License, remains in full force
|
|
116
|
+
and effect. The Licensor reserves all rights not expressly granted
|
|
117
|
+
by this License.
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
Change Date: Four years from the date the specific version of the Licensed
|
|
121
|
+
Work is first publicly released by Licensor.
|
|
122
|
+
|
|
123
|
+
Change License: Mozilla Public License, Version 2.0
|
|
124
|
+
|
|
125
|
+
For information about alternative licensing arrangements, commercial
|
|
126
|
+
licensing, enterprise licensing, OEM licensing, appliance licensing, managed
|
|
127
|
+
service licensing, cloud provider licensing, or other commercial use of the
|
|
128
|
+
Licensed Work, please contact: licensing@neuralchowder.com
|
|
129
|
+
|
|
130
|
+
-----------------------------------------------------------------------------
|
|
131
|
+
|
|
132
|
+
Notice
|
|
133
|
+
|
|
134
|
+
Business Source License 1.1
|
|
135
|
+
|
|
136
|
+
Terms
|
|
137
|
+
|
|
138
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
139
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
140
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
141
|
+
production use.
|
|
142
|
+
|
|
143
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
144
|
+
available distribution of a specific version of the Licensed Work under this
|
|
145
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
146
|
+
the terms of the Change License, and the rights granted in the paragraph above
|
|
147
|
+
terminate.
|
|
148
|
+
|
|
149
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
150
|
+
currently in effect as described in this License, you must purchase a
|
|
151
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
152
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
153
|
+
|
|
154
|
+
All copies of the original and modified Licensed Work, and derivative works of
|
|
155
|
+
the Licensed Work, are subject to this License. This License applies separately
|
|
156
|
+
for each version of the Licensed Work and the Change Date may vary for each
|
|
157
|
+
version of the Licensed Work released by Licensor.
|
|
158
|
+
|
|
159
|
+
You must conspicuously display this License on each original or modified copy
|
|
160
|
+
of the Licensed Work. If you receive the Licensed Work in original or modified
|
|
161
|
+
form from a third party, the terms and conditions set forth in this License
|
|
162
|
+
apply to your use of that work.
|
|
163
|
+
|
|
164
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
165
|
+
terminate your rights under this License for the current and all other
|
|
166
|
+
versions of the Licensed Work.
|
|
167
|
+
|
|
168
|
+
This License does not grant you any right in any trademark or logo of Licensor
|
|
169
|
+
or its affiliates, provided that you may use a trademark or logo of Licensor
|
|
170
|
+
as expressly required by this License.
|
|
171
|
+
|
|
172
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN
|
|
173
|
+
"AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS
|
|
174
|
+
OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
175
|
+
FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xema-composed-process.d.ts","sourceRoot":"","sources":["../../src/bin/xema-composed-process.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const xema_service_nest_1 = require("@xemahq/xema-service-nest");
|
|
6
|
+
const composed_process_host_1 = require("../composed-process-host");
|
|
7
|
+
(0, composed_process_host_1.runComposedProcessHost)({
|
|
8
|
+
argv: process.argv.slice(2),
|
|
9
|
+
env: process.env,
|
|
10
|
+
packageRoot: (0, node_path_1.dirname)((0, node_path_1.dirname)(__dirname)),
|
|
11
|
+
onFatal: (error) => {
|
|
12
|
+
(0, xema_service_nest_1.reportComposedProcessRefusal)(error);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
},
|
|
15
|
+
tokenSource: (serviceName) => (0, xema_service_nest_1.createStandaloneWorkloadTokenSource)({ serviceName, env: process.env }),
|
|
16
|
+
})
|
|
17
|
+
.then((host) => {
|
|
18
|
+
let stopping = false;
|
|
19
|
+
const stop = () => {
|
|
20
|
+
if (stopping) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
stopping = true;
|
|
24
|
+
host.stop().then(() => process.exit(0), (error) => {
|
|
25
|
+
(0, xema_service_nest_1.reportComposedProcessRefusal)(error);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
process.on('SIGTERM', stop);
|
|
30
|
+
process.on('SIGINT', stop);
|
|
31
|
+
host.supervisor.onGenerationLost((lost) => {
|
|
32
|
+
process.stderr.write(`[xema-composed-process] generation ${String(lost.generation)} was lost (code ${String(lost.code)}, signal ${String(lost.signal)}); exiting so the platform restarts the process\n`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
});
|
|
35
|
+
})
|
|
36
|
+
.catch((error) => {
|
|
37
|
+
(0, xema_service_nest_1.reportComposedProcessRefusal)(error);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=xema-composed-process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xema-composed-process.js","sourceRoot":"","sources":["../../src/bin/xema-composed-process.ts"],"names":[],"mappings":";;;AAaA,yCAAoC;AAEpC,iEAGmC;AAEnC,oEAAkE;AAElE,IAAA,8CAAsB,EAAC;IACrB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,C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M,CAAC,mDAAmD,CACpL,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;KACD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IACxB,IAAA,gDAA4B,EAAC,KAAK,CAAC,CAAC;IACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ExecutorMemberConfig, ExecutorRegistry } from '@xemahq/xema-service-nest';
|
|
2
|
+
export declare function biomeHostRegistry(biomeHostUrl: string, getAuthToken: () => Promise<string>): ExecutorRegistry;
|
|
3
|
+
export declare function biomeHostMemberConfig(): ExecutorMemberConfig;
|
|
4
|
+
//# sourceMappingURL=biome-host-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"biome-host-registry.d.ts","sourceRoot":"","sources":["../src/biome-host-registry.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAQxF,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAClC,gBAAgB,CAwBlB;AAiBD,wBAAgB,qBAAqB,IAAI,oBAAoB,CAU5D"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.biomeHostRegistry = biomeHostRegistry;
|
|
4
|
+
exports.biomeHostMemberConfig = biomeHostMemberConfig;
|
|
5
|
+
const biome_host_internal_api_client_1 = require("@xemahq/biome-host-internal-api-client");
|
|
6
|
+
const process_executor_1 = require("@xemahq/contracts/process-executor");
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
function biomeHostRegistry(biomeHostUrl, getAuthToken) {
|
|
9
|
+
(0, biome_host_internal_api_client_1.configureClient)({ baseUrl: biomeHostUrl.replace(/\/+$/, ''), getAuthToken });
|
|
10
|
+
return {
|
|
11
|
+
async register(registration) {
|
|
12
|
+
const { podUid, seedPartition, ...rest } = registration;
|
|
13
|
+
const envelope = await (0, biome_host_internal_api_client_1.composedProcessExecutorControllerRegister)({
|
|
14
|
+
...rest,
|
|
15
|
+
...(podUid === undefined ? {} : { podUid }),
|
|
16
|
+
...(seedPartition === undefined
|
|
17
|
+
? {}
|
|
18
|
+
: {
|
|
19
|
+
seedPartition: {
|
|
20
|
+
trustDomain: seedPartition.trustDomain,
|
|
21
|
+
credentialCustody: seedPartition.credentialCustody,
|
|
22
|
+
...(seedPartition.exclusiveMember === undefined ? {} : { exclusiveMember: seedPartition.exclusiveMember }),
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
return process_executor_1.ProcessRegistrationAcceptedSchema.parse(envelope.data);
|
|
27
|
+
},
|
|
28
|
+
async acknowledge(process, replica, ack) {
|
|
29
|
+
await (0, biome_host_internal_api_client_1.composedProcessExecutorControllerAcknowledge)(process, replica, ack);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const ResolvedMemberConfigSchema = zod_1.z.object({
|
|
34
|
+
revision: zod_1.z.string().min(1),
|
|
35
|
+
members: zod_1.z.record(zod_1.z.string(), zod_1.z.record(zod_1.z.string(), zod_1.z.string())),
|
|
36
|
+
});
|
|
37
|
+
function biomeHostMemberConfig() {
|
|
38
|
+
return {
|
|
39
|
+
async resolve(reference, members) {
|
|
40
|
+
const envelope = await (0, biome_host_internal_api_client_1.memberConfigControllerResolve)(reference.process, {
|
|
41
|
+
reference,
|
|
42
|
+
members: members.map((facts) => ({ ...facts })),
|
|
43
|
+
});
|
|
44
|
+
return ResolvedMemberConfigSchema.parse(envelope.data).members;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=biome-host-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"biome-host-registry.js","sourceRoot":"","sources":["../src/biome-host-registry.ts"],"names":[],"mappings":";;AAiBA,8CA2BC;AAiBD,sDAUC;AAvED,2FAKgD;AAChD,yEAAuF;AACvF,6BAAwB;AAUxB,SAAgB,iBAAiB,CAC/B,YAAoB,EACpB,YAAmC;IAEnC,IAAA,gDAAe,EAAC,EAAE,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC;IAC7E,OAAO;QACL,KAAK,CAAC,QAAQ,CAAC,YAAY;YACzB,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,GAAG,YAAY,CAAC;YACxD,MAAM,QAAQ,GAAG,MAAM,IAAA,0EAAyC,EAAC;gBAC/D,GAAG,IAAI;gBACP,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;gBAC3C,GAAG,CAAC,aAAa,KAAK,SAAS;oBAC7B,CAAC,CAAC,EAAE;oBACJ,CAAC,CAAC;wBACE,aAAa,EAAE;4BACb,WAAW,EAAE,aAAa,CAAC,WAAW;4BACtC,iBAAiB,EAAE,aAAa,CAAC,iBAAiB;4BAClD,GAAG,CAAC,aAAa,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,aAAa,CAAC,eAAe,EAAE,CAAC;yBAC3G;qBACF,CAAC;aACP,CAAC,CAAC;YACH,OAAO,oDAAiC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAChE,CAAC;QACD,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG;YACrC,MAAM,IAAA,6EAA4C,EAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAC5E,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,0BAA0B,GAAG,OAAC,CAAC,MAAM,CAAC;IAC1C,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC;CAChE,CAAC,CAAC;AAYH,SAAgB,qBAAqB;IACnC,OAAO;QACL,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO;YAC9B,MAAM,QAAQ,GAAG,MAAM,IAAA,8DAA6B,EAAC,SAAS,CAAC,OAAO,EAAE;gBACtE,SAAS;gBACT,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;aAChD,CAAC,CAAC;YACH,OAAO,0BAA0B,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;QACjE,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Oras } from '@xemahq/oci-closure';
|
|
2
|
+
import { ComposedProcessExecutor, type ExecutorMemberConfig, type InstalledVersionReader, type OwnTokenSource, type RunningSupervisorProcess } from '@xemahq/xema-service-nest';
|
|
3
|
+
import { type ReplayStreamer } from './event-hub-command-stream';
|
|
4
|
+
import type { ServiceRegistry } from '@xemahq/contracts/service-registry';
|
|
5
|
+
export declare const COMPOSED_GENERATION_ENTRY: string;
|
|
6
|
+
export interface ComposedProcessHostOptions {
|
|
7
|
+
readonly argv: readonly string[];
|
|
8
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
9
|
+
readonly packageRoot: string;
|
|
10
|
+
readonly tokenSource: (serviceName: string) => Promise<OwnTokenSource>;
|
|
11
|
+
readonly write?: (line: string) => void;
|
|
12
|
+
readonly onFatal: (error: Error) => void;
|
|
13
|
+
readonly oras?: Oras;
|
|
14
|
+
readonly streamer?: ReplayStreamer;
|
|
15
|
+
readonly versionOf?: InstalledVersionReader;
|
|
16
|
+
readonly memberConfig?: ExecutorMemberConfig;
|
|
17
|
+
readonly registryFor?: (env: Readonly<Record<string, string | undefined>>) => ServiceRegistry;
|
|
18
|
+
}
|
|
19
|
+
export interface RunningComposedProcessHost extends RunningSupervisorProcess {
|
|
20
|
+
readonly executor: ComposedProcessExecutor;
|
|
21
|
+
stop(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export declare function runComposedProcessHost(host: ComposedProcessHostOptions): Promise<RunningComposedProcessHost>;
|
|
24
|
+
//# sourceMappingURL=composed-process-host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composed-process-host.d.ts","sourceRoot":"","sources":["../src/composed-process-host.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EACL,uBAAuB,EAKvB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC9B,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAA2C,KAAK,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAS1G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAG1E,eAAO,MAAM,yBAAyB,QAAyC,CAAC;AAMhF,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAE3D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAM7B,QAAQ,CAAC,WAAW,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IACvE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAMxC,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAEzC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;IACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,sBAAsB,CAAC;IAE5C,QAAQ,CAAC,YAAY,CAAC,EAAE,oBAAoB,CAAC;IAE7C,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,KAAK,eAAe,CAAC;CAC/F;AAED,MAAM,WAAW,0BAA2B,SAAQ,wBAAwB;IAC1E,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,CAAC;IAC3C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAgCD,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,0BAA0B,GAC/B,OAAO,CAAC,0BAA0B,CAAC,CAwCrC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.COMPOSED_GENERATION_ENTRY = void 0;
|
|
4
|
+
exports.runComposedProcessHost = runComposedProcessHost;
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const oci_closure_1 = require("@xemahq/oci-closure");
|
|
7
|
+
const xema_service_nest_1 = require("@xemahq/xema-service-nest");
|
|
8
|
+
const biome_host_registry_1 = require("./biome-host-registry");
|
|
9
|
+
const event_hub_command_stream_1 = require("./event-hub-command-stream");
|
|
10
|
+
const host_platform_1 = require("./host-platform");
|
|
11
|
+
const oci_bundle_store_1 = require("./oci-bundle-store");
|
|
12
|
+
const pack_bundle_reader_1 = require("./pack-bundle-reader");
|
|
13
|
+
const seed_closure_1 = require("./seed-closure");
|
|
14
|
+
const seed_platform_registration_1 = require("./seed-platform-registration");
|
|
15
|
+
const seed_processes_1 = require("./seed-processes");
|
|
16
|
+
exports.COMPOSED_GENERATION_ENTRY = (0, node_path_1.join)(__dirname, 'generation-entry.js');
|
|
17
|
+
function definedEntries(env) {
|
|
18
|
+
return Object.fromEntries(Object.entries(env).filter(([, value]) => value !== undefined));
|
|
19
|
+
}
|
|
20
|
+
const BIOME_HOST_SERVICE = 'biome-host-api';
|
|
21
|
+
function biomeHostEntryPort(biomeHostUrl) {
|
|
22
|
+
return (member) => {
|
|
23
|
+
if (member.componentKey !== BIOME_HOST_SERVICE) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
const { port } = new URL(biomeHostUrl);
|
|
27
|
+
if (port === '') {
|
|
28
|
+
throw new Error(`xema-composed-process: --biome-host-url ${biomeHostUrl} names no port, so the process hosting ${BIOME_HOST_SERVICE} cannot listen where it is addressed`);
|
|
29
|
+
}
|
|
30
|
+
return Number(port);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const EVENT_HUB_SERVICE = 'event-hub-api';
|
|
34
|
+
async function runComposedProcessHost(host) {
|
|
35
|
+
const write = host.write ?? ((line) => process.stderr.write(line));
|
|
36
|
+
let registration;
|
|
37
|
+
try {
|
|
38
|
+
const running = await (0, xema_service_nest_1.runSupervisorProcess)({
|
|
39
|
+
argv: host.argv,
|
|
40
|
+
env: host.env,
|
|
41
|
+
generationModulePath: exports.COMPOSED_GENERATION_ENTRY,
|
|
42
|
+
generationEnv: definedEntries(host.env),
|
|
43
|
+
...(host.write === undefined ? {} : { write: host.write }),
|
|
44
|
+
beforeSeedSwap: async (options) => {
|
|
45
|
+
registration = await (0, seed_platform_registration_1.registerSeedPlatformServices)({
|
|
46
|
+
closureFile: (0, seed_closure_1.seedClosureFileOf)(host.packageRoot),
|
|
47
|
+
processName: options.processName,
|
|
48
|
+
env: host.env,
|
|
49
|
+
instanceSuffix: options.instanceId ?? options.replica,
|
|
50
|
+
write,
|
|
51
|
+
onFatal: host.onFatal,
|
|
52
|
+
...(host.registryFor === undefined ? {} : { registryFor: host.registryFor }),
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
entryPortOf: (options) => biomeHostEntryPort(options.biomeHostUrl),
|
|
56
|
+
seedInputs: (options) => (0, seed_closure_1.readSeedClosure)({
|
|
57
|
+
file: (0, seed_closure_1.seedClosureFileOf)(host.packageRoot),
|
|
58
|
+
processName: options.processName,
|
|
59
|
+
probePort: options.probePort,
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
return await attachExecutor(running, host, registration);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
await registration?.stop();
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function attachExecutor(running, host, registration) {
|
|
70
|
+
const { options, supervisor } = running;
|
|
71
|
+
if (options.bundleRegistry === undefined) {
|
|
72
|
+
await supervisor.shutdown();
|
|
73
|
+
throw new Error('xema-composed-process: --bundle-registry / XEMA_SUPERVISOR_BUNDLE_REGISTRY is required');
|
|
74
|
+
}
|
|
75
|
+
const tokens = await host.tokenSource(options.processName).catch(async (error) => {
|
|
76
|
+
await supervisor.shutdown();
|
|
77
|
+
throw error;
|
|
78
|
+
});
|
|
79
|
+
let streamer;
|
|
80
|
+
try {
|
|
81
|
+
streamer =
|
|
82
|
+
host.streamer ??
|
|
83
|
+
(0, event_hub_command_stream_1.replayStreamerFor)({
|
|
84
|
+
eventHubUrl: options.eventHubUrl,
|
|
85
|
+
serviceId: options.processName,
|
|
86
|
+
serviceName: options.processName,
|
|
87
|
+
schemaVersion: '1.0.0',
|
|
88
|
+
realmId: (0, xema_service_nest_1.ownRealmOfService)({ get: (name) => host.env[name] }, options.processName),
|
|
89
|
+
tokenProvider: () => tokens.getAccessTokenFor(EVENT_HUB_SERVICE),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
await supervisor.shutdown();
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
const seedPartition = options.role === xema_service_nest_1.SupervisorLaunchRole.Seed
|
|
97
|
+
? (0, seed_processes_1.seedProcessNamed)((0, seed_closure_1.readSeedProcesses)((0, seed_closure_1.seedClosureFileOf)(host.packageRoot)), options.processName).seedPartition
|
|
98
|
+
: undefined;
|
|
99
|
+
const executor = new xema_service_nest_1.ComposedProcessExecutor({
|
|
100
|
+
process: options.processName,
|
|
101
|
+
replica: options.replica,
|
|
102
|
+
...(options.instanceId === undefined ? {} : { podUid: options.instanceId }),
|
|
103
|
+
...(seedPartition === undefined ? {} : { seedPartition }),
|
|
104
|
+
hostAbi: (0, xema_service_nest_1.nodeComposedHostAbi)(host.versionOf),
|
|
105
|
+
platform: (0, host_platform_1.currentBundlePlatform)(),
|
|
106
|
+
probePort: options.probePort,
|
|
107
|
+
registry: (0, biome_host_registry_1.biomeHostRegistry)(options.biomeHostUrl, () => tokens.getAccessTokenFor(BIOME_HOST_SERVICE)),
|
|
108
|
+
bundles: (0, oci_bundle_store_1.ociBundleStore)({
|
|
109
|
+
oras: host.oras ?? (0, oci_closure_1.createOras)({ env: { ...host.env } }),
|
|
110
|
+
reader: pack_bundle_reader_1.packBundleReader,
|
|
111
|
+
bundleRegistry: options.bundleRegistry,
|
|
112
|
+
cacheDir: options.bundleCacheDir,
|
|
113
|
+
}),
|
|
114
|
+
memberConfig: host.memberConfig ?? (0, biome_host_registry_1.biomeHostMemberConfig)(),
|
|
115
|
+
supervisor,
|
|
116
|
+
});
|
|
117
|
+
const accepted = await executor.start();
|
|
118
|
+
const stopStream = await (0, event_hub_command_stream_1.consumeCommandStream)({
|
|
119
|
+
streamer,
|
|
120
|
+
process: options.processName,
|
|
121
|
+
streamCursor: accepted.streamCursor,
|
|
122
|
+
handlers: {
|
|
123
|
+
onCommand: (command) => executor.handleCommand(command),
|
|
124
|
+
onAdmission: (admission) => executor.handleAdmission(admission),
|
|
125
|
+
onError: (error) => (host.write ?? ((line) => process.stderr.write(line)))(`[composed-process-host] ${error.message}\n`),
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
...running,
|
|
130
|
+
executor,
|
|
131
|
+
stop: async () => {
|
|
132
|
+
stopStream();
|
|
133
|
+
await supervisor.shutdown();
|
|
134
|
+
await registration?.stop();
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=composed-process-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composed-process-host.js","sourceRoot":"","sources":["../src/composed-process-host.ts"],"names":[],"mappings":";;;AAiGA,wDA0CC;AA3ID,yCAAiC;AAEjC,qDAA4D;AAC5D,iEAUmC;AAEnC,+DAAiF;AACjF,yEAA0G;AAC1G,mDAAwD;AACxD,yDAAoD;AACpD,6DAAwD;AACxD,iDAAuF;AACvF,6EAA2G;AAC3G,qDAAoD;AAMvC,QAAA,yBAAyB,GAAG,IAAA,gBAAI,EAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;AAEhF,SAAS,cAAc,CAAC,GAAiD;IACvE,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC;AAC5F,CAAC;AAoCD,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAO5C,SAAS,kBAAkB,CAAC,YAAoB;IAC9C,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,IAAI,MAAM,CAAC,YAAY,KAAK,kBAAkB,EAAE,CAAC;YAC/C,OAAO,S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I,CAAC;SACzH;KACF,CAAC,CAAC;IACH,OAAO;QACL,GAAG,OAAO;QACV,QAAQ;QACR,IAAI,EAAE,KAAK,IAAI,EAAE;YACf,UAAU,EAAE,CAAC;YACb,MAAM,UAAU,CAAC,QAAQ,EAAE,CAAC;YAC5B,MAAM,YAAY,EAAE,IAAI,EAAE,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ExecutorAdmission, type ExecutorCommand } from '@xemahq/contracts/process-executor';
|
|
2
|
+
import { type EventHubModuleConfig } from '@xemahq/event-hub-client';
|
|
3
|
+
export interface CommandStreamHandlers {
|
|
4
|
+
onCommand(command: ExecutorCommand): Promise<void>;
|
|
5
|
+
onAdmission(admission: ExecutorAdmission): Promise<void>;
|
|
6
|
+
onError(error: Error): void;
|
|
7
|
+
}
|
|
8
|
+
export interface ReplayStreamer {
|
|
9
|
+
streamFrom<TEnvelope>(cursors: {
|
|
10
|
+
global: string;
|
|
11
|
+
}, options: {
|
|
12
|
+
types: string[];
|
|
13
|
+
subject: string;
|
|
14
|
+
}, onEnvelope: (envelope: TEnvelope, sequenceId: string) => void, onResync?: () => void, onError?: (error: Error) => void): Promise<() => void>;
|
|
15
|
+
}
|
|
16
|
+
export declare const replayStreamerFor: (config: EventHubModuleConfig) => ReplayStreamer;
|
|
17
|
+
export declare function consumeCommandStream(input: {
|
|
18
|
+
readonly streamer: ReplayStreamer;
|
|
19
|
+
readonly process: string;
|
|
20
|
+
readonly streamCursor: string;
|
|
21
|
+
readonly handlers: CommandStreamHandlers;
|
|
22
|
+
}): Promise<() => void>;
|
|
23
|
+
//# sourceMappingURL=event-hub-command-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-hub-command-stream.d.ts","sourceRoot":"","sources":["../src/event-hub-command-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,eAAe,E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ream = consumeCommandStream;
|
|
5
|
+
const process_executor_1 = require("@xemahq/contracts/process-executor");
|
|
6
|
+
const event_hub_client_1 = require("@xemahq/event-hub-client");
|
|
7
|
+
const replayStreamerFor = (config) => new event_hub_client_1.EventHubReplayClient(config);
|
|
8
|
+
exports.replayStreamerFor = replayStreamerFor;
|
|
9
|
+
function consumeCommandStream(input) {
|
|
10
|
+
const { streamer, process, streamCursor, handlers } = input;
|
|
11
|
+
let chain = Promise.resolve();
|
|
12
|
+
const deliver = (envelope) => {
|
|
13
|
+
switch (envelope.type) {
|
|
14
|
+
case process_executor_1.COMPOSED_PROCESS_COMMAND_EVENT_TYPE:
|
|
15
|
+
return handlers.onCommand(process_executor_1.ExecutorCommandSchema.parse(envelope.data));
|
|
16
|
+
case process_executor_1.COMPOSED_PROCESS_ADMISSION_EVENT_TYPE:
|
|
17
|
+
return handlers.onAdmission(process_executor_1.ExecutorAdmissionSchema.parse(envelope.data));
|
|
18
|
+
default:
|
|
19
|
+
throw new Error(`unexpected event type "${envelope.type}" on the command stream of ${process}`);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return streamer.streamFrom({ global: streamCursor }, { types: [process_executor_1.COMPOSED_PROCESS_COMMAND_EVENT_TYPE, process_executor_1.COMPOSED_PROCESS_ADMISSION_EVENT_TYPE], subject: process }, (envelope) => {
|
|
23
|
+
chain = chain
|
|
24
|
+
.then(() => deliver(envelope))
|
|
25
|
+
.catch((error) => handlers.onError(error instanceof Error ? error : new Error(String(error))));
|
|
26
|
+
}, undefined, handlers.onError);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=event-hub-command-stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-hub-command-stream.js","sourceRoot":"","sources":["../src/event-hub-command-stream.ts"],"names":[],"mappings":";;;AA0CA,oDA6BC;AAvED,yEAO4C;AAC5C,+DAA2F;AAoBpF,MAAM,iBAAiB,GAAG,CAAC,MAA4B,EAAkB,EAAE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AC,OAAO,CACjB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generation-entry.d.ts","sourceRoot":"","sources":["../src/generation-entry.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const xema_service_nest_1 = require("@xemahq/xema-service-nest");
|
|
5
|
+
const send = process.send?.bind(process);
|
|
6
|
+
if (send === undefined) {
|
|
7
|
+
process.stderr.write('[xema-composed-process] the generation entry has no IPC channel; the supervisor forks it\n');
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
const runtime = new xema_service_nest_1.GenerationRuntime({
|
|
11
|
+
send: (message) => new Promise((resolve, reject) => {
|
|
12
|
+
send(message, (error) => {
|
|
13
|
+
if (error === null) {
|
|
14
|
+
resolve();
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
reject(error);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}),
|
|
21
|
+
exit: (code) => process.exit(code),
|
|
22
|
+
});
|
|
23
|
+
process.on('message', (message, handle) => {
|
|
24
|
+
void runtime.handleMessage(message, handle);
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=generation-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generation-entry.js","sourceRoot":"","sources":["../src/generation-entry.ts"],"names":[],"mappings":";;;AASA,iEAA8D;AAE9D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;AACzC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;IACvB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4FAA4F,CAAC,CAAC;IACnH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,OAAO,GAAG,IAAI,qCAAiB,CAAC;IACpC,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAChB,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACpC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAmB,EAAE,EAAE;YACpC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACnB,OAAO,EAAE,CAAC;YACZ,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,KAAK,CAAC,CAAC;YAChB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IACJ,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;CACnC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,OAAgB,EAAE,MAAe,EAAE,EAAE;IAC1D,KAAK,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type BundlePlatform } from '@xemahq/contracts/biome-bundle';
|
|
2
|
+
export declare function currentBundlePlatform(facts?: {
|
|
3
|
+
readonly platform: NodeJS.Platform;
|
|
4
|
+
readonly arch: string;
|
|
5
|
+
readonly glibcVersionRuntime: string | undefined;
|
|
6
|
+
}): BundlePlatform;
|
|
7
|
+
//# sourceMappingURL=host-platform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-platform.d.ts","sourceRoot":"","sources":["../src/host-platform.ts"],"names":[],"mappings":"AACA,OAAO,EAAqC,KAAK,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGxG,wBAAgB,qBAAqB,CACnC,KAAK,GAAE;IACL,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;CAMlD,GACA,cAAc,CAiBhB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.currentBundlePlatform = currentBundlePlatform;
|
|
4
|
+
const biome_1 = require("@xemahq/contracts/biome");
|
|
5
|
+
const biome_bundle_1 = require("@xemahq/contracts/biome-bundle");
|
|
6
|
+
function currentBundlePlatform(facts = {
|
|
7
|
+
platform: process.platform,
|
|
8
|
+
arch: process.arch,
|
|
9
|
+
glibcVersionRuntime: process.report.getReport()
|
|
10
|
+
?.header?.glibcVersionRuntime,
|
|
11
|
+
}) {
|
|
12
|
+
const cpu = { x64: biome_1.BiomeCpuArchitecture.Amd64, arm64: biome_1.BiomeCpuArchitecture.Arm64 }[facts.arch];
|
|
13
|
+
if (cpu === undefined) {
|
|
14
|
+
throw new Error(`Node arch "${facts.arch}" is not a platform bundles are built for.`);
|
|
15
|
+
}
|
|
16
|
+
switch (facts.platform) {
|
|
17
|
+
case 'linux':
|
|
18
|
+
return {
|
|
19
|
+
os: biome_bundle_1.BundleOperatingSystem.Linux,
|
|
20
|
+
cpu,
|
|
21
|
+
libc: facts.glibcVersionRuntime === undefined ? biome_bundle_1.BundleLibc.Musl : biome_bundle_1.BundleLibc.Glibc,
|
|
22
|
+
};
|
|
23
|
+
case 'darwin':
|
|
24
|
+
return { os: biome_bundle_1.BundleOperatingSystem.Darwin, cpu };
|
|
25
|
+
default:
|
|
26
|
+
throw new Error(`Node platform "${facts.platform}" is not a platform bundles are built for.`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=host-platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-platform.js","sourceRoot":"","sources":["../src/host-platform.ts"],"names":[],"mappings":";;AAIA,sDA4BC;AAhCD,mDAA+D;AAC/D,iEAAwG;AAGxG,SAAgB,qBAAqB,CACnC,QAII;IACF,QAAQ,EAAE,OAAO,CAAC,QAAQ;IAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;IAClB,mBAAmB,EAAG,OAAO,CAAC,MAAM,CAAC,SAAS,EAAgE;QAC5G,EAAE,MAAM,EAAE,mBAAmB;CAChC;IAED,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,4BAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,4BAAoB,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/F,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,cAAc,KAAK,CAAC,IAAI,4CAA4C,CAAC,CAAC;IACxF,CAAC;IACD,QAAQ,KAAK,CAAC,QAAQ,EAAE,CAAC;QACvB,KAAK,OAAO;YACV,OAAO;gBACL,EAAE,EAAE,oCAAqB,CAAC,KAAK;gBAC/B,GAAG;gBACH,IAAI,EAAE,KAAK,CAAC,mBAAmB,KAAK,SAAS,CAAC,CAAC,CAAC,yBAAU,CAAC,IAAI,CAAC,CAAC,CAAC,yBAAU,CAAC,KAAK;aACnF,CAAC;QACJ,KAAK,QAAQ;YACX,OAAO,EAAE,EAAE,EAAE,oCAAqB,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC;QACnD;YACE,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,CAAC,QAAQ,4CAA4C,CAAC,CAAC;IAClG,CAAC;AACH,CAAC"}
|