Skip to content
API reference

media-json

Import
import * as api from "@fungi.computer/agar/media-json";
Kind Export Description
class MediaGeneration Page-side Agar handle over an admitted generic JSON method caller.
class MediaGenerationAttempt One replayable host-issued Media attempt, sharing cancellation with its handle.
type alias MediaGenerationJsonCaller Page-local generic JSON method caller. Signals never enter JSON or RPC.
type alias MediaGenerationJsonRequest Plain JSON generation input for an admitted capability’s generate method.
type alias MediaGenerationJsonReply JSON generation reply, including the shared Pending owner.
type alias MediaGenerationDescription Catalog and permission snapshot for the handle’s fixed Computer.
constant mediaGenerationDescriptionSchema Plain JSON catalog reply, decoded with Agar’s Media model grammar.
constant mediaGenerationJsonRequestSchema A generation call carries paths and a replay ID; the host supplies authority.
constant mediaGenerationJsonOutcomeSchema A typed completion or refusal; no live attempt handles cross this boundary.
constant mediaGenerationJsonReplySchema Generate may also report Agar’s canonical, bounded Pending result.

Page-side Agar handle over an admitted generic JSON method caller.

  • RpcTarget
Signature
new MediaGeneration(
call,
computerId,
signal?
): MediaGeneration;
Parameter Type
call MediaGenerationJsonCaller
computerId string
signal? AbortSignal

MediaGeneration

Signature
RpcTarget.constructor;
Signature
describe(): Promise<Readonly<{
computerId: string;
canGenerate: boolean;
models: readonly object[];
}>>;

Describe this handle’s fixed Computer through the admitted JSON method.

Promise<Readonly<{ computerId: string; canGenerate: boolean; models: readonly object[]; }>>

Signature
MediaGenerationHandle.describe;
Signature
createAttempt(): Promise<MediaGenerationAttempt>;

Issue a canonical replay identity for a new generation attempt.

Promise<MediaGenerationAttempt>

Signature
MediaGenerationHandle.createAttempt;
Signature
restoreAttempt(reference): Promise<MediaGenerationAttempt>;

Resume the original Computer and canonical request without issuing a new ID.

Parameter Type
reference { requestId: string; computerId: string; }
reference.requestId string
reference.computerId string

Promise<MediaGenerationAttempt>

Signature
MediaGenerationHandle.restoreAttempt;
Signature
cancelAttempt(reference): Promise<void>;

Abort every active browser request belonging to this attempt.

Parameter Type
reference { requestId: string; computerId: string; }
reference.requestId string
reference.computerId string

Promise<void>

Signature
MediaGenerationHandle.cancelAttempt;

One replayable host-issued Media attempt, sharing cancellation with its handle.

  • RpcTarget
Signature
new MediaGenerationAttempt(
call,
computerId,
signal,
requestId,
activeRequests
): MediaGenerationAttempt;
Parameter Type
call MediaGenerationJsonCaller
computerId string
signal AbortSignal | undefined
requestId string
activeRequests Map<string, Set<AbortController>>

MediaGenerationAttempt

Signature
RpcTarget.constructor;
Signature
reference(): Promise<{
requestId: string;
computerId: string;
}>;

Return the stable Computer and request identity for replay.

Promise<{ requestId: string; computerId: string; }>

Signature
MediaGenerationAttemptHandle.reference;
Signature
generate(input): Promise<MediaGenerationOutcome>;

Save through the admitted host; poll pending work with the same replay identity.

Parameter Type
input MediaGenerationInput

Promise<MediaGenerationOutcome>

Signature
MediaGenerationAttemptHandle.generate;

MediaGenerationJsonCallertype alias

Section titled “MediaGenerationJsonCaller”
Signature
type MediaGenerationJsonCaller = (
method,
input?,
options?,
) => Promise<Schema.Json | undefined>;

Page-local generic JSON method caller. Signals never enter JSON or RPC.

Parameter Type
method string
input? Schema.Json
options? { signal?: AbortSignal; }
options.signal? AbortSignal

Promise<Schema.Json | undefined>


MediaGenerationJsonRequesttype alias

Section titled “MediaGenerationJsonRequest”
Signature
type MediaGenerationJsonRequest = Schema.Schema.Type<
typeof mediaGenerationJsonRequestSchema
>;

Plain JSON generation input for an admitted capability’s generate method.


MediaGenerationJsonReplytype alias

Section titled “MediaGenerationJsonReply”
Signature
type MediaGenerationJsonReply = Schema.Schema.Type<
typeof mediaGenerationJsonReplySchema
>;

JSON generation reply, including the shared Pending owner.


MediaGenerationDescriptiontype alias

Section titled “MediaGenerationDescription”
Signature
type MediaGenerationDescription = Readonly<{
computerId: string;
canGenerate: boolean;
models: readonly MediaModel[];
}>;

Catalog and permission snapshot for the handle’s fixed Computer.

mediaGenerationDescriptionSchemaconstant

Section titled “mediaGenerationDescriptionSchema”
Signature
const mediaGenerationDescriptionSchema: Struct<{
computerId: String;
canGenerate: Boolean;
models: $Array<Struct<{
id: String;
input: Struct<{
defaultHeight: Number;
defaultSteps: NullOr<Number>;
defaultWidth: Number;
dimensions: Literals<readonly ["none", "own"]>;
maxDimension: NullOr<Number>;
maxDimensionDocumented: Boolean;
maxReferences: Number;
maxSteps: NullOr<Number>;
referenceField: NullOr<String>;
steps: Literals<readonly ["steps", "num_steps", "fixed"]>;
transport: Literals<readonly ["json", "multipart"]>;
}>;
kind: Literals<readonly ["image", "video"]>;
label: String;
maxPromptLength: Number;
tier: Literals<readonly ["draft", "balanced", "premium", "max"]>;
outputFormats: $Array<Literals<readonly ["png", "jpeg", "webp"]>>;
sizes: NullOr<$Array<String>>;
video: NullOr<Struct<{
minSeconds: Number;
maxSeconds: Number;
defaultSeconds: Number;
durations: $Array<Number>;
provider: Literals<readonly ["seedance", "veo", "minimax"]>;
formats: $Array<Struct<{
resolution: ...;
aspectRatio: ...;
width: ...;
height: ...;
}>>;
defaultResolution: Literals<readonly ["480p", "720p", "768p", "1080p", "4k"]>;
defaultAspectRatio: Literals<readonly ["16:9", "4:3", "1:1", "3:4", "9:16", "21:9", "9:21"]>;
supportsAudio: Boolean;
defaultGenerateAudio: NullOr<Boolean>;
referenceRoles: $Array<Literals<readonly [..., ..., ...]>>;
maxReferenceImages: Number;
referenceResolutions: $Array<Literals<readonly [..., ..., ..., ..., ...]>>;
prices: $Array<Struct<{
resolution: ...;
silentMilliunitsPerSecond: ...;
audioMilliunitsPerSecond: ...;
}>>;
}>>;
}>>;
}>;

Plain JSON catalog reply, decoded with Agar’s Media model grammar.


mediaGenerationJsonRequestSchemaconstant

Section titled “mediaGenerationJsonRequestSchema”
Signature
const mediaGenerationJsonRequestSchema: Struct<{
requestId: String;
settings: Struct<{
model: String;
prompt: String;
width: Number;
height: Number;
steps: optional<Number>;
durationSeconds: optional<Number>;
resolution: optional<Literals<readonly ["480p", "720p", "768p", "1080p", "4k"]>>;
aspectRatio: optional<Literals<readonly ["16:9", "4:3", "1:1", "3:4", "9:16", "21:9", "9:21"]>>;
generateAudio: optional<Boolean>;
references: optional<$Array<Struct<{
path: String;
role: optional<Literals<readonly [..., ..., ...]>>;
}>>>;
}>;
destination: Struct<{
path: String;
}>;
}>;

A generation call carries paths and a replay ID; the host supplies authority.


mediaGenerationJsonOutcomeSchemaconstant

Section titled “mediaGenerationJsonOutcomeSchema”
Signature
const mediaGenerationJsonOutcomeSchema: Union<readonly [Struct<{
kind: Literal<"succeeded">;
result: Struct<{
[dispose]: optional<Unknown>;
bytes: Number;
costMilliunits: Number;
destination: Struct<{
computerId: String;
path: String;
}>;
format: Literals<readonly ["png", "jpeg", "gif", "webp", "mp4"]>;
height: Number;
model: String;
width: Number;
}>;
}>, Struct<{
kind: Literal<"failed">;
failure: Struct<{
message: String;
stage: optional<Literals<readonly ["admission", "generation-authorization", "settings", "estimate", "billing", "operation", "provider", "normalization", "artifact", "destination-authorization", "destination-write"]>>;
provider: optional<Union<readonly [Struct<{
category: ...;
code: ...;
}>, Struct<{
category: ...;
status: ...;
}>]>>;
code: Literals<readonly ["CANCELLED", "CAPABILITY_DENIED", "CAPABILITY_REVOKED", "DISCONNECTED", "HOST_FAILURE", "IDENTITY", "INSUFFICIENT_CREDIT", "INVALID_ARGUMENT", "PROTOCOL", "SAFETY_FILTER_REFUSED", "TIMEOUT"]>;
retryable: Boolean;
}>;
}>]>;

A typed completion or refusal; no live attempt handles cross this boundary.


mediaGenerationJsonReplySchemaconstant

Section titled “mediaGenerationJsonReplySchema”
Signature
const mediaGenerationJsonReplySchema: Union<readonly [Union<readonly [Struct<{
kind: Literal<"succeeded">;
result: Struct<{
[dispose]: optional<Unknown>;
bytes: Number;
costMilliunits: Number;
destination: Struct<{
computerId: String;
path: String;
}>;
format: Literals<readonly ["png", "jpeg", "gif", "webp", "mp4"]>;
height: Number;
model: String;
width: Number;
}>;
}>, Struct<{
kind: Literal<"failed">;
failure: Struct<{
message: String;
stage: optional<Literals<readonly [..., ..., ..., ..., ..., ..., ..., ..., ..., ..., ...]>>;
provider: optional<Union<readonly [..., ...]>>;
code: Literals<readonly ["CANCELLED", "CAPABILITY_DENIED", "CAPABILITY_REVOKED", "DISCONNECTED", "HOST_FAILURE", "IDENTITY", "INSUFFICIENT_CREDIT", "INVALID_ARGUMENT", "PROTOCOL", "SAFETY_FILTER_REFUSED", "TIMEOUT"]>;
retryable: Boolean;
}>;
}>]>, declare<Readonly<{
kind: "pending";
retryAfterMs: number;
}>, unknown>]>;

Generate may also report Agar’s canonical, bounded Pending result.

Re-exports mediaGenerationReferenceSchema