@tangle-network/agent-app 0.63.30 → 0.63.32
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/dist/{DesignCanvas-3DGZQOD7.js → DesignCanvas-VKZ7Y3JU.js} +2 -3
- package/dist/{DesignCanvasEditor-OG4QY5WJ.js → DesignCanvasEditor-3V53YLLZ.js} +2 -3
- package/dist/agent-profiles/d1.js +4 -3
- package/dist/agent-profiles/d1.js.map +1 -1
- package/dist/agent-profiles/index.js +4 -3
- package/dist/alerting/github.d.ts +33 -0
- package/dist/alerting/index.d.ts +1 -0
- package/dist/alerting/index.js +47 -0
- package/dist/alerting/index.js.map +1 -1
- package/dist/app-auth/index.js +1 -2
- package/dist/app-auth/index.js.map +1 -1
- package/dist/assistant/index.js +4 -4
- package/dist/billing/index.d.ts +15 -0
- package/dist/billing/index.js +5 -3
- package/dist/chat-routes/index.js +15 -14
- package/dist/chat-routes/index.js.map +1 -1
- package/dist/chat-store/index.js +34 -4
- package/dist/chat-store/index.js.map +1 -1
- package/dist/chat-store/schema.d.ts +286 -0
- package/dist/{chunk-6JEDSKFH.js → chunk-2SDX3OC4.js} +32 -24
- package/dist/{chunk-6JEDSKFH.js.map → chunk-2SDX3OC4.js.map} +1 -1
- package/dist/{chunk-QLZ6A73E.js → chunk-4CEIZZTH.js} +9 -9
- package/dist/{chunk-WL7PZK7Q.js → chunk-4PIN6QYQ.js} +43 -1
- package/dist/chunk-4PIN6QYQ.js.map +1 -0
- package/dist/{chunk-6UMIOEDR.js → chunk-AZRPDSRQ.js} +3 -3
- package/dist/{chunk-6LMM3OVX.js → chunk-BMCC2BUP.js} +3 -3
- package/dist/{chunk-36HSG7HU.js → chunk-CRZXEKCX.js} +2 -2
- package/dist/chunk-F4XBNR5L.js +16 -0
- package/dist/chunk-F4XBNR5L.js.map +1 -0
- package/dist/chunk-GY4IPYG4.js +40 -0
- package/dist/chunk-GY4IPYG4.js.map +1 -0
- package/dist/{chunk-6OG4244Y.js → chunk-MTKD2FN5.js} +2 -251
- package/dist/chunk-MTKD2FN5.js.map +1 -0
- package/dist/{chunk-5AUZR655.js → chunk-NDXQFEZQ.js} +51 -48
- package/dist/chunk-NDXQFEZQ.js.map +1 -0
- package/dist/chunk-NSWLZTJX.js +645 -0
- package/dist/chunk-NSWLZTJX.js.map +1 -0
- package/dist/chunk-PU6AWIRE.js +252 -0
- package/dist/chunk-PU6AWIRE.js.map +1 -0
- package/dist/{chunk-JKECSYDB.js → chunk-PV3GSLUY.js} +3 -3
- package/dist/{chunk-7Y7U7U7X.js → chunk-Q7RSHLEV.js} +5 -3
- package/dist/{chunk-7Y7U7U7X.js.map → chunk-Q7RSHLEV.js.map} +1 -1
- package/dist/{chunk-HRBF4B5L.js → chunk-TUJ4277Q.js} +1 -14
- package/dist/chunk-TUJ4277Q.js.map +1 -0
- package/dist/{chunk-57XPEL7X.js → chunk-V42C72V5.js} +25 -2
- package/dist/chunk-V42C72V5.js.map +1 -0
- package/dist/{chunk-FCYHDENJ.js → chunk-VOIVDEAV.js} +2 -2
- package/dist/{chunk-ACB7KOQ6.js → chunk-WSQSKYXP.js} +4 -4
- package/dist/{chunk-F6J5J4H6.js → chunk-WYQTPFPI.js} +26 -2
- package/dist/chunk-WYQTPFPI.js.map +1 -0
- package/dist/{chunk-PFTOGTHH.js → chunk-Z3IJ7XEW.js} +3 -3
- package/dist/{chunk-ZD2AUFIT.js → chunk-ZGGEYYEQ.js} +3 -3
- package/dist/{chunk-O5AUJQIA.js → chunk-ZNWJJRHP.js} +2 -2
- package/dist/design-canvas/index.js +1 -2
- package/dist/design-canvas/index.js.map +1 -1
- package/dist/design-canvas-react/engine.js +1 -2
- package/dist/design-canvas-react/index.js +2 -3
- package/dist/design-canvas-react/index.js.map +1 -1
- package/dist/design-canvas-react/lazy.js +1 -1
- package/dist/media/generate-request.d.ts +27 -1
- package/dist/media/index.js +36 -426
- package/dist/media/index.js.map +1 -1
- package/dist/media/router-generation.d.ts +7 -0
- package/dist/operator/gateway-keys.d.ts +44 -0
- package/dist/operator/index.d.ts +1 -0
- package/dist/operator/index.js +55 -1
- package/dist/operator/index.js.map +1 -1
- package/dist/plans/decision.d.ts +31 -0
- package/dist/plans/drizzle.js +1 -1
- package/dist/plans/index.js +5 -1
- package/dist/platform/billing.d.ts +3 -2
- package/dist/platform/deployment.d.ts +21 -0
- package/dist/platform/index.d.ts +1 -0
- package/dist/platform/index.js +30 -10
- package/dist/platform/index.js.map +1 -1
- package/dist/preset-cloudflare/index.js +9 -8
- package/dist/preset-cloudflare/index.js.map +1 -1
- package/dist/public-consultation/index.d.ts +1 -1
- package/dist/public-consultation/index.js +13 -12
- package/dist/public-consultation/index.js.map +1 -1
- package/dist/sandbox/computer-receipts.d.ts +1 -1
- package/dist/sandbox/index.d.ts +1 -0
- package/dist/sandbox/index.js +15 -8
- package/dist/sandbox/router-model-policy.d.ts +31 -0
- package/dist/sequences/index.js +1 -2
- package/dist/sequences/index.js.map +1 -1
- package/dist/spend/drizzle.d.ts +195 -0
- package/dist/spend/drizzle.js +22 -0
- package/dist/spend/drizzle.js.map +1 -1
- package/dist/stream/index.js +2 -2
- package/dist/studio/generated-media/flows.d.ts +240 -0
- package/dist/studio/generated-media/index.d.ts +3 -1
- package/dist/studio/generated-media/index.js +357 -138
- package/dist/studio/generated-media/index.js.map +1 -1
- package/dist/studio/index.js +18 -16
- package/dist/studio-react/index.js +28 -26
- package/dist/studio-react/index.js.map +1 -1
- package/dist/teams/index.d.ts +1 -0
- package/dist/teams/index.js +16 -0
- package/dist/teams/index.js.map +1 -1
- package/dist/teams/invitations-api.js +1 -1
- package/dist/teams/members-api.d.ts +5 -3
- package/dist/teams/members-api.js +1 -1
- package/dist/teams/thread-access.d.ts +22 -0
- package/dist/tools/index.js +5 -4
- package/dist/web/index.js +4 -6
- package/dist/web-react/index.js +4 -4
- package/dist/work-product/index.js +3 -2
- package/dist/work-product/index.js.map +1 -1
- package/dist/workspace-export/d1.d.ts +1 -1
- package/dist/workspace-export/index.js +9 -2
- package/dist/workspace-export/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-57XPEL7X.js.map +0 -1
- package/dist/chunk-5AUZR655.js.map +0 -1
- package/dist/chunk-6OG4244Y.js.map +0 -1
- package/dist/chunk-6Z7TZVKZ.js +0 -26
- package/dist/chunk-6Z7TZVKZ.js.map +0 -1
- package/dist/chunk-F6J5J4H6.js.map +0 -1
- package/dist/chunk-HRBF4B5L.js.map +0 -1
- package/dist/chunk-WL7PZK7Q.js.map +0 -1
- /package/dist/{DesignCanvas-3DGZQOD7.js.map → DesignCanvas-VKZ7Y3JU.js.map} +0 -0
- /package/dist/{DesignCanvasEditor-OG4QY5WJ.js.map → DesignCanvasEditor-3V53YLLZ.js.map} +0 -0
- /package/dist/{chunk-QLZ6A73E.js.map → chunk-4CEIZZTH.js.map} +0 -0
- /package/dist/{chunk-6UMIOEDR.js.map → chunk-AZRPDSRQ.js.map} +0 -0
- /package/dist/{chunk-6LMM3OVX.js.map → chunk-BMCC2BUP.js.map} +0 -0
- /package/dist/{chunk-36HSG7HU.js.map → chunk-CRZXEKCX.js.map} +0 -0
- /package/dist/{chunk-JKECSYDB.js.map → chunk-PV3GSLUY.js.map} +0 -0
- /package/dist/{chunk-FCYHDENJ.js.map → chunk-VOIVDEAV.js.map} +0 -0
- /package/dist/{chunk-ACB7KOQ6.js.map → chunk-WSQSKYXP.js.map} +0 -0
- /package/dist/{chunk-PFTOGTHH.js.map → chunk-Z3IJ7XEW.js.map} +0 -0
- /package/dist/{chunk-ZD2AUFIT.js.map → chunk-ZGGEYYEQ.js.map} +0 -0
- /package/dist/{chunk-O5AUJQIA.js.map → chunk-ZNWJJRHP.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plans/decision.ts","../src/plans/index.ts"],"sourcesContent":["/**\n * The product half of deciding a durable plan: validate what the user clicked,\n * project the sandbox SDK's plan snapshot onto the chat projection, and\n * classify a 409 as a decision that already happened. Pure; no I/O.\n */\nimport type { ChatPlan, ChatPlanStatus } from './index'\n\n/** The SDK's plan snapshot, as the fields the projection reads. */\nexport interface DurablePlanLike {\n id: string\n revision: number\n title?: string\n body: string\n submittedAt: string\n status: ChatPlan['status']\n decidedAt?: string\n feedback?: string\n supersededAt?: string\n supersededByPlanId?: string\n withdrawnAt?: string\n reason?: string\n}\n\nexport type PlanDecisionOutcome = 'approved' | 'rejected'\n\nexport type PlanDecisionBody =\n | {\n ok: true\n workspaceId: string\n threadId: string\n planId: string\n revision: number\n outcome: PlanDecisionOutcome\n feedback?: string\n }\n | { ok: false; error: string }\n\n/** Validate a plan-decision request body. Rejection requires feedback: without\n * it the agent has nothing to revise against. */\nexport function parsePlanDecisionBody(body: Record<string, unknown>): PlanDecisionBody {\n const workspaceId = typeof body.workspaceId === 'string' ? body.workspaceId.trim() : ''\n const threadId = typeof body.threadId === 'string' ? body.threadId.trim() : ''\n const planId = typeof body.planId === 'string' ? body.planId.trim() : ''\n const revision = body.revision\n const outcome = body.outcome\n if (!workspaceId) return { ok: false, error: 'Missing workspaceId' }\n if (!threadId) return { ok: false, error: 'Missing threadId' }\n if (!planId) return { ok: false, error: 'Missing planId' }\n if (!Number.isInteger(revision) || Number(revision) < 1) {\n return { ok: false, error: 'Invalid revision: expected a positive integer' }\n }\n if (outcome !== 'approved' && outcome !== 'rejected') {\n return { ok: false, error: 'Invalid outcome: expected approved or rejected' }\n }\n if (outcome === 'rejected') {\n const feedback = typeof body.feedback === 'string' ? body.feedback.trim() : ''\n if (!feedback) return { ok: false, error: 'Plan rejection feedback is required' }\n return { ok: true, workspaceId, threadId, planId, revision: Number(revision), outcome, feedback }\n }\n return { ok: true, workspaceId, threadId, planId, revision: Number(revision), outcome }\n}\n\n/** Project the SDK's plan onto the chat projection. A status whose required\n * fields are missing is a broken projection, not a plan to render. */\nexport function toChatPlan(plan: DurablePlanLike): ChatPlan {\n const common = {\n planId: plan.id,\n revision: plan.revision,\n ...(plan.title ? { title: plan.title } : {}),\n body: plan.body,\n submittedAt: plan.submittedAt,\n }\n if (plan.status === 'preparing') return { ...common, status: 'preparing' }\n if (plan.status === 'pending') return { ...common, status: 'pending' }\n if (plan.status === 'approved' && plan.decidedAt) {\n return { ...common, status: 'approved', decidedAt: plan.decidedAt }\n }\n if (plan.status === 'rejected' && plan.decidedAt && plan.feedback) {\n return { ...common, status: 'rejected', decidedAt: plan.decidedAt, feedback: plan.feedback }\n }\n if (plan.status === 'superseded' && plan.supersededAt && plan.supersededByPlanId) {\n return {\n ...common,\n status: 'superseded',\n supersededAt: plan.supersededAt,\n supersededByPlanId: plan.supersededByPlanId,\n }\n }\n if (plan.status === 'withdrawn' && plan.withdrawnAt && plan.reason) {\n return { ...common, status: 'withdrawn', withdrawnAt: plan.withdrawnAt, withdrawnReason: plan.reason }\n }\n throw new Error(`Sandbox returned an incomplete ${plan.status} plan projection`)\n}\n\n/** A 409 from the sandbox is a decision that already happened; classify which\n * one so the caller can reconcile instead of reporting a failure. */\nexport function durablePlanConflictCode(error: {\n status?: number\n code?: string\n message: string\n}): 'plan_already_decided' | 'plan_superseded' | 'plan_withdrawn' | null {\n if (error.status !== 409) return null\n if (error.code === 'PLAN_ALREADY_DECIDED' || /already (approved|rejected|decided)/i.test(error.message)) {\n return 'plan_already_decided'\n }\n if (error.code === 'PLAN_SUPERSEDED' || /superseded/i.test(error.message)) return 'plan_superseded'\n if (error.code === 'PLAN_WITHDRAWN' || /withdrawn/i.test(error.message)) return 'plan_withdrawn'\n return null\n}\n\nconst TERMINAL_PLAN_STATUSES: readonly ChatPlanStatus[] = ['approved', 'rejected', 'superseded', 'withdrawn']\n\nexport function isTerminalPlanStatus(status: ChatPlanStatus): boolean {\n return TERMINAL_PLAN_STATUSES.includes(status)\n}\n\nexport type PlanLookupQuery =\n | { ok: true; workspaceId: string; threadId: string; planId: string; revision: number | null }\n | { ok: false; error: string }\n\n/**\n * Validate a current-plan lookup (`?workspaceId&threadId[&planId&revision]`).\n * `planId` is empty when the caller asks for the thread's current plan; a\n * named plan needs its positive integer revision.\n */\nexport function parsePlanLookupQuery(url: URL): PlanLookupQuery {\n const workspaceId = url.searchParams.get('workspaceId')?.trim() ?? ''\n const threadId = url.searchParams.get('threadId')?.trim() ?? ''\n const planId = url.searchParams.get('planId')?.trim() ?? ''\n const revisionParam = url.searchParams.get('revision')\n const revision = revisionParam ? Number(revisionParam) : null\n if (!workspaceId) return { ok: false, error: 'Missing workspaceId' }\n if (!threadId) return { ok: false, error: 'Missing threadId' }\n if (planId && (!Number.isInteger(revision) || Number(revision) < 1)) {\n return { ok: false, error: 'Invalid revision: expected a positive integer' }\n }\n return { ok: true, workspaceId, threadId, planId, revision }\n}\n\n/**\n * The response for a sandbox refusal of a plan decision, or null when the\n * refusal is not one the decision flow answers. A 409 means someone decided\n * first: converge on the recorded outcome (`reconcile`), running `onApproved`\n * when it was an approval. A plan the platform no longer knows can never be\n * decided, so it is reported gone rather than retried.\n */\nexport async function planDecisionRefusalResponse(\n error: { status?: number; code?: string; message: string },\n options: {\n reconcile: () => Promise<ChatPlan | null>\n onApproved: () => Promise<void>\n },\n): Promise<Response | null> {\n const code = durablePlanConflictCode(error)\n if (code) {\n const plan = await options.reconcile()\n if (!plan || plan.status === 'preparing' || plan.status === 'pending') {\n return Response.json(\n {\n code: 'plan_reconciliation_pending',\n error: 'The plan decision status is still being checked. Retry in a moment.',\n },\n { status: 503 },\n )\n }\n if (plan.status === 'approved') await options.onApproved()\n return Response.json({ code, plan }, { status: 409 })\n }\n if (error.code === 'PLAN_NOT_FOUND') {\n return Response.json(\n {\n code: 'plan_missing',\n error: 'This plan no longer exists on the agent platform. Ask the agent to submit a fresh plan.',\n },\n { status: 410 },\n )\n }\n return null\n}\n","/**\n * Durable-plan application-shell contract.\n *\n * The sandbox SDK owns the authoritative plan lifecycle and decision APIs.\n * This module only projects that substrate state into chat events and\n * persisted message parts that products can render and restore.\n */\n\nexport const PLAN_SUBMITTED_EVENT = 'plan.submitted' as const\n\n/** Sandbox plan lifecycle. `preparing` is the transient submission state and\n * is retained in the projection even though the chat card normally starts at\n * `pending`. */\nexport type ChatPlanStatus = 'preparing' | 'pending' | 'approved' | 'rejected' | 'superseded' | 'withdrawn'\n\ntype ChatPlanBase = {\n /** The sandbox SDK calls this field `id`; the transcript projection names\n * it explicitly so it cannot collide with a message-part id. */\n planId: string\n revision: number\n title?: string\n body: string\n submittedAt: string\n /** Provider/Sandbox metadata is deliberately opaque to this package. */\n metadata?: Record<string, unknown>\n decidedBy?: string\n}\n\n/** Browser/persisted projection of the sandbox SDK's durable-plan union. */\nexport type ChatPlan = ChatPlanBase & (\n | { status: 'preparing' }\n | { status: 'pending' }\n | { status: 'approved'; decidedAt: string }\n | { status: 'rejected'; decidedAt: string; feedback: string }\n | { status: 'superseded'; supersededAt: string; supersededByPlanId: string }\n | { status: 'withdrawn'; withdrawnAt: string; withdrawnReason: string }\n)\n\n/** Canonical transcript part for one durable plan. */\nexport type ChatPlanPersistedPart = ChatPlan & { type: 'plan' }\n\n/** Resolve the result of parsing a plan submission into success with value or failure with error */\nexport type ParsePlanSubmittedResult =\n | { succeeded: true; value: ChatPlan }\n | { succeeded: false; error: string }\n\nconst PLAN_STATUSES: ReadonlySet<string> = new Set([\n 'preparing',\n 'pending',\n 'approved',\n 'rejected',\n 'superseded',\n 'withdrawn',\n])\n\nfunction asRecord(value: unknown): Record<string, unknown> | null {\n return value && typeof value === 'object' && !Array.isArray(value)\n ? value as Record<string, unknown>\n : null\n}\n\nfunction requiredString(record: Record<string, unknown>, key: string): string | null {\n const value = record[key]\n return typeof value === 'string' && value ? value : null\n}\n\nfunction parsePlan(record: Record<string, unknown>, defaultStatus?: ChatPlanStatus): ChatPlan | null {\n const planId = requiredString(record, 'planId') ?? requiredString(record, 'id')\n const revision = record.revision\n const body = requiredString(record, 'body')\n const submittedAt = requiredString(record, 'submittedAt')\n const status = typeof record.status === 'string' ? record.status : defaultStatus\n if (\n !planId ||\n typeof revision !== 'number' ||\n !Number.isInteger(revision) ||\n revision < 1 ||\n !body ||\n !submittedAt ||\n !status ||\n !PLAN_STATUSES.has(status)\n ) {\n return null\n }\n\n const common = {\n planId,\n revision,\n ...(typeof record.title === 'string' && record.title ? { title: record.title } : {}),\n body,\n submittedAt,\n ...(record.metadata && typeof record.metadata === 'object' && !Array.isArray(record.metadata)\n ? { metadata: record.metadata as Record<string, unknown> }\n : {}),\n ...(typeof record.decidedBy === 'string' && record.decidedBy ? { decidedBy: record.decidedBy } : {}),\n }\n\n if (status === 'preparing') return { ...common, status: 'preparing' }\n if (status === 'pending') return { ...common, status: 'pending' }\n if (status === 'approved') {\n const decidedAt = requiredString(record, 'decidedAt')\n return decidedAt ? { ...common, status, decidedAt } : null\n }\n if (status === 'rejected') {\n const decidedAt = requiredString(record, 'decidedAt')\n const feedback = requiredString(record, 'feedback')\n return decidedAt && feedback ? { ...common, status, decidedAt, feedback } : null\n }\n if (status === 'superseded') {\n const supersededAt = requiredString(record, 'supersededAt')\n const supersededByPlanId = requiredString(record, 'supersededByPlanId')\n return supersededAt && supersededByPlanId\n ? { ...common, status, supersededAt, supersededByPlanId }\n : null\n }\n\n const withdrawnAt = requiredString(record, 'withdrawnAt')\n const withdrawnReason = requiredString(record, 'withdrawnReason') ?? requiredString(record, 'reason')\n return withdrawnAt && withdrawnReason\n ? { ...common, status: 'withdrawn', withdrawnAt, withdrawnReason }\n : null\n}\n\n/** Generate a unique key string for a given plan identifier */\nexport function planPartKey(planId: string): string {\n return `plan:${planId}`\n}\n\n/** Generate a unique key string for a plan based on its ID and revision number */\nexport function planRevisionKey(planId: string, revision: number): string {\n return `plan:${planId}:revision:${revision}`\n}\n\n/**\n * The follow-up turn the Sandbox platform enqueues when one plan revision is\n * decided. It is revision-qualified because deciding revision 2 must not reuse\n * revision 1's execution and assistant row. The platform mints the same value.\n */\nexport function planFollowUpTurnId(planId: string, revision: number, outcome: 'approved' | 'rejected'): string {\n return `${planRevisionKey(planId, revision)}:${outcome}`\n}\n\n/** Plan status is monotonic: only a pending plan can settle. */\nexport function canTransitionPlanStatus(from: ChatPlanStatus, to: ChatPlanStatus): boolean {\n if (from === to) return true\n if (from === 'preparing') return to === 'pending' || to === 'superseded' || to === 'withdrawn'\n if (from === 'pending') return to === 'approved' || to === 'rejected' || to === 'superseded' || to === 'withdrawn'\n return false\n}\n\n/** Resolve a ChatPlan into its persisted part representation for storage or transmission */\nexport function planToPersistedPart(plan: ChatPlan): ChatPlanPersistedPart {\n return { type: 'plan', ...plan }\n}\n\n/** Resolve a persisted part object into a ChatPlan or return null if the type is not 'plan */\nexport function persistedPartToPlan(part: Record<string, unknown>): ChatPlan | null {\n if (String(part.type ?? '') !== 'plan') return null\n return parsePlan(part)\n}\n\n/** Parses both direct sandbox events (`data.plan`) and session envelopes\n * (`properties.plan`). Session identity is carried by the surrounding stream\n * and is deliberately not required in the payload. */\nexport function parsePlanSubmittedEvent(event: unknown): ParsePlanSubmittedResult {\n const root = asRecord(event)\n if (!root || root.type !== PLAN_SUBMITTED_EVENT) {\n return { succeeded: false, error: 'event is not plan.submitted' }\n }\n const plan = asRecord(asRecord(root.properties)?.plan) ?? asRecord(asRecord(root.data)?.plan)\n if (!plan) {\n return { succeeded: false, error: 'plan.submitted event carried no plan' }\n }\n const parsed = parsePlan(plan, 'pending')\n return parsed\n ? { succeeded: true, value: parsed }\n : { succeeded: false, error: 'plan.submitted event carried a malformed plan' }\n}\nexport * from './decision'\n"],"mappings":";AAuCO,SAAS,sBAAsB,MAAiD;AACrF,QAAM,cAAc,OAAO,KAAK,gBAAgB,WAAW,KAAK,YAAY,KAAK,IAAI;AACrF,QAAM,WAAW,OAAO,KAAK,aAAa,WAAW,KAAK,SAAS,KAAK,IAAI;AAC5E,QAAM,SAAS,OAAO,KAAK,WAAW,WAAW,KAAK,OAAO,KAAK,IAAI;AACtE,QAAM,WAAW,KAAK;AACtB,QAAM,UAAU,KAAK;AACrB,MAAI,CAAC,YAAa,QAAO,EAAE,IAAI,OAAO,OAA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AAO,SAAS,SAAS,KAAK,UAAU,GAAG,IAAI,KAAK,SAAS,SAAS,KAAK,IAAI,GAAG,IAAI;AAC5F,MAAI,CAAC,MAAM;AACT,WAAO,EAAE,WAAW,OAAO,OAAO,uCAAuC;AAAA,EAC3E;AACA,QAAM,SAAS,UAAU,MAAM,SAAS;AACxC,SAAO,SACH,EAAE,WAAW,MAAM,OAAO,OAAO,IACjC,EAAE,WAAW,OAAO,OAAO,gDAAgD;AACjF;","names":[]}
|
|
@@ -52,7 +52,7 @@ import {
|
|
|
52
52
|
} from "./chunk-AVP5SNIG.js";
|
|
53
53
|
import {
|
|
54
54
|
attachmentPartsFromMessageParts
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-CRZXEKCX.js";
|
|
56
56
|
import {
|
|
57
57
|
cancelStatusFor,
|
|
58
58
|
fieldAcceptsFreeText,
|
|
@@ -73,7 +73,7 @@ import {
|
|
|
73
73
|
import {
|
|
74
74
|
parsePlanSubmittedEvent,
|
|
75
75
|
persistedPartToPlan
|
|
76
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-4PIN6QYQ.js";
|
|
77
77
|
|
|
78
78
|
// src/web-react/chat-stream.ts
|
|
79
79
|
var trackedCallbacks = /* @__PURE__ */ new WeakSet();
|
|
@@ -8575,4 +8575,4 @@ export {
|
|
|
8575
8575
|
AgentProfileChoices,
|
|
8576
8576
|
ComposerProfilePill
|
|
8577
8577
|
};
|
|
8578
|
-
//# sourceMappingURL=chunk-
|
|
8578
|
+
//# sourceMappingURL=chunk-AZRPDSRQ.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
toChatMessageParts
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CRZXEKCX.js";
|
|
4
4
|
import {
|
|
5
5
|
asRecord
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZNWJJRHP.js";
|
|
7
7
|
|
|
8
8
|
// src/chat-routes/draft-persistence.ts
|
|
9
9
|
var CONTENT_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -222,4 +222,4 @@ export {
|
|
|
222
222
|
assistantRowIdForTurn,
|
|
223
223
|
addStepFinishUsage
|
|
224
224
|
};
|
|
225
|
-
//# sourceMappingURL=chunk-
|
|
225
|
+
//# sourceMappingURL=chunk-BMCC2BUP.js.map
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
persistedPartToPlan,
|
|
12
12
|
planToPersistedPart
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-4PIN6QYQ.js";
|
|
14
14
|
|
|
15
15
|
// src/chat-store/parts.ts
|
|
16
16
|
function toChatMessageParts(parts) {
|
|
@@ -146,4 +146,4 @@ export {
|
|
|
146
146
|
buildAttachmentPromptBlock,
|
|
147
147
|
historyContentWithAttachments
|
|
148
148
|
};
|
|
149
|
-
//# sourceMappingURL=chunk-
|
|
149
|
+
//# sourceMappingURL=chunk-CRZXEKCX.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/tools/errors.ts
|
|
2
|
+
var ToolInputError = class extends Error {
|
|
3
|
+
constructor(code, message, status = 400) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.code = code;
|
|
6
|
+
this.status = status;
|
|
7
|
+
this.name = "ToolInputError";
|
|
8
|
+
}
|
|
9
|
+
code;
|
|
10
|
+
status;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
ToolInputError
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=chunk-F4XBNR5L.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tools/errors.ts"],"sourcesContent":["/** A correctable bad-input error a tool handler throws; the HTTP layer maps it\n * to a 4xx with the code, the runtime layer to a failed tool_result. So the\n * agent learns the call failed and can correct, instead of a silent success. */\nexport class ToolInputError extends Error {\n constructor(\n public code: string,\n message: string,\n public status = 400,\n ) {\n super(message)\n this.name = 'ToolInputError'\n }\n}\n"],"mappings":";AAGO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YACS,MACP,SACO,SAAS,KAChB;AACA,UAAM,OAAO;AAJN;AAEA;AAGP,SAAK,OAAO;AAAA,EACd;AAAA,EANS;AAAA,EAEA;AAKX;","names":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/sandbox/computer-receipts.ts
|
|
2
|
+
var DEFAULT_COMPUTER_STEP_RECEIPT_TABLE = "computer_step_receipts";
|
|
3
|
+
var COMPUTER_STEP_RECEIPT_TABLE_DDL = `CREATE TABLE IF NOT EXISTS ${DEFAULT_COMPUTER_STEP_RECEIPT_TABLE} (
|
|
4
|
+
step_id TEXT PRIMARY KEY,
|
|
5
|
+
state TEXT NOT NULL,
|
|
6
|
+
receipt TEXT NOT NULL,
|
|
7
|
+
updated_at INTEGER NOT NULL
|
|
8
|
+
);
|
|
9
|
+
CREATE INDEX IF NOT EXISTS ${DEFAULT_COMPUTER_STEP_RECEIPT_TABLE}_by_age ON ${DEFAULT_COMPUTER_STEP_RECEIPT_TABLE} (updated_at);`;
|
|
10
|
+
var SAFE_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
11
|
+
var PRUNE_EVERY_WRITES = 64;
|
|
12
|
+
var DEFAULT_RETENTION_MS = 30 * 24 * 36e5;
|
|
13
|
+
function createD1ComputerStepReceipts(db, options = {}) {
|
|
14
|
+
const table = options.table ?? DEFAULT_COMPUTER_STEP_RECEIPT_TABLE;
|
|
15
|
+
if (!SAFE_IDENTIFIER.test(table)) throw new Error(`Invalid computer step receipt table name: ${JSON.stringify(table)}`);
|
|
16
|
+
const now = options.now ?? (() => Date.now());
|
|
17
|
+
const readSql = `SELECT receipt FROM ${table} WHERE step_id = ?`;
|
|
18
|
+
const writeSql = `INSERT INTO ${table} (step_id, state, receipt, updated_at) VALUES (?, ?, ?, ?)
|
|
19
|
+
ON CONFLICT(step_id) DO UPDATE SET state = excluded.state, receipt = excluded.receipt, updated_at = excluded.updated_at
|
|
20
|
+
WHERE ${table}.state <> 'settled'`;
|
|
21
|
+
const pruneSql = `DELETE FROM ${table} WHERE updated_at < ?`;
|
|
22
|
+
let writes = 0;
|
|
23
|
+
return {
|
|
24
|
+
async read(stepId) {
|
|
25
|
+
const row = await db.prepare(readSql).bind(stepId).first();
|
|
26
|
+
return row ? JSON.parse(row.receipt) : null;
|
|
27
|
+
},
|
|
28
|
+
async write(receipt) {
|
|
29
|
+
await db.prepare(writeSql).bind(receipt.stepId, receipt.state, JSON.stringify(receipt), receipt.updatedAt).run();
|
|
30
|
+
if (++writes % PRUNE_EVERY_WRITES === 0) await db.prepare(pruneSql).bind(now() - (options.retentionMs ?? DEFAULT_RETENTION_MS)).run();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
DEFAULT_COMPUTER_STEP_RECEIPT_TABLE,
|
|
37
|
+
COMPUTER_STEP_RECEIPT_TABLE_DDL,
|
|
38
|
+
createD1ComputerStepReceipts
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=chunk-GY4IPYG4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sandbox/computer-receipts.ts"],"sourcesContent":["/**\n * Computer-step receipts: the durable record of one `sandbox_run` call, keyed\n * by its step id (the turn's execution, the session and the tool call).\n *\n * `prepared` is written before the task is sent and holds the Vault listing\n * taken then, so a repeated call after a lost request still copies the files\n * the first send wrote. `settled` holds the answer the model read, the model\n * that ran and the file receipt; a repeated call returns it and sends nothing.\n * A receipt holds no credential.\n */\nimport type { ComputerFileListing, ComputerFileReceipt } from './computer-files'\n\nexport interface ComputerStepReceipt {\n stepId: string\n state: 'prepared' | 'settled'\n sessionId: string\n model?: string\n /** The Vault listing before the first send, while `prepared`. */\n before?: ComputerFileListing\n /** The answer the model read, file receipt line included, once `settled`. */\n answer?: string\n files?: ComputerFileReceipt\n updatedAt: number\n}\n\nexport interface ComputerStepReceipts {\n read(stepId: string): Promise<ComputerStepReceipt | null>\n /** A `settled` receipt is final: a later `prepared` write for the same step never replaces it. */\n write(receipt: ComputerStepReceipt): Promise<void>\n}\n\n/** The D1 surface the store uses. A real `D1Database` satisfies it. */\nexport interface ComputerStepReceiptD1Like {\n prepare(query: string): {\n bind(...values: unknown[]): {\n first<T = Record<string, unknown>>(): Promise<T | null>\n run(): Promise<unknown>\n }\n }\n}\n\nexport const DEFAULT_COMPUTER_STEP_RECEIPT_TABLE = 'computer_step_receipts'\n\n/** Paste into a product migration; the store never runs DDL. Times are epoch ms. */\nexport const COMPUTER_STEP_RECEIPT_TABLE_DDL = `CREATE TABLE IF NOT EXISTS ${DEFAULT_COMPUTER_STEP_RECEIPT_TABLE} (\n step_id TEXT PRIMARY KEY,\n state TEXT NOT NULL,\n receipt TEXT NOT NULL,\n updated_at INTEGER NOT NULL\n);\nCREATE INDEX IF NOT EXISTS ${DEFAULT_COMPUTER_STEP_RECEIPT_TABLE}_by_age ON ${DEFAULT_COMPUTER_STEP_RECEIPT_TABLE} (updated_at);`\n\nconst SAFE_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/\nconst PRUNE_EVERY_WRITES = 64\nconst DEFAULT_RETENTION_MS = 30 * 24 * 3600_000\n\n/** Receipts in one D1 table, shared by every isolate. Rows older than `retentionMs` (default 30 days) are pruned. */\nexport function createD1ComputerStepReceipts(db: ComputerStepReceiptD1Like, options: {\n table?: string; retentionMs?: number; now?: () => number\n} = {}): ComputerStepReceipts {\n const table = options.table ?? DEFAULT_COMPUTER_STEP_RECEIPT_TABLE\n if (!SAFE_IDENTIFIER.test(table)) throw new Error(`Invalid computer step receipt table name: ${JSON.stringify(table)}`)\n const now = options.now ?? (() => Date.now())\n const readSql = `SELECT receipt FROM ${table} WHERE step_id = ?`\n const writeSql = `INSERT INTO ${table} (step_id, state, receipt, updated_at) VALUES (?, ?, ?, ?)\nON CONFLICT(step_id) DO UPDATE SET state = excluded.state, receipt = excluded.receipt, updated_at = excluded.updated_at\nWHERE ${table}.state <> 'settled'`\n const pruneSql = `DELETE FROM ${table} WHERE updated_at < ?`\n let writes = 0\n return {\n async read(stepId) {\n const row = await db.prepare(readSql).bind(stepId).first<{ receipt: string }>()\n return row ? JSON.parse(row.receipt) as ComputerStepReceipt : null\n },\n async write(receipt) {\n await db.prepare(writeSql).bind(receipt.stepId, receipt.state, JSON.stringify(receipt), receipt.updatedAt).run()\n if (++writes % PRUNE_EVERY_WRITES === 0) await db.prepare(pruneSql).bind(now() - (options.retentionMs ?? DEFAULT_RETENTION_MS)).run()\n },\n }\n}\n"],"mappings":";AAyCO,IAAM,sCAAsC;AAG5C,IAAM,kCAAkC,8BAA8B,mCAAmC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAMnF,mCAAmC,cAAc,mCAAmC;AAEjH,IAAM,kBAAkB;AACxB,IAAM,qBAAqB;AAC3B,IAAM,uBAAuB,KAAK,KAAK;AAGhC,SAAS,6BAA6B,IAA+B,UAExE,CAAC,GAAyB;AAC5B,QAAM,QAAQ,QAAQ,SAAS;AAC/B,MAAI,CAAC,gBAAgB,KAAK,KAAK,EAAG,OAAM,IAAI,MAAM,6CAA6C,KAAK,UAAU,KAAK,CAAC,EAAE;AACtH,QAAM,MAAM,QAAQ,QAAQ,MAAM,KAAK,IAAI;AAC3C,QAAM,UAAU,uBAAuB,KAAK;AAC5C,QAAM,WAAW,eAAe,KAAK;AAAA;AAAA,QAE/B,KAAK;AACX,QAAM,WAAW,eAAe,KAAK;AACrC,MAAI,SAAS;AACb,SAAO;AAAA,IACL,MAAM,KAAK,QAAQ;AACjB,YAAM,MAAM,MAAM,GAAG,QAAQ,OAAO,EAAE,KAAK,MAAM,EAAE,MAA2B;AAC9E,aAAO,MAAM,KAAK,MAAM,IAAI,OAAO,IAA2B;AAAA,IAChE;AAAA,IACA,MAAM,MAAM,SAAS;AACnB,YAAM,GAAG,QAAQ,QAAQ,EAAE,KAAK,QAAQ,QAAQ,QAAQ,OAAO,KAAK,UAAU,OAAO,GAAG,QAAQ,SAAS,EAAE,IAAI;AAC/G,UAAI,EAAE,SAAS,uBAAuB,EAAG,OAAM,GAAG,QAAQ,QAAQ,EAAE,KAAK,IAAI,KAAK,QAAQ,eAAe,qBAAqB,EAAE,IAAI;AAAA,IACtI;AAAA,EACF;AACF;","names":[]}
|
|
@@ -294,238 +294,6 @@ function generationSpecSegments(generation) {
|
|
|
294
294
|
return segments;
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
// src/studio/model-options.ts
|
|
298
|
-
var SEEDANCE_2_0 = {
|
|
299
|
-
duration: {
|
|
300
|
-
values: ["auto", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15"],
|
|
301
|
-
default: "auto"
|
|
302
|
-
},
|
|
303
|
-
resolution: { values: ["480p", "720p", "1080p", "4k"], default: "720p" },
|
|
304
|
-
aspect_ratio: { values: ["auto", "21:9", "16:9", "4:3", "1:1", "3:4", "9:16"], default: "auto" },
|
|
305
|
-
audio: { default: true }
|
|
306
|
-
};
|
|
307
|
-
var FALLBACK_VIDEO_MODEL_OPTIONS = {
|
|
308
|
-
"runway/gen4.5": {
|
|
309
|
-
duration: { min: 2, max: 10, default: 5 },
|
|
310
|
-
aspect_ratio: { values: ["16:9", "9:16"], default: "16:9" },
|
|
311
|
-
resolution: { supported: false },
|
|
312
|
-
audio: { supported: false }
|
|
313
|
-
},
|
|
314
|
-
"runway/gen4_turbo": {
|
|
315
|
-
duration: { min: 2, max: 10, default: 5 },
|
|
316
|
-
aspect_ratio: { values: ["16:9", "9:16", "4:3", "3:4", "1:1", "21:9"], default: "16:9" },
|
|
317
|
-
resolution: { supported: false },
|
|
318
|
-
audio: { supported: false }
|
|
319
|
-
},
|
|
320
|
-
"kling/kling-v1-6": {
|
|
321
|
-
duration: { values: [5, 10], default: 5 },
|
|
322
|
-
aspect_ratio: { values: ["16:9", "9:16", "1:1"], default: "16:9" },
|
|
323
|
-
resolution: { supported: false },
|
|
324
|
-
audio: { supported: false },
|
|
325
|
-
mode: { values: ["std", "pro"], default: "std" }
|
|
326
|
-
},
|
|
327
|
-
"kling/kling-v2-master": {
|
|
328
|
-
duration: { values: [5, 10], default: 5 },
|
|
329
|
-
aspect_ratio: { values: ["16:9", "9:16", "1:1"], default: "16:9" },
|
|
330
|
-
resolution: { supported: false },
|
|
331
|
-
audio: { supported: false },
|
|
332
|
-
mode: { supported: false }
|
|
333
|
-
},
|
|
334
|
-
"bytedance/seedance-2.0/text-to-video": SEEDANCE_2_0,
|
|
335
|
-
"bytedance/seedance-2.0/image-to-video": SEEDANCE_2_0,
|
|
336
|
-
"fal-ai/kling-video/v3/pro/text-to-video": {
|
|
337
|
-
duration: { values: ["3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15"], default: "5" },
|
|
338
|
-
resolution: { supported: false },
|
|
339
|
-
aspect_ratio: { values: ["16:9", "9:16", "1:1"], default: "16:9" },
|
|
340
|
-
audio: { default: true }
|
|
341
|
-
},
|
|
342
|
-
"fal-ai/veo3.1": {
|
|
343
|
-
duration: { values: ["4s", "6s", "8s"], default: "8s" },
|
|
344
|
-
resolution: { values: ["720p", "1080p", "4k"], default: "720p" },
|
|
345
|
-
aspect_ratio: { values: ["16:9", "9:16"], default: "16:9" },
|
|
346
|
-
audio: { default: true }
|
|
347
|
-
},
|
|
348
|
-
"xai/grok-imagine-video/text-to-video": {
|
|
349
|
-
duration: { min: 1, max: 15, default: 6 },
|
|
350
|
-
resolution: { values: ["480p", "720p"], default: "720p" },
|
|
351
|
-
aspect_ratio: { values: ["16:9", "4:3", "3:2", "1:1", "2:3", "3:4", "9:16"], default: "16:9" },
|
|
352
|
-
audio: { supported: false }
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
var IMAGE_MODEL_OPTIONS = {
|
|
356
|
-
"gpt-image-2": {
|
|
357
|
-
size: { values: ["auto", "1024x1024", "1536x1024", "1024x1536"], default: "auto" },
|
|
358
|
-
quality: { values: ["low", "medium", "high", "auto"], default: "auto" },
|
|
359
|
-
n: { values: [1, 2, 4, 8], default: 1 }
|
|
360
|
-
}
|
|
361
|
-
};
|
|
362
|
-
var OPENAI_TTS_VOICES = ["alloy", "ash", "coral", "echo", "fable", "onyx", "nova", "sage", "shimmer"];
|
|
363
|
-
var OPENAI_GPT4O_MINI_TTS_VOICES = [...OPENAI_TTS_VOICES, "ballad", "cedar", "marin", "verse"];
|
|
364
|
-
var GOOGLE_TTS_VOICE_ALIASES = ["alloy", "echo", "fable", "onyx", "nova", "shimmer"];
|
|
365
|
-
var OPENAI_AUDIO_MODEL_OPTIONS = {
|
|
366
|
-
"tts-1": {
|
|
367
|
-
voice: { values: OPENAI_TTS_VOICES, default: "alloy" },
|
|
368
|
-
speed: { min: 0.25, max: 4, default: 1 }
|
|
369
|
-
},
|
|
370
|
-
"tts-1-hd": {
|
|
371
|
-
voice: { values: OPENAI_TTS_VOICES, default: "alloy" },
|
|
372
|
-
speed: { min: 0.25, max: 4, default: 1 }
|
|
373
|
-
},
|
|
374
|
-
"gpt-4o-mini-tts": {
|
|
375
|
-
voice: { values: OPENAI_GPT4O_MINI_TTS_VOICES, default: "alloy" },
|
|
376
|
-
speed: { min: 0.25, max: 4, default: 1 }
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
var GOOGLE_AUDIO_MODEL_OPTIONS = {
|
|
380
|
-
voice: { values: GOOGLE_TTS_VOICE_ALIASES, default: "alloy" },
|
|
381
|
-
speed: { supported: false }
|
|
382
|
-
};
|
|
383
|
-
var GPT_IMAGE_2_CUSTOM_SIZE = { multipleOf: 16, maxLongEdge: 3840, maxRatio: 3 };
|
|
384
|
-
function validateCustomImageSize(width, height) {
|
|
385
|
-
if (!Number.isInteger(width) || !Number.isInteger(height) || width <= 0 || height <= 0) {
|
|
386
|
-
return { ok: false, reason: "Width and height must be positive integers." };
|
|
387
|
-
}
|
|
388
|
-
if (width % GPT_IMAGE_2_CUSTOM_SIZE.multipleOf !== 0 || height % GPT_IMAGE_2_CUSTOM_SIZE.multipleOf !== 0) {
|
|
389
|
-
return { ok: false, reason: "Each side must be a multiple of 16." };
|
|
390
|
-
}
|
|
391
|
-
if (Math.max(width, height) > GPT_IMAGE_2_CUSTOM_SIZE.maxLongEdge) {
|
|
392
|
-
return { ok: false, reason: "The long edge must be 3840 pixels or less." };
|
|
393
|
-
}
|
|
394
|
-
if (Math.max(width / height, height / width) > GPT_IMAGE_2_CUSTOM_SIZE.maxRatio) {
|
|
395
|
-
return { ok: false, reason: "The aspect ratio must be between 1:3 and 3:1." };
|
|
396
|
-
}
|
|
397
|
-
return { ok: true };
|
|
398
|
-
}
|
|
399
|
-
var KNOWN_PROVIDER_ALIASES = /* @__PURE__ */ new Set([
|
|
400
|
-
"openai",
|
|
401
|
-
"google",
|
|
402
|
-
"gemini",
|
|
403
|
-
"fal",
|
|
404
|
-
"fal-ai",
|
|
405
|
-
"runway",
|
|
406
|
-
"kling",
|
|
407
|
-
"bytedance",
|
|
408
|
-
"xai"
|
|
409
|
-
]);
|
|
410
|
-
function bareSingleSlashId(modelId) {
|
|
411
|
-
const segments = modelId.split("/");
|
|
412
|
-
if (segments.length !== 2 || !KNOWN_PROVIDER_ALIASES.has(segments[0] ?? "")) return void 0;
|
|
413
|
-
return segments[1];
|
|
414
|
-
}
|
|
415
|
-
function audioOptions(modelId, provider) {
|
|
416
|
-
const bareId = bareSingleSlashId(modelId) ?? modelId;
|
|
417
|
-
const exact = OPENAI_AUDIO_MODEL_OPTIONS[modelId] ?? OPENAI_AUDIO_MODEL_OPTIONS[bareId];
|
|
418
|
-
if (exact) return exact;
|
|
419
|
-
const normalizedProvider = provider?.toLowerCase();
|
|
420
|
-
if (bareId.toLowerCase().startsWith("gemini") && bareId.toLowerCase().includes("tts") || normalizedProvider === "google" || normalizedProvider === "gemini") return GOOGLE_AUDIO_MODEL_OPTIONS;
|
|
421
|
-
return void 0;
|
|
422
|
-
}
|
|
423
|
-
function resolveComposerOptions(input) {
|
|
424
|
-
if (input.catalogOptions) return input.catalogOptions;
|
|
425
|
-
if (input.type === "speech") return audioOptions(input.modelId, input.provider);
|
|
426
|
-
const table = input.type === "image" ? IMAGE_MODEL_OPTIONS : FALLBACK_VIDEO_MODEL_OPTIONS;
|
|
427
|
-
const exact = table[input.modelId];
|
|
428
|
-
if (exact) return exact;
|
|
429
|
-
const bareId = bareSingleSlashId(input.modelId);
|
|
430
|
-
return bareId ? table[bareId] : void 0;
|
|
431
|
-
}
|
|
432
|
-
function supportsCustomImageSize(modelId) {
|
|
433
|
-
return modelId === "gpt-image-2" || bareSingleSlashId(modelId) === "gpt-image-2";
|
|
434
|
-
}
|
|
435
|
-
var IMAGE_TO_VIDEO_SIBLINGS = {
|
|
436
|
-
"bytedance/seedance-2.0/text-to-video": "bytedance/seedance-2.0/image-to-video"
|
|
437
|
-
};
|
|
438
|
-
function imageToVideoSibling(modelId) {
|
|
439
|
-
return IMAGE_TO_VIDEO_SIBLINGS[modelId];
|
|
440
|
-
}
|
|
441
|
-
function textToVideoSibling(modelId) {
|
|
442
|
-
return Object.entries(IMAGE_TO_VIDEO_SIBLINGS).find(([, sibling]) => sibling === modelId)?.[0];
|
|
443
|
-
}
|
|
444
|
-
function curateComposerModels(type, models) {
|
|
445
|
-
if (type === "image") return models.filter((model) => supportsCustomImageSize(model.id));
|
|
446
|
-
if (type === "video") {
|
|
447
|
-
const imageToVideoIds = new Set(Object.values(IMAGE_TO_VIDEO_SIBLINGS));
|
|
448
|
-
return models.filter((model) => !model.id.toLowerCase().includes("sora") && !imageToVideoIds.has(model.id));
|
|
449
|
-
}
|
|
450
|
-
return models;
|
|
451
|
-
}
|
|
452
|
-
function optionDefault(meta) {
|
|
453
|
-
return meta.default ?? meta.values?.[0] ?? meta.min;
|
|
454
|
-
}
|
|
455
|
-
function optionChoices(meta) {
|
|
456
|
-
if (meta.values) return meta.values;
|
|
457
|
-
if (meta.min == null || meta.max == null) return [];
|
|
458
|
-
const values = [];
|
|
459
|
-
for (let value = Math.ceil(meta.min); value <= Math.floor(meta.max); value += 1) values.push(value);
|
|
460
|
-
return values;
|
|
461
|
-
}
|
|
462
|
-
function isCustomSize(value) {
|
|
463
|
-
if (typeof value !== "string") return false;
|
|
464
|
-
const match = /^(\d+)x(\d+)$/.exec(value);
|
|
465
|
-
if (!match) return false;
|
|
466
|
-
return validateCustomImageSize(Number(match[1]), Number(match[2])).ok;
|
|
467
|
-
}
|
|
468
|
-
function isLegalOptionValue(meta, value) {
|
|
469
|
-
if (meta.values) return meta.values.includes(value);
|
|
470
|
-
if (typeof value === "number" && meta.min != null && meta.max != null) {
|
|
471
|
-
return value >= meta.min && value <= meta.max;
|
|
472
|
-
}
|
|
473
|
-
return meta.min == null && meta.max == null;
|
|
474
|
-
}
|
|
475
|
-
function reconcileOptionValues(options, current, opts) {
|
|
476
|
-
if (!options) return {};
|
|
477
|
-
const reconciled = {};
|
|
478
|
-
for (const [key, meta] of Object.entries(options)) {
|
|
479
|
-
if (meta.supported === false) continue;
|
|
480
|
-
const selected = current[key];
|
|
481
|
-
const customSizeIsLegal = key === "size" && selected !== void 0 && opts?.allowCustomSize === true && isCustomSize(selected);
|
|
482
|
-
const selectionIsLegal = selected !== void 0 && (isLegalOptionValue(meta, selected) || customSizeIsLegal);
|
|
483
|
-
const next = selectionIsLegal ? selected : optionDefault(meta);
|
|
484
|
-
if (next !== void 0) reconciled[key] = next;
|
|
485
|
-
}
|
|
486
|
-
return reconciled;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
// src/studio/ports.ts
|
|
490
|
-
var MEDIA_TYPE_FILTERS = [
|
|
491
|
-
{ value: "all", label: "All media" },
|
|
492
|
-
{ value: "image", label: "Images" },
|
|
493
|
-
{ value: "video", label: "Videos" },
|
|
494
|
-
{ value: "speech", label: "Audio" }
|
|
495
|
-
];
|
|
496
|
-
|
|
497
|
-
// src/studio/audio-preview.ts
|
|
498
|
-
var GRID_WAVEFORM_BARS = 26;
|
|
499
|
-
var WIDE_WAVEFORM_BARS = 72;
|
|
500
|
-
function hashSeed(value) {
|
|
501
|
-
let hash = 2166136261;
|
|
502
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
503
|
-
hash ^= value.charCodeAt(index);
|
|
504
|
-
hash = Math.imul(hash, 16777619);
|
|
505
|
-
}
|
|
506
|
-
return hash >>> 0;
|
|
507
|
-
}
|
|
508
|
-
function mulberry32(seed) {
|
|
509
|
-
let a = seed;
|
|
510
|
-
return () => {
|
|
511
|
-
a |= 0;
|
|
512
|
-
a = a + 1831565813 | 0;
|
|
513
|
-
let t = Math.imul(a ^ a >>> 15, 1 | a);
|
|
514
|
-
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
|
|
515
|
-
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
function previewWaveformBars(seed, count) {
|
|
519
|
-
const rnd = mulberry32(hashSeed(seed));
|
|
520
|
-
return Array.from({ length: count }, (_, index) => {
|
|
521
|
-
const t = count > 1 ? index / (count - 1) : 0;
|
|
522
|
-
const env = Math.sin(Math.PI * t) * 0.55 + 0.45;
|
|
523
|
-
const heightPct = +Math.max(7, (0.22 + rnd() * 0.78) * env * 92).toFixed(1);
|
|
524
|
-
const opacity = +(0.5 + rnd() * 0.5).toFixed(2);
|
|
525
|
-
return { heightPct, opacity };
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
|
|
529
297
|
export {
|
|
530
298
|
GENERATION_TYPES,
|
|
531
299
|
isGenerationType,
|
|
@@ -557,23 +325,6 @@ export {
|
|
|
557
325
|
defaultVaultPathFor,
|
|
558
326
|
normalizeVaultPath,
|
|
559
327
|
mergeGenerationPages,
|
|
560
|
-
generationSpecSegments
|
|
561
|
-
FALLBACK_VIDEO_MODEL_OPTIONS,
|
|
562
|
-
GPT_IMAGE_2_CUSTOM_SIZE,
|
|
563
|
-
validateCustomImageSize,
|
|
564
|
-
resolveComposerOptions,
|
|
565
|
-
supportsCustomImageSize,
|
|
566
|
-
IMAGE_TO_VIDEO_SIBLINGS,
|
|
567
|
-
imageToVideoSibling,
|
|
568
|
-
textToVideoSibling,
|
|
569
|
-
curateComposerModels,
|
|
570
|
-
optionDefault,
|
|
571
|
-
optionChoices,
|
|
572
|
-
reconcileOptionValues,
|
|
573
|
-
MEDIA_TYPE_FILTERS,
|
|
574
|
-
GRID_WAVEFORM_BARS,
|
|
575
|
-
WIDE_WAVEFORM_BARS,
|
|
576
|
-
hashSeed,
|
|
577
|
-
previewWaveformBars
|
|
328
|
+
generationSpecSegments
|
|
578
329
|
};
|
|
579
|
-
//# sourceMappingURL=chunk-
|
|
330
|
+
//# sourceMappingURL=chunk-MTKD2FN5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/studio/generation.ts"],"sourcesContent":["import type { CatalogModel } from '../runtime/model-catalog'\nimport type { ModelOptionsMetadata } from './model-options'\n\n/** Define generation categories for media including image, video, speech, avatar, and transcription */\nexport type GenerationType = 'image' | 'video' | 'speech' | 'avatar' | 'transcription'\n\n/** Define possible states representing the progress of a generation process */\nexport type GenerationStatus = 'pending' | 'running' | 'succeeded' | 'failed'\n\n/** Define possible status values for a media model's availability and accessibility */\nexport type MediaModelStatus = 'available' | 'limited' | 'unavailable'\n\n/** Define the structure for a generation entity including its metadata and creation details */\nexport interface Generation {\n id: string\n type: string\n prompt: string\n result: string | null\n model: string | null\n cost: number | null\n createdAt: Date | null\n metadata: Record<string, unknown> | null\n}\n\n/** Describe a catalog media model and its optional wire-level option metadata. */\nexport interface MediaModelOption {\n id: string\n name: string\n /** The host that serves the request (fal, runway). */\n provider?: string\n /** The brand that made the model (bytedance, google), when the catalogue\n * names one; the picker shows its logo instead of the host's. */\n maker?: string\n type: GenerationType\n status: MediaModelStatus\n reason?: string\n options?: ModelOptionsMetadata\n /** USD per unit of output as the catalog publishes it (one image, one second\n * of video, one minute of audio, 1,000 characters of speech). Absent when no\n * price is published; the picker then shows none rather than a guess. */\n outputPrice?: CatalogModel['outputPrice']\n /** An example output (an image, or a video poster frame) for the picker row. */\n previewUrl?: string\n /** One line on what the model is for, shown under its name in the picker. */\n capability?: string\n}\n\n/** Represent media model catalog with default values, model options, and optional error message */\nexport interface MediaModelCatalogResponse {\n defaults: Record<GenerationType, string>\n models: Record<GenerationType, MediaModelOption[]>\n error?: string\n}\n\n// Order drives the library type filter tabs. The composer offers its own\n// subset (`COMPOSER_TYPES` in studio-react) while avatar/transcription are\n// disabled (#451).\n/** Provide an array of supported generation types for media and content processing */\nexport const GENERATION_TYPES: readonly GenerationType[] = ['image', 'video', 'avatar', 'speech', 'transcription']\n\n/** Resolve whether a string value matches a valid GenerationType */\nexport function isGenerationType(value: string): value is GenerationType {\n return (GENERATION_TYPES as readonly string[]).includes(value)\n}\n\n/** Define the minimum number of images required for processing or validation */\nexport const MIN_IMAGE_COUNT = 1\n/** Define the maximum number of images allowed for upload or display */\nexport const MAX_IMAGE_COUNT = 8\n\n/** Resolve a human-readable relative time string from a given date or return an empty string if null */\nexport function relativeTime(date: Date | string | null): string {\n if (!date) return ''\n const now = Date.now()\n const diff = now - new Date(date).getTime()\n const minutes = Math.floor(diff / 60000)\n if (minutes < 1) return 'just now'\n if (minutes < 60) return `${minutes}m ago`\n const hours = Math.floor(minutes / 60)\n if (hours < 24) return `${hours}h ago`\n const days = Math.floor(hours / 24)\n if (days < 7) return `${days}d ago`\n return new Date(date).toLocaleDateString('en-US', { month: 'short', day: 'numeric' })\n}\n\n/** Resolve the output directory path based on the specified generation type */\nexport function outputPathFor(type: GenerationType): string {\n if (type === 'image') return 'generated/images'\n if (type === 'video') return 'generated/videos'\n if (type === 'avatar') return 'generated/avatars'\n if (type === 'speech') return 'generated/audio'\n return 'generated/transcripts'\n}\n\n/** Resolve the vault path string from a Generation object or return null if unavailable */\nexport function generationVaultPath(generation: Generation): string | null {\n const value = generation.metadata?.vaultPath\n return typeof value === 'string' && value.trim() ? value.trim() : null\n}\n\n/** Whether the product has admitted generated media into its Vault. Products\n * that expose an explicit `savedToVaultAt` marker override the legacy\n * path-only contract: generated bytes may already have an internal Vault path\n * while still waiting for the user's save decision. An absent marker keeps\n * existing consumers backward-compatible. */\nexport function generationSavedToVault(generation: Generation): boolean {\n const metadata = generation.metadata\n if (metadata && Object.hasOwn(metadata, 'savedToVaultAt')) {\n const value = metadata.savedToVaultAt\n return value !== null && value !== undefined && value !== false && value !== ''\n }\n return generationVaultPath(generation) !== null\n}\n\n/** Resolve the preferred model ID for a given generation type from the media model catalog */\nexport function preferredModelId(type: GenerationType, catalog: MediaModelCatalogResponse | null): string | undefined {\n if (!catalog) return undefined\n const models = catalog.models[type] ?? []\n const preferred = catalog.defaults[type]\n return models.find((model) => model.id === preferred && model.status !== 'unavailable')?.id\n ?? models.find((model) => model.status !== 'unavailable')?.id\n ?? models[0]?.id\n}\n\n/** True when a model list offers nothing sendable: no models, or every model unavailable. */\nexport function laneUnavailable(models: readonly MediaModelOption[]): boolean {\n return models.length === 0 || models.every((model) => model.status === 'unavailable')\n}\n\n/** Define fields required to configure and request various types of media generation */\nexport interface GenerationRequestFields {\n workspaceId: string\n clientRequestId: string\n type: GenerationType\n model: string\n prompt: string\n // Every per-lane parameter except the image COUNT is optional, because the\n // composer only sends what the selected model publishes: a model whose\n // metadata omits `size` (or marks it `supported: false`) must send no `size`\n // at all, and a model that publishes nothing — `ltx-video` — sends only the\n // prompt. `count` stays required: it is the number of optimistic cards the\n // caller already drew, not a model parameter.\n image: { size?: string; quality?: string; count: number }\n video: {\n duration?: string | number\n resolution?: string\n aspectRatio?: string\n referenceImageUrl?: string\n audio?: boolean\n mode?: string\n }\n speech: { voice?: string; speed?: number }\n // Optional while the composer lanes are disabled (#451); the server capability stays.\n avatar?: { audioUrl: string; imageUrl: string; avatarId: string }\n transcription?: { audioUrl: string; language: string; responseFormat: string; temperature: string }\n}\n\n// image.count must already be normalized — it is also the optimistic-card count on the caller side\n/** Build the request body object for a generation operation from provided fields */\nexport function buildGenerationRequestBody(fields: GenerationRequestFields): Record<string, unknown> {\n const body: Record<string, unknown> = {\n workspaceId: fields.workspaceId,\n clientRequestId: fields.clientRequestId,\n type: fields.type,\n model: fields.model,\n prompt: fields.prompt.trim(),\n }\n if (fields.type === 'image') {\n if (fields.image.size) body.size = fields.image.size\n if (fields.image.quality) body.quality = fields.image.quality\n body.n = fields.image.count\n }\n if (fields.type === 'video') {\n if (fields.video.duration !== undefined) body.duration = fields.video.duration\n if (fields.video.resolution) body.resolution = fields.video.resolution\n if (fields.video.aspectRatio) body.aspectRatio = fields.video.aspectRatio\n if (fields.video.referenceImageUrl) body.referenceImageUrl = fields.video.referenceImageUrl\n if (fields.video.audio !== undefined) body.audio = fields.video.audio\n if (fields.video.mode) body.mode = fields.video.mode\n }\n if (fields.type === 'speech') {\n if (fields.speech.voice) body.voice = fields.speech.voice\n if (fields.speech.speed !== undefined) body.speed = fields.speech.speed\n }\n if (fields.type === 'avatar' && fields.avatar) Object.assign(body, {\n audioUrl: fields.avatar.audioUrl.trim(),\n imageUrl: fields.avatar.imageUrl.trim() || undefined,\n avatarId: fields.avatar.avatarId.trim() || undefined,\n })\n if (fields.type === 'transcription' && fields.transcription) {\n const temperature = Number(fields.transcription.temperature)\n Object.assign(body, {\n audioUrl: fields.transcription.audioUrl.trim(),\n language: fields.transcription.language.trim() || undefined,\n responseFormat: fields.transcription.responseFormat,\n // omit (let the API default) rather than serialize NaN → null on bad input\n temperature: Number.isFinite(temperature) ? temperature : undefined,\n })\n }\n return body\n}\n\n/** Resolve the current status of a generation based on its metadata and result fields */\nexport function generationStatus(generation: Generation): GenerationStatus {\n const metadata = generation.metadata ?? {}\n const status = typeof metadata.generationStatus === 'string' ? metadata.generationStatus : ''\n if (status === 'pending' || status === 'running' || status === 'failed' || status === 'succeeded') return status\n return generation.result ? 'succeeded' : 'pending'\n}\n\n/** Resolve and return the first user-safe error message from generation metadata or null if none exist */\nexport function generationError(generation: Generation): string | null {\n const metadata = generation.metadata ?? {}\n if (typeof metadata.providerError === 'string' && metadata.providerError.trim()) {\n return userSafeGenerationMessage(metadata.providerError)\n }\n if (typeof metadata.storageError === 'string' && metadata.storageError.trim()) {\n return metadata.storageError\n }\n return null\n}\n\nfunction generationClientRequestId(generation: Generation): string | null {\n const metadata = generation.metadata ?? {}\n return typeof metadata.clientRequestId === 'string' && metadata.clientRequestId.trim()\n ? metadata.clientRequestId\n : null\n}\n\nfunction generationBatchSlotKey(generation: Generation): string | null {\n const metadata = generation.metadata ?? {}\n const batchId = typeof metadata.batchId === 'string' && metadata.batchId.trim() ? metadata.batchId : null\n return batchId && typeof metadata.outputIndex === 'number'\n ? `${batchId}:${metadata.outputIndex}`\n : null\n}\n\n/** Resolve a unique merge key from a generation using batch slot or client request ID */\nexport function generationMergeKey(generation: Generation): string | null {\n return generationBatchSlotKey(generation) ?? generationClientRequestId(generation)\n}\n\n/** Merge a new generation into the current list by replacing or prepending it based on matching keys */\nexport function mergeLiveGeneration(current: Generation[], generation: Generation): Generation[] {\n const mergeKey = generationMergeKey(generation)\n const existingIndex = current.findIndex((item) => (\n item.id === generation.id\n || (mergeKey && generationMergeKey(item) === mergeKey)\n ))\n if (existingIndex === -1) return [generation, ...current]\n\n const next = [...current]\n next[existingIndex] = generation\n return next\n}\n\n// Overlay in-flight `live` generations on the loader's rows: each live row leads\n// (prefer the matching loader row by merge key / id so it carries the freshest\n// server state), then the remaining loader rows that no live row already\n// represents — deduped by BOTH id and merge key so a server row and its\n// optimistic twin never both appear. Returns `loader` unchanged when nothing is\n// live. Drives the canvas, library, and polling off one list.\n/** Merge two Generation arrays prioritizing live entries and matching by merge keys or IDs */\nexport function mergeLoaderAndLive(loader: Generation[], live: Generation[]): Generation[] {\n if (live.length === 0) return loader\n const leading = live.map((generation) => {\n const mergeKey = generationMergeKey(generation)\n return mergeKey\n ? loader.find((gen) => generationMergeKey(gen) === mergeKey) ?? generation\n : loader.find((gen) => gen.id === generation.id) ?? generation\n })\n const leadingIds = new Set(leading.map((gen) => gen.id))\n const leadingMergeKeys = new Set(leading\n .map((gen) => generationMergeKey(gen))\n .filter((id): id is string => Boolean(id)))\n return [\n ...leading,\n ...loader.filter((gen) => (\n !leadingIds.has(gen.id)\n && !leadingMergeKeys.has(generationMergeKey(gen) ?? '')\n )),\n ]\n}\n\n/** Determine if a generation ID indicates a local generation */\nexport function isLocalGeneration(generation: Generation): boolean {\n return generation.id.startsWith('local-')\n}\n\nfunction generationOutputIndex(generation: Generation): number {\n const value = generation.metadata?.outputIndex\n return typeof value === 'number' ? value : 0\n}\n\n// The most-recent run: all generations sharing the leading item's clientRequestId\n// (a multi-image batch), ordered by output slot. Falls back to the single leading\n// item when no request id is present. Drives the result canvas.\n/** Resolve and return the latest batch of generations grouped and sorted by client request ID and output index */\nexport function latestBatchOf(generations: Generation[]): Generation[] {\n const first = generations[0]\n if (!first) return []\n const key = generationClientRequestId(first)\n const batch = key\n ? generations.filter((generation) => generationClientRequestId(generation) === key)\n : [first]\n return [...batch].sort((a, b) => generationOutputIndex(a) - generationOutputIndex(b))\n}\n\n/** Resolve a user-safe generation message by filtering sensitive or error-related content */\nexport function userSafeGenerationMessage(message?: string): string {\n if (!message) return 'Generation failed'\n if (/Tangle API key is invalid or expired/i.test(message)) return message\n if (/(api[_ -]?key|secret|token|credential|env|configured|configuration)/i.test(message)) {\n return 'Generation failed'\n }\n return message\n}\n\n/** Generate content optimistically based on input parameters and optional model and output details */\nexport function optimisticGeneration({\n type,\n prompt,\n model,\n clientRequestId,\n outputIndex,\n outputCount,\n}: {\n type: GenerationType\n prompt: string\n model?: string\n clientRequestId: string\n outputIndex?: number\n outputCount?: number\n}, aspectRatio?: number): Generation {\n const batchId = outputIndex == null ? undefined : clientRequestId\n const aspectRatioMetadata = Number.isFinite(aspectRatio) && (aspectRatio ?? 0) > 0\n ? { aspectRatio }\n : {}\n return {\n id: outputIndex == null ? `local-${clientRequestId}` : `local-${clientRequestId}-${outputIndex}`,\n type,\n prompt,\n result: null,\n model: model ?? null,\n cost: null,\n createdAt: new Date(),\n metadata: {\n generationStatus: 'pending',\n provider: type,\n clientRequestId,\n batchId,\n outputIndex,\n outputCount,\n ...aspectRatioMetadata,\n },\n }\n}\n\n/** Mark a generation as failed with updated status and error information */\nexport function failedOptimisticGeneration(generation: Generation): Generation {\n return {\n ...generation,\n metadata: {\n ...(generation.metadata ?? {}),\n generationStatus: 'failed',\n providerError: 'Generation failed',\n },\n }\n}\n\n/** Normalize a value to a finite integer within the allowed image count range */\nexport function normalizeImageCount(value: unknown): number {\n const numeric = typeof value === 'number' ? value : Number(value)\n if (!Number.isFinite(numeric)) return MIN_IMAGE_COUNT\n return Math.min(Math.max(Math.trunc(numeric), MIN_IMAGE_COUNT), MAX_IMAGE_COUNT)\n}\n\n/** Resolve a generation's batch identity, preferring the server batch id. */\nexport function generationBatchKey(generation: Generation): string {\n const metadata = generation.metadata ?? {}\n if (typeof metadata.batchId === 'string' && metadata.batchId.trim()) return metadata.batchId\n if (typeof metadata.clientRequestId === 'string' && metadata.clientRequestId.trim()) return metadata.clientRequestId\n return generation.id\n}\n\n/** Resolve the stored media asset id, when present. */\nexport function generationAssetId(generation: Generation): string | null {\n const value = generation.metadata?.assetId\n return typeof value === 'string' && value.trim() ? value : null\n}\n\n/** Select and order all outputs belonging to a generation batch. */\nexport function generationsInBatch(generations: readonly Generation[], batchKey: string): Generation[] {\n return generations\n .map((generation, inputIndex) => ({ generation, inputIndex }))\n .filter(({ generation }) => generationBatchKey(generation) === batchKey)\n .sort((left, right) => {\n const leftIndex = left.generation.metadata?.outputIndex\n const rightIndex = right.generation.metadata?.outputIndex\n const leftOrder = typeof leftIndex === 'number' && Number.isFinite(leftIndex) ? leftIndex : Infinity\n const rightOrder = typeof rightIndex === 'number' && Number.isFinite(rightIndex) ? rightIndex : Infinity\n return leftOrder - rightOrder || left.inputIndex - right.inputIndex\n })\n .map(({ generation }) => generation)\n}\n\nfunction ratioFromDimensions(value: string, separator: 'size' | 'aspect'): number | undefined {\n const match = separator === 'size'\n ? /^(\\d+)[x×](\\d+)$/.exec(value)\n : /^(\\d+):(\\d+)$/.exec(value)\n if (!match) return undefined\n const width = Number(match[1])\n const height = Number(match[2])\n return width > 0 && height > 0 ? width / height : undefined\n}\n\nfunction roundedRatio(value: number): number {\n return +value.toFixed(4)\n}\n\n/** Resolve the best available aspect ratio for a generation row. */\nexport function generationAspectRatio(generation: Generation): number {\n const metadata = generation.metadata ?? {}\n if (typeof metadata.aspectRatio === 'number'\n && Number.isFinite(metadata.aspectRatio)\n && metadata.aspectRatio > 0) {\n return roundedRatio(metadata.aspectRatio)\n }\n if (typeof metadata.size === 'string') {\n const ratio = ratioFromDimensions(metadata.size, 'size')\n if (ratio !== undefined) return roundedRatio(ratio)\n }\n if (typeof metadata.aspectRatio === 'string') {\n const ratio = ratioFromDimensions(metadata.aspectRatio, 'aspect')\n if (ratio !== undefined) return roundedRatio(ratio)\n }\n if (generation.type === 'video') return roundedRatio(16 / 9)\n if (generation.type === 'speech' || generation.type === 'audio') return 3.2\n return 1\n}\n\n/** Resolve a requested lane's aspect ratio from its selected options. */\nexport function aspectRatioFromOptions(\n type: GenerationType,\n options: { size?: string; aspectRatio?: string },\n): number | undefined {\n if (type === 'speech') return 3.2\n const ratio = type === 'image'\n ? options.size ? ratioFromDimensions(options.size, 'size') : undefined\n : type === 'video'\n ? options.aspectRatio ? ratioFromDimensions(options.aspectRatio, 'aspect') : undefined\n : undefined\n return ratio === undefined ? undefined : roundedRatio(ratio)\n}\n\n/** Choose the default vault folder shared by a homogeneous media selection. */\nexport function defaultVaultPathFor(generations: readonly Generation[]): string {\n const types = new Set(generations.map((generation) => generation.type))\n if (types.size !== 1) return 'generated/media'\n const [type] = types\n return type !== undefined && isGenerationType(type) ? outputPathFor(type) : 'generated/media'\n}\n\n/** Normalize a user-entered relative vault folder or reject an unsafe path. */\nexport function normalizeVaultPath(input: string): string | null {\n const path = input.trim().replace(/^\\/+|\\/+$/g, '').replace(/\\/{2,}/g, '/')\n if (!path) return null\n const segments = path.split('/')\n return segments.some((segment) => segment === '.' || segment === '..' || segment.includes('\\\\'))\n ? null\n : path\n}\n\n/** Append a page while preserving the first row seen for each id. */\nexport function mergeGenerationPages(prev: readonly Generation[], next: readonly Generation[]): Generation[] {\n const seen = new Set(prev.map((generation) => generation.id))\n const merged = [...prev]\n for (const generation of next) {\n if (seen.has(generation.id)) continue\n seen.add(generation.id)\n merged.push(generation)\n }\n return merged\n}\n\n/** Resolve only the human-readable media specification fields a row carries. */\nexport function generationSpecSegments(generation: Generation): string[] {\n const metadata = generation.metadata ?? {}\n const segments: string[] = []\n if (typeof metadata.size === 'string') segments.push(metadata.size.replace(/x/g, '×'))\n if (typeof metadata.resolution === 'string') segments.push(metadata.resolution)\n if (typeof metadata.aspectRatio === 'string' && /^(\\d+):(\\d+)$/.test(metadata.aspectRatio)) {\n segments.push(metadata.aspectRatio)\n }\n if (typeof metadata.duration === 'string') {\n segments.push(metadata.duration)\n } else if (typeof metadata.durationSeconds === 'number' && Number.isFinite(metadata.durationSeconds)) {\n const seconds = Math.max(0, Math.floor(metadata.durationSeconds))\n segments.push(`${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`)\n }\n if (typeof metadata.voice === 'string') segments.push(metadata.voice)\n return segments\n}\n"],"mappings":";AA0DO,IAAM,mBAA8C,CAAC,SAAS,SAAS,UAAU,UAAU,eAAe;AAG1G,SAAS,iBAAiB,OAAwC;AACvE,SAAQ,iBAAuC,SAAS,KAAK;AAC/D;AAGO,IAAM,kBAAkB;AAExB,IAAM,kBAAkB;AAGxB,SAAS,aAAa,MAAoC;AAC/D,MAAI,CAAC,KAAM,QAAO;AAClB,QAAM,MAAM,KAAK,IAAI;AACrB,QAAM,OAAO,MAAM,IAAI,KAAK,IAAI,EAAE,QAAQ;AAC1C,QAAM,UAAU,KAAK,MAAM,OAAO,GAAK;AACvC,MAAI,UAAU,EAAG,QAAO;AACxB,MAA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