@evident-ai/runner-cdk 3.5.2-dev.1c27282 → 3.5.2-dev.40a986e
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/README.md +89 -39
- package/dist/controller-lambda/handler.js +16 -16
- package/dist/evident-scale-to-zero-construct.js +7 -0
- package/dist/image-version-pruner-lambda/handler.js +28250 -0
- package/dist/image-version-reporter-lambda/handler.js +15 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -2
- package/dist/microvm/constants.d.ts +1 -1
- package/dist/microvm/constants.js +7 -4
- package/dist/microvm/construct.d.ts +12 -8
- package/dist/microvm/construct.js +42 -33
- package/dist/microvm/controller/handle-doorbell.d.ts +2 -2
- package/dist/microvm/controller/handle-doorbell.js +2 -2
- package/dist/microvm/image/stage-context.d.ts +13 -38
- package/dist/microvm/image/stage-context.js +30 -120
- package/dist/microvm/image-version-pruner/construct.d.ts +13 -0
- package/dist/microvm/image-version-pruner/construct.js +79 -0
- package/dist/microvm/image-version-pruner/handler.d.ts +20 -0
- package/dist/microvm/image-version-pruner/handler.js +116 -0
- package/dist/microvm/image-version-reporter/construct.d.ts +1 -1
- package/dist/microvm/image-version-reporter/construct.js +3 -3
- package/dist/microvm/image-version-reporter/handler.d.ts +2 -2
- package/dist/microvm/image-version-reporter/handler.js +9 -7
- package/dist/microvm/shapes.d.ts +10 -21
- package/dist/microvm/shapes.js +10 -17
- package/dist/waker-lambda/handler.js +3 -3
- package/package.json +3 -3
- package/dist/microvm-image-context/Dockerfile +0 -190
- package/dist/microvm-image-context/hook-server.js +0 -286
- package/dist/microvm-image-context/hooks/common.sh +0 -905
- package/dist/microvm-image-context/hooks/resume +0 -81
- package/dist/microvm-image-context/hooks/run +0 -95
- package/dist/microvm-image-context/hooks/suspend +0 -21
- package/dist/microvm-image-context/hooks/terminate +0 -36
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ImageVersionPruner = void 0;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const cdk = __importStar(require("aws-cdk-lib"));
|
|
39
|
+
const iam = __importStar(require("aws-cdk-lib/aws-iam"));
|
|
40
|
+
const lambda = __importStar(require("aws-cdk-lib/aws-lambda"));
|
|
41
|
+
const cr = __importStar(require("aws-cdk-lib/custom-resources"));
|
|
42
|
+
const constructs_1 = require("constructs");
|
|
43
|
+
class ImageVersionPruner extends constructs_1.Construct {
|
|
44
|
+
constructor(scope, id, props) {
|
|
45
|
+
super(scope, id);
|
|
46
|
+
const handler = new lambda.Function(this, 'Function', {
|
|
47
|
+
runtime: lambda.Runtime.NODEJS_22_X,
|
|
48
|
+
code: lambda.Code.fromAsset(path.join(__dirname, '..', '..', '..', 'dist', 'image-version-pruner-lambda')),
|
|
49
|
+
handler: 'handler.handler',
|
|
50
|
+
memorySize: 256,
|
|
51
|
+
timeout: cdk.Duration.minutes(5),
|
|
52
|
+
});
|
|
53
|
+
handler.addToRolePolicy(new iam.PolicyStatement({
|
|
54
|
+
actions: [
|
|
55
|
+
'lambda:GetMicrovmImage',
|
|
56
|
+
'lambda:ListMicrovmImageVersions',
|
|
57
|
+
'lambda:UpdateMicrovmImageVersion',
|
|
58
|
+
'lambda:DeleteMicrovmImageVersion',
|
|
59
|
+
],
|
|
60
|
+
resources: [...props.imageArns],
|
|
61
|
+
}));
|
|
62
|
+
handler.addToRolePolicy(new iam.PolicyStatement({
|
|
63
|
+
// Evidence-only read: this account-wide permission cannot authorize a mutation.
|
|
64
|
+
actions: ['lambda:ListMicrovms'],
|
|
65
|
+
resources: ['*'],
|
|
66
|
+
}));
|
|
67
|
+
const provider = new cr.Provider(this, 'Provider', {
|
|
68
|
+
onEventHandler: handler,
|
|
69
|
+
});
|
|
70
|
+
new cdk.CustomResource(this, 'Resource', {
|
|
71
|
+
serviceToken: provider.serviceToken,
|
|
72
|
+
properties: {
|
|
73
|
+
imageArns: props.imageArns,
|
|
74
|
+
buildTriggers: props.buildTriggers,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.ImageVersionPruner = ImageVersionPruner;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LambdaMicrovmsClient } from '@aws-sdk/client-lambda-microvms';
|
|
2
|
+
import { type PruneImageVersionsOptions, type PruneSummary } from '@evident-ai/lambda-microvm-cdk/prune';
|
|
3
|
+
export declare const PRUNE_DEADLINE_MS: number;
|
|
4
|
+
export type ImageVersionPrunerEvent = {
|
|
5
|
+
RequestType: 'Create' | 'Update' | 'Delete';
|
|
6
|
+
ResourceProperties?: {
|
|
7
|
+
imageArns?: unknown;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export type ImageVersionPrunerDependencies = {
|
|
11
|
+
pruneImageVersions: (options: PruneImageVersionsOptions) => Promise<PruneSummary>;
|
|
12
|
+
createClient: () => LambdaMicrovmsClient;
|
|
13
|
+
now: () => number;
|
|
14
|
+
};
|
|
15
|
+
type ImageVersionPrunerResponse = {
|
|
16
|
+
PhysicalResourceId: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function handleImageVersionPrune(event: ImageVersionPrunerEvent, dependencies?: ImageVersionPrunerDependencies): Promise<ImageVersionPrunerResponse>;
|
|
19
|
+
export declare const handler: (event: ImageVersionPrunerEvent) => Promise<ImageVersionPrunerResponse>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handler = exports.PRUNE_DEADLINE_MS = void 0;
|
|
4
|
+
exports.handleImageVersionPrune = handleImageVersionPrune;
|
|
5
|
+
const client_lambda_microvms_1 = require("@aws-sdk/client-lambda-microvms");
|
|
6
|
+
const prune_1 = require("@evident-ai/lambda-microvm-cdk/prune");
|
|
7
|
+
const PHYSICAL_RESOURCE_ID = 'evident-image-version-pruner';
|
|
8
|
+
exports.PRUNE_DEADLINE_MS = 4 * 60 * 1_000;
|
|
9
|
+
const runtimeDependencies = {
|
|
10
|
+
pruneImageVersions: prune_1.pruneImageVersions,
|
|
11
|
+
createClient: () => new client_lambda_microvms_1.LambdaMicrovmsClient({}),
|
|
12
|
+
now: Date.now,
|
|
13
|
+
};
|
|
14
|
+
function response() {
|
|
15
|
+
return { PhysicalResourceId: PHYSICAL_RESOURCE_ID };
|
|
16
|
+
}
|
|
17
|
+
function log(message) {
|
|
18
|
+
console.log(`[image-version-pruner] ${message}`);
|
|
19
|
+
}
|
|
20
|
+
function logError(message) {
|
|
21
|
+
console.error(`[image-version-pruner] ${message}`);
|
|
22
|
+
}
|
|
23
|
+
function readImageArns(value) {
|
|
24
|
+
if (!Array.isArray(value) || !value.every((imageArn) => typeof imageArn === 'string')) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
async function raceWithDeadline(operation, controller) {
|
|
30
|
+
let timer;
|
|
31
|
+
const deadline = new Promise((resolve) => {
|
|
32
|
+
timer = setTimeout(() => resolve({ timedOut: true }), exports.PRUNE_DEADLINE_MS);
|
|
33
|
+
});
|
|
34
|
+
try {
|
|
35
|
+
const result = await Promise.race([
|
|
36
|
+
operation.then((summary) => ({ timedOut: false, summary })),
|
|
37
|
+
deadline,
|
|
38
|
+
]);
|
|
39
|
+
if (result.timedOut) {
|
|
40
|
+
controller.abort();
|
|
41
|
+
try {
|
|
42
|
+
await operation;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.warn('MicroVM image version pruning cancellation observed', {
|
|
46
|
+
error: error instanceof Error ? error.message : String(error),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
if (timer !== undefined) {
|
|
54
|
+
clearTimeout(timer);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function handleImageVersionPrune(event, dependencies = runtimeDependencies) {
|
|
59
|
+
if (event.RequestType === 'Delete') {
|
|
60
|
+
return response();
|
|
61
|
+
}
|
|
62
|
+
const imageArns = readImageArns(event.ResourceProperties?.imageArns);
|
|
63
|
+
if (imageArns === undefined) {
|
|
64
|
+
console.warn('MicroVM image version pruning skipped', {
|
|
65
|
+
operation: event.RequestType,
|
|
66
|
+
reason: 'imageArns must be an array of strings',
|
|
67
|
+
});
|
|
68
|
+
return response();
|
|
69
|
+
}
|
|
70
|
+
if (imageArns.length === 0) {
|
|
71
|
+
console.warn('MicroVM image version pruning skipped', {
|
|
72
|
+
operation: event.RequestType,
|
|
73
|
+
reason: 'imageArns is empty',
|
|
74
|
+
});
|
|
75
|
+
return response();
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const startedAt = dependencies.now();
|
|
79
|
+
const controller = new AbortController();
|
|
80
|
+
const operation = dependencies.pruneImageVersions({
|
|
81
|
+
client: dependencies.createClient(),
|
|
82
|
+
imageArns,
|
|
83
|
+
abortSignal: controller.signal,
|
|
84
|
+
log,
|
|
85
|
+
logError,
|
|
86
|
+
});
|
|
87
|
+
const result = await raceWithDeadline(operation, controller);
|
|
88
|
+
if (result.timedOut) {
|
|
89
|
+
console.warn('MicroVM image version pruning deadline reached', {
|
|
90
|
+
operation: event.RequestType,
|
|
91
|
+
imageArns,
|
|
92
|
+
deadlineMs: exports.PRUNE_DEADLINE_MS,
|
|
93
|
+
elapsedMs: dependencies.now() - startedAt,
|
|
94
|
+
});
|
|
95
|
+
return response();
|
|
96
|
+
}
|
|
97
|
+
console.log('MicroVM image version pruning complete', {
|
|
98
|
+
operation: event.RequestType,
|
|
99
|
+
imageArns,
|
|
100
|
+
deactivated: result.summary.deactivated.length,
|
|
101
|
+
deleted: result.summary.deleted.length,
|
|
102
|
+
skipped: result.summary.skipped.length,
|
|
103
|
+
stoppedOnQuota: result.summary.stoppedOnQuota,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
console.warn('MicroVM image version pruning failed', {
|
|
108
|
+
operation: event.RequestType,
|
|
109
|
+
imageArns,
|
|
110
|
+
error: error instanceof Error ? error.message : String(error),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return response();
|
|
114
|
+
}
|
|
115
|
+
const handler = (event) => handleImageVersionPrune(event);
|
|
116
|
+
exports.handler = handler;
|
|
@@ -3,7 +3,7 @@ import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager';
|
|
|
3
3
|
import type { MicrovmImageBuildInputs } from '@evident-ai/lambda-microvm-cdk';
|
|
4
4
|
export type ImageVersionReporterProps = {
|
|
5
5
|
/** The secret whose value is the same HMAC key the controller verifies every doorbell against. */
|
|
6
|
-
|
|
6
|
+
controllerSigningSecret: secretsmanager.ISecret;
|
|
7
7
|
/** Base URL of Evident's own API — non-secret. */
|
|
8
8
|
evidentApiUrl: string;
|
|
9
9
|
/** The pool runner id the report is filed against — non-secret, public UUID. */
|
|
@@ -64,13 +64,13 @@ class ImageVersionReporter extends constructs_1.Construct {
|
|
|
64
64
|
timeout: cdk.Duration.seconds(30),
|
|
65
65
|
environment: {
|
|
66
66
|
// ARN + field name only, never the value (mirrors the controller and waker).
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
CONTROLLER_SIGNING_SECRET_ARN: props.controllerSigningSecret.secretArn,
|
|
68
|
+
CONTROLLER_SIGNING_SECRET_KEY: constants_1.CONTROLLER_SIGNING_SECRET_KEY,
|
|
69
69
|
EVIDENT_API_URL: props.evidentApiUrl,
|
|
70
70
|
EVIDENT_RUNNER_ID: props.evidentRunnerId,
|
|
71
71
|
},
|
|
72
72
|
});
|
|
73
|
-
props.
|
|
73
|
+
props.controllerSigningSecret.grantRead(handler);
|
|
74
74
|
const provider = new cr.Provider(this, 'Provider', {
|
|
75
75
|
onEventHandler: handler,
|
|
76
76
|
});
|
|
@@ -9,8 +9,8 @@ export type ReporterEvent = {
|
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
export type ReporterConfig = {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
controllerSigningSecretArn: string;
|
|
13
|
+
controllerSigningSecretKey: string;
|
|
14
14
|
evidentApiUrl: string;
|
|
15
15
|
evidentRunnerId: string;
|
|
16
16
|
};
|
|
@@ -7,17 +7,17 @@ const client_secrets_manager_1 = require("@aws-sdk/client-secrets-manager");
|
|
|
7
7
|
const PHYSICAL_RESOURCE_ID = 'evident-image-version-report';
|
|
8
8
|
const REPORT_TIMEOUT_MS = 5_000;
|
|
9
9
|
const secrets = new client_secrets_manager_1.SecretsManagerClient({});
|
|
10
|
-
async function
|
|
10
|
+
async function fetchControllerSigningSecret(secretArn, secretKey) {
|
|
11
11
|
const { SecretString } = await secrets.send(new client_secrets_manager_1.GetSecretValueCommand({ SecretId: secretArn }));
|
|
12
12
|
if (!SecretString) {
|
|
13
|
-
throw new Error(`
|
|
13
|
+
throw new Error(`controller signing secret ${secretArn} has no SecretString`);
|
|
14
14
|
}
|
|
15
15
|
const parsed = JSON.parse(SecretString);
|
|
16
16
|
const value = parsed !== null && typeof parsed === 'object'
|
|
17
17
|
? parsed[secretKey]
|
|
18
18
|
: undefined;
|
|
19
19
|
if (typeof value !== 'string' || value === '') {
|
|
20
|
-
throw new Error(`
|
|
20
|
+
throw new Error(`controller signing secret ${secretArn} is missing a non-empty '${secretKey}' field`);
|
|
21
21
|
}
|
|
22
22
|
return value;
|
|
23
23
|
}
|
|
@@ -43,7 +43,7 @@ function response() {
|
|
|
43
43
|
return { PhysicalResourceId: PHYSICAL_RESOURCE_ID };
|
|
44
44
|
}
|
|
45
45
|
const runtimeDependencies = {
|
|
46
|
-
getSecret:
|
|
46
|
+
getSecret: fetchControllerSigningSecret,
|
|
47
47
|
fetch: globalThis.fetch,
|
|
48
48
|
};
|
|
49
49
|
async function handleImageVersionReport(event, getConfig, dependencies = runtimeDependencies) {
|
|
@@ -57,10 +57,12 @@ async function handleImageVersionReport(event, getConfig, dependencies = runtime
|
|
|
57
57
|
versions = readImageVersions(event.ResourceProperties?.imageVersions);
|
|
58
58
|
const config = getConfig();
|
|
59
59
|
runnerId = config.evidentRunnerId;
|
|
60
|
-
const secret = await dependencies.getSecret(config.
|
|
60
|
+
const secret = await dependencies.getSecret(config.controllerSigningSecretArn, config.controllerSigningSecretKey);
|
|
61
61
|
const body = JSON.stringify({
|
|
62
62
|
type: 'runner.microvm_image_versions_reported',
|
|
63
63
|
versions,
|
|
64
|
+
// The API orders reports by this value because replacing an image restarts its version counter.
|
|
65
|
+
reporter_clock_ms: Date.now(),
|
|
64
66
|
});
|
|
65
67
|
const signature = (0, node_crypto_1.createHmac)('sha256', secret).update(body).digest('hex');
|
|
66
68
|
const url = `${config.evidentApiUrl.replace(/\/+$/, '')}/v1/runners/${encodeURIComponent(runnerId)}/microvm-image-versions`;
|
|
@@ -96,8 +98,8 @@ async function handleImageVersionReport(event, getConfig, dependencies = runtime
|
|
|
96
98
|
return response();
|
|
97
99
|
}
|
|
98
100
|
const handler = (event) => handleImageVersionReport(event, () => ({
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
controllerSigningSecretArn: requireEnv('CONTROLLER_SIGNING_SECRET_ARN'),
|
|
102
|
+
controllerSigningSecretKey: requireEnv('CONTROLLER_SIGNING_SECRET_KEY'),
|
|
101
103
|
evidentApiUrl: requireEnv('EVIDENT_API_URL'),
|
|
102
104
|
evidentRunnerId: requireEnv('EVIDENT_RUNNER_ID'),
|
|
103
105
|
}));
|
package/dist/microvm/shapes.d.ts
CHANGED
|
@@ -5,11 +5,8 @@ import { type MicrovmMemoryMiB } from '@evident-ai/lambda-microvm-cdk';
|
|
|
5
5
|
* there is no launch-time resource dial — so "a bigger machine" means "a
|
|
6
6
|
* different shape", each backed by its own `MicrovmImage`.
|
|
7
7
|
*
|
|
8
|
-
* `
|
|
9
|
-
*
|
|
10
|
-
* deployment identity (see the comment on `MICROVM_SHAPES` below): deriving
|
|
11
|
-
* them would let an innocent rename of `name` silently rebuild the live
|
|
12
|
-
* image. Every other shape is free to name these however is convenient.
|
|
8
|
+
* `name` is also the `MicrovmImage` child id, so it identifies both the
|
|
9
|
+
* controller-facing shape and the image resource built for it.
|
|
13
10
|
*/
|
|
14
11
|
export interface MicrovmShape {
|
|
15
12
|
/** The stable id a doorbell asks for; crosses the wire to Evident. */
|
|
@@ -27,8 +24,6 @@ export interface MicrovmShape {
|
|
|
27
24
|
* it must be the first entry in `MICROVM_SHAPES`.
|
|
28
25
|
*/
|
|
29
26
|
readonly isDefault: boolean;
|
|
30
|
-
/** The `MicrovmImage` construct id within the stack. */
|
|
31
|
-
readonly constructId: string;
|
|
32
27
|
/** The account-unique `imageName` passed to `MicrovmImage`. */
|
|
33
28
|
readonly imageName: string;
|
|
34
29
|
}
|
|
@@ -45,28 +40,22 @@ export interface MicrovmShape {
|
|
|
45
40
|
* making the construction-order contract enforceable rather than a
|
|
46
41
|
* convention.
|
|
47
42
|
*
|
|
48
|
-
* The default entry's `
|
|
49
|
-
* ("evident-microvm") are FROZEN:
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* verbatim from the image that is live today so the deploy changes nothing
|
|
53
|
-
* about it.
|
|
43
|
+
* The default entry's `name` ("standard") and `imageName`
|
|
44
|
+
* ("evident-microvm-standard") are FROZEN: `name` crosses the wire and
|
|
45
|
+
* identifies the image child, while `imageName` is account-unique. Changing
|
|
46
|
+
* either replaces the image, so both values remain stable after deployment.
|
|
54
47
|
*
|
|
55
48
|
* "Frozen" means unchanged under OUR OWN synth (no `microvm:*` context set —
|
|
56
49
|
* `main.ts` passes none). `imageName` MAY carry a customer's
|
|
57
50
|
* `microvm:namePrefix` (`deployment.ts`'s `resolveShapeCatalogue`) — that is
|
|
58
|
-
* account-scoped naming, not a change to this module.
|
|
59
|
-
* frozen unconditionally, with no override anywhere: it is the
|
|
60
|
-
* CloudFormation logical-id path, and prefixing it is the resource
|
|
61
|
-
* replacement this whole file's FROZEN warning exists to prevent.
|
|
51
|
+
* account-scoped naming, not a change to this module.
|
|
62
52
|
*/
|
|
63
53
|
export declare const MICROVM_SHAPES: readonly MicrovmShape[];
|
|
64
54
|
/**
|
|
65
55
|
* Validates a shape list at synth time. Deliberately lean
|
|
66
56
|
* (`code-simplicity.mdc`): this is a hand-edited constant list in a typed
|
|
67
|
-
* file, so it only checks what `tsc` cannot already catch
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* so a rendered size is not measurable anyway).
|
|
57
|
+
* file, so it only checks what `tsc` cannot already catch. No byte-budget cap
|
|
58
|
+
* is applied because the image ARNs are unresolved tokens at synth, so a
|
|
59
|
+
* rendered size is not measurable anyway.
|
|
71
60
|
*/
|
|
72
61
|
export declare function validateShapes(shapes: readonly MicrovmShape[]): readonly MicrovmShape[];
|
package/dist/microvm/shapes.js
CHANGED
|
@@ -16,20 +16,15 @@ const lambda_microvm_cdk_1 = require("@evident-ai/lambda-microvm-cdk");
|
|
|
16
16
|
* making the construction-order contract enforceable rather than a
|
|
17
17
|
* convention.
|
|
18
18
|
*
|
|
19
|
-
* The default entry's `
|
|
20
|
-
* ("evident-microvm") are FROZEN:
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* verbatim from the image that is live today so the deploy changes nothing
|
|
24
|
-
* about it.
|
|
19
|
+
* The default entry's `name` ("standard") and `imageName`
|
|
20
|
+
* ("evident-microvm-standard") are FROZEN: `name` crosses the wire and
|
|
21
|
+
* identifies the image child, while `imageName` is account-unique. Changing
|
|
22
|
+
* either replaces the image, so both values remain stable after deployment.
|
|
25
23
|
*
|
|
26
24
|
* "Frozen" means unchanged under OUR OWN synth (no `microvm:*` context set —
|
|
27
25
|
* `main.ts` passes none). `imageName` MAY carry a customer's
|
|
28
26
|
* `microvm:namePrefix` (`deployment.ts`'s `resolveShapeCatalogue`) — that is
|
|
29
|
-
* account-scoped naming, not a change to this module.
|
|
30
|
-
* frozen unconditionally, with no override anywhere: it is the
|
|
31
|
-
* CloudFormation logical-id path, and prefixing it is the resource
|
|
32
|
-
* replacement this whole file's FROZEN warning exists to prevent.
|
|
27
|
+
* account-scoped naming, not a change to this module.
|
|
33
28
|
*/
|
|
34
29
|
exports.MICROVM_SHAPES = [
|
|
35
30
|
{
|
|
@@ -38,18 +33,16 @@ exports.MICROVM_SHAPES = [
|
|
|
38
33
|
description: 'Evident per-session runner: an arm64 image that boots with no identity and acquires one at /run.',
|
|
39
34
|
memoryMiB: 4096,
|
|
40
35
|
isDefault: true,
|
|
41
|
-
// FROZEN —
|
|
42
|
-
|
|
43
|
-
imageName: 'evident-microvm',
|
|
36
|
+
// FROZEN — name crosses the wire and imageName is account-unique.
|
|
37
|
+
imageName: 'evident-microvm-standard',
|
|
44
38
|
},
|
|
45
39
|
];
|
|
46
40
|
/**
|
|
47
41
|
* Validates a shape list at synth time. Deliberately lean
|
|
48
42
|
* (`code-simplicity.mdc`): this is a hand-edited constant list in a typed
|
|
49
|
-
* file, so it only checks what `tsc` cannot already catch
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* so a rendered size is not measurable anyway).
|
|
43
|
+
* file, so it only checks what `tsc` cannot already catch. No byte-budget cap
|
|
44
|
+
* is applied because the image ARNs are unresolved tokens at synth, so a
|
|
45
|
+
* rendered size is not measurable anyway.
|
|
53
46
|
*/
|
|
54
47
|
function validateShapes(shapes) {
|
|
55
48
|
if (shapes.length === 0) {
|
|
@@ -27,9 +27,9 @@ module.exports = __toCommonJS(handler_exports);
|
|
|
27
27
|
var import_client_ecs = require("@aws-sdk/client-ecs");
|
|
28
28
|
var import_client_secrets_manager = require("@aws-sdk/client-secrets-manager");
|
|
29
29
|
|
|
30
|
-
//
|
|
30
|
+
// ../../sdk/src/signature.ts
|
|
31
31
|
var import_node_crypto = require("node:crypto");
|
|
32
|
-
function
|
|
32
|
+
function verifyEvidentSignature(rawBody, signatureHeader, secret) {
|
|
33
33
|
if (!signatureHeader || !secret) {
|
|
34
34
|
return false;
|
|
35
35
|
}
|
|
@@ -64,7 +64,7 @@ async function handleWake({
|
|
|
64
64
|
service,
|
|
65
65
|
ecs
|
|
66
66
|
}) {
|
|
67
|
-
if (!
|
|
67
|
+
if (!verifyEvidentSignature(rawBody, signatureHeader, wakeSecret)) {
|
|
68
68
|
const { statusCode: statusCode2, body: body2 } = jsonResponse(401, "invalid signature");
|
|
69
69
|
return { statusCode: statusCode2, body: body2, calledUpdateService: false };
|
|
70
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evident-ai/runner-cdk",
|
|
3
|
-
"version": "3.5.2-dev.
|
|
3
|
+
"version": "3.5.2-dev.40a986e",
|
|
4
4
|
"description": "Reusable CDK constructs for an Evident agent runner: a single scale-to-zero Fargate runner (task + service + per-agent self-stop role + waker Lambda), or a per-session AWS Lambda MicroVM that boots on demand and suspends between messages. Instantiate once per agent from your own stack.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "pnpm run build-bundled-deps && ts-node scripts/build.ts && node -e 'const m=require(\"./package.json\").main; if (!require(\"node:fs\").existsSync(m)) { console.error(`build produced no ${m}`); process.exit(1); }'",
|
|
18
|
-
"//build-bundled-deps": "
|
|
19
|
-
"build-bundled-deps": "pnpm --filter @evident-ai/lambda-microvm-cdk build && pnpm --filter @evident-ai/lambda-microvm-runtime build",
|
|
18
|
+
"//build-bundled-deps": "Builds the workspace dependencies whose dist/ output the direct runner-cdk build chain consumes: lambda-microvm-cdk for the public construct types, lambda-microvm-runtime for runner-microvm-image's hook-server bundle, and runner-microvm-image for that bundle itself. Chained into `build` rather than left to turbo's `^build` because callers outside turbo invoke `pnpm --filter @evident-ai/runner-cdk build` directly, which bypasses turbo entirely.",
|
|
19
|
+
"build-bundled-deps": "pnpm --filter @evident-ai/lambda-microvm-cdk build && pnpm --filter @evident-ai/lambda-microvm-runtime build && pnpm --filter runner-microvm-image build",
|
|
20
20
|
"typecheck": "tsc --noEmit",
|
|
21
21
|
"test": "node --test --require ts-node/register 'src/**/*.test.ts'",
|
|
22
22
|
"format": "prettier --write 'src/**/*.ts'",
|