Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

feat: make metadata nullable for sandbox providers (#246)

Sujai Kumar Gupta02d815569104
diff --git a/.github/fern/openapi/openapi.json b/.github/fern/openapi/openapi.json
index 2ac0e30d1..cbd8f02d1 100644
--- a/.github/fern/openapi/openapi.json
+++ b/.github/fern/openapi/openapi.json
@@ -2705,24 +2705,6 @@
},
"type": "object"
},
- "SandboxBuildMetadata": {
- "additionalProperties": false,
- "properties": {
- "build_ref": {
- "description": "Provider build handle derived from the image digest (e.g. Daytona snapshot name).",
- "type": "string"
- },
- "image_uri": {
- "description": "Full reference of the release sandbox image this build refers to.",
- "type": "string"
- }
- },
- "required": [
- "build_ref",
- "image_uri"
- ],
- "type": "object"
- },
"SandboxBuildStatus": {
"description": "Current build status.",
"enum": [
@@ -2913,9 +2895,6 @@
"SandboxProviderResponse": {
"additionalProperties": false,
"properties": {
- "build_metadata": {
- "$ref": "#/components/schemas/SandboxBuildMetadata"
- },
"manifest": {
"$ref": "#/components/schemas/SandboxProviderManifest"
},
@@ -2933,8 +2912,7 @@
"required": [
"manifest",
"status",
- "status_reason",
- "build_metadata"
+ "status_reason"
],
"type": "object"
},
diff --git a/packages/harness/src/core/sandbox/provider/DaytonaProvider.ts b/packages/harness/src/core/sandbox/provider/DaytonaProvider.ts
index ab0a3c257..20ce7cdf5 100644
--- a/packages/harness/src/core/sandbox/provider/DaytonaProvider.ts
+++ b/packages/harness/src/core/sandbox/provider/DaytonaProvider.ts
@@ -242,7 +242,7 @@ export class DaytonaSandboxProvider implements SandboxProvider {
}
private toBuild(state: Snapshot['state'], errorReason: string | null): SandboxBuild {
- const metadata = { buildRef: this.buildRef, imageUri: this.imageUri };
+ const metadata = { build_ref: this.buildRef, image_uri: this.imageUri };
switch (state) {
case BUILD_STATE_ACTIVE:
return { status: 'ready', reason: null, metadata };
@@ -279,7 +279,7 @@ export class DaytonaSandboxProvider implements SandboxProvider {
return {
status: 'pending',
reason: 'Sandbox image build started.',
- metadata: { buildRef: this.buildRef, imageUri: this.imageUri },
+ metadata: { build_ref: this.buildRef, image_uri: this.imageUri },
};
}
@@ -290,7 +290,7 @@ export class DaytonaSandboxProvider implements SandboxProvider {
return {
status: 'pending',
reason: 'Sandbox image build not started.',
- metadata: { buildRef: this.buildRef, imageUri: this.imageUri },
+ metadata: { build_ref: this.buildRef, image_uri: this.imageUri },
};
}
return this.toBuild(snapshot.state, snapshot.errorReason);
diff --git a/packages/harness/src/core/sandbox/provider/Provider.ts b/packages/harness/src/core/sandbox/provider/Provider.ts
index c31bcce8b..43f8733b8 100644
--- a/packages/harness/src/core/sandbox/provider/Provider.ts
+++ b/packages/harness/src/core/sandbox/provider/Provider.ts
@@ -51,19 +51,15 @@ export type SandboxInit = Omit<SandboxExecParams, 'sandboxId'>;
export type SandboxBuildStatus = 'pending' | 'ready' | 'failed';
-/** Provider-internal build details, surfaced to callers as opaque metadata. */
-export interface SandboxBuildMetadata {
- /** Provider build handle derived from the image digest (e.g. the Daytona snapshot name). */
- buildRef: string;
- /** Full reference of the release sandbox image this build refers to. */
- imageUri: string;
-}
+/** Provider-specific opaque build metadata (string map). */
+export type SandboxBuildMetadata = Record<string, string>;
export interface SandboxBuild {
status: SandboxBuildStatus;
/** Human-readable detail for the current status (shown to the user); null when ready. */
reason: string | null;
- metadata: SandboxBuildMetadata;
+ /** Provider-specific build details; null when the provider has none. */
+ metadata: SandboxBuildMetadata | null;
}
export interface SandboxProvider {
diff --git a/packages/harness/src/core/sandbox/provider/TFYSandboxProvider.ts b/packages/harness/src/core/sandbox/provider/TFYSandboxProvider.ts
index 36d26f37b..2636f344d 100644
--- a/packages/harness/src/core/sandbox/provider/TFYSandboxProvider.ts
+++ b/packages/harness/src/core/sandbox/provider/TFYSandboxProvider.ts
@@ -59,7 +59,7 @@ export class TFYSandboxProvider implements SandboxProvider {
private static readonly readyBuild: SandboxBuild = {
status: 'ready',
reason: null,
- metadata: { buildRef: 'tfy-managed', imageUri: 'tfy-managed' },
+ metadata: null,
};
buildImage(): Promise<SandboxBuild> {
diff --git a/packages/harness/tests/core/sandbox/sandboxBridgeTimeout.test.ts b/packages/harness/tests/core/sandbox/sandboxBridgeTimeout.test.ts
index fa0fabc04..c8b7c8ef7 100644
--- a/packages/harness/tests/core/sandbox/sandboxBridgeTimeout.test.ts
+++ b/packages/harness/tests/core/sandbox/sandboxBridgeTimeout.test.ts
@@ -21,10 +21,8 @@ function makeSandbox(options: { mcpRequestTimeoutMs: number; mcpConnectTimeoutMs
} {
const execCalls: SandboxExecParams[] = [];
const provider: SandboxProvider = {
- buildImage: () =>
- Promise.resolve({ status: 'ready', reason: null, metadata: { buildRef: 'test', imageUri: 'test' } }),
- getImageBuildStatus: () =>
- Promise.resolve({ status: 'ready', reason: null, metadata: { buildRef: 'test', imageUri: 'test' } }),
+ buildImage: () => Promise.resolve({ status: 'ready', reason: null, metadata: null }),
+ getImageBuildStatus: () => Promise.resolve({ status: 'ready', reason: null, metadata: null }),
createSandbox: () => Promise.resolve({ sandboxId: 'test-tenant.sandbox-1' }),
exec: (params): Promise<ExecResult> => {
execCalls.push(params);
diff --git a/packages/sdk/src/api/types/SandboxBuildMetadata.ts b/packages/sdk/src/api/types/SandboxBuildMetadata.ts
deleted file mode 100644
index 692c33cfd..000000000
--- a/packages/sdk/src/api/types/SandboxBuildMetadata.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-// This file was auto-generated by Fern from our API Definition.
-
-export interface SandboxBuildMetadata {
- /** Provider build handle derived from the image digest (e.g. Daytona snapshot name). */
- buildRef: string;
- /** Full reference of the release sandbox image this build refers to. */
- imageUri: string;
-}
diff --git a/packages/sdk/src/api/types/SandboxProviderResponse.ts b/packages/sdk/src/api/types/SandboxProviderResponse.ts
index 430c2c6eb..c686234bc 100644
--- a/packages/sdk/src/api/types/SandboxProviderResponse.ts
+++ b/packages/sdk/src/api/types/SandboxProviderResponse.ts
@@ -3,7 +3,6 @@
import type * as TrueForge from "../index.js";
export interface SandboxProviderResponse {
- buildMetadata: TrueForge.SandboxBuildMetadata;
manifest: TrueForge.SandboxProviderManifest;
status: TrueForge.SandboxBuildStatus;
/** Human-readable detail for the current status; null when ready. */
diff --git a/packages/sdk/src/api/types/index.ts b/packages/sdk/src/api/types/index.ts
index 453371391..02699611b 100644
--- a/packages/sdk/src/api/types/index.ts
+++ b/packages/sdk/src/api/types/index.ts
@@ -124,7 +124,6 @@ export * from "./ResponseFormatJsonSchema.js";
export * from "./ResponseFormatJsonSchemaJsonSchema.js";
export * from "./ResponseFormatText.js";
export * from "./RuntimeConfig.js";
-export * from "./SandboxBuildMetadata.js";
export * from "./SandboxBuildStatus.js";
export * from "./SandboxConfig.js";
export * from "./SandboxCreatedEvent.js";
diff --git a/packages/sdk/src/serialization/types/SandboxBuildMetadata.ts b/packages/sdk/src/serialization/types/SandboxBuildMetadata.ts
deleted file mode 100644
index 7bd745855..000000000
--- a/packages/sdk/src/serialization/types/SandboxBuildMetadata.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-// This file was auto-generated by Fern from our API Definition.
-
-import type * as TrueForge from "../../api/index.js";
-import * as core from "../../core/index.js";
-import type * as serializers from "../index.js";
-
-export const SandboxBuildMetadata: core.serialization.ObjectSchema<
- serializers.SandboxBuildMetadata.Raw,
- TrueForge.SandboxBuildMetadata
-> = core.serialization.object({
- buildRef: core.serialization.property("build_ref", core.serialization.string()),
- imageUri: core.serialization.property("image_uri", core.serialization.string()),
-});
-
-export declare namespace SandboxBuildMetadata {
- export interface Raw {
- build_ref: string;
- image_uri: string;
- }
-}
diff --git a/packages/sdk/src/serialization/types/SandboxProviderResponse.ts b/packages/sdk/src/serialization/types/SandboxProviderResponse.ts
index 9bd044fa4..0252f603e 100644
--- a/packages/sdk/src/serialization/types/SandboxProviderResponse.ts
+++ b/packages/sdk/src/serialization/types/SandboxProviderResponse.ts
@@ -3,7 +3,6 @@
import type * as TrueForge from "../../api/index.js";
import * as core from "../../core/index.js";
import type * as serializers from "../index.js";
-import { SandboxBuildMetadata } from "./SandboxBuildMetadata.js";
import { SandboxBuildStatus } from "./SandboxBuildStatus.js";
import { SandboxProviderManifest } from "./SandboxProviderManifest.js";
@@ -11,7 +10,6 @@ export const SandboxProviderResponse: core.serialization.ObjectSchema<
serializers.SandboxProviderResponse.Raw,
TrueForge.SandboxProviderResponse
> = core.serialization.object({
- buildMetadata: core.serialization.property("build_metadata", SandboxBuildMetadata),
manifest: SandboxProviderManifest,
status: SandboxBuildStatus,
statusReason: core.serialization.property("status_reason", core.serialization.string().nullable()),
@@ -19,7 +17,6 @@ export const SandboxProviderResponse: core.serialization.ObjectSchema<
export declare namespace SandboxProviderResponse {
export interface Raw {
- build_metadata: SandboxBuildMetadata.Raw;
manifest: SandboxProviderManifest.Raw;
status: SandboxBuildStatus.Raw;
status_reason?: string | null;
diff --git a/packages/sdk/src/serialization/types/index.ts b/packages/sdk/src/serialization/types/index.ts
index 453371391..02699611b 100644
--- a/packages/sdk/src/serialization/types/index.ts
+++ b/packages/sdk/src/serialization/types/index.ts
@@ -124,7 +124,6 @@ export * from "./ResponseFormatJsonSchema.js";
export * from "./ResponseFormatJsonSchemaJsonSchema.js";
export * from "./ResponseFormatText.js";
export * from "./RuntimeConfig.js";
-export * from "./SandboxBuildMetadata.js";
export * from "./SandboxBuildStatus.js";
export * from "./SandboxConfig.js";
export * from "./SandboxCreatedEvent.js";
diff --git a/packages/sdk/tests/wire/settings/sandboxProviders.test.ts b/packages/sdk/tests/wire/settings/sandboxProviders.test.ts
index e63f8ef3c..68c002026 100644
--- a/packages/sdk/tests/wire/settings/sandboxProviders.test.ts
+++ b/packages/sdk/tests/wire/settings/sandboxProviders.test.ts
@@ -11,7 +11,6 @@ describe("SandboxProvidersClient", () => {
const rawResponseBody = {
data: {
- build_metadata: { build_ref: "build_ref", image_uri: "image_uri" },
manifest: {
auth: { api_key: "api_key" },
auto_archive_interval_in_minutes: 1,
@@ -36,10 +35,6 @@ describe("SandboxProvidersClient", () => {
const response = await client.settings.sandboxProviders.get();
expect(response).toEqual({
data: {
- buildMetadata: {
- buildRef: "build_ref",
- imageUri: "image_uri",
- },
manifest: {
auth: {
apiKey: "api_key",
@@ -88,7 +83,6 @@ describe("SandboxProvidersClient", () => {
};
const rawResponseBody = {
data: {
- build_metadata: { build_ref: "build_ref", image_uri: "image_uri" },
manifest: {
auth: { api_key: "api_key" },
auto_archive_interval_in_minutes: 1,
@@ -123,10 +117,6 @@ describe("SandboxProvidersClient", () => {
});
expect(response).toEqual({
data: {
- buildMetadata: {
- buildRef: "build_ref",
- imageUri: "image_uri",
- },
manifest: {
auth: {
apiKey: "api_key",
diff --git a/packages/server/src/apis/sandboxProviders.ts b/packages/server/src/apis/sandboxProviders.ts
index a33b12ccf..03a45e7a5 100644
--- a/packages/server/src/apis/sandboxProviders.ts
+++ b/packages/server/src/apis/sandboxProviders.ts
@@ -47,11 +47,8 @@ export function createSandboxProvidersRouter<TTransaction>(deps: SandboxProvider
{
data: {
manifest: redactSandboxProvider(record.manifest),
- ...(status ?? {
- status: record.status,
- status_reason: record.status_reason,
- build_metadata: record.build_metadata,
- }),
+ status: status?.status ?? record.status,
+ status_reason: status?.status_reason ?? record.status_reason,
},
},
200,
@@ -84,7 +81,16 @@ export function createSandboxProvidersRouter<TTransaction>(deps: SandboxProvider
);
return { manifest: resolved, status: built };
});
- return c.json({ data: { manifest: redactSandboxProvider(manifest), ...status } }, 200);
+ return c.json(
+ {
+ data: {
+ manifest: redactSandboxProvider(manifest),
+ status: status.status,
+ status_reason: status.status_reason,
+ },
+ },
+ 200,
+ );
} catch (error) {
if (error instanceof MissingStoredSecretError) {
return c.json({ error: { message: 'API key is required' } }, 400);
diff --git a/packages/server/src/db/postgres/migrations/20260815_000001_sandbox_provider_status.ts b/packages/server/src/db/postgres/migrations/20260815_000001_sandbox_provider_status.ts
index 30efdc200..4b142536f 100644
--- a/packages/server/src/db/postgres/migrations/20260815_000001_sandbox_provider_status.ts
+++ b/packages/server/src/db/postgres/migrations/20260815_000001_sandbox_provider_status.ts
@@ -2,7 +2,7 @@ import { sql, type Kysely } from 'kysely';
/**
* Persist the release sandbox image build status alongside the provider config.
- * `build_metadata` holds the build_ref + image_uri and is set on every upsert.
+ * `build_metadata` is nullable opaque jsonb (build_ref + image_uri when present).
*
* `status` is added with a temporary 'pending' default so the NOT NULL column can
* be backfilled on existing rows, then the default is dropped — every upsert writes
@@ -21,7 +21,7 @@ export async function up(db: Kysely<unknown>): Promise<void> {
.alterTable('sandbox_provider')
.addColumn('status', 'text', col => col.notNull().defaultTo('pending'))
.addColumn('status_reason', 'text')
- .addColumn('build_metadata', 'jsonb', col => col.notNull().defaultTo(sql`'{}'::jsonb`))
+ .addColumn('build_metadata', 'jsonb')
.execute();
await sql`
diff --git a/packages/server/src/db/postgres/sandbox-provider-store/PostgresSandboxProviderStore.ts b/packages/server/src/db/postgres/sandbox-provider-store/PostgresSandboxProviderStore.ts
index b07d7e6a4..c0ca35dfb 100644
--- a/packages/server/src/db/postgres/sandbox-provider-store/PostgresSandboxProviderStore.ts
+++ b/packages/server/src/db/postgres/sandbox-provider-store/PostgresSandboxProviderStore.ts
@@ -65,7 +65,7 @@ export class PostgresSandboxProviderStore implements ISandboxProviderStore<Trans
manifest: json(input.manifest),
status: input.status,
status_reason: input.status_reason,
- build_metadata: json(input.build_metadata),
+ build_metadata: input.build_metadata !== null ? json(input.build_metadata) : null,
created_at: now(),
updated_at: now(),
})
@@ -74,7 +74,7 @@ export class PostgresSandboxProviderStore implements ISandboxProviderStore<Trans
manifest: json(input.manifest),
status: input.status,
status_reason: input.status_reason,
- build_metadata: json(input.build_metadata),
+ build_metadata: input.build_metadata !== null ? json(input.build_metadata) : null,
updated_at: now(),
}),
)
@@ -93,7 +93,7 @@ export class PostgresSandboxProviderStore implements ISandboxProviderStore<Trans
.set({
status: input.status,
status_reason: input.status_reason,
- build_metadata: json(input.build_metadata),
+ build_metadata: input.build_metadata !== null ? json(input.build_metadata) : null,
updated_at: now(),
})
.where('tenant_id', '=', input.tenant_id)
diff --git a/packages/server/src/db/postgres/types.ts b/packages/server/src/db/postgres/types.ts
index 461f78b46..02e1711cc 100644
--- a/packages/server/src/db/postgres/types.ts
+++ b/packages/server/src/db/postgres/types.ts
@@ -346,8 +346,8 @@ export interface SandboxProviderTable {
status: SandboxBuildStatus;
/** Human-readable detail for `status`; null when ready. */
status_reason: string | null;
- /** SandboxBuildMetadata document (build_ref + image_uri). */
- build_metadata: JSONColumnType<SandboxBuildMetadata, SandboxBuildMetadata, SandboxBuildMetadata>;
+ /** SandboxBuildMetadata document (opaque string map); null when the provider has none. */
+ build_metadata: JSONColumnType<SandboxBuildMetadata | null, SandboxBuildMetadata | null, SandboxBuildMetadata | null>;
created_at: Date;
updated_at: Date;
}
diff --git a/packages/server/src/db/sandboxProviderStore.ts b/packages/server/src/db/sandboxProviderStore.ts
index e1339d66f..59eaa47d3 100644
--- a/packages/server/src/db/sandboxProviderStore.ts
+++ b/packages/server/src/db/sandboxProviderStore.ts
@@ -13,8 +13,8 @@ export interface SandboxProviderRecord {
status: SandboxBuildStatus;
/** Human-readable detail for `status`; null when ready. */
status_reason: string | null;
- /** Provider build identity (build_ref + image_uri) persisted alongside the status. */
- build_metadata: SandboxBuildMetadata;
+ /** Provider-specific build metadata; null when the provider has none. */
+ build_metadata: SandboxBuildMetadata | null;
/** ISO-8601 UTC instant. */
created_at: string;
/** ISO-8601 UTC instant. */
@@ -26,14 +26,14 @@ export interface UpsertSandboxProviderInput {
manifest: SandboxProviderManifest;
status: SandboxBuildStatus;
status_reason: string | null;
- build_metadata: SandboxBuildMetadata;
+ build_metadata: SandboxBuildMetadata | null;
}
export interface UpdateSandboxStatusInput {
tenant_id: string;
status: SandboxBuildStatus;
status_reason: string | null;
- build_metadata: SandboxBuildMetadata;
+ build_metadata: SandboxBuildMetadata | null;
}
export interface ISandboxProviderStore<TTransaction = never> {
diff --git a/packages/server/src/db/sqlite/migrations/20260815_000001_sandbox_provider_status.ts b/packages/server/src/db/sqlite/migrations/20260815_000001_sandbox_provider_status.ts
index 147ef5329..6c2fbd8d9 100644
--- a/packages/server/src/db/sqlite/migrations/20260815_000001_sandbox_provider_status.ts
+++ b/packages/server/src/db/sqlite/migrations/20260815_000001_sandbox_provider_status.ts
@@ -2,7 +2,7 @@ import { sql, type Kysely } from 'kysely';
/**
* Persist the release sandbox image build status alongside the provider config.
- * `build_metadata` holds the build_ref + image_uri and is set on every upsert.
+ * `build_metadata` is nullable opaque jsonb (build_ref + image_uri when present).
*
* `status` keeps the 'pending' default here: SQLite cannot drop a column default
* without rebuilding the table, and it is harmless because every upsert writes
@@ -18,7 +18,8 @@ const RELEASE_IMAGE_URI =
export async function up(db: Kysely<unknown>): Promise<void> {
await sql`ALTER TABLE sandbox_provider ADD COLUMN status TEXT NOT NULL DEFAULT 'pending'`.execute(db);
await sql`ALTER TABLE sandbox_provider ADD COLUMN status_reason TEXT`.execute(db);
- await sql`ALTER TABLE sandbox_provider ADD COLUMN build_metadata BLOB NOT NULL DEFAULT (jsonb('{}'))`.execute(db);
+ // Nullable: SQLite forbids non-constant DEFAULTs on ADD COLUMN when rows exist.
+ await sql`ALTER TABLE sandbox_provider ADD COLUMN build_metadata BLOB`.execute(db);
await sql`
UPDATE sandbox_provider
diff --git a/packages/server/src/db/sqlite/sandbox-provider-store/SqliteSandboxProviderStore.ts b/packages/server/src/db/sqlite/sandbox-provider-store/SqliteSandboxProviderStore.ts
index ada67e1c6..6550f12ad 100644
--- a/packages/server/src/db/sqlite/sandbox-provider-store/SqliteSandboxProviderStore.ts
+++ b/packages/server/src/db/sqlite/sandbox-provider-store/SqliteSandboxProviderStore.ts
@@ -69,7 +69,7 @@ export class SqliteSandboxProviderStore implements ISandboxProviderStore<Transac
manifest: jsonbBind(input.manifest),
status: input.status,
status_reason: input.status_reason,
- build_metadata: jsonbBind(input.build_metadata),
+ build_metadata: input.build_metadata !== null ? jsonbBind(input.build_metadata) : null,
created_at: timestamp,
updated_at: timestamp,
})
@@ -78,7 +78,7 @@ export class SqliteSandboxProviderStore implements ISandboxProviderStore<Transac
manifest: jsonbBind(input.manifest),
status: input.status,
status_reason: input.status_reason,
- build_metadata: jsonbBind(input.build_metadata),
+ build_metadata: input.build_metadata !== null ? jsonbBind(input.build_metadata) : null,
updated_at: timestamp,
}),
)
@@ -96,7 +96,7 @@ export class SqliteSandboxProviderStore implements ISandboxProviderStore<Transac
.set({
status: input.status,
status_reason: input.status_reason,
- build_metadata: jsonbBind(input.build_metadata),
+ build_metadata: input.build_metadata !== null ? jsonbBind(input.build_metadata) : null,
updated_at: nowIso(),
})
.where('tenant_id', '=', input.tenant_id)
diff --git a/packages/server/src/db/sqlite/types.ts b/packages/server/src/db/sqlite/types.ts
index c897354a1..deb248d54 100644
--- a/packages/server/src/db/sqlite/types.ts
+++ b/packages/server/src/db/sqlite/types.ts
@@ -196,8 +196,8 @@ export interface SandboxProviderTable {
status: SandboxBuildStatus;
/** Human-readable detail for `status`; null when ready. */
status_reason: string | null;
- /** SandboxBuildMetadata document (build_ref + image_uri). */
- build_metadata: JsonbColumn<SandboxBuildMetadata>;
+ /** SandboxBuildMetadata document (opaque string map); null when the provider has none. */
+ build_metadata: JsonbColumn<SandboxBuildMetadata> | null;
created_at: string;
updated_at: string;
}
diff --git a/packages/server/src/runtime/sessionResources.ts b/packages/server/src/runtime/sessionResources.ts
index ae876a40c..ec0b4dd47 100644
--- a/packages/server/src/runtime/sessionResources.ts
+++ b/packages/server/src/runtime/sessionResources.ts
@@ -227,7 +227,7 @@ export async function resolveSandboxProvider({
manifest: record.manifest,
tenant_id,
logger,
- buildRef: record.build_metadata.build_ref,
+ build_metadata: record.build_metadata,
});
}
diff --git a/packages/server/src/sandbox/providerUtils.ts b/packages/server/src/sandbox/providerUtils.ts
index 0586a9a4a..cf4a879ce 100644
--- a/packages/server/src/sandbox/providerUtils.ts
+++ b/packages/server/src/sandbox/providerUtils.ts
@@ -6,6 +6,7 @@ import configuration from '../config';
import type { ISandboxProviderStore } from '../db/sandboxProviderStore';
import {
toDaytonaSandboxProviderInput,
+ type SandboxBuildMetadata,
type SandboxProviderManifest,
type SandboxStatus,
} from '../schemas/sandboxProvider';
@@ -20,13 +21,12 @@ export function toDaytonaSandboxProvider({
manifest,
tenant_id,
logger,
- buildRef,
+ build_metadata,
}: {
manifest: SandboxProviderManifest;
tenant_id: string;
logger: Logger;
- /** Snapshot name to clone from (persisted build_ref). Omit to derive from the current image. */
- buildRef?: string;
+ build_metadata?: SandboxBuildMetadata | null;
}): DaytonaSandboxProvider {
const { apiKey, ...settings } = toDaytonaSandboxProviderInput(manifest);
return new DaytonaSandboxProvider({
@@ -34,17 +34,18 @@ export function toDaytonaSandboxProvider({
...settings,
tenantName: tenant_id,
sandboxImage: SANDBOX_IMAGE_URI,
- buildRef,
+ buildRef: build_metadata?.['build_ref'],
fileMaxBytesForDownload: configuration.SANDBOX_FILE_MAX_BYTES_FOR_DOWNLOAD,
logger,
});
}
+/** Maps a core `SandboxBuild` onto the persisted/wire status shape (metadata passes through). */
export function toSandboxStatus(build: SandboxBuild): SandboxStatus {
return {
status: build.status,
status_reason: build.reason,
- build_metadata: { build_ref: build.metadata.buildRef, image_uri: build.metadata.imageUri },
+ build_metadata: build.metadata,
};
}
@@ -61,7 +62,7 @@ export async function checkSnapshotStatus({
logger: Logger;
}): Promise<SandboxStatus | undefined> {
const record = await store.getSandboxProvider(tenant_id);
- if (record === undefined) {
+ if (!record) {
return undefined;
}
@@ -77,7 +78,12 @@ export async function checkSnapshotStatus({
return persisted;
}
- const provider = toDaytonaSandboxProvider({ manifest: record.manifest, tenant_id, logger });
+ const provider = toDaytonaSandboxProvider({
+ manifest: record.manifest,
+ tenant_id,
+ logger,
+ build_metadata: record.build_metadata,
+ });
let build: SandboxBuild;
if (record.status === 'ready') {
// this is because image may have deactivated
diff --git a/packages/server/src/schemas/sandboxProvider.ts b/packages/server/src/schemas/sandboxProvider.ts
index 126e970e8..bfc182acd 100644
--- a/packages/server/src/schemas/sandboxProvider.ts
+++ b/packages/server/src/schemas/sandboxProvider.ts
@@ -62,31 +62,28 @@ export const SandboxBuildStatusSchema = z
.describe('Current build status.')
.openapi('SandboxBuildStatus');
-/** Provider-specific build identity, persisted alongside the status. */
+/** Provider-specific opaque build metadata (string map), persisted alongside the status — not on the wire. */
export const SandboxBuildMetadataSchema = z
- .object({
- build_ref: z.string().describe('Provider build handle derived from the image digest (e.g. Daytona snapshot name).'),
- image_uri: z.string().describe('Full reference of the release sandbox image this build refers to.'),
- })
- .strict()
- .openapi('SandboxBuildMetadata');
+ .record(z.string(), z.string())
+ .describe('Provider-specific build metadata (opaque string map).');
-/** Build status + identity, without the provider manifest. Persisted and refreshed on read. */
+/** Build status persisted and refreshed on read (includes opaque metadata for the provider). */
export const SandboxStatusSchema = z
.object({
status: SandboxBuildStatusSchema,
status_reason: z.string().nullable().describe('Human-readable detail for the current status; null when ready.'),
- build_metadata: SandboxBuildMetadataSchema,
+ build_metadata: SandboxBuildMetadataSchema.nullable().describe(
+ 'Provider-specific build metadata; null when the provider has none.',
+ ),
})
.strict();
-/** GET/PUT response body: the stored provider manifest plus its build status. */
+/** GET/PUT response body: the stored provider manifest plus its build status (no build_metadata). */
export const SandboxProviderResponseSchema = z
.object({
manifest: SandboxProviderManifestSchema,
status: SandboxBuildStatusSchema,
status_reason: z.string().nullable().describe('Human-readable detail for the current status; null when ready.'),
- build_metadata: SandboxBuildMetadataSchema,
})
.strict()
.openapi('SandboxProviderResponse');
diff --git a/packages/server/tests/unit/apis/sandboxProviders.test.ts b/packages/server/tests/unit/apis/sandboxProviders.test.ts
index 16531dedf..6d14e38ab 100644
--- a/packages/server/tests/unit/apis/sandboxProviders.test.ts
+++ b/packages/server/tests/unit/apis/sandboxProviders.test.ts
@@ -40,12 +40,11 @@ const IMAGE_URI = 'tfy.jfrog.io/tfy-images/truefoundry-utils-core-sandbox:029ea5
const readyBuild: SandboxBuild = {
status: 'ready',
reason: null,
- metadata: { buildRef: 'trueforge-build-029ea5ff', imageUri: IMAGE_URI },
+ metadata: { build_ref: 'trueforge-build-029ea5ff', image_uri: IMAGE_URI },
};
const expectedStatus = {
status: 'ready' as const,
status_reason: null,
- build_metadata: { build_ref: 'trueforge-build-029ea5ff', image_uri: IMAGE_URI },
};
/** Wire GET/PUT response: the (redacted) manifest nested under `manifest`, plus the build status. */