@hypit/hypit 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +1 -1
  2. package/examples/semantic-composition/README.md +2 -1
  3. package/examples/semantic-composition/chat.svml +1 -1
  4. package/examples/semantic-composition/hypit.runtime.json +1 -1
  5. package/package.json +4 -1
  6. package/packages/caption-fine/README.md +7 -0
  7. package/packages/cli/src/view.ts +4 -3
  8. package/packages/film/src/surface.ts +4 -1
  9. package/packages/provider-hypihub/README.md +17 -3
  10. package/packages/provider-hypihub/src/oauth.ts +1 -1
  11. package/packages/provider-hypihub/src/provider.ts +35 -9
  12. package/packages/provider-hypihub/src/upload.ts +37 -4
  13. package/packages/runtime-local/README.md +17 -0
  14. package/packages/script/README.md +15 -3
  15. package/packages/script/src/manifest.ts +2 -1
  16. package/packages/script/src/parser.ts +45 -6
  17. package/packages/studio/LOCALIZATION.md +98 -0
  18. package/packages/studio/README.md +13 -0
  19. package/packages/studio/locales/en.json +197 -0
  20. package/packages/studio/locales/zh-CN.json +191 -0
  21. package/packages/studio/src/localization-node.ts +46 -0
  22. package/packages/studio/src/localization.ts +85 -0
  23. package/packages/studio/src/style.css +15 -3
  24. package/packages/studio/src/ui/artifact-name.ts +8 -6
  25. package/packages/studio/src/ui/artifact-preview.ts +5 -4
  26. package/packages/studio/src/ui/code.ts +17 -16
  27. package/packages/studio/src/ui/comments.ts +26 -25
  28. package/packages/studio/src/ui/dropdown.ts +68 -0
  29. package/packages/studio/src/ui/i18n.ts +109 -0
  30. package/packages/studio/src/ui/icons.ts +1 -0
  31. package/packages/studio/src/ui/library.ts +76 -65
  32. package/packages/studio/src/ui/main.ts +84 -131
  33. package/packages/studio/src/ui/scrub-preview.ts +8 -6
  34. package/packages/studio/src/ui/stage.ts +28 -27
  35. package/packages/studio/src/ui/timeline.ts +17 -14
  36. package/packages/studio/start.ts +39 -22
package/README.md CHANGED
@@ -16,7 +16,7 @@
16
16
  </p>
17
17
 
18
18
  <p align="center">
19
- <a href="https://github.com/hypit-ai/hypit/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/hypit-ai/hypit?style=flat-square&color=FFD700&logo=github&logoColor=white&label=Stars"></a>
19
+ <img alt="Stars" src="https://img.shields.io/github/stars/hypit-ai/hypit?style=flat-square&color=FFD700&logo=github&logoColor=white&label=Stars">
20
20
  <a href="https://github.com/hypit-ai/hypit/blob/main/package.json"><img alt="Node 22.15+" src="https://img.shields.io/badge/Node.js-22.15%2B-5FA04E?style=flat-square&logo=nodedotjs&logoColor=white"></a>
21
21
  <a href="https://github.com/hypit-ai/hypit/blob/main/package.json"><img alt="pnpm 10.33" src="https://img.shields.io/badge/pnpm-10.33-F69220?style=flat-square&logo=pnpm&logoColor=white"></a>
22
22
  <a href="https://github.com/hypit-ai/hypit/blob/main/package.json"><img alt="TypeScript 5.9" src="https://img.shields.io/badge/TypeScript-5.9-3178C6?style=flat-square&logo=typescript&logoColor=white"></a>
@@ -28,7 +28,8 @@ node bin/hypit.mjs check examples/semantic-composition/chat.svml --workspace exa
28
28
  node bin/hypit.mjs build examples/semantic-composition/chat.svrun --workspace examples/semantic-composition --runtime examples/semantic-composition/hypit.runtime.json --follow
29
29
  ```
30
30
 
31
- The Profile selects local HyperFrames and FFmpeg. Use the machine's prepared browser/media tools;
31
+ The Profile selects local HyperFrames and FFmpeg. Its execution data lives in `.hypit/runtimes/local`;
32
+ `.hypit/runtime` is reserved for the project's Profile-selection file. Use the machine's prepared browser/media tools;
32
33
  there is no hosted generation account in this example. The final Output is `final.video`. The same
33
34
  Run can be opened in Studio, where its component lane and physical clock work without a Script lane.
34
35
  For an independent project, install `@hypit/hypit`, copy the component into `packages/`, replace its workspace
@@ -9,7 +9,7 @@
9
9
  <import as="style" source="./chat.svs"/>
10
10
 
11
11
  <time:Clock id="animation-clock" frame-rate="30"/>
12
- <time:Timeline id="animation" clock={animation-clock} end="8s"/>
12
+ <time:Timeline id="animation" clock={animation-clock} end="8s"/>
13
13
  <spatial:Canvas id="canvas" width="540" height="960"/>
14
14
  <fonts:Stack id="font" family="inter" weight="600" style="normal"/>
15
15
  <chat:Scene id="conversation" timeline={animation.timeline} canvas={canvas} font={font}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "format": "hypit.runtime-local@1",
3
- "dataRoot": ".hypit/runtime",
3
+ "dataRoot": ".hypit/runtimes/local",
4
4
  "endpoints": {
5
5
  "media.local": { "use": "@hypit/provider-media-local", "config": { "defaultConcurrency": 2 } },
6
6
  "hyperframes.local": { "use": "@hypit/provider-hyperframes-local", "config": { "workers": 2, "defaultConcurrency": 1 } }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypit/hypit",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "homepage": "https://hypit.ai",
5
5
  "repository": {
6
6
  "type": "git",
@@ -125,6 +125,8 @@
125
125
  "packages/*/README.md",
126
126
  "packages/temporal-markup/EDITING.md",
127
127
  "packages/studio/INSPECTOR.md",
128
+ "packages/studio/LOCALIZATION.md",
129
+ "packages/studio/locales/*.json",
128
130
  "services/image-opencv/pyproject.toml",
129
131
  "services/image-opencv/package.json",
130
132
  "services/image-opencv/uv.lock",
@@ -172,6 +174,7 @@
172
174
  "docs:build": "vitepress build docs",
173
175
  "docs:preview": "vitepress preview docs",
174
176
  "test": "node test/run.mjs",
177
+ "test:runtime-scale": "node test/run.mjs runtime-scale",
175
178
  "test:whisperx-service": "uv run --project services/whisperx --frozen python -m unittest discover -s services/whisperx/tests -p \"test_*.py\"",
176
179
  "test:image-opencv": "node test/run.mjs image-opencv",
177
180
  "hypit": "node bin/hypit.mjs",
@@ -87,6 +87,13 @@ individual Han characters as Display Words; punctuation stays with its display w
87
87
  those units for timing and active Paint, while authored Cues remain complete reading phrases.
88
88
  Dual Text retains its complete alignment unit even when it displays or speaks several words.
89
89
 
90
+ `<组件化|>` authors the same unit as `<组件化|组件化>` without repeating the speech. Fine's `step`
91
+ karaoke, active underline and active box treat that unit together using its first-to-last speech
92
+ interval. Ordinary Chinese characters around it retain their own activation times. This is an
93
+ explicit authored group, not a renderer-selected segmentation, and does not introduce a new Cue.
94
+ The underlying character anchors remain available to other Timeline consumers. `wipe` and
95
+ `typewriter` still animate inside the complete unit over its interval when deliberately selected.
96
+
90
97
  `word-gap` applies between Latin words and at Chinese/Latin boundaries. Adjacent Han characters and
91
98
  full-width punctuation carry no extra word gap. `letter-spacing` controls glyph tracking. Exact
92
99
  font fallbacks supply the required glyphs; the layout does not select a font by language.
@@ -164,6 +164,8 @@ export function buildStatusView(options: {
164
164
  ? "unavailable" as const
165
165
  : options.result?.outcome ?? (options.result === undefined ? "missing" as const : "open" as const);
166
166
  const issue = options.runtime?.issue;
167
+ const operations = (options.runtime?.operations ?? options.result?.operations ?? [])
168
+ .filter((item) => options.verbose || item.status !== "completed");
167
169
  return {
168
170
  id: options.id,
169
171
  ...((options.runtime?.targets ?? options.result?.targets) === undefined ? {} : {
@@ -197,9 +199,8 @@ export function buildStatusView(options: {
197
199
  }
198
200
  : { message: options.resultReadError! },
199
201
  }),
200
- ...((options.runtime?.operations ?? options.result?.operations ?? []).some((item) => item.status !== "completed") ? {
201
- operations: groupOperationViews((options.runtime?.operations ?? options.result?.operations ?? [])
202
- .filter((item) => item.status !== "completed")
202
+ ...(operations.length > 0 ? {
203
+ operations: groupOperationViews(operations
203
204
  .map((item) => ({
204
205
  ...(!options.verbose ? {} : "operation" in item ? { id: item.operation } : item.id === undefined ? {} : { id: item.id }),
205
206
  ...(item.receipt === undefined || (!options.verbose && item.failure === undefined) ? {} : { receipt: item.receipt }),
@@ -117,7 +117,10 @@ export const decodeFilmSurface: StructuredSurfaceHandler = ({ element, resolveRe
117
117
  const name = `track-${index + 1}`;
118
118
  return { name, kind: trackKind(source), source };
119
119
  });
120
- if (new Set(tracks.map((track) => track.name)).size !== tracks.length) {
120
+ const sourceKeys = tracks.map(({ source: { ref } }) => ref.kind === "record"
121
+ ? `record\u0000${ref.id}`
122
+ : `component-output\u0000${ref.component}\u0000${ref.output}`);
123
+ if (new Set(sourceKeys).size !== tracks.length) {
121
124
  throw new Error(`${element.name} cannot include the same Track more than once`);
122
125
  }
123
126
  const fragment = createFilmAssemblyFragment({ name: "@hypit/film/surface-assembly@1", tracks });
@@ -74,9 +74,13 @@ to the selected deployment's origin or an existing `/v1`/`/v1beta` base. The Run
74
74
  normalizes it to `/v1`; missing or insufficient user
75
75
  credentials should be resolved at [hypit.ai](https://hypit.ai). Referenced image, audio and video
76
76
  Resources are uploaded through a session from `POST /v1/files/uploads`, followed by the private
77
- regional multipart instructions returned by HypiHub. The Provider follows the server-selected part
77
+ regional multipart instructions or `api_multipart` file POST selected by HypiHub. The latter sends
78
+ one multipart/form-data file to the selected service's `/v1/files`, preserving reference purpose
79
+ and person classification; an uncertain file POST is not repeated automatically.
80
+ For direct multipart uploads, the Provider follows the server-selected part
78
81
  size and part concurrency, retries a failed part with a fresh signed URL, completes or cancels that
79
- one upload, and then passes the returned HTTPS URL to generation or transcription. One
82
+ one upload, and then passes the returned HTTPS URL to generation or transcription. Signing requests
83
+ contain at most the service's 128-part limit; all batches belong to the same upload. One
80
84
  Resource identity with the same declared person-reference classification is uploaded once within one Runtime operation. Hypit keeps no upload catalog or
81
85
  cross-Build cache. Seedance visual references can carry `personReference` in their media fields;
82
86
  the mapping declares it as a resource-transport field and the upload session receives
@@ -97,13 +101,23 @@ selected Store is writable. Its Endpoint receives only the credential slot it de
97
101
  operation for replacing that same slot; it cannot enumerate the Store, choose another key or read
98
102
  another Endpoint's credentials. A raw credential remains an ordinary static API key.
99
103
 
104
+ Refresh uses `oauthRequestTimeoutMs` during generation, transcription, uploads and pricing too.
105
+ It completes before the subsequent API request starts its own deadline. A stalled refresh reports
106
+ an OAuth refresh timeout without starting that API request.
107
+
100
108
  The service currently requires whole-file and per-part SHA-256 values as fields of its signed upload
101
109
  protocol. They exist only while transferring bytes; Hypit never uses them as Resource identity,
102
110
  Result metadata, lookup keys or reuse evidence. Signed URLs and their query credentials are removed
103
111
  from surfaced upload errors.
104
112
 
105
113
  The default remote alignment model is `victor-upmeet/whisperx`; `transcriptionModel` may select another
106
- HypiHub model that exposes the `transcriptions` route. `hypit doctor` reads the authenticated model
114
+ HypiHub model that exposes the `transcriptions` route. When transcription response headers include
115
+ `X-Request-Id`, the Provider records it in the existing execution diagnostics before reading the body.
116
+ A matching same-service `Location` is retained as the authenticated result lookup URL, including on
117
+ an HTTP failure or interrupted response body. This is a receipt for investigation, not automatic
118
+ resubmission or Build restoration. No receipt can be recorded if no response headers arrive.
119
+
120
+ `hypit doctor` reads the authenticated model
107
121
  catalog to verify configured capabilities; ordinary preflight never makes that request. The package
108
122
  declares HypiHub's public pricing page, `https://hypit.ai/commercial/pricing/`, as its price source.
109
123
  For each selected Need, `readPricing` resolves the corresponding HypiHub model and returns the service's
@@ -65,7 +65,7 @@ export function createHypiHubAuth(options: {
65
65
  throw new Error("HypiHub OAuth credential is read-only; run hypit auth login with a writable Credential Store");
66
66
  }
67
67
  refreshing = (async () => {
68
- const deadline = requestDeadline(options.requestTimeoutMs);
68
+ const deadline = requestDeadline(options.requestTimeoutMs, () => new Error("HypiHub OAuth refresh timed out"));
69
69
  try {
70
70
  const response = await deadline.wait(options.fetch(tokenEndpoint, {
71
71
  method: "POST",
@@ -100,12 +100,14 @@ class HypiHubHttpError extends Error {
100
100
  class HypiHubClient {
101
101
  readonly baseUrl: string;
102
102
  readonly timeout: number;
103
+ readonly oauthTimeout: number;
103
104
  readonly downloadAttempts: number;
104
105
  readonly fetcher: typeof globalThis.fetch;
105
106
  readonly uploader: HypiHubUploader;
106
107
  constructor(options: {
107
108
  readonly baseUrl: string;
108
109
  readonly timeout: number;
110
+ readonly oauthTimeout: number;
109
111
  readonly uploadConcurrency: number;
110
112
  readonly uploadPartTimeout: number;
111
113
  readonly uploadPartAttempts: number;
@@ -114,6 +116,7 @@ class HypiHubClient {
114
116
  }) {
115
117
  this.baseUrl = options.baseUrl.replace(/\/$/u, "");
116
118
  this.timeout = options.timeout;
119
+ this.oauthTimeout = options.oauthTimeout;
117
120
  this.downloadAttempts = options.downloadAttempts;
118
121
  this.fetcher = options.fetcher;
119
122
  this.uploader = new HypiHubUploader({
@@ -125,14 +128,18 @@ class HypiHubClient {
125
128
  fetch: this.fetcher,
126
129
  });
127
130
  }
128
- async json(path: string, auth: HypiHubAuth, init: RequestInit = {}, refreshOnUnauthorized = true): Promise<Record<string, unknown>> {
131
+ async json(path: string, auth: HypiHubAuth, init: RequestInit = {}, refreshOnUnauthorized = true,
132
+ onResponse?: (response: Response) => Promise<void>): Promise<Record<string, unknown>> {
133
+ const token = await auth.token();
129
134
  const deadline = requestDeadline(this.timeout);
130
135
  try {
131
- const response = await deadline.wait(this.fetcher(`${this.baseUrl}${path}`, { ...init, signal: deadline.signal, headers: { authorization: `Bearer ${await auth.token()}`, ...(init.headers ?? {}) } }));
136
+ const response = await deadline.wait(this.fetcher(`${this.baseUrl}${path}`, { ...init, signal: deadline.signal, headers: { authorization: `Bearer ${token}`, ...(init.headers ?? {}) } }));
137
+ if (response.status !== 401 && onResponse !== undefined) await deadline.wait(onResponse(response));
132
138
  const text = await deadline.wait(response.text()); let body: unknown = {};
133
139
  if (response.status === 401 && refreshOnUnauthorized && auth.canRefresh()) {
140
+ deadline.finish();
134
141
  await auth.refresh();
135
- return await this.json(path, auth, init, false);
142
+ return await this.json(path, auth, init, false, onResponse);
136
143
  }
137
144
  if (!response.ok) throw new HypiHubHttpError(response.status, `HypiHub returned HTTP ${response.status}: ${text.slice(0, 300)}`);
138
145
  try { body = text.length === 0 ? {} : JSON.parse(text); } catch { throw new Error(`HypiHub returned invalid JSON (${response.status})`); }
@@ -165,24 +172,40 @@ class HypiHubClient {
165
172
  ...(personReference === undefined ? {} : { isPersonReference: personReference }) }, auth);
166
173
  }
167
174
 
168
- async transcribe(body: Record<string, unknown>, auth: HypiHubAuth): Promise<Record<string, unknown>> {
175
+ async transcribe(body: Record<string, unknown>, auth: HypiHubAuth,
176
+ report?: (message: string) => Promise<void>): Promise<Record<string, unknown>> {
169
177
  return await this.json("/audio/transcriptions", auth, {
170
178
  method: "POST",
171
179
  headers: { "content-type": "application/json" },
172
180
  body: JSON.stringify(body),
181
+ }, true, async (response) => {
182
+ const requestId = response.headers.get("x-request-id");
183
+ if (requestId === null || !/^[A-Za-z0-9_-]{1,200}$/u.test(requestId)) return;
184
+ let retrieval = "";
185
+ const location = response.headers.get("location");
186
+ if (location !== null) {
187
+ try {
188
+ const url = new URL(location, this.baseUrl);
189
+ const expected = new URL(`${this.baseUrl}/audio/transcriptions/${encodeURIComponent(requestId)}`);
190
+ if (url.href === expected.href) retrieval = `; result lookup: ${url.href}`;
191
+ } catch { /* A malformed Location does not erase the request identifier. */ }
192
+ }
193
+ await report?.(`HypiHub transcription request ${requestId} (HTTP ${response.status})${retrieval}`);
173
194
  });
174
195
  }
175
196
  async speech(auth: HypiHubAuth, body: Record<string, unknown>, refreshOnUnauthorized = true): Promise<readonly { readonly bytes: Uint8Array; readonly mediaType: string }[]> {
197
+ const token = await auth.token();
176
198
  const deadline = requestDeadline(this.timeout);
177
199
  try {
178
200
  const response = await deadline.wait(this.fetcher(`${this.baseUrl}/audio/speech`, {
179
201
  method: "POST",
180
- headers: { authorization: `Bearer ${await auth.token()}`, "content-type": "application/json" },
202
+ headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
181
203
  body: JSON.stringify({ ...body, output: "b64_json" }),
182
204
  signal: deadline.signal,
183
205
  }));
184
206
  const bytes = new Uint8Array(await deadline.wait(response.arrayBuffer()));
185
207
  if (response.status === 401 && refreshOnUnauthorized && auth.canRefresh()) {
208
+ deadline.finish();
186
209
  await auth.refresh();
187
210
  return await this.speech(auth, body, false);
188
211
  }
@@ -226,7 +249,7 @@ function authFor(context: EndpointInvocationContext, client: HypiHubClient): Hyp
226
249
  return createHypiHubAuth({
227
250
  credential: credential(context.credentials),
228
251
  baseUrl: client.baseUrl,
229
- requestTimeoutMs: client.timeout,
252
+ requestTimeoutMs: client.oauthTimeout,
230
253
  fetch: client.fetcher,
231
254
  });
232
255
  }
@@ -235,7 +258,7 @@ function pricingAuth(credentials: Readonly<Record<string, EndpointCredential>>,
235
258
  return createHypiHubAuth({
236
259
  credential: credential(credentials),
237
260
  baseUrl: client.baseUrl,
238
- requestTimeoutMs: client.timeout,
261
+ requestTimeoutMs: client.oauthTimeout,
239
262
  fetch: client.fetcher,
240
263
  });
241
264
  }
@@ -311,6 +334,7 @@ export async function diagnoseHypiHubProvider(
311
334
  const client = new HypiHubClient({
312
335
  baseUrl: apiBaseUrl(options.baseUrl ?? "https://hypit.ai/v1"),
313
336
  timeout: options.requestTimeoutMs ?? 30_000,
337
+ oauthTimeout: options.oauthRequestTimeoutMs ?? 30_000,
314
338
  uploadConcurrency: options.uploadConcurrency ?? 8,
315
339
  uploadPartTimeout: options.uploadPartTimeoutMs ?? 5 * 60_000,
316
340
  uploadPartAttempts: options.uploadPartAttempts ?? 3,
@@ -320,7 +344,7 @@ export async function diagnoseHypiHubProvider(
320
344
  const auth = createHypiHubAuth({
321
345
  credential: { secret: apiKey },
322
346
  baseUrl: client.baseUrl,
323
- requestTimeoutMs: client.timeout,
347
+ requestTimeoutMs: client.oauthTimeout,
324
348
  fetch: client.fetcher,
325
349
  });
326
350
  const response = await client.json("/models", auth);
@@ -487,6 +511,7 @@ export function createHypiHubProvider(options: CreateHypiHubProviderOptions = {}
487
511
  const client = new HypiHubClient({
488
512
  baseUrl: apiBaseUrl(options.baseUrl ?? "https://hypit.ai/v1"),
489
513
  timeout: requestTimeoutMs,
514
+ oauthTimeout: oauthRequestTimeoutMs,
490
515
  uploadConcurrency: options.uploadConcurrency ?? 8,
491
516
  uploadPartTimeout: uploadPartTimeoutMs,
492
517
  uploadPartAttempts,
@@ -496,6 +521,7 @@ export function createHypiHubProvider(options: CreateHypiHubProviderOptions = {}
496
521
  const pricingClient = new HypiHubClient({
497
522
  baseUrl: apiBaseUrl(options.baseUrl ?? "https://hypit.ai/v1"),
498
523
  timeout: pricingRequestTimeoutMs,
524
+ oauthTimeout: oauthRequestTimeoutMs,
499
525
  uploadConcurrency: options.uploadConcurrency ?? 8,
500
526
  uploadPartTimeout: uploadPartTimeoutMs,
501
527
  uploadPartAttempts,
@@ -531,7 +557,7 @@ export function createHypiHubProvider(options: CreateHypiHubProviderOptions = {}
531
557
  response_format: "verbose_json",
532
558
  language: request.language,
533
559
  timestamp_granularities: ["segment", "word"],
534
- }, auth);
560
+ }, auth, async (message) => { await context.reportDiagnostic?.({ level: "info", message }); });
535
561
  const evidence = sealAlignedTranscriptEvidence({
536
562
  passages: interpretWhisperXTranscript(response as WhisperXTranscriptResponse, request.sampleFrames),
537
563
  });
@@ -120,7 +120,7 @@ async function acquireUploadSlot(origin: string, auth: UploadAuth, limit: number
120
120
  };
121
121
  }
122
122
 
123
- /** Uploads media through HypiHub's session-negotiated private regional S3 multipart flow. */
123
+ /** Uploads media using the transfer mode negotiated by the selected HypiHub service. */
124
124
  export class HypiHubUploader {
125
125
  readonly baseUrl: string;
126
126
  readonly requestTimeout: number;
@@ -179,16 +179,18 @@ export class HypiHubUploader {
179
179
  }
180
180
 
181
181
  private async jsonOnce(path: string, auth: UploadAuth, init: RequestInit, timeoutMs: number, retryAuth = true): Promise<Record<string, unknown>> {
182
+ const token = await uploadToken(auth);
182
183
  const request = requestDeadline(timeoutMs);
183
184
  const deadline = Date.now() + timeoutMs;
184
185
  try {
185
186
  const response = await request.wait(this.fetcher(`${this.baseUrl}${path}`, {
186
187
  ...init,
187
188
  signal: request.signal,
188
- headers: { authorization: `Bearer ${await uploadToken(auth)}`, ...(init.headers ?? {}) },
189
+ headers: { authorization: `Bearer ${token}`, ...(init.headers ?? {}) },
189
190
  }));
190
191
  const text = await request.wait(response.text());
191
192
  if (response.status === 401 && retryAuth && uploadCanRefresh(auth)) {
193
+ request.finish();
192
194
  await (auth as HypiHubAuth).refresh();
193
195
  return await this.jsonOnce(path, auth, init, Math.max(1, deadline - Date.now()), false);
194
196
  }
@@ -214,6 +216,16 @@ export class HypiHubUploader {
214
216
  }
215
217
 
216
218
  private async signParts(uploadId: string, declarations: readonly PartDeclaration[], auth: UploadAuth): Promise<Map<number, Record<string, unknown>>> {
219
+ // HypiHub accepts at most 128 part declarations per signing request.
220
+ if (declarations.length > 128) {
221
+ const signed = new Map<number, Record<string, unknown>>();
222
+ for (let offset = 0; offset < declarations.length; offset += 128) {
223
+ for (const [number, part] of await this.signParts(uploadId, declarations.slice(offset, offset + 128), auth)) {
224
+ signed.set(number, part);
225
+ }
226
+ }
227
+ return signed;
228
+ }
217
229
  const startedAt = Date.now();
218
230
  this.log(`part signing started upload=${uploadId} parts=${declarations.length}`);
219
231
  const response = await this.json(`/files/uploads/${encodeURIComponent(uploadId)}/parts`, auth, {
@@ -396,9 +408,30 @@ export class HypiHubUploader {
396
408
  this.log(`upload session request failed elapsed=${this.elapsed(policyStartedAt)} reason=${this.safeReason(error)}`);
397
409
  throw error;
398
410
  }
399
- assert(policy.upload_mode === "s3_multipart", "HypiHub returned an unknown upload mode");
400
- const result = await this.uploadDirect(input.bytes, auth, policy);
411
+ assert(policy.upload_mode === "s3_multipart" || policy.upload_mode === "api_multipart",
412
+ "HypiHub returned an unknown upload mode");
413
+ const result = policy.upload_mode === "api_multipart"
414
+ ? await this.uploadApi(input, auth, policy)
415
+ : await this.uploadDirect(input.bytes, auth, policy);
401
416
  this.log(`upload finished bytes=${input.bytes.byteLength} mime=${input.mediaType} elapsed=${this.elapsed(startedAt)}`);
402
417
  return result;
403
418
  }
419
+
420
+ private async uploadApi(input: HypiHubUploadInput, auth: UploadAuth, policy: Record<string, unknown>): Promise<string> {
421
+ const endpoint = new URL(requiredString(policy.endpoint, "HypiHub file upload endpoint"), this.baseUrl);
422
+ assert(endpoint.href === `${this.baseUrl}/files`, "HypiHub file upload endpoint must belong to the selected service");
423
+ if (policy.max_bytes !== undefined) {
424
+ assert(input.bytes.byteLength <= requiredInteger(policy.max_bytes, "HypiHub file upload byte limit"),
425
+ "HypiHub reference exceeds the negotiated file upload byte limit");
426
+ }
427
+ const form = new FormData();
428
+ form.set("file", new Blob([new Uint8Array(input.bytes)], { type: input.mediaType }),
429
+ input.filename ?? `reference.${extension(input.mediaType)}`);
430
+ form.set("purpose", input.purpose ?? "reference");
431
+ if (input.isPersonReference !== undefined) form.set("is_person_reference", String(input.isPersonReference));
432
+ const response = await this.json("/files", auth, { method: "POST", body: form });
433
+ const url = requiredString(response.url, "HypiHub file upload URL");
434
+ assertHTTPS(url, "HypiHub file upload URL");
435
+ return url;
436
+ }
404
437
  }
@@ -122,6 +122,12 @@ for a submission that never became active and therefore has no Result to save.
122
122
  Source imports select author packages. Runtime Profile entries select only code allowed to access files,
123
123
  credentials, processes or networks. Installing a package changes neither selection.
124
124
 
125
+ Endpoint scoping happens before activation when explicit instance IDs are supplied, or when every
126
+ requested capability has a binding. Otherwise discovery loads the Profile's Endpoint packages to
127
+ find eligible implementations. Thus unused service readiness is not required, but an uninstalled
128
+ declared package can still prevent unbound discovery. `scopedProfile` owns this distinction; package
129
+ names are not used to guess which capabilities they supply.
130
+
125
131
  The lifecycle commands have deliberately narrow meanings:
126
132
 
127
133
  - `hypit runtime init` writes and selects the Distribution's starter Profile; it performs no setup or
@@ -224,3 +230,14 @@ Managed Programs have independent lifetimes. A healthy WhisperX service keeps it
224
230
  Distribution changes and shell environment changes still concern the coordinator's bootstrap process.
225
231
  Inspect active work before restarting it. Environment-backed credentials use that inherited process
226
232
  environment; external writable Credential Stores resolve through their own implementation.
233
+
234
+ ### Concurrency checks
235
+
236
+ `pnpm test` exercises 24 Builds with an eight-task remote pool and with all 24 submissions pending
237
+ at once. Both cases verify local progress, per-Build module isolation, one submission per Build,
238
+ capacity release and every completed Result. They use the production execution process and SQLite.
239
+
240
+ `pnpm test:runtime-scale` runs the same checks with 1000 simultaneous remote submissions, on its own.
241
+ This is a load experiment rather than part of every package regression. It reports fixture preparation,
242
+ local progress, completion, executor RSS and cleanup separately; total test time also includes creating
243
+ and removing the temporary Result repositories. Neither suite uses a completion-time performance target.
@@ -64,7 +64,7 @@ CaptionDocument contracts.
64
64
  - **Role Cue**: a speaker turn, written as a bare tag such as `<ALICE>` inside a Segment. The next
65
65
  Role Cue or the Segment close ends that turn.
66
66
  - **Dual Text**: one authored speech span with separate display and spoken projections, written
67
- `<display text | spoken text>`.
67
+ `<display text | spoken text>`. In `<display text|>`, omitted speech inherits the displayed prose.
68
68
  - **Selection marker**: a named semantic range, written `@name ... @/name`.
69
69
  - **Moment marker**: a named semantic point, written `@name!`.
70
70
  - **CaptionDocument**: the Script-owned caption truth; it contains **Display Words**,
@@ -73,11 +73,23 @@ CaptionDocument contracts.
73
73
  `really{emphasis,importance=2,tone=warm}`. Values may be strings, finite numbers or booleans. It
74
74
  becomes `CaptionDisplayWord.attributes`; it is not a Selection and does not carry timing.
75
75
 
76
- Within Dual Text, an unescaped `@` is legal only on the spoken side. The display side is literal; write
77
- `\@` if an at-sign must be shown. An empty display side, such as `< | spoken words>`, keeps the speech
76
+ Within Dual Text, an unescaped `@` belongs to the source of spoken text: the right side when supplied,
77
+ or the shared left side in `<display text|>`. Write `\@` if an at-sign must be shown. An empty display side, such as `< | spoken words>`, keeps the speech
78
78
  tokens and omits them from Caption. `||` is an authored Caption Cue Break and must occur between
79
79
  complete Alignment Units.
80
80
 
81
+ `<组件化|>` is shorthand for `<组件化|组件化>`, using the same exported Caption Alignment Unit.
82
+ It groups the displayed expression without merging its individual speech Tokens or time anchors.
83
+ For example, `把<动效|><组件化|>。|| 之后<直接复用|>。` authors groups inside two Cues.
84
+ Use groups where the expression should be treated together; ordinary prose needs no extra markup.
85
+ Caption Styles choose whether to highlight, reveal or keep the text steady.
86
+
87
+ In a shared side, markers and display attributes do not enter either text projection. Its speech
88
+ Tokens retain offsets into the actually written left-hand text, so Studio can move an anchor inside
89
+ `<组@beat!件化|>` without expanding the shorthand. Attributes still annotate the preceding display
90
+ word, not the whole group. Whitespace-only speech is omitted; a group with no spoken text on either
91
+ side is invalid. This adds no new public value type or protocol version.
92
+
81
93
  ## Segments, turns and Cues are different boundaries
82
94
 
83
95
  A Segment names a structural production passage. It can contain several Role turns and be performed
@@ -64,7 +64,8 @@ export const scriptMarkupSurfaces = [
64
64
  "A Script requires at least one Segment, and natural-language text is refused outside a Segment.",
65
65
  "A Segment is opened by its own lower-case name and closed by that exact name, or written self-closing as `<pause/>`; the name is the Segment id, must be unique within the Script, and `script` is reserved. Segments do not nest.",
66
66
  "A Role Cue such as `<HOST>` is a bare tag inside a Segment with no close; its turn runs until the next Cue or the end of the Segment, and a Cue may not follow unowned speech in the same Segment. Role state resets when the Segment closes.",
67
- "Dual Text is written `<display | speech>`: the left side reaches the caption projection and the right side reaches dialogue and speech. The spoken side must not be empty; the displayed side may be, which speaks a word that is never displayed.",
67
+ "Dual Text is written `<display | speech>`: the left side reaches Caption and the right side reaches dialogue and speech. `<display|>` inherits speech from the displayed prose and forms the same complete alignment unit; its word times remain individual. `<|speech>` speaks without displaying. Both sides empty is invalid.",
68
+ "Inside Dual Text, semantic markers belong to the source of spoken text: the explicit right side, or the shared left side when speech is omitted. Display attributes remain visual metadata and never enter spoken text.",
68
69
  "A flat token attribute follows a complete display token as `{name}` or `{name=value}`; multiple attributes use one comma-separated block. Attributes do not nest, do not carry timing, and never split a Dual Alignment Unit.",
69
70
  "Selection and Moment markers are zero-width, share one name namespace, and may not split a speech token:",
70
71
  [
@@ -499,16 +499,22 @@ export function parseScript(
499
499
  const consumeSpeechSide = (
500
500
  raw: string,
501
501
  absoluteStart: number,
502
- caption: string,
502
+ caption: string | undefined,
503
503
  marks: ParsedCaptionRegion["marks"] = [],
504
504
  ): void => {
505
505
  const startToken = tokens.length;
506
+ // An omitted speech side shares the written display source. Keep its original offsets:
507
+ // marker edits target these words, not a synthetic copy beyond the pipe.
508
+ const shared = caption === undefined;
509
+ const spokenParts: string[] = [];
510
+ const sharedMarks: Array<ParsedCaptionRegion["marks"][number]> = [];
506
511
  let partStart = 0;
507
512
  let index = 0;
508
513
  let emittedCaption = false;
509
514
  const addLiteral = (part: string, start: number): void => {
510
515
  for (const piece of literalPieces(part, start, true)) {
511
- addText(piece.value, emittedCaption ? "" : caption, piece.start, piece.end, false, piece.positions);
516
+ spokenParts.push(piece.value);
517
+ addText(piece.value, shared ? piece.value : emittedCaption ? "" : caption!, piece.start, piece.end, false, piece.positions);
512
518
  emittedCaption = true;
513
519
  }
514
520
  };
@@ -520,6 +526,29 @@ export function parseScript(
520
526
  if (raw.startsWith("||", index)) {
521
527
  fail("SCRIPT_CAPTION_BREAK_DUAL", "Caption Cue break cannot occur inside Dual Text; split the Dual Text into separate units.", absoluteStart + index);
522
528
  }
529
+ if (shared && raw[index] === "{") {
530
+ const before = raw.slice(partStart, index);
531
+ if (!before || /\s$/u.test(before)) {
532
+ fail("SCRIPT_ATTRIBUTE_TARGET", "A token attribute must immediately follow a display token.", absoluteStart + index);
533
+ }
534
+ addLiteral(before, absoluteStart + partStart);
535
+ const block = parseAttributeBlock(raw.slice(index), absoluteStart + index);
536
+ const displayIndex = displayWordSurfaces(spokenParts.join("")).length - 1;
537
+ if (displayIndex < 0 || tokens.length === startToken) {
538
+ fail("SCRIPT_ATTRIBUTE_TARGET", "A token attribute must follow a visible display token.", absoluteStart + index);
539
+ }
540
+ if (sharedMarks.some(mark => mark.displayIndex === displayIndex)) {
541
+ fail("SCRIPT_ATTRIBUTE_OVERLAP", "A display token cannot receive two separate attribute blocks.", absoluteStart + index);
542
+ }
543
+ sharedMarks.push({ displayIndex, attributes: block.attributes });
544
+ const token = tokens.at(-1)!;
545
+ tokens[tokens.length - 1] = { ...token, editRange: {
546
+ start: token.editRange.start, end: sourceOffset + absoluteStart + index + block.length,
547
+ } };
548
+ index += block.length;
549
+ partStart = index;
550
+ continue;
551
+ }
523
552
  const marker = parseMarker(raw, index);
524
553
  if (!marker) {
525
554
  if (raw[index] === "@") fail("SCRIPT_MARKER", "Unescaped @ must begin a valid marker.", absoluteStart + index);
@@ -532,15 +561,19 @@ export function parseScript(
532
561
  partStart = index;
533
562
  }
534
563
  addLiteral(raw.slice(partStart), absoluteStart + partStart);
564
+ const display = caption ?? spokenParts.join("");
565
+ if (shared && tokens.length === startToken) {
566
+ fail("SCRIPT_DUAL_EMPTY", "Dual Text with omitted speech must contain spoken text on its display side.", absoluteStart);
567
+ }
535
568
  if (tokens.length > startToken) {
536
569
  addCaptionRegion(
537
- caption,
570
+ display,
538
571
  current!.id,
539
572
  startToken,
540
573
  tokens.length,
541
- cleanProjection(caption) ? "alias" : "hidden",
574
+ cleanProjection(display) ? "alias" : "hidden",
542
575
  { start: sourceOffset + absoluteStart, end: sourceOffset + absoluteStart + raw.length },
543
- marks,
576
+ shared ? sharedMarks : marks,
544
577
  );
545
578
  }
546
579
  };
@@ -636,10 +669,16 @@ export function parseScript(
636
669
  const pipe = findUnescaped(inside, "|");
637
670
  if (pipe >= 0) {
638
671
  finishLexicalRun();
672
+ const speech = inside.slice(pipe + 1);
673
+ if (!speech.trim()) {
674
+ consumeSpeechSide(inside.slice(0, pipe), offset + 1, undefined);
675
+ finishLexicalRun();
676
+ offset = end + 1;
677
+ continue;
678
+ }
639
679
  assertDualDisplayLiteral(inside.slice(0, pipe), offset + 1);
640
680
  const markedDisplay = parseMarkedDisplay(inside.slice(0, pipe), offset + 1);
641
681
  const display = markedDisplay.display;
642
- const speech = inside.slice(pipe + 1);
643
682
  if (!speech.replace(/~?@\/?[A-Za-z_][A-Za-z0-9_.-]*!?~?/gu, "").trim()) {
644
683
  fail("SCRIPT_DUAL_EMPTY", "Dual Text speech side must not be empty.", offset);
645
684
  }