@atolis-hq/wake 0.4.85 → 0.4.87
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/src/bootstrap/analytics-reports.js +2 -1
- package/dist/src/bootstrap/composition-root.d.ts +63 -2
- package/dist/src/bootstrap/composition-root.js +47 -4
- package/dist/src/bootstrap/integration-runtime.d.ts +1 -0
- package/dist/src/bootstrap/integration-runtime.js +24 -21
- package/dist/src/bootstrap/surface-applications.d.ts +1 -0
- package/dist/src/bootstrap/surface-applications.js +1 -0
- package/dist/src/bootstrap/surface-cli-applications.d.ts +4 -2
- package/dist/src/bootstrap/surface-cli-applications.js +92 -31
- package/dist/src/bootstrap/version.js +1 -1
- package/dist/src/execution/application/run-reports.d.ts +7 -0
- package/dist/src/execution/application/run-reports.js +70 -26
- package/dist/src/kernel/contracts/reports.d.ts +3 -1
- package/dist/src/main.d.ts +2 -1
- package/dist/src/main.js +25 -13
- package/dist/src/surfaces/cli/main.d.ts +7 -0
- package/dist/src/surfaces/cli/main.js +26 -8
- package/dist/src/surfaces/web-assets/assets/index--h2bjD5B.js +1192 -0
- package/dist/src/surfaces/web-assets/index.html +1 -1
- package/package.json +1 -1
- package/dist/src/surfaces/web-assets/assets/index-BuVkTveW.js +0 -1192
package/dist/src/main.js
CHANGED
|
@@ -21,17 +21,10 @@ export async function main(argv = process.argv.slice(2), dependencies) {
|
|
|
21
21
|
resolvedDependencies.output.write(`${JSON.stringify(result)}\n`);
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
if (resolvedDependencies.sandboxRuntime
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
bypassSandbox,
|
|
29
|
-
hasDockerfile: () => sandboxRuntime.hasDockerfile(wakeRoot),
|
|
30
|
-
exec: () => sandboxRuntime.exec(wakeRoot, rewriteSandboxArguments(suppliedArguments)),
|
|
31
|
-
});
|
|
32
|
-
if (ranInSandbox)
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
24
|
+
if (await routeSandboxCommand(command, wakeRoot, suppliedArguments, bypassSandbox, resolvedDependencies.sandboxRuntime))
|
|
25
|
+
return;
|
|
26
|
+
if (await runHostCommandIfAvailable(command, wakeRoot, output, resolvedDependencies))
|
|
27
|
+
return;
|
|
35
28
|
const applications = await resolvedDependencies.compose(wakeRoot);
|
|
36
29
|
if (applications.sandboxRuntime !== undefined) {
|
|
37
30
|
const sandboxRuntime = applications.sandboxRuntime;
|
|
@@ -46,6 +39,19 @@ export async function main(argv = process.argv.slice(2), dependencies) {
|
|
|
46
39
|
}
|
|
47
40
|
await runWakeCommand(command, applications, resolvedDependencies.output, resolvedDependencies.signal);
|
|
48
41
|
}
|
|
42
|
+
async function runHostCommandIfAvailable(command, wakeRoot, output, dependencies) {
|
|
43
|
+
return (await dependencies.runHostCommand?.(command, wakeRoot, output)) ?? false;
|
|
44
|
+
}
|
|
45
|
+
async function routeSandboxCommand(command, wakeRoot, arguments_, bypassSandbox, router) {
|
|
46
|
+
if (router === undefined)
|
|
47
|
+
return false;
|
|
48
|
+
return runInSandboxIfAvailable({
|
|
49
|
+
commandKind: command.kind,
|
|
50
|
+
bypassSandbox,
|
|
51
|
+
hasDockerfile: () => router.hasDockerfile(wakeRoot),
|
|
52
|
+
exec: () => router.exec(wakeRoot, rewriteSandboxArguments(arguments_)),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
49
55
|
function normalizeDeveloperAlias(arguments_) {
|
|
50
56
|
if (arguments_[0] !== 'dev' || arguments_[1] !== 'sandbox')
|
|
51
57
|
return arguments_;
|
|
@@ -124,8 +130,10 @@ function rewriteSandboxArguments(arguments_) {
|
|
|
124
130
|
return [...rewritten, '--no-sandbox'];
|
|
125
131
|
}
|
|
126
132
|
function operationalWakeRoot(arguments_) {
|
|
127
|
-
const
|
|
128
|
-
|
|
133
|
+
const end = arguments_.indexOf('--');
|
|
134
|
+
const options = end === -1 ? arguments_ : arguments_.slice(0, end);
|
|
135
|
+
const index = options.indexOf('--wake-root');
|
|
136
|
+
return index === -1 ? undefined : options[index + 1];
|
|
129
137
|
}
|
|
130
138
|
function productionDependencies() {
|
|
131
139
|
const controller = new AbortController();
|
|
@@ -133,6 +141,10 @@ function productionDependencies() {
|
|
|
133
141
|
process.once('SIGTERM', () => controller.abort());
|
|
134
142
|
return {
|
|
135
143
|
initialise: initialiseWakeRoot,
|
|
144
|
+
async runHostCommand(command, wakeRoot, output) {
|
|
145
|
+
const { runHostCommand } = await import('./bootstrap/surface-applications.js');
|
|
146
|
+
return runHostCommand(command, wakeRoot, output);
|
|
147
|
+
},
|
|
136
148
|
sandboxRuntime: productionSandboxRuntime(),
|
|
137
149
|
async compose(wakeRoot) {
|
|
138
150
|
const [{ createCompositionRoot }, { createSurfaceApplications }] = await Promise.all([
|
|
@@ -124,4 +124,11 @@ export interface CliOutput {
|
|
|
124
124
|
}
|
|
125
125
|
/** Parses Surface vocabulary only; Bootstrap supplies every application facade. */
|
|
126
126
|
export declare function parseWakeCommand(arguments_: readonly string[]): WakeCommand;
|
|
127
|
+
export interface WakeReadApplications {
|
|
128
|
+
readonly doctor?: (arguments_: readonly string[]) => Promise<unknown>;
|
|
129
|
+
readonly audit?: WakeCliApplications['audit'];
|
|
130
|
+
readonly validateState?: Pick<WakeCliApplications['validateState'], 'health'>;
|
|
131
|
+
}
|
|
132
|
+
/** Shared presentation for both storage-only reads and fully composed facades. */
|
|
133
|
+
export declare function runWakeReadCommand(command: WakeCommand, applications: WakeReadApplications, output: CliOutput): Promise<boolean>;
|
|
127
134
|
export declare function runWakeCommand(command: WakeCommand, applications: WakeCliApplications, output: CliOutput, signal: AbortSignal): Promise<void>;
|
|
@@ -172,15 +172,37 @@ function requiredArgument(value, label) {
|
|
|
172
172
|
throw new Error(`Missing ${label}`);
|
|
173
173
|
return value;
|
|
174
174
|
}
|
|
175
|
+
/** Shared presentation for both storage-only reads and fully composed facades. */
|
|
176
|
+
export async function runWakeReadCommand(command, applications, output) {
|
|
177
|
+
if (command.kind === 'doctor' && applications.doctor !== undefined) {
|
|
178
|
+
writeResult(output, await applications.doctor(command.arguments));
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
if (command.kind === 'audit' && applications.audit !== undefined) {
|
|
182
|
+
for (const record of await applications.audit.read(command.workItemId))
|
|
183
|
+
writeResult(output, record);
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
if (command.kind === 'validate-state' &&
|
|
187
|
+
!command.rebuildProjections &&
|
|
188
|
+
applications.validateState !== undefined) {
|
|
189
|
+
writeResult(output, await applications.validateState.health());
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
175
194
|
// eslint-disable-next-line complexity -- each parsed command has one explicit application dispatch.
|
|
176
195
|
export async function runWakeCommand(command, applications, output, signal) {
|
|
177
196
|
switch (command.kind) {
|
|
197
|
+
case 'doctor':
|
|
198
|
+
await runWakeReadCommand(command, { doctor: (arguments_) => operational(applications).doctor(arguments_) }, output);
|
|
199
|
+
return;
|
|
200
|
+
case 'audit':
|
|
201
|
+
await runWakeReadCommand(command, { audit: applications.audit }, output);
|
|
202
|
+
return;
|
|
178
203
|
case 'init':
|
|
179
204
|
writeResult(output, await operational(applications).init(command.arguments));
|
|
180
205
|
return;
|
|
181
|
-
case 'doctor':
|
|
182
|
-
writeResult(output, await operational(applications).doctor(command.arguments));
|
|
183
|
-
return;
|
|
184
206
|
case WakeOperationalCommand.Maintenance:
|
|
185
207
|
writeResult(output, await operational(applications).maintenance(command.arguments));
|
|
186
208
|
return;
|
|
@@ -220,10 +242,6 @@ export async function runWakeCommand(command, applications, output, signal) {
|
|
|
220
242
|
case 'mcp':
|
|
221
243
|
await mcp(applications).serve(command.sessionPath, process.env.WAKE_MCP_TOKEN ?? '');
|
|
222
244
|
return;
|
|
223
|
-
case 'audit':
|
|
224
|
-
for (const record of await applications.audit.read(command.workItemId))
|
|
225
|
-
output.write(`${JSON.stringify(record)}\n`);
|
|
226
|
-
return;
|
|
227
245
|
case 'correlate':
|
|
228
246
|
output.write(`${JSON.stringify(await applications.correlate.correlate(command.resource, command.workItemId))}\n`);
|
|
229
247
|
return;
|
|
@@ -233,7 +251,7 @@ export async function runWakeCommand(command, applications, output, signal) {
|
|
|
233
251
|
case 'validate-state': {
|
|
234
252
|
if (command.rebuildProjections)
|
|
235
253
|
await applications.validateState.rebuildProjections();
|
|
236
|
-
|
|
254
|
+
await runWakeReadCommand({ ...command, rebuildProjections: false }, { validateState: applications.validateState }, output);
|
|
237
255
|
return;
|
|
238
256
|
}
|
|
239
257
|
}
|