@moinulmoin/eden 0.1.4 → 0.1.5

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 CHANGED
@@ -17,15 +17,15 @@ create a new Eden-native agent, start with `eden agent init`.
17
17
  Use any one of these package managers:
18
18
 
19
19
  ```sh
20
- npm install --global @moinulmoin/eden@0.1.4
20
+ npm install --global @moinulmoin/eden@0.1.5
21
21
  ```
22
22
 
23
23
  ```sh
24
- pnpm add --global @moinulmoin/eden@0.1.4
24
+ pnpm add --global @moinulmoin/eden@0.1.5
25
25
  ```
26
26
 
27
27
  ```sh
28
- bun add --global @moinulmoin/eden@0.1.4
28
+ bun add --global @moinulmoin/eden@0.1.5
29
29
  ```
30
30
 
31
31
  Then confirm the CLI is available:
@@ -1,6 +1,6 @@
1
1
  import { type EveCliEnvironment, type EveCliExecutionRequest } from "./eve.js";
2
2
  import { type EveNodeImage, type EveProjectBuildCandidate, type EveProjectBuilder } from "./eve-packaging.js";
3
- import { type EveHostRequirements, type EveRuntimeCleanup } from "./eve-runtime-image.js";
3
+ import { type EveHostRequirements, type EveRuntimeCleanup, type EveRuntimeImageDiscardRequest } from "./eve-runtime-image.js";
4
4
  import { type EveRuntimeConfig, type EveRuntimeInjection, type EveRuntimeProtectedStore } from "./eve-runtime-config.js";
5
5
  import type { EveHostConfig } from "@moinulmoin/eden-runtime-cloudflare";
6
6
  export declare const DEFAULT_EVE_HOST_REQUIREMENTS: EveHostRequirements;
@@ -79,6 +79,7 @@ export interface EvePreflightRuntimeRunnerRequest {
79
79
  readonly retainImage?: boolean;
80
80
  }
81
81
  export type EvePreflightRuntimeRunner = (request: EvePreflightRuntimeRunnerRequest) => EvePreflightRuntimeEvidence | Promise<EvePreflightRuntimeEvidence>;
82
+ export type EveRuntimeImageDiscardRunner = (request: EveRuntimeImageDiscardRequest) => boolean | Promise<boolean>;
82
83
  export interface EveDeploymentIdentity {
83
84
  readonly projectId: string;
84
85
  readonly sourceDigest: string;
@@ -189,6 +190,7 @@ export interface EvePreflightOptions {
189
190
  readonly compensate?: EveDeploymentCompensationRunner;
190
191
  readonly health?: EveDeploymentHealthRunner;
191
192
  readonly afterPromotion?: () => void | Promise<void>;
193
+ readonly discardRuntimeImage?: EveRuntimeImageDiscardRunner;
192
194
  readonly retainRuntimeImage?: boolean;
193
195
  readonly stdout?: (line: string) => void;
194
196
  /**
@@ -9,7 +9,7 @@ import { fileURLToPath, } from "node:url";
9
9
  import { promisify, } from "node:util";
10
10
  import { EveCliError, } from "./eve.js";
11
11
  import { buildEveProjectSnapshot, createDockerEveProjectBuilder, revalidateEveProjectCandidateInputs, EvePackagingError, } from "./eve-packaging.js";
12
- import { buildEveRuntimeImage, revalidateEveRuntimeCandidate, validateEveHostRequirements, } from "./eve-runtime-image.js";
12
+ import { buildEveRuntimeImage, discardEveRuntimeImage, revalidateEveRuntimeCandidate, validateEveHostRequirements, } from "./eve-runtime-image.js";
13
13
  import { EveRuntimeConfigError, prepareEveRuntimeInjection, redactEveRuntimeOutput, } from "./eve-runtime-config.js";
14
14
  const execFileAsync = promisify(execFile);
15
15
  const require = createRequire(import.meta.url);
@@ -1341,9 +1341,35 @@ async function runEveDeployment(request, options, collected) {
1341
1341
  });
1342
1342
  await promoteEveTargetPointer(join(request.projectRoot, ".eden", "eve-deploy"), targetKey, candidate.generationRoot);
1343
1343
  await options.afterPromotion?.();
1344
+ let runtimeImageCleanup;
1345
+ if (runtimeEvidence.cleanup.imageRetained) {
1346
+ if (options.retainRuntimeImage === true) {
1347
+ runtimeImageCleanup = check("VAL-CROSS-004", "skipped", "The exact local runtime image was intentionally retained by the programmatic caller.");
1348
+ }
1349
+ else {
1350
+ let discarded = false;
1351
+ try {
1352
+ discarded = await (options.discardRuntimeImage ??
1353
+ discardEveRuntimeImage)({
1354
+ imageId: imageDigest,
1355
+ generationId: candidate.generationId,
1356
+ generationRoot: candidate.generationRoot,
1357
+ });
1358
+ }
1359
+ catch {
1360
+ discarded = false;
1361
+ }
1362
+ runtimeImageCleanup = discarded
1363
+ ? check("VAL-CROSS-004", "passed", "The exact local runtime image and its publication tags were removed after the healthy deployment was promoted.")
1364
+ : check("VAL-CROSS-004", "failed", "The remote deployment is healthy, but exact local runtime-image cleanup could not be verified.", `Remove only the recorded image ${imageDigest}; do not retry or run broad Docker cleanup.`);
1365
+ }
1366
+ }
1344
1367
  return {
1345
1368
  ...collected.result,
1346
- ok: true,
1369
+ ok: runtimeImageCleanup?.status !== "failed",
1370
+ ...(runtimeImageCleanup === undefined
1371
+ ? {}
1372
+ : { checks: [...collected.result.checks, runtimeImageCleanup] }),
1347
1373
  deployment: deploymentMetadata(identity, targetKey, "deployed"),
1348
1374
  };
1349
1375
  }
@@ -1696,10 +1722,14 @@ export async function runEveControlPlane(request, options = {}) {
1696
1722
  throw new EveCliError({
1697
1723
  code: status === "indeterminate"
1698
1724
  ? "DEPLOY_INDETERMINATE"
1699
- : "EVE_DEPLOYMENT_FAILED",
1725
+ : status === "deployed"
1726
+ ? "EVE_RUNTIME_IMAGE_CLEANUP_FAILED"
1727
+ : "EVE_DEPLOYMENT_FAILED",
1700
1728
  message: status === "indeterminate"
1701
1729
  ? "The Eve deployment outcome is indeterminate; inspect the retained exact ownership evidence before retrying."
1702
- : "The Eve deployment failed before exact target promotion.",
1730
+ : status === "deployed"
1731
+ ? "The Eve deployment is healthy and promoted, but exact local runtime-image cleanup failed; do not retry the deployment."
1732
+ : "The Eve deployment failed before exact target promotion.",
1703
1733
  });
1704
1734
  }
1705
1735
  }
@@ -92,6 +92,12 @@ export interface EveRuntimeImageRequest {
92
92
  */
93
93
  readonly retainImage?: boolean;
94
94
  }
95
+ export interface EveRuntimeImageDiscardRequest {
96
+ readonly imageId: string;
97
+ readonly generationId: string;
98
+ readonly generationRoot: string;
99
+ readonly dockerCommand?: string;
100
+ }
95
101
  export interface EveRuntimeImageResult {
96
102
  readonly schemaVersion: 1;
97
103
  readonly worker: "eve-packaging-worker";
@@ -116,6 +122,7 @@ export interface EveRuntimeImageResult {
116
122
  }
117
123
  export declare function validateEveHostRequirements(requirements: EveHostRequirements): void;
118
124
  export declare function revalidateEveRuntimeCandidate(candidate: EveProjectBuildCandidate): Promise<EveRuntimeClosure>;
125
+ export declare function discardEveRuntimeImage(request: EveRuntimeImageDiscardRequest): Promise<boolean>;
119
126
  export declare function buildEveRuntimeImage(request: EveRuntimeImageRequest): Promise<EveRuntimeImageResult>;
120
127
  export {};
121
128
  //# sourceMappingURL=eve-runtime-image.d.ts.map
@@ -743,6 +743,46 @@ async function removeOwnedImage(state) {
743
743
  }
744
744
  return verified;
745
745
  }
746
+ export async function discardEveRuntimeImage(request) {
747
+ if (!IMAGE_ID_PATTERN.test(request.imageId) ||
748
+ !/^[a-z0-9][a-z0-9._-]{0,127}$/u.test(request.generationId)) {
749
+ return false;
750
+ }
751
+ const state = {
752
+ command: request.dockerCommand ?? "docker",
753
+ env: safeDockerEnvironment(),
754
+ generationRoot: request.generationRoot,
755
+ imageIdPath: join(request.generationRoot, "runtime-image-id"),
756
+ imageLabel: `eden.eve.generation=${request.generationId}`,
757
+ imageBuilt: true,
758
+ imageId: request.imageId,
759
+ containerId: undefined,
760
+ imageRetained: true,
761
+ };
762
+ let inspected;
763
+ try {
764
+ inspected = await docker(state, [
765
+ "image",
766
+ "inspect",
767
+ request.imageId,
768
+ "--format",
769
+ "{{.Id}} {{index .Config.Labels \"eden.eve.generation\"}}",
770
+ ]);
771
+ }
772
+ catch (error) {
773
+ const stderr = typeof error === "object" &&
774
+ error !== null &&
775
+ "stderr" in error &&
776
+ typeof error.stderr === "string"
777
+ ? error.stderr
778
+ : "";
779
+ return /(?:no such|not found|does not exist)/iu.test(stderr);
780
+ }
781
+ if (inspected.stdout.trim() !== `${request.imageId} ${request.generationId}`) {
782
+ return false;
783
+ }
784
+ return removeOwnedImage(state);
785
+ }
746
786
  function healthReady(value) {
747
787
  if (value === "ready")
748
788
  return true;
package/dist/index.d.ts CHANGED
@@ -6,12 +6,12 @@ export { EVE_CLI_COMMANDS, EVE_USAGE, EveCliError, eveHelpText, parseEveArgument
6
6
  export { EvePackagingError, buildEveProjectSnapshot, createDockerEveProjectBuilder, revalidateEveProjectCandidateInputs, } from "./eve-packaging.js";
7
7
  export { EVE_RESERVED_HOST_VARIABLES, EVE_START_COMMAND, EveRuntimeConfig, EveRuntimeConfigError, loadEveRuntimeConfig, parseEveRuntimeConfig, prepareEveRuntimeInjection, readEveRuntimeConfig, redactEveRuntimeOutput, } from "./eve-runtime-config.js";
8
8
  export type { EveReservedHostVariable, EveRuntimeConfigErrorCode, EveRuntimeInjection, EveRuntimeInjectionMode, EveRuntimeInjectionOptions, EveRuntimeInputIdentity, EveRuntimeProtectedPutRequest, EveRuntimeProtectedPutResult, EveRuntimeProtectedStore, EveStartProcessRequest, RedactedRuntimeConfigSeam, } from "./eve-runtime-config.js";
9
- export { buildEveRuntimeImage, revalidateEveRuntimeCandidate, validateEveHostRequirements, } from "./eve-runtime-image.js";
9
+ export { buildEveRuntimeImage, discardEveRuntimeImage, revalidateEveRuntimeCandidate, validateEveHostRequirements, } from "./eve-runtime-image.js";
10
10
  export type { EveCliCommand, EveCliEnvironment, EveCliExecutionRequest, EveCliHelp, EveCliInvocation, EveCliRunner, ParsedEveInvocation, } from "./eve.js";
11
11
  export type { EveNodeImage, EvePackagingCheck, EvePackagingCode, EveProjectBuilder, EveProjectBuilderRequest, EveProjectBuilderResult, EveProjectBuildCandidate, EveProjectFile, EveProjectImage, EveProjectInputManifest, EveProjectOutput, EveProjectPackagingResult, EveProjectRuntime, EveProjectSnapshot, EveProjectSnapshotOptions, EveProjectToolchain, EveRuntimeConfigExclusion, } from "./eve-packaging.js";
12
- export type { EveHostRequirements, EveRuntimeClosure, EveRuntimeClosureFile, EveRuntimeCleanup, EveRuntimeImage, EveRuntimeImageMetadata, EveRuntimeImageRequest, EveRuntimeImageResult, EveRuntimeNativeModule, EveRuntimeStatus, } from "./eve-runtime-image.js";
12
+ export type { EveHostRequirements, EveRuntimeClosure, EveRuntimeClosureFile, EveRuntimeCleanup, EveRuntimeImage, EveRuntimeImageDiscardRequest, EveRuntimeImageMetadata, EveRuntimeImageRequest, EveRuntimeImageResult, EveRuntimeNativeModule, EveRuntimeStatus, } from "./eve-runtime-image.js";
13
13
  export { DEFAULT_EVE_HOST_REQUIREMENTS, DEFAULT_EVE_NODE_IMAGE, runEveControlPlane, runEveDestroy, } from "./eve-control-plane.js";
14
- export type { EveCloudflareReadRequest, EveCloudflareReadResult, EveCloudflareReadRunner, EveCloudflareTargetState, EveContainerDeleteRunner, EveDeploymentCompensationRequest, EveDeploymentCompensationRunner, EveDeploymentHealthRequest, EveDeploymentHealthResult, EveDeploymentHealthRunner, EveDeploymentIdentity, EveDeploymentIdentityProof, EveDeploymentMetadata, EveDeploymentPublicationRequest, EveDeploymentPublicationResult, EveDeploymentPublicationRunner, EveDeploymentStatus, EveDestroyCloudflareReadRequest, EveDestroyCloudflareReadRunner, EveDestroyOutcome, EveDestroyTargetRead, EveImagePublicationRequest, EveImagePublicationResult, EveImagePublicationRunner, EvePreflightCandidate, EvePreflightCheck, EvePreflightCheckStatus, EvePreflightOptions, EvePreflightResult, EvePreflightRuntimeEvidence, EvePreflightRuntimeRunner, EvePreflightRuntimeRunnerRequest, EveRuntimeConfigLoader, EveWorkerDeleteRunner, } from "./eve-control-plane.js";
14
+ export type { EveCloudflareReadRequest, EveCloudflareReadResult, EveCloudflareReadRunner, EveCloudflareTargetState, EveContainerDeleteRunner, EveDeploymentCompensationRequest, EveDeploymentCompensationRunner, EveDeploymentHealthRequest, EveDeploymentHealthResult, EveDeploymentHealthRunner, EveDeploymentIdentity, EveDeploymentIdentityProof, EveDeploymentMetadata, EveDeploymentPublicationRequest, EveDeploymentPublicationResult, EveDeploymentPublicationRunner, EveDeploymentStatus, EveDestroyCloudflareReadRequest, EveDestroyCloudflareReadRunner, EveDestroyOutcome, EveDestroyTargetRead, EveImagePublicationRequest, EveImagePublicationResult, EveImagePublicationRunner, EvePreflightCandidate, EvePreflightCheck, EvePreflightCheckStatus, EvePreflightOptions, EvePreflightResult, EvePreflightRuntimeEvidence, EvePreflightRuntimeRunner, EvePreflightRuntimeRunnerRequest, EveRuntimeConfigLoader, EveRuntimeImageDiscardRunner, EveWorkerDeleteRunner, } from "./eve-control-plane.js";
15
15
  export declare const EDEN_CLI_COMMANDS: readonly ["preflight", "deploy", "destroy", "agent"];
16
16
  export type EdenCliCommand = (typeof EDEN_CLI_COMMANDS)[number];
17
17
  export declare const EDEN_AGENT_COMMANDS: readonly ["init", "dev", "build", "deploy"];
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ import { DEFAULT_EVE_HOST_REQUIREMENTS, runEveControlPlane, runEveDestroy, } fro
16
16
  export { EVE_CLI_COMMANDS, EVE_USAGE, EveCliError, eveHelpText, parseEveArguments, } from "./eve.js";
17
17
  export { EvePackagingError, buildEveProjectSnapshot, createDockerEveProjectBuilder, revalidateEveProjectCandidateInputs, } from "./eve-packaging.js";
18
18
  export { EVE_RESERVED_HOST_VARIABLES, EVE_START_COMMAND, EveRuntimeConfig, EveRuntimeConfigError, loadEveRuntimeConfig, parseEveRuntimeConfig, prepareEveRuntimeInjection, readEveRuntimeConfig, redactEveRuntimeOutput, } from "./eve-runtime-config.js";
19
- export { buildEveRuntimeImage, revalidateEveRuntimeCandidate, validateEveHostRequirements, } from "./eve-runtime-image.js";
19
+ export { buildEveRuntimeImage, discardEveRuntimeImage, revalidateEveRuntimeCandidate, validateEveHostRequirements, } from "./eve-runtime-image.js";
20
20
  export { DEFAULT_EVE_HOST_REQUIREMENTS, DEFAULT_EVE_NODE_IMAGE, runEveControlPlane, runEveDestroy, } from "./eve-control-plane.js";
21
21
  const require = createRequire(import.meta.url);
22
22
  export const EDEN_CLI_COMMANDS = [
@@ -128,8 +128,8 @@ export default greet;
128
128
  "deploy": "eden agent deploy"
129
129
  },
130
130
  "devDependencies": {
131
- "@moinulmoin/eden": "0.1.4",
132
- "@moinulmoin/eden-definitions": "0.1.4",
131
+ "@moinulmoin/eden": "0.1.5",
132
+ "@moinulmoin/eden-definitions": "0.1.5",
133
133
  "typescript": "5.9.3",
134
134
  "wrangler": "4.120.0"
135
135
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moinulmoin/eden",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Deploy existing Eve agents to Cloudflare and author Cloudflare-native Eden Agents.",
5
5
  "keywords": [
6
6
  "ai",
@@ -31,8 +31,8 @@
31
31
  "NOTICE"
32
32
  ],
33
33
  "dependencies": {
34
- "@moinulmoin/eden-compiler": "0.1.4",
35
- "@moinulmoin/eden-runtime-cloudflare": "0.1.4",
34
+ "@moinulmoin/eden-compiler": "0.1.5",
35
+ "@moinulmoin/eden-runtime-cloudflare": "0.1.5",
36
36
  "chokidar": "5.0.0",
37
37
  "wrangler": "4.120.0"
38
38
  },