media-json
Import
Section titled “Import”import * as api from "@fungi.computer/agar/media-json";Exports
Section titled “Exports”| 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. |
MediaGenerationclass
Section titled “MediaGeneration”Page-side Agar handle over an admitted generic JSON method caller.
Extends
Section titled “Extends”RpcTarget
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MediaGeneration( call, computerId, signal?): MediaGeneration;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
call |
MediaGenerationJsonCaller |
computerId |
string |
signal? |
AbortSignal |
Returns
Section titled “Returns”Overrides
Section titled “Overrides”RpcTarget.constructor;Methods
Section titled “Methods”describe()
Section titled “describe()”describe(): Promise<Readonly<{ computerId: string; canGenerate: boolean; models: readonly object[];}>>;Describe this handle’s fixed Computer through the admitted JSON method.
Returns
Section titled “Returns”Promise<Readonly<{ computerId: string; canGenerate: boolean;
models: readonly object[]; }>>
Implementation of
Section titled “Implementation of”MediaGenerationHandle.describe;createAttempt()
Section titled “createAttempt()”createAttempt(): Promise<MediaGenerationAttempt>;Issue a canonical replay identity for a new generation attempt.
Returns
Section titled “Returns”Promise<MediaGenerationAttempt>
Implementation of
Section titled “Implementation of”MediaGenerationHandle.createAttempt;restoreAttempt()
Section titled “restoreAttempt()”restoreAttempt(reference): Promise<MediaGenerationAttempt>;Resume the original Computer and canonical request without issuing a new ID.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
reference |
{ requestId: string; computerId: string; } |
reference.requestId |
string |
reference.computerId |
string |
Returns
Section titled “Returns”Promise<MediaGenerationAttempt>
Implementation of
Section titled “Implementation of”MediaGenerationHandle.restoreAttempt;cancelAttempt()
Section titled “cancelAttempt()”cancelAttempt(reference): Promise<void>;Abort every active browser request belonging to this attempt.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
reference |
{ requestId: string; computerId: string; } |
reference.requestId |
string |
reference.computerId |
string |
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”MediaGenerationHandle.cancelAttempt;MediaGenerationAttemptclass
Section titled “MediaGenerationAttempt”One replayable host-issued Media attempt, sharing cancellation with its handle.
Extends
Section titled “Extends”RpcTarget
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MediaGenerationAttempt( call, computerId, signal, requestId, activeRequests): MediaGenerationAttempt;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
call |
MediaGenerationJsonCaller |
computerId |
string |
signal |
AbortSignal | undefined |
requestId |
string |
activeRequests |
Map<string, Set<AbortController>> |
Returns
Section titled “Returns”Overrides
Section titled “Overrides”RpcTarget.constructor;Methods
Section titled “Methods”reference()
Section titled “reference()”reference(): Promise<{ requestId: string; computerId: string;}>;Return the stable Computer and request identity for replay.
Returns
Section titled “Returns”Promise<{ requestId: string; computerId: string; }>
Implementation of
Section titled “Implementation of”MediaGenerationAttemptHandle.reference;generate()
Section titled “generate()”generate(input): Promise<MediaGenerationOutcome>;Save through the admitted host; poll pending work with the same replay identity.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
MediaGenerationInput |
Returns
Section titled “Returns”Promise<MediaGenerationOutcome>
Implementation of
Section titled “Implementation of”MediaGenerationAttemptHandle.generate;MediaGenerationJsonCallertype alias
Section titled “MediaGenerationJsonCaller”type MediaGenerationJsonCaller = ( method, input?, options?,) => Promise<Schema.Json | undefined>;Page-local generic JSON method caller. Signals never enter JSON or RPC.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
method |
string |
input? |
Schema.Json |
options? |
{ signal?: AbortSignal; } |
options.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<Schema.Json | undefined>
MediaGenerationJsonRequesttype alias
Section titled “MediaGenerationJsonRequest”type MediaGenerationJsonRequest = Schema.Schema.Type< typeof mediaGenerationJsonRequestSchema>;Plain JSON generation input for an admitted capability’s generate method.
MediaGenerationJsonReplytype alias
Section titled “MediaGenerationJsonReply”type MediaGenerationJsonReply = Schema.Schema.Type< typeof mediaGenerationJsonReplySchema>;JSON generation reply, including the shared Pending owner.
MediaGenerationDescriptiontype alias
Section titled “MediaGenerationDescription”type MediaGenerationDescription = Readonly<{ computerId: string; canGenerate: boolean; models: readonly MediaModel[];}>;Catalog and permission snapshot for the handle’s fixed Computer.
mediaGenerationDescriptionSchemaconstant
Section titled “mediaGenerationDescriptionSchema”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”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”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”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.
References
Section titled “References”mediaGenerationReferenceSchema
Section titled “mediaGenerationReferenceSchema”Re-exports mediaGenerationReferenceSchema