Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions packages/cli/src/agent-sandbox.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { readFile } from "node:fs/promises"
import { basename, resolve } from "node:path"
import { SANDBOX_DMC_PARENT_ONLY_ABILITIES, SANDBOX_DMC_SAFE_ABILITIES, SANDBOX_WORKSPACE_ROOT, type MountSpec, type RuntimePolicy, type SandboxWorkspaceContract, type SandboxWorkspaceMode, type WorkspaceRecipe } from "@chubes4/wp-codebox-core"
import { SANDBOX_DMC_PARENT_ONLY_ABILITIES, SANDBOX_DMC_SAFE_ABILITIES, SANDBOX_WORKSPACE_ROOT, stripUndefined, type MountSpec, type RuntimePolicy, type SandboxWorkspaceContract, type SandboxWorkspaceMode, type WorkspaceRecipe } from "@chubes4/wp-codebox-core"
import { agentRuntimeProbeCode, agentSandboxRunCode, resolveSandboxTaskCode } from "./agent-code.js"
import type { PreparedWorkspaceMount } from "./recipe-sources.js"
import { defaultPolicy } from "./recipe-validation.js"
Expand Down Expand Up @@ -452,7 +452,3 @@ function workspaceMountRef(target: string, mode: "readonly" | "readwrite", metad
wpContentPath: typeof metadata.wpContentPath === "string" ? metadata.wpContentPath : undefined,
})
}

function stripUndefined<T extends Record<string, unknown>>(value: T): T {
return Object.fromEntries(Object.entries(value).filter(([, entryValue]) => entryValue !== undefined)) as T
}
6 changes: 1 addition & 5 deletions packages/cli/src/commands/recipe-run.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { readFile } from "node:fs/promises"
import { basename, dirname, resolve } from "node:path"
import { createRuntime, type ArtifactBundle, type ExecutionResult, type Runtime, type RuntimeInfo, type WorkspaceRecipe, type WorkspaceRecipePluginRuntimeHealthProbe, type WorkspaceRecipeSiteSeed } from "@chubes4/wp-codebox-core"
import { createRuntime, stripUndefined, type ArtifactBundle, type ExecutionResult, type Runtime, type RuntimeInfo, type WorkspaceRecipe, type WorkspaceRecipePluginRuntimeHealthProbe, type WorkspaceRecipeSiteSeed } from "@chubes4/wp-codebox-core"
import { createPlaygroundRuntimeBackend } from "@chubes4/wp-codebox-playground"
import { recipeExecutionSpec, sandboxWorkspaceContract } from "../agent-sandbox.js"
import { captureStdout, printRecipeHumanOutput, printRecipeValidateHumanOutput, serializeError } from "../output.js"
Expand Down Expand Up @@ -1293,7 +1293,3 @@ function matchesNumberSelector(record: Record<string, unknown>, allowed: number[
const values = keys.map((key) => record[key]).filter((value): value is number => typeof value === "number")
return values.some((value) => allowed.includes(value))
}

function stripUndefined<T extends Record<string, unknown>>(record: T): T {
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)) as T
}
6 changes: 1 addition & 5 deletions packages/cli/src/recipe-dry-run.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { readFile } from "node:fs/promises"
import { basename, dirname, resolve } from "node:path"
import { SANDBOX_WORKSPACE_ROOT, validateRuntimePolicy, type MountSpec, type RuntimePolicy, type SandboxWorkspaceMode, type WorkspaceRecipe, type WorkspaceRecipePluginRuntime, type WorkspaceRecipePluginRuntimeHealthProbe, type WorkspaceRecipeSiteSeed, type WorkspaceRecipeWorkspace } from "@chubes4/wp-codebox-core"
import { SANDBOX_WORKSPACE_ROOT, stripUndefined, validateRuntimePolicy, type MountSpec, type RuntimePolicy, type SandboxWorkspaceMode, type WorkspaceRecipe, type WorkspaceRecipePluginRuntime, type WorkspaceRecipePluginRuntimeHealthProbe, type WorkspaceRecipeSiteSeed, type WorkspaceRecipeWorkspace } from "@chubes4/wp-codebox-core"
import { serializeError } from "./output.js"
import { activateExtraPluginsCode, defaultWorkspaceTarget, installMuPluginsCode, pluginTarget, recipeExtraPluginFile, recipeExtraPluginSlug, recipeExtraPlugins, recipeMountType, recipeSource, recipeSourceProvenance, resolveRecipeExtraPluginFile, stagedFileMountType, stagedFileProvenance, type RecipeSourceProvenance, type RecipeSourceType, type RecipeStagedFileProvenance } from "./recipe-sources.js"
import { hasExplicitSiteSeedSelectors, parseWorkspaceRecipe, pluginRuntimeHealthProbeStep, recipePolicy, recipeWorkflowSteps, validateWorkspaceRecipe, type RecipeValidationIssue, type RecipeWorkflowPhase } from "./recipe-validation.js"
Expand Down Expand Up @@ -514,7 +514,3 @@ export function siteSeedScopesAreBounded(siteSeed: WorkspaceRecipeSiteSeed): boo

return Object.values(siteSeed.scopes).some((scope) => scope !== undefined && scope !== false)
}

function stripUndefined<T extends Record<string, unknown>>(record: T): T {
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)) as T
}
6 changes: 1 addition & 5 deletions packages/cli/src/recipe-evidence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { mkdir, readFile, writeFile } from "node:fs/promises"
import { dirname, join, relative, resolve } from "node:path"
import { fileURLToPath } from "node:url"
import { promisify } from "node:util"
import { artifactFileDigest, artifactManifestFileWithSha256, checkWorkspacePolicy, isPlainObject as isRecord, refreshArtifactManifestFileSha256s, sha256StableJson, upsertArtifactManifestFiles, verifyArtifactBundle, type ArtifactBundle, type ArtifactBundleVerificationResult, type ArtifactManifest, type ArtifactManifestFile, type ExecutionResult, type Runtime, type RuntimeInfo, type RuntimePolicy, type WorkspacePolicyResult, type WorkspaceRecipe } from "@chubes4/wp-codebox-core"
import { artifactFileDigest, artifactManifestFileWithSha256, checkWorkspacePolicy, isPlainObject as isRecord, refreshArtifactManifestFileSha256s, sha256StableJson, stripUndefined, upsertArtifactManifestFiles, verifyArtifactBundle, type ArtifactBundle, type ArtifactBundleVerificationResult, type ArtifactManifest, type ArtifactManifestFile, type ExecutionResult, type Runtime, type RuntimeInfo, type RuntimePolicy, type WorkspacePolicyResult, type WorkspaceRecipe } from "@chubes4/wp-codebox-core"

export interface RecipeArtifactEvidenceFile {
path: string
Expand Down Expand Up @@ -813,7 +813,3 @@ function markRecipeArtifactsFinalized(interruption: RecipeArtifactsFinalizationC

;(interruption.metadata as { artifactsFinalized: boolean }).artifactsFinalized = artifactsFinalized
}

function stripUndefined<T extends Record<string, unknown>>(record: T): T {
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)) as T
}
6 changes: 1 addition & 5 deletions packages/cli/src/runtime-command-wrappers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createRuntime, type ArtifactBundle, type ExecutionResult, type MountSpec, type Runtime, type RuntimeInfo, type RuntimePolicy } from "@chubes4/wp-codebox-core"
import { createRuntime, stripUndefined, type ArtifactBundle, type ExecutionResult, type MountSpec, type Runtime, type RuntimeInfo, type RuntimePolicy } from "@chubes4/wp-codebox-core"
import { createPlaygroundRuntimeBackend } from "@chubes4/wp-codebox-playground"
import { serializeError } from "./output.js"
import { recipeMountType } from "./recipe-sources.js"
Expand Down Expand Up @@ -362,7 +362,3 @@ export async function releaseRuntime(runtime: Runtime, previewHoldSeconds = 0, a
await afterDestroy?.()
}
}

function stripUndefined<T extends Record<string, unknown>>(record: T): T {
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)) as T
}
4 changes: 4 additions & 0 deletions packages/runtime-core/src/object-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export function sha256StableJson(value: unknown, trailingNewline = false): strin
return createHash("sha256").update(`${stableJson(value)}${trailingNewline ? "\n" : ""}`).digest("hex")
}

export function stripUndefined<T extends Record<string, unknown>>(record: T): T {
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)) as T
}

export function stringList(value: unknown): string[] {
if (!Array.isArray(value)) return []

Expand Down
6 changes: 1 addition & 5 deletions packages/runtime-playground/src/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createHash } from "node:crypto"
import { readdir, readFile } from "node:fs/promises"
import { basename, join } from "node:path"
import { normalizeBlueprint, preferredVersionsForEnvironment } from "./blueprint.js"
import { artifactFileDigest } from "@chubes4/wp-codebox-core"
import { artifactFileDigest, stripUndefined } from "@chubes4/wp-codebox-core"
import type {
ArtifactPreview,
ArtifactProvenance,
Expand Down Expand Up @@ -517,10 +517,6 @@ function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value)
}

function stripUndefined<T extends Record<string, unknown>>(record: T): T {
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)) as T
}

function fileDiff(path: string, before: string, after: string, isAdded: boolean, isDeleted: boolean): string {
const beforeLines = splitLines(before)
const afterLines = splitLines(after)
Expand Down