Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.
TypeScript agentic-aiaiai-agentsai-videocompilerdslffmpeggenerative-aillmmarkup-languagemonorepoplugin-systemprogramming-languagetext-to-videotypescriptvideovideo-automationvideo-clonevideo-editingvideo-generation
refactor(studio): make authoring execution runtime-owned
kashorinf15b1d46f811
diff --git a/docs/guide/packages.md b/docs/guide/packages.mdindex a66b58d3..63864f5f 100644--- a/docs/guide/packages.md+++ b/docs/guide/packages.md@@ -245,7 +245,7 @@ A physical package may expose independently activated facets:| `credential-store` | resolves explicitly named credentials | secret storage | Runtime Profile || `result-repository` | completed Build Results | project history storage | project `hypit.results.json` || `infrastructure` | Runtime Host, Scheduler and Worker implementation | persistence, scheduling | application Distribution |-| `application` | Host-specific interpretation such as a Studio Track Companion | only that application's UI/operations | explicit application profile |+| `application` | Host-specific interpretation such as a Studio Track Companion | only that application's UI/operations | Distribution or selected Source package |A source `<import>` activates only author facets. It never grants network, filesystem, process,credential or queue authority.@@ -261,7 +261,7 @@ installs packages and owns their versions and integrity. Each owner has one expl| Source imports | Frontends, Surfaces, Producers and Validators || Runtime Profile `credentials.*.use` / `endpoints.*.use` | Credential Stores and Provider Endpoints || Project Result config `use` | one Build Result Repository |-| Studio Profile `companionPackages` | project Companion packages selected for that Studio session |+| Studio Distribution + selected Source packages | official Companions plus project Companions used by that Source closure |A Source import never grants network, filesystem, process, credential or queue authority. Thoseremain available only to the Runtime Host and packages explicitly selected at environmentaldiff --git a/docs/guide/providers.md b/docs/guide/providers.mdindex 5de04afe..67ec3d02 100644--- a/docs/guide/providers.md+++ b/docs/guide/providers.md@@ -145,8 +145,12 @@ url }` on `defineEndpointPackage`, pointing at the Provider's own public price pruns on this machine declares `pricing: { kind: "local" }`. Hypit never copies or interprets prices;`hypit plan --runtime <profile>` prints the Endpoint behind each request. Local work is marked local;Provider work carries the Provider's price page so the Agent can read the source before a paid Build.-An undeclared price source is reported as unknown. When the complete request already exists, planning-also applies that Endpoint's ordinary `supports` check; it does not maintain a second selection table.+An undeclared price source is reported as unknown. Planning applies the selected Endpoint's ordinary+`supports` check and does not maintain a second selection table. When an upstream file will only exist+during the Build, the capability package reconstructs the authored+request parameters and leaves that file as a symbolic Resource slot. The same `supports` predicate still+runs before the Build is queued. A package that cannot describe the request stops planning instead of+falling back to capability-only selection.## 5. Declare a Managed Program when neededdiff --git a/docs/quickstart/preview.md b/docs/quickstart/preview.mdindex 7b24a0f3..8247ff37 100644--- a/docs/quickstart/preview.md+++ b/docs/quickstart/preview.md@@ -7,7 +7,7 @@ description: Open a satisfied Run, inspect its picture and timeline, and edit reHypit Studio opens one `.svrun`, traces its Film or Render target back to explainable Semantic and Track projections, and presents four regions: Source at the upper left, Preview in the center, Inspector at the upper right, and Timeline below.-Studio never invokes a Provider or creates a Build. Generated material must already be selected by the Run as a real Candidate, either from a project file or from a Record accepted by an earlier Build and referenced through `<build-record>`. The display closure may contain no unresolved Need. Missing facts fail explicitly; Studio does not guess material or create placeholders.+Studio never submits generation or creates a Build. Generated material must be selected explicitly by the Run: from a project file, an earlier Build through `<build-record>`, or an ordinary stand-in Fragment selected with `satisfy`. Studio may ask the selected Runtime Profile to execute exact media Needs whose Provider marks them safe for transient authoring, such as inspection and normalization. It does not infer that permission from pricing, choose another Candidate or invent a placeholder. Other Needs fail with their capability named.```bashhypit-studio --run examples/all-components-preview/studio.svrun --workspace .@@ -17,7 +17,7 @@ hypit-studio --run examples/all-components-preview/studio.svrun --workspace .| Argument | Meaning || --- | --- || `--run <build.svrun>` | Run Source to open. Required. |-| `--runtime <hypit.runtime.json>` | Optional Runtime Profile used only to show active `BuildView` and Operation information. Historical Results and `<build-record>` come from the project Result Repository. |+| `--runtime <hypit.runtime.json>` | Runtime Profile used for transient media execution and active `BuildView` information. Historical Results and `<build-record>` still come from the project Result Repository. || `--workspace <directory>` | Source access and writeback boundary; defaults to the Run directory. || `--port <number>` | HTTP port; defaults to `5179`. |@@ -29,8 +29,8 @@ Studio requires:- a real Film or Render target;- a traceable Semantic Track and display Tracks;-- satisfied material Candidates;-- a display closure completed by deterministic Producers.+- explicitly selected material Candidates;+- a display closure completed by deterministic Producers and transient capabilities declared by their Providers.Studio refuses a Run that supplies only an opaque finished movie or whose display graph still requires external generation. It edits the current author graph and Tracks; it does not reconstruct a project from final pixels.@@ -67,7 +67,7 @@ Studio exposes two structured author mutations:- timeline gestures submit `timeline.adjust`;- Inspector fields submit `parameter.adjust`.-They follow the executed lineage selected by the Run to a real SVML or SVS preimage. Studio recompiles with the same Run after a change. It publishes the new picture only on success; on failure it restores the files and reports the domain error. It creates no hidden Build, invokes no Provider, and never turns a Selection into an anonymous frame span.+They follow the executed lineage selected by the Run to a real SVML or SVS preimage. Studio recompiles with the same Run after a change. It publishes the new picture only on success; on failure it restores the files and reports the domain error. It creates no hidden Build, submits no generation, and never turns a Selection into an anonymous frame span.The complete selection, projection, consumption and writeback model is documented in [Studio Temporal Lineage](../guide/studio-temporal-windows.md).diff --git a/docs/zh/guide/packages.md b/docs/zh/guide/packages.mdindex 6b562e34..9f25fa68 100644--- a/docs/zh/guide/packages.md+++ b/docs/zh/guide/packages.md@@ -226,7 +226,7 @@ packages/example/| `credential-store` | 解析被显式命名的凭据 | 密钥存储 | Runtime Profile || `result-repository` | 已结束的 Build Result | 项目历史存储 | 项目 `hypit.results.json` || `infrastructure` | Runtime Host、Scheduler 与 Worker 实现 | 持久化、调度 | 应用 Distribution |-| `application` | Studio Track Companion 等特定应用解释 | 仅该应用的 UI/操作 | 显式应用 profile |+| `application` | Studio Track Companion 等特定应用解释 | 仅该应用的 UI/操作 | Distribution 或已选 Source 包 |源码中的 `<import>` 只会 activate author facet。它绝不授予网络、文件系统、进程、凭据或队列权限。@@ -241,7 +241,7 @@ Hypit 不维护中央包注册表,也不维护自定义包锁。npm 或 pnpm| Source import | Frontend、Surface、Producer、Validator || Runtime Profile 的 `credentials.*.use` / `endpoints.*.use` | Credential Store 与 Provider Endpoint || 项目 Result 配置的 `use` | 一个 Build Result Repository |-| Studio Profile 的 `companionPackages` | 当前 Studio 会话显式选择的项目 Companion 包 |+| Studio Distribution + 已选 Source 包 | 官方 Companion 与当前 Source 实际使用的项目 Companion |Source import 绝不授予网络、文件系统、进程、凭据或队列权限;这些权限只属于 RuntimeHost 以及在环境边界被显式选择的包。diff --git a/docs/zh/guide/providers.md b/docs/zh/guide/providers.mdindex ef09e187..fb3d90ec 100644--- a/docs/zh/guide/providers.md+++ b/docs/zh/guide/providers.md@@ -133,7 +133,7 @@ Activation 还可以返回 `diagnose(context)`。它只会在用户显式运行Runtime 会先解析该 Endpoint 自己声明的凭据槽。它可以对真实服务做一次有界只读请求,例如读取已认证账户的模型目录;Build 预检不能调用它,它也绝不能提交生成任务。-收费的 Provider 只声明一件事:价格发布在哪里。在 `defineEndpointPackage` 上写 `pricing: { kind: "page", url }`,指向 Provider 自己的公开价格页;在本机运行的 Provider 声明 `pricing: { kind: "local" }`。Hypit 不复制也不解释价格;`hypit plan --runtime <profile>` 会列出每个请求的 Endpoint,本地工作明确标成本地,Provider 工作附带它自己的价格页,Agent 在付费 Build 之前去原始页面读价。未声明价格来源的会被报告为未知。当完整请求已经存在时,Plan 也会执行同一个 Endpoint 的普通 `supports` 检查,不维护第二张选择表。+收费的 Provider 只声明一件事:价格发布在哪里。在 `defineEndpointPackage` 上写 `pricing: { kind: "page", url }`,指向 Provider 自己的公开价格页;在本机运行的 Provider 声明 `pricing: { kind: "local" }`。Hypit 不复制也不解释价格;`hypit plan --runtime <profile>` 会列出每个请求的 Endpoint,本地工作明确标成本地,Provider 工作附带它自己的价格页,Agent 在付费 Build 之前去原始页面读价。未声明价格来源的会被报告为未知。上游文件尚未生成时,能力包仍重建全部作者参数,只把未来文件保留为符号 Resource 槽;同一个 Endpoint 的普通 `supports` 会在 Build 入队前检查这份规格。包无法说明请求时直接停止,不回退成 capability-only 的假验证,也不维护第二张选择表。## 5. 按需声明 Managed Programdiff --git a/docs/zh/quickstart/preview.md b/docs/zh/quickstart/preview.mdindex 5196e40e..cfb0b8f5 100644--- a/docs/zh/quickstart/preview.md+++ b/docs/zh/quickstart/preview.md@@ -7,7 +7,7 @@ description: 打开一份素材已经满足的 Run,检查画面、时间线并Hypit Studio 打开一份 `.svrun`,把它的 Film 或 Render target 回溯到可解释的 Semantic 与 Track 投影,并用四个区域呈现:左上 Source、中上 Preview、右上 Inspector、下方 Timeline。-Studio 不调用 Provider,也不创建 Build。需要生成的素材必须已经由 Run 选择为真实 Candidate:可以是项目文件,也可以是早先 Build 接受并由 `<build-record>` 引用的 Record。显示闭包里不允许残留 Need;缺失关系会明确失败,不猜测素材、不制造占位。+Studio 不提交生成,也不创建 Build。需要生成的素材必须由 Run 明确选择:可以是项目文件、由 `<build-record>` 引用的历史 Build Output,也可以是用 `satisfy` 选择的普通替身 Fragment。Studio 可以请求所选 Runtime Profile 执行 Provider 明确允许临时创作执行的媒体 Need,例如检查和归一化;它不根据价格猜权限、不替换 Candidate,也不暗中制造占位。其余 Need 会带着准确 capability 失败。```bashhypit-studio --run examples/all-components-preview/studio.svrun --workspace .@@ -17,7 +17,7 @@ hypit-studio --run examples/all-components-preview/studio.svrun --workspace .| 参数 | 含义 || --- | --- || `--run <build.svrun>` | 要打开的 Run Source。必填。 |-| `--runtime <hypit.runtime.json>` | 可选,只用于显示活动 `BuildView` 与 Operation;历史 Result 与 `<build-record>` 来自项目 Result Repository。 |+| `--runtime <hypit.runtime.json>` | 用于临时媒体执行和显示活动 `BuildView`;历史 Result 与 `<build-record>` 仍来自项目 Result Repository。 || `--workspace <directory>` | Source 访问与写回边界;默认是 Run 所在目录。 || `--port <number>` | HTTP 端口,默认 `5179`。 |@@ -29,8 +29,8 @@ Studio 需要:- 一个真实存在的 Film 或 Render target;- 可以追溯的 Semantic Track 与可展示 Track;-- 已经满足的素材 Candidate;-- 能由确定性 Producer 完成的显示闭包。+- 明确选择的素材 Candidate;+- 能由确定性 Producer 和 Provider 声明的临时能力完成的显示闭包。如果 Run 只提供一个不透明成片,或某条显示链仍要求外部生成,Studio 会拒绝启动。它编辑的是当前作者图和 Track,不从最终视频反推一份新工程。@@ -67,7 +67,7 @@ Studio 有两类结构化作者操作:- 时间线手势提交 `timeline.adjust`;- Inspector 参数提交 `parameter.adjust`。-它们沿本次 Run 的真实执行谱系找到 SVML/SVS 中的作者逆像。修改后 Studio 使用同一 Run 重新编译;成功才发布新画面,失败就恢复文件并显示真实领域错误。它不会创建隐藏 Build、调用 Provider,或把 Selection 偷换成绝对帧。+它们沿本次 Run 的真实执行谱系找到 SVML/SVS 中的作者逆像。修改后 Studio 使用同一 Run 重新编译;成功才发布新画面,失败就恢复文件并显示真实领域错误。它不会创建隐藏 Build、提交生成,或把 Selection 偷换成绝对帧。选择、投影、消费与写回的完整语义见 [Studio 时间谱系](../guide/studio-temporal-windows.md) 和 [Studio 作者操作](../guide/studio-timeline-operations.md)。diff --git a/packages/background-removal/src/component.ts b/packages/background-removal/src/component.tsindex 74232a31..2182afa0 100644--- a/packages/background-removal/src/component.ts+++ b/packages/background-removal/src/component.ts@@ -1,7 +1,8 @@+import { plannedNeedInputs } from "@hypit/component-kit";import type { ComponentPackage, ProducerHandlerContext } from "@hypit/component-kit";import type { StoredValue } from "@hypit/protocol";-import { backgroundRemovalProducers } from "./manifest.js";+import { backgroundRemovalCapabilities, backgroundRemovalProducers } from "./manifest.js";import { backgroundRemovalRequest } from "./program.js";function blob(value: StoredValue | undefined) {@@ -16,4 +17,16 @@ export const backgroundRemovalComponent = {outputs: {}, needs: { image: backgroundRemovalRequest(blob(inputs.source?.value)) },}),}],+ plannedNeeds: [{+ producer: backgroundRemovalProducers.request,+ port: "image",+ capability: backgroundRemovalCapabilities.remove,+ plan: ({ state, step }) => ({+ constraints: {},+ pendingInputs: plannedNeedInputs(state, step, { source: "image" }),+ }),+ present: (specification) => ({ fields: {}, references: {+ image: specification.pendingInputs.filter((input) => input.role === "image").length,+ } }),+ }],} satisfies ComponentPackage;diff --git a/packages/cli/package.json b/packages/cli/package.jsonindex 11f81e9f..fb0d3002 100644--- a/packages/cli/package.json+++ b/packages/cli/package.json@@ -15,8 +15,6 @@"@hypit/core": "workspace:*","@hypit/driver-node": "workspace:*","@hypit/elaborator": "workspace:*",- "@hypit/generation": "workspace:*",- "@hypit/model-kit": "workspace:*","@hypit/package-loader-node": "workspace:*","@hypit/protocol": "workspace:*","@hypit/run": "workspace:*",diff --git a/packages/cli/src/build-planning.ts b/packages/cli/src/build-planning.tsindex 883ede79..2eb1b85f 100644--- a/packages/cli/src/build-planning.ts+++ b/packages/cli/src/build-planning.ts@@ -2,11 +2,12 @@ import { resolve } from "node:path";import type { NodeCompiledSourceClosure } from "@hypit/compiler-node";import { registerProducerFacets, registerTypeValidatorFacets } from "@hypit/component-kit";+import type {+ PlannedNeedFacet,+ PlannedNeedPresentation,+ PlannedNeedSpecification,+} from "@hypit/component-kit";import { evaluateProducerPlan, ProducerRegistry } from "@hypit/driver-node";-import { isMediaPort } from "@hypit/generation";-import type { GenerationPortTable, GenerationRequestDraft } from "@hypit/generation";-import { exactModelsFromHostFacets, plannedExactModelRequest } from "@hypit/model-kit";-import type { ExactModelEndpoint } from "@hypit/model-kit";import type { NodePackageContribution } from "@hypit/package-loader-node";import type { BuildDefinition, BuildState, CanonicalValue, CapabilityRef } from "@hypit/protocol";import type { NodeRuntimeHost } from "@hypit/runtime-host-node";@@ -69,7 +70,6 @@ export type PlanProviderView = {readonly pricing?: { readonly kind: "page"; readonly url: string } | { readonly kind: "local" };readonly endpoints?: readonly string[];readonly binding?: string;- readonly checked: "request" | "capability";};export type PendingPlanInput = {@@ -87,6 +87,8 @@ export type NeedSummary = {export type EvaluatedPlanNeed = {readonly constraints?: CanonicalValue;+ /** Package-owned support slots; kept separate from the CLI's compact pending-input view. */+ readonly pendingInputs: PlannedNeedSpecification["pendingInputs"];readonly summary?: NeedSummary;readonly pending: readonly PendingPlanInput[];readonly issue?: string;@@ -106,7 +108,6 @@ export type PlanNeedView = {readonly summary?: NeedSummary;readonly pending: readonly PendingPlanInput[];readonly issue?: string;- readonly checked?: "request" | "capability";};function mediaKind(mediaType: string): string {@@ -170,54 +171,39 @@ export function summarizeConstraints(constraints: CanonicalValue): NeedSummary {return { fields: summarizeFields(constraints as Record<string, CanonicalValue>), references };}-/** Exact-model requests are summarized from the model package's port table, not an object-shape guess. */-function summarizeExactModel(- table: GenerationPortTable,- ports: GenerationRequestDraft["ports"],- pending: readonly PendingPlanInput[],-): NeedSummary {+/** Convert a package-owned request presentation into the compact generic CLI view. */+function summarizePresentation(presentation: PlannedNeedPresentation): NeedSummary {const fields: Record<string, string | number | boolean> = {};- const references: Record<string, number> = {};- for (const port of table.ports) {- const values = ports[port.name] ?? [];- if (isMediaPort(port)) {- for (const value of values) {- if (value === null || typeof value !== "object" || Array.isArray(value)) continue;- const role = (value as { readonly role?: unknown }).role;- if (role === "image" || role === "video" || role === "audio") references[role] = (references[role] ?? 0) + 1;- }- continue;- }+ for (const [name, values] of Object.entries(presentation.fields)) {const summarized = values.map((value) => scalarSummary(value as CanonicalValue)).filter((value): value is string | number | boolean => value !== undefined);- if (summarized.length > 0) fields[port.name] = summarized.length === 1 ? summarized[0]! : summarized.map(String).join(", ");- }- for (const item of pending) {- const kind = item.kind ?? "other";- references[kind] = (references[kind] ?? 0) + 1;+ if (summarized.length > 0) fields[name] = summarized.length === 1 ? summarized[0]! : summarized.map(String).join(", ");}- return { fields, references };+ return { fields, references: structuredClone(presentation.references) };}-function exactModels(contributions: readonly NodePackageContribution[]): readonly ExactModelEndpoint[] {- return exactModelsFromHostFacets(contributions.flatMap((item) => item.hostFacets ?? []));+function plannedNeedFacets(contributions: readonly NodePackageContribution[]): readonly PlannedNeedFacet[] {+ return contributions.flatMap((contribution) =>+ (contribution.components ?? []).flatMap((component) => component.plannedNeeds ?? []));}-function exactModelFor(- models: readonly ExactModelEndpoint[],+function plannedNeedFacetFor(+ facets: readonly PlannedNeedFacet[],state: BuildState,stepId: string,+ port: string,capability: CapabilityRef,-): ExactModelEndpoint | undefined {+): PlannedNeedFacet | undefined {const step = state.plan.steps.find((item) => item.id === stepId);if (step === undefined) return undefined;- return models.find((model) => sameRef(model.capability, capability) && sameRef(model.producer, step.producer));+ return facets.find((facet) => facet.port === port+ && sameRef(facet.capability, capability)+ && sameRef(facet.producer, step.producer));}/**- * Evaluate deterministic Producers only. A missing upstream Resource is kept as its direct graph- * edge, not described as missing author intent and never found by searching for a request-looking- * object.+ * Evaluate deterministic Producers only. A missing upstream value is kept as its direct graph edge,+ * not described as missing author intent and never found by searching for a request-looking object.*/export async function evaluatePlanNeeds(definition: BuildDefinition,@@ -237,36 +223,42 @@ export async function evaluatePlanNeeds(const producedBy = new Map(state.plan.steps.flatMap((step) =>Object.values(step.outputs).map((record) => [record, step.id] as const)));const records = new Set(state.records.map((record) => record.id));- const models = exactModels(contributions);+ const facets = plannedNeedFacets(contributions);const result = new Map<string, EvaluatedPlanNeed>();for (const planned of plannedNeeds(state)) {+ const facet = plannedNeedFacetFor(facets, state, planned.step, planned.port, planned.capability);const need = known.get(planned.need);if (need !== undefined) {- const model = exactModelFor(models, state, planned.step, planned.capability);- const exact = model === undefined ? undefined : plannedExactModelRequest(state, planned.step, planned.port, model);+ const specification: PlannedNeedSpecification = { constraints: need.constraints, pendingInputs: [] };result.set(planned.need, {constraints: need.constraints,- summary: model === undefined || exact === undefined+ pendingInputs: [],+ summary: facet?.present === undefined? summarizeConstraints(need.constraints)- : summarizeExactModel(model.ports, exact.ports, []),+ : summarizePresentation(facet.present(specification)),pending: [],});continue;}- const model = exactModelFor(models, state, planned.step, planned.capability);- const exact = model === undefined ? undefined : plannedExactModelRequest(state, planned.step, planned.port, model);- if (model !== undefined && exact !== undefined) {- const pending = exact.pendingMedia.map((item): PendingPlanInput => ({- input: item.port,+ const specification = facet?.plan({ state, step: planned.step, port: planned.port });+ if (facet !== undefined && specification !== undefined) {+ const pending = specification.pendingInputs.map((item): PendingPlanInput => ({+ input: item.input,record: item.record,...(item.sourceStep === undefined ? {} : { sourceStep: item.sourceStep }),- kind: item.role,+ ...(item.role === undefined ? {} : {+ kind: item.role === "image" || item.role === "video" || item.role === "audio" ? item.role : "other",+ }),}));const issue = evaluation.failures.get(planned.step);result.set(planned.need, {- summary: summarizeExactModel(model.ports, exact.ports, pending),+ constraints: specification.constraints,+ pendingInputs: specification.pendingInputs,+ summary: facet.present === undefined+ ? summarizeConstraints(specification.constraints)+ : summarizePresentation(facet.present(specification)),pending,...(issue === undefined ? {} : { issue }),});@@ -282,8 +274,11 @@ export async function evaluatePlanNeeds(});const issue = evaluation.failures.get(planned.step);result.set(planned.need, {+ pendingInputs: [],pending,- ...(issue === undefined ? {} : { issue }),+ issue: issue === undefined+ ? `Package does not describe the complete request for ${capabilityName(planned.capability)} before Build`+ : `${issue}; package also does not describe the complete request for ${capabilityName(planned.capability)} before Build`,});}return { state, needs: result };@@ -295,26 +290,65 @@ export async function describePlanProviders(state: BuildState,evaluated: EvaluatedPlan,): Promise<readonly PlanProviderView[]> {- const requests = plannedNeeds(state).map((planned) => {- const constraints = evaluated.needs.get(planned.need)?.constraints;- return {- request: planned.need,- capability: planned.capability,- returns: planned.returns,- ...(constraints === undefined ? {} : { constraints }),- };+ const planned = plannedNeeds(state);+ const requests = planned.flatMap((item) => {+ const plannedRequest = evaluated.needs.get(item.need);+ const constraints = plannedRequest?.constraints;+ if (plannedRequest === undefined || constraints === undefined) return [];+ return [{+ request: item.need,+ capability: item.capability,+ returns: item.returns,+ constraints,+ ...(plannedRequest.pendingInputs.length === 0 ? {} : {+ pendingInputs: plannedRequest.pendingInputs.map((input) => ({+ input: input.input,+ ...(input.role === undefined ? {} : { role: input.role }),+ })),+ }),+ }];});- return (await host.providers(requests)).map((item) => ({+ const described = (await host.providers(requests)).map((item) => ({request: item.request,capability: capabilityName(item.capability),status: item.status,- checked: item.checked,...(item.endpoint === undefined ? {} : { endpoint: item.endpoint }),...(item.use === undefined ? {} : { use: item.use }),...(item.pricing === undefined ? {} : { pricing: item.pricing }),...(item.endpoints === undefined ? {} : { endpoints: item.endpoints }),...(item.binding === undefined ? {} : { binding: item.binding }),}));+ return planned.map((item) => described.find((provider) => provider.request === item.need) ?? {+ request: item.need,+ capability: capabilityName(item.capability),+ status: "unresolved" as const,+ }).filter((item, index, all) => all.findIndex((candidate) => candidate.request === item.request) === index);+}++/** Refuse a Build before it is queued when any external request is not fully selectable. */+export function assertPlannedRequests(+ state: BuildState,+ evaluated: EvaluatedPlan,+ providers: readonly PlanProviderView[],+): void {+ const byRequest = new Map(providers.map((item) => [item.request, item]));+ const problems = plannedNeeds(state).flatMap((planned) => {+ const issue = evaluated.needs.get(planned.need)?.issue;+ if (issue !== undefined) return [`${planned.step}.${planned.port}: ${issue}`];+ const provider = byRequest.get(planned.need);+ if (provider?.status === "resolved") return [];+ if (provider?.status === "ambiguous") {+ return [`${planned.step}.${planned.port}: several Endpoints accept ${capabilityName(planned.capability)}; bind one in the Runtime Profile`];+ }+ return [`${planned.step}.${planned.port}: no selected Endpoint accepts the complete ${capabilityName(planned.capability)} request`];+ });+ if (problems.length > 0) {+ throw new Error([+ `Build has ${problems.length} external request${problems.length === 1 ? "" : "s"} that cannot be submitted:`,+ ...problems.map((problem) => ` ${problem}`),+ "No Build was queued and no external request was made.",+ ].join("\n"));+ }}export async function preflightPlan(host: NodeRuntimeHost, state: BuildState) {@@ -356,7 +390,6 @@ export function describePlanNeeds(...(found?.summary === undefined ? {} : { summary: found.summary }),pending: found?.pending ?? [],...(found?.issue === undefined ? {} : { issue: found.issue }),- ...(provider?.checked === undefined ? {} : { checked: provider.checked }),};});}diff --git a/packages/cli/src/main.ts b/packages/cli/src/main.tsindex 98005268..fa8b9bec 100644--- a/packages/cli/src/main.ts+++ b/packages/cli/src/main.ts@@ -17,7 +17,7 @@ import { writeCliHelp, writeCliOutput } from "./output.js";import type { CliIo, CliMachineView } from "./output.js";import { parseCommand } from "./arguments.js";import type { CliCommand, RuntimeOption } from "./command.js";-import { assertPreflight, createCatalogDescriptor, describePlanNeeds, describePlanProviders, evaluatePlanNeeds, preflightPlan } from "./build-planning.js";+import { assertPlannedRequests, assertPreflight, createCatalogDescriptor, describePlanNeeds, describePlanProviders, evaluatePlanNeeds, preflightPlan } from "./build-planning.js";import { buildProgressLines, observeBuild } from "./observation.js";import { isProjectResultCommand, runProjectResultCommand } from "./commands/results.js";import { isEnvironmentCommand, runEnvironmentCommand } from "./commands/environment.js";@@ -387,10 +387,14 @@ export async function runCli(catalog.publishedOutputs.some((published) => published.ref.id === forward.output)),},} as const;- const controller = await (await runtimeHost(runtimeProfile)).controller({+ const host = await runtimeHost(runtimeProfile);+ const controller = await host.controller({packageRoot: sourcePackageRoot,});- const preflight = await preflightPlan(await runtimeHost(runtimeProfile), result.state);+ const evaluated = await evaluatePlanNeeds(result.definition, packageContributions);+ const providers = await describePlanProviders(host, evaluated.state, evaluated);+ assertPlannedRequests(evaluated.state, evaluated, providers);+ const preflight = await preflightPlan(host, evaluated.state);// Build is an execution boundary, not a provisioning command. The cheap// preflight must already be clean; `runtime up` is the explicit place for// installing or starting declared programs.diff --git a/packages/cli/src/output.ts b/packages/cli/src/output.tsindex 8e4a8da9..bdd38f5a 100644--- a/packages/cli/src/output.ts+++ b/packages/cli/src/output.ts@@ -104,7 +104,6 @@ export type PlanProvider = {readonly pricing?: { readonly kind: "page"; readonly url: string } | { readonly kind: "local" };readonly endpoints?: readonly string[];readonly binding?: string;- readonly checked: "request" | "capability";};export type PlanOutput = {@@ -151,7 +150,6 @@ export type PlanNeed = {readonly kind?: "image" | "video" | "audio" | "other";}[];readonly issue?: string;- readonly checked?: "request" | "capability";};export type CliMachineView = OperationalMachineView;@@ -359,15 +357,15 @@ const MEASURE = /^(\d+) (words|chars)$/u;/** Text lengths are ranged across a group rather than splitting otherwise identical requests. */function groupKey(need: PlanNeed): string {- const pending = need.pending.map((item) => item.kind ?? "file").sort().join(",");- if (need.summary === undefined) return `?${pending}|${need.issue ?? ""}|${need.checked ?? ""}`;+ const pending = need.pending.map((item) => item.kind ?? "value").sort().join(",");+ if (need.summary === undefined) return `?${pending}|${need.issue ?? ""}`;const fields = Object.entries(need.summary.fields).map(([name, value]) => {const measured = typeof value === "string" ? MEASURE.exec(value) : null;return measured === null ? `${name}=${String(value)}` : `${name}=<${measured[2]}>`;});const references = Object.entries(need.summary.references).map(([kind, count]) => `${kind}=${count}`);- return [...fields, "|", ...references, "|", pending, "|", need.issue ?? "", "|", need.checked ?? ""].join(" ");+ return [...fields, "|", ...references, "|", pending, "|", need.issue ?? ""].join(" ");}function needSummaryText(needs: readonly PlanNeed[]): string {@@ -391,7 +389,7 @@ function needSummaryText(needs: readonly PlanNeed[]): string {.map(([kind, count]) => `${count} ${kind}`);if (references.length > 0) parts.push(`${references.join(" + ")} reference${references.length === 1 && references[0]!.startsWith("1 ") ? "" : "s"}`);const pendingCount = first.pending.length;- if (pendingCount > 0) parts.push(`${pendingCount === 1 ? "file" : `${pendingCount} files`} produced during Build`);+ if (pendingCount > 0) parts.push(`${pendingCount === 1 ? "input" : `${pendingCount} inputs`} produced during Build`);if (first.issue !== undefined) parts.push(`could not inspect: ${first.issue}`);return parts.length === 0 ? "no parameters" : parts.join(" · ");}@@ -405,11 +403,8 @@ function groupedNeedLines(needs: readonly PlanNeed[], colors: Palette, verbose:}return [...groups.values()].map((group) => {const who = group.length === 1 || verbose ? colors.dim(group.map((need) => stepLabel(need.step)).join(", ")) : "";- const verification = verbose && group.some((need) => need.checked === "capability")- ? colors.dim("Endpoint selected by capability; file compatibility is checked before the request is sent")- : "";const count = `×${group.length}`.padStart(4);- return ` ${colors.dim(count)} ${needSummaryText(group)}${who.length === 0 ? "" : ` ${who}`}${verification.length === 0 ? "" : ` ${verification}`}`;+ return ` ${colors.dim(count)} ${needSummaryText(group)}${who.length === 0 ? "" : ` ${who}`}`;});}@@ -422,9 +417,6 @@ function providerGroupKey(provider: PlanProvider): string {pricing: provider.pricing,endpoints: provider.endpoints,binding: provider.binding,- // A resolved request belongs under its Endpoint regardless of whether its file already exists.- // Keep the distinction on each request for verbose honesty, not as another visible Provider.- checked: provider.status === "resolved" ? undefined : provider.checked,});}@@ -464,12 +456,16 @@ function renderPlan(}for (const group of groups.values()) {const item = group[0]!;- const where = item.status === "resolved"+ const requestIssue = (view.machine.needs ?? [])+ .find((need) => need.request === item.request)?.issue;+ const where = requestIssue !== undefined+ ? colors.error("request is not completely described before Build")+ : item.status === "resolved"? `${item.endpoint ?? ""} ${colors.dim(`(${item.use ?? "?"})${item.binding === undefined ? "" : ", bound in the Profile"}`)}`: item.status === "ambiguous"? colors.warning(`${(item.endpoints ?? []).join(", ")} all offer it; add "bindings": { "${item.capability}": "<instance>" } to the Profile`): item.binding === undefined- ? colors.error(item.checked === "request" ? "no selected Endpoint accepts this request" : "no selected Endpoint")+ ? colors.error("no selected Endpoint accepts this request"): colors.error(`bound to ${item.binding}, which does not offer it`);const price = item.pricing === undefined? (item.status === "resolved" ? colors.warning("price source unknown") : undefined)diff --git a/packages/cli/test/output.test.ts b/packages/cli/test/output.test.tsindex 386fa676..5d928a36 100644--- a/packages/cli/test/output.test.ts+++ b/packages/cli/test/output.test.ts@@ -110,15 +110,14 @@ test("plan names the Provider and price page behind each request, and points at{request: "seedance:one",capability: "@hypit/seedance@1#seedance-2-mini",- checked: "capability",status: "resolved",endpoint: "hypihub.default",use: "@hypit/provider-hypihub",pricing: { kind: "page", url: "https://hypit.ai/commercial/pricing/" },},- { request: "media:one", capability: "@hypit/media@1#inspect", checked: "request", status: "resolved", endpoint: "media.local", use: "@hypit/provider-media-local", pricing: { kind: "local" } },- { request: "whisper:one", capability: "@hypit/whisperx@1#whisperx-alignment", checked: "request", status: "resolved", endpoint: "whisperx.remote", use: "@hypit/provider-example" },- { request: "image:one", capability: "@hypit/gpt-image@1#gpt-image-2", checked: "request", status: "unresolved" },+ { request: "media:one", capability: "@hypit/media@1#inspect", status: "resolved", endpoint: "media.local", use: "@hypit/provider-media-local", pricing: { kind: "local" } },+ { request: "whisper:one", capability: "@hypit/whisperx@1#whisperx-alignment", status: "resolved", endpoint: "whisperx.remote", use: "@hypit/provider-example" },+ { request: "image:one", capability: "@hypit/gpt-image@1#gpt-image-2", status: "unresolved" },], needs: [{request: "seedance:one",step: "video::component::presenter.generate",@@ -126,19 +125,18 @@ test("plan names the Provider and price page behind each request, and points atcapability: "@hypit/seedance@1#seedance-2-mini",summary: { fields: { prompt: "42 chars", duration: 10, resolution: "720p" }, references: { image: 1 } },pending: [{ input: "referenceImages", record: "presenter:image", sourceStep: "presenter.generate", kind: "image" }],- checked: "capability",}] } });assert.match(output, /Providers and price pages/u);assert.match(output, /@hypit\/seedance#seedance-2-mini\n\s+hypihub\.default \(@hypit\/provider-hypihub\)\s+·\s+https:\/\/hypit\.ai\/commercial\/pricing\//u);assert.match(output, /media\.local .*·\s+local, no Provider charge/u);assert.match(output, /whisperx\.remote .*·\s+price source unknown/u);assert.match(output, /gpt-image#gpt-image-2\n\s+no selected Endpoint accepts this request\n/u);- assert.match(output, /prompt 42 chars · duration 10 · resolution 720p · 1 image reference · file produced during Build/u);+ assert.match(output, /prompt 42 chars · duration 10 · resolution 720p · 1 image reference · input produced during Build/u);assert.doesNotMatch(output, /Pass --runtime/u);assert.doesNotMatch(output, /seedance@1#/u);const verbose = capture({ ...human, verbose: true }, { kind: "plan", machine: { ...base, providers: [- { request: "seedance:one", capability: "@hypit/seedance@1#seedance-2-mini", checked: "capability", status: "ambiguous", endpoints: ["hypihub.default", "kie.default"] },+ { request: "seedance:one", capability: "@hypit/seedance@1#seedance-2-mini", status: "ambiguous", endpoints: ["hypihub.default", "kie.default"] },] } });assert.match(verbose, /@hypit\/seedance@1#seedance-2-mini\n\s+hypihub\.default, kie\.default all offer it/u);});diff --git a/packages/component-kit/src/index.ts b/packages/component-kit/src/index.tsindex 806e3c13..0a123d41 100644--- a/packages/component-kit/src/index.ts+++ b/packages/component-kit/src/index.ts@@ -1,5 +1,7 @@import type {+ BuildState,CanonicalValue,+ CapabilityRef,InvokeProducerCommand,ProducerRef,StoredValue,@@ -59,6 +61,67 @@ export type ProducerFacet = {readonly handler: ProducerHandler;};+/** One input whose value will exist only after an upstream Build step has run. */+export type PlannedNeedInput = {+ readonly input: string;+ readonly record: string;+ readonly sourceStep?: string;+ /** Capability-owned semantic role when the value represents media, such as image or audio. */+ readonly role?: string;+};++/**+ * The complete support-relevant request known before external work starts. Values produced later+ * are represented by input slots; their eventual StoredValues are execution bindings, not missing+ * author intent. A slot may be a Resource or a structured value.+ */+export type PlannedNeedSpecification = {+ readonly constraints: CanonicalValue;+ readonly pendingInputs: readonly PlannedNeedInput[];+};++/** Package-owned, presentation-neutral reading of one request. */+export type PlannedNeedPresentation = {+ readonly fields: Readonly<Record<string, readonly CanonicalValue[]>>;+ readonly references: Readonly<Record<string, number>>;+};++export type PlannedNeedFacet = {+ readonly producer: ProducerRef;+ readonly port: string;+ readonly capability: CapabilityRef;+ plan(input: {+ readonly state: BuildState;+ readonly step: string;+ readonly port: string;+ }): PlannedNeedSpecification | undefined;+ present?(specification: PlannedNeedSpecification): PlannedNeedPresentation;+};++/** Missing direct inputs of one planned Need, preserved as graph edges rather than guessed values. */+export function plannedNeedInputs(+ state: BuildState,+ stepId: string,+ roles: Readonly<Record<string, string>> = {},+): readonly PlannedNeedInput[] {+ const step = state.plan.steps.find((item) => item.id === stepId);+ if (step === undefined) return [];+ const available = new Set(state.records.map((record) => record.id));+ const producedBy = new Map(state.plan.steps.flatMap((item) =>+ Object.values(item.outputs).map((record) => [record, item.id] as const)));+ return Object.entries(step.inputs).flatMap(([input, record]) => {+ if (available.has(record)) return [];+ const sourceStep = producedBy.get(record);+ const role = roles[input];+ return [{+ input,+ record,+ ...(sourceStep === undefined ? {} : { sourceStep }),+ ...(role === undefined ? {} : { role }),+ }];+ });+}+export function registerProducerFacets(registry: ProducerRegistrar,facets: readonly ProducerFacet[],@@ -87,4 +150,6 @@ export function registerTypeValidatorFacets(export type ComponentPackage = {readonly producers?: readonly ProducerFacet[];readonly validators?: readonly TypeValidatorFacet[];+ /** Planning knowledge owned by the package that declares the external request. */+ readonly plannedNeeds?: readonly PlannedNeedFacet[];};diff --git a/packages/driver-node/src/index.ts b/packages/driver-node/src/index.tsindex 45359007..76f48ad4 100644--- a/packages/driver-node/src/index.ts+++ b/packages/driver-node/src/index.ts@@ -1,10 +1,10 @@export { MemoryResourceStore } from "./resources.js";export { NodeDriver } from "./driver.js";+export type { NodeDriverOptions } from "./driver.js";export { evaluateProducerPlan } from "./planning.js";export type { ProducerPlanEvaluation } from "./planning.js";export {ProducerRegistry,EndpointRegistry,} from "./registry.js";-export type { ResolvableNeed } from "./registry.js";export type * from "./types.js";diff --git a/packages/driver-node/src/registry.ts b/packages/driver-node/src/registry.tsindex 1eecbf54..08e50c30 100644--- a/packages/driver-node/src/registry.ts+++ b/packages/driver-node/src/registry.ts@@ -1,4 +1,5 @@import type {+ EndpointRequest,EndpointRegistrar,EndpointRegistrationOptions,EndpointScheduling,@@ -10,7 +11,6 @@ import type {} from "@hypit/component-kit";import type {CapabilityRef,- Need,ProducerRef,TypeRef,} from "@hypit/protocol";@@ -91,13 +91,9 @@ function verifyEndpointOptions(options: EndpointOptions): void {}/**- * A Need, or the declared shape of one before its constraints exist.- *- * `plan` resolves capabilities before any request has been built, so it may leave `constraints`- * out; an Endpoint's `supports` refinement is then not consulted and several candidates stay- * ambiguous until the Profile binds one or the constraints arrive.+ * Endpoint selection always receives the complete support-relevant request. Upstream graph values+ * may still be pending, but the package that declares the request exposes their semantic slots.*/-export type ResolvableNeed = Pick<Need, "capability"> & Partial<Omit<Need, "capability">>;export class EndpointRegistry implements EndpointRegistrar {readonly #registrations: EndpointRegistration[] = [];@@ -194,11 +190,11 @@ export class EndpointRegistry implements EndpointRegistrar {this.#registrationsByCapability.set(endpointCapabilityKey(capability), registrations);}- resolve(need: ResolvableNeed): EndpointResolution {+ resolve(need: EndpointRequest): EndpointResolution {const key = endpointCapabilityKey(need.capability);const registrations = (this.#registrationsByCapability.get(key) ?? []).filter((registration) =>- (need.returns === undefined || sameRef(registration.returns, need.returns))- && (need.constraints === undefined || (registration.supports?.(need as Need) ?? true)));+ sameRef(registration.returns, need.returns)+ && (registration.supports?.(need) ?? true));const bound = this.#bindings.get(key);if (bound !== undefined) {const chosen = registrations.find((registration) => registration.id === bound);diff --git a/packages/endpoint-kit/README.md b/packages/endpoint-kit/README.mdindex f2ad77b0..ae499aa4 100644--- a/packages/endpoint-kit/README.md+++ b/packages/endpoint-kit/README.md@@ -11,5 +11,17 @@ optional best effort `cancel`. Provider-total and exact-capability resource limiwithout changing Core demand. Each resource declares one limit; asynchronous work retains that slot untilits persisted Operation is terminal.+An individual immediate capability may declare `transient: true`. That permits a Runtime to use the+same handler in a disposable authoring execution with no Build, Result or recoverable Operation. It is a+Provider assertion that the call submits no paid generation and creates no external side effect; it is+independent of pricing metadata and does not promise byte-identical output. The default is Build-only,+and asynchronous capabilities cannot be transient. Its capacity limits apply within one disposable+session; capabilities that require durable quota shared with Builds stay Build-only.+Endpoint packages are selected by a Runtime Profile, never activated by author imports. This packagedepends on no Node filesystem, scheduler implementation or video domain.++`supports` receives one complete support description. For an executing Need, concrete graph values+are already in `constraints`. During pre-Build planning, an upstream value that does not exist yet is+represented by a semantic `pendingInputs` slot instead. A Provider may use the slot's input and+media role to enforce support limits, but it never receives graph traversal rules or future bytes.diff --git a/packages/endpoint-kit/src/index.ts b/packages/endpoint-kit/src/index.tsindex f20219ec..09ccd1d2 100644--- a/packages/endpoint-kit/src/index.ts+++ b/packages/endpoint-kit/src/index.ts@@ -23,6 +23,24 @@ export type EndpointFulfillment = {readonly value: StoredValue;};+/** One future input binding whose value does not exist until an upstream graph step runs. */+export type EndpointInputSlot = {+ readonly input: string;+ readonly role?: string;+};++/**+ * The complete support-relevant request. Execution-only ids and the result Record are deliberately+ * absent. Before a Build, future graph values appear as semantic slots; during execution their+ * concrete values are already present in `constraints` and `pendingInputs` is omitted.+ */+export type EndpointRequest = {+ readonly capability: Need["capability"];+ readonly returns: Need["returns"];+ readonly constraints: Need["constraints"];+ readonly pendingInputs?: readonly EndpointInputSlot[];+};+export type EndpointInvocationContext = {readonly command: FulfillNeedCommand;readonly need: Need;@@ -82,9 +100,16 @@ export type EndpointScheduling = {};export type EndpointRegistrationOptions = {- readonly supports?: (need: Need) => boolean;+ readonly supports?: (request: EndpointRequest) => boolean;readonly scheduling?: EndpointScheduling;readonly credentials?: Readonly<Record<string, CredentialRef>>;+ /**+ * This immediate capability may be evaluated by a disposable authoring session without a+ * Build, Result or recoverable Operation. The Provider is asserting that doing so submits no+ * paid generation and creates no externally visible side effect. It is not a byte-for-byte+ * reproducibility claim.+ */+ readonly transient?: true;};/** Minimal structural port implemented by a trusted execution Host. */@@ -130,7 +155,8 @@ export type EndpointOffer = {readonly capability: CapabilityRef;readonly returns: TypeRef;readonly endpoint: string;- readonly supports?: (need: Need) => boolean;+ readonly supports?: (request: EndpointRequest) => boolean;+ readonly transient?: true;};export type EndpointCredentialDescription = {@@ -145,7 +171,13 @@ export type EndpointCredentialDescription = {type EndpointCapabilityBase = {readonly capability: CapabilityRef;readonly returns: TypeRef;- readonly supports?: (need: Need) => boolean;+ readonly supports?: (request: EndpointRequest) => boolean;+ /**+ * Also allow this capability in a disposable, non-Build authoring execution.+ * The Provider is asserting that it needs no durable or cross-Build capacity+ * admission; declared limits are still honored within that one session.+ */+ readonly transient?: true;/** Stable Provider-local capacity class. Defaults to the capability name. */readonly capacity?: string;/** Exact-capability capacity; the Provider pool keeps its independent total capacity. */@@ -215,6 +247,8 @@ export function defineEndpointPackage(options: DefineEndpointPackageOptions): En}const capacityConcurrency = new Map<string, number>();for (const capability of options.capabilities) {+ assert(capability.transient !== true || capability.lifecycle === "immediate",+ `Endpoint capability ${refKey(capability.capability)} cannot be transient and asynchronous`);const capacity = capability.capacity ?? capability.capability.name;const concurrency = positiveInteger(capability.maxConcurrency ?? options.defaultConcurrency ?? 1,@@ -255,6 +289,7 @@ export function defineEndpointPackage(options: DefineEndpointPackageOptions): Encapability: structuredClone(item.capability),returns: structuredClone(item.returns),...(item.supports === undefined ? {} : { supports: item.supports }),+ ...(item.transient === true ? { transient: true as const } : {}),}));const instance = {id: options.instance,@@ -279,6 +314,7 @@ export function defineEndpointPackage(options: DefineEndpointPackageOptions): En);const common: EndpointRegistrationOptions = {...(capability.supports === undefined ? {} : { supports: capability.supports }),+ ...(capability.transient === true ? { transient: true } : {}),credentials,scheduling: {resources: [diff --git a/packages/endpoint-kit/test/endpoint.test.ts b/packages/endpoint-kit/test/endpoint.test.tsindex b0fbb98c..56246c7c 100644--- a/packages/endpoint-kit/test/endpoint.test.ts+++ b/packages/endpoint-kit/test/endpoint.test.ts@@ -45,6 +45,7 @@ test("one Endpoint definition generates one configured instance and host-neutraldefaultConcurrency: 3,capabilities: [{lifecycle: "immediate",+ transient: true,capability: capabilities.generation,returns: types.generated,capacity: "text-generation",@@ -60,6 +61,7 @@ test("one Endpoint definition generates one configured instance and host-neutralcapability: capabilities.generation,returns: types.generated,endpoint: "example.personal",+ transient: true,}]);const registrations: CapturedRegistration[] = [];@@ -69,6 +71,7 @@ test("one Endpoint definition generates one configured instance and host-neutralassert.deepEqual(registrations[0]?.options.credentials, {apiKey: credentialRef("env", "EXAMPLE_API_KEY"),});+ assert.equal(registrations[0]?.options.transient, true);assert.deepEqual(registrations[0]?.options.scheduling, {resources: [{ id: "pool:example.personal", limit: 3 },@@ -77,6 +80,25 @@ test("one Endpoint definition generates one configured instance and host-neutral});});+test("an asynchronous Endpoint cannot opt into disposable execution", () => {+ assert.throws(() => defineEndpointPackage({+ module: { name: "example.provider", version: "1" },+ facet: "remote",+ instance: "example.remote",+ pool: "example.remote",+ capabilities: [{+ lifecycle: "asynchronous",+ transient: true,+ capability: capabilities.generation,+ returns: types.generated,+ endpoint: {+ start: () => ({ status: "failed", failure: { code: "unused", message: "unused" } }),+ poll: () => ({ status: "failed", failure: { code: "unused", message: "unused" } }),+ },+ }],+ }), /cannot be transient and asynchronous/u);+});+test("wakeAfter turns polling policy into an explicit Runtime wake hint", () => {assert.deepEqual(wakeAfter({ job: "123" }, 5_000, 10_000), {status: "pending",diff --git a/packages/gemini/src/component.ts b/packages/gemini/src/component.tsindex cd93cacc..deaf03ba 100644--- a/packages/gemini/src/component.ts+++ b/packages/gemini/src/component.ts@@ -1,10 +1,11 @@-import type { ComponentPackage, ProducerHandlerContext } from "@hypit/component-kit";+import { plannedNeedInputs } from "@hypit/component-kit";+import type { ComponentPackage, PlannedNeedFacet, ProducerHandlerContext } from "@hypit/component-kit";import { canonicalize } from "@hypit/protocol";-import type { StoredValue } from "@hypit/protocol";+import type { BuildState, CanonicalValue, StoredValue } from "@hypit/protocol";import type { Text } from "@hypit/text";import { verifyText } from "@hypit/text";-import { geminiModels, geminiProducers, geminiTypes } from "./manifest.js";+import { geminiCapabilities, geminiModels, geminiProducers, geminiTypes } from "./manifest.js";import { sealGeminiRequest, verifyGeminiRequest } from "./request.js";import type { GeminiRequest } from "./request.js";import { verifyVisualObservation } from "./observation.js";@@ -20,6 +21,73 @@ function text(value: StoredValue | undefined, subject: string): string {return result.value;}+function plannedGeminiText(state: BuildState, requestStep: string): {+ readonly instruction: string;+ readonly prompt: string;+} | undefined {+ const producedBy = new Map(state.plan.steps.flatMap((step) =>+ Object.values(step.outputs).map((record) => [record, step] as const)));+ const request = state.plan.steps.find((step) => step.id === requestStep);+ let draft = request?.inputs.request;+ const seen = new Set<string>();+ while (draft !== undefined && !seen.has(draft)) {+ seen.add(draft);+ const existing = state.records.find((record) => record.id === draft)?.value;+ if (existing?.kind === "inline") {+ const value = existing.value as Readonly<Record<string, CanonicalValue>>;+ if (typeof value.instruction === "string" && typeof value.prompt === "string") {+ return { instruction: value.instruction, prompt: value.prompt };+ }+ }+ const producer = producedBy.get(draft);+ if (producer === undefined) return undefined;+ if (producer.producer.name === geminiProducers.finalize.name) {+ draft = producer.inputs.draft;+ continue;+ }+ if (producer.producer.name === geminiProducers.bindMedia.name) {+ draft = producer.inputs.draft;+ continue;+ }+ if (producer.producer.name !== geminiProducers.start.name) return undefined;+ const readText = (input: string): string | undefined => {+ const record = producer.inputs[input];+ const stored = record === undefined ? undefined : state.records.find((item) => item.id === record)?.value;+ if (stored?.kind !== "inline" || stored.value === null || typeof stored.value !== "object" || Array.isArray(stored.value)) return undefined;+ const value = (stored.value as Readonly<Record<string, CanonicalValue>>).value;+ return typeof value === "string" ? value : undefined;+ };+ const instruction = readText("instruction");+ const prompt = readText("prompt");+ return instruction === undefined || prompt === undefined ? undefined : { instruction, prompt };+ }+ return undefined;+}++const plannedGeminiNeeds: readonly PlannedNeedFacet[] = geminiModels.map((model) => ({+ producer: geminiProducers[model],+ port: "observation",+ capability: geminiCapabilities[model],+ plan({ state, step }) {+ const authored = plannedGeminiText(state, step);+ if (authored === undefined) return undefined;+ return {+ constraints: authored,+ pendingInputs: plannedNeedInputs(state, step),+ };+ },+ present(specification) {+ const fields = specification.constraints as Readonly<Record<string, CanonicalValue>>;+ return {+ fields: {+ ...(typeof fields.instruction === "string" ? { instruction: [fields.instruction] } : {}),+ ...(typeof fields.prompt === "string" ? { prompt: [fields.prompt] } : {}),+ },+ references: {},+ };+ },+}));+export const geminiComponent = {validators: [{ type: geminiTypes.request, handler: ({ value }) => verifyGeminiRequest(inline(value, "Gemini request")) },@@ -70,4 +138,5 @@ export const geminiComponent = {},})),],+ plannedNeeds: plannedGeminiNeeds,} satisfies ComponentPackage;diff --git a/packages/image-compose/src/component.ts b/packages/image-compose/src/component.tsindex e9e6e763..a79e0378 100644--- a/packages/image-compose/src/component.ts+++ b/packages/image-compose/src/component.ts@@ -1,7 +1,9 @@+import { plannedNeedInputs } from "@hypit/component-kit";import type { ComponentPackage, ProducerHandlerContext } from "@hypit/component-kit";-import type { BlobRef, StoredValue } from "@hypit/protocol";+import type { BlobRef, CanonicalValue, StoredValue } from "@hypit/protocol";import { canonicalize } from "@hypit/protocol";import { rasterComposeRequest } from "@hypit/raster";+import { rasterCapabilities } from "@hypit/raster";import type { CanvasSpace, SpatialFrame } from "@hypit/spatial";import { imageComposeProducers, imageComposeTypes } from "./manifest.js";@@ -64,4 +66,35 @@ export const imageComposeComponent = {type: imageComposeTypes.layerSet,handler: ({ value }) => assertImageComposeLayerSet(inline<ImageComposeLayerSet>(value, "ImageComposeLayerSet")),}],+ plannedNeeds: [{+ producer: imageComposeProducers.request,+ port: "image",+ capability: rasterCapabilities.execute,+ plan({ state, step }) {+ const operation = state.plan.steps.find((item) => item.id === step);+ if (operation === undefined) return undefined;+ const read = (input: string) => {+ const record = operation.inputs[input];+ const value = record === undefined ? undefined : state.records.find((item) => item.id === record)?.value;+ return value?.kind === "inline" ? value.value : undefined;+ };+ const canvas = read("canvas");+ const options = read("options");+ if (canvas === undefined || options === undefined) return undefined;+ return {+ constraints: { kind: "compose", canvas, options },+ pendingInputs: plannedNeedInputs(state, step),+ };+ },+ present(specification) {+ const constraints = specification.constraints as Readonly<Record<string, CanonicalValue>>;+ const canvas = constraints.canvas as Readonly<Record<string, CanonicalValue>> | undefined;+ return {+ fields: typeof canvas?.widthPx === "number" && typeof canvas.heightPx === "number"+ ? { canvas: [`${canvas.widthPx}×${canvas.heightPx}`] }+ : {},+ references: {},+ };+ },+ }],} satisfies ComponentPackage;diff --git a/packages/image-transform/src/component.ts b/packages/image-transform/src/component.tsindex 7a3d7001..e2442293 100644--- a/packages/image-transform/src/component.ts+++ b/packages/image-transform/src/component.ts@@ -1,9 +1,11 @@+import { plannedNeedInputs } from "@hypit/component-kit";import type { ComponentPackage } from "@hypit/component-kit";-import type { BlobRef, StoredValue } from "@hypit/protocol";+import type { BlobRef, CanonicalValue, StoredValue } from "@hypit/protocol";import { canonicalize } from "@hypit/protocol";import { rasterTransformRequest } from "@hypit/raster";import { imageTransformProducers, imageTransformTypes } from "./manifest.js";+import { rasterCapabilities } from "@hypit/raster";import { verifyImageTransformProgram } from "./program.js";import type { ImageTransformProgram } from "./types.js";@@ -34,4 +36,32 @@ export const imageTransformComponent = {return { outputs: {}, needs: { image: canonicalize(rasterTransformRequest(source, program.operations)) } };},}],+ plannedNeeds: [{+ producer: imageTransformProducers.request,+ port: "image",+ capability: rasterCapabilities.execute,+ plan({ state, step }) {+ const operation = state.plan.steps.find((item) => item.id === step);+ const programRecord = operation?.inputs.program;+ const program = programRecord === undefined+ ? undefined+ : state.records.find((record) => record.id === programRecord)?.value;+ if (program?.kind !== "inline") return undefined;+ return {+ constraints: { kind: "transform", program: program.value as CanonicalValue },+ pendingInputs: plannedNeedInputs(state, step, { source: "image" }),+ };+ },+ present(specification) {+ const fields = specification.constraints as Readonly<Record<string, CanonicalValue>>;+ const program = fields.program as Readonly<Record<string, CanonicalValue>> | undefined;+ const operations = Array.isArray(program?.operations) ? program.operations.length : undefined;+ return {+ fields: operations === undefined ? {} : { operations: [operations] },+ references: {+ image: specification.pendingInputs.filter((input) => input.role === "image").length,+ },+ };+ },+ }],} satisfies ComponentPackage;diff --git a/packages/media-pipeline/README.md b/packages/media-pipeline/README.mdindex 5e91acad..16ca060c 100644--- a/packages/media-pipeline/README.md+++ b/packages/media-pipeline/README.md@@ -71,6 +71,11 @@ frame and letterboxed. Inspection and normalization remain the same explicit steor generated moving video, so the Blob can serve B-roll through Normalize, or continue into eitherestimated or measured A-roll semantics afterward.+The package also exposes its one-picture Fragment as+`@hypit/media-pipeline@1#still-video`, so a Run may select the same ordinary+StillVideo branch as a Candidate. Its inputs are `duration`, `clock`, `layout`+and `source-0`; choosing it remains an explicit `candidate` / `satisfy` decision.+Four ordinary author operations reuse that same inspection/execution boundary:```xmldiff --git a/packages/media-pipeline/package.json b/packages/media-pipeline/package.jsonindex 7f1ae587..0b32f752 100644--- a/packages/media-pipeline/package.json+++ b/packages/media-pipeline/package.json@@ -19,6 +19,7 @@"@hypit/narrative": "workspace:*","@hypit/program-space": "workspace:*","@hypit/protocol": "workspace:*",+ "@hypit/run": "workspace:*","@hypit/speech": "workspace:*","@hypit/svs": "workspace:*","@hypit/markup": "workspace:*"diff --git a/packages/media-pipeline/src/activation.ts b/packages/media-pipeline/src/activation.tsindex 631664c4..18524f95 100644--- a/packages/media-pipeline/src/activation.ts+++ b/packages/media-pipeline/src/activation.ts@@ -1,4 +1,5 @@import { createMarkupSurfaceHostFacet } from "@hypit/markup";+import { createRunFragmentHostFacet } from "@hypit/run";import {decodeSynchronizedMediaSurface,decodeStillVideoSurface,@@ -9,13 +10,17 @@ import {mediaPipelineManifest,mediaPipelineModuleRef,mediaPipelineMarkupSurfaces,+ stillVideoFragment,} from "./index.js";export const hypitPackage = {format: "hypit.node-package@1" as const,modules: [{ manifest: mediaPipelineManifest }],components: [mediaPipelineComponent],- hostFacets: [createMarkupSurfaceHostFacet({+ hostFacets: [createRunFragmentHostFacet({+ name: "@hypit/media-pipeline@1",+ fragments: { "still-video": stillVideoFragment },+ }), createMarkupSurfaceHostFacet({module: mediaPipelineModuleRef,declaration: mediaPipelineMarkupSurfaces.find((item) => item.name === "synchronized-media")!,handler: decodeSynchronizedMediaSurface,diff --git a/packages/media-pipeline/src/component.ts b/packages/media-pipeline/src/component.tsindex 48c14038..e7a67a3c 100644--- a/packages/media-pipeline/src/component.ts+++ b/packages/media-pipeline/src/component.ts@@ -1,5 +1,6 @@import { mediaComponent } from "@hypit/media";-import type { ComponentPackage } from "@hypit/component-kit";+import { plannedNeedInputs } from "@hypit/component-kit";+import type { ComponentPackage, PlannedNeedFacet } from "@hypit/component-kit";import { synchronizedMediaSampleFrames, verifyMediaInspection, verifyMediaStreamSelection, verifyMuxedMedia, verifyRenderedVisual, verifySynchronizedMedia, verifyTimelineAudio } from "@hypit/media";import type { MediaInspection, MediaStreamSelection, MuxedMedia, RenderedVisual, SynchronizedMedia, TimelineAudio } from "@hypit/media";import { assertProgramClockIdentity } from "@hypit/program-space";@@ -7,14 +8,14 @@ import type { ProgramClock, ProgramSpace } from "@hypit/program-space";import { assertSpeechDurationIdentity, speechEvidenceSampleBoundary } from "@hypit/speech";import type { SpeechDuration } from "@hypit/speech";import type { Composition } from "@hypit/composition";-import type { BlobRef, CanonicalValue, StoredValue } from "@hypit/protocol";+import type { BlobRef, CanonicalValue, CapabilityRef, ProducerRef, StoredValue } from "@hypit/protocol";import { canonicalize } from "@hypit/protocol";import {compileAudioProgramPlan,verifyAudioProgramPlan,} from "./audio-plan.js";-import { mediaPipelineProducers, mediaPipelineTypes } from "./manifest.js";+import { mediaPipelineCapabilities, mediaPipelineProducers, mediaPipelineTypes } from "./manifest.js";import {selectMediaStreams,verifyMediaSelectionRequest,@@ -58,6 +59,32 @@ function blob(value: StoredValue, subject: string): BlobRef {return value;}+/** Preserve unresolved graph inputs without pretending a structured value is a file. */+function plannedMediaNeed(+ producer: ProducerRef,+ port: string,+ capability: CapabilityRef,+ roles: Readonly<Record<string, string>> = {},+): PlannedNeedFacet {+ return {+ producer,+ port,+ capability,+ plan({ state, step }) {+ return { constraints: {}, pendingInputs: plannedNeedInputs(state, step, roles) };+ },+ present(specification) {+ const references: Record<string, number> = {};+ for (const item of specification.pendingInputs) {+ const role = item.role;+ if (role === undefined) continue;+ references[role] = (references[role] ?? 0) + 1;+ }+ return { fields: {}, references };+ },+ };+}+export const mediaPipelineComponent = {validators: [{@@ -311,6 +338,22 @@ export const mediaPipelineComponent = {},},],+ plannedNeeds: [+ plannedMediaNeed(mediaPipelineProducers.inspect, "inspection", mediaPipelineCapabilities.inspect, { source: "media" }),+ plannedMediaNeed(mediaPipelineProducers.normalize, "media", mediaPipelineCapabilities.normalize, { source: "media" }),+ plannedMediaNeed(mediaPipelineProducers.transform, "video", mediaPipelineCapabilities.transform, { media: "video" }),+ plannedMediaNeed(mediaPipelineProducers.extractAudio, "audio", mediaPipelineCapabilities.extractAudio, { source: "audio" }),+ plannedMediaNeed(mediaPipelineProducers.extractFrame, "image", mediaPipelineCapabilities.extractFrame, { source: "video" }),+ plannedMediaNeed(mediaPipelineProducers.renderStill, "video", mediaPipelineCapabilities.renderStill, { request: "image" }),+ plannedMediaNeed(+ mediaPipelineProducers.projectSpeechEvidenceAudio,+ "evidenceAudio",+ mediaPipelineCapabilities.projectSpeechEvidenceAudio,+ { media: "audio" },+ ),+ plannedMediaNeed(mediaPipelineProducers.renderAudio, "audio", mediaPipelineCapabilities.renderAudio, { plan: "audio" }),+ plannedMediaNeed(mediaPipelineProducers.mux, "media", mediaPipelineCapabilities.mux, { visual: "video", audio: "audio" }),+ ],} satisfies ComponentPackage;/** Convenience set: public media validators must accompany the pipeline Producers. */diff --git a/packages/media-pipeline/test/manifest.test.ts b/packages/media-pipeline/test/manifest.test.tsindex c1467558..23b9da25 100644--- a/packages/media-pipeline/test/manifest.test.ts+++ b/packages/media-pipeline/test/manifest.test.ts@@ -3,6 +3,7 @@ import { mediaTypes } from "@hypit/media";import { programSpaceTypes } from "@hypit/program-space";import { speechTypes } from "@hypit/speech";import { svsRecipeType } from "@hypit/svs";+import { installRunFragmentHostFacets, RunFragmentRegistry } from "@hypit/run";import assert from "node:assert/strict";import test from "node:test";import { fixtureResource } from "../../../test/fixture-resource.js";@@ -23,6 +24,13 @@ import {transformMediaFragment,stillVideoFragment,} from "../src/index.js";+import { hypitPackage } from "../src/activation.js";++test("the package exposes StillVideo as an ordinary Run Fragment", () => {+ const fragments = new RunFragmentRegistry();+ installRunFragmentHostFacets(hypitPackage.hostFacets, fragments);+ assert.equal(fragments.resolve("@hypit/media-pipeline@1", "still-video"), stillVideoFragment);+});test("the Normalize Surface makes inspection and normalization an explicit author graph branch", async () => {const range = { source: "normalize.svml", start: 0, end: 1 };diff --git a/packages/model-kit/src/index.ts b/packages/model-kit/src/index.tsindex 64018f9d..edda6bf9 100644--- a/packages/model-kit/src/index.ts+++ b/packages/model-kit/src/index.ts@@ -1,5 +1,8 @@import type {ComponentPackage,+ PlannedNeedFacet,+ PlannedNeedPresentation,+ PlannedNeedSpecification,ProducerFacet,ProducerHandlerContext,TypeValidatorFacet,@@ -122,6 +125,7 @@ export type ExactModelModule<Key extends string = string> = {readonly component: ComponentPackage & {readonly validators: readonly TypeValidatorFacet[];readonly producers: readonly ProducerFacet[];+ readonly plannedNeeds: readonly PlannedNeedFacet[];};/** Inert declaration of these exact models for Hosts that address one directly. */readonly hostFacet: ExactModelHostFacet;@@ -358,6 +362,63 @@ export function plannedExactModelRequest(};}+function exactModelSpecification(planned: PlannedExactModelRequest): PlannedNeedSpecification {+ const ports = structuredClone(planned.ports) as Record<string, CanonicalValue[]>;+ for (const resource of planned.pendingMedia) {+ const items = ports[resource.port] ?? [];+ items.push(canonicalize({+ role: resource.role,+ slot: resource.record,+ ...(resource.fields === undefined ? {} : { fields: resource.fields }),+ }));+ ports[resource.port] = items;+ }+ return {+ constraints: canonicalize({ ports }),+ pendingInputs: planned.pendingMedia.map((resource) => ({+ input: resource.port,+ record: resource.record,+ ...(resource.sourceStep === undefined ? {} : { sourceStep: resource.sourceStep }),+ role: resource.role,+ })),+ };+}++function exactModelPresentation(+ endpoint: ExactModelEndpoint,+ specification: PlannedNeedSpecification,+): PlannedNeedPresentation {+ const request = specification.constraints as { readonly ports?: Readonly<Record<string, readonly CanonicalValue[]>> };+ const fields: Record<string, readonly CanonicalValue[]> = {};+ const references: Record<string, number> = {};+ for (const port of endpoint.ports.ports) {+ const values = request.ports?.[port.name] ?? [];+ if (port.value.kind !== "media") {+ if (values.length > 0) fields[port.name] = structuredClone(values);+ continue;+ }+ for (const value of values) {+ if (value === null || typeof value !== "object" || Array.isArray(value)) continue;+ const role = (value as { readonly role?: unknown }).role;+ if (typeof role === "string") references[role] = (references[role] ?? 0) + 1;+ }+ }+ return { fields, references };+}++function exactModelPlannedNeedFacet(endpoint: ExactModelEndpoint): PlannedNeedFacet {+ return {+ producer: endpoint.producer,+ port: "generation",+ capability: endpoint.capability,+ plan({ state, step, port }) {+ const planned = plannedExactModelRequest(state, step, port, endpoint);+ return planned === undefined ? undefined : exactModelSpecification(planned);+ },+ present: (specification) => exactModelPresentation(endpoint, specification),+ };+}+/*** Builds the repetitive nominal shell around an exact model request. The model package still owns* every field, constraint and model name; this helper only wires Type -> Producer -> Need -> Fragment.@@ -552,6 +613,7 @@ export function defineExactModelModule<const Key extends string>(}),},]),+ plannedNeeds: Object.values(endpoints).map((endpoint) => exactModelPlannedNeedFacet(endpoint)),},};}diff --git a/packages/model-kit/test/model-kit.test.ts b/packages/model-kit/test/model-kit.test.tsindex d5b6dfb8..a2748123 100644--- a/packages/model-kit/test/model-kit.test.ts+++ b/packages/model-kit/test/model-kit.test.ts@@ -117,13 +117,13 @@ test("planning follows the model's declared assembly edges and leaves an upstrea{ id: "bind-image-one", producer: endpoint.mediaBindings.images!.producer, inputs: { draft: "draft:text", binding: "binding", artifact: "image:upstream-one" }, outputs: { draft: "draft:image-one" }, needs: {} },{ id: "bind-image-two", producer: endpoint.mediaBindings.images!.producer, inputs: { draft: "draft:image-one", binding: "binding", artifact: "image:upstream-two" }, outputs: { draft: "draft:image-two" }, needs: {} },{ id: "finalize", producer: endpoint.finalizeProducer, inputs: { draft: "draft:image-two" }, outputs: { request: "request" }, needs: {} },- { id: "generate", producer: endpoint.producer, inputs: { request: "request" }, outputs: {}, needs: { image: { id: "need:image" } } },+ { id: "generate", producer: endpoint.producer, inputs: { request: "request" }, outputs: {}, needs: { generation: { id: "need:image" } } },{ id: "make-image-one", producer: { module: { name: "@test/upstream", version: "1" }, name: "make" }, inputs: {}, outputs: { image: "image:upstream-one" }, needs: {} },{ id: "make-image-two", producer: { module: { name: "@test/upstream", version: "1" }, name: "make" }, inputs: {}, outputs: { image: "image:upstream-two" }, needs: {} },] },} as unknown as BuildState;- assert.deepEqual(plannedExactModelRequest(state, "generate", "image", endpoint), {+ assert.deepEqual(plannedExactModelRequest(state, "generate", "generation", endpoint), {model: "graph-native-image",ports: { prompt: ["draw the authored scene"] },pendingMedia: [@@ -144,4 +144,25 @@ test("planning follows the model's declared assembly edges and leaves an upstrea],complete: false,});+ const facet = definition.component.plannedNeeds[0]!;+ const specification = facet.plan({ state, step: "generate", port: "generation" });+ assert.deepEqual(specification, {+ constraints: {+ ports: {+ images: [+ { role: "image", slot: "image:upstream-one" },+ { role: "image", slot: "image:upstream-two" },+ ],+ prompt: ["draw the authored scene"],+ },+ },+ pendingInputs: [+ { input: "images", record: "image:upstream-one", sourceStep: "make-image-one", role: "image" },+ { input: "images", record: "image:upstream-two", sourceStep: "make-image-two", role: "image" },+ ],+ });+ assert.deepEqual(specification === undefined ? undefined : facet.present?.(specification), {+ fields: { prompt: ["draw the authored scene"] },+ references: { image: 2 },+ });});diff --git a/packages/provider-kie/src/routes.ts b/packages/provider-kie/src/routes.tsindex d6472d0c..b3432772 100644--- a/packages/provider-kie/src/routes.ts+++ b/packages/provider-kie/src/routes.ts@@ -12,7 +12,8 @@ import {} from "@hypit/generation";import type { GenerationArtifactUrlResolver, GenerationRequest } from "@hypit/generation";import { canonicalize } from "@hypit/protocol";-import type { BlobRef, CanonicalValue, CapabilityRef, Need, StoredValue, TypeRef } from "@hypit/protocol";+import type { BlobRef, CanonicalValue, CapabilityRef, StoredValue, TypeRef } from "@hypit/protocol";+import type { EndpointRequest } from "@hypit/endpoint-kit";import { kieModelCatalog, verifyKieModelCatalog } from "./mapping.js";import type { KieGenerationWireMapping } from "./mapping.js";@@ -28,7 +29,7 @@ export type KieRoute = {readonly returns: TypeRef;readonly media: "image" | "video";readonly maxResults: number;- readonly supports?: (need: Need) => boolean;+ readonly supports?: (request: EndpointRequest) => boolean;readonly compile: (constraints: CanonicalValue,resolve: GenerationArtifactUrlResolver,@@ -80,7 +81,7 @@ const generationRoutes: readonly KieRoute[] = kieGenerationMappings.map((mappingmedia: mapping.result,maxResults: mapping.result === "image" ? 16 : 8,...(mapping.unsupportedPortValues === undefined ? {} : {- supports: (need: Need) => supportsKieGenerationRequest(+ supports: (need: EndpointRequest) => supportsKieGenerationRequest(mapping,need.constraints as unknown as GenerationRequest,),diff --git a/packages/provider-media-local/README.md b/packages/provider-media-local/README.mdindex 5a109414..3c2e8bf5 100644--- a/packages/provider-media-local/README.md+++ b/packages/provider-media-local/README.md@@ -32,6 +32,11 @@ Its shared probe checks the encoders and filters used by the execution body. Comremain valid; the package neither pins a semantic Capability to one FFmpeg version nor mutates asystem package manager.+The reusable display-materialization capabilities—inspection, normalization, transform, extraction,+StillVideo and stand-in drawing—also opt into transient authoring execution. Speech-evidence projection,+programme-audio rendering and final muxing remain Build-only. This is declared per capability; the+Runtime and Studio contain no media capability allowlist.+Video-backed normalization is video-authoritative so an AAC packet tail cannot extend the programpast its final picture. Audio-only normalization is audio-authoritative. The AWS Lambda media Providermust return the same public contracts and timing laws; Lambda is an execution topology, not anotherdiff --git a/packages/provider-media-local/src/provider.ts b/packages/provider-media-local/src/provider.tsindex 5f322565..b68a53b7 100644--- a/packages/provider-media-local/src/provider.ts+++ b/packages/provider-media-local/src/provider.ts@@ -88,48 +88,56 @@ export function createLocalMediaProvider(config: CreateLocalMediaProviderOptionscapabilities: [{lifecycle: "immediate" as const,+ transient: true,capability: mediaPipelineCapabilities.inspect,returns: mediaTypes.inspection,handler: operation(executeInspectMedia),},{lifecycle: "immediate" as const,+ transient: true,capability: mediaPipelineCapabilities.normalize,returns: mediaTypes.synchronized,handler: operation(executeNormalizeMedia),},{lifecycle: "immediate" as const,+ transient: true,capability: mediaPipelineCapabilities.transform,returns: artifactTypes.blob,handler: operation(executeTransformMedia),},{lifecycle: "immediate" as const,+ transient: true,capability: mediaPipelineCapabilities.extractAudio,returns: artifactTypes.blob,handler: operation(executeExtractAudio),},{lifecycle: "immediate" as const,+ transient: true,capability: mediaPipelineCapabilities.extractFrame,returns: artifactTypes.blob,handler: operation(executeExtractFrame),},{lifecycle: "immediate" as const,+ transient: true,capability: mediaPipelineCapabilities.renderStill,returns: artifactTypes.blob,handler: operation(executeRenderStillVideo),},{lifecycle: "immediate" as const,+ transient: true,capability: standInCapabilities.drawCard,returns: artifactTypes.blob,handler: operation(executeDrawStandInCard),},{lifecycle: "immediate" as const,+ transient: true,capability: standInCapabilities.drawSilence,returns: artifactTypes.blob,handler: operation(executeDrawStandInSilence),diff --git a/packages/provider-media-local/test/provider.test.ts b/packages/provider-media-local/test/provider.test.tsindex 7647e287..5aa0c615 100644--- a/packages/provider-media-local/test/provider.test.ts+++ b/packages/provider-media-local/test/provider.test.ts@@ -187,6 +187,27 @@ async function handlerFor(request: Need): Promise<{ handler: ImmediateEndpointHareturn { handler: resolution.registration.handler, registration: resolution.registration };}+test("local media opts only reusable display materialization into transient execution", () => {+ const provider = createLocalMediaProvider({});+ assert.deepEqual(provider.offers.filter((offer) => offer.transient === true)+ .map((offer) => offer.capability.name), [+ "inspect-media",+ "normalize-media",+ "transform-media",+ "extract-media-audio",+ "extract-media-frame",+ "render-still-video",+ "draw-card",+ "draw-silence",+ ]);+ assert.deepEqual(provider.offers.filter((offer) => offer.transient !== true)+ .map((offer) => offer.capability.name), [+ "project-speech-evidence-audio",+ "render-timeline-audio",+ "mux-program-media",+ ]);+});+async function inspectArtifact(resources: MemoryResourceStore, source: Awaited<ReturnType<MemoryResourceStore["put"]>>) {const constraints = canonicalize({ source });const request = need("need:media-inspect", mediaPipelineCapabilities.inspect,diff --git a/packages/provider-vertex/test/provider.test.ts b/packages/provider-vertex/test/provider.test.tsindex 05727028..8d7cdfaa 100644--- a/packages/provider-vertex/test/provider.test.ts+++ b/packages/provider-vertex/test/provider.test.ts@@ -17,11 +17,9 @@ test("Vertex Runtime provider exposes the same provider-neutral Gemini capabilitawait provider.install(registry);for (const model of ["gemini-3.1-pro"] as const) {const resolution = registry.resolve({- id: `need:${model}`,capability: geminiCapabilities[model],returns: geminiTypes.visualObservation,constraints: { instruction: "x", prompt: "x", media: [] },- result: `record:${model}`,});assert.equal(resolution.status, "resolved");assert.equal(resolution.registration.kind, "immediate");diff --git a/packages/render-hyperframes/src/component.ts b/packages/render-hyperframes/src/component.tsindex bff1e484..e6ae095c 100644--- a/packages/render-hyperframes/src/component.ts+++ b/packages/render-hyperframes/src/component.ts@@ -1,8 +1,9 @@+import { plannedNeedInputs } from "@hypit/component-kit";import type { ComponentPackage } from "@hypit/component-kit";import type { StoredValue } from "@hypit/protocol";import { hyperframesVisualRequest } from "./product.js";-import { renderHyperframesProducers } from "./manifest.js";+import { renderHyperframesCapabilities, renderHyperframesProducers } from "./manifest.js";/** Declares the visual Need. It contains no renderer, queue, credentials or deployment choice. */export const renderHyperframesComponent = {@@ -15,6 +16,17 @@ export const renderHyperframesComponent = {},}),}],+ plannedNeeds: [{+ producer: renderHyperframesProducers.requestVisual,+ port: "visual",+ capability: renderHyperframesCapabilities.renderVisual,+ plan({ state, step }) {+ return { constraints: {}, pendingInputs: plannedNeedInputs(state, step) };+ },+ present(specification) {+ return { fields: {}, references: {} };+ },+ }],} satisfies ComponentPackage;function inline(value: StoredValue, subject: string): unknown {diff --git a/packages/runtime-host-node/README.md b/packages/runtime-host-node/README.mdindex 30ed9431..70d48ae2 100644--- a/packages/runtime-host-node/README.md+++ b/packages/runtime-host-node/README.md@@ -17,3 +17,9 @@ The generic CLI depends only on this port. The official video application selectrather than replacing the Runtime itself or selecting Build history storage. A second applicationmay supply another `NodeRuntimeHost` at its Distribution assembly boundary; no unused Host pluginregistry or selector is exposed in a local Profile.++The same port lets an authoring application open a disposable transient execution. The caller hands+over a graph state, deterministic Producers, validators and temporary Resources; the Runtime keeps+Endpoint selection, handlers and concurrency for that disposable session private and returns the evaluated+state. This is an execution boundary, not a second Runtime Profile, Build type, cross-Build scheduler or+preview registry.diff --git a/packages/runtime-host-node/src/index.ts b/packages/runtime-host-node/src/index.tsindex ee4c4fe0..9d8283ec 100644--- a/packages/runtime-host-node/src/index.ts+++ b/packages/runtime-host-node/src/index.ts@@ -5,6 +5,7 @@ import { delimiter, isAbsolute, join, resolve } from "node:path";import type { ArtifactAttachment } from "@hypit/workspace";import type { BuildResultForward } from "@hypit/build-result";import type { BuildResultRepositoryLocation } from "@hypit/build-result-kit";+import type { DriverRunResult, NodeDriverOptions, ProducerRegistry } from "@hypit/driver-node";import type { BuildDefinition, BuildState, CapabilityRef, Need, StoredValue } from "@hypit/protocol";import type {BuildCatalogDescriptor,@@ -128,6 +129,21 @@ export type RuntimeHostDoctorResult = {readonly diagnostics: readonly RuntimeDoctorDiagnostic[];};+/**+ * Disposable graph evaluation through capabilities that their Providers explicitly allow outside+ * a Build. The Host owns Endpoint selection, credentials, invocation and session-local concurrency;+ * callers contribute only deterministic domain Producers, validation and an ephemeral ResourceStore.+ */+export type RuntimeHostTransientExecution = {+ evaluate(input: {+ readonly state: BuildState;+ readonly producers: ProducerRegistry;+ readonly validators: NonNullable<NodeDriverOptions["validators"]>;+ readonly resources: ResourceStore;+ }): Promise<DriverRunResult>;+ close(): void | Promise<void>;+};+/** The selected Endpoint behind one demanded capability, read from the Profile alone. */export type RuntimeHostCapabilityProvider = {/** Caller-owned identity for this planned request. */@@ -144,16 +160,19 @@ export type RuntimeHostCapabilityProvider = {readonly endpoints?: readonly string[];/** The Endpoint instance the Profile's `bindings` name for this capability, when it names one. */readonly binding?: string;- /** `request` means Endpoint `supports` checked the complete Need; `capability` is static selection only. */- readonly checked: "request" | "capability";};export type RuntimeHostProviderQuery = {readonly request: string;readonly capability: CapabilityRef;readonly returns: import("@hypit/protocol").TypeRef;- /** Omitted only while an upstream Resource in the closed Build graph does not exist yet. */- readonly constraints?: import("@hypit/protocol").CanonicalValue;+ /** Complete support-relevant parameters available before the Build. */+ readonly constraints: import("@hypit/protocol").CanonicalValue;+ /** Future graph inputs described by the package that owns this request. */+ readonly pendingInputs?: readonly {+ readonly input: string;+ readonly role?: string;+ }[];};export type ManagedProgramProgress = {@@ -249,13 +268,8 @@ export type NodeRuntimeHost = {* creates no Build, Result or state, and refuses asynchronous capabilities.*/invoke(need: Need, resources: ResourceStore): Promise<{ readonly value: StoredValue }>;- /**- * The Endpoints a display may execute without a Build: every Endpoint the Profile selects whose- * Provider declares `local` pricing, immediate capabilities only, with the Profile's bindings- * applied. A capability bound to a priced Endpoint stays unresolved here instead of falling to a- * local one, so nothing shown was ever paid for.- */- localEndpoints(): Promise<import("@hypit/driver-node").EndpointRegistry>;+ /** Open one disposable authoring execution. It creates no Build, Result or recoverable Operation. */+ openTransientExecution(): Promise<RuntimeHostTransientExecution>;runWorker(readyFile: string, owner: string): Promise<void>;};diff --git a/packages/runtime-local/README.md b/packages/runtime-local/README.mdindex d550a4a0..1e755d8b 100644--- a/packages/runtime-local/README.md+++ b/packages/runtime-local/README.md@@ -35,6 +35,14 @@ reported by `doctor` and `plan` and blocks the Need at Build time; a binding tonot offer the capability is an error. `plan`, creation-time tools and the Build resolve Endpointsthrough the same registry with the same bindings.+Disposable authoring clients may open one transient execution. It installs only immediate capabilities+whose Provider explicitly declares `transient: true`, keeps the same Profile bindings and resolves each+complete Need through its ordinary `supports` predicate. Pricing is informational and is never used as+an execution permission. The Runtime retains Endpoint handlers, credentials and Program readiness; the+client supplies its temporary Resources and receives no Endpoint registry. Declared concurrency is shared+inside that one disposable session only. A Provider that needs durable or cross-Build quota admission must+not opt that capability into transient execution.+A project that wants a non-default Result repository owns a separate `hypit.results.json`:```json@@ -53,8 +61,10 @@ no second queue.Cancellation prevents new work and makes a best effort to cancel an external operation already submitted;completed output is never rolled back.-Without `hypit.results.json`, Hypit uses the project's `.hypit/results` directory with no cloud-account or service. The project may instead select `@hypit/build-result-s3` for a shared repository.+Without `hypit.results.json`, the official video Distribution selects the filesystem adapter at the+project's `.hypit/results` directory, with no cloud account or service. Runtime Local opens that default+through the same adapter registry as an explicit `@hypit/build-result-s3` selection; it contains no+filesystem Repository shortcut.Runtime working Resources remain internal and Build-local; there is no ResourceStore selector. Aftera Result has an outcome, history is read from the selected repository, not Runtime SQLite.diff --git a/packages/runtime-local/package.json b/packages/runtime-local/package.jsonindex 64cf25dd..edadfe96 100644--- a/packages/runtime-local/package.json+++ b/packages/runtime-local/package.json@@ -12,7 +12,6 @@},"dependencies": {"@hypit/resource-store-fs": "workspace:*",- "@hypit/build-result": "workspace:*","@hypit/build-result-fs": "workspace:*","@hypit/build-result-kit": "workspace:*","@hypit/component-kit": "workspace:*",@@ -28,6 +27,7 @@"@hypit/validation": "workspace:*"},"devDependencies": {+ "@hypit/build-result": "workspace:*","@hypit/credential-store-env": "workspace:*"}}diff --git a/packages/runtime-local/src/config.ts b/packages/runtime-local/src/config.tsindex 1c450f77..7351addd 100644--- a/packages/runtime-local/src/config.ts+++ b/packages/runtime-local/src/config.ts@@ -7,8 +7,8 @@ import {loadNodePackageSelection,} from "@hypit/package-loader-node";import type { NodePackageSelectionRequest } from "@hypit/package-loader-node";-import { EndpointRegistry } from "@hypit/driver-node";-import type { EndpointFulfillment, EndpointRegistrar } from "@hypit/endpoint-kit";+import { EndpointRegistry, NodeDriver } from "@hypit/driver-node";+import type { EndpointFulfillment, EndpointRegistrar, EndpointScheduling } from "@hypit/endpoint-kit";import { assertBuildId, canonicalize, canonicalStringify } from "@hypit/protocol";import type { CanonicalValue, CapabilityRef, Need } from "@hypit/protocol";import {@@ -16,7 +16,6 @@ import {} from "@hypit/runtime";import type { CredentialStore, CredentialValue, ResourceStore } from "@hypit/runtime";import { FileResourceStore } from "@hypit/resource-store-fs";-import { FileBuildResultRepository } from "@hypit/build-result";import {buildResultRepositoryHostAbi,BuildResultRepositoryRegistry,@@ -26,6 +25,7 @@ import type {BuildResultRepositoryDiagnostic,BuildResultRepositoryLocation,BuildResultRepositoryOpened,+ BuildResultRepositorySelection,} from "@hypit/build-result-kit";import {isRuntimeAdapterHostFacet,@@ -46,7 +46,13 @@ import {hypitHostStateRoot,prepareHostPackages,} from "@hypit/runtime-host-node";-import type { HostPackageProgress, HostPackageReport, RuntimeHostCapabilityProvider, RuntimeHostProviderQuery } from "@hypit/runtime-host-node";+import type {+ HostPackageProgress,+ HostPackageReport,+ RuntimeHostCapabilityProvider,+ RuntimeHostProviderQuery,+ RuntimeHostTransientExecution,+} from "@hypit/runtime-host-node";import { SqliteRuntimeState } from "@hypit/store-sqlite";import { applyEndpointBindings, createLocalRuntime, parseCapabilityKey } from "./runtime.js";@@ -305,35 +311,29 @@ export async function openBuildResultRepositoryLocation(export async function openProjectBuildResultRepository(projectRoot: string,- options: LoadRuntimeConfigOptions = {},+ options: LoadRuntimeConfigOptions & {+ readonly defaultSelection: BuildResultRepositorySelection;+ },): Promise<BuildResultRepositoryOpened & { readonly location: BuildResultRepositoryLocation }> {const root = resolve(projectRoot);- const selected = await projectBuildResultLocation(root);- const location = selected.location;- if (selected.implicit) {- return {- location,- repository: new FileBuildResultRepository(resolve(root, ".hypit/results")),- };- }+ const location = await projectBuildResultLocation(root, options.defaultSelection);const registry = options.resultRegistry ?? new BuildResultRepositoryRegistry();const result = await openBuildResultLocation(location, options, resolve(options.packageRoot ?? root), registry);return { ...result, location };}-async function projectBuildResultLocation(root: string): Promise<{- readonly location: BuildResultRepositoryLocation;- readonly implicit: boolean;-}> {+async function projectBuildResultLocation(+ root: string,+ defaultSelection: BuildResultRepositorySelection,+): Promise<BuildResultRepositoryLocation> {const configPath = resolve(root, "hypit.results.json");const text = await readFile(configPath, "utf8").catch((error: unknown) => {if (error instanceof Error && "code" in error && error.code === "ENOENT") return undefined;throw error;});let selection: BuildResultRepositoryLocation["selection"];- const implicit = text === undefined;if (text === undefined) {- selection = { use: "@hypit/build-result-fs", config: { path: ".hypit/results" } };+ selection = defaultSelection;} else {const item = object(JSON.parse(text), "$results");exactKeys(item, ["format", "use", "config"], "$results");@@ -345,18 +345,20 @@ async function projectBuildResultLocation(root: string): Promise<{...(item.config === undefined ? {} : { config: canonicalize(item.config) }),};}- return { location: { root, selection }, implicit };+ return { root, selection };}/** Diagnose the project-owned Result Store without reading Result history or mutating storage. */export async function doctorProjectBuildResultRepository(projectRoot: string,- options: LoadRuntimeConfigOptions = {},+ options: LoadRuntimeConfigOptions & {+ readonly defaultSelection: BuildResultRepositorySelection;+ },): Promise<ProjectBuildResultDoctorResult> {const root = resolve(projectRoot);let location: BuildResultRepositoryLocation | undefined;try {- location = (await projectBuildResultLocation(root)).location;+ location = await projectBuildResultLocation(root, options.defaultSelection);const registry = options.resultRegistry ?? new BuildResultRepositoryRegistry();await installBuildResultAdapter(registry,@@ -484,30 +486,136 @@ async function installedEndpointRegistry(return endpoints;}+type TransientResourceClaim = EndpointScheduling["resources"][number];++/** In-memory concurrency shared only by evaluations inside one disposable authoring session. */+class TransientSessionCapacity {+ readonly #limits = new Map<string, number>();+ readonly #active = new Map<string, number>();+ readonly #waiters = new Set<() => void>();++ declare(resources: readonly TransientResourceClaim[]): void {+ for (const resource of resources) {+ const previous = this.#limits.get(resource.id);+ if (previous !== undefined && previous !== resource.limit) {+ throw new Error(`Transient Runtime resource ${resource.id} has conflicting limits ${previous} and ${resource.limit}`);+ }+ this.#limits.set(resource.id, resource.limit);+ }+ }++ async run<T>(resources: readonly TransientResourceClaim[], task: () => Promise<T>): Promise<T> {+ const ordered = [...resources].sort((left, right) => left.id.localeCompare(right.id));+ while (ordered.some((resource) => (this.#active.get(resource.id) ?? 0) >= resource.limit)) {+ await new Promise<void>((resolveWait) => this.#waiters.add(resolveWait));+ }+ for (const resource of ordered) this.#active.set(resource.id, (this.#active.get(resource.id) ?? 0) + 1);+ try {+ return await task();+ } finally {+ for (const resource of ordered) {+ const next = (this.#active.get(resource.id) ?? 1) - 1;+ if (next === 0) this.#active.delete(resource.id);+ else this.#active.set(resource.id, next);+ }+ const waiters = [...this.#waiters];+ this.#waiters.clear();+ for (const wake of waiters) wake();+ }+ }+}+/**- * The Endpoints a display may execute without a Build. Only Providers that declare `local` pricing- * are installed, and only their immediate capabilities; the Profile's bindings still apply, so a- * capability bound to a priced Endpoint resolves to nothing here rather than to a local stand-in.+ * Open the Profile's disposable authoring execution. Endpoint Providers opt individual immediate+ * capabilities into this boundary; price and process location are deliberately irrelevant.*/-export async function localRuntimeConfigEndpoints(+export async function openTransientRuntimeConfigExecution(path: string,options: LoadRuntimeConfigOptions = {},-): Promise<EndpointRegistry> {+): Promise<RuntimeHostTransientExecution> {const { document, root, packageRoot } = await openRuntimeConfig(path, options.packageRoot);const hostStateRoot = resolve(options.hostStateRoot ?? hypitHostStateRoot());const registry = options.registry ?? new RuntimeAdapterRegistry();- await installRuntimeAdapters(registry, packageRoot, endpointPackageSelection(document), options.distributionPackageRoot);+ await installRuntimeAdapters(registry, packageRoot, runtimePackageSelection(document), options.distributionPackageRoot);const endpoints = new EndpointRegistry();- const immediateOnly: EndpointRegistrar = {- registerImmediateEndpoint: (...args) => endpoints.registerImmediateEndpoint(...args),- registerAsyncEndpoint: () => {},- };- for (const { activation } of await activatedEndpoints(document, root, hostStateRoot, registry)) {- if (activation.endpoint.pricing?.kind !== "local") continue;- await activation.endpoint.install(immediateOnly);+ const capacity = new TransientSessionCapacity();+ const activations = await activatedEndpoints(document, root, hostStateRoot, registry);+ for (const { activation } of activations) {+ let readiness: Promise<void> | undefined;+ const assertReady = async (): Promise<void> => {+ const program = activation.program;+ if (program === undefined) return;+ readiness ??= program.probe().then((state) => {+ if (state.state !== "ready") {+ throw new Error(`Runtime program ${program.id} is ${state.state}: ${state.detail}`);+ }+ });+ try {+ await readiness;+ } catch (error) {+ readiness = undefined;+ throw error;+ }+ };+ const transientOnly: EndpointRegistrar = {+ registerImmediateEndpoint(id, capability, returns, handler, registrationOptions) {+ if (registrationOptions?.transient !== true) return;+ const resources = registrationOptions.scheduling?.resources ?? [{ id: `endpoint:${id}`, limit: 1 }];+ capacity.declare(resources);+ endpoints.registerImmediateEndpoint(id, capability, returns, async (context) => {+ return await capacity.run(resources, async () => {+ await assertReady();+ return await handler(context);+ });+ }, registrationOptions);+ },+ registerAsyncEndpoint(id, capability, _returns, _endpoint, registrationOptions) {+ if (registrationOptions?.transient === true) {+ throw new Error(`Endpoint ${id} declares asynchronous capability ${capabilityKey(capability)} as transient`);+ }+ },+ };+ await activation.endpoint.install(transientOnly);}applyEndpointBindings(endpoints, document.bindings);- return endpoints;+ const stores = await openCredentialStores(document, root, hostStateRoot, registry);+ let closed = false;+ let activeEvaluations = 0;+ let closing: Promise<void> | undefined;+ const idleWaiters = new Set<() => void>();+ return {+ async evaluate(input) {+ if (closed) throw new Error("transient Runtime execution is closed");+ activeEvaluations += 1;+ try {+ return await new NodeDriver({+ producers: input.producers,+ validators: input.validators,+ endpoints,+ resources: input.resources,+ credentials: stores.store,+ }).run(input.state);+ } finally {+ activeEvaluations -= 1;+ if (activeEvaluations === 0) {+ const waiters = [...idleWaiters];+ idleWaiters.clear();+ for (const wake of waiters) wake();+ }+ }+ },+ async close() {+ if (closing !== undefined) return await closing;+ closed = true;+ closing = (async () => {+ if (activeEvaluations > 0) {+ await new Promise<void>((resolveWait) => idleWaiters.add(resolveWait));+ }+ await stores.close();+ })();+ await closing;+ },+ };}/** Static Endpoint selection per capability. Reads the Profile and activations only; never a credential or a service. */@@ -527,14 +635,14 @@ export async function describeRuntimeConfigProviders(const base = {request: request.request,capability: structuredClone(request.capability),- checked: request.constraints === undefined ? "capability" as const : "request" as const,};const binding = document.bindings[capabilityKey(request.capability)];const bound = binding === undefined ? {} : { binding };const resolution = endpoints.resolve({capability: request.capability,returns: request.returns,- ...(request.constraints === undefined ? {} : { constraints: request.constraints }),+ constraints: request.constraints,+ ...(request.pendingInputs === undefined ? {} : { pendingInputs: request.pendingInputs }),});if (resolution.status === "missing") return { ...base, status: "unresolved", ...bound };if (resolution.status === "ambiguous") return { ...base, status: "ambiguous", endpoints: resolution.endpointIds, ...bound };diff --git a/packages/runtime-local/src/host.ts b/packages/runtime-local/src/host.tsindex 45875224..4d09f5a4 100644--- a/packages/runtime-local/src/host.ts+++ b/packages/runtime-local/src/host.ts@@ -15,7 +15,7 @@ import {describeRuntimeConfigProviders,doctorRuntimeConfig,invokeRuntimeConfigNeed,- localRuntimeConfigEndpoints,+ openTransientRuntimeConfigExecution,prepareRuntimeConfigPackages,preflightRuntimeConfig,resolveRuntimeConfigPaths,@@ -141,7 +141,7 @@ export async function openLocalRuntimeHost(packageRoot: basePackageRoot,...distribution,}),- localEndpoints: async () => await localRuntimeConfigEndpoints(profile, {+ openTransientExecution: async () => await openTransientRuntimeConfigExecution(profile, {packageRoot: basePackageRoot,...distribution,}),diff --git a/packages/runtime-local/src/index.ts b/packages/runtime-local/src/index.tsindex a90ea9c7..2b81382f 100644--- a/packages/runtime-local/src/index.ts+++ b/packages/runtime-local/src/index.ts@@ -19,7 +19,7 @@ export {describeRuntimeConfigProviders,doctorRuntimeConfig,invokeRuntimeConfigNeed,- localRuntimeConfigEndpoints,+ openTransientRuntimeConfigExecution,prepareRuntimeConfigPackages,preflightRuntimeConfig,parseLocalRuntimeProfile,diff --git a/packages/runtime-local/test/config.test.ts b/packages/runtime-local/test/config.test.tsindex 0e2c7b3e..c9903c86 100644--- a/packages/runtime-local/test/config.test.ts+++ b/packages/runtime-local/test/config.test.ts@@ -14,12 +14,19 @@ import {createBuildResultRepositoryHostFacet,} from "@hypit/build-result-kit";import { FileBuildResultRepository } from "@hypit/build-result";-import { MemoryResourceStore } from "@hypit/driver-node";+import { MemoryResourceStore, ProducerRegistry } from "@hypit/driver-node";import { defineEndpointPackage } from "@hypit/endpoint-kit";import { credentialRef } from "@hypit/runtime";import type { CanonicalValue, CapabilityRef, TypeRef } from "@hypit/protocol";import type { RuntimeHostProviderQuery } from "@hypit/runtime-host-node";import { SqliteRuntimeState } from "@hypit/store-sqlite";+import { TypeValidatorRegistry } from "@hypit/validation";+import {+ capabilities as greetingCapabilities,+ createGreetingBuild,+ producers as greetingProducerRefs,+ types as greetingTypes,+} from "../../core/test/greeting-fixture.js";import {createRuntimeControlFromConfig,createRuntimeFromConfig,@@ -28,11 +35,45 @@ import {doctorProjectBuildResultRepository,doctorRuntimeConfig,invokeRuntimeConfigNeed,- localRuntimeConfigEndpoints,+ openTransientRuntimeConfigExecution,openProjectBuildResultRepository,parseLocalRuntimeProfile,preflightRuntimeConfig,} from "@hypit/runtime-local";++function inlineString(value: unknown): string {+ if (typeof value !== "string") throw new Error("expected inline string");+ return value;+}++function greetingProducers(): ProducerRegistry {+ const producers = new ProducerRegistry();+ producers.registerProducer(greetingProducerRefs.makePrompt, ({ inputs }) => {+ const intent = inputs.intent;+ if (intent?.value.kind !== "inline" || intent.value.value === null+ || Array.isArray(intent.value.value) || typeof intent.value.value !== "object") {+ throw new Error("intent must be an inline object");+ }+ return {+ outputs: {+ prompt: {+ kind: "inline",+ value: `Greet ${inlineString((intent.value.value as Readonly<Record<string, unknown>>).name)}`,+ },+ },+ needs: {},+ };+ });+ producers.registerProducer(greetingProducerRefs.requestText, ({ inputs }) => {+ const prompt = inputs.prompt;+ if (prompt?.value.kind !== "inline") throw new Error("prompt must be inline");+ return {+ outputs: {},+ needs: { generation: { prompt: inlineString(prompt.value.value) } },+ };+ });+ return producers;+}function profile(config: {readonly dataRoot?: string;readonly credentials?: Readonly<Record<string, unknown>>;@@ -52,9 +93,9 @@ function providerQuery(request: string,capability: CapabilityRef,returns: TypeRef,- constraints?: CanonicalValue,+ constraints: CanonicalValue = null,): RuntimeHostProviderQuery {- return { request, capability, returns, ...(constraints === undefined ? {} : { constraints }) };+ return { request, capability, returns, constraints };}test("Local Runtime Profile names credentials and Endpoints, not project result storage", () => {@@ -107,6 +148,7 @@ test("Build Result repositories default to the project path and can be selectedtry {const local = await openProjectBuildResultRepository(defaultProject, {packageRoot: process.cwd(),+ defaultSelection: { use: "@hypit/build-result-fs", config: { path: ".hypit/results" } },});assert.ok(local.repository instanceof FileBuildResultRepository);assert.equal(local.location.root, defaultProject);@@ -117,6 +159,7 @@ test("Build Result repositories default to the project path and can be selectedconst selected = await openProjectBuildResultRepository(selectedProject, {resultRegistry: registry,+ defaultSelection: { use: "unused.default" },});assert.deepEqual(openedContext, {root: selectedProject,@@ -128,6 +171,7 @@ test("Build Result repositories default to the project path and can be selected});const diagnosed = await doctorProjectBuildResultRepository(selectedProject, {resultRegistry: registry,+ defaultSelection: { use: "unused.default" },});assert.deepEqual(diagnosed.diagnostics, []);assert.deepEqual(diagnosedContext, {@@ -324,46 +368,67 @@ test("Runtime providers name the selected Endpoint and its declared price source{request: "generate",capability: generate,- checked: "capability",status: "resolved",endpoint: "paid",use: "example.paid",pricing: { kind: "page", url: "https://prices.example/models" },},- { request: "render", capability: render, checked: "capability", status: "resolved", endpoint: "local", use: "example.local", pricing: { kind: "local" } },- { request: "missing", capability: missing, checked: "capability", status: "unresolved" },+ { request: "render", capability: render, status: "resolved", endpoint: "local", use: "example.local", pricing: { kind: "local" } },+ { request: "missing", capability: missing, status: "unresolved" },]);} finally {await rm(root, { recursive: true, force: true });}});-test("local Endpoints for display install only local-priced Providers and keep the Profile's bindings", async () => {- const root = await mkdtemp(join(tmpdir(), "hypit-runtime-local-endpoints-"));+test("transient execution follows capability opt-in rather than pricing and keeps Profile bindings", async () => {+ const root = await mkdtemp(join(tmpdir(), "hypit-runtime-transient-"));const path = join(root, "hypit.runtime.json");- const generate = { module: { name: "example.model", version: "1" }, name: "generate" } as const;- const render = { module: { name: "example.render", version: "1" }, name: "render" } as const;- const returns = { module: { name: "example.value", version: "1" }, name: "Output" } as const;- const handler = () => ({ value: { kind: "inline" as const, value: null } });await writeFile(path, JSON.stringify(profile({dataRoot: ".",- endpoints: { paid: { use: "example.paid" }, local: { use: "example.local" }, "local-b": { use: "example.local" } },- bindings: { "example.render@1#render": "local", "example.model@1#generate": "paid" },+ credentials: { secrets: { use: "example.credentials" } },+ endpoints: { remote: { use: "example.remote" }, local: { use: "example.local" } },+ bindings: { "[email protected]#generate-greeting-text": "remote" },})));+ let remoteCalls = 0;+ let localCalls = 0;const registry = new RuntimeAdapterRegistry();+ registry.registerFacet(createRuntimeCredentialStoreAdapterFacet({+ use: "example.credentials",+ validate() {},+ open: () => ({+ value: {+ async resolve(ref) {+ return ref.store === "secrets" && ref.key === "remote.key"+ ? { secret: "available" }+ : undefined;+ },+ },+ }),+ }));registry.registerFacet(createRuntimeEndpointAdapterFacet({- use: "example.paid",+ use: "example.remote",activate: (context) => ({endpoint: defineEndpointPackage({module: { name: "example.provider", version: "1" },- facet: "paid",+ facet: "remote",instance: context.instance,pool: context.pool ?? context.instance,+ credentials: { apiKey: credentialRef("secrets", "remote.key") },pricing: { kind: "page", url: "https://prices.example/models" },- capabilities: [- { capability: generate, returns, lifecycle: "immediate", handler },- { capability: render, returns, lifecycle: "immediate", handler },- ],+ capabilities: [{+ capability: greetingCapabilities.generation,+ returns: greetingTypes.generated,+ lifecycle: "immediate",+ transient: true,+ supports: (need) => (need.constraints as { readonly prompt?: unknown }).prompt === "Greet Ada",+ handler: ({ need, credentials }) => {+ remoteCalls += 1;+ assert.deepEqual(need.constraints, { prompt: "Greet Ada" });+ assert.equal(credentials.apiKey?.secret, "available");+ return { value: { kind: "inline", value: "Hello, Ada!" } };+ },+ }],}),}),}));@@ -376,16 +441,71 @@ test("local Endpoints for display install only local-priced Providers and keep tinstance: context.instance,pool: context.pool ?? context.instance,pricing: { kind: "local" },- capabilities: [{ capability: render, returns, lifecycle: "immediate", handler }],+ capabilities: [{+ capability: greetingCapabilities.generation,+ returns: greetingTypes.generated,+ lifecycle: "immediate",+ handler: () => {+ localCalls += 1;+ return { value: { kind: "inline", value: "wrong" } };+ },+ }],}),}),}));try {- const endpoints = await localRuntimeConfigEndpoints(path, { registry });- assert.deepEqual(endpoints.endpointIds(), ["local", "local-b"], "a priced Provider is never installed for display");- assert.equal(endpoints.resolve({ capability: render, returns }).status, "resolved", "the binding picks one local Endpoint");- const bound = endpoints.resolve({ capability: generate, returns });- assert.deepEqual(bound, { status: "missing", endpointId: "paid" }, "a capability bound to a priced Endpoint stays unresolved");+ const execution = await openTransientRuntimeConfigExecution(path, { registry });+ const completed = await execution.evaluate({+ state: createGreetingBuild({ targetOutputs: ["generated"] }),+ producers: greetingProducers(),+ validators: new TypeValidatorRegistry(),+ resources: new MemoryResourceStore(),+ });+ assert.equal(completed.status, "complete");+ assert.equal(remoteCalls, 1, "pricing metadata does not exclude an explicitly transient capability");+ assert.equal(localCalls, 0);++ const unsupportedBase = createGreetingBuild({ targetOutputs: ["generated"] });+ const grace = (record: (typeof unsupportedBase.records)[number]) => record.id === "intent:root"+ ? { ...record, value: { kind: "inline" as const, value: { name: "Grace" } } }+ : record;+ const unsupported = {+ ...unsupportedBase,+ records: unsupportedBase.records.map(grace),+ program: {+ ...unsupportedBase.program,+ records: unsupportedBase.program.records.map(grace),+ },+ };+ const rejected = await execution.evaluate({+ state: unsupported,+ producers: greetingProducers(),+ validators: new TypeValidatorRegistry(),+ resources: new MemoryResourceStore(),+ });+ assert.equal(rejected.status, "paused");+ assert.equal(remoteCalls, 1, "supports receives the complete Need before a transient handler runs");+ await execution.close();++ await writeFile(path, JSON.stringify(profile({+ dataRoot: ".",+ credentials: { secrets: { use: "example.credentials" } },+ endpoints: { remote: { use: "example.remote" }, local: { use: "example.local" } },+ bindings: { "[email protected]#generate-greeting-text": "local" },+ })));+ const boundExecution = await openTransientRuntimeConfigExecution(path, { registry });+ const blocked = await boundExecution.evaluate({+ state: createGreetingBuild({ targetOutputs: ["generated"] }),+ producers: greetingProducers(),+ validators: new TypeValidatorRegistry(),+ resources: new MemoryResourceStore(),+ });+ assert.equal(blocked.status, "paused");+ assert.match(blocked.blocked[0]?.subject ?? "", /local/u,+ "a binding to a non-transient Endpoint must not fall back to another Endpoint");+ assert.equal(remoteCalls, 1);+ assert.equal(localCalls, 0);+ await boundExecution.close();} finally {await rm(root, { recursive: true, force: true });}@@ -414,7 +534,8 @@ test("Runtime provider inspection applies Endpoint supports when the complete recapability,returns,lifecycle: "immediate",- supports: (need) => (need.constraints as { readonly allowed?: unknown } | null)?.allowed === true,+ supports: (need) => (need.constraints as { readonly allowed?: unknown } | null)?.allowed === true+ && need.pendingInputs?.some((input) => input.role === "image") === true,handler: () => ({ value: { kind: "inline", value: null } }),}],}),@@ -424,9 +545,14 @@ test("Runtime provider inspection applies Endpoint supports when the complete reassert.deepEqual(await describeRuntimeConfigProviders(path, [providerQuery("pending-file", capability, returns),providerQuery("complete", capability, returns, { allowed: false }),+ {+ ...providerQuery("symbolic-resource", capability, returns, { allowed: true }),+ pendingInputs: [{ input: "reference", role: "image" }],+ },], { registry }), [- { request: "pending-file", capability, checked: "capability", status: "resolved", endpoint: "narrow", use: "example.narrow", pricing: { kind: "local" } },- { request: "complete", capability, checked: "request", status: "unresolved" },+ { request: "pending-file", capability, status: "unresolved" },+ { request: "complete", capability, status: "unresolved" },+ { request: "symbolic-resource", capability, status: "resolved", endpoint: "narrow", use: "example.narrow", pricing: { kind: "local" } },]);} finally {await rm(root, { recursive: true, force: true });@@ -569,8 +695,8 @@ test("providers, doctor and invoke share one resolver: a contested capability isproviderQuery("generate", generate, returns, null),providerQuery("render", render, returns, null),], { registry }), [- { request: "generate", capability: generate, checked: "request", status: "ambiguous", endpoints: ["other", "paid"] },- { request: "render", capability: render, checked: "request", status: "resolved", endpoint: "local", use: "example.local", pricing: { kind: "local" } },+ { request: "generate", capability: generate, status: "ambiguous", endpoints: ["other", "paid"] },+ { request: "render", capability: render, status: "resolved", endpoint: "local", use: "example.local", pricing: { kind: "local" } },]);const contested = (await preflightRuntimeConfig(unbound, { registry, capabilities: [generate] })).diagnostics.filter((item) => item.code === "RUNTIME_CAPABILITY_AMBIGUOUS");@@ -586,7 +712,7 @@ test("providers, doctor and invoke share one resolver: a contested capability isconst bound = join(root, "bound.json");await writeFile(bound, JSON.stringify(profile({ dataRoot: ".", endpoints, bindings: { [generateKey]: "other" } })));assert.deepEqual(await describeRuntimeConfigProviders(bound, [providerQuery("generate", generate, returns, null)], { registry }), [- { request: "generate", capability: generate, checked: "request", status: "resolved", endpoint: "other", use: "example.other", pricing: { kind: "local" }, binding: "other" },+ { request: "generate", capability: generate, status: "resolved", endpoint: "other", use: "example.other", pricing: { kind: "local" }, binding: "other" },]);assert.equal((await preflightRuntimeConfig(bound, { registry, capabilities: [generate] })).diagnostics.some((item) => item.code === "RUNTIME_CAPABILITY_AMBIGUOUS"), false);@@ -596,7 +722,7 @@ test("providers, doctor and invoke share one resolver: a contested capability isconst wrong = join(root, "wrong.json");await writeFile(wrong, JSON.stringify(profile({ dataRoot: ".", endpoints, bindings: { [generateKey]: "local" } })));assert.deepEqual(await describeRuntimeConfigProviders(wrong, [providerQuery("generate", generate, returns, null)], { registry }), [- { request: "generate", capability: generate, checked: "request", status: "unresolved", binding: "local" },+ { request: "generate", capability: generate, status: "unresolved", binding: "local" },]);assert.ok((await preflightRuntimeConfig(wrong, { registry, capabilities: [generate] })).diagnostics.some((item) => item.code === "RUNTIME_BINDING_INVALID"));diff --git a/packages/studio/README.md b/packages/studio/README.mdindex 9ef25f75..da8d8211 100644--- a/packages/studio/README.md+++ b/packages/studio/README.md@@ -24,16 +24,10 @@ Result tasks and Artifacts still work; only active execution status is unavailabStudio is an application boundary. Core and domain packages do not import it orregister UI metadata. The installed Distribution explicitly selects one independent-Studio Companion per supported official domain. An external project may add Companion packages-through `hypit.studio.json`; the application assembles one immutable registry for-that project session.--```json-{- "format": "hypit.studio-profile@1",- "companionPackages": ["@my-project/local-example-studio"]-}-```+Studio Companion per supported official domain. Packages actually selected by the+current Source closure may contribute their own Companion facet. The application+assembles both sets into one immutable registry for that session; there is no second+Studio profile, package scan or replacement map.Project packages live at `<project>/packages/<package-basename>/`. Neither theproject nor its packages are added to the Hypit Distribution or contributor workspace.@@ -53,8 +47,8 @@ source binding is never shown merely because Studio can reach it. Material layerResource id or Surface identity, never a Studio HTTP URL. Studio always ownstime formatting and transport resolution, so chrome and material cannot hide atitle or its time.-Studio owns session-wide behavior and chrome: Companion selection, collision and-replacement rules, fallback defaults, selection treatment, playback, zoom,+Studio owns session-wide behavior and chrome: Companion assembly, collision rules,+fallback defaults, selection treatment, playback, zoom,scrolling, the finite Inspector control set and source mutation transport. Acompanion cannot ship arbitrary DOM or CSS into the application.@@ -76,19 +70,18 @@ endpoint's author authority and direct consumer edge. Common timeline inverses cauthority rather than Companion declarations. Track Companions never infer semantic sources from SVMLattribute names, runtime id prefixes or coincident frame spans.-Opening Studio never spends and never creates a Build. Its display closure is-everything the Run makes computable for free: supplied Candidates, deterministic-Producers, and Needs served by the selected Profile's local Endpoints (Providers-that declare `local` pricing, such as the FFmpeg media Endpoint that inspects and-normalizes a media file). Resolution is the same as `plan` and a Build use,-including the Profile's bindings, minus every priced Endpoint; a Need that reaches-a priced Endpoint or none at all stops Studio with the capability named, and the-author supplies a Candidate for that output or builds the Run. A stand-in card-(`@hypit/stand-in`, one `<model>-stand-in` Run Fragment per exact model) is such a-local Need: the picture a generation would have made, drawn from its draft instead.+Opening Studio never spends and never creates a Build. Its display closure contains+the Candidates selected by the Run, deterministic Producers and exact Needs that+their Provider explicitly allows in transient authoring execution. The Runtime owns+Endpoint activation, Profile bindings, request-level `supports`, credentials and+invocation; Studio receives no Endpoint Registry and makes no decision from pricing,+process location, model name or package name. A Need without transient support stops+with its exact capability named. A stand-in is an ordinary generic image, video or+silence Candidate from `@hypit/stand-in`; the Run supplies its visible dimensions and+duration and selects it with `satisfy`. Model packages do not manufacture stand-ins.Studio and an encoded review use the same ordinary Run. Studio evaluates its-free display closure in the browser; building that Run evaluates the+transient display closure in the browser; building that Run evaluates thefull target closure and sends the resulting HyperFrames document to the chosenrender Endpoint. A separate review Run is useful only when the author wants adifferent Candidate selection. Its path and filename carry no executiondiff --git a/packages/studio/src/build-library.ts b/packages/studio/src/build-library.tsindex a3b4da81..7108b231 100644--- a/packages/studio/src/build-library.ts+++ b/packages/studio/src/build-library.ts@@ -1,8 +1,7 @@import { isAbsolute, relative, resolve, sep } from "node:path";import { buildIdCreatedAt } from "@hypit/protocol";-import type { EndpointRegistry } from "@hypit/driver-node";-import type { BuildView, NodeRuntimeHost } from "@hypit/runtime-host-node";+import type { BuildView, NodeRuntimeHost, RuntimeHostTransientExecution } from "@hypit/runtime-host-node";import type { StoredValue, TypeRef } from "@hypit/protocol";import type {BuildResultFileRange,@@ -23,8 +22,8 @@ type RuntimeControl = Awaited<ReturnType<NodeRuntimeHost["openControl"]>>;export type StudioBuildLibrary = {readonly profile?: string;readonly runtime?: Pick<RuntimeControl, "activity">;- /** The Profile's local Endpoints: what Studio may execute for display without a Build. */- readonly endpoints?: EndpointRegistry;+ /** Runtime-owned, disposable execution for the current authoring session. */+ readonly transientExecution?: RuntimeHostTransientExecution;readonly library: (before?: string) => Promise<StudioLibraryView>;readonly resolveHistoricalOutput: (build: string,@@ -232,15 +231,16 @@ export async function openStudioBuildLibrary(...(distributionPackageRoot === undefined ? {} : { distributionPackageRoot }),});const runtime = await host?.openControl({ readOnly: true });- let endpoints: EndpointRegistry | undefined;+ let transientExecution: RuntimeHostTransientExecution | undefined;let openedResults: Awaited<ReturnType<typeof videoCliDistribution.openProjectResults>>;try {- endpoints = await host?.localEndpoints();+ transientExecution = await host?.openTransientExecution();openedResults = await videoCliDistribution.openProjectResults(workspaceRoot, {packageRoot,...(distributionPackageRoot === undefined ? {} : { distributionPackageRoot }),});} catch (error) {+ await transientExecution?.close();await runtime?.close();throw error;}@@ -248,7 +248,7 @@ export async function openStudioBuildLibrary(return {...(resolvedProfile === undefined ? {} : { profile: resolvedProfile }),...(runtime === undefined ? {} : { runtime }),- ...(endpoints === undefined ? {} : { endpoints }),+ ...(transientExecution === undefined ? {} : { transientExecution }),async library(before) {return await readStudioLibrary({...(resolvedProfile === undefined ? {} : { profile: resolvedProfile }),@@ -274,6 +274,7 @@ export async function openStudioBuildLibrary(},async close() {await openedResults.close();+ await transientExecution?.close();await runtime?.close();},};diff --git a/packages/studio/src/companion-assembly.ts b/packages/studio/src/companion-assembly.tsnew file mode 100644index 00000000..07ebbfd7--- /dev/null+++ b/packages/studio/src/companion-assembly.ts@@ -0,0 +1,39 @@+import { installDistributionPackageResolution, loadNodePackageSelection } from "@hypit/package-loader-node";+import type { LoadedPackage } from "@hypit/package-loader-node";+import { studioContributionFromPackage } from "@hypit/studio-adapter";++import { fallbackStudioTrackCompanions } from "./fallback-companions.js";+import { StudioCompanionRegistry } from "./studio-registry.js";++/**+ * Assemble the immutable Companion Registry for one Source closure.+ *+ * The distribution contributes its normal video vocabulary. Every package+ * actually selected by the Source may contribute its own Companion through the+ * same package host-facet boundary. There is no second project profile and no+ * replacement table.+ */+export async function loadStudioCompanionRegistry(input: {+ readonly distributionPackageRoot: string;+ readonly distributionPackages: readonly string[];+ readonly sourcePackages: readonly LoadedPackage[];+}): Promise<StudioCompanionRegistry> {+ installDistributionPackageResolution([input.distributionPackageRoot]);+ const distribution = await loadNodePackageSelection(+ input.distributionPackages,+ input.distributionPackageRoot,+ );+ const selected = new Map<string, LoadedPackage>();+ for (const item of [...distribution, ...input.sourcePackages]) {+ if (!selected.has(item.specifier)) selected.set(item.specifier, item);+ }+ const contributions = [...selected.values()].map((item) =>+ studioContributionFromPackage(item.specifier, item.contribution.hostFacets ?? []));+ return new StudioCompanionRegistry(+ [...fallbackStudioTrackCompanions, ...contributions.flatMap((item) => item.tracks)],+ {+ films: contributions.flatMap((item) => item.films),+ scripts: contributions.flatMap((item) => item.scripts),+ },+ );+}diff --git a/packages/studio/src/companion-profile.ts b/packages/studio/src/companion-profile.tsdeleted file mode 100644index 08488b7e..00000000--- a/packages/studio/src/companion-profile.ts+++ /dev/null@@ -1,135 +0,0 @@-import { readFile } from "node:fs/promises";-import { resolve } from "node:path";--import { installDistributionPackageResolution, loadNodePackageSelection } from "@hypit/package-loader-node";-import { studioContributionFromPackage } from "@hypit/studio-adapter";-import type { StudioTrackCompanion, StudioFilmCompanion, StudioScriptCompanion } from "@hypit/studio-adapter";--import { fallbackStudioTrackCompanions } from "./fallback-companions.js";-import { StudioCompanionRegistry } from "./studio-registry.js";--export const officialStudioCompanionPackages = [- "@hypit/audio-track-studio",- "@hypit/caption-fine-studio",- "@hypit/comment-sticker-studio",- "@hypit/deck-track-studio",- "@hypit/film-studio",- "@hypit/media-track-studio",- "@hypit/ranking-studio",- "@hypit/screen-overlay-studio",- "@hypit/script-studio",- "@hypit/speech-track-studio",- "@hypit/typography-track-studio",-] as const;--export const studioProfileFilename = "hypit.studio.json";--export type StudioProfile = {- readonly format: "hypit.studio-profile@1";- readonly companionPackages: readonly string[];- readonly replace: Readonly<Record<string, string>>;-};--function object(value: unknown, subject: string): Record<string, unknown> {- if (value === null || typeof value !== "object" || Array.isArray(value)) {- throw new Error(`${subject} must be an object`);- }- return value as Record<string, unknown>;-}--function parseStudioProfile(value: unknown, path: string): StudioProfile {- const item = object(value, path);- if (item.format !== "hypit.studio-profile@1") {- throw new Error(`${path} has unsupported format ${String(item.format)}`);- }- if (!Array.isArray(item.companionPackages)- || item.companionPackages.some((entry) => typeof entry !== "string" || entry.length === 0)) {- throw new Error(`${path}.companionPackages must be an array of installed package names`);- }- const companionPackages = item.companionPackages as string[];- if (new Set(companionPackages).size !== companionPackages.length) {- throw new Error(`${path}.companionPackages repeats a package`);- }- const rawReplace = item.replace === undefined ? {} : object(item.replace, `${path}.replace`);- const replace: Record<string, string> = {};- for (const [target, replacement] of Object.entries(rawReplace)) {- if (target.length === 0 || typeof replacement !== "string" || replacement.length === 0) {- throw new Error(`${path}.replace must map companion ids to companion ids`);- }- replace[target] = replacement;- }- return { format: "hypit.studio-profile@1", companionPackages, replace };-}--/** Read only the explicit project profile. A missing conventional profile means no project Companions. */-export async function loadProjectStudioCompanions(input: {- readonly workspaceRoot: string;- readonly packageRoot: string;- readonly distributionPackageRoot?: string;- readonly profile?: string;-}): Promise<{- readonly tracks: readonly StudioTrackCompanion[];- readonly films: readonly StudioFilmCompanion[];- readonly scripts: readonly StudioScriptCompanion[];- readonly replace: Readonly<Record<string, string>>;- readonly profile?: string;-}> {- const path = resolve(input.profile ?? resolve(input.workspaceRoot, studioProfileFilename));- let text: string;- try {- text = await readFile(path, "utf8");- } catch (error) {- if (input.profile === undefined && error instanceof Error && "code" in error && error.code === "ENOENT") {- return { tracks: [], films: [], scripts: [], replace: {} };- }- throw error;- }- const profile = parseStudioProfile(JSON.parse(text), path);- const packages = await loadNodePackageSelection(profile.companionPackages, input.packageRoot, {- ...(input.distributionPackageRoot === undefined- ? {}- : { fallbackRoots: [input.distributionPackageRoot] }),- });- const bySpecifier = new Map(packages.map((item) => [item.specifier, item] as const));- const contributions = profile.companionPackages.map((specifier) => {- const item = bySpecifier.get(specifier);- if (item === undefined) throw new Error(`${path} did not resolve selected Studio companion package ${specifier}`);- const found = studioContributionFromPackage(item.specifier, item.contribution.hostFacets ?? []);- if (found.tracks.length + found.films.length + found.scripts.length === 0) {- throw new Error(`${path} selects ${item.specifier}, which provides no Studio Companion facet`);- }- return found;- });- return {- tracks: contributions.flatMap((item) => item.tracks),- films: contributions.flatMap((item) => item.films),- scripts: contributions.flatMap((item) => item.scripts),- replace: profile.replace,- profile: path,- };-}--/** Assemble the one immutable Registry shared by preflight, snapshot and UI for this session. */-export async function loadStudioCompanionRegistry(input: {- readonly workspaceRoot: string;- readonly packageRoot: string;- readonly distributionPackageRoot: string;- readonly profile?: string;-}): Promise<StudioCompanionRegistry> {- installDistributionPackageResolution([input.distributionPackageRoot]);- const officialPackages = await loadNodePackageSelection(- officialStudioCompanionPackages,- input.distributionPackageRoot,- );- const official = officialPackages.map((item) =>- studioContributionFromPackage(item.specifier, item.contribution.hostFacets ?? []));- const project = await loadProjectStudioCompanions(input);- return new StudioCompanionRegistry(- [...fallbackStudioTrackCompanions, ...official.flatMap((item) => item.tracks), ...project.tracks],- {- replace: project.replace,- films: [...official.flatMap((item) => item.films), ...project.films],- scripts: [...official.flatMap((item) => item.scripts), ...project.scripts],- },- );-}diff --git a/packages/studio/src/execute.ts b/packages/studio/src/execute.tsindex 0d0a200a..cbc53684 100644--- a/packages/studio/src/execute.ts+++ b/packages/studio/src/execute.ts@@ -1,6 +1,7 @@-import { EndpointRegistry, MemoryResourceStore, NodeDriver } from "@hypit/driver-node";+import { MemoryResourceStore, NodeDriver } from "@hypit/driver-node";import type { ResourceStore } from "@hypit/runtime";import type { BuildState } from "@hypit/protocol";+import type { RuntimeHostTransientExecution } from "@hypit/runtime-host-node";import type { StudioDomain } from "./domain.js";@@ -12,26 +13,35 @@ export type Executed = {};/**- * Run the display closure: deterministic Producers, plus Needs served by the Profile's local- * Endpoints when the caller hands them in. Nothing priced is ever installed here; a Need that- * reaches no installed Endpoint is reported as unserved, never guessed at.+ * Run the display closure: deterministic Producers, plus Needs the Runtime explicitly permits in+ * a disposable authoring execution. The Runtime owns Endpoint selection and invocation; Studio+ * never filters Providers or sees their handlers.*/-export async function executeDeterministic(+export async function executeStudioProjection(domain: StudioDomain,planned: BuildState,resources: ResourceStore,- endpoints: EndpointRegistry = new EndpointRegistry(),+ execution?: RuntimeHostTransientExecution,): Promise<Executed> {- const result = await new NodeDriver({- producers: domain.producers,- validators: domain.validators,- endpoints,- resources,- }).run(planned);+ const result = execution === undefined+ ? await new NodeDriver({+ producers: domain.producers,+ validators: domain.validators,+ resources,+ }).run(planned)+ : await execution.evaluate({+ state: planned,+ producers: domain.producers,+ validators: domain.validators,+ resources,+ });const counts = new Map<string, number>();for (const item of result.blocked) {- const need = result.state.needs.find((candidate) => item.subject.includes(candidate.capability.name));- const name = need?.capability.name ?? item.subject;+ const command = result.state.outstanding.find((candidate) => candidate.id === item.command);+ const capability = command?.kind === "fulfill-need" ? command.need.capability : undefined;+ const name = capability === undefined+ ? item.subject+ : `${capability.module.name}@${capability.module.version}#${capability.name}`;counts.set(name, (counts.get(name) ?? 0) + 1);}return {diff --git a/packages/studio/src/programme.ts b/packages/studio/src/programme.tsindex 22a15579..e338d969 100644--- a/packages/studio/src/programme.ts+++ b/packages/studio/src/programme.ts@@ -12,12 +12,11 @@ import type { SemanticTrack } from "@hypit/semantic-track";import { semanticTrackTypes } from "@hypit/semantic-track";import type { ProgramSpace } from "@hypit/program-space";import type { StudioResolvedTrack, StudioTemporalBinding } from "@hypit/studio-adapter";+import type { RuntimeHostTransientExecution } from "@hypit/runtime-host-node";import type { CompiledSource, ServedFile } from "./compile.js";import type { StudioDomain } from "./domain.js";-import type { EndpointRegistry } from "@hypit/driver-node";--import { executeDeterministic, MemoryResourceStore } from "./execute.js";+import { executeStudioProjection, MemoryResourceStore } from "./execute.js";import type { RunPlan } from "./run.js";import type { StudioViewRequirement } from "./studio-preflight.js";import { studioSurfacePreview } from "./surface-preview.js";@@ -69,7 +68,7 @@ async function bytesOf(attachment: ArtifactAttachment): Promise<Uint8Array> {return bytes;}-type ExecutionState = Awaited<ReturnType<typeof executeDeterministic>>["state"];+type ExecutionState = Awaited<ReturnType<typeof executeStudioProjection>>["state"];function selectedValue(state: ExecutionState,@@ -111,8 +110,8 @@ export async function preview(input: {readonly outputRefs: readonly string[];readonly compositionRef: string;readonly projections: readonly StudioViewRequirement[];- /** The Profile's local Endpoints, when a Runtime Profile is selected. */- readonly endpoints?: EndpointRegistry;+ /** Runtime-owned execution for capabilities explicitly safe outside a Build. */+ readonly transientExecution?: RuntimeHostTransientExecution;}): Promise<Preview> {const exportsByRef = new Map(input.source.exports.map((item) => [item.ref, item] as const));const targets = input.outputRefs.flatMap((ref) => {@@ -150,7 +149,12 @@ export async function preview(input: {},};const planned = input.run.plan(input.run.run, targets.map((target) => target.ref));- const executed = await executeDeterministic(input.domain, planned.state, resources, input.endpoints);+ const executed = await executeStudioProjection(+ input.domain,+ planned.state,+ resources,+ input.transientExecution,+ );if (executed.unserved.length > 0) {throw new Error(`Studio projection is unresolved: ${executed.unserved.map((item) => item.capability).join(", ")}`,diff --git a/packages/studio/src/server.ts b/packages/studio/src/server.tsindex e78b0223..2b67ab58 100644--- a/packages/studio/src/server.ts+++ b/packages/studio/src/server.ts@@ -146,7 +146,9 @@ export function studioPlugin(options: StudioPluginOptions): Plugin {domain: options.domain,registry: options.registry,run,- ...(options.buildLibrary?.endpoints === undefined ? {} : { endpoints: options.buildLibrary.endpoints }),+ ...(options.buildLibrary?.transientExecution === undefined+ ? {}+ : { transientExecution: options.buildLibrary.transientExecution }),revision: attempt,sourcePath: relative(options.workspaceRoot, run.authorSource),workspaceRoot: options.workspaceRoot,diff --git a/packages/studio/src/session.ts b/packages/studio/src/session.tsindex ffb32469..ae30ee2a 100644--- a/packages/studio/src/session.ts+++ b/packages/studio/src/session.ts@@ -1,8 +1,8 @@import { existsSync, readFileSync } from "node:fs";import { relative } from "node:path";-import type { EndpointRegistry } from "@hypit/driver-node";import { markupAuthorFrontendId } from "@hypit/markup";+import type { RuntimeHostTransientExecution } from "@hypit/runtime-host-node";import { svsFrontendId } from "@hypit/svs";import type { ServedFile } from "./compile.js";@@ -59,10 +59,10 @@ export async function readStudioSession(input: {readonly revision: number;readonly sourcePath?: string;readonly workspaceRoot: string;- readonly endpoints?: EndpointRegistry;+ readonly transientExecution?: RuntimeHostTransientExecution;}): Promise<StudioSession> {const source = input.run.source;- const inspection = inspectStudioRun(input.registry, source, input.run, input.endpoints);+ const inspection = inspectStudioRun(input.registry, source, input.run);const outputRefs = [inspection.filmComposition,...inspection.projections.map((projection) => projection.ref),@@ -74,7 +74,7 @@ export async function readStudioSession(input: {outputRefs,compositionRef: inspection.filmComposition,projections: inspection.projections,- ...(input.endpoints === undefined ? {} : { endpoints: input.endpoints }),+ ...(input.transientExecution === undefined ? {} : { transientExecution: input.transientExecution }),});const rendered = renderPreview({composition: built.composition,diff --git a/packages/studio/src/studio-preflight.ts b/packages/studio/src/studio-preflight.tsindex 04062531..14601db6 100644--- a/packages/studio/src/studio-preflight.ts+++ b/packages/studio/src/studio-preflight.ts@@ -1,6 +1,3 @@-import { plannedNeeds } from "@hypit/core";-import type { PlannedNeed } from "@hypit/core";-import type { EndpointRegistry } from "@hypit/driver-node";import type { Candidate } from "@hypit/protocol";import { sameType } from "@hypit/protocol";import type { StudioFilmCompanion } from "@hypit/studio-adapter";@@ -51,22 +48,6 @@ function candidateIsMaterialized(candidate: Candidate | undefined): boolean {&& candidate.root.value.value.kind === "inline";}-/**- * The capabilities of a display closure that no local Endpoint serves. With no Profile every Need- * is unserved; with one, a Need resolves exactly as `plan` and a Build resolve it, minus every- * priced Endpoint.- */-export function unservedNeeds(needs: readonly PlannedNeed[], endpoints: EndpointRegistry | undefined): readonly string[] {- return unique(needs- .filter((need) => endpoints?.resolve({ capability: need.capability, returns: need.returns }).status !== "resolved")- .map((need) => `${need.capability.module.name}@${need.capability.module.version}#${need.capability.name}`));-}--function plannedExternalNeeds(base: RunPlan, refs: readonly string[], endpoints: EndpointRegistry | undefined): readonly string[] {- const planned = base.plan(base.run, refs);- return unservedNeeds(plannedNeeds(planned.state), endpoints);-}-function localName(value: string): string {return value.includes(":") ? value.slice(value.lastIndexOf(":") + 1) : value;}@@ -104,7 +85,6 @@ export function inspectStudioRun(registry: StudioCompanionRegistry,source: CompiledSource,base: RunPlan,- endpoints?: EndpointRegistry,): StudioInspection {const issues: string[] = [];if (base.targets.length === 0) issues.push("the Run Source has no target; Studio requires Film or Render");@@ -199,17 +179,10 @@ export function inspectStudioRun(}if (derived.length > 0) {- const needs = plannedExternalNeeds(base, derived.map((projection) => projection.ref), endpoints);- if (needs.length > 0) {- issues.push(endpoints === undefined- ? `the display closure needs ${needs.join(", ")} and no Runtime Profile is selected; select one, or supply Candidates for those outputs`- : `the display closure needs ${needs.join(", ")}, which no local Endpoint of the Profile serves; supply Candidates for those outputs or build the Run`);- } else {- projections.push(...derived.map((projection) => ({- ...projection,- candidatePolicy: "deterministic-derived" as const,- })));- }+ projections.push(...derived.map((projection) => ({+ ...projection,+ candidatePolicy: "deterministic-derived" as const,+ })));}if (issues.length > 0) throw new StudioPreflightError(issues);return {diff --git a/packages/studio/src/studio-registry.ts b/packages/studio/src/studio-registry.tsindex 3039efd0..b536abd2 100644--- a/packages/studio/src/studio-registry.ts+++ b/packages/studio/src/studio-registry.ts@@ -153,7 +153,6 @@ export class StudioCompanionRegistry {constructor(tracks: readonly StudioTrackCompanion[],options: {- readonly replace?: Readonly<Record<string, string>>;readonly films?: readonly StudioFilmCompanion[];readonly scripts?: readonly StudioScriptCompanion[];} = {},@@ -176,23 +175,9 @@ export class StudioCompanionRegistry {ids.add(companion.id);}}- const kind = new Map<string, "track" | "film" | "script">([- ...tracks.map((item) => [item.id, "track"] as const),- ...films.map((item) => [item.id, "film"] as const),- ...scripts.map((item) => [item.id, "script"] as const),- ]);- const replacements = options.replace ?? {};- for (const [target, replacement] of Object.entries(replacements)) {- if (!ids.has(target)) throw new Error(`Studio companion replacement target does not exist: ${target}`);- if (!ids.has(replacement)) throw new Error(`Studio companion replacement does not exist: ${replacement}`);- if (target === replacement) throw new Error(`Studio companion cannot replace itself: ${target}`);- if (kind.get(target) !== kind.get(replacement)) {- throw new Error(`Studio companion replacement must keep its kind: ${target} -> ${replacement}`);- }- }- this.#tracks = Object.freeze(tracks.filter((companion) => !(companion.id in replacements)));- this.#films = Object.freeze(films.filter((film) => !(film.id in replacements)));- this.#scripts = Object.freeze(scripts.filter((script) => !(script.id in replacements)));+ this.#tracks = Object.freeze([...tracks]);+ this.#films = Object.freeze(films);+ this.#scripts = Object.freeze(scripts);}filmCompanionFor(diff --git a/packages/studio/start.ts b/packages/studio/start.tsindex dfc65669..14283cab 100644--- a/packages/studio/start.ts+++ b/packages/studio/start.ts@@ -3,10 +3,10 @@ import { fileURLToPath } from "node:url";import { createServer } from "vite";import { findRuntimeProfile, resolveProjectRoot } from "@hypit/cli";-import { videoCliDistribution } from "@hypit/video-cli";+import { videoCliDistribution, videoStudioCompanionPackages } from "@hypit/video-cli";import { openStudioBuildLibrary } from "./src/build-library.js";-import { loadStudioCompanionRegistry } from "./src/companion-profile.js";+import { loadStudioCompanionRegistry } from "./src/companion-assembly.js";import { loadStudioDomain } from "./src/domain.js";import { loadStudioRun } from "./src/run.js";import { studioPlugin } from "./src/server.js";@@ -19,7 +19,6 @@ function usage(message?: string): never {process.stderr.write(`Usage:hypit-studio --run <build.svrun> [--runtime <hypit.runtime.json>][--port <number>] [--workspace <directory>] [--package-root <directory>]- [--studio-profile <hypit.studio.json>]Studio opens one explicit Run Source, requires a Film/Render target and aresolved deterministic semantic projection, and writes only the selected file@@ -29,6 +28,7 @@ inside that exact Run and Author Source closure.}function argumentsByName(argv: readonly string[]): ReadonlyMap<string, string> {+ const accepted = new Set(["run", "runtime", "port", "workspace", "package-root"]);const result = new Map<string, string>();for (let index = 0; index < argv.length; index += 2) {const flag = argv[index];@@ -36,7 +36,9 @@ function argumentsByName(argv: readonly string[]): ReadonlyMap<string, string> {if (flag === undefined || !flag.startsWith("--") || value === undefined || value.startsWith("--")) {usage(`Malformed argument near ${flag ?? "end of command"}`);}- result.set(flag.slice(2), value);+ const name = flag.slice(2);+ if (!accepted.has(name)) usage(`Unknown option --${name}`);+ result.set(name, value);}return result;}@@ -66,19 +68,16 @@ const selectedRuntime = runtimeArgument === undefinedconst runtimePath = runtimeArgument === undefined? selectedRuntime?.profile: resolve(invokedFrom, runtimeArgument);-const studioProfileArgument = values.get("studio-profile");-const studioProfilePath = studioProfileArgument === undefined ? undefined : resolve(invokedFrom, studioProfileArgument);const port = Number(values.get("port") ?? "5179");if (!Number.isSafeInteger(port) || port <= 0) usage("--port must be a positive integer");const distributionPackageRoot = videoCliDistribution.packageRoot ?? resolve(here, "../..");+const domain = await loadStudioDomain({ run: runPath, workspaceRoot, packageRoot });const registry = await loadStudioCompanionRegistry({- workspaceRoot,- packageRoot,distributionPackageRoot,- ...(studioProfilePath === undefined ? {} : { profile: studioProfilePath }),+ distributionPackages: videoStudioCompanionPackages,+ sourcePackages: domain.packages,});-const domain = await loadStudioDomain({ run: runPath, workspaceRoot, packageRoot });const buildLibrary = await openStudioBuildLibrary(runtimePath, packageRoot, workspaceRoot, distributionPackageRoot);let run;try {@@ -94,7 +93,7 @@ try {}const source = run.authorSource;try {- inspectStudioRun(registry, run.source, run, buildLibrary.endpoints);+ inspectStudioRun(registry, run.source, run);} catch (error) {await buildLibrary.close();throw error;@@ -119,5 +118,10 @@ const server = await createServer({...(buildLibrary === undefined ? {} : { buildLibrary }),})],});+server.httpServer?.once("close", () => {+ void buildLibrary.close().catch((error: unknown) => {+ console.error(error instanceof Error ? error.message : String(error));+ });+});await server.listen();server.printUrls();diff --git a/packages/studio/test/companion-assembly.test.ts b/packages/studio/test/companion-assembly.test.tsnew file mode 100644index 00000000..2e60522a--- /dev/null+++ b/packages/studio/test/companion-assembly.test.ts@@ -0,0 +1,31 @@+import assert from "node:assert/strict";+import test from "node:test";++import { compositionTypes } from "@hypit/composition";+import { createStudioTrackCompanionHostFacet } from "@hypit/studio-adapter";++import { loadStudioCompanionRegistry } from "../src/companion-assembly.js";++test("a Source-selected package contributes its Companion without a second Studio profile", async () => {+ const module = { name: "@project/cards", version: "1" } as const;+ const registry = await loadStudioCompanionRegistry({+ distributionPackageRoot: process.cwd(),+ distributionPackages: [],+ sourcePackages: [{+ specifier: "@project/cards",+ contribution: {+ format: "hypit.node-package@1",+ hostFacets: [createStudioTrackCompanionHostFacet([{+ id: "cards",+ role: "track",+ family: "cards",+ output: { type: compositionTypes.visualTrack, surface: "track", modules: [module] },+ }])],+ },+ }],+ });+ assert.equal(+ registry.trackCompanionFor(compositionTypes.visualTrack, { surface: "track", module }, [])?.id,+ "@project/cards#cards",+ );+});diff --git a/packages/studio/test/preflight.test.ts b/packages/studio/test/preflight.test.tsindex b857e298..a8f53306 100644--- a/packages/studio/test/preflight.test.ts+++ b/packages/studio/test/preflight.test.ts@@ -2,14 +2,12 @@ import assert from "node:assert/strict";import test from "node:test";import { compositionTypes } from "@hypit/composition";-import type { PlannedNeed } from "@hypit/core";-import { EndpointRegistry } from "@hypit/driver-node";import { semanticTrackTypes } from "@hypit/semantic-track";import type { StudioFilmCompanion, StudioPlacement } from "@hypit/studio-adapter";import type { CompiledSource } from "../src/compile.js";import type { RunPlan } from "../src/run.js";-import { inspectStudioRun, StudioPreflightError, unservedNeeds } from "../src/studio-preflight.js";+import { inspectStudioRun, StudioPreflightError } from "../src/studio-preflight.js";import { StudioCompanionRegistry } from "../src/studio-registry.js";const filmModule = { name: "@example/film", version: "1" } as const;@@ -50,20 +48,3 @@ test("Studio rejects a Run that reaches two distinct Film compositions", () => {&& error.issues.some((issue) => issue.includes("multiple Film compositions")),);});--test("the display closure may reach a Need only through a local Endpoint the Profile installed", () => {- const normalize = { module: { name: "@hypit/media-pipeline", version: "1" }, name: "normalize-media" } as const;- const generate = { module: { name: "@hypit/seedance", version: "1" }, name: "seedance-2-mini" } as const;- const returns = { module: { name: "@hypit/artifact", version: "1" }, name: "BlobArtifact" } as const;- const needs: PlannedNeed[] = [- { step: "step:a", port: "media", need: "need:a", result: "record:a", capability: normalize, returns },- { step: "step:b", port: "video", need: "need:b", result: "record:b", capability: generate, returns },- ] as unknown as PlannedNeed[];- assert.deepEqual(unservedNeeds(needs, undefined), ["@hypit/media-pipeline@1#normalize-media", "@hypit/seedance@1#seedance-2-mini"]);- const endpoints = new EndpointRegistry();- endpoints.registerImmediateEndpoint("media.local", normalize, returns, () => ({ value: { kind: "inline", value: null } }));- assert.deepEqual(unservedNeeds(needs, endpoints), ["@hypit/seedance@1#seedance-2-mini"]);- endpoints.bind(normalize, "media.other");- assert.deepEqual(unservedNeeds(needs, endpoints), ["@hypit/media-pipeline@1#normalize-media", "@hypit/seedance@1#seedance-2-mini"],- "a binding to an Endpoint that is not installed for display leaves the Need unserved");-});diff --git a/packages/video-cli/src/distribution.ts b/packages/video-cli/src/distribution.tsindex 820458ce..a88155c8 100644--- a/packages/video-cli/src/distribution.ts+++ b/packages/video-cli/src/distribution.ts@@ -14,6 +14,10 @@ import {// package's source directory and never the author's project.const packageRoot = resolve(process.env.HYPIT_DISTRIBUTION_ROOT ?? resolve(import.meta.dirname, "../../.."));const installedLauncher = process.env.HYPIT_CLI_LAUNCHER;+const defaultBuildResultRepository = {+ use: "@hypit/build-result-fs",+ config: { path: ".hypit/results" },+} as const;/** Official video authoring assembly for the generic CLI engine. */export const videoCliDistribution: CliDistribution = {@@ -64,7 +68,11 @@ export const videoCliDistribution: CliDistribution = {},}),openProjectResults: async (projectRoot, options) => {- const opened = await openProjectBuildResultRepository(projectRoot, options);+ const opened = await openProjectBuildResultRepository(projectRoot, {+ ...options,+ distributionPackageRoot: options.distributionPackageRoot ?? packageRoot,+ defaultSelection: defaultBuildResultRepository,+ });return {location: opened.location,repository: opened.repository,@@ -72,5 +80,9 @@ export const videoCliDistribution: CliDistribution = {};},diagnoseProjectResults: async (projectRoot, options) =>- await doctorProjectBuildResultRepository(projectRoot, options),+ await doctorProjectBuildResultRepository(projectRoot, {+ ...options,+ distributionPackageRoot: options.distributionPackageRoot ?? packageRoot,+ defaultSelection: defaultBuildResultRepository,+ }),};diff --git a/packages/video-cli/src/index.ts b/packages/video-cli/src/index.tsindex 8b9433e8..c610e477 100644--- a/packages/video-cli/src/index.ts+++ b/packages/video-cli/src/index.ts@@ -16,6 +16,7 @@ export {createVideoCompiler,} from "./compiler.js";export { videoCliDistribution } from "./distribution.js";+export { videoStudioCompanionPackages } from "./studio-distribution.js";export { discoverVideoSourcePackages } from "./package-selection.js";export { creationCommands, isCreationCommand, runCreationCli, writeCreationHelp } from "./creation.js";export type { CreationCommand, CreationEnvironment, CreationHost } from "./creation.js";diff --git a/packages/video-cli/src/media.ts b/packages/video-cli/src/media.tsindex c145f831..9968bb48 100644--- a/packages/video-cli/src/media.ts+++ b/packages/video-cli/src/media.ts@@ -1,10 +1,11 @@-import { mkdir, stat } from "node:fs/promises";+import { mkdir, mkdtemp, readFile, rename, rm, stat } from "node:fs/promises";+import { tmpdir } from "node:os";import { dirname, extname, join, resolve } from "node:path";import type { CliIo } from "@hypit/cli";import { downloadVideo, isVideoUrl } from "@hypit/yt-dlp";-import { runProcess } from "./process.js";+import { runProcess, runProcessWithInput } from "./process.js";/*** Media preparation for the eyes: dumb, local, stateless.@@ -16,7 +17,7 @@ import { runProcess } from "./process.js";* a file. Each writes exactly what the caller named and nothing else; none decides what the video is.*/-export const mediaCommands = ["probe", "cut", "frames", "tile", "shots", "fetch"] as const;+export const mediaCommands = ["probe", "cut", "frames", "tile", "tiles", "boundaries", "fetch"] as const;export type MediaCommand = typeof mediaCommands[number];function assert(condition: unknown, message: string): asserts condition {@@ -36,12 +37,14 @@ function clamp(value: number, low: number, high: number): number { return Math.mtype Parsed = {readonly positionals: readonly string[];readonly options: ReadonlyMap<string, string>;+ readonly flags: ReadonlySet<string>;readonly json: boolean;};-function parseArguments(argv: readonly string[], allowed: readonly string[]): Parsed {+function parseArguments(argv: readonly string[], allowed: readonly string[], allowedFlags: readonly string[] = []): Parsed {const positionals: string[] = [];const options = new Map<string, string>();+ const flags = new Set<string>();let json = false;for (let index = 0; index < argv.length; index += 1) {const item = argv[index]!;@@ -49,6 +52,11 @@ function parseArguments(argv: readonly string[], allowed: readonly string[]): Paif (item === "--debug" || item === "--verbose" || item === "--no-color") continue;if (item === "--color") { index += 1; continue; }if (!item.startsWith("--")) { positionals.push(item); continue; }+ if (allowedFlags.includes(item)) {+ if (flags.has(item)) throw new Error(`${item} cannot be repeated`);+ flags.add(item);+ continue;+ }if (!allowed.includes(item)) throw new Error(`unknown option ${item}`);if (options.has(item)) throw new Error(`${item} cannot be repeated`);const value = argv[index + 1];@@ -56,7 +64,7 @@ function parseArguments(argv: readonly string[], allowed: readonly string[]): Paoptions.set(item, value);index += 1;}- return { positionals, options, json };+ return { positionals, options, flags, json };}function required(parsed: Parsed, option: string, hint: string): string {@@ -84,9 +92,26 @@ function integerOption(parsed: Parsed, option: string, fallback: number, low: nureturn value;}+function numberOption(parsed: Parsed, option: string, fallback: number, low: number, high: number): number {+ const raw = parsed.options.get(option);+ if (raw === undefined) return fallback;+ const value = Number(raw);+ assert(Number.isFinite(value) && value >= low && value <= high, `${option} must be between ${low} and ${high}, got ${raw}`);+ return value;+}++function secondsList(raw: string, option: string, minimum: number): number[] {+ const parts = raw.split(",").map((item) => item.trim());+ assert(parts.length >= minimum && parts.every((item) => item.length > 0), `${option} must list at least ${minimum} seconds, got ${raw}`);+ const values = parts.map(Number);+ assert(values.every((value) => Number.isFinite(value) && value >= 0), `${option} must list non-negative seconds, got ${raw}`);+ return values;+}+async function sourceFile(parsed: Parsed, cwd: string): Promise<string> {const [source] = parsed.positionals;assert(source !== undefined, "name the media file first");+ assert(parsed.positionals.length === 1, "media commands take exactly one media file");const path = resolve(cwd, source);assert(await stat(path).then((item) => item.isFile(), () => false), `cannot read ${path}`);return path;@@ -99,6 +124,13 @@ async function destination(parsed: Parsed, cwd: string, hint: string): Promise<sreturn to;}+async function destinationDirectory(parsed: Parsed, cwd: string, hint: string): Promise<string> {+ const to = resolve(cwd, required(parsed, "--to", hint));+ assert(!(await stat(to).then(() => true, () => false)), `Destination ${to} already exists`);+ await mkdir(dirname(to), { recursive: true });+ return to;+}+// ---------------------------------------------------------------------------------------------------// ffmpeg@@ -152,16 +184,130 @@ function openAt(source: string, at: number): readonly string[] {// unless told which it is writing (`Non full-range YUV is non-standard`).const JPEG = ["-pix_fmt", "yuvj420p", "-q:v", "3"] as const;-export async function cutClip(source: string, start: number, end: number, target: string): Promise<void> {+const GLYPHS: Readonly<Record<string, readonly string[]>> = {+ "0": ["11111", "10001", "10011", "10101", "11001", "10001", "11111"],+ "1": ["00100", "01100", "00100", "00100", "00100", "00100", "01110"],+ "2": ["11110", "00001", "00001", "11110", "10000", "10000", "11111"],+ "3": ["11110", "00001", "00001", "01110", "00001", "00001", "11110"],+ "4": ["10010", "10010", "10010", "11111", "00010", "00010", "00010"],+ "5": ["11111", "10000", "10000", "11110", "00001", "00001", "11110"],+ "6": ["01111", "10000", "10000", "11110", "10001", "10001", "01110"],+ "7": ["11111", "00001", "00010", "00100", "01000", "01000", "01000"],+ "8": ["01110", "10001", "10001", "01110", "10001", "10001", "01110"],+ "9": ["01110", "10001", "10001", "01111", "00001", "00001", "11110"],+ ":": ["00000", "00100", "00100", "00000", "00100", "00100", "00000"],+ ".": ["00000", "00000", "00000", "00000", "00000", "00100", "00100"],+};++function timecode(seconds: number): string {+ const milliseconds = Math.max(0, Math.round(seconds * 1_000));+ const hours = Math.floor(milliseconds / 3_600_000);+ const minutes = Math.floor(milliseconds / 60_000) % 60;+ const wholeSeconds = Math.floor(milliseconds / 1_000) % 60;+ const remainder = milliseconds % 1_000;+ return `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}:${String(wholeSeconds).padStart(2, "0")}.${String(remainder).padStart(3, "0")}`;+}++type RasterLabel = {+ readonly width: number;+ readonly height: number;+ readonly bytes: Buffer;+};++/** A tiny built-in numeric face keeps evidence labels available even when ffmpeg lacks drawtext. */+function rasterLabel(text: string, requestedWidth?: number): RasterLabel {+ const scale = requestedWidth === undefined+ ? 3+ : clamp(Math.min(Math.floor((requestedWidth - 8) / (text.length * 6)), Math.floor(requestedWidth / 240) + 1), 1, 3);+ const padding = scale * 2;+ const naturalWidth = padding * 2 + text.length * 6 * scale - scale;+ const width = Math.max(requestedWidth ?? naturalWidth, naturalWidth);+ const rawHeight = padding * 2 + 7 * scale;+ const height = rawHeight + rawHeight % 2;+ const bytes = Buffer.alloc(width * height * 3, 12);+ let left = padding;+ for (const character of text) {+ const glyph = GLYPHS[character];+ assert(glyph !== undefined, `cannot draw time label character ${character}`);+ for (let row = 0; row < glyph.length; row += 1) {+ for (let column = 0; column < glyph[row]!.length; column += 1) {+ if (glyph[row]![column] !== "1") continue;+ for (let y = 0; y < scale; y += 1) {+ for (let x = 0; x < scale; x += 1) {+ const pixel = ((padding + row * scale + y) * width + left + column * scale + x) * 3;+ bytes[pixel] = 245;+ bytes[pixel + 1] = 245;+ bytes[pixel + 2] = 245;+ }+ }+ }+ }+ left += 6 * scale;+ }+ return { width, height, bytes };+}++function rawVideoInput(label: RasterLabel, frameRate: number): readonly string[] {+ return [+ "-f", "rawvideo", "-pixel_format", "rgb24", "-video_size", `${label.width}x${label.height}`,+ "-framerate", String(frameRate), "-i", "pipe:0",+ ];+}++export async function cutClip(+ source: string,+ start: number,+ end: number,+ target: string,+ labelInfo?: Pick<MediaProbe, "frameRate">,+): Promise<void> {assert(end > start, `the clip must end after it starts (${start} to ${end})`);- await runProcess("ffmpeg", [- "-hide_banner", "-loglevel", "error", "-y", ...openAt(source, start), "-t", String(round(end - start)),- "-c:v", "libx264", "-preset", "veryfast", "-crf", "23", "-c:a", "aac", "-b:a", "96k", "-movflags", "+faststart", target,- ]);+ const seconds = round(end - start);+ const common = ["-c:v", "libx264", "-preset", "veryfast", "-crf", "23", "-c:a", "aac", "-b:a", "96k", "-movflags", "+faststart"];+ if (labelInfo === undefined) {+ await runProcess("ffmpeg", [+ "-hide_banner", "-loglevel", "error", "-y", ...openAt(source, start), "-t", String(seconds), ...common, target,+ ]);+ return;+ }+ const temporary = await mkdtemp(join(tmpdir(), "hypit-labeled-clip-"));+ const clean = join(temporary, "clean.mp4");+ try {+ await cutClip(source, start, end, clean);+ const rate = clamp(Math.ceil(labelInfo.frameRate || 10), 1, 30);+ const count = Math.max(1, Math.ceil(seconds * rate));+ const first = rasterLabel(timecode(start));+ function* labels(): Iterable<Uint8Array> {+ yield first.bytes;+ for (let index = 1; index < count; index += 1) yield rasterLabel(timecode(start + index / rate)).bytes;+ }+ await runProcessWithInput("ffmpeg", [+ "-hide_banner", "-loglevel", "error", "-y", "-i", clean, ...rawVideoInput(first, rate),+ "-t", String(seconds), "-filter_complex", "[0:v][1:v]overlay=8:8:eof_action=repeat[v]",+ "-map", "[v]", "-map", "0:a?", ...common, target,+ ], labels());+ } finally {+ await rm(temporary, { recursive: true, force: true });+ }}-export async function cutFrame(source: string, at: number, target: string): Promise<void> {- await runProcess("ffmpeg", ["-hide_banner", "-loglevel", "error", "-y", ...openAt(source, at), "-frames:v", "1", ...JPEG, target]);+export async function cutFrame(source: string, at: number, target: string, labelTime = false): Promise<void> {+ if (!labelTime) {+ await runProcess("ffmpeg", ["-hide_banner", "-loglevel", "error", "-y", ...openAt(source, at), "-frames:v", "1", ...JPEG, target]);+ return;+ }+ const temporary = await mkdtemp(join(tmpdir(), "hypit-labeled-frame-"));+ const clean = join(temporary, "clean.jpg");+ try {+ await cutFrame(source, at, clean);+ const label = rasterLabel(timecode(at));+ await runProcessWithInput("ffmpeg", [+ "-hide_banner", "-loglevel", "error", "-y", "-i", clean, ...rawVideoInput(label, 1),+ "-filter_complex", "[0:v][1:v]overlay=8:8[out]", "-map", "[out]", "-frames:v", "1", ...JPEG, target,+ ], label.bytes);+ } finally {+ await rm(temporary, { recursive: true, force: true });+ }}const TILE_COLUMNS = 3;@@ -169,58 +315,79 @@ const TILE_CELL_WIDTH = 480;/** Four frames show what moves in a one-second shot; nine keep a fifteen-second one legible. */export function tileFrameCount(seconds: number): number { return clamp(Math.round(seconds * 1.5), 4, 9); }+export function tileSampleTimes(start: number, end: number, frameCount: number): readonly number[] {+ assert(end > start, `the stretch must end after it starts (${start} to ${end})`);+ assert(Number.isSafeInteger(frameCount) && frameCount >= 2, "a grid needs at least two frames");+ return Array.from({ length: frameCount }, (_, index) => round(start + (index + 0.5) * (end - start) / frameCount));+}++async function labeledTileCell(source: string, at: number, target: string, cellWidth: number): Promise<void> {+ const clean = `${target}.clean.jpg`;+ try {+ await cutFrame(source, at, clean);+ const label = rasterLabel(timecode(at), cellWidth);+ await runProcessWithInput("ffmpeg", [+ "-hide_banner", "-loglevel", "error", "-y", "-i", clean, ...rawVideoInput(label, 1),+ "-filter_complex", `[0:v]scale=${cellWidth}:-2[frame];[frame][1:v]vstack=inputs=2[out]`,+ "-map", "[out]", "-frames:v", "1", ...JPEG, target,+ ], label.bytes);+ } finally {+ await rm(clean, { force: true });+ }+}+export async function tileFrames(source: string,- start: number,- end: number,+ times: readonly number[],target: string,cellWidth: number,- frameCount: number,+ columns: number,): Promise<void> {- assert(end > start, `the stretch must end after it starts (${start} to ${end})`);- const seconds = end - start;- const rows = Math.ceil(frameCount / TILE_COLUMNS);- const rate = frameCount / Math.max(seconds, 0.1);- await runProcess("ffmpeg", [- "-hide_banner", "-loglevel", "error", "-y", ...openAt(source, start), "-t", String(round(seconds)),- "-vf", `fps=${rate},scale='min(${Math.round(cellWidth)},iw)':-2,tile=layout=${TILE_COLUMNS}x${rows}:padding=8:margin=8:color=black`,- "-frames:v", "1", ...JPEG, target,- ]);+ assert(times.length >= 2, "a grid needs at least two frames");+ const temporary = await mkdtemp(join(tmpdir(), "hypit-tile-"));+ try {+ for (let index = 0; index < times.length; index += 1) {+ await labeledTileCell(source, times[index]!, join(temporary, `cell-${String(index).padStart(4, "0")}.jpg`), cellWidth);+ }+ const rows = Math.ceil(times.length / columns);+ await runProcess("ffmpeg", [+ "-hide_banner", "-loglevel", "error", "-y", "-framerate", "1", "-pattern_type", "glob",+ "-i", join(temporary, "cell-*.jpg"),+ "-vf", `tile=layout=${columns}x${rows}:nb_frames=${times.length}:padding=8:margin=8:color=black`,+ "-frames:v", "1", ...JPEG, target,+ ]);+ } finally {+ await rm(temporary, { recursive: true, force: true });+ }}/**- * Where the picture jumps, at 12 samples per second of 32×32 signatures.- *- * At three samples a second a boundary overshot by a third of a second, long enough for an observer- * to describe a shot as the picture before it. A jump closer than one second to the previous one is a- * flicker, flash frame or fast pan rather than a shot, and a clip that short is refused by the model- * anyway; a final fragment that short belongs to the shot before it.+ * Adjacent-frame visual change candidates. Scores are mechanical evidence, not editorial shots.*/-const SAMPLE_RATE = 12;-const SHORTEST_SHOT = 1;-export async function shotBoundaries(source: string, duration: number): Promise<readonly { readonly start: number; readonly end: number }[]> {+const DEFAULT_BOUNDARY_RATE = 12;+const DEFAULT_BOUNDARY_THRESHOLD = 0.1;+export type VisualBoundary = { readonly at: number; readonly score: number };+export async function visualBoundaries(+ source: string,+ sampleRate = DEFAULT_BOUNDARY_RATE,+ threshold = DEFAULT_BOUNDARY_THRESHOLD,+): Promise<readonly VisualBoundary[]> {const bytes = await runProcess("ffmpeg", [- "-hide_banner", "-loglevel", "error", "-i", source, "-vf", `fps=${SAMPLE_RATE},scale=32:32,format=rgb24`, "-f", "rawvideo", "-",+ "-hide_banner", "-loglevel", "error", "-i", source, "-vf", `fps=${sampleRate},scale=32:32,format=rgb24`, "-f", "rawvideo", "-",]);const stride = 32 * 32 * 3;const frames: Uint8Array[] = [];for (let index = 0; index + stride <= bytes.byteLength; index += stride) frames.push(bytes.subarray(index, index + stride));- const starts = [0];- if (frames.length >= 2) {- let anchor = frames[0]!;- for (let index = 1; index < frames.length; index += 1) {- const frame = frames[index]!;- let total = 0;- for (let byte = 0; byte < frame.length; byte += 1) total += Math.abs(frame[byte]! - anchor[byte]!);- if (total / frame.length / 255 > 0.1) {- const at = round(index / SAMPLE_RATE);- if (at - starts.at(-1)! >= SHORTEST_SHOT) starts.push(at);- anchor = frame;- }- }+ const candidates: VisualBoundary[] = [];+ for (let index = 1; index < frames.length; index += 1) {+ const before = frames[index - 1]!;+ const after = frames[index]!;+ let total = 0;+ for (let byte = 0; byte < after.length; byte += 1) total += Math.abs(after[byte]! - before[byte]!);+ const score = total / after.length / 255;+ if (score >= threshold) candidates.push({ at: round(index / sampleRate), score: round(score) });}- if (starts.length > 1 && duration - starts.at(-1)! < SHORTEST_SHOT) starts.pop();- return starts.map((start, index) => ({ start, end: round(starts[index + 1] ?? duration) }));+ return candidates;}// ---------------------------------------------------------------------------------------------------@@ -235,20 +402,21 @@ async function probe(argv: readonly string[], io: CliIo, cwd: string): Promise<v}async function cut(argv: readonly string[], io: CliIo, cwd: string): Promise<void> {- const parsed = parseArguments(argv, ["--start", "--end", "--to"]);+ const parsed = parseArguments(argv, ["--start", "--end", "--to"], ["--label-time"]);const source = await sourceFile(parsed, cwd);const start = secondsOption(parsed, "--start", 0);const info = await probeMedia(source);const end = secondsOption(parsed, "--end", info.duration);assert(end <= info.duration + 0.001, `--end ${end} is past the end of the file (${info.duration} s)`);const target = await destination(parsed, cwd, "the clip to write, for example notes/hook.mp4");- await cutClip(source, start, end, target);- if (parsed.json) { io.write(`${JSON.stringify({ path: target, start, end, seconds: round(end - start) }, null, 2)}\n`); return; }- io.write(`${target}\n ${start} s to ${end} s (${round(end - start)} s)\n`);+ const labeled = parsed.flags.has("--label-time");+ await cutClip(source, start, end, target, labeled ? info : undefined);+ if (parsed.json) { io.write(`${JSON.stringify({ path: target, start, end, seconds: round(end - start), labeled }, null, 2)}\n`); return; }+ io.write(`${target}\n ${start} s to ${end} s (${round(end - start)} s)${labeled ? ", source time visible" : ""}\n`);}async function frames(argv: readonly string[], io: CliIo, cwd: string): Promise<void> {- const parsed = parseArguments(argv, ["--at", "--every", "--to"]);+ const parsed = parseArguments(argv, ["--at", "--every", "--to"], ["--label-time"]);const source = await sourceFile(parsed, cwd);const info = await probeMedia(source);const at = parsed.options.get("--at");@@ -256,60 +424,134 @@ async function frames(argv: readonly string[], io: CliIo, cwd: string): Promise<assert((at === undefined) !== (every === undefined), "name the seconds with --at <s,s,…> or sample with --every <seconds>, not both");let times: number[];if (at !== undefined) {- times = at.split(",").map((item) => Number(item.trim()));- assert(times.every((value) => Number.isFinite(value) && value >= 0), `--at must list seconds, got ${at}`);+ times = secondsList(at, "--at", 1);} else {const step = Number(every);assert(Number.isFinite(step) && step > 0, `--every must be a positive number of seconds, got ${every}`);times = [];for (let time = 0; time < info.duration; time += step) times.push(round(time));}- assert(times.every((value) => value <= info.duration), `a time is past the end of the file (${info.duration} s)`);- const to = resolve(cwd, required(parsed, "--to", "the directory to write the frames into"));- assert(!(await stat(to).then((item) => item.isFile(), () => false)), `${to} is a file; --to names a directory`);- await mkdir(to, { recursive: true });+ assert(times.length > 0, "name at least one frame time");+ assert(times.every((value) => value < info.duration), `a frame time must be before the end of the file (${info.duration} s)`);+ assert(new Set(times.map((value) => value.toFixed(3))).size === times.length, "frame times must be distinct to the nearest millisecond");+ const to = await destinationDirectory(parsed, cwd, "the new directory to write the frames into");+ const staging = await mkdtemp(join(dirname(to), ".hypit-frames-"));+ const labeled = parsed.flags.has("--label-time");const written: { readonly at: number; readonly path: string }[] = [];- for (const time of times) {- const target = join(to, `frame-${time.toFixed(2).replace(".", "_")}s.jpg`);- assert(!(await stat(target).then(() => true, () => false)), `${target} already exists`);- await cutFrame(source, time, target);- written.push({ at: time, path: target });+ try {+ for (const time of times) {+ const name = `frame-${time.toFixed(3).replace(".", "_")}s.jpg`;+ await cutFrame(source, time, join(staging, name), labeled);+ written.push({ at: time, path: join(to, name) });+ }+ await rename(staging, to);+ } catch (error) {+ await rm(staging, { recursive: true, force: true });+ throw error;}- if (parsed.json) { io.write(`${JSON.stringify({ directory: to, frames: written }, null, 2)}\n`); return; }- io.write(`${to}\n${written.map((item) => ` ${item.at} s ${item.path}`).join("\n")}\n`);+ if (parsed.json) { io.write(`${JSON.stringify({ directory: to, labeled, frames: written }, null, 2)}\n`); return; }+ io.write(`${to}\n ${written.length} ${labeled ? "time-labeled " : ""}${written.length === 1 ? "frame" : "frames"} from ${written[0]!.at} s to ${written.at(-1)!.at} s\n`);}async function tile(argv: readonly string[], io: CliIo, cwd: string): Promise<void> {- const parsed = parseArguments(argv, ["--start", "--end", "--frames", "--cell", "--to"]);+ const parsed = parseArguments(argv, ["--start", "--end", "--at", "--frames", "--cell", "--columns", "--to"]);const source = await sourceFile(parsed, cwd);const info = await probeMedia(source);- const start = secondsOption(parsed, "--start", 0);- const end = secondsOption(parsed, "--end", info.duration);- assert(end <= info.duration + 0.001, `--end ${end} is past the end of the file (${info.duration} s)`);- const count = integerOption(parsed, "--frames", tileFrameCount(end - start), 2);- // Never enlarge a small source: a grid drawn wider than the video carries the same pixels as more.- const cell = integerOption(parsed, "--cell", Math.min(TILE_CELL_WIDTH, info.width), 64);+ const explicit = parsed.options.get("--at");+ let times: readonly number[];+ if (explicit !== undefined) {+ assert(!parsed.options.has("--start") && !parsed.options.has("--end") && !parsed.options.has("--frames"), "--at cannot be combined with --start, --end or --frames");+ times = secondsList(explicit, "--at", 2);+ } else {+ const start = secondsOption(parsed, "--start", 0);+ const end = secondsOption(parsed, "--end", info.duration);+ assert(end <= info.duration + 0.001, `--end ${end} is past the end of the file (${info.duration} s)`);+ const count = integerOption(parsed, "--frames", tileFrameCount(end - start), 2);+ times = tileSampleTimes(start, end, count);+ }+ assert(times.every((value) => value < info.duration), `a sample time must be before the end of the file (${info.duration} s)`);+ assert(times.every((value, index) => index === 0 || value > times[index - 1]!), "sample times must be strictly increasing");+ // Preserve source width unless an exceptionally tiny input needs room for a legible timecode.+ const cell = integerOption(parsed, "--cell", Math.max(80, Math.min(TILE_CELL_WIDTH, info.width)), 80);+ const columns = integerOption(parsed, "--columns", TILE_COLUMNS, 1);const target = await destination(parsed, cwd, "the grid image to write, for example notes/hook-grid.jpg");- await tileFrames(source, start, end, target, cell, count);- const rows = Math.ceil(count / TILE_COLUMNS);- if (parsed.json) { io.write(`${JSON.stringify({ path: target, start, end, frames: count, columns: TILE_COLUMNS, rows, cellWidth: cell }, null, 2)}\n`); return; }- io.write(`${target}\n ${count} frames from ${start} s to ${end} s, ${TILE_COLUMNS}×${rows}, ${cell} px cells, reading order left to right then top to bottom\n`);+ await tileFrames(source, times, target, cell, columns);+ const rows = Math.ceil(times.length / columns);+ if (parsed.json) { io.write(`${JSON.stringify({ path: target, samples: times, columns, rows, cellWidth: cell }, null, 2)}\n`); return; }+ io.write(`${target}\n ${times.length} labeled frames, ${columns}×${rows}, ${cell} px cells\n ${times.map((at) => `${at} s`).join(" ")}\n`);}-async function shots(argv: readonly string[], io: CliIo, cwd: string): Promise<void> {- const parsed = parseArguments(argv, []);+type TileRange = {+ readonly id?: string;+ readonly start: number;+ readonly end: number;+ readonly frames?: number;+};++function tileRange(value: unknown, index: number, duration: number): TileRange {+ assert(typeof value === "object" && value !== null && !Array.isArray(value), `range ${index + 1} must be an object`);+ const raw = value as Record<string, unknown>;+ assert(typeof raw.start === "number" && Number.isFinite(raw.start) && raw.start >= 0, `range ${index + 1}.start must be non-negative seconds`);+ assert(typeof raw.end === "number" && Number.isFinite(raw.end) && raw.end > raw.start, `range ${index + 1}.end must be after its start`);+ assert(raw.end <= duration + 0.001, `range ${index + 1}.end is past the end of the file (${duration} s)`);+ assert(raw.id === undefined || (typeof raw.id === "string" && /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(raw.id)), `range ${index + 1}.id must be a safe file name`);+ assert(raw.frames === undefined || (Number.isSafeInteger(raw.frames) && (raw.frames as number) >= 2), `range ${index + 1}.frames must be a whole number of at least 2`);+ return { start: raw.start, end: raw.end, ...(raw.id === undefined ? {} : { id: raw.id as string }), ...(raw.frames === undefined ? {} : { frames: raw.frames as number }) };+}++async function tiles(argv: readonly string[], io: CliIo, cwd: string): Promise<void> {+ const parsed = parseArguments(argv, ["--ranges", "--frames", "--cell", "--columns", "--to"]);const source = await sourceFile(parsed, cwd);const info = await probeMedia(source);- const bounds = await shotBoundaries(source, info.duration);- if (parsed.json) { io.write(`${JSON.stringify({ path: source, shots: bounds }, null, 2)}\n`); return; }- io.write(`${source}\n ${bounds.length} pixel-jump ${bounds.length === 1 ? "stretch" : "stretches"}; a jump is not a shot until the eyes say so\n${- bounds.map((bound, index) => ` ${String(index + 1).padStart(3, " ")} ${bound.start} s to ${bound.end} s (${round(bound.end - bound.start)} s)`).join("\n")}\n`);+ const rangesPath = resolve(cwd, required(parsed, "--ranges", "a JSON array of { start, end, id?, frames? } ranges"));+ const rangesRaw = JSON.parse(await readFile(rangesPath, "utf8")) as unknown;+ assert(Array.isArray(rangesRaw) && rangesRaw.length > 0, `${rangesPath} must contain a non-empty JSON array`);+ const ranges = rangesRaw.map((value, index) => tileRange(value, index, info.duration));+ const ids = ranges.flatMap((range) => range.id === undefined ? [] : [range.id]);+ assert(new Set(ids).size === ids.length, "range ids must be unique");+ const defaultFrames = parsed.options.has("--frames") ? integerOption(parsed, "--frames", 2, 2) : undefined;+ const cell = integerOption(parsed, "--cell", Math.max(80, Math.min(TILE_CELL_WIDTH, info.width)), 80);+ const columns = integerOption(parsed, "--columns", TILE_COLUMNS, 1);+ const to = await destinationDirectory(parsed, cwd, "the new directory to write the grids into");+ const staging = await mkdtemp(join(dirname(to), ".hypit-tiles-"));+ const written: { readonly id?: string; readonly start: number; readonly end: number; readonly samples: readonly number[]; readonly path: string }[] = [];+ try {+ for (let index = 0; index < ranges.length; index += 1) {+ const range = ranges[index]!;+ const count = range.frames ?? defaultFrames ?? tileFrameCount(range.end - range.start);+ const times = tileSampleTimes(range.start, range.end, count);+ const stem = range.id ?? `${range.start.toFixed(3).replace(".", "_")}s-${range.end.toFixed(3).replace(".", "_")}s`;+ const name = `${String(index + 1).padStart(3, "0")}-${stem}.jpg`;+ await tileFrames(source, times, join(staging, name), cell, columns);+ written.push({ ...(range.id === undefined ? {} : { id: range.id }), start: range.start, end: range.end, samples: times, path: join(to, name) });+ }+ await rename(staging, to);+ } catch (error) {+ await rm(staging, { recursive: true, force: true });+ throw error;+ }+ if (parsed.json) { io.write(`${JSON.stringify({ directory: to, grids: written }, null, 2)}\n`); return; }+ io.write(`${to}\n ${written.length} time-labeled ${written.length === 1 ? "grid" : "grids"} from ${written[0]!.start} s to ${written.at(-1)!.end} s\n`);+}++async function boundaries(argv: readonly string[], io: CliIo, cwd: string): Promise<void> {+ const parsed = parseArguments(argv, ["--rate", "--threshold"]);+ const source = await sourceFile(parsed, cwd);+ const rate = numberOption(parsed, "--rate", DEFAULT_BOUNDARY_RATE, 1, 120);+ const threshold = numberOption(parsed, "--threshold", DEFAULT_BOUNDARY_THRESHOLD, 0, 1);+ const candidates = await visualBoundaries(source, rate, threshold);+ if (parsed.json) { io.write(`${JSON.stringify({ path: source, sampleRate: rate, threshold, candidates }, null, 2)}\n`); return; }+ const shown = candidates.slice(0, 40);+ const remaining = candidates.length - shown.length;+ io.write(`${source}\n ${candidates.length} visual-change ${candidates.length === 1 ? "candidate" : "candidates"} at ${rate} samples/s; scores are not shot labels\n${+ shown.map((candidate) => ` ${candidate.at} s score ${candidate.score}`).join("\n")}${remaining > 0 ? `\n … ${remaining} more; --json returns all candidates` : ""}\n`);}async function fetch(argv: readonly string[], io: CliIo, cwd: string): Promise<void> {const parsed = parseArguments(argv, ["--to"]);const [url] = parsed.positionals;assert(url !== undefined && isVideoUrl(url), "name an http or https link first");+ assert(parsed.positionals.length === 1, "fetch takes exactly one link");const target = await destination(parsed, cwd, "the video file to write, for example reference/source.mp4");assert([".mp4", ".mkv", ".webm", ".mov"].includes(extname(target).toLowerCase()), "--to must end in .mp4, .mkv, .webm or .mov");await downloadVideo(url, target);@@ -324,17 +566,21 @@ async function fetch(argv: readonly string[], io: CliIo, cwd: string): Promise<vexport function writeMediaHelp(io: CliIo, topic?: MediaCommand): void {const sections: Record<MediaCommand, readonly string[]> = {probe: [" hypit media probe <file>", " Duration, size, frame rate and whether there is audio."],- cut: [" hypit media cut <file> --start <s> --end <s> --to <clip.mp4>", " One stretch as a clip of its own, cut on the exact frames."],- frames: [" hypit media frames <file> (--at <s,s,…> | --every <s>) --to <dir>", " Single frames at those seconds, as JPEG files named by their time."],- tile: [" hypit media tile <file> [--start <s> --end <s>] [--frames <n>] [--cell <px>] --to <grid.jpg>",- " Frames sampled evenly across a stretch, in one grid read left to right then top to bottom.",- " Defaults: 4 to 9 frames at 1.5 per second, 480 px cells, never wider than the source."],- shots: [" hypit media shots <file>", " Where the picture jumps. A starting point when nothing is known yet; not a shot list."],+ cut: [" hypit media cut <file> --start <s> --end <s> [--label-time] --to <clip.mp4>",+ " One exact stretch. --label-time visibly overlays absolute source time on the evidence copy."],+ frames: [" hypit media frames <file> (--at <s,s,…> | --every <s>) [--label-time] --to <dir>",+ " Single frames named by absolute source time; optional visible labels."],+ tile: [" hypit media tile <file> ([--start <s> --end <s>] | --at <s,s,…>) [--frames <n>] [--cell <px>] [--columns <n>] --to <grid.jpg>",+ " One time-labeled grid. Range samples are evenly spaced; --at names exact samples."],+ tiles: [" hypit media tiles <file> --ranges <ranges.json> [--frames <n>] [--cell <px>] [--columns <n>] --to <dir>",+ " One labeled grid per { start, end, id?, frames? } in a JSON array."],+ boundaries: [" hypit media boundaries <file> [--rate <samples/s>] [--threshold <0..1>]",+ " Mechanical adjacent-frame change candidates with scores; never editorial shot labels."],fetch: [" hypit media fetch <url> --to <video.mp4>", " A link turned into a file with the pinned yt-dlp, video and audio together."],};const chosen = topic === undefined ? mediaCommands : [topic];io.write(`hypit media\nPrepare what the eyes will look at. Local ffmpeg work; no Runtime Profile, no request, no state.\n\n${- chosen.map((item) => sections[item].join("\n")).join("\n\n")}\n\nEvery command writes only what --to names and refuses to overwrite. Add --json for a machine view.\n`);+ chosen.map((item) => sections[item].join("\n")).join("\n\n")}\n\nCommands that create evidence write only what --to names and refuse to overwrite. Add --json for the complete machine view.\n`);}export async function runMediaCli(argv: readonly string[], io: CliIo, cwd = process.cwd()): Promise<void> {@@ -349,6 +595,7 @@ export async function runMediaCli(argv: readonly string[], io: CliIo, cwd = procelse if (command === "cut") await cut(rest, io, cwd);else if (command === "frames") await frames(rest, io, cwd);else if (command === "tile") await tile(rest, io, cwd);- else if (command === "shots") await shots(rest, io, cwd);+ else if (command === "tiles") await tiles(rest, io, cwd);+ else if (command === "boundaries") await boundaries(rest, io, cwd);else await fetch(rest, io, cwd);}diff --git a/packages/video-cli/src/process.ts b/packages/video-cli/src/process.tsindex 87f1f86c..b963f719 100644--- a/packages/video-cli/src/process.ts+++ b/packages/video-cli/src/process.ts@@ -1,9 +1,16 @@import { spawn } from "node:child_process";+import { once } from "node:events";-/** Run one external program to completion and return its stdout; stderr becomes the error text. */-export function runProcess(executable: string, args: readonly string[], timeoutMs = 300_000): Promise<Buffer> {+type ProcessInput = Uint8Array | Iterable<Uint8Array> | AsyncIterable<Uint8Array>;++function run(+ executable: string,+ args: readonly string[],+ input: ProcessInput | undefined,+ timeoutMs: number,+): Promise<Buffer> {return new Promise((resolveRun, reject) => {- const child = spawn(executable, [...args], { stdio: ["ignore", "pipe", "pipe"], windowsHide: true });+ const child = spawn(executable, [...args], { stdio: [input === undefined ? "ignore" : "pipe", "pipe", "pipe"], windowsHide: true });const out: Buffer[] = [];let err = "";let settled = false;@@ -15,12 +22,44 @@ export function runProcess(executable: string, args: readonly string[], timeoutMelse reject(error);};const timer = setTimeout(() => { child.kill("SIGKILL"); finish(new Error(`${executable} timed out after ${timeoutMs} ms`)); }, timeoutMs);- child.stdout.on("data", (chunk: Buffer) => out.push(chunk));- child.stderr.on("data", (chunk: Buffer) => { err = `${err}${chunk.toString("utf8")}`.slice(-100_000); });+ child.stdout?.on("data", (chunk: Buffer) => out.push(chunk));+ child.stderr?.on("data", (chunk: Buffer) => { err = `${err}${chunk.toString("utf8")}`.slice(-100_000); });child.on("error", (error) => finish(new Error(`${executable} could not start: ${error.message}`)));child.on("close", (code) => {if (code === 0) finish();else finish(new Error(`${executable} exited with ${code}: ${err.trim()}`));});+ if (input !== undefined && child.stdin !== null) {+ child.stdin.on("error", (error: NodeJS.ErrnoException) => {+ if (error.code !== "EPIPE") finish(new Error(`${executable} input failed: ${error.message}`));+ });+ void (async () => {+ const chunks: Iterable<Uint8Array> | AsyncIterable<Uint8Array> = input instanceof Uint8Array ? [input] : input;+ for await (const chunk of chunks) {+ if (!child.stdin!.write(chunk)) await once(child.stdin!, "drain");+ }+ child.stdin!.end();+ })().catch((error: unknown) => {+ if (!(error instanceof Error && "code" in error && error.code === "EPIPE")) {+ child.kill("SIGKILL");+ finish(error instanceof Error ? error : new Error(String(error)));+ }+ });+ }});}++/** Run one external program to completion and return its stdout; stderr becomes the error text. */+export function runProcess(executable: string, args: readonly string[], timeoutMs = 300_000): Promise<Buffer> {+ return run(executable, args, undefined, timeoutMs);+}++/** The same process boundary when a deterministic byte stream is one of the program's inputs. */+export function runProcessWithInput(+ executable: string,+ args: readonly string[],+ input: ProcessInput,+ timeoutMs = 300_000,+): Promise<Buffer> {+ return run(executable, args, input, timeoutMs);+}diff --git a/packages/video-cli/src/studio-distribution.ts b/packages/video-cli/src/studio-distribution.tsnew file mode 100644index 00000000..59b59204--- /dev/null+++ b/packages/video-cli/src/studio-distribution.ts@@ -0,0 +1,19 @@+/**+ * Studio Companions carried by the official video distribution.+ *+ * This is distribution policy, not Studio discovery policy: a different video+ * distribution may assemble a different set without changing Studio itself.+ */+export const videoStudioCompanionPackages = [+ "@hypit/audio-track-studio",+ "@hypit/caption-fine-studio",+ "@hypit/comment-sticker-studio",+ "@hypit/deck-track-studio",+ "@hypit/film-studio",+ "@hypit/media-track-studio",+ "@hypit/ranking-studio",+ "@hypit/screen-overlay-studio",+ "@hypit/script-studio",+ "@hypit/speech-track-studio",+ "@hypit/typography-track-studio",+] as const;diff --git a/packages/video-cli/test/creation.test.ts b/packages/video-cli/test/creation.test.tsindex a70745ee..8b6764a0 100644--- a/packages/video-cli/test/creation.test.ts+++ b/packages/video-cli/test/creation.test.ts@@ -37,7 +37,6 @@ function host(seen: Need[]): CreationHost {providers: async (requests) => requests.map((request) => ({request: request.request,capability: request.capability,- checked: request.constraints === undefined ? "capability" as const : "request" as const,status: "resolved" as const,endpoint: "paid.default",use: "@hypit/provider-example",@@ -154,7 +153,6 @@ test("a Profile that does not serve the capability stops before anything is spenproviders: async (requests) => requests.map((request) => ({request: request.request,capability: request.capability,- checked: request.constraints === undefined ? "capability" as const : "request" as const,status: "unresolved" as const,})),invoke: async () => { invoked = true; throw new Error("must not be reached"); },diff --git a/packages/video-cli/test/media.test.ts b/packages/video-cli/test/media.test.tsindex 3ab31ef9..73015c5a 100644--- a/packages/video-cli/test/media.test.ts+++ b/packages/video-cli/test/media.test.ts@@ -1,13 +1,13 @@import assert from "node:assert/strict";import { spawnSync } from "node:child_process";-import { mkdtemp, readdir, rm, stat } from "node:fs/promises";+import { mkdtemp, readdir, rm, stat, writeFile } from "node:fs/promises";import { tmpdir } from "node:os";import { join } from "node:path";import test from "node:test";import type { CliIo } from "@hypit/cli";-import { probeMedia, runMediaCli, shotBoundaries, tileFrameCount } from "../src/media.js";+import { probeMedia, runMediaCli, tileFrameCount, tileSampleTimes, visualBoundaries } from "../src/media.js";const ffmpeg = spawnSync("ffmpeg", ["-version"], { stdio: "ignore" }).status === 0&& spawnSync("ffprobe", ["-version"], { stdio: "ignore" }).status === 0;@@ -25,14 +25,16 @@ function io(): { readonly io: CliIo; text: () => string } {};}-/** Three seconds of two flat colours with a hard cut at 1.5 s, 24 fps, no audio. */+/** Three seconds with three sub-second cuts, 24 fps and no audio. */async function sample(directory: string): Promise<string> {const path = join(directory, "sample.mp4");const result = spawnSync("ffmpeg", ["-hide_banner", "-loglevel", "error", "-y",- "-f", "lavfi", "-i", "color=c=red:s=320x240:r=24:d=1.5",- "-f", "lavfi", "-i", "color=c=blue:s=320x240:r=24:d=1.5",- "-filter_complex", "[0:v][1:v]concat=n=2:v=1:a=0",+ "-f", "lavfi", "-i", "color=c=red:s=320x240:r=24:d=0.5",+ "-f", "lavfi", "-i", "color=c=blue:s=320x240:r=24:d=0.5",+ "-f", "lavfi", "-i", "color=c=green:s=320x240:r=24:d=0.5",+ "-f", "lavfi", "-i", "color=c=white:s=320x240:r=24:d=1.5",+ "-filter_complex", "[0:v][1:v][2:v][3:v]concat=n=4:v=1:a=0","-c:v", "libx264", "-preset", "veryfast", "-pix_fmt", "yuv420p", path,], { encoding: "utf8" });assert.equal(result.status, 0, result.stderr);@@ -43,16 +45,17 @@ test("tile frame counts follow the measured bounds", () => {assert.equal(tileFrameCount(0.5), 4);assert.equal(tileFrameCount(4), 6);assert.equal(tileFrameCount(30), 9);+ assert.deepEqual(tileSampleTimes(1, 2, 4), [1.125, 1.375, 1.625, 1.875]);});test("media help names every command and no state", () => {const out = io();runMediaCli(["media"], out.io);- for (const name of ["probe", "cut", "frames", "tile", "shots", "fetch"]) assert.match(out.text(), new RegExp(`hypit media ${name}`));+ for (const name of ["probe", "cut", "frames", "tile", "tiles", "boundaries", "fetch"]) assert.match(out.text(), new RegExp(`hypit media ${name}`));assert.match(out.text(), /no state/);});-test("probe, cut, frames, tile and shots read one file and write only what --to names", { skip: !ffmpeg && "ffmpeg is not installed" }, async () => {+test("media evidence keeps source times and sub-second visual changes", { skip: !ffmpeg && "ffmpeg is not installed" }, async () => {const work = await mkdtemp(join(tmpdir(), "hypit-media-"));try {const source = await sample(work);@@ -74,30 +77,50 @@ test("probe, cut, frames, tile and shots read one file and write only what --torunMediaCli(["media", "cut", source, "--start", "0", "--end", "1", "--to", "out/piece.mp4"], io().io, work),/already exists/,);+ const labeledCut = io();+ await runMediaCli(["media", "cut", source, "--start", "0.5", "--end", "1", "--label-time", "--to", "out/labeled.mp4", "--json"], labeledCut.io, work);+ assert.equal((JSON.parse(labeledCut.text()) as { labeled: boolean }).labeled, true);const frames = io();await runMediaCli(["media", "frames", source, "--at", "0.2,2.5", "--to", "out/frames"], frames.io, work);const written = (await readdir(join(work, "out", "frames"))).sort();- assert.deepEqual(written, ["frame-0_20s.jpg", "frame-2_50s.jpg"]);+ assert.deepEqual(written, ["frame-0_200s.jpg", "frame-2_500s.jpg"]);const every = io();- await runMediaCli(["media", "frames", source, "--every", "1", "--to", "out/every", "--json"], every.io, work);- assert.equal((JSON.parse(every.text()) as { frames: unknown[] }).frames.length, 3);+ await runMediaCli(["media", "frames", source, "--every", "1", "--label-time", "--to", "out/every", "--json"], every.io, work);+ const everyView = JSON.parse(every.text()) as { labeled: boolean; frames: unknown[] };+ assert.equal(everyView.frames.length, 3);+ assert.equal(everyView.labeled, true);const tile = io();- await runMediaCli(["media", "tile", source, "--to", "out/grid.jpg", "--json"], tile.io, work);- const grid = JSON.parse(tile.text()) as { frames: number; columns: number; rows: number; cellWidth: number };- assert.equal(grid.frames, tileFrameCount(info.duration));- assert.equal(grid.columns, 3);+ await runMediaCli(["media", "tile", source, "--at", "0.2,1.1,2.5", "--columns", "2", "--to", "out/grid.jpg", "--json"], tile.io, work);+ const grid = JSON.parse(tile.text()) as { samples: number[]; columns: number; rows: number; cellWidth: number };+ assert.deepEqual(grid.samples, [0.2, 1.1, 2.5]);+ assert.equal(grid.columns, 2);+ assert.equal(grid.rows, 2);assert.equal(grid.cellWidth, 320, "a grid never enlarges a small source");assert.ok((await stat(join(work, "out", "grid.jpg"))).size > 0);- const bounds = await shotBoundaries(source, info.duration);- assert.equal(bounds.length, 2, JSON.stringify(bounds));- assert.ok(Math.abs(bounds[1]!.start - 1.5) < 0.2, `cut found at ${bounds[1]!.start}`);- const shots = io();- await runMediaCli(["media", "shots", source], shots.io, work);- assert.match(shots.text(), /2 pixel-jump stretches/);+ const ranges = join(work, "ranges.json");+ await writeFile(ranges, JSON.stringify([+ { id: "opening", start: 0, end: 0.8, frames: 3 },+ { start: 1.5, end: 3 },+ ]));+ const tiles = io();+ await runMediaCli(["media", "tiles", source, "--ranges", ranges, "--to", "out/grids", "--json"], tiles.io, work);+ const grids = (JSON.parse(tiles.text()) as { grids: { samples: number[]; path: string }[] }).grids;+ assert.equal(grids.length, 2);+ assert.equal(grids[0]!.samples.length, 3);+ assert.deepEqual((await readdir(join(work, "out", "grids"))).sort(), ["001-opening.jpg", "002-1_500s-3_000s.jpg"]);++ const changes = await visualBoundaries(source);+ assert.ok(changes.some((item) => Math.abs(item.at - 0.5) < 0.1), JSON.stringify(changes));+ assert.ok(changes.some((item) => Math.abs(item.at - 1) < 0.1), JSON.stringify(changes));+ assert.ok(changes.some((item) => Math.abs(item.at - 1.5) < 0.1), JSON.stringify(changes));+ const boundaries = io();+ await runMediaCli(["media", "boundaries", source], boundaries.io, work);+ assert.match(boundaries.text(), /visual-change candidates/);+ assert.match(boundaries.text(), /scores are not shot labels/);} finally {await rm(work, { recursive: true, force: true });}diff --git a/packages/whisperx/src/component.ts b/packages/whisperx/src/component.tsindex 70cc5c3b..84681626 100644--- a/packages/whisperx/src/component.ts+++ b/packages/whisperx/src/component.ts@@ -1,10 +1,11 @@+import { plannedNeedInputs } from "@hypit/component-kit";import type { ComponentPackage } from "@hypit/component-kit";import type { SpeechEvidenceAudio } from "@hypit/speech";import type { CanonicalValue, StoredValue } from "@hypit/protocol";import { canonicalize } from "@hypit/protocol";import { whisperXRequestForEvidenceAudio } from "./evidence.js";-import { whisperXProducers } from "./manifest.js";+import { whisperXCapabilities, whisperXProducers } from "./manifest.js";import type { WhisperXLanguage } from "./types.js";function inline(value: StoredValue, subject: string): CanonicalValue {@@ -29,4 +30,35 @@ export const whisperXComponent = {},},],+ plannedNeeds: [{+ producer: whisperXProducers.request,+ port: "alignment",+ capability: whisperXCapabilities.alignment,+ plan({ state, step }) {+ const operation = state.plan.steps.find((item) => item.id === step);+ const languageRecord = operation?.inputs.language;+ const language = languageRecord === undefined+ ? undefined+ : state.records.find((record) => record.id === languageRecord)?.value;+ if (language?.kind !== "inline" || typeof language.value !== "string") return undefined;+ return {+ constraints: { language: language.value },+ pendingInputs: plannedNeedInputs(state, step, { evidence: "audio" }),+ };+ },+ present(specification) {+ const fields = specification.constraints !== null+ && typeof specification.constraints === "object"+ && !Array.isArray(specification.constraints)+ ? specification.constraints as Readonly<Record<string, CanonicalValue>>+ : {};+ const language = typeof fields.language === "string" ? fields.language : undefined;+ return {+ fields: language === undefined ? {} : { language: [language] },+ references: {+ audio: specification.pendingInputs.filter((input) => input.role === "audio").length,+ },+ };+ },+ }],} satisfies ComponentPackage;diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex ba5aae55..1830cae2 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -576,12 +576,6 @@ importers:'@hypit/elaborator':specifier: workspace:*version: link:../elaborator- '@hypit/generation':- specifier: workspace:*- version: link:../generation- '@hypit/model-kit':- specifier: workspace:*- version: link:../model-kit'@hypit/package-loader-node':specifier: workspace:*version: link:../package-loader-node@@ -1708,6 +1702,9 @@ importers:'@hypit/protocol':specifier: workspace:*version: link:../protocol+ '@hypit/run':+ specifier: workspace:*+ version: link:../run'@hypit/speech':specifier: workspace:*version: link:../speech@@ -2502,9 +2499,6 @@ importers:packages/runtime-local:dependencies:- '@hypit/build-result':- specifier: workspace:*- version: link:../build-result'@hypit/build-result-fs':specifier: workspace:*version: link:../build-result-fs@@ -2548,6 +2542,9 @@ importers:specifier: workspace:*version: link:../validationdevDependencies:+ '@hypit/build-result':+ specifier: workspace:*+ version: link:../build-result'@hypit/credential-store-env':specifier: workspace:*version: link:../credential-store-env